dtable-ui-component 5.3.1-beta6 → 5.3.2-alpha1

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 (248) hide show
  1. package/lib/CheckboxEditor/index.css +20 -3
  2. package/lib/CheckboxEditor/index.js +35 -98
  3. package/lib/CheckboxFormatter/index.js +9 -6
  4. package/lib/CollaboratorEditor/index.css +35 -12
  5. package/lib/CollaboratorEditor/index.js +212 -18
  6. package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.js +29 -26
  7. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +97 -0
  8. package/lib/CollaboratorItem/index.css +1 -1
  9. package/lib/CollaboratorItem/index.js +2 -6
  10. package/lib/DTableCustomizeSelect/index.css +1 -1
  11. package/lib/DTableFiltersPopover/utils/index.js +7 -1
  12. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  13. package/lib/DTableGroupSelect/select-option-group.css +17 -17
  14. package/lib/DTableGroupSelect/select-option-group.js +1 -1
  15. package/lib/DTableSelect/index.js +1 -3
  16. package/lib/DateEditor/index.js +51 -14
  17. package/lib/DateEditor/pc-date-editor-popover.js +12 -145
  18. package/lib/Department-editor/department-single-select.js +1 -1
  19. package/lib/Department-editor/index.js +4 -3
  20. package/lib/DepartmentSingleSelectFormatter/index.js +1 -2
  21. package/lib/FileEditor/index.js +11 -258
  22. package/lib/FileEditor/pc-files-addition/index.js +1 -0
  23. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +1 -0
  24. package/lib/FileEditor/pc-files-preview/index.js +1 -0
  25. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +1 -0
  26. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  27. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  28. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  29. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  30. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  31. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  32. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  33. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  34. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  35. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  36. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  37. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  38. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  39. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  40. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  41. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  42. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  43. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  44. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  45. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  46. package/lib/FileItemFormatter/index.js +20 -19
  47. package/lib/FileItemFormatter/utils.js +99 -0
  48. package/lib/FileUploader/index.js +14 -268
  49. package/lib/FormulaFormatter/index.js +1 -2
  50. package/lib/FormulaFormatter/utils.js +31 -0
  51. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  52. package/lib/MultipleSelectEditor/index.css +9 -0
  53. package/lib/MultipleSelectEditor/index.js +177 -16
  54. package/lib/NumberEditor/index.js +77 -64
  55. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.css +1 -1
  56. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.js +1 -1
  57. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.css +6 -6
  58. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.js +1 -3
  59. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/row-expand-file-item-formatter.js +11 -10
  60. package/lib/RowExpandFormatter/index.css +1 -27
  61. package/lib/RowExpandFormatter/index.js +100 -83
  62. package/lib/{RowExpandFormatter/RowExpandFormulaFormatter → RowExpandFormulaFormatter}/index.js +10 -11
  63. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.css +6 -6
  64. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.js +1 -1
  65. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  66. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  67. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.js +6 -6
  68. package/lib/RowExpandLinkFormatter/utils.js +71 -0
  69. package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.css +1 -1
  70. package/lib/RowExpandUrlFormatter/index.css +1 -0
  71. package/lib/{RowExpandFormatter/RowExpandUrlFormatter → RowExpandUrlFormatter}/index.js +3 -4
  72. package/lib/SingleSelectEditor/index.css +14 -0
  73. package/lib/SingleSelectEditor/index.js +156 -16
  74. package/lib/TextEditor/index.js +42 -113
  75. package/lib/constants/index.js +2 -34
  76. package/lib/css/cell-editor.css +2 -18
  77. package/lib/index.js +46 -74
  78. package/lib/lang/index.js +16 -19
  79. package/lib/locals/de.js +103 -0
  80. package/lib/locals/en.js +104 -0
  81. package/lib/locals/es.js +103 -0
  82. package/lib/locals/fr.js +103 -0
  83. package/lib/locals/pt.js +103 -0
  84. package/lib/locals/ru.js +103 -0
  85. package/lib/locals/zh-CN.js +104 -0
  86. package/lib/select-editor/index.js +6 -6
  87. package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.js +3 -3
  88. package/lib/select-editor/pc-select-editor-popover/index.css +71 -0
  89. package/lib/select-editor/pc-select-editor-popover/index.js +122 -0
  90. package/lib/utils/editor-utils.js +6 -1
  91. package/lib/utils/url.js +8 -121
  92. package/lib/utils/utils.js +2 -145
  93. package/package.json +2 -3
  94. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +0 -257
  95. package/lib/Comment/body/comment.js +0 -190
  96. package/lib/Comment/body/index.css +0 -95
  97. package/lib/Comment/body/index.js +0 -32
  98. package/lib/Comment/footer/btns/index.css +0 -40
  99. package/lib/Comment/footer/btns/index.js +0 -113
  100. package/lib/Comment/footer/index.css +0 -157
  101. package/lib/Comment/footer/index.js +0 -170
  102. package/lib/Comment/footer/input/index.css +0 -52
  103. package/lib/Comment/footer/input/index.js +0 -448
  104. package/lib/Comment/footer/input/participant/index.css +0 -0
  105. package/lib/Comment/footer/input/participant/index.js +0 -53
  106. package/lib/Comment/footer/participants/index.css +0 -22
  107. package/lib/Comment/footer/participants/index.js +0 -68
  108. package/lib/Comment/footer/participants/participant/index.css +0 -5
  109. package/lib/Comment/footer/participants/participant/index.js +0 -32
  110. package/lib/Comment/footer/participants/participant-select/index.css +0 -104
  111. package/lib/Comment/footer/participants/participant-select/index.js +0 -182
  112. package/lib/Comment/index.css +0 -19
  113. package/lib/Comment/index.js +0 -305
  114. package/lib/Comment/model.js +0 -25
  115. package/lib/Comment/utils/common.js +0 -62
  116. package/lib/Comment/utils/index.js +0 -27
  117. package/lib/Comment/utils/utilities.js +0 -176
  118. package/lib/DeleteTip/index.js +0 -50
  119. package/lib/DigitalSignEditor/constants.js +0 -7
  120. package/lib/DigitalSignEditor/index.css +0 -69
  121. package/lib/DigitalSignEditor/index.js +0 -182
  122. package/lib/DigitalSignEditor/service.js +0 -38
  123. package/lib/DigitalSignEditor/signature-board/index.css +0 -35
  124. package/lib/DigitalSignEditor/signature-board/index.js +0 -135
  125. package/lib/DigitalSignEditor/signature-board/signature-tool.js +0 -396
  126. package/lib/DigitalSignEditor/utils.js +0 -29
  127. package/lib/DurationEditor/index.js +0 -111
  128. package/lib/EmailEditor/index.js +0 -59
  129. package/lib/FileEditor/addition-previewer/index.css +0 -1
  130. package/lib/FileEditor/addition-previewer/index.js +0 -52
  131. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +0 -1
  132. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +0 -252
  133. package/lib/FileEditor/constants.js +0 -7
  134. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +0 -74
  135. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +0 -5
  136. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +0 -77
  137. package/lib/FileEditor/files-previewer/file-previewer/index.css +0 -88
  138. package/lib/FileEditor/files-previewer/file-previewer/index.js +0 -167
  139. package/lib/FileEditor/files-previewer/index.css +0 -56
  140. package/lib/FileEditor/files-previewer/index.js +0 -277
  141. package/lib/FileEditor/index.css +0 -6
  142. package/lib/FileEditor/utils.js +0 -22
  143. package/lib/FileUploader/index.css +0 -9
  144. package/lib/GeolocationEditor/country-editor.js +0 -319
  145. package/lib/GeolocationEditor/index.css +0 -641
  146. package/lib/GeolocationEditor/index.js +0 -241
  147. package/lib/GeolocationEditor/location-editor.js +0 -368
  148. package/lib/GeolocationEditor/map-editor/index.js +0 -456
  149. package/lib/GeolocationEditor/map-editor/large-editor/index.css +0 -137
  150. package/lib/GeolocationEditor/map-editor/large-editor/index.js +0 -461
  151. package/lib/GeolocationEditor/map-editor-utils.js +0 -153
  152. package/lib/GeolocationEditor/map-selection-editor/index.js +0 -455
  153. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +0 -1
  154. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +0 -447
  155. package/lib/GeolocationEditor/parse-geolocation.js +0 -282
  156. package/lib/GeolocationEditor/province-city-editor.js +0 -292
  157. package/lib/GeolocationEditor/province-editor.js +0 -226
  158. package/lib/GeolocationEditor/selector-header-item.js +0 -28
  159. package/lib/GeolocationEditor/selector-list.js +0 -33
  160. package/lib/GeolocationEditor/with-ref.js +0 -27
  161. package/lib/ImageEditor/addition-previewer/image-link/index.css +0 -45
  162. package/lib/ImageEditor/addition-previewer/image-link/index.js +0 -73
  163. package/lib/ImageEditor/addition-previewer/index.css +0 -106
  164. package/lib/ImageEditor/addition-previewer/index.js +0 -63
  165. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +0 -125
  166. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +0 -254
  167. package/lib/ImageEditor/constants.js +0 -7
  168. package/lib/ImageEditor/images-previewer/image-preview/index.css +0 -59
  169. package/lib/ImageEditor/images-previewer/image-preview/index.js +0 -155
  170. package/lib/ImageEditor/images-previewer/index.css +0 -18
  171. package/lib/ImageEditor/images-previewer/index.js +0 -140
  172. package/lib/ImageEditor/index.css +0 -24
  173. package/lib/ImageEditor/index.js +0 -194
  174. package/lib/ImageThumbnail/index.css +0 -20
  175. package/lib/ImageThumbnail/index.js +0 -136
  176. package/lib/RowExpandDialog/body/index.css +0 -21
  177. package/lib/RowExpandDialog/body/index.js +0 -262
  178. package/lib/RowExpandDialog/column-content/index.css +0 -44
  179. package/lib/RowExpandDialog/column-content/index.js +0 -50
  180. package/lib/RowExpandDialog/header/index.css +0 -31
  181. package/lib/RowExpandDialog/header/index.js +0 -55
  182. package/lib/RowExpandDialog/index.css +0 -24
  183. package/lib/RowExpandDialog/index.js +0 -252
  184. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +0 -22
  185. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +0 -24
  186. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +0 -18
  187. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +0 -43
  188. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +0 -5
  189. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +0 -232
  190. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +0 -130
  191. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +0 -129
  192. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +0 -13
  193. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +0 -208
  194. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +0 -105
  195. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +0 -2
  196. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +0 -125
  197. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +0 -1
  198. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +0 -146
  199. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +0 -17
  200. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +0 -165
  201. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +0 -6
  202. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +0 -170
  203. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +0 -6
  204. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +0 -123
  205. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +0 -44
  206. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +0 -224
  207. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +0 -105
  208. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +0 -13
  209. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +0 -152
  210. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +0 -58
  211. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +0 -192
  212. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +0 -4
  213. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +0 -127
  214. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +0 -31
  215. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +0 -130
  216. package/lib/RowExpandEditor/constants.js +0 -44
  217. package/lib/RowExpandEditor/index.css +0 -0
  218. package/lib/RowExpandEditor/index.js +0 -32
  219. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +0 -27
  220. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +0 -1
  221. package/lib/RowExpandFormatter/constants.js +0 -60
  222. package/lib/UploadProgress/index.js +0 -38
  223. package/lib/UrlEditor/index.js +0 -62
  224. package/lib/common/editor-base.js +0 -53
  225. package/lib/constants/file.js +0 -96
  226. package/lib/constants/key-codes.js +0 -109
  227. package/lib/hooks/index.js +0 -16
  228. package/lib/locales/de.json +0 -167
  229. package/lib/locales/en.json +0 -167
  230. package/lib/locales/es.json +0 -167
  231. package/lib/locales/fr.json +0 -167
  232. package/lib/locales/pt.json +0 -167
  233. package/lib/locales/ru.json +0 -167
  234. package/lib/locales/zh-CN.json +0 -167
  235. package/lib/select-editor/pc-select-editor/index.css +0 -85
  236. package/lib/select-editor/pc-select-editor/index.js +0 -290
  237. package/lib/utils/cell-comparer.js +0 -35
  238. package/lib/utils/cell.js +0 -55
  239. package/lib/utils/column-utils.js +0 -25
  240. package/lib/utils/get-event-transfer.js +0 -75
  241. package/lib/utils/hotkey.js +0 -37
  242. package/lib/utils/object-utils.js +0 -61
  243. /package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.css +0 -0
  244. /package/lib/CollaboratorEditor/{pc-collaborator-editor → pc-collaborator-editor-popover}/index.css +0 -0
  245. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.css +0 -0
  246. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/value-display-utils.js +0 -0
  247. /package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.js +0 -0
  248. /package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.css +0 -0
