@fctc/sme-widget-ui 1.4.8 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,93 +1,93 @@
1
- # edu-widget-ui
2
-
3
-
4
-
5
- ## Getting started
6
-
7
- To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8
-
9
- Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10
-
11
- ## Add your files
12
-
13
- - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14
- - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15
-
16
- ```
17
- cd existing_repo
18
- git remote add origin https://gitlab.atomsolution.vn/education-erp/edu-widget-ui.git
19
- git branch -M main
20
- git push -uf origin main
21
- ```
22
-
23
- ## Integrate with your tools
24
-
25
- - [ ] [Set up project integrations](https://gitlab.atomsolution.vn/education-erp/edu-widget-ui/-/settings/integrations)
26
-
27
- ## Collaborate with your team
28
-
29
- - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30
- - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31
- - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32
- - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33
- - [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34
-
35
- ## Test and Deploy
36
-
37
- Use the built-in continuous integration in GitLab.
38
-
39
- - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40
- - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41
- - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42
- - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43
- - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44
-
45
- ***
46
-
47
- # Editing this README
48
-
49
- When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
50
-
51
- ## Suggestions for a good README
52
-
53
- Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
54
-
55
- ## Name
56
- Choose a self-explaining name for your project.
57
-
58
- ## Description
59
- Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
60
-
61
- ## Badges
62
- On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
63
-
64
- ## Visuals
65
- Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
66
-
67
- ## Installation
68
- Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
69
-
70
- ## Usage
71
- Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
72
-
73
- ## Support
74
- Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
75
-
76
- ## Roadmap
77
- If you have ideas for releases in the future, it is a good idea to list them in the README.
78
-
79
- ## Contributing
80
- State if you are open to contributions and what your requirements are for accepting them.
81
-
82
- For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
83
-
84
- You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
85
-
86
- ## Authors and acknowledgment
87
- Show your appreciation to those who have contributed to the project.
88
-
89
- ## License
90
- For open source projects, say how it is licensed.
91
-
92
- ## Project status
93
- If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
1
+ # edu-widget-ui
2
+
3
+
4
+
5
+ ## Getting started
6
+
7
+ To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8
+
9
+ Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10
+
11
+ ## Add your files
12
+
13
+ - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14
+ - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15
+
16
+ ```
17
+ cd existing_repo
18
+ git remote add origin https://gitlab.atomsolution.vn/education-erp/edu-widget-ui.git
19
+ git branch -M main
20
+ git push -uf origin main
21
+ ```
22
+
23
+ ## Integrate with your tools
24
+
25
+ - [ ] [Set up project integrations](https://gitlab.atomsolution.vn/education-erp/edu-widget-ui/-/settings/integrations)
26
+
27
+ ## Collaborate with your team
28
+
29
+ - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30
+ - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31
+ - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32
+ - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33
+ - [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34
+
35
+ ## Test and Deploy
36
+
37
+ Use the built-in continuous integration in GitLab.
38
+
39
+ - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40
+ - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41
+ - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42
+ - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43
+ - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44
+
45
+ ***
46
+
47
+ # Editing this README
48
+
49
+ When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
50
+
51
+ ## Suggestions for a good README
52
+
53
+ Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
54
+
55
+ ## Name
56
+ Choose a self-explaining name for your project.
57
+
58
+ ## Description
59
+ Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
60
+
61
+ ## Badges
62
+ On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
63
+
64
+ ## Visuals
65
+ Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
66
+
67
+ ## Installation
68
+ Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
69
+
70
+ ## Usage
71
+ Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
72
+
73
+ ## Support
74
+ Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
75
+
76
+ ## Roadmap
77
+ If you have ideas for releases in the future, it is a good idea to list them in the README.
78
+
79
+ ## Contributing
80
+ State if you are open to contributions and what your requirements are for accepting them.
81
+
82
+ For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
83
+
84
+ You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
85
+
86
+ ## Authors and acknowledgment
87
+ Show your appreciation to those who have contributed to the project.
88
+
89
+ ## License
90
+ For open source projects, say how it is licensed.
91
+
92
+ ## Project status
93
+ If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
package/dist/.babelrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-env",
4
+ "@babel/preset-react",
5
+ "@babel/preset-typescript"
6
+ ]
7
+ }
@@ -0,0 +1,10 @@
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ insert_final_newline = true
6
+
7
+ [*.{js,json,yml}]
8
+ charset = utf-8
9
+ indent_style = space
10
+ indent_size = 2
@@ -0,0 +1,6 @@
1
+ dist
2
+ .cache
3
+ package-lock.json
4
+ public
5
+ node_modules
6
+ yarn.lock
@@ -0,0 +1,66 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: { browser: true, es2020: true },
4
+ extends: [
5
+ 'eslint:recommended',
6
+ 'plugin:@typescript-eslint/recommended',
7
+ 'plugin:prettier/recommended',
8
+ ],
9
+ ignorePatterns: ['dist', '.eslintrc.cjs', 'commitlint.config.cjs'],
10
+ parser: '@typescript-eslint/parser',
11
+ overrides: [
12
+ {
13
+ files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.cjs'],
14
+ plugins: [
15
+ '@typescript-eslint',
16
+ 'unused-imports',
17
+ 'simple-import-sort',
18
+ 'react-refresh',
19
+ ],
20
+ rules: {
21
+ 'react-refresh/only-export-components': [
22
+ 'warn',
23
+ { allowConstantExport: true },
24
+ ],
25
+ 'import/prefer-default-export': 'off',
26
+ 'simple-import-sort/imports': [
27
+ 'error',
28
+ {
29
+ groups: [
30
+ // Packages `react` related packages come first.
31
+ ['^react', '^@?\\w'],
32
+ // Internal packages.
33
+ ['^(@|components)(/.*|$)'],
34
+ // Side effect imports.
35
+ ['^\\u0000'],
36
+ // Parent imports. Put `..` last.
37
+ ['^\\.\\.(?!/?$)', '^\\.\\./?$'],
38
+ // Other relative imports. Put same-folder imports and `.` last.
39
+ ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
40
+ // Style imports.
41
+ ['^.+\\.?(css)$'],
42
+ ],
43
+ },
44
+ ],
45
+ 'prettier/prettier': [
46
+ 'error',
47
+ {
48
+ endOfLine: 'auto',
49
+ },
50
+ ],
51
+ 'react/react-in-jsx-scope': 'off',
52
+ 'no-param-reassign': 'off',
53
+ 'simple-import-sort/exports': 'error',
54
+ '@typescript-eslint/no-unused-vars': 'off',
55
+ '@typescript-eslint/no-non-null-assertion': 'off',
56
+ '@typescript-eslint/no-explicit-any': 'off',
57
+ '@typescript-eslint/ban-ts-comment': 'off',
58
+ '@typescript-eslint/ban-types': 'off',
59
+ 'unused-imports/no-unused-imports': 'error',
60
+ 'unused-imports/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
61
+ 'no-plusplus': 'off',
62
+ 'no-case-declarations': 'off',
63
+ },
64
+ },
65
+ ],
66
+ }
@@ -0,0 +1,4 @@
1
+ /.yarn/** linguist-vendored
2
+ /.yarn/releases/* binary
3
+ /.yarn/plugins/**/* binary
4
+ /.pnp.* binary linguist-generated
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": true,
3
+ "semi": false
4
+ }
package/dist/index.js CHANGED
@@ -17994,22 +17994,24 @@ var ButtonSelectFiles = ({
17994
17994
  }
17995
17995
  return true;
17996
17996
  };
