react-dialogger 1.1.59 → 1.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Actions.js +3 -2
- package/components/DialogActionBase.d.ts +14 -0
- package/components/DialogActionBase.js +19 -2
- package/components/DialogWithBackdropWrapper.js +1 -1
- package/components/RippleButton.js +17 -9
- package/helpers/Colorify.d.ts +8 -0
- package/helpers/Colorify.js +76 -0
- package/helpers/index.d.ts +1 -1
- package/helpers/index.js +3 -3
- package/models/DialogAction.d.ts +9 -17
- package/models/DialogAction.js +11 -17
- package/models/baseDialogOptions.js +17 -1
- package/package.json +1 -1
- package/types/DialogActionTypes.d.ts +7 -3
- package/types/DialogTypes.d.ts +3 -3
- package/helpers/hexToRgb.d.ts +0 -5
- package/helpers/hexToRgb.js +0 -31
package/components/Actions.js
CHANGED
|
@@ -18,13 +18,14 @@ var Actions = function (_a) {
|
|
|
18
18
|
var actions = _a.actions, dialog = _a.dialog;
|
|
19
19
|
var dialogOptions = dialog.dialogOptions;
|
|
20
20
|
return (0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', display: 'flex', flexDirection: 'row', columnGap: 10, alignItems: 'center' }, children: actions.map(function (action, index) {
|
|
21
|
-
console.log('Actions_action', __assign(__assign({}, action.options), action.
|
|
21
|
+
console.log('Actions_action', __assign(__assign({}, action.options), action.intent));
|
|
22
22
|
var referencedAction = dialog.initializeActionRef(action.name);
|
|
23
|
+
action._actionComponent = referencedAction;
|
|
23
24
|
return (0, jsx_runtime_1.jsx)(_components_1.DialogActionBase, { name: action.name, ref: referencedAction, dialogBaseComponent: dialog,
|
|
24
25
|
//onClick={ action.onClickHandler() }
|
|
25
26
|
onClick: action._onCLick,
|
|
26
27
|
// inProcess={action.isInProcess()}
|
|
27
|
-
style: action.options.style, baseStyle: dialogOptions.base.actions.baseStyle, fontFamily: dialogOptions.base.style.fontFamily, stateListener: action._stateListener, options: action.options, intent: action.
|
|
28
|
+
style: action.options.style, baseStyle: dialogOptions.base.actions.baseStyle, fontFamily: dialogOptions.base.style.fontFamily, stateListener: action._stateListener, options: action.options, intent: action.intent() }, index.toString());
|
|
28
29
|
}) });
|
|
29
30
|
};
|
|
30
31
|
exports.Actions = Actions;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { Component } from "react";
|
|
2
2
|
import { DialogBase } from "./index.js";
|
|
3
3
|
import { ActionProps, ActionState, DialogActionType, TBVariant, TBColor, DialogActionOptionsType, TDialogStateListenerForActionCallbackType, ActionIntent } from "../types/index.js";
|
|
4
|
+
export declare const BASE_INTENTS: {
|
|
5
|
+
readonly positive: {
|
|
6
|
+
readonly color: "primary";
|
|
7
|
+
readonly variant: "contained";
|
|
8
|
+
};
|
|
9
|
+
readonly negative: {
|
|
10
|
+
readonly color: "error";
|
|
11
|
+
readonly variant: "contained";
|
|
12
|
+
};
|
|
13
|
+
readonly neutral: {
|
|
14
|
+
readonly variant: "text";
|
|
15
|
+
readonly color: "primary";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
4
18
|
declare class DialogActionBase extends Component<ActionProps, ActionState> {
|
|
5
19
|
get dialogBaseComponent(): DialogBase<any>;
|
|
6
20
|
protected _options: DialogActionOptionsType;
|
|
@@ -59,10 +59,25 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
59
59
|
};
|
|
60
60
|
})();
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.BASE_INTENTS = void 0;
|
|
62
63
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
63
64
|
var react_1 = require("react");
|
|
64
65
|
var React = __importStar(require("react"));
|
|
65
66
|
var _components_1 = require("./index.js");
|
|
67
|
+
exports.BASE_INTENTS = {
|
|
68
|
+
positive: {
|
|
69
|
+
color: 'primary',
|
|
70
|
+
variant: 'contained',
|
|
71
|
+
},
|
|
72
|
+
negative: {
|
|
73
|
+
color: 'error',
|
|
74
|
+
variant: 'contained',
|
|
75
|
+
},
|
|
76
|
+
neutral: {
|
|
77
|
+
variant: 'text',
|
|
78
|
+
color: 'primary',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
66
81
|
var DialogActionBase = /** @class */ (function (_super) {
|
|
67
82
|
__extends(DialogActionBase, _super);
|
|
68
83
|
function DialogActionBase(props) {
|
|
@@ -203,11 +218,13 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
203
218
|
_this._inProcess = props.inProcess;
|
|
204
219
|
var converted = (_b = (_a = props.name) === null || _a === void 0 ? void 0 : _a.replace(/action/i, '')) !== null && _b !== void 0 ? _b : props.name;
|
|
205
220
|
var label = (_g = ((_f = (_e = (_d = (_c = _this.props.dialogBaseComponent) === null || _c === void 0 ? void 0 : _c.dialogOptions) === null || _d === void 0 ? void 0 : _d.localText) === null || _e === void 0 ? void 0 : _e[converted]) !== null && _f !== void 0 ? _f : converted)) !== null && _g !== void 0 ? _g : 'Button';
|
|
221
|
+
var initialIntents = props.dialogBaseComponent.dialogOptions.base.actions.initialIntents;
|
|
222
|
+
var mergedIntents = __assign(__assign({}, exports.BASE_INTENTS), initialIntents);
|
|
206
223
|
_this.state = {
|
|
207
224
|
coords: { x: -1, y: -1 },
|
|
208
225
|
isRippling: false,
|
|
209
226
|
// intent: props.intent,
|
|
210
|
-
options: __assign(__assign(__assign({}, props.options), props.intent), { label: label }),
|
|
227
|
+
options: __assign(__assign(__assign({}, props.options), mergedIntents[props.intent]), { label: label }),
|
|
211
228
|
inProcess: false
|
|
212
229
|
};
|
|
213
230
|
_this._buttonRef = React.createRef();
|
|
@@ -245,7 +262,7 @@ var DialogActionBase = /** @class */ (function (_super) {
|
|
|
245
262
|
configurable: true
|
|
246
263
|
});
|
|
247
264
|
DialogActionBase.prototype.updateOptions = function (options) {
|
|
248
|
-
this.setState(function (prevState) { return (__assign(__assign({}, prevState), { options: options })); });
|
|
265
|
+
this.setState(function (prevState) { return (__assign(__assign({}, prevState), { options: __assign(__assign({}, prevState.options), options) })); });
|
|
249
266
|
// this._options = {...this._options, ...options};
|
|
250
267
|
// this.forceUpdate();
|
|
251
268
|
return this;
|
|
@@ -9,7 +9,7 @@ var _context_1 = require("../context/index.js");
|
|
|
9
9
|
var DialogWithBackdropWrapper = function () {
|
|
10
10
|
var _a = (0, react_1.useContext)(_context_1.DialogContentContext), dialog = _a.dialog, backdropRef = _a.backdropRef, baseZoomEffect = _a.baseZoomEffect;
|
|
11
11
|
var _b = dialog.dialogOptions.backdrop, backgroundColor = _b.backgroundColor, opacity = _b.opacity;
|
|
12
|
-
var bgCl = (0, _helpers_1.
|
|
12
|
+
var bgCl = (0, _helpers_1.hexToRGB)(backgroundColor, opacity);
|
|
13
13
|
return (0, jsx_runtime_1.jsx)("div", { className: "dialog-backdrop dialog-backdrop-show", ref: backdropRef, style: {
|
|
14
14
|
justifyContent: dialog.dialogOptions.base.initialAnchor.horizontal,
|
|
15
15
|
// alignItems: dialogOptions.base.initialAnchor.vertical,
|
|
@@ -47,8 +47,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
47
47
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
48
48
|
var React = __importStar(require("react"));
|
|
49
49
|
var react_1 = require("react");
|
|
50
|
-
var
|
|
51
|
-
var hexToRgb_1 = require("../helpers/hexToRgb");
|
|
50
|
+
var Colorify_1 = require("../helpers/Colorify");
|
|
52
51
|
exports.default = React.forwardRef(function (_a, ref) {
|
|
53
52
|
var variant = _a.variant, color = _a.color, children = _a.children, disabled = _a.disabled, onClick = _a.onClick, style = _a.style, baseStyle = _a.baseStyle, innerRef = _a.innerRef, fontFamily = _a.fontFamily;
|
|
54
53
|
var _b = React.useState({ x: -1, y: -1 }), coords = _b[0], setCoords = _b[1];
|
|
@@ -80,16 +79,25 @@ exports.default = React.forwardRef(function (_a, ref) {
|
|
|
80
79
|
}); });
|
|
81
80
|
var namedColors = ["primary", "success", "error", "warning", "info", "secondary", "default"];
|
|
82
81
|
var isNamedColor = namedColors.includes(color);
|
|
83
|
-
var
|
|
82
|
+
var hexedColor = null;
|
|
83
|
+
var exclusive = {};
|
|
84
84
|
if (!isNamedColor) {
|
|
85
85
|
// Like Yellow
|
|
86
|
-
|
|
87
|
-
if (!(0,
|
|
88
|
-
|
|
86
|
+
hexedColor = color;
|
|
87
|
+
if (!(0, Colorify_1.isHexColor)(hexedColor)) {
|
|
88
|
+
hexedColor = (0, Colorify_1.colorNameToHex)(hexedColor);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
exclusive = (0, Colorify_1.getButtonColors)(hexedColor);
|
|
91
|
+
// textColor = getLuminance(hexedColor);
|
|
92
|
+
// bgColor = hexToRGB(hexedColor, disabled ? .5 : 1);
|
|
93
|
+
//
|
|
94
|
+
// exclusive.color = textColor;
|
|
95
|
+
// exclusive.backgroundColor = bgColor;
|
|
96
|
+
console.log('Button_exclusive', exclusive, hexedColor);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
exclusive = null;
|
|
91
100
|
}
|
|
92
|
-
console.log('Ripple_button_style', localColor);
|
|
93
101
|
return ((0, jsx_runtime_1.jsxs)("button", { ref: ref, disabled: disabled, className: "ripple-button ripple-button-".concat(variant, " ripple-button-").concat(color, " ").concat(disabled ? 'ripple-button-disabled' : ''), onClick: function (e) {
|
|
94
102
|
//@ts-ignore
|
|
95
103
|
var rect = e.target.getBoundingClientRect();
|
|
@@ -97,5 +105,5 @@ exports.default = React.forwardRef(function (_a, ref) {
|
|
|
97
105
|
setTimeout(function () {
|
|
98
106
|
onClick && onClick(e);
|
|
99
107
|
}, 200);
|
|
100
|
-
}, style: __assign(__assign(__assign(__assign(__assign({}, baseStyle), style), { fontFamily: fontFamily }),
|
|
108
|
+
}, style: __assign(__assign(__assign(__assign(__assign({}, baseStyle), style), { fontFamily: fontFamily }), exclusive), variant === 'text' ? { border: "none" } : null), children: [isRippling && (0, jsx_runtime_1.jsx)("span", { className: "ripple", style: { left: coords.x, top: coords.y } }), (0, jsx_runtime_1.jsx)("span", { className: "content", children: children(ref.current) })] }));
|
|
101
109
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
declare const hexToRGB: (hex: string, opacity: number) => string;
|
|
3
|
+
export type HexColor = `#${string}`;
|
|
4
|
+
declare function isHexColor(color: string): color is HexColor;
|
|
5
|
+
declare function colorNameToHex(colorName: string): string | null;
|
|
6
|
+
declare function getLuminance(hex: string): number;
|
|
7
|
+
declare const getButtonColors: (hex: string) => Pick<CSSProperties, "color" | "backgroundColor">;
|
|
8
|
+
export { hexToRGB, colorNameToHex, isHexColor, getLuminance, getButtonColors };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getButtonColors = exports.hexToRGB = void 0;
|
|
4
|
+
exports.colorNameToHex = colorNameToHex;
|
|
5
|
+
exports.isHexColor = isHexColor;
|
|
6
|
+
exports.getLuminance = getLuminance;
|
|
7
|
+
var hexToRGB = function (hex, opacity) {
|
|
8
|
+
try {
|
|
9
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
10
|
+
var colors = {
|
|
11
|
+
r: parseInt(result[1], 16),
|
|
12
|
+
g: parseInt(result[2], 16),
|
|
13
|
+
b: parseInt(result[3], 16)
|
|
14
|
+
};
|
|
15
|
+
return "rgba(".concat(colors.r, ", ").concat(colors.g, ", ").concat(colors.b, ", ").concat(opacity, ")");
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.warn('Color should be hex string', e.message);
|
|
19
|
+
}
|
|
20
|
+
return '';
|
|
21
|
+
};
|
|
22
|
+
exports.hexToRGB = hexToRGB;
|
|
23
|
+
function isHexColor(color) {
|
|
24
|
+
return /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color);
|
|
25
|
+
}
|
|
26
|
+
function colorNameToHex(colorName) {
|
|
27
|
+
var ctx = document.createElement("canvas").getContext("2d");
|
|
28
|
+
if (!ctx)
|
|
29
|
+
return null;
|
|
30
|
+
ctx.fillStyle = colorName;
|
|
31
|
+
return ctx.fillStyle; // canvas, renk ismini hex'e çevirir
|
|
32
|
+
}
|
|
33
|
+
function getLuminance(hex) {
|
|
34
|
+
var rgb = hex.replace("#", "").match(/.{2}/g).map(function (v) { return parseInt(v, 16) / 255; });
|
|
35
|
+
var _a = rgb.map(function (c) {
|
|
36
|
+
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
37
|
+
}), r = _a[0], g = _a[1], b = _a[2];
|
|
38
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
39
|
+
}
|
|
40
|
+
function normalizeHex(hex) {
|
|
41
|
+
if (hex.length === 4) {
|
|
42
|
+
// #fff -> #ffffff
|
|
43
|
+
return "#" + hex.slice(1).split("").map(function (c) { return c + c; }).join("");
|
|
44
|
+
}
|
|
45
|
+
return hex;
|
|
46
|
+
}
|
|
47
|
+
function adjustColor(hex, amount) {
|
|
48
|
+
var rgb = normalizeHex(hex)
|
|
49
|
+
.replace("#", "")
|
|
50
|
+
.match(/.{2}/g)
|
|
51
|
+
.map(function (v) { return parseInt(v, 16); });
|
|
52
|
+
var adjusted = rgb.map(function (v) {
|
|
53
|
+
return Math.min(255, Math.max(0, v + amount));
|
|
54
|
+
});
|
|
55
|
+
return "#".concat(adjusted.map(function (v) { return v.toString(16).padStart(2, "0"); }).join(""));
|
|
56
|
+
}
|
|
57
|
+
var getButtonColors = function (hex) {
|
|
58
|
+
if (!isHexColor(hex)) {
|
|
59
|
+
console.warn("getButtonColors: invalid hex color", hex);
|
|
60
|
+
return { backgroundColor: "#ccc", color: "#000" };
|
|
61
|
+
}
|
|
62
|
+
var normalized = normalizeHex(hex);
|
|
63
|
+
var lum = getLuminance(normalized);
|
|
64
|
+
// const backgroundColor =
|
|
65
|
+
// lum > 0.5
|
|
66
|
+
// ? adjustColor(normalized, -120) // açık → koyu
|
|
67
|
+
// : adjustColor(normalized, 120); // koyu → açık
|
|
68
|
+
var backgroundColor = normalized;
|
|
69
|
+
var color = getLuminance(backgroundColor) > 0.5 ? "#000" : "#fff";
|
|
70
|
+
// const color =
|
|
71
|
+
// lum > 0.5
|
|
72
|
+
// ? adjustColor(normalized, -120) // açık → koyu
|
|
73
|
+
// : adjustColor(normalized, 120); // koyu → açık
|
|
74
|
+
return { backgroundColor: backgroundColor, color: color };
|
|
75
|
+
};
|
|
76
|
+
exports.getButtonColors = getButtonColors;
|
package/helpers/index.d.ts
CHANGED
package/helpers/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.hexToRGB = exports.dialogRectAuto = exports.formInputKeyListeners = exports.registeredDialogs = exports.InitDialogMemoizeBoundsDeclared = exports.InitDialogMemoizeBounds = void 0;
|
|
18
18
|
var initDialogMemoizeBounds_1 = require("./initDialogMemoizeBounds");
|
|
19
19
|
Object.defineProperty(exports, "InitDialogMemoizeBounds", { enumerable: true, get: function () { return initDialogMemoizeBounds_1.InitDialogMemoizeBounds; } });
|
|
20
20
|
Object.defineProperty(exports, "InitDialogMemoizeBoundsDeclared", { enumerable: true, get: function () { return initDialogMemoizeBounds_1.InitDialogMemoizeBoundsDeclared; } });
|
|
@@ -25,5 +25,5 @@ Object.defineProperty(exports, "formInputKeyListeners", { enumerable: true, get:
|
|
|
25
25
|
__exportStar(require("./Resizeable"), exports);
|
|
26
26
|
var dialogRectAuto_1 = require("./dialogRectAuto");
|
|
27
27
|
Object.defineProperty(exports, "dialogRectAuto", { enumerable: true, get: function () { return dialogRectAuto_1.dialogRectAuto; } });
|
|
28
|
-
var
|
|
29
|
-
Object.defineProperty(exports, "
|
|
28
|
+
var Colorify_1 = require("./Colorify");
|
|
29
|
+
Object.defineProperty(exports, "hexToRGB", { enumerable: true, get: function () { return Colorify_1.hexToRGB; } });
|
package/models/DialogAction.d.ts
CHANGED
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
import type { TDialogStateListenerForActionCallbackType, DialogActionOptionsType, DialogActionType
|
|
1
|
+
import type { TDialogStateListenerForActionCallbackType, DialogActionOptionsType, DialogActionType } from "../types/index.js";
|
|
2
|
+
import { DialogActionBase } from "../components/index.js";
|
|
3
|
+
import { RefObject } from "react";
|
|
4
|
+
import { ActionIntentsType } from "../types/index.js";
|
|
2
5
|
declare const ActionProgress: () => import("react/jsx-runtime").JSX.Element;
|
|
3
6
|
export { ActionProgress };
|
|
4
|
-
export declare const ACTION_INTENTS: {
|
|
5
|
-
readonly positive: {
|
|
6
|
-
readonly color: "primary";
|
|
7
|
-
readonly variant: "contained";
|
|
8
|
-
};
|
|
9
|
-
readonly negative: {
|
|
10
|
-
readonly color: "error";
|
|
11
|
-
readonly variant: "contained";
|
|
12
|
-
};
|
|
13
|
-
readonly neutral: {
|
|
14
|
-
readonly variant: "text";
|
|
15
|
-
readonly color: "primary";
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
7
|
declare class DialogAction {
|
|
19
8
|
private readonly _name;
|
|
20
9
|
private _options;
|
|
21
10
|
private _intent;
|
|
22
11
|
_onCLick: DialogActionType;
|
|
23
12
|
_stateListener: TDialogStateListenerForActionCallbackType;
|
|
13
|
+
_actionComponent: RefObject<DialogActionBase>;
|
|
24
14
|
constructor(name: string, options?: DialogActionOptionsType);
|
|
25
15
|
get name(): string;
|
|
26
|
-
setIntent(intent:
|
|
27
|
-
|
|
16
|
+
setIntent(intent: ActionIntentsType): this;
|
|
17
|
+
intent(): ActionIntentsType;
|
|
18
|
+
setInProcess: (inProcess: boolean) => this;
|
|
19
|
+
setDisabled: (disabled: boolean) => this;
|
|
28
20
|
setOptions: (options: DialogActionOptionsType) => this;
|
|
29
21
|
get options(): DialogActionOptionsType;
|
|
30
22
|
onClick: (callback: DialogActionType) => this;
|
package/models/DialogAction.js
CHANGED
|
@@ -11,31 +11,25 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.DialogAction = exports.
|
|
14
|
+
exports.DialogAction = exports.ActionProgress = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var _components_1 = require("../components/index.js");
|
|
17
17
|
var ActionProgress = function () {
|
|
18
18
|
return (0, jsx_runtime_1.jsx)(_components_1.CircularProgress, { size: 20, inProcess: { inProcess: true } });
|
|
19
19
|
};
|
|
20
20
|
exports.ActionProgress = ActionProgress;
|
|
21
|
-
exports.ACTION_INTENTS = {
|
|
22
|
-
positive: {
|
|
23
|
-
color: 'primary',
|
|
24
|
-
variant: 'contained',
|
|
25
|
-
},
|
|
26
|
-
negative: {
|
|
27
|
-
color: 'error',
|
|
28
|
-
variant: 'contained',
|
|
29
|
-
},
|
|
30
|
-
neutral: {
|
|
31
|
-
variant: 'text',
|
|
32
|
-
color: 'primary',
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
21
|
// class DialogAction extends DialogActionBase {
|
|
36
22
|
var DialogAction = /** @class */ (function () {
|
|
37
23
|
function DialogAction(name, options) {
|
|
38
24
|
var _this = this;
|
|
25
|
+
this.setInProcess = function (inProcess) {
|
|
26
|
+
_this._actionComponent.current.setInProcess(inProcess);
|
|
27
|
+
return _this;
|
|
28
|
+
};
|
|
29
|
+
this.setDisabled = function (disabled) {
|
|
30
|
+
_this._actionComponent.current.setDisabled(disabled);
|
|
31
|
+
return _this;
|
|
32
|
+
};
|
|
39
33
|
this.setOptions = function (options) {
|
|
40
34
|
_this._options = options;
|
|
41
35
|
return _this;
|
|
@@ -71,10 +65,10 @@ var DialogAction = /** @class */ (function () {
|
|
|
71
65
|
configurable: true
|
|
72
66
|
});
|
|
73
67
|
DialogAction.prototype.setIntent = function (intent) {
|
|
74
|
-
this._intent =
|
|
68
|
+
this._intent = intent; // ACTION_INTENTS[intent];
|
|
75
69
|
return this;
|
|
76
70
|
};
|
|
77
|
-
DialogAction.prototype.
|
|
71
|
+
DialogAction.prototype.intent = function () {
|
|
78
72
|
return this._intent;
|
|
79
73
|
};
|
|
80
74
|
Object.defineProperty(DialogAction.prototype, "options", {
|
|
@@ -43,7 +43,23 @@ var BASE_DIALOG_OPTIONS = {
|
|
|
43
43
|
about: false,
|
|
44
44
|
initialAnchor: { vertical: "flex-start", horizontal: "center" },
|
|
45
45
|
draggable: false,
|
|
46
|
-
size: { width: 'min-content', height: 300 }
|
|
46
|
+
size: { width: 'min-content', height: 300 },
|
|
47
|
+
actions: {
|
|
48
|
+
initialIntents: {
|
|
49
|
+
positive: {
|
|
50
|
+
color: 'primary',
|
|
51
|
+
variant: 'contained'
|
|
52
|
+
},
|
|
53
|
+
negative: {
|
|
54
|
+
color: 'error',
|
|
55
|
+
variant: 'contained'
|
|
56
|
+
},
|
|
57
|
+
neutral: {
|
|
58
|
+
color: 'default',
|
|
59
|
+
variant: "text"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
47
63
|
},
|
|
48
64
|
animate: 'none',
|
|
49
65
|
progress: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-dialogger",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.65",
|
|
4
4
|
"description": "This package is a continuation of the react-araci package. Due to an error, react-araci was removed, and it has been decided to continue under the new package name react-dialogger",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Sueleyman Topaloglu",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IDialogApiDef, IListenerDialogDef, TValues, ICoords } from "./index.js";
|
|
2
2
|
import { DialogBase, DialogActionBase } from "../components/index.js";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { DialogAction
|
|
4
|
+
import { DialogAction } from "../models/index.js";
|
|
5
5
|
import { CSSProperties } from "react";
|
|
6
6
|
export type ActionDialogDef = Omit<IDialogApiDef, 'switchFullScreen'>;
|
|
7
7
|
export type ActionDef = Pick<DialogAction, 'onClick' | 'setOptions' | 'name'>;
|
|
@@ -43,7 +43,7 @@ export interface ActionProps {
|
|
|
43
43
|
baseStyle?: CSSProperties;
|
|
44
44
|
fontFamily?: string;
|
|
45
45
|
stateListener?: TDialogStateListenerForActionCallbackType;
|
|
46
|
-
intent:
|
|
46
|
+
intent: ActionIntentsType;
|
|
47
47
|
}
|
|
48
48
|
export interface ActionState {
|
|
49
49
|
isRippling: boolean;
|
|
@@ -70,7 +70,11 @@ export interface DialogContentFooterReturnType {
|
|
|
70
70
|
setProcessing: React.Dispatch<React.SetStateAction<boolean>>;
|
|
71
71
|
inProcess: boolean;
|
|
72
72
|
}
|
|
73
|
-
export
|
|
73
|
+
export interface IActionIntents {
|
|
74
|
+
positive?: ActionIntent;
|
|
75
|
+
negative?: ActionIntent;
|
|
76
|
+
neutral?: ActionIntent;
|
|
77
|
+
}
|
|
74
78
|
export type ActionIntentsType = "positive" | "negative" | "neutral";
|
|
75
79
|
export interface ActionIntent extends Partial<Pick<DialogActionOptionsType, 'variant' | 'color'>> {
|
|
76
80
|
}
|
package/types/DialogTypes.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { DialogBase } from "../components/index.js";
|
|
|
5
5
|
import type { FormikProps } from "formik";
|
|
6
6
|
import type { RefObject } from "react";
|
|
7
7
|
import { Resizeable } from "../helpers/index.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { DialogContentFooterReturnType, IActionIntents } from "./DialogActionTypes";
|
|
9
9
|
import { SnackbarKey, VariantType } from "notistack";
|
|
10
10
|
export interface TBaseDialogState {
|
|
11
11
|
[K: string]: any;
|
|
@@ -68,9 +68,8 @@ interface IDialogOptionsType {
|
|
|
68
68
|
busyMessage?: string;
|
|
69
69
|
[k: string]: any;
|
|
70
70
|
};
|
|
71
|
-
actionsIntents?: ActionIntentsType;
|
|
72
71
|
}
|
|
73
|
-
export type DialogOptionsType = Partial<Pick<IDialogOptionsType, 'base' | 'snackbar' | 'backdrop' | 'slotProps' | 'slot' | 'animate' | 'progress' | 'localText'
|
|
72
|
+
export type DialogOptionsType = Partial<Pick<IDialogOptionsType, 'base' | 'snackbar' | 'backdrop' | 'slotProps' | 'slot' | 'animate' | 'progress' | 'localText'>>;
|
|
74
73
|
interface kSlot {
|
|
75
74
|
action?: React.JSXElementConstructor<any>;
|
|
76
75
|
footer?: React.JSXElementConstructor<any>;
|
|
@@ -108,6 +107,7 @@ export interface IBaseDialogOptions {
|
|
|
108
107
|
actions?: {
|
|
109
108
|
disabledOnDialogProcessing?: boolean;
|
|
110
109
|
baseStyle?: React.CSSProperties;
|
|
110
|
+
initialIntents?: IActionIntents;
|
|
111
111
|
};
|
|
112
112
|
headerControllerIcons?: {
|
|
113
113
|
size?: number;
|
package/helpers/hexToRgb.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare const hexToRgb: (hex: string, opacity: number) => string;
|
|
2
|
-
export type HexColor = `#${string}`;
|
|
3
|
-
declare function isHexColor(color: string): color is HexColor;
|
|
4
|
-
declare function colorNameToHex(colorName: string): string | null;
|
|
5
|
-
export { hexToRgb, colorNameToHex, isHexColor };
|
package/helpers/hexToRgb.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hexToRgb = void 0;
|
|
4
|
-
exports.colorNameToHex = colorNameToHex;
|
|
5
|
-
exports.isHexColor = isHexColor;
|
|
6
|
-
var hexToRgb = function (hex, opacity) {
|
|
7
|
-
try {
|
|
8
|
-
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
9
|
-
var colors = {
|
|
10
|
-
r: parseInt(result[1], 16),
|
|
11
|
-
g: parseInt(result[2], 16),
|
|
12
|
-
b: parseInt(result[3], 16)
|
|
13
|
-
};
|
|
14
|
-
return "rgba(".concat(colors.r, ", ").concat(colors.g, ", ").concat(colors.b, ", ").concat(opacity, ")");
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.warn('Color should be hex string', e.message);
|
|
18
|
-
}
|
|
19
|
-
return '';
|
|
20
|
-
};
|
|
21
|
-
exports.hexToRgb = hexToRgb;
|
|
22
|
-
function isHexColor(color) {
|
|
23
|
-
return /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color);
|
|
24
|
-
}
|
|
25
|
-
function colorNameToHex(colorName) {
|
|
26
|
-
var ctx = document.createElement("canvas").getContext("2d");
|
|
27
|
-
if (!ctx)
|
|
28
|
-
return null;
|
|
29
|
-
ctx.fillStyle = colorName;
|
|
30
|
-
return ctx.fillStyle; // canvas, renk ismini hex'e çevirir
|
|
31
|
-
}
|