react-dialogger 1.1.67 → 1.1.68

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