react-dialogger 1.1.66 → 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 +332 -0
- package/components/DialogActionBase.js +0 -27
- package/components/DialogBase.d.ts +0 -1
- package/components/DialogBase.js +4 -14
- package/components/DialogContent.js +5 -6
- package/components/DialogContentBody.js +0 -4
- package/components/RippleButton.js +0 -8
- package/models/DialogAction.js +1 -2
- package/package.json +1 -1
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
|
+
|
|
@@ -96,45 +96,34 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
96
96
|
return _this._initialClickHandler;
|
|
97
97
|
};
|
|
98
98
|
_this.updateLabel = function (label) {
|
|
99
|
-
// this._options.label = label;
|
|
100
|
-
// this.forceUpdate();
|
|
101
99
|
_this.setState(function (prevStae) { return (__assign(__assign({}, prevStae), { options: __assign(__assign({}, prevStae.options), { label: label }) })); });
|
|
102
100
|
return _this;
|
|
103
101
|
};
|
|
104
102
|
/**
|
|
105
103
|
* @deprecated use Options*/
|
|
106
104
|
_this.updateVariant = function (variant) {
|
|
107
|
-
// this._options.variant = variant;
|
|
108
|
-
// this.forceUpdate();
|
|
109
105
|
_this.setState(function (prevStae) { return (__assign(__assign({}, prevStae), { options: __assign(__assign({}, prevStae.options), { variant: variant }) })); });
|
|
110
106
|
return _this;
|
|
111
107
|
};
|
|
112
108
|
/**
|
|
113
109
|
* @deprecated use Options*/
|
|
114
110
|
_this.getVariant = function () {
|
|
115
|
-
// return this._options.variant;
|
|
116
111
|
return _this.state.options.variant;
|
|
117
112
|
};
|
|
118
113
|
/**
|
|
119
114
|
* @deprecated use Options*/
|
|
120
115
|
_this.updateColor = function (color) {
|
|
121
|
-
// this._color = color;
|
|
122
|
-
// this._options.color = color;
|
|
123
|
-
// this.forceUpdate();
|
|
124
116
|
_this.setState(function (prevState) { return (__assign(__assign({}, prevState), { options: __assign(__assign({}, prevState.options), { color: color }) })); });
|
|
125
117
|
return _this;
|
|
126
118
|
};
|
|
127
119
|
/**
|
|
128
120
|
* @deprecated use Options*/
|
|
129
121
|
_this.getColor = function () {
|
|
130
|
-
// return this._options.color;
|
|
131
122
|
return _this.state.options.color;
|
|
132
123
|
};
|
|
133
124
|
/**
|
|
134
125
|
* @deprecated use Options*/
|
|
135
126
|
_this.setDisabled = function (disabled) {
|
|
136
|
-
// this._options.disabled = disabled;
|
|
137
|
-
// this.forceUpdate();
|
|
138
127
|
_this.setState(function (prevStae) { return (__assign(__assign({}, prevStae), { options: __assign(__assign({}, prevStae.options), { disabled: disabled }) })); });
|
|
139
128
|
return _this;
|
|
140
129
|
};
|
|
@@ -155,9 +144,6 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
155
144
|
return _this;
|
|
156
145
|
};
|
|
157
146
|
_this.setInProcess = function (inProcess) {
|
|
158
|
-
// this._inProcess = inProcess;
|
|
159
|
-
// this._options.disabled = inProcess;
|
|
160
|
-
// this.forceUpdate();
|
|
161
147
|
_this.setState(function (prevState) { return (__assign(__assign({}, prevState), { options: __assign(__assign({}, prevState.options), { disabled: inProcess }), inProcess: inProcess })); });
|
|
162
148
|
return _this;
|
|
163
149
|
};
|
|
@@ -173,20 +159,12 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
173
159
|
_this._rippleButtonRef.current.rippleEffect(_this._buttonRef, 19, 8);
|
|
174
160
|
_this._buttonRef.current.click();
|
|
175
161
|
};
|
|
176
|
-
// public onClickHandler = () => {
|
|
177
|
-
// return this._onClick;
|
|
178
|
-
// }
|
|
179
162
|
_this.render = function () {
|
|
180
|
-
console.log('Dialog_Action_Base_render', _this.state.options, _this._intent);
|
|
181
|
-
// // Set as default converted from action name prop
|
|
182
|
-
// const converted = this.props.name?.replace(/action/i, '') ?? this.props.name;
|
|
183
|
-
// this._options.label = (this.props.dialogBaseComponent?.dialogOptions?.localText?.[converted] ?? converted) ?? 'Button';
|
|
184
163
|
return (0, jsx_runtime_1.jsx)(_components_1.RippleButton, { ref: _this._buttonRef, innerRef: _this._rippleButtonRef,
|
|
185
164
|
// Intent Based
|
|
186
165
|
variant: _this.state.options.variant,
|
|
187
166
|
// Intent Based
|
|
188
167
|
color: _this.state.options.color, disabled: _this.state.options.disabled, onClick: function (e) {
|
|
189
|
-
// if(this.state.options.disabled || this.isInProcess() ) return;
|
|
190
168
|
if (_this.state.options.disabled || _this.state.inProcess)
|
|
191
169
|
return;
|
|
192
170
|
// @ts-ignore
|
|
@@ -220,7 +198,6 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
220
198
|
var label = (_g = ((_f = (_e = (_d = (_c = _this.props.dialogBaseComponent) === null || _c === void 0 ? void 0 : _c.dialogOptions) === null || _d === void 0 ? void 0 : _d.localText) === null || _e === void 0 ? void 0 : _e[converted]) !== null && _f !== void 0 ? _f : converted)) !== null && _g !== void 0 ? _g : 'Button';
|
|
221
199
|
var initialIntents = props.dialogBaseComponent.dialogOptions.base.actions.initialIntents;
|
|
222
200
|
var mergedIntents = __assign(__assign({}, exports.BASE_INTENTS), initialIntents);
|
|
223
|
-
console.log('DialogActionBase', initialIntents, mergedIntents, exports.BASE_INTENTS);
|
|
224
201
|
_this.state = {
|
|
225
202
|
coords: { x: -1, y: -1 },
|
|
226
203
|
isRippling: false,
|
|
@@ -257,15 +234,12 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
257
234
|
Object.defineProperty(DialogActionBase.prototype, "baseDialogAction", {
|
|
258
235
|
get: function () {
|
|
259
236
|
return this._baseDialogAction;
|
|
260
|
-
// return this;
|
|
261
237
|
},
|
|
262
238
|
enumerable: false,
|
|
263
239
|
configurable: true
|
|
264
240
|
});
|
|
265
241
|
DialogActionBase.prototype.updateOptions = function (options) {
|
|
266
242
|
this.setState(function (prevState) { return (__assign(__assign({}, prevState), { options: __assign(__assign({}, prevState.options), options) })); });
|
|
267
|
-
// this._options = {...this._options, ...options};
|
|
268
|
-
// this.forceUpdate();
|
|
269
243
|
return this;
|
|
270
244
|
};
|
|
271
245
|
/**
|
|
@@ -278,7 +252,6 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
278
252
|
};
|
|
279
253
|
Object.defineProperty(DialogActionBase.prototype, "options", {
|
|
280
254
|
get: function () {
|
|
281
|
-
// return this._options;
|
|
282
255
|
return this.state.options;
|
|
283
256
|
},
|
|
284
257
|
enumerable: false,
|
package/components/DialogBase.js
CHANGED
|
@@ -61,7 +61,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
62
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
63
63
|
var react_1 = require("react");
|
|
64
|
-
var formik_1 = require("formik");
|
|
65
64
|
var React = __importStar(require("react"));
|
|
66
65
|
var lodash_1 = require("lodash");
|
|
67
66
|
var _components_1 = require("./index.js");
|
|
@@ -164,18 +163,6 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
164
163
|
_this.getDom = function () {
|
|
165
164
|
return _this.props.dom;
|
|
166
165
|
};
|
|
167
|
-
_this.Body = function (_a) {
|
|
168
|
-
var body = _a.body;
|
|
169
|
-
var formikProps = (0, formik_1.useFormik)({
|
|
170
|
-
initialValues: {},
|
|
171
|
-
onSubmit: function (values, formikHelpers) { }
|
|
172
|
-
});
|
|
173
|
-
console.log('Body_formikProps', formikProps);
|
|
174
|
-
if (body instanceof Function) {
|
|
175
|
-
return (0, jsx_runtime_1.jsxs)("div", { ref: _this._dialogBodyRef, className: 'dialog-body', style: { height: '100%' }, children: ["N", body(_this)] });
|
|
176
|
-
}
|
|
177
|
-
return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-body', style: { height: '100%', padding: 10 }, children: body });
|
|
178
|
-
};
|
|
179
166
|
_this.render = function () {
|
|
180
167
|
console.log('this._prevDialogRect', _this.state.prevDialogRect);
|
|
181
168
|
return (0, jsx_runtime_1.jsx)(_context_1.DialogContentContextProvider
|
|
@@ -358,6 +345,7 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
358
345
|
};
|
|
359
346
|
// ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
|
|
360
347
|
DialogBase.prototype.componentDidMount = function () {
|
|
348
|
+
var _this = this;
|
|
361
349
|
var _a, _b, _c;
|
|
362
350
|
// First position take from Global
|
|
363
351
|
var _d = this._dialogOptions.snackbar.anchorOrigin, vertical = _d.vertical, horizontal = _d.horizontal;
|
|
@@ -365,7 +353,9 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
365
353
|
// Merge user defied positions with global positions!
|
|
366
354
|
this._snackbarAnchor = __assign(__assign(__assign({}, initialAnchor), (((_a = this.props.snackbarAnchor) === null || _a === void 0 ? void 0 : _a.vertical) ? { vertical: this.props.snackbarAnchor.vertical } : {})), (((_b = this.props.snackbarAnchor) === null || _b === void 0 ? void 0 : _b.horizontal) ? { horizontal: this.props.snackbarAnchor.horizontal } : {}));
|
|
367
355
|
if (typeof ((_c = this.props) === null || _c === void 0 ? void 0 : _c.didMountCallback) === "function") {
|
|
368
|
-
|
|
356
|
+
setTimeout(function () {
|
|
357
|
+
_this.props.didMountCallback(_this);
|
|
358
|
+
}, this.dialogOptions.animate === "jumper" ? 500 : 100);
|
|
369
359
|
}
|
|
370
360
|
// accessFrom Property of Parent object Internal->External
|
|
371
361
|
this.accessFrom = "internal";
|
|
@@ -62,13 +62,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
62
62
|
exports.DialogContent = void 0;
|
|
63
63
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
64
64
|
var react_draggable_1 = __importDefault(require("react-draggable"));
|
|
65
|
-
var
|
|
65
|
+
var _helpers_1 = require("../helpers/index.js");
|
|
66
66
|
var React = __importStar(require("react"));
|
|
67
67
|
var _icons_1 = require("../icons/index.js");
|
|
68
68
|
var notistack_1 = require("notistack");
|
|
69
69
|
var _1 = require("./");
|
|
70
70
|
var react_1 = require("react");
|
|
71
|
-
var _helpers_1 = require("../helpers/index.js");
|
|
72
71
|
var jumper_animate_1 = require("../utils/effects/jumper-animate");
|
|
73
72
|
var _context_1 = require("../context/index.js");
|
|
74
73
|
var DialogContent = function (props) {
|
|
@@ -79,7 +78,7 @@ var DialogContent = function (props) {
|
|
|
79
78
|
var baseOptions = dialogOptions.base;
|
|
80
79
|
var _g = React.useState(false), fullscreenMode = _g[0], setFullscreenMode = _g[1];
|
|
81
80
|
var _h = React.useState(null), rect = _h[0], setRect = _h[1];
|
|
82
|
-
var bounds = ((_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) ? (0,
|
|
81
|
+
var bounds = ((_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) ? (0, _helpers_1.getDialogBounds)(dialog.dialogOptions.base.id) : null;
|
|
83
82
|
var domZIndex = window.getComputedStyle(dialog.getDom()).zIndex;
|
|
84
83
|
var positionSelector = function () {
|
|
85
84
|
var _a;
|
|
@@ -130,13 +129,13 @@ var DialogContent = function (props) {
|
|
|
130
129
|
setTimeout(function () {
|
|
131
130
|
var _a, _b;
|
|
132
131
|
if ((_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.memoBounds) {
|
|
133
|
-
if (!
|
|
132
|
+
if (!_helpers_1.InitDialogMemoizeBoundsDeclared) {
|
|
134
133
|
throw new Error('InitDialogMemoizeBounds is not defined. Please make sure to declare it only once, at the top‑level of your module—outside of App or its render logic.\n' +
|
|
135
134
|
'InitDialogMemoizeBounds()\n' +
|
|
136
135
|
'const App() => {...');
|
|
137
136
|
}
|
|
138
137
|
var _c = (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect(), width = _c.width, height = _c.height, x = _c.x, y = _c.y;
|
|
139
|
-
(0,
|
|
138
|
+
(0, _helpers_1.dialogRegister)(dialog.dialogOptions.base.id, {
|
|
140
139
|
width: width,
|
|
141
140
|
height: height,
|
|
142
141
|
x: x,
|
|
@@ -155,7 +154,7 @@ var DialogContent = function (props) {
|
|
|
155
154
|
event.preventDefault();
|
|
156
155
|
var _c = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(), width = _c.width, height = _c.height, x = _c.x, y = _c.y;
|
|
157
156
|
console.log('onDragStop', 'fired', (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect());
|
|
158
|
-
(0,
|
|
157
|
+
(0, _helpers_1.setDialogBounds)(dialogOptions.base.id, {
|
|
159
158
|
width: width,
|
|
160
159
|
height: height,
|
|
161
160
|
x: x,
|
|
@@ -51,12 +51,8 @@ var Placeholder = function (_a) {
|
|
|
51
51
|
}, children: placeholder });
|
|
52
52
|
};
|
|
53
53
|
var DialogContentBody = React.forwardRef(function (_a, ref) {
|
|
54
|
-
// const [localBody, setLocalBody] = React.useState(null);
|
|
55
54
|
var body = _a.body;
|
|
56
55
|
var dialog = (0, react_1.useContext)(_context_1.DialogContentContext).dialog;
|
|
57
|
-
// useEffect(() => {
|
|
58
|
-
// setLocalBody(body(dialog));
|
|
59
|
-
// }, [body]);
|
|
60
56
|
if (body instanceof Function) {
|
|
61
57
|
return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-body', style: { height: '100%' }, children: [dialog.holder && (0, jsx_runtime_1.jsx)(Placeholder, { dialogOptions: dialog.dialogOptions, placeholder: dialog.holder }), body(dialog)] });
|
|
62
58
|
}
|
|
@@ -52,7 +52,6 @@ exports.default = React.forwardRef(function (_a, ref) {
|
|
|
52
52
|
var variant = _a.variant, color = _a.color, children = _a.children, disabled = _a.disabled, onClick = _a.onClick, style = _a.style, baseStyle = _a.baseStyle, innerRef = _a.innerRef, fontFamily = _a.fontFamily;
|
|
53
53
|
var _b = React.useState({ x: -1, y: -1 }), coords = _b[0], setCoords = _b[1];
|
|
54
54
|
var _c = React.useState(false), isRippling = _c[0], setIsRippling = _c[1];
|
|
55
|
-
// const buttonRef = React.useRef<HTMLButtonElement>(null)
|
|
56
55
|
React.useEffect(function () {
|
|
57
56
|
if (coords.x !== -1 && coords.y !== -1) {
|
|
58
57
|
setIsRippling(true);
|
|
@@ -93,12 +92,6 @@ exports.default = React.forwardRef(function (_a, ref) {
|
|
|
93
92
|
exclusive.backgroundColor = 'inherit';
|
|
94
93
|
exclusive.color = color; // exclusive.backgroundColor;
|
|
95
94
|
}
|
|
96
|
-
// textColor = getLuminance(hexedColor);
|
|
97
|
-
// bgColor = hexToRGB(hexedColor, disabled ? .5 : 1);
|
|
98
|
-
//
|
|
99
|
-
// exclusive.color = textColor;
|
|
100
|
-
// exclusive.backgroundColor = bgColor;
|
|
101
|
-
console.log('Button_exclusive', exclusive, hexedColor);
|
|
102
95
|
}
|
|
103
96
|
else {
|
|
104
97
|
exclusive = null;
|
|
@@ -109,7 +102,6 @@ exports.default = React.forwardRef(function (_a, ref) {
|
|
|
109
102
|
setCoords({ x: e.clientX - rect.left, y: e.clientY - rect.top });
|
|
110
103
|
setTimeout(function () {
|
|
111
104
|
onClick && onClick(e);
|
|
112
|
-
// setIsRippling(true);
|
|
113
105
|
}, 200);
|
|
114
106
|
}, style: __assign(__assign(__assign(__assign(__assign({}, baseStyle), style), exclusive), { fontFamily: fontFamily }), variant === 'text' ? { border: "none" } : null), children: [isRippling && (0, jsx_runtime_1.jsx)("span", { className: "ripple", style: { left: coords.x, top: coords.y } }), (0, jsx_runtime_1.jsx)("span", { className: "content", children: children(ref.current) })] }));
|
|
115
107
|
});
|
package/models/DialogAction.js
CHANGED
|
@@ -18,7 +18,6 @@ var ActionProgress = function () {
|
|
|
18
18
|
return (0, jsx_runtime_1.jsx)(_components_1.CircularProgress, { size: 20, inProcess: { inProcess: true } });
|
|
19
19
|
};
|
|
20
20
|
exports.ActionProgress = ActionProgress;
|
|
21
|
-
// class DialogAction extends DialogActionBase {
|
|
22
21
|
var DialogAction = /** @class */ (function () {
|
|
23
22
|
function DialogAction(name, options) {
|
|
24
23
|
var _this = this;
|
|
@@ -65,7 +64,7 @@ var DialogAction = /** @class */ (function () {
|
|
|
65
64
|
configurable: true
|
|
66
65
|
});
|
|
67
66
|
DialogAction.prototype.setIntent = function (intent) {
|
|
68
|
-
this._intent = intent;
|
|
67
|
+
this._intent = intent;
|
|
69
68
|
return this;
|
|
70
69
|
};
|
|
71
70
|
DialogAction.prototype.intent = function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-dialogger",
|
|
3
|
-
"version": "1.1.
|
|
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",
|