yootd 0.0.45 → 0.0.47

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.
@@ -15,14 +15,14 @@ var statusColor = {
15
15
  2: ['var(--ant-color-warning-bg)', 'var(--ant-color-warning)'],
16
16
  3: ['var(--ant-color-success-bg)', 'var(--ant-color-success)'],
17
17
  4: ['var(--ant-color-error-bg)', 'var(--ant-color-error)'],
18
- 5: ['var(--ant-color-border-secondary)', 'var(--ant-color-border)']
18
+ 0: ['var(--ant-color-border-secondary)', 'var(--ant-color-text-quaternary)']
19
19
  };
20
20
  var statusText = {
21
21
  1: '审批中',
22
22
  2: '审批中',
23
23
  3: '审批通过',
24
24
  4: '已驳回',
25
- 5: '已撤回'
25
+ 0: '已撤回'
26
26
  };
27
27
  export var ApprovalProcess = function ApprovalProcess(_ref) {
28
28
  var _queryProcess$hisTask;
@@ -42,7 +42,7 @@ export var ApprovalProcess = function ApprovalProcess(_ref) {
42
42
  4: /*#__PURE__*/React.createElement(Failed, {
43
43
  className: "".concat(mb.b('steps').b('info').b('avatar').b('status').b('icon'))
44
44
  }),
45
- 5: /*#__PURE__*/React.createElement(BackOut, {
45
+ 0: /*#__PURE__*/React.createElement(BackOut, {
46
46
  className: "".concat(mb.b('steps').b('info').b('avatar').b('status').b('icon'))
47
47
  })
48
48
  };
@@ -58,6 +58,9 @@ export var ApprovalProcess = function ApprovalProcess(_ref) {
58
58
  useEffect(function () {
59
59
  refetch();
60
60
  }, []);
61
+ useEffect(function () {
62
+ console.log(steps);
63
+ }, [steps]);
61
64
  return /*#__PURE__*/React.createElement("div", {
62
65
  className: "".concat(mb)
63
66
  }, steps.map(function (step, index) {
@@ -11,5 +11,16 @@ declare class Bem {
11
11
  toString(): string;
12
12
  clone(): Bem;
13
13
  }
14
+ /**
15
+ * 自定义 Hook,用于创建并缓存 BEM 命名实例
16
+ * @param namespace - BEM 命名的命名空间,用于生成基础类名
17
+ * @returns {Bem} 返回一个 Bem 实例,用于生成 BEM 格式的类名
18
+ *
19
+ * 使用示例:
20
+ * const b = useBem('button');
21
+ * b.toString(); // => 'yot-button'
22
+ * b.e('icon').toString(); // => 'yot-button__icon'
23
+ * b.m('primary').toString(); // => 'yot-button--primary'
24
+ */
14
25
  export declare const useBem: (namespace: string) => Bem;
15
26
  export {};
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
8
  import _ from 'lodash';
9
+ import { useRef } from 'react';
9
10
  var Bem = /*#__PURE__*/function () {
10
11
  function Bem(_namespace) {
11
12
  _classCallCheck(this, Bem);
@@ -75,6 +76,26 @@ var Bem = /*#__PURE__*/function () {
75
76
  }]);
76
77
  return Bem;
77
78
  }();
79
+ /**
80
+ * 自定义 Hook,用于创建并缓存 BEM 命名实例
81
+ * @param namespace - BEM 命名的命名空间,用于生成基础类名
82
+ * @returns {Bem} 返回一个 Bem 实例,用于生成 BEM 格式的类名
83
+ *
84
+ * 使用示例:
85
+ * const b = useBem('button');
86
+ * b.toString(); // => 'yot-button'
87
+ * b.e('icon').toString(); // => 'yot-button__icon'
88
+ * b.m('primary').toString(); // => 'yot-button--primary'
89
+ */
78
90
  export var useBem = function useBem(namespace) {
79
- return new Bem(namespace);
91
+ // 使用 useRef 存储 Bem 实例,确保在组件重渲染时保持实例不变
92
+ var bemRef = useRef();
93
+
94
+ // 仅在首次渲染时创建 Bem 实例
95
+ if (!bemRef.current) {
96
+ bemRef.current = new Bem(namespace);
97
+ }
98
+
99
+ // 返回缓存的 Bem 实例
100
+ return bemRef.current;
80
101
  };
@@ -3,10 +3,42 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
3
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
5
  import { Modal as AntModal } from 'antd';
6
- import React from 'react';
6
+ import React, { useEffect } from 'react';
7
7
  import { HeaderIcon } from "./components/header-icon";
8
8
  import { useBem } from "../hooks/useBem";
9
9
  import "./index.scss";
10
+ // 添加一个工具函数来创建 SVG
11
+ var createColorDefs = function createColorDefs(mb) {
12
+ var svgId = 'yootd-modal-color-defs';
13
+
14
+ // 检查是否已存在相同 id 的 SVG
15
+ if (document.getElementById(svgId)) {
16
+ return null;
17
+ }
18
+
19
+ // 创建 SVG 元素及其子元素
20
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
21
+ svg.setAttribute('id', svgId);
22
+ svg.setAttribute('class', mb.e('color-defs').toString());
23
+ var defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
24
+ var linearGradient = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient');
25
+ linearGradient.setAttribute('id', 'paint0_linear_589_9609');
26
+ linearGradient.setAttribute('x1', '132.5');
27
+ linearGradient.setAttribute('y1', '0');
28
+ linearGradient.setAttribute('x2', '132.5');
29
+ linearGradient.setAttribute('y2', '56');
30
+ linearGradient.setAttribute('gradientUnits', 'userSpaceOnUse');
31
+ var stop1 = document.createElementNS('http://www.w3.org/2000/svg', 'stop');
32
+ stop1.setAttribute('class', 'stop-color-1');
33
+ var stop2 = document.createElementNS('http://www.w3.org/2000/svg', 'stop');
34
+ stop2.setAttribute('class', 'stop-color-2');
35
+ stop2.setAttribute('offset', '1');
36
+ linearGradient.appendChild(stop1);
37
+ linearGradient.appendChild(stop2);
38
+ defs.appendChild(linearGradient);
39
+ svg.appendChild(defs);
40
+ return svg;
41
+ };
10
42
  var ModalComponent = function ModalComponent(_ref) {
11
43
  var className = _ref.className,
12
44
  children = _ref.children,
@@ -17,21 +49,13 @@ var ModalComponent = function ModalComponent(_ref) {
17
49
 
18
50
  // title content block
19
51
  var tcb = mb.b('title').b('content');
20
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
21
- className: "".concat(mb.e('color-defs'))
22
- }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
23
- id: "paint0_linear_589_9609",
24
- x1: "132.5",
25
- y1: "0",
26
- x2: "132.5",
27
- y2: "56",
28
- gradientUnits: "userSpaceOnUse"
29
- }, /*#__PURE__*/React.createElement("stop", {
30
- className: "stop-color-1"
31
- }), /*#__PURE__*/React.createElement("stop", {
32
- className: "stop-color-2",
33
- offset: "1"
34
- })))), /*#__PURE__*/React.createElement(AntModal, _extends({}, rest, {
52
+ useEffect(function () {
53
+ var svg = createColorDefs(mb);
54
+ if (svg) {
55
+ document.body.appendChild(svg);
56
+ }
57
+ }, [mb]);
58
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AntModal, _extends({}, rest, {
35
59
  className: "".concat(mb, " ").concat(className !== null && className !== void 0 ? className : ''),
36
60
  title: /*#__PURE__*/React.createElement("div", {
37
61
  className: "".concat(tcb)
@@ -79,7 +79,7 @@
79
79
  }
80
80
  .ant-tag.ant-tag-default {
81
81
  background-color: var(--ant-color-border-secondary);
82
- color: var(--ant-color-border);
82
+ color: var(--ant-color-text-quaternary);
83
83
  }
84
84
  .ant-tag.ant-tag-processing {
85
85
  background-color: var(--ant-color-primary-bg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yootd",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",