react-dialogger 1.1.48 → 1.1.50

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.
Files changed (76) hide show
  1. package/README.md +2 -1
  2. package/components/Actions.d.ts +7 -0
  3. package/components/Actions.js +17 -0
  4. package/components/DialogActionBase.d.ts +10 -0
  5. package/components/DialogActionBase.js +13 -11
  6. package/components/DialogBase.d.ts +42 -109
  7. package/components/DialogBase.js +104 -762
  8. package/components/DialogContent.d.ts +1 -19
  9. package/components/DialogContent.js +66 -72
  10. package/components/DialogContentBody.d.ts +3 -5
  11. package/components/DialogContentBody.js +2 -23
  12. package/components/DialogContentFooter.d.ts +4 -0
  13. package/components/{DialogContenFooter.js → DialogContentFooter.js} +6 -33
  14. package/components/DialogContentHeader.d.ts +6 -6
  15. package/components/DialogContentHeader.js +74 -32
  16. package/components/DialogWithBackdropWrapper.d.ts +4 -0
  17. package/components/DialogWithBackdropWrapper.js +72 -0
  18. package/components/Features/DialogCloseAction.js +18 -0
  19. package/components/Features/DialogFullscreenAction.js +24 -0
  20. package/components/{Futures → Features}/DialogInfoAction.js +8 -11
  21. package/components/Features/DialogProcessing.js +14 -0
  22. package/components/RippleButton.d.ts +2 -2
  23. package/components/RippleButton.js +1 -3
  24. package/components/index.d.ts +9 -0
  25. package/components/index.js +24 -0
  26. package/components/utils/effects/jumper-animate.d.ts +2 -0
  27. package/components/utils/effects/jumper-animate.js +36 -0
  28. package/context/index.d.ts +3 -0
  29. package/context/index.js +54 -0
  30. package/{models → helpers}/Resizeable.d.ts +2 -2
  31. package/{models → helpers}/Resizeable.js +23 -11
  32. package/helpers/dialogBoundsMemoize.d.ts +5 -5
  33. package/helpers/dialogBoundsMemoize.js +82 -77
  34. package/helpers/dialogRectAuto.d.ts +3 -0
  35. package/helpers/dialogRectAuto.js +21 -0
  36. package/helpers/formInputKeyListeners.d.ts +2 -0
  37. package/helpers/formInputKeyListeners.js +18 -0
  38. package/helpers/hexToRgb.d.ts +2 -0
  39. package/helpers/hexToRgb.js +19 -0
  40. package/helpers/index.d.ts +1 -0
  41. package/helpers/index.js +3 -1
  42. package/helpers/initDialogMemoizeBounds.d.ts +7 -2
  43. package/helpers/initDialogMemoizeBounds.js +19 -14
  44. package/index.d.ts +3 -4
  45. package/index.js +12 -15
  46. package/models/Dialog.d.ts +30 -35
  47. package/models/Dialog.js +112 -99
  48. package/models/DialogAction.d.ts +1 -39
  49. package/models/DialogAction.js +2 -171
  50. package/models/baseDialogOptions.d.ts +5 -0
  51. package/models/baseDialogOptions.js +63 -0
  52. package/models/index.d.ts +3 -0
  53. package/models/index.js +13 -0
  54. package/package.json +1 -1
  55. package/styles/dialog.css +1 -2
  56. package/{helpers → types}/BoundTypes.d.ts +4 -1
  57. package/types/DialogActionTypes.d.ts +14 -6
  58. package/types/DialogTypes.d.ts +81 -31
  59. package/types/SizePosTypes.d.ts +3 -2
  60. package/types/index.d.ts +1 -1
  61. package/types/types.d.ts +1 -0
  62. package/components/DialogContenFooter.d.ts +0 -13
  63. package/components/Futures/DialogCloseAction.js +0 -30
  64. package/components/Futures/DialogFullscreenAction.js +0 -37
  65. package/components/Futures/DialogProcessing.js +0 -18
  66. package/hooks/useDialogOptions.d.ts +0 -3
  67. package/hooks/useDialogOptions.js +0 -82
  68. /package/components/{Futures → Features}/DialogCloseAction.d.ts +0 -0
  69. /package/components/{Futures → Features}/DialogFullscreenAction.d.ts +0 -0
  70. /package/components/{Futures → Features}/DialogHeaderActionsWrapper.d.ts +0 -0
  71. /package/components/{Futures → Features}/DialogHeaderActionsWrapper.js +0 -0
  72. /package/components/{Futures → Features}/DialogInfoAction.d.ts +0 -0
  73. /package/components/{Futures → Features}/DialogProcessing.d.ts +0 -0
  74. /package/components/{Futures → Features}/index.d.ts +0 -0
  75. /package/components/{Futures → Features}/index.js +0 -0
  76. /package/{helpers → types}/BoundTypes.js +0 -0
@@ -1,22 +1,4 @@
1
1
  import * as React from "react";
2
- import { BaseDialogProps, DialogOptionsType, TDialogCallbackNodeFn } from "../types/DialogTypes";
3
- import DialogBase from "./DialogBase";
4
- import { DialogContentFooterReturnType } from "./DialogContenFooter";
5
- import { FormikProps } from "formik";
6
- interface IContentProps {
7
- body: TDialogCallbackNodeFn;
8
- header: TDialogCallbackNodeFn;
9
- actions: any;
10
- dialogRef: React.RefObject<any>;
11
- footerRef: React.RefObject<DialogContentFooterReturnType>;
12
- backdropRef: React.RefObject<any>;
13
- dialogOptions: DialogOptionsType;
14
- dom: HTMLDivElement;
15
- keyboardListener: BaseDialogProps['keyboardListener'];
16
- dialog: DialogBase<any>;
17
- }
2
+ import { IContentProps } from "../types/DialogTypes";
18
3
  declare const DialogContent: React.FC<IContentProps>;
