@solidstarters/solid-core-ui 1.0.2 → 1.1.0
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/auth/SolidForgotPassword.d.ts +3 -0
- package/dist/components/auth/SolidForgotPassword.d.ts.map +1 -0
- package/dist/components/auth/SolidForgotPassword.js +108 -0
- package/dist/components/auth/SolidForgotPassword.js.map +1 -0
- package/dist/components/auth/SolidLogin.d.ts +3 -0
- package/dist/components/auth/SolidLogin.d.ts.map +1 -0
- package/dist/components/auth/SolidLogin.js +115 -0
- package/dist/components/auth/SolidLogin.js.map +1 -0
- package/dist/components/auth/SolidOTPVerify.d.ts +3 -0
- package/dist/components/auth/SolidOTPVerify.d.ts.map +1 -0
- package/dist/components/auth/SolidOTPVerify.js +108 -0
- package/dist/components/auth/SolidOTPVerify.js.map +1 -0
- package/dist/components/auth/SolidRegister.d.ts +3 -0
- package/dist/components/auth/SolidRegister.d.ts.map +1 -0
- package/dist/components/auth/SolidRegister.js +166 -0
- package/dist/components/auth/SolidRegister.js.map +1 -0
- package/dist/components/auth/SolidResetPassword.d.ts +3 -0
- package/dist/components/auth/SolidResetPassword.d.ts.map +1 -0
- package/dist/components/auth/SolidResetPassword.js +119 -0
- package/dist/components/auth/SolidResetPassword.js.map +1 -0
- package/dist/components/core/common/FilterComponent.d.ts +33 -1
- package/dist/components/core/common/FilterComponent.d.ts.map +1 -1
- package/dist/components/core/common/FilterComponent.js +26 -25
- package/dist/components/core/common/FilterComponent.js.map +1 -1
- package/dist/components/core/common/SolidConfigureLayoutElement.d.ts.map +1 -1
- package/dist/components/core/common/SolidConfigureLayoutElement.js +3 -3
- package/dist/components/core/common/SolidConfigureLayoutElement.js.map +1 -1
- package/dist/components/core/common/SolidCreateButton.js +1 -1
- package/dist/components/core/common/SolidCreateButton.js.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.d.ts +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.js +14 -9
- package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
- package/dist/components/core/common/SolidLayoutViews.d.ts +19 -0
- package/dist/components/core/common/SolidLayoutViews.d.ts.map +1 -0
- package/dist/components/core/common/SolidLayoutViews.js +14 -0
- package/dist/components/core/common/SolidLayoutViews.js.map +1 -0
- package/dist/components/core/common/SolidListViewOptions.d.ts +2 -0
- package/dist/components/core/common/SolidListViewOptions.d.ts.map +1 -0
- package/dist/components/core/common/SolidListViewOptions.js +11 -0
- package/dist/components/core/common/SolidListViewOptions.js.map +1 -0
- package/dist/components/core/filter/SolidManyToOneFilterElement.js +1 -1
- package/dist/components/core/filter/SolidManyToOneFilterElement.js.map +1 -1
- package/dist/components/core/filter/columns/SolidBigintField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidBigintField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidBigintField.js +8 -0
- package/dist/components/core/filter/columns/SolidBigintField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidBooleanField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidBooleanField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidBooleanField.js +27 -0
- package/dist/components/core/filter/columns/SolidBooleanField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidComputedField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidComputedField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidComputedField.js +22 -0
- package/dist/components/core/filter/columns/SolidComputedField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidDateField.d.ts +9 -0
- package/dist/components/core/filter/columns/SolidDateField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidDateField.js +35 -0
- package/dist/components/core/filter/columns/SolidDateField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidDatetimeField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidDatetimeField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidDatetimeField.js +24 -0
- package/dist/components/core/filter/columns/SolidDatetimeField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidDecimalField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidDecimalField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidDecimalField.js +8 -0
- package/dist/components/core/filter/columns/SolidDecimalField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidExternalIdField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidExternalIdField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidExternalIdField.js +25 -0
- package/dist/components/core/filter/columns/SolidExternalIdField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidFloatField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidFloatField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidFloatField.js +8 -0
- package/dist/components/core/filter/columns/SolidFloatField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidIdField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidIdField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidIdField.js +25 -0
- package/dist/components/core/filter/columns/SolidIdField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidIntField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidIntField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidIntField.js +34 -0
- package/dist/components/core/filter/columns/SolidIntField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidLongTextField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidLongTextField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidLongTextField.js +8 -0
- package/dist/components/core/filter/columns/SolidLongTextField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidMediaMultipleField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidMediaMultipleField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidMediaMultipleField.js +35 -0
- package/dist/components/core/filter/columns/SolidMediaMultipleField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidMediaSingleField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidMediaSingleField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidMediaSingleField.js +35 -0
- package/dist/components/core/filter/columns/SolidMediaSingleField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidRelationField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidRelationField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidRelationField.js +12 -0
- package/dist/components/core/filter/columns/SolidRelationField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidRichTextField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidRichTextField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidRichTextField.js +8 -0
- package/dist/components/core/filter/columns/SolidRichTextField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidSelectionDynamicField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidSelectionDynamicField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidSelectionDynamicField.js +25 -0
- package/dist/components/core/filter/columns/SolidSelectionDynamicField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidSelectionStaticField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidSelectionStaticField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidSelectionStaticField.js +26 -0
- package/dist/components/core/filter/columns/SolidSelectionStaticField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidShortTextField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidShortTextField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidShortTextField.js +33 -0
- package/dist/components/core/filter/columns/SolidShortTextField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidTimeField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidTimeField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidTimeField.js +24 -0
- package/dist/components/core/filter/columns/SolidTimeField.js.map +1 -0
- package/dist/components/core/filter/columns/SolidUuidField.d.ts +4 -0
- package/dist/components/core/filter/columns/SolidUuidField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/SolidUuidField.js +25 -0
- package/dist/components/core/filter/columns/SolidUuidField.js.map +1 -0
- package/dist/components/core/filter/columns/relations/SolidRelationManyToOneField.d.ts +4 -0
- package/dist/components/core/filter/columns/relations/SolidRelationManyToOneField.d.ts.map +1 -0
- package/dist/components/core/filter/columns/relations/SolidRelationManyToOneField.js +54 -0
- package/dist/components/core/filter/columns/relations/SolidRelationManyToOneField.js.map +1 -0
- package/dist/components/core/kanban/KanbanBoard.d.ts +1 -1
- package/dist/components/core/kanban/KanbanBoard.d.ts.map +1 -1
- package/dist/components/core/kanban/KanbanBoard.js +11 -11
- package/dist/components/core/kanban/KanbanBoard.js.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.d.ts.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.js +113 -202
- package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
- package/dist/components/core/list/SolidListView.d.ts.map +1 -1
- package/dist/components/core/list/SolidListView.js +312 -62
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/list/SolidManyToOneFilterElement.js +2 -3
- package/dist/components/core/list/SolidManyToOneFilterElement.js.map +1 -1
- package/dist/components/core/list/columns/SolidBooleanColumn.js +3 -1
- package/dist/components/core/list/columns/SolidBooleanColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.js +3 -1
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidShortTextColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidShortTextColumn.js +5 -1
- package/dist/components/core/list/columns/SolidShortTextColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidTimeColumn.js +3 -1
- package/dist/components/core/list/columns/SolidTimeColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidUuidColumn.js +3 -1
- package/dist/components/core/list/columns/SolidUuidColumn.js.map +1 -1
- package/dist/components/layout/AppConfig.d.ts +4 -0
- package/dist/components/layout/AppConfig.d.ts.map +1 -0
- package/dist/components/layout/AppConfig.js +57 -0
- package/dist/components/layout/AppConfig.js.map +1 -0
- package/dist/components/layout/AppSidebar.d.ts +3 -0
- package/dist/components/layout/AppSidebar.d.ts.map +1 -0
- package/dist/components/layout/AppSidebar.js +75 -0
- package/dist/components/layout/AppSidebar.js.map +1 -0
- package/dist/components/layout/CustomPagination.d.ts +0 -6
- package/dist/components/layout/CustomPagination.d.ts.map +1 -1
- package/dist/components/layout/CustomPagination.js +48 -27
- package/dist/components/layout/CustomPagination.js.map +1 -1
- package/dist/components/layout/FilterMenu.d.ts.map +1 -1
- package/dist/components/layout/FilterMenu.js +1 -2
- package/dist/components/layout/FilterMenu.js.map +1 -1
- package/dist/components/layout/context/layoutcontext.d.ts +5 -0
- package/dist/components/layout/context/layoutcontext.d.ts.map +1 -0
- package/dist/components/layout/context/layoutcontext.js +56 -0
- package/dist/components/layout/context/layoutcontext.js.map +1 -0
- package/dist/components/layout/navbar-two-menu.d.ts.map +1 -1
- package/dist/components/layout/navbar-two-menu.js +5 -5
- package/dist/components/layout/navbar-two-menu.js.map +1 -1
- package/dist/components/layout/user-profile-menu.d.ts.map +1 -1
- package/dist/components/layout/user-profile-menu.js +37 -5
- package/dist/components/layout/user-profile-menu.js.map +1 -1
- package/dist/components/modelsComponents/filterIcon.d.ts.map +1 -1
- package/dist/components/modelsComponents/filterIcon.js.map +1 -1
- package/dist/components/tables/ListViewTable.d.ts.map +1 -1
- package/dist/components/tables/ListViewTable.js +2 -1
- package/dist/components/tables/ListViewTable.js.map +1 -1
- package/dist/helpers/helpers.d.ts +1 -1
- package/dist/helpers/helpers.d.ts.map +1 -1
- package/dist/index.d.ts +19 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/auth/SolidForgotPassword.tsx +124 -0
- package/src/components/auth/SolidLogin.tsx +156 -0
- package/src/components/auth/SolidOTPVerify.tsx +127 -0
- package/src/components/auth/SolidRegister.tsx +221 -0
- package/src/components/auth/SolidResetPassword.tsx +160 -0
- package/src/components/core/common/FilterComponent.tsx +45 -40
- package/src/components/core/common/SolidConfigureLayoutElement.tsx +11 -10
- package/src/components/core/common/SolidCreateButton.tsx +1 -1
- package/src/components/core/common/SolidGlobalSearchElement.tsx +33 -13
- package/src/components/core/common/SolidLayoutViews.tsx +87 -0
- package/src/components/core/common/SolidListViewOptions.tsx +31 -0
- package/src/components/core/filter/SolidManyToOneFilterElement.tsx +1 -1
- package/src/components/core/kanban/KanbanBoard.tsx +7 -4
- package/src/components/core/kanban/SolidKanbanView.tsx +110 -248
- package/src/components/core/list/SolidListView.tsx +421 -96
- package/src/components/core/list/SolidManyToOneFilterElement.tsx +3 -3
- package/src/components/core/list/columns/SolidBooleanColumn.tsx +1 -1
- package/src/components/core/list/columns/SolidSelectionStaticColumn.tsx +1 -1
- package/src/components/core/list/columns/SolidShortTextColumn.tsx +8 -3
- package/src/components/core/list/columns/SolidTimeColumn.tsx +1 -1
- package/src/components/core/list/columns/SolidUuidColumn.tsx +1 -1
- package/src/components/layout/AppConfig.tsx +103 -0
- package/src/components/layout/AppSidebar.tsx +170 -0
- package/src/components/layout/CustomPagination.tsx +55 -55
- package/src/components/layout/FilterMenu.tsx +1 -2
- package/src/components/layout/context/layoutcontext.tsx +52 -0
- package/src/components/layout/navbar-two-menu.tsx +12 -9
- package/src/components/layout/user-profile-menu.tsx +74 -189
- package/src/components/modelsComponents/filterIcon.tsx +0 -1
- package/src/components/tables/ListViewTable.tsx +4 -3
- package/src/index.ts +157 -144
- package/src/types/index.d.ts +26 -0
- package/src/types/layout.d.ts +94 -0
- package/src/types/next-auth.d.ts +0 -0
- package/dist/components/core/kanban/SolidKanbanFilter.d.ts +0 -2
- package/dist/components/core/kanban/SolidKanbanFilter.d.ts.map +0 -1
- package/dist/components/core/kanban/SolidKanbanViewSearchColumn.d.ts +0 -10
- package/dist/components/core/kanban/SolidKanbanViewSearchColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/SolidManyToOneFilterElement.d.ts +0 -2
- package/dist/components/core/kanban/SolidManyToOneFilterElement.d.ts.map +0 -1
- package/dist/components/core/kanban/SolidSelectionDynamicFilterElement.d.ts +0 -2
- package/dist/components/core/kanban/SolidSelectionDynamicFilterElement.d.ts.map +0 -1
- package/dist/components/core/kanban/SolidSelectionStaticFilterElement.d.ts +0 -2
- package/dist/components/core/kanban/SolidSelectionStaticFilterElement.d.ts.map +0 -1
- package/dist/components/core/kanban/SolidVarInputsFilterElement.d.ts +0 -12
- package/dist/components/core/kanban/SolidVarInputsFilterElement.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidBigintColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidBigintColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidBooleanColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidBooleanColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidComputedColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidComputedColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidDateColumn.d.ts +0 -9
- package/dist/components/core/kanban/columns/SolidDateColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidDatetimeColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidDatetimeColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidDecimalColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidDecimalColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidExternalIdColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidExternalIdColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidFloatColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidFloatColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidIdColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidIdColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidIntColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidIntColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidLongTextColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidLongTextColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidMediaMultipleColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidMediaMultipleColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidMediaSingleColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidMediaSingleColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidRelationColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidRelationColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidRichTextColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidRichTextColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidSelectionDynamicColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidSelectionDynamicColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidSelectionStaticColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidSelectionStaticColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidShortTextColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidShortTextColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidTimeColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidTimeColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/SolidUuidColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/SolidUuidColumn.d.ts.map +0 -1
- package/dist/components/core/kanban/columns/relations/SolidRelationManyToOneColumn.d.ts +0 -4
- package/dist/components/core/kanban/columns/relations/SolidRelationManyToOneColumn.d.ts.map +0 -1
- package/src/components/common/FilterComponent.tsx +0 -428
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
"use client";
|
|
3
|
-
import { Calendar } from 'primereact/calendar';
|
|
4
|
-
import { Dropdown } from 'primereact/dropdown';
|
|
5
|
-
import { InputNumber } from 'primereact/inputnumber';
|
|
6
|
-
import { InputText } from 'primereact/inputtext';
|
|
7
|
-
import { Tooltip } from 'primereact/tooltip';
|
|
8
|
-
import React, { useState } from 'react';
|
|
9
|
-
|
|
10
|
-
enum FilterRuleType {
|
|
11
|
-
RULE = 'rule',
|
|
12
|
-
RULE_GROUP = 'rule_group'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
enum FilterOperator {
|
|
16
|
-
AND = 'and',
|
|
17
|
-
OR = 'or'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
enum FilterMatchMode {
|
|
21
|
-
STARTS_WITH = 'startsWith',
|
|
22
|
-
CONTAINS = 'contains',
|
|
23
|
-
EQUALS = 'equals',
|
|
24
|
-
GREATER_THAN = 'gt',
|
|
25
|
-
LESS_THAN = 'lt',
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface FilterRule {
|
|
29
|
-
id: number;
|
|
30
|
-
type: FilterRuleType;
|
|
31
|
-
matchOperator?: FilterOperator;
|
|
32
|
-
fieldName?: string;
|
|
33
|
-
matchMode?: FilterMatchMode;
|
|
34
|
-
value?: any;
|
|
35
|
-
parentRule: number | null;
|
|
36
|
-
children?: FilterRule[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface Field {
|
|
40
|
-
name: string;
|
|
41
|
-
type: 'string' | 'number' | 'date';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const fields: Field[] = [
|
|
45
|
-
{ name: 'name', type: 'string' },
|
|
46
|
-
{ name: 'dob', type: 'date' },
|
|
47
|
-
{ name: 'lastName', type: 'string' },
|
|
48
|
-
{ name: 'amount', type: 'number' }
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
const operatorOptions = {
|
|
52
|
-
string: [FilterMatchMode.CONTAINS, FilterMatchMode.EQUALS],
|
|
53
|
-
date: [FilterMatchMode.EQUALS, FilterMatchMode.GREATER_THAN, FilterMatchMode.LESS_THAN],
|
|
54
|
-
number: [FilterMatchMode.GREATER_THAN, FilterMatchMode.LESS_THAN]
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const getRandomInt = (min, max) => {
|
|
58
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Component to render a single filter rule
|
|
62
|
-
const FilterRuleComponent = ({ rule, onChange, onAddRule, onAddGroup, onDelete, level }) => {
|
|
63
|
-
const applicableOperators = rule.fieldName ? operatorOptions[fields.find(f => f.name === rule.fieldName)?.type].map(e => { return { name: e } }) : [];
|
|
64
|
-
const applicableInputField = rule.fieldName ? fields.find(f => f.name === rule.fieldName)?.type : "";
|
|
65
|
-
|
|
66
|
-
const [fieldName, setFieldName] = useState({ name: rule.fieldName });
|
|
67
|
-
const [matchMode, setMatchMode] = useState({ name: rule.matchMode });
|
|
68
|
-
|
|
69
|
-
console.log("fields");
|
|
70
|
-
console.log(fields);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
// <div style={{ marginLeft: (level - 1) * 10 + 'px' }} className="filter-rule">
|
|
75
|
-
<div style={{ marginLeft: 5 + 'px' }} className="filter-rule">
|
|
76
|
-
<div className="filter-individual-rule">
|
|
77
|
-
<div className='filter-individual-rule-form'>
|
|
78
|
-
<div className="grid align-items-center">
|
|
79
|
-
<div className="col-10">
|
|
80
|
-
<div className="grid">
|
|
81
|
-
<div className="col-4">
|
|
82
|
-
{/* <select
|
|
83
|
-
value={rule.fieldName || ''}
|
|
84
|
-
onChange={e => onChange(rule.id, 'fieldName', e.target.value)}
|
|
85
|
-
>
|
|
86
|
-
<option value="" disabled>Select Field</option>
|
|
87
|
-
{fields.map(field => (
|
|
88
|
-
<option key={field.name} value={field.name}>{field.name}</option>
|
|
89
|
-
))}
|
|
90
|
-
</select> */}
|
|
91
|
-
<Dropdown
|
|
92
|
-
value={fieldName}
|
|
93
|
-
onChange={e => {
|
|
94
|
-
console.log("e.target");
|
|
95
|
-
console.log(e.target);
|
|
96
|
-
|
|
97
|
-
setFieldName({ name: e.value.name , type: e.value.type})
|
|
98
|
-
onChange(rule.id, 'fieldName', e.value.name)
|
|
99
|
-
}}
|
|
100
|
-
options={fields}
|
|
101
|
-
optionLabel='name'
|
|
102
|
-
optionValue='name'
|
|
103
|
-
placeholder="Select Field" className="w-full md:w-14rem" />
|
|
104
|
-
|
|
105
|
-
</div>
|
|
106
|
-
<div className="col-4">
|
|
107
|
-
{/* <select
|
|
108
|
-
value={rule.matchMode || ''}
|
|
109
|
-
onChange={e => onChange(rule.id, 'matchMode', e.target.value)}
|
|
110
|
-
disabled={!rule.fieldName}
|
|
111
|
-
>
|
|
112
|
-
<option value="" disabled>Select Operator</option>
|
|
113
|
-
{applicableOperators.map(op => (
|
|
114
|
-
<option key={op} value={op}>{op}</option>
|
|
115
|
-
))}
|
|
116
|
-
</select> */}
|
|
117
|
-
<Dropdown
|
|
118
|
-
value={matchMode}
|
|
119
|
-
onChange={e => {
|
|
120
|
-
setMatchMode({ name: e.value.name })
|
|
121
|
-
onChange(rule.id, 'matchMode', e.value.name)
|
|
122
|
-
}}
|
|
123
|
-
disabled={!rule.fieldName}
|
|
124
|
-
options={applicableOperators}
|
|
125
|
-
optionLabel='name'
|
|
126
|
-
optionValue='name'
|
|
127
|
-
placeholder="Select Field" className="w-full md:w-14rem" />
|
|
128
|
-
|
|
129
|
-
</div>
|
|
130
|
-
<div className="col-4">
|
|
131
|
-
{applicableInputField === 'number' && (
|
|
132
|
-
// <input
|
|
133
|
-
// type="number"
|
|
134
|
-
// value={rule.value || ''}
|
|
135
|
-
// onChange={e => onChange(rule.id, 'value', e.target.value)}
|
|
136
|
-
// placeholder="Value"
|
|
137
|
-
// />
|
|
138
|
-
<InputNumber
|
|
139
|
-
value={rule.value || ''}
|
|
140
|
-
placeholder="Value"
|
|
141
|
-
onChange={(e) => onChange(rule.id, 'value', e.value)}
|
|
142
|
-
/>
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
{applicableInputField === 'string' && (
|
|
146
|
-
<InputText
|
|
147
|
-
value={rule.value || ''}
|
|
148
|
-
placeholder="Value"
|
|
149
|
-
onChange={(e) => onChange(rule.id, 'value', e.target.value)}
|
|
150
|
-
/>
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
{applicableInputField === 'date' && (
|
|
154
|
-
// <InputText
|
|
155
|
-
// value={rule.value || ''}
|
|
156
|
-
// placeholder="Value"
|
|
157
|
-
// onChange={(e) => onChange(rule.id, 'value', e.target.value)}
|
|
158
|
-
// />
|
|
159
|
-
|
|
160
|
-
<Calendar value={rule.value || ''} onChange={(e) => onChange(rule.id, 'value', new Date(e.value))} dateFormat="dd/mm/yy" showIcon />
|
|
161
|
-
)
|
|
162
|
-
}
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
<div className="col-2 flex justify-content-end">
|
|
169
|
-
<button onClick={() => onAddRule(rule.parentRule)}>
|
|
170
|
-
<div className="card flex justify-content-center">
|
|
171
|
-
{/* <Tooltip target=".custom-target-icon" /> */}
|
|
172
|
-
|
|
173
|
-
<i className="custom-target-icon pi pi-plus-circle p-text-secondary p-overlay-badge"
|
|
174
|
-
data-pr-tooltip="Add Rule"
|
|
175
|
-
data-pr-position="right"
|
|
176
|
-
data-pr-at="right+5 top"
|
|
177
|
-
data-pr-my="left center-2"
|
|
178
|
-
style={{ fontSize: '1.2rem', cursor: 'pointer' }}>
|
|
179
|
-
</i>
|
|
180
|
-
</div>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
</button>
|
|
184
|
-
<button onClick={() => onAddGroup(rule.id)}>
|
|
185
|
-
<div className="card flex justify-content-center">
|
|
186
|
-
{/* <Tooltip target=".custom-target-icon" /> */}
|
|
187
|
-
|
|
188
|
-
<i className="custom-target-icon pi pi-sitemap p-text-secondary p-overlay-badge"
|
|
189
|
-
data-pr-tooltip="Add Group"
|
|
190
|
-
data-pr-position="right"
|
|
191
|
-
data-pr-at="right+5 top"
|
|
192
|
-
data-pr-my="left center-2"
|
|
193
|
-
style={{ fontSize: '1.2rem', cursor: 'pointer' }}>
|
|
194
|
-
</i>
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
</button>
|
|
198
|
-
|
|
199
|
-
<button onClick={() => onDelete(rule.id)}>
|
|
200
|
-
<div className="card flex justify-content-center">
|
|
201
|
-
{/* <Tooltip target=".custom-target-icon" /> */}
|
|
202
|
-
|
|
203
|
-
<i className="custom-target-icon pi pi-trash p-text-secondary p-overlay-badge"
|
|
204
|
-
data-pr-tooltip="Delete Rule"
|
|
205
|
-
data-pr-position="right"
|
|
206
|
-
data-pr-at="right+5 top"
|
|
207
|
-
data-pr-my="left center-2"
|
|
208
|
-
style={{ fontSize: '1.2rem', cursor: 'pointer' }}>
|
|
209
|
-
</i>
|
|
210
|
-
</div>
|
|
211
|
-
</button>
|
|
212
|
-
|
|
213
|
-
</div>
|
|
214
|
-
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
</div>
|
|
224
|
-
|
|
225
|
-
<div className="nested-rules">
|
|
226
|
-
{rule.children && rule.children.map(nestedRule => (
|
|
227
|
-
nestedRule.type === FilterRuleType.RULE
|
|
228
|
-
? <FilterRuleComponent key={nestedRule.id} rule={nestedRule} onChange={onChange} onAddRule={onAddRule} onAddGroup={onAddGroup} onDelete={onDelete} level={level + 1} />
|
|
229
|
-
: <FilterGroupComponent key={nestedRule.id} group={nestedRule} onChange={onChange} onAddRule={onAddRule} onAddGroup={onAddGroup} onDelete={onDelete} level={level + 1} />
|
|
230
|
-
))}
|
|
231
|
-
</div>
|
|
232
|
-
</div>
|
|
233
|
-
);
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// Component to render a group of filter rules
|
|
237
|
-
const FilterGroupComponent = ({ group, onChange, onAddRule, onAddGroup, onDelete, level }) => {
|
|
238
|
-
return (
|
|
239
|
-
<div style={{ marginLeft: 5 + 'px' }} className="filter-group">
|
|
240
|
-
{/* <div style={{ marginLeft: (level - 1) * 10 + 'px' }} className="filter-group"> */}
|
|
241
|
-
|
|
242
|
-
<div className='flex justify-content-between align-items-center'>
|
|
243
|
-
<p> Match
|
|
244
|
-
<select className='filter-select'
|
|
245
|
-
value={group.matchOperator}
|
|
246
|
-
onChange={e => onChange(group.id, 'matchOperator', e.target.value)}
|
|
247
|
-
>
|
|
248
|
-
<option value={FilterOperator.AND}>AND</option>
|
|
249
|
-
<option value={FilterOperator.OR}>OR</option>
|
|
250
|
-
</select>
|
|
251
|
-
of the following rules:</p>
|
|
252
|
-
|
|
253
|
-
{/* <button onClick={() => onAddRule(group.id)}>Add Rule to Group</button> */}
|
|
254
|
-
{/* <button onClick={() => onAddGroup(group.id)}>Add Group to Group</button> */}
|
|
255
|
-
|
|
256
|
-
{/* Add Delete Button for non-root groups */}
|
|
257
|
-
{level > 0 && <button onClick={() => onDelete(group.id)}>
|
|
258
|
-
<div className="card flex justify-content-center">
|
|
259
|
-
<Tooltip target=".custom-target-icon" />
|
|
260
|
-
|
|
261
|
-
<i className="custom-target-icon pi pi-trash p-text-secondary p-overlay-badge"
|
|
262
|
-
data-pr-tooltip="Delete Group"
|
|
263
|
-
data-pr-position="right"
|
|
264
|
-
data-pr-at="right+5 top"
|
|
265
|
-
data-pr-my="left center-2"
|
|
266
|
-
style={{ fontSize: '1.2rem', cursor: 'pointer' }}>
|
|
267
|
-
</i>
|
|
268
|
-
</div></button>}
|
|
269
|
-
</div>
|
|
270
|
-
{group.children && group.children.map(rule => (
|
|
271
|
-
rule.type === FilterRuleType.RULE
|
|
272
|
-
? <FilterRuleComponent key={rule.id} rule={rule} onChange={onChange} onAddRule={onAddRule} onAddGroup={onAddGroup} onDelete={onDelete} level={level + 1} />
|
|
273
|
-
: <FilterGroupComponent key={rule.id} group={rule} onChange={onChange} onAddRule={onAddRule} onAddGroup={onAddGroup} onDelete={onDelete} level={level + 1} />
|
|
274
|
-
))}
|
|
275
|
-
</div>
|
|
276
|
-
);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
// Main Filter component
|
|
280
|
-
const FilterComponent = () => {
|
|
281
|
-
const initialState: FilterRule[] = [
|
|
282
|
-
{
|
|
283
|
-
id: 1,
|
|
284
|
-
type: FilterRuleType.RULE_GROUP,
|
|
285
|
-
matchOperator: FilterOperator.OR,
|
|
286
|
-
parentRule: null,
|
|
287
|
-
children: [
|
|
288
|
-
{
|
|
289
|
-
id: Date.now() + getRandomInt(1, 500),
|
|
290
|
-
type: FilterRuleType.RULE,
|
|
291
|
-
fieldName: null,
|
|
292
|
-
matchMode: null,
|
|
293
|
-
value: null,
|
|
294
|
-
parentRule: 1,
|
|
295
|
-
children: []
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
|
-
}
|
|
299
|
-
];
|
|
300
|
-
|
|
301
|
-
const [filterRules, setFilterRules] = useState<FilterRule[]>(initialState);
|
|
302
|
-
const [printedState, setPrintedState] = useState<string>('');
|
|
303
|
-
|
|
304
|
-
const addChild = (rules, parentId, newChild) => {
|
|
305
|
-
return rules.map(rule => {
|
|
306
|
-
if (rule.id === parentId) {
|
|
307
|
-
return {
|
|
308
|
-
...rule,
|
|
309
|
-
children: [...(rule.children || []), newChild]
|
|
310
|
-
};
|
|
311
|
-
} else if (rule.children) {
|
|
312
|
-
return {
|
|
313
|
-
...rule,
|
|
314
|
-
children: addChild(rule.children, parentId, newChild)
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
return rule;
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const handleChange = (id, key, value) => {
|
|
322
|
-
const updateRuleRecursively = (rules) => {
|
|
323
|
-
return rules.map(rule => {
|
|
324
|
-
if (rule.id === id) {
|
|
325
|
-
return { ...rule, [key]: value };
|
|
326
|
-
} else if (rule.children) {
|
|
327
|
-
return {
|
|
328
|
-
...rule,
|
|
329
|
-
children: updateRuleRecursively(rule.children)
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
return rule;
|
|
333
|
-
});
|
|
334
|
-
};
|
|
335
|
-
setFilterRules(prev => updateRuleRecursively(prev));
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
const handleAddRule = (parentGroupId) => {
|
|
339
|
-
const newRule: FilterRule = {
|
|
340
|
-
id: Date.now(),
|
|
341
|
-
type: FilterRuleType.RULE,
|
|
342
|
-
fieldName: null,
|
|
343
|
-
matchMode: null,
|
|
344
|
-
value: null,
|
|
345
|
-
parentRule: parentGroupId,
|
|
346
|
-
children: []
|
|
347
|
-
};
|
|
348
|
-
setFilterRules(prev => addChild(prev, parentGroupId, newRule));
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
const handleAddGroup = (parentRuleId) => {
|
|
352
|
-
const newGroupId = Date.now();
|
|
353
|
-
const newGroup: FilterRule = {
|
|
354
|
-
id: newGroupId,
|
|
355
|
-
type: FilterRuleType.RULE_GROUP,
|
|
356
|
-
matchOperator: FilterOperator.AND,
|
|
357
|
-
parentRule: parentRuleId,
|
|
358
|
-
children: [
|
|
359
|
-
{
|
|
360
|
-
id: Date.now() + getRandomInt(1, 500),
|
|
361
|
-
type: FilterRuleType.RULE,
|
|
362
|
-
fieldName: null,
|
|
363
|
-
matchMode: null,
|
|
364
|
-
value: null,
|
|
365
|
-
parentRule: newGroupId,
|
|
366
|
-
children: []
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
id: Date.now() + getRandomInt(1, 500),
|
|
370
|
-
type: FilterRuleType.RULE,
|
|
371
|
-
fieldName: null,
|
|
372
|
-
matchMode: null,
|
|
373
|
-
value: null,
|
|
374
|
-
parentRule: newGroupId,
|
|
375
|
-
children: []
|
|
376
|
-
}
|
|
377
|
-
]
|
|
378
|
-
};
|
|
379
|
-
setFilterRules(prev => addChild(prev, parentRuleId, newGroup));
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
const handleDeleteRule = (id) => {
|
|
383
|
-
const deleteRecursively = (rules, id) => {
|
|
384
|
-
return rules.filter(rule => rule.id !== id).map(rule => {
|
|
385
|
-
if (rule.children) {
|
|
386
|
-
return {
|
|
387
|
-
...rule,
|
|
388
|
-
children: deleteRecursively(rule.children, id)
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
return rule;
|
|
392
|
-
});
|
|
393
|
-
};
|
|
394
|
-
setFilterRules(prev => deleteRecursively(prev, id));
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
const handlePrintState = () => {
|
|
398
|
-
setPrintedState(JSON.stringify(filterRules, null, 2)); // Pretty format the state
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
return (
|
|
402
|
-
<div className=''>
|
|
403
|
-
<div className="filter-builder">
|
|
404
|
-
|
|
405
|
-
{filterRules.map(rule => (
|
|
406
|
-
<FilterGroupComponent
|
|
407
|
-
key={rule.id}
|
|
408
|
-
group={rule}
|
|
409
|
-
onChange={handleChange}
|
|
410
|
-
onAddRule={handleAddRule}
|
|
411
|
-
onAddGroup={handleAddGroup}
|
|
412
|
-
onDelete={handleDeleteRule}
|
|
413
|
-
level={0} // Top-level group
|
|
414
|
-
/>
|
|
415
|
-
))}
|
|
416
|
-
|
|
417
|
-
</div>
|
|
418
|
-
|
|
419
|
-
<div>
|
|
420
|
-
<button onClick={handlePrintState}>Print State</button>
|
|
421
|
-
<br></br>
|
|
422
|
-
<textarea value={printedState} readOnly rows={20} cols={80} style={{ marginTop: '20px' }} />
|
|
423
|
-
</div>
|
|
424
|
-
</div>
|
|
425
|
-
);
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
export default FilterComponent;
|