baaz-custom-components 5.0.28 → 5.0.29

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.d.mts CHANGED
@@ -79,6 +79,7 @@ type Filters = {
79
79
  label: string;
80
80
  value: string;
81
81
  }[];
82
+ key?: string;
82
83
  }[];
83
84
  };
84
85
  type GridProps = {
@@ -124,6 +125,7 @@ type FilterValue = string | {
124
125
  type ActiveFilter = {
125
126
  column?: string;
126
127
  operator?: string;
128
+ key?: string;
127
129
  value?: FilterValue;
128
130
  };
129
131
 
package/dist/index.d.ts CHANGED
@@ -79,6 +79,7 @@ type Filters = {
79
79
  label: string;
80
80
  value: string;
81
81
  }[];
82
+ key?: string;
82
83
  }[];
83
84
  };
84
85
  type GridProps = {
@@ -124,6 +125,7 @@ type FilterValue = string | {
124
125
  type ActiveFilter = {
125
126
  column?: string;
126
127
  operator?: string;
128
+ key?: string;
127
129
  value?: FilterValue;
128
130
  };
129
131
 
package/dist/index.js CHANGED
@@ -2010,10 +2010,11 @@ var Filters = ({
2010
2010
  }, [conditions]);
2011
2011
  const activeFilterCount = (initialFilters == null ? void 0 : initialFilters.length) || 0;
2012
2012
  const formatFiltersForApi = (conditions2) => {
2013
- return conditions2.filter(isValidFilter).map(({ column, operator, value, logic }, index) => ({
2013
+ return conditions2.filter(isValidFilter).map(({ column, operator, value, logic, key }, index) => ({
2014
2014
  column,
2015
2015
  operator,
2016
2016
  value,
2017
+ key,
2017
2018
  logic: index === 0 ? "WHERE" : logic != null ? logic : "AND"
2018
2019
  }));
2019
2020
  };
@@ -2096,6 +2097,9 @@ var Filters = ({
2096
2097
  document.addEventListener("mousedown", handleClickOutside);
2097
2098
  return () => document.removeEventListener("mousedown", handleClickOutside);
2098
2099
  }, []);
2100
+ const selectedColumns = (0, import_react5.useMemo)(() => {
2101
+ return conditions.map((c) => c.column).filter(Boolean);
2102
+ }, [conditions]);
2099
2103
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative", ref: filterRef, children: [
2100
2104
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2101
2105
  "button",
@@ -2175,14 +2179,18 @@ var Filters = ({
2175
2179
  className: "w-full sm:min-w-[8rem] px-3 py-2 rounded-md bg-input text-sm focus:outline-none",
2176
2180
  children: [
2177
2181
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", disabled: true, children: "Column" }),
2178
- filterList.map((f) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2179
- "option",
2180
- {
2181
- value: f.columnName.value,
2182
- children: f.columnName.label
2183
- },
2184
- f.columnName.value
2185
- ))
2182
+ filterList.map((f) => {
2183
+ const isUsed = selectedColumns.includes(f.columnName.value) && condition.column !== f.columnName.value;
2184
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2185
+ "option",
2186
+ {
2187
+ value: f.columnName.value,
2188
+ disabled: isUsed,
2189
+ children: f.columnName.label
2190
+ },
2191
+ f.columnName.value
2192
+ );
2193
+ })
2186
2194
  ]
2187
2195
  }
2188
2196
  ),
@@ -2191,10 +2199,17 @@ var Filters = ({
2191
2199
  {
2192
2200
  value: (_c = condition.operator) != null ? _c : "",
2193
2201
  disabled: !selectedColumn,
2194
- onChange: (e) => updateCondition(condition.id, {
2195
- operator: e.target.value,
2196
- value: void 0
2197
- }),
2202
+ onChange: (e) => {
2203
+ const operatorValue = e.target.value;
2204
+ const operator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
2205
+ (op) => op.value === operatorValue
2206
+ );
2207
+ updateCondition(condition.id, {
2208
+ operator: e.target.value,
2209
+ key: operator == null ? void 0 : operator.key,
2210
+ value: void 0
2211
+ });
2212
+ },
2198
2213
  className: "w-full sm:min-w-[8rem] px-3 py-2 rounded-md bg-input text-sm disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none",
2199
2214
  children: [
2200
2215
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", disabled: true, children: "Operator" }),
@@ -2410,7 +2425,7 @@ var GridHeader = ({
2410
2425
  search && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "relative h-[40px] flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2411
2426
  "div",
2412
2427
  {
2413
- className: `absolute left-0 md:right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
2428
+ className: `absolute md:right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
2414
2429
  children: !searchOpen ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2415
2430
  "button",
2416
2431
  {
package/dist/index.mjs CHANGED
@@ -1985,10 +1985,11 @@ var Filters = ({
1985
1985
  }, [conditions]);
1986
1986
  const activeFilterCount = (initialFilters == null ? void 0 : initialFilters.length) || 0;
1987
1987
  const formatFiltersForApi = (conditions2) => {
1988
- return conditions2.filter(isValidFilter).map(({ column, operator, value, logic }, index) => ({
1988
+ return conditions2.filter(isValidFilter).map(({ column, operator, value, logic, key }, index) => ({
1989
1989
  column,
1990
1990
  operator,
1991
1991
  value,
1992
+ key,
1992
1993
  logic: index === 0 ? "WHERE" : logic != null ? logic : "AND"
1993
1994
  }));
1994
1995
  };
@@ -2071,6 +2072,9 @@ var Filters = ({
2071
2072
  document.addEventListener("mousedown", handleClickOutside);
2072
2073
  return () => document.removeEventListener("mousedown", handleClickOutside);
2073
2074
  }, []);
2075
+ const selectedColumns = useMemo3(() => {
2076
+ return conditions.map((c) => c.column).filter(Boolean);
2077
+ }, [conditions]);
2074
2078
  return /* @__PURE__ */ jsxs17("div", { className: "relative", ref: filterRef, children: [
2075
2079
  /* @__PURE__ */ jsxs17(
2076
2080
  "button",
@@ -2150,14 +2154,18 @@ var Filters = ({
2150
2154
  className: "w-full sm:min-w-[8rem] px-3 py-2 rounded-md bg-input text-sm focus:outline-none",
2151
2155
  children: [
2152
2156
  /* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Column" }),
2153
- filterList.map((f) => /* @__PURE__ */ jsx23(
2154
- "option",
2155
- {
2156
- value: f.columnName.value,
2157
- children: f.columnName.label
2158
- },
2159
- f.columnName.value
2160
- ))
2157
+ filterList.map((f) => {
2158
+ const isUsed = selectedColumns.includes(f.columnName.value) && condition.column !== f.columnName.value;
2159
+ return /* @__PURE__ */ jsx23(
2160
+ "option",
2161
+ {
2162
+ value: f.columnName.value,
2163
+ disabled: isUsed,
2164
+ children: f.columnName.label
2165
+ },
2166
+ f.columnName.value
2167
+ );
2168
+ })
2161
2169
  ]
2162
2170
  }
2163
2171
  ),
@@ -2166,10 +2174,17 @@ var Filters = ({
2166
2174
  {
2167
2175
  value: (_c = condition.operator) != null ? _c : "",
2168
2176
  disabled: !selectedColumn,
2169
- onChange: (e) => updateCondition(condition.id, {
2170
- operator: e.target.value,
2171
- value: void 0
2172
- }),
2177
+ onChange: (e) => {
2178
+ const operatorValue = e.target.value;
2179
+ const operator = selectedColumn == null ? void 0 : selectedColumn.operators.find(
2180
+ (op) => op.value === operatorValue
2181
+ );
2182
+ updateCondition(condition.id, {
2183
+ operator: e.target.value,
2184
+ key: operator == null ? void 0 : operator.key,
2185
+ value: void 0
2186
+ });
2187
+ },
2173
2188
  className: "w-full sm:min-w-[8rem] px-3 py-2 rounded-md bg-input text-sm disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none",
2174
2189
  children: [
2175
2190
  /* @__PURE__ */ jsx23("option", { value: "", disabled: true, children: "Operator" }),
@@ -2385,7 +2400,7 @@ var GridHeader = ({
2385
2400
  search && /* @__PURE__ */ jsx24("div", { className: "relative h-[40px] flex items-center", children: /* @__PURE__ */ jsx24(
2386
2401
  "div",
2387
2402
  {
2388
- className: `absolute left-0 md:right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
2403
+ className: `absolute md:right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
2389
2404
  children: !searchOpen ? /* @__PURE__ */ jsx24(
2390
2405
  "button",
2391
2406
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baaz-custom-components",
3
- "version": "5.0.28",
3
+ "version": "5.0.29",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "main": "dist/index.js",