@pisell/materials 6.0.6 → 6.0.8

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.
Files changed (182) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +7 -7
  6. package/build/lowcode/preview.js +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +21 -53
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +18 -50
  11. package/es/components/config-provider/index.js +1 -1
  12. package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +20 -11
  13. package/es/components/dataSourceComponents/dataSourceForm/formItem.js +1 -1
  14. package/es/components/dataSourceComponents/dataSourceForm/group/index.less +2 -2
  15. package/es/components/dataSourceComponents/dataSourceForm/index.js +4 -2
  16. package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +4 -0
  17. package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +11 -3
  18. package/es/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.js +10 -3
  19. package/es/components/dataSourceComponents/dataSourceForm/serve.d.ts +3 -2
  20. package/es/components/dataSourceComponents/dataSourceForm/serve.js +36 -20
  21. package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +46 -25
  22. package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +5 -0
  23. package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +3 -1
  24. package/es/components/dataSourceComponents/dataSourceForm/utils.js +38 -10
  25. package/es/components/dataSourceComponents/dataSourceTable/filter/index.js +1 -1
  26. package/es/components/dataSourceComponents/dataSourceTable/hooks/useColumns.js +4 -1
  27. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +7 -0
  28. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +28 -5
  29. package/es/components/dataSourceComponents/dataSourceTable/index.js +4 -2
  30. package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +9 -1
  31. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +7 -1
  32. package/es/components/dataSourceComponents/fields/Input.Url/ReadPretty.d.ts +1 -0
  33. package/es/components/dataSourceComponents/fields/Input.Url/ReadPretty.js +16 -1
  34. package/es/components/dataSourceComponents/fields/Input.Url/ReadPretty.less +1 -1
  35. package/es/components/dataSourceComponents/fields/Select/index.js +7 -1
  36. package/es/components/dataSourceComponents/fields/Upload/serve.d.ts +4 -1
  37. package/es/components/dataSourceComponents/fields/Upload/serve.js +10 -31
  38. package/es/components/dataSourceComponents/hooks/useActions.d.ts +2 -1
  39. package/es/components/dataSourceComponents/hooks/useActions.js +73 -36
  40. package/es/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +7 -0
  41. package/es/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +3 -1
  42. package/es/components/dataSourceComponents/provider/variables/VariablesProvider.js +49 -3
  43. package/es/components/login-and-register/index.d.ts +82 -0
  44. package/es/components/login-and-register/index.js +360 -0
  45. package/es/components/login-and-register/index.less +211 -0
  46. package/es/components/organizationTenantSwitcher/defaultLogo.png +0 -0
  47. package/es/components/organizationTenantSwitcher/index.d.ts +17 -0
  48. package/es/components/organizationTenantSwitcher/index.js +96 -0
  49. package/es/components/organizationTenantSwitcher/index.less +88 -0
  50. package/es/components/page/index.js +4 -4
  51. package/es/components/page-header/index.d.ts +14 -0
  52. package/es/components/page-header/index.js +36 -0
  53. package/es/components/page-header/index.less +45 -0
  54. package/es/components/pisellAvatar/index.d.ts +19 -0
  55. package/es/components/pisellAvatar/index.js +89 -0
  56. package/es/components/pisellAvatar/index.less +26 -0
  57. package/es/components/pisellModal/components/PcModal/index.js +1 -1
  58. package/es/components/pisellTags/index.d.ts +13 -0
  59. package/es/components/pisellTags/index.js +83 -0
  60. package/es/components/pisellTags/index.less +17 -0
  61. package/es/components/pisellTags/utils.d.ts +1 -0
  62. package/es/components/pisellTags/utils.js +89 -0
  63. package/es/components/pisellText/components/Amount/index.js +1 -1
  64. package/es/components/pisellViewGrid/index.d.ts +16 -0
  65. package/es/components/pisellViewGrid/index.js +66 -0
  66. package/es/components/pisellViewGrid/index.less +31 -0
  67. package/es/components/profileMenu/index.d.ts +26 -0
  68. package/es/components/profileMenu/index.js +115 -0
  69. package/es/components/profileMenu/index.less +135 -0
  70. package/es/components/table/Header/index.js +8 -11
  71. package/es/index.d.ts +7 -0
  72. package/es/index.js +8 -1
  73. package/es/locales/en-US.d.ts +1 -0
  74. package/es/locales/en-US.js +1 -0
  75. package/es/locales/zh-CN.d.ts +1 -0
  76. package/es/locales/zh-CN.js +1 -0
  77. package/es/locales/zh-TW.d.ts +1 -0
  78. package/es/locales/zh-TW.js +1 -0
  79. package/lib/components/config-provider/index.js +1 -1
  80. package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +22 -4
  81. package/lib/components/dataSourceComponents/dataSourceForm/formItem.js +1 -1
  82. package/lib/components/dataSourceComponents/dataSourceForm/group/index.less +2 -2
  83. package/lib/components/dataSourceComponents/dataSourceForm/index.js +3 -2
  84. package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +4 -0
  85. package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +17 -3
  86. package/lib/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.js +16 -6
  87. package/lib/components/dataSourceComponents/dataSourceForm/serve.d.ts +3 -2
  88. package/lib/components/dataSourceComponents/dataSourceForm/serve.js +9 -5
  89. package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +15 -4
  90. package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +5 -0
  91. package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +3 -1
  92. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +51 -5
  93. package/lib/components/dataSourceComponents/dataSourceTable/filter/index.js +1 -1
  94. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useColumns.js +4 -1
  95. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +7 -0
  96. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +24 -3
  97. package/lib/components/dataSourceComponents/dataSourceTable/index.js +2 -2
  98. package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +9 -1
  99. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +6 -1
  100. package/lib/components/dataSourceComponents/fields/Input.Url/ReadPretty.d.ts +1 -0
  101. package/lib/components/dataSourceComponents/fields/Input.Url/ReadPretty.js +17 -2
  102. package/lib/components/dataSourceComponents/fields/Input.Url/ReadPretty.less +1 -1
  103. package/lib/components/dataSourceComponents/fields/Select/index.js +5 -1
  104. package/lib/components/dataSourceComponents/fields/Upload/serve.d.ts +4 -1
  105. package/lib/components/dataSourceComponents/fields/Upload/serve.js +20 -12
  106. package/lib/components/dataSourceComponents/hooks/useActions.d.ts +2 -1
  107. package/lib/components/dataSourceComponents/hooks/useActions.js +25 -7
  108. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +7 -0
  109. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +3 -1
  110. package/lib/components/dataSourceComponents/provider/variables/VariablesProvider.js +49 -3
  111. package/lib/components/login-and-register/index.d.ts +82 -0
  112. package/lib/components/login-and-register/index.js +261 -0
  113. package/lib/components/login-and-register/index.less +211 -0
  114. package/lib/components/organizationTenantSwitcher/defaultLogo.png +0 -0
  115. package/lib/components/organizationTenantSwitcher/index.d.ts +17 -0
  116. package/lib/components/organizationTenantSwitcher/index.js +119 -0
  117. package/lib/components/organizationTenantSwitcher/index.less +88 -0
  118. package/lib/components/page/index.js +4 -4
  119. package/lib/components/page-header/index.d.ts +14 -0
  120. package/lib/components/page-header/index.js +63 -0
  121. package/lib/components/page-header/index.less +45 -0
  122. package/lib/components/pisellAvatar/index.d.ts +19 -0
  123. package/lib/components/pisellAvatar/index.js +108 -0
  124. package/lib/components/pisellAvatar/index.less +26 -0
  125. package/lib/components/pisellModal/components/PcModal/index.js +1 -1
  126. package/lib/components/pisellTags/index.d.ts +13 -0
  127. package/lib/components/pisellTags/index.js +113 -0
  128. package/lib/components/pisellTags/index.less +17 -0
  129. package/lib/components/pisellTags/utils.d.ts +1 -0
  130. package/lib/components/pisellTags/utils.js +86 -0
  131. package/lib/components/pisellText/components/Amount/index.js +2 -2
  132. package/lib/components/pisellViewGrid/index.d.ts +16 -0
  133. package/lib/components/pisellViewGrid/index.js +98 -0
  134. package/lib/components/pisellViewGrid/index.less +31 -0
  135. package/lib/components/profileMenu/index.d.ts +26 -0
  136. package/lib/components/profileMenu/index.js +113 -0
  137. package/lib/components/profileMenu/index.less +135 -0
  138. package/lib/components/table/Header/index.js +11 -1
  139. package/lib/index.d.ts +7 -0
  140. package/lib/index.js +21 -0
  141. package/lib/locales/en-US.d.ts +1 -0
  142. package/lib/locales/en-US.js +1 -0
  143. package/lib/locales/zh-CN.d.ts +1 -0
  144. package/lib/locales/zh-CN.js +1 -0
  145. package/lib/locales/zh-TW.d.ts +1 -0
  146. package/lib/locales/zh-TW.js +1 -0
  147. package/lowcode/_utils/defaultSchema.ts +64 -0
  148. package/lowcode/data-source-form/meta.ts +130 -0
  149. package/lowcode/data-source-form/utils.ts +33 -3
  150. package/lowcode/data-source-table/meta.ts +139 -3
  151. package/lowcode/data-source-table/utils.tsx +6 -0
  152. package/lowcode/form-item-date-picker/snippets.ts +3 -0
  153. package/lowcode/form-item-input/snippets.ts +3 -1
  154. package/lowcode/form-item-input-number/snippets.ts +4 -0
  155. package/lowcode/form-item-input.email/snippets.ts +3 -0
  156. package/lowcode/form-item-input.json/snippets.ts +4 -1
  157. package/lowcode/form-item-input.password/snippets.ts +3 -0
  158. package/lowcode/form-item-input.phone/snippets.ts +3 -0
  159. package/lowcode/form-item-input.text-area/snippets.ts +3 -1
  160. package/lowcode/form-item-input.url/snippets.ts +3 -0
  161. package/lowcode/form-item-select/meta.ts +2 -1
  162. package/lowcode/form-item-select/snippets.ts +6 -0
  163. package/lowcode/form-item-time-picker/snippets.ts +3 -0
  164. package/lowcode/form-item-translation/snippets.ts +3 -1
  165. package/lowcode/login-and-register/meta.ts +541 -0
  166. package/lowcode/login-and-register/snippets.ts +38 -0
  167. package/lowcode/organization-tenant-switch/meta.ts +127 -0
  168. package/lowcode/page-header/meta.ts +68 -124
  169. package/lowcode/page-header/snippets.ts +1 -1
  170. package/lowcode/pisell-avatar/__screenshots__/avatar-1.jpg +0 -0
  171. package/lowcode/pisell-avatar/meta.ts +111 -0
  172. package/lowcode/pisell-avatar/snippets.ts +14 -0
  173. package/lowcode/pisell-tags/__screenshots__/tag-1.png +0 -0
  174. package/lowcode/pisell-tags/meta.ts +123 -0
  175. package/lowcode/pisell-tags/snippets.ts +14 -0
  176. package/lowcode/pisell-view-grid/__screenshots__/card-1.png +0 -0
  177. package/lowcode/pisell-view-grid/meta.ts +167 -0
  178. package/lowcode/pisell-view-grid/snippets.ts +54 -0
  179. package/lowcode/profile-menu/meta.ts +175 -0
  180. package/lowcode/profile-menu/snippets.ts +71 -0
  181. package/lowcode/submit-button/meta.ts +6 -0
  182. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
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
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/components/dataSourceComponents/fields/Upload/serve.ts
@@ -27,6 +37,7 @@ module.exports = __toCommonJS(serve_exports);
27
37
  var import_ahooks = require("ahooks");