17997
+ const convertFileToBase64 = (file) => {
17998
+ return new Promise((resolve, reject) => {
17999
+ const reader = new FileReader();
18000
+ reader.readAsDataURL(file);
18001
+ reader.onload = () => resolve(reader.result);
18002
+ reader.onerror = (error2) => reject(error2);
18003
+ });
18004
+ };
17997
18005
  const handleOnChange = async (event) => {
17998
18006
  const files = Array.from(event.target.files ?? []);
17999
- setUploadError();
18000
18007
  event.target.value = "";
18001
- if (files.length > 0) {
18002
- const file = files[0];
18003
- if (!validateFile(file)) {
18004
- return;
18005
- }
18006
- setUploadError(false);
18007
- const formData = new FormData();
18008
- formData.append("ufile", file);
18009
- formData.append("thread_model", String(model));
18010
- formData.append("thread_id", Number(id));
18011
- formData.append("is_pending", true);
18012
- await handleUploadImage({ formData });
18008
+ if (files.length === 0) return;
18009
+ const file = files[0];
18010
+ try {
18011
+ const base64 = await convertFileToBase64(file);
18012
+ setSelectedFiles([...selectedFiles, { name: file.name, data: base64 }]);
18013
+ } catch (error2) {
18014
+ console.error("Error converting file:", error2);
18013
18015
  }
18014
18016
  };
18015
18017
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
@@ -32881,7 +32883,19 @@ var FeeField = (props) => {
32881
32883
  var import_react54 = require("react");
32882
32884
  var import_jsx_runtime83 = require("react/jsx-runtime");
32883
32885
  var FileUploadField = (props) => {
32884
- const { name: name2, methods, isForm, model, required, idForm, widget, useUploadImage, useUploadFile, useGetImage, isBase64File } = props;
32886
+ const {
32887
+ name: name2,
32888
+ methods,
32889
+ isForm,
32890
+ model,
32891
+ required,
32892
+ idForm,
32893
+ widget,
32894
+ useUploadImage,
32895
+ useUploadFile,
32896
+ useGetImage,
32897
+ isBase64File
32898
+ } = props;
32885
32899
  const fileInputRef = (0, import_react54.useRef)(null);
32886
32900
  const [selectedFiles, setSelectedFiles] = (0, import_react54.useState)([]);
32887
32901
  const [uploadError, setUploadError] = (0, import_react54.useState)();
@@ -32895,11 +32909,11 @@ var FileUploadField = (props) => {
32895
32909
  },
32896
32910
  render: ({ field: { onChange: onChange2 }, fieldState: { error: error2 } }) => {
32897
32911
  (0, import_react54.useEffect)(() => {
32898
- let datas = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.datas;
32899
- if (widget !== "many2many_binary" && datas && isBase64File(datas)) {
32900
- datas = datas.split(",")[1];
32912
+ let data = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.data;
32913
+ if (widget !== "many2many_binary" && data && isBase64File(data)) {
32914
+ data = data.split(",")[1];
32901
32915
  }
32902
- onChange2(datas || null);
32916
+ onChange2(data || null);
32903
32917
  if (model === "ir.attachment") {
32904
32918
  methods.setValue(
32905
32919
  "name",
package/dist/index.mjs CHANGED
@@ -17875,22 +17875,24 @@ var ButtonSelectFiles = ({
17875
17875
  }
17876
17876
  return true;
17877
17877
  };
17878
+ const convertFileToBase64 = (file) => {
17879
+ return new Promise((resolve, reject) => {
17880
+ const reader = new FileReader();
17881
+ reader.readAsDataURL(file);
17882
+ reader.onload = () => resolve(reader.result);
17883
+ reader.onerror = (error2) => reject(error2);
17884
+ });
17885
+ };
17878
17886
  const handleOnChange = async (event) => {
17879
17887
  const files = Array.from(event.target.files ?? []);
17880
- setUploadError();
17881
17888
  event.target.value = "";
17882
- if (files.length > 0) {
17883
- const file = files[0];
17884
- if (!validateFile(file)) {
17885
- return;
17886
- }
17887
- setUploadError(false);
17888
- const formData = new FormData();
17889
- formData.append("ufile", file);
17890
- formData.append("thread_model", String(model));
17891
- formData.append("thread_id", Number(id));
17892
- formData.append("is_pending", true);
17893
- await handleUploadImage({ formData });
17889
+ if (files.length === 0) return;
17890
+ const file = files[0];
17891
+ try {
17892
+ const base64 = await convertFileToBase64(file);
17893
+ setSelectedFiles([...selectedFiles, { name: file.name, data: base64 }]);
17894
+ } catch (error2) {
17895
+ console.error("Error converting file:", error2);
17894
17896
  }
17895
17897
  };
17896
17898
  return /* @__PURE__ */ jsxs45(Fragment13, { children: [
@@ -32762,7 +32764,19 @@ var FeeField = (props) => {
32762
32764
  import { useEffect as useEffect16, useRef as useRef14, useState as useState16 } from "react";
32763
32765
  import { jsx as jsx85, jsxs as jsxs58 } from "react/jsx-runtime";
32764
32766
  var FileUploadField = (props) => {
32765
- const { name: name2, methods, isForm, model, required, idForm, widget, useUploadImage, useUploadFile, useGetImage, isBase64File } = props;
32767
+ const {
32768
+ name: name2,
32769
+ methods,
32770
+ isForm,
32771
+ model,
32772
+ required,
32773
+ idForm,
32774
+ widget,
32775
+ useUploadImage,
32776
+ useUploadFile,
32777
+ useGetImage,
32778
+ isBase64File
32779
+ } = props;
32766
32780
  const fileInputRef = useRef14(null);
32767
32781
  const [selectedFiles, setSelectedFiles] = useState16([]);
32768
32782
  const [uploadError, setUploadError] = useState16();
@@ -32776,11 +32790,11 @@ var FileUploadField = (props) => {
32776
32790
  },
32777
32791
  render: ({ field: { onChange: onChange2 }, fieldState: { error: error2 } }) => {
32778
32792
  useEffect16(() => {
32779
- let datas = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.datas;
32780
- if (widget !== "many2many_binary" && datas && isBase64File(datas)) {
32781
- datas = datas.split(",")[1];
32793
+ let data = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.data;
32794
+ if (widget !== "many2many_binary" && data && isBase64File(data)) {
32795
+ data = data.split(",")[1];
32782
32796
  }
32783
- onChange2(datas || null);
32797
+ onChange2(data || null);
32784
32798
  if (model === "ir.attachment") {
32785
32799
  methods.setValue(
32786
32800
  "name",
package/dist/widgets.js CHANGED
@@ -17620,22 +17620,24 @@ var ButtonSelectFiles = ({
17620
17620
  }
17621
17621
  return true;
17622
17622
  };
17623
+ const convertFileToBase64 = (file) => {
17624
+ return new Promise((resolve, reject) => {
17625
+ const reader = new FileReader();
17626
+ reader.readAsDataURL(file);
17627
+ reader.onload = () => resolve(reader.result);
17628
+ reader.onerror = (error2) => reject(error2);
17629
+ });
17630
+ };
17623
17631
  const handleOnChange = async (event) => {
17624
17632
  const files = Array.from(event.target.files ?? []);
17625
- setUploadError();
17626
17633
  event.target.value = "";
17627
- if (files.length > 0) {
17628
- const file = files[0];
17629
- if (!validateFile(file)) {
17630
- return;
17631
- }
17632
- setUploadError(false);
17633
- const formData = new FormData();
17634
- formData.append("ufile", file);
17635
- formData.append("thread_model", String(model));
17636
- formData.append("thread_id", Number(id));
17637
- formData.append("is_pending", true);
17638
- await handleUploadImage({ formData });
17634
+ if (files.length === 0) return;
17635
+ const file = files[0];
17636
+ try {
17637
+ const base64 = await convertFileToBase64(file);
17638
+ setSelectedFiles([...selectedFiles, { name: file.name, data: base64 }]);
17639
+ } catch (error2) {
17640
+ console.error("Error converting file:", error2);
17639
17641
  }
17640
17642
  };
17641
17643
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
@@ -32507,7 +32509,19 @@ var FeeField = (props) => {
32507
32509
  var import_react54 = require("react");
32508
32510
  var import_jsx_runtime83 = require("react/jsx-runtime");
32509
32511
  var FileUploadField = (props) => {
32510
- const { name: name2, methods, isForm, model, required, idForm, widget, useUploadImage, useUploadFile, useGetImage, isBase64File } = props;
32512
+ const {
32513
+ name: name2,
32514
+ methods,
32515
+ isForm,
32516
+ model,
32517
+ required,
32518
+ idForm,
32519
+ widget,
32520
+ useUploadImage,
32521
+ useUploadFile,
32522
+ useGetImage,
32523
+ isBase64File
32524
+ } = props;
32511
32525
  const fileInputRef = (0, import_react54.useRef)(null);
32512
32526
  const [selectedFiles, setSelectedFiles] = (0, import_react54.useState)([]);
32513
32527
  const [uploadError, setUploadError] = (0, import_react54.useState)();
@@ -32521,11 +32535,11 @@ var FileUploadField = (props) => {
32521
32535
  },
32522
32536
  render: ({ field: { onChange: onChange2 }, fieldState: { error: error2 } }) => {
32523
32537
  (0, import_react54.useEffect)(() => {
32524
- let datas = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.datas;
32525
- if (widget !== "many2many_binary" && datas && isBase64File(datas)) {
32526
- datas = datas.split(",")[1];
32538
+ let data = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.data;
32539
+ if (widget !== "many2many_binary" && data && isBase64File(data)) {
32540
+ data = data.split(",")[1];
32527
32541
  }
32528
- onChange2(datas || null);
32542
+ onChange2(data || null);
32529
32543
  if (model === "ir.attachment") {
32530
32544
  methods.setValue(
32531
32545
  "name",
package/dist/widgets.mjs CHANGED
@@ -17557,22 +17557,24 @@ var ButtonSelectFiles = ({
17557
17557
  }
17558
17558
  return true;
17559
17559
  };
17560
+ const convertFileToBase64 = (file) => {
17561
+ return new Promise((resolve, reject) => {
17562
+ const reader = new FileReader();
17563
+ reader.readAsDataURL(file);
17564
+ reader.onload = () => resolve(reader.result);
17565
+ reader.onerror = (error2) => reject(error2);
17566
+ });
17567
+ };
17560
17568
  const handleOnChange = async (event) => {
17561
17569
  const files = Array.from(event.target.files ?? []);
17562
- setUploadError();
17563
17570
  event.target.value = "";
17564
- if (files.length > 0) {
17565
- const file = files[0];
17566
- if (!validateFile(file)) {
17567
- return;
17568
- }
17569
- setUploadError(false);
17570
- const formData = new FormData();
17571
- formData.append("ufile", file);
17572
- formData.append("thread_model", String(model));
17573
- formData.append("thread_id", Number(id));
17574
- formData.append("is_pending", true);
17575
- await handleUploadImage({ formData });
17571
+ if (files.length === 0) return;
17572
+ const file = files[0];
17573
+ try {
17574
+ const base64 = await convertFileToBase64(file);
17575
+ setSelectedFiles([...selectedFiles, { name: file.name, data: base64 }]);
17576
+ } catch (error2) {
17577
+ console.error("Error converting file:", error2);
17576
17578
  }
17577
17579
  };
17578
17580
  return /* @__PURE__ */ jsxs45(Fragment13, { children: [
@@ -32444,7 +32446,19 @@ var FeeField = (props) => {
32444
32446
  import { useEffect as useEffect16, useRef as useRef14, useState as useState16 } from "react";
32445
32447
  import { jsx as jsx85, jsxs as jsxs58 } from "react/jsx-runtime";
32446
32448
  var FileUploadField = (props) => {
32447
- const { name: name2, methods, isForm, model, required, idForm, widget, useUploadImage, useUploadFile, useGetImage, isBase64File } = props;
32449
+ const {
32450
+ name: name2,
32451
+ methods,
32452
+ isForm,
32453
+ model,
32454
+ required,
32455
+ idForm,
32456
+ widget,
32457
+ useUploadImage,
32458
+ useUploadFile,
32459
+ useGetImage,
32460
+ isBase64File
32461
+ } = props;
32448
32462
  const fileInputRef = useRef14(null);
32449
32463
  const [selectedFiles, setSelectedFiles] = useState16([]);
32450
32464
  const [uploadError, setUploadError] = useState16();
@@ -32458,11 +32472,11 @@ var FileUploadField = (props) => {
32458
32472
  },
32459
32473
  render: ({ field: { onChange: onChange2 }, fieldState: { error: error2 } }) => {
32460
32474
  useEffect16(() => {
32461
- let datas = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.datas;
32462
- if (widget !== "many2many_binary" && datas && isBase64File(datas)) {
32463
- datas = datas.split(",")[1];
32475
+ let data = widget === "many2many_binary" ? selectedFiles : selectedFiles?.[0]?.data;
32476
+ if (widget !== "many2many_binary" && data && isBase64File(data)) {
32477
+ data = data.split(",")[1];
32464
32478
  }
32465
- onChange2(datas || null);
32479
+ onChange2(data || null);
32466
32480
  if (model === "ir.attachment") {
32467
32481
  methods.setValue(
32468
32482
  "name",
package/package.json CHANGED
@@ -1,71 +1,71 @@
1
- {
2
- "name": "@fctc/sme-widget-ui",
3
- "version": "1.4.8",
4
- "main": "dist/index.cjs",
5
- "module": "dist/index.mjs",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.mjs",
11
- "require": "./dist/index.cjs"
12
- },
13
- "./hooks": {
14
- "types": "./dist/hooks.d.ts",
15
- "import": "./dist/hooks.mjs",
16
- "require": "./dist/hooks.cjs"
17
- },
18
- "./icons": {
19
- "types": "./dist/icons.d.ts",
20
- "import": "./dist/icons.mjs",
21
- "require": "./dist/icons.cjs"
22
- },
23
- "./types": {
24
- "types": "./dist/types.d.ts",
25
- "import": "./dist/types.mjs",
26
- "require": "./dist/types.cjs"
27
- },
28
- "./widgets": {
29
- "types": "./dist/widgets.d.ts",
30
- "import": "./dist/widgets.mjs",
31
- "require": "./dist/widgets.cjs"
32
- },
33
- "./utils": {
34
- "types": "./dist/utils.d.ts",
35
- "import": "./dist/utils.mjs",
36
- "require": "./dist/utils.cjs"
37
- }
38
- },
39
- "files": [
40
- "dist"
41
- ],
42
- "scripts": {
43
- "build": "tsup",
44
- "test": "jest"
45
- },
46
- "dependencies": {
47
- "@headlessui/react": "^2.2.7",
48
- "@types/react-dom": "^19.1.7",
49
- "react-dom": "18.0.0",
50
- "zod": "^3.24.2"
51
- },
52
- "devDependencies": {
53
- "@hookform/resolvers": "^4.1.3",
54
- "@types/react": "18.0.0",
55
- "i18next": "^24.2.3",
56
- "i18next-browser-languagedetector": "^8.0.4",
57
- "jest": "^29.7.0",
58
- "moment": "^2.30.1",
59
- "react": "18.0.0",
60
- "react-datepicker": "^8.2.1",
61
- "react-hook-form": "^7.54.2",
62
- "react-i18next": "^15.4.1",
63
- "react-redux": "^9.2.0",
64
- "react-select": "^5.10.1",
65
- "react-toastify": "^11.0.5",
66
- "react-tooltip": "^5.28.0",
67
- "tailwindcss": "^3",
68
- "tsup": "^8.0.0",
69
- "typescript": "^5.8.2"
70
- }
71
- }
1
+ {
2
+ "name": "@fctc/sme-widget-ui",
3
+ "version": "1.4.9",
4
+ "main": "dist/index.cjs",
5
+ "module": "dist/index.mjs",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.cjs"
12
+ },
13
+ "./hooks": {
14
+ "types": "./dist/hooks.d.ts",
15
+ "import": "./dist/hooks.mjs",
16
+ "require": "./dist/hooks.cjs"
17
+ },
18
+ "./icons": {
19
+ "types": "./dist/icons.d.ts",
20
+ "import": "./dist/icons.mjs",
21
+ "require": "./dist/icons.cjs"
22
+ },
23
+ "./types": {
24
+ "types": "./dist/types.d.ts",
25
+ "import": "./dist/types.mjs",
26
+ "require": "./dist/types.cjs"
27
+ },
28
+ "./widgets": {
29
+ "types": "./dist/widgets.d.ts",
30
+ "import": "./dist/widgets.mjs",
31
+ "require": "./dist/widgets.cjs"
32
+ },
33
+ "./utils": {
34
+ "types": "./dist/utils.d.ts",
35
+ "import": "./dist/utils.mjs",
36
+ "require": "./dist/utils.cjs"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "scripts": {
43
+ "build": "tsup",
44
+ "test": "jest"
45
+ },
46
+ "dependencies": {
47
+ "@headlessui/react": "^2.2.7",
48
+ "@types/react-dom": "^19.1.7",
49
+ "react-dom": "18.0.0",
50
+ "zod": "^3.24.2"
51
+ },
52
+ "devDependencies": {
53
+ "@hookform/resolvers": "^4.1.3",
54
+ "@types/react": "18.0.0",
55
+ "i18next": "^24.2.3",
56
+ "i18next-browser-languagedetector": "^8.0.4",
57
+ "jest": "^29.7.0",
58
+ "moment": "^2.30.1",
59
+ "react": "18.0.0",
60
+ "react-datepicker": "^8.2.1",
61
+ "react-hook-form": "^7.54.2",
62
+ "react-i18next": "^15.4.1",
63
+ "react-redux": "^9.2.0",
64
+ "react-select": "^5.10.1",
65
+ "react-toastify": "^11.0.5",
66
+ "react-tooltip": "^5.28.0",
67
+ "tailwindcss": "^3",
68
+ "tsup": "^8.0.0",
69
+ "typescript": "^5.8.2"
70
+ }
71
+ }