react-dialogger 1.1.98 → 1.1.100

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.
@@ -1,12 +1,13 @@
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, DialogValues, DialogValue } 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 } 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 DialogValues<Record<string, any>>> extends Component<BaseDialogProps, BaseDialogState> {
9
+ declare class DialogBase<Values extends Record<string, any>> extends Component<BaseDialogProps<Values>, BaseDialogState> {
10
+ protected _initialValues: Dialogify<Values>;
10
11
  _dialogTranslate: {
11
12
  lastX: number;
12
13
  lastY: number;
@@ -29,7 +30,6 @@ declare class DialogBase<Values extends DialogValues<Record<string, any>>> exten
29
30
  protected _onClose: TDialogCallbackVoidFn;
30
31
  protected _shInterval: number;
31
32
  protected _snackbarAnchor: ISnackbarAnchor;
32
- protected _initialValues: DialogValues<Values>;
33
33
  protected _parent: Dialog<Values>;
34
34
  protected _handlers: DialogHandlers;
35
35
  private _inProcess;
@@ -39,8 +39,7 @@ declare class DialogBase<Values extends DialogValues<Record<string, any>>> exten
39
39
  private _accessFrom;
40
40
  private readonly _processingListeners;
41
41
  private readonly _abortedListeners;
42
- constructor(props: BaseDialogProps & {
43
- initialValues: DialogValues<Values>;
42
+ constructor(props: BaseDialogProps<Values> & {
44
43
  parent: Dialog<Values>;
45
44
  });
46
45
  private T;
@@ -63,9 +62,9 @@ declare class DialogBase<Values extends DialogValues<Record<string, any>>> exten
63
62
  set formikProps(value: FormikProps<any>);
64
63
  get formikValidate(): Promise<DialogFormikAdapter<any>>;
65
64
  set inlineFormikProps(inlineFormikProps: IFormikAdapter);
66
- get values(): IFormikAdapter['values'];
67
- setValue(key: string, value: DialogValue): void;
68
- setValues(values: DialogValues<Values>, callbackFn?: () => void): void;
65
+ get values(): Values;
66
+ setValue<T>(key: string, value: Dialogify<T>): void;
67
+ setValues<T>(values: Dialogify<T>, callbackFn?: () => void): void;
69
68
  componentDidMount(): void;
70
69
  setInProcess: (process: boolean, message?: string, holder?: TInitialHolder) => this;
71
70
  isInProcess: () => IInProcess;
@@ -68,8 +68,6 @@ 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) {
73
71
  function DialogBase(props) {
74
72
  var _a, _b;
75
73
  var _this = _super.call(this, props) || this;
@@ -127,20 +125,12 @@ var DialogBase = /** @class */ (function (_super) {
127
125
  if (!process) {
128
126
  _this.snackbar.close("kInProcess");
129
127
  }
130
- // if( typeof this._processingListener === "function" ){
131
- // this._processingListener(process);
132
- //
133
- // }
134
128
  for (var _i = 0, _l = _this._processingListeners; _i < _l.length; _i++) {
135
129
  var listener = _l[_i];
136
130
  if (typeof listener === "function") {
137
131
  listener(process);
138
132
  }
139
133
  }
140
- // if( ._processingListener === "function" ){
141
- // // this._processingListener(process);
142
- // //
143
- // // }
144
134
  // @ts-ignore
145
135
  (_k = _this._footerRef.current) === null || _k === void 0 ? void 0 : _k.setProcessing(process);
146
136
  return _this;
@@ -197,15 +187,9 @@ var DialogBase = /** @class */ (function (_super) {
197
187
  return _this.props.dom;
198
188
  };
199
189
  _this.render = function () {
200
- return (0, jsx_runtime_1.jsx)(_context_1.DialogContentContextProvider
201
- // 1️⃣initialValues={this.props.initialValues}
202
- , {
203
- // 1️⃣initialValues={this.props.initialValues}
204
- dialogBase: _this,
190
+ return (0, jsx_runtime_1.jsx)(_context_1.DialogContentContextProvider, { dialogBase: _this,
205
191
  // Component
206
- // body={this.state.body(this)}
207
192
  body: _this.state.body,
208
- // body={<this.Body body={this.state.body} /> as any}
209
193
  // Refs Props
210
194
  dialogRef: _this._dialogRef, headerRef: _this._headerRef, bodyRef: _this._dialogBodyRef, footerRef: _this._footerRef, backdropRef: _this._backdropRef, snackbarRef: _this._snackbarRef, prevDialogRect: _this.state.prevDialogRect, children: (0, jsx_runtime_1.jsx)(_components_1.DialogWithBackdropWrapper, {}) });
211
195
  };
@@ -356,9 +340,6 @@ var DialogBase = /** @class */ (function (_super) {
356
340
  configurable: true
357
341
  });
358
342
  Object.defineProperty(DialogBase.prototype, "inlineFormikProps", {
359
- // ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
360
- // ༄ inlineFormikProps 👉 Will Be initialized from Body or Content Component
361
- // Instead of Dialog stateValues use FormikEngine
362
343
  set: function (inlineFormikProps) {
363
344
  this._inlineFormikProps = inlineFormikProps;
364
345
  },
@@ -366,34 +347,22 @@ var DialogBase = /** @class */ (function (_super) {
366
347
  configurable: true
367
348
  });
368
349
  Object.defineProperty(DialogBase.prototype, "values", {
369
- // ✨✨✨✨✨✨✨✨✨✨✨
370
350
  get: function () {
371
- // get values(): DialogValues<Values> {
372
351
  return this._inlineFormikProps.values;
373
- // UseImperative
374
- // return this._dialogWithBackDropRef?.current?.formikProps.values;
375
352
  },
376
353
  enumerable: false,
377
354
  configurable: true
378
355
  });
379
- // ✨✨✨✨✨✨✨✨✨✨✨
380
356
  DialogBase.prototype.setValue = function (key, value) {
381
357
  var _a;
382
358
  (_a = this._inlineFormikProps) === null || _a === void 0 ? void 0 : _a.setFieldValue(key, value);
383
- // UseImperative
384
- // this._dialogWithBackDropRef?.current?.formikProps?.setFieldValue(key, value);
385
359
  };
386
- // ✨✨✨✨✨✨✨✨✨✨✨
387
- // public setValues(values: IFormikAdapter['values'], callbackFn?: () => void): void {
388
360
  DialogBase.prototype.setValues = function (values, callbackFn) {
389
361
  this._inlineFormikProps.setValues(values);
390
- // UseImperative
391
- // this._dialogWithBackDropRef?.current?.formikProps?.setValues(values);
392
362
  if (typeof callbackFn === "function") {
393
363
  callbackFn();
394
364
  }
395
365
  };
396
- // ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
397
366
  DialogBase.prototype.componentDidMount = function () {
398
367
  var _this = this;
399
368
  var _a, _b, _c;
@@ -422,8 +391,6 @@ var DialogBase = /** @class */ (function (_super) {
422
391
  setTimeout(function () {
423
392
  _this.props.root.unmount();
424
393
  _this.props.dom.remove();
425
- // unmountComponentAtNode(this.props.dom);
426
- // @deprecated
427
394
  if (typeof _this._onClose === "function") {
428
395
  _this._onClose(_this);
429
396
  }
@@ -450,13 +417,10 @@ var DialogBase = /** @class */ (function (_super) {
450
417
  this.setState(function (prevState) { return (__assign(__assign({}, _this.state), { body: body })); });
451
418
  };
452
419
  DialogBase.prototype.processingListener = function (listener) {
453
- // @ts-ignore
454
- // this._processingListeners = listener;
455
420
  this._processingListeners.push(listener);
456
421
  return this;
457
422
  };
458
423
  DialogBase.prototype.onAbort = function (callbackFn) {
459
- // @ts-ignore
460
424
  this._abortedListeners.push(callbackFn);
461
425
  return this;
462
426
  };
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { DialogAction } from "./DialogAction";
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>>> {
3
+ import { TInitialHolder, IDialogSize, TDialogStateListenerCallbackType, DialogOptionsType, IDialogApiDef, TDialogCallbackVoidFn, TDialogCallbackFn, DialogHandlers, Dialogify } from "../types/index.js";
4
+ declare class Dialog<Values extends Record<string, any>> {
5
5
  private readonly _processingListeners;
6
6
  private readonly _abortedListeners;
7
7
  private _stateListener;
@@ -35,7 +35,7 @@ declare class Dialog<Values extends ModelDialogValues<Record<string, any>>> {
35
35
  stateListener(listener: TDialogStateListenerCallbackType): this;
36
36
  processingListener(listener: (inProcess: boolean) => void): this;
37
37
  onAbort(callbackFn: TDialogCallbackFn<void>): this;
38
- initialValues(values: ModelDialogValues<Values>): this;
38
+ initialValues<T extends Record<string, any>>(values: Dialogify<T>): Dialog<T>;
39
39
  handlers(handlers: DialogHandlers): this;
40
40
  initialHolder(holder: TInitialHolder): this;
41
41
  keyboardListener(listener: (key: string, dialog: IDialogApiDef) => void): this;
@@ -43,6 +43,7 @@ declare class Dialog<Values extends ModelDialogValues<Record<string, any>>> {
43
43
  onClose(callback: TDialogCallbackVoidFn): this;
44
44
  private highestZ;
45
45
  private createDom;
46
+ get values(): Dialogify<Values>;
46
47
  show(callback?: TDialogCallbackVoidFn): void;
47
48
  }
48
49
  export default Dialog;
package/models/Dialog.js CHANGED
@@ -128,9 +128,16 @@ var Dialog = /** @class */ (function () {
128
128
  this._abortedListeners.push(callbackFn);
129
129
  return this;
130
130
  };
131
+ // 👌Ok
132
+ // public initialValues<T>( values: Dialogify<T> ): this {
133
+ // this._initialValues = values as Dialogify<Values>;;
134
+ // return this;
135
+ // }
136
+ // 👌Ok Combined with Dialog Class
131
137
  Dialog.prototype.initialValues = function (values) {
132
- this._initialValues = values;
133
- return this;
138
+ var next = this;
139
+ next._initialValues = values;
140
+ return next;
134
141
  };
135
142
  Dialog.prototype.handlers = function (handlers) {
136
143
  this._handlers = handlers;
@@ -152,6 +159,13 @@ var Dialog = /** @class */ (function () {
152
159
  this._onCloseCallback = callback;
153
160
  return this;
154
161
  };
162
+ Object.defineProperty(Dialog.prototype, "values", {
163
+ get: function () {
164
+ return this._initialValues;
165
+ },
166
+ enumerable: false,
167
+ configurable: true
168
+ });
155
169
  Dialog.prototype.show = function (callback) {
156
170
  var dom = this.createDom();
157
171
  var root = (0, client_1.createRoot)(dom);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-dialogger",
3
- "version": "1.1.98",
3
+ "version": "1.1.100",
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",
@@ -31,7 +31,8 @@ export interface DialogFormikAdapter<Values> extends Omit<FormikProps<any>, 'val
31
31
  validateForm(): Promise<any>;
32
32
  errors: any;
33
33
  }
34
- export interface BaseDialogProps {
34
+ export interface BaseDialogProps<Values extends Record<string, any>> {
35
+ initialValues: Dialogify<Values>;
35
36
  initialOptions?: DialogOptionsType;
36
37
  body: TDialogCallbackFn;
37
38
  header?: TDialogCallbackFn;
@@ -39,7 +40,6 @@ export interface BaseDialogProps {
39
40
  didMountCallback?: TDialogCallbackVoidFn;
40
41
  dialogSize?: IDialogSize;
41
42
  stateListener: TDialogStateListenerCallbackType;
42
- initialValues: DialogValues<Record<string, any>>;
43
43
  handlers: DialogHandlers;
44
44
  initialHolder: TInitialHolder;
45
45
  snackbarAnchor?: ISnackbarAnchor;
@@ -245,13 +245,17 @@ export type TInitialValues<T extends Record<string, any>> = T;
245
245
  export type TUserProps = {
246
246
  [K: string]: any;
247
247
  };
248
- export type DialogValue = string | number | any[] | {
249
- [k: string]: string | number | any[];
248
+ export type NonFunction<T> = T extends Function ? never : T;
249
+ export type DialogValue<T> = string | number | boolean | null | undefined | DialogValue<T>[] | {
250
+ [key: string]: DialogValue<T>;
250
251
  };
251
252
  export type ModelDialogValues<T> = {
252
- [K in keyof T]: DialogValue;
253
+ [K in keyof T]: DialogValue<T>;
253
254
  };
254
- export type DialogValues<T> = ModelDialogValues<T>;
255
+ export type DialogValues<T extends Record<string, any>> = ModelDialogValues<T>;
256
+ export type Dialogify<T> = T extends Function ? never : T extends string | number | boolean | null | undefined ? T : T extends Array<infer U> ? Dialogify<U>[] : T extends object ? {
257
+ [K in keyof T]: Dialogify<T[K]>;
258
+ } : never;
255
259
  export type DialogHandlerFn = (...args: any[]) => any;
256
260
  export type DialogHandlers = Record<string, DialogHandlerFn>;
257
261
  export interface BaseDialogDOMRect {