@tachybase/client 1.3.17 → 1.3.19

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,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ButtonProps } from 'antd';
3
3
  import { SchemaInitializerOptions } from '../types';
4
- export * from './useAriaAttributeOfMenuItem';
4
+ export { useAriaAttributeOfMenuItem } from './useAriaAttributeOfMenuItem';
5
5
  /**
6
6
  * @internal
7
7
  */
@@ -4,7 +4,7 @@ import { useApp } from "../../hooks/index.mjs";
4
4
  import { SchemaInitializerChild, SchemaInitializerItems } from "../components/index.mjs";
5
5
  import { SchemaInitializerButton } from "../components/SchemaInitializerButton.mjs";
6
6
  import { withInitializer } from "../hoc/index.mjs";
7
- export * from "./useAriaAttributeOfMenuItem.mjs";
7
+ import { useAriaAttributeOfMenuItem } from "./useAriaAttributeOfMenuItem.mjs";
8
8
  function useSchemaInitializerMenuItems(items, name, onClick) {
9
9
  const getMenuItems = useGetSchemaInitializerMenuItems(onClick);
10
10
  return useMemo(()=>getMenuItems(items, name), [
@@ -150,4 +150,4 @@ function useSchemaInitializerRender(name, options) {
150
150
  ]);
151
151
  return res;
152
152
  }
153
- export { useGetSchemaInitializerMenuItems, useSchemaInitializerMenuItems, useSchemaInitializerRender };
153
+ export { useAriaAttributeOfMenuItem, useGetSchemaInitializerMenuItems, useSchemaInitializerMenuItems, useSchemaInitializerRender };
@@ -50,7 +50,7 @@ class LocalePlugin extends Plugin {
50
50
  setValidateLanguage(null == data ? void 0 : null == (_data_data2 = data.data) ? void 0 : _data_data2.lang);
51
51
  loadConstrueLocale(null == data ? void 0 : data.data);
52
52
  const dayjsLang = dayjsLocale[null == data ? void 0 : null == (_data_data3 = data.data) ? void 0 : _data_data3.lang] || 'en';
53
- await import("dayjs/locale/".concat(dayjsLang));
53
+ await import("dayjs/locale/".concat(dayjsLang, ".js"));
54
54
  dayjs.locale(dayjsLang);
55
55
  const updateLocale = await import("dayjs/plugin/updateLocale");
56
56
  dayjs.extend(updateLocale.default);
@@ -2,7 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useContext, useMemo, useState } from "react";
3
3
  import { uid, useForm } from "@tachybase/schema";
4
4
  import { useTranslation } from "react-i18next";
5
- import { ActionContextProvider, DropdownVisibleContext, SchemaComponent, useActionContext } from "../index.mjs";
5
+ import { ActionContextProvider, DropdownVisibleContext, SchemaComponent, useActionContext, useCurrentUserContext } from "../index.mjs";
6
6
  import { useAPIClient } from "../api-client/index.mjs";
7
7
  const useCloseAction = ()=>{
8
8
  const { setVisible } = useActionContext();
@@ -17,15 +17,24 @@ const useCloseAction = ()=>{
17
17
  };
18
18
  };
19
19
  const useSaveCurrentUserValues = ()=>{
20
+ var _currentUser_data_data, _currentUser_data;
20
21
  const { setVisible } = useActionContext();
21
22
  const form = useForm();
22
23
  const api = useAPIClient();
24
+ const currentUser = useCurrentUserContext();
25
+ const hideOldPassword = (null == currentUser ? void 0 : null == (_currentUser_data = currentUser.data) ? void 0 : null == (_currentUser_data_data = _currentUser_data.data) ? void 0 : _currentUser_data_data.password) === null;
23
26
  return {
24
27
  async run () {
25
28
  await form.submit();
26
29
  await api.resource('auth').changePassword({
27
30
  values: form.values
28
31
  });
32
+ if (hideOldPassword) currentUser.mutate({
33
+ data: {
34
+ ...currentUser.data.data,
35
+ password: ''
36
+ }
37
+ });
29
38
  await form.reset();
30
39
  setVisible(false);
31
40
  }
@@ -45,7 +54,8 @@ const schema = {
45
54
  title: '{{t("Old password")}}',
46
55
  required: true,
47
56
  'x-component': 'Password',
48
- 'x-decorator': 'FormItem'
57
+ 'x-decorator': 'FormItem',
58
+ 'x-hidden': '{{ hideOldPassword }}'
49
59
  },
50
60
  newPassword: {
51
61
  type: 'string',
@@ -119,9 +129,12 @@ const schema = {
119
129
  }
120
130
  };
121
131
  const useChangePassword = ()=>{
132
+ var _currentUser_data_data, _currentUser_data;
122
133
  const ctx = useContext(DropdownVisibleContext);
123
134
  const [visible, setVisible] = useState(false);
124
135
  const { t } = useTranslation();
136
+ const currentUser = useCurrentUserContext();
137
+ const hideOldPassword = (null == currentUser ? void 0 : null == (_currentUser_data = currentUser.data) ? void 0 : null == (_currentUser_data_data = _currentUser_data.data) ? void 0 : _currentUser_data_data.password) === null;
125
138
  return useMemo(()=>({
126
139
  key: 'password',
127
140
  eventKey: 'ChangePassword',
@@ -142,7 +155,8 @@ const useChangePassword = ()=>{
142
155
  children: /*#__PURE__*/ jsx(SchemaComponent, {
143
156
  scope: {
144
157
  useCloseAction,
145
- useSaveCurrentUserValues
158
+ useSaveCurrentUserValues,
159
+ hideOldPassword
146
160
  },
147
161
  schema: schema
148
162
  })
@@ -151,7 +165,8 @@ const useChangePassword = ()=>{
151
165
  ]
152
166
  })
153
167
  }), [
154
- visible
168
+ visible,
169
+ hideOldPassword
155
170
  ]);
156
171
  };
157
172
  export { useChangePassword };
@@ -1,37 +1,5 @@
1
1
  "use strict";
2
- var __webpack_modules__ = {
3
- "../../../schema-component": function(module) {
4
- module.exports = require("../../../schema-component/index.js");
5
- },
6
- "../../hooks": function(module) {
7
- module.exports = require("../../hooks/index.js");
8
- },
9
- "../components/SchemaInitializerButton": function(module) {
10
- module.exports = require("../components/SchemaInitializerButton.js");
11
- },
12
- "../components": function(module) {
13
- module.exports = require("../components/index.js");
14
- },
15
- "../hoc": function(module) {
16
- module.exports = require("../hoc/index.js");
17
- },
18
- "./useAriaAttributeOfMenuItem": function(module) {
19
- module.exports = require("./useAriaAttributeOfMenuItem.js");
20
- },
21
- react: function(module) {
22
- module.exports = require("react");
23
- }
24
- };
25
- var __webpack_module_cache__ = {};
26
- function __webpack_require__(moduleId) {
27
- var cachedModule = __webpack_module_cache__[moduleId];
28
- if (void 0 !== cachedModule) return cachedModule.exports;
29
- var module = __webpack_module_cache__[moduleId] = {
30
- exports: {}
31
- };
32
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33
- return module.exports;
34
- }
2
+ var __webpack_require__ = {};
35
3
  (()=>{
36
4
  __webpack_require__.n = (module)=>{
37
5
  var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
@@ -63,181 +31,172 @@ function __webpack_require__(moduleId) {
63
31
  };
64
32
  })();
65
33
  var __webpack_exports__ = {};
66
- (()=>{
67
- __webpack_require__.r(__webpack_exports__);
68
- __webpack_require__.d(__webpack_exports__, {
69
- useGetSchemaInitializerMenuItems: ()=>useGetSchemaInitializerMenuItems,
70
- useSchemaInitializerMenuItems: ()=>useSchemaInitializerMenuItems,
71
- useSchemaInitializerRender: ()=>useSchemaInitializerRender
72
- });
73
- var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("react");
74
- var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
75
- var _schema_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../../schema-component");
76
- var _hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../hooks");
77
- var _components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../components");
78
- var _components_SchemaInitializerButton__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("../components/SchemaInitializerButton");
79
- var _hoc__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../hoc");
80
- var _useAriaAttributeOfMenuItem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./useAriaAttributeOfMenuItem");
81
- var __WEBPACK_REEXPORT_OBJECT__ = {};
82
- for(var __WEBPACK_IMPORT_KEY__ in _useAriaAttributeOfMenuItem__WEBPACK_IMPORTED_MODULE_6__)if ([
83
- "useGetSchemaInitializerMenuItems",
84
- "useSchemaInitializerRender",
85
- "useSchemaInitializerMenuItems",
86
- "default"
87
- ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
88
- return _useAriaAttributeOfMenuItem__WEBPACK_IMPORTED_MODULE_6__[key];
89
- }).bind(0, __WEBPACK_IMPORT_KEY__);
90
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
91
- function useSchemaInitializerMenuItems(items, name, onClick) {
92
- const getMenuItems = useGetSchemaInitializerMenuItems(onClick);
93
- return (0, react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(()=>getMenuItems(items, name), [
94
- getMenuItems,
95
- items,
96
- name
97
- ]);
98
- }
99
- function useGetSchemaInitializerMenuItems(onClick) {
100
- const compile = (0, _schema_component__WEBPACK_IMPORTED_MODULE_1__.useCompile)();
101
- const getMenuItems = (0, react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((items, parentKey)=>{
102
- if (!(null == items ? void 0 : items.length)) return [];
103
- return items.map((item, indexA)=>{
104
- const ItemComponent = item.component || item.Component;
105
- let element;
106
- const compiledTitle = item.title || item.label ? compile(item.title || item.label) : void 0;
107
- if (ItemComponent) {
108
- element = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components__WEBPACK_IMPORTED_MODULE_3__.SchemaInitializerChild, {
109
- ...item,
110
- title: compiledTitle
111
- });
112
- if (!element) return;
113
- }
114
- if ('divider' === item.type) return {
115
- type: 'divider',
116
- key: item.key || "divider-".concat(indexA)
117
- };
118
- if ('item' === item.type && ItemComponent) {
119
- if (!item.key) item.key = "".concat(compiledTitle, "-").concat(indexA);
120
- return item.associationField ? {
121
- key: item.key,
122
- label: element,
123
- associationField: item.associationField
124
- } : {
125
- key: item.key,
126
- label: element
127
- };
128
- }
129
- if ('itemGroup' === item.type) {
130
- const label = 'string' == typeof compiledTitle ? compiledTitle : item.title;
131
- const key = item.key || "".concat(parentKey, "-item-group-").concat(indexA);
132
- return {
133
- type: 'group',
134
- key,
135
- label,
136
- children: (null == item ? void 0 : item.children.length) ? getMenuItems(item.children, key) : []
137
- };
138
- }
139
- if ('subMenu' === item.type) {
140
- const label = compiledTitle;
141
- const key = item.key || item.name || "".concat(parentKey, "-sub-menu-").concat(indexA);
142
- return {
143
- key,
144
- label,
145
- children: (null == item ? void 0 : item.children.length) ? getMenuItems(item.children, key) : []
146
- };
147
- }
148
- if (item.isMenuType) {
149
- const { isMenuType, ...menuData } = item;
150
- return menuData;
151
- }
152
- const label = element || compiledTitle || item.label;
153
- const key = item.key || "".concat(parentKey, "-").concat(compiledTitle, "-").concat(indexA);
154
- const handleClick = (info)=>{
155
- info.domEvent.stopPropagation();
156
- if (info.key !== key) return;
157
- if (item.onClick) item.onClick({
158
- ...info,
159
- item
160
- });
161
- else null == onClick || onClick({
162
- ...info,
163
- item
164
- });
165
- };
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ useGetSchemaInitializerMenuItems: ()=>useGetSchemaInitializerMenuItems,
37
+ useSchemaInitializerRender: ()=>useSchemaInitializerRender,
38
+ useSchemaInitializerMenuItems: ()=>useSchemaInitializerMenuItems,
39
+ useAriaAttributeOfMenuItem: ()=>external_useAriaAttributeOfMenuItem_js_namespaceObject.useAriaAttributeOfMenuItem
40
+ });
41
+ const external_react_namespaceObject = require("react");
42
+ var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
43
+ const index_js_namespaceObject = require("../../../schema-component/index.js");
44
+ const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
45
+ const external_components_index_js_namespaceObject = require("../components/index.js");
46
+ const SchemaInitializerButton_js_namespaceObject = require("../components/SchemaInitializerButton.js");
47
+ const external_hoc_index_js_namespaceObject = require("../hoc/index.js");
48
+ const external_useAriaAttributeOfMenuItem_js_namespaceObject = require("./useAriaAttributeOfMenuItem.js");
49
+ function useSchemaInitializerMenuItems(items, name, onClick) {
50
+ const getMenuItems = useGetSchemaInitializerMenuItems(onClick);
51
+ return (0, external_react_namespaceObject.useMemo)(()=>getMenuItems(items, name), [
52
+ getMenuItems,
53
+ items,
54
+ name
55
+ ]);
56
+ }
57
+ function useGetSchemaInitializerMenuItems(onClick) {
58
+ const compile = (0, index_js_namespaceObject.useCompile)();
59
+ const getMenuItems = (0, external_react_namespaceObject.useCallback)((items, parentKey)=>{
60
+ if (!(null == items ? void 0 : items.length)) return [];
61
+ return items.map((item, indexA)=>{
62
+ const ItemComponent = item.component || item.Component;
63
+ let element;
64
+ const compiledTitle = item.title || item.label ? compile(item.title || item.label) : void 0;
65
+ if (ItemComponent) {
66
+ element = /*#__PURE__*/ external_react_default().createElement(external_components_index_js_namespaceObject.SchemaInitializerChild, {
67
+ ...item,
68
+ title: compiledTitle
69
+ });
70
+ if (!element) return;
71
+ }
72
+ if ('divider' === item.type) return {
73
+ type: 'divider',
74
+ key: item.key || "divider-".concat(indexA)
75
+ };
76
+ if ('item' === item.type && ItemComponent) {
77
+ if (!item.key) item.key = "".concat(compiledTitle, "-").concat(indexA);
166
78
  return item.associationField ? {
79
+ key: item.key,
80
+ label: element,
81
+ associationField: item.associationField
82
+ } : {
83
+ key: item.key,
84
+ label: element
85
+ };
86
+ }
87
+ if ('itemGroup' === item.type) {
88
+ const label = 'string' == typeof compiledTitle ? compiledTitle : item.title;
89
+ const key = item.key || "".concat(parentKey, "-item-group-").concat(indexA);
90
+ return {
91
+ type: 'group',
167
92
  key,
168
93
  label,
169
- associationField: item.associationField,
170
- onClick: handleClick
171
- } : {
94
+ children: (null == item ? void 0 : item.children.length) ? getMenuItems(item.children, key) : []
95
+ };
96
+ }
97
+ if ('subMenu' === item.type) {
98
+ const label = compiledTitle;
99
+ const key = item.key || item.name || "".concat(parentKey, "-sub-menu-").concat(indexA);
100
+ return {
172
101
  key,
173
102
  label,
174
- onClick: handleClick
103
+ children: (null == item ? void 0 : item.children.length) ? getMenuItems(item.children, key) : []
175
104
  };
176
- });
177
- }, [
178
- compile,
179
- onClick
180
- ]);
181
- return getMenuItems;
182
- }
183
- const InitializerComponent = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0___default().memo((options)=>{
184
- const Component = options.Component || _components_SchemaInitializerButton__WEBPACK_IMPORTED_MODULE_4__.SchemaInitializerButton;
185
- const ItemsComponent = options.ItemsComponent || _components__WEBPACK_IMPORTED_MODULE_3__.SchemaInitializerItems;
186
- const itemsComponentProps = {
187
- ...options.itemsComponentProps,
188
- options,
189
- items: options.items,
190
- style: options.itemsComponentStyle
105
+ }
106
+ if (item.isMenuType) {
107
+ const { isMenuType, ...menuData } = item;
108
+ return menuData;
109
+ }
110
+ const label = element || compiledTitle || item.label;
111
+ const key = item.key || "".concat(parentKey, "-").concat(compiledTitle, "-").concat(indexA);
112
+ const handleClick = (info)=>{
113
+ info.domEvent.stopPropagation();
114
+ if (info.key !== key) return;
115
+ if (item.onClick) item.onClick({
116
+ ...info,
117
+ item
118
+ });
119
+ else null == onClick || onClick({
120
+ ...info,
121
+ item
122
+ });
123
+ };
124
+ return item.associationField ? {
125
+ key,
126
+ label,
127
+ associationField: item.associationField,
128
+ onClick: handleClick
129
+ } : {
130
+ key,
131
+ label,
132
+ onClick: handleClick
133
+ };
134
+ });
135
+ }, [
136
+ compile,
137
+ onClick
138
+ ]);
139
+ return getMenuItems;
140
+ }
141
+ const InitializerComponent = /*#__PURE__*/ external_react_default().memo((options)=>{
142
+ const Component = options.Component || SchemaInitializerButton_js_namespaceObject.SchemaInitializerButton;
143
+ const ItemsComponent = options.ItemsComponent || external_components_index_js_namespaceObject.SchemaInitializerItems;
144
+ const itemsComponentProps = {
145
+ ...options.itemsComponentProps,
146
+ options,
147
+ items: options.items,
148
+ style: options.itemsComponentStyle
149
+ };
150
+ const C = (0, external_react_namespaceObject.useMemo)(()=>(0, external_hoc_index_js_namespaceObject.withInitializer)(Component), [
151
+ Component
152
+ ]);
153
+ return /*#__PURE__*/ external_react_default().createElement(C, options, /*#__PURE__*/ external_react_default().createElement(ItemsComponent, itemsComponentProps));
154
+ });
155
+ InitializerComponent.displayName = 'InitializerComponent';
156
+ function useSchemaInitializerRender(name, options) {
157
+ const app = (0, external_hooks_index_js_namespaceObject.useApp)();
158
+ const renderCache = external_react_default().useRef({});
159
+ const initializer = (0, external_react_namespaceObject.useMemo)(()=>app.schemaInitializerManager.get(name), [
160
+ app.schemaInitializerManager,
161
+ name
162
+ ]);
163
+ const res = (0, external_react_namespaceObject.useMemo)(()=>{
164
+ if (!name) return {
165
+ exists: false,
166
+ render: ()=>null
191
167
  };
192
- const C = (0, react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(()=>(0, _hoc__WEBPACK_IMPORTED_MODULE_5__.withInitializer)(Component), [
193
- Component
194
- ]);
195
- return /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0___default().createElement(C, options, /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ItemsComponent, itemsComponentProps));
196
- });
197
- InitializerComponent.displayName = 'InitializerComponent';
198
- function useSchemaInitializerRender(name, options) {
199
- const app = (0, _hooks__WEBPACK_IMPORTED_MODULE_2__.useApp)();
200
- const renderCache = react__WEBPACK_IMPORTED_MODULE_0___default().useRef({});
201
- const initializer = (0, react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(()=>app.schemaInitializerManager.get(name), [
202
- app.schemaInitializerManager,
203
- name
204
- ]);
205
- const res = (0, react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(()=>{
206
- if (!name) return {
168
+ if (!initializer) {
169
+ console.error('[tachybase]: SchemaInitializer "'.concat(name, '" not found'));
170
+ return {
207
171
  exists: false,
208
172
  render: ()=>null
209
173
  };
210
- if (!initializer) {
211
- console.error('[tachybase]: SchemaInitializer "'.concat(name, '" not found'));
212
- return {
213
- exists: false,
214
- render: ()=>null
215
- };
174
+ }
175
+ return {
176
+ exists: true,
177
+ render: (props)=>{
178
+ const key = JSON.stringify(props) || '{}';
179
+ if (renderCache.current[key]) return renderCache.current[key];
180
+ return renderCache.current[key] = /*#__PURE__*/ external_react_default().createElement(InitializerComponent, {
181
+ ...initializer.options,
182
+ ...options,
183
+ ...props
184
+ });
216
185
  }
217
- return {
218
- exists: true,
219
- render: (props)=>{
220
- const key = JSON.stringify(props) || '{}';
221
- if (renderCache.current[key]) return renderCache.current[key];
222
- return renderCache.current[key] = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_0___default().createElement(InitializerComponent, {
223
- ...initializer.options,
224
- ...options,
225
- ...props
226
- });
227
- }
228
- };
229
- }, [
230
- initializer,
231
- name,
232
- options
233
- ]);
234
- return res;
235
- }
236
- })();
186
+ };
187
+ }, [
188
+ initializer,
189
+ name,
190
+ options
191
+ ]);
192
+ return res;
193
+ }
194
+ exports.useAriaAttributeOfMenuItem = __webpack_exports__.useAriaAttributeOfMenuItem;
237
195
  exports.useGetSchemaInitializerMenuItems = __webpack_exports__.useGetSchemaInitializerMenuItems;
238
196
  exports.useSchemaInitializerMenuItems = __webpack_exports__.useSchemaInitializerMenuItems;
239
197
  exports.useSchemaInitializerRender = __webpack_exports__.useSchemaInitializerRender;
240
198
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
199
+ "useAriaAttributeOfMenuItem",
241
200
  "useGetSchemaInitializerMenuItems",
242
201
  "useSchemaInitializerMenuItems",
243
202
  "useSchemaInitializerRender"
@@ -105,7 +105,7 @@ var __webpack_exports__ = {};
105
105
  (0, schema_namespaceObject.setValidateLanguage)(null == data ? void 0 : null == (_data_data2 = data.data) ? void 0 : _data_data2.lang);
106
106
  (0, external_loadConstrueLocale_js_namespaceObject.loadConstrueLocale)(null == data ? void 0 : data.data);
107
107
  const dayjsLang = index_js_namespaceObject.dayjsLocale[null == data ? void 0 : null == (_data_data3 = data.data) ? void 0 : _data_data3.lang] || 'en';
108
- await import("dayjs/locale/".concat(dayjsLang));
108
+ await import("dayjs/locale/".concat(dayjsLang, ".js"));
109
109
  external_dayjs_default().locale(dayjsLang);
110
110
  const updateLocale = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "dayjs/plugin/updateLocale"));
111
111
  external_dayjs_default().extend(updateLocale.default);
@@ -45,15 +45,24 @@ const useCloseAction = ()=>{
45
45
  };
46
46
  };
47
47
  const useSaveCurrentUserValues = ()=>{
48
+ var _currentUser_data_data, _currentUser_data;
48
49
  const { setVisible } = (0, external_index_js_namespaceObject.useActionContext)();
49
50
  const form = (0, schema_namespaceObject.useForm)();
50
51
  const api = (0, index_js_namespaceObject.useAPIClient)();
52
+ const currentUser = (0, external_index_js_namespaceObject.useCurrentUserContext)();
53
+ const hideOldPassword = (null == currentUser ? void 0 : null == (_currentUser_data = currentUser.data) ? void 0 : null == (_currentUser_data_data = _currentUser_data.data) ? void 0 : _currentUser_data_data.password) === null;
51
54
  return {
52
55
  async run () {
53
56
  await form.submit();
54
57
  await api.resource('auth').changePassword({
55
58
  values: form.values
56
59
  });
60
+ if (hideOldPassword) currentUser.mutate({
61
+ data: {
62
+ ...currentUser.data.data,
63
+ password: ''
64
+ }
65
+ });
57
66
  await form.reset();
58
67
  setVisible(false);
59
68
  }
@@ -73,7 +82,8 @@ const schema = {
73
82
  title: '{{t("Old password")}}',
74
83
  required: true,
75
84
  'x-component': 'Password',
76
- 'x-decorator': 'FormItem'
85
+ 'x-decorator': 'FormItem',
86
+ 'x-hidden': '{{ hideOldPassword }}'
77
87
  },
78
88
  newPassword: {
79
89
  type: 'string',
@@ -147,9 +157,12 @@ const schema = {
147
157
  }
148
158
  };
149
159
  const useChangePassword = ()=>{
160
+ var _currentUser_data_data, _currentUser_data;
150
161
  const ctx = (0, external_react_namespaceObject.useContext)(external_index_js_namespaceObject.DropdownVisibleContext);
151
162
  const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
152
163
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
164
+ const currentUser = (0, external_index_js_namespaceObject.useCurrentUserContext)();
165
+ const hideOldPassword = (null == currentUser ? void 0 : null == (_currentUser_data = currentUser.data) ? void 0 : null == (_currentUser_data_data = _currentUser_data.data) ? void 0 : _currentUser_data_data.password) === null;
153
166
  return (0, external_react_namespaceObject.useMemo)(()=>({
154
167
  key: 'password',
155
168
  eventKey: 'ChangePassword',
@@ -170,7 +183,8 @@ const useChangePassword = ()=>{
170
183
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_js_namespaceObject.SchemaComponent, {
171
184
  scope: {
172
185
  useCloseAction,
173
- useSaveCurrentUserValues
186
+ useSaveCurrentUserValues,
187
+ hideOldPassword
174
188
  },
175
189
  schema: schema
176
190
  })
@@ -179,7 +193,8 @@ const useChangePassword = ()=>{
179
193
  ]
180
194
  })
181
195
  }), [
182
- visible
196
+ visible,
197
+ hideOldPassword
183
198
  ]);
184
199
  };
185
200
  exports.useChangePassword = __webpack_exports__.useChangePassword;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/client",
3
- "version": "1.3.17",
3
+ "version": "1.3.19",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.mjs",
@@ -19,9 +19,9 @@
19
19
  "@dnd-kit/utilities": "^3.2.2",
20
20
  "@emotion/css": "^11.13.5",
21
21
  "@floating-ui/react": "0.26.28",
22
- "@js-preview/excel": "^1.7.12",
22
+ "@js-preview/excel": "^1.7.14",
23
23
  "@lottiefiles/dotlottie-react": "^0.9.3",
24
- "ahooks": "^3.8.4",
24
+ "ahooks": "^3.9.0",
25
25
  "antd": "5.22.5",
26
26
  "antd-style": "3.7.1",
27
27
  "axios": "1.7.7",
@@ -43,7 +43,7 @@
43
43
  "mitt": "^3.0.1",
44
44
  "nanoid": "^3.3.8",
45
45
  "qrcode": "^1.5.4",
46
- "rc-menu": "9.16.0",
46
+ "rc-menu": "9.16.1",
47
47
  "rc-tree-select": "^5.25.0",
48
48
  "rc-util": "^5.44.2",
49
49
  "react-beautiful-dnd": "^13.1.1",
@@ -66,19 +66,18 @@
66
66
  "sanitize-html": "2.17.0",
67
67
  "use-deep-compare-effect": "^1.8.1",
68
68
  "xlsx": "0.18.5",
69
- "@tachybase/components": "1.3.17",
70
- "@tachybase/evaluators": "1.3.17",
71
- "@tachybase/requirejs": "1.3.17",
72
- "@tachybase/schema": "1.3.17",
73
- "@tachybase/sdk": "1.3.17",
74
- "@tachybase/utils": "1.3.17"
69
+ "@tachybase/requirejs": "1.3.19",
70
+ "@tachybase/components": "1.3.19",
71
+ "@tachybase/schema": "1.3.19",
72
+ "@tachybase/evaluators": "1.3.19",
73
+ "@tachybase/sdk": "1.3.19",
74
+ "@tachybase/utils": "1.3.19"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@testing-library/react": "^16.2.0",
78
78
  "@types/flat": "^5.0.5",
79
79
  "@types/lodash": "^4.17.13",
80
80
  "@types/markdown-it": "12.2.3",
81
- "@types/markdown-it-highlightjs": "3.3.4",
82
81
  "@types/react-big-calendar": "^1.16.0"
83
82
  },
84
83
  "peerDependencies": {