19
- export declare const DialogContentContext: React.Context<{
20
- formikProps: FormikProps<any>;
21
- }>;
22
4
  export { DialogContent };
@@ -43,119 +43,113 @@ var __importStar = (this && this.__importStar) || (function () {
43
43
  return result;
44
44
  };
45
45
  })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
46
57
  var __importDefault = (this && this.__importDefault) || function (mod) {
47
58
  return (mod && mod.__esModule) ? mod : { "default": mod };
48
59
  };
49
60
  var _this = this;
50
61
  Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.DialogContent = exports.DialogContentContext = void 0;
62
+ exports.DialogContent = void 0;
52
63
  var jsx_runtime_1 = require("react/jsx-runtime");
53
64
  var react_draggable_1 = __importDefault(require("react-draggable"));
54
65
  var helpers_1 = require("../helpers");
55
66
  var React = __importStar(require("react"));
56
67
  var ResizeIcon_1 = __importDefault(require("./icons/ResizeIcon"));
57
68
  var notistack_1 = require("notistack");
58
- var DialogContentHeader_1 = require("./DialogContentHeader");
59
- var DialogContentBody_1 = require("./DialogContentBody");
60
- var DialogContenFooter_1 = require("./DialogContenFooter");
61
- var formik_1 = require("formik");
69
+ var _1 = require("./");
62
70
  var react_1 = require("react");
71
+ var helpers_2 = require("../helpers");
72
+ var jumper_animate_1 = require("./utils/effects/jumper-animate");
63
73
  var WithSnackbar = function (props) {
64
74
  return (0, jsx_runtime_1.jsx)(notistack_1.SnackbarProvider, { ref: props.snackbarRef, maxSnack: props.maxSnack, children: props.children });
65
75
  };
