@tachybase/client 1.0.18 → 1.0.25

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 (106) hide show
  1. package/es/application/Application.d.ts +2 -0
  2. package/es/application/Application.mjs +15 -0
  3. package/es/application/TrackingManager.d.ts +13 -0
  4. package/es/application/TrackingManager.mjs +30 -0
  5. package/es/application/components/SharePage.d.ts +4 -0
  6. package/es/application/components/SharePage.mjs +113 -0
  7. package/es/application/components/ShareSchemaComponent.d.ts +1 -0
  8. package/es/application/components/ShareSchemaComponent.mjs +10 -0
  9. package/es/application/components/index.d.ts +2 -0
  10. package/es/application/components/index.mjs +2 -0
  11. package/es/built-in/admin-layout/index.d.ts +1 -0
  12. package/es/built-in/admin-layout/index.mjs +1 -0
  13. package/es/collection-manager/interfaces/__tests__/json.mjs +2 -2
  14. package/es/collection-manager/interfaces/integer.d.ts +12 -0
  15. package/es/collection-manager/interfaces/integer.mjs +13 -1
  16. package/es/collection-manager/interfaces/number.d.ts +16 -0
  17. package/es/collection-manager/interfaces/number.mjs +22 -1
  18. package/es/collection-manager/interfaces/percent.d.ts +12 -0
  19. package/es/collection-manager/interfaces/percent.mjs +12 -0
  20. package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToFormInitializerItems.d.ts +3 -0
  21. package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToFormInitializerItems.mjs +67 -0
  22. package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToInitializerItems.d.ts +3 -0
  23. package/es/data-source/collection-fields-to-initializer-items/CollectionFieldsToInitializerItems.mjs +37 -0
  24. package/es/data-source/collection-fields-to-initializer-items/index.d.ts +1 -0
  25. package/es/data-source/collection-fields-to-initializer-items/index.mjs +1 -0
  26. package/es/data-source/collection-fields-to-initializer-items/items/AssociationCollectionFields.d.ts +3 -0
  27. package/es/data-source/collection-fields-to-initializer-items/items/AssociationCollectionFields.mjs +59 -0
  28. package/es/data-source/collection-fields-to-initializer-items/items/ParentCollectionFields.d.ts +3 -0
  29. package/es/data-source/collection-fields-to-initializer-items/items/ParentCollectionFields.mjs +34 -0
  30. package/es/data-source/collection-fields-to-initializer-items/items/SelfFields.d.ts +3 -0
  31. package/es/data-source/collection-fields-to-initializer-items/items/SelfFields.mjs +14 -0
  32. package/es/data-source/collection-fields-to-initializer-items/items/index.d.ts +3 -0
  33. package/es/data-source/collection-fields-to-initializer-items/items/index.mjs +7 -0
  34. package/es/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.d.ts +5 -0
  35. package/es/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.mjs +91 -0
  36. package/es/data-source/collection-fields-to-initializer-items/utils/index.d.ts +3 -0
  37. package/es/data-source/collection-fields-to-initializer-items/utils/index.mjs +3 -0
  38. package/es/data-source/collection-fields-to-initializer-items/utils/type.d.ts +108 -0
  39. package/es/data-source/collection-fields-to-initializer-items/utils/type.mjs +0 -0
  40. package/es/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.d.ts +21 -0
  41. package/es/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.mjs +31 -0
  42. package/es/data-source/index.d.ts +1 -0
  43. package/es/data-source/index.mjs +1 -0
  44. package/es/modules/blocks/data-blocks/form/fieldSettingsFormItem.mjs +0 -8
  45. package/es/modules/blocks/data-blocks/form/hooks/useEditFormBlockDecoratorProps.d.ts +1 -3
  46. package/es/modules/blocks/data-blocks/form/hooks/useEditFormBlockDecoratorProps.mjs +4 -1
  47. package/es/modules/fields/component/InputNumber/inputNumberComponentFieldSettings.mjs +91 -0
  48. package/es/schema-component/antd/index.d.ts +2 -0
  49. package/es/schema-component/antd/index.mjs +2 -0
  50. package/es/schema-component/antd/page/Page.Settings.mjs +33 -0
  51. package/es/schema-component/antd/page/Page.mjs +113 -18
  52. package/es/schema-component/antd/page/hooks/index.d.ts +1 -0
  53. package/es/schema-component/antd/page/hooks/index.mjs +1 -0
  54. package/es/schema-component/antd/page/hooks/useShareActions.d.ts +7 -0
  55. package/es/schema-component/antd/page/hooks/useShareActions.mjs +245 -0
  56. package/es/schema-component/antd/page/index.d.ts +1 -0
  57. package/es/schema-component/antd/page/index.mjs +1 -0
  58. package/es/schema-component/antd/page/style.d.ts +5 -0
  59. package/es/schema-component/antd/page/style.mjs +59 -2
  60. package/es/schema-component/antd/slider/index.d.ts +1 -0
  61. package/es/schema-component/antd/slider/index.mjs +1 -0
  62. package/es/schema-component/antd/slider/slider.d.ts +3 -0
  63. package/es/schema-component/antd/slider/slider.mjs +11 -0
  64. package/es/schema-component/antd/tracking-link/index.d.ts +10 -0
  65. package/es/schema-component/antd/tracking-link/index.mjs +25 -0
  66. package/es/schema-initializer/utils.d.ts +1 -0
  67. package/es/schema-initializer/utils.mjs +1 -1
  68. package/lib/application/Application.js +15 -0
  69. package/lib/application/TrackingManager.js +66 -0
  70. package/lib/application/components/SharePage.js +150 -0
  71. package/lib/application/components/ShareSchemaComponent.js +44 -0
  72. package/lib/application/components/index.js +18 -0
  73. package/lib/block-provider/hooks/index.js +2 -2
  74. package/lib/built-in/admin-layout/index.js +9 -0
  75. package/lib/collection-manager/interfaces/__tests__/json.js +4 -4
  76. package/lib/collection-manager/interfaces/integer.js +13 -1
  77. package/lib/collection-manager/interfaces/number.js +22 -1
  78. package/lib/collection-manager/interfaces/percent.js +12 -0
  79. package/lib/data-source/collection-fields-to-initializer-items/CollectionFieldsToFormInitializerItems.js +102 -0
  80. package/lib/data-source/collection-fields-to-initializer-items/CollectionFieldsToInitializerItems.js +71 -0
  81. package/lib/data-source/collection-fields-to-initializer-items/index.js +65 -0
  82. package/lib/data-source/collection-fields-to-initializer-items/items/AssociationCollectionFields.js +93 -0
  83. package/lib/data-source/collection-fields-to-initializer-items/items/ParentCollectionFields.js +68 -0
  84. package/lib/data-source/collection-fields-to-initializer-items/items/SelfFields.js +48 -0
  85. package/lib/data-source/collection-fields-to-initializer-items/items/index.js +40 -0
  86. package/lib/data-source/collection-fields-to-initializer-items/utils/getInitializerItemsByFields.js +127 -0
  87. package/lib/data-source/collection-fields-to-initializer-items/utils/index.js +83 -0
  88. package/lib/data-source/collection-fields-to-initializer-items/utils/type.js +19 -0
  89. package/lib/data-source/collection-fields-to-initializer-items/utils/useCollectionFieldContext.js +65 -0
  90. package/lib/data-source/index.js +12 -3
  91. package/lib/locale/zh-CN.js +18 -0
  92. package/lib/modules/blocks/data-blocks/form/fieldSettingsFormItem.js +0 -8
  93. package/lib/modules/blocks/data-blocks/form/hooks/useEditFormBlockDecoratorProps.js +4 -1
  94. package/lib/modules/fields/component/InputNumber/inputNumberComponentFieldSettings.js +91 -0
  95. package/lib/schema-component/antd/index.js +161 -133
  96. package/lib/schema-component/antd/page/Page.Settings.js +33 -0
  97. package/lib/schema-component/antd/page/Page.js +113 -18
  98. package/lib/schema-component/antd/page/hooks/index.js +65 -0
  99. package/lib/schema-component/antd/page/hooks/useShareActions.js +293 -0
  100. package/lib/schema-component/antd/page/index.js +9 -0
  101. package/lib/schema-component/antd/page/style.js +60 -2
  102. package/lib/schema-component/antd/slider/index.js +65 -0
  103. package/lib/schema-component/antd/slider/slider.js +46 -0
  104. package/lib/schema-component/antd/tracking-link/index.js +59 -0
  105. package/lib/schema-initializer/utils.js +2 -1
  106. package/package.json +8 -7
