sccoreui 6.5.17 → 6.5.19
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.
|
@@ -144,7 +144,9 @@ const TableFilter = () => {
|
|
|
144
144
|
case Types_1.FilterDataType.COLORPICKER:
|
|
145
145
|
case Types_1.FilterDataType.SELECT:
|
|
146
146
|
case Types_1.FilterDataType.BOOLEAN:
|
|
147
|
-
return Array.isArray(value)
|
|
147
|
+
return Array.isArray(value)
|
|
148
|
+
? value.length > 0
|
|
149
|
+
: value !== undefined && value !== "" && value !== null;
|
|
148
150
|
default:
|
|
149
151
|
return true;
|
|
150
152
|
}
|
|
@@ -181,9 +183,7 @@ const TableFilter = () => {
|
|
|
181
183
|
const validationSchema = (0, react_1.useMemo)(() => Yup.object().shape({
|
|
182
184
|
conditions: Yup.array()
|
|
183
185
|
.of(Yup.object().shape({
|
|
184
|
-
columnName: Yup.object()
|
|
185
|
-
.nullable()
|
|
186
|
-
.required("Select a column"),
|
|
186
|
+
columnName: Yup.object().nullable().required("Select a column"),
|
|
187
187
|
condition: Yup.mixed().required("Select a condition"),
|
|
188
188
|
value: Yup.mixed().test("value-required", "Value is required", function (val) {
|
|
189
189
|
const { columnName: col, condition } = this.parent || {};
|
|
@@ -336,7 +336,9 @@ const TableFilter = () => {
|
|
|
336
336
|
setConditionsArray(globalFilters);
|
|
337
337
|
}
|
|
338
338
|
else if (conditionsArray.length === 0) {
|
|
339
|
-
setConditionsArray([
|
|
339
|
+
setConditionsArray([
|
|
340
|
+
Object.assign(Object.assign({}, defaultCondition), { id: Math.random().toString() }),
|
|
341
|
+
]);
|
|
340
342
|
}
|
|
341
343
|
}, [globalFilters]);
|
|
342
344
|
/**
|
|
@@ -345,7 +347,9 @@ const TableFilter = () => {
|
|
|
345
347
|
(0, react_1.useEffect)(() => {
|
|
346
348
|
if (isVisible) {
|
|
347
349
|
if (globalFilters.length === 0) {
|
|
348
|
-
setConditionsArray([
|
|
350
|
+
setConditionsArray([
|
|
351
|
+
Object.assign(Object.assign({}, defaultCondition), { id: Math.random().toString() }),
|
|
352
|
+
]);
|
|
349
353
|
}
|
|
350
354
|
else {
|
|
351
355
|
setConditionsArray(globalFilters);
|
|
@@ -377,13 +381,13 @@ const TableFilter = () => {
|
|
|
377
381
|
// Count of active filters for display
|
|
378
382
|
const activeFilterCount = (globalFilters === null || globalFilters === void 0 ? void 0 : globalFilters.filter((each) => each.isActive).length) || 0;
|
|
379
383
|
const hasActiveFilters = activeFilterCount >= 1;
|
|
380
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `cursor-pointer filter-btn-grid font-semibold hover:bg-primary-25 sc_icon_hover flex align-items-center gap-2 border-round-6 ${isDisabled && "disabled"} ${isVisible || hasActiveFilters ? "bg-primary-50" : "bg-white"}`, title: "Apply Filters" }, { children: [(0, jsx_runtime_1.jsx)("div", { id: "advancedFilterParent", className: "hidden" }), (0, jsx_runtime_1.jsxs)("span", Object.assign({ onClick: (e) => !isDisabled && onClickFilter(e), className: "flex zoom_animate", id: "advance-filter-id" }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "filter-lines", size: 18, color: isVisible || hasActiveFilters ? "#243DC6" : "#667085" }), hasActiveFilters && ((0, jsx_runtime_1.jsxs)("span", Object.assign({ id: "selected-filters", className: "flex gap-2 align-items-center text-primary-400 pl-2" }, { children: [`${activeFilterCount} ${(filterModelText === null || filterModelText === void 0 ? void 0 : filterModelText.onSelectedFilter)
|
|
384
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `cursor-pointer filter-btn-grid font-semibold hover:bg-primary-25 sc_icon_hover flex align-items-center gap-2 border-round-6 ${isDisabled && "disabled"} ${isVisible || hasActiveFilters ? "bg-primary-50" : "bg-white"}`, title: "Apply Filters" }, { children: [(0, jsx_runtime_1.jsx)("div", { id: "advancedFilterParent", className: "hidden" }), (0, jsx_runtime_1.jsxs)("span", Object.assign({ onClick: (e) => !isDisabled && onClickFilter(e), className: "flex zoom_animate", id: "advance-filter-id" }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "filter-lines", size: 18, color: isVisible || hasActiveFilters ? "#243DC6" : "#667085" }), hasActiveFilters && ((0, jsx_runtime_1.jsxs)("span", Object.assign({ id: "selected-filters", className: "flex gap-2 align-items-center text-primary-400 pl-2 white-space-nowrap" }, { children: [`${activeFilterCount} ${(filterModelText === null || filterModelText === void 0 ? void 0 : filterModelText.onSelectedFilter)
|
|
381
385
|
? filterModelText.onSelectedFilter
|
|
382
386
|
: "Selected"}`, (0, jsx_runtime_1.jsx)("span", Object.assign({ onClick: (e) => {
|
|
383
387
|
e.preventDefault();
|
|
384
388
|
e.stopPropagation();
|
|
385
389
|
onResetFilter();
|
|
386
|
-
} }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", size: 18, color: "#243DC6" }) }))] })))] }))] })), (0, jsx_runtime_1.jsx)(form_1.default, Object.assign({ values: formInitialValues, enableReinitialize: true, formRef: formRef, validateOnChange: true, validateOnBlur: false, validateOnMount: true, validations: validationSchema, className: "h-full", onSubmit: () => onApplyFilter() }, { children: ({ handleSubmit, setFieldValue, isValid, values, errors, touched }) => {
|
|
390
|
+
} }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", size: 18, color: "#243DC6" }) }))] })))] }))] })), (0, jsx_runtime_1.jsx)(form_1.default, Object.assign({ values: formInitialValues, enableReinitialize: true, formRef: formRef, validateOnChange: true, validateOnBlur: false, validateOnMount: true, validations: validationSchema, className: "h-full", onSubmit: () => onApplyFilter() }, { children: ({ handleSubmit, setFieldValue, isValid, values, errors, touched, }) => {
|
|
387
391
|
const conditionsToRender = (values === null || values === void 0 ? void 0 : values.conditions) && values.conditions.length > 0
|
|
388
392
|
? values.conditions
|
|
389
393
|
: conditionsArray;
|