66
- var dialogAutoPos = function () {
67
- var nodes = Array.from(document.querySelectorAll('.appinsource-dialog-root'));
68
- if (nodes.length > 1) {
69
- var lastDialog = nodes[nodes.length - 2];
70
- var dialogMain = lastDialog.querySelector('#dialog-main');
71
- return {
72
- top: (dialogMain === null || dialogMain === void 0 ? void 0 : dialogMain.getBoundingClientRect().top) + 10,
73
- left: (dialogMain === null || dialogMain === void 0 ? void 0 : dialogMain.getBoundingClientRect().left) + 10,
74
- isMultiple: true
75
- };
76
- }
77
- return { top: 0, left: 0, isMultiple: false };
78
- };
79
76
  var DialogContent = function (_a) {
80
- var _b;
81
- var _c, _d, _e;
82
- var body = _a.body, header = _a.header, actions = _a.actions, dialogRef = _a.dialogRef, footerRef = _a.footerRef, dialogOptions = _a.dialogOptions, dom = _a.dom, backdropRef = _a.backdropRef, keyboardListener = _a.keyboardListener, dialog = _a.dialog;
83
- var position = dialogAutoPos();
84
- var snackbarRef = React.useRef(null);
85
- var _f = React.useState(false), fullscreenMode = _f[0], setFullscreenMode = _f[1];
86
- // ✨✨✨✨
87
- var dialogBodyRef = (0, react_1.useRef)(null);
77
+ var _b, _c, _d, _e, _f;
78
+ var body = _a.body, header = _a.header, actions = _a.actions, dialogRef = _a.dialogRef, headerRef = _a.headerRef, bodyRef = _a.bodyRef, footerRef = _a.footerRef, dialogOptions = _a.dialogOptions, backdropRef = _a.backdropRef, dialog = _a.dialog, resizeableObject = _a.resizeableObject, prevDialogRect = _a.prevDialogRect, snackbarRef = _a.snackbarRef;
79
+ var _g = React.useState(false), fullscreenMode = _g[0], setFullscreenMode = _g[1];
80
+ var _h = React.useState(null), rect = _h[0], setRect = _h[1];
88
81
  var baseOptions = dialogOptions.base;
89
- // dialog.formikProps = formikProps;
90
- if (dialogRef.current) {
91
- // Öncelikle ref'i al ve input elemanlarını bul
92
- var inputElements = dialogRef.current.querySelectorAll("input");
93
- // Tüm input elemanlarını döngüye al
94
- inputElements.forEach(function (input) {
95
- console.log(input); // Her bir input elemanını burada işleyebilirsiniz
96
- // Örneğin, input değerini okuma veya ayarlama
97
- input.addEventListener('keydown', function (e) { return e.key === "Enter" && e.preventDefault(); }); // Değerini boşaltmak için örnek
98
- input.addEventListener('keyup', function (e) { return e.key === "Enter" && e.preventDefault(); }); // Değerini boşaltmak için örnek
99
- input.addEventListener('keypress', function (e) { return e.key === "Enter" && e.preventDefault(); }); // Değerini boşaltmak için örnek
100
- });
101
- }
102
- var xKey = position.isMultiple ? "left" : "marginLeft";
103
- var yKey = position.isMultiple ? "top" : "marginTop";
104
82
  /**
105
83
  * default null
106
- * eget momoize islemi uygulanmissa read from memory
84
+ * If memoized, than read values from memory
107
85
  * */
108
86
  var base = dialogOptions.base;
109
- var bounds = ((_c = dialogOptions.base) === null || _c === void 0 ? void 0 : _c.memoBounds) ? (0, helpers_1.getDialogBounds)(base) : null;
110
- // console.log('MAIN DOM', window.getComputedStyle(this.props.dom).zIndex);
87
+ var bounds = ((_b = dialogOptions.base) === null || _b === void 0 ? void 0 : _b.memoBounds) ? (0, helpers_1.getDialogBounds)(base.id) : null;
111
88
  var domZIndex = window.getComputedStyle(dialog.getDom()).zIndex;
89
+ // Effect Listener
112
90
  (0, react_1.useEffect)(function () {
113
91
  var _a;
114
- console.log('DialogContent_Runned', '');
115
- dialog.props.didMountCallback(dialog, (_a = dialogBodyRef.current) === null || _a === void 0 ? void 0 : _a.formikProps);
92
+ // State Listener Dialog
93
+ if (typeof dialog.props.stateListener === "function") {
94
+ dialog.props.stateListener(dialog.values, dialog);
95
+ }
96
+ // State Listener Actions
97
+ for (var actionKey in dialog._actionRefs) {
98
+ var action = dialog._actionRefs[actionKey];
99
+ if (typeof action.current._stateListener === "function") {
100
+ action.current._stateListener(dialog.values, (_a = dialog._actionRefs[action.current.name]) === null || _a === void 0 ? void 0 : _a.current, dialog);
101
+ }
102
+ }
103
+ }, [dialog === null || dialog === void 0 ? void 0 : dialog.values]);
104
+ (0, react_1.useEffect)(function () {
105
+ // setDialogRect();
106
+ (0, helpers_2.formInputKeyListeners)(dialogRef.current);
107
+ if (dialog.dialogOptions.animate === 'jumper') {
108
+ (0, jumper_animate_1.jumperAnimate)(dialogRef.current);
109
+ }
110
+ }, []);
111
+ (0, react_1.useEffect)(function () {
112
+ var _a;
113
+ var dialogRectSelectors = { xKey: 'marginLeft', yKey: 'marginTop' };
114
+ if (prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.isMultiple) {
115
+ dialogRectSelectors = { xKey: 'left', yKey: 'top' };
116
+ }
117
+ var _b = bounds !== null && bounds !== void 0 ? bounds : {}, fullscreen = _b.fullscreen, x = _b.x, y = _b.y, restBounds = __rest(_b, ["fullscreen", "x", "y"]);
118
+ var cssBounds = __assign(__assign(__assign(__assign({}, restBounds), (_a = {}, _a[dialogRectSelectors.xKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.left, _a[dialogRectSelectors.yKey] = prevDialogRect === null || prevDialogRect === void 0 ? void 0 : prevDialogRect.top, _a)), prevDialogRect.isMultiple ? { position: 'absolute' } : null), { translate: prevDialogRect.isMultiple ? "".concat(5, "px ").concat(5, "px") : 'none' });
119
+ setRect(__assign({}, bounds ? { position: 'absolute', top: bounds.y, left: bounds.x, width: bounds.width, height: bounds.height } : cssBounds));
116
120
  }, []);
117
- // Burda kaldik
118
121
  return (0, jsx_runtime_1.jsx)(react_draggable_1.default, { disabled: !baseOptions.draggable || fullscreenMode, axis: 'both', handle: baseOptions.draggable ? '.drag-handle' : '', scale: 1, ref: backdropRef, onDrag: function (event, data) {
119
122
  event.stopPropagation();
120
123
  dialog._dialogTranslate = { lastX: data.lastX, lastY: data.lastY };
121
124
  }, onStop: function (event, data) {
122
- var _a;
125
+ var _a, _b;
123
126
  event.stopPropagation();
124
127
  event.preventDefault();
125
- console.log('onDragStop', 'fired');
126
- var _b = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(), width = _b.width, height = _b.height, x = _b.x, y = _b.y;
128
+ 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;
129
+ console.log('onDragStop', 'fired', (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect());
127
130
  (0, helpers_1.setDialogBounds)(dialogOptions.base.id, {
128
131
  width: width,
129
132
  height: height,
130
133
  x: x,
131
- y: y
134
+ y: y,
135
+ fullscreen: false
132
136
  }, dialogRef);
133
137
  }, children: (0, jsx_runtime_1.jsxs)("div", { id: "dialog-main", ref: dialogRef, onClick: function (e) {
134
138
  e.stopPropagation();
135
- }, onKeyDown: function (e) {
136
- if (typeof keyboardListener === "function") {
139
+ }, tabIndex: 0, onKeyDown: function (e) {
140
+ var target = e.target;
141
+ if (target.tagName === 'INPUT' ||
142
+ target.tagName === 'TEXTAREA' ||
143
+ target.isContentEditable) {
144
+ return;
145
+ }
146
+ if (typeof dialog.props.keyboardListener === "function") {
137
147
  // @ts-ignore
138
- keyboardListener(e.key, _this);
148
+ dialog.props.keyboardListener(e.key, _this);
139
149
  }
140
- },
141
- // className={this._dialogSize.width === 'auto' ? 'auto' : `dialog-width-${this._dialogSize.width} dialog-main show-opacity show-position-${this._dialogOptions.base.initialAnchor.vertical}`}
142
- className: baseOptions.size.width === 'auto' ? 'auto' : "dialog-width-".concat(dialogOptions.base.size.width, " dialog-main show-opacity show-position-").concat(baseOptions.initialAnchor.vertical), style: __assign(__assign(__assign(__assign(__assign({ alignSelf: baseOptions.initialAnchor.vertical, height: (_d = baseOptions.size.height) !== null && _d !== void 0 ? _d : 'auto' }, typeof baseOptions.size.width === "number" ? { width: baseOptions.size.width } : null), (_b = { outline: 'none' }, _b[yKey] = position.top + 'px', _b[xKey] = position.left + 'px', _b)), baseOptions.style), { fontFamily: (_e = baseOptions.style.fontFamily) !== null && _e !== void 0 ? _e : 'Arial' }), bounds ? { position: 'absolute', top: bounds.y, left: bounds.x, width: bounds.width, height: bounds.height } : null), children: [(0, jsx_runtime_1.jsx)(DialogContentContextProvider, { initialValues: dialog.values, children: function (formikProps) { return ((0, jsx_runtime_1.jsxs)(WithSnackbar, { snackbarRef: snackbarRef, maxSnack: dialogOptions.snackbar.maxSnack, children: [(header || dialogOptions.slot.header) && ((0, jsx_runtime_1.jsx)(DialogContentHeader_1.DialogContentHeader, { header: header, dialog: dialog, dialogBodyRef: dialogBodyRef })), (0, jsx_runtime_1.jsx)(DialogContentBody_1.DialogContentBody, { ref: dialogBodyRef, dialog: dialog, body: body, formikProps: formikProps }), (0, jsx_runtime_1.jsx)(DialogContenFooter_1.DialogContentFooter, { dialog: dialog, ref: footerRef, actions: actions })] })); } }), (baseOptions.resizeable) &&
150
+ }, className: baseOptions.size.width === 'auto' ? 'auto' : "dialog-width-".concat(dialogOptions.base.size.width, " dialog-main show-opacity show-position-").concat(baseOptions.initialAnchor.vertical), style: __assign(__assign(__assign(__assign({ height: (_c = baseOptions.size.height) !== null && _c !== void 0 ? _c : 'auto' }, typeof baseOptions.size.width === "number" ? { width: "".concat(baseOptions.size.width, "px") } : { width: "".concat(baseOptions.size.width) }), { outline: 'none', fontFamily: (_d = baseOptions.style.fontFamily) !== null && _d !== void 0 ? _d : 'Arial' }), rect), { alignSelf: (_e = baseOptions.initialAnchor.vertical) !== null && _e !== void 0 ? _e : 'flex-start', justifySelf: (_f = baseOptions.initialAnchor.horizontal) !== null && _f !== void 0 ? _f : 'flex-start' }), children: [(0, jsx_runtime_1.jsxs)(WithSnackbar, { snackbarRef: snackbarRef, maxSnack: dialogOptions.snackbar.maxSnack, children: [(header || dialogOptions.slot.header) && ((0, jsx_runtime_1.jsx)(_1.DialogContentHeader, { ref: headerRef, dialogRef: dialogRef, header: header, dialog: dialog, bounds: bounds })), (0, jsx_runtime_1.jsx)(_1.DialogContentBody, { ref: bodyRef, dialog: dialog, body: body }), (0, jsx_runtime_1.jsx)(_1.DialogContentFooter, { ref: footerRef, dialog: dialog, actions: actions })] }), (baseOptions.resizeable) &&
143
151
  (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
144
152
  zIndex: parseInt(domZIndex) + 1
145
- }, onMouseDown: dialog.Resizeable.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(ResizeIcon_1.default, { color: '#286e94' }) }) })] }) });
153
+ }, onMouseDown: resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.resizeHandleMouseDown, children: (0, jsx_runtime_1.jsx)(ResizeIcon_1.default, { color: '#286e94' }) }) })] }) });
146
154
  };
