@antv/dumi-theme-antv 0.5.7-beta.3 → 0.5.7

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.
@@ -1,18 +0,0 @@
1
- import { proxy } from 'valtio';
2
- export var feedbackStore = proxy({});
3
- export var resetFeedbackState = function resetFeedbackState() {
4
- feedbackStore.rating = undefined;
5
- feedbackStore.section = undefined;
6
- };
7
- export var invokePageFeedback = function invokePageFeedback(like) {
8
- feedbackStore.rating = like ? '1' : '0';
9
- };
10
- export var resetPageFeedback = function resetPageFeedback() {
11
- feedbackStore.rating = undefined;
12
- };
13
- export var invokeSectionFeedback = function invokeSectionFeedback(section) {
14
- feedbackStore.section = section;
15
- };
16
- export var resetSectionFeedback = function resetSectionFeedback() {
17
- feedbackStore.section = undefined;
18
- };
@@ -1,101 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/plugin/antVReactTechStack.ts
30
- var antVReactTechStack_exports = {};
31
- __export(antVReactTechStack_exports, {
32
- AntVReactTechStack: () => AntVReactTechStack
33
- });
34
- module.exports = __toCommonJS(antVReactTechStack_exports);
35
- var import_react = __toESM(require("dumi/dist/techStacks/react"));
36
- var import_fs = __toESM(require("fs"));
37
- var import_sylvanas = __toESM(require("sylvanas"));
38
- var import_package = require("../../package.json");
39
- var AntVReactTechStack = class extends import_react.default {
40
- generatePreviewerProps(...[props, opts]) {
41
- var _a;
42
- props.pkgDependencyList = { ...import_package.devDependencies, ...import_package.dependencies };
43
- props.jsx ?? (props.jsx = "");
44
- if (opts.type === "code-block") {
45
- props.jsx = (opts == null ? void 0 : opts.entryPointCode) ? import_sylvanas.default.parseText(opts.entryPointCode) : "";
46
- }
47
- if (opts.type === "external") {
48
- const locale = (_a = opts.mdAbsPath.match(/[a-z-]+\.([a-z-]+)\.md$/i)) == null ? void 0 : _a[1];
49
- const mdPath = opts.fileAbsPath.replace(/\.\w+$/, ".md");
50
- const md = import_fs.default.existsSync(mdPath) ? import_fs.default.readFileSync(mdPath, "utf-8") : "";
51
- const codePath = opts.fileAbsPath.replace(/\.\w+$/, ".tsx");
52
- const code = import_fs.default.existsSync(codePath) ? import_fs.default.readFileSync(codePath, "utf-8") : "";
53
- props.jsx = import_sylvanas.default.parseText(code);
54
- if (md) {
55
- const blocks = {};
56
- const lines = md.split("\n");
57
- let blockName = "";
58
- let cacheList = [];
59
- const getBlockName = (text) => {
60
- if (text.startsWith("## ")) {
61
- return text.replace("## ", "").trim();
62
- }
63
- if (text.startsWith("```css") || text.startsWith("<style>")) {
64
- return "style";
65
- }
66
- return null;
67
- };
68
- const fillBlock = (name, lineList) => {
69
- if (lineList.length) {
70
- let fullText;
71
- if (name === "style") {
72
- fullText = lineList.join("\n").replace(/<\/?style>/g, "").replace(/```(\s*css)/g, "");
73
- } else {
74
- fullText = lineList.slice(1).join("\n");
75
- }
76
- blocks[name] = fullText;
77
- }
78
- };
79
- for (let i = 0; i < lines.length; i++) {
80
- const line = lines[i];
81
- const nextBlockName = getBlockName(line);
82
- if (nextBlockName) {
83
- fillBlock(blockName, cacheList);
84
- blockName = nextBlockName;
85
- cacheList = [line];
86
- } else {
87
- cacheList.push(line);
88
- }
89
- }
90
- fillBlock(blockName, cacheList);
91
- props.description = blocks[locale];
92
- props.style = blocks.style;
93
- }
94
- }
95
- return props;
96
- }
97
- };
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {
100
- AntVReactTechStack
101
- });
@@ -1,52 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/plugin/remarkFeedback.ts
30
- var remarkFeedback_exports = {};
31
- __export(remarkFeedback_exports, {
32
- default: () => remarkFeedback
33
- });
34
- module.exports = __toCommonJS(remarkFeedback_exports);
35
- var visit;
36
- (async () => {
37
- ({ visit } = await import("unist-util-visit"));
38
- })();
39
- var icon = '<span role="img" aria-label="message" class="anticon anticon-message"><svg viewBox="64 64 896 896" focusable="false" data-icon="message" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M464 512a48 48 0 1096 0 48 48 0 10-96 0zm200 0a48 48 0 1096 0 48 48 0 10-96 0zm-400 0a48 48 0 1096 0 48 48 0 10-96 0zm661.2-173.6c-22.6-53.7-55-101.9-96.3-143.3a444.35 444.35 0 00-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9a445.35 445.35 0 00-142 96.5c-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9A449.4 449.4 0 00112 714v152a46 46 0 0046 46h152.1A449.4 449.4 0 00510 960h2.1c59.9 0 118-11.6 172.7-34.3a444.48 444.48 0 00142.8-95.2c41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"></path></svg></span>';
40
- function remarkFeedback() {
41
- return (tree) => {
42
- visit(tree, "heading", (node) => {
43
- const headingText = node.children.filter((child) => child.type === "text").map((child) => child.value).join(" ").split(" ").join("-");
44
- const template = `<button title="Post a comment" data-feedback-hash=${headingText} type="button" class="ant-btn ant-btn-text ant-btn-icon-only button comment-link feedback-link">${icon}</button>`;
45
- const button = {
46
- type: "html",
47
- value: template
48
- };
49
- node.children.push(button);
50
- });
51
- };
52
- }
@@ -1,42 +0,0 @@
1
- import { Avatar, Skeleton, Tooltip } from 'antd';
2
- import React from 'react';
3
- var AvatarPlaceholder = function AvatarPlaceholder(_ref) {
4
- var _ref$num = _ref.num,
5
- num = _ref$num === void 0 ? 3 : _ref$num;
6
- return /*#__PURE__*/React.createElement("li", null, Array.from({
7
- length: num
8
- }).map(function (_, i) {
9
- return /*#__PURE__*/React.createElement(Skeleton.Avatar, {
10
- size: "small",
11
- active: true,
12
- key: i,
13
- style: {
14
- marginInlineStart: i === 0 ? 0 : -8
15
- }
16
- });
17
- }));
18
- };
19
- export var ContributorAvatar = function ContributorAvatar(props) {
20
- var _props$item = props.item,
21
- _props$item2 = _props$item === void 0 ? {} : _props$item,
22
- username = _props$item2.username,
23
- url = _props$item2.url,
24
- loading = props.loading;
25
- if (loading) {
26
- return /*#__PURE__*/React.createElement(AvatarPlaceholder, null);
27
- }
28
- if (username !== null && username !== void 0 && username.includes('github-actions')) {
29
- return null;
30
- }
31
- return /*#__PURE__*/React.createElement(Tooltip, {
32
- title: username
33
- }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
34
- href: "https://github.com/".concat(username),
35
- target: "_blank",
36
- rel: "noopener noreferrer"
37
- }, /*#__PURE__*/React.createElement(Avatar, {
38
- size: "small",
39
- src: url,
40
- alt: username
41
- }, username))));
42
- };
@@ -1,45 +0,0 @@
1
- import { useIntl, useRouteMeta, useSiteData } from 'dumi';
2
- import path from 'path';
3
- import React from 'react';
4
- import styled from 'styled-components';
5
- import ContributorsList from "../../common/AvatarList";
6
- import { useGithubRepo } from "../../utils/github";
7
- import { ContributorAvatar } from "./ContributorAvatar";
8
- var StyledContributorsWrapper = styled.div.withConfig({
9
- displayName: "StyledContributorsWrapper",
10
- componentId: "dumi-theme-antv-c7ef__sc-11d631u-0"
11
- })(["margin-top:80px;.title{margin-bottom:14px;color:#bfbfbf;}.list{display:flex;flex-wrap:wrap;clear:both;li{height:24px;transition:all 0.3s;margin-inline-end:-8px;}&:hover{li{margin-inline-end:0;}}}"]);
12
- export var Contributors = function Contributors() {
13
- var _useIntl = useIntl(),
14
- formatMessage = _useIntl.formatMessage;
15
- var _useSiteData$themeCon = useSiteData().themeConfig.sitePackagePath,
16
- sitePackagePath = _useSiteData$themeCon === void 0 ? '/packages/site' : _useSiteData$themeCon;
17
- var _useGithubRepo = useGithubRepo(),
18
- owner = _useGithubRepo.owner,
19
- repo = _useGithubRepo.repo,
20
- defaultBranch = _useGithubRepo.defaultBranch;
21
- var meta = useRouteMeta();
22
- var editable = !meta.frontmatter.readonly;
23
- if (!editable || !meta.frontmatter.filename) {
24
- return null;
25
- }
26
- return /*#__PURE__*/React.createElement(StyledContributorsWrapper, null, /*#__PURE__*/React.createElement("div", {
27
- className: "title"
28
- }, formatMessage({
29
- id: '文档贡献者'
30
- })), /*#__PURE__*/React.createElement(ContributorsList, {
31
- cache: true,
32
- repo: repo,
33
- owner: owner,
34
- fileName: path.join(sitePackagePath, meta.frontmatter.filename),
35
- className: "list",
36
- renderItem: function renderItem(item, loading) {
37
- return /*#__PURE__*/React.createElement(ContributorAvatar, {
38
- item: item,
39
- loading: loading,
40
- key: item === null || item === void 0 ? void 0 : item.url
41
- });
42
- },
43
- branch: defaultBranch
44
- }));
45
- };
@@ -1,37 +0,0 @@
1
- import { FormOutlined } from '@ant-design/icons';
2
- import { useIntl, useRouteMeta, useSiteData } from 'dumi';
3
- import path from 'path';
4
- import React from 'react';
5
- import { useGithubRepo } from "../../utils/github";
6
- export var EditButton = function EditButton() {
7
- var meta = useRouteMeta();
8
- var _useIntl = useIntl(),
9
- formatMessage = _useIntl.formatMessage;
10
- var _useSiteData = useSiteData(),
11
- themeConfig = _useSiteData.themeConfig;
12
- var githubUrl = themeConfig.githubUrl,
13
- _themeConfig$sitePack = themeConfig.sitePackagePath,
14
- sitePackagePath = _themeConfig$sitePack === void 0 ? '/packages/site' : _themeConfig$sitePack;
15
- var _useGithubRepo = useGithubRepo(),
16
- defaultBranch = _useGithubRepo.defaultBranch;
17
- var editable = !meta.frontmatter.readonly;
18
- if (!editable) {
19
- return null;
20
- }
21
- var branchUrl = "".concat(githubUrl, "/edit/").concat(defaultBranch);
22
- var url = meta.frontmatter.redirect ? path.join(branchUrl, meta.frontmatter.redirect) : path.join(branchUrl, sitePackagePath, meta.frontmatter.filename || '');
23
- return /*#__PURE__*/React.createElement("a", {
24
- onClick: function onClick() {
25
- return window.open(url, '_blank');
26
- }
27
- }, /*#__PURE__*/React.createElement(FormOutlined, {
28
- style: {
29
- fontSize: 16,
30
- marginRight: 8
31
- }
32
- }), /*#__PURE__*/React.createElement("span", {
33
- className: "button-text"
34
- }, formatMessage({
35
- id: '在 GitHub 上编辑此页'
36
- })));
37
- };
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { styled } from 'styled-components';
3
- import { PageFeedbackReasonForm } from "./PageFeedbackReasonForm";
4
- import { PageFeedbackVoteButtons } from "./PageFeedbackVoteButtons";
5
- var StyledWrapper = styled.div.withConfig({
6
- displayName: "StyledWrapper",
7
- componentId: "dumi-theme-antv-c7ef__sc-1vamzhw-0"
8
- })(["background-color:#fff;border-radius:12px;bottom:24px;box-shadow:0 0.5rem 1.2rem #f0f1f2;padding:10px 18px;position:fixed;right:12px;width:262px;z-index:1000;"]);
9
- export var PageFeedback = function PageFeedback() {
10
- return /*#__PURE__*/React.createElement(StyledWrapper, null, /*#__PURE__*/React.createElement(PageFeedbackVoteButtons, null), /*#__PURE__*/React.createElement(PageFeedbackReasonForm, null));
11
- };
@@ -1,163 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { Alert, Button, Divider, Form, Select } from 'antd';
8
- import { useIntl, useLocale } from 'dumi';
9
- import React, { useEffect } from 'react';
10
- import { styled } from 'styled-components';
11
- import { useSnapshot } from 'valtio';
12
- import { feedbackStore, resetPageFeedback } from "../../model/feedback";
13
- import { useGithubRepo } from "../../utils/github";
14
- import { useFeedbackService } from "./service";
15
- var StyledFeedbackMessageWrapper = styled.div.withConfig({
16
- displayName: "StyledFeedbackMessageWrapper",
17
- componentId: "dumi-theme-antv-c7ef__sc-1xff90d-0"
18
- })(["display:", ";.ant-divider-horizontal{margin:16px 0;}.alert{margin:12px 0 16px;padding:16px;font-size:13px;line-height:1.8;background-color:rgba(255,251,235,0.5);border:1px solid rgba(173,104,0,0.15);border-radius:8px;.ant-alert-icon{color:#cc8800;}}.alert-link{color:#56390c;font-weight:bold;text-decoration:underline;}.ant-form-item:last-child{margin-bottom:8px;}"], function (props) {
19
- return props.$rating ? 'block' : 'none';
20
- });
21
- export var PageFeedbackReasonForm = function PageFeedbackReasonForm() {
22
- var _useIntl = useIntl(),
23
- formatMessage = _useIntl.formatMessage;
24
- var _Form$useForm = Form.useForm(),
25
- _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
26
- form = _Form$useForm2[0];
27
- var feedbackState = useSnapshot(feedbackStore);
28
- var _useGithubRepo = useGithubRepo(),
29
- owner = _useGithubRepo.owner,
30
- repo = _useGithubRepo.repo;
31
- var pageUrl = window.location.href;
32
- var locale = useLocale();
33
- var currentLocale = locale.id;
34
- var issueUrl = "https://github.com/".concat(owner, "/").concat(repo, "/issues/new?labels=status%3A+waiting+for+maintainer%2Cdocs-feedback&template=docs-feedback.yml&title=[docs]+&page-url=").concat(pageUrl);
35
- var alertMsg = /*#__PURE__*/React.createElement("div", null, formatMessage({
36
- id: '如果遇到问题或发现某些功能无法正常工作,请通过'
37
- }), /*#__PURE__*/React.createElement("a", {
38
- onClick: function onClick() {
39
- return window.open(issueUrl, '_blank');
40
- },
41
- className: "alert-link"
42
- }, formatMessage({
43
- id: '提交问题报告'
44
- })), formatMessage({
45
- id: '来反馈。否则,团队将无法提供进一步的答复或获取更多信息。'
46
- }));
47
- var _useFeedbackService = useFeedbackService(),
48
- submitFeedback = _useFeedbackService.submitFeedback,
49
- showFeedbackResult = _useFeedbackService.showFeedbackResult;
50
- var onFinish = function onFinish(values) {
51
- var params = {
52
- rating: feedbackState.rating,
53
- reason: values.reason
54
- };
55
- submitFeedback(params).then(function (f) {
56
- onCancel();
57
- showFeedbackResult(true);
58
- }).catch(function () {
59
- showFeedbackResult(false);
60
- });
61
- };
62
- var onCancel = function onCancel() {
63
- form.resetFields();
64
- resetPageFeedback();
65
- };
66
- useEffect(function () {
67
- if (!feedbackState.rating) onCancel();
68
- }, [feedbackState.rating]);
69
- var likeReasons = [{
70
- label: formatMessage({
71
- id: '容易理解'
72
- }),
73
- value: 'easy_to_understand'
74
- }, {
75
- label: formatMessage({
76
- id: '解决了我的问题'
77
- }),
78
- value: 'solved_my_problem'
79
- }, {
80
- label: formatMessage({
81
- id: '其它'
82
- }),
83
- value: 'other'
84
- }];
85
- var dislikeReasons = [{
86
- label: formatMessage({
87
- id: '缺少我需要的信息'
88
- }),
89
- value: 'missing_information'
90
- }, {
91
- label: formatMessage({
92
- id: '过于复杂/步骤太多'
93
- }),
94
- value: 'too_complicated'
95
- }, {
96
- label: formatMessage({
97
- id: '内容更新不及时'
98
- }),
99
- value: 'out_of_date'
100
- }, {
101
- label: formatMessage({
102
- id: '示例/代码有问题'
103
- }),
104
- value: 'code_issue'
105
- }, {
106
- label: formatMessage({
107
- id: '其它'
108
- }),
109
- value: 'other'
110
- }];
111
- var reasons = feedbackState.rating === '1' ? likeReasons : dislikeReasons;
112
- useEffect(function () {
113
- // 默认选中第一个原因
114
- form === null || form === void 0 || form.setFieldsValue({
115
- reason: reasons[0].value
116
- });
117
- }, [feedbackState.rating, currentLocale]);
118
- var dislike = feedbackState.rating !== '1';
119
- return /*#__PURE__*/React.createElement(StyledFeedbackMessageWrapper, {
120
- $rating: feedbackState.rating
121
- }, /*#__PURE__*/React.createElement(Divider, {
122
- dashed: true
123
- }), /*#__PURE__*/React.createElement("div", {
124
- className: "form"
125
- }, /*#__PURE__*/React.createElement(Form, {
126
- form: form,
127
- name: "page-feedback-form",
128
- onFinish: onFinish,
129
- layout: "vertical"
130
- }, /*#__PURE__*/React.createElement(Form.Item, {
131
- name: "reason",
132
- label: formatMessage({
133
- id: '🚀 留下你的真实感受'
134
- })
135
- }, /*#__PURE__*/React.createElement(Select, {
136
- options: reasons
137
- })), dislike && /*#__PURE__*/React.createElement(Alert, {
138
- type: "warning",
139
- className: "alert",
140
- message: alertMsg,
141
- showIcon: true
142
- }), /*#__PURE__*/React.createElement(Form.Item, {
143
- style: {
144
- textAlign: 'right'
145
- }
146
- }, /*#__PURE__*/React.createElement(Button, {
147
- htmlType: "button",
148
- type: "text",
149
- size: "small",
150
- onClick: onCancel,
151
- style: {
152
- marginRight: 8
153
- }
154
- }, formatMessage({
155
- id: '取消'
156
- })), /*#__PURE__*/React.createElement(Button, {
157
- type: "primary",
158
- htmlType: "submit",
159
- size: "small"
160
- }, formatMessage({
161
- id: '提交'
162
- }))))));
163
- };
@@ -1,60 +0,0 @@
1
- import { DislikeFilled, LikeFilled } from '@ant-design/icons';
2
- import { Button, Tooltip } from 'antd';
3
- import { useIntl } from 'dumi';
4
- import React from 'react';
5
- import { styled } from 'styled-components';
6
- import { useSnapshot } from 'valtio';
7
- import { feedbackStore, invokePageFeedback, resetPageFeedback } from "../../model/feedback";
8
- var StyledVoteButtonsWrapper = styled.div.withConfig({
9
- displayName: "StyledVoteButtonsWrapper",
10
- componentId: "dumi-theme-antv-c7ef__sc-1x5fro0-0"
11
- })(["color:rgba(0,0,0,0.65);display:flex;align-items:center;gap:4px;font-weight:500;.button{color:rgba(0,0,0,0.65);}.active-button{color:#873bf4;background-color:#f8f1ff;}"]);
12
- export var PageFeedbackVoteButtons = function PageFeedbackVoteButtons() {
13
- var _useIntl = useIntl(),
14
- formatMessage = _useIntl.formatMessage;
15
- var feedbackState = useSnapshot(feedbackStore);
16
- var items = [{
17
- title: formatMessage({
18
- id: 'yes'
19
- }),
20
- icon: /*#__PURE__*/React.createElement(LikeFilled, null),
21
- onClick: function onClick() {
22
- if (feedbackState.rating === '1') {
23
- resetPageFeedback();
24
- } else {
25
- invokePageFeedback(true);
26
- }
27
- },
28
- isActive: feedbackState.rating === '1'
29
- }, {
30
- title: formatMessage({
31
- id: 'no'
32
- }),
33
- icon: /*#__PURE__*/React.createElement(DislikeFilled, null),
34
- onClick: function onClick() {
35
- if (feedbackState.rating === '0') {
36
- resetPageFeedback();
37
- } else {
38
- invokePageFeedback(false);
39
- }
40
- },
41
- isActive: feedbackState.rating === '0'
42
- }];
43
- return /*#__PURE__*/React.createElement(StyledVoteButtonsWrapper, null, /*#__PURE__*/React.createElement("span", null, formatMessage({
44
- id: '这个页面对你有帮助吗?'
45
- })), items.map(function (_ref) {
46
- var title = _ref.title,
47
- icon = _ref.icon,
48
- onClick = _ref.onClick,
49
- isActive = _ref.isActive;
50
- return /*#__PURE__*/React.createElement(Tooltip, {
51
- key: title,
52
- title: title
53
- }, /*#__PURE__*/React.createElement(Button, {
54
- className: "button ".concat(isActive ? 'active-button' : ''),
55
- type: "text",
56
- icon: icon,
57
- onClick: onClick
58
- }));
59
- }));
60
- };
@@ -1,97 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useEffect, useState } from 'react';
8
- import { useLocation } from 'react-router-dom';
9
- import { styled } from 'styled-components';
10
- import { useSnapshot } from 'valtio';
11
- import { feedbackStore, invokeSectionFeedback, resetSectionFeedback } from "../../model/feedback";
12
- import { SectionFeedbackCommentForm } from "./SectionFeedbackCommentForm";
13
- var StyledWrapper = styled.div.withConfig({
14
- displayName: "StyledWrapper",
15
- componentId: "dumi-theme-antv-c7ef__sc-vcamqv-0"
16
- })(["background-color:#fff;border-radius:12px;box-shadow:0 0.5rem 1.2rem #f0f1f2;transition:height 0.3s ease-in-out;width:262px;position:fixed;z-index:1001;padding:10px 18px;border-radius:8px;transition:top 0.3s ease-in-out,right 0.3s ease-in-out;"]);
17
- export var SectionFeedback = function SectionFeedback() {
18
- var feedbackState = useSnapshot(feedbackStore);
19
- var location = useLocation();
20
- useEffect(function () {
21
- var observer = new MutationObserver(function () {
22
- var buttons = document.querySelectorAll('.comment-link');
23
- if (!buttons || buttons.length === 0) return;
24
- var focusCommentInput = function focusCommentInput(e) {
25
- var button = e.target.closest('.comment-link');
26
- invokeSectionFeedback(button.getAttribute('data-feedback-hash'));
27
- };
28
- buttons.forEach(function (button) {
29
- button.addEventListener('click', focusCommentInput);
30
- });
31
- return function () {
32
- buttons.forEach(function (button) {
33
- button.removeEventListener('click', focusCommentInput);
34
- });
35
- };
36
- });
37
- observer.observe(document.body, {
38
- childList: true,
39
- subtree: true
40
- });
41
- return function () {
42
- observer.disconnect();
43
- };
44
- }, []);
45
- var _useState = useState({
46
- top: 0,
47
- right: 12
48
- }),
49
- _useState2 = _slicedToArray(_useState, 2),
50
- position = _useState2[0],
51
- setPosition = _useState2[1];
52
- useEffect(function () {
53
- var handleClick = function handleClick(e) {
54
- var target = e.target;
55
- var closestCommentLink = target.closest('.comment-link');
56
- if (!feedbackState.section || !closestCommentLink) return;
57
- var escapedSection = CSS.escape(feedbackState.section);
58
- var elements = document.querySelectorAll(".comment-link[data-feedback-hash=".concat(escapedSection, "]"));
59
- var closestElement = findClosetElement(e, elements);
60
- if (closestElement) {
61
- var rect = closestElement.getBoundingClientRect();
62
- var top = Math.min(Math.max(rect.top, 0), window.innerHeight - 380);
63
- setPosition({
64
- top: top,
65
- right: 12
66
- });
67
- }
68
- };
69
- window.addEventListener('click', handleClick);
70
- return function () {
71
- window.removeEventListener('click', handleClick);
72
- };
73
- }, [feedbackState.section]);
74
- useEffect(function () {
75
- resetSectionFeedback();
76
- }, [location.pathname]);
77
- if (!feedbackState.section) return null;
78
- return /*#__PURE__*/React.createElement(StyledWrapper, {
79
- style: {
80
- top: position.top,
81
- right: position.right
82
- }
83
- }, /*#__PURE__*/React.createElement(SectionFeedbackCommentForm, null));
84
- };
85
- var findClosetElement = function findClosetElement(e, elements) {
86
- var closestElement = null;
87
- var closestDistance = Infinity;
88
- elements.forEach(function (element) {
89
- var rect = element.getBoundingClientRect();
90
- var distance = Math.sqrt(Math.pow(rect.left + rect.width / 2 - e.clientX, 2) + Math.pow(rect.top + rect.height / 2 - e.clientY, 2));
91
- if (distance < closestDistance) {
92
- closestDistance = distance;
93
- closestElement = element;
94
- }
95
- });
96
- return closestElement;
97
- };