28
38
  var import_utils = require("./utils");
29
39
  var import_utils2 = require("../../../table/utils");
40
+ var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
30
41
  var getMediaTypeList = async () => {
31
42
  const { data } = await import_utils2.request.getRequest().get(
32
43
  `/media_type:list`,
@@ -41,19 +52,16 @@ var getMediaTypeList = async () => {
41
52
  );
42
53
  return data;
43
54
  };
44
- var getMediaConfig = async () => {
45
- const data = await import_utils2.request.getRequest().get(`/core/module/media/config`, {});
46
- return data;
47
- };
48
55
  var useMediaConfig = () => {
49
- const { data } = (0, import_ahooks.useRequest)(getMediaConfig, {
50
- cacheKey: "media-config",
51
- staleTime: 1e3 * 60 * 5,
52
- // 5分钟后数据过期
53
- cacheTime: 1e3 * 60 * 60
54
- // 1小时后清除缓存
55
- });
56
- return { data };
56
+ var _a, _b, _c, _d, _e, _f, _g, _h;
57
+ const context = (0, import_useEngineContext.default)();
58
+ const data = (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = context.appHelper.utils) == null ? void 0 : _a.getApp) == null ? void 0 : _b.call(_a)) == null ? void 0 : _c.data) == null ? void 0 : _d.store) == null ? void 0 : _e.getStore) == null ? void 0 : _f.call(_e)) == null ? void 0 : _g.getDataByModel) == null ? void 0 : _h.call(_g, "core", "core");
59
+ return {
60
+ data: {
61
+ upload_onetime_limit: data == null ? void 0 : data.media_upload_onetime_limit,
62
+ upload_maxsize: data == null ? void 0 : data.media_upload_maxsize
63
+ }
64
+ };
57
65
  };
