@fctc/sme-widget-ui 1.2.3 → 1.2.4

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
@@ -12081,7 +12081,7 @@ var Row = (props) => {
12081
12081
  }, [row?.id, selectedRowKeys, checkedAll]);
12082
12082
  const handleCheckBoxSingle = (event) => {
12083
12083
  event.stopPropagation();
12084
- if (checkedAll && checkboxRef && checkboxRef.current) {
12084
+ if (checkedAll) {
12085
12085
  checkboxRef.current = "uncheck";
12086
12086
  setIsAutoSelect(true);
12087
12087
  return;
@@ -12094,7 +12094,7 @@ var Row = (props) => {
12094
12094
  };
12095
12095
  (0, import_react11.useEffect)(() => {
12096
12096
  if (!row?.id) return;
12097
- if (isAutoSelect && checkboxRef && checkboxRef.current) {
12097
+ if (isAutoSelect) {
12098
12098
  if (checkboxRef?.current === "uncheck") {
12099
12099
  const filtered = selectedRowKeysRef.current.filter(
12100
12100
  (id) => id !== row.id
@@ -12111,9 +12111,9 @@ var Row = (props) => {
12111
12111
  }
12112
12112
  }, [isAutoSelect]);
12113
12113
  (0, import_react11.useEffect)(() => {
12114
- if (!checkedAll && checkboxRef && checkboxRef.current) {
12114
+ if (!checkedAll) {
12115
12115
  checkboxRef.current = "enabled";
12116
- false;
12116
+ setIsAutoSelect(false);
12117
12117
  }
12118
12118
  }, [checkedAll]);
12119
12119
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
@@ -12312,7 +12312,7 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
12312
12312
  style: {
12313
12313
  transform: "translateY(-50%)"
12314
12314
  },
12315
- className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-[#eff1f2]",
12315
+ className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-white",
12316
12316
  children: [
12317
12317
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
12318
12318
  "button",
@@ -12383,7 +12383,11 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
12383
12383
  "div",
12384
12384
  {
12385
12385
  ref: filterPopupRef,
12386
- style: { top: filterPosition?.top, right: filterPosition?.right },
12386
+ style: {
12387
+ top: filterPosition?.top,
12388
+ right: filterPosition?.right,
12389
+ zIndex: 9999
12390
+ },
12387
12391
  className: "absolute z-[9999] flex w-[250px] h-auto max-h-[800%] overflow-auto flex-col gap-[16px] rounded-[8px] bg-[#fff] px-[24px] py-[16px] shadow-md",
12388
12392
  children: columns?.filter((val) => val?.optional !== void 0)?.map((item) => {
12389
12393
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex items-center gap-2", children: [
@@ -12489,7 +12493,7 @@ var TableHead = (props) => {
12489
12493
  style: {
12490
12494
  userSelect: "none",
12491
12495
  WebkitUserSelect: "none",
12492
- zIndex: 1,
12496
+ zIndex: 10,
12493
12497
  position: "sticky",
12494
12498
  top: 0
12495
12499
  },
@@ -12528,7 +12532,7 @@ var TableHead = (props) => {
12528
12532
  minWidth: "40px",
12529
12533
  right: 0
12530
12534
  },
12531
- className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-[#eff1f2]`,
12535
+ className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-white`,
12532
12536
  children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
12533
12537
  TableFilter,
12534
12538
  {
@@ -15103,7 +15107,8 @@ var TagSearch = ({
15103
15107
  removeSearchItems,
15104
15108
  selectedTags,
15105
15109
  filterBy,
15106
- setFilterBy
15110
+ setFilterBy,
15111
+ setGroupBy
15107
15112
  }) => {
15108
15113
  return selectedTags?.length > 0 && selectedTags?.map((tag, index4) => {
15109
15114
  if (tag?.values?.length > 0) {
@@ -15175,6 +15180,12 @@ var TagSearch = ({
15175
15180
  onClick: () => {
15176
15181
  if (tag?.type === SearchType.GROUP) {
15177
15182
  typeof removeSearchItems === "function" && removeSearchItems(`${SearchType.GROUP}`);
15183
+ setGroupBy(
15184
+ (prev2) => prev2?.map((item) => ({
15185
+ ...item,
15186
+ active: false
15187
+ }))
15188
+ );
15178
15189
  }
15179
15190
  },
15180
15191
  children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CloseIcon, { className: "size-4 cursor-pointer" })
@@ -15239,7 +15250,16 @@ var SearchList = ({
15239
15250
  instance.t("for"),
15240
15251
  ":",
15241
15252
  " ",
15242
- /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "custom-input-result text-primary font-bold italic", children: searchString })
15253
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
15254
+ "span",
15255
+ {
15256
+ style: {
15257
+ color: "var(--color-primary)"
15258
+ },
15259
+ className: "custom-input-result text-primary font-bold italic",
15260
+ children: searchString
15261
+ }
15262
+ )
15243
15263
  ]
15244
15264
  },
15245
15265
  "header-" + index4 + 1
@@ -15295,6 +15315,8 @@ var Search = ({
15295
15315
  }
15296
15316
  }, [selectedTags, isReadyFormatDomain]);
15297
15317
  (0, import_react18.useEffect)(() => {
15318
+ setDidInit(false);
15319
+ setIsReadyFormatDomain(false);
15298
15320
  return () => {
15299
15321
  clearSearch();
15300
15322
  setDidInit(false);
@@ -15302,13 +15324,14 @@ var Search = ({
15302
15324
  };
15303
15325
  }, [aid]);
15304
15326
  (0, import_react18.useEffect)(() => {
15305
- if (!filterBy) return;
15306
- if (didInit || selectedTags?.length > 0) return;
15327
+ if (!filterBy || !fieldsList || fieldsList?.length === 0) return;
15328
+ if (didInit) return;
15307
15329
  const searchDefaults = Object.entries(context || {}).filter(
15308
15330
  ([key]) => key.startsWith("search_default_")
15309
15331
  );
15332
+ const defaultGroupBy = context ? Object.entries(context).filter(([key]) => key.includes("group_by")) : [];
15310
15333
  const hasGroupBy = viewData?.views?.search?.filters_by?.length > 0;
15311
- if (searchDefaults.length === 0 && !hasGroupBy) {
15334
+ if (searchDefaults.length === 0 && !hasGroupBy && defaultGroupBy?.length === 0) {
15312
15335
  setIsReadyFormatDomain(true);
15313
15336
  setDidInit(true);
15314
15337
  return;
@@ -15329,8 +15352,24 @@ var Search = ({
15329
15352
  }
15330
15353
  return item;
15331
15354
  });
15355
+ const updatedGroupBy = groupBy?.map((item) => {
15356
+ const defaultGroupByItem = defaultGroupBy.find(
15357
+ ([_2, value]) => item?.context?.includes(value)
15358
+ );
15359
+ if (defaultGroupByItem && typeof handleAddTagSearch == "function") {
15360
+ handleAddTagSearch({
15361
+ name: item?.name,
15362
+ value: item?.string,
15363
+ type: SearchType.GROUP,
15364
+ context: JSON.parse(item?.context.replace(/'/g, '"'))
15365
+ });
15366
+ return { ...item, active: true };
15367
+ }
15368
+ return item;
15369
+ });
15332
15370
  if (updatedFilter) setFilterBy(updatedFilter);
15333
- if (hasGroupBy && fieldsList?.length > 0) {
15371
+ if (updatedGroupBy) setGroupBy(updatedGroupBy);
15372
+ if (hasGroupBy) {
15334
15373
  viewData?.views?.search?.filters_by?.forEach((item, idx) => {
15335
15374
  const groupCtx = evalJSONContext(item?.context);
15336
15375
  handleAddTagSearch?.({
@@ -15343,8 +15382,8 @@ var Search = ({
15343
15382
  fieldsGroup: fieldsList
15344
15383
  });
15345
15384
  });
15346
- setDidInit(true);
15347
15385
  }
15386
+ setDidInit(true);
15348
15387
  setIsReadyFormatDomain(true);
15349
15388
  }, [aid, filterBy, fieldsList]);
15350
15389
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
@@ -15361,7 +15400,8 @@ var Search = ({
15361
15400
  removeSearchItems,
15362
15401
  selectedTags,
15363
15402
  filterBy,
15364
- setFilterBy
15403
+ setFilterBy,
15404
+ setGroupBy
15365
15405
  }
15366
15406
  ),
15367
15407
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
@@ -34507,7 +34547,12 @@ var Many2OneField = (props) => {
34507
34547
  menuPlacement: "bottom",
34508
34548
  menuPortalTarget: typeof window !== "undefined" ? document.body : null,
34509
34549
  styles: {
34510
- control: () => ({}),
34550
+ control: (base) => ({
34551
+ ...base,
34552
+ "&:focus": {
34553
+ borderColor: "var(--color-primary)"
34554
+ }
34555
+ }),
34511
34556
  container: (base) => ({
34512
34557
  ...base,
34513
34558
  height: "100%"
@@ -34671,8 +34716,8 @@ var StatusBarOptionField = (props) => {
34671
34716
  // pr-[20px]
34672
34717
  fontWeight: 600,
34673
34718
  // font-semibold
34674
- fontSize: "12px",
34675
- background: value ? "var(--primary-color)" : "#FAFAFA",
34719
+ fontSize: "14px",
34720
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34676
34721
  color: value ? "#fff" : "#121212",
34677
34722
  borderTopLeftRadius: index4 === 0 ? "0.75rem" : "0px",
34678
34723
  // rounded-l-xl
@@ -34703,12 +34748,12 @@ var StatusBarOptionField = (props) => {
34703
34748
  width: "25.5px",
34704
34749
  height: "25.5px",
34705
34750
  right: value ? "-13px" : "-12.5px",
34706
- background: value ? "var(--primary-color)" : "#FAFAFA",
34707
- border: value ? "1px solid var(--primary-color)" : "1px solid rgba(0,0,0,0.04)",
34708
- borderBottomColor: value ? "var(--primary-color)" : "#FAFAFA",
34709
- borderLeftColor: value ? "var(--primary-color)" : "#FAFAFA",
34710
- borderTopColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)",
34711
- borderRightColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)"
34751
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34752
+ border: value ? "1px solid var(--color-primary)" : "1px solid rgba(0,0,0,0.04)",
34753
+ borderBottomColor: value ? "var(--color-primary)" : "#FAFAFA",
34754
+ borderLeftColor: value ? "var(--color-primary)" : "#FAFAFA",
34755
+ borderTopColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)",
34756
+ borderRightColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)"
34712
34757
  }
34713
34758
  }
34714
34759
  )
package/dist/index.mjs CHANGED
@@ -11962,7 +11962,7 @@ var Row = (props) => {
11962
11962
  }, [row?.id, selectedRowKeys, checkedAll]);
11963
11963
  const handleCheckBoxSingle = (event) => {
11964
11964
  event.stopPropagation();
11965
- if (checkedAll && checkboxRef && checkboxRef.current) {
11965
+ if (checkedAll) {
11966
11966
  checkboxRef.current = "uncheck";
11967
11967
  setIsAutoSelect(true);
11968
11968
  return;
@@ -11975,7 +11975,7 @@ var Row = (props) => {
11975
11975
  };
11976
11976
  useEffect3(() => {
11977
11977
  if (!row?.id) return;
11978
- if (isAutoSelect && checkboxRef && checkboxRef.current) {
11978
+ if (isAutoSelect) {
11979
11979
  if (checkboxRef?.current === "uncheck") {
11980
11980
  const filtered = selectedRowKeysRef.current.filter(
11981
11981
  (id) => id !== row.id
@@ -11992,9 +11992,9 @@ var Row = (props) => {
11992
11992
  }
11993
11993
  }, [isAutoSelect]);
11994
11994
  useEffect3(() => {
11995
- if (!checkedAll && checkboxRef && checkboxRef.current) {
11995
+ if (!checkedAll) {
11996
11996
  checkboxRef.current = "enabled";
11997
- false;
11997
+ setIsAutoSelect(false);
11998
11998
  }
11999
11999
  }, [checkedAll]);
12000
12000
  return /* @__PURE__ */ jsx40(
@@ -12193,7 +12193,7 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
12193
12193
  style: {
12194
12194
  transform: "translateY(-50%)"
12195
12195
  },
12196
- className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-[#eff1f2]",
12196
+ className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-white",
12197
12197
  children: [
12198
12198
  /* @__PURE__ */ jsx42(
12199
12199
  "button",
@@ -12264,7 +12264,11 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
12264
12264
  "div",
12265
12265
  {
12266
12266
  ref: filterPopupRef,
12267
- style: { top: filterPosition?.top, right: filterPosition?.right },
12267
+ style: {
12268
+ top: filterPosition?.top,
12269
+ right: filterPosition?.right,
12270
+ zIndex: 9999
12271
+ },
12268
12272
  className: "absolute z-[9999] flex w-[250px] h-auto max-h-[800%] overflow-auto flex-col gap-[16px] rounded-[8px] bg-[#fff] px-[24px] py-[16px] shadow-md",
12269
12273
  children: columns?.filter((val) => val?.optional !== void 0)?.map((item) => {
12270
12274
  return /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-2", children: [
@@ -12370,7 +12374,7 @@ var TableHead = (props) => {
12370
12374
  style: {
12371
12375
  userSelect: "none",
12372
12376
  WebkitUserSelect: "none",
12373
- zIndex: 1,
12377
+ zIndex: 10,
12374
12378
  position: "sticky",
12375
12379
  top: 0
12376
12380
  },
@@ -12409,7 +12413,7 @@ var TableHead = (props) => {
12409
12413
  minWidth: "40px",
12410
12414
  right: 0
12411
12415
  },
12412
- className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-[#eff1f2]`,
12416
+ className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-white`,
12413
12417
  children: /* @__PURE__ */ jsx44(
12414
12418
  TableFilter,
12415
12419
  {
@@ -14984,7 +14988,8 @@ var TagSearch = ({
14984
14988
  removeSearchItems,
14985
14989
  selectedTags,
14986
14990
  filterBy,
14987
- setFilterBy
14991
+ setFilterBy,
14992
+ setGroupBy
14988
14993
  }) => {
14989
14994
  return selectedTags?.length > 0 && selectedTags?.map((tag, index4) => {
14990
14995
  if (tag?.values?.length > 0) {
@@ -15056,6 +15061,12 @@ var TagSearch = ({
15056
15061
  onClick: () => {
15057
15062
  if (tag?.type === SearchType.GROUP) {
15058
15063
  typeof removeSearchItems === "function" && removeSearchItems(`${SearchType.GROUP}`);
15064
+ setGroupBy(
15065
+ (prev2) => prev2?.map((item) => ({
15066
+ ...item,
15067
+ active: false
15068
+ }))
15069
+ );
15059
15070
  }
15060
15071
  },
15061
15072
  children: /* @__PURE__ */ jsx56(CloseIcon, { className: "size-4 cursor-pointer" })
@@ -15120,7 +15131,16 @@ var SearchList = ({
15120
15131
  instance.t("for"),
15121
15132
  ":",
15122
15133
  " ",
15123
- /* @__PURE__ */ jsx57("span", { className: "custom-input-result text-primary font-bold italic", children: searchString })
15134
+ /* @__PURE__ */ jsx57(
15135
+ "span",
15136
+ {
15137
+ style: {
15138
+ color: "var(--color-primary)"
15139
+ },
15140
+ className: "custom-input-result text-primary font-bold italic",
15141
+ children: searchString
15142
+ }
15143
+ )
15124
15144
  ]
15125
15145
  },
15126
15146
  "header-" + index4 + 1
@@ -15176,6 +15196,8 @@ var Search = ({
15176
15196
  }
15177
15197
  }, [selectedTags, isReadyFormatDomain]);
15178
15198
  useEffect6(() => {
15199
+ setDidInit(false);
15200
+ setIsReadyFormatDomain(false);
15179
15201
  return () => {
15180
15202
  clearSearch();
15181
15203
  setDidInit(false);
@@ -15183,13 +15205,14 @@ var Search = ({
15183
15205
  };
15184
15206
  }, [aid]);
15185
15207
  useEffect6(() => {
15186
- if (!filterBy) return;
15187
- if (didInit || selectedTags?.length > 0) return;
15208
+ if (!filterBy || !fieldsList || fieldsList?.length === 0) return;
15209
+ if (didInit) return;
15188
15210
  const searchDefaults = Object.entries(context || {}).filter(
15189
15211
  ([key]) => key.startsWith("search_default_")
15190
15212
  );
15213
+ const defaultGroupBy = context ? Object.entries(context).filter(([key]) => key.includes("group_by")) : [];
15191
15214
  const hasGroupBy = viewData?.views?.search?.filters_by?.length > 0;
15192
- if (searchDefaults.length === 0 && !hasGroupBy) {
15215
+ if (searchDefaults.length === 0 && !hasGroupBy && defaultGroupBy?.length === 0) {
15193
15216
  setIsReadyFormatDomain(true);
15194
15217
  setDidInit(true);
15195
15218
  return;
@@ -15210,8 +15233,24 @@ var Search = ({
15210
15233
  }
15211
15234
  return item;
15212
15235
  });
15236
+ const updatedGroupBy = groupBy?.map((item) => {
15237
+ const defaultGroupByItem = defaultGroupBy.find(
15238
+ ([_2, value]) => item?.context?.includes(value)
15239
+ );
15240
+ if (defaultGroupByItem && typeof handleAddTagSearch == "function") {
15241
+ handleAddTagSearch({
15242
+ name: item?.name,
15243
+ value: item?.string,
15244
+ type: SearchType.GROUP,
15245
+ context: JSON.parse(item?.context.replace(/'/g, '"'))
15246
+ });
15247
+ return { ...item, active: true };
15248
+ }
15249
+ return item;
15250
+ });
15213
15251
  if (updatedFilter) setFilterBy(updatedFilter);
15214
- if (hasGroupBy && fieldsList?.length > 0) {
15252
+ if (updatedGroupBy) setGroupBy(updatedGroupBy);
15253
+ if (hasGroupBy) {
15215
15254
  viewData?.views?.search?.filters_by?.forEach((item, idx) => {
15216
15255
  const groupCtx = evalJSONContext(item?.context);
15217
15256
  handleAddTagSearch?.({
@@ -15224,8 +15263,8 @@ var Search = ({
15224
15263
  fieldsGroup: fieldsList
15225
15264
  });
15226
15265
  });
15227
- setDidInit(true);
15228
15266
  }
15267
+ setDidInit(true);
15229
15268
  setIsReadyFormatDomain(true);
15230
15269
  }, [aid, filterBy, fieldsList]);
15231
15270
  return /* @__PURE__ */ jsxs38(
@@ -15242,7 +15281,8 @@ var Search = ({
15242
15281
  removeSearchItems,
15243
15282
  selectedTags,
15244
15283
  filterBy,
15245
- setFilterBy
15284
+ setFilterBy,
15285
+ setGroupBy
15246
15286
  }
15247
15287
  ),
15248
15288
  /* @__PURE__ */ jsx58(
@@ -34388,7 +34428,12 @@ var Many2OneField = (props) => {
34388
34428
  menuPlacement: "bottom",
34389
34429
  menuPortalTarget: typeof window !== "undefined" ? document.body : null,
34390
34430
  styles: {
34391
- control: () => ({}),
34431
+ control: (base) => ({
34432
+ ...base,
34433
+ "&:focus": {
34434
+ borderColor: "var(--color-primary)"
34435
+ }
34436
+ }),
34392
34437
  container: (base) => ({
34393
34438
  ...base,
34394
34439
  height: "100%"
@@ -34552,8 +34597,8 @@ var StatusBarOptionField = (props) => {
34552
34597
  // pr-[20px]
34553
34598
  fontWeight: 600,
34554
34599
  // font-semibold
34555
- fontSize: "12px",
34556
- background: value ? "var(--primary-color)" : "#FAFAFA",
34600
+ fontSize: "14px",
34601
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34557
34602
  color: value ? "#fff" : "#121212",
34558
34603
  borderTopLeftRadius: index4 === 0 ? "0.75rem" : "0px",
34559
34604
  // rounded-l-xl
@@ -34584,12 +34629,12 @@ var StatusBarOptionField = (props) => {
34584
34629
  width: "25.5px",
34585
34630
  height: "25.5px",
34586
34631
  right: value ? "-13px" : "-12.5px",
34587
- background: value ? "var(--primary-color)" : "#FAFAFA",
34588
- border: value ? "1px solid var(--primary-color)" : "1px solid rgba(0,0,0,0.04)",
34589
- borderBottomColor: value ? "var(--primary-color)" : "#FAFAFA",
34590
- borderLeftColor: value ? "var(--primary-color)" : "#FAFAFA",
34591
- borderTopColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)",
34592
- borderRightColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)"
34632
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34633
+ border: value ? "1px solid var(--color-primary)" : "1px solid rgba(0,0,0,0.04)",
34634
+ borderBottomColor: value ? "var(--color-primary)" : "#FAFAFA",
34635
+ borderLeftColor: value ? "var(--color-primary)" : "#FAFAFA",
34636
+ borderTopColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)",
34637
+ borderRightColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)"
34593
34638
  }
34594
34639
  }
34595
34640
  )
package/dist/widgets.js CHANGED
@@ -11682,7 +11682,7 @@ var Row = (props) => {
11682
11682
  }, [row?.id, selectedRowKeys, checkedAll]);
11683
11683
  const handleCheckBoxSingle = (event) => {
11684
11684
  event.stopPropagation();
11685
- if (checkedAll && checkboxRef && checkboxRef.current) {
11685
+ if (checkedAll) {
11686
11686
  checkboxRef.current = "uncheck";
11687
11687
  setIsAutoSelect(true);
11688
11688
  return;
@@ -11695,7 +11695,7 @@ var Row = (props) => {
11695
11695
  };
11696
11696
  (0, import_react10.useEffect)(() => {
11697
11697
  if (!row?.id) return;
11698
- if (isAutoSelect && checkboxRef && checkboxRef.current) {
11698
+ if (isAutoSelect) {
11699
11699
  if (checkboxRef?.current === "uncheck") {
11700
11700
  const filtered = selectedRowKeysRef.current.filter(
11701
11701
  (id) => id !== row.id
@@ -11712,9 +11712,9 @@ var Row = (props) => {
11712
11712
  }
11713
11713
  }, [isAutoSelect]);
11714
11714
  (0, import_react10.useEffect)(() => {
11715
- if (!checkedAll && checkboxRef && checkboxRef.current) {
11715
+ if (!checkedAll) {
11716
11716
  checkboxRef.current = "enabled";
11717
- false;
11717
+ setIsAutoSelect(false);
11718
11718
  }
11719
11719
  }, [checkedAll]);
11720
11720
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
@@ -11947,7 +11947,7 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
11947
11947
  style: {
11948
11948
  transform: "translateY(-50%)"
11949
11949
  },
11950
- className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-[#eff1f2]",
11950
+ className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-white",
11951
11951
  children: [
11952
11952
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11953
11953
  "button",
@@ -12018,7 +12018,11 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
12018
12018
  "div",
12019
12019
  {
12020
12020
  ref: filterPopupRef,
12021
- style: { top: filterPosition?.top, right: filterPosition?.right },
12021
+ style: {
12022
+ top: filterPosition?.top,
12023
+ right: filterPosition?.right,
12024
+ zIndex: 9999
12025
+ },
12022
12026
  className: "absolute z-[9999] flex w-[250px] h-auto max-h-[800%] overflow-auto flex-col gap-[16px] rounded-[8px] bg-[#fff] px-[24px] py-[16px] shadow-md",
12023
12027
  children: columns?.filter((val) => val?.optional !== void 0)?.map((item) => {
12024
12028
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex items-center gap-2", children: [
@@ -12124,7 +12128,7 @@ var TableHead = (props) => {
12124
12128
  style: {
12125
12129
  userSelect: "none",
12126
12130
  WebkitUserSelect: "none",
12127
- zIndex: 1,
12131
+ zIndex: 10,
12128
12132
  position: "sticky",
12129
12133
  top: 0
12130
12134
  },
@@ -12163,7 +12167,7 @@ var TableHead = (props) => {
12163
12167
  minWidth: "40px",
12164
12168
  right: 0
12165
12169
  },
12166
- className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-[#eff1f2]`,
12170
+ className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-white`,
12167
12171
  children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
12168
12172
  TableFilter,
12169
12173
  {
@@ -14749,7 +14753,8 @@ var TagSearch = ({
14749
14753
  removeSearchItems,
14750
14754
  selectedTags,
14751
14755
  filterBy,
14752
- setFilterBy
14756
+ setFilterBy,
14757
+ setGroupBy
14753
14758
  }) => {
14754
14759
  return selectedTags?.length > 0 && selectedTags?.map((tag, index4) => {
14755
14760
  if (tag?.values?.length > 0) {
@@ -14821,6 +14826,12 @@ var TagSearch = ({
14821
14826
  onClick: () => {
14822
14827
  if (tag?.type === SearchType.GROUP) {
14823
14828
  typeof removeSearchItems === "function" && removeSearchItems(`${SearchType.GROUP}`);
14829
+ setGroupBy(
14830
+ (prev2) => prev2?.map((item) => ({
14831
+ ...item,
14832
+ active: false
14833
+ }))
14834
+ );
14824
14835
  }
14825
14836
  },
14826
14837
  children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CloseIcon, { className: "size-4 cursor-pointer" })
@@ -14885,7 +14896,16 @@ var SearchList = ({
14885
14896
  instance.t("for"),
14886
14897
  ":",
14887
14898
  " ",
14888
- /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "custom-input-result text-primary font-bold italic", children: searchString })
14899
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
14900
+ "span",
14901
+ {
14902
+ style: {
14903
+ color: "var(--color-primary)"
14904
+ },
14905
+ className: "custom-input-result text-primary font-bold italic",
14906
+ children: searchString
14907
+ }
14908
+ )
14889
14909
  ]
14890
14910
  },
14891
14911
  "header-" + index4 + 1
@@ -14941,6 +14961,8 @@ var Search = ({
14941
14961
  }
14942
14962
  }, [selectedTags, isReadyFormatDomain]);
14943
14963
  (0, import_react18.useEffect)(() => {
14964
+ setDidInit(false);
14965
+ setIsReadyFormatDomain(false);
14944
14966
  return () => {
14945
14967
  clearSearch();
14946
14968
  setDidInit(false);
@@ -14948,13 +14970,14 @@ var Search = ({
14948
14970
  };
14949
14971
  }, [aid]);
14950
14972
  (0, import_react18.useEffect)(() => {
14951
- if (!filterBy) return;
14952
- if (didInit || selectedTags?.length > 0) return;
14973
+ if (!filterBy || !fieldsList || fieldsList?.length === 0) return;
14974
+ if (didInit) return;
14953
14975
  const searchDefaults = Object.entries(context || {}).filter(
14954
14976
  ([key]) => key.startsWith("search_default_")
14955
14977
  );
14978
+ const defaultGroupBy = context ? Object.entries(context).filter(([key]) => key.includes("group_by")) : [];
14956
14979
  const hasGroupBy = viewData?.views?.search?.filters_by?.length > 0;
14957
- if (searchDefaults.length === 0 && !hasGroupBy) {
14980
+ if (searchDefaults.length === 0 && !hasGroupBy && defaultGroupBy?.length === 0) {
14958
14981
  setIsReadyFormatDomain(true);
14959
14982
  setDidInit(true);
14960
14983
  return;
@@ -14975,8 +14998,24 @@ var Search = ({
14975
14998
  }
14976
14999
  return item;
14977
15000
  });
15001
+ const updatedGroupBy = groupBy?.map((item) => {
15002
+ const defaultGroupByItem = defaultGroupBy.find(
15003
+ ([_2, value]) => item?.context?.includes(value)
15004
+ );
15005
+ if (defaultGroupByItem && typeof handleAddTagSearch == "function") {
15006
+ handleAddTagSearch({
15007
+ name: item?.name,
15008
+ value: item?.string,
15009
+ type: SearchType.GROUP,
15010
+ context: JSON.parse(item?.context.replace(/'/g, '"'))
15011
+ });
15012
+ return { ...item, active: true };
15013
+ }
15014
+ return item;
15015
+ });
14978
15016
  if (updatedFilter) setFilterBy(updatedFilter);
14979
- if (hasGroupBy && fieldsList?.length > 0) {
15017
+ if (updatedGroupBy) setGroupBy(updatedGroupBy);
15018
+ if (hasGroupBy) {
14980
15019
  viewData?.views?.search?.filters_by?.forEach((item, idx) => {
14981
15020
  const groupCtx = evalJSONContext(item?.context);
14982
15021
  handleAddTagSearch?.({
@@ -14989,8 +15028,8 @@ var Search = ({
14989
15028
  fieldsGroup: fieldsList
14990
15029
  });
14991
15030
  });
14992
- setDidInit(true);
14993
15031
  }
15032
+ setDidInit(true);
14994
15033
  setIsReadyFormatDomain(true);
14995
15034
  }, [aid, filterBy, fieldsList]);
14996
15035
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
@@ -15007,7 +15046,8 @@ var Search = ({
15007
15046
  removeSearchItems,
15008
15047
  selectedTags,
15009
15048
  filterBy,
15010
- setFilterBy
15049
+ setFilterBy,
15050
+ setGroupBy
15011
15051
  }
15012
15052
  ),
15013
15053
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
@@ -34153,7 +34193,12 @@ var Many2OneField = (props) => {
34153
34193
  menuPlacement: "bottom",
34154
34194
  menuPortalTarget: typeof window !== "undefined" ? document.body : null,
34155
34195
  styles: {
34156
- control: () => ({}),
34196
+ control: (base) => ({
34197
+ ...base,
34198
+ "&:focus": {
34199
+ borderColor: "var(--color-primary)"
34200
+ }
34201
+ }),
34157
34202
  container: (base) => ({
34158
34203
  ...base,
34159
34204
  height: "100%"
@@ -34317,8 +34362,8 @@ var StatusBarOptionField = (props) => {
34317
34362
  // pr-[20px]
34318
34363
  fontWeight: 600,
34319
34364
  // font-semibold
34320
- fontSize: "12px",
34321
- background: value ? "var(--primary-color)" : "#FAFAFA",
34365
+ fontSize: "14px",
34366
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34322
34367
  color: value ? "#fff" : "#121212",
34323
34368
  borderTopLeftRadius: index4 === 0 ? "0.75rem" : "0px",
34324
34369
  // rounded-l-xl
@@ -34349,12 +34394,12 @@ var StatusBarOptionField = (props) => {
34349
34394
  width: "25.5px",
34350
34395
  height: "25.5px",
34351
34396
  right: value ? "-13px" : "-12.5px",
34352
- background: value ? "var(--primary-color)" : "#FAFAFA",
34353
- border: value ? "1px solid var(--primary-color)" : "1px solid rgba(0,0,0,0.04)",
34354
- borderBottomColor: value ? "var(--primary-color)" : "#FAFAFA",
34355
- borderLeftColor: value ? "var(--primary-color)" : "#FAFAFA",
34356
- borderTopColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)",
34357
- borderRightColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)"
34397
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34398
+ border: value ? "1px solid var(--color-primary)" : "1px solid rgba(0,0,0,0.04)",
34399
+ borderBottomColor: value ? "var(--color-primary)" : "#FAFAFA",
34400
+ borderLeftColor: value ? "var(--color-primary)" : "#FAFAFA",
34401
+ borderTopColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)",
34402
+ borderRightColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)"
34358
34403
  }
34359
34404
  }
34360
34405
  )
package/dist/widgets.mjs CHANGED
@@ -11619,7 +11619,7 @@ var Row = (props) => {
11619
11619
  }, [row?.id, selectedRowKeys, checkedAll]);
11620
11620
  const handleCheckBoxSingle = (event) => {
11621
11621
  event.stopPropagation();
11622
- if (checkedAll && checkboxRef && checkboxRef.current) {
11622
+ if (checkedAll) {
11623
11623
  checkboxRef.current = "uncheck";
11624
11624
  setIsAutoSelect(true);
11625
11625
  return;
@@ -11632,7 +11632,7 @@ var Row = (props) => {
11632
11632
  };
11633
11633
  useEffect2(() => {
11634
11634
  if (!row?.id) return;
11635
- if (isAutoSelect && checkboxRef && checkboxRef.current) {
11635
+ if (isAutoSelect) {
11636
11636
  if (checkboxRef?.current === "uncheck") {
11637
11637
  const filtered = selectedRowKeysRef.current.filter(
11638
11638
  (id) => id !== row.id
@@ -11649,9 +11649,9 @@ var Row = (props) => {
11649
11649
  }
11650
11650
  }, [isAutoSelect]);
11651
11651
  useEffect2(() => {
11652
- if (!checkedAll && checkboxRef && checkboxRef.current) {
11652
+ if (!checkedAll) {
11653
11653
  checkboxRef.current = "enabled";
11654
- false;
11654
+ setIsAutoSelect(false);
11655
11655
  }
11656
11656
  }, [checkedAll]);
11657
11657
  return /* @__PURE__ */ jsx40(
@@ -11884,7 +11884,7 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
11884
11884
  style: {
11885
11885
  transform: "translateY(-50%)"
11886
11886
  },
11887
- className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-[#eff1f2]",
11887
+ className: "w-fit absolute top-[50%] translate-y-[-50%] right-[10px] ms-auto z-[32] bg-white",
11888
11888
  children: [
11889
11889
  /* @__PURE__ */ jsx42(
11890
11890
  "button",
@@ -11955,7 +11955,11 @@ var TableFilter = ({ columns, onToggleColumnOptional }) => {
11955
11955
  "div",
11956
11956
  {
11957
11957
  ref: filterPopupRef,
11958
- style: { top: filterPosition?.top, right: filterPosition?.right },
11958
+ style: {
11959
+ top: filterPosition?.top,
11960
+ right: filterPosition?.right,
11961
+ zIndex: 9999
11962
+ },
11959
11963
  className: "absolute z-[9999] flex w-[250px] h-auto max-h-[800%] overflow-auto flex-col gap-[16px] rounded-[8px] bg-[#fff] px-[24px] py-[16px] shadow-md",
11960
11964
  children: columns?.filter((val) => val?.optional !== void 0)?.map((item) => {
11961
11965
  return /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-2", children: [
@@ -12061,7 +12065,7 @@ var TableHead = (props) => {
12061
12065
  style: {
12062
12066
  userSelect: "none",
12063
12067
  WebkitUserSelect: "none",
12064
- zIndex: 1,
12068
+ zIndex: 10,
12065
12069
  position: "sticky",
12066
12070
  top: 0
12067
12071
  },
@@ -12100,7 +12104,7 @@ var TableHead = (props) => {
12100
12104
  minWidth: "40px",
12101
12105
  right: 0
12102
12106
  },
12103
- className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-[#eff1f2]`,
12107
+ className: `column whitespace-nowrap text-left p-3 text-sm font-medium capitalize text-[#121212] min-w-[40px] sticky right-[0px] bg-white`,
12104
12108
  children: /* @__PURE__ */ jsx44(
12105
12109
  TableFilter,
12106
12110
  {
@@ -14686,7 +14690,8 @@ var TagSearch = ({
14686
14690
  removeSearchItems,
14687
14691
  selectedTags,
14688
14692
  filterBy,
14689
- setFilterBy
14693
+ setFilterBy,
14694
+ setGroupBy
14690
14695
  }) => {
14691
14696
  return selectedTags?.length > 0 && selectedTags?.map((tag, index4) => {
14692
14697
  if (tag?.values?.length > 0) {
@@ -14758,6 +14763,12 @@ var TagSearch = ({
14758
14763
  onClick: () => {
14759
14764
  if (tag?.type === SearchType.GROUP) {
14760
14765
  typeof removeSearchItems === "function" && removeSearchItems(`${SearchType.GROUP}`);
14766
+ setGroupBy(
14767
+ (prev2) => prev2?.map((item) => ({
14768
+ ...item,
14769
+ active: false
14770
+ }))
14771
+ );
14761
14772
  }
14762
14773
  },
14763
14774
  children: /* @__PURE__ */ jsx56(CloseIcon, { className: "size-4 cursor-pointer" })
@@ -14822,7 +14833,16 @@ var SearchList = ({
14822
14833
  instance.t("for"),
14823
14834
  ":",
14824
14835
  " ",
14825
- /* @__PURE__ */ jsx57("span", { className: "custom-input-result text-primary font-bold italic", children: searchString })
14836
+ /* @__PURE__ */ jsx57(
14837
+ "span",
14838
+ {
14839
+ style: {
14840
+ color: "var(--color-primary)"
14841
+ },
14842
+ className: "custom-input-result text-primary font-bold italic",
14843
+ children: searchString
14844
+ }
14845
+ )
14826
14846
  ]
14827
14847
  },
14828
14848
  "header-" + index4 + 1
@@ -14878,6 +14898,8 @@ var Search = ({
14878
14898
  }
14879
14899
  }, [selectedTags, isReadyFormatDomain]);
14880
14900
  useEffect6(() => {
14901
+ setDidInit(false);
14902
+ setIsReadyFormatDomain(false);
14881
14903
  return () => {
14882
14904
  clearSearch();
14883
14905
  setDidInit(false);
@@ -14885,13 +14907,14 @@ var Search = ({
14885
14907
  };
14886
14908
  }, [aid]);
14887
14909
  useEffect6(() => {
14888
- if (!filterBy) return;
14889
- if (didInit || selectedTags?.length > 0) return;
14910
+ if (!filterBy || !fieldsList || fieldsList?.length === 0) return;
14911
+ if (didInit) return;
14890
14912
  const searchDefaults = Object.entries(context || {}).filter(
14891
14913
  ([key]) => key.startsWith("search_default_")
14892
14914
  );
14915
+ const defaultGroupBy = context ? Object.entries(context).filter(([key]) => key.includes("group_by")) : [];
14893
14916
  const hasGroupBy = viewData?.views?.search?.filters_by?.length > 0;
14894
- if (searchDefaults.length === 0 && !hasGroupBy) {
14917
+ if (searchDefaults.length === 0 && !hasGroupBy && defaultGroupBy?.length === 0) {
14895
14918
  setIsReadyFormatDomain(true);
14896
14919
  setDidInit(true);
14897
14920
  return;
@@ -14912,8 +14935,24 @@ var Search = ({
14912
14935
  }
14913
14936
  return item;
14914
14937
  });
14938
+ const updatedGroupBy = groupBy?.map((item) => {
14939
+ const defaultGroupByItem = defaultGroupBy.find(
14940
+ ([_2, value]) => item?.context?.includes(value)
14941
+ );
14942
+ if (defaultGroupByItem && typeof handleAddTagSearch == "function") {
14943
+ handleAddTagSearch({
14944
+ name: item?.name,
14945
+ value: item?.string,
14946
+ type: SearchType.GROUP,
14947
+ context: JSON.parse(item?.context.replace(/'/g, '"'))
14948
+ });
14949
+ return { ...item, active: true };
14950
+ }
14951
+ return item;
14952
+ });
14915
14953
  if (updatedFilter) setFilterBy(updatedFilter);
14916
- if (hasGroupBy && fieldsList?.length > 0) {
14954
+ if (updatedGroupBy) setGroupBy(updatedGroupBy);
14955
+ if (hasGroupBy) {
14917
14956
  viewData?.views?.search?.filters_by?.forEach((item, idx) => {
14918
14957
  const groupCtx = evalJSONContext(item?.context);
14919
14958
  handleAddTagSearch?.({
@@ -14926,8 +14965,8 @@ var Search = ({
14926
14965
  fieldsGroup: fieldsList
14927
14966
  });
14928
14967
  });
14929
- setDidInit(true);
14930
14968
  }
14969
+ setDidInit(true);
14931
14970
  setIsReadyFormatDomain(true);
14932
14971
  }, [aid, filterBy, fieldsList]);
14933
14972
  return /* @__PURE__ */ jsxs38(
@@ -14944,7 +14983,8 @@ var Search = ({
14944
14983
  removeSearchItems,
14945
14984
  selectedTags,
14946
14985
  filterBy,
14947
- setFilterBy
14986
+ setFilterBy,
14987
+ setGroupBy
14948
14988
  }
14949
14989
  ),
14950
14990
  /* @__PURE__ */ jsx58(
@@ -34090,7 +34130,12 @@ var Many2OneField = (props) => {
34090
34130
  menuPlacement: "bottom",
34091
34131
  menuPortalTarget: typeof window !== "undefined" ? document.body : null,
34092
34132
  styles: {
34093
- control: () => ({}),
34133
+ control: (base) => ({
34134
+ ...base,
34135
+ "&:focus": {
34136
+ borderColor: "var(--color-primary)"
34137
+ }
34138
+ }),
34094
34139
  container: (base) => ({
34095
34140
  ...base,
34096
34141
  height: "100%"
@@ -34254,8 +34299,8 @@ var StatusBarOptionField = (props) => {
34254
34299
  // pr-[20px]
34255
34300
  fontWeight: 600,
34256
34301
  // font-semibold
34257
- fontSize: "12px",
34258
- background: value ? "var(--primary-color)" : "#FAFAFA",
34302
+ fontSize: "14px",
34303
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34259
34304
  color: value ? "#fff" : "#121212",
34260
34305
  borderTopLeftRadius: index4 === 0 ? "0.75rem" : "0px",
34261
34306
  // rounded-l-xl
@@ -34286,12 +34331,12 @@ var StatusBarOptionField = (props) => {
34286
34331
  width: "25.5px",
34287
34332
  height: "25.5px",
34288
34333
  right: value ? "-13px" : "-12.5px",
34289
- background: value ? "var(--primary-color)" : "#FAFAFA",
34290
- border: value ? "1px solid var(--primary-color)" : "1px solid rgba(0,0,0,0.04)",
34291
- borderBottomColor: value ? "var(--primary-color)" : "#FAFAFA",
34292
- borderLeftColor: value ? "var(--primary-color)" : "#FAFAFA",
34293
- borderTopColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)",
34294
- borderRightColor: value ? "var(--primary-color)" : "rgba(0,0,0,0.04)"
34334
+ background: value ? "var(--color-primary)" : "#FAFAFA",
34335
+ border: value ? "1px solid var(--color-primary)" : "1px solid rgba(0,0,0,0.04)",
34336
+ borderBottomColor: value ? "var(--color-primary)" : "#FAFAFA",
34337
+ borderLeftColor: value ? "var(--color-primary)" : "#FAFAFA",
34338
+ borderTopColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)",
34339
+ borderRightColor: value ? "var(--color-primary)" : "rgba(0,0,0,0.04)"
34295
34340
  }
34296
34341
  }
34297
34342
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/sme-widget-ui",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",