@esvndev/es-react-config-setting 1.0.84 → 1.0.86

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/dist/index.js CHANGED
@@ -17134,6 +17134,8 @@ const SettingApp = (props) => {
17134
17134
  return { innerWidth, innerHeight };
17135
17135
  };
17136
17136
  const [windowSize, setWindowSize] = React.useState(getWindowSize());
17137
+ //Lưu dữ liệu tab đã chọn
17138
+ const dataTabSelected = React.useRef({});
17137
17139
  //Cho phép tự đóng hoặc không
17138
17140
  const [backdrop, setBackdrop] = React.useState(true);
17139
17141
  //Sự kiện đóng/mở cài đặt
@@ -17163,6 +17165,7 @@ const SettingApp = (props) => {
17163
17165
  }]
17164
17166
  }, obj.file, (rs) => {
17165
17167
  console.log(rs);
17168
+ loadSettingConfigByGroup(dataTabSelected.current);
17166
17169
  });
17167
17170
  if (eventChange)
17168
17171
  eventChange([{ key: obj.key, value: obj.value, state: "update" }]);
@@ -17206,6 +17209,7 @@ const SettingApp = (props) => {
17206
17209
  }, [settingData]);
17207
17210
  //Sự kiện chọn nhóm cài đặt
17208
17211
  const switchSettingTab = (data) => {
17212
+ dataTabSelected.current = data;
17209
17213
  const updated = dataSettingGroup.map((item) => ({
17210
17214
  ...item,
17211
17215
  active: item.id === data.id
@@ -17223,19 +17227,22 @@ const SettingApp = (props) => {
17223
17227
  allowed_defects_per_model_day: null
17224
17228
  }).current;
17225
17229
  //Cấu hình thông số delay tránh gửi liên tục
17226
- const change_save = (root, obj, e) => {
17230
+ const change_save = (root, obj, e, index, _index, dataRoot) => {
17227
17231
  const _m = saveSettings;
17228
17232
  if (saveSettings && _m[obj.id] !== null) {
17229
17233
  clearTimeout(_m[obj.id]);
17230
17234
  }
17235
+ let time_update = 1000;
17231
17236
  let value;
17232
17237
  let value_file;
17233
17238
  if (e.target.type === "checkbox") {
17234
17239
  value = e.target.checked;
17240
+ time_update = 100;
17235
17241
  }
17236
17242
  else if (e.target.type === "file") {
17237
17243
  value = e.target.value;
17238
17244
  value_file = e.target.files?.[0] ?? null;
17245
+ time_update = 100;
17239
17246
  }
17240
17247
  else {
17241
17248
  value = e.target.value;
@@ -17254,17 +17261,19 @@ const SettingApp = (props) => {
17254
17261
  };
17255
17262
  _m[obj.id] = setTimeout(() => {
17256
17263
  _eventChange(_data);
17257
- }, 1000);
17264
+ }, time_update);
17265
+ dataRoot[index].data[_index] = value;
17266
+ setSettingData([...dataRoot]);
17258
17267
  };
17259
17268
  //Hàm sử dụng tạo theo loại giá trị
17260
- const _renderInput = (root, data) => {
17269
+ const _renderInput = (root, data, index, _index, dataRoot) => {
17261
17270
  const value = formState[data.id] ?? data.value ?? "";
17262
17271
  switch (data.type) {
17263
17272
  case "switch":
17264
17273
  case "checkbox":
17265
- return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { style: { width: '237px !important' }, type: "checkbox", checked: (value === "true"), onChange: (e) => change_save(root, data, e) }) }, data.id));
17274
+ return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { style: { width: '237px !important' }, type: "checkbox", checked: (value === "true"), onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17266
17275
  case "radio":
17267
- return (jsxRuntime.jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxRuntime.jsxs("label", { children: [jsxRuntime.jsx(Input$1, { type: "radio", name: data.name, value: opt.value, checked: value === opt.value, onChange: (e) => change_save(root, data, e) }), opt.name] }, index))) }, data.id));
17276
+ return (jsxRuntime.jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxRuntime.jsxs("label", { children: [jsxRuntime.jsx(Input$1, { type: "radio", name: data.name, value: opt.value, checked: value === opt.value, onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }), opt.name] }, index))) }, data.id));
17268
17277
  case "combobox":
