@ug666/ui-react 0.1.0 → 0.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aliases.d.ts +59 -0
- package/dist/aliases.d.ts.map +1 -0
- package/dist/blocks/feature-grid.d.ts +40 -0
- package/dist/blocks/feature-grid.d.ts.map +1 -0
- package/dist/blocks/index.cjs +467 -0
- package/dist/blocks/index.cjs.map +1 -0
- package/dist/blocks/index.d.ts +8 -0
- package/dist/blocks/index.d.ts.map +1 -0
- package/dist/blocks/index.js +194 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/blocks/landing-hero.d.ts +55 -0
- package/dist/blocks/landing-hero.d.ts.map +1 -0
- package/dist/chunk-AKWJMDCW.js +467 -0
- package/dist/chunk-AKWJMDCW.js.map +1 -0
- package/dist/chunk-F23X4N6B.js +11 -0
- package/dist/chunk-F23X4N6B.js.map +1 -0
- package/dist/chunk-HGO3GZ56.js +1777 -0
- package/dist/chunk-HGO3GZ56.js.map +1 -0
- package/dist/chunk-HXIWD5LQ.js +319 -0
- package/dist/chunk-HXIWD5LQ.js.map +1 -0
- package/dist/chunk-M6J4PLF4.js +521 -0
- package/dist/chunk-M6J4PLF4.js.map +1 -0
- package/dist/chunk-N3Z7R6GG.js +139 -0
- package/dist/chunk-N3Z7R6GG.js.map +1 -0
- package/dist/chunk-UXWCK6M7.js +5757 -0
- package/dist/chunk-UXWCK6M7.js.map +1 -0
- package/dist/components/accordion.d.ts +59 -0
- package/dist/components/accordion.d.ts.map +1 -0
- package/dist/components/alert.d.ts +23 -0
- package/dist/components/alert.d.ts.map +1 -0
- package/dist/components/avatar-group.d.ts +20 -0
- package/dist/components/avatar-group.d.ts.map +1 -0
- package/dist/components/avatar.d.ts +34 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/badge.d.ts +17 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/breadcrumb.d.ts +33 -0
- package/dist/components/breadcrumb.d.ts.map +1 -0
- package/dist/components/button-group.d.ts +26 -0
- package/dist/components/button-group.d.ts.map +1 -0
- package/dist/components/button.d.ts +43 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/card.d.ts +26 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/checkbox-group-context.d.ts +14 -0
- package/dist/components/checkbox-group-context.d.ts.map +1 -0
- package/dist/components/checkbox-group.d.ts +18 -0
- package/dist/components/checkbox-group.d.ts.map +1 -0
- package/dist/components/checkbox.d.ts +32 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/config-provider.d.ts +29 -0
- package/dist/components/config-provider.d.ts.map +1 -0
- package/dist/components/container.d.ts +27 -0
- package/dist/components/container.d.ts.map +1 -0
- package/dist/components/context/form-context.d.ts +41 -0
- package/dist/components/context/form-context.d.ts.map +1 -0
- package/dist/components/context-menu.d.ts +39 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/descriptions.d.ts +40 -0
- package/dist/components/descriptions.d.ts.map +1 -0
- package/dist/components/dialog.d.ts +55 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/drawer.d.ts +38 -0
- package/dist/components/drawer.d.ts.map +1 -0
- package/dist/components/dropdown.d.ts +42 -0
- package/dist/components/dropdown.d.ts.map +1 -0
- package/dist/components/empty-state.d.ts +24 -0
- package/dist/components/empty-state.d.ts.map +1 -0
- package/dist/components/form.d.ts +127 -0
- package/dist/components/form.d.ts.map +1 -0
- package/dist/components/icon.d.ts +16 -0
- package/dist/components/icon.d.ts.map +1 -0
- package/dist/components/index.cjs +8684 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.ts +60 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +391 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/input.d.ts +28 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/label.d.ts +18 -0
- package/dist/components/label.d.ts.map +1 -0
- package/dist/components/layout.d.ts +34 -0
- package/dist/components/layout.d.ts.map +1 -0
- package/dist/components/link.d.ts +18 -0
- package/dist/components/link.d.ts.map +1 -0
- package/dist/components/modal.d.ts +46 -0
- package/dist/components/modal.d.ts.map +1 -0
- package/dist/components/navigation-menu.d.ts +39 -0
- package/dist/components/navigation-menu.d.ts.map +1 -0
- package/dist/components/number-input.d.ts +35 -0
- package/dist/components/number-input.d.ts.map +1 -0
- package/dist/components/otp-input.d.ts +35 -0
- package/dist/components/otp-input.d.ts.map +1 -0
- package/dist/components/pagination.d.ts +16 -0
- package/dist/components/pagination.d.ts.map +1 -0
- package/dist/components/popover.d.ts +36 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/progress.d.ts +21 -0
- package/dist/components/progress.d.ts.map +1 -0
- package/dist/components/radio.d.ts +68 -0
- package/dist/components/radio.d.ts.map +1 -0
- package/dist/components/scrollbar.d.ts +29 -0
- package/dist/components/scrollbar.d.ts.map +1 -0
- package/dist/components/select.d.ts +48 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/separator.d.ts +28 -0
- package/dist/components/separator.d.ts.map +1 -0
- package/dist/components/sheet.d.ts +24 -0
- package/dist/components/sheet.d.ts.map +1 -0
- package/dist/components/sidebar.d.ts +48 -0
- package/dist/components/sidebar.d.ts.map +1 -0
- package/dist/components/skeleton.d.ts +16 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/slider.d.ts +44 -0
- package/dist/components/slider.d.ts.map +1 -0
- package/dist/components/space.d.ts +19 -0
- package/dist/components/space.d.ts.map +1 -0
- package/dist/components/spinner.d.ts +18 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/splitter.d.ts +51 -0
- package/dist/components/splitter.d.ts.map +1 -0
- package/dist/components/statistic.d.ts +30 -0
- package/dist/components/statistic.d.ts.map +1 -0
- package/dist/components/steps.d.ts +33 -0
- package/dist/components/steps.d.ts.map +1 -0
- package/dist/components/switch.d.ts +49 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/table.d.ts +32 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/tabs.d.ts +27 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tag.d.ts +27 -0
- package/dist/components/tag.d.ts.map +1 -0
- package/dist/components/text.d.ts +16 -0
- package/dist/components/text.d.ts.map +1 -0
- package/dist/components/textarea.d.ts +26 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/toast.d.ts +26 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/tooltip.d.ts +29 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/hooks/index.cjs +229 -27
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +19 -231
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/use-click-outside.d.ts +9 -0
- package/dist/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +12 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -0
- package/dist/hooks/use-debounce.d.ts +7 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-escape-key.d.ts +10 -0
- package/dist/hooks/use-escape-key.d.ts.map +1 -0
- package/dist/hooks/use-event-listener.d.ts +28 -0
- package/dist/hooks/use-event-listener.d.ts.map +1 -0
- package/dist/hooks/use-form.d.ts +48 -0
- package/dist/hooks/use-form.d.ts.map +1 -0
- package/dist/hooks/use-hotkeys.d.ts +30 -0
- package/dist/hooks/use-hotkeys.d.ts.map +1 -0
- package/dist/hooks/use-interval.d.ts +19 -0
- package/dist/hooks/use-interval.d.ts.map +1 -0
- package/dist/hooks/use-local-storage.d.ts +9 -0
- package/dist/hooks/use-local-storage.d.ts.map +1 -0
- package/dist/hooks/use-media-query.d.ts +8 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-mounted.d.ts +18 -0
- package/dist/hooks/use-mounted.d.ts.map +1 -0
- package/dist/hooks/use-pagination.d.ts +36 -0
- package/dist/hooks/use-pagination.d.ts.map +1 -0
- package/dist/hooks/use-timeout.d.ts +19 -0
- package/dist/hooks/use-timeout.d.ts.map +1 -0
- package/dist/hooks/use-toggle.d.ts +9 -0
- package/dist/hooks/use-toggle.d.ts.map +1 -0
- package/dist/index.cjs +7017 -1610
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +74 -1361
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +281 -3245
- package/dist/index.js.map +1 -1
- package/dist/internal/button-group-context.d.ts +11 -0
- package/dist/internal/button-group-context.d.ts.map +1 -0
- package/dist/internal/cn.d.ts +8 -0
- package/dist/internal/cn.d.ts.map +1 -0
- package/dist/internal/use-overlay-focus.d.ts +8 -0
- package/dist/internal/use-overlay-focus.d.ts.map +1 -0
- package/dist/internal/use-portal-container.d.ts +2 -0
- package/dist/internal/use-portal-container.d.ts.map +1 -0
- package/dist/labs/file-preview.d.ts +44 -0
- package/dist/labs/file-preview.d.ts.map +1 -0
- package/dist/labs/index.cjs +224 -0
- package/dist/labs/index.cjs.map +1 -0
- package/dist/labs/index.d.ts +14 -0
- package/dist/labs/index.d.ts.map +1 -0
- package/dist/labs/index.js +188 -0
- package/dist/labs/index.js.map +1 -0
- package/dist/labs/model-card.d.ts +50 -0
- package/dist/labs/model-card.d.ts.map +1 -0
- package/dist/patterns/admin-shell.d.ts +52 -0
- package/dist/patterns/admin-shell.d.ts.map +1 -0
- package/dist/patterns/confirm-dialog.d.ts +50 -0
- package/dist/patterns/confirm-dialog.d.ts.map +1 -0
- package/dist/patterns/copy-field.d.ts +29 -0
- package/dist/patterns/copy-field.d.ts.map +1 -0
- package/dist/patterns/index.cjs +1206 -0
- package/dist/patterns/index.cjs.map +1 -0
- package/dist/patterns/index.d.ts +5 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +375 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/page-header.d.ts +37 -0
- package/dist/patterns/page-header.d.ts.map +1 -0
- package/dist/primitives/index.cjs +2161 -0
- package/dist/primitives/index.cjs.map +1 -0
- package/dist/primitives/index.d.ts +24 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +107 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/styles.css +4365 -0
- package/dist/theme.cjs +161 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.ts +39 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +19 -0
- package/dist/theme.js.map +1 -0
- package/dist/themes/default.css +80 -0
- package/dist/themes/mecha.css +195 -0
- package/dist/themes/minimal.css +160 -0
- package/dist/tokens.css +1241 -9
- package/package.json +54 -14
- package/dist/chunk-MGXIF756.js +0 -313
- package/dist/chunk-MGXIF756.js.map +0 -1
- package/dist/hooks/index.d.cts +0 -232
- package/dist/index.d.cts +0 -1363
|
@@ -0,0 +1,1777 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonGroupProvider,
|
|
3
|
+
resolveControlSize,
|
|
4
|
+
resolveDisabled,
|
|
5
|
+
useUIConfig
|
|
6
|
+
} from "./chunk-HXIWD5LQ.js";
|
|
7
|
+
import {
|
|
8
|
+
cn
|
|
9
|
+
} from "./chunk-F23X4N6B.js";
|
|
10
|
+
|
|
11
|
+
// src/components/button-group.tsx
|
|
12
|
+
import { forwardRef } from "react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
var attachedClasses = {
|
|
15
|
+
horizontal: "[&>[data-ug=button]]:[border-radius:0] [&>[data-ug=button]:first-child]:[border-radius:var(--radius-control)_0_0_var(--radius-control)] [&>[data-ug=button]:last-child]:[border-radius:0_var(--radius-control)_var(--radius-control)_0] [&>[data-ug=button]+[data-ug=button]]:-ml-px",
|
|
16
|
+
vertical: "[&>[data-ug=button]]:[border-radius:0] [&>[data-ug=button]:first-child]:[border-radius:var(--radius-control)_var(--radius-control)_0_0] [&>[data-ug=button]:last-child]:[border-radius:0_0_var(--radius-control)_var(--radius-control)] [&>[data-ug=button]+[data-ug=button]]:-mt-px"
|
|
17
|
+
};
|
|
18
|
+
var CONFIG_SIZE_TO_BUTTON_SIZE = {
|
|
19
|
+
small: "sm",
|
|
20
|
+
medium: "default",
|
|
21
|
+
large: "lg"
|
|
22
|
+
};
|
|
23
|
+
var ButtonGroup = forwardRef(
|
|
24
|
+
({
|
|
25
|
+
className,
|
|
26
|
+
variant,
|
|
27
|
+
tone,
|
|
28
|
+
size,
|
|
29
|
+
shape,
|
|
30
|
+
disabled,
|
|
31
|
+
orientation = "horizontal",
|
|
32
|
+
attached = false,
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
}, ref) => {
|
|
36
|
+
const config = useUIConfig();
|
|
37
|
+
const resolvedSize = size ?? CONFIG_SIZE_TO_BUTTON_SIZE[config.size];
|
|
38
|
+
const resolvedDisabled = resolveDisabled(disabled, config.disabled);
|
|
39
|
+
return /* @__PURE__ */ jsx(ButtonGroupProvider, { value: {
|
|
40
|
+
variant,
|
|
41
|
+
tone,
|
|
42
|
+
size: resolvedSize,
|
|
43
|
+
shape,
|
|
44
|
+
disabled: resolvedDisabled
|
|
45
|
+
}, children: /* @__PURE__ */ jsx(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
ref,
|
|
49
|
+
role: "group",
|
|
50
|
+
...props,
|
|
51
|
+
className: cn(
|
|
52
|
+
"inline-flex",
|
|
53
|
+
orientation === "horizontal" ? "flex-row items-center" : "flex-col items-stretch",
|
|
54
|
+
attached ? attachedClasses[orientation] : "gap-2",
|
|
55
|
+
className
|
|
56
|
+
),
|
|
57
|
+
"aria-disabled": resolvedDisabled || void 0,
|
|
58
|
+
"aria-orientation": orientation,
|
|
59
|
+
"data-ug": "button-group",
|
|
60
|
+
"data-ug-slot": "root",
|
|
61
|
+
"data-state": resolvedDisabled ? "disabled" : "default",
|
|
62
|
+
"data-variant": variant,
|
|
63
|
+
"data-tone": tone,
|
|
64
|
+
"data-size": resolvedSize,
|
|
65
|
+
"data-shape": shape,
|
|
66
|
+
"data-orientation": orientation,
|
|
67
|
+
"data-attached": attached ? "true" : "false",
|
|
68
|
+
"data-ug-namespace": config.namespace,
|
|
69
|
+
children
|
|
70
|
+
}
|
|
71
|
+
) });
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
75
|
+
|
|
76
|
+
// src/components/input.tsx
|
|
77
|
+
import {
|
|
78
|
+
forwardRef as forwardRef2,
|
|
79
|
+
useEffect,
|
|
80
|
+
useId,
|
|
81
|
+
useRef,
|
|
82
|
+
useState
|
|
83
|
+
} from "react";
|
|
84
|
+
import { Eye, EyeOff, X } from "lucide-react";
|
|
85
|
+
import {
|
|
86
|
+
countTextCharacters,
|
|
87
|
+
limitTextByCount
|
|
88
|
+
} from "@ug666/ui-core";
|
|
89
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
90
|
+
var inputSizeClasses = {
|
|
91
|
+
sm: "h-[var(--control-height-sm)] text-xs",
|
|
92
|
+
default: "h-[var(--control-height-md)] text-sm",
|
|
93
|
+
lg: "h-[var(--control-height-lg)] text-base"
|
|
94
|
+
};
|
|
95
|
+
var inputPaddingClasses = {
|
|
96
|
+
sm: "px-[var(--control-padding-x-sm)]",
|
|
97
|
+
default: "px-[var(--control-padding-x-md)]",
|
|
98
|
+
lg: "px-[var(--control-padding-x-lg)]"
|
|
99
|
+
};
|
|
100
|
+
function assignRef(ref, value) {
|
|
101
|
+
if (typeof ref === "function") ref(value);
|
|
102
|
+
else if (ref) ref.current = value;
|
|
103
|
+
}
|
|
104
|
+
function normalizeValue(value) {
|
|
105
|
+
if (value === void 0 || value === null) return "";
|
|
106
|
+
return Array.isArray(value) ? value.join(",") : String(value);
|
|
107
|
+
}
|
|
108
|
+
function getInputState(disabled, invalid, readonly, focused) {
|
|
109
|
+
return [
|
|
110
|
+
disabled && "disabled",
|
|
111
|
+
invalid && "invalid",
|
|
112
|
+
readonly && "readonly",
|
|
113
|
+
focused && "focused"
|
|
114
|
+
].filter(Boolean).join(" ") || "default";
|
|
115
|
+
}
|
|
116
|
+
var Input = forwardRef2(
|
|
117
|
+
({
|
|
118
|
+
append,
|
|
119
|
+
className,
|
|
120
|
+
clearable = false,
|
|
121
|
+
clearIcon,
|
|
122
|
+
countCharacters,
|
|
123
|
+
defaultValue,
|
|
124
|
+
disabled,
|
|
125
|
+
error,
|
|
126
|
+
formatter,
|
|
127
|
+
helperText,
|
|
128
|
+
id,
|
|
129
|
+
label,
|
|
130
|
+
maxLength,
|
|
131
|
+
onBlur,
|
|
132
|
+
onChange,
|
|
133
|
+
onClear,
|
|
134
|
+
onCompositionEnd,
|
|
135
|
+
onCompositionStart,
|
|
136
|
+
onFocus,
|
|
137
|
+
onValueChange,
|
|
138
|
+
parser,
|
|
139
|
+
passwordHiddenIcon,
|
|
140
|
+
passwordVisibleIcon,
|
|
141
|
+
prefix,
|
|
142
|
+
prepend,
|
|
143
|
+
readOnly = false,
|
|
144
|
+
showPassword = false,
|
|
145
|
+
showWordLimit = false,
|
|
146
|
+
size,
|
|
147
|
+
suffix,
|
|
148
|
+
type = "text",
|
|
149
|
+
value,
|
|
150
|
+
wordLimitPosition = "inside",
|
|
151
|
+
"aria-describedby": describedBy,
|
|
152
|
+
"aria-invalid": invalid,
|
|
153
|
+
form,
|
|
154
|
+
name,
|
|
155
|
+
...props
|
|
156
|
+
}, forwardedRef) => {
|
|
157
|
+
const config = useUIConfig();
|
|
158
|
+
const generatedId = useId();
|
|
159
|
+
const inputId = id ?? generatedId;
|
|
160
|
+
const messageId = `${inputId}-message`;
|
|
161
|
+
const [focused, setFocused] = useState(false);
|
|
162
|
+
const [composing, setComposing] = useState(false);
|
|
163
|
+
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
164
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(() => normalizeValue(defaultValue));
|
|
165
|
+
const inputRef = useRef(null);
|
|
166
|
+
const resolvedDisabled = resolveDisabled(disabled, config.disabled);
|
|
167
|
+
const resolvedSize = resolveControlSize(size, config.size);
|
|
168
|
+
const rawValue = value === void 0 ? uncontrolledValue : normalizeValue(value);
|
|
169
|
+
const displayValue = formatter && !composing && rawValue !== "" ? formatter(rawValue) : rawValue;
|
|
170
|
+
const hasValue = rawValue.length > 0;
|
|
171
|
+
const canClear = clearable && hasValue && !resolvedDisabled && !readOnly;
|
|
172
|
+
const canTogglePassword = showPassword && type === "password" && !resolvedDisabled;
|
|
173
|
+
const resolvedType = showPassword && type === "password" && passwordVisible ? "text" : type;
|
|
174
|
+
const hasMessage = Boolean(error || helperText || showWordLimit && maxLength);
|
|
175
|
+
const state = getInputState(resolvedDisabled, Boolean(error), readOnly, focused);
|
|
176
|
+
const characterCount = countTextCharacters(rawValue, countCharacters);
|
|
177
|
+
const hasInsideCount = Boolean(
|
|
178
|
+
showWordLimit && maxLength && wordLimitPosition === "inside"
|
|
179
|
+
);
|
|
180
|
+
const usesCanonicalSubmitValue = Boolean(formatter && name);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
const form2 = inputRef.current?.form;
|
|
183
|
+
if (!form2) return;
|
|
184
|
+
function handleReset() {
|
|
185
|
+
setUncontrolledValue(normalizeValue(defaultValue));
|
|
186
|
+
setPasswordVisible(false);
|
|
187
|
+
}
|
|
188
|
+
form2.addEventListener("reset", handleReset);
|
|
189
|
+
return () => form2.removeEventListener("reset", handleReset);
|
|
190
|
+
}, [defaultValue]);
|
|
191
|
+
function setInputRef(node) {
|
|
192
|
+
inputRef.current = node;
|
|
193
|
+
assignRef(forwardedRef, node);
|
|
194
|
+
}
|
|
195
|
+
function handleChange(event) {
|
|
196
|
+
const inputValue = event.currentTarget.value;
|
|
197
|
+
const isComposing = composing || event.nativeEvent.isComposing;
|
|
198
|
+
const parsedValue = isComposing || !parser ? inputValue : parser(inputValue);
|
|
199
|
+
const nextValue = isComposing ? parsedValue : limitTextByCount(parsedValue, maxLength, countCharacters);
|
|
200
|
+
if (nextValue !== event.currentTarget.value) event.currentTarget.value = nextValue;
|
|
201
|
+
setUncontrolledValue(nextValue);
|
|
202
|
+
onValueChange?.(nextValue);
|
|
203
|
+
onChange?.(event);
|
|
204
|
+
}
|
|
205
|
+
function handleCompositionStart(event) {
|
|
206
|
+
setComposing(true);
|
|
207
|
+
onCompositionStart?.(event);
|
|
208
|
+
}
|
|
209
|
+
function handleCompositionEnd(event) {
|
|
210
|
+
setComposing(false);
|
|
211
|
+
const parsedValue = parser ? parser(event.currentTarget.value) : event.currentTarget.value;
|
|
212
|
+
const nextValue = limitTextByCount(parsedValue, maxLength, countCharacters);
|
|
213
|
+
if (nextValue !== event.currentTarget.value) event.currentTarget.value = nextValue;
|
|
214
|
+
setUncontrolledValue(nextValue);
|
|
215
|
+
onValueChange?.(nextValue);
|
|
216
|
+
onCompositionEnd?.(event);
|
|
217
|
+
}
|
|
218
|
+
function handleFocus(event) {
|
|
219
|
+
setFocused(true);
|
|
220
|
+
onFocus?.(event);
|
|
221
|
+
}
|
|
222
|
+
function handleBlur(event) {
|
|
223
|
+
setFocused(false);
|
|
224
|
+
onBlur?.(event);
|
|
225
|
+
}
|
|
226
|
+
function handleClear() {
|
|
227
|
+
setUncontrolledValue("");
|
|
228
|
+
onValueChange?.("");
|
|
229
|
+
onClear?.();
|
|
230
|
+
inputRef.current?.focus();
|
|
231
|
+
}
|
|
232
|
+
return /* @__PURE__ */ jsxs(
|
|
233
|
+
"div",
|
|
234
|
+
{
|
|
235
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
236
|
+
"data-size": resolvedSize,
|
|
237
|
+
"data-state": state,
|
|
238
|
+
"data-ug": "input",
|
|
239
|
+
"data-ug-slot": "root",
|
|
240
|
+
"data-variant": "default",
|
|
241
|
+
children: [
|
|
242
|
+
label ? /* @__PURE__ */ jsx2(
|
|
243
|
+
"label",
|
|
244
|
+
{
|
|
245
|
+
className: "text-sm font-medium text-text-primary",
|
|
246
|
+
"data-ug-slot": "label",
|
|
247
|
+
htmlFor: inputId,
|
|
248
|
+
children: label
|
|
249
|
+
}
|
|
250
|
+
) : null,
|
|
251
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full min-w-0", "data-ug-slot": "group", children: [
|
|
252
|
+
prepend ? /* @__PURE__ */ jsx2(
|
|
253
|
+
"span",
|
|
254
|
+
{
|
|
255
|
+
className: cn(
|
|
256
|
+
"inline-flex shrink-0 items-center border border-r-0 border-border-strong bg-surface-2 text-text-secondary [border-end-start-radius:var(--radius-control)] [border-start-start-radius:var(--radius-control)]",
|
|
257
|
+
inputSizeClasses[resolvedSize],
|
|
258
|
+
inputPaddingClasses[resolvedSize]
|
|
259
|
+
),
|
|
260
|
+
"data-ug-slot": "prepend",
|
|
261
|
+
children: prepend
|
|
262
|
+
}
|
|
263
|
+
) : null,
|
|
264
|
+
/* @__PURE__ */ jsxs(
|
|
265
|
+
"div",
|
|
266
|
+
{
|
|
267
|
+
className: cn(
|
|
268
|
+
"flex min-w-0 flex-1 items-center rounded-[var(--radius-control)] border bg-surface-1",
|
|
269
|
+
inputSizeClasses[resolvedSize],
|
|
270
|
+
"transition-[background,border-color,box-shadow] duration-[var(--motion-duration-base)] ease-[var(--motion-easing-standard)] motion-reduce:transition-none",
|
|
271
|
+
"focus-within:ring-2 focus-within:ring-offset-1",
|
|
272
|
+
error ? "border-danger focus-within:ring-danger/30" : "border-border-strong focus-within:border-primary focus-within:ring-ring/30",
|
|
273
|
+
resolvedDisabled && "cursor-not-allowed opacity-50",
|
|
274
|
+
readOnly && "bg-surface-2",
|
|
275
|
+
prepend && "[border-end-start-radius:0] [border-start-start-radius:0]",
|
|
276
|
+
append && "[border-end-end-radius:0] [border-start-end-radius:0]"
|
|
277
|
+
),
|
|
278
|
+
"data-has-append": append ? "true" : void 0,
|
|
279
|
+
"data-has-prepend": prepend ? "true" : void 0,
|
|
280
|
+
"data-ug-slot": "wrapper",
|
|
281
|
+
children: [
|
|
282
|
+
prefix ? /* @__PURE__ */ jsx2(
|
|
283
|
+
"span",
|
|
284
|
+
{
|
|
285
|
+
"aria-hidden": "true",
|
|
286
|
+
className: cn("inline-flex shrink-0 items-center text-text-secondary", inputPaddingClasses[resolvedSize], "pr-0"),
|
|
287
|
+
"data-ug-slot": "prefix",
|
|
288
|
+
children: prefix
|
|
289
|
+
}
|
|
290
|
+
) : null,
|
|
291
|
+
/* @__PURE__ */ jsx2(
|
|
292
|
+
"input",
|
|
293
|
+
{
|
|
294
|
+
...props,
|
|
295
|
+
ref: setInputRef,
|
|
296
|
+
"aria-describedby": describedBy ?? (hasMessage ? messageId : void 0),
|
|
297
|
+
"aria-invalid": invalid ?? (error ? true : void 0),
|
|
298
|
+
className: cn(
|
|
299
|
+
"h-full min-w-0 flex-1 border-0 bg-transparent py-0 text-text-primary outline-none placeholder:text-text-tertiary",
|
|
300
|
+
inputPaddingClasses[resolvedSize],
|
|
301
|
+
prefix && "pl-2",
|
|
302
|
+
(suffix || canClear || canTogglePassword || hasInsideCount) && "pr-2",
|
|
303
|
+
resolvedDisabled && "cursor-not-allowed",
|
|
304
|
+
className
|
|
305
|
+
),
|
|
306
|
+
"data-ug-slot": "control",
|
|
307
|
+
disabled: resolvedDisabled,
|
|
308
|
+
form,
|
|
309
|
+
id: inputId,
|
|
310
|
+
maxLength: countCharacters ? void 0 : maxLength,
|
|
311
|
+
name: usesCanonicalSubmitValue ? void 0 : name,
|
|
312
|
+
onBlur: handleBlur,
|
|
313
|
+
onChange: handleChange,
|
|
314
|
+
onCompositionEnd: handleCompositionEnd,
|
|
315
|
+
onCompositionStart: handleCompositionStart,
|
|
316
|
+
onFocus: handleFocus,
|
|
317
|
+
readOnly,
|
|
318
|
+
type: resolvedType,
|
|
319
|
+
value: displayValue
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
hasInsideCount ? /* @__PURE__ */ jsxs(
|
|
323
|
+
"span",
|
|
324
|
+
{
|
|
325
|
+
"aria-hidden": "true",
|
|
326
|
+
className: "shrink-0 whitespace-nowrap text-xs tabular-nums text-text-tertiary",
|
|
327
|
+
"data-ug-slot": "count",
|
|
328
|
+
children: [
|
|
329
|
+
characterCount,
|
|
330
|
+
"/",
|
|
331
|
+
maxLength
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
) : null,
|
|
335
|
+
canClear ? /* @__PURE__ */ jsx2(
|
|
336
|
+
"button",
|
|
337
|
+
{
|
|
338
|
+
"aria-label": "\u6E05\u7A7A\u8F93\u5165",
|
|
339
|
+
className: "inline-flex h-full shrink-0 items-center justify-center px-[calc(var(--control-padding-x-sm)*0.5)] text-text-secondary hover:text-text-primary",
|
|
340
|
+
"data-ug-slot": "clear",
|
|
341
|
+
onClick: handleClear,
|
|
342
|
+
tabIndex: -1,
|
|
343
|
+
type: "button",
|
|
344
|
+
children: clearIcon ?? /* @__PURE__ */ jsx2(X, { "aria-hidden": "true", size: 14 })
|
|
345
|
+
}
|
|
346
|
+
) : null,
|
|
347
|
+
canTogglePassword ? /* @__PURE__ */ jsx2(
|
|
348
|
+
"button",
|
|
349
|
+
{
|
|
350
|
+
"aria-label": passwordVisible ? "\u9690\u85CF\u5BC6\u7801" : "\u663E\u793A\u5BC6\u7801",
|
|
351
|
+
"aria-pressed": passwordVisible,
|
|
352
|
+
className: "inline-flex h-full shrink-0 items-center justify-center px-[calc(var(--control-padding-x-sm)*0.5)] text-text-secondary hover:text-text-primary",
|
|
353
|
+
"data-ug-slot": "password-toggle",
|
|
354
|
+
onClick: () => setPasswordVisible((current) => !current),
|
|
355
|
+
tabIndex: -1,
|
|
356
|
+
type: "button",
|
|
357
|
+
children: passwordVisible ? passwordVisibleIcon ?? /* @__PURE__ */ jsx2(EyeOff, { "aria-hidden": "true", size: 15 }) : passwordHiddenIcon ?? /* @__PURE__ */ jsx2(Eye, { "aria-hidden": "true", size: 15 })
|
|
358
|
+
}
|
|
359
|
+
) : null,
|
|
360
|
+
suffix ? /* @__PURE__ */ jsx2(
|
|
361
|
+
"span",
|
|
362
|
+
{
|
|
363
|
+
"aria-hidden": "true",
|
|
364
|
+
className: cn("inline-flex shrink-0 items-center text-text-secondary", inputPaddingClasses[resolvedSize], "pl-0"),
|
|
365
|
+
"data-ug-slot": "suffix",
|
|
366
|
+
children: suffix
|
|
367
|
+
}
|
|
368
|
+
) : null
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
),
|
|
372
|
+
append ? /* @__PURE__ */ jsx2(
|
|
373
|
+
"span",
|
|
374
|
+
{
|
|
375
|
+
className: cn(
|
|
376
|
+
"inline-flex shrink-0 items-center border border-l-0 border-border-strong bg-surface-2 text-text-secondary [border-end-end-radius:var(--radius-control)] [border-start-end-radius:var(--radius-control)]",
|
|
377
|
+
inputSizeClasses[resolvedSize],
|
|
378
|
+
inputPaddingClasses[resolvedSize]
|
|
379
|
+
),
|
|
380
|
+
"data-ug-slot": "append",
|
|
381
|
+
children: append
|
|
382
|
+
}
|
|
383
|
+
) : null
|
|
384
|
+
] }),
|
|
385
|
+
usesCanonicalSubmitValue ? /* @__PURE__ */ jsx2(
|
|
386
|
+
"input",
|
|
387
|
+
{
|
|
388
|
+
disabled: resolvedDisabled,
|
|
389
|
+
form,
|
|
390
|
+
name,
|
|
391
|
+
type: "hidden",
|
|
392
|
+
value: rawValue
|
|
393
|
+
}
|
|
394
|
+
) : null,
|
|
395
|
+
showWordLimit && maxLength && wordLimitPosition === "outside" ? /* @__PURE__ */ jsxs(
|
|
396
|
+
"span",
|
|
397
|
+
{
|
|
398
|
+
"aria-hidden": "true",
|
|
399
|
+
className: "self-end text-xs tabular-nums text-text-tertiary",
|
|
400
|
+
"data-ug-slot": "count",
|
|
401
|
+
children: [
|
|
402
|
+
characterCount,
|
|
403
|
+
"/",
|
|
404
|
+
maxLength
|
|
405
|
+
]
|
|
406
|
+
}
|
|
407
|
+
) : null,
|
|
408
|
+
error ? /* @__PURE__ */ jsx2("p", { id: messageId, className: "text-xs text-danger", "data-ug-slot": "message", children: error }) : null,
|
|
409
|
+
!error && helperText ? /* @__PURE__ */ jsx2("p", { id: messageId, className: "text-xs text-text-secondary", "data-ug-slot": "message", children: helperText }) : null
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
Input.displayName = "Input";
|
|
416
|
+
|
|
417
|
+
// src/components/label.tsx
|
|
418
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
419
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
420
|
+
var labelSizeClasses = {
|
|
421
|
+
sm: "text-xs",
|
|
422
|
+
default: "text-sm",
|
|
423
|
+
lg: "text-base"
|
|
424
|
+
};
|
|
425
|
+
var Label = forwardRef3(({
|
|
426
|
+
className,
|
|
427
|
+
required,
|
|
428
|
+
size,
|
|
429
|
+
disabled,
|
|
430
|
+
children,
|
|
431
|
+
...props
|
|
432
|
+
}, ref) => {
|
|
433
|
+
const config = useUIConfig();
|
|
434
|
+
const resolvedSize = resolveControlSize(size, config.size);
|
|
435
|
+
const resolvedDisabled = resolveDisabled(disabled, config.disabled);
|
|
436
|
+
const state = resolvedDisabled ? "disabled" : required ? "required" : "default";
|
|
437
|
+
return /* @__PURE__ */ jsxs2(
|
|
438
|
+
"label",
|
|
439
|
+
{
|
|
440
|
+
ref,
|
|
441
|
+
className: cn(
|
|
442
|
+
"leading-none font-medium text-text-primary",
|
|
443
|
+
resolvedDisabled && "cursor-not-allowed opacity-60",
|
|
444
|
+
labelSizeClasses[resolvedSize],
|
|
445
|
+
className
|
|
446
|
+
),
|
|
447
|
+
...props,
|
|
448
|
+
"data-ug": "label",
|
|
449
|
+
"data-state": state,
|
|
450
|
+
"data-required": required || void 0,
|
|
451
|
+
"data-variant": "default",
|
|
452
|
+
"data-size": resolvedSize,
|
|
453
|
+
"aria-disabled": resolvedDisabled || void 0,
|
|
454
|
+
children: [
|
|
455
|
+
/* @__PURE__ */ jsx3("span", { "data-ug-slot": "label", children }),
|
|
456
|
+
required && /* @__PURE__ */ jsx3("span", { className: "ml-[calc(var(--content-gap)*0.125)] text-danger", "aria-hidden": "true", "data-ug-slot": "marker", children: "*" })
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
});
|
|
461
|
+
Label.displayName = "Label";
|
|
462
|
+
|
|
463
|
+
// src/components/card.tsx
|
|
464
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
465
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
466
|
+
var Card = forwardRef4(({ className, ...props }, ref) => {
|
|
467
|
+
return /* @__PURE__ */ jsx4("div", { ref, ...props, className: cn("overflow-hidden rounded-[var(--radius-panel)] border border-border-base bg-surface-1 shadow-sm", className), "data-ug": "card", "data-state": "default", "data-variant": "default", "data-size": "md" });
|
|
468
|
+
});
|
|
469
|
+
var CardHeader = forwardRef4(({ className, ...props }, ref) => {
|
|
470
|
+
return /* @__PURE__ */ jsx4("div", { ref, ...props, className: cn("flex flex-col gap-1.5 p-[var(--content-gap)] pb-[calc(var(--content-gap)*0.5)]", className), "data-ug-slot": "header" });
|
|
471
|
+
});
|
|
472
|
+
var CardTitle = forwardRef4(({ className, ...props }, ref) => {
|
|
473
|
+
return /* @__PURE__ */ jsx4("h3", { ref, ...props, className: cn("leading-none font-semibold text-text-primary", className), "data-ug-slot": "title" });
|
|
474
|
+
});
|
|
475
|
+
var CardDescription = forwardRef4(({ className, ...props }, ref) => {
|
|
476
|
+
return /* @__PURE__ */ jsx4("p", { ref, ...props, className: cn("text-sm text-text-secondary", className), "data-ug-slot": "description" });
|
|
477
|
+
});
|
|
478
|
+
var CardContent = forwardRef4(({ className, ...props }, ref) => {
|
|
479
|
+
return /* @__PURE__ */ jsx4("div", { ref, ...props, className: cn("px-[var(--content-gap)] pb-[var(--content-gap)] pt-[calc(var(--content-gap)*0.5)]", className), "data-ug-slot": "content" });
|
|
480
|
+
});
|
|
481
|
+
var CardFooter = forwardRef4(({ className, ...props }, ref) => {
|
|
482
|
+
return /* @__PURE__ */ jsx4("div", { ref, ...props, className: cn("flex items-center gap-2 px-[var(--content-gap)] pb-[var(--content-gap)]", className), "data-ug-slot": "footer" });
|
|
483
|
+
});
|
|
484
|
+
Card.displayName = "Card";
|
|
485
|
+
CardHeader.displayName = "CardHeader";
|
|
486
|
+
CardTitle.displayName = "CardTitle";
|
|
487
|
+
CardDescription.displayName = "CardDescription";
|
|
488
|
+
CardContent.displayName = "CardContent";
|
|
489
|
+
CardFooter.displayName = "CardFooter";
|
|
490
|
+
|
|
491
|
+
// src/components/badge.tsx
|
|
492
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
493
|
+
import { cva } from "class-variance-authority";
|
|
494
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
495
|
+
var badgeVariants = cva(
|
|
496
|
+
"inline-flex min-h-[calc(var(--control-height-sm)*0.75)] items-center rounded-[var(--radius-control)] px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.125)] text-xs font-semibold leading-none transition-colors",
|
|
497
|
+
{
|
|
498
|
+
variants: {
|
|
499
|
+
variant: {
|
|
500
|
+
default: "border border-primary/20 bg-primary-soft text-primary-soft-fg",
|
|
501
|
+
secondary: "border border-border-base bg-surface-2 text-text-primary",
|
|
502
|
+
destructive: "border border-danger/20 bg-danger-soft text-danger-soft-fg",
|
|
503
|
+
outline: "border border-border-strong bg-transparent text-text-primary",
|
|
504
|
+
success: "border border-success/20 bg-success-soft text-success-soft-fg",
|
|
505
|
+
warning: "border border-warning/20 bg-warning-soft text-warning-soft-fg"
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
defaultVariants: {
|
|
509
|
+
variant: "default"
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
var Badge = forwardRef5(({ className, variant, children, ...props }, ref) => {
|
|
514
|
+
const resolvedVariant = variant ?? "default";
|
|
515
|
+
return /* @__PURE__ */ jsx5(
|
|
516
|
+
"span",
|
|
517
|
+
{
|
|
518
|
+
ref,
|
|
519
|
+
className: cn(badgeVariants({ variant }), className),
|
|
520
|
+
...props,
|
|
521
|
+
"data-ug": "badge",
|
|
522
|
+
"data-state": "default",
|
|
523
|
+
"data-variant": resolvedVariant,
|
|
524
|
+
"data-size": "md",
|
|
525
|
+
children: /* @__PURE__ */ jsx5("span", { "data-ug-slot": "label", children })
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
});
|
|
529
|
+
Badge.displayName = "Badge";
|
|
530
|
+
|
|
531
|
+
// src/components/tag.tsx
|
|
532
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
533
|
+
import { X as X2 } from "lucide-react";
|
|
534
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
535
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
536
|
+
var tagVariants = cva2(
|
|
537
|
+
"inline-flex items-center gap-1.5 rounded-[var(--radius-control)] border font-medium leading-none transition-colors",
|
|
538
|
+
{
|
|
539
|
+
variants: {
|
|
540
|
+
variant: {
|
|
541
|
+
default: "border-border-base bg-surface-2 text-text-primary",
|
|
542
|
+
primary: "border-primary/20 bg-primary-soft text-primary-soft-fg",
|
|
543
|
+
success: "border-success/20 bg-success-soft text-success-soft-fg",
|
|
544
|
+
warning: "border-warning/20 bg-warning-soft text-warning-soft-fg",
|
|
545
|
+
destructive: "border-danger/20 bg-danger-soft text-danger-soft-fg",
|
|
546
|
+
outline: "border-border-strong bg-transparent text-text-primary"
|
|
547
|
+
},
|
|
548
|
+
size: {
|
|
549
|
+
sm: "min-h-[calc(var(--control-height-sm)*0.75)] px-[var(--control-padding-x-sm)] text-[11px]",
|
|
550
|
+
default: "min-h-[calc(var(--control-height-sm)*0.875)] px-[var(--control-padding-x-sm)] text-xs"
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
defaultVariants: {
|
|
554
|
+
variant: "default",
|
|
555
|
+
size: "default"
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
var Tag = forwardRef6(
|
|
560
|
+
({ variant, size, closable = false, disabled = false, color, onClose, className, children, style, ...props }, ref) => {
|
|
561
|
+
const customStyle = color ? { backgroundColor: color, color: "hsl(var(--primary-fg))", borderColor: color, ...style } : style ?? {};
|
|
562
|
+
const resolvedVariant = variant ?? "default";
|
|
563
|
+
const resolvedSize = size ?? "default";
|
|
564
|
+
const state = disabled ? "disabled" : "default";
|
|
565
|
+
function handleClose(event) {
|
|
566
|
+
event.stopPropagation();
|
|
567
|
+
if (!disabled) {
|
|
568
|
+
onClose?.(event);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return /* @__PURE__ */ jsxs3(
|
|
572
|
+
"span",
|
|
573
|
+
{
|
|
574
|
+
ref,
|
|
575
|
+
className: cn(tagVariants({ variant, size }), disabled && "cursor-not-allowed opacity-50", className),
|
|
576
|
+
style: customStyle,
|
|
577
|
+
...props,
|
|
578
|
+
"data-ug": "tag",
|
|
579
|
+
"data-state": state,
|
|
580
|
+
"data-variant": resolvedVariant,
|
|
581
|
+
"data-size": resolvedSize,
|
|
582
|
+
children: [
|
|
583
|
+
/* @__PURE__ */ jsx6("span", { "data-ug-slot": "label", children }),
|
|
584
|
+
closable && /* @__PURE__ */ jsx6(
|
|
585
|
+
"button",
|
|
586
|
+
{
|
|
587
|
+
type: "button",
|
|
588
|
+
onClick: handleClose,
|
|
589
|
+
disabled,
|
|
590
|
+
className: "-mr-[calc(var(--control-padding-x-sm)*0.33)] inline-flex h-[calc(var(--control-height-sm)*0.5)] w-[calc(var(--control-height-sm)*0.5)] items-center justify-center rounded-[calc(var(--radius-control)*0.5)] opacity-70 transition hover:bg-surface-3 hover:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-current disabled:pointer-events-none",
|
|
591
|
+
"aria-label": "\u5173\u95ED\u6807\u7B7E",
|
|
592
|
+
"data-ug-slot": "close",
|
|
593
|
+
"data-state": state,
|
|
594
|
+
"data-variant": resolvedVariant,
|
|
595
|
+
"data-size": resolvedSize,
|
|
596
|
+
children: /* @__PURE__ */ jsx6(X2, { size: 10, strokeWidth: 2.5 })
|
|
597
|
+
}
|
|
598
|
+
)
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
);
|
|
604
|
+
Tag.displayName = "Tag";
|
|
605
|
+
|
|
606
|
+
// src/components/spinner.tsx
|
|
607
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
608
|
+
import { Loader2 } from "lucide-react";
|
|
609
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
610
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
611
|
+
var spinnerVariants = cva3("animate-spin text-text-tertiary", {
|
|
612
|
+
variants: {
|
|
613
|
+
size: {
|
|
614
|
+
sm: "h-[calc(var(--control-height-sm)*0.5)] w-[calc(var(--control-height-sm)*0.5)]",
|
|
615
|
+
md: "h-[calc(var(--control-height-md)*0.6)] w-[calc(var(--control-height-md)*0.6)]",
|
|
616
|
+
lg: "h-[calc(var(--control-height-lg)*0.75)] w-[calc(var(--control-height-lg)*0.75)]"
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
defaultVariants: {
|
|
620
|
+
size: "md"
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
var Spinner = forwardRef7(({ className, size, label = "\u52A0\u8F7D\u4E2D", ...props }, ref) => {
|
|
624
|
+
const resolvedSize = size ?? "md";
|
|
625
|
+
return /* @__PURE__ */ jsx7(
|
|
626
|
+
Loader2,
|
|
627
|
+
{
|
|
628
|
+
ref,
|
|
629
|
+
className: cn(spinnerVariants({ size }), className),
|
|
630
|
+
"aria-label": label,
|
|
631
|
+
role: "status",
|
|
632
|
+
"data-ug": "spinner",
|
|
633
|
+
"data-ug-slot": "icon",
|
|
634
|
+
"data-state": "loading",
|
|
635
|
+
"data-variant": "default",
|
|
636
|
+
"data-size": resolvedSize,
|
|
637
|
+
...props
|
|
638
|
+
}
|
|
639
|
+
);
|
|
640
|
+
});
|
|
641
|
+
Spinner.displayName = "Spinner";
|
|
642
|
+
|
|
643
|
+
// src/components/separator.tsx
|
|
644
|
+
import { Children, forwardRef as forwardRef8 } from "react";
|
|
645
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
646
|
+
var contentPositionClasses = {
|
|
647
|
+
start: "after:flex-[1_1_auto] before:flex-[0_1_5%]",
|
|
648
|
+
center: "after:flex-1 before:flex-1",
|
|
649
|
+
end: "after:flex-[0_1_5%] before:flex-[1_1_auto]"
|
|
650
|
+
};
|
|
651
|
+
var lineStyleClasses = {
|
|
652
|
+
solid: "border-solid before:border-solid after:border-solid",
|
|
653
|
+
dashed: "border-dashed before:border-dashed after:border-dashed",
|
|
654
|
+
dotted: "border-dotted before:border-dotted after:border-dotted"
|
|
655
|
+
};
|
|
656
|
+
var Separator = forwardRef8(
|
|
657
|
+
({
|
|
658
|
+
orientation = "horizontal",
|
|
659
|
+
lineStyle = "solid",
|
|
660
|
+
contentPosition = "center",
|
|
661
|
+
children,
|
|
662
|
+
className,
|
|
663
|
+
style,
|
|
664
|
+
...props
|
|
665
|
+
}, ref) => {
|
|
666
|
+
const hasContent = orientation === "horizontal" && Children.toArray(children).some(
|
|
667
|
+
(child) => typeof child !== "string" || child.trim().length > 0
|
|
668
|
+
);
|
|
669
|
+
return /* @__PURE__ */ jsx8(
|
|
670
|
+
"div",
|
|
671
|
+
{
|
|
672
|
+
ref,
|
|
673
|
+
role: "separator",
|
|
674
|
+
"aria-orientation": orientation,
|
|
675
|
+
className: cn(
|
|
676
|
+
orientation === "vertical" ? "h-full min-h-[1em] w-0 shrink-0 border-l border-border-base" : hasContent ? "flex w-full items-center gap-3 text-xs text-text-secondary before:min-w-4 before:border-t before:border-border-base after:min-w-4 after:border-t after:border-border-base" : "w-full border-t border-border-base",
|
|
677
|
+
hasContent && contentPositionClasses[contentPosition],
|
|
678
|
+
lineStyleClasses[lineStyle],
|
|
679
|
+
className
|
|
680
|
+
),
|
|
681
|
+
style,
|
|
682
|
+
...props,
|
|
683
|
+
"data-ug": "separator",
|
|
684
|
+
"data-ug-slot": "line",
|
|
685
|
+
"data-state": "default",
|
|
686
|
+
"data-variant": `${orientation} ${lineStyle}`,
|
|
687
|
+
"data-size": "md",
|
|
688
|
+
children: hasContent ? /* @__PURE__ */ jsx8("span", { className: "shrink-0", "data-ug-slot": "content", children }) : null
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
Separator.displayName = "Separator";
|
|
694
|
+
|
|
695
|
+
// src/components/link.tsx
|
|
696
|
+
import { forwardRef as forwardRef9 } from "react";
|
|
697
|
+
import { ExternalLink } from "lucide-react";
|
|
698
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
699
|
+
var linkSizeClasses = {
|
|
700
|
+
sm: "text-xs",
|
|
701
|
+
default: "text-sm",
|
|
702
|
+
lg: "text-base"
|
|
703
|
+
};
|
|
704
|
+
var linkToneClasses = {
|
|
705
|
+
neutral: "text-[hsl(var(--link-neutral))]",
|
|
706
|
+
primary: "text-[hsl(var(--link-primary))]",
|
|
707
|
+
success: "text-[hsl(var(--link-success))]",
|
|
708
|
+
warning: "text-[hsl(var(--link-warning))]",
|
|
709
|
+
danger: "text-[hsl(var(--link-danger))]",
|
|
710
|
+
info: "text-[hsl(var(--link-info))]",
|
|
711
|
+
inherit: "text-inherit"
|
|
712
|
+
};
|
|
713
|
+
function resolveLinkRel(target, rel) {
|
|
714
|
+
if (target !== "_blank") return rel;
|
|
715
|
+
const tokens = new Set(rel?.split(/\s+/).filter(Boolean) ?? []);
|
|
716
|
+
tokens.add("noopener");
|
|
717
|
+
tokens.add("noreferrer");
|
|
718
|
+
return Array.from(tokens).join(" ");
|
|
719
|
+
}
|
|
720
|
+
var Link = forwardRef9(
|
|
721
|
+
({
|
|
722
|
+
children,
|
|
723
|
+
className,
|
|
724
|
+
disabled,
|
|
725
|
+
external = false,
|
|
726
|
+
endIcon,
|
|
727
|
+
href,
|
|
728
|
+
onClick,
|
|
729
|
+
rel,
|
|
730
|
+
showExternalIcon = false,
|
|
731
|
+
size,
|
|
732
|
+
startIcon,
|
|
733
|
+
tabIndex,
|
|
734
|
+
target,
|
|
735
|
+
tone,
|
|
736
|
+
underline,
|
|
737
|
+
...props
|
|
738
|
+
}, ref) => {
|
|
739
|
+
const config = useUIConfig();
|
|
740
|
+
const resolvedDisabled = resolveDisabled(disabled, config.disabled);
|
|
741
|
+
const resolvedSize = resolveControlSize(size, config.size);
|
|
742
|
+
const resolvedTone = tone ?? config.link.tone ?? "primary";
|
|
743
|
+
const resolvedUnderline = underline ?? config.link.underline ?? "hover";
|
|
744
|
+
const resolvedTarget = external ? target ?? "_blank" : target;
|
|
745
|
+
const resolvedRel = resolveLinkRel(resolvedTarget, rel);
|
|
746
|
+
return /* @__PURE__ */ jsxs4(
|
|
747
|
+
"a",
|
|
748
|
+
{
|
|
749
|
+
ref,
|
|
750
|
+
...props,
|
|
751
|
+
"aria-disabled": resolvedDisabled || void 0,
|
|
752
|
+
"data-external": external || void 0,
|
|
753
|
+
"data-size": resolvedSize,
|
|
754
|
+
"data-state": resolvedDisabled ? "disabled" : "default",
|
|
755
|
+
"data-tone": resolvedTone,
|
|
756
|
+
"data-ug": "link",
|
|
757
|
+
"data-ug-slot": "root",
|
|
758
|
+
"data-variant": resolvedUnderline,
|
|
759
|
+
href: resolvedDisabled ? void 0 : href,
|
|
760
|
+
className: cn(
|
|
761
|
+
"inline-flex items-center gap-1 rounded-[var(--radius-sm)] outline-none transition-[color,text-decoration-color,opacity] duration-[var(--motion-duration-base)] ease-[var(--motion-easing-standard)] motion-reduce:transition-none",
|
|
762
|
+
linkSizeClasses[resolvedSize],
|
|
763
|
+
linkToneClasses[resolvedTone],
|
|
764
|
+
"focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
765
|
+
resolvedUnderline === "always" && "underline decoration-current underline-offset-4",
|
|
766
|
+
resolvedUnderline === "hover" && "decoration-transparent underline underline-offset-4 hover:decoration-current",
|
|
767
|
+
resolvedUnderline === "never" && "no-underline",
|
|
768
|
+
resolvedDisabled && "cursor-not-allowed opacity-50",
|
|
769
|
+
className
|
|
770
|
+
),
|
|
771
|
+
onClick: (event) => {
|
|
772
|
+
if (resolvedDisabled) {
|
|
773
|
+
event.preventDefault();
|
|
774
|
+
event.stopPropagation();
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
onClick?.(event);
|
|
778
|
+
},
|
|
779
|
+
rel: resolvedRel,
|
|
780
|
+
tabIndex: resolvedDisabled ? -1 : tabIndex,
|
|
781
|
+
target: resolvedTarget,
|
|
782
|
+
children: [
|
|
783
|
+
startIcon ? /* @__PURE__ */ jsx9("span", { "aria-hidden": "true", className: "inline-flex shrink-0", "data-ug-slot": "start-icon", children: startIcon }) : null,
|
|
784
|
+
children,
|
|
785
|
+
endIcon ? /* @__PURE__ */ jsx9("span", { "aria-hidden": "true", className: "inline-flex shrink-0", "data-ug-slot": "end-icon", children: endIcon }) : null,
|
|
786
|
+
external && showExternalIcon ? /* @__PURE__ */ jsx9(
|
|
787
|
+
ExternalLink,
|
|
788
|
+
{
|
|
789
|
+
"aria-hidden": "true",
|
|
790
|
+
className: "h-[1em] w-[1em]",
|
|
791
|
+
"data-ug-slot": "external-icon",
|
|
792
|
+
size: 16,
|
|
793
|
+
strokeWidth: 1.8
|
|
794
|
+
}
|
|
795
|
+
) : null
|
|
796
|
+
]
|
|
797
|
+
}
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
);
|
|
801
|
+
Link.displayName = "Link";
|
|
802
|
+
|
|
803
|
+
// src/components/text.tsx
|
|
804
|
+
import {
|
|
805
|
+
forwardRef as forwardRef10
|
|
806
|
+
} from "react";
|
|
807
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
808
|
+
var toneClasses = {
|
|
809
|
+
default: "text-text-primary",
|
|
810
|
+
primary: "text-primary",
|
|
811
|
+
secondary: "text-text-secondary",
|
|
812
|
+
tertiary: "text-text-tertiary",
|
|
813
|
+
success: "text-success",
|
|
814
|
+
warning: "text-warning",
|
|
815
|
+
danger: "text-danger",
|
|
816
|
+
info: "text-info",
|
|
817
|
+
inherit: "text-inherit"
|
|
818
|
+
};
|
|
819
|
+
var sizeClasses = {
|
|
820
|
+
xs: "text-[11px]",
|
|
821
|
+
sm: "text-xs",
|
|
822
|
+
default: "text-sm",
|
|
823
|
+
md: "text-[15px]",
|
|
824
|
+
lg: "text-base"
|
|
825
|
+
};
|
|
826
|
+
function normalizeLineClamp(value) {
|
|
827
|
+
if (value === void 0 || value === null || value === "") return void 0;
|
|
828
|
+
const parsed = typeof value === "number" ? value : Number(value);
|
|
829
|
+
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : void 0;
|
|
830
|
+
}
|
|
831
|
+
var Text = forwardRef10(
|
|
832
|
+
({
|
|
833
|
+
as: Component = "span",
|
|
834
|
+
className,
|
|
835
|
+
lineClamp,
|
|
836
|
+
style,
|
|
837
|
+
tone = "default",
|
|
838
|
+
size,
|
|
839
|
+
truncate = false,
|
|
840
|
+
...props
|
|
841
|
+
}, ref) => {
|
|
842
|
+
const config = useUIConfig();
|
|
843
|
+
const resolvedSize = size ?? resolveControlSize(void 0, config.size);
|
|
844
|
+
const normalizedLineClamp = normalizeLineClamp(lineClamp);
|
|
845
|
+
const clampStyle = normalizedLineClamp ? {
|
|
846
|
+
display: "-webkit-box",
|
|
847
|
+
WebkitBoxOrient: "vertical",
|
|
848
|
+
WebkitLineClamp: normalizedLineClamp,
|
|
849
|
+
overflow: "hidden"
|
|
850
|
+
} : void 0;
|
|
851
|
+
return /* @__PURE__ */ jsx10(
|
|
852
|
+
Component,
|
|
853
|
+
{
|
|
854
|
+
ref,
|
|
855
|
+
className: cn(
|
|
856
|
+
toneClasses[tone],
|
|
857
|
+
sizeClasses[resolvedSize],
|
|
858
|
+
truncate && !normalizedLineClamp && "inline-block min-w-0 max-w-full truncate align-bottom",
|
|
859
|
+
className
|
|
860
|
+
),
|
|
861
|
+
style: { ...clampStyle, ...style },
|
|
862
|
+
"data-size": resolvedSize,
|
|
863
|
+
"data-state": truncate || normalizedLineClamp ? "truncated" : "default",
|
|
864
|
+
"data-ug": "text",
|
|
865
|
+
"data-ug-slot": "root",
|
|
866
|
+
"data-variant": tone,
|
|
867
|
+
...props
|
|
868
|
+
}
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
);
|
|
872
|
+
Text.displayName = "Text";
|
|
873
|
+
|
|
874
|
+
// src/components/space.tsx
|
|
875
|
+
import {
|
|
876
|
+
Children as Children2,
|
|
877
|
+
Fragment,
|
|
878
|
+
forwardRef as forwardRef11,
|
|
879
|
+
isValidElement
|
|
880
|
+
} from "react";
|
|
881
|
+
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
882
|
+
var gapSizes = {
|
|
883
|
+
xs: 4,
|
|
884
|
+
sm: 8,
|
|
885
|
+
md: 12,
|
|
886
|
+
lg: 16,
|
|
887
|
+
small: 8,
|
|
888
|
+
default: 12,
|
|
889
|
+
large: 16
|
|
890
|
+
};
|
|
891
|
+
var alignClasses = {
|
|
892
|
+
start: "items-start",
|
|
893
|
+
center: "items-center",
|
|
894
|
+
end: "items-end",
|
|
895
|
+
baseline: "items-baseline",
|
|
896
|
+
stretch: "items-stretch"
|
|
897
|
+
};
|
|
898
|
+
function resolveGap(gap) {
|
|
899
|
+
return typeof gap === "number" ? Number.isFinite(gap) ? Math.max(0, gap) : 0 : gapSizes[gap];
|
|
900
|
+
}
|
|
901
|
+
function resolveGaps(size) {
|
|
902
|
+
if (Array.isArray(size)) {
|
|
903
|
+
return [resolveGap(size[0]), resolveGap(size[1])];
|
|
904
|
+
}
|
|
905
|
+
const gap = resolveGap(size);
|
|
906
|
+
return [gap, gap];
|
|
907
|
+
}
|
|
908
|
+
function resolveFillRatio(fillRatio) {
|
|
909
|
+
return Number.isFinite(fillRatio) ? Math.min(100, Math.max(1, fillRatio)) : 100;
|
|
910
|
+
}
|
|
911
|
+
function flattenSpaceItems(children) {
|
|
912
|
+
return Children2.toArray(children).flatMap((item) => {
|
|
913
|
+
if (typeof item === "string" && item.trim() === "") return [];
|
|
914
|
+
if (isValidElement(item) && item.type === Fragment) {
|
|
915
|
+
return flattenSpaceItems(item.props.children);
|
|
916
|
+
}
|
|
917
|
+
return [item];
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
var Space = forwardRef11(
|
|
921
|
+
({
|
|
922
|
+
align = "center",
|
|
923
|
+
children,
|
|
924
|
+
className,
|
|
925
|
+
direction = "horizontal",
|
|
926
|
+
fill = false,
|
|
927
|
+
fillRatio = 100,
|
|
928
|
+
inline = false,
|
|
929
|
+
separator,
|
|
930
|
+
size = "default",
|
|
931
|
+
style,
|
|
932
|
+
wrap = false,
|
|
933
|
+
...props
|
|
934
|
+
}, ref) => {
|
|
935
|
+
const items = flattenSpaceItems(children);
|
|
936
|
+
const hasSeparator = separator !== void 0 && separator !== null && separator !== false;
|
|
937
|
+
const shouldWrapItems = fill || hasSeparator;
|
|
938
|
+
const [horizontalGap, verticalGap] = resolveGaps(size);
|
|
939
|
+
const gapDivisor = hasSeparator ? 2 : 1;
|
|
940
|
+
const normalizedFillRatio = resolveFillRatio(fillRatio);
|
|
941
|
+
const itemStyle = fill ? direction === "horizontal" ? { flex: `1 1 ${normalizedFillRatio}%`, minWidth: 0 } : { width: `${normalizedFillRatio}%` } : void 0;
|
|
942
|
+
return /* @__PURE__ */ jsx11(
|
|
943
|
+
"div",
|
|
944
|
+
{
|
|
945
|
+
ref,
|
|
946
|
+
"data-fill": fill ? "true" : "false",
|
|
947
|
+
"data-size": typeof size === "string" ? size : "custom",
|
|
948
|
+
"data-state": wrap ? "wrap" : "default",
|
|
949
|
+
"data-ug": "space",
|
|
950
|
+
"data-ug-slot": "root",
|
|
951
|
+
"data-variant": direction,
|
|
952
|
+
className: cn(
|
|
953
|
+
inline ? "inline-flex" : "flex",
|
|
954
|
+
direction === "vertical" && "flex-col",
|
|
955
|
+
alignClasses[align],
|
|
956
|
+
wrap && "flex-wrap",
|
|
957
|
+
className
|
|
958
|
+
),
|
|
959
|
+
style: {
|
|
960
|
+
columnGap: horizontalGap / gapDivisor,
|
|
961
|
+
rowGap: verticalGap / gapDivisor,
|
|
962
|
+
...style
|
|
963
|
+
},
|
|
964
|
+
...props,
|
|
965
|
+
children: shouldWrapItems ? items.map((item, index) => /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
966
|
+
index > 0 && hasSeparator ? /* @__PURE__ */ jsx11(
|
|
967
|
+
"span",
|
|
968
|
+
{
|
|
969
|
+
"aria-hidden": "true",
|
|
970
|
+
className: "inline-flex shrink-0 items-center text-text-tertiary",
|
|
971
|
+
"data-ug-slot": "separator",
|
|
972
|
+
children: separator
|
|
973
|
+
}
|
|
974
|
+
) : null,
|
|
975
|
+
/* @__PURE__ */ jsx11("div", { "data-ug-slot": "item", style: itemStyle, children: item })
|
|
976
|
+
] }, item.key ?? index)) : items
|
|
977
|
+
}
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
Space.displayName = "Space";
|
|
982
|
+
|
|
983
|
+
// src/components/scrollbar.tsx
|
|
984
|
+
import { forwardRef as forwardRef12, useRef as useRef2 } from "react";
|
|
985
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
986
|
+
var orientationClasses = {
|
|
987
|
+
vertical: "overflow-y-auto overflow-x-hidden",
|
|
988
|
+
horizontal: "overflow-x-auto overflow-y-hidden",
|
|
989
|
+
both: "overflow-auto"
|
|
990
|
+
};
|
|
991
|
+
var appearanceClasses = {
|
|
992
|
+
auto: "[scrollbar-width:auto]",
|
|
993
|
+
thin: "[scrollbar-color:var(--color-border-strong)_transparent] [scrollbar-width:thin]",
|
|
994
|
+
hidden: "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
|
|
995
|
+
};
|
|
996
|
+
var overscrollClasses = {
|
|
997
|
+
auto: "overscroll-auto",
|
|
998
|
+
contain: "overscroll-contain",
|
|
999
|
+
none: "overscroll-none"
|
|
1000
|
+
};
|
|
1001
|
+
function toCssSize(value) {
|
|
1002
|
+
return typeof value === "number" ? Number.isFinite(value) ? `${Math.max(0, value)}px` : void 0 : value;
|
|
1003
|
+
}
|
|
1004
|
+
function normalizeDistance(value) {
|
|
1005
|
+
return Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
1006
|
+
}
|
|
1007
|
+
function assignRef2(ref, value) {
|
|
1008
|
+
if (typeof ref === "function") {
|
|
1009
|
+
ref(value);
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
if (ref) ref.current = value;
|
|
1013
|
+
}
|
|
1014
|
+
var Scrollbar = forwardRef12(
|
|
1015
|
+
({
|
|
1016
|
+
className,
|
|
1017
|
+
height,
|
|
1018
|
+
horizontal = false,
|
|
1019
|
+
maxHeight,
|
|
1020
|
+
maxWidth,
|
|
1021
|
+
onEndReached,
|
|
1022
|
+
onScroll,
|
|
1023
|
+
onScrollPosition,
|
|
1024
|
+
orientation,
|
|
1025
|
+
overscroll = "contain",
|
|
1026
|
+
distance = 0,
|
|
1027
|
+
scrollbar = "thin",
|
|
1028
|
+
style,
|
|
1029
|
+
tabIndex = 0,
|
|
1030
|
+
width,
|
|
1031
|
+
...props
|
|
1032
|
+
}, forwardedRef) => {
|
|
1033
|
+
const viewportRef = useRef2(null);
|
|
1034
|
+
const reachedDirectionsRef = useRef2(/* @__PURE__ */ new Set());
|
|
1035
|
+
const resolvedOrientation = orientation ?? (horizontal ? "horizontal" : "vertical");
|
|
1036
|
+
function setViewportRef(node) {
|
|
1037
|
+
viewportRef.current = node;
|
|
1038
|
+
assignRef2(forwardedRef, node);
|
|
1039
|
+
}
|
|
1040
|
+
function handleScroll(event) {
|
|
1041
|
+
onScroll?.(event);
|
|
1042
|
+
onScrollPosition?.({
|
|
1043
|
+
scrollTop: event.currentTarget.scrollTop,
|
|
1044
|
+
scrollLeft: event.currentTarget.scrollLeft
|
|
1045
|
+
});
|
|
1046
|
+
if (!onEndReached) return;
|
|
1047
|
+
const viewport = event.currentTarget;
|
|
1048
|
+
const threshold = normalizeDistance(distance);
|
|
1049
|
+
const checks = [];
|
|
1050
|
+
const activeDirections = /* @__PURE__ */ new Set();
|
|
1051
|
+
if (resolvedOrientation !== "horizontal" && viewport.scrollHeight > viewport.clientHeight) {
|
|
1052
|
+
activeDirections.add("top");
|
|
1053
|
+
activeDirections.add("bottom");
|
|
1054
|
+
checks.push(
|
|
1055
|
+
["top", viewport.scrollTop <= threshold],
|
|
1056
|
+
["bottom", viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop <= threshold]
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
if (resolvedOrientation !== "vertical" && viewport.scrollWidth > viewport.clientWidth) {
|
|
1060
|
+
activeDirections.add("left");
|
|
1061
|
+
activeDirections.add("right");
|
|
1062
|
+
checks.push(
|
|
1063
|
+
["left", viewport.scrollLeft <= threshold],
|
|
1064
|
+
["right", viewport.scrollWidth - viewport.clientWidth - viewport.scrollLeft <= threshold]
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
reachedDirectionsRef.current.forEach((direction) => {
|
|
1068
|
+
if (!activeDirections.has(direction)) reachedDirectionsRef.current.delete(direction);
|
|
1069
|
+
});
|
|
1070
|
+
checks.forEach(([direction, reached]) => {
|
|
1071
|
+
if (!reached) {
|
|
1072
|
+
reachedDirectionsRef.current.delete(direction);
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
if (reachedDirectionsRef.current.has(direction)) return;
|
|
1076
|
+
reachedDirectionsRef.current.add(direction);
|
|
1077
|
+
onEndReached(direction);
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
return /* @__PURE__ */ jsx12(
|
|
1081
|
+
"div",
|
|
1082
|
+
{
|
|
1083
|
+
ref: setViewportRef,
|
|
1084
|
+
"data-size": "auto",
|
|
1085
|
+
"data-state": "default",
|
|
1086
|
+
"data-ug": "scrollbar",
|
|
1087
|
+
"data-ug-slot": "viewport",
|
|
1088
|
+
"data-variant": resolvedOrientation,
|
|
1089
|
+
tabIndex,
|
|
1090
|
+
className: cn(
|
|
1091
|
+
orientationClasses[resolvedOrientation],
|
|
1092
|
+
appearanceClasses[scrollbar],
|
|
1093
|
+
overscrollClasses[overscroll],
|
|
1094
|
+
className
|
|
1095
|
+
),
|
|
1096
|
+
style: {
|
|
1097
|
+
height: toCssSize(height),
|
|
1098
|
+
maxHeight: toCssSize(maxHeight),
|
|
1099
|
+
width: toCssSize(width),
|
|
1100
|
+
maxWidth: toCssSize(maxWidth),
|
|
1101
|
+
...style
|
|
1102
|
+
},
|
|
1103
|
+
onScroll: handleScroll,
|
|
1104
|
+
...props
|
|
1105
|
+
}
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
1108
|
+
);
|
|
1109
|
+
Scrollbar.displayName = "Scrollbar";
|
|
1110
|
+
|
|
1111
|
+
// src/components/layout.tsx
|
|
1112
|
+
import { forwardRef as forwardRef13 } from "react";
|
|
1113
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1114
|
+
var justifyClasses = {
|
|
1115
|
+
start: "justify-start",
|
|
1116
|
+
center: "justify-center",
|
|
1117
|
+
end: "justify-end",
|
|
1118
|
+
between: "justify-between",
|
|
1119
|
+
around: "justify-around",
|
|
1120
|
+
evenly: "justify-evenly"
|
|
1121
|
+
};
|
|
1122
|
+
var alignClasses2 = {
|
|
1123
|
+
start: "items-start",
|
|
1124
|
+
center: "items-center",
|
|
1125
|
+
end: "items-end",
|
|
1126
|
+
stretch: "items-stretch"
|
|
1127
|
+
};
|
|
1128
|
+
var clampGridValue = (value, fallback) => {
|
|
1129
|
+
const resolvedValue = value ?? fallback;
|
|
1130
|
+
return Number.isFinite(resolvedValue) ? Math.min(24, Math.max(0, Math.round(resolvedValue))) : fallback;
|
|
1131
|
+
};
|
|
1132
|
+
var normalizeGutter = (value) => Number.isFinite(value) ? Math.max(0, value ?? 0) : 0;
|
|
1133
|
+
function normalizeColSize(value, fallback) {
|
|
1134
|
+
if (typeof value === "number") {
|
|
1135
|
+
return { ...fallback, span: clampGridValue(value, fallback.span) };
|
|
1136
|
+
}
|
|
1137
|
+
return {
|
|
1138
|
+
span: clampGridValue(value?.span, fallback.span),
|
|
1139
|
+
offset: clampGridValue(value?.offset, fallback.offset),
|
|
1140
|
+
push: clampGridValue(value?.push, fallback.push),
|
|
1141
|
+
pull: clampGridValue(value?.pull, fallback.pull)
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
var toPercent = (value) => `${value / 24 * 100}%`;
|
|
1145
|
+
var toShift = ({ pull, push }) => `${(push - pull) / 24 * 100}%`;
|
|
1146
|
+
var Row = forwardRef13(
|
|
1147
|
+
({ align = "stretch", as: Component = "div", className, gutter = 0, justify = "start", style, wrap = true, ...props }, ref) => {
|
|
1148
|
+
const [horizontalGutter, verticalGutter] = Array.isArray(gutter) ? [normalizeGutter(gutter[0]), normalizeGutter(gutter[1])] : [normalizeGutter(gutter), 0];
|
|
1149
|
+
const halfHorizontalGutter = horizontalGutter / 2;
|
|
1150
|
+
return /* @__PURE__ */ jsx13(
|
|
1151
|
+
Component,
|
|
1152
|
+
{
|
|
1153
|
+
ref,
|
|
1154
|
+
"data-size": "24",
|
|
1155
|
+
"data-state": wrap ? "wrap" : "default",
|
|
1156
|
+
"data-ug": "layout",
|
|
1157
|
+
"data-ug-slot": "row",
|
|
1158
|
+
"data-variant": "grid",
|
|
1159
|
+
className: cn("flex", justifyClasses[justify], alignClasses2[align], wrap && "flex-wrap", className),
|
|
1160
|
+
style: {
|
|
1161
|
+
marginInlineStart: horizontalGutter ? `${-halfHorizontalGutter}px` : void 0,
|
|
1162
|
+
marginInlineEnd: horizontalGutter ? `${-halfHorizontalGutter}px` : void 0,
|
|
1163
|
+
rowGap: `${verticalGutter}px`,
|
|
1164
|
+
"--ug-row-gutter": `${horizontalGutter}px`,
|
|
1165
|
+
...style
|
|
1166
|
+
},
|
|
1167
|
+
...props
|
|
1168
|
+
}
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
);
|
|
1172
|
+
var Col = forwardRef13(
|
|
1173
|
+
({ as: Component = "div", className, offset = 0, pull = 0, push = 0, span = 24, style, xs, sm, md, lg, xl, ...props }, ref) => {
|
|
1174
|
+
const base = normalizeColSize({ span, offset, push, pull }, { span: 24, offset: 0, push: 0, pull: 0 });
|
|
1175
|
+
const xsSize = normalizeColSize(xs, base);
|
|
1176
|
+
const smSize = normalizeColSize(sm, xsSize);
|
|
1177
|
+
const mdSize = normalizeColSize(md, smSize);
|
|
1178
|
+
const lgSize = normalizeColSize(lg, mdSize);
|
|
1179
|
+
const xlSize = normalizeColSize(xl, lgSize);
|
|
1180
|
+
return /* @__PURE__ */ jsx13(
|
|
1181
|
+
Component,
|
|
1182
|
+
{
|
|
1183
|
+
ref,
|
|
1184
|
+
"data-size": base.span,
|
|
1185
|
+
"data-state": "default",
|
|
1186
|
+
"data-ug": "layout",
|
|
1187
|
+
"data-ug-slot": "col",
|
|
1188
|
+
"data-variant": "grid",
|
|
1189
|
+
className: cn(
|
|
1190
|
+
"relative min-w-0 flex-none px-[calc(var(--ug-row-gutter,0px)/2)]",
|
|
1191
|
+
"[flex-basis:var(--ug-col-base)] [max-width:var(--ug-col-base)]",
|
|
1192
|
+
"[display:var(--ug-col-display-base)]",
|
|
1193
|
+
"[margin-inline-start:var(--ug-col-offset-base)] [inset-inline-start:var(--ug-col-shift-base)]",
|
|
1194
|
+
"max-sm:[flex-basis:var(--ug-col-xs)] max-sm:[max-width:var(--ug-col-xs)]",
|
|
1195
|
+
"max-sm:[display:var(--ug-col-display-xs)]",
|
|
1196
|
+
"max-sm:[margin-inline-start:var(--ug-col-offset-xs)] max-sm:[inset-inline-start:var(--ug-col-shift-xs)]",
|
|
1197
|
+
"sm:[flex-basis:var(--ug-col-sm)] sm:[max-width:var(--ug-col-sm)]",
|
|
1198
|
+
"sm:[display:var(--ug-col-display-sm)]",
|
|
1199
|
+
"sm:[margin-inline-start:var(--ug-col-offset-sm)] sm:[inset-inline-start:var(--ug-col-shift-sm)]",
|
|
1200
|
+
"md:[flex-basis:var(--ug-col-md)] md:[max-width:var(--ug-col-md)]",
|
|
1201
|
+
"md:[display:var(--ug-col-display-md)]",
|
|
1202
|
+
"md:[margin-inline-start:var(--ug-col-offset-md)] md:[inset-inline-start:var(--ug-col-shift-md)]",
|
|
1203
|
+
"lg:[flex-basis:var(--ug-col-lg)] lg:[max-width:var(--ug-col-lg)]",
|
|
1204
|
+
"lg:[display:var(--ug-col-display-lg)]",
|
|
1205
|
+
"lg:[margin-inline-start:var(--ug-col-offset-lg)] lg:[inset-inline-start:var(--ug-col-shift-lg)]",
|
|
1206
|
+
"xl:[flex-basis:var(--ug-col-xl)] xl:[max-width:var(--ug-col-xl)]",
|
|
1207
|
+
"xl:[display:var(--ug-col-display-xl)]",
|
|
1208
|
+
"xl:[margin-inline-start:var(--ug-col-offset-xl)] xl:[inset-inline-start:var(--ug-col-shift-xl)]",
|
|
1209
|
+
className
|
|
1210
|
+
),
|
|
1211
|
+
style: {
|
|
1212
|
+
"--ug-col-base": toPercent(base.span),
|
|
1213
|
+
"--ug-col-display-base": base.span === 0 ? "none" : "block",
|
|
1214
|
+
"--ug-col-offset-base": toPercent(base.offset),
|
|
1215
|
+
"--ug-col-shift-base": toShift(base),
|
|
1216
|
+
"--ug-col-xs": toPercent(xsSize.span),
|
|
1217
|
+
"--ug-col-display-xs": xsSize.span === 0 ? "none" : "block",
|
|
1218
|
+
"--ug-col-offset-xs": toPercent(xsSize.offset),
|
|
1219
|
+
"--ug-col-shift-xs": toShift(xsSize),
|
|
1220
|
+
"--ug-col-sm": toPercent(smSize.span),
|
|
1221
|
+
"--ug-col-display-sm": smSize.span === 0 ? "none" : "block",
|
|
1222
|
+
"--ug-col-offset-sm": toPercent(smSize.offset),
|
|
1223
|
+
"--ug-col-shift-sm": toShift(smSize),
|
|
1224
|
+
"--ug-col-md": toPercent(mdSize.span),
|
|
1225
|
+
"--ug-col-display-md": mdSize.span === 0 ? "none" : "block",
|
|
1226
|
+
"--ug-col-offset-md": toPercent(mdSize.offset),
|
|
1227
|
+
"--ug-col-shift-md": toShift(mdSize),
|
|
1228
|
+
"--ug-col-lg": toPercent(lgSize.span),
|
|
1229
|
+
"--ug-col-display-lg": lgSize.span === 0 ? "none" : "block",
|
|
1230
|
+
"--ug-col-offset-lg": toPercent(lgSize.offset),
|
|
1231
|
+
"--ug-col-shift-lg": toShift(lgSize),
|
|
1232
|
+
"--ug-col-xl": toPercent(xlSize.span),
|
|
1233
|
+
"--ug-col-display-xl": xlSize.span === 0 ? "none" : "block",
|
|
1234
|
+
"--ug-col-offset-xl": toPercent(xlSize.offset),
|
|
1235
|
+
"--ug-col-shift-xl": toShift(xlSize),
|
|
1236
|
+
...style
|
|
1237
|
+
},
|
|
1238
|
+
...props
|
|
1239
|
+
}
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
);
|
|
1243
|
+
Row.displayName = "Row";
|
|
1244
|
+
Col.displayName = "Col";
|
|
1245
|
+
|
|
1246
|
+
// src/components/container.tsx
|
|
1247
|
+
import {
|
|
1248
|
+
Children as Children3,
|
|
1249
|
+
Fragment as Fragment2,
|
|
1250
|
+
forwardRef as forwardRef14,
|
|
1251
|
+
isValidElement as isValidElement2
|
|
1252
|
+
} from "react";
|
|
1253
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1254
|
+
var toCssSize2 = (value) => typeof value === "number" ? Number.isFinite(value) ? `${Math.max(0, value)}px` : void 0 : value;
|
|
1255
|
+
function hasVerticalRegion(children) {
|
|
1256
|
+
return Children3.toArray(children).some((child) => {
|
|
1257
|
+
if (!isValidElement2(child)) return false;
|
|
1258
|
+
if (child.type === Header || child.type === Footer) return true;
|
|
1259
|
+
if (child.type !== Fragment2) return false;
|
|
1260
|
+
return hasVerticalRegion(child.props.children);
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
var Header = forwardRef14(
|
|
1264
|
+
({ as: Component = "header", className, height = 60, style, ...props }, ref) => /* @__PURE__ */ jsx14(
|
|
1265
|
+
Component,
|
|
1266
|
+
{
|
|
1267
|
+
ref,
|
|
1268
|
+
className: cn("shrink-0", className),
|
|
1269
|
+
style: { height: toCssSize2(height), ...style },
|
|
1270
|
+
"data-ug-slot": "header",
|
|
1271
|
+
...props
|
|
1272
|
+
}
|
|
1273
|
+
)
|
|
1274
|
+
);
|
|
1275
|
+
var Aside = forwardRef14(
|
|
1276
|
+
({ as: Component = "aside", className, width = 300, style, ...props }, ref) => /* @__PURE__ */ jsx14(
|
|
1277
|
+
Component,
|
|
1278
|
+
{
|
|
1279
|
+
ref,
|
|
1280
|
+
className: cn("min-h-[0] shrink-0", className),
|
|
1281
|
+
style: { width: toCssSize2(width), ...style },
|
|
1282
|
+
"data-ug-slot": "aside",
|
|
1283
|
+
...props
|
|
1284
|
+
}
|
|
1285
|
+
)
|
|
1286
|
+
);
|
|
1287
|
+
var Main = forwardRef14(
|
|
1288
|
+
({ as: Component = "main", className, ...props }, ref) => /* @__PURE__ */ jsx14(
|
|
1289
|
+
Component,
|
|
1290
|
+
{
|
|
1291
|
+
ref,
|
|
1292
|
+
className: cn("min-h-[0] min-w-0 flex-1", className),
|
|
1293
|
+
"data-ug-slot": "main",
|
|
1294
|
+
...props
|
|
1295
|
+
}
|
|
1296
|
+
)
|
|
1297
|
+
);
|
|
1298
|
+
var Footer = forwardRef14(
|
|
1299
|
+
({ as: Component = "footer", className, height = 60, style, ...props }, ref) => /* @__PURE__ */ jsx14(
|
|
1300
|
+
Component,
|
|
1301
|
+
{
|
|
1302
|
+
ref,
|
|
1303
|
+
className: cn("shrink-0", className),
|
|
1304
|
+
style: { height: toCssSize2(height), ...style },
|
|
1305
|
+
"data-ug-slot": "footer",
|
|
1306
|
+
...props
|
|
1307
|
+
}
|
|
1308
|
+
)
|
|
1309
|
+
);
|
|
1310
|
+
var Container = forwardRef14(
|
|
1311
|
+
({ as: Component = "div", children, className, direction = "auto", ...props }, ref) => {
|
|
1312
|
+
const resolvedDirection = direction === "auto" ? hasVerticalRegion(children) ? "vertical" : "horizontal" : direction;
|
|
1313
|
+
return /* @__PURE__ */ jsx14(
|
|
1314
|
+
Component,
|
|
1315
|
+
{
|
|
1316
|
+
ref,
|
|
1317
|
+
"data-size": "auto",
|
|
1318
|
+
"data-state": "default",
|
|
1319
|
+
"data-ug": "container",
|
|
1320
|
+
"data-ug-slot": "root",
|
|
1321
|
+
"data-variant": resolvedDirection,
|
|
1322
|
+
className: cn(
|
|
1323
|
+
"flex min-h-[0] min-w-0 flex-1",
|
|
1324
|
+
resolvedDirection === "vertical" ? "flex-col" : "flex-row",
|
|
1325
|
+
className
|
|
1326
|
+
),
|
|
1327
|
+
...props,
|
|
1328
|
+
children
|
|
1329
|
+
}
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
);
|
|
1333
|
+
Container.displayName = "Container";
|
|
1334
|
+
Header.displayName = "Header";
|
|
1335
|
+
Aside.displayName = "Aside";
|
|
1336
|
+
Main.displayName = "Main";
|
|
1337
|
+
Footer.displayName = "Footer";
|
|
1338
|
+
|
|
1339
|
+
// src/components/splitter.tsx
|
|
1340
|
+
import {
|
|
1341
|
+
Children as Children4,
|
|
1342
|
+
Fragment as Fragment3,
|
|
1343
|
+
cloneElement,
|
|
1344
|
+
forwardRef as forwardRef15,
|
|
1345
|
+
isValidElement as isValidElement3,
|
|
1346
|
+
useEffect as useEffect2,
|
|
1347
|
+
useId as useId2,
|
|
1348
|
+
useMemo,
|
|
1349
|
+
useRef as useRef3,
|
|
1350
|
+
useState as useState2
|
|
1351
|
+
} from "react";
|
|
1352
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1353
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, Number.isFinite(value) ? value : min));
|
|
1354
|
+
function normalizeSizes(values, count) {
|
|
1355
|
+
if (count <= 0) return [];
|
|
1356
|
+
const source = Array.from({ length: count }, (_, index) => Math.max(0, values[index] ?? 0));
|
|
1357
|
+
const total = source.reduce((sum, value) => sum + value, 0);
|
|
1358
|
+
if (total <= 0) return Array.from({ length: count }, () => 100 / count);
|
|
1359
|
+
return source.map((value) => value / total * 100);
|
|
1360
|
+
}
|
|
1361
|
+
function constrainSizes(values, configs) {
|
|
1362
|
+
if (configs.length === 0) return [];
|
|
1363
|
+
const normalized = normalizeSizes(values, configs.length);
|
|
1364
|
+
const declaredMins = configs.map((config, index) => {
|
|
1365
|
+
const min = config.collapsible && normalized[index] <= config.collapsedSize + 0.01 ? config.collapsedSize : config.min;
|
|
1366
|
+
return Math.min(min, config.max);
|
|
1367
|
+
});
|
|
1368
|
+
const declaredMaxs = configs.map((config) => Math.max(config.min, config.max));
|
|
1369
|
+
const minTotal = declaredMins.reduce((sum, value) => sum + value, 0);
|
|
1370
|
+
const maxTotal = declaredMaxs.reduce((sum, value) => sum + value, 0);
|
|
1371
|
+
const mins = minTotal > 100 ? declaredMins.map((value) => value / minTotal * 100) : declaredMins;
|
|
1372
|
+
const maxs = maxTotal < 100 ? declaredMaxs.map((value) => value / maxTotal * 100) : declaredMaxs;
|
|
1373
|
+
const next = normalized.map((value, index) => clamp(value, mins[index], maxs[index]));
|
|
1374
|
+
for (let attempt = 0; attempt < configs.length * 2; attempt += 1) {
|
|
1375
|
+
const delta = 100 - next.reduce((sum, value) => sum + value, 0);
|
|
1376
|
+
if (Math.abs(delta) < 1e-4) break;
|
|
1377
|
+
const capacities = next.map(
|
|
1378
|
+
(value, index) => delta > 0 ? Math.max(0, maxs[index] - value) : Math.max(0, value - mins[index])
|
|
1379
|
+
);
|
|
1380
|
+
const capacityTotal = capacities.reduce((sum, value) => sum + value, 0);
|
|
1381
|
+
if (capacityTotal <= 0) break;
|
|
1382
|
+
next.forEach((value, index) => {
|
|
1383
|
+
next[index] = value + delta * (capacities[index] / capacityTotal);
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
return normalizeSizes(next, configs.length);
|
|
1387
|
+
}
|
|
1388
|
+
function buildDefaultSizes(configs, defaults) {
|
|
1389
|
+
const values = configs.map((config, index) => defaults?.[index] ?? config.defaultSize);
|
|
1390
|
+
const specifiedTotal = values.reduce((sum, value) => sum + (value ?? 0), 0);
|
|
1391
|
+
const unspecifiedCount = values.filter((value) => value === void 0).length;
|
|
1392
|
+
const remainder = Math.max(0, 100 - specifiedTotal);
|
|
1393
|
+
const fallback = unspecifiedCount > 0 ? remainder / unspecifiedCount : 0;
|
|
1394
|
+
return constrainSizes(values.map((value) => value ?? fallback), configs);
|
|
1395
|
+
}
|
|
1396
|
+
function resizePair(sizes, configs, separatorIndex, requestedFirstSize, overrides) {
|
|
1397
|
+
const first = configs[separatorIndex];
|
|
1398
|
+
const second = configs[separatorIndex + 1];
|
|
1399
|
+
if (!first || !second || !first.resizable || !second.resizable) return [...sizes];
|
|
1400
|
+
const pairSize = sizes[separatorIndex] + sizes[separatorIndex + 1];
|
|
1401
|
+
const firstMin = overrides?.firstMin ?? first.min;
|
|
1402
|
+
const secondMin = overrides?.secondMin ?? second.min;
|
|
1403
|
+
const lowerBound = Math.max(firstMin, pairSize - second.max);
|
|
1404
|
+
const upperBound = Math.min(first.max, pairSize - secondMin);
|
|
1405
|
+
const nextFirst = clamp(requestedFirstSize, lowerBound, upperBound);
|
|
1406
|
+
const next = [...sizes];
|
|
1407
|
+
next[separatorIndex] = nextFirst;
|
|
1408
|
+
next[separatorIndex + 1] = pairSize - nextFirst;
|
|
1409
|
+
return next;
|
|
1410
|
+
}
|
|
1411
|
+
function getEffectivePanelMin(config, size) {
|
|
1412
|
+
return config.collapsible && size <= config.collapsedSize + 0.01 ? config.collapsedSize : config.min;
|
|
1413
|
+
}
|
|
1414
|
+
function getPairBounds(sizes, configs, separatorIndex) {
|
|
1415
|
+
const first = configs[separatorIndex];
|
|
1416
|
+
const second = configs[separatorIndex + 1];
|
|
1417
|
+
if (!first || !second) return { min: 0, max: 100 };
|
|
1418
|
+
const pairSize = sizes[separatorIndex] + sizes[separatorIndex + 1];
|
|
1419
|
+
const prefix = sizes.slice(0, separatorIndex).reduce((sum, value) => sum + value, 0);
|
|
1420
|
+
const firstMin = getEffectivePanelMin(first, sizes[separatorIndex]);
|
|
1421
|
+
const secondMin = getEffectivePanelMin(second, sizes[separatorIndex + 1]);
|
|
1422
|
+
return {
|
|
1423
|
+
min: prefix + Math.max(firstMin, pairSize - second.max),
|
|
1424
|
+
max: prefix + Math.min(first.max, pairSize - secondMin)
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
var SplitterPanel = forwardRef15(
|
|
1428
|
+
({
|
|
1429
|
+
children,
|
|
1430
|
+
className,
|
|
1431
|
+
collapsible: _collapsible,
|
|
1432
|
+
collapsedSize: _collapsedSize,
|
|
1433
|
+
defaultSize: _defaultSize,
|
|
1434
|
+
max: _max,
|
|
1435
|
+
min: _min,
|
|
1436
|
+
onCollapseChange: _onCollapseChange,
|
|
1437
|
+
resizable: _resizable,
|
|
1438
|
+
...props
|
|
1439
|
+
}, ref) => /* @__PURE__ */ jsx15(
|
|
1440
|
+
"div",
|
|
1441
|
+
{
|
|
1442
|
+
ref,
|
|
1443
|
+
className: cn("min-h-[0] min-w-[0] overflow-auto", className),
|
|
1444
|
+
"data-ug-slot": "panel",
|
|
1445
|
+
...props,
|
|
1446
|
+
children
|
|
1447
|
+
}
|
|
1448
|
+
)
|
|
1449
|
+
);
|
|
1450
|
+
SplitterPanel.displayName = "SplitterPanel";
|
|
1451
|
+
function getPanelElements(children) {
|
|
1452
|
+
return Children4.toArray(children).flatMap((child) => {
|
|
1453
|
+
if (!isValidElement3(child)) return [];
|
|
1454
|
+
if (child.type === Fragment3) {
|
|
1455
|
+
return getPanelElements(child.props.children);
|
|
1456
|
+
}
|
|
1457
|
+
return child.type === SplitterPanel ? [child] : [];
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
var Splitter = forwardRef15(
|
|
1461
|
+
({
|
|
1462
|
+
children,
|
|
1463
|
+
className,
|
|
1464
|
+
defaultSize = 50,
|
|
1465
|
+
defaultSizes,
|
|
1466
|
+
direction = "horizontal",
|
|
1467
|
+
first,
|
|
1468
|
+
keyboardStep = 2,
|
|
1469
|
+
lazy = false,
|
|
1470
|
+
max = 90,
|
|
1471
|
+
min = 10,
|
|
1472
|
+
onChange,
|
|
1473
|
+
onCollapse,
|
|
1474
|
+
onResize,
|
|
1475
|
+
onResizeEnd,
|
|
1476
|
+
onResizeStart,
|
|
1477
|
+
onSizesChange,
|
|
1478
|
+
second,
|
|
1479
|
+
size,
|
|
1480
|
+
sizes,
|
|
1481
|
+
...props
|
|
1482
|
+
}, ref) => {
|
|
1483
|
+
const rootRef = useRef3(null);
|
|
1484
|
+
const dragRef = useRef3(null);
|
|
1485
|
+
const restoreSizesRef = useRef3({});
|
|
1486
|
+
const generatedId = useId2();
|
|
1487
|
+
const configs = useMemo(() => {
|
|
1488
|
+
const compoundPanels = getPanelElements(children);
|
|
1489
|
+
const elements = compoundPanels.length > 0 ? compoundPanels : [
|
|
1490
|
+
/* @__PURE__ */ jsx15(SplitterPanel, { defaultSize, min, max, children: first }, "legacy-first"),
|
|
1491
|
+
/* @__PURE__ */ jsx15(SplitterPanel, { min: 100 - max, max: 100 - min, children: second }, "legacy-second")
|
|
1492
|
+
];
|
|
1493
|
+
return elements.map((element) => {
|
|
1494
|
+
const rawMin = clamp(element.props.min ?? 0, 0, 100);
|
|
1495
|
+
const rawMax = clamp(element.props.max ?? 100, 0, 100);
|
|
1496
|
+
const minSize = Math.min(rawMin, rawMax);
|
|
1497
|
+
const maxSize = Math.max(rawMin, rawMax);
|
|
1498
|
+
return {
|
|
1499
|
+
element,
|
|
1500
|
+
min: minSize,
|
|
1501
|
+
max: maxSize,
|
|
1502
|
+
defaultSize: element.props.defaultSize,
|
|
1503
|
+
collapsible: element.props.collapsible ?? false,
|
|
1504
|
+
collapsedSize: clamp(element.props.collapsedSize ?? 0, 0, minSize),
|
|
1505
|
+
resizable: element.props.resizable ?? true
|
|
1506
|
+
};
|
|
1507
|
+
});
|
|
1508
|
+
}, [children, defaultSize, first, max, min, second]);
|
|
1509
|
+
const defaultSignature = configs.map((config) => `${config.defaultSize ?? ""}:${config.min}:${config.max}`).join("|");
|
|
1510
|
+
const [internalSizes, setInternalSizes] = useState2(() => buildDefaultSizes(configs, defaultSizes));
|
|
1511
|
+
useEffect2(() => {
|
|
1512
|
+
setInternalSizes(
|
|
1513
|
+
(current) => current.length === configs.length ? constrainSizes(current, configs) : buildDefaultSizes(configs, defaultSizes)
|
|
1514
|
+
);
|
|
1515
|
+
}, [configs, configs.length, defaultSignature, defaultSizes]);
|
|
1516
|
+
const controlledSizes = sizes ? constrainSizes(sizes, configs) : size !== void 0 && configs.length === 2 ? constrainSizes([clamp(size, min, max), 100 - clamp(size, min, max)], configs) : void 0;
|
|
1517
|
+
const currentSizes = controlledSizes ?? internalSizes;
|
|
1518
|
+
const emitSizes = (next, separatorIndex, phase) => {
|
|
1519
|
+
const normalized = constrainSizes(next, configs);
|
|
1520
|
+
if (!controlledSizes) setInternalSizes(normalized);
|
|
1521
|
+
onSizesChange?.(normalized);
|
|
1522
|
+
onChange?.(normalized[0] ?? 0);
|
|
1523
|
+
const detail = { separatorIndex, sizes: normalized };
|
|
1524
|
+
if (phase === "resize") onResize?.(detail);
|
|
1525
|
+
if (phase === "end") onResizeEnd?.(detail);
|
|
1526
|
+
return normalized;
|
|
1527
|
+
};
|
|
1528
|
+
const finishDrag = (separatorIndex) => {
|
|
1529
|
+
const drag = dragRef.current;
|
|
1530
|
+
if (!drag) return;
|
|
1531
|
+
dragRef.current = null;
|
|
1532
|
+
emitSizes(drag.latestSizes, separatorIndex, "end");
|
|
1533
|
+
};
|
|
1534
|
+
const toggleCollapsedPanel = (separatorIndex) => {
|
|
1535
|
+
const candidateIndex = configs[separatorIndex]?.collapsible ? separatorIndex : configs[separatorIndex + 1]?.collapsible ? separatorIndex + 1 : -1;
|
|
1536
|
+
if (candidateIndex < 0) return;
|
|
1537
|
+
const pairIndex = candidateIndex === separatorIndex ? separatorIndex : separatorIndex;
|
|
1538
|
+
const config = configs[candidateIndex];
|
|
1539
|
+
const current = currentSizes[candidateIndex];
|
|
1540
|
+
const collapsed = current <= config.collapsedSize + 0.01;
|
|
1541
|
+
const pairTotal = currentSizes[pairIndex] + currentSizes[pairIndex + 1];
|
|
1542
|
+
let requestedFirstSize;
|
|
1543
|
+
if (candidateIndex === pairIndex) {
|
|
1544
|
+
if (!collapsed) restoreSizesRef.current[candidateIndex] = current;
|
|
1545
|
+
requestedFirstSize = collapsed ? restoreSizesRef.current[candidateIndex] ?? config.defaultSize ?? pairTotal / 2 : config.collapsedSize;
|
|
1546
|
+
} else {
|
|
1547
|
+
if (!collapsed) restoreSizesRef.current[candidateIndex] = current;
|
|
1548
|
+
const nextSecond = collapsed ? restoreSizesRef.current[candidateIndex] ?? config.defaultSize ?? pairTotal / 2 : config.collapsedSize;
|
|
1549
|
+
requestedFirstSize = pairTotal - nextSecond;
|
|
1550
|
+
}
|
|
1551
|
+
const next = resizePair(
|
|
1552
|
+
currentSizes,
|
|
1553
|
+
configs,
|
|
1554
|
+
pairIndex,
|
|
1555
|
+
requestedFirstSize,
|
|
1556
|
+
collapsed ? void 0 : candidateIndex === pairIndex ? { firstMin: config.collapsedSize } : { secondMin: config.collapsedSize }
|
|
1557
|
+
);
|
|
1558
|
+
const nextCollapsed = next[candidateIndex] <= config.collapsedSize + 0.01;
|
|
1559
|
+
if (nextCollapsed === collapsed) return;
|
|
1560
|
+
emitSizes(next, pairIndex, "change");
|
|
1561
|
+
config.element.props.onCollapseChange?.(nextCollapsed);
|
|
1562
|
+
onCollapse?.({
|
|
1563
|
+
panelIndex: candidateIndex,
|
|
1564
|
+
collapsed: nextCollapsed,
|
|
1565
|
+
sizes: next
|
|
1566
|
+
});
|
|
1567
|
+
};
|
|
1568
|
+
return /* @__PURE__ */ jsx15(
|
|
1569
|
+
"div",
|
|
1570
|
+
{
|
|
1571
|
+
ref: (node) => {
|
|
1572
|
+
rootRef.current = node;
|
|
1573
|
+
if (typeof ref === "function") ref(node);
|
|
1574
|
+
else if (ref) ref.current = node;
|
|
1575
|
+
},
|
|
1576
|
+
className: cn(
|
|
1577
|
+
"flex min-h-[0] min-w-[0] overflow-hidden",
|
|
1578
|
+
direction === "vertical" && "flex-col",
|
|
1579
|
+
className
|
|
1580
|
+
),
|
|
1581
|
+
"data-panel-count": configs.length,
|
|
1582
|
+
"data-size": "auto",
|
|
1583
|
+
"data-state": "default",
|
|
1584
|
+
"data-ug": "splitter",
|
|
1585
|
+
"data-ug-slot": "root",
|
|
1586
|
+
"data-variant": direction,
|
|
1587
|
+
...props,
|
|
1588
|
+
children: configs.flatMap((config, index) => {
|
|
1589
|
+
const panelId = config.element.props.id ?? `${generatedId}-panel-${index}`;
|
|
1590
|
+
const panel = cloneElement(config.element, {
|
|
1591
|
+
id: panelId,
|
|
1592
|
+
"aria-hidden": currentSizes[index] <= config.collapsedSize + 0.01 || void 0,
|
|
1593
|
+
"data-state": currentSizes[index] <= config.collapsedSize + 0.01 ? "collapsed" : "expanded",
|
|
1594
|
+
style: {
|
|
1595
|
+
flexBasis: `${currentSizes[index]}%`,
|
|
1596
|
+
flexGrow: 0,
|
|
1597
|
+
flexShrink: 0,
|
|
1598
|
+
...config.element.props.style
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
if (index === configs.length - 1) return [panel];
|
|
1602
|
+
const disabled = !config.resizable || !configs[index + 1]?.resizable;
|
|
1603
|
+
const position = currentSizes.slice(0, index + 1).reduce((sum, value) => sum + value, 0);
|
|
1604
|
+
const bounds = getPairBounds(currentSizes, configs, index);
|
|
1605
|
+
const separator = /* @__PURE__ */ jsx15(
|
|
1606
|
+
"div",
|
|
1607
|
+
{
|
|
1608
|
+
"aria-controls": `${panelId} ${configs[index + 1]?.element.props.id ?? `${generatedId}-panel-${index + 1}`}`,
|
|
1609
|
+
"aria-disabled": disabled || void 0,
|
|
1610
|
+
"aria-label": `\u8C03\u6574\u7B2C ${index + 1} \u4E0E\u7B2C ${index + 2} \u4E2A\u9762\u677F`,
|
|
1611
|
+
"aria-orientation": direction,
|
|
1612
|
+
"aria-valuemax": Math.round(bounds.max),
|
|
1613
|
+
"aria-valuemin": Math.round(bounds.min),
|
|
1614
|
+
"aria-valuenow": Math.round(position),
|
|
1615
|
+
className: cn(
|
|
1616
|
+
"group relative shrink-0 touch-none bg-border-base outline-none",
|
|
1617
|
+
!disabled && "focus-visible:bg-primary",
|
|
1618
|
+
direction === "horizontal" ? "w-[var(--control-border-width)] cursor-col-resize" : "h-[var(--control-border-width)] cursor-row-resize",
|
|
1619
|
+
disabled && "cursor-default opacity-disabled"
|
|
1620
|
+
),
|
|
1621
|
+
"data-ug-slot": "separator",
|
|
1622
|
+
onDoubleClick: () => toggleCollapsedPanel(index),
|
|
1623
|
+
onKeyDown: (event) => {
|
|
1624
|
+
if (disabled) return;
|
|
1625
|
+
const decrease = direction === "horizontal" ? "ArrowLeft" : "ArrowUp";
|
|
1626
|
+
const increase = direction === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
1627
|
+
if (event.key === decrease || event.key === increase) {
|
|
1628
|
+
event.preventDefault();
|
|
1629
|
+
const next = resizePair(
|
|
1630
|
+
currentSizes,
|
|
1631
|
+
configs,
|
|
1632
|
+
index,
|
|
1633
|
+
currentSizes[index] + (event.key === increase ? keyboardStep : -keyboardStep)
|
|
1634
|
+
);
|
|
1635
|
+
emitSizes(next, index, "change");
|
|
1636
|
+
} else if (event.key === "Home") {
|
|
1637
|
+
event.preventDefault();
|
|
1638
|
+
emitSizes(resizePair(currentSizes, configs, index, config.min), index, "change");
|
|
1639
|
+
} else if (event.key === "End") {
|
|
1640
|
+
event.preventDefault();
|
|
1641
|
+
emitSizes(resizePair(currentSizes, configs, index, config.max), index, "change");
|
|
1642
|
+
} else if (event.key === "Enter") {
|
|
1643
|
+
event.preventDefault();
|
|
1644
|
+
toggleCollapsedPanel(index);
|
|
1645
|
+
}
|
|
1646
|
+
},
|
|
1647
|
+
onLostPointerCapture: () => finishDrag(index),
|
|
1648
|
+
onPointerCancel: () => finishDrag(index),
|
|
1649
|
+
onPointerDown: (event) => {
|
|
1650
|
+
if (disabled || !rootRef.current) return;
|
|
1651
|
+
event.preventDefault();
|
|
1652
|
+
const rect = rootRef.current.getBoundingClientRect();
|
|
1653
|
+
dragRef.current = {
|
|
1654
|
+
pointerId: event.pointerId,
|
|
1655
|
+
separatorIndex: index,
|
|
1656
|
+
pointerStart: direction === "horizontal" ? event.clientX : event.clientY,
|
|
1657
|
+
sizes: [...currentSizes],
|
|
1658
|
+
latestSizes: [...currentSizes]
|
|
1659
|
+
};
|
|
1660
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1661
|
+
onResizeStart?.({ separatorIndex: index, sizes: [...currentSizes] });
|
|
1662
|
+
},
|
|
1663
|
+
onPointerMove: (event) => {
|
|
1664
|
+
const drag = dragRef.current;
|
|
1665
|
+
if (!drag || drag.pointerId !== event.pointerId || drag.separatorIndex !== index || !rootRef.current) return;
|
|
1666
|
+
const rect = rootRef.current.getBoundingClientRect();
|
|
1667
|
+
const total = direction === "horizontal" ? rect.width : rect.height;
|
|
1668
|
+
if (total <= 0) return;
|
|
1669
|
+
const pointer = direction === "horizontal" ? event.clientX : event.clientY;
|
|
1670
|
+
const delta = (pointer - drag.pointerStart) / total * 100;
|
|
1671
|
+
const next = resizePair(drag.sizes, configs, index, drag.sizes[index] + delta);
|
|
1672
|
+
drag.latestSizes = next;
|
|
1673
|
+
if (lazy) {
|
|
1674
|
+
onResize?.({ separatorIndex: index, sizes: normalizeSizes(next, configs.length) });
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
emitSizes(next, index, "resize");
|
|
1678
|
+
},
|
|
1679
|
+
onPointerUp: (event) => {
|
|
1680
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
1681
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
1682
|
+
}
|
|
1683
|
+
finishDrag(index);
|
|
1684
|
+
},
|
|
1685
|
+
role: "separator",
|
|
1686
|
+
tabIndex: disabled ? -1 : 0,
|
|
1687
|
+
children: /* @__PURE__ */ jsx15(
|
|
1688
|
+
"span",
|
|
1689
|
+
{
|
|
1690
|
+
className: cn(
|
|
1691
|
+
"absolute rounded-full bg-border-strong transition-colors duration-150 group-hover:bg-primary",
|
|
1692
|
+
direction === "horizontal" ? "left-1/2 top-1/2 h-[var(--control-height-sm)] w-[calc(var(--control-border-width)*4)] -translate-x-1/2 -translate-y-1/2" : "left-1/2 top-1/2 h-[calc(var(--control-border-width)*4)] w-[var(--control-height-sm)] -translate-x-1/2 -translate-y-1/2"
|
|
1693
|
+
)
|
|
1694
|
+
}
|
|
1695
|
+
)
|
|
1696
|
+
},
|
|
1697
|
+
`${generatedId}-separator-${index}`
|
|
1698
|
+
);
|
|
1699
|
+
return [panel, separator];
|
|
1700
|
+
})
|
|
1701
|
+
}
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
);
|
|
1705
|
+
Splitter.displayName = "Splitter";
|
|
1706
|
+
|
|
1707
|
+
// src/components/icon.tsx
|
|
1708
|
+
import { forwardRef as forwardRef16 } from "react";
|
|
1709
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1710
|
+
var Icon = forwardRef16(
|
|
1711
|
+
({
|
|
1712
|
+
children,
|
|
1713
|
+
className,
|
|
1714
|
+
color,
|
|
1715
|
+
decorative = true,
|
|
1716
|
+
icon: Graphic,
|
|
1717
|
+
size = 16,
|
|
1718
|
+
spin = false,
|
|
1719
|
+
strokeWidth = 2,
|
|
1720
|
+
style,
|
|
1721
|
+
...props
|
|
1722
|
+
}, ref) => /* @__PURE__ */ jsx16(
|
|
1723
|
+
"span",
|
|
1724
|
+
{
|
|
1725
|
+
ref,
|
|
1726
|
+
"aria-hidden": decorative || void 0,
|
|
1727
|
+
className: cn(
|
|
1728
|
+
"inline-flex shrink-0 items-center justify-center text-current [&_svg]:h-[1em] [&_svg]:w-[1em]",
|
|
1729
|
+
spin && "animate-spin motion-reduce:animate-none",
|
|
1730
|
+
className
|
|
1731
|
+
),
|
|
1732
|
+
"data-size": size,
|
|
1733
|
+
"data-state": spin ? "spinning" : "default",
|
|
1734
|
+
"data-ug": "icon",
|
|
1735
|
+
"data-ug-slot": "root",
|
|
1736
|
+
"data-variant": decorative ? "decorative" : "semantic",
|
|
1737
|
+
role: decorative ? void 0 : "img",
|
|
1738
|
+
style: { color, fontSize: size, height: size, width: size, ...style },
|
|
1739
|
+
...props,
|
|
1740
|
+
children: Graphic ? /* @__PURE__ */ jsx16(Graphic, { "aria-hidden": "true", focusable: "false", size, strokeWidth }) : /* @__PURE__ */ jsx16("span", { "aria-hidden": "true", className: "contents", children })
|
|
1741
|
+
}
|
|
1742
|
+
)
|
|
1743
|
+
);
|
|
1744
|
+
Icon.displayName = "Icon";
|
|
1745
|
+
|
|
1746
|
+
export {
|
|
1747
|
+
ButtonGroup,
|
|
1748
|
+
Input,
|
|
1749
|
+
Label,
|
|
1750
|
+
Card,
|
|
1751
|
+
CardHeader,
|
|
1752
|
+
CardTitle,
|
|
1753
|
+
CardDescription,
|
|
1754
|
+
CardContent,
|
|
1755
|
+
CardFooter,
|
|
1756
|
+
badgeVariants,
|
|
1757
|
+
Badge,
|
|
1758
|
+
tagVariants,
|
|
1759
|
+
Tag,
|
|
1760
|
+
Spinner,
|
|
1761
|
+
Separator,
|
|
1762
|
+
Link,
|
|
1763
|
+
Text,
|
|
1764
|
+
Space,
|
|
1765
|
+
Scrollbar,
|
|
1766
|
+
Row,
|
|
1767
|
+
Col,
|
|
1768
|
+
Header,
|
|
1769
|
+
Aside,
|
|
1770
|
+
Main,
|
|
1771
|
+
Footer,
|
|
1772
|
+
Container,
|
|
1773
|
+
SplitterPanel,
|
|
1774
|
+
Splitter,
|
|
1775
|
+
Icon
|
|
1776
|
+
};
|
|
1777
|
+
//# sourceMappingURL=chunk-HGO3GZ56.js.map
|