@revolist/react-datagrid 3.6.17 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/editor.adapter.d.ts +22 -0
  4. package/dist/editor.d.ts +10 -0
  5. package/dist/index.d.ts +6 -0
  6. package/dist/react-component-lib/createComponent.d.ts +3 -2
  7. package/dist/react-component-lib/createOverlayComponent.d.ts +3 -2
  8. package/dist/react-component-lib/utils/attachProps.d.ts +5 -1
  9. package/dist/react-component-lib/utils/index.d.ts +3 -2
  10. package/dist/react-datagrid.js +255 -0
  11. package/dist/react-datagrid.umd.cjs +255 -0
  12. package/dist/renderer.d.ts +16 -0
  13. package/dist/revogrid.d.ts +3 -15
  14. package/package.json +69 -32
  15. package/dist/react-component-lib/createComponent.js +0 -75
  16. package/dist/react-component-lib/createComponent.js.map +0 -1
  17. package/dist/react-component-lib/createOverlayComponent.js +0 -109
  18. package/dist/react-component-lib/createOverlayComponent.js.map +0 -1
  19. package/dist/react-component-lib/index.js +0 -3
  20. package/dist/react-component-lib/index.js.map +0 -1
  21. package/dist/react-component-lib/interfaces.js +0 -2
  22. package/dist/react-component-lib/interfaces.js.map +0 -1
  23. package/dist/react-component-lib/utils/attachProps.js +0 -98
  24. package/dist/react-component-lib/utils/attachProps.js.map +0 -1
  25. package/dist/react-component-lib/utils/case.js +0 -7
  26. package/dist/react-component-lib/utils/case.js.map +0 -1
  27. package/dist/react-component-lib/utils/dev.js +0 -13
  28. package/dist/react-component-lib/utils/dev.js.map +0 -1
  29. package/dist/react-component-lib/utils/index.js +0 -34
  30. package/dist/react-component-lib/utils/index.js.map +0 -1
  31. package/dist/revogrid.js +0 -18
  32. package/dist/revogrid.js.map +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Revolist OU
3
+ Copyright (c) 2024 Revolist OU
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -125,4 +125,4 @@ export default class App extends React.Component {
125
125
  }
