@isettingkit/business-rules 0.2.2 โ 1.0.1
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/README.md +64 -150
- package/dist/index.es.d.ts +52 -10
- package/dist/index.es.js +992 -782
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,173 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# isettingkit
|
|
2
|
+
isettingkit is a modular UI toolkit designed to streamline the creation and management of business rule-driven interfaces. It offers a suite of reusable components, utilities, and type definitions to facilitate the development of dynamic, rule-based forms and configurations.
|
|
2
3
|
|
|
3
|
-
##
|
|
4
|
+
## ๐ Project Structure
|
|
5
|
+
The src directory is organized into the following primary modules:
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
### 1. businessRules
|
|
8
|
+
Contains components and utilities for managing business rules:
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
Cards/: Components like BusinessRuleCard for visual representation of individual rules.
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
Form/: Components such as RulesForm to create and edit business rules.
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
Modal/: Modal components for rule creation and editing workflows.
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
The `getValueData` function extracts and formats the value data from a decision or condition element.
|
|
16
|
+
BusinessRuleView.tsx: A comprehensive view component to display business rules.
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
### 2. Filter
|
|
19
|
+
Provides components to filter and search through business rules:
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
```tsx
|
|
21
|
-
const value = getValueData(decision.decision);
|
|
22
|
-
```
|
|
21
|
+
FilterModal/: Modal components for applying filters.
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
decision={ruleDecision}
|
|
35
|
-
textValues={textValues}
|
|
36
|
-
/>
|
|
37
|
-
```
|
|
23
|
+
FilterTag/: Tag components representing active filters.
|
|
24
|
+
|
|
25
|
+
FormFilter/: Form components to define filter criteria.
|
|
26
|
+
|
|
27
|
+
### 3. types
|
|
28
|
+
Defines TypeScript interfaces and types to ensure type safety across components:
|
|
29
|
+
|
|
30
|
+
businessRules/: Types related to business rule components.
|
|
31
|
+
|
|
32
|
+
Filter/: Types associated with filtering functionalities.
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- **children** (React.ReactNode): The content of the card.
|
|
45
|
-
- **handleDelete** ((id: string) => void): Function to handle the deletion of a rule.
|
|
46
|
-
- **handleView** ((id: string) => void): Function to handle viewing a rule.
|
|
47
|
-
- **id (string)** : The ID of the business rule.
|
|
48
|
-
#### Usage Example
|
|
49
|
-
```tsx
|
|
50
|
-
<BusinessRuleCard
|
|
51
|
-
id="rule1"
|
|
52
|
-
handleDelete={deleteRule}
|
|
53
|
-
handleView={viewRule}
|
|
54
|
-
/>
|
|
34
|
+
## ๐ Getting Started
|
|
35
|
+
Installation
|
|
36
|
+
Install the package using npm:
|
|
37
|
+
``` bash
|
|
38
|
+
npm install @isettingkit/business-rules
|
|
55
39
|
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
#### Props
|
|
61
|
-
- **id** (string): The unique ID for the form.
|
|
62
|
-
- **decision** (IRuleDecision): The decision data for the form.
|
|
63
|
-
- **onCloseModal** (() => void): Function to handle closing the modal.
|
|
64
|
-
- **onCancel** (() => void): Function to handle cancelling the form.
|
|
65
|
-
- **onSubmitEvent** ((dataDecision: IRuleDecision) => void): Function to handle submitting the form data.
|
|
66
|
-
- **textValues** (IRulesFormTextValues): Text values for the form labels and descriptions.
|
|
67
|
-
#### Usage Example
|
|
68
|
-
```tsx
|
|
69
|
-
<RulesForm
|
|
70
|
-
id="ruleForm1"
|
|
71
|
-
decision={ruleDecision}
|
|
72
|
-
onCloseModal={closeModal}
|
|
73
|
-
onCancel={cancelForm}
|
|
74
|
-
onSubmitEvent={submitDecision}
|
|
75
|
-
/>
|
|
40
|
+
Usage
|
|
41
|
+
Import and use the components in your project:
|
|
42
|
+
``` bash
|
|
43
|
+
import { BusinessRuleCard, RulesForm } from '@isettingkit/business-rules';
|
|
76
44
|
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
- **placeholder** (string): The placeholder text for the textarea.
|
|
87
|
-
- **required** (boolean): Indicates if the field is required.
|
|
88
|
-
- **value** (string?): The value of the textarea (optional).
|
|
89
|
-
#### Usage Example
|
|
90
|
-
```tsx
|
|
91
|
-
<ReasonForChange
|
|
92
|
-
label="Change Reason"
|
|
93
|
-
labelText="Reason for Change"
|
|
94
|
-
onHandleChange={handleChange}
|
|
95
|
-
placeholder="Enter reason for change"
|
|
96
|
-
required={true}
|
|
97
|
-
/>
|
|
45
|
+
``` tsx
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<div>
|
|
49
|
+
<BusinessRuleCard rule={ruleData} />
|
|
50
|
+
<RulesForm onSubmit={handleSubmit} />
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
98
54
|
```
|
|
55
|
+
## Theming
|
|
56
|
+
isettingkit utilizes styled-components for styling. Ensure your application is wrapped with a ThemeProvider and the appropriate theme is provided.
|
|
99
57
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
Term is a component used to handle the start and end dates of a business rule term. It allows for toggling between an open and closed term, and managing start and end dates.
|
|
103
|
-
|
|
104
|
-
#### Props
|
|
105
|
-
- **onHandleStartChange** ((event: React.ChangeEvent<HTMLInputElement>) => void): Callback to handle the change in start date.
|
|
106
|
-
- **onHandleEndChange** ((event: React.ChangeEvent<HTMLInputElement>) => void): Callback to handle the change in end date.
|
|
107
|
-
- **labelStart** (string): The label for the start date input.
|
|
108
|
-
- **labelEnd** (string): The label for the end date input.
|
|
109
|
-
- **checkedClosed** (boolean?): Whether the term is closed (optional).
|
|
110
|
-
- **required** (boolean?): Whether the fields are required (optional).
|
|
111
|
-
- **valueStart** (string?): The value for the start date (optional).
|
|
112
|
-
- **valueEnd** (string?): The value for the end date (optional).
|
|
113
|
-
#### Usage Example
|
|
114
|
-
```tsx
|
|
115
|
-
<Term
|
|
116
|
-
labelStart="Start Date"
|
|
117
|
-
labelEnd="End Date"
|
|
118
|
-
onHandleStartChange={handleStartChange}
|
|
119
|
-
onHandleEndChange={handleEndChange}
|
|
120
|
-
/>
|
|
121
|
-
```
|
|
58
|
+
## ๐ Documentation
|
|
59
|
+
Each component is fully typed with TypeScript. Refer to the types directory for detailed type definitions:
|
|
122
60
|
|
|
123
|
-
|
|
124
|
-
#### Description
|
|
125
|
-
ToggleOption is a component that renders a toggle switch and displays additional content when the toggle is checked.
|
|
126
|
-
|
|
127
|
-
#### Props
|
|
128
|
-
- **checked** (boolean): The current checked state of the toggle.
|
|
129
|
-
- **children** (React.ReactNode): The content to display when the toggle is checked.
|
|
130
|
-
- **handleToggleChange** ((e: React.ChangeEvent<HTMLInputElement>) => void): Callback to handle the toggle change event.
|
|
131
|
-
- **id** (string): The unique ID for the toggle.
|
|
132
|
-
- **labelToggle** (string): The label for the toggle.
|
|
133
|
-
- **name** (string): The name of the toggle input.
|
|
134
|
-
- **valueToggle** (string?): The value of the toggle input (optional).
|
|
135
|
-
#### Usage Example
|
|
136
|
-
```tsx
|
|
137
|
-
<ToggleOption
|
|
138
|
-
checked={isChecked}
|
|
139
|
-
handleToggleChange={handleToggleChange}
|
|
140
|
-
id="toggleOption1"
|
|
141
|
-
labelToggle="Enable Option"
|
|
142
|
-
name="optionToggle"
|
|
143
|
-
/>
|
|
144
|
-
```
|
|
61
|
+
IBusinessRuleCard: Props for BusinessRuleCard component.
|
|
145
62
|
|
|
146
|
-
|
|
147
|
-
#### 1. Installation
|
|
148
|
-
Install the library using npm:
|
|
63
|
+
IRulesForm: Props for RulesForm component.
|
|
149
64
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Once installed, you can import and use the components like this:
|
|
65
|
+
IFilterTag: Props for FilterTag component.
|
|
66
|
+
|
|
67
|
+
## ๐ Development
|
|
68
|
+
To contribute or run the library locally:
|
|
155
69
|
|
|
156
|
-
|
|
157
|
-
|
|
70
|
+
Clone the repository:
|
|
71
|
+
``` bash
|
|
72
|
+
git clone https://github.com/selsa-inube/isettingkit.git
|
|
158
73
|
```
|
|
159
|
-
|
|
160
|
-
To visualize the components in action, we use Storybook. Storybook allows developers to interact with the components in isolation, view different states, and confirm that they behave as expected.
|
|
74
|
+
Navigate to the project directory:
|
|
161
75
|
|
|
162
|
-
|
|
76
|
+
cd isettingkit
|
|
163
77
|
|
|
164
|
-
|
|
78
|
+
Install dependencies:
|
|
79
|
+
``` bash
|
|
80
|
+
npm install
|
|
81
|
+
```
|
|
82
|
+
Run the development server:
|
|
83
|
+
``` bash
|
|
165
84
|
npm run storybook
|
|
166
85
|
```
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
- **BusinessRuleCard**: Displays a business rule in a card format with options to view or delete.
|
|
170
|
-
- **RulesForm**: A form component for handling and submitting business rule decisions.
|
|
171
|
-
- **ReasonForChange**: A textarea input for capturing the reason for a change.
|
|
172
|
-
- **Term**: Manages the start and end dates for a business rule term.
|
|
173
|
-
- **ToggleOption**: A toggle switch component with additional content.
|
|
86
|
+
## ๐งช Testing
|
|
87
|
+
The project uses Storybook for component development and visualization. Run Storybook to view and test components in isolation.
|
package/dist/index.es.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ICondition } from '@isettingkit/input';
|
|
2
2
|
import { IDecision } from '@isettingkit/input';
|
|
3
|
+
import { IOption } from '@inubekit/inubekit';
|
|
3
4
|
import { IRuleDecision } from '@isettingkit/input';
|
|
4
5
|
import { IValue } from '@isettingkit/input';
|
|
5
6
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
@@ -13,6 +14,12 @@ export declare const BusinessRules: (props: IBusinessRules) => JSX_2.Element;
|
|
|
13
14
|
|
|
14
15
|
export declare const BusinessRuleView: (props: IBusinessRuleView) => JSX_2.Element;
|
|
15
16
|
|
|
17
|
+
export declare const Filter: (props: IFilter) => JSX_2.Element;
|
|
18
|
+
|
|
19
|
+
export declare const FilterModal: (props: IFilterModal) => ReactPortal;
|
|
20
|
+
|
|
21
|
+
export declare const FormFilter: (props: IFormFilter) => JSX_2.Element;
|
|
22
|
+
|
|
16
23
|
export declare interface IBusinessRuleCard {
|
|
17
24
|
children: React.ReactNode;
|
|
18
25
|
controls?: boolean;
|
|
@@ -44,22 +51,57 @@ export declare interface IBusinessRuleView {
|
|
|
44
51
|
textValues?: IRulesFormTextValues;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
declare interface
|
|
54
|
+
export declare interface ICheckpickerField {
|
|
55
|
+
label?: string;
|
|
56
|
+
name: string;
|
|
57
|
+
options: IOption[];
|
|
58
|
+
values: string;
|
|
59
|
+
placeholder?: string;
|
|
60
|
+
required?: boolean;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
message?: string;
|
|
63
|
+
invalid?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export declare interface IFilter {
|
|
67
|
+
appliedFilters?: IFilterTag[];
|
|
68
|
+
onClear: () => void;
|
|
69
|
+
onClick: () => void;
|
|
70
|
+
titleClearFilter: string;
|
|
71
|
+
titleFilter: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export declare interface IFilterModal {
|
|
75
|
+
actionButtonLabel: string;
|
|
76
|
+
cancelButtonLabel: string;
|
|
48
77
|
children: React.ReactNode;
|
|
78
|
+
loading?: boolean;
|
|
79
|
+
onClick: () => void;
|
|
49
80
|
onCloseModal: () => void;
|
|
50
81
|
portalId: string;
|
|
51
82
|
title: string;
|
|
52
83
|
}
|
|
53
84
|
|
|
54
|
-
declare interface
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
85
|
+
export declare interface IFilterTag {
|
|
86
|
+
icon: JSX.Element;
|
|
87
|
+
label: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare interface IFormFilter {
|
|
91
|
+
fields: Array<ICheckpickerField & {
|
|
92
|
+
icon?: JSX.Element;
|
|
93
|
+
}>;
|
|
94
|
+
onChange: (name: string, values: string) => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare interface IModalRules {
|
|
98
|
+
children: React.ReactNode;
|
|
99
|
+
onCloseModal: () => void;
|
|
100
|
+
portalId: string;
|
|
101
|
+
title: string;
|
|
60
102
|
}
|
|
61
103
|
|
|
62
|
-
declare interface
|
|
104
|
+
declare interface IRevertSortedData {
|
|
63
105
|
decisionTemplate?: IRuleDecision;
|
|
64
106
|
dataDecision?: IRuleDecision;
|
|
65
107
|
decision?: IRuleDecision;
|
|
@@ -117,7 +159,7 @@ export declare const revertSortedDataSampleSwitchPlaces: (props: IRevertSortedDa
|
|
|
117
159
|
value?: string | string[] | number | IValue | undefined;
|
|
118
160
|
};
|
|
119
161
|
|
|
120
|
-
export declare const revertSortedDataSwitchPlaces: (props:
|
|
162
|
+
export declare const revertSortedDataSwitchPlaces: (props: IRevertSortedData) => IRuleDecision[] | undefined;
|
|
121
163
|
|
|
122
164
|
export declare const RulesForm: (props: IRulesForm) => JSX_2.Element;
|
|
123
165
|
|
|
@@ -144,6 +186,6 @@ export declare const sortDisplayDataSampleSwitchPlaces: (props: IRevertSortedDat
|
|
|
144
186
|
value?: string | string[] | number | IValue | undefined;
|
|
145
187
|
};
|
|
146
188
|
|
|
147
|
-
export declare const sortDisplayDataSwitchPlaces: (props:
|
|
189
|
+
export declare const sortDisplayDataSwitchPlaces: (props: IRevertSortedData) => IRuleDecision[] | undefined;
|
|
148
190
|
|
|
149
191
|
export { }
|