awing-library 2.1.139-beta → 2.1.141-beta

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.
@@ -86,13 +86,14 @@ var convertValueByType = function (type, val) {
86
86
  if (typeof val === 'string')
87
87
  val = val === 'true';
88
88
  }
89
- else if (type === Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER) {
90
- val = parseInt(val);
91
- }
92
89
  else if (type === Enum_1.TYPE_FIELD_TEMPLATE.DROPDOWN_LIST) {
93
90
  var spl = val.split('\\n');
94
91
  val = spl[0].trim();
95
92
  }
93
+ // Không parse số, trong trường hợp số có thể float
94
+ // else if (type === TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER) {
95
+ // // val = parseInt(val)
96
+ // }
96
97
  return val;
97
98
  };
98
99
  exports.convertValueByType = convertValueByType;
@@ -65,6 +65,7 @@ function BasicField(props) {
65
65
  register = hookControl.register, errors = hookControl.formState.errors, getValues = hookControl.getValues, setFormValue = hookControl.setFormValue;
66
66
  (0, react_1.useEffect)(function () {
67
67
  var isNotSubField = fieldPath.split('.').length === 3;
68
+ var timeOut;
68
69
  if (isNotSubField) {
69
70
  if (fieldType === Enum_1.TYPE_FIELD_TEMPLATE.CHECKBOX) {
70
71
  if (defaultValue === 'true' &&
@@ -76,14 +77,19 @@ function BasicField(props) {
76
77
  }
77
78
  }
78
79
  else {
80
+ console.log("fieldValue", { fieldValue: fieldValue });
79
81
  if (defaultValue && !fieldValue) {
80
- setTimeout(function () {
82
+ timeOut = setTimeout(function () {
81
83
  setFormValue(fieldPath, defaultValue);
82
84
  onChange(fieldPath);
83
85
  }, 0);
84
86
  }
85
87
  }
86
88
  }
89
+ return function () {
90
+ if (timeOut)
91
+ clearTimeout(timeOut);
92
+ };
87
93
  // eslint-disable-next-line react-hooks/exhaustive-deps
88
94
  }, []);
89
95
  var handleChange = function (newValue) {
@@ -107,7 +113,6 @@ function BasicField(props) {
107
113
  }));
108
114
  switch (fieldType) {
109
115
  case Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER:
110
- return renderTextField(field, isError);
111
116
  case Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD:
112
117
  case Enum_1.TYPE_FIELD_TEMPLATE.URL:
113
118
  return renderTextField(field, isError);
@@ -128,43 +133,11 @@ function BasicField(props) {
128
133
  default:
129
134
  return null;
130
135
  }
131
- // return (
132
- // <Controller
133
- // name={fieldPath}
134
- // {...register(fieldPath, { required: isRequired })}
135
- // ref={null}
136
- // control={control}
137
- // render={({ field }) => {
138
- // switch (fieldType) {
139
- // case TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER:
140
- // return renderTextField(field, isError)
141
- // case TYPE_FIELD_TEMPLATE.TEXT_FIELD:
142
- // return renderTextField(field, isError)
143
- // case TYPE_FIELD_TEMPLATE.TEXTAREA:
144
- // return renderTextField(field, isError)
145
- // case TYPE_FIELD_TEMPLATE.DROPDOWN_LIST:
146
- // return renderDropdownListField(field, isError)
147
- // case TYPE_FIELD_TEMPLATE.CHECKBOX:
148
- // return renderCheckboxField(field)
149
- // case TYPE_FIELD_TEMPLATE.COLOR:
150
- // return renderColorField(field, isError)
151
- // case TYPE_FIELD_TEMPLATE.IMAGE:
152
- // return renderImageOrVideoField(isError)
153
- // case TYPE_FIELD_TEMPLATE.VIDEO:
154
- // return renderImageOrVideoField(isError)
155
- // case TYPE_FIELD_TEMPLATE.HTML:
156
- // return renderHTMLField()
157
- // default:
158
- // return null
159
- // }
160
- // }}
161
- // ></Controller>
162
- // )
163
136
  };
164
137
  var renderTextField = function (field, isError) {
165
- return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({}, field, { className: classes.text, required: isRequired, fullWidth: true }, (fieldType === Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER
166
- ? { type: 'number' }
167
- : {}), (fieldType === Enum_1.TYPE_FIELD_TEMPLATE.TEXTAREA
138
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({}, field, { className: classes.text, required: isRequired, fullWidth: true, inputProps: fieldType === Enum_1.TYPE_FIELD_TEMPLATE.TEXT_FIELD_NUMBER
139
+ ? { type: 'number' }
140
+ : {} }, (fieldType === Enum_1.TYPE_FIELD_TEMPLATE.TEXTAREA
168
141
  ? { multiline: true, rows: 4 }
169
142
  : {}), { variant: "standard", label: labelName || fieldName, onChange: function (e) {
170
143
  handleChange(e.target.value);
@@ -58,12 +58,11 @@ var runScript = function (params, script) {
58
58
  };
59
59
  exports.runScript = runScript;
60
60
  var convertRelativeLink = function (link, pagePath, templateId, configs) {
61
- var isTemplatePath = (link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_TEMPLATE_PATH)) || (link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_PAGE_PATH));
61
+ var isTemplatePath = link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_TEMPLATE_PATH);
62
62
  if (isTemplatePath) {
63
63
  return "".concat(configs.TEMPLATE_FILE_PATH, "/").concat(templateId, "/").concat(link.split("/")[link.split("/").length - 1]);
64
64
  }
65
- return link;
66
- // return `${pagePath}/${link.split("/")[link.split("/").length - 1]}` || "";
65
+ return (link === null || link === void 0 ? void 0 : link.includes(constant_1.ACM_PAGE_PATH)) ? "".concat(pagePath, "/").concat(link.split("/")[link.split("/").length - 1]) || "" : link;
67
66
  };
68
67
  exports.convertRelativeLink = convertRelativeLink;
69
68
  var generateRandomInteger = function (max) {
@@ -60,10 +60,6 @@ function ViewTemplate(_a) {
60
60
  control: control,
61
61
  name: "templateDatas",
62
62
  }).fields;
63
- // const { fields } = useFieldArray({
64
- // control,
65
- // name: "templateDatas",
66
- // });
67
63
  (0, react_1.useEffect)(function () {
68
64
  var language = localStorage.getItem("i18nextLng");
69
65
  i18n_1.default.changeLanguage(language || "vi");
@@ -117,21 +113,18 @@ var addChilds = function (fields, fieldInfo) {
117
113
  }
118
114
  return result;
119
115
  };
120
- var convertToTreeData = function (data) {
121
- var treeData = data
122
- .map(function (item) { return addChilds(data, item); })
123
- .filter(function (item) { return !item.fieldName.includes("."); })
124
- .map(function (item) {
125
- if ([Enum_1.TYPE_FIELD_TEMPLATE.LIST, Enum_1.TYPE_FIELD_TEMPLATE.OBJECT].includes(item.fieldType)) {
126
- return __assign(__assign({}, item), { fieldValue: item.fieldValue && (0, common_1.isJSON)(item.fieldValue)
127
- ? JSON.parse(item.fieldValue)
128
- : item.fieldType === Enum_1.TYPE_FIELD_TEMPLATE.LIST
129
- ? []
130
- : {} });
131
- }
132
- else {
133
- return item;
134
- }
135
- });
136
- return treeData;
137
- };
116
+ var convertToTreeData = function (data) { return data
117
+ .map(function (item) { return addChilds(data, item); })
118
+ .filter(function (item) { return !item.fieldName.includes("."); })
119
+ .map(function (item) {
120
+ if ([Enum_1.TYPE_FIELD_TEMPLATE.LIST, Enum_1.TYPE_FIELD_TEMPLATE.OBJECT].includes(item.fieldType)) {
121
+ return __assign(__assign({}, item), { fieldValue: item.fieldValue && (0, common_1.isJSON)(item.fieldValue)
122
+ ? JSON.parse(item.fieldValue)
123
+ : item.fieldType === Enum_1.TYPE_FIELD_TEMPLATE.LIST
124
+ ? []
125
+ : {} });
126
+ }
127
+ else {
128
+ return item;
129
+ }
130
+ }); };
@@ -74,7 +74,7 @@ var EnhancedDialog = function (props) {
74
74
  };
75
75
  return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: isOpen, onClose: handleClose, "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", maxWidth: "sm", fullWidth: true, children: [(0, jsx_runtime_1.jsx)(DialogTitle_1.default, { id: "alert-dialog-title", children: title !== null && title !== void 0 ? title : t('Dialog.Title') }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [(0, jsx_runtime_1.jsx)(DialogContentText_1.default, { id: "alert-dialog-description", sx: { marginBottom: function (theme) { return theme.spacing(1.5); } }, children: content !== null && content !== void 0 ? content : t('Dialog.Content') }), !notIncludeInput && ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ autoFocus: true, margin: "dense", label: props.label, rows: 2, multiline: true, type: "text", name: "text", value: text, onChange: function (e) {
76
76
  setText(e.target.value);
77
- setValid((0, validation_1.textValidation)(e.target.value));
77
+ setValid((0, validation_1.textValidation)(e.target.value, 50, true, false));
78
78
  }, fullWidth: true, onKeyDown: handleKeyDown, error: !checkValid.valid, helperText: !checkValid.valid ? checkValid.message : '' }, textFieldProps)))] }), (0, jsx_runtime_1.jsxs)(DialogActions_1.default, { children: [(0, jsx_runtime_1.jsx)(Button_1.default, { onClick: handleClose, color: "secondary", children: t('Common.Cancel') }), (0, jsx_runtime_1.jsx)(Button_1.default, { disabled: !(!notIncludeInput && checkValid.valid), onClick: function () { return handleSubmit(); }, color: "primary", children: t('Common.Agree') })] })] }));