147
155
  exports.DialogContent = DialogContent;
148
- exports.DialogContentContext = React.createContext(null);
149
- var DialogContentContextProvider = function (_a) {
150
- var children = _a.children, initialValues = _a.initialValues;
151
- var formikProps = (0, formik_1.useFormik)({
152
- // enableReinitialize: true,
153
- initialValues: initialValues,
154
- onSubmit: function (values, formikHelpers) {
155
- // No Necessary
156
- }
157
- });
158
- return ((0, jsx_runtime_1.jsx)(exports.DialogContentContext.Provider, { value: { formikProps: formikProps }, children: typeof children === "function"
159
- ? children(formikProps)
160
- : children }));
161
- };
@@ -1,12 +1,10 @@
1
1
  import * as React from "react";
2
- import { TDialogCallbackNodeFn } from "../types/DialogTypes";
2
+ import { TDialogCallbackFn } from "../types/DialogTypes";
3
3
  import DialogBase from "./DialogBase";
4
- import { FormikProps } from "formik";
5
4
  interface IContentBodyProps {
6
- body: TDialogCallbackNodeFn;
5
+ body: TDialogCallbackFn;
7
6
  dialog: DialogBase<any>;
8
- ref: React.RefObject<any>;
9
- formikProps: FormikProps<any>;
7
+ ref?: React.RefObject<any>;
10
8
  }
11
9
  declare const DialogContentBody: React.FC<IContentBodyProps>;
12
10
  export { DialogContentBody };
@@ -36,7 +36,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DialogContentBody = void 0;
37
37
  var jsx_runtime_1 = require("react/jsx-runtime");
38
38
  var React = __importStar(require("react"));
39
- var react_1 = require("react");
40
39
  var Placeholder = function (_a) {
41
40
  var dialogOptions = _a.dialogOptions, placeholder = _a.placeholder;
42
41
  var bgColor = dialogOptions.base.style.backgroundColor ?
@@ -50,33 +49,13 @@ var Placeholder = function (_a) {
50
49
  }, children: placeholder });