17269
17278
  let _data_option = [];
17270
17279
  if (data.option) {
@@ -17276,7 +17285,7 @@ const SettingApp = (props) => {
17276
17285
  }
17277
17286
  }
17278
17287
  data.option = _data_option;
17279
- return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, value: value, onChange: (e) => change_save(root, data, e), children: [jsxRuntime.jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsxRuntime.jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
17288
+ return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, value: value, onChange: (e) => change_save(root, data, e, index, _index, dataRoot), children: [jsxRuntime.jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsxRuntime.jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
17280
17289
  case "slider":
17281
17290
  case "text":
17282
17291
  case "password":
@@ -17285,12 +17294,12 @@ const SettingApp = (props) => {
17285
17294
  case "time":
17286
17295
  case "datetime":
17287
17296
  case "color":
17288
- return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => change_save(root, data, e) }) }, data.id));
17297
+ return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17289
17298
  case "image":
17290
17299
  case "file":
17291
- return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => change_save(root, data, e) }) }, data.id));
17300
+ return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17292
17301
  default:
17293
- return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => change_save(root, data, e) }) }, data.id));
17302
+ return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17294
17303
  }
17295
17304
  };
17296
17305
  //hàm tạo các thông số cấu hình và cài đặt
@@ -17300,7 +17309,7 @@ const SettingApp = (props) => {
17300
17309
  jsxRuntime.jsx("div", { className: "setting-section-desc", children: jsxRuntime.jsx("div", { className: "", children: jsxRuntime.jsx("span", { children: item.description }) }) })
17301
17310
  : null, item.data ?
17302
17311
  jsxRuntime.jsx("div", { className: "setting-section-content ", children: item.data.length > 0 ? item.data.map((_item, _index) => {
17303
- return (jsxRuntime.jsxs("div", { className: 'flx flx-al-c flx-sp-btw setting-section-content__item ' + (item.data.length === 1 ? "single" : (_index === 0 ? 'first' : (_index === item.data.length - 1 ? 'last' : ""))), children: [jsxRuntime.jsxs("div", { className: "flx flx-col", style: { flex: "0 0 fit-content", maxWidth: '50%' }, children: [jsxRuntime.jsx("span", { children: _item.name }), jsxRuntime.jsx("span", { className: "setting-section-content__description", children: _item.description })] }), jsxRuntime.jsx("div", { style: { maxWidth: "50%" }, children: jsxRuntime.jsx("div", { style: { width: "100%", boxSizing: "border-box" }, children: _renderInput(item, _item) }) })] }));
17312
+ return (jsxRuntime.jsxs("div", { className: 'flx flx-al-c flx-sp-btw setting-section-content__item ' + (item.data.length === 1 ? "single" : (_index === 0 ? 'first' : (_index === item.data.length - 1 ? 'last' : ""))), children: [jsxRuntime.jsxs("div", { className: "flx flx-col", style: { flex: "0 0 fit-content", maxWidth: '50%' }, children: [jsxRuntime.jsx("span", { children: _item.name }), jsxRuntime.jsx("span", { className: "setting-section-content__description", children: _item.description })] }), jsxRuntime.jsx("div", { style: { maxWidth: "50%" }, children: jsxRuntime.jsx("div", { style: { width: "100%", boxSizing: "border-box" }, children: _renderInput(item, _item, index, _index, settingData) }) })] }));
17304
17313
  }) : null }) : null] }));
17305
17314
  })
17306
17315
  : null);