@lobehub/ui 1.144.5 → 1.145.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.
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { DivProps, SvgProps } from "../types";
3
+ export interface FileTypeIconProps extends SvgProps {
4
+ color?: string;
5
+ filetype?: string;
6
+ size?: number;
7
+ type?: 'file' | 'folder';
8
+ variant?: 'color' | 'mono';
9
+ }
10
+ declare const FileTypeIcon: import("react").NamedExoticComponent<FileTypeIconProps & DivProps>;
11
+ export default FileTypeIcon;
@@ -0,0 +1,87 @@
1
+ 'use client';
2
+
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["color", "filetype", "type", "size", "style", "variant"];
6
+ import { useTheme } from 'antd-style';
7
+ import { memo, useMemo } from 'react';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ var FileTypeIcon = /*#__PURE__*/memo(function (_ref) {
11
+ var color = _ref.color,
12
+ filetype = _ref.filetype,
13
+ _ref$type = _ref.type,
14
+ type = _ref$type === void 0 ? 'file' : _ref$type,
15
+ _ref$size = _ref.size,
16
+ size = _ref$size === void 0 ? 48 : _ref$size,
17
+ style = _ref.style,
18
+ variant = _ref.variant,
19
+ rest = _objectWithoutProperties(_ref, _excluded);
20
+ var theme = useTheme();
21
+ var fontSize = useMemo(function () {
22
+ if (filetype && filetype.length > 3) {
23
+ return 24 / (4 + (filetype.length - 3));
24
+ }
25
+ return 6;
26
+ }, [filetype]);
27
+ var isMono = variant === 'mono';
28
+ var iconColor = isMono ? theme.isDarkMode ? theme.colorFill : theme.colorBgContainer : color || theme.geekblue;
29
+ if (type === 'file') return /*#__PURE__*/_jsxs("svg", _objectSpread(_objectSpread({
30
+ height: size,
31
+ style: _objectSpread({
32
+ flex: 'none',
33
+ lineHeight: 1
34
+ }, style),
35
+ viewBox: "0 0 24 24",
36
+ width: size,
37
+ xmlns: "http://www.w3.org/2000/svg"
38
+ }, rest), {}, {
39
+ children: [/*#__PURE__*/_jsx("path", {
40
+ d: "M6 2a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6H6z",
41
+ fill: iconColor
42
+ }), /*#__PURE__*/_jsx("path", {
43
+ d: "M14 2l6 6h-4a2 2 0 01-2-2V2z",
44
+ fill: isMono ? theme.colorFill : '#fff',
45
+ fillOpacity: ".5"
46
+ }), filetype && /*#__PURE__*/_jsx("text", {
47
+ fill: isMono ? theme.colorTextSecondary : '#fff',
48
+ fontSize: fontSize,
49
+ fontWeight: "bold",
50
+ textAnchor: "middle",
51
+ x: "50%",
52
+ y: "70%",
53
+ children: filetype.toUpperCase()
54
+ }), /*#__PURE__*/_jsx("path", {
55
+ d: "M6 2a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6H6z",
56
+ fill: 'transparent',
57
+ stroke: theme.colorFillSecondary,
58
+ strokeWidth: 0.5
59
+ })]
60
+ }));
61
+ return /*#__PURE__*/_jsxs("svg", _objectSpread(_objectSpread({
62
+ height: size,
63
+ style: _objectSpread({
64
+ flex: 'none',
65
+ lineHeight: 1
66
+ }, style),
67
+ viewBox: "0 0 24 24",
68
+ width: size,
69
+ xmlns: "http://www.w3.org/2000/svg"
70
+ }, rest), {}, {
71
+ children: [/*#__PURE__*/_jsx("path", {
72
+ d: "M10.46 5.076l-.92-.752A1.446 1.446 0 008.626 4H3.429c-.38 0-.743.147-1.01.41A1.386 1.386 0 002 5.4v13.2c0 .371.15.727.418.99.268.262.632.41 1.01.41h17.143c.38 0 .743-.148 1.01-.41.268-.263.419-.619.419-.99V6.8c0-.371-.15-.727-.418-.99a1.444 1.444 0 00-1.01-.41h-9.198c-.334 0-.657-.115-.914-.324z",
73
+ fill: iconColor,
74
+ stroke: theme.colorFillSecondary,
75
+ strokeWidth: 0.5
76
+ }), filetype && /*#__PURE__*/_jsx("text", {
77
+ fill: isMono ? theme.colorTextSecondary : '#fff',
78
+ fontSize: fontSize,
79
+ fontWeight: "bold",
80
+ textAnchor: "middle",
81
+ x: '50%',
82
+ y: "70%",
83
+ children: filetype.toUpperCase()
84
+ })]
85
+ }));
86
+ });
87
+ export default FileTypeIcon;