51
50
  };
52
51
  var DialogContentBody = React.forwardRef(function (_a, ref) {
53
- var body = _a.body, dialog = _a.dialog, formikProps = _a.formikProps;
54
- console.log('DialogContentBody', dialog);
55
- // const formikProps = useFormik({
56
- // // enableReinitialize: true,
57
- // initialValues: dialog.values,
58
- // onSubmit: (values, formikHelpers) => {
59
- // // No Necessary
60
- // }
61
- // });
62
- //
63
- // useImperativeHandle( ref, () => ({
64
- // formikProps
65
- // }));
66
- // const {
67
- // formikProps
68
- // } = useContext(DialogContentContext);
69
- (0, react_1.useEffect)(function () {
70
- dialog.props.didMountCallback(dialog, formikProps);
71
- }, []);
52
+ var body = _a.body, dialog = _a.dialog;
72
53
  if (body instanceof Function) {
73
- 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, formikProps)] });
54
+ 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)] });
74
55
  }
75
56
  return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-body', style: { height: '100%', padding: 10 }, children: dialog.holder ?
76
- // this.Placeholder(this._holder)
77
57
  (0, jsx_runtime_1.jsx)(Placeholder, { dialogOptions: dialog.dialogOptions, placeholder: dialog.holder })
78
58
  :
79
- //@ts-ignore
80
59
  body });
81
60
  });
82
61
  exports.DialogContentBody = DialogContentBody;
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import { DialogContentFooterReturnType, IContentFooterProps } from "../types/DialogActionTypes";
3
+ declare const DialogContentFooter: React.ForwardRefExoticComponent<IContentFooterProps & React.RefAttributes<DialogContentFooterReturnType>>;
4
+ export { DialogContentFooter };
@@ -43,38 +43,19 @@ var __importStar = (this && this.__importStar) || (function () {
43
43
  return result;
44
44
  };
45
45
  })();
46
- var __importDefault = (this && this.__importDefault) || function (mod) {
47
- return (mod && mod.__esModule) ? mod : { "default": mod };
48
- };
49
46
  var _this = this;
50
47
  Object.defineProperty(exports, "__esModule", { value: true });
51
48
  exports.DialogContentFooter = void 0;
52
49
  var jsx_runtime_1 = require("react/jsx-runtime");
53
50
  var React = __importStar(require("react"));
54
51
  var react_1 = require("react");
55
- var DialogBase_1 = require("./DialogBase");
56
- var Futures_1 = require("./Futures");
57
- var DialogActionBase_1 = __importDefault(require("./DialogActionBase"));
58
- var Actions = function (_a) {
59
- var actions = _a.actions, dialog = _a.dialog;
60
- var dialogOptions = dialog.dialogOptions;
61
- console.log('Actions', actions);
62
- return (0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', display: 'flex', flexDirection: 'row', columnGap: 10, alignItems: 'center' }, children: actions.map(function (action, index) {
63
- var referencedAction = dialog.initializeActionRef(action.name);
64
- // this._actions[action.name] = referencedAction.current
65
- return (0, jsx_runtime_1.jsx)(DialogActionBase_1.default, { name: action.name, ref: referencedAction, dialogBaseComponent: dialog, options: action.options, onClick: action.onClickHandler(), inProcess: action.isInProcess(),
66
- // onLoad={ dialogAction => {
67
- // action.baseDialogAction = dialogAction;
68
- // }}
69
- style: action.options.style, baseStyle: dialogOptions.base.actions.baseStyle, fontFamily: dialogOptions.base.style.fontFamily, stateListener: action._stateListener }, index.toString());
70
- }) });
71
- };
52
+ var Features_1 = require("./Features");
53
+ var context_1 = require("../context");
54
+ var _1 = require("./");
72
55
  var DialogContentFooter = (0, react_1.forwardRef)(function (_a, ref) {
73
56
  var _b, _c, _d;
74
57
  var actions = _a.actions, dialog = _a.dialog;
75
- var state = dialog.state, dialogOptions = dialog.dialogOptions;
76
- console.log('DialogContentHeader', dialog);
77
- var baseOptions = dialogOptions.base;
58
+ var dialogOptions = dialog.dialogOptions;
78
59
  var CustomFooter = (_b = dialogOptions.slot) === null || _b === void 0 ? void 0 : _b.footer;
79
60
  // Imperative handle
80
61
  var _e = React.useState(false), inProcess = _e[0], setInProcess = _e[1];
@@ -85,28 +66,20 @@ var DialogContentFooter = (0, react_1.forwardRef)(function (_a, ref) {
85
66
  setProcessing: setProcessing,
86
67
  inProcess: inProcess
87
68
  }); });
88
- // console.log('processingListener', this._processingListener);
89
- if (typeof dialog._processingListener === "function") {
90
- dialog._processingListener(inProcess);
91
- }
92
69
  var staticProps = {
93
- dialogValues: dialog.state.values,
94
70
  dialogOptions: dialogOptions,
95
71
  dialog: _this
96
72
  };
97
73
  var footerProps = {};
98
74
  if (dialogOptions.slotProps.footer) {
99
75
  footerProps = dialogOptions.slotProps.footer({
100
- dialogValues: dialog.state.values,
101
76
  dialogOptions: dialogOptions,
102
77
  inProcess: dialog.isInProcess()
103
78
  });
104
79
  }
