react-dialogger 1.1.47 → 1.1.49

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 +103 -767
  8. package/components/DialogContent.d.ts +1 -18
  9. package/components/DialogContent.js +69 -62
  10. package/components/DialogContentBody.d.ts +3 -2
  11. package/components/DialogContentBody.js +36 -5
  12. package/components/DialogContentFooter.d.ts +4 -0
  13. package/components/{DialogContenFooter.js → DialogContentFooter.js} +6 -33
  14. package/components/DialogContentHeader.d.ts +6 -2
  15. package/components/DialogContentHeader.js +73 -19
  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 +29 -36
  47. package/models/Dialog.js +108 -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 +82 -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,21 +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
- initialValues: BaseDialogProps['initialValues'];
18
- formikProps: React.RefObject<FormikProps<any>>;
19
- }
2
+ import { IContentProps } from "../types/DialogTypes";
20
3
  declare const DialogContent: React.FC<IContentProps>;
21
4
  export { DialogContent };
@@ -43,6 +43,17 @@ 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
  };
@@ -55,94 +66,90 @@ 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("./");
70
+ var react_1 = require("react");
71
+ var helpers_2 = require("../helpers");
72
+ var jumper_animate_1 = require("./utils/effects/jumper-animate");
62
73
  var WithSnackbar = function (props) {
63
74
  return (0, jsx_runtime_1.jsx)(notistack_1.SnackbarProvider, { ref: props.snackbarRef, maxSnack: props.maxSnack, children: props.children });
64
75
  };
65
- var dialogAutoPos = function () {
66
- var nodes = Array.from(document.querySelectorAll('.appinsource-dialog-root'));
67
- if (nodes.length > 1) {
68
- var lastDialog = nodes[nodes.length - 2];
69
- var dialogMain = lastDialog.querySelector('#dialog-main');
70
- return {
71
- top: (dialogMain === null || dialogMain === void 0 ? void 0 : dialogMain.getBoundingClientRect().top) + 10,
72
- left: (dialogMain === null || dialogMain === void 0 ? void 0 : dialogMain.getBoundingClientRect().left) + 10,
73
- isMultiple: true
74
- };
75
- }
76
- return { top: 0, left: 0, isMultiple: false };
77
- };
78
76
  var DialogContent = function (_a) {
79
- var _b;
80
- var _c, _d, _e;
81
- 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, initialValues = _a.initialValues, formikProps = _a.formikProps;
82
- var position = dialogAutoPos();
83
- var snackbarRef = React.useRef(null);
84
- var _f = React.useState(false), fullscreenMode = _f[0], setFullscreenMode = _f[1];
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];
85
81
  var baseOptions = dialogOptions.base;
86
- formikProps.current = (0, formik_1.useFormik)({
87
- // enableReinitialize: true,
88
- initialValues: initialValues,
89
- onSubmit: function (values, formikHelpers) {
90
- // No Necessary
91
- }
92
- });
93
- // dialog.formikProps = formikProps;
94
- if (dialogRef.current) {
95
- // Öncelikle ref'i al ve input elemanlarını bul
96
- var inputElements = dialogRef.current.querySelectorAll("input");
97
- // Tüm input elemanlarını döngüye al
98
- inputElements.forEach(function (input) {
99
- console.log(input); // Her bir input elemanını burada işleyebilirsiniz
100
- // Örneğin, input değerini okuma veya ayarlama
101
- input.addEventListener('keydown', function (e) { return e.key === "Enter" && e.preventDefault(); }); // Değerini boşaltmak için örnek
102
- input.addEventListener('keyup', function (e) { return e.key === "Enter" && e.preventDefault(); }); // Değerini boşaltmak için örnek
103
- input.addEventListener('keypress', function (e) { return e.key === "Enter" && e.preventDefault(); }); // Değerini boşaltmak için örnek
104
- });
105
- }
106
- var xKey = position.isMultiple ? "left" : "marginLeft";
107
- var yKey = position.isMultiple ? "top" : "marginTop";
108
82
  /**
109
83
  * default null
110
- * eget momoize islemi uygulanmissa read from memory
84
+ * If memoized, than read values from memory
111
85
  * */
112
86
  var base = dialogOptions.base;
113
- var bounds = ((_c = dialogOptions.base) === null || _c === void 0 ? void 0 : _c.memoBounds) ? (0, helpers_1.getDialogBounds)(base) : null;
114
- // 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;
115
88
  var domZIndex = window.getComputedStyle(dialog.getDom()).zIndex;
