@progress/kendo-react-spreadsheet 5.14.0-dev.202305151331
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/LICENSE.md +11 -0
- package/NOTICE.txt +117 -0
- package/README.md +46 -0
- package/about.md +3 -0
- package/dist/cdn/js/kendo-react-spreadsheet.js +1 -0
- package/dist/es/FormulaInput.d.ts +5 -0
- package/dist/es/FormulaInput.js +116 -0
- package/dist/es/List.d.ts +5 -0
- package/dist/es/List.js +17 -0
- package/dist/es/NameBox.d.ts +5 -0
- package/dist/es/NameBox.js +88 -0
- package/dist/es/SheetsBar.d.ts +5 -0
- package/dist/es/SheetsBar.js +233 -0
- package/dist/es/Spreadsheet.d.ts +3 -0
- package/dist/es/Spreadsheet.js +206 -0
- package/dist/es/SpreadsheetProps.d.ts +104 -0
- package/dist/es/SpreadsheetProps.js +1 -0
- package/dist/es/main.d.ts +3 -0
- package/dist/es/main.js +2 -0
- package/dist/es/messages.d.ts +76 -0
- package/dist/es/messages.js +208 -0
- package/dist/es/package-metadata.d.ts +5 -0
- package/dist/es/package-metadata.js +11 -0
- package/dist/es/tools/align.d.ts +9 -0
- package/dist/es/tools/align.js +39 -0
- package/dist/es/tools/backgroundColor.d.ts +5 -0
- package/dist/es/tools/backgroundColor.js +12 -0
- package/dist/es/tools/bold.d.ts +5 -0
- package/dist/es/tools/bold.js +5 -0
- package/dist/es/tools/defaultTools.d.ts +2 -0
- package/dist/es/tools/defaultTools.js +42 -0
- package/dist/es/tools/export.d.ts +5 -0
- package/dist/es/tools/export.js +16 -0
- package/dist/es/tools/fontFamily.d.ts +5 -0
- package/dist/es/tools/fontFamily.js +18 -0
- package/dist/es/tools/fontSize.d.ts +5 -0
- package/dist/es/tools/fontSize.js +20 -0
- package/dist/es/tools/format.d.ts +5 -0
- package/dist/es/tools/format.js +23 -0
- package/dist/es/tools/gridLines.d.ts +6 -0
- package/dist/es/tools/gridLines.js +22 -0
- package/dist/es/tools/index.d.ts +17 -0
- package/dist/es/tools/index.js +17 -0
- package/dist/es/tools/italic.d.ts +5 -0
- package/dist/es/tools/italic.js +5 -0
- package/dist/es/tools/open.d.ts +5 -0
- package/dist/es/tools/open.js +33 -0
- package/dist/es/tools/redo.d.ts +5 -0
- package/dist/es/tools/redo.js +5 -0
- package/dist/es/tools/tableTools.d.ts +20 -0
- package/dist/es/tools/tableTools.js +72 -0
- package/dist/es/tools/textColor.d.ts +5 -0
- package/dist/es/tools/textColor.js +12 -0
- package/dist/es/tools/textWrap.d.ts +6 -0
- package/dist/es/tools/textWrap.js +23 -0
- package/dist/es/tools/underline.d.ts +5 -0
- package/dist/es/tools/underline.js +5 -0
- package/dist/es/tools/undo.d.ts +5 -0
- package/dist/es/tools/undo.js +5 -0
- package/dist/es/tools/utils.d.ts +79 -0
- package/dist/es/tools/utils.js +102 -0
- package/dist/npm/FormulaInput.d.ts +5 -0
- package/dist/npm/FormulaInput.js +119 -0
- package/dist/npm/List.d.ts +5 -0
- package/dist/npm/List.js +20 -0
- package/dist/npm/NameBox.d.ts +5 -0
- package/dist/npm/NameBox.js +91 -0
- package/dist/npm/SheetsBar.d.ts +5 -0
- package/dist/npm/SheetsBar.js +237 -0
- package/dist/npm/Spreadsheet.d.ts +3 -0
- package/dist/npm/Spreadsheet.js +209 -0
- package/dist/npm/SpreadsheetProps.d.ts +104 -0
- package/dist/npm/SpreadsheetProps.js +2 -0
- package/dist/npm/main.d.ts +3 -0
- package/dist/npm/main.js +20 -0
- package/dist/npm/messages.d.ts +76 -0
- package/dist/npm/messages.js +211 -0
- package/dist/npm/package-metadata.d.ts +5 -0
- package/dist/npm/package-metadata.js +14 -0
- package/dist/npm/tools/align.d.ts +9 -0
- package/dist/npm/tools/align.js +43 -0
- package/dist/npm/tools/backgroundColor.d.ts +5 -0
- package/dist/npm/tools/backgroundColor.js +15 -0
- package/dist/npm/tools/bold.d.ts +5 -0
- package/dist/npm/tools/bold.js +8 -0
- package/dist/npm/tools/defaultTools.d.ts +2 -0
- package/dist/npm/tools/defaultTools.js +45 -0
- package/dist/npm/tools/export.d.ts +5 -0
- package/dist/npm/tools/export.js +20 -0
- package/dist/npm/tools/fontFamily.d.ts +5 -0
- package/dist/npm/tools/fontFamily.js +22 -0
- package/dist/npm/tools/fontSize.d.ts +5 -0
- package/dist/npm/tools/fontSize.js +24 -0
- package/dist/npm/tools/format.d.ts +5 -0
- package/dist/npm/tools/format.js +27 -0
- package/dist/npm/tools/gridLines.d.ts +6 -0
- package/dist/npm/tools/gridLines.js +26 -0
- package/dist/npm/tools/index.d.ts +17 -0
- package/dist/npm/tools/index.js +33 -0
- package/dist/npm/tools/italic.d.ts +5 -0
- package/dist/npm/tools/italic.js +8 -0
- package/dist/npm/tools/open.d.ts +5 -0
- package/dist/npm/tools/open.js +37 -0
- package/dist/npm/tools/redo.d.ts +5 -0
- package/dist/npm/tools/redo.js +8 -0
- package/dist/npm/tools/tableTools.d.ts +20 -0
- package/dist/npm/tools/tableTools.js +75 -0
- package/dist/npm/tools/textColor.d.ts +5 -0
- package/dist/npm/tools/textColor.js +15 -0
- package/dist/npm/tools/textWrap.d.ts +6 -0
- package/dist/npm/tools/textWrap.js +27 -0
- package/dist/npm/tools/underline.d.ts +5 -0
- package/dist/npm/tools/underline.js +8 -0
- package/dist/npm/tools/undo.d.ts +5 -0
- package/dist/npm/tools/undo.js +8 -0
- package/dist/npm/tools/utils.d.ts +79 -0
- package/dist/npm/tools/utils.js +108 -0
- package/dist/systemjs/kendo-react-spreadsheet.js +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import { Spreadsheet as SpreadsheetInstance } from '@progress/kendo-spreadsheet-common';
|
|
4
|
+
import { ButtonGroup, Toolbar, ToolbarSeparator } from '@progress/kendo-react-buttons';
|
|
5
|
+
import { TabStrip, TabStripTab } from '@progress/kendo-react-layout';
|
|
6
|
+
import { Undo } from './tools/undo';
|
|
7
|
+
import { Redo } from './tools/redo';
|
|
8
|
+
import { FormulaInput } from './FormulaInput';
|
|
9
|
+
import { NameBox } from './NameBox';
|
|
10
|
+
import { SheetsBar } from './SheetsBar';
|
|
11
|
+
import { defaultTabs } from './tools/defaultTools';
|
|
12
|
+
import { IconWrap, classNames, validatePackage } from '@progress/kendo-react-common';
|
|
13
|
+
import { packageMetadata } from './package-metadata';
|
|
14
|
+
import { formulaFxIcon } from '@progress/kendo-svg-icons';
|
|
15
|
+
import { useInternationalization, useLocalization } from '@progress/kendo-react-intl';
|
|
16
|
+
import { keys, messages } from './messages';
|
|
17
|
+
const toolsFunctions = ['bold', 'italic', 'underline', 'fontFamily', 'fontSize', 'color', 'background', 'textAlign', 'verticalAlign', 'wrap', 'gridLines'];
|
|
18
|
+
const toolsValueMap = {
|
|
19
|
+
Bold: (state) => state.bold,
|
|
20
|
+
Italic: (state) => state.italic,
|
|
21
|
+
Underline: (state) => state.underline,
|
|
22
|
+
FontFamily: (state) => state.fontFamily,
|
|
23
|
+
FontSize: (state) => state.fontSize,
|
|
24
|
+
TextColor: (state) => state.color,
|
|
25
|
+
BackgroundColor: (state) => state.background,
|
|
26
|
+
Alignment: (state) => ({ textAlign: state.textAlign, verticalAlign: state.verticalAlign }),
|
|
27
|
+
Wrap: (state) => state.wrap,
|
|
28
|
+
GridLines: (state) => state.gridLines
|
|
29
|
+
};
|
|
30
|
+
const noInnerButton = ':not(.k-dropdownlist button)' +
|
|
31
|
+
':not(.k-combobox button)' +
|
|
32
|
+
':not(.k-upload-button)' +
|
|
33
|
+
':not(.k-colorpicker button)' +
|
|
34
|
+
':not(.k-split-button .k-split-button-arrow)';
|
|
35
|
+
const toolbarButtons = [
|
|
36
|
+
'button' + noInnerButton,
|
|
37
|
+
'.k-button-group > button' + noInnerButton,
|
|
38
|
+
'.k-dropdownlist',
|
|
39
|
+
'.k-combobox',
|
|
40
|
+
'.k-colorpicker'
|
|
41
|
+
];
|
|
42
|
+
export const Spreadsheet = React.forwardRef((props, ref) => {
|
|
43
|
+
validatePackage(packageMetadata);
|
|
44
|
+
const [tab, setTab] = React.useState(0);
|
|
45
|
+
const [_init, setInit] = React.useState(false);
|
|
46
|
+
const elementRef = React.useRef(null);
|
|
47
|
+
const formulaBarInputRef = React.useRef(null);
|
|
48
|
+
const formulaCellInputRef = React.useRef(null);
|
|
49
|
+
const nameBoxRef = React.useRef(null);
|
|
50
|
+
const spreadsheetRef = React.useRef(null);
|
|
51
|
+
const [toolsState, setToolsState] = React.useState({});
|
|
52
|
+
const prevState = React.useRef({});
|
|
53
|
+
prevState.current = toolsState;
|
|
54
|
+
const propsRef = React.useRef({});
|
|
55
|
+
propsRef.current = props;
|
|
56
|
+
const onRender = React.useCallback((event) => {
|
|
57
|
+
if (propsRef.current.onRender) {
|
|
58
|
+
propsRef.current.onRender.call(undefined, event);
|
|
59
|
+
}
|
|
60
|
+
}, []);
|
|
61
|
+
const onSelect = React.useCallback((event) => {
|
|
62
|
+
if (propsRef.current.onSelect) {
|
|
63
|
+
propsRef.current.onSelect.call(undefined, event);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
const onChange = React.useCallback((event) => {
|
|
67
|
+
if (propsRef.current.onChange) {
|
|
68
|
+
propsRef.current.onChange.call(undefined, event);
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
const onChangeFormat = React.useCallback((event) => {
|
|
72
|
+
if (propsRef.current.onChangeFormat) {
|
|
73
|
+
propsRef.current.onChangeFormat.call(undefined, event);
|
|
74
|
+
}
|
|
75
|
+
}, []);
|
|
76
|
+
const onExcelImport = React.useCallback((event) => {
|
|
77
|
+
if (propsRef.current.onExcelImport) {
|
|
78
|
+
propsRef.current.onExcelImport.call(undefined, event);
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
const onExcelExport = React.useCallback((event) => {
|
|
82
|
+
if (propsRef.current.onExcelExport) {
|
|
83
|
+
propsRef.current.onExcelExport.call(undefined, event);
|
|
84
|
+
}
|
|
85
|
+
}, []);
|
|
86
|
+
const target = React.useRef(null);
|
|
87
|
+
React.useImperativeHandle(target, () => ({
|
|
88
|
+
element: elementRef.current,
|
|
89
|
+
get instance() { return spreadsheetRef.current; },
|
|
90
|
+
props
|
|
91
|
+
}), [props]);
|
|
92
|
+
React.useImperativeHandle(ref, () => target.current);
|
|
93
|
+
const nameEditor = React.useCallback(() => {
|
|
94
|
+
return spreadsheetRef.current && spreadsheetRef.current.view.nameEditor;
|
|
95
|
+
}, []);
|
|
96
|
+
const onUpdateTools = React.useCallback((e) => {
|
|
97
|
+
const state = {};
|
|
98
|
+
toolsFunctions.forEach(tool => {
|
|
99
|
+
if (typeof e.range[tool] === 'function') {
|
|
100
|
+
state[tool] = e.range[tool]();
|
|
101
|
+
}
|
|
102
|
+
else if (tool === 'gridLines') {
|
|
103
|
+
state[tool] = e.range.sheet().showGridLines();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
if (toolsFunctions.some(k => state[k] !== prevState.current[k])) {
|
|
107
|
+
setToolsState(state);
|
|
108
|
+
}
|
|
109
|
+
}, []);
|
|
110
|
+
const intl = useInternationalization();
|
|
111
|
+
const localization = useLocalization();
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
var _a;
|
|
114
|
+
const options = Object.assign(Object.assign({}, props.defaultProps), { sheets: structuredClone((_a = props.defaultProps) === null || _a === void 0 ? void 0 : _a.sheets), messages: {
|
|
115
|
+
workbook: {
|
|
116
|
+
defaultSheetName: localization.toLanguageString(keys.defaultSheetName, messages[keys.defaultSheetName])
|
|
117
|
+
}
|
|
118
|
+
}, intl: {
|
|
119
|
+
localeInfo: () => intl.localeInfo(),
|
|
120
|
+
parseDate: (value, fmt) => intl.parseDate(value, fmt),
|
|
121
|
+
toString: (value, fmt) => intl.toString(value, fmt),
|
|
122
|
+
format: (fmt, ...values) => intl.format(fmt, ...values)
|
|
123
|
+
}, formulaBarInputRef,
|
|
124
|
+
formulaCellInputRef,
|
|
125
|
+
nameBoxRef });
|
|
126
|
+
const spreadsheet = new SpreadsheetInstance(elementRef.current, options);
|
|
127
|
+
spreadsheetRef.current = spreadsheet;
|
|
128
|
+
spreadsheet.bind('render', onRender);
|
|
129
|
+
spreadsheet.bind('select', onSelect);
|
|
130
|
+
spreadsheet.bind('change', onChange);
|
|
131
|
+
spreadsheet.bind('changeFormat', onChangeFormat);
|
|
132
|
+
spreadsheet.bind('excelImport', onExcelImport);
|
|
133
|
+
spreadsheet.bind('excelExport', onExcelExport);
|
|
134
|
+
spreadsheet.view.bind('update', onUpdateTools);
|
|
135
|
+
const sheet = spreadsheet.activeSheet();
|
|
136
|
+
if (sheet) {
|
|
137
|
+
onUpdateTools({ range: sheet.range(sheet.activeCell()) });
|
|
138
|
+
}
|
|
139
|
+
setInit(true);
|
|
140
|
+
const quickAccessToolbar = elementRef.current && elementRef.current.querySelector('.k-spreadsheet-quick-access-toolbar');
|
|
141
|
+
const tabstripItems = elementRef.current && elementRef.current.querySelector('.k-spreadsheet-tabstrip .k-tabstrip-items');
|
|
142
|
+
if (quickAccessToolbar && tabstripItems) {
|
|
143
|
+
tabstripItems.style.paddingLeft = quickAccessToolbar.offsetWidth + 'px';
|
|
144
|
+
}
|
|
145
|
+
return () => {
|
|
146
|
+
spreadsheet.destroy();
|
|
147
|
+
};
|
|
148
|
+
}, []);
|
|
149
|
+
const renderTool = React.useCallback((Tool, index) => {
|
|
150
|
+
const tool = (React.createElement(Tool, { spreadsheetRef: spreadsheetRef, value: toolsValueMap[Tool.displayName] ? toolsValueMap[Tool.displayName](toolsState) : undefined, key: index }));
|
|
151
|
+
return tool.type === ToolbarSeparator ? React.createElement(Tool, { key: index }) : tool;
|
|
152
|
+
}, [toolsState]);
|
|
153
|
+
const { toolbar = defaultTabs } = props;
|
|
154
|
+
const toolbarTools = [];
|
|
155
|
+
if (typeof toolbar === 'boolean') {
|
|
156
|
+
toolbarTools.push(...(toolbar ? defaultTabs : []));
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
toolbarTools.push(...toolbar);
|
|
160
|
+
}
|
|
161
|
+
let tabstrip = null;
|
|
162
|
+
if (toolbarTools.length) {
|
|
163
|
+
tabstrip = (React.createElement(TabStrip, { selected: tab, animation: false, className: "k-floatwrap k-spreadsheet-tabstrip", style: { minHeight: 'auto' }, onSelect: e => setTab(e.selected) }, toolbarTools.map((tabData) => {
|
|
164
|
+
const title = tabData.textKey ? localization.toLanguageString(tabData.textKey, messages[tabData.textKey]) : tabData.text;
|
|
165
|
+
return (React.createElement(TabStripTab, { key: tabData.textKey || tabData.text, title: title },
|
|
166
|
+
React.createElement(Toolbar, { buttons: toolbarButtons, className: 'k-spreadsheet-toolbar' }, tabData.tools.map((tool, index) => {
|
|
167
|
+
if (Array.isArray(tool)) {
|
|
168
|
+
return (React.createElement(ButtonGroup, { key: index }, tool.map((t, i) => renderTool(t, i))));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return renderTool(tool, index);
|
|
172
|
+
}
|
|
173
|
+
}))));
|
|
174
|
+
})));
|
|
175
|
+
}
|
|
176
|
+
return (React.createElement("div", { ref: elementRef, style: props.style, className: classNames('k-widget k-spreadsheet', props.className), role: "application" },
|
|
177
|
+
tabstrip && React.createElement("div", { className: "k-spreadsheet-quick-access-toolbar" },
|
|
178
|
+
React.createElement(Undo, { spreadsheetRef: spreadsheetRef }),
|
|
179
|
+
React.createElement(Redo, { spreadsheetRef: spreadsheetRef })),
|
|
180
|
+
tabstrip,
|
|
181
|
+
React.createElement("div", { className: "k-spreadsheet-action-bar" },
|
|
182
|
+
React.createElement(NameBox, { ref: nameBoxRef, nameEditor: nameEditor }),
|
|
183
|
+
React.createElement("div", { className: "k-spreadsheet-formula-bar" },
|
|
184
|
+
React.createElement(IconWrap, { name: "formula-fx", icon: formulaFxIcon }),
|
|
185
|
+
React.createElement(FormulaInput, { ref: formulaBarInputRef }))),
|
|
186
|
+
React.createElement("div", { className: "k-spreadsheet-view" },
|
|
187
|
+
React.createElement("div", { className: "k-spreadsheet-fixed-container" }),
|
|
188
|
+
React.createElement("div", { className: "k-spreadsheet-scroller" },
|
|
189
|
+
React.createElement("div", { className: "k-spreadsheet-view-size" })),
|
|
190
|
+
React.createElement("div", { tabIndex: 0, className: "k-spreadsheet-clipboard", contentEditable: "true" }),
|
|
191
|
+
React.createElement(FormulaInput, { ref: formulaCellInputRef, className: "k-spreadsheet-cell-editor" })),
|
|
192
|
+
React.createElement(SheetsBar, { spreadsheetRef: spreadsheetRef })));
|
|
193
|
+
});
|
|
194
|
+
Spreadsheet.displayName = 'KendoReactSpreadsheet';
|
|
195
|
+
Spreadsheet.propTypes = {
|
|
196
|
+
className: PropTypes.string,
|
|
197
|
+
defaultProps: PropTypes.any,
|
|
198
|
+
toolbar: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.any)]),
|
|
199
|
+
style: PropTypes.object,
|
|
200
|
+
onRender: PropTypes.func,
|
|
201
|
+
onSelect: PropTypes.func,
|
|
202
|
+
onChange: PropTypes.func,
|
|
203
|
+
onChangeFormat: PropTypes.func,
|
|
204
|
+
onExcelImport: PropTypes.func,
|
|
205
|
+
onExcelExport: PropTypes.func
|
|
206
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Workbook } from '@progress/kendo-ooxml';
|
|
3
|
+
import { SpreadsheetOptions, Spreadsheet as SpreadsheetInstance, Range as SpreadsheetRange } from '@progress/kendo-spreadsheet-common';
|
|
4
|
+
interface SpreadsheetEvent {
|
|
5
|
+
/**
|
|
6
|
+
* The widget instance which fired the event.
|
|
7
|
+
*/
|
|
8
|
+
sender: SpreadsheetInstance;
|
|
9
|
+
}
|
|
10
|
+
export interface SpreadsheetRenderEvent extends SpreadsheetEvent {
|
|
11
|
+
}
|
|
12
|
+
export interface SpreadsheetSelectEvent extends SpreadsheetEvent {
|
|
13
|
+
/**
|
|
14
|
+
* The Range that is selected.
|
|
15
|
+
*/
|
|
16
|
+
range: SpreadsheetRange;
|
|
17
|
+
}
|
|
18
|
+
export interface SpreadsheetChangeEvent extends SpreadsheetEvent, SpreadsheetSelectEvent {
|
|
19
|
+
}
|
|
20
|
+
export interface SpreadsheetExcelImportEvent extends SpreadsheetEvent {
|
|
21
|
+
/**
|
|
22
|
+
* The file that is being imported.
|
|
23
|
+
*/
|
|
24
|
+
file: Blob | File;
|
|
25
|
+
/**
|
|
26
|
+
* If invoked, the Spreadsheet will not import the file.
|
|
27
|
+
*/
|
|
28
|
+
preventDefault: Function;
|
|
29
|
+
}
|
|
30
|
+
export interface SpreadsheetExcelExportEvent extends SpreadsheetEvent {
|
|
31
|
+
/**
|
|
32
|
+
* The array of data items that is used to create the Excel workbook.
|
|
33
|
+
*/
|
|
34
|
+
data: Array<any>;
|
|
35
|
+
/**
|
|
36
|
+
* The Excel workbook configuration object.
|
|
37
|
+
* Modifications of the workbook will reflect in the output Excel document.
|
|
38
|
+
*/
|
|
39
|
+
workbook: Workbook;
|
|
40
|
+
/**
|
|
41
|
+
* If invoked, the Spreadsheet will not save the generated file.
|
|
42
|
+
*/
|
|
43
|
+
preventDefault: Function;
|
|
44
|
+
}
|
|
45
|
+
export interface Tab {
|
|
46
|
+
text?: string;
|
|
47
|
+
textKey?: string;
|
|
48
|
+
tools: (React.ComponentType<any> | React.ComponentType<any>[])[];
|
|
49
|
+
}
|
|
50
|
+
export interface SpreadsheetProps {
|
|
51
|
+
/**
|
|
52
|
+
* Sets additional classes to the Spreadsheet.
|
|
53
|
+
*/
|
|
54
|
+
className?: string;
|
|
55
|
+
defaultProps?: SpreadsheetOptions;
|
|
56
|
+
/**
|
|
57
|
+
* A Boolean value which indicates if the toolbar will be displayed. It also allows to customize the tabs content
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
toolbar?: boolean | Tab[];
|
|
62
|
+
/**
|
|
63
|
+
* Specifies the styles that will be applied to the wrapping element.
|
|
64
|
+
*/
|
|
65
|
+
style?: React.CSSProperties;
|
|
66
|
+
/**
|
|
67
|
+
* Triggered after the widget has completed rendering.
|
|
68
|
+
* The event will also fire when a cell is selected or when the Spreadsheet's tools (bold, italic) are used,
|
|
69
|
+
* as the target element is re-generated with new styles (e.g background-color, box-shadow, font-weight, etc.).
|
|
70
|
+
*/
|
|
71
|
+
onRender?: (event: SpreadsheetRenderEvent) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Triggered when the Spreadsheet selection is changed.
|
|
74
|
+
*/
|
|
75
|
+
onSelect?: (event: SpreadsheetSelectEvent) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Triggered when a value in the Spreadsheet has been changed.
|
|
78
|
+
*/
|
|
79
|
+
onChange?: (event: SpreadsheetChangeEvent) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Triggered when the range format is changed from the UI.
|
|
82
|
+
*/
|
|
83
|
+
onChangeFormat?: (event: SpreadsheetChangeEvent) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Fired when the user clicks the Open toolbar button.
|
|
86
|
+
*/
|
|
87
|
+
onExcelImport?: (event: SpreadsheetExcelImportEvent) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Fires when the user clicks the Export to Excel toolbar button.
|
|
90
|
+
*/
|
|
91
|
+
onExcelExport?: (event: SpreadsheetExcelExportEvent) => void;
|
|
92
|
+
}
|
|
93
|
+
export interface SpreadsheetHandle {
|
|
94
|
+
/**
|
|
95
|
+
* The current element or `null` if there is no one.
|
|
96
|
+
*/
|
|
97
|
+
element: HTMLDivElement | null;
|
|
98
|
+
/**
|
|
99
|
+
* The props values of the Spreadsheet.
|
|
100
|
+
*/
|
|
101
|
+
props: SpreadsheetProps;
|
|
102
|
+
instance: SpreadsheetInstance | null;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es/main.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
export declare const messages: {
|
|
5
|
+
"spreadsheet.bold": string;
|
|
6
|
+
"spreadsheet.italic": string;
|
|
7
|
+
"spreadsheet.underline": string;
|
|
8
|
+
"spreadsheet.undo": string;
|
|
9
|
+
"spreadsheet.redo": string;
|
|
10
|
+
"spreadsheet.fontSize": string;
|
|
11
|
+
"spreadsheet.fontName": string;
|
|
12
|
+
"spreadsheet.format": string;
|
|
13
|
+
"spreadsheet.align": string;
|
|
14
|
+
"spreadsheet.alignLeft": string;
|
|
15
|
+
"spreadsheet.alignRight": string;
|
|
16
|
+
"spreadsheet.alignCenter": string;
|
|
17
|
+
"spreadsheet.alignJustify": string;
|
|
18
|
+
"spreadsheet.alignTop": string;
|
|
19
|
+
"spreadsheet.alignMiddle": string;
|
|
20
|
+
"spreadsheet.alignBottom": string;
|
|
21
|
+
"spreadsheet.textColor": string;
|
|
22
|
+
"spreadsheet.background": string;
|
|
23
|
+
"spreadsheet.addRowAbove": string;
|
|
24
|
+
"spreadsheet.addRowBelow": string;
|
|
25
|
+
"spreadsheet.addColumnLeft": string;
|
|
26
|
+
"spreadsheet.addColumnRight": string;
|
|
27
|
+
"spreadsheet.deleteRow": string;
|
|
28
|
+
"spreadsheet.deleteColumn": string;
|
|
29
|
+
"spreadsheet.openFile": string;
|
|
30
|
+
"spreadsheet.exportToExcel": string;
|
|
31
|
+
"spreadsheet.textWrap": string;
|
|
32
|
+
"spreadsheet.gridLines": string;
|
|
33
|
+
"spreadsheet.nameBox": string;
|
|
34
|
+
"spreadsheet.defaultSheetName": string;
|
|
35
|
+
"spreadsheet.home": string;
|
|
36
|
+
"spreadsheet.insert": string;
|
|
37
|
+
"spreadsheet.addNewSheet": string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
export declare const keys: {
|
|
43
|
+
bold: string;
|
|
44
|
+
italic: string;
|
|
45
|
+
underline: string;
|
|
46
|
+
undo: string;
|
|
47
|
+
redo: string;
|
|
48
|
+
fontSize: string;
|
|
49
|
+
fontName: string;
|
|
50
|
+
format: string;
|
|
51
|
+
align: string;
|
|
52
|
+
alignLeft: string;
|
|
53
|
+
alignRight: string;
|
|
54
|
+
alignCenter: string;
|
|
55
|
+
alignJustify: string;
|
|
56
|
+
alignTop: string;
|
|
57
|
+
alignMiddle: string;
|
|
58
|
+
alignBottom: string;
|
|
59
|
+
textColor: string;
|
|
60
|
+
background: string;
|
|
61
|
+
addRowAbove: string;
|
|
62
|
+
addRowBelow: string;
|
|
63
|
+
addColumnLeft: string;
|
|
64
|
+
addColumnRight: string;
|
|
65
|
+
deleteRow: string;
|
|
66
|
+
deleteColumn: string;
|
|
67
|
+
open: string;
|
|
68
|
+
exportToExcel: string;
|
|
69
|
+
textWrap: string;
|
|
70
|
+
gridLines: string;
|
|
71
|
+
nameBox: string;
|
|
72
|
+
defaultSheetName: string;
|
|
73
|
+
home: string;
|
|
74
|
+
insert: string;
|
|
75
|
+
addNewSheet: string;
|
|
76
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
const bold = 'spreadsheet.bold';
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
const italic = 'spreadsheet.italic';
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
const underline = 'spreadsheet.underline';
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
const open = 'spreadsheet.openFile';
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
const textColor = 'spreadsheet.textColor';
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
const background = 'spreadsheet.background';
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
const addRowAbove = 'spreadsheet.addRowAbove';
|
|
29
|
+
/**
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
const addRowBelow = 'spreadsheet.addRowBelow';
|
|
33
|
+
/**
|
|
34
|
+
* @hidden
|
|
35
|
+
*/
|
|
36
|
+
const addColumnLeft = 'spreadsheet.addColumnLeft';
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
40
|
+
const addColumnRight = 'spreadsheet.addColumnRight';
|
|
41
|
+
/**
|
|
42
|
+
* @hidden
|
|
43
|
+
*/
|
|
44
|
+
const deleteRow = 'spreadsheet.deleteRow';
|
|
45
|
+
/**
|
|
46
|
+
* @hidden
|
|
47
|
+
*/
|
|
48
|
+
const deleteColumn = 'spreadsheet.deleteColumn';
|
|
49
|
+
/**
|
|
50
|
+
* @hidden
|
|
51
|
+
*/
|
|
52
|
+
const undo = 'spreadsheet.undo';
|
|
53
|
+
/**
|
|
54
|
+
* @hidden
|
|
55
|
+
*/
|
|
56
|
+
const redo = 'spreadsheet.redo';
|
|
57
|
+
/**
|
|
58
|
+
* @hidden
|
|
59
|
+
*/
|
|
60
|
+
const fontSize = 'spreadsheet.fontSize';
|
|
61
|
+
/**
|
|
62
|
+
* @hidden
|
|
63
|
+
*/
|
|
64
|
+
const fontName = 'spreadsheet.fontName';
|
|
65
|
+
/**
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
68
|
+
const format = 'spreadsheet.format';
|
|
69
|
+
/**
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
const align = 'spreadsheet.align';
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
const alignLeft = 'spreadsheet.alignLeft';
|
|
77
|
+
/**
|
|
78
|
+
* @hidden
|
|
79
|
+
*/
|
|
80
|
+
const alignRight = 'spreadsheet.alignRight';
|
|
81
|
+
/**
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
const alignCenter = 'spreadsheet.alignCenter';
|
|
85
|
+
/**
|
|
86
|
+
* @hidden
|
|
87
|
+
*/
|
|
88
|
+
const alignJustify = 'spreadsheet.alignJustify';
|
|
89
|
+
/**
|
|
90
|
+
* @hidden
|
|
91
|
+
*/
|
|
92
|
+
const alignTop = 'spreadsheet.alignTop';
|
|
93
|
+
/**
|
|
94
|
+
* @hidden
|
|
95
|
+
*/
|
|
96
|
+
const alignMiddle = 'spreadsheet.alignMiddle';
|
|
97
|
+
/**
|
|
98
|
+
* @hidden
|
|
99
|
+
*/
|
|
100
|
+
const alignBottom = 'spreadsheet.alignBottom';
|
|
101
|
+
/**
|
|
102
|
+
* @hidden
|
|
103
|
+
*/
|
|
104
|
+
const textWrap = 'spreadsheet.textWrap';
|
|
105
|
+
/**
|
|
106
|
+
* @hidden
|
|
107
|
+
*/
|
|
108
|
+
const gridLines = 'spreadsheet.gridLines';
|
|
109
|
+
/**
|
|
110
|
+
* @hidden
|
|
111
|
+
*/
|
|
112
|
+
const exportToExcel = 'spreadsheet.exportToExcel';
|
|
113
|
+
/**
|
|
114
|
+
* @hidden
|
|
115
|
+
*/
|
|
116
|
+
const nameBox = 'spreadsheet.nameBox';
|
|
117
|
+
/**
|
|
118
|
+
* @hidden
|
|
119
|
+
*/
|
|
120
|
+
const defaultSheetName = 'spreadsheet.defaultSheetName';
|
|
121
|
+
/**
|
|
122
|
+
* @hidden
|
|
123
|
+
*/
|
|
124
|
+
const home = 'spreadsheet.home';
|
|
125
|
+
/**
|
|
126
|
+
* @hidden
|
|
127
|
+
*/
|
|
128
|
+
const insert = 'spreadsheet.insert';
|
|
129
|
+
/**
|
|
130
|
+
* @hidden
|
|
131
|
+
*/
|
|
132
|
+
const addNewSheet = 'spreadsheet.addNewSheet';
|
|
133
|
+
/**
|
|
134
|
+
* @hidden
|
|
135
|
+
*/
|
|
136
|
+
export const messages = {
|
|
137
|
+
[bold]: 'Bold',
|
|
138
|
+
[italic]: 'Italic',
|
|
139
|
+
[underline]: 'Underline',
|
|
140
|
+
[undo]: 'Undo',
|
|
141
|
+
[redo]: 'Redo',
|
|
142
|
+
[fontSize]: 'Font size',
|
|
143
|
+
[fontName]: 'Font',
|
|
144
|
+
[format]: 'Custom format...',
|
|
145
|
+
[align]: 'Align',
|
|
146
|
+
[alignLeft]: 'Align Left',
|
|
147
|
+
[alignRight]: 'Align Right',
|
|
148
|
+
[alignCenter]: 'Align Center',
|
|
149
|
+
[alignJustify]: 'Align Justify',
|
|
150
|
+
[alignTop]: 'Align Top',
|
|
151
|
+
[alignMiddle]: 'Align Middle',
|
|
152
|
+
[alignBottom]: 'Align Bottom',
|
|
153
|
+
[textColor]: 'Text Color',
|
|
154
|
+
[background]: 'Background color',
|
|
155
|
+
[addRowAbove]: 'Add row above',
|
|
156
|
+
[addRowBelow]: 'Add row below',
|
|
157
|
+
[addColumnLeft]: 'Add column left',
|
|
158
|
+
[addColumnRight]: 'Add column right',
|
|
159
|
+
[deleteRow]: 'Delete row',
|
|
160
|
+
[deleteColumn]: 'Delete column',
|
|
161
|
+
[open]: 'Open...',
|
|
162
|
+
[exportToExcel]: 'Export to Excel',
|
|
163
|
+
[textWrap]: 'Text Wrap',
|
|
164
|
+
[gridLines]: 'Toggle gridlines',
|
|
165
|
+
[nameBox]: 'Name Box',
|
|
166
|
+
[defaultSheetName]: 'Sheet',
|
|
167
|
+
[home]: 'Home',
|
|
168
|
+
[insert]: 'Insert',
|
|
169
|
+
[addNewSheet]: 'Add new sheet'
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* @hidden
|
|
173
|
+
*/
|
|
174
|
+
export const keys = {
|
|
175
|
+
bold,
|
|
176
|
+
italic,
|
|
177
|
+
underline,
|
|
178
|
+
undo,
|
|
179
|
+
redo,
|
|
180
|
+
fontSize,
|
|
181
|
+
fontName,
|
|
182
|
+
format,
|
|
183
|
+
align,
|
|
184
|
+
alignLeft,
|
|
185
|
+
alignRight,
|
|
186
|
+
alignCenter,
|
|
187
|
+
alignJustify,
|
|
188
|
+
alignTop,
|
|
189
|
+
alignMiddle,
|
|
190
|
+
alignBottom,
|
|
191
|
+
textColor,
|
|
192
|
+
background,
|
|
193
|
+
addRowAbove,
|
|
194
|
+
addRowBelow,
|
|
195
|
+
addColumnLeft,
|
|
196
|
+
addColumnRight,
|
|
197
|
+
deleteRow,
|
|
198
|
+
deleteColumn,
|
|
199
|
+
open,
|
|
200
|
+
exportToExcel,
|
|
201
|
+
textWrap,
|
|
202
|
+
gridLines,
|
|
203
|
+
nameBox,
|
|
204
|
+
defaultSheetName,
|
|
205
|
+
home,
|
|
206
|
+
insert,
|
|
207
|
+
addNewSheet
|
|
208
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
export const packageMetadata = {
|
|
5
|
+
name: '@progress/kendo-react-spreadsheet',
|
|
6
|
+
productName: 'KendoReact',
|
|
7
|
+
productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
|
|
8
|
+
publishDate: 1684156698,
|
|
9
|
+
version: '',
|
|
10
|
+
licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
|
|
11
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BaseToolProps } from './utils';
|
|
3
|
+
export interface AlignmentProps extends BaseToolProps {
|
|
4
|
+
value: {
|
|
5
|
+
textAlign?: string;
|
|
6
|
+
verticalAlign?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const Alignment: React.FunctionComponent<AlignmentProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DropDownButton } from '@progress/kendo-react-buttons';
|
|
3
|
+
import { IconWrap } from '@progress/kendo-react-common';
|
|
4
|
+
import { alignLeftIcon, alignCenterIcon, alignRightIcon, alignJustifyIcon, alignTopIcon, alignMiddleIcon, alignBottomIcon, caretAltDownIcon } from '@progress/kendo-svg-icons';
|
|
5
|
+
import { useLocalization } from '@progress/kendo-react-intl';
|
|
6
|
+
import { keys, messages } from '../messages';
|
|
7
|
+
const alignItems = [
|
|
8
|
+
{ icon: 'align-left', svgIcon: alignLeftIcon, textKey: keys.alignLeft, commandName: 'textAlign', value: 'left' },
|
|
9
|
+
{ icon: 'align-center', svgIcon: alignCenterIcon, textKey: keys.alignCenter, commandName: 'textAlign', value: 'center' },
|
|
10
|
+
{ icon: 'align-right', svgIcon: alignRightIcon, textKey: keys.alignRight, commandName: 'textAlign', value: 'right' },
|
|
11
|
+
{ icon: 'align-justify', svgIcon: alignJustifyIcon, textKey: keys.alignJustify, commandName: 'textAlign', value: 'justify' },
|
|
12
|
+
{ icon: 'align-top', svgIcon: alignTopIcon, textKey: keys.alignTop, commandName: 'verticalAlign', value: 'top' },
|
|
13
|
+
{ icon: 'align-middle', svgIcon: alignMiddleIcon, textKey: keys.alignMiddle, commandName: 'verticalAlign', value: 'center' },
|
|
14
|
+
{ icon: 'align-bottom', svgIcon: alignBottomIcon, textKey: keys.alignBottom, commandName: 'verticalAlign', value: 'bottom' }
|
|
15
|
+
];
|
|
16
|
+
export const Alignment = props => {
|
|
17
|
+
const { value, spreadsheetRef } = props;
|
|
18
|
+
const { textAlign, verticalAlign } = value || {};
|
|
19
|
+
const loc = useLocalization();
|
|
20
|
+
const onItemClick = React.useCallback((event) => {
|
|
21
|
+
if (spreadsheetRef.current) {
|
|
22
|
+
const item = event.item;
|
|
23
|
+
const options = {
|
|
24
|
+
command: 'PropertyChangeCommand', options: { property: item.commandName, value: item.value || null }
|
|
25
|
+
};
|
|
26
|
+
spreadsheetRef.current.executeCommand(options);
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
let items = alignItems.slice();
|
|
30
|
+
items = items.map(i => (Object.assign(Object.assign({}, i), { text: loc.toLanguageString(i.textKey, messages[i.textKey]) })));
|
|
31
|
+
if (textAlign) {
|
|
32
|
+
items = items.map(i => i.commandName === 'textAlign' ? Object.assign(Object.assign({}, i), { selected: i.value === textAlign }) : i);
|
|
33
|
+
}
|
|
34
|
+
if (verticalAlign) {
|
|
35
|
+
items = items.map(i => i.commandName === 'verticalAlign' ? Object.assign(Object.assign({}, i), { selected: i.value === verticalAlign }) : i);
|
|
36
|
+
}
|
|
37
|
+
return (React.createElement(DropDownButton, { icon: "align-left", svgIcon: alignLeftIcon, items: items, onItemClick: onItemClick, title: loc.toLanguageString(keys.align, messages[keys.align]), text: React.createElement(IconWrap, { name: "caret-alt-down", icon: caretAltDownIcon }) }));
|
|
38
|
+
};
|
|
39
|
+
Alignment.displayName = 'Alignment';
|