@visactor/react-vtable 0.15.0-alpha.2

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 (130) hide show
  1. package/README.md +151 -0
  2. package/cjs/components/base-component.d.ts +9 -0
  3. package/cjs/components/base-component.js +81 -0
  4. package/cjs/components/base-component.js.map +1 -0
  5. package/cjs/components/component/menu.d.ts +9 -0
  6. package/cjs/components/component/menu.js +10 -0
  7. package/cjs/components/component/menu.js.map +1 -0
  8. package/cjs/components/component/tooltip.d.ts +7 -0
  9. package/cjs/components/component/tooltip.js +10 -0
  10. package/cjs/components/component/tooltip.js.map +1 -0
  11. package/cjs/components/index.d.ts +14 -0
  12. package/cjs/components/index.js +79 -0
  13. package/cjs/components/index.js.map +1 -0
  14. package/cjs/components/list/list-column.d.ts +4 -0
  15. package/cjs/components/list/list-column.js +10 -0
  16. package/cjs/components/list/list-column.js.map +1 -0
  17. package/cjs/components/pivot/pivot-corner.d.ts +4 -0
  18. package/cjs/components/pivot/pivot-corner.js +10 -0
  19. package/cjs/components/pivot/pivot-corner.js.map +1 -0
  20. package/cjs/components/pivot/pivot-dimension.d.ts +5 -0
  21. package/cjs/components/pivot/pivot-dimension.js +11 -0
  22. package/cjs/components/pivot/pivot-dimension.js.map +1 -0
  23. package/cjs/components/pivot/pivot-header-title.d.ts +5 -0
  24. package/cjs/components/pivot/pivot-header-title.js +11 -0
  25. package/cjs/components/pivot/pivot-header-title.js.map +1 -0
  26. package/cjs/components/pivot/pivot-indicator.d.ts +4 -0
  27. package/cjs/components/pivot/pivot-indicator.js +10 -0
  28. package/cjs/components/pivot/pivot-indicator.js.map +1 -0
  29. package/cjs/constants.d.ts +1 -0
  30. package/cjs/constants.js +6 -0
  31. package/cjs/constants.js.map +1 -0
  32. package/cjs/containers/withContainer.d.ts +8 -0
  33. package/cjs/containers/withContainer.js +64 -0
  34. package/cjs/containers/withContainer.js.map +1 -0
  35. package/cjs/context/table.d.ts +10 -0
  36. package/cjs/context/table.js +25 -0
  37. package/cjs/context/table.js.map +1 -0
  38. package/cjs/eventsUtils.d.ts +88 -0
  39. package/cjs/eventsUtils.js +72 -0
  40. package/cjs/eventsUtils.js.map +1 -0
  41. package/cjs/index.d.ts +2 -0
  42. package/cjs/index.js +20 -0
  43. package/cjs/index.js.map +1 -0
  44. package/cjs/index_old.d.ts +5 -0
  45. package/cjs/index_old.js +36 -0
  46. package/cjs/index_old.js.map +1 -0
  47. package/cjs/tables/base-table.d.ts +19 -0
  48. package/cjs/tables/base-table.js +127 -0
  49. package/cjs/tables/base-table.js.map +1 -0
  50. package/cjs/tables/index.d.ts +3 -0
  51. package/cjs/tables/index.js +38 -0
  52. package/cjs/tables/index.js.map +1 -0
  53. package/cjs/tables/list-table.d.ts +8 -0
  54. package/cjs/tables/list-table.js +10 -0
  55. package/cjs/tables/list-table.js.map +1 -0
  56. package/cjs/tables/pivot-chart.d.ts +9 -0
  57. package/cjs/tables/pivot-chart.js +40 -0
  58. package/cjs/tables/pivot-chart.js.map +1 -0
  59. package/cjs/tables/pivot-table.d.ts +8 -0
  60. package/cjs/tables/pivot-table.js +10 -0
  61. package/cjs/tables/pivot-table.js.map +1 -0
  62. package/cjs/util.d.ts +8 -0
  63. package/cjs/util.js +57 -0
  64. package/cjs/util.js.map +1 -0
  65. package/dist/react-vtable.js +3628 -0
  66. package/dist/react-vtable.min.js +19 -0
  67. package/es/components/base-component.d.ts +9 -0
  68. package/es/components/base-component.js +53 -0
  69. package/es/components/base-component.js.map +1 -0
  70. package/es/components/component/menu.d.ts +9 -0
  71. package/es/components/component/menu.js +4 -0
  72. package/es/components/component/menu.js.map +1 -0
  73. package/es/components/component/tooltip.d.ts +7 -0
  74. package/es/components/component/tooltip.js +4 -0
  75. package/es/components/component/tooltip.js.map +1 -0
  76. package/es/components/index.d.ts +14 -0
  77. package/es/components/index.js +14 -0
  78. package/es/components/index.js.map +1 -0
  79. package/es/components/list/list-column.d.ts +4 -0
  80. package/es/components/list/list-column.js +4 -0
  81. package/es/components/list/list-column.js.map +1 -0
  82. package/es/components/pivot/pivot-corner.d.ts +4 -0
  83. package/es/components/pivot/pivot-corner.js +4 -0
  84. package/es/components/pivot/pivot-corner.js.map +1 -0
  85. package/es/components/pivot/pivot-dimension.d.ts +5 -0
  86. package/es/components/pivot/pivot-dimension.js +6 -0
  87. package/es/components/pivot/pivot-dimension.js.map +1 -0
  88. package/es/components/pivot/pivot-header-title.d.ts +5 -0
  89. package/es/components/pivot/pivot-header-title.js +6 -0
  90. package/es/components/pivot/pivot-header-title.js.map +1 -0
  91. package/es/components/pivot/pivot-indicator.d.ts +4 -0
  92. package/es/components/pivot/pivot-indicator.js +4 -0
  93. package/es/components/pivot/pivot-indicator.js.map +1 -0
  94. package/es/constants.d.ts +1 -0
  95. package/es/constants.js +2 -0
  96. package/es/constants.js.map +1 -0
  97. package/es/containers/withContainer.d.ts +8 -0
  98. package/es/containers/withContainer.js +33 -0
  99. package/es/containers/withContainer.js.map +1 -0
  100. package/es/context/table.d.ts +10 -0
  101. package/es/context/table.js +16 -0
  102. package/es/context/table.js.map +1 -0
  103. package/es/eventsUtils.d.ts +88 -0
  104. package/es/eventsUtils.js +65 -0
  105. package/es/eventsUtils.js.map +1 -0
  106. package/es/index.d.ts +2 -0
  107. package/es/index.js +3 -0
  108. package/es/index.js.map +1 -0
  109. package/es/index_old.d.ts +5 -0
  110. package/es/index_old.js +29 -0
  111. package/es/index_old.js.map +1 -0
  112. package/es/tables/base-table.d.ts +19 -0
  113. package/es/tables/base-table.js +104 -0
  114. package/es/tables/base-table.js.map +1 -0
  115. package/es/tables/index.d.ts +3 -0
  116. package/es/tables/index.js +6 -0
  117. package/es/tables/index.js.map +1 -0
  118. package/es/tables/list-table.d.ts +8 -0
  119. package/es/tables/list-table.js +4 -0
  120. package/es/tables/list-table.js.map +1 -0
  121. package/es/tables/pivot-chart.d.ts +9 -0
  122. package/es/tables/pivot-chart.js +10 -0
  123. package/es/tables/pivot-chart.js.map +1 -0
  124. package/es/tables/pivot-table.d.ts +8 -0
  125. package/es/tables/pivot-table.js +4 -0
  126. package/es/tables/pivot-table.js.map +1 -0
  127. package/es/util.d.ts +8 -0
  128. package/es/util.js +36 -0
  129. package/es/util.js.map +1 -0
  130. package/package.json +99 -0
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.PivotTable = void 0;
6
+
7
+ const base_table_1 = require("./base-table");
8
+
9
+ exports.PivotTable = (0, base_table_1.createTable)("PivotTable", "pivot-table");
10
+ //# sourceMappingURL=pivot-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["tables/pivot-table.tsx"],"names":[],"mappings":";;;AAGA,6CAA2C;AAM9B,QAAA,UAAU,GAAG,IAAA,wBAAW,EAA2C,YAAY,EAAE,aAAa,CAAC,CAAC","file":"pivot-table.js","sourcesContent":["import type React from 'react';\nimport type { PivotTableConstructorOptions } from './../../../vtable/src/index.ts';\nimport type { BaseTableProps } from './base-table';\nimport { createTable } from './base-table';\n\nexport interface PivotTableProps\n extends Omit<BaseTableProps, 'option' | 'records' | 'type'>,\n Omit<PivotTableConstructorOptions, 'container'> {}\n\nexport const PivotTable = createTable<React.PropsWithChildren<PivotTableProps>>('PivotTable', 'pivot-table');\n"]}
package/cjs/util.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from 'react';
2
+ import React from 'react';
3
+ export declare const uid: (prefix?: string) => string;
4
+ export declare const getDisplayName: (Comp: any) => any;
5
+ export declare const typeOfComponent: (component: any, customTypeKey?: string) => string;
6
+ export declare const toArray: <T = ReactNode, TC = ReactNode>(children: T) => TC[];
7
+ export declare const findAllByType: <T extends ReactNode, TC = unknown>(children: React.ReactNode, type: TC | TC[]) => T[];
8
+ export declare const findChildByType: <T extends ReactNode, TC = unknown>(children: React.ReactNode, type: TC) => T;
package/cjs/util.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var __importDefault = this && this.__importDefault || function(mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ default: mod
6
+ };
7
+ };
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: !0
11
+ }), exports.findChildByType = exports.findAllByType = exports.toArray = exports.typeOfComponent = exports.getDisplayName = exports.uid = void 0;
12
+
13
+ const vutils_1 = require("@visactor/vutils"), react_1 = __importDefault(require("react")), react_is_1 = require("react-is");
14
+
15
+ let id = 0;
16
+
17
+ const uid = prefix => prefix ? `${prefix}-${id++}` : "" + id++;
18
+
19
+ exports.uid = uid;
20
+
21
+ const getDisplayName = Comp => "string" == typeof Comp ? Comp : Comp ? Comp.displayName || Comp.name : "";
22
+
23
+ exports.getDisplayName = getDisplayName;
24
+
25
+ const typeOfComponent = (component, customTypeKey = "__TYPE") => (null == component ? void 0 : component.props) && component.props[customTypeKey] || "string" == typeof (null == component ? void 0 : component.type) && component.type || (null == component ? void 0 : component.type) && "symbol" == typeof component.type && "Symbol(react.fragment)" === component.type.toString() && "react.fragment" || "function" == typeof (null == component ? void 0 : component.type) && component.type || "object" == typeof (null == component ? void 0 : component.type) && "Symbol(react.forward_ref)" === component.type.$$typeof.toString() && "react.forward_ref" || "string" == typeof component && "string" || "function" == typeof component && "function" || void 0;
26
+
27
+ exports.typeOfComponent = typeOfComponent;
28
+
29
+ const toArray = children => {
30
+ let result = [];
31
+ return react_1.default.Children.forEach(children, (child => {
32
+ (0, vutils_1.isNil)(child) || ((0, react_is_1.isFragment)(child) ? result = result.concat((0,
33
+ exports.toArray)(child.props.children)) : result.push(child));
34
+ })), result;
35
+ };
36
+
37
+ exports.toArray = toArray;
38
+
39
+ const findAllByType = (children, type) => {
40
+ const result = [];
41
+ let types = [];
42
+ return types = (0, vutils_1.isArray)(type) ? type.map((t => (0, exports.getDisplayName)(t))) : [ (0,
43
+ exports.getDisplayName)(type) ], (0, exports.toArray)(children).forEach((child => {
44
+ const childType = (0, exports.getDisplayName)((0, exports.typeOfComponent)(child));
45
+ -1 !== types.indexOf(childType) && result.push(child);
46
+ })), result;
47
+ };
48
+
49
+ exports.findAllByType = findAllByType;
50
+
51
+ const findChildByType = (children, type) => {
52
+ const result = (0, exports.findAllByType)(children, type);
53
+ return null == result ? void 0 : result[0];
54
+ };
55
+
56
+ exports.findChildByType = findChildByType;
57
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["util.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAuF;AAEvF,kDAA0B;AAC1B,uCAAsC;AAEtC,IAAI,EAAE,GAAG,CAAC,CAAC;AAEJ,MAAM,GAAG,GAAG,CAAC,MAAe,EAAE,EAAE;IACrC,IAAI,MAAM,EAAE;QACV,OAAO,GAAG,MAAM,IAAI,EAAE,EAAE,EAAE,CAAC;KAC5B;IAED,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC;AACnB,CAAC,CAAC;AANW,QAAA,GAAG,OAMd;AAOK,MAAM,cAAc,GAAG,CAAC,IAAS,EAAE,EAAE;IAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IACD,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC;AACvC,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB;AAEK,MAAM,eAAe,GAAG,CAAC,SAAc,EAAE,aAAa,GAAG,QAAQ,EAAU,EAAE;IAClF,OAAO,CACL,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,KAAI,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACpD,CAAC,OAAO,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAA,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC;QACvD,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,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,EAAE,CAAC;IACvB,IAAI,KAAK,GAAa,EAAE,CAAC;IAEzB,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,EAAE;QACjB,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,sBAAc,EAAC,CAAC,CAAC,CAAC,CAAC;KAC1C;SAAM;QACL,KAAK,GAAG,CAAC,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC,CAAC;KAChC;IAED,IAAA,eAAO,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAChC,MAAM,SAAS,GAAG,IAAA,sBAAc,EAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;QAEzD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;YACnC,MAAM,CAAC,IAAI,CAAC,KAAU,CAAC,CAAC;SACzB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAtBW,QAAA,aAAa,iBAsBxB;AAKK,MAAM,eAAe,GAAG,CAA0C,QAAyB,EAAE,IAAQ,EAAK,EAAE;IACjH,MAAM,MAAM,GAAG,IAAA,qBAAa,EAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC;IAEpD,OAAO,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B","file":"util.js","sourcesContent":["import { isNil, isArray, isString, isFunction, isPlainObject } from '@visactor/vutils';\nimport type { ReactNode } from 'react';\nimport React from 'react';\nimport { isFragment } from 'react-is';\n\nlet id = 0;\n\nexport const uid = (prefix?: string) => {\n if (prefix) {\n return `${prefix}-${id++}`;\n }\n\n return `${id++}`;\n};\n\n/**\n * Get the display name of a component\n * @param {Object} Comp Specified Component\n * @return {String} Display name of Component\n */\nexport const getDisplayName = (Comp: any) => {\n if (typeof Comp === 'string') {\n return Comp;\n }\n if (!Comp) {\n return '';\n }\n return Comp.displayName || Comp.name;\n};\n\nexport const typeOfComponent = (component: any, customTypeKey = '__TYPE'): string => {\n return (\n (component?.props && component.props[customTypeKey]) ||\n (typeof component?.type === 'string' && component.type) ||\n (component?.type &&\n typeof component.type === 'symbol' &&\n component.type.toString() === 'Symbol(react.fragment)' &&\n 'react.fragment') ||\n (typeof component?.type === 'function' && component.type) ||\n (typeof component?.type === 'object' &&\n component.type.$$typeof.toString() === 'Symbol(react.forward_ref)' &&\n 'react.forward_ref') ||\n (typeof component === 'string' && 'string') ||\n (typeof component === 'function' && 'function') ||\n undefined\n );\n};\n\nexport const toArray = <T = ReactNode, TC = ReactNode>(children: T): TC[] => {\n let result: TC[] = [];\n\n React.Children.forEach(children, child => {\n if (isNil(child)) {\n return;\n }\n\n if (isFragment(child)) {\n result = result.concat(toArray(child.props.children));\n } else {\n result.push(child as unknown as TC);\n }\n });\n\n return result;\n};\n\n/*\n * Find and return all matched children by type. `type` can be a React element class or\n * string\n */\nexport const findAllByType = <T extends React.ReactNode, TC = unknown>(\n children: React.ReactNode,\n type: TC | TC[]\n): T[] => {\n const result: T[] = [];\n let types: string[] = [];\n\n if (isArray(type)) {\n types = type.map(t => getDisplayName(t));\n } else {\n types = [getDisplayName(type)];\n }\n\n toArray(children).forEach(child => {\n const childType = getDisplayName(typeOfComponent(child));\n\n if (types.indexOf(childType) !== -1) {\n result.push(child as T);\n }\n });\n\n return result;\n};\n/*\n * Return the first matched child by type, return null otherwise.\n * `type` can be a React element class or string.\n */\nexport const findChildByType = <T extends React.ReactNode, TC = unknown>(children: React.ReactNode, type: TC): T => {\n const result = findAllByType<T, TC>(children, type);\n\n return result?.[0];\n};\n"]}