tabulator-tables 6.5.0 → 6.5.1
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.
- package/dist/js/tabulator.js +1 -1
- package/dist/js/tabulator.min.js +1 -1
- package/dist/js/tabulator_esm.js +1 -1
- package/dist/js/tabulator_esm.min.js +1 -1
- package/dist/js/tabulator_esm.min.mjs +1 -1
- package/dist/js/tabulator_esm.mjs +1 -1
- package/package.json +2 -1
- package/src/js/builds/esm.js +16 -0
- package/src/js/builds/jquery_wrapper.js +63 -0
- package/src/js/builds/usd.js +1 -0
- package/src/js/core/ColumnManager.js +789 -0
- package/src/js/core/CoreFeature.js +140 -0
- package/src/js/core/FooterManager.js +102 -0
- package/src/js/core/Module.js +140 -0
- package/src/js/core/RowManager.js +1140 -0
- package/src/js/core/Tabulator.js +928 -0
- package/src/js/core/TabulatorFull.js +21 -0
- package/src/js/core/cell/Cell.js +299 -0
- package/src/js/core/cell/CellComponent.js +79 -0
- package/src/js/core/column/Column.js +978 -0
- package/src/js/core/column/ColumnComponent.js +151 -0
- package/src/js/core/column/defaults/options.js +18 -0
- package/src/js/core/defaults/options.js +66 -0
- package/src/js/core/modules/core.js +3 -0
- package/src/js/core/modules/optional.js +37 -0
- package/src/js/core/rendering/Renderer.js +204 -0
- package/src/js/core/rendering/renderers/BasicHorizontal.js +27 -0
- package/src/js/core/rendering/renderers/BasicVertical.js +103 -0
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +587 -0
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +642 -0
- package/src/js/core/row/PseudoRow.js +47 -0
- package/src/js/core/row/Row.js +487 -0
- package/src/js/core/row/RowComponent.js +94 -0
- package/src/js/core/tools/Alert.js +66 -0
- package/src/js/core/tools/ComponentFunctionBinder.js +32 -0
- package/src/js/core/tools/DataLoader.js +128 -0
- package/src/js/core/tools/DependencyRegistry.js +82 -0
- package/src/js/core/tools/DeprecationAdvisor.js +51 -0
- package/src/js/core/tools/ExternalEventBus.js +105 -0
- package/src/js/core/tools/Helpers.js +66 -0
- package/src/js/core/tools/InteractionMonitor.js +329 -0
- package/src/js/core/tools/InternalEventBus.js +162 -0
- package/src/js/core/tools/ModuleBinder.js +153 -0
- package/src/js/core/tools/OptionsList.js +45 -0
- package/src/js/core/tools/Popup.js +317 -0
- package/src/js/core/tools/TableRegistry.js +65 -0
- package/src/js/modules/Accessor/Accessor.js +115 -0
- package/src/js/modules/Accessor/defaults/accessors.js +5 -0
- package/src/js/modules/Ajax/Ajax.js +142 -0
- package/src/js/modules/Ajax/defaults/config.js +3 -0
- package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +45 -0
- package/src/js/modules/Ajax/defaults/loaderPromise.js +87 -0
- package/src/js/modules/Ajax/defaults/urlGenerator.js +44 -0
- package/src/js/modules/Clipboard/Clipboard.js +282 -0
- package/src/js/modules/Clipboard/defaults/pasteActions.js +11 -0
- package/src/js/modules/Clipboard/defaults/pasteParsers.js +75 -0
- package/src/js/modules/Clipboard/extensions/extensions.js +9 -0
- package/src/js/modules/Clipboard/extensions/keybindings/actions.js +9 -0
- package/src/js/modules/Clipboard/extensions/keybindings/bindings.js +3 -0
- package/src/js/modules/ColumnCalcs/CalcComponent.js +46 -0
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +586 -0
- package/src/js/modules/ColumnCalcs/defaults/calculations.js +93 -0
- package/src/js/modules/Comms/Comms.js +49 -0
- package/src/js/modules/DataTree/DataTree.js +620 -0
- package/src/js/modules/Download/Download.js +146 -0
- package/src/js/modules/Download/defaults/downloaders/csv.js +61 -0
- package/src/js/modules/Download/defaults/downloaders/html.js +5 -0
- package/src/js/modules/Download/defaults/downloaders/json.js +34 -0
- package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
- package/src/js/modules/Download/defaults/downloaders/pdf.js +113 -0
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +103 -0
- package/src/js/modules/Download/defaults/downloaders.js +15 -0
- package/src/js/modules/Edit/Edit.js +845 -0
- package/src/js/modules/Edit/List.js +1060 -0
- package/src/js/modules/Edit/defaults/editors/adaptable.js +37 -0
- package/src/js/modules/Edit/defaults/editors/date.js +144 -0
- package/src/js/modules/Edit/defaults/editors/datetime.js +131 -0
- package/src/js/modules/Edit/defaults/editors/input.js +77 -0
- package/src/js/modules/Edit/defaults/editors/list.js +7 -0
- package/src/js/modules/Edit/defaults/editors/number.js +110 -0
- package/src/js/modules/Edit/defaults/editors/progress.js +127 -0
- package/src/js/modules/Edit/defaults/editors/range.js +81 -0
- package/src/js/modules/Edit/defaults/editors/star.js +146 -0
- package/src/js/modules/Edit/defaults/editors/textarea.js +123 -0
- package/src/js/modules/Edit/defaults/editors/tickCross.js +95 -0
- package/src/js/modules/Edit/defaults/editors/time.js +132 -0
- package/src/js/modules/Edit/defaults/editors.js +27 -0
- package/src/js/modules/Edit/inputMask.js +74 -0
- package/src/js/modules/Export/Export.js +654 -0
- package/src/js/modules/Export/ExportColumn.js +9 -0
- package/src/js/modules/Export/ExportRow.js +8 -0
- package/src/js/modules/Export/defaults/columnLookups.js +3 -0
- package/src/js/modules/Export/defaults/rowLookups.js +18 -0
- package/src/js/modules/Filter/Filter.js +902 -0
- package/src/js/modules/Filter/defaults/filters.js +215 -0
- package/src/js/modules/Format/Format.js +200 -0
- package/src/js/modules/Format/defaults/formatters/adaptable.js +32 -0
- package/src/js/modules/Format/defaults/formatters/array.js +30 -0
- package/src/js/modules/Format/defaults/formatters/buttonCross.js +3 -0
- package/src/js/modules/Format/defaults/formatters/buttonTick.js +3 -0
- package/src/js/modules/Format/defaults/formatters/color.js +4 -0
- package/src/js/modules/Format/defaults/formatters/datetime.js +39 -0
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +43 -0
- package/src/js/modules/Format/defaults/formatters/handle.js +4 -0
- package/src/js/modules/Format/defaults/formatters/html.js +3 -0
- package/src/js/modules/Format/defaults/formatters/image.js +40 -0
- package/src/js/modules/Format/defaults/formatters/json.js +12 -0
- package/src/js/modules/Format/defaults/formatters/link.js +82 -0
- package/src/js/modules/Format/defaults/formatters/lookup.js +10 -0
- package/src/js/modules/Format/defaults/formatters/money.js +44 -0
- package/src/js/modules/Format/defaults/formatters/plaintext.js +3 -0
- package/src/js/modules/Format/defaults/formatters/progress.js +133 -0
- package/src/js/modules/Format/defaults/formatters/rownum.js +14 -0
- package/src/js/modules/Format/defaults/formatters/star.js +38 -0
- package/src/js/modules/Format/defaults/formatters/textarea.js +4 -0
- package/src/js/modules/Format/defaults/formatters/tickCross.js +22 -0
- package/src/js/modules/Format/defaults/formatters/toggle.js +48 -0
- package/src/js/modules/Format/defaults/formatters/traffic.js +47 -0
- package/src/js/modules/Format/defaults/formatters.js +47 -0
- package/src/js/modules/FrozenColumns/FrozenColumns.js +302 -0
- package/src/js/modules/FrozenRows/FrozenRows.js +175 -0
- package/src/js/modules/GroupRows/Group.js +615 -0
- package/src/js/modules/GroupRows/GroupComponent.js +69 -0
- package/src/js/modules/GroupRows/GroupRows.js +636 -0
- package/src/js/modules/History/History.js +172 -0
- package/src/js/modules/History/defaults/redoers.js +31 -0
- package/src/js/modules/History/defaults/undoers.js +33 -0
- package/src/js/modules/History/extensions/extensions.js +9 -0
- package/src/js/modules/History/extensions/keybindings/actions.js +27 -0
- package/src/js/modules/History/extensions/keybindings/bindings.js +4 -0
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +180 -0
- package/src/js/modules/Import/Import.js +303 -0
- package/src/js/modules/Import/defaults/importers/array.js +3 -0
- package/src/js/modules/Import/defaults/importers/csv.js +61 -0
- package/src/js/modules/Import/defaults/importers/json.js +8 -0
- package/src/js/modules/Import/defaults/importers/xlsx.js +7 -0
- package/src/js/modules/Import/defaults/importers.js +11 -0
- package/src/js/modules/Interaction/Interaction.js +339 -0
- package/src/js/modules/Keybindings/Keybindings.js +198 -0
- package/src/js/modules/Keybindings/defaults/actions.js +90 -0
- package/src/js/modules/Keybindings/defaults/bindings.js +12 -0
- package/src/js/modules/Layout/Layout.js +66 -0
- package/src/js/modules/Layout/defaults/modes/fitColumns.js +171 -0
- package/src/js/modules/Layout/defaults/modes/fitData.js +10 -0
- package/src/js/modules/Layout/defaults/modes/fitDataGeneral.js +10 -0
- package/src/js/modules/Layout/defaults/modes/fitDataStretch.js +40 -0
- package/src/js/modules/Layout/defaults/modes.js +12 -0
- package/src/js/modules/Localize/Localize.js +184 -0
- package/src/js/modules/Localize/defaults/langs.js +37 -0
- package/src/js/modules/Menu/Menu.js +302 -0
- package/src/js/modules/MoveColumns/MoveColumns.js +311 -0
- package/src/js/modules/MoveRows/MoveRows.js +604 -0
- package/src/js/modules/MoveRows/defaults/receivers.js +30 -0
- package/src/js/modules/MoveRows/defaults/senders.js +5 -0
- package/src/js/modules/Mutator/Mutator.js +164 -0
- package/src/js/modules/Mutator/defaults/mutators.js +1 -0
- package/src/js/modules/Page/Page.js +891 -0
- package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
- package/src/js/modules/Page/defaults/pageCounters/rows.js +40 -0
- package/src/js/modules/Page/defaults/pageCounters.js +8 -0
- package/src/js/modules/Persistence/Persistence.js +473 -0
- package/src/js/modules/Persistence/defaults/readers.js +29 -0
- package/src/js/modules/Persistence/defaults/writers.js +13 -0
- package/src/js/modules/Popup/Popup.js +227 -0
- package/src/js/modules/Print/Print.js +136 -0
- package/src/js/modules/ReactiveData/ReactiveData.js +416 -0
- package/src/js/modules/ResizeColumns/ResizeColumns.js +365 -0
- package/src/js/modules/ResizeRows/ResizeRows.js +145 -0
- package/src/js/modules/ResizeTable/ResizeTable.js +158 -0
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +354 -0
- package/src/js/modules/ResponsiveLayout/extensions/extensions.js +9 -0
- package/src/js/modules/ResponsiveLayout/extensions/formatters/responsiveCollapse.js +44 -0
- package/src/js/modules/SelectRange/Range.js +366 -0
- package/src/js/modules/SelectRange/RangeComponent.js +91 -0
- package/src/js/modules/SelectRange/SelectRange.js +993 -0
- package/src/js/modules/SelectRange/extensions/clipboard/pasteActions.js +45 -0
- package/src/js/modules/SelectRange/extensions/clipboard/pasteParsers.js +57 -0
- package/src/js/modules/SelectRange/extensions/export/columnLookups.js +11 -0
- package/src/js/modules/SelectRange/extensions/export/rowLookups.js +5 -0
- package/src/js/modules/SelectRange/extensions/extensions.js +21 -0
- package/src/js/modules/SelectRange/extensions/keybindings/actions.js +38 -0
- package/src/js/modules/SelectRange/extensions/keybindings/bindings.js +14 -0
- package/src/js/modules/SelectRow/SelectRow.js +499 -0
- package/src/js/modules/SelectRow/extensions/extensions.js +9 -0
- package/src/js/modules/SelectRow/extensions/formatters/rowSelection.js +60 -0
- package/src/js/modules/Sort/Sort.js +480 -0
- package/src/js/modules/Sort/defaults/sorters/alphanum.js +44 -0
- package/src/js/modules/Sort/defaults/sorters/array.js +82 -0
- package/src/js/modules/Sort/defaults/sorters/boolean.js +7 -0
- package/src/js/modules/Sort/defaults/sorters/date.js +10 -0
- package/src/js/modules/Sort/defaults/sorters/datetime.js +48 -0
- package/src/js/modules/Sort/defaults/sorters/exists.js +7 -0
- package/src/js/modules/Sort/defaults/sorters/number.js +40 -0
- package/src/js/modules/Sort/defaults/sorters/string.js +34 -0
- package/src/js/modules/Sort/defaults/sorters/time.js +10 -0
- package/src/js/modules/Sort/defaults/sorters.js +21 -0
- package/src/js/modules/Spreadsheet/GridCalculator.js +64 -0
- package/src/js/modules/Spreadsheet/Sheet.js +243 -0
- package/src/js/modules/Spreadsheet/SheetComponent.js +59 -0
- package/src/js/modules/Spreadsheet/Spreadsheet.js +309 -0
- package/src/js/modules/Tooltip/Tooltip.js +128 -0
- package/src/js/modules/Validate/Validate.js +303 -0
- package/src/js/modules/Validate/defaults/validators.js +150 -0
- package/src/scss/tabulator.scss +1693 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +302 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +589 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +979 -0
- package/src/scss/themes/bootstrap/variables3.scss +872 -0
- package/src/scss/themes/bootstrap/variables4.scss +1059 -0
- package/src/scss/themes/bootstrap/variables5.scss +1967 -0
- package/src/scss/themes/bulma/tabulator_bulma.scss +316 -0
- package/src/scss/themes/bulma/variables.scss +198 -0
- package/src/scss/themes/materialize/tabulator_materialize.scss +318 -0
- package/src/scss/themes/materialize/variables.scss +71 -0
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +623 -0
- package/src/scss/themes/semanticui/variables.scss +843 -0
- package/src/scss/themes/semanticui/variables_table.scss +248 -0
- package/src/scss/themes/tabulator_midnight.scss +235 -0
- package/src/scss/themes/tabulator_modern.scss +308 -0
- package/src/scss/themes/tabulator_simple.scss +143 -0
- package/src/scss/themes/tabulator_site.scss +267 -0
- package/src/scss/themes/tabulator_site_dark.scss +496 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export default function(url, config, params){
|
|
2
|
+
var contentType;
|
|
3
|
+
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
//set url
|
|
6
|
+
url = this.urlGenerator.call(this.table, url, config, params);
|
|
7
|
+
|
|
8
|
+
//set body content if not GET request
|
|
9
|
+
if(config.method.toUpperCase() != "GET"){
|
|
10
|
+
contentType = typeof this.table.options.ajaxContentType === "object" ? this.table.options.ajaxContentType : this.contentTypeFormatters[this.table.options.ajaxContentType];
|
|
11
|
+
if(contentType){
|
|
12
|
+
|
|
13
|
+
for(var key in contentType.headers){
|
|
14
|
+
if(!config.headers){
|
|
15
|
+
config.headers = {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if(typeof config.headers[key] === "undefined"){
|
|
19
|
+
config.headers[key] = contentType.headers[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
config.body = contentType.body.call(this, url, config, params);
|
|
24
|
+
|
|
25
|
+
}else{
|
|
26
|
+
console.warn("Ajax Error - Invalid ajaxContentType value:", this.table.options.ajaxContentType);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if(url){
|
|
31
|
+
//configure headers
|
|
32
|
+
if(typeof config.headers === "undefined"){
|
|
33
|
+
config.headers = {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if(typeof config.headers.Accept === "undefined"){
|
|
37
|
+
config.headers.Accept = "application/json";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if(typeof config.headers["X-Requested-With"] === "undefined"){
|
|
41
|
+
config.headers["X-Requested-With"] = "XMLHttpRequest";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if(typeof config.mode === "undefined"){
|
|
45
|
+
config.mode = "cors";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if(config.mode == "cors"){
|
|
49
|
+
if(typeof config.headers["Origin"] === "undefined"){
|
|
50
|
+
config.headers["Origin"] = window.location.origin;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if(typeof config.credentials === "undefined"){
|
|
54
|
+
config.credentials = 'same-origin';
|
|
55
|
+
}
|
|
56
|
+
}else{
|
|
57
|
+
if(typeof config.credentials === "undefined"){
|
|
58
|
+
config.credentials = 'include';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//send request
|
|
63
|
+
fetch(url, config)
|
|
64
|
+
.then((response)=>{
|
|
65
|
+
if(response.ok) {
|
|
66
|
+
response.json()
|
|
67
|
+
.then((data)=>{
|
|
68
|
+
resolve(data);
|
|
69
|
+
}).catch((error)=>{
|
|
70
|
+
reject(error);
|
|
71
|
+
console.warn("Ajax Load Error - Invalid JSON returned", error);
|
|
72
|
+
});
|
|
73
|
+
}else{
|
|
74
|
+
console.error("Ajax Load Error - Connection Error: " + response.status, response.statusText);
|
|
75
|
+
reject(response);
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.catch((error)=>{
|
|
79
|
+
console.error("Ajax Load Error - Connection Error: ", error);
|
|
80
|
+
reject(error);
|
|
81
|
+
});
|
|
82
|
+
}else{
|
|
83
|
+
console.warn("Ajax Load Error - No URL Set");
|
|
84
|
+
resolve([]);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function generateParamsList(data, prefix){
|
|
2
|
+
var output = [];
|
|
3
|
+
|
|
4
|
+
prefix = prefix || "";
|
|
5
|
+
|
|
6
|
+
if(Array.isArray(data)){
|
|
7
|
+
data.forEach((item, i) => {
|
|
8
|
+
output = output.concat(generateParamsList(item, prefix ? prefix + "[" + i + "]" : i));
|
|
9
|
+
});
|
|
10
|
+
}else if (typeof data === "object"){
|
|
11
|
+
for (var key in data){
|
|
12
|
+
output = output.concat(generateParamsList(data[key], prefix ? prefix + "[" + key + "]" : key));
|
|
13
|
+
}
|
|
14
|
+
}else{
|
|
15
|
+
output.push({key:prefix, value:data});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return output;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function serializeParams(params){
|
|
22
|
+
var output = generateParamsList(params),
|
|
23
|
+
encoded = [];
|
|
24
|
+
|
|
25
|
+
output.forEach(function(item){
|
|
26
|
+
encoded.push(encodeURIComponent(item.key) + "=" + encodeURIComponent(item.value));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return encoded.join("&");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default function(url, config, params){
|
|
33
|
+
if(url){
|
|
34
|
+
if(params && Object.keys(params).length){
|
|
35
|
+
if(!config.method || config.method.toLowerCase() == "get"){
|
|
36
|
+
config.method = "get";
|
|
37
|
+
|
|
38
|
+
url += (url.includes("?") ? "&" : "?") + serializeParams(params);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return url;
|
|
44
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import Module from '../../core/Module.js';
|
|
2
|
+
|
|
3
|
+
import defaultPasteActions from './defaults/pasteActions.js';
|
|
4
|
+
import defaultPasteParsers from './defaults/pasteParsers.js';
|
|
5
|
+
import extensions from './extensions/extensions.js';
|
|
6
|
+
|
|
7
|
+
export default class Clipboard extends Module{
|
|
8
|
+
|
|
9
|
+
static moduleName = "clipboard";
|
|
10
|
+
static moduleExtensions = extensions;
|
|
11
|
+
|
|
12
|
+
//load defaults
|
|
13
|
+
static pasteActions = defaultPasteActions;
|
|
14
|
+
static pasteParsers = defaultPasteParsers;
|
|
15
|
+
|
|
16
|
+
constructor(table){
|
|
17
|
+
super(table);
|
|
18
|
+
|
|
19
|
+
this.mode = true;
|
|
20
|
+
this.pasteParser = function(){};
|
|
21
|
+
this.pasteAction = function(){};
|
|
22
|
+
this.customSelection = false;
|
|
23
|
+
this.rowRange = false;
|
|
24
|
+
this.blocked = true; //block copy actions not originating from this command
|
|
25
|
+
|
|
26
|
+
this.registerTableOption("clipboard", false); //enable clipboard
|
|
27
|
+
this.registerTableOption("clipboardCopyStyled", true); //formatted table data
|
|
28
|
+
this.registerTableOption("clipboardCopyConfig", false); //clipboard config
|
|
29
|
+
this.registerTableOption("clipboardCopyFormatter", false); //DEPRECATED - REMOVE in 5.0
|
|
30
|
+
this.registerTableOption("clipboardCopyRowRange", "active"); //restrict clipboard to visible rows only
|
|
31
|
+
this.registerTableOption("clipboardPasteParser", "table"); //convert pasted clipboard data to rows
|
|
32
|
+
this.registerTableOption("clipboardPasteAction", "insert"); //how to insert pasted data into the table
|
|
33
|
+
|
|
34
|
+
this.registerColumnOption("clipboard");
|
|
35
|
+
this.registerColumnOption("titleClipboard");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
initialize(){
|
|
39
|
+
this.mode = this.table.options.clipboard;
|
|
40
|
+
|
|
41
|
+
this.rowRange = this.table.options.clipboardCopyRowRange;
|
|
42
|
+
|
|
43
|
+
if(this.mode === true || this.mode === "copy"){
|
|
44
|
+
this.table.element.addEventListener("copy", (e) => {
|
|
45
|
+
var plain, html, list;
|
|
46
|
+
|
|
47
|
+
if(!this.blocked){
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
|
|
50
|
+
if(this.customSelection){
|
|
51
|
+
plain = this.customSelection;
|
|
52
|
+
|
|
53
|
+
if(this.table.options.clipboardCopyFormatter){
|
|
54
|
+
plain = this.table.options.clipboardCopyFormatter("plain", plain);
|
|
55
|
+
}
|
|
56
|
+
}else{
|
|
57
|
+
|
|
58
|
+
list = this.table.modules.export.generateExportList(this.table.options.clipboardCopyConfig, this.table.options.clipboardCopyStyled, this.rowRange, "clipboard");
|
|
59
|
+
|
|
60
|
+
html = this.table.modules.export.generateHTMLTable(list);
|
|
61
|
+
plain = html ? this.generatePlainContent(list) : "";
|
|
62
|
+
|
|
63
|
+
if(this.table.options.clipboardCopyFormatter){
|
|
64
|
+
plain = this.table.options.clipboardCopyFormatter("plain", plain);
|
|
65
|
+
html = this.table.options.clipboardCopyFormatter("html", html);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (window.clipboardData && window.clipboardData.setData) {
|
|
70
|
+
window.clipboardData.setData('Text', plain);
|
|
71
|
+
} else if (e.clipboardData && e.clipboardData.setData) {
|
|
72
|
+
e.clipboardData.setData('text/plain', plain);
|
|
73
|
+
if(html){
|
|
74
|
+
e.clipboardData.setData('text/html', html);
|
|
75
|
+
}
|
|
76
|
+
} else if (e.originalEvent && e.originalEvent.clipboardData.setData) {
|
|
77
|
+
e.originalEvent.clipboardData.setData('text/plain', plain);
|
|
78
|
+
if(html){
|
|
79
|
+
e.originalEvent.clipboardData.setData('text/html', html);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.dispatchExternal("clipboardCopied", plain, html);
|
|
84
|
+
|
|
85
|
+
this.reset();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if(this.mode === true || this.mode === "paste"){
|
|
91
|
+
this.table.element.addEventListener("paste", (e) => {
|
|
92
|
+
this.paste(e);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.setPasteParser(this.table.options.clipboardPasteParser);
|
|
97
|
+
this.setPasteAction(this.table.options.clipboardPasteAction);
|
|
98
|
+
|
|
99
|
+
this.registerTableFunction("copyToClipboard", this.copy.bind(this));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
reset(){
|
|
103
|
+
this.blocked = true;
|
|
104
|
+
this.customSelection = false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
generatePlainContent (list) {
|
|
108
|
+
var output = [];
|
|
109
|
+
|
|
110
|
+
list.forEach((row) => {
|
|
111
|
+
var rowData = [];
|
|
112
|
+
|
|
113
|
+
row.columns.forEach((col) => {
|
|
114
|
+
var value = "";
|
|
115
|
+
|
|
116
|
+
if(col){
|
|
117
|
+
|
|
118
|
+
if(row.type === "group"){
|
|
119
|
+
col.value = col.component.getKey();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if(col.value === null){
|
|
123
|
+
value = "";
|
|
124
|
+
}else{
|
|
125
|
+
switch(typeof col.value){
|
|
126
|
+
case "object":
|
|
127
|
+
value = JSON.stringify(col.value);
|
|
128
|
+
break;
|
|
129
|
+
|
|
130
|
+
case "undefined":
|
|
131
|
+
value = "";
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
default:
|
|
135
|
+
value = col.value;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
rowData.push(value);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
output.push(rowData.join("\t"));
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return output.join("\n");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
copy (range, internal) {
|
|
150
|
+
var sel, textRange;
|
|
151
|
+
this.blocked = false;
|
|
152
|
+
this.customSelection = false;
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if (this.mode === true || this.mode === "copy") {
|
|
156
|
+
|
|
157
|
+
this.rowRange = range || this.table.options.clipboardCopyRowRange;
|
|
158
|
+
|
|
159
|
+
if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {
|
|
160
|
+
range = document.createRange();
|
|
161
|
+
range.selectNodeContents(this.table.element);
|
|
162
|
+
sel = window.getSelection();
|
|
163
|
+
|
|
164
|
+
if (sel.toString() && internal) {
|
|
165
|
+
this.customSelection = sel.toString();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
sel.removeAllRanges();
|
|
169
|
+
sel.addRange(range);
|
|
170
|
+
} else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") {
|
|
171
|
+
textRange = document.body.createTextRange();
|
|
172
|
+
textRange.moveToElementText(this.table.element);
|
|
173
|
+
textRange.select();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
document.execCommand('copy');
|
|
177
|
+
|
|
178
|
+
if (sel) {
|
|
179
|
+
sel.removeAllRanges();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
//PASTE EVENT HANDLING
|
|
185
|
+
setPasteAction(action){
|
|
186
|
+
|
|
187
|
+
switch(typeof action){
|
|
188
|
+
case "string":
|
|
189
|
+
this.pasteAction = Clipboard.pasteActions[action];
|
|
190
|
+
|
|
191
|
+
if(!this.pasteAction){
|
|
192
|
+
console.warn("Clipboard Error - No such paste action found:", action);
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
|
|
196
|
+
case "function":
|
|
197
|
+
this.pasteAction = action;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
setPasteParser(parser){
|
|
203
|
+
switch(typeof parser){
|
|
204
|
+
case "string":
|
|
205
|
+
this.pasteParser = Clipboard.pasteParsers[parser];
|
|
206
|
+
|
|
207
|
+
if(!this.pasteParser){
|
|
208
|
+
console.warn("Clipboard Error - No such paste parser found:", parser);
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
|
|
212
|
+
case "function":
|
|
213
|
+
this.pasteParser = parser;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
paste(e){
|
|
219
|
+
var data, rowData, rows;
|
|
220
|
+
|
|
221
|
+
if(this.checkPasteOrigin(e)){
|
|
222
|
+
|
|
223
|
+
data = this.getPasteData(e);
|
|
224
|
+
|
|
225
|
+
rowData = this.pasteParser.call(this, data);
|
|
226
|
+
|
|
227
|
+
if(rowData){
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
|
|
230
|
+
if(this.table.modExists("mutator")){
|
|
231
|
+
rowData = this.mutateData(rowData);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
rows = this.pasteAction.call(this, rowData);
|
|
235
|
+
|
|
236
|
+
this.dispatchExternal("clipboardPasted", data, rowData, rows);
|
|
237
|
+
}else{
|
|
238
|
+
this.dispatchExternal("clipboardPasteError", data);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
mutateData(data){
|
|
244
|
+
var output = [];
|
|
245
|
+
|
|
246
|
+
if(Array.isArray(data)){
|
|
247
|
+
data.forEach((row) => {
|
|
248
|
+
output.push(this.table.modules.mutator.transformRow(row, "clipboard"));
|
|
249
|
+
});
|
|
250
|
+
}else{
|
|
251
|
+
output = data;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return output;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
checkPasteOrigin(e){
|
|
259
|
+
var valid = true;
|
|
260
|
+
var blocked = this.confirm("clipboard-paste", [e]);
|
|
261
|
+
|
|
262
|
+
if(blocked || !["DIV", "SPAN"].includes(e.target.tagName)){
|
|
263
|
+
valid = false;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return valid;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
getPasteData(e){
|
|
270
|
+
var data;
|
|
271
|
+
|
|
272
|
+
if (window.clipboardData && window.clipboardData.getData) {
|
|
273
|
+
data = window.clipboardData.getData('Text');
|
|
274
|
+
} else if (e.clipboardData && e.clipboardData.getData) {
|
|
275
|
+
data = e.clipboardData.getData('text/plain');
|
|
276
|
+
} else if (e.originalEvent && e.originalEvent.clipboardData.getData) {
|
|
277
|
+
data = e.originalEvent.clipboardData.getData('text/plain');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return data;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
table:function(clipboard){
|
|
3
|
+
var data = [],
|
|
4
|
+
headerFindSuccess = true,
|
|
5
|
+
columns = this.table.columnManager.columns,
|
|
6
|
+
columnMap = [],
|
|
7
|
+
rows = [];
|
|
8
|
+
|
|
9
|
+
//get data from clipboard into array of columns and rows.
|
|
10
|
+
clipboard = clipboard.split("\n");
|
|
11
|
+
|
|
12
|
+
clipboard.forEach(function(row){
|
|
13
|
+
data.push(row.split("\t"));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if(data.length && !(data.length === 1 && data[0].length < 2)){
|
|
17
|
+
|
|
18
|
+
//check if headers are present by title
|
|
19
|
+
data[0].forEach(function(value){
|
|
20
|
+
var column = columns.find(function(column){
|
|
21
|
+
return value && column.definition.title && value.trim() && column.definition.title.trim() === value.trim();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if(column){
|
|
25
|
+
columnMap.push(column);
|
|
26
|
+
}else{
|
|
27
|
+
headerFindSuccess = false;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
//check if column headers are present by field
|
|
32
|
+
if(!headerFindSuccess){
|
|
33
|
+
headerFindSuccess = true;
|
|
34
|
+
columnMap = [];
|
|
35
|
+
|
|
36
|
+
data[0].forEach(function(value){
|
|
37
|
+
var column = columns.find(function(column){
|
|
38
|
+
return value && column.field && value.trim() && column.field.trim() === value.trim();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if(column){
|
|
42
|
+
columnMap.push(column);
|
|
43
|
+
}else{
|
|
44
|
+
headerFindSuccess = false;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if(!headerFindSuccess){
|
|
49
|
+
columnMap = this.table.columnManager.columnsByIndex;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//remove header row if found
|
|
54
|
+
if(headerFindSuccess){
|
|
55
|
+
data.shift();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
data.forEach(function(item){
|
|
59
|
+
var row = {};
|
|
60
|
+
|
|
61
|
+
item.forEach(function(value, i){
|
|
62
|
+
if(columnMap[i]){
|
|
63
|
+
row[columnMap[i].field] = value;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
rows.push(row);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return rows;
|
|
71
|
+
}else{
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default class CalcComponent{
|
|
2
|
+
constructor (row){
|
|
3
|
+
this._row = row;
|
|
4
|
+
|
|
5
|
+
return new Proxy(this, {
|
|
6
|
+
get: function(target, name, receiver) {
|
|
7
|
+
if (typeof target[name] !== "undefined") {
|
|
8
|
+
return target[name];
|
|
9
|
+
}else{
|
|
10
|
+
return target._row.table.componentFunctionBinder.handle("row", target._row, name);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getData(transform){
|
|
17
|
+
return this._row.getData(transform);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getElement(){
|
|
21
|
+
return this._row.getElement();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getTable(){
|
|
25
|
+
return this._row.table;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getCells(){
|
|
29
|
+
var cells = [];
|
|
30
|
+
|
|
31
|
+
this._row.getCells().forEach(function(cell){
|
|
32
|
+
cells.push(cell.getComponent());
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return cells;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getCell(column){
|
|
39
|
+
var cell = this._row.getCell(column);
|
|
40
|
+
return cell ? cell.getComponent() : false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_getSelf(){
|
|
44
|
+
return this._row;
|
|
45
|
+
}
|
|
46
|
+
}
|