dtable-ui-component 5.3.0 → 5.3.1-beta

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 (239) hide show
  1. package/assets/dtable-font/dtable-font.eot +0 -0
  2. package/assets/dtable-font/dtable-font.svg +116 -0
  3. package/assets/dtable-font/dtable-font.ttf +0 -0
  4. package/assets/dtable-font/dtable-font.woff +0 -0
  5. package/assets/dtable-font/dtable-font.woff2 +0 -0
  6. package/assets/dtable-font.css +238 -6
  7. package/lib/CheckboxEditor/index.css +3 -20
  8. package/lib/CheckboxEditor/index.js +98 -35
  9. package/lib/CheckboxFormatter/index.js +6 -9
  10. package/lib/CollaboratorEditor/index.css +12 -35
  11. package/lib/CollaboratorEditor/index.js +18 -212
  12. package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +26 -29
  13. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
  14. package/lib/CollaboratorItem/index.css +1 -1
  15. package/lib/CollaboratorItem/index.js +6 -2
  16. package/lib/DTableCustomizeCollaboratorSelect/index.css +1 -1
  17. package/lib/DTableCustomizeCollaboratorSelect/index.js +1 -1
  18. package/lib/DTableCustomizeSelect/index.css +2 -2
  19. package/lib/DTableCustomizeSelect/index.js +1 -1
  20. package/lib/DTableFiltersPopover/utils/index.js +1 -7
  21. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +1 -1
  22. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +1 -1
  23. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  24. package/lib/DTableFiltersPopover/widgets/filter-list/index.css +2 -2
  25. package/lib/DTableSelect/index.js +3 -1
  26. package/lib/DTableSelect/utils.js +1 -1
  27. package/lib/DateEditor/index.js +14 -51
  28. package/lib/DateEditor/pc-date-editor-popover.js +145 -12
  29. package/lib/DeleteTip/index.js +50 -0
  30. package/lib/Department-editor/department-single-select.js +1 -1
  31. package/lib/Department-editor/index.js +3 -4
  32. package/lib/DepartmentSingleSelectFormatter/index.js +2 -1
  33. package/lib/DigitalSignEditor/constants.js +7 -0
  34. package/lib/DigitalSignEditor/index.css +69 -0
  35. package/lib/DigitalSignEditor/index.js +182 -0
  36. package/lib/DigitalSignEditor/service.js +38 -0
  37. package/lib/DigitalSignEditor/signature-board/index.css +35 -0
  38. package/lib/DigitalSignEditor/signature-board/index.js +135 -0
  39. package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
  40. package/lib/DigitalSignEditor/utils.js +29 -0
  41. package/lib/DurationEditor/index.js +111 -0
  42. package/lib/EmailEditor/index.js +59 -0
  43. package/lib/FileEditor/addition-previewer/index.css +1 -0
  44. package/lib/FileEditor/addition-previewer/index.js +52 -0
  45. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
  46. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
  47. package/lib/FileEditor/constants.js +7 -0
  48. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
  49. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
  50. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
  51. package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
  52. package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
  53. package/lib/FileEditor/files-previewer/index.css +56 -0
  54. package/lib/FileEditor/files-previewer/index.js +277 -0
  55. package/lib/FileEditor/index.css +6 -0
  56. package/lib/FileEditor/index.js +244 -11
  57. package/lib/FileEditor/utils.js +22 -0
  58. package/lib/FileItemFormatter/index.js +19 -20
  59. package/lib/FileUploader/index.css +9 -0
  60. package/lib/FileUploader/index.js +268 -14
  61. package/lib/FormulaFormatter/index.js +2 -1
  62. package/lib/FormulaFormatter/utils.js +0 -31
  63. package/lib/GeolocationEditor/country-editor.js +319 -0
  64. package/lib/GeolocationEditor/index.css +641 -0
  65. package/lib/GeolocationEditor/index.js +241 -0
  66. package/lib/GeolocationEditor/location-editor.js +368 -0
  67. package/lib/GeolocationEditor/map-editor/index.js +456 -0
  68. package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
  69. package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
  70. package/lib/GeolocationEditor/map-editor-utils.js +153 -0
  71. package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
  72. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
  73. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
  74. package/lib/GeolocationEditor/parse-geolocation.js +282 -0
  75. package/lib/GeolocationEditor/province-city-editor.js +292 -0
  76. package/lib/GeolocationEditor/province-editor.js +226 -0
  77. package/lib/GeolocationEditor/selector-header-item.js +28 -0
  78. package/lib/GeolocationEditor/selector-list.js +33 -0
  79. package/lib/GeolocationEditor/with-ref.js +27 -0
  80. package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
  81. package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
  82. package/lib/ImageEditor/addition-previewer/index.css +106 -0
  83. package/lib/ImageEditor/addition-previewer/index.js +63 -0
  84. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
  85. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
  86. package/lib/ImageEditor/constants.js +7 -0
  87. package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
  88. package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
  89. package/lib/ImageEditor/images-previewer/index.css +18 -0
  90. package/lib/ImageEditor/images-previewer/index.js +140 -0
  91. package/lib/ImageEditor/index.css +24 -0
  92. package/lib/ImageEditor/index.js +194 -0
  93. package/lib/ImageThumbnail/index.css +20 -0
  94. package/lib/ImageThumbnail/index.js +136 -0
  95. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  96. package/lib/MultipleSelectEditor/index.js +16 -177
  97. package/lib/NumberEditor/index.js +64 -77
  98. package/lib/RoleStatusEditor/index.css +3 -3
  99. package/lib/RoleStatusEditor/index.js +1 -1
  100. package/lib/RowExpandDialog/body/index.css +21 -0
  101. package/lib/RowExpandDialog/body/index.js +279 -0
  102. package/lib/RowExpandDialog/column-content/index.css +43 -0
  103. package/lib/RowExpandDialog/column-content/index.js +50 -0
  104. package/lib/RowExpandDialog/constants.js +114 -0
  105. package/lib/RowExpandDialog/header/index.css +31 -0
  106. package/lib/RowExpandDialog/header/index.js +33 -0
  107. package/lib/RowExpandDialog/index.css +24 -0
  108. package/lib/RowExpandDialog/index.js +268 -0
  109. package/lib/RowExpandDialog/utils.js +83 -0
  110. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
  111. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
  112. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
  113. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
  114. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
  115. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
  116. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
  117. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +129 -0
  118. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
  119. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
  120. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
  121. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
  122. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
  123. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
  124. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +146 -0
  125. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
  126. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
  127. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +6 -0
  128. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
  129. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
  130. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +124 -0
  131. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
  132. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +224 -0
  133. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
  134. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
  135. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
  136. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
  137. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +192 -0
  138. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
  139. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
  140. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
  141. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
  142. package/lib/RowExpandEditor/constants.js +44 -0
  143. package/lib/RowExpandEditor/index.css +0 -0
  144. package/lib/RowExpandEditor/index.js +32 -0
  145. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
  146. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
  147. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
  148. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
  149. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
  150. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +10 -11
  151. package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
  152. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
  153. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
  154. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  155. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  156. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +5 -5
  157. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/utils.js +1 -1
  158. package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
  159. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
  160. package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
  161. package/lib/RowExpandFormatter/constants.js +60 -0
  162. package/lib/RowExpandFormatter/index.css +26 -0
  163. package/lib/RowExpandFormatter/index.js +84 -100
  164. package/lib/SingleSelectEditor/index.js +16 -156
  165. package/lib/TextEditor/index.js +113 -42
  166. package/lib/UploadProgress/index.js +38 -0
  167. package/lib/UrlEditor/index.js +62 -0
  168. package/lib/common/editor-base.js +53 -0
  169. package/lib/constants/file.js +96 -0
  170. package/lib/constants/index.js +34 -2
  171. package/lib/constants/key-codes.js +109 -0
  172. package/lib/css/cell-editor.css +18 -2
  173. package/lib/hooks/index.js +16 -0
  174. package/lib/index.js +74 -46
  175. package/lib/lang/index.js +16 -14
  176. package/lib/locales/de.json +163 -0
  177. package/lib/locales/en.json +163 -0
  178. package/lib/locales/es.json +163 -0
  179. package/lib/locales/fr.json +163 -0
  180. package/lib/locales/pt.json +163 -0
  181. package/lib/locales/ru.json +163 -0
  182. package/lib/locales/zh-CN.json +163 -0
  183. package/lib/select-editor/index.js +6 -6
  184. package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
  185. package/lib/select-editor/pc-select-editor/index.css +85 -0
  186. package/lib/select-editor/pc-select-editor/index.js +290 -0
  187. package/lib/utils/cell-comparer.js +35 -0
  188. package/lib/utils/cell.js +55 -0
  189. package/lib/utils/column-utils.js +25 -0
  190. package/lib/utils/editor-utils.js +1 -6
  191. package/lib/utils/get-event-transfer.js +75 -0
  192. package/lib/utils/object-utils.js +61 -0
  193. package/lib/utils/url.js +119 -8
  194. package/lib/utils/utils.js +89 -2
  195. package/package.json +3 -2
  196. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
  197. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  198. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  199. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  200. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  201. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  202. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  203. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  204. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  205. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  206. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  207. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  208. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  209. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  210. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  211. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  212. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  213. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  214. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  215. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  216. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  217. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  218. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  219. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  220. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  221. package/lib/FileItemFormatter/utils.js +0 -99
  222. package/lib/MultipleSelectEditor/index.css +0 -9
  223. package/lib/RowExpandUrlFormatter/index.css +0 -1
  224. package/lib/SingleSelectEditor/index.css +0 -14
  225. package/lib/locals/de.js +0 -103
  226. package/lib/locals/en.js +0 -104
  227. package/lib/locals/es.js +0 -103
  228. package/lib/locals/fr.js +0 -103
  229. package/lib/locals/pt.js +0 -103
  230. package/lib/locals/ru.js +0 -103
  231. package/lib/locals/zh-CN.js +0 -104
  232. package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
  233. package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
  234. /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
  235. /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
  236. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +0 -0
  237. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
  238. /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
  239. /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