@@ -30,6 +30,7 @@ __webpack_require__.d(__webpack_exports__, {
30
30
  });
31
31
  const schema_namespaceObject = require("@tachybase/schema");
32
32
  const external_react_i18next_namespaceObject = require("react-i18next");
33
+ const external_react_router_namespaceObject = require("react-router");
33
34
  const external_index_js_namespaceObject = require("../../index.js");
34
35
  const index_js_namespaceObject = require("../../../application/schema-settings/index.js");
35
36
  const schema_toolbar_index_js_namespaceObject = require("../../../application/schema-toolbar/index.js");
@@ -66,6 +67,38 @@ const pageSettings = new index_js_namespaceObject.SchemaSettings({
66
67
  };
67
68
  }
68
69
  },
70
+ {
71
+ name: 'enablesharePage',
72
+ type: 'switch',
73
+ useVisible () {
74
+ const isShare = (0, external_react_router_namespaceObject.useMatch)('/share/:name');
75
+ return !isShare;
76
+ },
77
+ useComponentProps () {
78
+ var _fieldSchema_xcomponentprops;
79
+ const { dn } = (0, external_index_js_namespaceObject.useDesignable)();
80
+ const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
81
+ const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
82
+ const { title } = (0, schema_toolbar_index_js_namespaceObject.useSchemaToolbar)();
83
+ return {
84
+ title: t('Enable Share page'),
85
+ checked: null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.enableSharePage,
86
+ onChange (v) {
87
+ fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
88
+ fieldSchema['x-component-props']['enableSharePage'] = v;
89
+ if (!fieldSchema.title) fieldSchema.title = title;
90
+ dn.emit('patch', {
91
+ schema: {
92
+ ['x-uid']: fieldSchema['x-uid'],
93
+ ['x-component-props']: fieldSchema['x-component-props'],
94
+ title: fieldSchema.title
95
+ }
96
+ });
97
+ dn.refresh();
98
+ }
99
+ };
100
+ }
101
+ },
69
102
  {
70
103
  name: 'divider',
71
104
  type: 'divider',
@@ -72,18 +72,20 @@ const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
72
72
  const external_error_fallback_index_js_namespaceObject = require("../error-fallback/index.js");
73
73
  const external_FixedBlock_js_namespaceObject = require("./FixedBlock.js");
74
74
  var external_FixedBlock_js_default = /*#__PURE__*/ __webpack_require__.n(external_FixedBlock_js_namespaceObject);
75
+ const useShareActions_js_namespaceObject = require("./hooks/useShareActions.js");
75
76
  const external_Page_style_js_namespaceObject = require("./Page.style.js");
76
77
  const external_PageDesigner_js_namespaceObject = require("./PageDesigner.js");
77
78
  const external_PageTabDesigner_js_namespaceObject = require("./PageTabDesigner.js");
78
79
  const external_style_js_namespaceObject = require("./style.js");
79
80
  const Page = (props)=>{
80
- var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1;
81
+ var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1, _fieldSchema_xcomponentprops2;
81
82
  const { children, ...others } = props;
82
83
  const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
83
84
  const { title, setTitle } = (0, document_title_index_js_namespaceObject.useDocumentTitle)();
84
85
  const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
85
86
  const disablePageHeader = null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.disablePageHeader;
86
87
  const enablePageTabs = null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1.enablePageTabs;
88
+ const enableSharePage = null === (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops2 ? void 0 : _fieldSchema_xcomponentprops2.enableSharePage;
87
89
  const [searchParams, setSearchParams] = (0, external_react_router_dom_namespaceObject.useSearchParams)();
88
90
  const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
89
91
  const activeKey = (0, external_react_namespaceObject.useMemo)(()=>searchParams.get('tab') || Object.keys(fieldSchema.properties || {}).shift(), [
@@ -115,6 +117,7 @@ const Page = (props)=>{
115
117
  parentProps: others,
116
118
  setHeight: setHeight,
117
119
  setLoading: setLoading,
120
+ enableSharePage: enableSharePage,
118
121
  setSearchParams: setSearchParams
119
122
  }),
120
123
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(PageContentComponent, {
@@ -132,40 +135,132 @@ const Page = (props)=>{
132
135
  };
133
136
  const PageHeader = (props)=>{
134
137
  var _fieldSchema_xcomponentprops;
135
- const { disablePageHeader, enablePageTabs, setHeight, activeKey, setLoading, setSearchParams, fieldSchema, title, parentProps } = props;
138
+ const { disablePageHeader, enablePageTabs, setHeight, activeKey, setLoading, setSearchParams, fieldSchema, title, parentProps, enableSharePage } = props;
136
139
  const { theme } = (0, theme_index_js_namespaceObject.useGlobalTheme)();
137
140
  const options = (0, external_react_namespaceObject.useContext)(schema_namespaceObject.SchemaOptionsContext);
138
141
  const compile = (0, external_hooks_index_js_namespaceObject.useCompile)();
142
+ const [open, setOpen] = (0, external_react_namespaceObject.useState)(false);
143
+ const [imageOpen, setImageOpen] = (0, external_react_namespaceObject.useState)(false);
139
144
  const { showScrollArea } = (0, useContextMenu_js_namespaceObject.useContextMenu)();
140
145
  const hidePageTitle = null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.hidePageTitle;
141
146
  const pageHeaderTitle = hidePageTitle ? void 0 : fieldSchema.title || compile(title);
147
+ const isShare = (0, external_react_router_dom_namespaceObject.useMatch)('/share/:name');
142
148
  const items = fieldSchema.mapProperties((schema)=>({
143
149
  key: schema.name,
144
150
  label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabItem, {
145
151
  schema: schema
146
152
  })
147
153
  }));
148
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
154
+ const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
155
+ const { styles } = (0, external_style_js_namespaceObject.useStyles)();
156
+ const { copyLink, imageAction } = (0, useShareActions_js_namespaceObject.useShareActions)({
157
+ title: pageHeaderTitle,
158
+ uid: ''
159
+ });
160
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
149
161
  ref: (ref)=>{
150
162
  setHeight(Math.floor((null == ref ? void 0 : ref.getBoundingClientRect().height) || 0) + 1);
151
163
  },
152
164
  className: "tb-page-header-wrapper",
153
- children: !disablePageHeader && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(pro_layout_namespaceObject.PageHeader, {
154
- className: external_classnames_default()('pageHeaderCss', pageHeaderTitle || enablePageTabs ? '' : 'height0'),
155
- ghost: false,
156
- title: pageHeaderTitle || ' ',
157
- ...parentProps,
158
- extra: !enablePageTabs && showScrollArea && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_js_namespaceObject.ScrollArea, {}),
159
- footer: enablePageTabs && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabComponent, {
160
- activeKey: activeKey,
161
- setLoading: setLoading,
162
- setSearchParams: setSearchParams,
163
- showScrollArea: showScrollArea,
164
- options: options,
165
- theme: theme,
166
- items: items
165
+ children: [
166
+ !disablePageHeader && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(pro_layout_namespaceObject.PageHeader, {
167
+ className: external_classnames_default()('pageHeaderCss', pageHeaderTitle || enableSharePage ? '' : 'height0'),
168
+ ghost: false,
169
+ title: pageHeaderTitle || ' ',
170
+ ...parentProps,
171
+ extra: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(HeaderExtra, {
172
+ enablePageTabs: enablePageTabs,
173
+ showScrollArea: showScrollArea,
174
+ isShare: isShare,
175
+ setOpen: setOpen,
176
+ enableSharePage: enableSharePage
177
+ }),
178
+ footer: enablePageTabs && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabComponent, {
179
+ activeKey: activeKey,
180
+ setLoading: setLoading,
181
+ setSearchParams: setSearchParams,
182
+ showScrollArea: showScrollArea,
183
+ options: options,
184
+ theme: theme,
185
+ items: items
186
+ })
187
+ }),
188
+ disablePageHeader && enableSharePage && !isShare && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
189
+ className: "tb-page-header-button",
190
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
191
+ icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.ShareAltOutlined, {}),
192
+ onClick: ()=>{
193
+ setOpen(true);
194
+ },
195
+ children: t('Share')
196
+ })
197
+ }),
198
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_antd_namespaceObject.Modal, {
199
+ open: open,
200
+ className: styles.firstmodal,
201
+ title: t('Share'),
202
+ footer: null,
203
+ width: 500,
204
+ onCancel: ()=>{
205
+ setOpen(false);
206
+ },
207
+ children: [
208
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
209
+ className: styles.secondmodal,
210
+ children: [
211
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
212
+ className: "tb-header-modal-list",
213
+ onClick: copyLink,
214
+ children: [
215
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_icon_index_js_namespaceObject.Icon, {
216
+ type: "PaperClipOutlined"
217
+ }),
218
+ t('Copy link')
219
+ ]
220
+ }),
221
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
222
+ className: "tb-header-modal-list",
223
+ onClick: ()=>{
224
+ setImageOpen(true);
225
+ },
226
+ children: [
227
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_icon_index_js_namespaceObject.Icon, {
228
+ type: "QrcodeOutlined"
229
+ }),
230
+ t('Generate QR code')
231
+ ]
232
+ })
233
+ ]
234
+ }),
235
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Modal, {
236
+ className: styles.imageModal,
237
+ open: imageOpen,
238
+ footer: null,
239
+ onCancel: ()=>{
240
+ setImageOpen(false);
241
+ },
242
+ children: imageAction()
243
+ })
244
+ ]
167
245
  })
