vap1 0.6.2 → 0.6.4

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.
@@ -13,5 +13,9 @@ export type DButtonProps = Pick<DBaseProps, 'cId' | 'style' | 'className' | 'val
13
13
  * 图标
14
14
  */
15
15
  icon?: string;
16
+ /**
17
+ * 保留位,用于紧急/临时扩展
18
+ */
19
+ [key: string]: any;
16
20
  };
17
21
  export type DButtonComponent = ForwardRefExoticComponent<DButtonProps & RefAttributes<DMethodRef>>;
@@ -29,5 +29,9 @@ export type DColProps = Pick<DBaseProps, 'cId' | 'title' | 'style' | 'className'
29
29
  * 清理浮动
30
30
  */
31
31
  clearBoth?: boolean;
32
+ /**
33
+ * 保留位,用于紧急/临时扩展
34
+ */
35
+ [key: string]: any;
32
36
  };
33
37
  export type DColComponent = ForwardRefExoticComponent<DColProps & RefAttributes<DMethodRef>>;
@@ -61,5 +61,9 @@ export type DDivProps = Pick<DBaseProps, 'cId' | 'style' | 'className' | 'onChan
61
61
  * 子组件
62
62
  */
63
63
  children?: ReactNode;
64
+ /**
65
+ * 保留位,用于紧急/临时扩展
66
+ */
67
+ [key: string]: any;
64
68
  };
65
69
  export type DDivComponent = ForwardRefExoticComponent<DDivProps & RefAttributes<DMethodRef>>;
@@ -60,6 +60,10 @@ type _BoxSelectBarProps = BaseItem & {
60
60
  * 选择区映射,用于一些特殊场景
61
61
  */
62
62
  selectRef?: MutableRefObject<any>;
63
+ /**
64
+ * 是否隐藏 toggle 按钮
65
+ */
66
+ hideToggle?: boolean;
63
67
  };
64
68
  /**
65
69
  * 说明: 内置 stree/dtree/ftree 三种树类型,和 list 类型
@@ -74,7 +74,11 @@ var _i18n_1 = require("../_i18n");
74
74
  var Icon_1 = require("../_adapt/Icon");
75
75
  exports.SelectBar = (0, react_1.forwardRef)(function (props, ref) {
76
76
  var _a = __read((0, react_1.useState)(null), 2), keyword = _a[0], setKeyword = _a[1];
77
- var _b = __read((0, hooks_1.useToggle)(props.defaultCollapse || false), 2), collapsed = _b[0], setCollapsed = _b[1];
77
+ var _b = __read((0, hooks_1.useToggle)(function () {
78
+ if (utils_1.GLOBAL.CONFIG.BOX.SELECTBAR_HIDE_TOGGLE || props.hideToggle)
79
+ return false;
80
+ return props.defaultCollapse || false;
81
+ }), 2), collapsed = _b[0], setCollapsed = _b[1];
78
82
  var component = (0, _register_1.getSelectBar)(props.type);
79
83
  (0, react_1.useLayoutEffect)(function () {
80
84
  props.onSelectCollapse(collapsed);
@@ -119,7 +123,7 @@ exports.SelectBar = (0, react_1.forwardRef)(function (props, ref) {
119
123
  react_1.default.createElement("div", { className: 'c-selectbar' },
120
124
  react_1.default.createElement("div", { className: 'c-selectbar-head' },
121
125
  react_1.default.createElement("div", { className: 'c-selectbar-title' },
122
- react_1.default.createElement(Icon_1.Icon, { type: "left-circle", title: utils_1.i18n.txt(_i18n_1.V.TXT_COLLAPSE), onClick: setCollapsed }),
126
+ props.hideToggle ? react_1.default.createElement("span", { className: 'vicon' }) : react_1.default.createElement(Icon_1.Icon, { type: "left-circle", title: utils_1.i18n.txt(_i18n_1.V.TXT_COLLAPSE), onClick: setCollapsed }),
123
127
  props.filter && react_1.default.createElement("input", { onChange: function (evt) { return utils_1.PageUtil.stopEvent(evt, function () { return setKeyword(evt.target.value); }); }, value: keyword, placeholder: utils_1.i18n.getText(props.ik, lodash_1.default.isString(props.title) ? props.title : '') }),
124
128
  !props.filter && react_1.default.createElement("span", null, title)),
125
129
  react_1.default.createElement("div", { className: 'c-selectbar-action' }, (props.actions || []).map(function (item) { return react_1.default.createElement(SearchAction, __assign({}, item)); }))),
@@ -1,6 +1,24 @@
1
+ type ToggleInit = boolean | (() => boolean);
1
2
  /**
2
3
  * 快速控制一个 布尔状态
4
+ * 支持无参数调用方式,类似 useState
3
5
  * 使用方法参考
4
6
  * https://github.com/streamich/react-use/blob/master/docs/useToggle.md
7
+ *
8
+ * @example
9
+ * // 无参数调用(默认 false)
10
+ * const [isVisible, toggle] = useToggle();
11
+ *
12
+ * // 带初始值
13
+ * const [isVisible, toggle] = useToggle(true);
14
+ *
15
+ * // 带函数初始值
16
+ * const [isVisible, toggle] = useToggle(() => localStorage.getItem('visible') === 'true');
17
+ *
18
+ * // 使用方式
19
+ * toggle(); // 切换状态
20
+ * toggle(true); // 设置为 true
21
+ * toggle(false); // 设置为 false
5
22
  */