@@ -0,0 +1,268 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _reactstrap = require("reactstrap");
12
+ var _dtableUtils = require("dtable-utils");
13
+ var _lang = require("../lang");
14
+ var _header = _interopRequireDefault(require("./header"));
15
+ var _body = _interopRequireDefault(require("./body"));
16
+ var _Loading = _interopRequireDefault(require("../Loading"));
17
+ var _utils = require("../utils/utils");
18
+ var _cellComparer = require("../utils/cell-comparer");
19
+ require("./index.css");
20
+ var _toaster = _interopRequireDefault(require("../toaster"));
21
+ const RowExpandDialog = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
22
+ let {
23
+ saveImmediately = true,
24
+ isInsertingRow,
25
+ zIndex,
26
+ title,
27
+ className,
28
+ placeholder,
29
+ collaborators,
30
+ component,
31
+ eventBus,
32
+ valueKey = 'name',
33
+ // name or key
34
+ departments,
35
+ userDepartmentIdsMap,
36
+ config,
37
+ layout = 'horizontal',
38
+ // horizontal or vertical
39
+ longTextEditorAPI,
40
+ getRow,
41
+ modifyRow,
42
+ getCollaborators,
43
+ queryCollaborators,
44
+ checkEditable = c => c.editable && !_dtableUtils.NOT_SUPPORT_EDIT_COLUMN_TYPE_MAP[c.type],
45
+ onToggle,
46
+ uploadFile
47
+ } = _ref;
48
+ const [isAnimationEnd, setAnimationEnd] = (0, _react.useState)(false);
49
+ const [isLoading, setLoading] = (0, _react.useState)(true);
50
+ const [isSaving, setSaving] = (0, _react.useState)(false);
51
+ const [errorMessage, setErrorMessage] = (0, _react.useState)('');
52
+ const [row, setRow] = (0, _react.useState)({});
53
+ const [columns, setColumns] = (0, _react.useState)([]);
54
+ const modalRef = (0, _react.useRef)(null);
55
+ const isChangedRef = (0, _react.useRef)(false);
56
+ const update = (0, _react.useRef)({});
57
+ const initStyle = (0, _react.useMemo)(() => {
58
+ const defaultMargin = 80; // sequence cell width
59
+ const defaultHeight = 100;
60
+ return {
61
+ width: window.innerWidth - defaultMargin,
62
+ maxWidth: window.innerWidth - defaultMargin,
63
+ marginLeft: defaultMargin,
64
+ height: defaultHeight,
65
+ marginRight: defaultMargin,
66
+ marginTop: '30%',
67
+ transition: 'all .3s'
68
+ };
69
+ }, []);
70
+ const style = (0, _react.useMemo)(() => {
71
+ const width = 800;
72
+ return {
73
+ width,
74
+ maxWidth: width,
75
+ marginLeft: (window.innerWidth - width) / 2,
76
+ height: 'calc(100% - 56px)' // Dialog margin is 3.5rem (56px)
77
+ };
78
+ }, []);
79
+ const _checkEditable = (0, _react.useCallback)((column, row) => {
80
+ if (isSaving) return false;
81
+ if (!column) return false;
82
+ if (!checkEditable) return false;
83
+ if (!checkEditable(column, row)) return false;
84
+ if (column.type === _dtableUtils.CellType.IMAGE || column.type === _dtableUtils.CellType.FILE) return Boolean(uploadFile);
85
+ return true;
86
+ }, [isSaving, checkEditable, uploadFile]);
87
+ const initRowData = (0, _react.useCallback)(() => {
88
+ setLoading(true);
89
+ getRow().then(res => {
90
+ const {
91
+ row,
92
+ columns
93
+ } = res.data;
94
+ setRow(row);
95
+ const validColumns = columns.map(c => ({
96
+ ...c,
97
+ editable: _checkEditable(c, row),
98
+ width: 320
99
+ }));
100
+ isChangedRef.current = isInsertingRow && Object.keys(row).length > 0;
101
+ setColumns(validColumns);
102
+ setLoading(false);
103
+ }).catch(error => {
104
+ const errorMsg = (0, _utils.getErrorMsg)(error);
105
+ setErrorMessage((0, _lang.getLocale)(errorMsg));
106
+ setLoading(false);
107
+ });
108
+ }, [isInsertingRow, getRow, _checkEditable]);
109
+ const toggle = (0, _react.useCallback)(() => {
110
+ if (isSaving) return;
111
+ onToggle();
112
+ }, [isSaving, onToggle]);
113
+ const onSave = (0, _react.useCallback)(function (updated) {
114
+ let {
115
+ successCallback,
116
+ failCallback
117
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
118
+ modifyRow(updated, columns, {
119
+ successCallback,
120
+ failCallback
121
+ });
122
+ }, [columns, modifyRow]);
123
+ const onChange = (0, _react.useCallback)((column, value) => {
124
+ const key = column[valueKey];
125
+ const updated = {
126
+ [key]: value
127
+ };
128
+ const oldValue = row[key];
129
+ if (!(0, _cellComparer.isCellValueChanged)(oldValue, value, column.type)) return;
130
+ if (!saveImmediately || isInsertingRow) {
131
+ isChangedRef.current = true;
132
+ update.current = {
133
+ ...update.current,
134
+ ...updated
135
+ };
136
+ setRow({
137
+ ...row,
138
+ ...updated
139
+ });
140
+ return;
141
+ }
142
+ onSave(updated, {
143
+ successCallback: () => {
144
+ isChangedRef.current = false;
145
+ update.current = {};
146
+ setRow({
147
+ ...row,
148
+ ...updated
149
+ });
150
+ },
151
+ failCallback: () => {
152
+ _toaster.default.danger((0, _lang.getLocale)('Save_failed'));
153
+ }
154
+ });
155
+ }, [saveImmediately, isInsertingRow, row, valueKey, onSave]);
156
+ const onSubmit = (0, _react.useCallback)(() => {
157
+ setSaving(true);
158
+ const successCallback = isInsertingRow ? onToggle : () => {
159
+ isChangedRef.current = false;
160
+ update.current = {};
161
+ setSaving(false);
162
+ };
163
+ const failCallback = () => {
164
+ setSaving(false);
165
+ _toaster.default.danger((0, _lang.getLocale)('Save_failed'));
166
+ };
167
+ const newRow = isInsertingRow ? {
168
+ ...row,
169
+ ...update.current
170
+ } : update.current;
171
+ onSave(newRow, {
172
+ successCallback,
173
+ failCallback
174
+ });
175
+ }, [row, isInsertingRow, onSave, onToggle]);
176
+ (0, _react.useEffect)(() => {
177
+ // use setTimeout to make sure real dom rendered
178
+ setTimeout(() => {
179
+ let dom = modalRef.current.firstChild;
180
+ const {
181
+ width,
182
+ maxWidth,
183
+ marginLeft,
184
+ height
185
+ } = style;
186
+ dom.style.width = "".concat(width, "px");
187
+ dom.style.maxWidth = "".concat(maxWidth, "px");
188
+ dom.style.marginLeft = "".concat(marginLeft, "px");
189
+ dom.style.height = height;
190
+ dom.style.marginRight = 'unset';
191
+ dom.style.marginTop = '28px';
192
+ // after animation, change style and run callback
193
+ setTimeout(() => {
194
+ setAnimationEnd(true);
195
+ dom.style.transition = 'none';
196
+ initRowData();
197
+ }, 280);
198
+ }, 1);
199
+ // eslint-disable-next-line react-hooks/exhaustive-deps
200
+ }, []);
201
+ (0, _react.useImperativeHandle)(ref, () => ({
202
+ getData: () => ({
203
+ row,
204
+ columns
205
+ }),
206
+ setData: function () {
207
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
208
+ Object.keys(data).forEach(key => {
209
+ if (key === 'row') {
210
+ setRow(data[key]);
211
+ }
212
+ if (key === 'columns') {
213
+ setColumns(data[key]);
214
+ }
215
+ });
216
+ }
217
+ }), [row, columns]);
218
+ const renderContent = (0, _react.useCallback)(() => {
219
+ if (!isAnimationEnd) return null;
220
+ if (isLoading) return /*#__PURE__*/_react.default.createElement("div", {
221
+ className: "w-100 -h-100 d-flex align-items-center justify-content-center"
222
+ }, /*#__PURE__*/_react.default.createElement(_Loading.default, null));
223
+ if (errorMessage) return /*#__PURE__*/_react.default.createElement("div", null, errorMessage);
224
+ return /*#__PURE__*/_react.default.createElement("div", {
225
+ className: "dtable-ui-row-expand-details"
226
+ }, /*#__PURE__*/_react.default.createElement(_header.default, {
227
+ onToggle: toggle,
228
+ title: title
229
+ }), /*#__PURE__*/_react.default.createElement(_body.default, {
230
+ isInsertingRow: isInsertingRow,
231
+ row: row,
232
+ columns: columns,
233
+ placeholder: placeholder,
234
+ collaborators: collaborators,
235
+ eventBus: eventBus,
236
+ component: component,
237
+ valueKey: valueKey,
238
+ departments: departments,
239
+ userDepartmentIdsMap: userDepartmentIdsMap,
240
+ config: config,
241
+ onChange: onChange,
242
+ getCollaborators: getCollaborators,
243
+ queryCollaborators: queryCollaborators,
244
+ uploadFile: uploadFile,
245
+ longTextEditorAPI: longTextEditorAPI
246
+ }), (!saveImmediately || isInsertingRow) && /*#__PURE__*/_react.default.createElement(_reactstrap.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
247
+ onClick: toggle,
248
+ color: "secondary"
249
+ }, (0, _lang.getLocale)('Cancel')), /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
250
+ onClick: onSubmit,
251
+ disabled: isSaving || !isChangedRef.current,
252
+ color: "primary"
253
+ }, (0, _lang.getLocale)('Submit'))));
254
+ }, [isSaving, saveImmediately, isAnimationEnd, isLoading, isInsertingRow, errorMessage, title, row, columns, placeholder, collaborators, component, valueKey, departments, userDepartmentIdsMap, eventBus, onChange, toggle, getCollaborators, queryCollaborators, uploadFile, longTextEditorAPI, config, onSubmit]);
255
+ return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
256
+ isOpen: true,
257
+ toggle: onToggle,
258
+ className: (0, _classnames.default)('dtable-ui-row-expand-dialog', className),
259
+ style: isAnimationEnd ? style : initStyle,
260
+ zIndex: zIndex || 1048,
261
+ contentClassName: "dtable-ui-row-expand-content",
262
+ modalClassName: "dtable-ui-row-expand-modal",
263
+ fade: false,
264
+ innerRef: modalRef,
265
+ keyboard: false
266
+ }, renderContent());
267
+ });
268
+ var _default = exports.default = RowExpandDialog;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTwoDimensionArrayValue = exports.getFormulaArrayValue = exports.downloadFile = void 0;
7
+ exports.isArrayFormalColumn = isArrayFormalColumn;
8
+ exports.isValidCellValue = void 0;
9
+ var _dtableUtils = require("dtable-utils");
10
+ const isValidCellValue = value => {
11
+ if (value === undefined) return false;
12
+ if (value === null) return false;
13
+ if (value === '') return false;
14
+ if (JSON.stringify(value) === '{}') return false;
15
+ if (JSON.stringify(value) === '[]') return false;
16
+ return true;
17
+ };
18
+ exports.isValidCellValue = isValidCellValue;
19
+ function isArrayFormalColumn(columnType) {
20
+ return [_dtableUtils.CellType.IMAGE, _dtableUtils.CellType.FILE, _dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.COLLABORATOR].includes(columnType);
21
+ }
22
+ const getFormulaArrayValue = function (value) {
23
+ let isFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
24
+ if (!Array.isArray(value)) return [];
25
+ if (!isFlat) return getTwoDimensionArrayValue(value);
26
+ return value.map(item => {
27
+ if (Object.prototype.toString.call(item) !== '[object Object]') {
28
+ return item;
29
+ }
30
+ if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
31
+ const {
32
+ display_value
33
+ } = item;
34
+ if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
35
+ return display_value.map(i => {
36
+ if (Object.prototype.toString.call(i) === '[object Object]') {
37
+ if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
38
+ const {
39
+ display_value
40
+ } = i;
41
+ return display_value;
42
+ }
43
+ return i;
44
+ });
45
+ }).flat().filter(item => isValidCellValue(item));
46
+ };
47
+ exports.getFormulaArrayValue = getFormulaArrayValue;
48
+ const getTwoDimensionArrayValue = value => {
49
+ if (!Array.isArray(value)) return [];
50
+ return value.map(item => {
51
+ if (Object.prototype.toString.call(item) !== '[object Object]') {
52
+ return item;
53
+ }
54
+ if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) return item;
55
+ const {
56
+ display_value
57
+ } = item;
58
+ if (!Array.isArray(display_value) || display_value.length === 0) return display_value;
59
+ return display_value.map(i => {
60
+ if (Object.prototype.toString.call(i) === '[object Object]') {
61
+ if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) return i;
62
+ const {
63
+ display_value
64
+ } = i;
65
+ return display_value;
66
+ }
67
+ return i;
68
+ });
69
+ });
70
+ };
71
+ exports.getTwoDimensionArrayValue = getTwoDimensionArrayValue;
72
+ const downloadFile = downloadUrl => {
73
+ const downloadFrame = document.getElementById('download-iframe');
74
+ if (downloadFrame != null) {
75
+ document.body.removeChild(downloadFrame);
76
+ }
77
+ let iframe = document.createElement('iframe');
78
+ iframe.setAttribute('id', 'download-iframe');
79
+ iframe.style.display = 'none';
80
+ iframe.src = downloadUrl;
81
+ document.body.appendChild(iframe);
82
+ };
83
+ exports.downloadFile = downloadFile;
@@ -0,0 +1,22 @@
1
+ .dtable-ui-row-expand-add-btn {
2
+ min-width: 80px;
3
+ max-width: 100%;
4
+ height: 28px;
5
+ line-height: 24px;
6
+ border: 2px solid transparent;
7
+ padding: 0 10px;
8
+ background-color: #f0f0f0;
9
+ border-radius: 3px;
10
+ color: #666666;
11
+ font-size: 14px;
12
+ text-align: center;
13
+ display: inline-flex;
14
+ cursor: pointer;
15
+ width: fit-content;
16
+ }
17
+
18
+ .dtable-ui-row-expand-add-btn:hover {
19
+ background-color: #dbdbdb;
20
+ color: #666666;
21
+ cursor: pointer;
22
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _constants = require("../../constants");
10
+ require("./index.css");
11
+ const RowExpandAddBtn = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
12
+ return /*#__PURE__*/_react.default.createElement("div", {
13
+ ref: ref,
14
+ tabIndex: 0,
15
+ onClick: props.onClick,
16
+ onFocus: props.onFocus,
17
+ role: "button",
18
+ className: "dtable-ui-row-expand-add-btn d-print-none",
19
+ style: props.isFocus ? _constants.ROW_EXPAND_BTN_FOCUS_STYLE : {}
20
+ }, /*#__PURE__*/_react.default.createElement("span", {
21
+ className: "d-print-none"
22
+ }, props.text));
23
+ });
24
+ var _default = exports.default = RowExpandAddBtn;
@@ -0,0 +1,18 @@
1
+ .dtable-ui-row-expand-checkbox-editor {
2
+ width: 24px;
3
+ height: 24px;
4
+ border: 2px solid #e0e0e0;
5
+ border-radius: 3px;
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ margin-top: 6px;
10
+ }
11
+
12
+ .dtable-ui-checkbox-editor.dtable-ui-row-expand-checkbox-editor {
13
+ cursor: pointer;
14
+ }
15
+
16
+ .dtable-ui-checkbox-editor.dtable-ui-row-expand-checkbox-editor.focus {
17
+ box-shadow: 0 0 0 2px #66afe9;
18
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _CheckboxEditor = _interopRequireDefault(require("../../CheckboxEditor"));
10
+ var _constants = require("../../constants");
11
+ require("./index.css");
12
+ class RowExpandCheckboxEditor extends _react.default.Component {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.onChangeCheckboxValue = () => {
16
+ const {
17
+ columnIndex
18
+ } = this.props;
19
+ if (!this.editor) return;
20
+ if (this.props.updateTabIndex) {
21
+ this.props.updateTabIndex(columnIndex);
22
+ }
23
+ const newValue = this.editor.getValue();
24
+ this.props.onCommit(newValue);
25
+ };
26
+ }
27
+ render() {
28
+ const {
29
+ isEditorFocus,
30
+ column,
31
+ value
32
+ } = this.props;
33
+ return /*#__PURE__*/_react.default.createElement(_CheckboxEditor.default, {
34
+ ref: ref => this.editor = ref,
35
+ className: "dtable-ui-row-expand-checkbox-editor mt-2",
36
+ column: column,
37
+ value: value,
38
+ style: isEditorFocus ? _constants.ROW_EXPAND_FOCUS_STYLE : {},
39
+ onCommit: this.onChangeCheckboxValue
40
+ });
41
+ }
42
+ }
43
+ var _default = exports.default = RowExpandCheckboxEditor;
@@ -0,0 +1,5 @@
1
+ @import url('../../css/cell-editor.css');
2
+
3
+ .dtable-ui-row-expand-select-editor .dtable-ui.collaborator-item {
4
+ margin: 5px 10px 5px 0;
5
+ }
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _constants = require("../../constants");
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _CollaboratorEditor = _interopRequireDefault(require("../../CollaboratorEditor"));
12
+ var _lang = require("../../lang");
13
+ var _CollaboratorItem = _interopRequireDefault(require("../../CollaboratorItem"));
14
+ require("./index.css");
15
+ class RowExpandCollaboratorEditor extends _react.default.Component {
16
+ constructor(_props) {
17
+ super(_props);
18
+ this.initCollaborators = props => {
19
+ const {
20
+ row,
21
+ column,
22
+ valueKey
23
+ } = props;
24
+ const emails = row[column[valueKey]] || [];
25
+ props.queryCollaborators && props.queryCollaborators(emails);
26
+ };
27
+ this.getCollaborators = () => {
28
+ const {
29
+ getCollaborators,
30
+ collaborators
31
+ } = this.props;
32
+ if (getCollaborators) return getCollaborators();
33
+ return collaborators || [];
34
+ };
35
+ this.updateCollaborators = () => {
36
+ const collaborators = this.getCollaborators();
37
+ let emailCollaboratorMap = {};
38
+ collaborators.forEach(c => {
39
+ emailCollaboratorMap[c.email] = c;
40
+ });
41
+ this.setState({
42
+ emailCollaboratorMap
43
+ });
44
+ };
45
+ this.onKeyDown = e => {
46
+ if (e.keyCode === _constants.KeyCodes.Enter && this.props.isEditorFocus && !this.state.showCollaboratorSelect) {
47
+ this.toggleCollaboratorSelect(true);
48
+ }
49
+ };
50
+ this.hideSelect = event => {
51
+ if (!this.state.showCollaboratorSelect || !event.target || event.target.tagName.toUpperCase() === 'INPUT') {
52
+ return;
53
+ }
54
+ const editor = document.querySelector('.dtable-ui-collaborator-editor-container');
55
+ if (editor && editor.contains(event.target) || this.collaboratorSelectRef.contains(event.target)) {
56
+ return;
57
+ }
58
+ this.toggleCollaboratorSelect(false);
59
+ };
60
+ this.toggleCollaboratorSelect = value => {
61
+ this.setState({
62
+ showCollaboratorSelect: value
63
+ }, () => {
64
+ if (!value) this.collaboratorContentRef.focus();
65
+ });
66
+ };
67
+ this.onToggleSelect = event => {
68
+ event.stopPropagation();
69
+ this.props.updateTabIndex(this.props.columnIndex);
70
+ this.toggleCollaboratorSelect(true);
71
+ };
72
+ this.onFocus = () => {
73
+ this.props.updateTabIndex(this.props.columnIndex);
74
+ };
75
+ this.closeSelect = () => {
76
+ this.toggleCollaboratorSelect(false);
77
+ };
78
+ this.onChange = collaborator => {
79
+ let newValue = this.state.value.slice(0);
80
+ const collaboratorIndex = newValue.findIndex(email => collaborator.email === email);
81
+ if (collaboratorIndex === -1) {
82
+ newValue.push(collaborator.email);
83
+ } else {
84
+ newValue.splice(collaboratorIndex, 1);
85
+ }
86
+ this.setState({
87
+ value: newValue
88
+ });
89
+ this.props.onCommit(newValue);
90
+ };
91
+ this.removeCollaborator = index => {
92
+ let {
93
+ value
94
+ } = this.state;
95
+ let newValue = value.slice(0);
96
+ newValue.splice(index, 1);
97
+ this.setState({
98
+ value: newValue
99
+ });
100
+ this.props.onCommit(newValue);
101
+ };
102
+ this.renderSelectedCollaborators = () => {
103
+ const {
104
+ isEditorFocus
105
+ } = this.props;
106
+ const {
107
+ value,
108
+ emailCollaboratorMap
109
+ } = this.state;
110
+ return /*#__PURE__*/_react.default.createElement("div", {
111
+ tabIndex: 0,
112
+ onFocus: this.onFocus,
113
+ onClick: this.onToggleSelect,
114
+ ref: ref => this.collaboratorContentRef = ref,
115
+ className: (0, _classnames.default)('dtable-ui-row-expand-select-editor custom-select', {
116
+ 'focus': isEditorFocus
117
+ })
118
+ }, /*#__PURE__*/_react.default.createElement("div", {
119
+ className: "dtable-ui-row-expand-select-editor-inner"
120
+ }, /*#__PURE__*/_react.default.createElement("div", null, value.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
121
+ className: "dtable-ui-row-expand-select-options"
122
+ }, value.map((email, index) => {
123
+ let collaborator = emailCollaboratorMap[email];
124
+ if (collaborator) {
125
+ const {
126
+ email
127
+ } = collaborator;
128
+ return /*#__PURE__*/_react.default.createElement(_CollaboratorItem.default, {
129
+ key: email,
130
+ collaborator: collaborator,
131
+ enableDeleteCollaborator: true,
132
+ onDeleteCollaborator: this.removeCollaborator.bind(this, index)
133
+ });
134
+ }
135
+ collaborator = {
136
+ name: (0, _lang.getLocale)('Unknown'),
137
+ avatar_url: '',
138
+ email: index + ''
139
+ };
140
+ return /*#__PURE__*/_react.default.createElement(_CollaboratorItem.default, {
141
+ key: index,
142
+ className: "dtable-ui-unknown-collaborator",
143
+ collaborator: collaborator,
144
+ enableDeleteCollaborator: true,
145
+ onDeleteCollaborator: this.removeCollaborator.bind(this, index)
146
+ });
147
+ }))), /*#__PURE__*/_react.default.createElement("i", {
148
+ "aria-hidden": "true",
149
+ className: "dtable-font dtable-icon-down3"
150
+ })));
151
+ };
152
+ const {
153
+ row: _row,
154
+ column: _column,
155
+ valueKey: _valueKey
156
+ } = this.props;
157
+ this.state = {
158
+ menuPosition: null,
159
+ value: _row[_column[_valueKey]] || [],
160
+ showCollaboratorSelect: false,
161
+ isDataLoaded: false,
162
+ emailCollaboratorMap: {}
163
+ };
164
+ }
165
+ componentDidMount() {
166
+ this.initCollaborators(this.props);
167
+ document.addEventListener('mousedown', this.hideSelect);
168
+ document.addEventListener('keydown', this.onKeyDown);
169
+ const eventBus = this.props.eventBus;
170
+ if (eventBus) {
171
+ this.unsubscribeCollaboratorsUpdated = eventBus.subscribe('collaborators-updated', this.updateCollaborators);
172
+ } else {
173
+ this.updateCollaborators();
174
+ }
175
+ }
176
+ UNSAFE_componentWillReceiveProps(nextProps) {
177
+ const {
178
+ column,
179
+ row,
180
+ valueKey
181
+ } = nextProps;
182
+ if (row._id !== this.props.row._id) {
183
+ this.initCollaborators(nextProps);
184
+ this.setState({
185
+ value: row[column[valueKey]] || [],
186
+ showCollaboratorSelect: false
187
+ });
188
+ }
189
+ }
190
+ componentDidUpdate(prevProps, prevState) {
191
+ if (this.state.showCollaboratorSelect !== prevState.showCollaboratorSelect) {
192
+ if (this.state.showCollaboratorSelect === true && this.props.onEditorOpen) {
193
+ this.props.onEditorOpen();
194
+ }
195
+ if (this.state.showCollaboratorSelect === false && this.props.onEditorClose) {
196
+ this.props.onEditorClose();
197
+ }
198
+ }
199
+ }
200
+ componentWillUnmount() {
201
+ if (this.props.eventBus && this.unsubscribeCollaboratorsUpdated) {
202
+ this.unsubscribeCollaboratorsUpdated();
203
+ }
204
+ document.removeEventListener('mousedown', this.hideSelect);
205
+ document.removeEventListener('keydown', this.onKeyDown);
206
+ }
207
+ render() {
208
+ const {
209
+ collaborators,
210
+ column
211
+ } = this.props;
212
+ const {
213
+ showCollaboratorSelect,
214
+ value
215
+ } = this.state;
216
+ return /*#__PURE__*/_react.default.createElement("div", {
217
+ className: "position-relative mt-1 w-100",
218
+ ref: ref => this.collaboratorSelectRef = ref
219
+ }, this.renderSelectedCollaborators(), /*#__PURE__*/_react.default.createElement("span", {
220
+ ref: ref => this.targetRef = ref
221
+ }), showCollaboratorSelect && /*#__PURE__*/_react.default.createElement(_CollaboratorEditor.default, {
222
+ target: this.targetRef,
223
+ isInModal: true,
224
+ value: value,
225
+ column: column,
226
+ collaborators: collaborators,
227
+ onCommit: this.onChange,
228
+ onClose: this.closeSelect
229
+ }));
230
+ }
231
+ }
232
+ var _default = exports.default = RowExpandCollaboratorEditor;