react-dialogger 1.1.52 → 1.1.53

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 DELETED
@@ -1,320 +0,0 @@
1
- # NPM
2
- ```js
3
- npm i react-dialogger
4
- ```
5
-
6
- # GitHub
7
- You can find the example code and more information about the project on our [GitHub repository](https://github.com/appinsource2021/react-dialogger-example.git).
8
-
9
- # codesandbox
10
- You can find the example code about the project on our [Codesandbox](https://codesandbox.io/p/sandbox/7r3t84).
11
-
12
-
13
- # react-araci - Custom Dialog Component Documentation
14
-
15
- This documentation explains the configuration of the Custom Dialog Component and how to customize it using initial options with the `useDialogOptions` function. `useDialogOptions` allows you to set the initial options to manage the dialog's appearance and behavior.
16
-
17
- ## useDialogOptions Hook
18
-
19
- `useDialogOptions` is a hook used to set the initial options of a Dialog component. This hook allows you to configure various properties of the dialog, such as the header, footer, size, style, etc.
20
-
21
- ```Global Dialog Configuration
22
- The useDialogOptions function is placed at the beginning of the application to define base settings for all dialogs used throughout the app. These settings act as a global configuration, ensuring consistency across all dialog components.
23
-
24
- By defining these options globally, you ensure that all dialogs share common behaviors and styling. This approach simplifies managing the appearance and functionality of dialogs, as you only need to modify the base configuration in one place.
25
-
26
- Custom Dialog Configurations
27
-
28
- Although a global configuration is set by useDialogOptions, each dialog can still be individually customized as needed. You can override the default settings for specific dialogs to meet particular requirements. This flexibility allows you to customize the appearance, behavior, and actions of each dialog instance separately, while still maintaining the benefits of a unified base configuration.
29
- ```
30
- ## Example Usage
31
-
32
- Below is an example of customizing a dialog using `useDialogOptions`:
33
-
34
- #### useDialogOptions (Base)
35
-
36
- ```js
37
- initialDialogOptions({
38
- base: {
39
- footer: {
40
- style: { // Footer custom styles
41
- backgroundColor: '#f1f1f1' // Background color for footer
42
- }
43
- },
44
- header: {
45
- style: { // Header custom styles
46
- backgroundColor: '#333', // Background color for header
47
- color: '#fff' // Text color for header
48
- }
49
- },
50
- fullscreen: true, // Enables fullscreen mode for the dialog
51
- notifyOnClosing: 'zoom', // Notification method on closing ('zoom' or 'snackbar')
52
- headerControllerIcons: {
53
- size: 20, // Icon size in header
54
- color: 'red' // Icon color in header
55
- },
56
- style: { // General styles for the dialog
57
- borderRadius: '8px', // Round corners for the dialog
58
- boxShadow: '0px 5px 15px rgba(0, 0, 0, 0.2)' // Shadow around the dialog
59
- },
60
- resizeable: true, // Makes the dialog resizable by the user
61
- draggable: true, // Allows the dialog to be dragged around the screen
62
- closeable: true, // Allows the dialog to be closed
63
- initialAnchor: {
64
- vertical: 'center', // Vertical position of the dialog ('flex-start', 'center', 'flex-end')
65
- horizontal: 'center' // Horizontal position of the dialog ('flex-start', 'center', 'flex-end')
66
- },
67
- size: {
68
- width: 800, // Dialog width in pixels
69
- height: 600 // Dialog height in pixels
70
- },
71
- actions: {
72
- disabledOnDialogProcessing: true, // Disables actions when the dialog is processing
73
- baseStyle: { // Custom styles for action buttons
74
- padding: '5px 20px', // Padding inside action buttons
75
- border: '2px solid #ccc', // Border for action buttons
76
- boxShadow: '0 0 10px rgba(0, 0, 0, 0.15)' // Shadow for action buttons
77
- }
78
- }
79
- }
80
- });
81
- ```
82
- #### useDialogOptions (snackbar)
83
- ```js
84
- snackbar: {
85
- busyMessage: 'On Process, please wait!', // Message displayed during the process
86
- maxSnack: 4, // Maximum number of snackbars that can be displayed at once
87
- autoHideDuration: 5000, // Time in milliseconds before the snackbar automatically disappears (5000ms = 5 seconds)
88
- anchorOrigin: {
89
- horizontal: "center", // Horizontal alignment of the snackbar (center, left, right)
90
- vertical: "top" // Vertical alignment of the snackbar (top, bottom)
91
- }
92
- }
93
- ```
94
-
95
- #### useDialogOptions (Slot & Slot Props)
96
- ```js
97
- slot: {
98
- header: HeaderSlot, // Slot for the header, can be a custom component or template
99
- footer: FooterSlot // Slot for the footer, can be a custom component or template
100
- },
101
- slotProps: {
102
- header: (props: IBaseHeaderProps) => {
103
- return {
104
- headerName: 'sampleProp' // Custom properties to be passed to the header slot component
105
- }
106
- },
107
- footer: (props: IBaseFooterProps) => {
108
- return {
109
- footerName: 'Footer' // Custom properties to be passed to the footer slot component
110
- }
111
- }
112
- }
113
-
114
- // Header Slot Component
115
- const HeaderSlot = (props: IHeaderProps) => {
116
- const { headerName } = props;
117
- return <div style={{display: 'flex', flexDirection: 'row', width: '100%', justifyContent: 'space-between'}}>
118
- <div>
119
- {headerName}
120
- {/**values.name is dynamic by updated state than will trigger re-render*/}
121
- <span style={{fontSize: '12px', fontWeight: 'bold', color: "cyan", fontStyle: "italic"}}>{props.values.name}</span>
122
- </div>
123
- {/**Use futures*/}
124
- <DialogHeaderActionsWrapper>
125
- <DialogFullscreenAction />
126
- <DialogCloseAction />
127
- </DialogHeaderActionsWrapper>
128
- </div>;
129
- }
130
-
131
- // Footer Slot Component
132
- const FooterSlot = (props: IFooterProps) => {
133
-
134
- const {footerName, inProcess} = props;
135
- return <div style={{display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', columnGap: 2}} >
136
- <span>Collected: Online {props.footerName}</span>
137
- <DialogProcessing />
138
- </div>;
139
- }
140
-
141
- // Explanation
142
- // Footer & Header slot props are merged with the custom props inside slotProps.
143
- // These custom props are then passed to the respective slot components, allowing dynamic and flexible content injection.
144
- // The base dialog props (e.g., dialogValues, dialogOptions) are still accessible, and users can merge their own custom props as needed.
145
-
146
- export interface BaseDialogSlotProps {
147
- dialogValues: TValues; // The values that the dialog holds
148
- dialogOptions: DialogOptionsType; // The options controlling the dialog's behavior
149
- dialog?: IDialogRef; // A reference to the dialog component for external control
150
- }
151
-
152
-
153
- ```
154
-
155
- #### useDialogOptions (Progress)
156
- ```js
157
- progress: {
158
- size: 20,
159
- color: 'red'
160
- },
161
- ```
162
- #### useDialogOptions (Backdrop)
163
- ```js
164
- backdrop: {
165
- backgroundColor: '#282828', // The background color of the backdrop (overlay) behind the dialog
166
- opacity: 0.6, // The opacity of the backdrop (0 = fully transparent, 1 = fully opaque)
167
- hideOnClick: false // Determines whether the backdrop will hide when clicked
168
- }
169
-
170
-
171
- ```
172
-
173
-
174
- # Basic Usage of Custom Dialog Component
175
-
176
- This example demonstrates the basic usage of the **Custom Dialog Component** with predefined actions, content, and properties. The dialog can be configured to include actions (buttons), initial values, and custom behaviors for interaction.
177
-
178
- ## 1. Create Actions
179
-
180
- Actions are defined for the dialog buttons (e.g., "Ok" and "Close").
181
-
182
- - **Ok Action**: The "Ok" button has a `text` variant and `default` color.
183
- - **Close Action**: The "Close" button has a `contained` variant and `primary` color.
184
-
185
- ```javascript
186
- const okAction = new DialogAction('okAction', {
187
- label: 'Ok',
188
- variant: 'text',
189
- color: 'default'
190
- });
191
- okAction.onClick((button, dialog1) => {
192
- // Actions when Ok button is clicked
193
- });
194
-
195
- const closeAction = new DialogAction('closeAction', {
196
- label: 'Close',
197
- variant: 'contained',
198
- color: 'primary'
199
- });
200
- closeAction.onClick((button, dialog1) => {
201
- dialog1.close(); // Closes the dialog when the Close button is clicked
202
- });
203
- ```
204
-
205
- ## 2. Create Dialog
206
- The Dialog component is initialized with optional configuration such as resize and drag capabilities.
207
-
208
- ```javascript
209
- const dialog = new Dialog(null, {
210
- base: {
211
- resizeable: true, // Dialog can be resized
212
- draggable: true // Dialog can be dragged
213
- }
214
- });
215
- ```
216
- ## 3. Set Header and Body
217
- You can define the dialog’s header and body content dynamically. The content is set through functions, allowing flexibility in displaying data.
218
-
219
- ```javascript
220
- dialog
221
- .setHeader(dialog1 => 'Dialog header') // Set dialog header
222
- .setBody(dialog1 => 'Dialog Body') // Set dialog body content
223
- ```
224
-
225
- ## 4. Add Actions
226
- The dialog supports custom actions like the "Ok" and "Close" buttons. These actions are added to the dialog with the addActions method.
227
-
228
- ```javascript
229
- .addActions([
230
- okAction, // Add Ok button action
231
- closeAction // Add Close button action
232
- ])
233
- ```
234
- ## 5. Set Initial Values
235
- You can initialize values for the dialog, such as form fields or other settings. These values will be used throughout the dialog lifecycle.
236
-
237
- ```javascript
238
- .initialValues({
239
- my_name: 'Eric', // Set initial value for name
240
- age: 29 // Set initial value for age
241
- })
242
- ```
243
- ## 6. Show the Dialog
244
- Finally, the dialog is displayed using the show method. You can define additional logic that runs when the dialog is shown.
245
-
246
- ```javascript
247
- .show(dialog1 => {
248
- // Actions when the dialog is shown
249
- });
250
- ```
251
-
252
- ## Using Formik Inside Dialog Body
253
-
254
- If **Formik** is used inside the dialog body, its `formikProps` can be linked to the dialog’s internal `formikProps`. This allows access to form properties from anywhere within the dialog.
255
-
256
- ### Example: Binding Formik to Dialog
257
-
258
- ```javascript
259
- dialog.setBody(dialog1 => (
260
- <MyComponent>
261
- <Formik
262
- initialValues={{
263
- my_name: dialog1.values.my_name,
264
- age: dialog1.values.age
265
- }}
266
- onSubmit={(values, formikHelpers) => {
267
- // Form submission logic
268
- // This event is triggered via okAction click 🚀
269
- }}
270
- >
271
- {formikProps => {
272
- dialog1.formikProps = formikProps; // Bind Formik props to dialog
273
-
274
- return (
275
- <form>
276
- {/* Form content goes here */}
277
- </form>
278
- );
279
- }}
280
- </Formik>
281
- </MyComponent>
282
- ));
283
-
284
- // Example: Triggering Form Submission from an Action
285
-
286
- const okAction = new DialogAction('okAction', {
287
- label: 'Ok',
288
- variant: 'text',
289
- color: 'default'
290
- });
291
-
292
- okAction.onClick((button, dialog1) => {
293
- dialog1.formikProps.submitForm(); // 🚀 Trigger form submission via action button
294
- });
295
- ```
296
-
297
- ## User Footer Slot
298
-
299
-
300
-
301
- ## Summary of Basic Usage
302
- ```php
303
- - **Dialog Initialization**: Create a dialog instance with optional configuration for resize and drag behavior.
304
- - **Actions**: Define action buttons (Ok, Close) with custom behavior (click handling).
305
- - **Content**: Dynamically set the dialog header and body content.
306
- - **⚠ Header Slot Consideration**: `setHeader` will be ignored if a **header slot** is used.
307
- - **Initial Values**: Set initial values for the dialog’s content (e.g., form fields).
308
- - **Show Dialog**: Display the dialog and handle any post-display logic.
309
-
310
- This basic usage setup enables you to quickly configure and display a custom dialog with dynamic content and actions, making it highly customizable for various use cases in your application.
311
- ```
312
-
313
- > **⚠ Important Notice**
314
- > This package is a continuation of the `react-araci` package.
315
- > Due to an error, `react-araci` was removed, and it has been decided to continue under the new package name **`react-dialogger`**.
316
-
317
- ## 📩 Contact
318
- For support or inquiries, please reach out via email:
319
- ✉️ [developer@appinsource.eu](mailto:developer@appinsource.eu)
320
-