168
- })
246
+ ]
247
+ });
248
+ };
249
+ const HeaderExtra = (param)=>{
250
+ let { enablePageTabs, showScrollArea, isShare, setOpen, enableSharePage } = param;
251
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
252
+ children: [
253
+ !isShare && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
254
+ icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.ShareAltOutlined, {}),
255
+ onClick: ()=>{
256
+ setOpen(true);
257
+ },
258
+ style: {
259
+ visibility: "".concat(enableSharePage ? 'visible' : 'hidden')
260
+ }
261
+ }),
262
+ !enablePageTabs && showScrollArea && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_js_namespaceObject.ScrollArea, {})
263
+ ]
169
264
  });
170
265
  };
171
266
  const TabComponent = (props)=>{
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./useShareActions": function(module) {
4
+ module.exports = require("./useShareActions.js");
5
+ }
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = function(module) {
19
+ var getter = module && module.__esModule ? function() {
20
+ return module['default'];
21
+ } : function() {
22
+ return module;
23
+ };
24
+ __webpack_require__.d(getter, {
25
+ a: getter
26
+ });
27
+ return getter;
28
+ };
29
+ })();
30
+ (()=>{
31
+ __webpack_require__.d = function(exports1, definition) {
32
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
33
+ enumerable: true,
34
+ get: definition[key]
35
+ });
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.o = function(obj, prop) {
40
+ return Object.prototype.hasOwnProperty.call(obj, prop);
41
+ };
42
+ })();
43
+ (()=>{
44
+ __webpack_require__.r = function(exports1) {
45
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
46
+ value: 'Module'
47
+ });
48
+ Object.defineProperty(exports1, '__esModule', {
49
+ value: true
50
+ });
51
+ };
52
+ })();
53
+ var __webpack_exports__ = {};
54
+ __webpack_require__.r(__webpack_exports__);
55
+ var _useShareActions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./useShareActions");
56
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
57
+ for(var __WEBPACK_IMPORT_KEY__ in _useShareActions__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
58
+ return _useShareActions__WEBPACK_IMPORTED_MODULE_0__[key];
59
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
60
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
61
+ var __webpack_export_target__ = exports;
62
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
63
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
64
+ value: true
65
+ });
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = function(module) {
5
+ var getter = module && module.__esModule ? function() {
6
+ return module['default'];
7
+ } : function() {
8
+ return module;
9
+ };
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = function(exports1, definition) {
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = function(obj, prop) {
26
+ return Object.prototype.hasOwnProperty.call(obj, prop);
27
+ };
28
+ })();
29
+ (()=>{
30
+ __webpack_require__.r = function(exports1) {
31
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
32
+ value: 'Module'
33
+ });
34
+ Object.defineProperty(exports1, '__esModule', {
35
+ value: true
36
+ });
37
+ };
38
+ })();
39
+ var __webpack_exports__ = {};
40
+ __webpack_require__.r(__webpack_exports__);
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ useShareActions: ()=>useShareActions
43
+ });
44
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
45
+ const external_react_namespaceObject = require("react");
46
+ const schema_namespaceObject = require("@tachybase/schema");
47
+ const external_antd_namespaceObject = require("antd");
48
+ const external_qrcode_namespaceObject = require("qrcode");
49
+ var external_qrcode_default = /*#__PURE__*/ __webpack_require__.n(external_qrcode_namespaceObject);
50
+ const external_react_i18next_namespaceObject = require("react-i18next");
51
+ const external_react_router_namespaceObject = require("react-router");
52
+ const index_js_namespaceObject = require("../../../../block-provider/index.js");
53
+ const external_index_js_namespaceObject = require("../../../index.js");
54
+ const external_schema_settings_index_js_namespaceObject = require("../../../../schema-settings/index.js");
55
+ const useShareActions = (param)=>{
56
+ let { title, uid } = param;
57
+ var _currentRoute_params;
58
+ const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
59
+ const isAdmin = (0, external_react_router_namespaceObject.useMatch)('/admin/:name');
60
+ const isShare = (0, external_react_router_namespaceObject.useMatch)('/share/:name');
61
+ const isMobile = (0, external_react_router_namespaceObject.useMatch)('/mobile/:name');
62
+ const isMobilePage = (0, index_js_namespaceObject.useIsMobile)();
63
+ const currentRoute = isAdmin || isShare || isMobile;
64
+ const replaceLink = isMobilePage ? window.location.href.replace('/mobile', '/share') : window.location.href.replace('/admin', '/share');
65
+ const link = replaceLink.replace(null == currentRoute ? void 0 : null === (_currentRoute_params = currentRoute.params) || void 0 === _currentRoute_params ? void 0 : _currentRoute_params.name, uid || fieldSchema['x-uid']).replace(window.location.search || '', '');
66
+ const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
67
+ const [qrLink, setQrLink] = (0, external_react_namespaceObject.useState)();
68
+ const compile = (0, external_index_js_namespaceObject.useCompile)();
69
+ external_qrcode_default().toDataURL(link, {
70
+ width: 170
71
+ }, (err, url)=>{
72
+ if (err) {
73
+ console.error(err);
74
+ return;
75
+ }
76
+ if (!qrLink) setQrLink(url);
77
+ });
78
+ const copyLink = ()=>{
79
+ navigator.clipboard.writeText(link).then((res)=>{
80
+ external_antd_namespaceObject.message.open({
81
+ type: 'success',
82
+ content: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
83
+ children: [
84
+ t('Replicated'),
85
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
86
+ style: {
87
+ color: '#3279FE'
88
+ },
89
+ children: compile(title || '')
90
+ }),
91
+ t('page link')
92
+ ]
93
+ })
94
+ });
95
+ });
96
+ };
97
+ const imageAction = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ImageModal, {
98
+ link: qrLink,
99
+ title: title
100
+ });
101
+ return {
102
+ copyLink,
103
+ imageAction
104
+ };
105
+ };
106
+ const ImageModal = (props)=>{
107
+ const { link, title } = props;
108
+ const canvasRef = (0, external_react_namespaceObject.useRef)(null);
109
+ const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
110
+ const { currentUserCtx } = (0, external_schema_settings_index_js_namespaceObject.useCurrentUserVariable)();
111
+ const compile = (0, external_index_js_namespaceObject.useCompile)();
112
+ (0, external_react_namespaceObject.useEffect)(()=>{
113
+ canvasContent(canvasRef, link, currentUserCtx, t);
114
+ }, []);
115
+ const saveImage = ()=>{
116
+ const canvas = canvasRef.current;
117
+ if (canvas) {
118
+ const imageData = canvas.toDataURL('image/png');
119
+ const link = document.createElement('a');
120
+ link.href = imageData;
121
+ link.download = 'Tachybase-Share.png';
122
+ link.click();
123
+ external_antd_namespaceObject.message.open({
124
+ type: 'success',
125
+ content: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
126
+ children: [
127
+ t('Saved'),
128
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
129
+ style: {
130
+ color: '#3279FE'
131
+ },
132
+ children: compile(title || '')
133
+ }),
134
+ t('QR code')
135
+ ]
136
+ })
137
+ });
138
+ }
139
+ };
140
+ const copyImage = ()=>{
141
+ const canvas = canvasRef.current;
142
+ if (canvas && navigator.clipboard) canvas.toBlob(async (blob)=>{
143
+ if (!blob) return;
144
+ try {
145
+ const item = new ClipboardItem({
146
+ 'image/png': blob
147
+ });
148
+ await navigator.clipboard.write([
149
+ item
150
+ ]);
151
+ external_antd_namespaceObject.message.open({
152
+ type: 'success',
153
+ content: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
154
+ children: [
155
+ t('Replicated'),
156
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
157
+ style: {
158
+ color: '#3279FE'
159
+ },
160
+ children: compile(title || '')
161
+ }),
162
+ t('QR code')
163
+ ]
164
+ })
165
+ });
166
+ } catch (err) {
167
+ external_antd_namespaceObject.message.error(t('Copy failed, please try again'));
168
+ }
169
+ }, 'image/png');
170
+ };
171
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
172
+ style: {
173
+ marginTop: '23px',
174
+ display: 'flex',
175
+ flexDirection: 'column',
176
+ justifyContent: 'center',
177
+ alignItems: 'center'
178
+ },
179
+ children: [
180
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("canvas", {
181
+ ref: canvasRef,
182
+ width: 240,
183
+ height: 260,
184
+ style: {
185
+ width: '240px',
186
+ height: '260px',
187
+ pointerEvents: 'none'
188
+ }
189
+ }),
190
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
191
+ style: {
192
+ width: '100%',
193
+ display: 'flex',
194
+ justifyContent: 'space-between',
195
+ marginTop: '10px',
196
+ gap: '15px'
197
+ },
198
+ children: [
199
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
200
+ onClick: saveImage,
201
+ style: {
202
+ flex: 1
203
+ },
204
+ children: t('Save Picture')
205
+ }),
206
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
207
+ onClick: copyImage,
208
+ style: {
209
+ flex: 1
210
+ },
211
+ children: t('Copy QR code')
212
+ })
213
+ ]
214
+ })
215
+ ]
216
+ });
217
+ };
218
+ const canvasContent = (canvasRef, link, currentUserCtx, t)=>{
219
+ const canvas = canvasRef.current;
220
+ const ctx = canvas.getContext('2d');
221
+ const dpr = window.devicePixelRatio;
222
+ const { width, height } = canvas;
223
+ canvas.width = Math.round(width * dpr);
224
+ canvas.height = Math.round(height * dpr);
225
+ canvas.style.width = width + 'px';
226
+ canvas.style.height = height + 'px';
227
+ ctx.scale(dpr, dpr);
228
+ ctx.filter = 'blur(20px)';
229
+ const backgroundGradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height);
230
+ backgroundGradient.addColorStop(0, 'rgba(255, 255, 255, 1)');
231
+ backgroundGradient.addColorStop(1, 'rgba(234, 238, 246, 0.80)');
232
+ ctx.fillStyle = backgroundGradient;
233
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
234
+ const drawGlow = (x, y)=>{
235
+ const radius = 100;
236
+ const gradient = ctx.createRadialGradient(x, y, 0, x, y, radius);
237
+ gradient.addColorStop(0, 'rgba(255, 255, 255, 1)');
238
+ gradient.addColorStop(1, 'rgba(217, 238, 255, 0.216)');
239
+ ctx.fillStyle = gradient;
240
+ ctx.beginPath();
241
+ ctx.arc(x, y, radius, 0, 2 * Math.PI);
242
+ ctx.fill();
243
+ };
244
+ drawGlow(60, 30);
245
+ drawGlow(190, 280);
246
+ ctx.filter = 'none';
247
+ ctx.fillStyle = '#AAAAAA';
248
+ ctx.font = '13px Arial';
249
+ ctx.textAlign = 'center';
250
+ ctx.fillText("".concat(currentUserCtx.nickname), canvas.width / 4, 30);
251
+ const img = new Image();
252
+ img.src = link;
253
+ img.onload = ()=>{
254
+ const imgWidth = img.width;
255
+ const imgHeight = img.height;
256
+ const x = (canvas.width - imgWidth) / 8;
257
+ const y = 40;
258
+ const borderWidth = 3;
259
+ const borderRadius = 20;
260
+ ctx.beginPath();
261
+ ctx.moveTo(x + borderRadius, y);
262
+ ctx.arcTo(x + imgWidth, y, x + imgWidth, y + imgHeight, borderRadius);
263
+ ctx.arcTo(x + imgWidth, y + imgHeight, x, y + imgHeight, borderRadius);
264
+ ctx.arcTo(x, y + imgHeight, x, y, borderRadius);
265
+ ctx.arcTo(x, y, x + imgWidth, y, borderRadius);
266
+ ctx.closePath();
267
+ ctx.clip();
268
+ ctx.drawImage(img, x + borderWidth, y + borderWidth, imgWidth - 2 * borderWidth, imgHeight - 2 * borderWidth);
269
+ ctx.lineWidth = borderWidth;
270
+ ctx.strokeStyle = '#000';
271
+ ctx.beginPath();
272
+ ctx.moveTo(x + borderRadius, y);
273
+ ctx.arcTo(x + imgWidth, y, x + imgWidth, y + imgHeight, borderRadius);
274
+ ctx.arcTo(x + imgWidth, y + imgHeight, x, y + imgHeight, borderRadius);
275
+ ctx.arcTo(x, y + imgHeight, x, y, borderRadius);
276
+ ctx.arcTo(x, y, x + imgWidth, y, borderRadius);
277
+ ctx.closePath();
278
+ ctx.stroke();
279
+ };
280
+ ctx.fillStyle = '#AAAAAA';
281
+ ctx.font = '13px Arial';
282
+ ctx.textAlign = 'center';
283
+ ctx.fillText(t('Scan the code to view the sharing'), canvas.width / 4, 230);
284
+ ctx.fillStyle = 'rgba(50, 121, 254, 1)';
285
+ ctx.font = '14px Arial';
286
+ ctx.textAlign = 'center';
287
+ ctx.fillText('灵矶(Tachybase)', canvas.width / 4, 250);
288
+ };
289
+ var __webpack_export_target__ = exports;
290
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
291
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
292
+ value: true
293
+ });
@@ -14,6 +14,9 @@ var __webpack_modules__ = {
14
14
  },
15
15
  "./PageTab.Settings": function(module) {
16
16
  module.exports = require("./PageTab.Settings.js");
17
+ },
18
+ "./hooks?6ac2": function(module) {
19
+ module.exports = require("./hooks/index.js");
17
20
  }
18
21
  };
19
22
  var __webpack_module_cache__ = {};
@@ -94,6 +97,12 @@ for(var __WEBPACK_IMPORT_KEY__ in _FixedBlockDesignerItem__WEBPACK_IMPORTED_MODU
94
97
  return _FixedBlockDesignerItem__WEBPACK_IMPORTED_MODULE_4__[key];
95
98
  }).bind(0, __WEBPACK_IMPORT_KEY__);
96
99
  __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
100
+ var _hooks__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./hooks?6ac2");
101
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
102
+ for(var __WEBPACK_IMPORT_KEY__ in _hooks__WEBPACK_IMPORTED_MODULE_5__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
103
+ return _hooks__WEBPACK_IMPORTED_MODULE_5__[key];
104
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
105
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
97
106
  var __webpack_export_target__ = exports;
98
107
  for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
99
108
  if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {