bj-web-components 0.2.26 → 0.2.28
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/favicon.ico +0 -0
- package/dist/file.svg +1 -0
- package/dist/globe.svg +1 -0
- package/dist/index.d.ts +1141 -0
- package/dist/index.js +51 -0
- package/dist/index.mjs +51 -0
- package/dist/miniapp.d.ts +1 -0
- package/dist/miniapp.js +1 -0
- package/dist/miniapp.mjs +1 -0
- package/dist/mobile.d.ts +1 -0
- package/dist/mobile.js +1 -0
- package/dist/mobile.mjs +1 -0
- package/dist/next.svg +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/dist/shared.d.ts +1 -0
- package/dist/shared.js +1 -0
- package/dist/shared.mjs +1 -0
- package/dist/style.css +3744 -0
- package/dist/vercel.svg +1 -0
- package/dist/web/BasicInput/BInput.js +208 -0
- package/dist/web/BasicInput/BInput.mjs +209 -0
- package/dist/web/BasicInput/utils.js +47 -0
- package/dist/web/BasicInput/utils.mjs +47 -0
- package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -0
- package/dist/web/CategoryDropdown/CategoryDropdown.mjs +308 -0
- package/dist/web/CheckBox/BCheckBox.js +116 -0
- package/dist/web/CheckBox/BCheckBox.mjs +117 -0
- package/dist/web/CheckBox/Group.js +73 -0
- package/dist/web/CheckBox/Group.mjs +74 -0
- package/dist/web/CheckBox/context.js +5 -0
- package/dist/web/CheckBox/context.mjs +5 -0
- package/dist/web/CheckBox/index.js +8 -0
- package/dist/web/CheckBox/index.mjs +8 -0
- package/dist/web/Dropdown/BDropdown.js +186 -0
- package/dist/web/Dropdown/BDropdown.mjs +186 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.mjs +78 -0
- package/dist/web/FileCard/FileCard.js +157 -0
- package/dist/web/FileCard/FileCard.mjs +158 -0
- package/dist/web/Icon/Icon.js +9 -0
- package/dist/web/Icon/Icon.mjs +10 -0
- package/dist/web/Input/Input.js +181 -0
- package/dist/web/Input/Input.mjs +182 -0
- package/dist/web/InputNumber/BInputNumber.js +311 -0
- package/dist/web/InputNumber/BInputNumber.mjs +312 -0
- package/dist/web/InputNumber/StepHandler.js +69 -0
- package/dist/web/InputNumber/StepHandler.mjs +70 -0
- package/dist/web/InputNumber/hooks/useCursor.js +40 -0
- package/dist/web/InputNumber/hooks/useCursor.mjs +41 -0
- package/dist/web/InputNumber/hooks/useFrame.js +12 -0
- package/dist/web/InputNumber/hooks/useFrame.mjs +13 -0
- package/dist/web/InputNumber/utils/decimal.js +147 -0
- package/dist/web/InputNumber/utils/decimal.mjs +147 -0
- package/dist/web/Modal/Modal.js +84 -0
- package/dist/web/Modal/Modal.mjs +85 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +233 -0
- package/dist/web/Pagination/Pagination.js +328 -0
- package/dist/web/Pagination/Pagination.mjs +329 -0
- package/dist/web/ProductField/ProductField.js +272 -0
- package/dist/web/ProductField/ProductField.mjs +273 -0
- package/dist/web/ProductField/arrow-up.svg.js +3 -0
- package/dist/web/ProductField/arrow-up.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-no.svg.js +3 -0
- package/dist/web/ProductField/checkbox-no.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-ok.svg.js +3 -0
- package/dist/web/ProductField/checkbox-ok.svg.mjs +4 -0
- package/dist/web/ProductField/no_data_light.svg.js +3 -0
- package/dist/web/ProductField/no_data_light.svg.mjs +4 -0
- package/dist/web/ProductField/search.svg.js +3 -0
- package/dist/web/ProductField/search.svg.mjs +4 -0
- package/dist/web/ProductField/sort.svg.js +3 -0
- package/dist/web/ProductField/sort.svg.mjs +4 -0
- package/dist/web/SkuInputCard/SkuInputCard.js +276 -0
- package/dist/web/SkuInputCard/SkuInputCard.mjs +277 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +4 -0
- package/dist/web/Switch/Switch.js +70 -0
- package/dist/web/Switch/Switch.mjs +71 -0
- package/dist/web/Table/BTable.js +950 -0
- package/dist/web/Table/BTable.mjs +950 -0
- package/dist/web/Table/Column.js +5 -0
- package/dist/web/Table/Column.mjs +6 -0
- package/dist/web/Table/ColumnGroup.js +5 -0
- package/dist/web/Table/ColumnGroup.mjs +6 -0
- package/dist/web/Table/utils/columns.js +48 -0
- package/dist/web/Table/utils/columns.mjs +48 -0
- package/dist/web/Table/utils/sortFilter.js +84 -0
- package/dist/web/Table/utils/sortFilter.mjs +84 -0
- package/dist/web/Tabs/BTabs.js +150 -0
- package/dist/web/Tabs/BTabs.mjs +150 -0
- package/dist/web/Tabs/TabPane.js +8 -0
- package/dist/web/Tabs/TabPane.mjs +8 -0
- package/dist/web/Tooltip/ConfirmTooltip.js +26 -0
- package/dist/web/Tooltip/ConfirmTooltip.mjs +27 -0
- package/dist/web/Tooltip/ContentTooltip.js +94 -0
- package/dist/web/Tooltip/ContentTooltip.mjs +95 -0
- package/dist/web/Tooltip/ProgressTooltip.js +36 -0
- package/dist/web/Tooltip/ProgressTooltip.mjs +37 -0
- package/dist/web/Tooltip/TooltipWrapper.js +12 -0
- package/dist/web/Tooltip/TooltipWrapper.mjs +13 -0
- package/dist/web/Tooltip/useAutoPlacement.js +41 -0
- package/dist/web/Tooltip/useAutoPlacement.mjs +41 -0
- package/dist/web.d.ts +1141 -0
- package/dist/web.js +51 -0
- package/dist/web.mjs +51 -0
- package/package.json +1 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import BInput from "../BasicInput/BInput.mjs";
|
|
5
|
+
import { BCheckBox as CompoundBCheckBox } from "../CheckBox/index.mjs";
|
|
6
|
+
import BuIcon from "../Icon/Icon.mjs";
|
|
7
|
+
import BOverlayScrollbar from "../OverlayScrollbar/BOverlayScrollbar.mjs";
|
|
8
|
+
/* empty css */
|
|
9
|
+
import BTooltip from "../Tooltip/ContentTooltip.mjs";
|
|
10
|
+
import "../Tooltip/TooltipWrapper.mjs";
|
|
11
|
+
import defaultEmptyImage from "../ProductField/no_data_light.svg.mjs";
|
|
12
|
+
/* empty css */
|
|
13
|
+
function classNames(...values) {
|
|
14
|
+
return values.filter(Boolean).join(" ");
|
|
15
|
+
}
|
|
16
|
+
function getOptionText(option) {
|
|
17
|
+
return typeof option.label === "string" || typeof option.label === "number" ? String(option.label) : String(option.value);
|
|
18
|
+
}
|
|
19
|
+
function TruncatedOptionLabel({ option }) {
|
|
20
|
+
const labelRef = useRef(null);
|
|
21
|
+
const [visible, setVisible] = useState(false);
|
|
22
|
+
const [anchorRect, setAnchorRect] = useState(null);
|
|
23
|
+
const isTextLabel = typeof option.label === "string" || typeof option.label === "number";
|
|
24
|
+
const label = isTextLabel ? String(option.label) : option.label;
|
|
25
|
+
function handleMouseEnter() {
|
|
26
|
+
const element = labelRef.current;
|
|
27
|
+
if (isTextLabel && element && element.scrollWidth > element.clientWidth) {
|
|
28
|
+
setAnchorRect(element.getBoundingClientRect());
|
|
29
|
+
setVisible(true);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return /* @__PURE__ */ jsxs(
|
|
33
|
+
"span",
|
|
34
|
+
{
|
|
35
|
+
ref: labelRef,
|
|
36
|
+
className: "bj-dropdown__option-label",
|
|
37
|
+
onMouseEnter: handleMouseEnter,
|
|
38
|
+
onMouseLeave: () => setVisible(false),
|
|
39
|
+
children: [
|
|
40
|
+
label,
|
|
41
|
+
visible && anchorRect && typeof document !== "undefined" && createPortal(
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
"span",
|
|
44
|
+
{
|
|
45
|
+
className: "bj-dropdown__option-tooltip-anchor",
|
|
46
|
+
style: {
|
|
47
|
+
position: "fixed",
|
|
48
|
+
top: anchorRect.top,
|
|
49
|
+
left: anchorRect.left,
|
|
50
|
+
width: anchorRect.width,
|
|
51
|
+
height: anchorRect.height
|
|
52
|
+
},
|
|
53
|
+
children: /* @__PURE__ */ jsx(BTooltip, { className: "bj-dropdown__option-tooltip", content: label, placement: "top" })
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
document.body
|
|
57
|
+
)
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
function DefaultOptionContent({ option, doubleLine }) {
|
|
63
|
+
if (!doubleLine) return /* @__PURE__ */ jsx(TruncatedOptionLabel, { option });
|
|
64
|
+
return /* @__PURE__ */ jsxs("span", { className: "bj-dropdown__option-content", children: [
|
|
65
|
+
/* @__PURE__ */ jsx(TruncatedOptionLabel, { option }),
|
|
66
|
+
option.description !== void 0 && /* @__PURE__ */ jsx("span", { className: "bj-dropdown__option-description", children: option.description })
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
function BDropdown({
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
72
|
+
options,
|
|
73
|
+
value,
|
|
74
|
+
defaultValue = [],
|
|
75
|
+
multiple = false,
|
|
76
|
+
optionMode = "single-line",
|
|
77
|
+
searchable = false,
|
|
78
|
+
searchValue,
|
|
79
|
+
searchPlaceholder = "搜索",
|
|
80
|
+
onSearch,
|
|
81
|
+
filterOption = true,
|
|
82
|
+
emptyText,
|
|
83
|
+
labels,
|
|
84
|
+
t = (text) => text,
|
|
85
|
+
optionRender,
|
|
86
|
+
onChange,
|
|
87
|
+
footer = true,
|
|
88
|
+
showReset = true,
|
|
89
|
+
showConfirm = true,
|
|
90
|
+
resetText = t("重置"),
|
|
91
|
+
confirmText = t("确定"),
|
|
92
|
+
onReset,
|
|
93
|
+
onConfirm
|
|
94
|
+
}) {
|
|
95
|
+
const dropdownRef = useRef(null);
|
|
96
|
+
const optionsRef = useRef(null);
|
|
97
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
98
|
+
const [internalSearchValue, setInternalSearchValue] = useState("");
|
|
99
|
+
const selectedValue = value ?? internalValue;
|
|
100
|
+
const isMultiple = multiple === true;
|
|
101
|
+
const isDoubleLine = optionMode === "double-line";
|
|
102
|
+
const currentSearchValue = searchValue ?? internalSearchValue;
|
|
103
|
+
const resolvedEmptyText = emptyText ?? (labels == null ? void 0 : labels.emptyText) ?? t("暂无结果");
|
|
104
|
+
const visibleOptions = !onSearch && filterOption !== false && currentSearchValue ? options.filter((option) => typeof filterOption === "function" ? filterOption(currentSearchValue, option) : getOptionText(option).toLocaleLowerCase().includes(currentSearchValue.toLocaleLowerCase())) : options;
|
|
105
|
+
function updateValue(nextValue, option) {
|
|
106
|
+
if (value === void 0) {
|
|
107
|
+
setInternalValue(nextValue);
|
|
108
|
+
}
|
|
109
|
+
onChange == null ? void 0 : onChange(nextValue, option);
|
|
110
|
+
}
|
|
111
|
+
function handleSearch(nextSearchValue) {
|
|
112
|
+
if (searchValue === void 0) {
|
|
113
|
+
setInternalSearchValue(nextSearchValue);
|
|
114
|
+
}
|
|
115
|
+
onSearch == null ? void 0 : onSearch(nextSearchValue);
|
|
116
|
+
}
|
|
117
|
+
function handleOptionChange(option) {
|
|
118
|
+
if (option.disabled) return;
|
|
119
|
+
const nextValue = isMultiple ? selectedValue.includes(option.value) ? selectedValue.filter((item) => item !== option.value) : [...selectedValue, option.value] : [option.value];
|
|
120
|
+
updateValue(nextValue, option);
|
|
121
|
+
}
|
|
122
|
+
function handleReset() {
|
|
123
|
+
if (value === void 0) {
|
|
124
|
+
setInternalValue([]);
|
|
125
|
+
}
|
|
126
|
+
onReset == null ? void 0 : onReset();
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ jsxs("div", { ref: dropdownRef, className: classNames("bj-dropdown", isDoubleLine && "bj-dropdown--double-line", !isMultiple && "bj-dropdown--single", className), role: "dialog", style, children: [
|
|
129
|
+
searchable && /* @__PURE__ */ jsx("div", { className: "bj-dropdown__search", children: /* @__PURE__ */ jsx(
|
|
130
|
+
BInput,
|
|
131
|
+
{
|
|
132
|
+
"aria-label": "搜索选项",
|
|
133
|
+
allowClear: { clearIcon: /* @__PURE__ */ jsx(BuIcon, { className: "bj-dropdown__search-clear-icon", type: "icon-a-guanbixi" }) },
|
|
134
|
+
onChange: (event) => handleSearch(event.target.value),
|
|
135
|
+
onClear: () => handleSearch(""),
|
|
136
|
+
placeholder: searchPlaceholder,
|
|
137
|
+
prefix: /* @__PURE__ */ jsx(BuIcon, { type: "icon-a-sousuoxi" }),
|
|
138
|
+
inputMode: "search",
|
|
139
|
+
role: "searchbox",
|
|
140
|
+
type: "text",
|
|
141
|
+
value: currentSearchValue
|
|
142
|
+
}
|
|
143
|
+
) }),
|
|
144
|
+
/* @__PURE__ */ jsxs("div", { ref: optionsRef, className: classNames("bj-dropdown__options", "bj-overlay-scrollbar-hidden", visibleOptions.length === 0 && "bj-dropdown__options--empty", !isMultiple && "bj-dropdown__options--single"), children: [
|
|
145
|
+
visibleOptions.map((option) => isMultiple ? /* @__PURE__ */ jsx(
|
|
146
|
+
CompoundBCheckBox,
|
|
147
|
+
{
|
|
148
|
+
checked: selectedValue.includes(option.value),
|
|
149
|
+
className: classNames("bj-dropdown__option", isDoubleLine && option.description !== void 0 && "bj-dropdown__option--double-line"),
|
|
150
|
+
disabled: option.disabled,
|
|
151
|
+
onChange: () => handleOptionChange(option),
|
|
152
|
+
skipGroup: true,
|
|
153
|
+
variant: "white",
|
|
154
|
+
children: optionRender ? optionRender(option) : /* @__PURE__ */ jsx(DefaultOptionContent, { doubleLine: isDoubleLine && option.description !== void 0, option })
|
|
155
|
+
},
|
|
156
|
+
String(option.value)
|
|
157
|
+
) : /* @__PURE__ */ jsxs(
|
|
158
|
+
"button",
|
|
159
|
+
{
|
|
160
|
+
"aria-pressed": selectedValue.includes(option.value),
|
|
161
|
+
className: classNames("bj-dropdown__option", "bj-dropdown__option--single", isDoubleLine && option.description !== void 0 && "bj-dropdown__option--double-line", selectedValue.includes(option.value) && "bj-dropdown__option--selected"),
|
|
162
|
+
disabled: option.disabled,
|
|
163
|
+
onClick: () => handleOptionChange(option),
|
|
164
|
+
type: "button",
|
|
165
|
+
children: [
|
|
166
|
+
optionRender ? /* @__PURE__ */ jsx("span", { className: "bj-dropdown__option-label", children: optionRender(option) }) : /* @__PURE__ */ jsx(DefaultOptionContent, { doubleLine: isDoubleLine && option.description !== void 0, option }),
|
|
167
|
+
selectedValue.includes(option.value) && /* @__PURE__ */ jsx(BuIcon, { className: "bj-dropdown__option-icon", type: "icon-a-dagouxi" })
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
String(option.value)
|
|
171
|
+
)),
|
|
172
|
+
visibleOptions.length === 0 && /* @__PURE__ */ jsxs("div", { className: "bj-dropdown__empty", children: [
|
|
173
|
+
/* @__PURE__ */ jsx("img", { alt: "", className: "bj-dropdown__empty-image", src: defaultEmptyImage }),
|
|
174
|
+
/* @__PURE__ */ jsx("span", { className: "bj-dropdown__empty-text", children: resolvedEmptyText })
|
|
175
|
+
] })
|
|
176
|
+
] }),
|
|
177
|
+
/* @__PURE__ */ jsx(BOverlayScrollbar, { containerRef: dropdownRef, gap: 2, size: 2, targetRef: optionsRef }),
|
|
178
|
+
footer !== false && (footer !== true ? footer : /* @__PURE__ */ jsxs("div", { className: classNames("bj-dropdown__actions", !isMultiple && "bj-dropdown__actions--single"), children: [
|
|
179
|
+
showReset && /* @__PURE__ */ jsx("button", { onClick: handleReset, type: "button", children: resetText }),
|
|
180
|
+
isMultiple && showConfirm && /* @__PURE__ */ jsx("button", { onClick: () => onConfirm == null ? void 0 : onConfirm(selectedValue), type: "button", children: confirmText })
|
|
181
|
+
] }))
|
|
182
|
+
] });
|
|
183
|
+
}
|
|
184
|
+
export {
|
|
185
|
+
BDropdown
|
|
186
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
;/* empty css */
|
|
5
|
+
function DeleteIcon() {
|
|
6
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14.1667 5.3335C15.1792 5.3335 16 6.15431 16 7.16683V8.00016H19C19.2761 8.00016 19.5 8.22402 19.5 8.50016C19.5 8.7763 19.2761 9.00016 19 9.00016H17.3333V16.8335C17.3333 17.846 16.5125 18.6668 15.5 18.6668H8.5C7.48748 18.6668 6.66667 17.846 6.66667 16.8335V9.00016H5C4.72386 9.00016 4.5 8.7763 4.5 8.50016C4.5 8.22402 4.72386 8.00016 5 8.00016H8V7.16683C8 6.15431 8.82081 5.3335 9.83333 5.3335H14.1667ZM7.66667 16.8335C7.66667 17.2937 8.03976 17.6668 8.5 17.6668H15.5C15.9602 17.6668 16.3333 17.2937 16.3333 16.8335V9.00016H7.66667V16.8335ZM10.5 11.3335C10.7761 11.3335 11 11.5574 11 11.8335V15.0002C11 15.2763 10.7761 15.5002 10.5 15.5002C10.2239 15.5002 10 15.2763 10 15.0002V11.8335C10 11.5574 10.2239 11.3335 10.5 11.3335ZM13.5 11.3335C13.7761 11.3335 14 11.5574 14 11.8335V15.0002C14 15.2763 13.7761 15.5002 13.5 15.5002C13.2239 15.5002 13 15.2763 13 15.0002V11.8335C13 11.5574 13.2239 11.3335 13.5 11.3335ZM9.83333 6.3335C9.3731 6.3335 9 6.70659 9 7.16683V8.00016H15V7.16683C15 6.70659 14.6269 6.3335 14.1667 6.3335H9.83333Z", fill: "currentColor" }) });
|
|
7
|
+
}
|
|
8
|
+
const BuEmptyInputBox = react.forwardRef(
|
|
9
|
+
function BuEmptyInputBox2({
|
|
10
|
+
mode = "single",
|
|
11
|
+
activeLang = "zh",
|
|
12
|
+
onLangChange,
|
|
13
|
+
value = "",
|
|
14
|
+
onChange,
|
|
15
|
+
placeholder,
|
|
16
|
+
maxLength,
|
|
17
|
+
error = false,
|
|
18
|
+
disabled,
|
|
19
|
+
onDelete,
|
|
20
|
+
labels,
|
|
21
|
+
id,
|
|
22
|
+
className,
|
|
23
|
+
style
|
|
24
|
+
}, ref) {
|
|
25
|
+
const zhLabel = (labels == null ? void 0 : labels.zh) ?? "中文";
|
|
26
|
+
const enLabel = (labels == null ? void 0 : labels.en) ?? "EN";
|
|
27
|
+
const hasBilingual = mode === "bilingual";
|
|
28
|
+
const hasDelete = !!onDelete;
|
|
29
|
+
const boxCls = [
|
|
30
|
+
"bu-eib__box",
|
|
31
|
+
hasBilingual && hasDelete && "bu-eib__box--actions-both",
|
|
32
|
+
hasBilingual && !hasDelete && "bu-eib__box--actions-toggle",
|
|
33
|
+
!hasBilingual && hasDelete && "bu-eib__box--actions-delete",
|
|
34
|
+
error && "bu-eib__box--error",
|
|
35
|
+
disabled && "bu-eib__box--disabled"
|
|
36
|
+
].filter(Boolean).join(" ");
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["bu-eib", className].filter(Boolean).join(" "), style, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: boxCls, children: [
|
|
38
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39
|
+
"input",
|
|
40
|
+
{
|
|
41
|
+
ref,
|
|
42
|
+
id,
|
|
43
|
+
className: "bu-eib__field",
|
|
44
|
+
value,
|
|
45
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
46
|
+
placeholder,
|
|
47
|
+
maxLength,
|
|
48
|
+
disabled
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
(hasBilingual || hasDelete) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bu-eib__actions", children: [
|
|
52
|
+
hasBilingual && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bu-eib__lang-toggle", children: [
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
className: `bu-eib__lang-btn${activeLang === "zh" ? " bu-eib__lang-btn--active" : ""}`,
|
|
58
|
+
onClick: () => onLangChange == null ? void 0 : onLangChange("zh"),
|
|
59
|
+
children: zhLabel
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
63
|
+
"button",
|
|
64
|
+
{
|
|
65
|
+
type: "button",
|
|
66
|
+
className: `bu-eib__lang-btn${activeLang === "en" ? " bu-eib__lang-btn--active" : ""}`,
|
|
67
|
+
onClick: () => onLangChange == null ? void 0 : onLangChange("en"),
|
|
68
|
+
children: enLabel
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] }),
|
|
72
|
+
hasDelete && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "bu-eib__delete", onClick: onDelete, children: /* @__PURE__ */ jsxRuntime.jsx(DeleteIcon, {}) })
|
|
73
|
+
] })
|
|
74
|
+
] }) });
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
module.exports = BuEmptyInputBox;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
/* empty css */
|
|
4
|
+
function DeleteIcon() {
|
|
5
|
+
return /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M14.1667 5.3335C15.1792 5.3335 16 6.15431 16 7.16683V8.00016H19C19.2761 8.00016 19.5 8.22402 19.5 8.50016C19.5 8.7763 19.2761 9.00016 19 9.00016H17.3333V16.8335C17.3333 17.846 16.5125 18.6668 15.5 18.6668H8.5C7.48748 18.6668 6.66667 17.846 6.66667 16.8335V9.00016H5C4.72386 9.00016 4.5 8.7763 4.5 8.50016C4.5 8.22402 4.72386 8.00016 5 8.00016H8V7.16683C8 6.15431 8.82081 5.3335 9.83333 5.3335H14.1667ZM7.66667 16.8335C7.66667 17.2937 8.03976 17.6668 8.5 17.6668H15.5C15.9602 17.6668 16.3333 17.2937 16.3333 16.8335V9.00016H7.66667V16.8335ZM10.5 11.3335C10.7761 11.3335 11 11.5574 11 11.8335V15.0002C11 15.2763 10.7761 15.5002 10.5 15.5002C10.2239 15.5002 10 15.2763 10 15.0002V11.8335C10 11.5574 10.2239 11.3335 10.5 11.3335ZM13.5 11.3335C13.7761 11.3335 14 11.5574 14 11.8335V15.0002C14 15.2763 13.7761 15.5002 13.5 15.5002C13.2239 15.5002 13 15.2763 13 15.0002V11.8335C13 11.5574 13.2239 11.3335 13.5 11.3335ZM9.83333 6.3335C9.3731 6.3335 9 6.70659 9 7.16683V8.00016H15V7.16683C15 6.70659 14.6269 6.3335 14.1667 6.3335H9.83333Z", fill: "currentColor" }) });
|
|
6
|
+
}
|
|
7
|
+
const BuEmptyInputBox = forwardRef(
|
|
8
|
+
function BuEmptyInputBox2({
|
|
9
|
+
mode = "single",
|
|
10
|
+
activeLang = "zh",
|
|
11
|
+
onLangChange,
|
|
12
|
+
value = "",
|
|
13
|
+
onChange,
|
|
14
|
+
placeholder,
|
|
15
|
+
maxLength,
|
|
16
|
+
error = false,
|
|
17
|
+
disabled,
|
|
18
|
+
onDelete,
|
|
19
|
+
labels,
|
|
20
|
+
id,
|
|
21
|
+
className,
|
|
22
|
+
style
|
|
23
|
+
}, ref) {
|
|
24
|
+
const zhLabel = (labels == null ? void 0 : labels.zh) ?? "中文";
|
|
25
|
+
const enLabel = (labels == null ? void 0 : labels.en) ?? "EN";
|
|
26
|
+
const hasBilingual = mode === "bilingual";
|
|
27
|
+
const hasDelete = !!onDelete;
|
|
28
|
+
const boxCls = [
|
|
29
|
+
"bu-eib__box",
|
|
30
|
+
hasBilingual && hasDelete && "bu-eib__box--actions-both",
|
|
31
|
+
hasBilingual && !hasDelete && "bu-eib__box--actions-toggle",
|
|
32
|
+
!hasBilingual && hasDelete && "bu-eib__box--actions-delete",
|
|
33
|
+
error && "bu-eib__box--error",
|
|
34
|
+
disabled && "bu-eib__box--disabled"
|
|
35
|
+
].filter(Boolean).join(" ");
|
|
36
|
+
return /* @__PURE__ */ jsx("div", { className: ["bu-eib", className].filter(Boolean).join(" "), style, children: /* @__PURE__ */ jsxs("div", { className: boxCls, children: [
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
"input",
|
|
39
|
+
{
|
|
40
|
+
ref,
|
|
41
|
+
id,
|
|
42
|
+
className: "bu-eib__field",
|
|
43
|
+
value,
|
|
44
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
45
|
+
placeholder,
|
|
46
|
+
maxLength,
|
|
47
|
+
disabled
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
(hasBilingual || hasDelete) && /* @__PURE__ */ jsxs("div", { className: "bu-eib__actions", children: [
|
|
51
|
+
hasBilingual && /* @__PURE__ */ jsxs("div", { className: "bu-eib__lang-toggle", children: [
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
"button",
|
|
54
|
+
{
|
|
55
|
+
type: "button",
|
|
56
|
+
className: `bu-eib__lang-btn${activeLang === "zh" ? " bu-eib__lang-btn--active" : ""}`,
|
|
57
|
+
onClick: () => onLangChange == null ? void 0 : onLangChange("zh"),
|
|
58
|
+
children: zhLabel
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
"button",
|
|
63
|
+
{
|
|
64
|
+
type: "button",
|
|
65
|
+
className: `bu-eib__lang-btn${activeLang === "en" ? " bu-eib__lang-btn--active" : ""}`,
|
|
66
|
+
onClick: () => onLangChange == null ? void 0 : onLangChange("en"),
|
|
67
|
+
children: enLabel
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] }),
|
|
71
|
+
hasDelete && /* @__PURE__ */ jsx("button", { type: "button", className: "bu-eib__delete", onClick: onDelete, children: /* @__PURE__ */ jsx(DeleteIcon, {}) })
|
|
72
|
+
] })
|
|
73
|
+
] }) });
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
export {
|
|
77
|
+
BuEmptyInputBox as default
|
|
78
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
;/* empty css */
|
|
5
|
+
const FILE_TYPE_CONFIG = {
|
|
6
|
+
pdf: { color: "#F54A45", label: "PDF" },
|
|
7
|
+
image: { color: "#00AAFF", label: "IMG" },
|
|
8
|
+
doc: { color: "#3B64FC", label: "DOC" },
|
|
9
|
+
docx: { color: "#3B64FC", label: "DOC" },
|
|
10
|
+
xls: { color: "#1D9B4C", label: "XLS" },
|
|
11
|
+
xlsx: { color: "#1D9B4C", label: "XLS" },
|
|
12
|
+
ppt: { color: "#DF4023", label: "PPT" },
|
|
13
|
+
pptx: { color: "#DF4023", label: "PPT" },
|
|
14
|
+
zip: { color: "#7B5EA7", label: "ZIP" },
|
|
15
|
+
rar: { color: "#7B5EA7", label: "RAR" },
|
|
16
|
+
txt: { color: "#8C8C8C", label: "TXT" },
|
|
17
|
+
other: { color: "#1677FF", label: "FILE" }
|
|
18
|
+
};
|
|
19
|
+
function FileIcon({ fileType, fileUrl, fileName }) {
|
|
20
|
+
if (fileType === "image" && fileUrl) {
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx("img", { src: fileUrl, alt: fileName, className: "file-card__image-thumb" });
|
|
22
|
+
}
|
|
23
|
+
const { color, label } = FILE_TYPE_CONFIG[fileType];
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "88", height: "88", viewBox: "0 0 88 88", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "14", y: "8", width: "50", height: "62", rx: "4", fill: "#F5F5F5" }),
|
|
26
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M50 8L64 22H50V8Z", fill: "#E2E2E2" }),
|
|
27
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "20", y: "30", width: "30", height: "4", rx: "2", fill: "#E2E2E2" }),
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "20", y: "40", width: "30", height: "4", rx: "2", fill: "#E2E2E2" }),
|
|
29
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "20", y: "50", width: "20", height: "4", rx: "2", fill: "#E2E2E2" }),
|
|
30
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "42", y: "52", width: "32", height: "28", rx: "4", fill: color }),
|
|
31
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "42", y: "52", width: "4", height: "28", rx: "2", fill: "rgba(255,255,255,0.25)" }),
|
|
32
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "42", y: "76", width: "32", height: "4", rx: "2", fill: "rgba(0,0,0,0.15)" }),
|
|
33
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
"text",
|
|
35
|
+
{
|
|
36
|
+
x: "58",
|
|
37
|
+
y: "71",
|
|
38
|
+
textAnchor: "middle",
|
|
39
|
+
fill: "white",
|
|
40
|
+
fontSize: "9",
|
|
41
|
+
fontWeight: "700",
|
|
42
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
43
|
+
letterSpacing: "0.3",
|
|
44
|
+
children: label
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
function IconEye() {
|
|
50
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "3", stroke: "currentColor", strokeWidth: "2" })
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
function IconTrash() {
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [
|
|
57
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "3,6 5,6 21,6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 11v6M14 11v6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
function NameRow({ fileName, onRename }) {
|
|
64
|
+
const [editing, setEditing] = react.useState(false);
|
|
65
|
+
const [editValue, setEditValue] = react.useState(fileName);
|
|
66
|
+
const inputRef = react.useRef(null);
|
|
67
|
+
react.useEffect(() => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (editing) {
|
|
70
|
+
setEditValue(fileName);
|
|
71
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
72
|
+
(_b = inputRef.current) == null ? void 0 : _b.select();
|
|
73
|
+
}
|
|
74
|
+
}, [editing, fileName]);
|
|
75
|
+
const handleConfirm = async () => {
|
|
76
|
+
const trimmed = editValue.trim();
|
|
77
|
+
if (trimmed && trimmed !== fileName) {
|
|
78
|
+
await (onRename == null ? void 0 : onRename(trimmed));
|
|
79
|
+
}
|
|
80
|
+
setEditing(false);
|
|
81
|
+
};
|
|
82
|
+
const handleCancel = () => setEditing(false);
|
|
83
|
+
const handleKeyDown = (e) => {
|
|
84
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
handleConfirm();
|
|
87
|
+
}
|
|
88
|
+
if (e.key === "Escape") handleCancel();
|
|
89
|
+
};
|
|
90
|
+
const handleBlur = () => {
|
|
91
|
+
handleConfirm();
|
|
92
|
+
};
|
|
93
|
+
const handleDoubleClick = () => {
|
|
94
|
+
if (onRename) {
|
|
95
|
+
setEditing(true);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
if (editing) {
|
|
99
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "file-card__name-area file-card__name-area--editing", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
100
|
+
"textarea",
|
|
101
|
+
{
|
|
102
|
+
ref: inputRef,
|
|
103
|
+
className: "file-card__edit-input",
|
|
104
|
+
value: editValue,
|
|
105
|
+
onChange: (e) => setEditValue(e.target.value),
|
|
106
|
+
onKeyDown: handleKeyDown,
|
|
107
|
+
onBlur: handleBlur,
|
|
108
|
+
rows: 2,
|
|
109
|
+
style: { height: "42px" }
|
|
110
|
+
}
|
|
111
|
+
) });
|
|
112
|
+
}
|
|
113
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "file-card__name-area", onDoubleClick: handleDoubleClick, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "file-card__filename", title: fileName, children: fileName }) });
|
|
114
|
+
}
|
|
115
|
+
function PdfCard({ fileName, onDelete, onRename, onPreview, className, style }) {
|
|
116
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `file-card file-card--pdf ${className || ""}`, style, children: [
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "file-card__pdf-preview", onClick: onPreview, children: [
|
|
118
|
+
(onPreview || onDelete) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "file-card__overlay", children: [
|
|
119
|
+
onPreview && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
120
|
+
e.stopPropagation();
|
|
121
|
+
onPreview();
|
|
122
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(IconEye, {}) }),
|
|
123
|
+
onDelete && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
onDelete();
|
|
126
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(IconTrash, {}) })
|
|
127
|
+
] }),
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "file-card__pdf-label", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "PDF" }) })
|
|
129
|
+
] }),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx(NameRow, { fileName, onRename })
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
function OtherCard({ fileName, fileType, fileUrl, onDelete, onRename, onPreview, className, style }) {
|
|
134
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `file-card file-card--other ${className || ""}`, style, children: [
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "file-card__other-preview", onClick: onPreview, children: [
|
|
136
|
+
(onPreview || onDelete) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "file-card__overlay", children: [
|
|
137
|
+
onPreview && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
onPreview();
|
|
140
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(IconEye, {}) }),
|
|
141
|
+
onDelete && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
onDelete();
|
|
144
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(IconTrash, {}) })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx(FileIcon, { fileType, fileUrl, fileName })
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx(NameRow, { fileName, onRename })
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
function FileCard(props) {
|
|
152
|
+
if (props.fileType === "pdf") {
|
|
153
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PdfCard, { ...props });
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OtherCard, { ...props });
|
|
156
|
+
}
|
|
157
|
+
module.exports = FileCard;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
/* empty css */
|
|
4
|
+
const FILE_TYPE_CONFIG = {
|
|
5
|
+
pdf: { color: "#F54A45", label: "PDF" },
|
|
6
|
+
image: { color: "#00AAFF", label: "IMG" },
|
|
7
|
+
doc: { color: "#3B64FC", label: "DOC" },
|
|
8
|
+
docx: { color: "#3B64FC", label: "DOC" },
|
|
9
|
+
xls: { color: "#1D9B4C", label: "XLS" },
|
|
10
|
+
xlsx: { color: "#1D9B4C", label: "XLS" },
|
|
11
|
+
ppt: { color: "#DF4023", label: "PPT" },
|
|
12
|
+
pptx: { color: "#DF4023", label: "PPT" },
|
|
13
|
+
zip: { color: "#7B5EA7", label: "ZIP" },
|
|
14
|
+
rar: { color: "#7B5EA7", label: "RAR" },
|
|
15
|
+
txt: { color: "#8C8C8C", label: "TXT" },
|
|
16
|
+
other: { color: "#1677FF", label: "FILE" }
|
|
17
|
+
};
|
|
18
|
+
function FileIcon({ fileType, fileUrl, fileName }) {
|
|
19
|
+
if (fileType === "image" && fileUrl) {
|
|
20
|
+
return /* @__PURE__ */ jsx("img", { src: fileUrl, alt: fileName, className: "file-card__image-thumb" });
|
|
21
|
+
}
|
|
22
|
+
const { color, label } = FILE_TYPE_CONFIG[fileType];
|
|
23
|
+
return /* @__PURE__ */ jsxs("svg", { width: "88", height: "88", viewBox: "0 0 88 88", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("rect", { x: "14", y: "8", width: "50", height: "62", rx: "4", fill: "#F5F5F5" }),
|
|
25
|
+
/* @__PURE__ */ jsx("path", { d: "M50 8L64 22H50V8Z", fill: "#E2E2E2" }),
|
|
26
|
+
/* @__PURE__ */ jsx("rect", { x: "20", y: "30", width: "30", height: "4", rx: "2", fill: "#E2E2E2" }),
|
|
27
|
+
/* @__PURE__ */ jsx("rect", { x: "20", y: "40", width: "30", height: "4", rx: "2", fill: "#E2E2E2" }),
|
|
28
|
+
/* @__PURE__ */ jsx("rect", { x: "20", y: "50", width: "20", height: "4", rx: "2", fill: "#E2E2E2" }),
|
|
29
|
+
/* @__PURE__ */ jsx("rect", { x: "42", y: "52", width: "32", height: "28", rx: "4", fill: color }),
|
|
30
|
+
/* @__PURE__ */ jsx("rect", { x: "42", y: "52", width: "4", height: "28", rx: "2", fill: "rgba(255,255,255,0.25)" }),
|
|
31
|
+
/* @__PURE__ */ jsx("rect", { x: "42", y: "76", width: "32", height: "4", rx: "2", fill: "rgba(0,0,0,0.15)" }),
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
"text",
|
|
34
|
+
{
|
|
35
|
+
x: "58",
|
|
36
|
+
y: "71",
|
|
37
|
+
textAnchor: "middle",
|
|
38
|
+
fill: "white",
|
|
39
|
+
fontSize: "9",
|
|
40
|
+
fontWeight: "700",
|
|
41
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
42
|
+
letterSpacing: "0.3",
|
|
43
|
+
children: label
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] });
|
|
47
|
+
}
|
|
48
|
+
function IconEye() {
|
|
49
|
+
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [
|
|
50
|
+
/* @__PURE__ */ jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
51
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3", stroke: "currentColor", strokeWidth: "2" })
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
function IconTrash() {
|
|
55
|
+
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: [
|
|
56
|
+
/* @__PURE__ */ jsx("polyline", { points: "3,6 5,6 21,6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
57
|
+
/* @__PURE__ */ jsx("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
58
|
+
/* @__PURE__ */ jsx("path", { d: "M10 11v6M14 11v6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
59
|
+
/* @__PURE__ */ jsx("path", { d: "M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
60
|
+
] });
|
|
61
|
+
}
|
|
62
|
+
function NameRow({ fileName, onRename }) {
|
|
63
|
+
const [editing, setEditing] = useState(false);
|
|
64
|
+
const [editValue, setEditValue] = useState(fileName);
|
|
65
|
+
const inputRef = useRef(null);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
if (editing) {
|
|
69
|
+
setEditValue(fileName);
|
|
70
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
71
|
+
(_b = inputRef.current) == null ? void 0 : _b.select();
|
|
72
|
+
}
|
|
73
|
+
}, [editing, fileName]);
|
|
74
|
+
const handleConfirm = async () => {
|
|
75
|
+
const trimmed = editValue.trim();
|
|
76
|
+
if (trimmed && trimmed !== fileName) {
|
|
77
|
+
await (onRename == null ? void 0 : onRename(trimmed));
|
|
78
|
+
}
|
|
79
|
+
setEditing(false);
|
|
80
|
+
};
|
|
81
|
+
const handleCancel = () => setEditing(false);
|
|
82
|
+
const handleKeyDown = (e) => {
|
|
83
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
handleConfirm();
|
|
86
|
+
}
|
|
87
|
+
if (e.key === "Escape") handleCancel();
|
|
88
|
+
};
|
|
89
|
+
const handleBlur = () => {
|
|
90
|
+
handleConfirm();
|
|
91
|
+
};
|
|
92
|
+
const handleDoubleClick = () => {
|
|
93
|
+
if (onRename) {
|
|
94
|
+
setEditing(true);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
if (editing) {
|
|
98
|
+
return /* @__PURE__ */ jsx("div", { className: "file-card__name-area file-card__name-area--editing", children: /* @__PURE__ */ jsx(
|
|
99
|
+
"textarea",
|
|
100
|
+
{
|
|
101
|
+
ref: inputRef,
|
|
102
|
+
className: "file-card__edit-input",
|
|
103
|
+
value: editValue,
|
|
104
|
+
onChange: (e) => setEditValue(e.target.value),
|
|
105
|
+
onKeyDown: handleKeyDown,
|
|
106
|
+
onBlur: handleBlur,
|
|
107
|
+
rows: 2,
|
|
108
|
+
style: { height: "42px" }
|
|
109
|
+
}
|
|
110
|
+
) });
|
|
111
|
+
}
|
|
112
|
+
return /* @__PURE__ */ jsx("div", { className: "file-card__name-area", onDoubleClick: handleDoubleClick, children: /* @__PURE__ */ jsx("span", { className: "file-card__filename", title: fileName, children: fileName }) });
|
|
113
|
+
}
|
|
114
|
+
function PdfCard({ fileName, onDelete, onRename, onPreview, className, style }) {
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", { className: `file-card file-card--pdf ${className || ""}`, style, children: [
|
|
116
|
+
/* @__PURE__ */ jsxs("div", { className: "file-card__pdf-preview", onClick: onPreview, children: [
|
|
117
|
+
(onPreview || onDelete) && /* @__PURE__ */ jsxs("div", { className: "file-card__overlay", children: [
|
|
118
|
+
onPreview && /* @__PURE__ */ jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
onPreview();
|
|
121
|
+
}, children: /* @__PURE__ */ jsx(IconEye, {}) }),
|
|
122
|
+
onDelete && /* @__PURE__ */ jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
onDelete();
|
|
125
|
+
}, children: /* @__PURE__ */ jsx(IconTrash, {}) })
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ jsx("div", { className: "file-card__pdf-label", children: /* @__PURE__ */ jsx("span", { children: "PDF" }) })
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ jsx(NameRow, { fileName, onRename })
|
|
130
|
+
] });
|
|
131
|
+
}
|
|
132
|
+
function OtherCard({ fileName, fileType, fileUrl, onDelete, onRename, onPreview, className, style }) {
|
|
133
|
+
return /* @__PURE__ */ jsxs("div", { className: `file-card file-card--other ${className || ""}`, style, children: [
|
|
134
|
+
/* @__PURE__ */ jsxs("div", { className: "file-card__other-preview", onClick: onPreview, children: [
|
|
135
|
+
(onPreview || onDelete) && /* @__PURE__ */ jsxs("div", { className: "file-card__overlay", children: [
|
|
136
|
+
onPreview && /* @__PURE__ */ jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
onPreview();
|
|
139
|
+
}, children: /* @__PURE__ */ jsx(IconEye, {}) }),
|
|
140
|
+
onDelete && /* @__PURE__ */ jsx("button", { className: "file-card__overlay-btn", onClick: (e) => {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
onDelete();
|
|
143
|
+
}, children: /* @__PURE__ */ jsx(IconTrash, {}) })
|
|
144
|
+
] }),
|
|
145
|
+
/* @__PURE__ */ jsx(FileIcon, { fileType, fileUrl, fileName })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsx(NameRow, { fileName, onRename })
|
|
148
|
+
] });
|
|
149
|
+
}
|
|
150
|
+
function FileCard(props) {
|
|
151
|
+
if (props.fileType === "pdf") {
|
|
152
|
+
return /* @__PURE__ */ jsx(PdfCard, { ...props });
|
|
153
|
+
}
|
|
154
|
+
return /* @__PURE__ */ jsx(OtherCard, { ...props });
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
FileCard as default
|
|
158
|
+
};
|