@importcsv/react 0.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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +470 -0
  3. package/build/App.d.ts +2 -0
  4. package/build/api.d.ts +17 -0
  5. package/build/components/CSVImporter/CSVImporter.stories.d.ts +44 -0
  6. package/build/components/CSVImporter/index.d.ts +26 -0
  7. package/build/config/environments.d.ts +12 -0
  8. package/build/config/index.d.ts +5 -0
  9. package/build/config.d.ts +10 -0
  10. package/build/i18n/de.d.ts +32 -0
  11. package/build/i18n/es.d.ts +32 -0
  12. package/build/i18n/fr.d.ts +32 -0
  13. package/build/i18n/i18n.d.ts +2 -0
  14. package/build/i18n/it.d.ts +32 -0
  15. package/build/importer/components/Box/index.d.ts +2 -0
  16. package/build/importer/components/Box/types/index.d.ts +5 -0
  17. package/build/importer/components/Checkbox/index.d.ts +2 -0
  18. package/build/importer/components/Checkbox/types/index.d.ts +4 -0
  19. package/build/importer/components/Errors/index.d.ts +4 -0
  20. package/build/importer/components/Input/index.d.ts +2 -0
  21. package/build/importer/components/Input/types/index.d.ts +18 -0
  22. package/build/importer/components/Portal/index.d.ts +3 -0
  23. package/build/importer/components/Portal/types/index.d.ts +5 -0
  24. package/build/importer/components/Stepper/hooks/useStepper.d.ts +2 -0
  25. package/build/importer/components/Stepper/index.d.ts +2 -0
  26. package/build/importer/components/Stepper/types/index.d.ts +13 -0
  27. package/build/importer/components/Table/index.d.ts +9 -0
  28. package/build/importer/components/Table/storyData.d.ts +36 -0
  29. package/build/importer/components/Table/types/index.d.ts +42 -0
  30. package/build/importer/components/ToggleFilter/ToggleFilter.stories.d.ts +18 -0
  31. package/build/importer/components/ToggleFilter/index.d.ts +3 -0
  32. package/build/importer/components/ToggleFilter/types/index.d.ts +11 -0
  33. package/build/importer/components/Tooltip/index.d.ts +2 -0
  34. package/build/importer/components/Tooltip/types/index.d.ts +11 -0
  35. package/build/importer/components/UploaderWrapper/UploaderWrapper.d.ts +2 -0
  36. package/build/importer/components/UploaderWrapper/types/index.d.ts +2 -0
  37. package/build/importer/features/complete/index.d.ts +2 -0
  38. package/build/importer/features/complete/types/index.d.ts +5 -0
  39. package/build/importer/features/main/hooks/useMutableLocalStorage.d.ts +1 -0
  40. package/build/importer/features/main/hooks/useStepNavigation.d.ts +17 -0
  41. package/build/importer/features/main/index.d.ts +2 -0
  42. package/build/importer/features/main/types/index.d.ts +16 -0
  43. package/build/importer/features/map-columns/components/DropDownFields.d.ts +19 -0
  44. package/build/importer/features/map-columns/hooks/useMapColumnsTable.d.ts +15 -0
  45. package/build/importer/features/map-columns/hooks/useNameChange.d.ts +5 -0
  46. package/build/importer/features/map-columns/index.d.ts +2 -0
  47. package/build/importer/features/map-columns/types/index.d.ts +23 -0
  48. package/build/importer/features/row-selection/index.d.ts +2 -0
  49. package/build/importer/features/row-selection/types/index.d.ts +8 -0
  50. package/build/importer/features/uploader/hooks/useTemplateTable.d.ts +10 -0
  51. package/build/importer/features/uploader/index.d.ts +2 -0
  52. package/build/importer/features/uploader/types/index.d.ts +9 -0
  53. package/build/importer/features/validate/index.d.ts +24 -0
  54. package/build/importer/features/validation/AIFixModal.d.ts +23 -0
  55. package/build/importer/features/validation/SimpleValidation.d.ts +2 -0
  56. package/build/importer/features/validation/Validation.d.ts +2 -0
  57. package/build/importer/features/validation/ValidationFixed.d.ts +2 -0
  58. package/build/importer/features/validation/components/AISuggestionsPanel.d.ts +15 -0
  59. package/build/importer/features/validation/components/InlineFixSuggestion.d.ts +8 -0
  60. package/build/importer/features/validation/index.d.ts +1 -0
  61. package/build/importer/features/validation/types.d.ts +31 -0
  62. package/build/importer/hooks/useClickOutside.d.ts +1 -0
  63. package/build/importer/hooks/useCustomStyles.d.ts +1 -0
  64. package/build/importer/hooks/useDelayLoader.d.ts +2 -0
  65. package/build/importer/hooks/useEventListener.d.ts +4 -0
  66. package/build/importer/hooks/useIsomorphicLayoutEffect.d.ts +3 -0
  67. package/build/importer/hooks/useRect.d.ts +12 -0
  68. package/build/importer/hooks/useWindowSize.d.ts +1 -0
  69. package/build/importer/providers/Theme.d.ts +4 -0
  70. package/build/importer/providers/index.d.ts +2 -0
  71. package/build/importer/providers/types/index.d.ts +4 -0
  72. package/build/importer/services/api.d.ts +0 -0
  73. package/build/importer/services/validation-api.d.ts +14 -0
  74. package/build/importer/settings/chakra/components/alert.d.ts +31 -0
  75. package/build/importer/settings/chakra/components/button.d.ts +37 -0
  76. package/build/importer/settings/chakra/components/index.d.ts +2 -0
  77. package/build/importer/settings/chakra/foundations/blur.d.ts +11 -0
  78. package/build/importer/settings/chakra/foundations/borders.d.ts +8 -0
  79. package/build/importer/settings/chakra/foundations/breakpoints.d.ts +9 -0
  80. package/build/importer/settings/chakra/foundations/colors.d.ts +247 -0
  81. package/build/importer/settings/chakra/foundations/index.d.ts +487 -0
  82. package/build/importer/settings/chakra/foundations/radius.d.ts +12 -0
  83. package/build/importer/settings/chakra/foundations/shadows.d.ts +14 -0
  84. package/build/importer/settings/chakra/foundations/sizes.d.ts +60 -0
  85. package/build/importer/settings/chakra/foundations/spacing.d.ts +35 -0
  86. package/build/importer/settings/chakra/foundations/transition.d.ts +24 -0
  87. package/build/importer/settings/chakra/foundations/typography.d.ts +61 -0
  88. package/build/importer/settings/chakra/foundations/z-index.d.ts +16 -0
  89. package/build/importer/settings/chakra/index.d.ts +592 -0
  90. package/build/importer/settings/chakra/semantic-tokens.d.ts +32 -0
  91. package/build/importer/settings/chakra/styles.d.ts +2 -0
  92. package/build/importer/settings/chakra/theme.types.d.ts +93 -0
  93. package/build/importer/settings/chakra/utils/is-chakra-theme.d.ts +3 -0
  94. package/build/importer/settings/chakra/utils/run-if-fn.d.ts +1 -0
  95. package/build/importer/settings/theme/colors.d.ts +4 -0
  96. package/build/importer/settings/theme/index.d.ts +2 -0
  97. package/build/importer/settings/theme/sizes.d.ts +7 -0
  98. package/build/importer/stores/theme.d.ts +17 -0
  99. package/build/importer/types/index.d.ts +17 -0
  100. package/build/importer/utils/classes.d.ts +2 -0
  101. package/build/importer/utils/debounce.d.ts +2 -0
  102. package/build/importer/utils/getStringLengthOfChildren.d.ts +2 -0
  103. package/build/importer/utils/stringSimilarity.d.ts +1 -0
  104. package/build/importer/utils/template.d.ts +2 -0
  105. package/build/importer/utils/utils.d.ts +11 -0
  106. package/build/index.d.ts +2 -0
  107. package/build/index.esm.js +54893 -0
  108. package/build/index.esm.js.map +1 -0
  109. package/build/index.js +54919 -0
  110. package/build/index.js.map +1 -0
  111. package/build/js.d.ts +31 -0
  112. package/build/services/api.d.ts +18 -0
  113. package/build/services/apiClient.d.ts +21 -0
  114. package/build/settings/defaults.d.ts +3 -0
  115. package/build/types/index.d.ts +24 -0
  116. package/build/types.d.ts +91 -0
  117. package/package.json +122 -0
