@handsontable/vue3 0.0.0-next-9ec04ce-20221121
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/HotColumn.vue.d.ts +11 -0
- package/HotTable.vue.d.ts +30 -0
- package/LICENSE.txt +25 -0
- package/README.md +134 -0
- package/commonjs/HotColumn.vue.d.ts +11 -0
- package/commonjs/HotTable.vue.d.ts +30 -0
- package/commonjs/helpers.d.ts +36 -0
- package/commonjs/index.d.ts +3 -0
- package/commonjs/types.d.ts +9 -0
- package/commonjs/vue-handsontable.js +343 -0
- package/dist/HotColumn.vue.d.ts +11 -0
- package/dist/HotTable.vue.d.ts +30 -0
- package/dist/helpers.d.ts +36 -0
- package/dist/index.d.ts +3 -0
- package/dist/types.d.ts +9 -0
- package/dist/vue-handsontable.js +376 -0
- package/dist/vue-handsontable.js.map +1 -0
- package/dist/vue-handsontable.min.js +31 -0
- package/dist/vue-handsontable.min.js.map +1 -0
- package/es/vue-handsontable.mjs +333 -0
- package/handsontable-general-terms.pdf +0 -0
- package/handsontable-non-commercial-license.pdf +0 -0
- package/helpers.d.ts +36 -0
- package/index.d.ts +3 -0
- package/package.json +109 -0
- package/types.d.ts +9 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const HotColumn: import("vue").DefineComponent<import("./types").VueProps<import("./types").HotTableProps>, unknown, unknown, {}, {
|
|
2
|
+
/**
|
|
3
|
+
* Create the column settings based on the data provided to the `hot-column`
|
|
4
|
+
* component and it's child components.
|
|
5
|
+
*/
|
|
6
|
+
createColumnSettings(): void;
|
|
7
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<import("./types").VueProps<import("./types").HotTableProps>>>, {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
}>;
|
|
10
|
+
export default HotColumn;
|
|
11
|
+
export { HotColumn };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
import Handsontable from 'handsontable/base';
|
|
3
|
+
import { HotTableProps } from './types';
|
|
4
|
+
declare const HotTable: import("vue").DefineComponent<import("./types").VueProps<HotTableProps>, unknown, {
|
|
5
|
+
__hotInstance: Handsontable;
|
|
6
|
+
miscCache: {
|
|
7
|
+
currentSourceColumns: any;
|
|
8
|
+
};
|
|
9
|
+
columnSettings: HotTableProps[];
|
|
10
|
+
columnsCache: Map<VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>, HotTableProps>;
|
|
13
|
+
hotInstance: Handsontable;
|
|
14
|
+
}, {}, {
|
|
15
|
+
/**
|
|
16
|
+
* Initialize Handsontable.
|
|
17
|
+
*/
|
|
18
|
+
hotInit(): void;
|
|
19
|
+
matchHotMappersSize(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get settings for the columns provided in the `hot-column` components.
|
|
22
|
+
*
|
|
23
|
+
* @returns {HotTableProps[] | undefined}
|
|
24
|
+
*/
|
|
25
|
+
getColumnSettings(): HotTableProps[] | void;
|
|
26
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<import("./types").VueProps<HotTableProps>>>, {
|
|
27
|
+
[x: string]: any;
|
|
28
|
+
}>;
|
|
29
|
+
export default HotTable;
|
|
30
|
+
export { HotTable };
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) HANDSONCODE sp. z o. o.
|
|
2
|
+
|
|
3
|
+
HANDSONTABLE is a software distributed by HANDSONCODE sp. z o. o., a Polish corporation based in
|
|
4
|
+
Gdynia, Poland, at Aleja Zwycięstwa 96-98, registered by the District Court in Gdansk under number
|
|
5
|
+
538651, EU tax ID number: PL5862294002, share capital: PLN 62,800.00.
|
|
6
|
+
|
|
7
|
+
This software is protected by applicable copyright laws, including international treaties, and dual-
|
|
8
|
+
licensed – depending on whether your use for commercial purposes, meaning intended for or
|
|
9
|
+
resulting in commercial advantage or monetary compensation, or not.
|
|
10
|
+
|
|
11
|
+
If your use is strictly personal or solely for evaluation purposes, meaning for the purposes of testing
|
|
12
|
+
the suitability, performance, and usefulness of this software outside the production environment,
|
|
13
|
+
you agree to be bound by the terms included in the "handsontable-non-commercial-license.pdf" file.
|
|
14
|
+
|
|
15
|
+
Your use of this software for commercial purposes is subject to the terms included in an applicable
|
|
16
|
+
license agreement.
|
|
17
|
+
|
|
18
|
+
In any case, you must not make any such use of this software as to develop software which may be
|
|
19
|
+
considered competitive with this software.
|
|
20
|
+
|
|
21
|
+
UNLESS EXPRESSLY AGREED OTHERWISE, HANDSONCODE PROVIDES THIS SOFTWARE ON AN "AS IS"
|
|
22
|
+
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, AND IN NO EVENT AND UNDER NO
|
|
23
|
+
LEGAL THEORY, SHALL HANDSONCODE BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
|
|
24
|
+
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM
|
|
25
|
+
USE OR INABILITY TO USE THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<a href="https://handsontable.com" rel="nofollow"><img src="https://raw.githubusercontent.com/handsontable/handsontable/develop/resources/handsontable-logo-blue.svg" alt="Handsontable - data grid for Vue 3" width="300"></a>
|
|
4
|
+
|
|
5
|
+
# Data Grid for Vue 3<img src="https://raw.githubusercontent.com/handsontable/handsontable/develop/resources/icons/vue-icon.svg" width="22" height="22">
|
|
6
|
+
|
|
7
|
+
Handsontable's wrapper for Vue 3 combines data grid features with spreadsheet-like UX. <br>
|
|
8
|
+
It provides data binding, data validation, filtering, sorting, and CRUD operations.
|
|
9
|
+
|
|
10
|
+
[](https://npmjs.com/package/@handsontable/vue3)
|
|
11
|
+
[](https://npmjs.com/package/@handsontable/vue3)
|
|
12
|
+
[](https://github.com/handsontable/handsontable/actions/workflows/test.yml?query=branch%3Amaster)
|
|
13
|
+
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fhandsontable%2Fhandsontable?ref=badge_shield)
|
|
14
|
+
[](https://sonarcloud.io/dashboard?id=handsontable_handsontable)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<a href="https://handsontable.com/demo"><img src="https://raw.githubusercontent.com/handsontable/handsontable/develop/resources/handsontable-github-preview.png" alt="Handsontable data grid for Vue 3" width="805"/></a>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
The most popular features of Handsontable for Vue 3:
|
|
25
|
+
|
|
26
|
+
✓ Multiple column sorting <br>
|
|
27
|
+
✓ Non-contiguous selection <br>
|
|
28
|
+
✓ Filtering data <br>
|
|
29
|
+
✓ Export to file <br>
|
|
30
|
+
✓ Validating data <br>
|
|
31
|
+
✓ Conditional formatting <br>
|
|
32
|
+
✓ Merging cells <br>
|
|
33
|
+
✓ Freezing rows/columns <br>
|
|
34
|
+
✓ Moving rows/columns <br>
|
|
35
|
+
✓ Resizing rows/columns <br>
|
|
36
|
+
✓ Hiding rows/columns <br>
|
|
37
|
+
✓ Context menu <br>
|
|
38
|
+
✓ Comments <br>
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
- [Developer guides](https://handsontable.com/docs/vue3-installation/)
|
|
43
|
+
- [API Reference](https://handsontable.com/docs/api/core/)
|
|
44
|
+
- [Changelog](https://handsontable.com/docs/release-notes/)
|
|
45
|
+
- [Demo](https://handsontable.com/demo)
|
|
46
|
+
|
|
47
|
+
<div id="installation"></div>
|
|
48
|
+
|
|
49
|
+
## Get Started
|
|
50
|
+
### Install with npm
|
|
51
|
+
|
|
52
|
+
Run the following command in your terminal
|
|
53
|
+
```
|
|
54
|
+
npm install handsontable @handsontable/vue3
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You can load it directly from [jsDelivr](https:jsdelivr.com/package/npm/@handsontable/vue3) as well.
|
|
58
|
+
```html
|
|
59
|
+
<script src="https://cdn.jsdelivr.net/npm/handsontable/dist/handsontable.full.min.js"></script>
|
|
60
|
+
<script src="https://cdn.jsdelivr.net/npm/@handsontable/vue3/dist/vue-handsontable.min.js"></script>
|
|
61
|
+
|
|
62
|
+
<link href="https://cdn.jsdelivr.net/npm/handsontable/dist/handsontable.full.min.css" rel="stylesheet">
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The component will be available as `Handsontable.vue.HotTable`.
|
|
66
|
+
|
|
67
|
+
### Usage
|
|
68
|
+
|
|
69
|
+
Use this data grid as you would any other component in your application. [Options](https://handsontable.com/docs/api/options/) can be set as `HotTable` props.
|
|
70
|
+
|
|
71
|
+
**Styles**
|
|
72
|
+
```css
|
|
73
|
+
@import '~handsontable/dist/handsontable.full.css';
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Vue 3 Component**
|
|
77
|
+
```vue
|
|
78
|
+
<template>
|
|
79
|
+
<hot-table :data="data" :rowHeaders="true" :colHeaders="true"></hot-table>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<script>
|
|
83
|
+
import { defineComponent } from 'vue';
|
|
84
|
+
import { HotTable } from '@handsontable/vue3';
|
|
85
|
+
import { registerAllModules } from 'handsontable/registry';
|
|
86
|
+
|
|
87
|
+
// register Handsontable's modules
|
|
88
|
+
registerAllModules();
|
|
89
|
+
|
|
90
|
+
export default defineComponent({
|
|
91
|
+
data() {
|
|
92
|
+
return {
|
|
93
|
+
data: [
|
|
94
|
+
['', 'Ford', 'Volvo', 'Toyota', 'Honda'],
|
|
95
|
+
['2016', 10, 11, 12, 13],
|
|
96
|
+
['2017', 20, 11, 14, 13],
|
|
97
|
+
['2018', 30, 15, 12, 13]
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
components: {
|
|
102
|
+
HotTable,
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<style src="handsontable/dist/handsontable.full.css"></style>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### [View live demo](https://handsontable.com/docs/vue3-simple-example/)
|
|
111
|
+
|
|
112
|
+
## Support
|
|
113
|
+
|
|
114
|
+
We provide support for developers working with commercial version via [contact form](https://handsontable.com/contact?category=technical_support)</a> or at support@handsontable.com.
|
|
115
|
+
|
|
116
|
+
If you use a non-commercial version then please ask your tagged question on [StackOverflow](https://stackoverflow.com/questions/tagged/handsontable).
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
Handsontable is a commercial software with two licenses available:
|
|
121
|
+
|
|
122
|
+
- Free for non-commercial purposes such as teaching, academic research, and evaluation. [Read it here](https://github.com/handsontable/handsontable/blob/master/handsontable-non-commercial-license.pdf).
|
|
123
|
+
- Commercial license with support and maintenance included. See [pricing plans](https://handsontable.com/pricing).
|
|
124
|
+
|
|
125
|
+
## License key
|
|
126
|
+
|
|
127
|
+
If you use Handsontable for Vue 3 in a project that supports your commercial activity, then you must purchase the license key at [handsontable.com](https://handsontable.com/pricing).
|
|
128
|
+
|
|
129
|
+
If you use the free for non-commercial license of Handsontable, then pass the phrase `'non-commercial-and-evaluation'`, as described in [this documentation](https://handsontable.com/docs/license-key/).
|
|
130
|
+
|
|
131
|
+
<br>
|
|
132
|
+
<br>
|
|
133
|
+
|
|
134
|
+
Proudly created and maintained by the [Handsontable Team](https://handsontable.com/team).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const HotColumn: import("vue").DefineComponent<import("./types").VueProps<import("./types").HotTableProps>, unknown, unknown, {}, {
|
|
2
|
+
/**
|
|
3
|
+
* Create the column settings based on the data provided to the `hot-column`
|
|
4
|
+
* component and it's child components.
|
|
5
|
+
*/
|
|
6
|
+
createColumnSettings(): void;
|
|
7
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<import("./types").VueProps<import("./types").HotTableProps>>>, {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
}>;
|
|
10
|
+
export default HotColumn;
|
|
11
|
+
export { HotColumn };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
import Handsontable from 'handsontable/base';
|
|
3
|
+
import { HotTableProps } from './types';
|
|
4
|
+
declare const HotTable: import("vue").DefineComponent<import("./types").VueProps<HotTableProps>, unknown, {
|
|
5
|
+
__hotInstance: Handsontable;
|
|
6
|
+
miscCache: {
|
|
7
|
+
currentSourceColumns: any;
|
|
8
|
+
};
|
|
9
|
+
columnSettings: HotTableProps[];
|
|
10
|
+
columnsCache: Map<VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>, HotTableProps>;
|
|
13
|
+
hotInstance: Handsontable;
|
|
14
|
+
}, {}, {
|
|
15
|
+
/**
|
|
16
|
+
* Initialize Handsontable.
|
|
17
|
+
*/
|
|
18
|
+
hotInit(): void;
|
|
19
|
+
matchHotMappersSize(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get settings for the columns provided in the `hot-column` components.
|
|
22
|
+
*
|
|
23
|
+
* @returns {HotTableProps[] | undefined}
|
|
24
|
+
*/
|
|
25
|
+
getColumnSettings(): HotTableProps[] | void;
|
|
26
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<import("./types").VueProps<HotTableProps>>>, {
|
|
27
|
+
[x: string]: any;
|
|
28
|
+
}>;
|
|
29
|
+
export default HotTable;
|
|
30
|
+
export { HotTable };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Handsontable from 'handsontable/base';
|
|
2
|
+
import { HotTableProps, VueProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
5
|
+
*/
|
|
6
|
+
export declare const HOT_DESTROYED_WARNING: string;
|
|
7
|
+
/**
|
|
8
|
+
* Check if at specified `key` there is any value for `object`.
|
|
9
|
+
*
|
|
10
|
+
* @param {object} object Object to search value at specyfic key.
|
|
11
|
+
* @param {string} key String key to check.
|
|
12
|
+
* @returns {boolean}
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasOwnProperty(object: unknown, key: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Generate an object containing all the available Handsontable properties and plugin hooks.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').
|
|
19
|
+
* @returns {object}
|
|
20
|
+
*/
|
|
21
|
+
export declare function propFactory(source: 'HotTable' | 'HotColumn'): VueProps<HotTableProps>;
|
|
22
|
+
/**
|
|
23
|
+
* Filter out all of the unassigned props, and return only the one passed to the component.
|
|
24
|
+
*
|
|
25
|
+
* @param {object} props Object containing all the possible props.
|
|
26
|
+
* @returns {object} Object containing only used props.
|
|
27
|
+
*/
|
|
28
|
+
export declare function filterPassedProps(props: any): VueProps<HotTableProps>;
|
|
29
|
+
/**
|
|
30
|
+
* Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component.
|
|
31
|
+
*
|
|
32
|
+
* @param {HotTableProps} props The props passed to the component.
|
|
33
|
+
* @param {Handsontable.GridSettings} currentSettings The current Handsontable settings.
|
|
34
|
+
* @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable.
|
|
35
|
+
*/
|
|
36
|
+
export declare function prepareSettings(props: HotTableProps, currentSettings?: Handsontable.GridSettings): HotTableProps;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Handsontable from 'handsontable/base';
|
|
2
|
+
export interface HotTableProps extends Handsontable.GridSettings {
|
|
3
|
+
id?: string;
|
|
4
|
+
settings?: Handsontable.GridSettings;
|
|
5
|
+
[additional: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export declare type VueProps<T> = {
|
|
8
|
+
[P in keyof T]: any;
|
|
9
|
+
};
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
var Handsontable = require('handsontable/base');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var Handsontable__default = /*#__PURE__*/_interopDefaultLegacy(Handsontable);
|
|
11
|
+
|
|
12
|
+
var unassignedPropSymbol = Symbol('unassigned');
|
|
13
|
+
/**
|
|
14
|
+
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
15
|
+
*/
|
|
16
|
+
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
|
|
17
|
+
/**
|
|
18
|
+
* Check if at specified `key` there is any value for `object`.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} object Object to search value at specyfic key.
|
|
21
|
+
* @param {string} key String key to check.
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
function hasOwnProperty(object, key) {
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(object, key);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generate an object containing all the available Handsontable properties and plugin hooks.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').
|
|
31
|
+
* @returns {object}
|
|
32
|
+
*/
|
|
33
|
+
function propFactory(source) {
|
|
34
|
+
var registeredHooks = Handsontable__default["default"].hooks.getRegistered();
|
|
35
|
+
var propSchema = {};
|
|
36
|
+
Object.assign(propSchema, Handsontable__default["default"].DefaultSettings);
|
|
37
|
+
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
38
|
+
for (var prop in propSchema) {
|
|
39
|
+
propSchema[prop] = {
|
|
40
|
+
"default": unassignedPropSymbol
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
for (var i = 0; i < registeredHooks.length; i++) {
|
|
44
|
+
propSchema[registeredHooks[i]] = {
|
|
45
|
+
"default": unassignedPropSymbol
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
propSchema.settings = {
|
|
49
|
+
"default": unassignedPropSymbol
|
|
50
|
+
};
|
|
51
|
+
if (source === 'HotTable') {
|
|
52
|
+
propSchema.id = {
|
|
53
|
+
type: String,
|
|
54
|
+
"default": "hot-".concat(Math.random().toString(36).substring(5))
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return propSchema;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Filter out all of the unassigned props, and return only the one passed to the component.
|
|
61
|
+
*
|
|
62
|
+
* @param {object} props Object containing all the possible props.
|
|
63
|
+
* @returns {object} Object containing only used props.
|
|
64
|
+
*/
|
|
65
|
+
function filterPassedProps(props) {
|
|
66
|
+
var filteredProps = {};
|
|
67
|
+
var columnSettingsProp = props.settings;
|
|
68
|
+
if (columnSettingsProp !== unassignedPropSymbol) {
|
|
69
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
70
|
+
for (var propName in columnSettingsProp) {
|
|
71
|
+
if (hasOwnProperty(columnSettingsProp, propName) && columnSettingsProp[propName] !== unassignedPropSymbol) {
|
|
72
|
+
filteredProps[propName] = columnSettingsProp[propName];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
77
|
+
for (var _propName in props) {
|
|
78
|
+
if (hasOwnProperty(props, _propName) && _propName !== 'settings' && props[_propName] !== unassignedPropSymbol) {
|
|
79
|
+
filteredProps[_propName] = props[_propName];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return filteredProps;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component.
|
|
86
|
+
*
|
|
87
|
+
* @param {HotTableProps} props The props passed to the component.
|
|
88
|
+
* @param {Handsontable.GridSettings} currentSettings The current Handsontable settings.
|
|
89
|
+
* @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable.
|
|
90
|
+
*/
|
|
91
|
+
function prepareSettings(props, currentSettings) {
|
|
92
|
+
var assignedProps = filterPassedProps(props);
|
|
93
|
+
var hotSettingsInProps = props.settings ? props.settings : assignedProps;
|
|
94
|
+
var additionalHotSettingsInProps = props.settings ? assignedProps : null;
|
|
95
|
+
var newSettings = {};
|
|
96
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
97
|
+
for (var key in hotSettingsInProps) {
|
|
98
|
+
if (hasOwnProperty(hotSettingsInProps, key) && hotSettingsInProps[key] !== void 0 && (currentSettings && key !== 'data' ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)) {
|
|
99
|
+
newSettings[key] = hotSettingsInProps[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
103
|
+
for (var _key in additionalHotSettingsInProps) {
|
|
104
|
+
if (hasOwnProperty(additionalHotSettingsInProps, _key) && _key !== 'id' && _key !== 'settings' && additionalHotSettingsInProps[_key] !== void 0 && (currentSettings && _key !== 'data' ? !simpleEqual(currentSettings[_key], additionalHotSettingsInProps[_key]) : true)) {
|
|
105
|
+
newSettings[_key] = additionalHotSettingsInProps[_key];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return newSettings;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Compare two objects using `JSON.stringify`.
|
|
112
|
+
* *Note: * As it's using the stringify function to compare objects, the property order in both objects is
|
|
113
|
+
* important. It will return `false` for the same objects, if they're defined in a different order.
|
|
114
|
+
*
|
|
115
|
+
* @param {object} objectA First object to compare.
|
|
116
|
+
* @param {object} objectB Second object to compare.
|
|
117
|
+
* @returns {boolean} `true` if they're the same, `false` otherwise.
|
|
118
|
+
*/
|
|
119
|
+
function simpleEqual(objectA, objectB) {
|
|
120
|
+
return JSON.stringify(objectA) === JSON.stringify(objectB);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var version="0.0.0-next-9ec04ce-20221121";
|
|
124
|
+
|
|
125
|
+
var HotTable = vue.defineComponent({
|
|
126
|
+
name: 'HotTable',
|
|
127
|
+
props: propFactory('HotTable'),
|
|
128
|
+
provide: function provide() {
|
|
129
|
+
return {
|
|
130
|
+
columnsCache: this.columnsCache
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
watch: {
|
|
134
|
+
$props: {
|
|
135
|
+
handler: function handler(props) {
|
|
136
|
+
var settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);
|
|
137
|
+
if (!this.hotInstance || settings === void 0) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (settings.data) {
|
|
141
|
+
if (this.hotInstance.isColumnModificationAllowed() || !this.hotInstance.isColumnModificationAllowed() && this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns) {
|
|
142
|
+
// If the dataset dimensions change, update the index mappers.
|
|
143
|
+
this.matchHotMappersSize();
|
|
144
|
+
// Data is automatically synchronized by reference.
|
|
145
|
+
delete settings.data;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// If there are another options changed, update the HOT settings, render the table otherwise.
|
|
149
|
+
if (Object.keys(settings).length) {
|
|
150
|
+
this.hotInstance.updateSettings(settings);
|
|
151
|
+
} else {
|
|
152
|
+
this.hotInstance.render();
|
|
153
|
+
}
|
|
154
|
+
this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();
|
|
155
|
+
},
|
|
156
|
+
deep: true,
|
|
157
|
+
immediate: true
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
data: function data() {
|
|
161
|
+
return {
|
|
162
|
+
/* eslint-disable vue/no-reserved-keys */
|
|
163
|
+
__hotInstance: null,
|
|
164
|
+
/* eslint-enable vue/no-reserved-keys */
|
|
165
|
+
miscCache: {
|
|
166
|
+
currentSourceColumns: null
|
|
167
|
+
},
|
|
168
|
+
columnSettings: null,
|
|
169
|
+
columnsCache: new Map(),
|
|
170
|
+
get hotInstance() {
|
|
171
|
+
if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) {
|
|
172
|
+
// Will return the Handsontable instance or `null` if it's not yet been created.
|
|
173
|
+
return this.__hotInstance;
|
|
174
|
+
} else {
|
|
175
|
+
/* eslint-disable-next-line no-console */
|
|
176
|
+
console.warn(HOT_DESTROYED_WARNING);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
set hotInstance(hotInstance) {
|
|
181
|
+
this.__hotInstance = hotInstance;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
methods: {
|
|
186
|
+
/**
|
|
187
|
+
* Initialize Handsontable.
|
|
188
|
+
*/
|
|
189
|
+
hotInit: function hotInit() {
|
|
190
|
+
var newSettings = prepareSettings(this.$props);
|
|
191
|
+
newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;
|
|
192
|
+
this.hotInstance = vue.markRaw(new Handsontable__default["default"].Core(this.$el, newSettings));
|
|
193
|
+
this.hotInstance.init();
|
|
194
|
+
this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();
|
|
195
|
+
},
|
|
196
|
+
matchHotMappersSize: function matchHotMappersSize() {
|
|
197
|
+
var _this = this;
|
|
198
|
+
if (!this.hotInstance) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
var data = this.hotInstance.getSourceData();
|
|
202
|
+
var rowsToRemove = [];
|
|
203
|
+
var columnsToRemove = [];
|
|
204
|
+
var indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();
|
|
205
|
+
var isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();
|
|
206
|
+
var indexMapperColumnCount = 0;
|
|
207
|
+
if (data && data.length !== indexMapperRowCount) {
|
|
208
|
+
if (data.length < indexMapperRowCount) {
|
|
209
|
+
for (var r = data.length; r < indexMapperRowCount; r++) {
|
|
210
|
+
rowsToRemove.push(r);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (isColumnModificationAllowed) {
|
|
215
|
+
var _data$;
|
|
216
|
+
indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();
|
|
217
|
+
if (data && data[0] && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.length) !== indexMapperColumnCount) {
|
|
218
|
+
if (data[0].length < indexMapperColumnCount) {
|
|
219
|
+
for (var c = data[0].length; c < indexMapperColumnCount; c++) {
|
|
220
|
+
columnsToRemove.push(c);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
this.hotInstance.batch(function () {
|
|
226
|
+
if (rowsToRemove.length > 0) {
|
|
227
|
+
_this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);
|
|
228
|
+
} else {
|
|
229
|
+
_this.hotInstance.rowIndexMapper.insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);
|
|
230
|
+
}
|
|
231
|
+
if (isColumnModificationAllowed && data.length !== 0) {
|
|
232
|
+
if (columnsToRemove.length > 0) {
|
|
233
|
+
_this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);
|
|
234
|
+
} else {
|
|
235
|
+
_this.hotInstance.columnIndexMapper.insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
/**
|
|
241
|
+
* Get settings for the columns provided in the `hot-column` components.
|
|
242
|
+
*
|
|
243
|
+
* @returns {HotTableProps[] | undefined}
|
|
244
|
+
*/
|
|
245
|
+
getColumnSettings: function getColumnSettings() {
|
|
246
|
+
var columnSettings = Array.from(this.columnsCache.values());
|
|
247
|
+
return columnSettings.length ? columnSettings : void 0;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
mounted: function mounted() {
|
|
251
|
+
this.columnSettings = this.getColumnSettings();
|
|
252
|
+
this.hotInit();
|
|
253
|
+
},
|
|
254
|
+
beforeUnmount: function beforeUnmount() {
|
|
255
|
+
if (this.hotInstance) {
|
|
256
|
+
this.hotInstance.destroy();
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
version: version
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
var _hoisted_1 = ["id"];
|
|
263
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
264
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
265
|
+
id: _ctx.id
|
|
266
|
+
}, [vue.renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
HotTable.render = render;
|
|
270
|
+
HotTable.__file = "src/HotTable.vue";
|
|
271
|
+
|
|
272
|
+
function ownKeys(object, enumerableOnly) {
|
|
273
|
+
var keys = Object.keys(object);
|
|
274
|
+
if (Object.getOwnPropertySymbols) {
|
|
275
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
276
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
277
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
278
|
+
})), keys.push.apply(keys, symbols);
|
|
279
|
+
}
|
|
280
|
+
return keys;
|
|
281
|
+
}
|
|
282
|
+
function _objectSpread2(target) {
|
|
283
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
284
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
285
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
286
|
+
_defineProperty(target, key, source[key]);
|
|
287
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
288
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return target;
|
|
292
|
+
}
|
|
293
|
+
function _defineProperty(obj, key, value) {
|
|
294
|
+
if (key in obj) {
|
|
295
|
+
Object.defineProperty(obj, key, {
|
|
296
|
+
value: value,
|
|
297
|
+
enumerable: true,
|
|
298
|
+
configurable: true,
|
|
299
|
+
writable: true
|
|
300
|
+
});
|
|
301
|
+
} else {
|
|
302
|
+
obj[key] = value;
|
|
303
|
+
}
|
|
304
|
+
return obj;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
var HotColumn = vue.defineComponent({
|
|
308
|
+
name: 'HotColumn',
|
|
309
|
+
props: propFactory('HotColumn'),
|
|
310
|
+
inject: ['columnsCache'],
|
|
311
|
+
methods: {
|
|
312
|
+
/**
|
|
313
|
+
* Create the column settings based on the data provided to the `hot-column`
|
|
314
|
+
* component and it's child components.
|
|
315
|
+
*/
|
|
316
|
+
createColumnSettings: function createColumnSettings() {
|
|
317
|
+
var assignedProps = filterPassedProps(this.$props);
|
|
318
|
+
var columnSettings = _objectSpread2({}, assignedProps);
|
|
319
|
+
if (assignedProps.renderer) {
|
|
320
|
+
columnSettings.renderer = assignedProps.renderer;
|
|
321
|
+
}
|
|
322
|
+
if (assignedProps.editor) {
|
|
323
|
+
columnSettings.editor = assignedProps.editor;
|
|
324
|
+
}
|
|
325
|
+
this.columnsCache.set(this, columnSettings);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
mounted: function mounted() {
|
|
329
|
+
this.createColumnSettings();
|
|
330
|
+
},
|
|
331
|
+
unmounted: function unmounted() {
|
|
332
|
+
this.columnsCache["delete"](this);
|
|
333
|
+
},
|
|
334
|
+
render: function render() {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
HotColumn.__file = "src/HotColumn.vue";
|
|
340
|
+
|
|
341
|
+
exports.HotColumn = HotColumn;
|
|
342
|
+
exports.HotTable = HotTable;
|
|
343
|
+
exports["default"] = HotTable;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const HotColumn: import("vue").DefineComponent<import("./types").VueProps<import("./types").HotTableProps>, unknown, unknown, {}, {
|
|
2
|
+
/**
|
|
3
|
+
* Create the column settings based on the data provided to the `hot-column`
|
|
4
|
+
* component and it's child components.
|
|
5
|
+
*/
|
|
6
|
+
createColumnSettings(): void;
|
|
7
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<import("./types").VueProps<import("./types").HotTableProps>>>, {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
}>;
|
|
10
|
+
export default HotColumn;
|
|
11
|
+
export { HotColumn };
|