slickgrid-react 4.0.2 → 4.1.0
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/README.md +3 -0
- package/dist/cjs/components/slickgrid-react.js +4 -3
- package/dist/cjs/components/slickgrid-react.js.map +1 -1
- package/dist/esm/components/slickgrid-react.js +5 -4
- package/dist/esm/components/slickgrid-react.js.map +1 -1
- package/dist/types/components/slickgrid-react.d.ts.map +1 -1
- package/package.json +23 -18
- package/src/slickgrid-react/components/slickgrid-react.tsx +1600 -0
- package/src/slickgrid-react/components/slickgridEventAggregator.ts +12 -0
- package/src/slickgrid-react/components/slickgridReactProps.ts +195 -0
- package/src/slickgrid-react/constants.ts +89 -0
- package/src/slickgrid-react/global-grid-options.ts +262 -0
- package/src/slickgrid-react/index.ts +30 -0
- package/src/slickgrid-react/models/gridOption.interface.ts +7 -0
- package/src/slickgrid-react/models/index.ts +4 -0
- package/src/slickgrid-react/models/reactComponentOutput.interface.ts +7 -0
- package/src/slickgrid-react/models/slickGrid.interface.ts +7 -0
- package/src/slickgrid-react/models/slickgridReactInstance.interface.ts +71 -0
- package/src/slickgrid-react/services/container.service.ts +13 -0
- package/src/slickgrid-react/services/index.ts +4 -0
- package/src/slickgrid-react/services/reactUtil.service.ts +26 -0
- package/src/slickgrid-react/services/singletons.ts +7 -0
- package/src/slickgrid-react/services/translater.service.ts +36 -0
- package/src/slickgrid-react/services/utilities.ts +18 -0
- package/src/slickgrid-react/slickgrid-config.ts +10 -0
- package/.gitbook.yaml +0 -5
- package/global.d.ts +0 -2
- package/tsconfig.json +0 -44
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BackendService,
|
|
3
|
+
ExtensionService,
|
|
4
|
+
FilterService,
|
|
5
|
+
GridEventService,
|
|
6
|
+
GridService,
|
|
7
|
+
GridStateService,
|
|
8
|
+
GroupingAndColspanService,
|
|
9
|
+
PaginationService,
|
|
10
|
+
ResizerService,
|
|
11
|
+
SlickDataView,
|
|
12
|
+
SortService,
|
|
13
|
+
TreeDataService
|
|
14
|
+
} from '@slickgrid-universal/common';
|
|
15
|
+
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
16
|
+
|
|
17
|
+
import { SlickGrid } from '../models/index';
|
|
18
|
+
|
|
19
|
+
export interface SlickgridReactInstance {
|
|
20
|
+
element: HTMLDivElement;
|
|
21
|
+
|
|
22
|
+
/** Slick DataView object */
|
|
23
|
+
dataView: SlickDataView;
|
|
24
|
+
|
|
25
|
+
/** Slick Grid object */
|
|
26
|
+
slickGrid: SlickGrid;
|
|
27
|
+
|
|
28
|
+
// --
|
|
29
|
+
// Methods
|
|
30
|
+
/** Dispose of the grid and optionally empty the DOM element grid container as well */
|
|
31
|
+
dispose: (emptyDomElementContainer?: boolean) => void;
|
|
32
|
+
|
|
33
|
+
// --
|
|
34
|
+
// Services
|
|
35
|
+
|
|
36
|
+
/** Backend Service, when available */
|
|
37
|
+
backendService?: BackendService;
|
|
38
|
+
|
|
39
|
+
/** EventPubSub Service instance that is used internal by the lib and could be used externally to subscribe to Slickgrid-React events */
|
|
40
|
+
eventPubSubService?: EventPubSubService;
|
|
41
|
+
|
|
42
|
+
/** Extension (Plugins & Controls) Service */
|
|
43
|
+
extensionService: ExtensionService;
|
|
44
|
+
|
|
45
|
+
/** Filter Service */
|
|
46
|
+
filterService: FilterService;
|
|
47
|
+
|
|
48
|
+
/** Grid Service (grid extra functionalities) */
|
|
49
|
+
gridService: GridService;
|
|
50
|
+
|
|
51
|
+
/** Grid Events Service */
|
|
52
|
+
gridEventService: GridEventService;
|
|
53
|
+
|
|
54
|
+
/** Grid State Service */
|
|
55
|
+
gridStateService: GridStateService;
|
|
56
|
+
|
|
57
|
+
/** Grouping (and colspan) Service */
|
|
58
|
+
groupingService: GroupingAndColspanService;
|
|
59
|
+
|
|
60
|
+
/** Pagination Service (allows you to programmatically go to first/last page, etc...) */
|
|
61
|
+
paginationService?: PaginationService;
|
|
62
|
+
|
|
63
|
+
/** Resizer Service (including auto-resize) */
|
|
64
|
+
resizerService: ResizerService;
|
|
65
|
+
|
|
66
|
+
/** Sort Service */
|
|
67
|
+
sortService: SortService;
|
|
68
|
+
|
|
69
|
+
/** Tree Data View Service */
|
|
70
|
+
treeDataService: TreeDataService;
|
|
71
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContainerService as UniversalContainerService } from '@slickgrid-universal/common';
|
|
2
|
+
|
|
3
|
+
export class ContainerService implements UniversalContainerService {
|
|
4
|
+
private readonly container: { [key: string]: any } = {};
|
|
5
|
+
|
|
6
|
+
get<T = any>(key: string): T | null {
|
|
7
|
+
return this.container[key];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
registerInstance(key: string, instance: any) {
|
|
11
|
+
this.container[key] = instance;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { SlickgridReactComponentOutput } from '../models/reactComponentOutput.interface';
|
|
4
|
+
|
|
5
|
+
export class ReactUtilService {
|
|
6
|
+
createReactComponentAppendToDom(component: any, targetElement?: HTMLElement | Element, clearTargetContent = false, props: any = undefined, children: ReactNode[] = []): SlickgridReactComponentOutput {
|
|
7
|
+
const componentElement = React.createElement(component, props, children);
|
|
8
|
+
let componentInstance: any;
|
|
9
|
+
|
|
10
|
+
// Append DOM element to the HTML element specified
|
|
11
|
+
if (targetElement) {
|
|
12
|
+
if (clearTargetContent && targetElement.innerHTML) {
|
|
13
|
+
targetElement.innerHTML = '';
|
|
14
|
+
}
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
componentInstance = ReactDOM.render(componentElement, targetElement);
|
|
17
|
+
} else {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
componentInstance = ReactDOM.render(componentElement, document.body);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const domElement = ReactDOM.findDOMNode(componentInstance);
|
|
23
|
+
|
|
24
|
+
return { componentInstance, componentElement, domElement };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SharedService } from '@slickgrid-universal/common';
|
|
2
|
+
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
3
|
+
import { ContainerService } from './container.service';
|
|
4
|
+
|
|
5
|
+
export const GlobalEventPubSubService = new EventPubSubService();
|
|
6
|
+
export const GlobalEventSharedService = new SharedService();
|
|
7
|
+
export const GlobalContainerService = new ContainerService();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TranslaterService as UniversalTranslateService } from '@slickgrid-universal/common';
|
|
2
|
+
import i18next, { i18n } from 'i18next';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This is a Translate Service Wrapper for Slickgrid-Universal monorepo lib to work properly,
|
|
6
|
+
* it must implement Slickgrid-Universal TranslaterService interface to work properly
|
|
7
|
+
*/
|
|
8
|
+
export class TranslaterService implements UniversalTranslateService {
|
|
9
|
+
private readonly i18n: i18n = i18next;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Method to return the current language used by the App
|
|
13
|
+
* @return {string} current language
|
|
14
|
+
*/
|
|
15
|
+
getCurrentLanguage(): string {
|
|
16
|
+
return this.i18n.language;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Method to set the language to use in the App and Translate Service
|
|
21
|
+
* @param {string} language
|
|
22
|
+
* @return {Promise} output
|
|
23
|
+
*/
|
|
24
|
+
async use(newLang: string): Promise<any> {
|
|
25
|
+
return this.i18n.changeLanguage(newLang);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Method which receives a translation key and returns the translated value assigned to that key
|
|
30
|
+
* @param {string} translation key
|
|
31
|
+
* @return {string} translated value
|
|
32
|
+
*/
|
|
33
|
+
translate(translationKey: string): string {
|
|
34
|
+
return this.i18n.t(translationKey);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventSubscription } from '@slickgrid-universal/common';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Loop through and dispose of all subscriptions when they are disposable
|
|
5
|
+
* @param subscriptions
|
|
6
|
+
* @return empty array
|
|
7
|
+
*/
|
|
8
|
+
export function disposeAllSubscriptions(subscriptions: Array<EventSubscription>): Array<EventSubscription> {
|
|
9
|
+
if (Array.isArray(subscriptions)) {
|
|
10
|
+
while (subscriptions.length > 0) {
|
|
11
|
+
const subscription = subscriptions.pop() as EventSubscription;
|
|
12
|
+
if ((subscription as EventSubscription)?.unsubscribe) {
|
|
13
|
+
(subscription as EventSubscription).unsubscribe!();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return subscriptions;
|
|
18
|
+
}
|
package/.gitbook.yaml
DELETED
package/global.d.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compileOnSave": false,
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es2018",
|
|
5
|
-
"module": "esnext",
|
|
6
|
-
"sourceMap": true,
|
|
7
|
-
"allowSyntheticDefaultImports": true,
|
|
8
|
-
"downlevelIteration": true,
|
|
9
|
-
"emitDecoratorMetadata": true,
|
|
10
|
-
"experimentalDecorators": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"allowJs": true,
|
|
14
|
-
"baseUrl": "src",
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"strict": true,
|
|
18
|
-
"jsx": "react",
|
|
19
|
-
"lib": [
|
|
20
|
-
"es2018",
|
|
21
|
-
"dom"
|
|
22
|
-
],
|
|
23
|
-
"typeRoots": [
|
|
24
|
-
"node_modules/@types",
|
|
25
|
-
"src/typings"
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
"exclude": [
|
|
29
|
-
"react_project",
|
|
30
|
-
"dist",
|
|
31
|
-
"node_modules",
|
|
32
|
-
"**/*.spec.ts"
|
|
33
|
-
],
|
|
34
|
-
"filesGlob": [
|
|
35
|
-
"./src/**/*.ts",
|
|
36
|
-
"./test/**/*.ts",
|
|
37
|
-
"./custom_typings/**/*.d.ts"
|
|
38
|
-
],
|
|
39
|
-
"include": [
|
|
40
|
-
"src/**/*.ts",
|
|
41
|
-
"src/typings/**/*.ts"
|
|
42
|
-
],
|
|
43
|
-
"typeAcquisition": { "include": ["jest"] }
|
|
44
|
-
}
|