@digigov/form 0.4.11 → 0.5.2
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/CHANGELOG.md +19 -1
- package/Field/index.js +7 -0
- package/es/Field/index.js +6 -0
- package/es/index.js +3 -2
- package/es/inputs/DateInput/index.js +149 -0
- package/es/validators.js +79 -0
- package/esm/Field/index.js +6 -0
- package/esm/index.js +4 -3
- package/esm/inputs/DateInput/index.js +149 -0
- package/esm/validators.js +79 -0
- package/index.js +3 -2
- package/inputs/DateInput/index.js +173 -0
- package/libs/form/src/index.d.ts +2 -1
- package/libs/form/src/inputs/DateInput/index.d.ts +14 -0
- package/libs/ui/src/core/Divider/index.d.ts +5 -0
- package/libs/ui/src/core/Table/index.d.ts +7 -0
- package/libs/ui/src/core/index.d.ts +3 -0
- package/libs/ui/src/locales/el.d.ts +10 -0
- package/libs-ui/react-core/src/ArrowIcon/index.d.ts +15 -0
- package/libs-ui/react-core/src/CaretIcon/index.d.ts +15 -0
- package/libs-ui/react-core/src/DateInput/index.d.ts +12 -0
- package/libs-ui/react-core/src/DateInputItem/index.d.ts +25 -0
- package/libs-ui/react-core/src/Table/index.d.ts +34 -0
- package/libs-ui/react-core/src/TableBody/index.d.ts +9 -0
- package/libs-ui/react-core/src/TableCaption/index.d.ts +15 -0
- package/libs-ui/react-core/src/TableDataCell/index.d.ts +15 -0
- package/libs-ui/react-core/src/TableHead/index.d.ts +9 -0
- package/libs-ui/react-core/src/TableHeaderCell/index.d.ts +21 -0
- package/libs-ui/react-core/src/TableRow/index.d.ts +9 -0
- package/package.json +4 -3
- package/validators.js +82 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type TrElementAttributes = JSX.IntrinsicElements['tr'];
|
|
3
|
+
export interface TableRowProps extends TrElementAttributes {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Use TableRow inside the Table component to provide a new row to the table.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TableRow: React.ForwardRefExoticComponent<Pick<TableRowProps, "className" | "style" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLTableRowElement>>;
|
|
9
|
+
export default TableRow;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "@digigov form builder",
|
|
5
5
|
"author": "GRNET Developers <devs@lists.grnet.gr>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"react-hook-form": "6.12.2",
|
|
15
15
|
"yup": "0.30.0",
|
|
16
|
-
"google-libphonenumber": "3.2.8"
|
|
16
|
+
"google-libphonenumber": "3.2.8",
|
|
17
|
+
"dayjs": "1.10.4"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
|
-
"@digigov/ui": "0.
|
|
20
|
+
"@digigov/ui": "0.12.2",
|
|
20
21
|
"@material-ui/core": "4.11.3",
|
|
21
22
|
"@material-ui/icons": "4.11.2",
|
|
22
23
|
"clsx": "1.1.1",
|
package/validators.js
CHANGED
|
@@ -22,6 +22,10 @@ var gPhoneNumber = _interopRequireWildcard(require("google-libphonenumber"));
|
|
|
22
22
|
|
|
23
23
|
var _react = require("react");
|
|
24
24
|
|
|
25
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
26
|
+
|
|
27
|
+
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
28
|
+
|
|
25
29
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
30
|
|
|
27
31
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -32,6 +36,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
32
36
|
|
|
33
37
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
34
38
|
|
|
39
|
+
_dayjs["default"].extend(_customParseFormat["default"]);
|
|
40
|
+
|
|
35
41
|
var DEFAULT_FILE_MAX_SIZE = 10000000;
|
|
36
42
|
|
|
37
43
|
function validateAFM(afm) {
|
|
@@ -306,6 +312,13 @@ var IBAN_VALIDATOR = function IBAN_VALIDATOR(field) {
|
|
|
306
312
|
};
|
|
307
313
|
};
|
|
308
314
|
|
|
315
|
+
var VALID_DATE_FORMATS = ['DD/MM/YYYY'];
|
|
316
|
+
var DATE_CACHE = {};
|
|
317
|
+
|
|
318
|
+
var getDate = function getDate(v) {
|
|
319
|
+
return DATE_CACHE[v] ? DATE_CACHE[v] : (0, _dayjs["default"])(v, VALID_DATE_FORMATS, true);
|
|
320
|
+
};
|
|
321
|
+
|
|
309
322
|
function getYupField(field, yupTypeMap) {
|
|
310
323
|
var yupField = yupTypeMap[field.type] || yupTypeMap.string;
|
|
311
324
|
return yupField(field);
|
|
@@ -442,6 +455,75 @@ var getYUPTypeMap = function getYUPTypeMap() {
|
|
|
442
455
|
},
|
|
443
456
|
'choice:single': function choiceSingle() {
|
|
444
457
|
return yup.string().nullable();
|
|
458
|
+
},
|
|
459
|
+
date: function date(field) {
|
|
460
|
+
var simpleDate = yup.string().nullable(true).test('date', 'form.error.date.invalid', function (value) {
|
|
461
|
+
if (!value) return true;
|
|
462
|
+
value = getDate(value);
|
|
463
|
+
return value.isValid();
|
|
464
|
+
});
|
|
465
|
+
var params = field.extra || {};
|
|
466
|
+
|
|
467
|
+
if (params.max) {
|
|
468
|
+
var maxDate;
|
|
469
|
+
|
|
470
|
+
if (params.max === 'now') {
|
|
471
|
+
var today = new Date();
|
|
472
|
+
maxDate = new Date(today);
|
|
473
|
+
} else {
|
|
474
|
+
maxDate = getDate(params.max).toDate();
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
var maxNextDate = new Date(maxDate);
|
|
478
|
+
maxNextDate.setDate(maxDate.getDate() + 1);
|
|
479
|
+
simpleDate = simpleDate.test({
|
|
480
|
+
name: 'earlier-than',
|
|
481
|
+
message: {
|
|
482
|
+
key: 'form.error.date.earlier_than',
|
|
483
|
+
context: {
|
|
484
|
+
maxDate: maxNextDate.toLocaleDateString()
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
test: function test(value) {
|
|
488
|
+
if (!value) return true;
|
|
489
|
+
value = getDate(value);
|
|
490
|
+
var isValid = +value.toDate() < +maxDate;
|
|
491
|
+
return isValid;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (params.min) {
|
|
497
|
+
var minDate;
|
|
498
|
+
|
|
499
|
+
if (params.min === 'now') {
|
|
500
|
+
var _today = new Date();
|
|
501
|
+
|
|
502
|
+
minDate = new Date(_today);
|
|
503
|
+
} else {
|
|
504
|
+
minDate = getDate(params.min).toDate();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
var minPreviousDate = new Date(minDate);
|
|
508
|
+
minPreviousDate.setDate(minDate.getDate() - 1);
|
|
509
|
+
simpleDate = simpleDate.test({
|
|
510
|
+
name: 'later-than',
|
|
511
|
+
message: {
|
|
512
|
+
key: 'form.error.date.later_than',
|
|
513
|
+
context: {
|
|
514
|
+
minDate: minPreviousDate.toLocaleDateString()
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
test: function test(value) {
|
|
518
|
+
if (!value) return true;
|
|
519
|
+
value = getDate(value);
|
|
520
|
+
var isValid = +value.toDate() > +minDate;
|
|
521
|
+
return isValid;
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return simpleDate;
|
|
445
527
|
}
|
|
446
528
|
};
|
|
447
529
|
return yupTypeMap;
|