116
- // Burda kaldik
89
+ // Effect Listener
90
+ (0, react_1.useEffect)(function () {
91
+ var _a;
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));
120
+ }, []);
117
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) {
118
122
  event.stopPropagation();
119
123
  dialog._dialogTranslate = { lastX: data.lastX, lastY: data.lastY };
120
124
  }, onStop: function (event, data) {
121
- var _a;
125
+ var _a, _b;
122
126
  event.stopPropagation();
123
127
  event.preventDefault();
124
- console.log('onDragStop', 'fired');
125
- 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());
126
130
  (0, helpers_1.setDialogBounds)(dialogOptions.base.id, {
127
131
  width: width,
128
132
  height: height,
129
133
  x: x,
130
- y: y
134
+ y: y,
135
+ fullscreen: false
131
136
  }, dialogRef);
132
137
  }, children: (0, jsx_runtime_1.jsxs)("div", { id: "dialog-main", ref: dialogRef, onClick: function (e) {
133
138
  e.stopPropagation();
134
- }, onKeyDown: function (e) {
135
- 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") {
136
147
  // @ts-ignore
137
- keyboardListener(e.key, _this);
148
+ dialog.props.keyboardListener(e.key, _this);
138
149
  }
139
- },
140
- // className={this._dialogSize.width === 'auto' ? 'auto' : `dialog-width-${this._dialogSize.width} dialog-main show-opacity show-position-${this._dialogOptions.base.initialAnchor.vertical}`}
141
- 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.jsxs)(WithSnackbar, { snackbarRef: snackbarRef, maxSnack: dialogOptions.snackbar.maxSnack, children: [(header || dialogOptions.slot.header) && (0, jsx_runtime_1.jsx)(DialogContentHeader_1.DialogContentHeader, { header: header,
142
- // dialogOptions={dialogOptions}
143
- dialog: dialog }), (0, jsx_runtime_1.jsx)(DialogContentBody_1.DialogContentBody, { dialog: dialog, body: body }), (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) &&
144
151
  (0, jsx_runtime_1.jsx)(React.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "resizable-handle", style: {
145
152
  zIndex: parseInt(domZIndex) + 1
146
- }, 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' }) }) })] }) });
147
154
  };
148
155
  exports.DialogContent = DialogContent;
@@ -1,9 +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
4
  interface IContentBodyProps {
5
- body: TDialogCallbackNodeFn;
5
+ body: TDialogCallbackFn;
6
6
  dialog: DialogBase<any>;
7
+ ref?: React.RefObject<any>;
7
8
  }
8
9
  declare const DialogContentBody: React.FC<IContentBodyProps>;
9
10
  export { DialogContentBody };
@@ -1,7 +1,41 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.DialogContentBody = void 0;
4
37
  var jsx_runtime_1 = require("react/jsx-runtime");
38
+ var React = __importStar(require("react"));
5
39
  var Placeholder = function (_a) {
6
40
  var dialogOptions = _a.dialogOptions, placeholder = _a.placeholder;
7
41
  var bgColor = dialogOptions.base.style.backgroundColor ?
@@ -14,17 +48,14 @@ var Placeholder = function (_a) {
14
48
  display: placeholder ? 'flex' : 'none',
15
49
  }, children: placeholder });
16
50
  };
17
- var DialogContentBody = function (_a) {
51
+ var DialogContentBody = React.forwardRef(function (_a, ref) {
18
52
  var body = _a.body, dialog = _a.dialog;
19
- console.log('DialogContentBody', dialog);
20
53
  if (body instanceof Function) {
21
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)] });
22
55
  }
23
56
  return (0, jsx_runtime_1.jsx)("div", { className: 'dialog-body', style: { height: '100%', padding: 10 }, children: dialog.holder ?
24
- // this.Placeholder(this._holder)
25
57
  (0, jsx_runtime_1.jsx)(Placeholder, { dialogOptions: dialog.dialogOptions, placeholder: dialog.holder })
26
58
  :
27
- //@ts-ignore
28
59
  body });
29
- };
60
+ });
30
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,9 +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 { IDialogBoundsDef } from "../types/BoundTypes";
4
5
  interface IContentHeaderProps {
5
- header: TDialogCallbackNodeFn;
6
+ header: TDialogCallbackFn;
6
7
  dialog: DialogBase<any>;
8
+ ref: React.RefObject<any>;
9
+ dialogRef: React.RefObject<any>;
10
+ bounds: IDialogBoundsDef;
7
11
  }
8
12
  declare const DialogContentHeader: React.FC<IContentHeaderProps>;
9
13
  export { DialogContentHeader };