105
- console.log('FooterSlot_props_Y', footerProps, staticProps, 'V6 ya hazirlik -2');
106
- return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-footer', style: (_d = (_c = dialogOptions.base) === null || _c === void 0 ? void 0 : _c.footer) === null || _d === void 0 ? void 0 : _d.style, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(DialogBase_1.WithHeaderFooterContext, __assign({}, staticProps, { dialog: dialog, children: dialogOptions.slot.footer ?
107
- /*<CustomFooter inProcess={this._inProcess} dialogValues={this.state.values} dialogOptions={this._dialogOptions} />*/
80
+ return (0, jsx_runtime_1.jsxs)("div", { className: 'dialog-footer', style: (_d = (_c = dialogOptions.base) === null || _c === void 0 ? void 0 : _c.footer) === null || _d === void 0 ? void 0 : _d.style, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(context_1.WithHeaderFooterContext, __assign({}, staticProps, { dialog: dialog, children: dialogOptions.slot.footer ?
108
81
  (0, jsx_runtime_1.jsx)(CustomFooter, __assign({}, staticProps, footerProps))
109
82
  :
110
- (0, jsx_runtime_1.jsx)(Futures_1.DialogProcessing, {}) })) }), (0, jsx_runtime_1.jsx)(Actions, { dialog: dialog, actions: actions })] });
83
+ (0, jsx_runtime_1.jsx)(Features_1.DialogProcessing, {}) })) }), (0, jsx_runtime_1.jsx)(_1.Actions, { dialog: dialog, actions: actions })] });
111
84
  });
112
85
  exports.DialogContentFooter = DialogContentFooter;
@@ -1,13 +1,13 @@
1
- import { TDialogCallbackNodeFn } from "../types/DialogTypes";
1
+ import { TDialogCallbackFn } from "../types/DialogTypes";
2
2
  import * as React from "react";
3
3
  import DialogBase from "./DialogBase";
4
- import { FormikProps } from "formik";
4
+ import { IDialogBoundsDef } from "../types/BoundTypes";
5
5
  interface IContentHeaderProps {
6
- header: TDialogCallbackNodeFn;
6
+ header: TDialogCallbackFn;
7
7
  dialog: DialogBase<any>;
8
- dialogBodyRef: React.RefObject<{
9
- formikProps: FormikProps<any>;
10
- }>;
8
+ ref: React.RefObject<any>;
9
+ dialogRef: React.RefObject<any>;
10
+ bounds: IDialogBoundsDef;
11
11
  }
12
12
  declare const DialogContentHeader: React.FC<IContentHeaderProps>;
13
13
  export { DialogContentHeader };
@@ -10,58 +10,100 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
13
46
  var _this = this;
14
47
  Object.defineProperty(exports, "__esModule", { value: true });
15
48
  exports.DialogContentHeader = void 0;
16
49
  var jsx_runtime_1 = require("react/jsx-runtime");
17
- var Futures_1 = require("./Futures");
18
- var DialogBase_1 = require("./DialogBase");
50
+ var Features_1 = require("./Features");
51
+ var React = __importStar(require("react"));
19
52
  var react_1 = require("react");
