@sustaina/shared-ui 1.6.2 → 1.6.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.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +218 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +218 -102
- 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;
|
|
@@ -346,10 +348,10 @@ type NavbarBaseProps = {
|
|
|
346
348
|
searchButton?: React__default.ReactNode;
|
|
347
349
|
separatorDisable?: boolean;
|
|
348
350
|
};
|
|
349
|
-
type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title"
|
|
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>;
|
|
351
|
+
type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title">;
|
|
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;
|
|
@@ -346,10 +348,10 @@ type NavbarBaseProps = {
|
|
|
346
348
|
searchButton?: React__default.ReactNode;
|
|
347
349
|
separatorDisable?: boolean;
|
|
348
350
|
};
|
|
349
|
-
type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title"
|
|
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>;
|
|
351
|
+
type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title">;
|
|
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 = "w-[450px] lg:!w-[630px]",
|
|
1957
1958
|
tooltipTitle,
|
|
1958
1959
|
tooltipIcon,
|
|
1959
|
-
tooltipdescription
|
|
1960
|
+
tooltipdescription,
|
|
1961
|
+
tooltipDescriptionWrapperClassName,
|
|
1960
1962
|
mainButtonText,
|
|
1961
1963
|
mainButtonClassName,
|
|
1962
1964
|
mainButtonDisable = false,
|
|
@@ -1975,31 +1977,31 @@ 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
|
{
|
|
1992
1994
|
forceMount: true,
|
|
1993
1995
|
side: isDesktop ? "right" : "bottom",
|
|
1994
|
-
sideOffset: 8,
|
|
1995
1996
|
align: "start",
|
|
1996
1997
|
avoidCollisions: false,
|
|
1997
1998
|
className: cn(
|
|
1998
|
-
"bg-
|
|
1999
|
-
"transition-all duration-150 ease-out origin-top",
|
|
1999
|
+
"bg-white border border-black p-6",
|
|
2000
|
+
"transition-all duration-150 ease-out origin-top top-1 left-4",
|
|
2000
2001
|
"data-[state=closed]:opacity-0 data-[state=open]:opacity-100",
|
|
2001
2002
|
"data-[state=closed]:scale-95 data-[state=open]:scale-100",
|
|
2002
|
-
{ "mt-5": isDesktop }
|
|
2003
|
+
{ "mt-5": isDesktop },
|
|
2004
|
+
tooltipContentClassName
|
|
2003
2005
|
),
|
|
2004
2006
|
children: [
|
|
2005
2007
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2007,13 +2009,16 @@ var Navbar = ({
|
|
|
2007
2009
|
{
|
|
2008
2010
|
role: "tooltip",
|
|
2009
2011
|
"aria-label": tooltipTitle,
|
|
2010
|
-
className: cn(
|
|
2012
|
+
className: cn(
|
|
2013
|
+
"flex flex-col gap-4 text-sm text-black text-pretty",
|
|
2014
|
+
tooltipDescriptionWrapperClassName
|
|
2015
|
+
),
|
|
2011
2016
|
children: [
|
|
2012
2017
|
tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2013
2018
|
React4.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
|
|
2014
2019
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-bold", children: tooltipTitle })
|
|
2015
2020
|
] }),
|
|
2016
|
-
React4.isValidElement(tooltipdescription)
|
|
2021
|
+
React4.isValidElement(tooltipdescription) && tooltipdescription
|
|
2017
2022
|
]
|
|
2018
2023
|
}
|
|
2019
2024
|
),
|
|
@@ -2112,6 +2117,7 @@ var ExpandCollapse_default = ExpandCollapse;
|
|
|
2112
2117
|
|
|
2113
2118
|
// src/components/advanceSearch/operatorMap.ts
|
|
2114
2119
|
var OPERATOR_MAP = {
|
|
2120
|
+
uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
|
|
2115
2121
|
text: [
|
|
2116
2122
|
"contains",
|
|
2117
2123
|
"equals",
|
|
@@ -2141,22 +2147,30 @@ function firstOperatorFor(fields, fieldName) {
|
|
|
2141
2147
|
const t3 = getFieldType(fields, fieldName);
|
|
2142
2148
|
return OPERATOR_MAP[t3][0];
|
|
2143
2149
|
}
|
|
2144
|
-
function makeNewRow(
|
|
2145
|
-
const
|
|
2146
|
-
const op = OPERATOR_MAP[first.type][0];
|
|
2150
|
+
function makeNewRow(field) {
|
|
2151
|
+
const op = OPERATOR_MAP[field.type][0];
|
|
2147
2152
|
if (op === "between") {
|
|
2148
2153
|
return {
|
|
2149
2154
|
id: crypto.randomUUID(),
|
|
2150
|
-
fieldName:
|
|
2155
|
+
fieldName: field.name,
|
|
2156
|
+
fieldType: field.type,
|
|
2151
2157
|
operator: "between",
|
|
2152
2158
|
value: "",
|
|
2153
|
-
value2: ""
|
|
2159
|
+
value2: "",
|
|
2160
|
+
multiTableSearch: field.multiTableSearch
|
|
2154
2161
|
};
|
|
2155
2162
|
}
|
|
2156
|
-
return {
|
|
2163
|
+
return {
|
|
2164
|
+
id: crypto.randomUUID(),
|
|
2165
|
+
fieldName: field.name,
|
|
2166
|
+
fieldType: field.type,
|
|
2167
|
+
operator: op,
|
|
2168
|
+
value: "",
|
|
2169
|
+
multiTableSearch: field.multiTableSearch
|
|
2170
|
+
};
|
|
2157
2171
|
}
|
|
2158
2172
|
function useAdvanceSearch({ fields, limitRows }) {
|
|
2159
|
-
const [rows, setRows] = React4.useState([makeNewRow(fields)]);
|
|
2173
|
+
const [rows, setRows] = React4.useState([makeNewRow(fields[0])]);
|
|
2160
2174
|
const updateRows = React4.useCallback((next) => {
|
|
2161
2175
|
setRows(next);
|
|
2162
2176
|
}, []);
|
|
@@ -2169,7 +2183,7 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2169
2183
|
);
|
|
2170
2184
|
const addRow = React4.useCallback(() => {
|
|
2171
2185
|
if (!limitRows || rows.length < limitRows) {
|
|
2172
|
-
updateRows([...rows, makeNewRow(fields)]);
|
|
2186
|
+
updateRows([...rows, makeNewRow(fields[0])]);
|
|
2173
2187
|
}
|
|
2174
2188
|
}, [rows, fields, updateRows, limitRows]);
|
|
2175
2189
|
const removeRow = React4.useCallback(
|
|
@@ -2185,22 +2199,29 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2185
2199
|
rows.map((r2) => {
|
|
2186
2200
|
if (r2.id !== id) return r2;
|
|
2187
2201
|
const nextOp = firstOperatorFor(fields, r2.fieldName);
|
|
2188
|
-
return nextOp === "between" ? {
|
|
2202
|
+
return nextOp === "between" ? {
|
|
2203
|
+
id: r2.id,
|
|
2204
|
+
fieldName: r2.fieldName,
|
|
2205
|
+
fieldType: r2.fieldType,
|
|
2206
|
+
operator: "between",
|
|
2207
|
+
value: "",
|
|
2208
|
+
value2: ""
|
|
2209
|
+
} : { id: r2.id, fieldName: r2.fieldName, fieldType: r2.fieldType, operator: nextOp, value: "" };
|
|
2189
2210
|
})
|
|
2190
2211
|
);
|
|
2191
2212
|
},
|
|
2192
2213
|
[rows, fields, updateRows]
|
|
2193
2214
|
);
|
|
2194
2215
|
const clearAllRow = React4.useCallback(() => {
|
|
2195
|
-
updateRows([makeNewRow(fields)]);
|
|
2216
|
+
updateRows([makeNewRow(fields[0])]);
|
|
2196
2217
|
}, [fields, updateRows]);
|
|
2197
2218
|
const changeField = React4.useCallback(
|
|
2198
2219
|
(id, fieldName) => {
|
|
2199
|
-
const nextOp = firstOperatorFor(fields, fieldName);
|
|
2200
2220
|
updateRows(
|
|
2201
2221
|
rows.map((r2) => {
|
|
2202
2222
|
if (r2.id !== id) return r2;
|
|
2203
|
-
|
|
2223
|
+
const newRow = makeNewRow(fields.find((f) => f.name === fieldName) || fields[0]);
|
|
2224
|
+
return { ...newRow, id: r2.id };
|
|
2204
2225
|
})
|
|
2205
2226
|
);
|
|
2206
2227
|
},
|
|
@@ -2212,9 +2233,24 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2212
2233
|
rows.map((r2) => {
|
|
2213
2234
|
if (r2.id !== id) return r2;
|
|
2214
2235
|
if (operator === "between") {
|
|
2215
|
-
return {
|
|
2236
|
+
return {
|
|
2237
|
+
id: r2.id,
|
|
2238
|
+
fieldName: r2.fieldName,
|
|
2239
|
+
fieldType: r2.fieldType,
|
|
2240
|
+
multiTableSearch: r2.multiTableSearch,
|
|
2241
|
+
operator,
|
|
2242
|
+
value: "",
|
|
2243
|
+
value2: ""
|
|
2244
|
+
};
|
|
2216
2245
|
}
|
|
2217
|
-
return {
|
|
2246
|
+
return {
|
|
2247
|
+
id: r2.id,
|
|
2248
|
+
fieldName: r2.fieldName,
|
|
2249
|
+
fieldType: r2.fieldType,
|
|
2250
|
+
multiTableSearch: r2.multiTableSearch,
|
|
2251
|
+
operator,
|
|
2252
|
+
value: ""
|
|
2253
|
+
};
|
|
2218
2254
|
})
|
|
2219
2255
|
);
|
|
2220
2256
|
},
|
|
@@ -2239,55 +2275,16 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2239
2275
|
})),
|
|
2240
2276
|
[fields]
|
|
2241
2277
|
);
|
|
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]);
|
|
2278
|
+
const buildFilter = React4.useCallback(
|
|
2279
|
+
(prismaFilter, options) => {
|
|
2280
|
+
return options?.multiTableSearch ? {
|
|
2281
|
+
some: {
|
|
2282
|
+
value: { ...prismaFilter, ...options?.insensitive ? { mode: "insensitive" } : void 0 }
|
|
2283
|
+
}
|
|
2284
|
+
} : prismaFilter;
|
|
2285
|
+
},
|
|
2286
|
+
[]
|
|
2287
|
+
);
|
|
2291
2288
|
return {
|
|
2292
2289
|
rows,
|
|
2293
2290
|
addRow,
|
|
@@ -2299,7 +2296,7 @@ function useAdvanceSearch({ fields, limitRows }) {
|
|
|
2299
2296
|
changeValue,
|
|
2300
2297
|
operatorsForField,
|
|
2301
2298
|
fieldOptions,
|
|
2302
|
-
|
|
2299
|
+
buildFilter
|
|
2303
2300
|
};
|
|
2304
2301
|
}
|
|
2305
2302
|
|
|
@@ -4825,7 +4822,10 @@ var AdvanceSearch = ({
|
|
|
4825
4822
|
onSearch,
|
|
4826
4823
|
onClear
|
|
4827
4824
|
}) => {
|
|
4828
|
-
const fieldsData = React4.useMemo(() =>
|
|
4825
|
+
const fieldsData = React4.useMemo(() => {
|
|
4826
|
+
if (fields.length === 0) throw new Error("fields cannot be an empty array");
|
|
4827
|
+
return fields || [];
|
|
4828
|
+
}, [fields]);
|
|
4829
4829
|
const {
|
|
4830
4830
|
rows,
|
|
4831
4831
|
addRow,
|
|
@@ -4835,7 +4835,8 @@ var AdvanceSearch = ({
|
|
|
4835
4835
|
changeField,
|
|
4836
4836
|
changeOperator,
|
|
4837
4837
|
operatorsForField,
|
|
4838
|
-
fieldOptions
|
|
4838
|
+
fieldOptions,
|
|
4839
|
+
buildFilter
|
|
4839
4840
|
} = useAdvanceSearch({ fields: fieldsData, limitRows });
|
|
4840
4841
|
const form = reactHookForm.useForm({
|
|
4841
4842
|
mode: "onSubmit",
|
|
@@ -4847,66 +4848,181 @@ var AdvanceSearch = ({
|
|
|
4847
4848
|
const currentValues = getValues();
|
|
4848
4849
|
const param = {
|
|
4849
4850
|
AND: rows.map((r2) => {
|
|
4850
|
-
|
|
4851
|
+
let val1 = currentValues[`value_${r2.id}`];
|
|
4851
4852
|
const val2 = currentValues[`value2_${r2.id}`];
|
|
4852
4853
|
if (r2.operator === "between") {
|
|
4853
4854
|
if (!val1 || !val2) return null;
|
|
4855
|
+
const start = new Date(val1);
|
|
4856
|
+
start.setHours(0, 0, 0, 0);
|
|
4857
|
+
const end = new Date(val2);
|
|
4858
|
+
end.setHours(23, 59, 59, 59);
|
|
4854
4859
|
return {
|
|
4855
4860
|
[r2.fieldName]: {
|
|
4856
|
-
gte:
|
|
4857
|
-
|
|
4861
|
+
gte: start.toISOString(),
|
|
4862
|
+
lt: end.toISOString()
|
|
4858
4863
|
}
|
|
4859
4864
|
};
|
|
4860
4865
|
}
|
|
4861
4866
|
if (!val1) return null;
|
|
4867
|
+
val1 = r2.fieldType === "number" ? Number(val1) : val1;
|
|
4862
4868
|
switch (r2.operator) {
|
|
4863
4869
|
case "contains":
|
|
4864
|
-
return {
|
|
4870
|
+
return {
|
|
4871
|
+
[r2.fieldName]: buildFilter(
|
|
4872
|
+
{ contains: val1 },
|
|
4873
|
+
{
|
|
4874
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4875
|
+
insensitive: true
|
|
4876
|
+
}
|
|
4877
|
+
)
|
|
4878
|
+
};
|
|
4865
4879
|
case "beginsWith":
|
|
4866
|
-
return {
|
|
4880
|
+
return {
|
|
4881
|
+
[r2.fieldName]: buildFilter(
|
|
4882
|
+
{ startsWith: val1 },
|
|
4883
|
+
{
|
|
4884
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4885
|
+
insensitive: true
|
|
4886
|
+
}
|
|
4887
|
+
)
|
|
4888
|
+
};
|
|
4867
4889
|
case "endsWith":
|
|
4868
|
-
return {
|
|
4890
|
+
return {
|
|
4891
|
+
[r2.fieldName]: buildFilter(
|
|
4892
|
+
{ endsWith: val1 },
|
|
4893
|
+
{
|
|
4894
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4895
|
+
insensitive: true
|
|
4896
|
+
}
|
|
4897
|
+
)
|
|
4898
|
+
};
|
|
4869
4899
|
case "equals":
|
|
4870
|
-
return {
|
|
4900
|
+
return {
|
|
4901
|
+
[r2.fieldName]: buildFilter(
|
|
4902
|
+
{ equals: val1 },
|
|
4903
|
+
{
|
|
4904
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4905
|
+
insensitive: true
|
|
4906
|
+
}
|
|
4907
|
+
)
|
|
4908
|
+
};
|
|
4871
4909
|
case "notEquals":
|
|
4872
|
-
return {
|
|
4910
|
+
return {
|
|
4911
|
+
[r2.fieldName]: buildFilter(
|
|
4912
|
+
{ not: val1 },
|
|
4913
|
+
{
|
|
4914
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4915
|
+
insensitive: true
|
|
4916
|
+
}
|
|
4917
|
+
)
|
|
4918
|
+
};
|
|
4873
4919
|
case "gt":
|
|
4874
|
-
return {
|
|
4920
|
+
return {
|
|
4921
|
+
[r2.fieldName]: buildFilter({ gt: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4922
|
+
};
|
|
4875
4923
|
case "gte":
|
|
4876
|
-
return {
|
|
4924
|
+
return {
|
|
4925
|
+
[r2.fieldName]: buildFilter({ gte: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4926
|
+
};
|
|
4877
4927
|
case "lt":
|
|
4878
|
-
return {
|
|
4928
|
+
return {
|
|
4929
|
+
[r2.fieldName]: buildFilter({ lt: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4930
|
+
};
|
|
4879
4931
|
case "lte":
|
|
4880
|
-
return {
|
|
4932
|
+
return {
|
|
4933
|
+
[r2.fieldName]: buildFilter({ lte: val1 }, { multiTableSearch: r2.multiTableSearch })
|
|
4934
|
+
};
|
|
4881
4935
|
case "is":
|
|
4882
4936
|
return { [r2.fieldName]: val1 };
|
|
4883
4937
|
case "isNot":
|
|
4884
4938
|
return { [r2.fieldName]: { not: val1 } };
|
|
4885
4939
|
case "notContains":
|
|
4886
|
-
return {
|
|
4940
|
+
return {
|
|
4941
|
+
[r2.fieldName]: buildFilter(
|
|
4942
|
+
{ not: { contains: val1 } },
|
|
4943
|
+
{
|
|
4944
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4945
|
+
insensitive: true
|
|
4946
|
+
}
|
|
4947
|
+
)
|
|
4948
|
+
};
|
|
4887
4949
|
case "notBeginsWith":
|
|
4888
|
-
return {
|
|
4950
|
+
return {
|
|
4951
|
+
[r2.fieldName]: buildFilter(
|
|
4952
|
+
{ not: { startsWith: val1 } },
|
|
4953
|
+
{
|
|
4954
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4955
|
+
insensitive: true
|
|
4956
|
+
}
|
|
4957
|
+
)
|
|
4958
|
+
};
|
|
4889
4959
|
case "notEndsWith":
|
|
4890
|
-
return {
|
|
4960
|
+
return {
|
|
4961
|
+
[r2.fieldName]: buildFilter(
|
|
4962
|
+
{ not: { endsWith: val1 } },
|
|
4963
|
+
{
|
|
4964
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4965
|
+
insensitive: true
|
|
4966
|
+
}
|
|
4967
|
+
)
|
|
4968
|
+
};
|
|
4891
4969
|
case "containsAny":
|
|
4892
|
-
return {
|
|
4970
|
+
return {
|
|
4971
|
+
[r2.fieldName]: buildFilter(
|
|
4972
|
+
{ hasSome: String(val1).split(",") },
|
|
4973
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
4974
|
+
)
|
|
4975
|
+
};
|
|
4893
4976
|
case "containsAll":
|
|
4894
|
-
return {
|
|
4977
|
+
return {
|
|
4978
|
+
[r2.fieldName]: buildFilter(
|
|
4979
|
+
{ hasEvery: String(val1).split(",") },
|
|
4980
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
4981
|
+
)
|
|
4982
|
+
};
|
|
4895
4983
|
case "containsOnly":
|
|
4896
|
-
return {
|
|
4897
|
-
|
|
4898
|
-
|
|
4984
|
+
return {
|
|
4985
|
+
[r2.fieldName]: buildFilter(
|
|
4986
|
+
{ equals: String(val1).split(",") },
|
|
4987
|
+
{
|
|
4988
|
+
multiTableSearch: r2.multiTableSearch,
|
|
4989
|
+
insensitive: true
|
|
4990
|
+
}
|
|
4991
|
+
)
|
|
4992
|
+
};
|
|
4993
|
+
case "on": {
|
|
4994
|
+
const start = new Date(val1);
|
|
4995
|
+
start.setHours(0, 0, 0, 0);
|
|
4996
|
+
const end = new Date(val1);
|
|
4997
|
+
end.setHours(23, 59, 59, 59);
|
|
4998
|
+
return {
|
|
4999
|
+
[r2.fieldName]: buildFilter(
|
|
5000
|
+
{ gte: start.toISOString(), lt: end.toISOString() },
|
|
5001
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
5002
|
+
)
|
|
5003
|
+
};
|
|
5004
|
+
}
|
|
4899
5005
|
case "after":
|
|
4900
|
-
return {
|
|
5006
|
+
return {
|
|
5007
|
+
[r2.fieldName]: buildFilter(
|
|
5008
|
+
{ gte: new Date(val1).toISOString() },
|
|
5009
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
5010
|
+
)
|
|
5011
|
+
};
|
|
4901
5012
|
case "before":
|
|
4902
|
-
return {
|
|
5013
|
+
return {
|
|
5014
|
+
[r2.fieldName]: buildFilter(
|
|
5015
|
+
{ lt: new Date(val1).toISOString() },
|
|
5016
|
+
{ multiTableSearch: r2.multiTableSearch }
|
|
5017
|
+
)
|
|
5018
|
+
};
|
|
4903
5019
|
}
|
|
4904
5020
|
}).filter(Boolean)
|
|
4905
5021
|
};
|
|
4906
5022
|
if (onSearch) {
|
|
4907
5023
|
onSearch(param);
|
|
4908
5024
|
}
|
|
4909
|
-
}, [getValues, rows, onSearch]);
|
|
5025
|
+
}, [buildFilter, getValues, rows, onSearch]);
|
|
4910
5026
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4911
5027
|
ExpandCollapse_default,
|
|
4912
5028
|
{
|