126
126
  ```
127
127
 
128
- Check [Sandbox](https://codesandbox.io/s/react-datagrid-g3ygo?file=/src/App.js) for real live sample.
128
+ Check [Sandbox](https://codesandbox.io/s/react-datagrid-g3ygo?file=/src/App.js) for real live sample.
@@ -0,0 +1,22 @@
1
+ import { EditCell, ColumnDataSchemaModel, HyperFunc, VNode, SaveData } from '@revolist/revogrid';
2
+ import { ReactElement } from './renderer';
3
+ import { ComponentType } from 'react';
4
+
5
+ export type EditorType = {
6
+ save: (value: SaveData, preventFocus?: boolean) => void;
7
+ close: (focusNext?: boolean) => void;
8
+ column: ColumnDataSchemaModel;
9
+ } & Partial<EditCell>;
10
+ export declare class EditorAdapter {
11
+ private EditorComponent;
12
+ column: ColumnDataSchemaModel;
13
+ private save;
14
+ private close;
15
+ element: ReactElement | null;
16
+ editCell: EditCell | null;
17
+ private renderedComponent;
18
+ constructor(EditorComponent: ComponentType<EditorType>, column: ColumnDataSchemaModel, save: (value: SaveData, preventFocus?: boolean) => void, close: (focusNext?: boolean) => void);
19
+ componentDidRender(): void;
20
+ disconnectedCallback(): void;
21
+ render(h: HyperFunc<VNode>): VNode;
22
+ }
@@ -0,0 +1,10 @@
1
+ import { EditorCtr } from '@revolist/revogrid';
2
+ import { ComponentType } from 'react';
3
+ import { EditorType } from './editor.adapter';
4
+
5
+ /**
6
+ * Create editor constructor.
7
+ * This function creates editor constructor by wrapping it with EditorAdapter
8
+ * which is responsible for connecting editor with grid.
9
+ */
10
+ export declare const Editor: (EditorComponent: ComponentType<EditorType>) => EditorCtr;
@@ -0,0 +1,6 @@
1
+ import { JSX } from '@revolist/revogrid';
2
+
3
+ export declare const RevoGrid: import('react').ForwardRefExoticComponent<JSX.RevoGrid & Omit<import('react').HTMLAttributes<HTMLRevoGridElement>, "style"> & import('./react-component-lib/interfaces').StyleReactProps & import('react').RefAttributes<HTMLRevoGridElement>>;
4
+ export { Template, type ReactElement, type RenderedComponent, } from './renderer';
5
+ export { Editor } from './editor';
6
+ export { type EditorType, EditorAdapter } from './editor.adapter';
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import { default as React } from 'react';
2
+
2
3
  export interface HTMLStencilElement extends HTMLElement {
3
4
  componentOnReady(): Promise<this>;
4
5
  }
@@ -6,5 +7,5 @@ interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<El
6
7
  forwardedRef: React.RefObject<ElementType>;
7
8
  ref?: React.Ref<any>;
8
9
  }
9
- export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
10
+ export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import('./utils').StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
10
11
  export {};
@@ -1,6 +1,7 @@
1
- import React from 'react';
1
+ import { default as React } from 'react';
2
2
  import { OverlayEventDetail } from './interfaces';
3
3
  import { StencilReactForwardedRef } from './utils';
4
+
4
5
  interface OverlayElement extends HTMLElement {
5
6
  present: () => Promise<void>;
6
7
  dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;
@@ -16,6 +17,6 @@ export interface ReactOverlayProps {
16
17
  export declare const createOverlayComponent: <OverlayComponent extends object, OverlayType extends OverlayElement>(tagName: string, controller: {
17
18
  create: (options: any) => Promise<OverlayType>;
18
19
  }, customElement?: any) => React.ForwardRefExoticComponent<React.PropsWithoutRef<OverlayComponent & ReactOverlayProps & {
19
- forwardedRef?: StencilReactForwardedRef<OverlayType>;
20
+ forwardedRef?: StencilReactForwardedRef<OverlayType> | undefined;
20
21
  }> & React.RefAttributes<OverlayType>>;
21
22
  export {};
@@ -1,5 +1,9 @@
1
1
  export declare const attachProps: (node: HTMLElement, newProps: any, oldProps?: any) => void;
2
2
  export declare const getClassName: (classList: DOMTokenList, newProps: any, oldProps: any) => string;
3
+ /**
4
+ * Transforms a React event name to a browser event name.
5
+ */
6
+ export declare const transformReactEventName: (eventNameSuffix: string) => string;
3
7
  /**
4
8
  * Checks if an event is supported in the current execution environment.
5
9
  * @license Modernizr 3.0.0pre (Custom Build) | MIT
@@ -7,6 +11,6 @@ export declare const getClassName: (classList: DOMTokenList, newProps: any, oldP
7
11
  export declare const isCoveredByReact: (eventNameSuffix: string) => boolean;
8
12
  export declare const syncEvent: (node: Element & {
9
13
  __events?: {
10
- [key: string]: (e: Event) => any;
14
+ [key: string]: ((e: Event) => any) | undefined;
11
15
  };
12
16
  }, eventName: string, newEventHandler?: (e: Event) => any) => void;
@@ -1,5 +1,6 @@
1
- import React from 'react';
2
- import type { StyleReactProps } from '../interfaces';
1
+ import { default as React } from 'react';
2
+ import { StyleReactProps } from '../interfaces';
3
+
3
4
  export type StencilReactExternalProps<PropType, ElementType> = PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & StyleReactProps;
4
5
  export type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
5
6
  export declare const setRef: (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => void;
@@ -0,0 +1,255 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { defineCustomElements } from "@revolist/revogrid/loader";
8
+ import { createRoot } from "/Users/maks/Projects/revogrid/packages/react/node_modules/react-dom/client.js";
9
+ import React, { createElement } from "react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ const dashToPascalCase = (str) => str.toLowerCase().split("-").map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("");
12
+ const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
13
+ const attachProps = (node, newProps, oldProps = {}) => {
14
+ if (node instanceof Element) {
15
+ const className = getClassName(node.classList, newProps, oldProps);
16
+ if (className !== "") {
17
+ node.className = className;
18
+ }
19
+ Object.keys(newProps).forEach((name) => {
20
+ if (name === "children" || name === "style" || name === "ref" || name === "class" || name === "className" || name === "forwardedRef") {
21
+ return;
22
+ }
23
+ if (name.indexOf("on") === 0 && name[2] === name[2].toUpperCase()) {
24
+ const eventName = name.substring(2);
25
+ const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
26
+ if (!isCoveredByReact(eventNameLc)) {
27
+ syncEvent(node, eventNameLc, newProps[name]);
28
+ }
29
+ } else {
30
+ node[name] = newProps[name];
31
+ const propType = typeof newProps[name];
32
+ if (propType === "string") {
33
+ node.setAttribute(camelToDashCase(name), newProps[name]);
34
+ }
35
+ }
36
+ });
37
+ }
38
+ };
39
+ const getClassName = (classList, newProps, oldProps) => {
40
+ const newClassProp = newProps.className || newProps.class;
41
+ const oldClassProp = oldProps.className || oldProps.class;
42
+ const currentClasses = arrayToMap(classList);
43
+ const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(" ") : []);
44
+ const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(" ") : []);
45
+ const finalClassNames = [];
46
+ currentClasses.forEach((currentClass) => {
47
+ if (incomingPropClasses.has(currentClass)) {
48
+ finalClassNames.push(currentClass);
49
+ incomingPropClasses.delete(currentClass);
50
+ } else if (!oldPropClasses.has(currentClass)) {
51
+ finalClassNames.push(currentClass);
52
+ }
53
+ });
54
+ incomingPropClasses.forEach((s) => finalClassNames.push(s));
55
+ return finalClassNames.join(" ");
56
+ };
57
+ const transformReactEventName = (eventNameSuffix) => {
58
+ switch (eventNameSuffix) {
59
+ case "doubleclick":
60
+ return "dblclick";
61
+ }
62
+ return eventNameSuffix;
63
+ };
64
+ /**
65
+ * Checks if an event is supported in the current execution environment.
66
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
67
+ */
68
+ const isCoveredByReact = (eventNameSuffix) => {
69
+ if (typeof document === "undefined") {
70
+ return true;
71
+ } else {
72
+ const eventName = "on" + transformReactEventName(eventNameSuffix);
73
+ let isSupported = eventName in document;
74
+ if (!isSupported) {
75
+ const element = document.createElement("div");
76
+ element.setAttribute(eventName, "return;");
77
+ isSupported = typeof element[eventName] === "function";
78
+ }
79
+ return isSupported;
80
+ }
81
+ };
82
+ const syncEvent = (node, eventName, newEventHandler) => {
83
+ const eventStore = node.__events || (node.__events = {});
84
+ const oldEventHandler = eventStore[eventName];
85
+ if (oldEventHandler) {
86
+ node.removeEventListener(eventName, oldEventHandler);
87
+ }
88
+ node.addEventListener(
89
+ eventName,
90
+ eventStore[eventName] = function handler(e) {
91
+ if (newEventHandler) {
92
+ newEventHandler.call(this, e);
93
+ }
94
+ }
95
+ );
96
+ };
97
+ const arrayToMap = (arr) => {
98
+ const map = /* @__PURE__ */ new Map();
99
+ arr.forEach((s) => map.set(s, s));
100
+ return map;
101
+ };
102
+ const setRef = (ref, value) => {
103
+ if (typeof ref === "function") {
104
+ ref(value);
105
+ } else if (ref != null) {
106
+ ref.current = value;
107
+ }
108
+ };
109
+ const mergeRefs = (...refs) => {
110
+ return (value) => {
111
+ refs.forEach((ref) => {
112
+ setRef(ref, value);
113
+ });
114
+ };
115
+ };
116
+ const createForwardRef = (ReactComponent, displayName) => {
117
+ const forwardRef = (props, ref) => {
118
+ return /* @__PURE__ */ jsx(ReactComponent, { ...props, forwardedRef: ref });
119
+ };
120
+ forwardRef.displayName = displayName;
121
+ return React.forwardRef(forwardRef);
122
+ };
123
+ const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
124
+ if (defineCustomElement !== void 0) {
125
+ defineCustomElement();
126
+ }
127
+ const displayName = dashToPascalCase(tagName);
128
+ const ReactComponent = class extends React.Component {
129
+ constructor(props) {
130
+ super(props);
131
+ __publicField(this, "componentEl");
132
+ __publicField(this, "setComponentElRef", (element) => {
133
+ this.componentEl = element;
134
+ });
135
+ }
136
+ componentDidMount() {
137
+ this.componentDidUpdate(this.props);
138
+ }
139
+ componentDidUpdate(prevProps) {
140
+ attachProps(this.componentEl, this.props, prevProps);
141
+ }
142
+ render() {
143
+ const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
144
+ let propsToPass = Object.keys(cProps).reduce((acc, name) => {
145
+ const value = cProps[name];
146
+ if (name.indexOf("on") === 0 && name[2] === name[2].toUpperCase()) {
147
+ const eventName = name.substring(2).toLowerCase();
148
+ if (typeof document !== "undefined" && isCoveredByReact(eventName)) {
149
+ acc[name] = value;
150
+ }
151
+ } else {
152
+ const type = typeof value;
153
+ if (type === "string" || type === "boolean" || type === "number") {
154
+ acc[camelToDashCase(name)] = value;
155
+ }
156
+ }
157
+ return acc;
158
+ }, {});
159
+ const newProps = {
160
+ ...propsToPass,
161
+ ref: mergeRefs(forwardedRef, this.setComponentElRef),
162
+ style
163
+ };
164
+ return createElement(tagName, newProps, children);
165
+ }
166
+ static get displayName() {
167
+ return displayName;
168
+ }
169
+ };
170
+ return createForwardRef(ReactComponent, displayName);
171
+ };
172
+ function TemplateConstructor(el, ReactComponent, initialProps, lastEl = null) {
173
+ var _a;
174
+ if (!el) {
175
+ (_a = lastEl == null ? void 0 : lastEl.destroy) == null ? void 0 : _a.call(lastEl);
176
+ return null;
177
+ }
178
+ if (!el._root) {
179
+ el._root = createRoot(el);
180
+ }
181
+ const renderComponent = (props) => {
182
+ var _a2;
183
+ const vNode = createElement(ReactComponent, props);
184
+ (_a2 = el._root) == null ? void 0 : _a2.render(vNode);
185
+ };
186
+ renderComponent(initialProps);
187
+ const update = (newProps) => {
188
+ renderComponent(newProps);
189
+ };
190
+ const destroy = () => {
191
+ var _a2;
192
+ (_a2 = el._root) == null ? void 0 : _a2.unmount();
193
+ el._root = void 0;
194
+ };
195
+ return { update, destroy };
196
+ }
197
+ const Template = (ReactComponent, customProps) => {
198
+ return (h, p, addition) => {
199
+ const props = customProps ? { ...customProps, ...p } : p;
200
+ props.addition = addition;
201
+ let lastEl = null;
202
+ return h("span", {
203
+ ref: (el) => {
204
+ lastEl = TemplateConstructor(el, ReactComponent, props, lastEl);
205
+ }
206
+ });
207
+ };
208
+ };
209
+ class EditorAdapter {
210
+ constructor(EditorComponent, column, save, close) {
211
+ __publicField(this, "element", null);
212
+ __publicField(this, "editCell", null);
213
+ __publicField(this, "renderedComponent", null);
214
+ this.EditorComponent = EditorComponent;
215
+ this.column = column;
216
+ this.save = save;
217
+ this.close = close;
218
+ }
219
+ // optional, called after editor rendered
220
+ componentDidRender() {
221
+ }
222
+ // optional, called after editor destroyed
223
+ disconnectedCallback() {
224
+ var _a;
225
+ (_a = this.renderedComponent) == null ? void 0 : _a.destroy();
226
+ this.renderedComponent = null;
227
+ }
228
+ render(h) {
229
+ return h("span", {
230
+ ref: (el) => this.renderedComponent = TemplateConstructor(
231
+ el,
232
+ this.EditorComponent,
233
+ {
234
+ ...this.editCell,
235
+ column: this.column,
236
+ save: this.save,
237
+ close: this.close
238
+ },
239
+ this.renderedComponent
240
+ )
241
+ });
242
+ }
243
+ }
244
+ const Editor = (EditorComponent) => {
245
+ return function(column, save, close) {
246
+ return new EditorAdapter(EditorComponent, column, save, close);
247
+ };
248
+ };
249
+ const RevoGrid = /* @__PURE__ */ createReactComponent("revo-grid", void 0, void 0, defineCustomElements);
250
+ export {
251
+ Editor,
252
+ EditorAdapter,
253
+ RevoGrid,
254
+ Template
255
+ };
@@ -0,0 +1,255 @@
1
+ (function(global, factory) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@revolist/revogrid/loader"), require("/Users/maks/Projects/revogrid/packages/react/node_modules/react-dom/client.js"), require("react"), require("react/jsx-runtime")) : typeof define === "function" && define.amd ? define(["exports", "@revolist/revogrid/loader", "/Users/maks/Projects/revogrid/packages/react/node_modules/react-dom/client.js", "react", "react/jsx-runtime"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.ReactDatagrid = {}, global.loader, global.client_js, global.React, global.jsxRuntime));
3
+ })(this, function(exports2, loader, client_js, React, jsxRuntime) {
4
+ "use strict";var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => {
7
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
+ return value;
9
+ };
10
+
11
+ const dashToPascalCase = (str) => str.toLowerCase().split("-").map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("");
12
+ const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
13
+ const attachProps = (node, newProps, oldProps = {}) => {
14
+ if (node instanceof Element) {
15
+ const className = getClassName(node.classList, newProps, oldProps);
16
+ if (className !== "") {
17
+ node.className = className;
18
+ }
19
+ Object.keys(newProps).forEach((name) => {
20
+ if (name === "children" || name === "style" || name === "ref" || name === "class" || name === "className" || name === "forwardedRef") {
21
+ return;
22
+ }
23
+ if (name.indexOf("on") === 0 && name[2] === name[2].toUpperCase()) {
24
+ const eventName = name.substring(2);
25
+ const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
26
+ if (!isCoveredByReact(eventNameLc)) {
27
+ syncEvent(node, eventNameLc, newProps[name]);
28
+ }
29
+ } else {
30
+ node[name] = newProps[name];
31
+ const propType = typeof newProps[name];
32
+ if (propType === "string") {
33
+ node.setAttribute(camelToDashCase(name), newProps[name]);
34
+ }
35
+ }
36
+ });
37
+ }
38
+ };
39
+ const getClassName = (classList, newProps, oldProps) => {
40
+ const newClassProp = newProps.className || newProps.class;
41
+ const oldClassProp = oldProps.className || oldProps.class;
42
+ const currentClasses = arrayToMap(classList);
43
+ const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(" ") : []);
44
+ const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(" ") : []);
45
+ const finalClassNames = [];
46
+ currentClasses.forEach((currentClass) => {
47
+ if (incomingPropClasses.has(currentClass)) {
48
+ finalClassNames.push(currentClass);
49
+ incomingPropClasses.delete(currentClass);
50
+ } else if (!oldPropClasses.has(currentClass)) {
51
+ finalClassNames.push(currentClass);
52
+ }
53
+ });
54
+ incomingPropClasses.forEach((s) => finalClassNames.push(s));
55
+ return finalClassNames.join(" ");
56
+ };
57
+ const transformReactEventName = (eventNameSuffix) => {
58
+ switch (eventNameSuffix) {
59
+ case "doubleclick":
60
+ return "dblclick";
61
+ }
62
+ return eventNameSuffix;
63
+ };
64
+ /**
65
+ * Checks if an event is supported in the current execution environment.
66
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
67
+ */
68
+ const isCoveredByReact = (eventNameSuffix) => {
69
+ if (typeof document === "undefined") {
70
+ return true;
71
+ } else {
72
+ const eventName = "on" + transformReactEventName(eventNameSuffix);
73
+ let isSupported = eventName in document;
74
+ if (!isSupported) {
75
+ const element = document.createElement("div");
76
+ element.setAttribute(eventName, "return;");
77
+ isSupported = typeof element[eventName] === "function";
78
+ }
79
+ return isSupported;
80
+ }
81
+ };
82
+ const syncEvent = (node, eventName, newEventHandler) => {
83
+ const eventStore = node.__events || (node.__events = {});
84
+ const oldEventHandler = eventStore[eventName];
85
+ if (oldEventHandler) {
86
+ node.removeEventListener(eventName, oldEventHandler);
87
+ }
88
+ node.addEventListener(
89
+ eventName,
90
+ eventStore[eventName] = function handler(e) {
91
+ if (newEventHandler) {
92
+ newEventHandler.call(this, e);
93
+ }
94
+ }
95
+ );
96
+ };
97
+ const arrayToMap = (arr) => {
98
+ const map = /* @__PURE__ */ new Map();
99
+ arr.forEach((s) => map.set(s, s));
100
+ return map;
101
+ };
102
+ const setRef = (ref, value) => {
103
+ if (typeof ref === "function") {
104
+ ref(value);
105
+ } else if (ref != null) {
106
+ ref.current = value;
107
+ }
108
+ };
109
+ const mergeRefs = (...refs) => {
110
+ return (value) => {
111
+ refs.forEach((ref) => {
112
+ setRef(ref, value);
113
+ });
114
+ };
115
+ };
116
+ const createForwardRef = (ReactComponent, displayName) => {
117
+ const forwardRef = (props, ref) => {
118
+ return /* @__PURE__ */ jsxRuntime.jsx(ReactComponent, { ...props, forwardedRef: ref });
119
+ };
120
+ forwardRef.displayName = displayName;
121
+ return React.forwardRef(forwardRef);
122
+ };
123
+ const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
124
+ if (defineCustomElement !== void 0) {
125
+ defineCustomElement();
126
+ }
127
+ const displayName = dashToPascalCase(tagName);
128
+ const ReactComponent = class extends React.Component {
129
+ constructor(props) {
130
+ super(props);
131
+ __publicField(this, "componentEl");
132
+ __publicField(this, "setComponentElRef", (element) => {
133
+ this.componentEl = element;
134
+ });
135
+ }
136
+ componentDidMount() {
137
+ this.componentDidUpdate(this.props);
138
+ }
139
+ componentDidUpdate(prevProps) {
140
+ attachProps(this.componentEl, this.props, prevProps);
141
+ }
142
+ render() {
143
+ const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
144
+ let propsToPass = Object.keys(cProps).reduce((acc, name) => {
145
+ const value = cProps[name];
146
+ if (name.indexOf("on") === 0 && name[2] === name[2].toUpperCase()) {
147
+ const eventName = name.substring(2).toLowerCase();
148
+ if (typeof document !== "undefined" && isCoveredByReact(eventName)) {
149
+ acc[name] = value;
150
+ }
151
+ } else {
152
+ const type = typeof value;
153
+ if (type === "string" || type === "boolean" || type === "number") {
154
+ acc[camelToDashCase(name)] = value;
155
+ }
156
+ }
157
+ return acc;
158
+ }, {});
159
+ const newProps = {
160
+ ...propsToPass,
161
+ ref: mergeRefs(forwardedRef, this.setComponentElRef),
162
+ style
163
+ };
164
+ return React.createElement(tagName, newProps, children);
165
+ }
166
+ static get displayName() {
167
+ return displayName;
168
+ }
169
+ };
170
+ return createForwardRef(ReactComponent, displayName);
171
+ };
172
+ function TemplateConstructor(el, ReactComponent, initialProps, lastEl = null) {
173
+ var _a;
174
+ if (!el) {
175
+ (_a = lastEl == null ? void 0 : lastEl.destroy) == null ? void 0 : _a.call(lastEl);
176
+ return null;
177
+ }
178
+ if (!el._root) {
179
+ el._root = client_js.createRoot(el);
180
+ }
181
+ const renderComponent = (props) => {
182
+ var _a2;
183
+ const vNode = React.createElement(ReactComponent, props);
184
+ (_a2 = el._root) == null ? void 0 : _a2.render(vNode);
185
+ };
186
+ renderComponent(initialProps);
187
+ const update = (newProps) => {
188
+ renderComponent(newProps);
189
+ };
190
+ const destroy = () => {
191
+ var _a2;
192
+ (_a2 = el._root) == null ? void 0 : _a2.unmount();
193
+ el._root = void 0;
194
+ };
195
+ return { update, destroy };
196
+ }
197
+ const Template = (ReactComponent, customProps) => {
198
+ return (h, p, addition) => {
199
+ const props = customProps ? { ...customProps, ...p } : p;
200
+ props.addition = addition;
201
+ let lastEl = null;
202
+ return h("span", {
203
+ ref: (el) => {
204
+ lastEl = TemplateConstructor(el, ReactComponent, props, lastEl);
205
+ }
206
+ });
207
+ };
208
+ };
209
+ class EditorAdapter {
210
+ constructor(EditorComponent, column, save, close) {
211
+ __publicField(this, "element", null);
212
+ __publicField(this, "editCell", null);
213
+ __publicField(this, "renderedComponent", null);
214
+ this.EditorComponent = EditorComponent;
215
+ this.column = column;
216
+ this.save = save;
217
+ this.close = close;
218
+ }
219
+ // optional, called after editor rendered
220
+ componentDidRender() {
221
+ }
222
+ // optional, called after editor destroyed
223
+ disconnectedCallback() {
224
+ var _a;
225
+ (_a = this.renderedComponent) == null ? void 0 : _a.destroy();
226
+ this.renderedComponent = null;
227
+ }
228
+ render(h) {
229
+ return h("span", {
230
+ ref: (el) => this.renderedComponent = TemplateConstructor(
231
+ el,
232
+ this.EditorComponent,
233
+ {
234
+ ...this.editCell,
235
+ column: this.column,
236
+ save: this.save,
237
+ close: this.close
238
+ },
239
+ this.renderedComponent
240
+ )
241
+ });
242
+ }
243
+ }
244
+ const Editor = (EditorComponent) => {
245
+ return function(column, save, close) {
246
+ return new EditorAdapter(EditorComponent, column, save, close);
247
+ };
248
+ };
249
+ const RevoGrid = /* @__PURE__ */ createReactComponent("revo-grid", void 0, void 0, loader.defineCustomElements);
250
+ exports2.Editor = Editor;
251
+ exports2.EditorAdapter = EditorAdapter;
252
+ exports2.RevoGrid = RevoGrid;
253
+ exports2.Template = Template;
254
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
255
+ });
@@ -0,0 +1,16 @@
1
+ import { Root } from 'react-dom/client';
2
+ import { ComponentType } from 'react';
3
+ import { HyperFunc, ColumnDataSchemaModel, VNode } from '@revolist/revogrid';
4
+
5
+ export interface ReactElement extends HTMLElement {
6
+ _root?: Root;
7
+ }
8
+ export interface RenderedComponent<T> {
9
+ update: (newProps: T) => void;
10
+ destroy: () => void;
11
+ }
12
+ export declare function TemplateConstructor<T = ColumnDataSchemaModel>(el: ReactElement | null, ReactComponent: ComponentType<any>, initialProps: T, lastEl?: RenderedComponent<T> | null): RenderedComponent<T> | null;
13
+ /**
14
+ * Render React component in Grid column template.
15
+ */
16
+ export declare const Template: (ReactComponent: ComponentType<ColumnDataSchemaModel>, customProps?: any) => (h: HyperFunc<VNode>, p: ColumnDataSchemaModel, addition?: any) => VNode;
@@ -1,15 +1,3 @@
1
- /// <reference types="react" />
2
- import type { JSX } from '@revolist/revogrid';
3
- export declare const RevoGrid: import("react").ForwardRefExoticComponent<JSX.RevoGrid & Omit<import("react").HTMLAttributes<HTMLRevoGridElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevoGridElement>>;
4
- export declare const RevogrClipboard: import("react").ForwardRefExoticComponent<JSX.RevogrClipboard & Omit<import("react").HTMLAttributes<HTMLRevogrClipboardElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrClipboardElement>>;
5
- export declare const RevogrData: import("react").ForwardRefExoticComponent<JSX.RevogrData & Omit<import("react").HTMLAttributes<HTMLRevogrDataElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrDataElement>>;
6
- export declare const RevogrEdit: import("react").ForwardRefExoticComponent<JSX.RevogrEdit & Omit<import("react").HTMLAttributes<HTMLRevogrEditElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrEditElement>>;
7
- export declare const RevogrFilterPanel: import("react").ForwardRefExoticComponent<JSX.RevogrFilterPanel & Omit<import("react").HTMLAttributes<HTMLRevogrFilterPanelElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrFilterPanelElement>>;
8
- export declare const RevogrFocus: import("react").ForwardRefExoticComponent<JSX.RevogrFocus & Omit<import("react").HTMLAttributes<HTMLRevogrFocusElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrFocusElement>>;
9
- export declare const RevogrHeader: import("react").ForwardRefExoticComponent<JSX.RevogrHeader & Omit<import("react").HTMLAttributes<HTMLRevogrHeaderElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrHeaderElement>>;
10
- export declare const RevogrOrderEditor: import("react").ForwardRefExoticComponent<JSX.RevogrOrderEditor & Omit<import("react").HTMLAttributes<HTMLRevogrOrderEditorElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrOrderEditorElement>>;
11
- export declare const RevogrOverlaySelection: import("react").ForwardRefExoticComponent<JSX.RevogrOverlaySelection & Omit<import("react").HTMLAttributes<HTMLRevogrOverlaySelectionElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrOverlaySelectionElement>>;
12
- export declare const RevogrRowHeaders: import("react").ForwardRefExoticComponent<JSX.RevogrRowHeaders & Omit<import("react").HTMLAttributes<HTMLRevogrRowHeadersElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrRowHeadersElement>>;
13
- export declare const RevogrScrollVirtual: import("react").ForwardRefExoticComponent<JSX.RevogrScrollVirtual & Omit<import("react").HTMLAttributes<HTMLRevogrScrollVirtualElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrScrollVirtualElement>>;
14
- export declare const RevogrTempRange: import("react").ForwardRefExoticComponent<JSX.RevogrTempRange & Omit<import("react").HTMLAttributes<HTMLRevogrTempRangeElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrTempRangeElement>>;
15
- export declare const RevogrViewportScroll: import("react").ForwardRefExoticComponent<JSX.RevogrViewportScroll & Omit<import("react").HTMLAttributes<HTMLRevogrViewportScrollElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLRevogrViewportScrollElement>>;
1
+ import { JSX } from '@revolist/revogrid';
2
+
3
+ export declare const RevoGrid: import('react').ForwardRefExoticComponent<JSX.RevoGrid & Omit<import('react').HTMLAttributes<HTMLRevoGridElement>, "style"> & import('./react-component-lib/interfaces').StyleReactProps & import('react').RefAttributes<HTMLRevoGridElement>>;
package/package.json CHANGED
@@ -1,9 +1,58 @@
1
1
  {
2
2
  "name": "@revolist/react-datagrid",
3
3
  "sideEffects": false,
4
- "version": "3.6.17",
5
- "description": "React excel like datagrid component",
6
- "license": "MIT",
4
+ "version": "4.0.4",
5
+ "description": "React DataGrid Spreadsheet component with native cell render support",
6
+ "main": "./dist/react-datagrid.umd.js",
7
+ "module": "./dist/react-datagrid.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/react-datagrid.js",
12
+ "require": "./dist/react-datagrid.umd.cjs"
13
+ }
14
+ },
15
+ "type": "module",
16
+ "files": [
17
+ "dist/"
18
+ ],
19
+ "scripts": {
20
+ "dev": "vite",
21
+ "build": "tsc && vite build",
22
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
23
+ "preview": "vite preview"
24
+ },
25
+ "keywords": [
26
+ "revo-grid",
27
+ "revolist",
28
+ "csv",
29
+ "datagrid",
30
+ "datalist",
31
+ "datamanager",
32
+ "editable",
33
+ "excel",
34
+ "excel-grid",
35
+ "export",
36
+ "fast-grid",
37
+ "filtering",
38
+ "grid",
39
+ "gridjs",
40
+ "grouping",
41
+ "infinity-grid",
42
+ "rangeedit",
43
+ "reactive",
44
+ "spreadsheet",
45
+ "stenciljs",
46
+ "storybook",
47
+ "treeview",
48
+ "virtualgrid",
49
+ "virtual",
50
+ "virtual-scroll",
51
+ "react",
52
+ "react-grid",
53
+ "react-datagrid"
54
+ ],
55
+ "author": "revolist",
7
56
  "repository": {
8
57
  "type": "git",
9
58
  "url": "https://github.com/revolist/react-datagrid.git"
@@ -12,36 +61,24 @@
12
61
  "url": "https://github.com/revolist/revogrid/issues"
13
62
  },
14
63
  "homepage": "https://github.com/revolist/revogrid#readme",
15
- "author": "revolist",
16
- "scripts": {
17
- "build": "npm run clean && npm run compile",
18
- "clean": "rm -rf dist",
19
- "compile": "npm run tsc",
20
- "tsc": "tsc -p .",
21
- "rollup": "rollup -c",
22
- "serve": "parcel public/index.html"
23
- },
24
- "main": "./dist/revogrid.js",
25
- "module": "./dist/revogrid.js",
26
- "types": "./dist/revogrid.d.ts",
27
- "files": [
28
- "dist/"
29
- ],
30
- "devDependencies": {
31
- "@types/node": "^20.4.5",
32
- "@types/react": "^18.2.18",
33
- "@types/react-dom": "^18.2.7",
34
- "np": "^8.0.4",
35
- "parcel-bundler": "^1.12.5",
36
- "react": "^18.2.0",
37
- "react-dom": "^18.2.0",
38
- "typescript": "^5.1.6"
39
- },
64
+ "license": "MIT",
40
65
  "dependencies": {
41
- "@stencil/core": "^2.17.3",
42
- "@revolist/revogrid": "^3.6.16"
66
+ "@stencil/core": "^4.17.1",
67
+ "@revolist/revogrid": "^4.0.4",
68
+ "react": "^18.3.1",
69
+ "react-dom": "^18.3.1"
43
70
  },
44
- "alias": {
45
- "@revolist/react-datagrid": "./dist/revogrid.js"
71
+ "devDependencies": {
72
+ "@types/react": "^18.3.2",
73
+ "@types/react-dom": "^18.3.0",
74
+ "@typescript-eslint/eslint-plugin": "^7.8.0",
75
+ "@typescript-eslint/parser": "^7.8.0",
76
+ "@vitejs/plugin-react": "^4.2.1",
77
+ "eslint": "^8.57.0",
78
+ "eslint-plugin-react-hooks": "^4.6.2",
79
+ "eslint-plugin-react-refresh": "^0.4.7",
80
+ "typescript": "^5.2.2",
81
+ "vite": "^5.2.11",
82
+ "vite-plugin-dts": "^3.9.1"
46
83
  }
47
84
  }
@@ -1,75 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React, { createElement } from 'react';
13
- import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs, } from './utils';
14
- export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
15
- if (defineCustomElement !== undefined) {
16
- defineCustomElement();
17
- }
18
- const displayName = dashToPascalCase(tagName);
19
- const ReactComponent = class extends React.Component {
20
- constructor(props) {
21
- super(props);
22
- this.setComponentElRef = (element) => {
23
- this.componentEl = element;
24
- };
25
- }
26
- componentDidMount() {
27
- this.componentDidUpdate(this.props);
28
- }
29
- componentDidUpdate(prevProps) {
30
- attachProps(this.componentEl, this.props, prevProps);
31
- }
32
- render() {
33
- const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
34
- let propsToPass = Object.keys(cProps).reduce((acc, name) => {
35
- const value = cProps[name];
36
- if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
37
- const eventName = name.substring(2).toLowerCase();
38
- if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
39
- acc[name] = value;
40
- }
41
- }
42
- else {
43
- // we should only render strings, booleans, and numbers as attrs in html.
44
- // objects, functions, arrays etc get synced via properties on mount.
45
- const type = typeof value;
46
- if (type === 'string' || type === 'boolean' || type === 'number') {
47
- acc[camelToDashCase(name)] = value;
48
- }
49
- }
50
- return acc;
51
- }, {});
52
- if (manipulatePropsFunction) {
53
- propsToPass = manipulatePropsFunction(this.props, propsToPass);
54
- }
55
- const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
56
- /**
57
- * We use createElement here instead of
58
- * React.createElement to work around a
59
- * bug in Vite (https://github.com/vitejs/vite/issues/6104).
60
- * React.createElement causes all elements to be rendered
61
- * as <tagname> instead of the actual Web Component.
62
- */
63
- return createElement(tagName, newProps, children);
64
- }
65
- static get displayName() {
66
- return displayName;
67
- }
68
- };
69
- // If context was passed to createReactComponent then conditionally add it to the Component Class
70
- if (ReactComponentContext) {
71
- ReactComponent.contextType = ReactComponentContext;
72
- }
73
- return createForwardRef(ReactComponent, displayName);
74
- };
75
- //# sourceMappingURL=createComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createComponent.js","sourceRoot":"","sources":["../../src/react-component-lib/createComponent.tsx"],"names":[],"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0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import React from 'react';
22
- import ReactDOM from 'react-dom';
23
- import { attachProps, dashToPascalCase, defineCustomElement, setRef, } from './utils';
24
- export const createOverlayComponent = (tagName, controller, customElement) => {
25
- defineCustomElement(tagName, customElement);
26
- const displayName = dashToPascalCase(tagName);
27
- const didDismissEventName = `on${displayName}DidDismiss`;
28
- const didPresentEventName = `on${displayName}DidPresent`;
29
- const willDismissEventName = `on${displayName}WillDismiss`;
30
- const willPresentEventName = `on${displayName}WillPresent`;
31
- let isDismissing = false;
32
- class Overlay extends React.Component {
33
- constructor(props) {
34
- super(props);
35
- if (typeof document !== 'undefined') {
36
- this.el = document.createElement('div');
37
- }
38
- this.handleDismiss = this.handleDismiss.bind(this);
39
- }
40
- static get displayName() {
41
- return displayName;
42
- }
43
- componentDidMount() {
44
- if (this.props.isOpen) {
45
- this.present();
46
- }
47
- }
48
- componentWillUnmount() {
49
- if (this.overlay) {
50
- this.overlay.dismiss();
51
- }
52
- }
53
- handleDismiss(event) {
54
- if (this.props.onDidDismiss) {
55
- this.props.onDidDismiss(event);
56
- }
57
- setRef(this.props.forwardedRef, null);
58
- }
59
- shouldComponentUpdate(nextProps) {
60
- // Check if the overlay component is about to dismiss
61
- if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
62
- isDismissing = true;
63
- }
64
- return true;
65
- }
66
- componentDidUpdate(prevProps) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- if (this.overlay) {
69
- attachProps(this.overlay, this.props, prevProps);
70
- }
71
- if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
72
- this.present(prevProps);
73
- }
74
- if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
75
- yield this.overlay.dismiss();
76
- isDismissing = false;
77
- /**
78
- * Now that the overlay is dismissed
79
- * we need to render again so that any
80
- * inner components will be unmounted
81
- */
82
- this.forceUpdate();
83
- }
84
- });
85
- }
86
- present(prevProps) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- const _a = this.props, { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent } = _a, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
89
- const elementProps = Object.assign(Object.assign({}, cProps), { ref: this.props.forwardedRef, [didDismissEventName]: this.handleDismiss, [didPresentEventName]: (e) => this.props.onDidPresent && this.props.onDidPresent(e), [willDismissEventName]: (e) => this.props.onWillDismiss && this.props.onWillDismiss(e), [willPresentEventName]: (e) => this.props.onWillPresent && this.props.onWillPresent(e) });
90
- this.overlay = yield controller.create(Object.assign(Object.assign({}, elementProps), { component: this.el, componentProps: {} }));
91
- setRef(this.props.forwardedRef, this.overlay);
92
- attachProps(this.overlay, elementProps, prevProps);
93
- yield this.overlay.present();
94
- });
95
- }
96
- render() {
97
- /**
98
- * Continue to render the component even when
99
- * overlay is dismissing otherwise component
100
- * will be hidden before animation is done.
101
- */
102
- return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
103
- }
104
- }
105
- return React.forwardRef((props, ref) => {
106
- return React.createElement(Overlay, Object.assign({}, props, { forwardedRef: ref }));
107
- });
108
- };
109
- //# sourceMappingURL=createOverlayComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createOverlayComponent.js","sourceRoot":"","sources":["../../src/react-component-lib/createOverlayComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,WAAW,CAAC;AAGjC,OAAO,EAEL,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,GACP,MAAM,SAAS,CAAC;AAgBjB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAIpC,OAAe,EACf,UAA8D,EAC9D,aAAmB,EACnB,EAAE;IACF,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,mBAAmB,GAAG,KAAK,WAAW,YAAY,CAAC;IACzD,MAAM,mBAAmB,GAAG,KAAK,WAAW,YAAY,CAAC;IACzD,MAAM,oBAAoB,GAAG,KAAK,WAAW,aAAa,CAAC;IAC3D,MAAM,oBAAoB,GAAG,KAAK,WAAW,aAAa,CAAC;IAO3D,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,MAAM,OAAQ,SAAQ,KAAK,CAAC,SAAgB;QAI1C,YAAY,KAAY;YACtB,KAAK,CAAC,KAAK,CAAC,CAAC;YACb,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;gBACnC,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aACzC;YACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QAED,MAA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,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC/B,CAAC;SAAA;QAED,MAAM;YACJ;;;;eAIG;YACH,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxG,CAAC;KACF;IAED,OAAO,KAAK,CAAC,UAAU,CAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACzD,OAAO,oBAAC,OAAO,oBAAK,KAAK,IAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- export { createReactComponent } from './createComponent';
2
- export { createOverlayComponent } from './createOverlayComponent';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-component-lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/react-component-lib/interfaces.ts"],"names":[],"mappings":""}
@@ -1,98 +0,0 @@
1
- import { camelToDashCase } from './case';
2
- export const attachProps = (node, newProps, oldProps = {}) => {
3
- // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
4
- if (node instanceof Element) {
5
- // add any classes in className to the class list
6
- const className = getClassName(node.classList, newProps, oldProps);
7
- if (className !== '') {
8
- node.className = className;
9
- }
10
- Object.keys(newProps).forEach((name) => {
11
- if (name === 'children' ||
12
- name === 'style' ||
13
- name === 'ref' ||
14
- name === 'class' ||
15
- name === 'className' ||
16
- name === 'forwardedRef') {
17
- return;
18
- }
19
- if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
20
- const eventName = name.substring(2);
21
- const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
22
- if (!isCoveredByReact(eventNameLc)) {
23
- syncEvent(node, eventNameLc, newProps[name]);
24
- }
25
- }
26
- else {
27
- node[name] = newProps[name];
28
- const propType = typeof newProps[name];
29
- if (propType === 'string') {
30
- node.setAttribute(camelToDashCase(name), newProps[name]);
31
- }
32
- }
33
- });
34
- }
35
- };
36
- export const getClassName = (classList, newProps, oldProps) => {
37
- const newClassProp = newProps.className || newProps.class;
38
- const oldClassProp = oldProps.className || oldProps.class;
39
- // map the classes to Maps for performance
40
- const currentClasses = arrayToMap(classList);
41
- const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
42
- const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
43
- const finalClassNames = [];
44
- // loop through each of the current classes on the component
45
- // to see if it should be a part of the classNames added
46
- currentClasses.forEach((currentClass) => {
47
- if (incomingPropClasses.has(currentClass)) {
48
- // add it as its already included in classnames coming in from newProps
49
- finalClassNames.push(currentClass);
50
- incomingPropClasses.delete(currentClass);
51
- }
52
- else if (!oldPropClasses.has(currentClass)) {
53
- // add it as it has NOT been removed by user
54
- finalClassNames.push(currentClass);
55
- }
56
- });
57
- incomingPropClasses.forEach((s) => finalClassNames.push(s));
58
- return finalClassNames.join(' ');
59
- };
60
- /**
61
- * Checks if an event is supported in the current execution environment.
62
- * @license Modernizr 3.0.0pre (Custom Build) | MIT
63
- */
64
- export const isCoveredByReact = (eventNameSuffix) => {
65
- if (typeof document === 'undefined') {
66
- return true;
67
- }
68
- else {
69
- const eventName = 'on' + eventNameSuffix;
70
- let isSupported = eventName in document;
71
- if (!isSupported) {
72
- const element = document.createElement('div');
73
- element.setAttribute(eventName, 'return;');
74
- isSupported = typeof element[eventName] === 'function';
75
- }
76
- return isSupported;
77
- }
78
- };
79
- export const syncEvent = (node, eventName, newEventHandler) => {
80
- const eventStore = node.__events || (node.__events = {});
81
- const oldEventHandler = eventStore[eventName];
82
- // Remove old listener so they don't double up.
83
- if (oldEventHandler) {
84
- node.removeEventListener(eventName, oldEventHandler);
85
- }
86
- // Bind new listener.
87
- node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
88
- if (newEventHandler) {
89
- newEventHandler.call(this, e);
90
- }
91
- }));
92
- };
93
- const arrayToMap = (arr) => {
94
- const map = new Map();
95
- arr.forEach((s) => map.set(s, s));
96
- return map;
97
- };
98
- //# sourceMappingURL=attachProps.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachProps.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/attachProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,QAAa,EAAE,WAAgB,EAAE,EAAE,EAAE;IAClF,6GAA6G;IAC7G,IAAI,IAAI,YAAY,OAAO,EAAE;QAC3B,iDAAiD;QACjD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,SAAS,KAAK,EAAE,EAAE;YACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;SAC5B;QAED,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrC,IACE,IAAI,KAAK,UAAU;gBACnB,IAAI,KAAK,OAAO;gBAChB,IAAI,KAAK,KAAK;gBACd,IAAI,KAAK,OAAO;gBAChB,IAAI,KAAK,WAAW;gBACpB,IAAI,KAAK,cAAc,EACvB;gBACA,OAAO;aACR;YACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAA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AC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAiF,EACjF,SAAiB,EACjB,eAAmC,EACnC,EAAE;IACF,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;IACzD,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAE9C,+CAA+C;IAC/C,IAAI,eAAe,EAAE;QACnB,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;KACtD;IAED,qBAAqB;IACrB,IAAI,CAAC,gBAAgB,CACnB,SAAS,EACT,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,SAAS,OAAO,CAAC,CAAQ;QAChD,IAAI,eAAe,EAAE;YACnB,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SAC/B;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAA4B,EAAE,EAAE;IAClD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACrC,GAAgB,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- export const dashToPascalCase = (str) => str
2
- .toLowerCase()
3
- .split('-')
4
- .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
5
- .join('');
6
- export const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
7
- //# sourceMappingURL=case.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"case.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/case.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC9C,GAAG;KACA,WAAW,EAAE;KACb,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACpE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- export const isDevMode = () => {
2
- return process && process.env && process.env.NODE_ENV === 'development';
3
- };
4
- const warnings = {};
5
- export const deprecationWarning = (key, message) => {
6
- if (isDevMode()) {
7
- if (!warnings[key]) {
8
- console.warn(message);
9
- warnings[key] = true;
10
- }
11
- }
12
- };
13
- //# sourceMappingURL=dev.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/dev.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,OAAO,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,QAAQ,GAA+B,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,OAAe,EAAE,EAAE;IACjE,IAAI,SAAS,EAAE,EAAE;QACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;SACtB;KACF;AACH,CAAC,CAAC"}
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- export const setRef = (ref, value) => {
3
- if (typeof ref === 'function') {
4
- ref(value);
5
- }
6
- else if (ref != null) {
7
- // Cast as a MutableRef so we can assign current
8
- ref.current = value;
9
- }
10
- };
11
- export const mergeRefs = (...refs) => {
12
- return (value) => {
13
- refs.forEach(ref => {
14
- setRef(ref, value);
15
- });
16
- };
17
- };
18
- export const createForwardRef = (ReactComponent, displayName) => {
19
- const forwardRef = (props, ref) => {
20
- return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
21
- };
22
- forwardRef.displayName = displayName;
23
- return React.forwardRef(forwardRef);
24
- };
25
- export const defineCustomElement = (tagName, customElement) => {
26
- if (customElement !== undefined &&
27
- typeof customElements !== 'undefined' &&
28
- !customElements.get(tagName)) {
29
- customElements.define(tagName, customElement);
30
- }
31
- };
32
- export * from './attachProps';
33
- export * from './case';
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAA+D,EAAE,KAAU,EAAE,EAAE;IACpG,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;QAC7B,GAAG,CAAC,KAAK,CAAC,CAAA;KACX;SAAM,IAAI,GAAG,IAAI,IAAI,EAAE;QACtB,gDAAgD;QAC/C,GAAmC,CAAC,OAAO,GAAG,KAAK,CAAA;KACrD;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAAG,IAAoE,EAC/C,EAAE;IAC1B,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACjB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,cAAmB,EACnB,WAAmB,EACnB,EAAE;IACF,MAAM,UAAU,GAAG,CACjB,KAAuD,EACvD,GAA0C,EAC1C,EAAE;QACF,OAAO,oBAAC,cAAc,oBAAK,KAAK,IAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC1D,CAAC,CAAC;IACF,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC;IAErC,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,aAAkB,EAAE,EAAE;IACzE,IACE,aAAa,KAAK,SAAS;QAC3B,OAAO,cAAc,KAAK,WAAW;QACrC,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAC5B;QACA,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KAC/C;AACH,CAAC,CAAA;AAED,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC"}
package/dist/revogrid.js DELETED
@@ -1,18 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- /* auto-generated react proxies */
4
- import { createReactComponent } from './react-component-lib';
5
- export const RevoGrid = /*@__PURE__*/ createReactComponent('revo-grid');
6
- export const RevogrClipboard = /*@__PURE__*/ createReactComponent('revogr-clipboard');
7
- export const RevogrData = /*@__PURE__*/ createReactComponent('revogr-data');
8
- export const RevogrEdit = /*@__PURE__*/ createReactComponent('revogr-edit');
9
- export const RevogrFilterPanel = /*@__PURE__*/ createReactComponent('revogr-filter-panel');
10
- export const RevogrFocus = /*@__PURE__*/ createReactComponent('revogr-focus');
11
- export const RevogrHeader = /*@__PURE__*/ createReactComponent('revogr-header');
12
- export const RevogrOrderEditor = /*@__PURE__*/ createReactComponent('revogr-order-editor');
13
- export const RevogrOverlaySelection = /*@__PURE__*/ createReactComponent('revogr-overlay-selection');
14
- export const RevogrRowHeaders = /*@__PURE__*/ createReactComponent('revogr-row-headers');
15
- export const RevogrScrollVirtual = /*@__PURE__*/ createReactComponent('revogr-scroll-virtual');
16
- export const RevogrTempRange = /*@__PURE__*/ createReactComponent('revogr-temp-range');
17
- export const RevogrViewportScroll = /*@__PURE__*/ createReactComponent('revogr-viewport-scroll');
18
- //# sourceMappingURL=revogrid.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"revogrid.js","sourceRoot":"","sources":["../src/revogrid.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB,kCAAkC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAM7D,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAA,oBAAoB,CAAoC,WAAW,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAA,oBAAoB,CAAkD,kBAAkB,CAAC,CAAC;AACtI,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA,oBAAoB,CAAwC,aAAa,CAAC,CAAC;AAClH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA,oBAAoB,CAAwC,aAAa,CAAC,CAAC;AAClH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAA,oBAAoB,CAAsD,qBAAqB,CAAC,CAAC;AAC/I,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAA,oBAAoB,CAA0C,cAAc,CAAC,CAAC;AACtH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAA,oBAAoB,CAA4C,eAAe,CAAC,CAAC;AAC1H,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAA,oBAAoB,CAAsD,qBAAqB,CAAC,CAAC;AAC/I,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAA,oBAAoB,CAAgE,0BAA0B,CAAC,CAAC;AACnK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