@@ -1,252 +0,0 @@
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
- var _toaster = _interopRequireDefault(require("../toaster"));
20
- require("./index.css");
21
- const RowExpandDialog = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
22
- let {
23
- saveImmediately = true,
24
- isInsertingRow,
25
- zIndex,
26
- title,
27
- className,
28
- valueKey = 'name',
29
- // name or key
30
- layout = 'horizontal',
31
- // horizontal or vertical
32
- getRow,
33
- modifyRow,
34
- checkEditable = c => c.editable && !_dtableUtils.NOT_SUPPORT_EDIT_COLUMN_TYPE_MAP[c.type],
35
- onToggle,
36
- uploadFile,
37
- copyURL,
38
- children = [],
39
- ...otherProps
40
- } = _ref;
41
- const [isAnimationEnd, setAnimationEnd] = (0, _react.useState)(false);
42
- const [isLoading, setLoading] = (0, _react.useState)(true);
43
- const [isSaving, setSaving] = (0, _react.useState)(false);
44
- const [errorMessage, setErrorMessage] = (0, _react.useState)('');
45
- const [row, setRow] = (0, _react.useState)({});
46
- const [columns, setColumns] = (0, _react.useState)([]);
47
- const modalRef = (0, _react.useRef)(null);
48
- const isChangedRef = (0, _react.useRef)(false);
49
- const update = (0, _react.useRef)({});
50
- const initStyle = (0, _react.useMemo)(() => {
51
- const defaultMargin = 80; // sequence cell width
52
- const defaultHeight = 100;
53
- return {
54
- width: window.innerWidth - defaultMargin,
55
- maxWidth: window.innerWidth - defaultMargin,
56
- marginLeft: defaultMargin,
57
- height: defaultHeight,
58
- marginRight: defaultMargin,
59
- marginTop: '30%',
60
- transition: 'all .3s'
61
- };
62
- }, []);
63
- const style = (0, _react.useMemo)(() => {
64
- const width = children[1] ? 1100 : 800;
65
- return {
66
- width,
67
- maxWidth: width,
68
- marginLeft: (window.innerWidth - width) / 2,
69
- height: 'calc(100% - 56px)' // Dialog margin is 3.5rem (56px)
70
- };
71
- }, [children]);
72
- const _checkEditable = (0, _react.useCallback)((column, row) => {
73
- if (isSaving) return false;
74
- if (!column) return false;
75
- if (!checkEditable) return false;
76
- if (!checkEditable(column, row)) return false;
77
- if (column.type === _dtableUtils.CellType.IMAGE || column.type === _dtableUtils.CellType.FILE) return Boolean(uploadFile);
78
- return true;
79
- }, [isSaving, checkEditable, uploadFile]);
80
- const initRowData = (0, _react.useCallback)(() => {
81
- setLoading(true);
82
- getRow().then(res => {
83
- const {
84
- row,
85
- columns
86
- } = res.data;
87
- setRow(row);
88
- let validColumns = columns.map(c => ({
89
- ...c,
90
- editable: _checkEditable(c, row),
91
- width: 320
92
- }));
93
- if (isInsertingRow) {
94
- validColumns = validColumns.filter(c => c.editable);
95
- }
96
- isChangedRef.current = isInsertingRow && Object.keys(row).length > 0;
97
- setColumns(validColumns);
98
- setLoading(false);
99
- }).catch(error => {
100
- const errorMsg = (0, _utils.getErrorMsg)(error);
101
- setErrorMessage((0, _lang.getLocale)(errorMsg));
102
- setLoading(false);
103
- });
104
- }, [isInsertingRow, getRow, _checkEditable]);
105
- const toggle = (0, _react.useCallback)(() => {
106
- if (isSaving) return;
107
- onToggle();
108
- }, [isSaving, onToggle]);
109
- const onSave = (0, _react.useCallback)(function (updated) {
110
- let {
111
- successCallback,
112
- failCallback
113
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
114
- modifyRow(updated, columns, {
115
- successCallback,
116
- failCallback
117
- });
118
- }, [columns, modifyRow]);
119
- const onChange = (0, _react.useCallback)((column, value) => {
120
- const key = column[valueKey];
121
- const updated = {
122
- [key]: value
123
- };
124
- const oldValue = row[key];
125
- if (!(0, _cellComparer.isCellValueChanged)(oldValue, value, column.type)) return;
126
- if (!saveImmediately || isInsertingRow) {
127
- isChangedRef.current = true;
128
- update.current = {
129
- ...update.current,
130
- ...updated
131
- };
132
- setRow({
133
- ...row,
134
- ...updated
135
- });
136
- return;
137
- }
138
- onSave(updated, {
139
- successCallback: () => {
140
- isChangedRef.current = false;
141
- update.current = {};
142
- setRow({
143
- ...row,
144
- ...updated
145
- });
146
- },
147
- failCallback: () => {
148
- _toaster.default.danger((0, _lang.getLocale)('Save_failed'));
149
- }
150
- });
151
- }, [saveImmediately, isInsertingRow, row, valueKey, onSave]);
152
- const onSubmit = (0, _react.useCallback)(() => {
153
- setSaving(true);
154
- const successCallback = isInsertingRow ? onToggle : () => {
155
- isChangedRef.current = false;
156
- update.current = {};
157
- setSaving(false);
158
- };
159
- const failCallback = () => {
160
- setSaving(false);
161
- _toaster.default.danger((0, _lang.getLocale)('Save_failed'));
162
- };
163
- const newRow = isInsertingRow ? {
164
- ...row,
165
- ...update.current
166
- } : update.current;
167
- onSave(newRow, {
168
- successCallback,
169
- failCallback
170
- });
171
- }, [row, isInsertingRow, onSave, onToggle]);
172
- (0, _react.useEffect)(() => {
173
- // use setTimeout to make sure real dom rendered
174
- setTimeout(() => {
175
- let dom = modalRef.current.firstChild;
176
- const {
177
- width,
178
- maxWidth,
179
- marginLeft,
180
- height
181
- } = style;
182
- dom.style.width = "".concat(width, "px");
183
- dom.style.maxWidth = "".concat(maxWidth, "px");
184
- dom.style.marginLeft = "".concat(marginLeft, "px");
185
- dom.style.height = height;
186
- dom.style.marginRight = 'unset';
187
- dom.style.marginTop = '28px';
188
- // after animation, change style and run callback
189
- setTimeout(() => {
190
- setAnimationEnd(true);
191
- dom.style.transition = 'none';
192
- initRowData();
193
- }, 280);
194
- }, 1);
195
- // eslint-disable-next-line react-hooks/exhaustive-deps
196
- }, []);
197
- (0, _react.useImperativeHandle)(ref, () => ({
198
- getData: () => ({
199
- row,
200
- columns
201
- }),
202
- setData: function () {
203
- let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
204
- Object.keys(data).forEach(key => {
205
- if (key === 'row') {
206
- setRow(data[key]);
207
- }
208
- if (key === 'columns') {
209
- setColumns(data[key]);
210
- }
211
- });
212
- }
213
- }), [row, columns]);
214
- return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
215
- isOpen: true,
216
- toggle: onToggle,
217
- className: (0, _classnames.default)('dtable-ui-row-expand-dialog', className),
218
- style: isAnimationEnd ? style : initStyle,
219
- zIndex: zIndex || 1048,
220
- contentClassName: "dtable-ui-row-expand-content",
221
- modalClassName: "dtable-ui-row-expand-modal",
222
- fade: false,
223
- innerRef: modalRef,
224
- keyboard: false
225
- }, isAnimationEnd && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isLoading ? /*#__PURE__*/_react.default.createElement("div", {
226
- className: "w-100 -h-100 d-flex align-items-center justify-content-center"
227
- }, /*#__PURE__*/_react.default.createElement(_Loading.default, null)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, errorMessage ? /*#__PURE__*/_react.default.createElement("div", {
228
- className: "w-100 -h-100 d-flex align-items-center justify-content-center error"
229
- }, errorMessage) : /*#__PURE__*/_react.default.createElement("div", {
230
- className: "dtable-ui-row-expand-details"
231
- }, /*#__PURE__*/_react.default.createElement(_header.default, {
232
- title: title,
233
- row: row,
234
- columns: columns,
235
- copyURL: copyURL,
236
- onToggle: toggle
237
- }, children[0]), /*#__PURE__*/_react.default.createElement(_body.default, Object.assign({}, otherProps, {
238
- row: row,
239
- columns: columns,
240
- valueKey: valueKey,
241
- onChange: onChange,
242
- uploadFile: uploadFile
243
- }), children[1]), (!saveImmediately || isInsertingRow) && /*#__PURE__*/_react.default.createElement(_reactstrap.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
244
- onClick: toggle,
245
- color: "secondary"
246
- }, (0, _lang.getLocale)('Cancel')), /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
247
- onClick: onSubmit,
248
- disabled: isSaving || !isChangedRef.current,
249
- color: "primary"
250
- }, (0, _lang.getLocale)('Submit')))))));
251
- });
252
- var _default = exports.default = RowExpandDialog;
@@ -1,22 +0,0 @@
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
- }
@@ -1,24 +0,0 @@
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;
@@ -1,18 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
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;
@@ -1,5 +0,0 @@
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
- }
@@ -1,232 +0,0 @@
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;