package/build/js.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /// <reference types="react" />
2
+ import { CSVImporterProps } from "./types";
3
+ type CreateImporterProps = CSVImporterProps & {
4
+ domElement?: Element;
5
+ };
6
+ export declare function createCSVImporter(props: CreateImporterProps): {
7
+ instance: (import("react").ForwardRefExoticComponent<{
8
+ darkMode?: boolean | undefined;
9
+ primaryColor?: string | undefined;
10
+ className?: string | undefined;
11
+ onComplete?: ((data: any) => void) | undefined;
12
+ waitOnComplete?: boolean | undefined;
13
+ customStyles?: string | Record<string, string> | undefined;
14
+ showDownloadTemplateButton?: boolean | undefined;
15
+ skipHeaderRowSelection?: boolean | undefined;
16
+ language?: string | undefined;
17
+ customTranslations?: import("i18next").Resource | undefined;
18
+ importerKey?: string | undefined;
19
+ backendUrl?: string | undefined;
20
+ user?: Record<string, any> | undefined;
21
+ metadata?: Record<string, any> | undefined;
22
+ } & {
23
+ isModal?: boolean | undefined;
24
+ modalIsOpen?: boolean | undefined;
25
+ modalOnCloseTriggered?: (() => void) | undefined;
26
+ modalCloseOnOutsideClick?: boolean | undefined;
27
+ } & import("react").RefAttributes<unknown>> & HTMLDialogElement) | null;
28
+ showModal: () => void;
29
+ closeModal: () => void;
30
+ };
31
+ export {};
@@ -0,0 +1,18 @@
1
+ export namespace authApi {
2
+ function login(email: string, password: string): Promise<Object>;
3
+ function getCurrentUser(token: string): Promise<Object>;
4
+ }
5
+ export namespace schemaApi {
6
+ function getSchemas(token: string): Promise<any[]>;
7
+ function getSchemaTemplate(token: string, schemaId: number): Promise<Object>;
8
+ }
9
+ export namespace importApi {
10
+ function processCSVData(token: string, schemaId: number, importData: Object): Promise<Object>;
11
+ function getImportJobStatus(token: string, jobId: number): Promise<Object>;
12
+ }
13
+ declare namespace _default {
14
+ export { authApi as auth };
15
+ export { schemaApi as schema };
16
+ export { importApi as import };
17
+ }
18
+ export default _default;
@@ -0,0 +1,21 @@
1
+ export namespace authApi {
2
+ function login(email: string, password: string): Promise<Object>;
3
+ function logout(): Promise<void>;
4
+ function getCurrentUser(): Promise<Object>;
5
+ }
6
+ export namespace schemaApi {
7
+ function getSchemas(): Promise<any[]>;
8
+ function getSchemaTemplate(schemaId: number): Promise<Object>;
9
+ }
10
+ export namespace importApi {
11
+ function processCSVData(schemaId: number, importData: Object): Promise<Object>;
12
+ function getImportJobStatus(jobId: number): Promise<Object>;
13
+ }
14
+ declare namespace _default {
15
+ export { apiClient as client };
16
+ export { authApi as auth };
17
+ export { schemaApi as schema };
18
+ export { importApi as import };
19
+ }
20
+ export default _default;
21
+ declare const apiClient: any;
@@ -0,0 +1,3 @@
1
+ import { CSVImporterProps } from "../types";
2
+ declare const defaults: CSVImporterProps;
3
+ export default defaults;
@@ -0,0 +1,24 @@
1
+ import { Resource } from "i18next";
2
+ type ModalParams = {
3
+ isModal?: boolean;
4
+ modalIsOpen?: boolean;
5
+ modalOnCloseTriggered?: () => void;
6
+ modalCloseOnOutsideClick?: boolean;
7
+ };
8
+ export type CSVImporterProps = {
9
+ darkMode?: boolean;
10
+ primaryColor?: string;
11
+ className?: string;
12
+ onComplete?: (data: any) => void;
13
+ waitOnComplete?: boolean;
14
+ customStyles?: Record<string, string> | string;
15
+ showDownloadTemplateButton?: boolean;
16
+ skipHeaderRowSelection?: boolean;
17
+ language?: string;
18
+ customTranslations?: Resource;
19
+ importerKey?: string;
20
+ backendUrl?: string;
21
+ user?: Record<string, any>;
22
+ metadata?: Record<string, any>;
23
+ } & ModalParams;
24
+ export {};
@@ -0,0 +1,91 @@
1
+ /**
2
+ * CSV Importer Types
3
+ */
4
+ export interface TemplateColumn {
5
+ name: string;
6
+ key?: string;
7
+ required?: boolean;
8
+ description?: string;
9
+ data_type?: string;
10
+ suggested_mappings?: string[];
11
+ }
12
+ export interface Template {
13
+ columns: TemplateColumn[];
14
+ }
15
+ export interface ImporterOptions {
16
+ /** The importer ID to use for API calls */
17
+ importerId: string;
18
+ /** Whether to show the importer as a modal or embed it directly */
19
+ isModal?: boolean;
20
+ /** Whether the modal is open (only used when isModal is true) */
21
+ modalIsOpen?: boolean;
22
+ /** Function called when the modal close is triggered */
23
+ modalOnCloseTriggered?: () => void;
24
+ /** Whether clicking outside the modal should close it */
25
+ modalCloseOnOutsideClick?: boolean;
26
+ /** The template defining the columns to import */
27
+ template: Template | TemplateColumn[];
28
+ /** Whether to use dark mode */
29
+ darkMode?: boolean;
30
+ /** The primary color to use for the importer */
31
+ primaryColor?: string;
32
+ /** Additional CSS class names to apply */
33
+ className?: string;
34
+ /** Function called when the import is complete */
35
+ onComplete?: (data: any) => void;
36
+ /** Custom CSS styles to apply */
37
+ customStyles?: Record<string, any>;
38
+ /** Whether to show the download template button */
39
+ showDownloadTemplateButton?: boolean;
40
+ /** Whether to skip the header row selection step */
41
+ skipHeaderRowSelection?: boolean;
42
+ /** The language to use */
43
+ language?: string;
44
+ /** Custom translations to use */
45
+ customTranslations?: Record<string, Record<string, string>>;
46
+ /** Custom API URL to use (overrides global config) */
47
+ apiUrl?: string;
48
+ }
49
+ export interface CSVImporterProps {
50
+ /** The importer ID to use for API calls */
51
+ importerId?: string;
52
+ /** Whether to show the importer as a modal or embed it directly */
53
+ isModal?: boolean;
54
+ /** Whether the modal is open (only used when isModal is true) */
55
+ modalIsOpen?: boolean;
56
+ /** Function called when the modal close is triggered */
57
+ modalOnCloseTriggered?: () => void;
58
+ /** Whether clicking outside the modal should close it */
59
+ modalCloseOnOutsideClick?: boolean;
60
+ /** The template defining the columns to import */
61
+ template?: Template | TemplateColumn[];
62
+ /** Whether to use dark mode */
63
+ darkMode?: boolean;
64
+ /** The primary color to use for the importer */
65
+ primaryColor?: string;
66
+ /** Additional CSS class names to apply */
67
+ className?: string;
68
+ /** Function called when the import is complete */
69
+ onComplete?: (data: any) => void;
70
+ /** Custom CSS styles to apply */
71
+ customStyles?: Record<string, any>;
72
+ /** Whether to show the download template button */
73
+ showDownloadTemplateButton?: boolean;
74
+ /** Whether to skip the header row selection step */
75
+ skipHeaderRowSelection?: boolean;
76
+ /** The language to use */
77
+ language?: string;
78
+ /** Custom translations to use */
79
+ customTranslations?: Record<string, Record<string, string>>;
80
+ /** Custom API URL to use (overrides global config) */
81
+ apiUrl?: string;
82
+ /** Any additional props to pass to the component */
83
+ [key: string]: any;
84
+ }
85
+ export interface ImportResult {
86
+ job_id: string;
87
+ status: string;
88
+ total_rows: number;
89
+ valid_rows: number;
90
+ invalid_rows: number;
91
+ }
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "@importcsv/react",
3
+ "version": "0.1.0",
4
+ "description": "Open-source CSV and XLS/XLSX file importer for React and JavaScript",
5
+ "main": "build/index.js",
6
+ "module": "build/index.esm.js",
7
+ "files": [
8
+ "build"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/abhishekray07/importcsv.git"
13
+ },
14
+ "keywords": [
15
+ "csv",
16
+ "import",
17
+ "excel",
18
+ "data",
19
+ "importer",
20
+ "react",
21
+ "csv-import"
22
+ ],
23
+ "author": "ImportCSV",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/abhishekray07/importcsv/issues"
27
+ },
28
+ "homepage": "https://github.com/abhishekray07/importcsv#readme",
29
+ "types": "build/index.d.ts",
30
+ "scripts": {
31
+ "build:js": "rollup --config rollup.config-js.js && cp package-js.json build/package.json",
32
+ "build:react": "rollup --config rollup.config.js",
33
+ "build:react:dev": "NODE_ENV=development rollup --config rollup.config.js",
34
+ "build:react:prod": "NODE_ENV=production rollup --config rollup.config.js",
35
+ "publish:local:js": "yarn build:js && cd build && yalc publish",
36
+ "publish:local:react": "yarn build:react:dev && yalc publish",
37
+ "publish:local:react:prod": "yarn build:react:prod && yalc publish",
38
+ "publish:js": "yarn build:js && cd build && npm publish",
39
+ "publish:react": "yarn build:react:prod && npm publish --access public",
40
+ "build:watch": "NODE_ENV=development rollup -c -w",
41
+ "storybook": "storybook dev -p 6006",
42
+ "storybook:export": "build-storybook",
43
+ "generate": "node ./util/create-component",
44
+ "build-storybook": "storybook build"
45
+ },
46
+ "peerDependencies": {
47
+ "react": ">=18.0.0",
48
+ "react-dom": ">=18.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@babel/preset-env": "^7.22.4",
52
+ "@babel/preset-react": "^7.22.3",
53
+ "@babel/preset-typescript": "^7.21.5",
54
+ "@rollup/plugin-commonjs": "^17.1.0",
55
+ "@rollup/plugin-image": "^2.1.1",
56
+ "@rollup/plugin-node-resolve": "^11.2.1",
57
+ "@rollup/plugin-replace": "^5.0.5",
58
+ "@storybook/addon-essentials": "7.0.18",
59
+ "@storybook/addon-interactions": "7.0.18",
60
+ "@storybook/addon-links": "7.0.18",
61
+ "@storybook/blocks": "7.0.18",
62
+ "@storybook/react": "7.0.18",
63
+ "@storybook/react-webpack5": "7.0.18",
64
+ "@storybook/testing-library": "0.0.14-next.2",
65
+ "@trivago/prettier-plugin-sort-imports": "^4.1.1",
66
+ "@types/babel__core": "^7.20.1",
67
+ "@types/jest": "^24.9.1",
68
+ "@types/papaparse": "^5.3.14",
69
+ "@types/react": "^18.0.0",
70
+ "@types/react-dom": "^18.0.0",
71
+ "@types/use-sync-external-store": "0.0.3",
72
+ "@types/xlsx": "^0.0.36",
73
+ "@typescript-eslint/eslint-plugin": "^5.56.0",
74
+ "@typescript-eslint/parser": "^5.56.0",
75
+ "core-js": "^3.22.7",
76
+ "css-loader": "^6.8.1",
77
+ "eslint-config-prettier": "^8.8.0",
78
+ "eslint-plugin-prettier": "^4.2.1",
79
+ "eslint-plugin-react": "^7.32.2",
80
+ "identity-obj-proxy": "^3.0.0",
81
+ "jest": "^26.6.3",
82
+ "node-sass": "^9.0.0",
83
+ "prettier": "^2.8.6",
84
+ "prop-types": "^15.8.1",
85
+ "react": "18.2.0",
86
+ "react-dom": "18.2.0",
87
+ "rollup": "^2.56.3",
88
+ "rollup-plugin-copy": "^3.4.0",
89
+ "rollup-plugin-peer-deps-external": "^2.2.4",
90
+ "rollup-plugin-postcss": "^3.1.8",
91
+ "rollup-plugin-typescript2": "^0.29.0",
92
+ "sass": "^1.69.7",
93
+ "sass-loader": "^13.3.3",
94
+ "storybook": "7.0.18",
95
+ "style-loader": "^3.3.3",
96
+ "ts-jest": "^26.5.6",
97
+ "typescript": "^4.5.5",
98
+ "typescript-plugin-css-modules": "^3.4.0",
99
+ "use-sync-external-store": "^1.2.0"
100
+ },
101
+ "dependencies": {
102
+ "@chakra-ui/alert": "^2.2.2",
103
+ "@chakra-ui/button": "^2.1.0",
104
+ "@chakra-ui/react": "^2.8.1",
105
+ "@chakra-ui/system": "^2.6.2",
106
+ "@emotion/cache": "^11.11.0",
107
+ "@emotion/react": "^11.11.3",
108
+ "@emotion/styled": "^11.11.0",
109
+ "@rollup/plugin-json": "^6.1.0",
110
+ "@tanstack/react-table": "^8.21.3",
111
+ "framer-motion": "^10.17.12",
112
+ "i18next": "^23.10.1",
113
+ "papaparse": "^5.4.1",
114
+ "react-data-grid": "^7.0.0-beta.52",
115
+ "react-dropzone": "^14.2.3",
116
+ "react-i18next": "^14.1.0",
117
+ "react-icons": "^4.12.0",
118
+ "xlsx": "^0.18.5",
119
+ "zustand": "^4.4.7"
120
+ },
121
+ "type": "module"
122
+ }