79
79
  };
80
80
  exports.default = EnhancedDialog;
package/package.json CHANGED
@@ -1,129 +1,129 @@
1
1
  {
2
- "name": "awing-library",
3
- "version": "2.1.139-beta",
4
- "description": "",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "files": [
8
- "lib"
9
- ],
10
- "resolutions": {
11
- "react-error-overlay": "6.0.9"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "https://gitlab.awing.vn/awing-libraries/react"
16
- },
17
- "dependencies": {
18
- "@date-io/date-fns": "^2.17.0",
19
- "@emotion/react": "^11.11.1",
20
- "@emotion/styled": "^11.11.0",
21
- "@goongmaps/goong-geocoder-react": "^0.1.1",
22
- "@goongmaps/goong-map-react": "^1.0.9",
23
- "@microsoft/signalr": "^8.0.0",
24
- "@monaco-editor/react": "^4.6.0",
25
- "@mui/icons-material": "^5.14.14",
26
- "@mui/lab": "5.0.0-alpha.149",
27
- "@mui/material": "^5.14.14",
28
- "@mui/styles": "^5.14.14",
29
- "@mui/x-charts": "^6.19.3",
30
- "@mui/x-date-pickers": "6.18.1",
31
- "@mui/x-tree-view": "^6.17.0",
32
- "@testing-library/jest-dom": "^6.1.4",
33
- "@testing-library/react": "^14.0.0",
34
- "@testing-library/user-event": "^14.5.1",
35
- "@types/file-saver": "^2.0.7",
36
- "@types/jest": "^29.5.6",
37
- "@types/lodash": "^4.17.0",
38
- "@types/node": "^20.8.8",
39
- "@types/react": "^18.2.31",
40
- "@types/react-dom": "^18.2.14",
41
- "aphrodite": "^2.4.0",
42
- "chart.js": "^4.4.1",
43
- "chartjs-adapter-moment": "^1.0.1",
44
- "concurrently": "^8.2.2",
45
- "dayjs": "^1.11.10",
46
- "enzyme": "^3.11.0",
47
- "faker": "^6.6.6",
48
- "file-saver": "^2.0.5",
49
- "i18next": "^23.6.0",
50
- "lodash": "^4.17.21",
51
- "moment": "^2.29.4",
52
- "prismjs": "^1.29.0",
53
- "process": "^0.11.10",
54
- "react": "^18.2.0",
55
- "react-chartjs-2": "^5.2.0",
56
- "react-dates": "^21.8.0",
57
- "react-diff-viewer": "^3.1.1",
58
- "react-dom": "^18.2.0",
59
- "react-helmet-async": "^2.0.4",
60
- "react-hook-form": "^7.48.2",
61
- "react-i18next": "^13.3.1",
62
- "react-input-mask": "^2.0.4",
63
- "react-router-dom": "^6.18.0",
64
- "react-scripts": "5.0.1",
65
- "react-with-styles": "^5.0.0",
66
- "react-with-styles-interface-aphrodite": "^6.0.1",
67
- "recoil": "^0.7.7",
68
- "typescript": "^5.2.2",
69
- "web-vitals": "^3.5.0",
70
- "xlsx": "^0.18.5"
71
- },
72
- "scripts": {
73
- "prepare": "npm run build",
74
- "dopublish": "npm publish",
75
- "start": "react-scripts start",
76
- "clean": "rm -rf ./lib",
77
- "test": "react-scripts test",
78
- "eject": "react-scripts eject",
79
- "storybook": "storybook dev -p 6006",
80
- "build-storybook": "storybook build",
81
- "build": "npm run clean && tsc && tsc-alias && npm run copy",
82
- "copy": "cp -r ./src/Assets/ ./lib/Assets",
83
- "build:watch": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")"
84
- },
85
- "prettier": {
86
- "trailingComma": "es5",
87
- "tabWidth": 4,
88
- "semi": false,
89
- "singleQuote": true
90
- },
91
- "eslintConfig": {
92
- "extends": [
93
- "react-app",
94
- "react-app/jest",
95
- "plugin:storybook/recommended"
96
- ]
97
- },
98
- "browserslist": {
99
- "production": [
100
- ">0.2%",
101
- "not dead",
102
- "not op_mini all"
2
+ "name": "awing-library",
3
+ "version": "2.1.141-beta",
4
+ "description": "",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib"
103
9
  ],
104
- "development": [
105
- "last 1 chrome version",
106
- "last 1 firefox version",
107
- "last 1 safari version"
108
- ]
109
- },
110
- "devDependencies": {
111
- "@faker-js/faker": "^8.4.1",
112
- "@storybook/addon-essentials": "^7.0.26",
113
- "@storybook/addon-interactions": "^7.0.26",
114
- "@storybook/addon-links": "^7.0.26",
115
- "@storybook/blocks": "^7.0.26",
116
- "@storybook/preset-create-react-app": "^7.0.26",
117
- "@storybook/react": "^7.0.26",
118
- "@storybook/react-webpack5": "^7.0.26",
119
- "@storybook/testing-library": "^0.0.14-next.2",
120
- "@types/prismjs": "^1.26.3",
121
- "babel-plugin-named-exports-order": "^0.0.2",
122
- "copyfiles": "^2.4.1",
123
- "eslint-plugin-storybook": "^0.6.12",
124
- "prop-types": "^15.8.1",
125
- "storybook": "^7.0.26",
126
- "tsc-alias": "^1.8.8",
127
- "webpack": "^5.88.1"
128
- }
10
+ "resolutions": {
11
+ "react-error-overlay": "6.0.9"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://gitlab.awing.vn/awing-libraries/react"
16
+ },
17
+ "dependencies": {
18
+ "@date-io/date-fns": "^2.17.0",
19
+ "@emotion/react": "^11.11.1",
20
+ "@emotion/styled": "^11.11.0",
21
+ "@goongmaps/goong-geocoder-react": "^0.1.1",
22
+ "@goongmaps/goong-map-react": "^1.0.9",
23
+ "@microsoft/signalr": "^8.0.0",
24
+ "@monaco-editor/react": "^4.6.0",
25
+ "@mui/icons-material": "^5.14.14",
26
+ "@mui/lab": "5.0.0-alpha.149",
27
+ "@mui/material": "^5.14.14",
28
+ "@mui/styles": "^5.14.14",
29
+ "@mui/x-charts": "^6.19.3",
30
+ "@mui/x-date-pickers": "6.18.1",
31
+ "@mui/x-tree-view": "^6.17.0",
32
+ "@testing-library/jest-dom": "^6.1.4",
33
+ "@testing-library/react": "^14.0.0",
34
+ "@testing-library/user-event": "^14.5.1",
35
+ "@types/file-saver": "^2.0.7",
36
+ "@types/jest": "^29.5.6",
37
+ "@types/lodash": "^4.17.0",
38
+ "@types/node": "^20.8.8",
39
+ "@types/react": "^18.2.31",
40
+ "@types/react-dom": "^18.2.14",
41
+ "aphrodite": "^2.4.0",
42
+ "chart.js": "^4.4.1",
43
+ "chartjs-adapter-moment": "^1.0.1",
44
+ "concurrently": "^8.2.2",
45
+ "dayjs": "^1.11.10",
46
+ "enzyme": "^3.11.0",
47
+ "faker": "^6.6.6",
48
+ "file-saver": "^2.0.5",
49
+ "i18next": "^23.6.0",
50
+ "lodash": "^4.17.21",
51
+ "moment": "^2.29.4",
52
+ "prismjs": "^1.29.0",
53
+ "process": "^0.11.10",
54
+ "react": "^18.2.0",
55
+ "react-chartjs-2": "^5.2.0",
56
+ "react-dates": "^21.8.0",
57
+ "react-diff-viewer": "^3.1.1",
58
+ "react-dom": "^18.2.0",
59
+ "react-helmet-async": "^2.0.4",
60
+ "react-hook-form": "^7.48.2",
61
+ "react-i18next": "^13.3.1",
62
+ "react-input-mask": "^2.0.4",
63
+ "react-router-dom": "^6.18.0",
64
+ "react-scripts": "5.0.1",
65
+ "react-with-styles": "^5.0.0",
66
+ "react-with-styles-interface-aphrodite": "^6.0.1",
67
+ "recoil": "^0.7.7",
68
+ "typescript": "^5.2.2",
69
+ "web-vitals": "^3.5.0",
70
+ "xlsx": "^0.18.5"
71
+ },
72
+ "scripts": {
73
+ "prepare": "npm run build",
74
+ "dopublish": "npm publish",
75
+ "start": "react-scripts start",
76
+ "clean": "rm -rf ./lib",
77
+ "test": "react-scripts test",
78
+ "eject": "react-scripts eject",
79
+ "storybook": "storybook dev -p 6006",
80
+ "build-storybook": "storybook build",
81
+ "build": "npm run clean && tsc && tsc-alias && npm run copy",
82
+ "copy": "cp -r ./src/Assets/ ./lib/Assets",
83
+ "build:watch": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")"
84
+ },
85
+ "prettier": {
86
+ "trailingComma": "es5",
87
+ "tabWidth": 4,
88
+ "semi": false,
89
+ "singleQuote": true
90
+ },
91
+ "eslintConfig": {
92
+ "extends": [
93
+ "react-app",
94
+ "react-app/jest",
95
+ "plugin:storybook/recommended"
96
+ ]
97
+ },
98
+ "browserslist": {
99
+ "production": [
100
+ ">0.2%",
101
+ "not dead",
102
+ "not op_mini all"
103
+ ],
104
+ "development": [
105
+ "last 1 chrome version",
106
+ "last 1 firefox version",
107
+ "last 1 safari version"
108
+ ]
109
+ },
110
+ "devDependencies": {
111
+ "@faker-js/faker": "^8.4.1",
112
+ "@storybook/addon-essentials": "^7.0.26",
113
+ "@storybook/addon-interactions": "^7.0.26",
114
+ "@storybook/addon-links": "^7.0.26",
115
+ "@storybook/blocks": "^7.0.26",
116
+ "@storybook/preset-create-react-app": "^7.0.26",
117
+ "@storybook/react": "^7.0.26",
118
+ "@storybook/react-webpack5": "^7.0.26",
119
+ "@storybook/testing-library": "^0.0.14-next.2",
120
+ "@types/prismjs": "^1.26.3",
121
+ "babel-plugin-named-exports-order": "^0.0.2",
122
+ "copyfiles": "^2.4.1",
123
+ "eslint-plugin-storybook": "^0.6.12",
124
+ "prop-types": "^15.8.1",
125
+ "storybook": "^7.0.26",
126
+ "tsc-alias": "^1.8.8",
127
+ "webpack": "^5.88.1"
128
+ }
129
129
  }