6
- export declare const useToggle: (initialValue?: boolean) => [boolean, (nextValue?: any) => void];
23
+ export declare const useToggle: (initialValue?: ToggleInit) => [boolean, (nextValue?: any) => void];
24
+ export {};
@@ -1,15 +1,57 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
3
19
  exports.useToggle = void 0;
4
20
  var react_1 = require("react");
5
21
  var toggleReducer = function (state, nextValue) { return typeof nextValue === 'boolean' ? nextValue : !state; };
6
22
  /**
7
23
  * 快速控制一个 布尔状态
24
+ * 支持无参数调用方式,类似 useState
8
25
  * 使用方法参考
9
26
  * https://github.com/streamich/react-use/blob/master/docs/useToggle.md
27
+ *
28
+ * @example
29
+ * // 无参数调用(默认 false)
30
+ * const [isVisible, toggle] = useToggle();
31
+ *
32
+ * // 带初始值
33
+ * const [isVisible, toggle] = useToggle(true);
34
+ *
35
+ * // 带函数初始值
36
+ * const [isVisible, toggle] = useToggle(() => localStorage.getItem('visible') === 'true');
37
+ *
38
+ * // 使用方式
39
+ * toggle(); // 切换状态
40
+ * toggle(true); // 设置为 true
41
+ * toggle(false); // 设置为 false
10
42
  */
11
43
  var useToggle = function (initialValue) {
12
- if (initialValue === void 0) { initialValue = false; }
13
- return (0, react_1.useReducer)(toggleReducer, initialValue);
44
+ // 处理初始值,支持无参数调用
45
+ var getInitialValue = (0, react_1.useCallback)(function () {
46
+ if (initialValue === undefined) {
47
+ return false; // 默认值
48
+ }
49
+ if (typeof initialValue === 'function') {
50
+ return initialValue();
51
+ }
52
+ return initialValue;
53
+ }, [initialValue]);
54
+ var _a = __read((0, react_1.useReducer)(toggleReducer, getInitialValue()), 2), state = _a[0], dispatch = _a[1];
55
+ return [state, dispatch];
14
56
  };
15
57
  exports.useToggle = useToggle;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.6.2","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.6.4","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
package/utils/Global.d.ts CHANGED
@@ -128,6 +128,7 @@ export type GlobalSetting = {
128
128
  SELECT_CLOSE: 1 | 2;
129
129
  SELECTBAR_CLOSE: 1 | 2;
130
130
  SELECTBAR_WIDTH: number;
131
+ SELECTBAR_HIDE_TOGGLE: boolean;
131
132
  };
132
133
  /**
133
134
  * 通用上传服务,默认为微服务版的配置,单机版需要在 portal 里面定制一下
package/utils/Global.js CHANGED
@@ -59,7 +59,12 @@ var DEFAULT = {
59
59
  RESULT: { code: 'code', message: 'message', success: '0' },
60
60
  VLIST: { list: 'list', total: 'total', totalAcc: 'totalAcc', start: 'start_', count: 'count_', order: 'order_', by: 'by_' },
61
61
  VDATA: { data: 'data' },
62
- BOX: { SELECT_CLOSE: 2, SELECTBAR_CLOSE: 2, SELECTBAR_WIDTH: 250 },
62
+ BOX: {
63
+ SELECT_CLOSE: 2,
64
+ SELECTBAR_CLOSE: 2,
65
+ SELECTBAR_WIDTH: 250,
66
+ SELECTBAR_HIDE_TOGGLE: false
67
+ },
63
68
  AJAX: {
64
69
  timeout: 30000,
65
70
  beforeSend: null,