20
- var DialogContent_1 = require("./DialogContent");
21
- var DialogContentHeader = function (_a) {
22
- var _b, _c, _d, _e, _f;
23
- var header = _a.header, dialog = _a.dialog, dialogBodyRef = _a.dialogBodyRef;
24
- var state = dialog.state, dialogOptions = dialog.dialogOptions;
25
- // const [formikProps, setFormikProps] = React.useState<FormikProps<any>>(null);
26
- //
27
- //
28
- // useEffect(() => {
29
- // console.log('DialogContentHeader_X', dialogBodyRef);
30
- // setFormikProps(dialogBodyRef.current.formikProps);
31
- // }, [dialogBodyRef, dialogBodyRef.current?.formikProps?.values]);
32
- var formikProps = (0, react_1.useContext)(DialogContent_1.DialogContentContext).formikProps;
53
+ var helpers_1 = require("../helpers");
54
+ var context_1 = require("../context");
55
+ var DialogContentHeader = React.forwardRef(function (_a, ref) {
56
+ var _b, _c, _d, _e;
57
+ var header = _a.header, dialog = _a.dialog, dialogRef = _a.dialogRef, bounds = _a.bounds;
58
+ var dialogOptions = dialog.dialogOptions;
59
+ var _f = React.useState(bounds === null || bounds === void 0 ? void 0 : bounds.fullscreen), fullscreen = _f[0], setFullscreen = _f[1];
60
+ (0, react_1.useImperativeHandle)(ref, function () { return ({
61
+ setFullscreen: setFullscreen,
62
+ fullscreen: fullscreen
63
+ }); });
64
+ (0, react_1.useEffect)(function () {
65
+ if (fullscreen) {
66
+ dialogRef.current.classList.add('fullscreen');
67
+ }
68
+ else {
69
+ dialogRef.current.classList.remove('fullscreen');
70
+ }
71
+ dialogRef.current.classList.add('no-user-select');
72
+ setTimeout(function () {
73
+ dialogRef.current.classList.remove('no-user-select');
74
+ }, 300);
75
+ }, [fullscreen]);
33
76
  var baseOptions = dialogOptions.base;
34
77
  var CustomHeader = (_b = dialogOptions.slot) === null || _b === void 0 ? void 0 : _b.header;
35
78
  var staticProps = {
36
- dialogValues: state.values,
37
79
  dialogOptions: dialogOptions,
38
80
  dialog: dialog
39
81
  };
40
- var headerProps = {
41
- formikProps: (_c = dialogBodyRef.current) === null || _c === void 0 ? void 0 : _c.formikProps
42
- };
43
- if (dialogOptions.slotProps.header) {
44
- headerProps = __assign(__assign({}, headerProps), dialogOptions.slotProps.header(staticProps));
45
- }
46
82
  if (dialogOptions.slot.header) {
83
+ var headerProps = dialogOptions.slotProps.header ? __assign({}, dialogOptions.slotProps.header(staticProps)) : {};
47
84
  return (0, jsx_runtime_1.jsx)("div", { onDoubleClick: function (event) {
48
85
  var _a;
49
86
  if ((_a = dialog === null || dialog === void 0 ? void 0 : dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.fullscreen) {
50
- dialog.switchFullScreen();
87
+ setFullscreen(!fullscreen);
51
88
  }
52
- }, style: (_d = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.header) === null || _d === void 0 ? void 0 : _d.style, className: "dialog-header ".concat(baseOptions.draggable && !dialog.state.fullscreenMode ? 'drag-handle' : ''), children: (0, jsx_runtime_1.jsx)(DialogBase_1.WithHeaderFooterContext, { dialog: dialog, children: (0, jsx_runtime_1.jsx)(CustomHeader, __assign({}, staticProps, headerProps, { dialog: _this })) }) });
89
+ }, style: (_c = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.header) === null || _c === void 0 ? void 0 : _c.style, className: "dialog-header ".concat(baseOptions.draggable && !dialog.state.fullscreenMode ? 'drag-handle' : ''), children: (0, jsx_runtime_1.jsx)(context_1.WithHeaderFooterContext, { dialog: dialog, children: (0, jsx_runtime_1.jsx)(CustomHeader, __assign({}, staticProps, headerProps, { dialog: _this })) }) });
53
90
  }
54
- console.log('DialogContentHeader_formikProps', formikProps);
55
91
  if (header instanceof Function) {
56
92
  return (0, jsx_runtime_1.jsxs)("div", { onDoubleClick: function (event) {
57
93
  if (baseOptions.fullscreen) {
58
- dialog.switchFullScreen();
94
+ if (bounds) {
95
+ (0, helpers_1.setDialogBounds)(dialog.dialogOptions.base.id, __assign(__assign({}, bounds), { fullscreen: !fullscreen }), dialogRef);
96
+ }
97
+ setFullscreen(!fullscreen);
98
+ event.stopPropagation();
99
+ event.preventDefault();
59
100
  }
60
- }, style: (_e = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.header) === null || _e === void 0 ? void 0 : _e.style, className: "dialog-header ".concat(baseOptions.draggable && !dialog.state.fullscreenMode ? 'drag-handle' : ''), children: [header(dialog, formikProps), (baseOptions.closeable || baseOptions.fullscreen) &&
61
- (0, jsx_runtime_1.jsx)(DialogBase_1.WithHeaderFooterContext, { dialog: dialog, children: (0, jsx_runtime_1.jsxs)(Futures_1.DialogHeaderActionsWrapper, { children: [baseOptions.fullscreen &&
62
- (0, jsx_runtime_1.jsx)(Futures_1.DialogFullscreenAction, {}), baseOptions.closeable &&
63
- (0, jsx_runtime_1.jsx)(Futures_1.DialogCloseAction, {}), (0, jsx_runtime_1.jsx)(Futures_1.DialogInfoAction, {})] }) })] });
101
+ }, style: (_d = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.header) === null || _d === void 0 ? void 0 : _d.style, className: "dialog-header ".concat(baseOptions.draggable && !fullscreen ? 'drag-handle' : ''), children: [header(dialog), (baseOptions.closeable || baseOptions.fullscreen) &&
102
+ (0, jsx_runtime_1.jsx)(context_1.WithHeaderFooterContext, { dialog: dialog, fullscreen: fullscreen, setFullscreen: setFullscreen, children: (0, jsx_runtime_1.jsxs)(Features_1.DialogHeaderActionsWrapper, { children: [baseOptions.fullscreen &&
103
+ (0, jsx_runtime_1.jsx)(Features_1.DialogFullscreenAction, {}), baseOptions.closeable &&
104
+ (0, jsx_runtime_1.jsx)(Features_1.DialogCloseAction, {}), baseOptions.about &&
105
+ (0, jsx_runtime_1.jsx)(Features_1.DialogInfoAction, {})] }) })] });
64
106
  }
65
- return (0, jsx_runtime_1.jsx)("div", { style: (_f = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.header) === null || _f === void 0 ? void 0 : _f.style, className: 'drag-handle dialog-header', children: header });
66
- };
107
+ return (0, jsx_runtime_1.jsx)("div", { style: (_e = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.header) === null || _e === void 0 ? void 0 : _e.style, className: 'drag-handle dialog-header', children: header });
108
+ });
67
109
  exports.DialogContentHeader = DialogContentHeader;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { DialogWithBackdropWrapperRefProps, WithBackdrop } from "../types/DialogTypes";
