@lobehub/ui 1.33.0 → 1.34.0
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/es/Giscus/index.d.ts +8 -0
- package/es/Giscus/index.js +50 -0
- package/es/Giscus/style.d.ts +3 -0
- package/es/Giscus/style.js +27 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type GiscusProps as GiscusComponentProps } from '@giscus/react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
export interface GiscusProps extends GiscusComponentProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
declare const Giscus: import("react").NamedExoticComponent<GiscusProps>;
|
|
8
|
+
export default Giscus;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["style", "className", "reactionsEnabled", "mapping", "lang", "inputPosition", "id", "loading", "emitMetadata"];
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
import GiscusComponent from '@giscus/react';
|
|
7
|
+
import { useTheme, useThemeMode } from 'antd-style';
|
|
8
|
+
import { memo, useMemo } from 'react';
|
|
9
|
+
import { formatLang, genStyles } from "./style";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
var Giscus = /*#__PURE__*/memo(function (_ref) {
|
|
12
|
+
var style = _ref.style,
|
|
13
|
+
className = _ref.className,
|
|
14
|
+
_ref$reactionsEnabled = _ref.reactionsEnabled,
|
|
15
|
+
reactionsEnabled = _ref$reactionsEnabled === void 0 ? '1' : _ref$reactionsEnabled,
|
|
16
|
+
_ref$mapping = _ref.mapping,
|
|
17
|
+
mapping = _ref$mapping === void 0 ? 'title' : _ref$mapping,
|
|
18
|
+
_ref$lang = _ref.lang,
|
|
19
|
+
lang = _ref$lang === void 0 ? 'en_US' : _ref$lang,
|
|
20
|
+
_ref$inputPosition = _ref.inputPosition,
|
|
21
|
+
inputPosition = _ref$inputPosition === void 0 ? 'top' : _ref$inputPosition,
|
|
22
|
+
_ref$id = _ref.id,
|
|
23
|
+
id = _ref$id === void 0 ? 'giscus' : _ref$id,
|
|
24
|
+
_ref$loading = _ref.loading,
|
|
25
|
+
loading = _ref$loading === void 0 ? 'lazy' : _ref$loading,
|
|
26
|
+
_ref$emitMetadata = _ref.emitMetadata,
|
|
27
|
+
emitMetadata = _ref$emitMetadata === void 0 ? '0' : _ref$emitMetadata,
|
|
28
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
var token = useTheme();
|
|
30
|
+
var _useThemeMode = useThemeMode(),
|
|
31
|
+
isDarkMode = _useThemeMode.isDarkMode;
|
|
32
|
+
var giscusTheme = useMemo(function () {
|
|
33
|
+
return btoa(genStyles(token, isDarkMode).styles);
|
|
34
|
+
}, [isDarkMode, token]);
|
|
35
|
+
return /*#__PURE__*/_jsx("div", {
|
|
36
|
+
className: className,
|
|
37
|
+
style: style,
|
|
38
|
+
children: /*#__PURE__*/_jsx(GiscusComponent, _objectSpread({
|
|
39
|
+
emitMetadata: emitMetadata,
|
|
40
|
+
id: id,
|
|
41
|
+
inputPosition: inputPosition,
|
|
42
|
+
lang: formatLang(lang),
|
|
43
|
+
loading: loading,
|
|
44
|
+
mapping: mapping,
|
|
45
|
+
reactionsEnabled: reactionsEnabled,
|
|
46
|
+
theme: "data:text/css;base64,".concat(giscusTheme)
|
|
47
|
+
}, props))
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
export default Giscus;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
import { css } from 'antd-style';
|
|
4
|
+
import { readableColor, rgba } from 'polished';
|
|
5
|
+
import { colorScales } from "../styles/colors";
|
|
6
|
+
export var genStyles = function genStyles(token, isDarkMode) {
|
|
7
|
+
var type = isDarkMode ? 'dark' : 'light';
|
|
8
|
+
var colorText = colorScales.gray[type][11];
|
|
9
|
+
var colorTextSecondary = colorScales.gray[type][10];
|
|
10
|
+
var colorTextTertiary = colorScales.gray[type][7];
|
|
11
|
+
var colorRed = isDarkMode ? colorScales.red[type][9] : colorScales.volcano[type][9];
|
|
12
|
+
var colorOrange = isDarkMode ? colorScales.gold[type][9] : colorScales.orange[type][9];
|
|
13
|
+
var colorGreen = isDarkMode ? colorScales.lime[type][9] : colorScales.green[type][9];
|
|
14
|
+
var colorBlue = isDarkMode ? colorScales.blue[type][9] : colorScales.geekblue[type][9];
|
|
15
|
+
var loaderContainer = isDarkMode ? 'https://github.com/images/modules/pulls/progressive-disclosure-line-dark.svg' : 'https://github.com/images/modules/pulls/progressive-disclosure-line.svg';
|
|
16
|
+
var loadingImage = isDarkMode ? 'https://github.githubassets.com/images/mona-loading-dark.gif' : 'https://github.githubassets.com/images/mona-loading-default.gif';
|
|
17
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n main {\n --color-prettylights-syntax-comment: ", ";\n --color-prettylights-syntax-constant: ", ";\n --color-prettylights-syntax-entity: ", ";\n --color-prettylights-syntax-storage-modifier-import: ", ";\n --color-prettylights-syntax-entity-tag: ", ";\n --color-prettylights-syntax-keyword: ", ";\n --color-prettylights-syntax-string: ", ";\n --color-prettylights-syntax-variable: ", ";\n --color-prettylights-syntax-brackethighlighter-unmatched: ", ";\n --color-prettylights-syntax-invalid-illegal-text: ", ";\n --color-prettylights-syntax-invalid-illegal-bg: ", ";\n --color-prettylights-syntax-carriage-return-text: ", ";\n --color-prettylights-syntax-carriage-return-bg: ", ";\n --color-prettylights-syntax-string-regexp: ", ";\n --color-prettylights-syntax-markup-list: ", ";\n --color-prettylights-syntax-markup-heading: ", ";\n --color-prettylights-syntax-markup-italic: ", ";\n --color-prettylights-syntax-markup-bold: ", ";\n --color-prettylights-syntax-markup-deleted-text: ", ";\n --color-prettylights-syntax-markup-deleted-bg: ", ";\n --color-prettylights-syntax-markup-inserted-text: ", ";\n --color-prettylights-syntax-markup-inserted-bg: ", ";\n --color-prettylights-syntax-markup-changed-text: ", ";\n --color-prettylights-syntax-markup-changed-bg: ", ";\n --color-prettylights-syntax-markup-ignored-text: ", ";\n --color-prettylights-syntax-markup-ignored-bg: ", ";\n --color-prettylights-syntax-meta-diff-range: ", ";\n --color-prettylights-syntax-brackethighlighter-angle: ", ";\n --color-prettylights-syntax-sublimelinter-gutter-mark: ", ";\n --color-prettylights-syntax-constant-other-reference-link: ", ";\n --color-btn-text: ", ";\n --color-btn-bg: ", ";\n --color-btn-border: ", ";\n --color-btn-shadow: 0 0 transparent;\n --color-btn-inset-shadow: 0 0 transparent;\n --color-btn-hover-bg: ", ";\n --color-btn-hover-border: ", ";\n --color-btn-active-bg: ", ";\n --color-btn-active-border: ", ";\n --color-btn-selected-bg: ", ";\n --color-btn-primary-text: ", ";\n --color-btn-primary-bg: ", ";\n --color-btn-primary-border: ", ";\n --color-btn-primary-shadow: 0 0 transparent;\n --color-btn-primary-inset-shadow: 0 0 transparent;\n --color-btn-primary-hover-bg: ", ";\n --color-btn-primary-hover-border: ", ";\n --color-btn-primary-selected-bg: ", ";\n --color-btn-primary-selected-shadow: 0 0 transparent;\n --color-btn-primary-disabled-text: ", ";\n --color-btn-primary-disabled-bg: ", ";\n --color-btn-primary-disabled-border: ", ";\n --color-action-list-item-default-hover-bg: ", ";\n --color-segmented-control-bg: ", ";\n --color-segmented-control-button-bg: transparent;\n --color-segmented-control-button-selected-border: ", ";\n --color-fg-default: ", ";\n --color-fg-muted: ", ";\n --color-fg-subtle: ", ";\n --color-canvas-default: transparent;\n --color-canvas-overlay: ", ";\n --color-canvas-inset: transparent;\n --color-canvas-subtle: ", ";\n --color-border-default: ", ";\n --color-border-muted: ", ";\n --color-neutral-muted: ", ";\n --color-neutral-subtle: ", ";\n --color-accent-fg: ", ";\n --color-accent-emphasis: ", ";\n --color-accent-muted: ", ";\n --color-accent-subtle: ", ";\n --color-success-fg: ", ";\n --color-attention-fg: ", ";\n --color-attention-muted: ", ";\n --color-attention-subtle: ", ";\n --color-danger-fg: ", ";\n --color-danger-muted: ", ";\n --color-danger-subtle: ", ";\n --color-primer-shadow-inset: 0 0 transparent;\n --color-scale-gray-7: ", ";\n --color-scale-blue-8: ", ";\n --color-social-reaction-bg-hover: ", ";\n --color-social-reaction-bg-reacted-hover: ", ";\n\n .markdown pre {\n color: ", ";\n }\n\n .pagination-loader-container {\n background-image: url(", ");\n }\n\n .gsc-pagination-button {\n background-color: var(--color-btn-bg);\n }\n\n .gsc-reactions-popover {\n width: 170px;\n\n > .m-2 {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n }\n }\n\n .gsc-emoji-button.has-reacted {\n border-color: ", ";\n border-radius: ", "px;\n }\n\n .gsc-loading-image {\n background-image: url(", ");\n }\n }\n "])), colorTextTertiary, colorGreen, colorOrange, colorRed, colorBlue, colorBlue, colorGreen, colorRed, colorRed, colorTextSecondary, rgba(colorRed, 0.4), colorTextSecondary, rgba(colorRed, 0.6), colorGreen, colorOrange, colorBlue, colorTextSecondary, colorTextSecondary, colorTextSecondary, rgba(colorRed, 0.2), colorGreen, rgba(colorGreen, 0.2), colorOrange, rgba(colorRed, 0.2), colorTextSecondary, rgba(colorBlue, 0.2), colorOrange, colorTextSecondary, colorTextTertiary, colorBlue, token.colorText, token.colorFillTertiary, token.colorBorderSecondary, token.colorFillSecondary, token.colorBorder, token.colorFillSecondary, token.colorBorder, token.colorFillSecondary, readableColor(token.colorPrimary), token.colorPrimary, token.colorPrimaryBorder, token.colorPrimaryHover, token.colorPrimaryBorderHover, token.colorPrimaryActive, rgba(readableColor(token.colorPrimary), 0.5), rgba(token.colorPrimary, 0.5), rgba(token.colorPrimaryBorder, 0.5), token.colorFillQuaternary, token.colorFillTertiary, token.colorBorder, token.colorText, token.colorTextSecondary, token.colorTextQuaternary, token.colorBgElevated, token.colorFillQuaternary, token.colorBorder, token.colorBorderSecondary, token.colorFillQuaternary, token.colorFillTertiary, token.colorInfo, token.colorInfoBorderHover, token.colorInfoBorder, token.colorInfoBg, token.colorSuccess, token.colorWarning, token.colorWarningBorder, token.colorWarningBg, token.colorError, token.colorErrorBorder, token.colorErrorBg, token.colorBgContainer, token.colorInfoBg, token.colorFillSecondary, token.colorInfoBgHover, colorText, loaderContainer, token.colorInfoBorderHover, token.borderRadius, loadingImage);
|
|
18
|
+
};
|
|
19
|
+
export var formatLang = function formatLang(lang) {
|
|
20
|
+
if (['zh_CN', 'zh_TW'].includes(lang)) {
|
|
21
|
+
return lang.replace('_', '-');
|
|
22
|
+
} else if (lang === 'zh_HK') {
|
|
23
|
+
return 'zh-TW';
|
|
24
|
+
} else {
|
|
25
|
+
return lang.split('_')[0];
|
|
26
|
+
}
|
|
27
|
+
};
|
package/es/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { default as FormFooter, type FormFooterProps } from './Form/components/F
|
|
|
28
28
|
export { default as FormGroup, type FormGroupProps } from './Form/components/FormGroup';
|
|
29
29
|
export { default as FormItem, type FormItemProps } from './Form/components/FormItem';
|
|
30
30
|
export { default as FormTitle, type FormTitleProps } from './Form/components/FormTitle';
|
|
31
|
+
export { default as Giscus, type GiscusProps } from './Giscus';
|
|
31
32
|
export { default as GradientButton, type GradientButtonProps } from './GradientButton';
|
|
32
33
|
export { default as Header, type HeaderProps } from './Header';
|
|
33
34
|
export { default as Hero, type HeroAction, type HeroProps } from './Hero';
|
package/es/index.js
CHANGED
|
@@ -27,6 +27,7 @@ export { default as FormFooter } from "./Form/components/FormFooter";
|
|
|
27
27
|
export { default as FormGroup } from "./Form/components/FormGroup";
|
|
28
28
|
export { default as FormItem } from "./Form/components/FormItem";
|
|
29
29
|
export { default as FormTitle } from "./Form/components/FormTitle";
|
|
30
|
+
export { default as Giscus } from "./Giscus";
|
|
30
31
|
export { default as GradientButton } from "./GradientButton";
|
|
31
32
|
export { default as Header } from "./Header";
|
|
32
33
|
export { default as Hero } from "./Hero";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.0",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building chatbot web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@ant-design/icons": "^5",
|
|
75
75
|
"@babel/runtime": "^7",
|
|
76
76
|
"@floating-ui/react": "^0",
|
|
77
|
+
"@giscus/react": "^2",
|
|
77
78
|
"@react-spring/web": "^9",
|
|
78
79
|
"ahooks": "^3",
|
|
79
80
|
"antd": "^5",
|
|
@@ -115,7 +116,6 @@
|
|
|
115
116
|
"@types/react-dom": "^18",
|
|
116
117
|
"@vitest/coverage-v8": "latest",
|
|
117
118
|
"antd-style": "^3",
|
|
118
|
-
"babel-plugin-antd-style": "^1",
|
|
119
119
|
"commitlint": "^17",
|
|
120
120
|
"concurrently": "^8",
|
|
121
121
|
"cross-env": "^7",
|