react-dialogger 1.1.67 → 1.1.69

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 ADDED
@@ -0,0 +1,336 @@
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
+ # Youtube
13
+ You can watch simple example on Youtube [Youtube](https://www.youtube.com/watch?v=vhSroEgdj1c)
14
+
15
+
16
+ # react-dialogger - Custom Dialog Component Documentation
17
+
18
+ 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.
19
+
20
+ # Global Dialog Configuration
21
+
22
+ #### baseDialogOptions
23
+
24
+ `baseDialogOptions` This property is created at the top-level of the app and serves as the default configuration used throughout the entire application. Later, when creating individual dialogs, these options can be overridden by specifying dialog-specific options.
25
+
26
+ ```Global Dialog Configuration
27
+ 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.
28
+
29
+ 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.
30
+
31
+ Custom Dialog Configurations
32
+
33
+ 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.
34
+ ```
35
+ ## Example Usage
36
+
37
+ Below is an example of customizing a dialog using `baseDialogOptions`:
38
+
39
+
40
+
41
+ ```js
42
+ baseDialogOptions({
43
+ backdrop: {
44
+ backgroundColor: "#282828",
45
+ opacity: 0.6,
46
+ hideOnClick: false,
47
+ },
48
+ base: {
49
+ style: {
50
+ backgroundColor: "white",
51
+ boxShadow: "0 0 20px #000000",
52
+ },
53
+ closeable: false,
54
+ about: false,
55
+ initialAnchor: { vertical: "flex-start", horizontal: "center" },
56
+ draggable: false,
57
+ size: { width: 'min-content', height: 300 },
58
+ actions: {
59
+ initialIntents: {
60
+ positive: { color: 'primary', variant: 'contained' },
61
+ negative: { color: 'error', variant: 'contained' },
62
+ neutral: { color: 'default', variant: 'text' }
63
+ }
64
+ }
65
+ },
66
+ animate: 'none',
67
+ progress: { color: "red", size: 30 },
68
+ snackbar: {
69
+ anchorOrigin: { vertical: "top", horizontal: "center" },
70
+ autoHideDuration: 3000,
71
+ maxSnack: 3
72
+ },
73
+ slot: { action: undefined },
74
+ slotProps: { action: {} },
75
+ localText: { busyMessage: "Please wait..." }
76
+ });
77
+ ```
78
+
79
+ #### useDialogOptions (Slot & Slot Props)
80
+ ```js
81
+ slot: {
82
+ header: HeaderSlot, // Slot for the header, can be a custom component or template
83
+ footer: FooterSlot // Slot for the footer, can be a custom component or template
84
+ },
85
+ slotProps: {
86
+ header: (props: IBaseHeaderProps) => {
87
+ return {
88
+ headerName: 'sampleProp' // Custom properties to be passed to the header slot component
89
+ }
90
+ },
91
+ footer: (props: IBaseFooterProps) => {
92
+ return {
93
+ footerName: 'Footer' // Custom properties to be passed to the footer slot component
94
+ }
95
+ }
96
+ }
97
+
98
+ // Header Slot Component
99
+ const HeaderSlot = (props: IHeaderProps) => {
100
+ const { headerName } = props;
101
+ return <div style={{display: 'flex', flexDirection: 'row', width: '100%', justifyContent: 'space-between'}}>
102
+ <div>
103
+ {headerName}
104
+ {/**values.name is dynamic by updated state than will trigger re-render*/}
105
+ <span style={{fontSize: '12px', fontWeight: 'bold', color: "cyan", fontStyle: "italic"}}>{props.values.name}</span>
106
+ </div>
107
+ {/**Use futures*/}
108
+ <DialogHeaderActionsWrapper>
109
+ <DialogFullscreenAction />
110
+ <DialogCloseAction />
111
+ </DialogHeaderActionsWrapper>
112
+ </div>;
113
+ }
114
+
115
+ // Footer Slot Component
116
+ const FooterSlot = (props: IFooterProps) => {
117
+
118
+ const {footerName, inProcess} = props;
119
+ return <div style={{display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', columnGap: 2}} >
120
+ <span>Collected: Online {props.footerName}</span>
121
+ <DialogProcessing />
122
+ </div>;
123
+ }
124
+
125
+ // Explanation
126
+ // Footer & Header slot props are merged with the custom props inside slotProps.
127
+ // These custom props are then passed to the respective slot components, allowing dynamic and flexible content injection.
128
+ // The base dialog props (e.g., dialogValues, dialogOptions) are still accessible, and users can merge their own custom props as needed.
129
+
130
+ export interface BaseDialogSlotProps {
131
+ dialogValues: TValues; // The values that the dialog holds
132
+ dialogOptions: DialogOptionsType; // The options controlling the dialog's behavior
133
+ dialog?: IDialogRef; // A reference to the dialog component for external control
134
+ }
135
+
136
+
137
+ ```
138
+
139
+
140
+ # Basic Usage of Custom Dialog Component
141
+
142
+ 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.
143
+
144
+ ## 1. Creating Actions with DialogAction
145
+
146
+ Actions are defined for the dialog buttons (e.g., "Ok" and "Close").
147
+
148
+ - **Ok Action**: The "Ok" button has a `text` variant and `default` color.
149
+ - **Close Action**: The "Close" button has a `contained` variant and `primary` color.
150
+
151
+ ```javascript
152
+ // You can create a simple action using shortened syntax:
153
+ const okAction = new DialogAction('okAction').setIntent('positive');
154
+ /**
155
+ * 'okAction' is used as the ID for this action. It is recommended to keep the variable name the same as the ID for easier access.
156
+ * .setIntent('positive') refers to a global intent defined in baseDialogOptions.
157
+ * Alternatively, you can provide custom options for this action, which will override the intent settings.
158
+ */
159
+ const okAction = new DialogAction('okAction', {
160
+ label: 'Ok',
161
+ variant: 'text',
162
+ color: 'default'
163
+ });
164
+ okAction.onClick((button, dialog1) => {
165
+ // Actions when Ok button is clicked
166
+ });
167
+ // Eget intent kullanilirsa ve options icinde bir label etiketi verilmesse action "name" label etiket olarak baz alinir
168
+ // Eget bu etiketin tercumesi ile iligli islem yapilacaksa o hanfe baseOptions icinde ki local text bolumde bu action name key olarak verilir
169
+ // tercumesi karsisina yazilir
170
+ ```
171
+ #### Notes on Labels and Translation
172
+ * If an intent is used and no label is provided in the options, the action will use the action name as the label.
173
+ * If you need to translate this label, you can define it in the localText section of baseDialogOptions using the action name as the key. The translated text will then replace the default label.
174
+
175
+ ## 2. Create Dialog
176
+ The Dialog component can be initialized with optional configuration, allowing you to customize its behavior and appearance, such as resizing and dragging capabilities.
177
+ ```javascript
178
+ const dialog = new Dialog(null, {
179
+ // These settings are customized and will override the default baseDialogOptions
180
+ base: {
181
+ memoBounds: true, // Register rect of last position and size of dialog
182
+ resizeable: true, // Allows the dialog to be resized
183
+ draggable: true // Allows the dialog to be dragged
184
+ }
185
+ });
186
+ ```
187
+ ## 3. Set Header and Body
188
+ The dialog’s header and body content can be defined dynamically. Both are set using functions, which allows you to render content based on the current state or data available in the dialog.
189
+ ```javascript
190
+ dialog
191
+ .setHeader((dialog) => <div>Dialog Header - {dialog.formikProps.values.name}</div>)
192
+ .setBody((dialog) => (
193
+ <>
194
+ <ProjectOrderDialogBody dialog={dialog} />
195
+ <p>Additional content here...</p>
196
+ </>
197
+ ));
198
+ ```
199
+ * Header: The setHeader function returns a React element to display in the dialog’s header area.
200
+ * Body: The setBody function returns a React element for the main content of the dialog.
201
+ * Both functions receive the dialog instance as an argument, giving access to values, features, and actions for dynamic rendering.
202
+ #### This approach makes it easy to inject custom components or dynamic content into dialogs at runtime.
203
+
204
+
205
+ ## 4. Add Actions
206
+ The dialog supports custom actions, such as "Ok" and "Close" buttons. Actions are created using the DialogAction class and then added to the dialog via the addActions method.
207
+
208
+ ```javascript
209
+ .addActions([
210
+ okAction, // Add Ok button action
211
+ closeAction // Add Close button action
212
+ ])
213
+ ```
214
+ * Creating Actions: Each action has an ID (used internally and recommended to match the variable name) and can have an intent or custom options like label, color, and variant.
215
+ * onClick: Defines the behavior when the action is clicked.
216
+ * addActions: Adds one or more actions to the dialog.
217
+ #### This allows you to define interactive buttons for your dialog, with full flexibility over appearance and behavior.
218
+
219
+
220
+ ## 5. Set Initial Values
221
+ You can initialize values for the dialog, such as form fields or other settings. These values will be used throughout the dialog lifecycle.
222
+
223
+ ```javascript
224
+ .initialValues({
225
+ my_name: 'Eric', // Set initial value for name
226
+ age: 29 // Set initial value for age
227
+ })
228
+ ```
229
+ * initialValues: Sets the starting data for the dialog.
230
+ * These values can be read or updated dynamically by the dialog body, header, or actions.
231
+ * Useful for prefilling forms, maintaining state, or passing initial configuration to dialog features.
232
+
233
+ ## Updating Dialog Values
234
+
235
+ #### You can update the dialog's values at any point during its lifecycle using the setValues method. This is useful for dynamically changing data within the dialog based on user actions or other events.
236
+ ```
237
+ dialog.setValues({
238
+ ...dialog.values, // Preserve existing values
239
+ sex: "Woman/Man" // Update or add new value
240
+ });
241
+
242
+ ```
243
+ * setValues: Merges the new values with the existing ones.
244
+ * dialog.values: Provides access to the current state of the dialog’s data.
245
+ * Allows components, actions, or features within the dialog to dynamically update the state.
246
+ #### This ensures that your dialog content and behavior can reactively adapt to user interactions or other runtime changes.
247
+
248
+ ## Updating a Single Value
249
+ #### You can also update a single value in the dialog using the setValue method:
250
+ ```
251
+ dialog.setValue('sex', 'Man/Woman');
252
+ ```
253
+ * setValue(key, value): Updates a specific property in the dialog’s values.
254
+ * Equivalent to updating via setValues, but convenient for single-field updates.
255
+ * Useful for reactively changing individual fields without affecting other values.
256
+ #### This method provides a concise and flexible way to modify the dialog’s state at runtime.
257
+
258
+
259
+ ## 6. Show the Dialog
260
+ Finally, the dialog is displayed using the show method. You can define additional logic that runs when the dialog is shown.
261
+
262
+ ```javascript
263
+ .show(dialog1 => {
264
+ // Actions when the dialog is shown
265
+ });
266
+ ```
267
+
268
+ ## Using Formik Inside Dialog Body
269
+
270
+ 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.
271
+
272
+ ### Example: Binding Formik to Dialog
273
+
274
+ ```javascript
275
+ dialog.setBody(dialog1 => (
276
+ <MyComponent>
277
+ <Formik
278
+ initialValues={{
279
+ my_name: dialog1.values.my_name,
280
+ age: dialog1.values.age
281
+ }}
282
+ onSubmit={(values, formikHelpers) => {
283
+ // Form submission logic
284
+ // This event is triggered via okAction click 🚀
285
+ }}
286
+ >
287
+ {formikProps => {
288
+ dialog1.formikProps = formikProps; // Bind Formik props to dialog
289
+
290
+ return (
291
+ <form>
292
+ {/* Form content goes here */}
293
+ </form>
294
+ );
295
+ }}
296
+ </Formik>
297
+ </MyComponent>
298
+ ));
299
+
300
+ // Example: Triggering Form Submission from an Action
301
+
302
+ const okAction = new DialogAction('okAction', {
303
+ label: 'Ok',
304
+ variant: 'text',
305
+ color: 'default'
306
+ });
307
+
308
+ okAction.onClick((button, dialog1) => {
309
+ dialog1.formikProps.submitForm(); // 🚀 Trigger form submission via action button
310
+ });
311
+ ```
312
+
313
+ ## User Footer Slot
314
+
315
+
316
+
317
+ ## Summary of Basic Usage
318
+ ```php
319
+ - **Dialog Initialization**: Create a dialog instance with optional configuration for resizing and dragging.
320
+ - **Actions**: Define action buttons (e.g., Ok, Cancel) with custom behavior via click handlers.
321
+ - **Content**: Dynamically set the dialog header and body content.
322
+ - **⚠ Header Slot Consideration**: The `setHeader` method will be ignored if a **header slot** is provided.
323
+ - **Initial Values**: Set initial values for the dialog’s content (e.g., form fields).
324
+ - **Show Dialog**: Display the dialog and handle any post-display logic.
325
+
326
+ 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.
327
+ ```
328
+
329
+ > **⚠ Important Notice**
330
+ > This package is a continuation of the `react-araci` package.
331
+ > Due to an error, `react-araci` was removed, and it has been decided to continue under the new package name **`react-dialogger`**.
332
+
333
+ ## 📩 Contact
334
+ For support or inquiries, please reach out via email:
335
+ ✉️ [developer@appinsource.eu](mailto:developer@appinsource.eu)
336
+
@@ -355,7 +355,7 @@ var DialogBase = /** @class */ (function (_super) {
355
355
  if (typeof ((_c = this.props) === null || _c === void 0 ? void 0 : _c.didMountCallback) === "function") {
356
356
  setTimeout(function () {
357
357
  _this.props.didMountCallback(_this);
358
- }, this.dialogOptions.animate === "jumper" ? 300 : 100);
358
+ }, this.dialogOptions.animate === "jumper" ? 500 : 100);
359
359
  }
360
360
  // accessFrom Property of Parent object Internal->External
361
361
  this.accessFrom = "internal";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.67",
3
+ "version": "1.1.69",
4
4
  "description": "This package is a continuation of the react-araci package. Due to an error, react-araci was removed, and it has been decided to continue under the new package name react-dialogger",
5
5
  "main": "index.js",
6
6
  "author": "Sueleyman Topaloglu",