@undevy-org/tablewright 0.7.5 → 0.7.7

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.
@@ -20,8 +20,10 @@ function patchFieldState(prev, fieldId, value) {
20
20
  function mergeCompoundSubDraft(compound, subKey, next) {
21
21
  const rest = { ...compound };
22
22
  delete rest[subKey];
23
- const merged = next === void 0 || isFilterValueEmpty(next) ? rest : { ...rest, [subKey]: next };
24
- return Object.keys(merged).length === 0 ? void 0 : merged;
23
+ if (isFilterValueEmpty(next)) {
24
+ return Object.keys(rest).length === 0 ? void 0 : rest;
25
+ }
26
+ return { ...rest, [subKey]: next };
25
27
  }
26
28
  function formatTextMultiSummary(values, labels) {
27
29
  if (values.length === 2) {
@@ -45,20 +47,21 @@ function shouldPreserveMultiSubOnApply(sub, subCommitted, touchKey, touched) {
45
47
  function mergeCompoundValueForApply(config, fieldId, committed, draft, touched, hiddenSubSet) {
46
48
  const committedCompound = getCompoundValue(committed);
47
49
  const draftCompound = getCompoundValue(draft);
48
- const merged = {};
50
+ const merged = { ...draftCompound };
49
51
  for (const sub of config.subFilters ?? []) {
50
52
  if (hiddenSubSet.has(compoundSubTouchKey(fieldId, sub.key))) continue;
51
53
  const touchKey = compoundSubTouchKey(fieldId, sub.key);
52
54
  const subCommitted = committedCompound[sub.key];
53
- const subDraft = draftCompound[sub.key];
54
55
  if (shouldPreserveMultiSubOnApply(sub, subCommitted, touchKey, touched)) {
55
- if (subCommitted !== void 0 && !isFilterValueEmpty(subCommitted)) {
56
- merged[sub.key] = subCommitted;
57
- }
56
+ merged[sub.key] = subCommitted;
58
57
  continue;
59
58
  }
60
- if (subDraft === void 0 || isFilterValueEmpty(subDraft)) continue;
61
- merged[sub.key] = subDraft;
59
+ }
60
+ for (const key of Object.keys(merged)) {
61
+ const value = merged[key];
62
+ if (isFilterValueEmpty(value)) {
63
+ delete merged[key];
64
+ }
62
65
  }
63
66
  return Object.keys(merged).length === 0 ? void 0 : merged;
64
67
  }
@@ -69,14 +72,14 @@ function resolveFieldApplyChange(config, fieldId, committed, draft, touched, hid
69
72
  if (isMultiStringFilterValue(committed) && !touched.has(fieldId)) {
70
73
  return { kind: "skip" };
71
74
  }
72
- if (draft === void 0 || isFilterValueEmpty(draft)) {
75
+ if (isFilterValueEmpty(draft)) {
73
76
  return isActive ? { kind: "remove" } : { kind: "skip" };
74
77
  }
75
78
  return { kind: "set", value: draft };
76
79
  }
77
80
  case "date":
78
81
  case "number-range": {
79
- if (draft === void 0 || isFilterValueEmpty(draft)) {
82
+ if (isFilterValueEmpty(draft)) {
80
83
  return isActive ? { kind: "remove" } : { kind: "skip" };
81
84
  }
82
85
  return { kind: "set", value: draft };
@@ -90,7 +93,7 @@ function resolveFieldApplyChange(config, fieldId, committed, draft, touched, hid
90
93
  touched,
91
94
  hiddenSubSet
92
95
  );
93
- if (merged === void 0 || isFilterValueEmpty(merged)) {
96
+ if (isFilterValueEmpty(merged)) {
94
97
  return isActive ? { kind: "remove" } : { kind: "skip" };
95
98
  }
96
99
  return { kind: "set", value: merged };
@@ -4058,8 +4058,10 @@ function patchFieldState(prev, fieldId, value) {
4058
4058
  function mergeCompoundSubDraft(compound, subKey, next) {
4059
4059
  const rest = { ...compound };
4060
4060
  delete rest[subKey];
4061
- const merged = next === void 0 || isFilterValueEmpty(next) ? rest : { ...rest, [subKey]: next };
4062
- return Object.keys(merged).length === 0 ? void 0 : merged;
4061
+ if (isFilterValueEmpty(next)) {
4062
+ return Object.keys(rest).length === 0 ? void 0 : rest;
4063
+ }
4064
+ return { ...rest, [subKey]: next };
4063
4065
  }
4064
4066
  function formatTextMultiSummary(values, labels) {
4065
4067
  if (values.length === 2) {
@@ -4083,20 +4085,21 @@ function shouldPreserveMultiSubOnApply(sub, subCommitted, touchKey, touched) {
4083
4085
  function mergeCompoundValueForApply(config, fieldId, committed, draft, touched, hiddenSubSet) {
4084
4086
  const committedCompound = getCompoundValue(committed);
4085
4087
  const draftCompound = getCompoundValue(draft);
4086
- const merged = {};
4088
+ const merged = { ...draftCompound };
4087
4089
  for (const sub of config.subFilters ?? []) {
4088
4090
  if (hiddenSubSet.has(compoundSubTouchKey(fieldId, sub.key))) continue;
4089
4091
  const touchKey = compoundSubTouchKey(fieldId, sub.key);
4090
4092
  const subCommitted = committedCompound[sub.key];
4091
- const subDraft = draftCompound[sub.key];
4092
4093
  if (shouldPreserveMultiSubOnApply(sub, subCommitted, touchKey, touched)) {
4093
- if (subCommitted !== void 0 && !isFilterValueEmpty(subCommitted)) {
4094
- merged[sub.key] = subCommitted;
4095
- }
4094
+ merged[sub.key] = subCommitted;
4096
4095
  continue;
4097
4096
  }
4098
- if (subDraft === void 0 || isFilterValueEmpty(subDraft)) continue;
4099
- merged[sub.key] = subDraft;
4097
+ }
4098
+ for (const key of Object.keys(merged)) {
4099
+ const value = merged[key];
4100
+ if (isFilterValueEmpty(value)) {
4101
+ delete merged[key];
4102
+ }
4100
4103
  }
4101
4104
  return Object.keys(merged).length === 0 ? void 0 : merged;
4102
4105
  }
@@ -4107,14 +4110,14 @@ function resolveFieldApplyChange(config, fieldId, committed, draft, touched, hid
4107
4110
  if (isMultiStringFilterValue(committed) && !touched.has(fieldId)) {
4108
4111
  return { kind: "skip" };
4109
4112
  }
4110
- if (draft === void 0 || isFilterValueEmpty(draft)) {
4113
+ if (isFilterValueEmpty(draft)) {
4111
4114
  return isActive ? { kind: "remove" } : { kind: "skip" };
4112
4115
  }
4113
4116
  return { kind: "set", value: draft };
4114
4117
  }
4115
4118
  case "date":
4116
4119
  case "number-range": {
4117
- if (draft === void 0 || isFilterValueEmpty(draft)) {
4120
+ if (isFilterValueEmpty(draft)) {
4118
4121
  return isActive ? { kind: "remove" } : { kind: "skip" };
4119
4122
  }
4120
4123
  return { kind: "set", value: draft };
@@ -4128,7 +4131,7 @@ function resolveFieldApplyChange(config, fieldId, committed, draft, touched, hid
4128
4131
  touched,
4129
4132
  hiddenSubSet
4130
4133
  );
4131
- if (merged === void 0 || isFilterValueEmpty(merged)) {
4134
+ if (isFilterValueEmpty(merged)) {
4132
4135
  return isActive ? { kind: "remove" } : { kind: "skip" };
4133
4136
  }
4134
4137
  return { kind: "set", value: merged };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@undevy-org/tablewright",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "React data-table and application-shell components: filters, drawers, row controls, sortable and resizable columns, built on Radix UI and TanStack Table.",
5
5
  "license": "MIT",
6
6
  "repository": {