58
66
  var useMediaTypes = () => {
59
67
  const { data } = (0, import_ahooks.useRequest)(getMediaTypeList, {
@@ -3,8 +3,9 @@ export interface UseActionsParams {
3
3
  dataSource?: DataSourceType;
4
4
  currentValue?: 'server' | 'local';
5
5
  __designMode?: string;
6
+ extraParams?: Record<string, any>;
6
7
  }
7
- declare const useActions: ({ dataSource: propsDataSource, currentValue: propsCurrentValue, __designMode, }?: UseActionsParams) => {
8
+ declare const useActions: ({ dataSource: propsDataSource, currentValue: propsCurrentValue, __designMode, extraParams: propsExtraParams, }?: UseActionsParams) => {
8
9
  create: (values: Record<string, any>) => Promise<any>;
9
10
  get: () => Promise<any>;
10
11
  update: (values: Record<string, any>) => Promise<any>;
@@ -44,7 +44,8 @@ var import_locales = require("../../../locales");
44
44
  var useActions = ({
45
45
  dataSource: propsDataSource,
46
46
  currentValue: propsCurrentValue,
47
- __designMode
47
+ __designMode,
48
+ extraParams: propsExtraParams
48
49
  } = {}) => {
49
50
  const { dataSource: ctxDataSource, __designMode: ctxDesignMode } = (0, import_useDataSource.default)();
50
51
  const { parseVariable } = (0, import_useVariables.default)();
@@ -68,6 +69,15 @@ var useActions = ({
68
69
  const currentRecord = (0, import_react.useMemo)(() => {
69
70
  return parseVariable == null ? void 0 : parseVariable(currentValue, {});
70
71
  }, [currentValue, parseVariable]);
72
+ const extraParams = (0, import_react.useMemo)(() => {
73
+ return Object.entries(propsExtraParams || {}).reduce((acc, [key, value]) => {
74
+ acc[key] = Object.entries(value || {}).reduce((acc2, [k, v]) => {
75
+ acc2[k] = parseVariable == null ? void 0 : parseVariable(v, {});
76
+ return acc2;
77
+ }, {});
78
+ return acc;
79
+ }, {});
80
+ }, [propsExtraParams, parseVariable]);
71
81
  const getParsedActions = (0, import_ahooks.useMemoizedFn)(() => {
72
82
  return parseActions(originalActions, { currentRecord });
73
83
  });
@@ -88,7 +98,7 @@ var useActions = ({
88
98
  headers,
89
99
  body
90
100
  });
91
- if (dataSourceKey === "mypisell-api") {
101
+ if (["pisell2-api", "mypisell-api"].includes(dataSourceKey)) {
92
102
  return result.data;
93
103
  }
94
104
  return result;
@@ -132,7 +142,12 @@ var useActions = ({
132
142
  const getApi = genCustomApi(actions == null ? void 0 : actions.get);
133
143
  return getApi({});
134
144
  }
135
- return {};
145
+ const res = await (0, import_serve.getNocobaseData)({
146
+ key: name || "",
147
+ query: extraParams == null ? void 0 : extraParams.get,
148
+ headers: getHeaders()
149
+ });
150
+ return (res == null ? void 0 : res.data) || {};
136
151
  } else if (currentValue) {
137
152
  return parseVariable == null ? void 0 : parseVariable(currentValue, {});
138
153
  }
@@ -151,7 +166,7 @@ var useActions = ({
151
166
  const updateApi = genCustomApi(actions == null ? void 0 : actions.update);
152
167
  return updateApi(formatCreateUpdateParams(values));
153
168
  } else {
154
- const id = values == null ? void 0 : values.id;
169
+ const id = (extraParams == null ? void 0 : extraParams.filterByTk) || (values == null ? void 0 : values.id);
155
170
  if (!id || !name) {
156
171
  (0, import_pisellToast.default)({
157
172
  content: (0, import_locales.getText)("pisell-action-get-data")
@@ -160,9 +175,9 @@ var useActions = ({
160
175
  }
161
176
  return (0, import_serve.updateNocobaseData)({
162
177
  key: name,
163
- id,
164
178
  data: formatCreateUpdateParams(values),
165
- headers: getHeaders()
179
+ headers: getHeaders(),
180
+ query: { filterByTk: id, ...extraParams == null ? void 0 : extraParams.update }
166
181
  });
167
182
  }
168
183
  });
@@ -182,7 +197,10 @@ var useActions = ({
182
197
  return formatListResult(
183
198
  await (0, import_serve.getNocobaseDataList)({
184
199
  key: name,
185
- params: formatParams,
200
+ params: {
201
+ ...formatParams,
202
+ ...(extraParams == null ? void 0 : extraParams.list) || {}
203
+ },
186
204
  headers: getHeaders()
187
205
  })
188
206
  );
@@ -88,6 +88,13 @@ export declare type DataSourceContextProps = {
88
88
  list?: boolean;
89
89
  get?: boolean;
90
90
  };
91
+ extraParams?: {
92
+ list?: Record<string, any>;
93
+ get?: Record<string, any>;
94
+ update?: Record<string, any>;
95
+ create?: Record<string, any>;
96
+ destroy?: Record<string, any>;
97
+ };
91
98
  __id?: string;
92
99
  __designMode?: string;
93
100
  };
@@ -44,6 +44,7 @@ var DataSourceProvider = (props) => {
44
44
  children,
45
45
  dataSource: propsDataSource,
46
46
  currentValue,
47
+ extraParams,
47
48
  actions: externalActions,
48
49
  overrideData,
49
50
  autoRun,
@@ -55,7 +56,8 @@ var DataSourceProvider = (props) => {
55
56
  const standardActions = (0, import_useActions.default)({
56
57
  dataSource,
57
58
  currentValue,
58
- __designMode
59
+ __designMode,
60
+ extraParams
59
61
  });
60
62
  const list = (externalActions == null ? void 0 : externalActions.list) || standardActions.list;
61
63
  const get = (externalActions == null ? void 0 : externalActions.get) || standardActions.get;
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(VariablesProvider_exports);
35
35
  var import_react = __toESM(require("react"));
36
36
  var import_utils = require("@pisell/utils");
37
37
  var import_ahooks = require("ahooks");
38
+ var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
38
39
  var import_VariablesContext = __toESM(require("./VariablesContext"));
39
40
  var import_utils2 = require("../../dataSourceForm/utils");
40
41
  var import_utils3 = require("../../../../utils");
@@ -46,9 +47,54 @@ var defaultCustomizer = (objValue, srcValue) => {
46
47
  };
47
48
  var VARIABLE_PATTERN = /{{([^}]+)}}/g;
48
49
  var VariablesProvider = (props) => {
50
+ var _a;
49
51
  const { children, variables } = props;
50
- const variablesRef = (0, import_react.useRef)(variables || {});
52
+ const context = (0, import_useEngineContext.default)();
53
+ const { getApp } = ((_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) || {};
54
+ const initialQuery = (0, import_react.useMemo)(() => {
55
+ var _a2, _b, _c;
56
+ const currentLocation = (_c = (_b = (_a2 = getApp == null ? void 0 : getApp()) == null ? void 0 : _a2.history) == null ? void 0 : _b.instance) == null ? void 0 : _c.location;
57
+ if (currentLocation == null ? void 0 : currentLocation.search) {
58
+ const searchParams = new URLSearchParams(currentLocation.search);
59
+ const query = {};
60
+ searchParams.forEach((value2, key) => {
61
+ query[key] = value2;
62
+ });
63
+ return query;
64
+ }
65
+ return {};
66
+ }, []);
67
+ const variablesRef = (0, import_react.useRef)(
68
+ (0, import_utils3.mergeWith)(
69
+ variables,
70
+ {
71
+ global: {
72
+ query: initialQuery
73
+ }
74
+ },
75
+ defaultCustomizer
76
+ )
77
+ );
51
78
  const listenersRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
79
+ const setQueryVariable = (0, import_ahooks.useMemoizedFn)((search) => {
80
+ const searchParams = new URLSearchParams(search);
81
+ const query = {};
82
+ searchParams.forEach((value2, key) => {
83
+ query[key] = value2;
84
+ });
85
+ registerVariable({
86
+ global: query
87
+ });
88
+ });
89
+ (0, import_react.useEffect)(() => {
90
+ var _a2, _b, _c;
91
+ const unlisten = (_c = (_b = (_a2 = getApp == null ? void 0 : getApp()) == null ? void 0 : _a2.history) == null ? void 0 : _b.instance) == null ? void 0 : _c.listen((location) => {
92
+ setQueryVariable(location.search);
93
+ });
94
+ return () => {
95
+ unlisten == null ? void 0 : unlisten();
96
+ };
97
+ }, []);
52
98
  const registerVariable = (0, import_ahooks.useMemoizedFn)((value2) => {
53
99
  variablesRef.current = (0, import_utils3.mergeWith)(
54
100
  variablesRef.current,
@@ -82,11 +128,11 @@ var VariablesProvider = (props) => {
82
128
  );
83
129
  const parseVariable = (0, import_ahooks.useMemoizedFn)(
84
130
  (str, localVariables = {}) => {
85
- var _a;
131
+ var _a2;
86
132
  if (!(0, import_utils.isString)(str)) {
87
133
  return str;
88
134
  }
89
- if (((_a = str.match(VARIABLE_PATTERN)) == null ? void 0 : _a[0]) === str) {
135
+ if (((_a2 = str.match(VARIABLE_PATTERN)) == null ? void 0 : _a2[0]) === str) {
90
136
  const key = (0, import_utils4.getVariableKey)(str);
91
137
  if (!key)
92
138
  return str;
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ /**
4
+ * loginAndRegister组件的属性接口
5
+ */
6
+ export interface loginAndRegisterProps {
7
+ /** Logo相关配置 */
8
+ showLogo?: boolean;
9
+ logo?: string;
10
+ logoPosition?: 'left' | 'center' | 'right';
11
+ logoSize?: {
12
+ width?: number;
13
+ height?: number;
14
+ };
15
+ /** 标题相关配置 */
16
+ title?: string;
17
+ showTitle?: boolean;
18
+ titleAlign?: 'left' | 'center' | 'right';
19
+ /** 副标题相关配置 */
20
+ subtitle?: string;
21
+ showSubtitle?: boolean;
22
+ subtitleAlign?: 'left' | 'center' | 'right';
23
+ /** 登录方式配置 */
24
+ loginMethods?: ('email' | 'google' | 'facebook' | 'apple')[];
25
+ defaultLoginMethod?: 'email' | 'google' | 'facebook' | 'apple';
26
+ /** 表单配置 */
27
+ emailLabel?: string;
28
+ passwordLabel?: string;
29
+ emailPlaceholder?: string;
30
+ passwordPlaceholder?: string;
31
+ emailRules?: any[];
32
+ buttonText?: string;
33
+ rememberMeText?: string;
34
+ forgotPasswordText?: string;
35
+ showRememberMe?: boolean;
36
+ showForgotPassword?: boolean;
37
+ /** 社交登录配置 */
38
+ socialLoginTexts?: {
39
+ google?: string;
40
+ facebook?: string;
41
+ apple?: string;
42
+ };
43
+ /** 底部配置 */
44
+ showFooter?: boolean;
45
+ showSignUp?: boolean;
46
+ signUpText?: string;
47
+ signUpLink?: string;
48
+ signUpPosition?: 'left' | 'center' | 'right';
49
+ otherLinks?: Array<{
50
+ text: string;
51
+ url: string;
52
+ }>;
53
+ otherLinksPosition?: 'left' | 'center' | 'right';
54
+ /** 登录/注册切换配置 */
55
+ showTabs?: boolean;
56
+ loginTabText?: string;
57
+ registerTabText?: string;
58
+ /** 注册表单配置 */
59
+ registerEmailPlaceholder?: string;
60
+ registerPasswordPlaceholder?: string;
61
+ registerButtonText?: string;
62
+ /** 事件回调 */
63
+ onLogin?: (values: {
64
+ email: string;
65
+ loginMethod: string;
66
+ }) => void;
67
+ onSocialLogin?: (type: 'google' | 'facebook' | 'apple') => void;
68
+ onSignUp?: () => void;
69
+ onRegister?: (values: {
70
+ email: string;
71
+ password: string;
72
+ }) => void;
73
+ /** 新增背景图片属性 */
74
+ backgroundImage?: string;
75
+ }
76
+ /**
77
+ * Saas登录组件
78
+ * @param props - 组件属性
79
+ * @returns React组件
80
+ */
81
+ declare const loginAndRegister: React.FC<loginAndRegisterProps>;
82
+ export default loginAndRegister;
@@ -0,0 +1,261 @@
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/components/login-and-register/index.tsx
30
+ var login_and_register_exports = {};
31
+ __export(login_and_register_exports, {
32
+ default: () => login_and_register_default
33
+ });
34
+ module.exports = __toCommonJS(login_and_register_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_antd = require("antd");
37
+ var import_icons = require("@ant-design/icons");
38
+ var import_index = require("./index.less");
39
+ var loginAndRegister = ({
40
+ showLogo = true,
41
+ logo,
42
+ logoPosition = "center",
43
+ logoSize = { width: 48, height: 48 },
44
+ title = "Log in to your account",
45
+ showTitle = false,
46
+ titleAlign = "center",
47
+ subtitle = "Welcome back! Please enter your details.",
48
+ showSubtitle = false,
49
+ subtitleAlign = "center",
50
+ loginMethods = ["email", "google", "facebook", "apple"],
51
+ defaultLoginMethod = "email",
52
+ emailLabel = "Email",
53
+ passwordLabel = "Password",
54
+ emailPlaceholder = "Enter your email",
55
+ passwordPlaceholder = "Enter your password",
56
+ emailRules = [
57
+ { required: true, message: "Please input your email!" },
58
+ { type: "email", message: "Please enter a valid email!" }
59
+ ],
60
+ buttonText = "Log in",
61
+ socialLoginTexts = {
62
+ google: "Continue with Google",
63
+ facebook: "Continue with Facebook",
64
+ apple: "Continue with Apple"
65
+ },
66
+ showFooter = true,
67
+ showSignUp = true,
68
+ signUpText = "Don't have an account? Sign up",
69
+ signUpLink = "",
70
+ signUpPosition = "center",
71
+ otherLinks = [],
72
+ otherLinksPosition = "center",
73
+ showTabs = true,
74
+ loginTabText = "Login",
75
+ registerTabText = "Register",
76
+ registerEmailPlaceholder = "Enter your email",
77
+ registerPasswordPlaceholder = "Create a password",
78
+ registerButtonText = "Create account",
79
+ rememberMeText = "Remember me",
80
+ forgotPasswordText = "Forgot password?",
81
+ showRememberMe = false,
82
+ showForgotPassword = false,
83
+ onLogin,
84
+ onSocialLogin,
85
+ onSignUp,
86
+ onRegister,
87
+ backgroundImage = "/login-illustration.png"
88
+ }) => {
89
+ const [form] = import_antd.Form.useForm();
90
+ const [loading, setLoading] = (0, import_react.useState)(false);
91
+ const [activeTab, setActiveTab] = (0, import_react.useState)("login");
92
+ (0, import_react.useEffect)(() => {
93
+ document.body.id = "body";
94
+ }, []);
95
+ const handleEmailLogin = async () => {
96
+ try {
97
+ setLoading(true);
98
+ const values = await form.validateFields();
99
+ onLogin == null ? void 0 : onLogin({ ...values, loginMethod: "email" });
100
+ } catch (error) {
101
+ console.error("Validation failed:", error);
102
+ } finally {
103
+ setLoading(false);
104
+ }
105
+ };
106
+ const handleSocialLogin = (type) => {
107
+ onSocialLogin == null ? void 0 : onSocialLogin(type);
108
+ };
109
+ const handleRegister = async () => {
110
+ try {
111
+ setLoading(true);
112
+ const values = await form.validateFields();
113
+ onRegister == null ? void 0 : onRegister(values);
114
+ } catch (error) {
115
+ console.error("Validation failed:", error);
116
+ } finally {
117
+ setLoading(false);
118
+ }
119
+ };
120
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-main" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-container" }, showLogo && /* @__PURE__ */ import_react.default.createElement(
121
+ "div",
122
+ {
123
+ className: `saas-login-logo ${logoPosition}`
124
+ },
125
+ logo && /* @__PURE__ */ import_react.default.createElement("img", { src: logo, alt: "logo" })
126
+ ), showTitle && /* @__PURE__ */ import_react.default.createElement("h1", { className: "saas-login-title", style: { textAlign: titleAlign } }, title), showSubtitle && /* @__PURE__ */ import_react.default.createElement("p", { className: "saas-login-subtitle", style: { textAlign: subtitleAlign } }, subtitle), showTabs && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-tabs" }, /* @__PURE__ */ import_react.default.createElement(
127
+ "div",
128
+ {
129
+ className: `tab ${activeTab === "login" ? "active" : ""}`,
130
+ onClick: () => setActiveTab("login")
131
+ },
132
+ loginTabText
133
+ ), /* @__PURE__ */ import_react.default.createElement(
134
+ "div",
135
+ {
136
+ className: `tab ${activeTab === "register" ? "active" : ""}`,
137
+ onClick: () => setActiveTab("register")
138
+ },
139
+ registerTabText
140
+ )), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-form" }, activeTab === "login" ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { form }, /* @__PURE__ */ import_react.default.createElement("div", { className: "form-item-label" }, emailLabel), /* @__PURE__ */ import_react.default.createElement(
141
+ import_antd.Form.Item,
142
+ {
143
+ name: "email",
144
+ rules: emailRules
145
+ },
146
+ /* @__PURE__ */ import_react.default.createElement(
147
+ import_antd.Input,
148
+ {
149
+ placeholder: emailPlaceholder,
150
+ size: "large",
151
+ className: "saas-login-input"
152
+ }
153
+ )
154
+ ), /* @__PURE__ */ import_react.default.createElement("div", { className: "form-item-label" }, passwordLabel), /* @__PURE__ */ import_react.default.createElement(
155
+ import_antd.Form.Item,
156
+ {
157
+ name: "password",
158
+ rules: [
159
+ { required: true, message: "Please input your password!" }
160
+ ]
161
+ },
162
+ /* @__PURE__ */ import_react.default.createElement(
163
+ import_antd.Input.Password,
164
+ {
165
+ placeholder: passwordPlaceholder,
166
+ size: "large",
167
+ className: "saas-login-input"
168
+ }
169
+ )
170
+ ), (showRememberMe || showForgotPassword) && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-options" }, showRememberMe && /* @__PURE__ */ import_react.default.createElement(import_antd.Checkbox, null, rememberMeText), showForgotPassword && /* @__PURE__ */ import_react.default.createElement("a", { className: "forgot-password" }, forgotPasswordText)), /* @__PURE__ */ import_react.default.createElement(
171
+ import_antd.Button,
172
+ {
173
+ type: "primary",
174
+ block: true,
175
+ size: "large",
176
+ loading,
177
+ onClick: handleEmailLogin,
178
+ className: "saas-login-button"
179
+ },
180
+ "Log in"
181
+ )) : /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { form }, /* @__PURE__ */ import_react.default.createElement(
182
+ import_antd.Form.Item,
183
+ {
184
+ name: "email",
185
+ rules: emailRules
186
+ },
187
+ /* @__PURE__ */ import_react.default.createElement(
188
+ import_antd.Input,
189
+ {
190
+ placeholder: registerEmailPlaceholder,
191
+ size: "large",
192
+ className: "saas-login-input"
193
+ }
194
+ )
195
+ ), /* @__PURE__ */ import_react.default.createElement(
196
+ import_antd.Form.Item,
197
+ {
198
+ name: "password",
199
+ rules: [
200
+ { required: true, message: "Please input your password!" },
201
+ { min: 6, message: "Password must be at least 6 characters!" }
202
+ ]
203
+ },
204
+ /* @__PURE__ */ import_react.default.createElement(
205
+ import_antd.Input.Password,
206
+ {
207
+ placeholder: registerPasswordPlaceholder,
208
+ size: "large",
209
+ className: "saas-login-input"
210
+ }
211
+ )
212
+ ), /* @__PURE__ */ import_react.default.createElement(
213
+ import_antd.Button,
214
+ {
215
+ type: "primary",
216
+ block: true,
217
+ size: "large",
218
+ loading,
219
+ onClick: handleRegister,
220
+ className: "saas-login-button"
221
+ },
222
+ registerButtonText
223
+ )), /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { direction: "vertical", className: "saas-login-social" }, loginMethods.includes("google") && /* @__PURE__ */ import_react.default.createElement(
224
+ import_antd.Button,
225
+ {
226
+ block: true,
227
+ icon: /* @__PURE__ */ import_react.default.createElement(import_icons.GoogleOutlined, null),
228
+ className: "saas-login-social-button google",
229
+ onClick: () => handleSocialLogin("google")
230
+ },
231
+ socialLoginTexts.google
232
+ ), loginMethods.includes("facebook") && /* @__PURE__ */ import_react.default.createElement(
233
+ import_antd.Button,
234
+ {
235
+ block: true,
236
+ icon: /* @__PURE__ */ import_react.default.createElement(import_icons.FacebookOutlined, null),
237
+ className: "saas-login-social-button facebook",
238
+ onClick: () => handleSocialLogin("facebook")
239
+ },
240
+ socialLoginTexts.facebook
241
+ ), loginMethods.includes("apple") && /* @__PURE__ */ import_react.default.createElement(
242
+ import_antd.Button,
243
+ {
244
+ block: true,
245
+ icon: /* @__PURE__ */ import_react.default.createElement(import_icons.AppleOutlined, null),
246
+ className: "saas-login-social-button apple",
247
+ onClick: () => handleSocialLogin("apple")
248
+ },
249
+ socialLoginTexts.apple
250
+ ))), showFooter && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-footer" }, showSignUp && /* @__PURE__ */ import_react.default.createElement("p", { className: "saas-login-signup" }, signUpText, signUpLink ? /* @__PURE__ */ import_react.default.createElement("a", { href: signUpLink }, "Sign up") : /* @__PURE__ */ import_react.default.createElement("a", { onClick: onSignUp }, "Sign up")), otherLinks.length > 0 && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-links" }, otherLinks.map((link, index) => /* @__PURE__ */ import_react.default.createElement(
251
+ "a",
252
+ {
253
+ key: index,
254
+ href: link.url,
255
+ target: "_blank",
256
+ rel: "noopener noreferrer"
257
+ },
258
+ link.text
259
+ ))))));
260
+ };
261
+ var login_and_register_default = loginAndRegister;