3
+ declare const DialogWithBackdropWrapper: React.ForwardRefExoticComponent<Omit<WithBackdrop, "ref"> & React.RefAttributes<DialogWithBackdropWrapperRefProps>>;
4
+ export { DialogWithBackdropWrapper };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DialogWithBackdropWrapper = void 0;
4
+ var jsx_runtime_1 = require("react/jsx-runtime");
5
+ var react_1 = require("react");
6
+ var DialogContent_1 = require("./DialogContent");
7
+ var hexToRgb_1 = require("../helpers/hexToRgb");
8
+ var Resizeable_1 = require("../helpers/Resizeable");
9
+ var formik_1 = require("formik");
10
+ var resizeManager = function (dialogRef, dialog) {
11
+ var _a;
12
+ dialogRef.current ? dialogRef.current.tabIndex = 0 : undefined; // Odaklanabilir hale getirir
13
+ (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.focus();
14
+ if (!(dialog === null || dialog === void 0 ? void 0 : dialog.props.initialOptions.base.resizeable))
15
+ return;
16
+ var rs = new Resizeable_1.Resizeable();
17
+ rs.setContainer(dialogRef, dialog.props.initialOptions);
18
+ rs.onResizeListener(function (width, height, rect) {
19
+ var _a;
20
+ if (typeof ((_a = dialog.props) === null || _a === void 0 ? void 0 : _a.resizeListener) === "function") {
21
+ dialog.props.resizeListener({ width: width, height: height, rect: rect }, dialog);
22
+ }
23
+ });
24
+ return rs;
25
+ };
26
+ var DialogWithBackdropWrapper = (0, react_1.forwardRef)(function (_a, ref) {
27
+ var body = _a.body, header = _a.header, actions = _a.actions, dialog = _a.dialog, dialogRef = _a.dialogRef, headerRef = _a.headerRef, bodyRef = _a.bodyRef, backdropRef = _a.backdropRef, footerRef = _a.footerRef, prevDialogRect = _a.prevDialogRect, snackbarRef = _a.snackbarRef;
28
+ var resizeableObject = (0, react_1.useState)(resizeManager(dialogRef, dialog))[0];
29
+ (0, react_1.useImperativeHandle)(ref, function () { return ({
30
+ baseZoomEffect: baseZoomEffect
31
+ }); });
32
+ dialog.inlineFormikProps = (0, formik_1.useFormik)({
33
+ initialValues: dialog.props.initialValues,
34
+ onSubmit: function (values, formikHelpers) { }
35
+ });
36
+ // Call only on initialize
37
+ (0, react_1.useEffect)(function () {
38
+ return function () {
39
+ resizeableObject === null || resizeableObject === void 0 ? void 0 : resizeableObject.cleanUp();
40
+ };
41
+ }, []);
42
+ var baseZoomEffect = function () {
43
+ var _a = dialog.dialogTranslate, lastX = _a.lastX, lastY = _a.lastY;
44
+ dialogRef.current.animate([
45
+ // key frames
46
+ { transform: "translate(".concat(lastX, "px, ").concat(lastY, "px) scale(1)") },
47
+ { transform: "translate(".concat(lastX, "px, ").concat(lastY, "px) scale(1.01)") },
48
+ // { boxShadow: `0 0 20px red`},
49
+ { transform: "translate(".concat(lastX, "px, ").concat(lastY, "px) scale(1)") }
50
+ ], {
51
+ // sync options
52
+ duration: 300,
53
+ iterations: 1
54
+ });
55
+ };
56
+ var _b = dialog.dialogOptions.backdrop, backgroundColor = _b.backgroundColor, opacity = _b.opacity;
57
+ var bgCl = (0, hexToRgb_1.hexToRgb)(backgroundColor, opacity);
58
+ return (0, jsx_runtime_1.jsx)("div", { className: "dialog-backdrop dialog-backdrop-show", ref: backdropRef, style: {
59
+ justifyContent: dialog.dialogOptions.base.initialAnchor.horizontal,
60
+ // alignItems: dialogOptions.base.initialAnchor.vertical,
61
+ background: bgCl
62
+ }, onClick: function (e) {
63
+ if (dialog.state.fullscreenMode)
64
+ return;
65
+ if (dialog.dialogOptions.backdrop.hideOnClick) {
66
+ dialog.close();
67
+ return;
68
+ }
69
+ baseZoomEffect();
70
+ }, children: (0, jsx_runtime_1.jsx)(DialogContent_1.DialogContent, { body: body, header: header, actions: actions, dialogRef: dialogRef, headerRef: headerRef, bodyRef: bodyRef, footerRef: footerRef, backdropRef: backdropRef, dialogOptions: dialog.dialogOptions, dialog: dialog, resizeableObject: resizeableObject, prevDialogRect: prevDialogRect, snackbarRef: snackbarRef }) });
71
+ });
72
+ exports.DialogWithBackdropWrapper = DialogWithBackdropWrapper;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DialogCloseAction = void 0;
7
+ var jsx_runtime_1 = require("react/jsx-runtime");
8
+ var CloseIcon_1 = __importDefault(require("../icons/CloseIcon"));
9
+ var react_1 = require("react");
10
+ var context_1 = require("../../context");
11
+ var DialogCloseAction = function () {
12
+ var _a, _b, _c, _d, _e, _f;
13
+ var dialog = (0, react_1.useContext)(context_1.DialogHeaderFooterContext).dialog;
14
+ return (0, jsx_runtime_1.jsx)("div", { className: 'close-icon-wrapper', onClick: function (event) {
15
+ dialog.close();
16
+ }, children: (0, jsx_runtime_1.jsx)(CloseIcon_1.default, { size: (_c = (_b = (_a = dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.headerControllerIcons) === null || _b === void 0 ? void 0 : _b.size) !== null && _c !== void 0 ? _c : 24, color: (_f = (_e = (_d = dialog.dialogOptions.base) === null || _d === void 0 ? void 0 : _d.headerControllerIcons) === null || _e === void 0 ? void 0 : _e.color) !== null && _f !== void 0 ? _f : null }) });
17
+ };
18
+ exports.DialogCloseAction = DialogCloseAction;