react-dialogger 1.1.104 → 1.1.106
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/components/DialogBase.d.ts +4 -1
- package/components/DialogBase.js +17 -3
- package/models/Dialog.d.ts +4 -2
- package/models/Dialog.js +7 -2
- package/package.json +1 -1
- package/types/DialogTypes.d.ts +9 -4
|
@@ -1,7 +1,7 @@
|
|
|
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, TAccessFrom, ActionApiDef, DialogContentFooterReturnType, DialogFormikAdapter, DialogHandlers, DialogHandlerFn, Dialogify } from "../types/index.js";
|
|
4
|
+
import { BaseDialogProps, BaseDialogState, IDialogSize, DialogOptionsType, TDialogCallbackFn, TDialogCallbackVoidFn, WithBackdrop, IDialogSnackbar, IInProcess, TInitialHolder, ISnackbarAnchor, TSeverity, TAccessFrom, ActionApiDef, DialogContentFooterReturnType, DialogFormikAdapter, DialogHandlers, DialogHandlerFn, Dialogify, DialogExternalRefs, DialogRef } 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
|
}
|
|
@@ -32,6 +32,7 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
|
|
|
32
32
|
protected _snackbarAnchor: ISnackbarAnchor;
|
|
33
33
|
protected _parent: Dialog<Values>;
|
|
34
34
|
protected _handlers: DialogHandlers;
|
|
35
|
+
protected _externalRefs: DialogExternalRefs;
|
|
35
36
|
private _inProcess;
|
|
36
37
|
private _footerRef;
|
|
37
38
|
protected _headerRef: RefObject<DialogContentFooterReturnType>;
|
|
@@ -46,6 +47,8 @@ declare class DialogBase<Values extends Record<string, any>> extends Component<B
|
|
|
46
47
|
private readonly _features;
|
|
47
48
|
get handlers(): DialogHandlers;
|
|
48
49
|
addHandler(key: string, handler: DialogHandlerFn): void;
|
|
50
|
+
get externalRefs(): DialogExternalRefs;
|
|
51
|
+
addExternalRef(key: string, ref: DialogRef): void;
|
|
49
52
|
addFeature(key: string, value: any): void;
|
|
50
53
|
getFeature(key: string): FeatureType;
|
|
51
54
|
get parent(): Dialog<Values>;
|
package/components/DialogBase.js
CHANGED
|
@@ -247,6 +247,7 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
247
247
|
_this._abortedListeners = (_b = props.abortedListeners) !== null && _b !== void 0 ? _b : [];
|
|
248
248
|
_this._features = [];
|
|
249
249
|
_this._handlers = props.handlers;
|
|
250
|
+
_this._externalRefs = props.externalRefs;
|
|
250
251
|
return _this;
|
|
251
252
|
}
|
|
252
253
|
Object.defineProperty(DialogBase.prototype, "handlers", {
|
|
@@ -260,12 +261,25 @@ var DialogBase = /** @class */ (function (_super) {
|
|
|
260
261
|
if (!key) {
|
|
261
262
|
throw new Error('Handler key is required');
|
|
262
263
|
}
|
|
263
|
-
if (typeof handler !== 'function'
|
|
264
|
-
|
|
265
|
-
throw new Error("Handler \"".concat(key, "\" must be a function or a ref object"));
|
|
264
|
+
if (typeof handler !== 'function') {
|
|
265
|
+
throw new Error("Handler \"".concat(key, "\" must be a function"));
|
|
266
266
|
}
|
|
267
267
|
this._handlers[key] = handler;
|
|
268
268
|
};
|
|
269
|
+
Object.defineProperty(DialogBase.prototype, "externalRefs", {
|
|
270
|
+
get: function () {
|
|
271
|
+
return this._externalRefs;
|
|
272
|
+
},
|
|
273
|
+
enumerable: false,
|
|
274
|
+
configurable: true
|
|
275
|
+
});
|
|
276
|
+
DialogBase.prototype.addExternalRef = function (key, ref) {
|
|
277
|
+
if (!key)
|
|
278
|
+
throw new Error('Ref key is required');
|
|
279
|
+
if (!(0, isRefObject_1.isRefObject)(ref))
|
|
280
|
+
throw new Error("Ref \"".concat(key, "\" must be a Reference RefObject"));
|
|
281
|
+
this._externalRefs[key] = ref;
|
|
282
|
+
};
|
|
269
283
|
DialogBase.prototype.addFeature = function (key, value) {
|
|
270
284
|
this._features[key] = value;
|
|
271
285
|
};
|
package/models/Dialog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DialogAction } from "./DialogAction";
|
|
3
|
-
import { TInitialHolder, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn, DialogHandlers, Dialogify } from "../types/index.js";
|
|
3
|
+
import { TInitialHolder, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn, DialogHandlers, Dialogify, DialogExternalRefs } from "../types/index.js";
|
|
4
4
|
declare class Dialog<Values extends Record<string, any>> {
|
|
5
5
|
private readonly _processingListeners;
|
|
6
6
|
private readonly _abortedListeners;
|
|
@@ -22,6 +22,7 @@ declare class Dialog<Values extends Record<string, any>> {
|
|
|
22
22
|
* UI / Dialog / Form bağlamında alışıldık
|
|
23
23
|
* */
|
|
24
24
|
private _handlers;
|
|
25
|
+
private _externalRefs;
|
|
25
26
|
private _headerRef;
|
|
26
27
|
private readonly _apiRef;
|
|
27
28
|
private _onCloseCallback;
|
|
@@ -36,7 +37,8 @@ declare class Dialog<Values extends Record<string, any>> {
|
|
|
36
37
|
processingListener(listener: (inProcess: boolean) => void): this;
|
|
37
38
|
onAbort(callbackFn: TDialogCallbackFn<void>): this;
|
|
38
39
|
initialValues<T extends Record<string, any>>(values: Dialogify<T>): Dialog<T>;
|
|
39
|
-
|
|
40
|
+
registerHandlers(handlers: DialogHandlers): this;
|
|
41
|
+
registerRefs(refs: DialogExternalRefs): this;
|
|
40
42
|
initialHolder(holder: TInitialHolder): this;
|
|
41
43
|
keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
|
|
42
44
|
resizeListener(listener: (size: IDialogSize, dialog: IDialogApiDef) => void): this;
|
package/models/Dialog.js
CHANGED
|
@@ -95,6 +95,7 @@ var Dialog = /** @class */ (function () {
|
|
|
95
95
|
if (options) {
|
|
96
96
|
this._dialogOptions = options;
|
|
97
97
|
}
|
|
98
|
+
this._externalRefs = {};
|
|
98
99
|
}
|
|
99
100
|
Dialog.prototype.setHeader = function (header) {
|
|
100
101
|
this._header = header;
|
|
@@ -139,10 +140,14 @@ var Dialog = /** @class */ (function () {
|
|
|
139
140
|
next._initialValues = values;
|
|
140
141
|
return next;
|
|
141
142
|
};
|
|
142
|
-
Dialog.prototype.
|
|
143
|
+
Dialog.prototype.registerHandlers = function (handlers) {
|
|
143
144
|
this._handlers = handlers;
|
|
144
145
|
return this;
|
|
145
146
|
};
|
|
147
|
+
Dialog.prototype.registerRefs = function (refs) {
|
|
148
|
+
this._externalRefs = refs;
|
|
149
|
+
return this;
|
|
150
|
+
};
|
|
146
151
|
Dialog.prototype.initialHolder = function (holder) {
|
|
147
152
|
this._initialHolder = holder;
|
|
148
153
|
return this;
|
|
@@ -171,7 +176,7 @@ var Dialog = /** @class */ (function () {
|
|
|
171
176
|
var root = (0, client_1.createRoot)(dom);
|
|
172
177
|
var props = __assign(__assign({
|
|
173
178
|
// Initials
|
|
174
|
-
initialOptions: this._dialogOptions, initialValues: this._initialValues, handlers: this._handlers, didMountCallback: callback,
|
|
179
|
+
initialOptions: this._dialogOptions, initialValues: this._initialValues, handlers: this._handlers, externalRefs: this._externalRefs, didMountCallback: callback,
|
|
175
180
|
// Component contents
|
|
176
181
|
header: this._header, body: this._body, actions: this._actions,
|
|
177
182
|
// Refs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-dialogger",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.106",
|
|
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",
|
package/types/DialogTypes.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface BaseDialogProps<Values extends Record<string, any>> {
|
|
|
41
41
|
dialogSize?: IDialogSize;
|
|
42
42
|
stateListener: TDialogStateListenerCallbackType;
|
|
43
43
|
handlers: DialogHandlers;
|
|
44
|
+
externalRefs: DialogExternalRefs;
|
|
44
45
|
initialHolder: TInitialHolder;
|
|
45
46
|
snackbarAnchor?: ISnackbarAnchor;
|
|
46
47
|
dom: HTMLDivElement;
|
|
@@ -148,7 +149,7 @@ export type TDialogStateListenerCallbackType = (values: FormikProps<any>['values
|
|
|
148
149
|
export type TDialogCallbackFn<T = React.ReactNode | React.ReactElement> = (dialog: IDialogApiDef) => T;
|
|
149
150
|
export type TDialogHeader = TDialogCallbackFn | React.ReactNode | React.JSX.Element;
|
|
150
151
|
export type TDialogCallbackVoidFn = TDialogCallbackFn<void>;
|
|
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' | 'addHandler'> {
|
|
152
|
+
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' | 'addHandler' | 'externalRefs' | 'addExternalRef'> {
|
|
152
153
|
}
|
|
153
154
|
export interface IDialogCloseRef extends Pick<DialogBase<any>, 'close'> {
|
|
154
155
|
}
|
|
@@ -256,10 +257,14 @@ export type DialogValues<T extends Record<string, any>> = ModelDialogValues<T>;
|
|
|
256
257
|
export type Dialogify<T> = T extends Function ? never : T extends string | number | boolean | null | undefined | Date ? T : T extends Array<infer U> ? Dialogify<U>[] : T extends object ? {
|
|
257
258
|
[K in keyof T]: Dialogify<T[K]>;
|
|
258
259
|
} : never;
|
|
259
|
-
export type DialogHandlerFn = (
|
|
260
|
-
current: null;
|
|
261
|
-
};
|
|
260
|
+
export type DialogHandlerFn = (...args: any[]) => any;
|
|
262
261
|
export type DialogHandlers = Record<string, DialogHandlerFn>;
|
|
262
|
+
export type DialogRef = {
|
|
263
|
+
current: unknown;
|
|
264
|
+
};
|
|
265
|
+
export type DialogExternalRefs = {
|
|
266
|
+
[key: string]: DialogRef;
|
|
267
|
+
};
|
|
263
268
|
export interface BaseDialogDOMRect {
|
|
264
269
|
height?: number;
|
|
265
270
|
width?: number;
|