react-dialogger 1.1.97 → 1.1.98
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 +33 -13
- package/components/DialogBase.d.ts +14 -8
- package/components/DialogBase.js +22 -2
- package/models/Dialog.d.ts +11 -3
- package/models/Dialog.js +5 -1
- package/package.json +1 -1
- package/types/DialogActionTypes.d.ts +2 -2
- package/types/DialogTypes.d.ts +16 -8
package/README.md
CHANGED
|
@@ -88,18 +88,24 @@ baseDialogOptions({
|
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
#### useDialogOptions (Slot & Slot Props)
|
|
91
|
+
|
|
91
92
|
```js
|
|
92
93
|
slot: {
|
|
93
94
|
header: HeaderSlot, // Slot for the header, can be a custom component or template
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
footer
|
|
96
|
+
:
|
|
97
|
+
FooterSlot // Slot for the footer, can be a custom component or template
|
|
98
|
+
}
|
|
99
|
+
,
|
|
96
100
|
slotProps: {
|
|
97
101
|
header: (props: IBaseHeaderProps) => {
|
|
98
102
|
return {
|
|
99
103
|
headerName: 'sampleProp' // Custom properties to be passed to the header slot component
|
|
100
104
|
}
|
|
101
105
|
},
|
|
102
|
-
footer
|
|
106
|
+
footer
|
|
107
|
+
:
|
|
108
|
+
(props: IBaseFooterProps) => {
|
|
103
109
|
return {
|
|
104
110
|
footerName: 'Footer' // Custom properties to be passed to the footer slot component
|
|
105
111
|
}
|
|
@@ -108,28 +114,39 @@ slotProps: {
|
|
|
108
114
|
|
|
109
115
|
// Header Slot Component
|
|
110
116
|
const HeaderSlot = (props: IHeaderProps) => {
|
|
111
|
-
const {
|
|
117
|
+
const {headerName} = props;
|
|
112
118
|
return <div style={{display: 'flex', flexDirection: 'row', width: '100%', justifyContent: 'space-between'}}>
|
|
113
119
|
<div>
|
|
114
120
|
{headerName}
|
|
115
121
|
{/**values.name is dynamic by updated state than will trigger re-render*/}
|
|
116
|
-
<span style={{
|
|
122
|
+
<span style={{
|
|
123
|
+
fontSize: '12px',
|
|
124
|
+
fontWeight: 'bold',
|
|
125
|
+
color: "cyan",
|
|
126
|
+
fontStyle: "italic"
|
|
127
|
+
}}>{props.values.name}</span>
|
|
117
128
|
</div>
|
|
118
129
|
{/**Use futures*/}
|
|
119
130
|
<DialogHeaderActionsWrapper>
|
|
120
|
-
<DialogFullscreenAction
|
|
121
|
-
<DialogCloseAction
|
|
131
|
+
<DialogFullscreenAction/>
|
|
132
|
+
<DialogCloseAction/>
|
|
122
133
|
</DialogHeaderActionsWrapper>
|
|
123
134
|
</div>;
|
|
124
135
|
}
|
|
125
136
|
|
|
126
137
|
// Footer Slot Component
|
|
127
138
|
const FooterSlot = (props: IFooterProps) => {
|
|
128
|
-
|
|
139
|
+
|
|
129
140
|
const {footerName, inProcess} = props;
|
|
130
|
-
return <div style={{
|
|
141
|
+
return <div style={{
|
|
142
|
+
display: 'flex',
|
|
143
|
+
flexDirection: 'column',
|
|
144
|
+
justifyContent: 'center',
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
columnGap: 2
|
|
147
|
+
}}>
|
|
131
148
|
<span>Collected: Online {props.footerName}</span>
|
|
132
|
-
<DialogProcessing
|
|
149
|
+
<DialogProcessing/>
|
|
133
150
|
</div>;
|
|
134
151
|
}
|
|
135
152
|
|
|
@@ -138,10 +155,13 @@ const FooterSlot = (props: IFooterProps) => {
|
|
|
138
155
|
// These custom props are then passed to the respective slot components, allowing dynamic and flexible content injection.
|
|
139
156
|
// The base dialog props (e.g., dialogValues, dialogOptions) are still accessible, and users can merge their own custom props as needed.
|
|
140
157
|
|
|
141
|
-
export
|
|
142
|
-
|
|
158
|
+
export
|
|
159
|
+
interface
|
|
160
|
+
BaseDialogSlotProps
|
|
161
|
+
{
|
|
162
|
+
dialogValues: DValues; // The values that the dialog holds
|
|
143
163
|
dialogOptions: DialogOptionsType; // The options controlling the dialog's behavior
|
|
144
|
-
dialog
|
|
164
|
+
dialog ? : IDialogRef; // A reference to the dialog component for external control
|
|
145
165
|
}
|
|
146
166
|
|
|
147
167
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Component, RefObject } from 'react';
|
|
2
2
|
import { FormikProps } from "formik";
|
|
3
3
|
import { DialogActionBase } from "./index.js";
|
|
4
|
-
import { BaseDialogProps, BaseDialogState, IDialogSize, DialogOptionsType, TDialogCallbackFn, TDialogCallbackVoidFn, WithBackdrop, IDialogSnackbar, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity,
|
|
4
|
+
import { BaseDialogProps, BaseDialogState, IDialogSize, DialogOptionsType, TDialogCallbackFn, TDialogCallbackVoidFn, WithBackdrop, IDialogSnackbar, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity, TAccessFrom, ActionApiDef, DialogContentFooterReturnType, DialogFormikAdapter, DialogHandlers, DialogHandlerFn, DialogValues, DialogValue } from "../types/index.js";
|
|
5
5
|
import Dialog, { DialogAction } from "../models/index.js";
|
|
6
6
|
interface IFormikAdapter extends Pick<FormikProps<any>, 'setValues' | 'setFieldValue' | 'values'> {
|
|
7
7
|
}
|
|
8
8
|
type FeatureType = Partial<Record<string, any>>;
|
|
9
|
-
declare class DialogBase<Values extends
|
|
9
|
+
declare class DialogBase<Values extends DialogValues<Record<string, any>>> extends Component<BaseDialogProps, BaseDialogState> {
|
|
10
10
|
_dialogTranslate: {
|
|
11
11
|
lastX: number;
|
|
12
12
|
lastY: number;
|
|
@@ -29,21 +29,27 @@ declare class DialogBase<Values extends FormikProps<Values>> extends Component<B
|
|
|
29
29
|
protected _onClose: TDialogCallbackVoidFn;
|
|
30
30
|
protected _shInterval: number;
|
|
31
31
|
protected _snackbarAnchor: ISnackbarAnchor;
|
|
32
|
-
protected _initialValues: DialogValues
|
|
32
|
+
protected _initialValues: DialogValues<Values>;
|
|
33
|
+
protected _parent: Dialog<Values>;
|
|
34
|
+
protected _handlers: DialogHandlers;
|
|
33
35
|
private _inProcess;
|
|
34
36
|
private _footerRef;
|
|
35
37
|
protected _headerRef: RefObject<DialogContentFooterReturnType>;
|
|
36
38
|
private readonly _dialogWithBackDropRef;
|
|
37
|
-
protected readonly _parent: Dialog;
|
|
38
39
|
private _accessFrom;
|
|
39
40
|
private readonly _processingListeners;
|
|
40
41
|
private readonly _abortedListeners;
|
|
41
|
-
constructor(props
|
|
42
|
+
constructor(props: BaseDialogProps & {
|
|
43
|
+
initialValues: DialogValues<Values>;
|
|
44
|
+
parent: Dialog<Values>;
|
|
45
|
+
});
|
|
42
46
|
private T;
|
|
43
47
|
private readonly _features;
|
|
48
|
+
get handlers(): DialogHandlers;
|
|
49
|
+
addHandler(key: string, handler: DialogHandlerFn): void;
|
|
44
50
|
addFeature(key: string, value: any): void;
|
|
45
51
|
getFeature(key: string): FeatureType;
|
|
46
|
-
get parent(): Dialog
|
|
52
|
+
get parent(): Dialog<Values>;
|
|
47
53
|
get dialogTranslate(): {
|
|
48
54
|
lastX: number;
|
|
49
55
|
lastY: number;
|
|
@@ -58,8 +64,8 @@ declare class DialogBase<Values extends FormikProps<Values>> extends Component<B
|
|
|
58
64
|
get formikValidate(): Promise<DialogFormikAdapter<any>>;
|
|
59
65
|
set inlineFormikProps(inlineFormikProps: IFormikAdapter);
|
|
60
66
|
get values(): IFormikAdapter['values'];
|
|
61
|
-
setValue(key: string, value:
|
|
62
|
-
setValues(values:
|
|
67
|
+
setValue(key: string, value: DialogValue): void;
|
|
68
|
+
setValues(values: DialogValues<Values>, callbackFn?: () => void): void;
|
|
63
69
|
componentDidMount(): void;
|
|
64
70
|
setInProcess: (process: boolean, message?: string, holder?: TInitialHolder) => this;
|
|
65
71
|
isInProcess: () => IInProcess;
|
package/components/DialogBase.js
CHANGED
|
@@ -68,8 +68,9 @@ var _helpers_1 = require("../helpers/index.js");
|
|
|
68
68
|
var _context_1 = require("../context/index.js");
|
|
69
69
|
var DialogBase = /** @class */ (function (_super) {
|
|
70
70
|
__extends(DialogBase, _super);
|
|
71
|
+
// constructor(props: Readonly<BaseDialogProps> = {} as Readonly<BaseDialogProps>) {
|
|
72
|
+
// constructor(props: BaseDialogProps) {
|
|
71
73
|
function DialogBase(props) {
|
|
72
|
-
if (props === void 0) { props = {}; }
|
|
73
74
|
var _a, _b;
|
|
74
75
|
var _this = _super.call(this, props) || this;
|
|
75
76
|
// ✨✨✨✨✨✨✨✨✨✨✨
|
|
@@ -255,13 +256,30 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
255
256
|
// Initialize _actionRefs as an empty object
|
|
256
257
|
_this._actionRefs = {};
|
|
257
258
|
_this._initialValues = props.initialValues;
|
|
258
|
-
_this._dialogWithBackDropRef = (0, react_1.createRef)();
|
|
259
259
|
_this._parent = props.parent;
|
|
260
|
+
_this._dialogWithBackDropRef = (0, react_1.createRef)();
|
|
260
261
|
_this._processingListeners = (_a = props.processingListeners) !== null && _a !== void 0 ? _a : [];
|
|
261
262
|
_this._abortedListeners = (_b = props.abortedListeners) !== null && _b !== void 0 ? _b : [];
|
|
262
263
|
_this._features = [];
|
|
264
|
+
_this._handlers = props.handlers;
|
|
263
265
|
return _this;
|
|
264
266
|
}
|
|
267
|
+
Object.defineProperty(DialogBase.prototype, "handlers", {
|
|
268
|
+
get: function () {
|
|
269
|
+
return this._handlers;
|
|
270
|
+
},
|
|
271
|
+
enumerable: false,
|
|
272
|
+
configurable: true
|
|
273
|
+
});
|
|
274
|
+
DialogBase.prototype.addHandler = function (key, handler) {
|
|
275
|
+
if (!key) {
|
|
276
|
+
throw new Error('Handler key is required');
|
|
277
|
+
}
|
|
278
|
+
if (typeof handler !== 'function') {
|
|
279
|
+
throw new Error("Handler \"".concat(key, "\" must be a function"));
|
|
280
|
+
}
|
|
281
|
+
this._handlers[key] = handler;
|
|
282
|
+
};
|
|
265
283
|
DialogBase.prototype.addFeature = function (key, value) {
|
|
266
284
|
this._features[key] = value;
|
|
267
285
|
};
|
|
@@ -350,6 +368,7 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
350
368
|
Object.defineProperty(DialogBase.prototype, "values", {
|
|
351
369
|
// ✨✨✨✨✨✨✨✨✨✨✨
|
|
352
370
|
get: function () {
|
|
371
|
+
// get values(): DialogValues<Values> {
|
|
353
372
|
return this._inlineFormikProps.values;
|
|
354
373
|
// UseImperative
|
|
355
374
|
// return this._dialogWithBackDropRef?.current?.formikProps.values;
|
|
@@ -365,6 +384,7 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
365
384
|
// this._dialogWithBackDropRef?.current?.formikProps?.setFieldValue(key, value);
|
|
366
385
|
};
|
|
367
386
|
// ✨✨✨✨✨✨✨✨✨✨✨
|
|
387
|
+
// public setValues(values: IFormikAdapter['values'], callbackFn?: () => void): void {
|
|
368
388
|
DialogBase.prototype.setValues = function (values, callbackFn) {
|
|
369
389
|
this._inlineFormikProps.setValues(values);
|
|
370
390
|
// UseImperative
|
package/models/Dialog.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DialogAction } from "./DialogAction";
|
|
3
|
-
import { TInitialHolder,
|
|
4
|
-
declare class Dialog {
|
|
3
|
+
import { TInitialHolder, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn, DialogHandlers, ModelDialogValues } from "../types/index.js";
|
|
4
|
+
declare class Dialog<Values extends ModelDialogValues<Record<string, any>>> {
|
|
5
5
|
private readonly _processingListeners;
|
|
6
6
|
private readonly _abortedListeners;
|
|
7
7
|
private _stateListener;
|
|
@@ -15,6 +15,13 @@ declare class Dialog {
|
|
|
15
15
|
private readonly _dialogOptions?;
|
|
16
16
|
private _snackbarAnchor;
|
|
17
17
|
private _initialValues;
|
|
18
|
+
/**
|
|
19
|
+
* Move Fucntions
|
|
20
|
+
* behavior
|
|
21
|
+
* Fonksiyon taşıdığını net anlatıyor
|
|
22
|
+
* UI / Dialog / Form bağlamında alışıldık
|
|
23
|
+
* */
|
|
24
|
+
private _handlers;
|
|
18
25
|
private _headerRef;
|
|
19
26
|
private readonly _apiRef;
|
|
20
27
|
private _onCloseCallback;
|
|
@@ -28,7 +35,8 @@ declare class Dialog {
|
|
|
28
35
|
stateListener(listener: TDialogStateListenerCallbackType): this;
|
|
29
36
|
processingListener(listener: (inProcess: boolean) => void): this;
|
|
30
37
|
onAbort(callbackFn: TDialogCallbackFn<void>): this;
|
|
31
|
-
initialValues(values:
|
|
38
|
+
initialValues(values: ModelDialogValues<Values>): this;
|
|
39
|
+
handlers(handlers: DialogHandlers): this;
|
|
32
40
|
initialHolder(holder: TInitialHolder): this;
|
|
33
41
|
keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
|
|
34
42
|
resizeListener(listener: (size: IDialogSize, dialog: IDialogApiDef) => void): this;
|
package/models/Dialog.js
CHANGED
|
@@ -132,6 +132,10 @@ var Dialog = /** @class */ (function () {
|
|
|
132
132
|
this._initialValues = values;
|
|
133
133
|
return this;
|
|
134
134
|
};
|
|
135
|
+
Dialog.prototype.handlers = function (handlers) {
|
|
136
|
+
this._handlers = handlers;
|
|
137
|
+
return this;
|
|
138
|
+
};
|
|
135
139
|
Dialog.prototype.initialHolder = function (holder) {
|
|
136
140
|
this._initialHolder = holder;
|
|
137
141
|
return this;
|
|
@@ -153,7 +157,7 @@ var Dialog = /** @class */ (function () {
|
|
|
153
157
|
var root = (0, client_1.createRoot)(dom);
|
|
154
158
|
var props = __assign(__assign({
|
|
155
159
|
// Initials
|
|
156
|
-
initialOptions: this._dialogOptions, initialValues: this._initialValues, didMountCallback: callback,
|
|
160
|
+
initialOptions: this._dialogOptions, initialValues: this._initialValues, handlers: this._handlers, didMountCallback: callback,
|
|
157
161
|
// Component contents
|
|
158
162
|
header: this._header, body: this._body, actions: this._actions,
|
|
159
163
|
// Refs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-dialogger",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.98",
|
|
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",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDialogApiDef, IListenerDialogDef,
|
|
1
|
+
import { IDialogApiDef, IListenerDialogDef, ICoords } from "./index.js";
|
|
2
2
|
import { DialogBase, DialogActionBase } from "../components/index.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { DialogAction } from "../models/index.js";
|
|
@@ -63,7 +63,7 @@ export type DialogActionOptionsType = {
|
|
|
63
63
|
baseStyle?: React.CSSProperties;
|
|
64
64
|
};
|
|
65
65
|
type TListenerButtonType = Pick<DialogActionBase, Exclude<keyof ActionApiDef, 'onClick' | 'getStateListener' | 'name'>>;
|
|
66
|
-
export type TDialogStateListenerForActionCallbackType = (values:
|
|
66
|
+
export type TDialogStateListenerForActionCallbackType = (values: Record<string, any>, button: TListenerButtonType, dialog: IListenerDialogDef) => void;
|
|
67
67
|
export interface IContentFooterProps {
|
|
68
68
|
}
|
|
69
69
|
export interface DialogContentFooterReturnType {
|
package/types/DialogTypes.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface TBaseDialogState {
|
|
|
12
12
|
}
|
|
13
13
|
export interface BaseDialogState {
|
|
14
14
|
/**@deprecated use FormikProps Values*/
|
|
15
|
-
values: DialogValues
|
|
15
|
+
values: DialogValues<Record<string, any>>;
|
|
16
16
|
inProcess: IInProcess;
|
|
17
17
|
fullscreenMode?: boolean;
|
|
18
18
|
prevDialogRect: WithBackdrop['prevDialogRect'];
|
|
@@ -39,11 +39,12 @@ export interface BaseDialogProps {
|
|
|
39
39
|
didMountCallback?: TDialogCallbackVoidFn;
|
|
40
40
|
dialogSize?: IDialogSize;
|
|
41
41
|
stateListener: TDialogStateListenerCallbackType;
|
|
42
|
-
initialValues: DialogValues
|
|
42
|
+
initialValues: DialogValues<Record<string, any>>;
|
|
43
|
+
handlers: DialogHandlers;
|
|
43
44
|
initialHolder: TInitialHolder;
|
|
44
45
|
snackbarAnchor?: ISnackbarAnchor;
|
|
45
46
|
dom: HTMLDivElement;
|
|
46
|
-
parent?:
|
|
47
|
+
parent?: DialogValues<Record<string, any>>;
|
|
47
48
|
onClose?: TDialogCallbackVoidFn;
|
|
48
49
|
root?: any;
|
|
49
50
|
keyboardListener: (key: string, dialog: IDialogApiDef) => void;
|
|
@@ -147,7 +148,7 @@ export type TDialogStateListenerCallbackType = (values: FormikProps<any>['values
|
|
|
147
148
|
export type TDialogCallbackFn<T = React.ReactNode | React.ReactElement> = (dialog: IDialogApiDef) => T;
|
|
148
149
|
export type TDialogHeader = TDialogCallbackFn | React.ReactNode | React.JSX.Element;
|
|
149
150
|
export type TDialogCallbackVoidFn = TDialogCallbackFn<void>;
|
|
150
|
-
export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'addFeature' | 'getFeature' | 'onAbort'> {
|
|
151
|
+
export interface IDialogApiDef extends Pick<DialogBase<any>, 'isInProcess' | 'setInProcess' | 'values' | 'setValue' | 'setValues' | 'close' | 'dialogOptions' | 'actions' | 'snackbar' | 'formikValidate' | 'formikProps' | 'focus' | 'updateBody' | 'processingListener' | 'addFeature' | 'getFeature' | 'onAbort' | 'handlers'> {
|
|
151
152
|
}
|
|
152
153
|
export interface IDialogCloseRef extends Pick<DialogBase<any>, 'close'> {
|
|
153
154
|
}
|
|
@@ -178,7 +179,7 @@ export interface WithBackdrop {
|
|
|
178
179
|
actions?: DialogAction[];
|
|
179
180
|
dialog: DialogBase<any>;
|
|
180
181
|
backdropRef: RefObject<any>;
|
|
181
|
-
initialValues: Partial<
|
|
182
|
+
initialValues: Partial<Record<string, any>>;
|
|
182
183
|
dialogRef: RefObject<any>;
|
|
183
184
|
headerRef: RefObject<any>;
|
|
184
185
|
bodyRef: RefObject<any>;
|
|
@@ -244,8 +245,15 @@ export type TInitialValues<T extends Record<string, any>> = T;
|
|
|
244
245
|
export type TUserProps = {
|
|
245
246
|
[K: string]: any;
|
|
246
247
|
};
|
|
247
|
-
export type
|
|
248
|
-
|
|
248
|
+
export type DialogValue = string | number | any[] | {
|
|
249
|
+
[k: string]: string | number | any[];
|
|
250
|
+
};
|
|
251
|
+
export type ModelDialogValues<T> = {
|
|
252
|
+
[K in keyof T]: DialogValue;
|
|
253
|
+
};
|
|
254
|
+
export type DialogValues<T> = ModelDialogValues<T>;
|
|
255
|
+
export type DialogHandlerFn = (...args: any[]) => any;
|
|
256
|
+
export type DialogHandlers = Record<string, DialogHandlerFn>;
|
|
249
257
|
export interface BaseDialogDOMRect {
|
|
250
258
|
height?: number;
|
|
251
259
|
width?: number;
|
|
@@ -269,6 +277,6 @@ export interface ICoords {
|
|
|
269
277
|
y: number;
|
|
270
278
|
}
|
|
271
279
|
export interface DialogProps {
|
|
272
|
-
setHeader(header: TDialogCallbackFn): Dialog
|
|
280
|
+
setHeader(header: TDialogCallbackFn): Dialog<Record<string, any>>;
|
|
273
281
|
}
|
|
274
282
|
export {};
|