@solidstarters/solid-core-ui 1.1.46 → 1.1.49
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/components/common/SolidThemeProvider.js +2 -2
- package/dist/components/common/SolidThemeProvider.js.map +1 -1
- package/dist/components/core/common/FilterComponent.d.ts.map +1 -1
- package/dist/components/core/common/FilterComponent.js +26 -10
- package/dist/components/core/common/FilterComponent.js.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.js +160 -94
- package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
- package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormView.js +43 -16
- package/dist/components/core/form/SolidFormView.js.map +1 -1
- package/dist/components/core/form/fields/ISolidField.d.ts +1 -0
- package/dist/components/core/form/fields/ISolidField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidBooleanField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidBooleanField.js +9 -2
- package/dist/components/core/form/fields/SolidBooleanField.js.map +1 -1
- package/dist/components/core/form/fields/SolidDateField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDateField.js +27 -11
- package/dist/components/core/form/fields/SolidDateField.js.map +1 -1
- package/dist/components/core/form/fields/SolidDateTimeField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDateTimeField.js +28 -11
- package/dist/components/core/form/fields/SolidDateTimeField.js.map +1 -1
- package/dist/components/core/form/fields/SolidDecimalField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDecimalField.js +24 -5
- package/dist/components/core/form/fields/SolidDecimalField.js.map +1 -1
- package/dist/components/core/form/fields/SolidEmailField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidEmailField.js +24 -5
- package/dist/components/core/form/fields/SolidEmailField.js.map +1 -1
- package/dist/components/core/form/fields/SolidIntegerField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidIntegerField.js +24 -5
- package/dist/components/core/form/fields/SolidIntegerField.js.map +1 -1
- package/dist/components/core/form/fields/SolidJsonField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidJsonField.js +22 -3
- package/dist/components/core/form/fields/SolidJsonField.js.map +1 -1
- package/dist/components/core/form/fields/SolidLongTextField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidLongTextField.js +30 -4
- package/dist/components/core/form/fields/SolidLongTextField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.js +52 -29
- package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.js +39 -16
- package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidPasswordField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidPasswordField.js +23 -3
- package/dist/components/core/form/fields/SolidPasswordField.js.map +1 -1
- package/dist/components/core/form/fields/SolidRichTextField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidRichTextField.js +23 -3
- package/dist/components/core/form/fields/SolidRichTextField.js.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionDynamicField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionDynamicField.js +14 -5
- package/dist/components/core/form/fields/SolidSelectionDynamicField.js.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionStaticField.js +10 -2
- package/dist/components/core/form/fields/SolidSelectionStaticField.js.map +1 -1
- package/dist/components/core/form/fields/SolidShortTextField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidShortTextField.js +28 -8
- package/dist/components/core/form/fields/SolidShortTextField.js.map +1 -1
- package/dist/components/core/form/fields/SolidTimeField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidTimeField.js +27 -8
- package/dist/components/core/form/fields/SolidTimeField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +15 -4
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +13 -4
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +17 -5
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js +1 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js +1 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.d.ts +2 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.js +9 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.d.ts +2 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.js +8 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.d.ts +2 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.js +9 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.d.ts +2 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.js +20 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.d.ts +2 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.js +7 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.js +74 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.js +58 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.d.ts +2 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.js +6 -0
- package/dist/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js +1 -1
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js +1 -1
- package/dist/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.js.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.d.ts.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.js +37 -14
- package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
- package/dist/components/core/list/SolidListView.d.ts +3 -0
- package/dist/components/core/list/SolidListView.d.ts.map +1 -1
- package/dist/components/core/list/SolidListView.js +167 -95
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/model/FieldMetaDataForm.js +1 -1
- package/dist/components/core/model/FieldMetaDataForm.js.map +1 -1
- package/dist/components/core/users/CreateUser.js +1 -3
- package/dist/components/core/users/CreateUser.js.map +1 -1
- package/dist/helpers/registry.d.ts.map +1 -1
- package/dist/helpers/registry.js +16 -0
- package/dist/helpers/registry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/globals.css +15 -5
- package/dist/resources/themes/solid-light-purple/solid-login-light.png +0 -0
- package/dist/resources/themes/solid-light-purple/theme.css +4 -0
- package/package.json +1 -1
- package/src/components/common/SolidThemeProvider.tsx +2 -2
- package/src/components/core/common/FilterComponent.tsx +39 -10
- package/src/components/core/common/SolidGlobalSearchElement.tsx +228 -135
- package/src/components/core/form/SolidFormView.tsx +69 -21
- package/src/components/core/form/fields/ISolidField.tsx +1 -0
- package/src/components/core/form/fields/SolidBooleanField.tsx +39 -25
- package/src/components/core/form/fields/SolidDateField.tsx +46 -32
- package/src/components/core/form/fields/SolidDateTimeField.tsx +47 -34
- package/src/components/core/form/fields/SolidDecimalField.tsx +42 -26
- package/src/components/core/form/fields/SolidEmailField.tsx +43 -27
- package/src/components/core/form/fields/SolidIntegerField.tsx +42 -25
- package/src/components/core/form/fields/SolidJsonField.tsx +40 -23
- package/src/components/core/form/fields/SolidLongTextField.tsx +86 -53
- package/src/components/core/form/fields/SolidMediaMultipleField.tsx +170 -139
- package/src/components/core/form/fields/SolidMediaSingleField.tsx +124 -93
- package/src/components/core/form/fields/SolidPasswordField.tsx +42 -25
- package/src/components/core/form/fields/SolidRichTextField.tsx +41 -24
- package/src/components/core/form/fields/SolidSelectionDynamicField.tsx +46 -28
- package/src/components/core/form/fields/SolidSelectionStaticField.tsx +38 -22
- package/src/components/core/form/fields/SolidShortTextField.tsx +63 -47
- package/src/components/core/form/fields/SolidTimeField.tsx +47 -30
- package/src/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +30 -8
- package/src/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +49 -31
- package/src/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +38 -19
- package/src/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.tsx +1 -1
- package/src/components/core/form/fields/widgets/SolidBooleanSelectFieldWidget.tsx +1 -1
- package/src/components/core/form/fields/widgets/SolidFormFieldJsonViewModeWidget.tsx +23 -0
- package/src/components/core/form/fields/widgets/SolidFormFieldMediaViewModeWidget.tsx +13 -0
- package/src/components/core/form/fields/widgets/SolidFormFieldPasswordViewModeWidget.tsx +23 -0
- package/src/components/core/form/fields/widgets/SolidFormFieldRelationViewModeWidget.tsx +32 -0
- package/src/components/core/form/fields/widgets/SolidFormFieldRichTextViewModeWidget.tsx +17 -0
- package/src/components/core/form/fields/widgets/SolidFormFieldViewMediaMultipleWidget.tsx +157 -0
- package/src/components/core/form/fields/widgets/SolidFormFieldViewMediaSingleWidget.tsx +98 -0
- package/src/components/core/form/fields/widgets/SolidFormFieldViewModeWidget.tsx +11 -0
- package/src/components/core/form/fields/widgets/SolidSelectionStaticAutocompleteFieldWidget.tsx +1 -1
- package/src/components/core/form/fields/widgets/SolidSelectionStaticRadioFieldWidget.tsx +1 -1
- package/src/components/core/kanban/SolidKanbanView.tsx +26 -5
- package/src/components/core/list/SolidListView.tsx +166 -105
- package/src/components/core/model/FieldMetaDataForm.tsx +1 -1
- package/src/components/core/users/CreateUser.tsx +5 -5
- package/src/helpers/registry.ts +16 -0
- package/src/index.ts +2 -1
- package/src/resources/globals.css +15 -5
- package/src/resources/themes/solid-light-purple/solid-login-light.png +0 -0
- package/src/resources/themes/solid-light-purple/theme.css +4 -0
- package/src/types/solid-core.d.ts +6 -1
|
@@ -1564,9 +1564,9 @@ li.header-li-px {
|
|
|
1564
1564
|
border: 8px;
|
|
1565
1565
|
padding: 5px;
|
|
1566
1566
|
height: 100%;
|
|
1567
|
-
min-width:fit-content;
|
|
1567
|
+
min-width: fit-content;
|
|
1568
1568
|
width: 100%;
|
|
1569
|
-
max-width:fit-content;
|
|
1569
|
+
max-width: fit-content;
|
|
1570
1570
|
}
|
|
1571
1571
|
|
|
1572
1572
|
.kaban-heading-area {
|
|
@@ -1729,6 +1729,9 @@ li.header-li-px {
|
|
|
1729
1729
|
margin-top: 10px;
|
|
1730
1730
|
}
|
|
1731
1731
|
|
|
1732
|
+
.solid-file-vieww-wrapper {
|
|
1733
|
+
margin-top: 10px;
|
|
1734
|
+
}
|
|
1732
1735
|
|
|
1733
1736
|
.solid-dynamic-stepper {
|
|
1734
1737
|
overflow: hidden;
|
|
@@ -2217,9 +2220,6 @@ li.header-li-px {
|
|
|
2217
2220
|
align-items: center;
|
|
2218
2221
|
justify-content: center;
|
|
2219
2222
|
} */
|
|
2220
|
-
.solid-auth-theme-wrapper.center {
|
|
2221
|
-
background-image: url(../resources/images/auth/solid-login-light.png);
|
|
2222
|
-
}
|
|
2223
2223
|
|
|
2224
2224
|
.auth-container {
|
|
2225
2225
|
min-width: 525px;
|
|
@@ -2953,4 +2953,14 @@ flex-shrink: 0; */
|
|
|
2953
2953
|
|
|
2954
2954
|
.kanban-column-cogwheel.p-button.p-button-secondary.p-button-text:not(:disabled):hover {
|
|
2955
2955
|
background: transparent;
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
.view-widget-chip.p-chip {
|
|
2959
|
+
background-color: #f9f9f9 !important;
|
|
2960
|
+
padding: 4px 10px !important;
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
.view-widget-chip.p-chip .p-chip-text {
|
|
2964
|
+
margin-top: 0 !important;
|
|
2965
|
+
margin-bottom: 0 !important;
|
|
2956
2966
|
}
|
|
Binary file
|
|
@@ -6094,6 +6094,10 @@
|
|
|
6094
6094
|
padding: 54px;
|
|
6095
6095
|
} */
|
|
6096
6096
|
|
|
6097
|
+
.solid-auth-theme-wrapper.center {
|
|
6098
|
+
background-image: url('./solid-login-light.png');
|
|
6099
|
+
}
|
|
6100
|
+
|
|
6097
6101
|
.auth-container {
|
|
6098
6102
|
border: 1px solid #E0E0E0;
|
|
6099
6103
|
background: rgba(255, 255, 255, 0.10);
|
package/package.json
CHANGED
|
@@ -10,13 +10,13 @@ export const SolidThemeProvider = () => {
|
|
|
10
10
|
const [theme, setTheme] = useState("solid-light-purple");
|
|
11
11
|
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
if (pathname.includes("/auth")) {
|
|
13
|
+
if (pathname.includes("/auth/")) {
|
|
14
14
|
trigger("");
|
|
15
15
|
}
|
|
16
16
|
}, [pathname, trigger]);
|
|
17
17
|
|
|
18
18
|
useEffect(() => {
|
|
19
|
-
if (pathname.includes("/auth") && solidSettingsData?.data?.authPagesTheme) {
|
|
19
|
+
if (pathname.includes("/auth/") && solidSettingsData?.data?.authPagesTheme) {
|
|
20
20
|
const selectedTheme =
|
|
21
21
|
solidSettingsData.data.authPagesTheme === "dark" ? "solid-dark-purple" : "solid-light-purple";
|
|
22
22
|
setTheme(selectedTheme);
|
|
@@ -99,9 +99,9 @@ const FilterRuleComponent = ({ viewData, fields, rule, onChange, onAddRule, onAd
|
|
|
99
99
|
<div className='col-4'>
|
|
100
100
|
<Dropdown
|
|
101
101
|
key={rule.id}
|
|
102
|
-
value={fieldName.
|
|
102
|
+
value={fieldName.name}
|
|
103
103
|
onChange={e => {
|
|
104
|
-
setFieldName({ name: e.value
|
|
104
|
+
setFieldName({ name: e.value })
|
|
105
105
|
onChange(rule.id, 'fieldName', e.value)
|
|
106
106
|
}}
|
|
107
107
|
options={fields}
|
|
@@ -351,27 +351,56 @@ const FilterComponent = ({ viewData, fields, filterRules, setFilterRules, transf
|
|
|
351
351
|
// setFilterRules(prev => deleteRecursively(prev, id));
|
|
352
352
|
// };
|
|
353
353
|
|
|
354
|
+
|
|
355
|
+
const removeEmptyGroups = (rule) => {
|
|
356
|
+
if (rule.type === "rule_group" && rule.children.length === 0) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
rule.children = rule.children
|
|
361
|
+
.map(removeEmptyGroups) // Recursively process children
|
|
362
|
+
.filter(child => child !== null); // Remove null values
|
|
363
|
+
|
|
364
|
+
return rule;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
|
|
354
368
|
const handleDeleteRule = (id) => {
|
|
355
|
-
|
|
356
|
-
return
|
|
357
|
-
|
|
369
|
+
if(filterRules[0].children.length === 1 && filterRules[0].children[0].id === id ){
|
|
370
|
+
return
|
|
371
|
+
}
|
|
372
|
+
const deleteRecursively = (rules, id, isRoot = false) => {
|
|
373
|
+
const mappedData = rules
|
|
358
374
|
.map(rule => {
|
|
375
|
+
if (rule.id === id) {
|
|
376
|
+
return null; // Remove the target rule
|
|
377
|
+
}
|
|
378
|
+
|
|
359
379
|
if (rule.children) {
|
|
360
380
|
const updatedChildren = deleteRecursively(rule.children, id);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
381
|
+
|
|
382
|
+
// If this rule had children and now has none, keep it but set children to []
|
|
383
|
+
if (rule.children.length > 0 && updatedChildren.length === 0) {
|
|
384
|
+
return { ...rule, children: [] };
|
|
364
385
|
}
|
|
386
|
+
|
|
365
387
|
return { ...rule, children: updatedChildren };
|
|
366
388
|
}
|
|
389
|
+
|
|
367
390
|
return rule;
|
|
368
391
|
})
|
|
369
|
-
.filter(
|
|
392
|
+
.filter(rule => rule !== null); // Remove null values
|
|
393
|
+
|
|
394
|
+
return mappedData
|
|
370
395
|
};
|
|
371
396
|
|
|
372
|
-
setFilterRules(
|
|
397
|
+
setFilterRules(prevRules => [removeEmptyGroups(deleteRecursively(prevRules, id, true)[0])]);
|
|
373
398
|
};
|
|
374
399
|
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
375
404
|
// const handlePrintState = () => {
|
|
376
405
|
// // setPrintedState(JSON.stringify(filterRules, null, 2)); // Pretty format the state
|
|
377
406
|
// transformFilterRules(filterRules)
|
|
@@ -2,19 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
4
4
|
import { Dialog } from "primereact/dialog";
|
|
5
|
-
import { TabPanel, TabView } from "primereact/tabview";
|
|
6
|
-
import { SolidSearchBox } from "./SolidSearchBox";
|
|
7
5
|
import FilterComponent, { FilterOperator, FilterRule, FilterRuleType } from "@/components/core/common/FilterComponent";
|
|
8
6
|
import { Button } from "primereact/button";
|
|
9
|
-
import { InputText } from "primereact/inputtext";
|
|
10
7
|
import { OverlayPanel } from "primereact/overlaypanel";
|
|
11
8
|
import { Divider } from "primereact/divider";
|
|
12
|
-
import {
|
|
9
|
+
import { useSearchParams } from "next/navigation";
|
|
10
|
+
import { queryStringToQueryObject } from "../list/SolidListView";
|
|
11
|
+
import { InputText } from "primereact/inputtext";
|
|
13
12
|
|
|
14
13
|
const getRandomInt = (min: number, max: number) => {
|
|
15
14
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
|
|
18
|
+
const transformFiltersToRules = (filter: any, parentRule: number | null = null): FilterRule => {
|
|
19
|
+
const currentId = idCounter++;
|
|
20
|
+
|
|
21
|
+
if (filter["$or"]) {
|
|
22
|
+
return {
|
|
23
|
+
id: currentId,
|
|
24
|
+
type: FilterRuleType.RULE_GROUP,
|
|
25
|
+
matchOperator: FilterOperator.OR,
|
|
26
|
+
parentRule,
|
|
27
|
+
children: filter["$or"].map((subFilter: any) => transformFiltersToRules(subFilter, currentId))
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (filter["$and"]) {
|
|
32
|
+
return {
|
|
33
|
+
id: currentId,
|
|
34
|
+
type: FilterRuleType.RULE_GROUP,
|
|
35
|
+
matchOperator: FilterOperator.AND,
|
|
36
|
+
parentRule,
|
|
37
|
+
children: filter["$and"].map((subFilter: any) => transformFiltersToRules(subFilter, currentId))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Handle single rule condition
|
|
42
|
+
for (const key in filter) {
|
|
43
|
+
const condition = filter[key];
|
|
44
|
+
|
|
45
|
+
for (const matchMode in condition) {
|
|
46
|
+
return {
|
|
47
|
+
id: currentId,
|
|
48
|
+
type: FilterRuleType.RULE,
|
|
49
|
+
fieldName: key,
|
|
50
|
+
//@ts-ignore
|
|
51
|
+
matchMode,
|
|
52
|
+
value: [condition[matchMode]],
|
|
53
|
+
parentRule,
|
|
54
|
+
children: []
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
throw new Error("Invalid filter structure");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let idCounter = 1;
|
|
66
|
+
const generateId = () => Date.now() + Math.floor(Math.random() * 1000);
|
|
67
|
+
|
|
68
|
+
|
|
18
69
|
const transformRulesToFilters = (input: any) => {
|
|
19
70
|
|
|
20
71
|
// Helper function to process individual rules
|
|
@@ -102,8 +153,28 @@ const transformRulesToFilters = (input: any) => {
|
|
|
102
153
|
|
|
103
154
|
}
|
|
104
155
|
|
|
156
|
+
const tranformSearchToFilters = (input: any) => {
|
|
157
|
+
|
|
158
|
+
if (!input || !input.$and) return input; // Return as-is if invalid
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
$and: input.$and.map((condition: any) => {
|
|
162
|
+
const { fieldName, matchMode, value } = condition;
|
|
163
|
+
|
|
164
|
+
// Ensure value is a single string (if it's an array with one element, extract it)
|
|
165
|
+
const formattedValue = Array.isArray(value) && value.length === 1 ? value[0] : value;
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
[fieldName]: {
|
|
169
|
+
[matchMode]: formattedValue
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
})
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
105
176
|
export const SolidGlobalSearchElement = forwardRef(({ viewData, handleApplyCustomFilter, filters, clearFilter }: any, ref) => {
|
|
106
|
-
const
|
|
177
|
+
const defaultState: FilterRule[] = [
|
|
107
178
|
{
|
|
108
179
|
id: 1,
|
|
109
180
|
type: FilterRuleType.RULE_GROUP,
|
|
@@ -131,28 +202,66 @@ export const SolidGlobalSearchElement = forwardRef(({ viewData, handleApplyCusto
|
|
|
131
202
|
]
|
|
132
203
|
}
|
|
133
204
|
];
|
|
205
|
+
const [initialState, setInitialState] = useState(defaultState);
|
|
206
|
+
|
|
207
|
+
const searchParams = useSearchParams().toString(); // Converts the query params to a string
|
|
208
|
+
|
|
209
|
+
console.log("searchParams", searchParams);
|
|
134
210
|
|
|
135
211
|
const op = useRef<OverlayPanel>(null);
|
|
136
|
-
const chipsRef = useRef<HTMLDivElement | null>(null);
|
|
212
|
+
const chipsRef = useRef<HTMLDivElement | null | any>(null);
|
|
137
213
|
|
|
138
214
|
const [filterRules, setFilterRules] = useState<FilterRule[]>(initialState);
|
|
139
215
|
const [fields, setFields] = useState<any[]>([]);
|
|
216
|
+
const [searchableFields, setSearchableFields] = useState<any[]>([]);
|
|
140
217
|
const [showGlobalSearchElement, setShowGlobalSearchElement] = useState<boolean>(false);
|
|
141
218
|
const [customChip, setCustomChip] = useState("");
|
|
142
219
|
const [searchChips, setSearchChips] = useState<{ columnName?: string; value: string }[]>([]);
|
|
143
220
|
const [inputValue, setInputValue] = useState<string | null>("");
|
|
144
|
-
|
|
221
|
+
const [searchFilter, setSearchFilter] = useState<any | null>(null);
|
|
222
|
+
const [customFilter, setCustomFilter] = useState<any | null>(null);
|
|
145
223
|
useImperativeHandle(ref, () => ({
|
|
146
224
|
clearFilter: () => {
|
|
147
225
|
setFilterRules(initialState);
|
|
148
226
|
}
|
|
149
227
|
}));
|
|
150
228
|
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
const queryObject = queryStringToQueryObject();
|
|
231
|
+
if (queryObject) {
|
|
232
|
+
const searchChips: any = queryObject?.s_filter || null;
|
|
233
|
+
const customChips = queryObject?.c_filter || null;
|
|
234
|
+
if (searchChips) {
|
|
235
|
+
const formattedChips = searchChips?.$and.map((chip: any, key: any) => {
|
|
236
|
+
const chipKey = Object.keys(chip)[0]; // Get the key, e.g., "displayName"
|
|
237
|
+
const chipValue = chip[chipKey]?.$containsi; // Get the value of "$containsi"
|
|
238
|
+
const chipdata = {
|
|
239
|
+
columnName: chipKey,
|
|
240
|
+
value: chipValue
|
|
241
|
+
};
|
|
242
|
+
return chipdata
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
setSearchChips(formattedChips);
|
|
246
|
+
}
|
|
247
|
+
if (customChips) {
|
|
248
|
+
const formatedCustomChips: FilterRule = transformFiltersToRules(customChips);
|
|
249
|
+
console.log("formatedCustomChips", formatedCustomChips);
|
|
250
|
+
setFilterRules([formatedCustomChips]);
|
|
251
|
+
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}, [searchParams])
|
|
255
|
+
|
|
256
|
+
|
|
151
257
|
useEffect(() => {
|
|
152
258
|
if (viewData?.data?.solidFieldsMetadata) {
|
|
153
|
-
const fieldsData = viewData?.data?.solidFieldsMetadata
|
|
154
|
-
const fieldsList = Object.entries(fieldsData).map(([key, value]: any) => ({ name: value.displayName, value: key }));
|
|
155
|
-
setFields(fieldsList)
|
|
259
|
+
const fieldsData = viewData?.data?.solidFieldsMetadata;
|
|
260
|
+
const fieldsList = Object.entries(fieldsData).map(([key, value]: any) => ({ name: value.displayName, value: key, type: value.type }));
|
|
261
|
+
setFields(fieldsList);
|
|
262
|
+
const searchableFieldsList = fieldsList.filter((field: any) => field.type === "longText" || field.type === "shortText");
|
|
263
|
+
const finalsearchableFieldsList = searchableFieldsList.filter((field: any) => field.value && viewData?.data?.solidView?.layout?.children?.some((child: any) => child?.attrs?.name === field.value && child?.attrs?.isSearchable)).map((field: any) => field.value);
|
|
264
|
+
setSearchableFields(finalsearchableFieldsList);
|
|
156
265
|
}
|
|
157
266
|
}, [])
|
|
158
267
|
|
|
@@ -160,7 +269,7 @@ export const SolidGlobalSearchElement = forwardRef(({ viewData, handleApplyCusto
|
|
|
160
269
|
if (chipsRef.current) {
|
|
161
270
|
const inputElement = chipsRef.current.querySelector("input");
|
|
162
271
|
if (inputElement) {
|
|
163
|
-
inputElement.addEventListener("input", (e) => {
|
|
272
|
+
inputElement.addEventListener("input", (e: any) => {
|
|
164
273
|
setInputValue((e.target as HTMLInputElement).value);
|
|
165
274
|
});
|
|
166
275
|
}
|
|
@@ -177,68 +286,72 @@ export const SolidGlobalSearchElement = forwardRef(({ viewData, handleApplyCusto
|
|
|
177
286
|
}
|
|
178
287
|
}, [filters]);
|
|
179
288
|
|
|
180
|
-
const
|
|
181
|
-
setInputValue(e.target.value);
|
|
182
|
-
if (op.current && e.target) {
|
|
183
|
-
op.current.show;
|
|
184
|
-
}
|
|
185
|
-
if (e.value && e.value.length > 0) {
|
|
186
|
-
const newChip = e.value[e.value.length - 1];
|
|
187
|
-
if (!searchChips.some(chip => chip.value === newChip.value)) {
|
|
188
|
-
setSearchChips([...searchChips, newChip]);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const firstFilterableFieldName = viewData?.data?.solidView?.layout?.children?.find(
|
|
194
|
-
(value: any) => value?.attrs?.filterable
|
|
195
|
-
)?.attrs?.name;
|
|
289
|
+
const firstFilterableFieldName = searchableFields[0]; // First searchable field
|
|
196
290
|
|
|
197
291
|
const handleAddChip = (columnName?: string) => {
|
|
198
292
|
if (inputValue?.trim()) {
|
|
199
|
-
const newChip = {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
293
|
+
const newChip = {
|
|
294
|
+
columnName: columnName || firstFilterableFieldName,
|
|
295
|
+
value: inputValue.trim(),
|
|
296
|
+
};
|
|
297
|
+
setSearchChips((prev) => [...prev, newChip]);
|
|
298
|
+
setInputValue("");
|
|
299
|
+
op.current?.hide();
|
|
203
300
|
}
|
|
204
|
-
}
|
|
301
|
+
};
|
|
205
302
|
|
|
206
|
-
const handleKeyDown = (e:
|
|
303
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
207
304
|
if (e.key === "Enter" && inputValue?.trim()) {
|
|
208
305
|
handleAddChip();
|
|
209
|
-
|
|
210
|
-
|
|
306
|
+
e.preventDefault();
|
|
307
|
+
} else if (e.key === "Backspace" && inputValue === "") {
|
|
308
|
+
setSearchChips((prev) => prev.slice(0, -1));
|
|
211
309
|
}
|
|
310
|
+
|
|
311
|
+
|
|
212
312
|
};
|
|
213
313
|
|
|
314
|
+
const mergeSearchAndCustomFilters = (transformedFilter: any, newFilter: any, transformedFilterName: string, newFilterName: string) => {
|
|
315
|
+
const filters: any = {};
|
|
316
|
+
|
|
317
|
+
// Add only non-null filters
|
|
318
|
+
if (transformedFilter && Object.keys(transformedFilter).length > 0) {
|
|
319
|
+
filters[transformedFilterName] = transformedFilter;
|
|
320
|
+
}
|
|
321
|
+
if (newFilter && Object.keys(newFilter).length > 0) {
|
|
322
|
+
filters[newFilterName] = newFilter;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Return the combined filters object
|
|
326
|
+
return filters;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
|
|
214
330
|
const transformFilterRules = (filterRules: any) => {
|
|
215
331
|
const transformedFilter = transformRulesToFilters(filterRules[0]);
|
|
332
|
+
console.log("transformedFilter from custom filter", transformedFilter);
|
|
333
|
+
setCustomFilter(transformedFilter);
|
|
216
334
|
if (transformedFilter) {
|
|
217
|
-
|
|
335
|
+
const finalFilter = mergeSearchAndCustomFilters(transformedFilter, searchFilter, "c_filter", "s_filter");
|
|
336
|
+
handleApplyCustomFilter(finalFilter)
|
|
218
337
|
}
|
|
219
338
|
setShowGlobalSearchElement(false)
|
|
220
339
|
}
|
|
221
340
|
|
|
222
341
|
useEffect(() => {
|
|
223
342
|
const formattedChips = {
|
|
224
|
-
|
|
225
|
-
matchOperator: "and",
|
|
226
|
-
parentRule: null,
|
|
227
|
-
type: "rule_group",
|
|
228
|
-
children: searchChips.map((chip) => ({
|
|
229
|
-
children: [],
|
|
343
|
+
$and: searchChips.map((chip) => ({
|
|
230
344
|
fieldName: chip.columnName,
|
|
231
|
-
id: Date.now() + getRandomInt(1, 500),
|
|
232
345
|
matchMode: "$containsi",
|
|
233
|
-
parentRule: 1,
|
|
234
|
-
type: "rule",
|
|
235
346
|
value: [chip.value]
|
|
236
347
|
}))
|
|
237
348
|
};
|
|
238
|
-
if (formattedChips.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
349
|
+
// if (formattedChips.$and.length > 0) {
|
|
350
|
+
const transformedFilter = tranformSearchToFilters(formattedChips);
|
|
351
|
+
setSearchFilter(transformedFilter);
|
|
352
|
+
const finalFilter = mergeSearchAndCustomFilters(transformedFilter, customFilter, "s_filter", "c_filter");
|
|
353
|
+
handleApplyCustomFilter(finalFilter);
|
|
354
|
+
// }
|
|
242
355
|
}, [searchChips]);
|
|
243
356
|
|
|
244
357
|
const groupedSearchChips = searchChips.reduce((acc, chip) => {
|
|
@@ -250,114 +363,94 @@ export const SolidGlobalSearchElement = forwardRef(({ viewData, handleApplyCusto
|
|
|
250
363
|
return acc;
|
|
251
364
|
}, {} as Record<string, string[]>);
|
|
252
365
|
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
];
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
// useEffect(() => {
|
|
260
|
-
// console.log("Input Value", customChip, "Input Value", searchChips, "Input Value", inputValue);
|
|
261
|
-
// }, [chipsToDisplay])
|
|
262
|
-
|
|
263
|
-
const customChipTemplate = (item: any) => {
|
|
264
|
-
if (item === customChip) {
|
|
265
|
-
return (
|
|
366
|
+
const CustomChip = () => (
|
|
367
|
+
<li>
|
|
368
|
+
<div className="custom-filter-chip-type">
|
|
266
369
|
<div className="flex align-items-center gap-2 text-base">
|
|
267
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"
|
|
370
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"
|
|
371
|
+
onClick={() => setShowGlobalSearchElement(true)}>
|
|
268
372
|
<rect width="20" height="20" rx="4" fill="#722ED1" />
|
|
269
|
-
<path d="M8.66667 15V13.3333H11.3333V15H8.66667ZM6 10.8333V9.16667H14V10.8333H6ZM4 6.66667V5H16V6.66667H4Z"
|
|
373
|
+
<path d="M8.66667 15V13.3333H11.3333V15H8.66667ZM6 10.8333V9.16667H14V10.8333H6ZM4 6.66667V5H16V6.66667H4Z"
|
|
374
|
+
fill="white" />
|
|
270
375
|
</svg>
|
|
271
|
-
<span><strong>{customChip}</strong>
|
|
376
|
+
<span><strong>{customChip}</strong> rules applied</span>
|
|
272
377
|
</div>
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
378
|
+
</div>
|
|
379
|
+
</li>
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
const SearchChip = () => (
|
|
384
|
+
<>
|
|
385
|
+
{Object.entries(groupedSearchChips).map(([column, values]) => (
|
|
386
|
+
<li key={column}>
|
|
387
|
+
<div className="search-filter-chip-type">
|
|
388
|
+
<div>{column}</div>
|
|
389
|
+
{values.map((value, index) => (
|
|
390
|
+
<span key={index} className="custom-chip-value mx-1">{value}</span>
|
|
391
|
+
))}
|
|
392
|
+
</div>
|
|
393
|
+
</li>
|
|
394
|
+
))}
|
|
395
|
+
</>
|
|
396
|
+
);
|
|
277
397
|
|
|
278
|
-
const handleRemoveChip = (removedChipValue: any) => {
|
|
279
|
-
console.log("Removing chip:", removedChipValue);
|
|
280
398
|
|
|
281
|
-
setSearchChips((prevChips) => {
|
|
282
|
-
const updatedChips = prevChips.filter((chip) => chip.value !== removedChipValue);
|
|
283
|
-
console.log("Updated searchChips after removal:", updatedChips);
|
|
284
|
-
return updatedChips;
|
|
285
|
-
});
|
|
286
399
|
|
|
287
|
-
// Prevent clearing customChip if it is different from the removed chip
|
|
288
|
-
if (customChip === removedChipValue) {
|
|
289
|
-
console.log("Clearing custom chip:", customChip);
|
|
290
|
-
setCustomChip("");
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
400
|
|
|
294
401
|
return (
|
|
295
402
|
<div className="flex justify-content-center solid-custom-filter-wrapper">
|
|
296
|
-
<div className="
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
/>
|
|
332
|
-
<Button
|
|
333
|
-
icon="pi pi-search"
|
|
334
|
-
style={{ fontSize: 10 }}
|
|
335
|
-
severity="secondary"
|
|
336
|
-
outlined size="small"
|
|
337
|
-
onClick={() => setShowGlobalSearchElement(true)}
|
|
338
|
-
// onClick={(e) => {
|
|
339
|
-
// if (op.current && e.target) {
|
|
340
|
-
// op.current.toggle(e);
|
|
341
|
-
// }
|
|
342
|
-
// }}
|
|
343
|
-
/>
|
|
403
|
+
<div className="solid-global-search-element">
|
|
404
|
+
<ul className="">
|
|
405
|
+
{customChip && <CustomChip />}
|
|
406
|
+
<SearchChip />
|
|
407
|
+
<li ref={chipsRef}>
|
|
408
|
+
<div className="relative">
|
|
409
|
+
<InputText
|
|
410
|
+
value={inputValue || ""}
|
|
411
|
+
placeholder="Search..."
|
|
412
|
+
onChange={(e) => {
|
|
413
|
+
setInputValue(e.target.value);
|
|
414
|
+
if (e.target.value.trim() !== "") {
|
|
415
|
+
//@ts-ignore
|
|
416
|
+
op.current?.show(e.currentTarget);
|
|
417
|
+
} else {
|
|
418
|
+
op.current?.hide();
|
|
419
|
+
}
|
|
420
|
+
}}
|
|
421
|
+
onFocus={(e: any) => {
|
|
422
|
+
//@ts-ignore
|
|
423
|
+
if (inputValue?.trim()) op.current?.show(e.currentTarget);
|
|
424
|
+
}}
|
|
425
|
+
onKeyDown={handleKeyDown}
|
|
426
|
+
/>
|
|
427
|
+
<Button
|
|
428
|
+
icon="pi pi-search"
|
|
429
|
+
style={{ fontSize: 10 }}
|
|
430
|
+
severity="secondary"
|
|
431
|
+
outlined size="small"
|
|
432
|
+
onClick={() => setShowGlobalSearchElement(true)}
|
|
433
|
+
className="custom-filter-button"
|
|
434
|
+
/>
|
|
435
|
+
</div>
|
|
436
|
+
</li>
|
|
437
|
+
</ul>
|
|
344
438
|
</div>
|
|
345
439
|
<OverlayPanel ref={op} className="solid-custom-overlay" style={{ minWidth: 405 }}>
|
|
346
440
|
{inputValue ? (
|
|
347
441
|
<>
|
|
348
442
|
<div className="custom-filter-search-options px-2 py-2 flex flex-column">
|
|
349
|
-
{
|
|
350
|
-
.
|
|
351
|
-
.map((value: any, index: any) => (
|
|
443
|
+
{
|
|
444
|
+
searchableFields.map((value: any, index: any) => (
|
|
352
445
|
<Button
|
|
353
446
|
key={index}
|
|
354
447
|
className="p-2 flex gap-1 text-color"
|
|
355
|
-
onClick={() => handleAddChip(value
|
|
448
|
+
onClick={() => handleAddChip(value)}
|
|
356
449
|
text
|
|
357
450
|
severity="secondary"
|
|
358
451
|
size="small"
|
|
359
452
|
>
|
|
360
|
-
Search <strong>{value
|
|
453
|
+
Search <strong>{value}</strong> for :
|
|
361
454
|
<span className="font-bold" style={{ color: '#000' }}>{inputValue}</span>
|
|
362
455
|
</Button>
|
|
363
456
|
))
|