@sustaina/shared-ui 1.6.2 → 1.6.3
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 +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +215 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -98
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -332,9 +332,11 @@ type NavbarBaseProps = {
|
|
|
332
332
|
subTitle?: React__default.ReactNode;
|
|
333
333
|
headImageURL?: string;
|
|
334
334
|
headImageURLClassName?: string;
|
|
335
|
+
tooltipContentClassName?: string;
|
|
335
336
|
tooltipTitle?: string;
|
|
336
337
|
tooltipIcon?: React__default.ReactNode;
|
|
337
338
|
tooltipdescription?: React__default.ReactNode;
|
|
339
|
+
tooltipDescriptionWrapperClassName?: string;
|
|
338
340
|
mainButtonText?: React__default.ReactNode;
|
|
339
341
|
mainButtonClassName?: string;
|
|
340
342
|
mainButtonDisable?: boolean;
|
|
@@ -347,9 +349,9 @@ type NavbarBaseProps = {
|
|
|
347
349
|
separatorDisable?: boolean;
|
|
348
350
|
};
|
|
349
351
|
type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title" | "headImageURL">;
|
|
350
|
-
declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipTitle, tooltipIcon, tooltipdescription, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
|
|
352
|
+
declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipContentClassName, tooltipTitle, tooltipIcon, tooltipdescription, tooltipDescriptionWrapperClassName, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
|
|
351
353
|
|
|
352
|
-
type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup";
|
|
354
|
+
type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup" | "uuid";
|
|
353
355
|
type Option = {
|
|
354
356
|
value: string;
|
|
355
357
|
label: string;
|
|
@@ -358,6 +360,7 @@ interface FieldSchemaBase<T extends FieldType> {
|
|
|
358
360
|
name: string;
|
|
359
361
|
type: T;
|
|
360
362
|
label?: string;
|
|
363
|
+
multiTableSearch?: boolean;
|
|
361
364
|
}
|
|
362
365
|
interface DropdownFieldSchema extends FieldSchemaBase<"dropdown"> {
|
|
363
366
|
options: Option[];
|
|
@@ -368,7 +371,8 @@ type DateFieldSchema = FieldSchemaBase<"date">;
|
|
|
368
371
|
type DateTimeFieldSchema = FieldSchemaBase<"datetime">;
|
|
369
372
|
type CheckboxFieldSchema = FieldSchemaBase<"checkbox">;
|
|
370
373
|
type LookupFieldSchema = FieldSchemaBase<"lookup">;
|
|
371
|
-
type
|
|
374
|
+
type UUIDFiledSchema = FieldSchemaBase<"uuid">;
|
|
375
|
+
type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | CheckboxFieldSchema | LookupFieldSchema | UUIDFiledSchema;
|
|
372
376
|
interface AdvanceSearchProps {
|
|
373
377
|
fields: FieldSchema[];
|
|
374
378
|
portalId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -332,9 +332,11 @@ type NavbarBaseProps = {
|
|
|
332
332
|
subTitle?: React__default.ReactNode;
|
|
333
333
|
headImageURL?: string;
|
|
334
334
|
headImageURLClassName?: string;
|
|
335
|
+
tooltipContentClassName?: string;
|
|
335
336
|
tooltipTitle?: string;
|
|
336
337
|
tooltipIcon?: React__default.ReactNode;
|
|
337
338
|
tooltipdescription?: React__default.ReactNode;
|
|
339
|
+
tooltipDescriptionWrapperClassName?: string;
|
|
338
340
|
mainButtonText?: React__default.ReactNode;
|
|
339
341
|
mainButtonClassName?: string;
|
|
340
342
|
mainButtonDisable?: boolean;
|
|
@@ -347,9 +349,9 @@ type NavbarBaseProps = {
|
|
|
347
349
|
separatorDisable?: boolean;
|
|
348
350
|
};
|
|
349
351
|
type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title" | "headImageURL">;
|
|
350
|
-
declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipTitle, tooltipIcon, tooltipdescription, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
|
|
352
|
+
declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipContentClassName, tooltipTitle, tooltipIcon, tooltipdescription, tooltipDescriptionWrapperClassName, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
|
|
351
353
|
|
|
352
|
-
type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup";
|
|
354
|
+
type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup" | "uuid";
|
|
353
355
|
type Option = {
|
|
354
356
|
value: string;
|
|
355
357
|
label: string;
|
|
@@ -358,6 +360,7 @@ interface FieldSchemaBase<T extends FieldType> {
|
|
|
358
360
|
name: string;
|
|
359
361
|
type: T;
|
|
360
362
|
label?: string;
|
|
363
|
+
multiTableSearch?: boolean;
|
|
361
364
|
}
|
|
362
365
|
interface DropdownFieldSchema extends FieldSchemaBase<"dropdown"> {
|
|
363
366
|
options: Option[];
|
|
@@ -368,7 +371,8 @@ type DateFieldSchema = FieldSchemaBase<"date">;
|
|
|
368
371
|
type DateTimeFieldSchema = FieldSchemaBase<"datetime">;
|
|
369
372
|
type CheckboxFieldSchema = FieldSchemaBase<"checkbox">;
|
|
370
373
|
type LookupFieldSchema = FieldSchemaBase<"lookup">;
|
|
371
|
-
type
|
|
374
|
+
type UUIDFiledSchema = FieldSchemaBase<"uuid">;
|
|
375
|
+
type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | CheckboxFieldSchema | LookupFieldSchema | UUIDFiledSchema;
|
|
372
376
|
interface AdvanceSearchProps {
|
|
373
377
|
fields: FieldSchema[];
|
|
374
378
|
portalId: string;
|
package/dist/index.js
CHANGED
|
@@ -1954,9 +1954,11 @@ var Navbar = ({
|
|
|
1954
1954
|
subTitle,
|
|
1955
1955
|
headImageURL = "",
|
|
1956
1956
|
headImageURLClassName,
|
|
1957
|
+
tooltipContentClassName = "md:w-[350px] lg:w-[420px]",
|
|
1957
1958
|
tooltipTitle,
|
|
1958
1959
|
tooltipIcon,
|
|
1959
1960
|
tooltipdescription = [],
|
|
1961
|
+
tooltipDescriptionWrapperClassName,
|
|
1960
1962
|
mainButtonText,
|
|
1961
1963
|
mainButtonClassName,
|
|
1962
1964
|
mainButtonDisable = false,
|
|
@@ -1975,17 +1977,17 @@ var Navbar = ({
|
|
|
1975
1977
|
"nav",
|
|
1976
1978
|
{
|
|
1977
1979
|
className: cn(
|
|
1978
|
-
"py-
|
|
1980
|
+
"py-3 px-8 w-full h-16 bg-sus-primary-1 flex items-center justify-between",
|
|
1979
1981
|
className
|
|
1980
1982
|
),
|
|
1981
1983
|
children: [
|
|
1982
1984
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
|
|
1983
|
-
headImageURL !== "" ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: headImageURL, alt: "", className: cn("w-full h-full", headImageURLClassName) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col
|
|
1984
|
-
React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-
|
|
1985
|
-
React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-
|
|
1985
|
+
headImageURL !== "" ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: headImageURL, alt: "", className: cn("w-full h-full", headImageURLClassName) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
1986
|
+
React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: title }),
|
|
1987
|
+
React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-sm font-semibold", children: subTitle })
|
|
1986
1988
|
] }),
|
|
1987
|
-
tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
|
|
1988
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "text-white hover:opacity-80
|
|
1989
|
+
tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { delayDuration: 700, children: [
|
|
1990
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "text-white hover:opacity-80", children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon_default, { className: "w-4" }) }) }),
|
|
1989
1991
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1990
1992
|
TooltipContent2,
|
|
1991
1993
|
{
|
|
@@ -1995,11 +1997,12 @@ var Navbar = ({
|
|
|
1995
1997
|
align: "start",
|
|
1996
1998
|
avoidCollisions: false,
|
|
1997
1999
|
className: cn(
|
|
1998
|
-
"bg-background text-foreground border border-black
|
|
2000
|
+
"bg-background text-foreground border border-black",
|
|
1999
2001
|
"transition-all duration-150 ease-out origin-top",
|
|
2000
2002
|
"data-[state=closed]:opacity-0 data-[state=open]:opacity-100",
|
|
2001
2003
|
"data-[state=closed]:scale-95 data-[state=open]:scale-100",
|
|
2002
|
-
{ "mt-5": isDesktop }
|
|
2004
|
+
{ "mt-5": isDesktop },
|
|
2005
|
+
tooltipContentClassName
|
|
2003
2006
|
),
|
|
2004
2007
|
children: [
|
|
2005
2008
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2007,7 +2010,10 @@ var Navbar = ({
|
|
|
2007
2010
|
{
|
|
2008
2011
|
role: "tooltip",
|
|
2009
2012
|
"aria-label": tooltipTitle,
|
|
2010
|
-
className: cn(
|
|
2013
|
+
className: cn(
|
|
2014
|
+
"flex flex-col gap-4 max-w-sm text-sm text-gray-700",
|
|
2015
|
+
tooltipDescriptionWrapperClassName
|
|
2016
|
+
),
|
|
2011
2017
|
children: [
|
|
2012
2018
|
tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2013
2019
|
React4.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
|
|
@@ -2112,6 +2118,7 @@ var ExpandCollapse_default = ExpandCollapse;
|
|
|
2112
2118
|
|
|
2113
2119
|
// src/components/advanceSearch/operatorMap.ts
|
|
2114
2120
|
var OPERATOR_MAP = {
|
|
2121
|
+
uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
|
|
2115
2122
|
text: [
|
|
2116
2123
|
"contains",
|
|
2117
2124
|
"equals",
|
|
@@ -2141,22 +2148,30 @@ function firstOperatorFor(fields, fieldName) {
|
|
|
2141
2148
|
const t3 = getFieldType(fields, fieldName);
|
|
2142
2149
|
return OPERATOR_MAP[t3][0];
|
|
2143
2150
|
}
|
|
2144
|
-
function makeNewRow(
|
|
2145
|
-
const
|
|
2146
|
-
const op = OPERATOR_MAP[first.type][0];
|
|
2151
|
+
function makeNewRow(field) {
|
|
2152
|
+
const op = OPERATOR_MAP[field.type][0];
|
|
2147
2153
|
if (op === "between") {
|
|
2148
2154
|
return {
|
|
2149
2155
|
id: crypto.randomUUID(),
|
|
2150
|
-
fieldName:
|
|
2156
|
+
fieldName: field.name,
|
|
2157
|
+
fieldType: field.type,
|
|
2151
2158
|
operator: "between",
|
|
2152
2159
|
value: "",
|
|
2153
|
-
value2: ""
|
|
2160
|
+
value2: "",
|
|
2161
|
+
multiTableSearch: field.multiTableSearch
|
|
2154
2162
|
};
|
|
2155
2163
|
}
|
|
2156
|
-
return {
|
|
2164
|
+
return {
|
|
2165
|
+
id: crypto.randomUUID(),
|
|
2166
|
+
fieldName: field.name,
|
|
2167
|
+
fieldType: field.type,
|
|
2168
|
+
operator: op,
|
|
2169
|
+
value: "",
|
|
2170
|
+
multiTableSearch: field.multiTableSearch
|
|
2171
|
+
};
|
|
2157
2172
|
}
|
|
2158
2173
|
function useAdvanceSearch({ fields, limitRows }) {
|
|
2159
|
-
const [rows, setRows] = React4.useState([makeNewRow(fields)]);
|
|
2174
|
+
const [rows, setRows] = React4.useState([makeNewRow(fields[0])]);
|
|
2160
2175
|
const updateRows = React4.useCallback((next) => {
|
|
2161
2176
|
setRows(next);
|
|
2162
2177
|
}, []);
|
|
@@ -2169,7 +2184,7 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2169
2184
|
);
|
|
2170
2185
|
const addRow = React4.useCallback(() => {
|
|
2171
2186
|
if (!limitRows || rows.length < limitRows) {
|
|
2172
|
-
updateRows([...rows, makeNewRow(fields)]);
|
|
2187
|
+
updateRows([...rows, makeNewRow(fields[0])]);
|
|
2173
2188
|
}
|
|
2174
2189
|
}, [rows, fields, updateRows, limitRows]);
|
|
2175
2190
|
const removeRow = React4.useCallback(
|
|
@@ -2185,22 +2200,29 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2185
2200
|
rows.map((r2) => {
|
|
2186
2201
|
if (r2.id !== id) return r2;
|
|
2187
2202
|
const nextOp = firstOperatorFor(fields, r2.fieldName);
|
|
2188
|
-
return nextOp === "between" ? {
|
|
2203
|
+
return nextOp === "between" ? {
|
|
2204
|
+
id: r2.id,
|
|
2205
|
+
fieldName: r2.fieldName,
|
|
2206
|
+
fieldType: r2.fieldType,
|
|
2207
|
+
operator: "between",
|
|
2208
|
+
value: "",
|
|
2209
|
+
value2: ""
|
|
2210
|
+
} : { id: r2.id, fieldName: r2.fieldName, fieldType: r2.fieldType, operator: nextOp, value: "" };
|
|
2189
2211
|
})
|
|
2190
2212
|
);
|
|
2191
2213
|
},
|
|
2192
2214
|
[rows, fields, updateRows]
|
|
2193
2215
|
);
|
|
2194
2216
|
const clearAllRow = React4.useCallback(() => {
|
|
2195
|
-
updateRows([makeNewRow(fields)]);
|
|
2217
|
+
updateRows([makeNewRow(fields[0])]);
|
|
2196
2218
|
}, [fields, updateRows]);
|
|
2197
2219
|
const changeField = React4.useCallback(
|
|
2198
2220
|
(id, fieldName) => {
|
|
2199
|
-
const nextOp = firstOperatorFor(fields, fieldName);
|
|
2200
2221
|
updateRows(
|
|
2201
2222
|
rows.map((r2) => {
|
|
2202
2223
|
if (r2.id !== id) return r2;
|
|
2203
|
-
|
|
2224
|
+
const newRow = makeNewRow(fields.find((f) => f.name === fieldName) || fields[0]);
|
|
2225
|
+
return { ...newRow, id: r2.id };
|
|
2204
2226
|
})
|
|
2205
2227
|
);
|
|
2206
2228
|
},
|
|
@@ -2212,9 +2234,24 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2212
2234
|
rows.map((r2) => {
|
|
2213
2235
|
if (r2.id !== id) return r2;
|
|
2214
2236
|
if (operator === "between") {
|
|
2215
|
-
return {
|
|
2237
|
+
return {
|
|
2238
|
+
id: r2.id,
|
|
2239
|
+
fieldName: r2.fieldName,
|
|
2240
|
+
fieldType: r2.fieldType,
|
|
2241
|
+
multiTableSearch: r2.multiTableSearch,
|
|
2242
|
+
operator,
|
|
2243
|
+
value: "",
|
|
2244
|
+
value2: ""
|
|
2245
|
+
};
|
|
2216
2246
|
}
|
|
2217
|
-
return {
|
|
2247
|
+
return {
|
|
2248
|
+
id: r2.id,
|
|
2249
|
+
fieldName: r2.fieldName,
|
|
2250
|
+
fieldType: r2.fieldType,
|
|
2251
|
+
multiTableSearch: r2.multiTableSearch,
|
|
2252
|
+
operator,
|
|
2253
|
+
value: ""
|
|
2254
|
+
};
|
|
2218
2255
|
})
|
|
2219
2256
|
);
|
|
2220
2257
|
},
|
|
@@ -2239,55 +2276,16 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2239
2276
|
})),
|
|
2240
2277
|
[fields]
|
|
2241
2278
|
);
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
return { [row.fieldName]: { contains: row.value } };
|
|
2253
|
-
case "beginsWith":
|
|
2254
|
-
return { [row.fieldName]: { startsWith: row.value } };
|
|
2255
|
-
case "endsWith":
|
|
2256
|
-
return { [row.fieldName]: { endsWith: row.value } };
|
|
2257
|
-
case "notEquals":
|
|
2258
|
-
return { [row.fieldName]: { not: row.value } };
|
|
2259
|
-
case "gt":
|
|
2260
|
-
return { [row.fieldName]: { gt: row.value } };
|
|
2261
|
-
case "gte":
|
|
2262
|
-
return { [row.fieldName]: { gte: row.value } };
|
|
2263
|
-
case "lt":
|
|
2264
|
-
return { [row.fieldName]: { lt: row.value } };
|
|
2265
|
-
case "lte":
|
|
2266
|
-
return { [row.fieldName]: { lte: row.value } };
|
|
2267
|
-
case "is":
|
|
2268
|
-
return { [row.fieldName]: row.value };
|
|
2269
|
-
case "isNot":
|
|
2270
|
-
return { [row.fieldName]: { not: row.value } };
|
|
2271
|
-
case "notContains":
|
|
2272
|
-
return { [row.fieldName]: { not: { contains: row.value } } };
|
|
2273
|
-
case "notBeginsWith":
|
|
2274
|
-
return { [row.fieldName]: { not: { startsWith: row.value } } };
|
|
2275
|
-
case "notEndsWith":
|
|
2276
|
-
return { [row.fieldName]: { not: { endsWith: row.value } } };
|
|
2277
|
-
case "containsAny":
|
|
2278
|
-
return { [row.fieldName]: { hasSome: row.value.split(",") } };
|
|
2279
|
-
case "containsAll":
|
|
2280
|
-
return { [row.fieldName]: { hasEvery: row.value.split(",") } };
|
|
2281
|
-
case "containsOnly":
|
|
2282
|
-
return { [row.fieldName]: { equals: row.value.split(",") } };
|
|
2283
|
-
default:
|
|
2284
|
-
return { [row.fieldName]: row.value };
|
|
2285
|
-
}
|
|
2286
|
-
};
|
|
2287
|
-
const buildParam = React4.useMemo(() => {
|
|
2288
|
-
const andConditions = rows.map((r2) => r2.value ? rowToFilter(r2) : null).filter(Boolean);
|
|
2289
|
-
return { AND: andConditions };
|
|
2290
|
-
}, [rows]);
|
|
2279
|
+
const buildFilter = React4.useCallback(
|
|
2280
|
+
(prismaFilter, options) => {
|
|
2281
|
+
return options?.multiTableSearch ? {
|
|
2282
|
+
some: {
|
|
2283
|
+
value: { ...prismaFilter, ...options?.insensitive ? { mode: "insensitive" } : void 0 }
|
|
2284
|
+
}
|
|
2285
|
+
} : prismaFilter;
|
|
2286
|
+
},
|
|
2287
|
+
[]
|
|
2288
|
+
);
|
|
2291
2289
|
return {
|
|
2292
2290
|
rows,
|
|
2293
2291
|
addRow,
|
|
@@ -2299,7 +2297,7 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2299
2297
|
changeValue,
|
|
2300
2298
|
operatorsForField,
|
|
2301
2299
|
fieldOptions,
|
|
2302
|
-
|
|
2300
|
+
buildFilter
|
|
2303
2301
|
};
|
|
2304
2302
|
}
|
|
2305
2303
|
|
|
@@ -4825,7 +4823,10 @@ var AdvanceSearch = ({
|
|
|
4825
4823
|
onSearch,
|
|
4826
4824
|
onClear
|
|
4827
4825
|
}) => {
|
|
4828
|
-
const fieldsData = React4.useMemo(() =>
|
|
4826
|
+
const fieldsData = React4.useMemo(() => {
|
|
4827
|
+
if (fields.length === 0) throw new Error("fields cannot be an empty array");
|
|
4828
|
+
return fields || [];
|
|
4829
|
+
}, [fields]);
|
|
4829
4830
|
const {
|
|
4830
4831
|
rows,
|
|
4831
4832
|
addRow,
|
|
@@ -4835,7 +4836,8 @@ var AdvanceSearch = ({
|
|
|
4835
4836
|
changeField,
|
|
4836
4837
|
changeOperator,
|
|
4837
4838
|
operatorsForField,
|
|
4838
|
-
fieldOptions
|
|
4839
|
+
fieldOptions,
|
|
4840
|
+
buildFilter
|
|
4839
4841
|
} = useAdvanceSearch({ fields: fieldsData, limitRows });
|
|
4840
4842
|
const form = reactHookForm.useForm({
|
|
4841
4843
|
mode: "onSubmit",
|
|
@@ -4847,66 +4849,181 @@ var AdvanceSearch = ({
|
|
|
4847
4849
|
const currentValues = getValues();
|
|
4848
4850
|
const param = {
|
|
4849
4851
|
AND: rows.map((r2) => {
|
|
4850
|
-
|
|
4852
|
+
let val1 = currentValues[`value_${r2.id}`];
|
|
4851
4853
|
const val2 = currentValues[`value2_${r2.id}`];
|
|
4852
4854
|
if (r2.operator === "between") {
|
|
4853
4855
|
if (!val1 || !val2) return null;
|
|
4856
|
+
const start = new Date(val1);
|
|
4857
|
+
start.setHours(0, 0, 0, 0);
|
|
4858
|
+
const end = new Date(val2);
|
|
4859
|
+
end.setHours(23, 59, 59, 59);
|
|
4854
4860
|
return {
|
|
4855
4861
|
[r2.fieldName]: {
|
|
4856
|
-
gte:
|
|
4857
|
-
|
|
4862
|
+
gte: start.toISOString(),
|
|
4863
|
+
lt: end.toISOString()
|
|
4858
4864
|
}
|
|
4859
4865
|
};
|
|
4860
4866
|
}
|
|
4861
4867
|
if (!val1) return null;
|
|
4868
|
+
val1 = r2.fieldType === "number" ? Number(val1) : val1;
|
|
4862
4869
|
switch (r2.operator) {
|
|
4863
4870
|
case "contains":
|
|
4864
|
-
return {
|
|
4871
|
+
return {
|
|
4872
|
+
[r2.fieldName]: buildFilter(
|
|
4873
|
+
{ contains: val1 },
|
|
4874
|
+
{
|
|
4875
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4876
|
+
insensitive: true
|
|
4877
|
+
}
|
|
4878
|
+
)
|
|
4879
|
+
};
|
|
4865
4880
|
case "beginsWith":
|
|
4866
|
-
return {
|
|
4881
|
+
return {
|
|
4882
|
+
[r2.fieldName]: buildFilter(
|
|
4883
|
+
{ startsWith: val1 },
|
|
4884
|
+
{
|
|
4885
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4886
|
+
insensitive: true
|
|
4887
|
+
}
|
|
4888
|
+
)
|
|
4889
|
+
};
|
|
4867
4890
|
case "endsWith":
|
|
4868
|
-
return {
|
|
4891
|
+
return {
|
|
4892
|
+
[r2.fieldName]: buildFilter(
|
|
4893
|
+
{ endsWith: val1 },
|
|
4894
|
+
{
|
|
4895
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4896
|
+
insensitive: true
|
|
4897
|
+
}
|
|
4898
|
+
)
|
|
4899
|
+
};
|
|
4869
4900
|
case "equals":
|
|
4870
|
-
return {
|
|
4901
|
+
return {
|
|
4902
|
+
[r2.fieldName]: buildFilter(
|
|
4903
|
+
{ equals: val1 },
|
|
4904
|
+
{
|
|
4905
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4906
|
+
insensitive: true
|
|
4907
|
+
}
|
|
4908
|
+
)
|
|
4909
|
+
};
|
|
4871
4910
|
case "notEquals":
|
|
4872
|
-
return {
|
|
4911
|
+
return {
|
|
4912
|
+
[r2.fieldName]: buildFilter(
|
|
4913
|
+
{ not: val1 },
|
|
4914
|
+
{
|
|
4915
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4916
|
+
insensitive: true
|
|
4917
|
+
}
|
|
4918
|
+
)
|
|
4919
|
+
};
|
|
4873
4920
|
case "gt":
|
|
4874
|
-
return {
|
|
4921
|
+
return {
|
|
4922
|
+
[r2.fieldName]: buildFilter({ gt: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4923
|
+
};
|
|
4875
4924
|
case "gte":
|
|
4876
|
-
return {
|
|
4925
|
+
return {
|
|
4926
|
+
[r2.fieldName]: buildFilter({ gte: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4927
|
+
};
|
|
4877
4928
|
case "lt":
|
|
4878
|
-
return {
|
|
4929
|
+
return {
|
|
4930
|
+
[r2.fieldName]: buildFilter({ lt: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4931
|
+
};
|
|
4879
4932
|
case "lte":
|
|
4880
|
-
return {
|
|
4933
|
+
return {
|
|
4934
|
+
[r2.fieldName]: buildFilter({ lte: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4935
|
+
};
|
|
4881
4936
|
case "is":
|
|
4882
4937
|
return { [r2.fieldName]: val1 };
|
|
4883
4938
|
case "isNot":
|
|
4884
4939
|
return { [r2.fieldName]: { not: val1 } };
|
|
4885
4940
|
case "notContains":
|
|
4886
|
-
return {
|
|
4941
|
+
return {
|
|
4942
|
+
[r2.fieldName]: buildFilter(
|
|
4943
|
+
{ not: { contains: val1 } },
|
|
4944
|
+
{
|
|
4945
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4946
|
+
insensitive: true
|
|
4947
|
+
}
|
|
4948
|
+
)
|
|
4949
|
+
};
|
|
4887
4950
|
case "notBeginsWith":
|
|
4888
|
-
return {
|
|
4951
|
+
return {
|
|
4952
|
+
[r2.fieldName]: buildFilter(
|
|
4953
|
+
{ not: { startsWith: val1 } },
|
|
4954
|
+
{
|
|
4955
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4956
|
+
insensitive: true
|
|
4957
|
+
}
|
|
4958
|
+
)
|
|
4959
|
+
};
|
|
4889
4960
|
case "notEndsWith":
|
|
4890
|
-
return {
|
|
4961
|
+
return {
|
|
4962
|
+
[r2.fieldName]: buildFilter(
|
|
4963
|
+
{ not: { endsWith: val1 } },
|
|
4964
|
+
{
|
|
4965
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4966
|
+
insensitive: true
|
|
4967
|
+
}
|
|
4968
|
+
)
|
|
4969
|
+
};
|
|
4891
4970
|
case "containsAny":
|
|
4892
|
-
return {
|
|
4971
|
+
return {
|
|
4972
|
+
[r2.fieldName]: buildFilter(
|
|
4973
|
+
{ hasSome: String(val1).split(",") },
|
|
4974
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
4975
|
+
)
|
|
4976
|
+
};
|
|
4893
4977
|
case "containsAll":
|
|
4894
|
-
return {
|
|
4978
|
+
return {
|
|
4979
|
+
[r2.fieldName]: buildFilter(
|
|
4980
|
+
{ hasEvery: String(val1).split(",") },
|
|
4981
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
4982
|
+
)
|
|
4983
|
+
};
|
|
4895
4984
|
case "containsOnly":
|
|
4896
|
-
return {
|
|
4897
|
-
|
|
4898
|
-
|
|
4985
|
+
return {
|
|
4986
|
+
[r2.fieldName]: buildFilter(
|
|
4987
|
+
{ equals: String(val1).split(",") },
|
|
4988
|
+
{
|
|
4989
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4990
|
+
insensitive: true
|
|
4991
|
+
}
|
|
4992
|
+
)
|
|
4993
|
+
};
|
|
4994
|
+
case "on": {
|
|
4995
|
+
const start = new Date(val1);
|
|
4996
|
+
start.setHours(0, 0, 0, 0);
|
|
4997
|
+
const end = new Date(val1);
|
|
4998
|
+
end.setHours(23, 59, 59, 59);
|
|
4999
|
+
return {
|
|
5000
|
+
[r2.fieldName]: buildFilter(
|
|
5001
|
+
{ gte: start.toISOString(), lt: end.toISOString() },
|
|
5002
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
5003
|
+
)
|
|
5004
|
+
};
|
|
5005
|
+
}
|
|
4899
5006
|
case "after":
|
|
4900
|
-
return {
|
|
5007
|
+
return {
|
|
5008
|
+
[r2.fieldName]: buildFilter(
|
|
5009
|
+
{ gte: new Date(val1).toISOString() },
|
|
5010
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
5011
|
+
)
|
|
5012
|
+
};
|
|
4901
5013
|
case "before":
|
|
4902
|
-
return {
|
|
5014
|
+
return {
|
|
5015
|
+
[r2.fieldName]: buildFilter(
|
|
5016
|
+
{ lt: new Date(val1).toISOString() },
|
|
5017
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
5018
|
+
)
|
|
5019
|
+
};
|
|
4903
5020
|
}
|
|
4904
5021
|
}).filter(Boolean)
|
|
4905
5022
|
};
|
|
4906
5023
|
if (onSearch) {
|
|
4907
5024
|
onSearch(param);
|
|
4908
5025
|
}
|
|
4909
|
-
}, [getValues, rows, onSearch]);
|
|
5026
|
+
}, [buildFilter, getValues, rows, onSearch]);
|
|
4910
5027
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4911
5028
|
ExpandCollapse_default,
|
|
4912
5029
|
{
|