@@ -10,46 +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");
19
- var DialogContentHeader = function (_a) {
50
+ var Features_1 = require("./Features");
51
+ var React = __importStar(require("react"));
52
+ var react_1 = require("react");
53
+ var helpers_1 = require("../helpers");
54
+ var context_1 = require("../context");
55
+ var DialogContentHeader = React.forwardRef(function (_a, ref) {
20
56
  var _b, _c, _d, _e;
21
- var header = _a.header, dialog = _a.dialog;
22
- var state = dialog.state, dialogOptions = dialog.dialogOptions;
23
- console.log('DialogContentHeader', dialog);
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]);
24
76
  var baseOptions = dialogOptions.base;
25
77
  var CustomHeader = (_b = dialogOptions.slot) === null || _b === void 0 ? void 0 : _b.header;
26
78
  var staticProps = {
27
- dialogValues: state.values,
28
79
  dialogOptions: dialogOptions,
29
80
  dialog: dialog
30
81
  };
31
- var headerProps = {};
32
- if (dialogOptions.slotProps.header) {
33
- headerProps = dialogOptions.slotProps.header(staticProps);
34
- }
35
82
  if (dialogOptions.slot.header) {
83
+ var headerProps = dialogOptions.slotProps.header ? __assign({}, dialogOptions.slotProps.header(staticProps)) : {};
36
84
  return (0, jsx_runtime_1.jsx)("div", { onDoubleClick: function (event) {
37
85
  var _a;
38
86
  if ((_a = dialog === null || dialog === void 0 ? void 0 : dialog.dialogOptions.base) === null || _a === void 0 ? void 0 : _a.fullscreen) {
39
- dialog.switchFullScreen();
87
+ setFullscreen(!fullscreen);
40
88
  }
41
- }, 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)(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 })) }) });
42
90
  }
43
91
  if (header instanceof Function) {
44
92
  return (0, jsx_runtime_1.jsxs)("div", { onDoubleClick: function (event) {
45
93
  if (baseOptions.fullscreen) {
46
- 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();
47
100
  }
48
- }, 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: [header(dialog), (baseOptions.closeable || baseOptions.fullscreen) &&
49
- (0, jsx_runtime_1.jsx)(DialogBase_1.WithHeaderFooterContext, { dialog: dialog, children: (0, jsx_runtime_1.jsxs)(Futures_1.DialogHeaderActionsWrapper, { children: [baseOptions.fullscreen &&
50
- (0, jsx_runtime_1.jsx)(Futures_1.DialogFullscreenAction, {}), baseOptions.closeable &&
51
- (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, {})] }) })] });
52
106
  }
53
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 });
54
- };
108
+ });
55
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;
@@ -0,0 +1,24 @@
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.DialogFullscreenAction = void 0;
7
+ var jsx_runtime_1 = require("react/jsx-runtime");
8
+ var FullscreenExitIcon_1 = __importDefault(require("../icons/FullscreenExitIcon"));
9
+ var FullscreenIcon_1 = __importDefault(require("../icons/FullscreenIcon"));
10
+ var react_1 = require("react");
11
+ var context_1 = require("../../context");
12
+ var helpers_1 = require("../../helpers");
13
+ var DialogFullscreenAction = function () {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h;
15
+ var _j = (0, react_1.useContext)(context_1.DialogHeaderFooterContext), dialog = _j.dialog, setFullscreen = _j.setFullscreen, fullscreen = _j.fullscreen;
16
+ return (0, jsx_runtime_1.jsx)("div", { className: 'fullscreen-icon-wrapper', onClick: function (event) {
17
+ setFullscreen(!fullscreen);
18
+ (0, helpers_1.setDialogBound)(dialog.dialogOptions.base.id, "fullscreen", !fullscreen);
19
+ }, children: fullscreen ?
20
+ (0, jsx_runtime_1.jsx)(FullscreenExitIcon_1.default, { size: (_b = (_a = dialog.dialogOptions.base.headerControllerIcons) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : 24, color: (_d = (_c = dialog.dialogOptions.base.headerControllerIcons) === null || _c === void 0 ? void 0 : _c.color) !== null && _d !== void 0 ? _d : null })
21
+ :
22
+ (0, jsx_runtime_1.jsx)(FullscreenIcon_1.default, { size: (_f = (_e = dialog.dialogOptions.base.headerControllerIcons) === null || _e === void 0 ? void 0 : _e.size) !== null && _f !== void 0 ? _f : 24, color: (_h = (_g = dialog.dialogOptions.base.headerControllerIcons) === null || _g === void 0 ? void 0 : _g.color) !== null && _h !== void 0 ? _h : null }) });
23
+ };
24
+ exports.DialogFullscreenAction = DialogFullscreenAction;