@progress/kendo-react-inputs 5.6.0-next.202208310638 → 5.6.0-next.202208311110
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/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/dist/es/colors/ColorPalette.d.ts +1 -1
- package/dist/es/main.d.ts +2 -0
- package/dist/es/main.js +2 -0
- package/dist/es/maskedtextbox/MaskedTextBox.d.ts +1 -1
- package/dist/es/messages/index.d.ts +15 -0
- package/dist/es/messages/index.js +15 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/signature/Signature.d.ts +14 -0
- package/dist/es/signature/Signature.js +346 -0
- package/dist/es/signature/interfaces/SignatureBlurEvent.d.ts +7 -0
- package/dist/es/signature/interfaces/SignatureBlurEvent.js +1 -0
- package/dist/es/signature/interfaces/SignatureChangeEvent.d.ts +11 -0
- package/dist/es/signature/interfaces/SignatureChangeEvent.js +1 -0
- package/dist/es/signature/interfaces/SignatureCloseEvent.d.ts +7 -0
- package/dist/es/signature/interfaces/SignatureCloseEvent.js +1 -0
- package/dist/es/signature/interfaces/SignatureFocusEvent.d.ts +7 -0
- package/dist/es/signature/interfaces/SignatureFocusEvent.js +1 -0
- package/dist/es/signature/interfaces/SignatureHandle.d.ts +34 -0
- package/dist/es/signature/interfaces/SignatureHandle.js +1 -0
- package/dist/es/signature/interfaces/SignatureOpenEvent.d.ts +7 -0
- package/dist/es/signature/interfaces/SignatureOpenEvent.js +1 -0
- package/dist/es/signature/interfaces/SignatureProps.d.ts +196 -0
- package/dist/es/signature/interfaces/SignatureProps.js +1 -0
- package/dist/es/signature/interfaces/index.d.ts +7 -0
- package/dist/es/signature/interfaces/index.js +1 -0
- package/dist/es/signature/utils/index.d.ts +4 -0
- package/dist/es/signature/utils/index.js +10 -0
- package/dist/npm/colors/ColorPalette.d.ts +1 -1
- package/dist/npm/main.d.ts +2 -0
- package/dist/npm/main.js +2 -0
- package/dist/npm/maskedtextbox/MaskedTextBox.d.ts +1 -1
- package/dist/npm/messages/index.d.ts +15 -0
- package/dist/npm/messages/index.js +16 -1
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/signature/Signature.d.ts +14 -0
- package/dist/npm/signature/Signature.js +349 -0
- package/dist/npm/signature/interfaces/SignatureBlurEvent.d.ts +7 -0
- package/dist/npm/signature/interfaces/SignatureBlurEvent.js +2 -0
- package/dist/npm/signature/interfaces/SignatureChangeEvent.d.ts +11 -0
- package/dist/npm/signature/interfaces/SignatureChangeEvent.js +2 -0
- package/dist/npm/signature/interfaces/SignatureCloseEvent.d.ts +7 -0
- package/dist/npm/signature/interfaces/SignatureCloseEvent.js +2 -0
- package/dist/npm/signature/interfaces/SignatureFocusEvent.d.ts +7 -0
- package/dist/npm/signature/interfaces/SignatureFocusEvent.js +2 -0
- package/dist/npm/signature/interfaces/SignatureHandle.d.ts +34 -0
- package/dist/npm/signature/interfaces/SignatureHandle.js +2 -0
- package/dist/npm/signature/interfaces/SignatureOpenEvent.d.ts +7 -0
- package/dist/npm/signature/interfaces/SignatureOpenEvent.js +2 -0
- package/dist/npm/signature/interfaces/SignatureProps.d.ts +196 -0
- package/dist/npm/signature/interfaces/SignatureProps.js +2 -0
- package/dist/npm/signature/interfaces/index.d.ts +7 -0
- package/dist/npm/signature/interfaces/index.js +2 -0
- package/dist/npm/signature/utils/index.d.ts +4 -0
- package/dist/npm/signature/utils/index.js +14 -0
- package/dist/systemjs/kendo-react-inputs.js +1 -1
- package/package.json +19 -15
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.Signature = exports.SignaturePropsContext = void 0;
|
|
51
|
+
var kendo_inputs_common_1 = require("@progress/kendo-inputs-common");
|
|
52
|
+
var kendo_react_buttons_1 = require("@progress/kendo-react-buttons");
|
|
53
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
54
|
+
var kendo_react_common_2 = require("@progress/kendo-react-common");
|
|
55
|
+
var kendo_react_dialogs_1 = require("@progress/kendo-react-dialogs");
|
|
56
|
+
var kendo_react_intl_1 = require("@progress/kendo-react-intl");
|
|
57
|
+
var PropTypes = require("prop-types");
|
|
58
|
+
var React = require("react");
|
|
59
|
+
var messages_1 = require("../messages");
|
|
60
|
+
var package_metadata_1 = require("../package-metadata");
|
|
61
|
+
var utils_1 = require("./utils");
|
|
62
|
+
var DEFAULT_WIDTH = 250;
|
|
63
|
+
var DEFAULT_HEIGHT = 84;
|
|
64
|
+
var DEFAULT_POPUP_SCALE = 3;
|
|
65
|
+
var DEFAULT_EXPORT_SCALE = 2;
|
|
66
|
+
/**
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
69
|
+
var isControlled = function (prop) {
|
|
70
|
+
return prop !== undefined;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Represents the PropsContext of the `Signature` component.
|
|
74
|
+
* Used for global configuration of all `Signature` instances.
|
|
75
|
+
*
|
|
76
|
+
* For more information, refer to the [Inputs Props Context]({% slug props-context_inputs %}) article.
|
|
77
|
+
*/
|
|
78
|
+
exports.SignaturePropsContext = (0, kendo_react_common_1.createPropsContext)();
|
|
79
|
+
/**
|
|
80
|
+
* Represents the [KendoReact Signature component]({% slug overview_signature %}).
|
|
81
|
+
*/
|
|
82
|
+
exports.Signature = React.forwardRef(function (directProps, target) {
|
|
83
|
+
var _a;
|
|
84
|
+
(0, kendo_react_common_2.validatePackage)(package_metadata_1.packageMetadata);
|
|
85
|
+
var props = (0, kendo_react_common_1.usePropsContext)(exports.SignaturePropsContext, directProps);
|
|
86
|
+
var localizationService = (0, kendo_react_intl_1.useLocalization)();
|
|
87
|
+
var elementRef = React.useRef(null);
|
|
88
|
+
var canvasRef = React.useRef(null);
|
|
89
|
+
var dialogRef = React.useRef(null);
|
|
90
|
+
var _b = React.useState(), instance = _b[0], setInstance = _b[1];
|
|
91
|
+
var _c = React.useState(false), focused = _c[0], setFocused = _c[1];
|
|
92
|
+
var _d = React.useState(false), isDrawing = _d[0], setIsDrawing = _d[1];
|
|
93
|
+
var _e = React.useState(), stateValue = _e[0], setStateValue = _e[1];
|
|
94
|
+
var _f = React.useState(), popupValue = _f[0], setPopupValue = _f[1];
|
|
95
|
+
var isValueControlled = isControlled(props.value);
|
|
96
|
+
var value = isValueControlled ? props.value : stateValue;
|
|
97
|
+
var _g = React.useState(false), stateOpen = _g[0], setStateOpen = _g[1];
|
|
98
|
+
var isOpenControlled = isControlled(props.open);
|
|
99
|
+
var open = isOpenControlled ? props.open : stateOpen;
|
|
100
|
+
var showMaximize = !(props.maximized || isDrawing || !props.maximizable || props.disabled);
|
|
101
|
+
var showMinimize = props.maximized && !isDrawing;
|
|
102
|
+
var isEmpty = !(props.value || stateValue);
|
|
103
|
+
var showClear = !(isEmpty || isDrawing || props.readOnly || props.disabled);
|
|
104
|
+
var maximizeTitle = localizationService.toLanguageString(messages_1.signatureMaximize, messages_1.messages[messages_1.signatureMaximize]);
|
|
105
|
+
var minimizeTitle = localizationService.toLanguageString(messages_1.signatureMinimize, messages_1.messages[messages_1.signatureMinimize]);
|
|
106
|
+
var clearTitle = localizationService.toLanguageString(messages_1.signatureClear, messages_1.messages[messages_1.signatureClear]);
|
|
107
|
+
var onValueChange = function (nextValue) {
|
|
108
|
+
setStateValue(nextValue);
|
|
109
|
+
if (props.onChange) {
|
|
110
|
+
props.onChange({ value: nextValue });
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var onDialogChange = function (e) {
|
|
114
|
+
instance === null || instance === void 0 ? void 0 : instance.loadImage(e.value);
|
|
115
|
+
onValueChange(e.value);
|
|
116
|
+
};
|
|
117
|
+
React.useEffect(function () {
|
|
118
|
+
if (props.value !== stateValue) {
|
|
119
|
+
setStateValue(props.value);
|
|
120
|
+
instance === null || instance === void 0 ? void 0 : instance.loadImage(props.value);
|
|
121
|
+
}
|
|
122
|
+
}, [props.value]);
|
|
123
|
+
var reset = function () {
|
|
124
|
+
instance === null || instance === void 0 ? void 0 : instance.clear();
|
|
125
|
+
onValueChange();
|
|
126
|
+
};
|
|
127
|
+
var setOpen = React.useCallback(function (nextOpen) {
|
|
128
|
+
if (!isOpenControlled) {
|
|
129
|
+
setStateOpen(nextOpen);
|
|
130
|
+
}
|
|
131
|
+
}, [isOpenControlled]);
|
|
132
|
+
var onDialogClose = function (event) {
|
|
133
|
+
onMinimizeClick(event);
|
|
134
|
+
focusElement();
|
|
135
|
+
};
|
|
136
|
+
var getOptions = function () { return ({
|
|
137
|
+
scale: props.maximized ? props.popupScale : 1,
|
|
138
|
+
color: props.color,
|
|
139
|
+
backgroundColor: props.backgroundColor,
|
|
140
|
+
strokeWidth: props.strokeWidth,
|
|
141
|
+
smooth: props.smooth,
|
|
142
|
+
readonly: props.readOnly
|
|
143
|
+
}); };
|
|
144
|
+
var exportImage = function (exportSize) { return __awaiter(void 0, void 0, void 0, function () {
|
|
145
|
+
var width, height;
|
|
146
|
+
return __generator(this, function (_a) {
|
|
147
|
+
switch (_a.label) {
|
|
148
|
+
case 0:
|
|
149
|
+
width = exportSize.width, height = exportSize.height;
|
|
150
|
+
return [4 /*yield*/, (instance === null || instance === void 0 ? void 0 : instance.exportImage({
|
|
151
|
+
width: width * (props.exportScale || DEFAULT_EXPORT_SCALE),
|
|
152
|
+
height: height * (props.exportScale || DEFAULT_EXPORT_SCALE)
|
|
153
|
+
}))];
|
|
154
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); };
|
|
158
|
+
React.useEffect(function () {
|
|
159
|
+
var canvas = canvasRef.current;
|
|
160
|
+
var pad = new kendo_inputs_common_1.SignaturePad(canvas, getOptions());
|
|
161
|
+
if (value) {
|
|
162
|
+
pad.loadImage(value);
|
|
163
|
+
}
|
|
164
|
+
setInstance(pad);
|
|
165
|
+
return function () { return pad.destroy(); };
|
|
166
|
+
}, []);
|
|
167
|
+
React.useEffect(function () {
|
|
168
|
+
instance === null || instance === void 0 ? void 0 : instance.setOptions({
|
|
169
|
+
onChange: function () { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
|
|
170
|
+
switch (_b.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
_a = onValueChange;
|
|
173
|
+
return [4 /*yield*/, exportImage(elementSize())];
|
|
174
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
175
|
+
}
|
|
176
|
+
}); }); },
|
|
177
|
+
onDraw: function () { return setIsDrawing(true); },
|
|
178
|
+
onDrawEnd: function () { return setIsDrawing(false); }
|
|
179
|
+
});
|
|
180
|
+
}, [instance]);
|
|
181
|
+
React.useLayoutEffect(function () { return instance === null || instance === void 0 ? void 0 : instance.setOptions(getOptions()); }, [props.readOnly, props.color, props.backgroundColor, props.strokeWidth, props.smooth]);
|
|
182
|
+
React.useEffect(function () {
|
|
183
|
+
var _a, _b;
|
|
184
|
+
var overlay = (_b = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.querySelector('.k-overlay');
|
|
185
|
+
if (!overlay) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
var onOverlayClick = function () { return setOpen(false); };
|
|
189
|
+
overlay.addEventListener('click', onOverlayClick);
|
|
190
|
+
return function () {
|
|
191
|
+
return overlay.removeEventListener('click', onOverlayClick);
|
|
192
|
+
};
|
|
193
|
+
}, [open]);
|
|
194
|
+
var focusElement = React.useCallback(function () { var _a; return (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, []);
|
|
195
|
+
var valueGetter = React.useCallback(function () { return props.value; }, [props.value]);
|
|
196
|
+
var nameGetter = React.useCallback(function () { return props.name; }, [props.name]);
|
|
197
|
+
var requiredGetter = React.useCallback(function () { return props.required; }, [props.required]);
|
|
198
|
+
var validityGetter = React.useCallback(function () {
|
|
199
|
+
var customError = props.validationMessage !== undefined;
|
|
200
|
+
var currentValue = valueGetter();
|
|
201
|
+
var valueMissing = !currentValue;
|
|
202
|
+
var valid = props.valid !== undefined ?
|
|
203
|
+
props.valid :
|
|
204
|
+
(!requiredGetter() || !valueMissing);
|
|
205
|
+
return {
|
|
206
|
+
customError: customError,
|
|
207
|
+
valid: valid,
|
|
208
|
+
valueMissing: valueMissing
|
|
209
|
+
};
|
|
210
|
+
}, [props.validationMessage, props.valid, valueGetter, requiredGetter]);
|
|
211
|
+
var validityStylesGetter = React.useCallback(function () {
|
|
212
|
+
return props.validityStyles;
|
|
213
|
+
}, [props.validityStyles]);
|
|
214
|
+
var propsGetter = React.useCallback(function () {
|
|
215
|
+
return props;
|
|
216
|
+
}, [props]);
|
|
217
|
+
var getImperativeHandle = React.useCallback(function () {
|
|
218
|
+
var options = {
|
|
219
|
+
element: elementRef.current,
|
|
220
|
+
focus: focusElement
|
|
221
|
+
};
|
|
222
|
+
Object.defineProperty(options, 'name', { get: nameGetter });
|
|
223
|
+
Object.defineProperty(options, 'value', { get: valueGetter });
|
|
224
|
+
Object.defineProperty(options, 'validity', { get: validityGetter });
|
|
225
|
+
Object.defineProperty(options, 'validityStyles', { get: validityStylesGetter });
|
|
226
|
+
Object.defineProperty(options, 'required', { get: requiredGetter });
|
|
227
|
+
Object.defineProperty(options, 'props', { get: propsGetter });
|
|
228
|
+
return options;
|
|
229
|
+
}, [nameGetter, valueGetter, validityGetter, validityStylesGetter, requiredGetter, focusElement, propsGetter]);
|
|
230
|
+
React.useImperativeHandle(target, getImperativeHandle);
|
|
231
|
+
var onFocus = React.useCallback(function (event) {
|
|
232
|
+
if (focused || props.maximized) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
setFocused(true);
|
|
236
|
+
(0, kendo_react_common_1.dispatchEvent)(props.onFocus, event, getImperativeHandle(), {});
|
|
237
|
+
}, [focused, props.onFocus, getImperativeHandle]);
|
|
238
|
+
var onBlur = React.useCallback(function (event) {
|
|
239
|
+
var insideWrapper = (0, utils_1.hasParent)(event.relatedTarget, elementRef.current);
|
|
240
|
+
if (insideWrapper) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
setFocused(false);
|
|
244
|
+
(0, kendo_react_common_1.dispatchEvent)(props.onBlur, event, getImperativeHandle(), {});
|
|
245
|
+
}, [focused, props.onBlur, getImperativeHandle]);
|
|
246
|
+
var onMaximizeClick = React.useCallback(function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
247
|
+
var _a;
|
|
248
|
+
return __generator(this, function (_b) {
|
|
249
|
+
switch (_b.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
_a = setPopupValue;
|
|
252
|
+
return [4 /*yield*/, exportImage(popupSize())];
|
|
253
|
+
case 1:
|
|
254
|
+
_a.apply(void 0, [_b.sent()]);
|
|
255
|
+
setOpen(true);
|
|
256
|
+
(0, kendo_react_common_1.dispatchEvent)(props.onOpen, event, getImperativeHandle(), {});
|
|
257
|
+
return [2 /*return*/];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}); }, [open, isOpenControlled, props.onOpen, props.value, stateValue, getImperativeHandle]);
|
|
261
|
+
var onMinimizeClick = React.useCallback(function (event) {
|
|
262
|
+
setOpen(false);
|
|
263
|
+
(0, kendo_react_common_1.dispatchEvent)(props.onClose, event, getImperativeHandle(), {});
|
|
264
|
+
}, [open, isOpenControlled, props.onClose, getImperativeHandle]);
|
|
265
|
+
var onClear = function () {
|
|
266
|
+
reset();
|
|
267
|
+
focusElement();
|
|
268
|
+
};
|
|
269
|
+
var elementSize = function () {
|
|
270
|
+
var _a, _b;
|
|
271
|
+
var width = props.width || ((_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || DEFAULT_WIDTH;
|
|
272
|
+
var height = props.height || ((_b = elementRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) || DEFAULT_HEIGHT;
|
|
273
|
+
return {
|
|
274
|
+
width: width,
|
|
275
|
+
height: height
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
var popupSize = function () {
|
|
279
|
+
var _a = elementSize(), width = _a.width, height = _a.height;
|
|
280
|
+
var popupScale = props.popupScale || DEFAULT_POPUP_SCALE;
|
|
281
|
+
return {
|
|
282
|
+
width: width * popupScale,
|
|
283
|
+
height: height * popupScale
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
var isValid = !validityStylesGetter() || validityGetter().valid;
|
|
287
|
+
return (React.createElement("div", { ref: elementRef, dir: props.dir, style: __assign({ width: props.width, height: props.height }, props.style), className: (0, kendo_react_common_1.classNames)('k-input', 'k-signature', (_a = {
|
|
288
|
+
'k-signature-maximized': props.maximized
|
|
289
|
+
},
|
|
290
|
+
_a["k-signature-".concat(kendo_react_common_1.kendoThemeMaps.sizeMap[props.size] || props.size)] = props.size,
|
|
291
|
+
_a["k-input-".concat(props.fillMode)] = props.fillMode,
|
|
292
|
+
_a["k-rounded-".concat(kendo_react_common_1.kendoThemeMaps.roundedMap[props.rounded] || props.rounded)] = props.rounded,
|
|
293
|
+
_a['k-invalid'] = !isValid,
|
|
294
|
+
_a['k-required'] = props.required,
|
|
295
|
+
_a['k-disabled'] = props.disabled,
|
|
296
|
+
_a['k-focus'] = focused,
|
|
297
|
+
_a), props.className), onFocus: onFocus, onBlur: onBlur },
|
|
298
|
+
React.createElement("div", { className: 'k-signature-actions k-signature-actions-top' },
|
|
299
|
+
showMaximize && (React.createElement(kendo_react_buttons_1.Button, { className: 'k-signature-action k-signature-maximize', icon: 'hyperlink-open', shape: null, fillMode: 'flat', size: props.size, onClick: onMaximizeClick, "aria-label": maximizeTitle, title: maximizeTitle })),
|
|
300
|
+
showMinimize && (React.createElement(kendo_react_buttons_1.Button, { className: 'k-signature-action k-signature-minimize', icon: 'window-minimize', shape: null, fillMode: 'flat', size: props.size, onClick: onMinimizeClick, "aria-label": minimizeTitle, title: minimizeTitle }))),
|
|
301
|
+
React.createElement("div", { className: 'k-signature-canvas', ref: canvasRef, tabIndex: (0, kendo_react_common_1.getTabIndex)(props.tabIndex, props.disabled), role: "img", id: props.id, "aria-label": props.ariaLabel, "aria-labelledby": props.ariaLabelledBy, "aria-describedby": props.ariaDescribedBy, "aria-disabled": props.disabled ? 'true' : undefined }),
|
|
302
|
+
!props.hideLine && (React.createElement("div", { className: 'k-signature-line', style: { zIndex: 2, pointerEvents: 'none' } })),
|
|
303
|
+
React.createElement("div", { className: 'k-signature-actions k-signature-actions-bottom' }, showClear && (React.createElement(kendo_react_buttons_1.Button, { className: 'k-signature-action k-signature-clear', icon: 'close', shape: null, fillMode: 'flat', size: props.size, onClick: onClear, "aria-label": clearTitle, title: clearTitle }))),
|
|
304
|
+
open && (React.createElement(kendo_react_dialogs_1.Dialog, { ref: dialogRef },
|
|
305
|
+
React.createElement(exports.Signature, __assign({}, props, popupSize(), { value: popupValue, maximized: true, open: false, onChange: onDialogChange, onClose: onDialogClose }))))));
|
|
306
|
+
});
|
|
307
|
+
exports.Signature.propTypes = {
|
|
308
|
+
value: PropTypes.string,
|
|
309
|
+
width: PropTypes.number,
|
|
310
|
+
height: PropTypes.number,
|
|
311
|
+
tabIndex: PropTypes.number,
|
|
312
|
+
dir: PropTypes.string,
|
|
313
|
+
ariaDescribedBy: PropTypes.string,
|
|
314
|
+
ariaLabelledBy: PropTypes.string,
|
|
315
|
+
ariaLabel: PropTypes.string,
|
|
316
|
+
readOnly: PropTypes.bool,
|
|
317
|
+
disabled: PropTypes.bool,
|
|
318
|
+
validationMessage: PropTypes.string,
|
|
319
|
+
required: PropTypes.bool,
|
|
320
|
+
onChange: PropTypes.func,
|
|
321
|
+
onFocus: PropTypes.func,
|
|
322
|
+
onBlur: PropTypes.func,
|
|
323
|
+
onOpen: PropTypes.func,
|
|
324
|
+
onClose: PropTypes.func,
|
|
325
|
+
size: PropTypes.oneOf([null, 'small', 'medium', 'large']),
|
|
326
|
+
rounded: PropTypes.oneOf([null, 'small', 'medium', 'large', 'full']),
|
|
327
|
+
fillMode: PropTypes.oneOf([null, 'solid', 'flat', 'outline'])
|
|
328
|
+
};
|
|
329
|
+
exports.Signature.displayName = 'KendoSignature';
|
|
330
|
+
exports.Signature.defaultProps = {
|
|
331
|
+
color: '#000000',
|
|
332
|
+
backgroundColor: '#ffffff',
|
|
333
|
+
strokeWidth: 1,
|
|
334
|
+
smooth: false,
|
|
335
|
+
popupScale: DEFAULT_POPUP_SCALE,
|
|
336
|
+
exportScale: DEFAULT_EXPORT_SCALE,
|
|
337
|
+
maximizable: true,
|
|
338
|
+
disabled: false,
|
|
339
|
+
required: false,
|
|
340
|
+
validityStyles: true,
|
|
341
|
+
onChange: function (_) { return kendo_react_common_1.noop; },
|
|
342
|
+
onFocus: function (_) { return kendo_react_common_1.noop; },
|
|
343
|
+
onBlur: function (_) { return kendo_react_common_1.noop; },
|
|
344
|
+
onOpen: function (_) { return kendo_react_common_1.noop; },
|
|
345
|
+
onClose: function (_) { return kendo_react_common_1.noop; },
|
|
346
|
+
size: 'medium',
|
|
347
|
+
rounded: 'medium',
|
|
348
|
+
fillMode: 'solid'
|
|
349
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEvent } from '@progress/kendo-react-common';
|
|
2
|
+
import { SignatureHandle } from './SignatureHandle';
|
|
3
|
+
/**
|
|
4
|
+
* The arguments for the `change` event of the Signature.
|
|
5
|
+
*/
|
|
6
|
+
export interface SignatureChangeEvent extends BaseEvent<SignatureHandle> {
|
|
7
|
+
/**
|
|
8
|
+
* The current value of the Signature.
|
|
9
|
+
*/
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SignatureProps } from './SignatureProps';
|
|
2
|
+
/**
|
|
3
|
+
* The Signature ref.
|
|
4
|
+
*/
|
|
5
|
+
export interface SignatureHandle {
|
|
6
|
+
/**
|
|
7
|
+
* The Signature element.
|
|
8
|
+
*/
|
|
9
|
+
element: HTMLInputElement | null;
|
|
10
|
+
/**
|
|
11
|
+
* Focus the Signature.
|
|
12
|
+
*/
|
|
13
|
+
focus: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the `name` property of the Signature.
|
|
16
|
+
*/
|
|
17
|
+
name: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the value of the Signature.
|
|
20
|
+
*/
|
|
21
|
+
value: number | null;
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
25
|
+
props: SignatureProps;
|
|
26
|
+
/**
|
|
27
|
+
* @hidden
|
|
28
|
+
*/
|
|
29
|
+
validityStyles: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
required: boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormComponentProps } from '@progress/kendo-react-common';
|
|
3
|
+
import { SignatureChangeEvent } from './SignatureChangeEvent';
|
|
4
|
+
import { SignatureFocusEvent } from './SignatureFocusEvent';
|
|
5
|
+
import { SignatureBlurEvent } from './SignatureBlurEvent';
|
|
6
|
+
import { SignatureOpenEvent } from './SignatureOpenEvent';
|
|
7
|
+
import { SignatureCloseEvent } from './SignatureCloseEvent';
|
|
8
|
+
/**
|
|
9
|
+
* Represents the props of the [KendoReact Signature component]({% slug overview_signature %}).
|
|
10
|
+
*/
|
|
11
|
+
export interface SignatureProps extends FormComponentProps {
|
|
12
|
+
/**
|
|
13
|
+
* Sets a class of the Signature DOM element.
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Specifies the value of the Signature.
|
|
18
|
+
*
|
|
19
|
+
* The value is an image encoded as a [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs).
|
|
20
|
+
*/
|
|
21
|
+
value?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Specifies the width of the Signature in pixels.
|
|
24
|
+
*/
|
|
25
|
+
width?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Specifies the height of the Signature in pixels.
|
|
28
|
+
*/
|
|
29
|
+
height?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the `tabIndex` property of the Signature.
|
|
32
|
+
*/
|
|
33
|
+
tabIndex?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the `id` of the Signature DOM element.
|
|
36
|
+
*/
|
|
37
|
+
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Represents the `dir` HTML attribute.
|
|
40
|
+
*/
|
|
41
|
+
dir?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Specifies the name of the Signature input.
|
|
44
|
+
*/
|
|
45
|
+
name?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Identifies the element(s) which will describe the component, similar to [HTML aria-describedby attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-describedby_attribute).
|
|
48
|
+
* For example these elements could contain error or hint message.
|
|
49
|
+
*/
|
|
50
|
+
ariaDescribedBy?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Identifies the element(s) which will label the component.
|
|
53
|
+
*/
|
|
54
|
+
ariaLabelledBy?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The accessible label of the component.
|
|
57
|
+
*/
|
|
58
|
+
ariaLabel?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Determines whether the Signature is in its read-only state.
|
|
61
|
+
*/
|
|
62
|
+
readOnly?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Determines whether the Signature is in its disabled state.
|
|
65
|
+
*/
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Configures the `size` of the Signature.
|
|
69
|
+
*
|
|
70
|
+
* The available options are:
|
|
71
|
+
* - small
|
|
72
|
+
* - medium
|
|
73
|
+
* - large
|
|
74
|
+
* - null—Does not set a size `className`.
|
|
75
|
+
*
|
|
76
|
+
* @default `medium`
|
|
77
|
+
*/
|
|
78
|
+
size?: null | 'small' | 'medium' | 'large';
|
|
79
|
+
/**
|
|
80
|
+
* Configures the `roundness` of the Signature.
|
|
81
|
+
*
|
|
82
|
+
* The available options are:
|
|
83
|
+
* - small
|
|
84
|
+
* - medium
|
|
85
|
+
* - large
|
|
86
|
+
* - full
|
|
87
|
+
* - null—Does not set a rounded `className`.
|
|
88
|
+
*
|
|
89
|
+
* @default `medium`
|
|
90
|
+
*/
|
|
91
|
+
rounded?: null | 'small' | 'medium' | 'large' | 'full';
|
|
92
|
+
/**
|
|
93
|
+
* Configures the `fillMode` of the Signature.
|
|
94
|
+
*
|
|
95
|
+
* The available options are:
|
|
96
|
+
* - solid
|
|
97
|
+
* - outline
|
|
98
|
+
* - flat
|
|
99
|
+
* - null—Does not set a fillMode `className`.
|
|
100
|
+
*
|
|
101
|
+
* @default `solid`
|
|
102
|
+
*/
|
|
103
|
+
fillMode?: null | 'solid' | 'flat' | 'outline';
|
|
104
|
+
/**
|
|
105
|
+
* The stroke color of the signature.
|
|
106
|
+
*
|
|
107
|
+
* Accepts CSS color names and hex values.
|
|
108
|
+
*
|
|
109
|
+
* @default '#000000'
|
|
110
|
+
*/
|
|
111
|
+
color?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The background color of the signature.
|
|
114
|
+
*
|
|
115
|
+
* Accepts CSS color names and hex values.
|
|
116
|
+
*
|
|
117
|
+
* @default '#ffffff'
|
|
118
|
+
*/
|
|
119
|
+
backgroundColor?: string;
|
|
120
|
+
/**
|
|
121
|
+
* The stroke width of the signature.
|
|
122
|
+
*
|
|
123
|
+
* @default 1
|
|
124
|
+
*/
|
|
125
|
+
strokeWidth?: number;
|
|
126
|
+
/**
|
|
127
|
+
* A flag indicating whether to smooth out signature lines.
|
|
128
|
+
*
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
smooth?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* A flag indicating if the signature can be maximized.
|
|
134
|
+
*
|
|
135
|
+
* @default true
|
|
136
|
+
*/
|
|
137
|
+
maximizable?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Sets the open and close state of the Signature.
|
|
140
|
+
*/
|
|
141
|
+
open?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* The scale factor for the popup.
|
|
144
|
+
*
|
|
145
|
+
* The Signature width and height will be multiplied by the scale when showing the popup.
|
|
146
|
+
*
|
|
147
|
+
* @default 3
|
|
148
|
+
*/
|
|
149
|
+
popupScale?: number;
|
|
150
|
+
/**
|
|
151
|
+
* The scale factor for the exported image.
|
|
152
|
+
*
|
|
153
|
+
* The Signature width and height will be multiplied by the scale when converting the signature to an image.
|
|
154
|
+
*
|
|
155
|
+
* @default 2
|
|
156
|
+
*/
|
|
157
|
+
exportScale?: number;
|
|
158
|
+
/**
|
|
159
|
+
* A flag indicating whether the dotted line should be displayed in the background.
|
|
160
|
+
*
|
|
161
|
+
* @default false
|
|
162
|
+
*/
|
|
163
|
+
hideLine?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Represents the `style` HTML attribute.
|
|
166
|
+
*/
|
|
167
|
+
style?: React.CSSProperties;
|
|
168
|
+
/**
|
|
169
|
+
* Represents the input element `style` HTML attribute.
|
|
170
|
+
*/
|
|
171
|
+
inputStyle?: React.CSSProperties;
|
|
172
|
+
/**
|
|
173
|
+
* Determines the event handler that will be fired when the user edits the value.
|
|
174
|
+
*/
|
|
175
|
+
onChange?: (event: SignatureChangeEvent) => void;
|
|
176
|
+
/**
|
|
177
|
+
* The event handler that will be fired when Signature is focused.
|
|
178
|
+
*/
|
|
179
|
+
onFocus?: (event: SignatureFocusEvent) => void;
|
|
180
|
+
/**
|
|
181
|
+
* The event handler that will be fired when Signature is blurred.
|
|
182
|
+
*/
|
|
183
|
+
onBlur?: (event: SignatureBlurEvent) => void;
|
|
184
|
+
/**
|
|
185
|
+
* The event handler that will be fired when Signature popup is open.
|
|
186
|
+
*/
|
|
187
|
+
onOpen?: (event: SignatureOpenEvent) => void;
|
|
188
|
+
/**
|
|
189
|
+
* The event handler that will be fired when Signature popup is closed.
|
|
190
|
+
*/
|
|
191
|
+
onClose?: (event: SignatureCloseEvent) => void;
|
|
192
|
+
/** @hidden */
|
|
193
|
+
children?: React.ReactNode;
|
|
194
|
+
/** @hidden */
|
|
195
|
+
maximized?: boolean;
|
|
196
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { SignatureBlurEvent } from './SignatureBlurEvent';
|
|
2
|
+
export { SignatureChangeEvent } from './SignatureChangeEvent';
|
|
3
|
+
export { SignatureCloseEvent } from './SignatureCloseEvent';
|
|
4
|
+
export { SignatureFocusEvent } from './SignatureFocusEvent';
|
|
5
|
+
export { SignatureHandle } from './SignatureHandle';
|
|
6
|
+
export { SignatureOpenEvent } from './SignatureOpenEvent';
|
|
7
|
+
export { SignatureProps } from './SignatureProps';
|