@digigov/form 0.12.6 → 0.13.0
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 +15 -4
- package/Field/FieldBase.js +2 -2
- package/Field/FieldBaseContainer.js +7 -7
- package/Field/FieldConditional.js +10 -5
- package/Field/types.d.ts +2 -1
- package/Field/utils.js +14 -10
- package/FieldArray/index.js +3 -3
- package/FieldObject/index.d.ts +1 -1
- package/FieldObject/index.js +4 -4
- package/Fieldset/FieldsetWithContext.js +4 -4
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +2 -2
- package/FormBuilder/FormBuilder.js +5 -5
- package/FormContext.d.ts +1 -1
- package/MultiplicityField/__stories__/PreviewDisplay.js +3 -3
- package/MultiplicityField/add-objects.js +6 -6
- package/MultiplicityField/index.d.ts +2 -2
- package/MultiplicityField/index.js +5 -5
- package/Questions/Questions.js +2 -2
- package/Questions/Step/ReviewStep.js +7 -7
- package/Questions/Step/Step.js +2 -2
- package/Questions/Step/StepArrayReview.js +10 -10
- package/Questions/Step/StepDescription.js +2 -2
- package/Questions/Step/StepForm.d.ts +1 -1
- package/Questions/Step/StepForm.js +5 -5
- package/Questions/Step/StepTitle.js +2 -2
- package/Questions/Step/getAddMoreFields.d.ts +1 -1
- package/Questions/__stories__/Default.js +6 -6
- package/Questions/index.spec.js +2 -2
- package/es/Field/FieldBase.js +1 -1
- package/es/Field/FieldBaseContainer.js +4 -4
- package/es/Field/FieldConditional.js +6 -2
- package/es/Field/utils.js +13 -9
- package/es/FieldArray/index.js +2 -2
- package/es/FieldObject/index.js +2 -2
- package/es/Fieldset/FieldsetWithContext.js +2 -2
- package/es/Fieldset/index.js +1 -1
- package/es/FormBuilder/FormBuilder.js +3 -3
- package/es/FormContext.js +1 -1
- package/es/MultiplicityField/__stories__/PreviewDisplay.js +2 -2
- package/es/MultiplicityField/add-objects.js +5 -5
- package/es/MultiplicityField/index.js +3 -3
- package/es/Questions/Questions.js +1 -1
- package/es/Questions/Step/ReviewStep.js +4 -4
- package/es/Questions/Step/Step.js +1 -1
- package/es/Questions/Step/StepArrayReview.js +6 -6
- package/es/Questions/Step/StepDescription.js +1 -1
- package/es/Questions/Step/StepForm.js +4 -4
- package/es/Questions/Step/StepTitle.js +1 -1
- package/es/Questions/__stories__/Default.js +4 -4
- package/es/Questions/index.spec.js +2 -1
- package/es/inputs/AutoComplete/__stories__/Default.js +2 -2
- package/es/inputs/AutoComplete/index.js +1 -1
- package/es/inputs/Checkboxes/Checkboxes.stories.js +3 -1
- package/es/inputs/Checkboxes/Checkboxes.stories.playwright.json +16 -0
- package/es/inputs/Checkboxes/__stories__/Conditional.js +95 -0
- package/es/inputs/Checkboxes/__stories__/WithDivider.js +43 -0
- package/es/inputs/Checkboxes/index.js +45 -13
- package/es/inputs/DateInput/index.js +1 -1
- package/es/inputs/FileInput/index.js +4 -4
- package/es/inputs/Input/Input.stories.js +2 -1
- package/es/inputs/Input/__stories__/TextWithCharacterLimit.js +31 -0
- package/es/inputs/Input/index.js +23 -5
- package/es/inputs/Label/index.js +1 -1
- package/es/inputs/Radio/Radio.stories.js +3 -1
- package/es/inputs/Radio/Radio.stories.playwright.json +16 -0
- package/es/inputs/Radio/__stories__/Conditional.js +95 -0
- package/es/inputs/Radio/__stories__/WithDivider.js +48 -0
- package/es/inputs/Radio/index.js +17 -6
- package/es/registry.js +3 -0
- package/es/utils.js +1 -1
- package/es/validators/index.js +10 -2
- package/es/validators/utils/index.js +16 -2
- package/es/validators/utils/text_limit.js +54 -0
- package/esm/Field/FieldBase.js +1 -1
- package/esm/Field/FieldBaseContainer.js +4 -4
- package/esm/Field/FieldConditional.js +6 -2
- package/esm/Field/utils.js +13 -9
- package/esm/FieldArray/index.js +2 -2
- package/esm/FieldObject/index.js +2 -2
- package/esm/Fieldset/FieldsetWithContext.js +2 -2
- package/esm/Fieldset/index.js +1 -1
- package/esm/FormBuilder/FormBuilder.js +3 -3
- package/esm/FormContext.js +1 -1
- package/esm/MultiplicityField/__stories__/PreviewDisplay.js +2 -2
- package/esm/MultiplicityField/add-objects.js +5 -5
- package/esm/MultiplicityField/index.js +3 -3
- package/esm/Questions/Questions.js +1 -1
- package/esm/Questions/Step/ReviewStep.js +4 -4
- package/esm/Questions/Step/Step.js +1 -1
- package/esm/Questions/Step/StepArrayReview.js +6 -6
- package/esm/Questions/Step/StepDescription.js +1 -1
- package/esm/Questions/Step/StepForm.js +4 -4
- package/esm/Questions/Step/StepTitle.js +1 -1
- package/esm/Questions/__stories__/Default.js +4 -4
- package/esm/Questions/index.spec.js +2 -1
- package/esm/index.js +1 -1
- package/esm/inputs/AutoComplete/__stories__/Default.js +2 -2
- package/esm/inputs/AutoComplete/index.js +1 -1
- package/esm/inputs/Checkboxes/Checkboxes.stories.js +3 -1
- package/esm/inputs/Checkboxes/Checkboxes.stories.playwright.json +16 -0
- package/esm/inputs/Checkboxes/__stories__/Conditional.js +95 -0
- package/esm/inputs/Checkboxes/__stories__/WithDivider.js +43 -0
- package/esm/inputs/Checkboxes/index.js +45 -13
- package/esm/inputs/DateInput/index.js +1 -1
- package/esm/inputs/FileInput/index.js +4 -4
- package/esm/inputs/Input/Input.stories.js +2 -1
- package/esm/inputs/Input/__stories__/TextWithCharacterLimit.js +31 -0
- package/esm/inputs/Input/index.js +23 -5
- package/esm/inputs/Label/index.js +1 -1
- package/esm/inputs/Radio/Radio.stories.js +3 -1
- package/esm/inputs/Radio/Radio.stories.playwright.json +16 -0
- package/esm/inputs/Radio/__stories__/Conditional.js +95 -0
- package/esm/inputs/Radio/__stories__/WithDivider.js +48 -0
- package/esm/inputs/Radio/index.js +17 -6
- package/esm/registry.js +3 -0
- package/esm/utils.js +1 -1
- package/esm/validators/index.js +10 -2
- package/esm/validators/utils/index.js +16 -2
- package/esm/validators/utils/text_limit.js +54 -0
- package/inputs/AutoComplete/__stories__/Default.js +3 -3
- package/inputs/AutoComplete/index.d.ts +2 -2
- package/inputs/AutoComplete/index.js +2 -2
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +2 -0
- package/inputs/Checkboxes/Checkboxes.stories.js +28 -0
- package/inputs/Checkboxes/Checkboxes.stories.playwright.json +16 -0
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -0
- package/inputs/Checkboxes/__stories__/Conditional.js +115 -0
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -0
- package/inputs/Checkboxes/__stories__/WithDivider.js +63 -0
- package/inputs/Checkboxes/index.d.ts +1 -1
- package/inputs/Checkboxes/index.js +53 -13
- package/inputs/DateInput/index.js +2 -2
- package/inputs/FileInput/index.js +5 -5
- package/inputs/Input/Input.stories.d.ts +1 -0
- package/inputs/Input/Input.stories.js +14 -0
- package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +2 -0
- package/inputs/Input/__stories__/TextWithCharacterLimit.js +51 -0
- package/inputs/Input/index.d.ts +4 -0
- package/inputs/Input/index.js +26 -5
- package/inputs/Label/index.d.ts +2 -0
- package/inputs/Label/index.js +2 -2
- package/inputs/Radio/Radio.stories.d.ts +2 -0
- package/inputs/Radio/Radio.stories.js +28 -0
- package/inputs/Radio/Radio.stories.playwright.json +16 -0
- package/inputs/Radio/__stories__/Conditional.d.ts +1 -0
- package/inputs/Radio/__stories__/Conditional.js +115 -0
- package/inputs/Radio/__stories__/WithDivider.d.ts +2 -0
- package/inputs/Radio/__stories__/WithDivider.js +68 -0
- package/inputs/Radio/index.d.ts +1 -1
- package/inputs/Radio/index.js +20 -8
- package/inputs/Select/index.d.ts +1 -1
- package/package.json +3 -3
- package/registry.d.ts +1 -0
- package/registry.js +4 -0
- package/src/Field/FieldBase.tsx +1 -1
- package/src/Field/FieldBaseContainer.tsx +5 -5
- package/src/Field/FieldConditional.tsx +9 -3
- package/src/Field/index.tsx +1 -1
- package/src/Field/types.tsx +2 -1
- package/src/Field/utils.ts +17 -11
- package/src/FieldArray/index.tsx +3 -3
- package/src/FieldObject/index.tsx +5 -5
- package/src/Fieldset/FieldsetWithContext.tsx +3 -3
- package/src/Fieldset/index.tsx +5 -5
- package/src/FormBuilder/FormBuilder.tsx +4 -4
- package/src/FormContext.tsx +2 -1
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +6 -6
- package/src/MultiplicityField/add-objects.tsx +4 -4
- package/src/MultiplicityField/index.tsx +5 -5
- package/src/Questions/Questions.tsx +2 -2
- package/src/Questions/Step/ReviewStep.tsx +5 -5
- package/src/Questions/Step/Step.tsx +1 -1
- package/src/Questions/Step/StepArrayReview.tsx +8 -8
- package/src/Questions/Step/StepDescription.tsx +1 -1
- package/src/Questions/Step/StepForm.tsx +5 -5
- package/src/Questions/Step/StepTitle.tsx +1 -1
- package/src/Questions/Step/getAddMoreFields.tsx +1 -1
- package/src/Questions/__stories__/Default.tsx +4 -4
- package/src/Questions/index.spec.tsx +2 -1
- package/src/inputs/AutoComplete/__stories__/Default.tsx +2 -2
- package/src/inputs/AutoComplete/index.tsx +3 -3
- package/src/inputs/Checkboxes/Checkboxes.stories.js +2 -0
- package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +16 -0
- package/src/inputs/Checkboxes/__stories__/Conditional.tsx +100 -0
- package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +39 -0
- package/src/inputs/Checkboxes/index.tsx +61 -31
- package/src/inputs/DateInput/index.tsx +2 -2
- package/src/inputs/FileInput/index.tsx +4 -4
- package/src/inputs/Input/Input.stories.js +2 -1
- package/src/inputs/Input/__stories__/TextWithCharacterLimit.tsx +24 -0
- package/src/inputs/Input/index.tsx +57 -16
- package/src/inputs/Label/index.tsx +4 -2
- package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/Radio.stories.js +3 -0
- package/src/inputs/Radio/Radio.stories.playwright.json +16 -0
- package/src/inputs/Radio/__stories__/Conditional.tsx +97 -0
- package/src/inputs/Radio/__stories__/WithDivider.tsx +42 -0
- package/src/inputs/Radio/index.tsx +22 -5
- package/src/inputs/Select/index.tsx +2 -2
- package/src/registry.js +3 -0
- package/src/types.tsx +6 -4
- package/src/utils.ts +1 -1
- package/src/validators/index.ts +8 -1
- package/src/validators/utils/file.ts +1 -1
- package/src/validators/utils/index.ts +10 -1
- package/src/validators/utils/phone.ts +1 -1
- package/src/validators/utils/postal_code.ts +1 -1
- package/src/validators/utils/text_limit.ts +44 -0
- package/types.d.ts +6 -4
- package/validators/index.js +9 -1
- package/validators/utils/file.d.ts +1 -1
- package/validators/utils/index.d.ts +1 -0
- package/validators/utils/index.js +29 -2
- package/validators/utils/phone.d.ts +1 -1
- package/validators/utils/postal_code.d.ts +1 -1
- package/validators/utils/text_limit.d.ts +4 -0
- package/validators/utils/text_limit.js +65 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ControlledFieldProps } from '@digigov/form/Field/types';
|
|
3
|
-
import { FieldOptionProps } from '@digigov/form/inputs/Label';
|
|
4
2
|
import { AutoCompleteProps as UIAutoCompleteProps } from '@digigov/ui/admin/AutoComplete';
|
|
3
|
+
import { FieldOptionProps } from '@digigov/form/inputs/Label';
|
|
4
|
+
import { ControlledFieldProps } from '@digigov/form/Field/types';
|
|
5
5
|
export interface AutoCompleteExtra extends Omit<UIAutoCompleteProps, 'source' | 'id' | 'templates' | 'defaultValue' | 'onConfirm' | 'dropdownArrow'> {
|
|
6
6
|
options: Array<FieldOptionProps>;
|
|
7
7
|
}
|
|
@@ -15,10 +15,10 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
15
15
|
|
|
16
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
17
|
|
|
18
|
-
var _reactCore = require("@digigov/react-core");
|
|
19
|
-
|
|
20
18
|
var _AutoComplete = _interopRequireDefault(require("@digigov/ui/admin/AutoComplete"));
|
|
21
19
|
|
|
20
|
+
var _reactCore = require("@digigov/react-core");
|
|
21
|
+
|
|
22
22
|
var _excluded = ["name", "extra", "onChange", "value"];
|
|
23
23
|
|
|
24
24
|
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); }
|
|
@@ -5,4 +5,6 @@ declare namespace _default {
|
|
|
5
5
|
}
|
|
6
6
|
export default _default;
|
|
7
7
|
export * from "@digigov/form/inputs/Checkboxes/__stories__/Default";
|
|
8
|
+
export * from "@digigov/form/inputs/Checkboxes/__stories__/WithDivider";
|
|
9
|
+
export * from "@digigov/form/inputs/Checkboxes/__stories__/Conditional";
|
|
8
10
|
import Checkboxes from "@digigov/form/inputs/Checkboxes";
|
|
@@ -23,6 +23,34 @@ Object.keys(_Default).forEach(function (key) {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
+
|
|
27
|
+
var _WithDivider = require("@digigov/form/inputs/Checkboxes/__stories__/WithDivider");
|
|
28
|
+
|
|
29
|
+
Object.keys(_WithDivider).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
+
if (key in exports && exports[key] === _WithDivider[key]) return;
|
|
33
|
+
Object.defineProperty(exports, key, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function get() {
|
|
36
|
+
return _WithDivider[key];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
var _Conditional = require("@digigov/form/inputs/Checkboxes/__stories__/Conditional");
|
|
42
|
+
|
|
43
|
+
Object.keys(_Conditional).forEach(function (key) {
|
|
44
|
+
if (key === "default" || key === "__esModule") return;
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
46
|
+
if (key in exports && exports[key] === _Conditional[key]) return;
|
|
47
|
+
Object.defineProperty(exports, key, {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function get() {
|
|
50
|
+
return _Conditional[key];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
26
54
|
var _default = {
|
|
27
55
|
title: 'Digigov Form/inputs/Checkboxes',
|
|
28
56
|
component: _Checkboxes["default"],
|
|
@@ -64,6 +64,22 @@
|
|
|
64
64
|
"title": "Focus and check using keyboard, click box and submit"
|
|
65
65
|
}
|
|
66
66
|
]
|
|
67
|
+
},
|
|
68
|
+
"digigov-form-inputs-checkboxes--conditional": {
|
|
69
|
+
"actionSets": [
|
|
70
|
+
{
|
|
71
|
+
"actions": [
|
|
72
|
+
{
|
|
73
|
+
"name": "click",
|
|
74
|
+
"args": {
|
|
75
|
+
"selector": "html>body>div:nth-child(5)>form>div>fieldset>div>div:nth-child(1)>label>input"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"id": "zpUjNzrqwtmW",
|
|
80
|
+
"title": "Checkboxes conditional action"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
67
83
|
}
|
|
68
84
|
}
|
|
69
85
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Conditional: () => JSX.Element;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.Conditional = void 0;
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _form = _interopRequireWildcard(require("@digigov/form"));
|
|
15
|
+
|
|
16
|
+
var _core = require("@digigov/ui/core");
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
var fields = [{
|
|
23
|
+
key: 'landline',
|
|
24
|
+
type: 'phone_number',
|
|
25
|
+
label: {
|
|
26
|
+
secondary: 'Εισάγετε το νούμερο του σταθερού σας τηλεφώνου.'
|
|
27
|
+
},
|
|
28
|
+
enabled: false,
|
|
29
|
+
condition: {
|
|
30
|
+
auth_form: {
|
|
31
|
+
is: 'via_mobile_phone',
|
|
32
|
+
then: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
required: true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: 'mobile_phone',
|
|
40
|
+
type: 'mobile_phone',
|
|
41
|
+
label: {
|
|
42
|
+
secondary: 'Εισάγετε το νούμερο του κινητού σας τηλεφώνου.'
|
|
43
|
+
},
|
|
44
|
+
enabled: false,
|
|
45
|
+
condition: {
|
|
46
|
+
auth_form: {
|
|
47
|
+
is: 'via_mobile_phone',
|
|
48
|
+
then: {
|
|
49
|
+
enabled: true,
|
|
50
|
+
required: true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: 'email',
|
|
56
|
+
type: 'email',
|
|
57
|
+
label: {
|
|
58
|
+
secondary: 'Εισάγετε την διεύθυνση του ηλεκτρονικού σας ταχυδρομείου.'
|
|
59
|
+
},
|
|
60
|
+
enabled: false,
|
|
61
|
+
condition: {
|
|
62
|
+
auth_form: {
|
|
63
|
+
is: 'via_email',
|
|
64
|
+
then: {
|
|
65
|
+
enabled: true,
|
|
66
|
+
required: true
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: 'auth_form',
|
|
72
|
+
type: 'choice:multiple',
|
|
73
|
+
required: true,
|
|
74
|
+
label: {
|
|
75
|
+
primary: 'Επιλέξτε μέθοδο πιστοποίησης',
|
|
76
|
+
secondary: 'Για την ολοκλήρωση της δήλωσης σας, θα χρειαστεί επιπλέον πιστοποίηση. Θα σας στείλουμε ένα κωδικό μιας χρήσης είτε στο τηλέφωνο είτε στην ηλεκτρονική σας διεύθυνση.'
|
|
77
|
+
},
|
|
78
|
+
extra: {
|
|
79
|
+
options: [{
|
|
80
|
+
key: 'via_mobile_phone',
|
|
81
|
+
label: {
|
|
82
|
+
primary: 'Mέσω κινητού τηλεφώνου'
|
|
83
|
+
},
|
|
84
|
+
value: 'via_mobile_phone',
|
|
85
|
+
show: ['mobile_phone', 'landline']
|
|
86
|
+
}, {
|
|
87
|
+
key: 'via_email',
|
|
88
|
+
label: {
|
|
89
|
+
primary: 'Μέσω διεύθυνσης ηλεκτρονικού ταχυδρομείου (e-mail)'
|
|
90
|
+
},
|
|
91
|
+
value: 'via_email',
|
|
92
|
+
show: ['email']
|
|
93
|
+
}]
|
|
94
|
+
}
|
|
95
|
+
}];
|
|
96
|
+
|
|
97
|
+
var _ref = /*#__PURE__*/_react["default"].createElement(_form.Field, {
|
|
98
|
+
key: "auth_form",
|
|
99
|
+
name: "auth_form"
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
var _ref2 = /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
103
|
+
type: "submit"
|
|
104
|
+
}, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
105
|
+
|
|
106
|
+
var Conditional = function Conditional() {
|
|
107
|
+
return /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
108
|
+
onSubmit: function onSubmit(data) {
|
|
109
|
+
console.log(data);
|
|
110
|
+
},
|
|
111
|
+
fields: fields
|
|
112
|
+
}, _ref, _ref2);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
exports.Conditional = Conditional;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = exports.WithDivider = void 0;
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _form = _interopRequireWildcard(require("@digigov/form"));
|
|
15
|
+
|
|
16
|
+
var _core = require("@digigov/ui/core");
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
var _ref = /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
23
|
+
type: "submit"
|
|
24
|
+
}, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
25
|
+
|
|
26
|
+
var WithDivider = function WithDivider() {
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
28
|
+
onSubmit: function onSubmit(data) {
|
|
29
|
+
console.log(data);
|
|
30
|
+
}
|
|
31
|
+
}, /*#__PURE__*/_react["default"].createElement(_form.Field, {
|
|
32
|
+
key: 'string',
|
|
33
|
+
name: "string",
|
|
34
|
+
type: "choice:multiple",
|
|
35
|
+
required: true,
|
|
36
|
+
label: {
|
|
37
|
+
primary: 'Πώς αισθάνεστε αυτή τη στιγμή;'
|
|
38
|
+
},
|
|
39
|
+
extra: {
|
|
40
|
+
options: [{
|
|
41
|
+
label: {
|
|
42
|
+
primary: 'Έχω συνάχι'
|
|
43
|
+
},
|
|
44
|
+
value: 'runny-nose'
|
|
45
|
+
}, {
|
|
46
|
+
label: {
|
|
47
|
+
primary: 'Έχω πυρετό'
|
|
48
|
+
},
|
|
49
|
+
value: 'fever'
|
|
50
|
+
}, {
|
|
51
|
+
label: {
|
|
52
|
+
primary: 'Αισθάνομαι κούραση'
|
|
53
|
+
},
|
|
54
|
+
value: 'fatigue',
|
|
55
|
+
divider: 'ή'
|
|
56
|
+
}]
|
|
57
|
+
}
|
|
58
|
+
}), _ref);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.WithDivider = WithDivider;
|
|
62
|
+
var _default = WithDivider;
|
|
63
|
+
exports["default"] = _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ControlledFieldProps } from '@digigov/form/Field/types';
|
|
3
2
|
import { FieldOptionProps } from '@digigov/form/inputs/Label';
|
|
3
|
+
import { ControlledFieldProps } from '@digigov/form/Field/types';
|
|
4
4
|
export interface CheckboxesProps extends Omit<ControlledFieldProps, 'extra' | 'value'> {
|
|
5
5
|
value?: string[];
|
|
6
6
|
extra: {
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -9,9 +11,13 @@ exports["default"] = exports.Checkboxes = void 0;
|
|
|
9
11
|
|
|
10
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
13
|
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
12
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
17
|
|
|
14
|
-
var _react =
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _i18n = require("@digigov/ui/app/i18n");
|
|
15
21
|
|
|
16
22
|
var _Checkbox = _interopRequireDefault(require("@digigov/react-core/Checkbox"));
|
|
17
23
|
|
|
@@ -19,9 +25,16 @@ var _CheckboxItem = _interopRequireDefault(require("@digigov/react-core/Checkbox
|
|
|
19
25
|
|
|
20
26
|
var _Hint = _interopRequireDefault(require("@digigov/react-core/Hint"));
|
|
21
27
|
|
|
22
|
-
var
|
|
28
|
+
var _form = require("@digigov/form");
|
|
29
|
+
|
|
30
|
+
var _reactCore = require("@digigov/react-core");
|
|
23
31
|
|
|
24
|
-
var _excluded = ["name", "onChange", "value", "extra", "disabled"]
|
|
32
|
+
var _excluded = ["name", "onChange", "value", "extra", "disabled"],
|
|
33
|
+
_excluded2 = ["label", "value", "show", "disabled", "selected"];
|
|
34
|
+
|
|
35
|
+
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); }
|
|
36
|
+
|
|
37
|
+
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; }
|
|
25
38
|
|
|
26
39
|
var Checkboxes = function Checkboxes(_ref) {
|
|
27
40
|
var name = _ref.name,
|
|
@@ -34,7 +47,7 @@ var Checkboxes = function Checkboxes(_ref) {
|
|
|
34
47
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
35
48
|
if (!value) value = [];
|
|
36
49
|
|
|
37
|
-
var handleChange = function handleChange(optionValue) {
|
|
50
|
+
var handleChange = function handleChange(optionValue, idx, show) {
|
|
38
51
|
return function (evt) {
|
|
39
52
|
var newValue;
|
|
40
53
|
|
|
@@ -48,6 +61,14 @@ var Checkboxes = function Checkboxes(_ref) {
|
|
|
48
61
|
newValue = value.filter(function (val) {
|
|
49
62
|
return val !== optionValue;
|
|
50
63
|
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (show && show.length > 0) {
|
|
67
|
+
setChecked(function (items) {
|
|
68
|
+
return items.map(function (item, index) {
|
|
69
|
+
return index === idx ? !item : item;
|
|
70
|
+
});
|
|
71
|
+
});
|
|
51
72
|
} // reset value to undefined instead of an empty array
|
|
52
73
|
// so the error state mechanism can throw validation errors
|
|
53
74
|
|
|
@@ -60,17 +81,31 @@ var Checkboxes = function Checkboxes(_ref) {
|
|
|
60
81
|
var _useTranslation = (0, _i18n.useTranslation)(),
|
|
61
82
|
t = _useTranslation.t;
|
|
62
83
|
|
|
84
|
+
var _useState = (0, _react.useState)(Array(options.length).fill(false)),
|
|
85
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
86
|
+
checked = _useState2[0],
|
|
87
|
+
setChecked = _useState2[1];
|
|
88
|
+
|
|
63
89
|
return /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
64
90
|
className: className
|
|
65
|
-
}, options.map(function (
|
|
66
|
-
|
|
91
|
+
}, options.map(function (_ref2, index) {
|
|
92
|
+
var _value;
|
|
93
|
+
|
|
94
|
+
var label = _ref2.label,
|
|
95
|
+
v = _ref2.value,
|
|
96
|
+
show = _ref2.show,
|
|
97
|
+
optionDisabled = _ref2.disabled,
|
|
98
|
+
selected = _ref2.selected,
|
|
99
|
+
option = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2);
|
|
100
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
101
|
+
key: index
|
|
102
|
+
}, /*#__PURE__*/_react["default"].createElement(_CheckboxItem["default"], (0, _extends2["default"])({
|
|
103
|
+
key: "".concat(name, ".").concat(index),
|
|
67
104
|
name: name,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
,
|
|
72
|
-
checked: value.includes(option.value),
|
|
73
|
-
onChange: handleChange(option.value)
|
|
105
|
+
value: v,
|
|
106
|
+
disabled: disabled || optionDisabled,
|
|
107
|
+
checked: (_value = value) === null || _value === void 0 ? void 0 : _value.includes(v),
|
|
108
|
+
onChange: handleChange(v, index, show)
|
|
74
109
|
}, option, (0, _extends2["default"])({}, props, {
|
|
75
110
|
reset: undefined,
|
|
76
111
|
defaultValue: undefined,
|
|
@@ -78,7 +113,12 @@ var Checkboxes = function Checkboxes(_ref) {
|
|
|
78
113
|
required: undefined,
|
|
79
114
|
'aria-describedby': undefined,
|
|
80
115
|
type: 'checkbox'
|
|
81
|
-
})),
|
|
116
|
+
})), label && label.primary && t(label.primary) || value, label && label.secondary && /*#__PURE__*/_react["default"].createElement(_Hint["default"], null, t(label.secondary))), !!checked[index] && show && /*#__PURE__*/_react["default"].createElement(_reactCore.CheckboxConditional, null, show.map(function (fieldName) {
|
|
117
|
+
return /*#__PURE__*/_react["default"].createElement(_form.Field, {
|
|
118
|
+
name: fieldName,
|
|
119
|
+
key: fieldName
|
|
120
|
+
});
|
|
121
|
+
})), selected && selected());
|
|
82
122
|
}));
|
|
83
123
|
};
|
|
84
124
|
|
|
@@ -19,12 +19,12 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
|
19
19
|
|
|
20
20
|
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
21
21
|
|
|
22
|
+
var _i18n = require("@digigov/ui/app/i18n");
|
|
23
|
+
|
|
22
24
|
var _DateInputContainer = _interopRequireDefault(require("@digigov/react-core/DateInputContainer"));
|
|
23
25
|
|
|
24
26
|
var _DateInputItem = _interopRequireDefault(require("@digigov/react-core/DateInputItem"));
|
|
25
27
|
|
|
26
|
-
var _i18n = require("@digigov/ui/app/i18n");
|
|
27
|
-
|
|
28
28
|
var _excluded = ["label"],
|
|
29
29
|
_excluded2 = ["name", "type"];
|
|
30
30
|
|
|
@@ -19,17 +19,17 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
19
19
|
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _i18n = require("@digigov/ui/app/i18n");
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _Paragraph = _interopRequireDefault(require("@digigov/ui/typography/Paragraph"));
|
|
25
25
|
|
|
26
26
|
var _Hint = _interopRequireDefault(require("@digigov/react-core/Hint"));
|
|
27
27
|
|
|
28
|
-
var _i18n = require("@digigov/ui/app/i18n");
|
|
29
|
-
|
|
30
28
|
var _Button = _interopRequireDefault(require("@digigov/ui/core/Button"));
|
|
31
29
|
|
|
32
|
-
var
|
|
30
|
+
var _FileUploadContainer = _interopRequireDefault(require("@digigov/react-core/FileUploadContainer"));
|
|
31
|
+
|
|
32
|
+
var _FileUpload = _interopRequireDefault(require("@digigov/react-core/FileUpload"));
|
|
33
33
|
|
|
34
34
|
var _excluded = ["name", "extra", "disabled", "reset", "onChange"];
|
|
35
35
|
|
|
@@ -12,4 +12,5 @@ export * from "@digigov/form/inputs/Input/__stories__/MobilePhone";
|
|
|
12
12
|
export * from "@digigov/form/inputs/Input/__stories__/AFM";
|
|
13
13
|
export * from "@digigov/form/inputs/Input/__stories__/IBAN";
|
|
14
14
|
export * from "@digigov/form/inputs/Input/__stories__/PostalCode";
|
|
15
|
+
export * from "@digigov/form/inputs/Input/__stories__/TextWithCharacterLimit";
|
|
15
16
|
import Input from "@digigov/form/inputs/Input";
|
|
@@ -121,6 +121,20 @@ Object.keys(_PostalCode).forEach(function (key) {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
|
+
|
|
125
|
+
var _TextWithCharacterLimit = require("@digigov/form/inputs/Input/__stories__/TextWithCharacterLimit");
|
|
126
|
+
|
|
127
|
+
Object.keys(_TextWithCharacterLimit).forEach(function (key) {
|
|
128
|
+
if (key === "default" || key === "__esModule") return;
|
|
129
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
130
|
+
if (key in exports && exports[key] === _TextWithCharacterLimit[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function get() {
|
|
134
|
+
return _TextWithCharacterLimit[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
124
138
|
var _default = {
|
|
125
139
|
title: 'Digigov Form/inputs/Input',
|
|
126
140
|
component: _Input["default"],
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = exports.TextWithCharacterLimit = void 0;
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _form = _interopRequireWildcard(require("@digigov/form"));
|
|
15
|
+
|
|
16
|
+
var _core = require("@digigov/ui/core");
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
var _ref = /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
23
|
+
type: "submit"
|
|
24
|
+
}, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
25
|
+
|
|
26
|
+
var TextWithCharacterLimit = function TextWithCharacterLimit() {
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
28
|
+
onSubmit: function onSubmit(data) {
|
|
29
|
+
console.log(data);
|
|
30
|
+
}
|
|
31
|
+
}, /*#__PURE__*/_react["default"].createElement(_form.Field, {
|
|
32
|
+
key: "text",
|
|
33
|
+
name: "text",
|
|
34
|
+
type: "text",
|
|
35
|
+
label: {
|
|
36
|
+
primary: 'Μπορείτε να δώσετε περισσότερες πληροφορίες;'
|
|
37
|
+
},
|
|
38
|
+
required: true,
|
|
39
|
+
extra: {
|
|
40
|
+
limit: {
|
|
41
|
+
min: 3,
|
|
42
|
+
max: 10
|
|
43
|
+
},
|
|
44
|
+
multiline: true
|
|
45
|
+
}
|
|
46
|
+
}), _ref);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.TextWithCharacterLimit = TextWithCharacterLimit;
|
|
50
|
+
var _default = TextWithCharacterLimit;
|
|
51
|
+
exports["default"] = _default;
|
package/inputs/Input/index.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export interface InputProps extends Omit<UncontrolledFieldProps, 'extra'> {
|
|
|
6
6
|
multiline?: boolean;
|
|
7
7
|
className?: string;
|
|
8
8
|
rows?: any;
|
|
9
|
+
limit: {
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
};
|
|
9
13
|
};
|
|
10
14
|
}
|
|
11
15
|
export declare const Input: React.ExoticComponent<InputProps>;
|
package/inputs/Input/index.js
CHANGED
|
@@ -13,11 +13,17 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
|
|
16
|
+
var _TextInput = _interopRequireDefault(require("@digigov/react-core/TextInput"));
|
|
17
|
+
|
|
16
18
|
var _TextArea = _interopRequireDefault(require("@digigov/react-core/TextArea"));
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var _reactCore = require("@digigov/react-core");
|
|
21
|
+
|
|
22
|
+
var _reactHookForm = require("react-hook-form");
|
|
19
23
|
|
|
20
|
-
var
|
|
24
|
+
var _i18n = require("@digigov/ui/app/i18n");
|
|
25
|
+
|
|
26
|
+
var _excluded = ["name", "control", "type", "extra"];
|
|
21
27
|
var TYPES_MAP = {
|
|
22
28
|
string: 'text',
|
|
23
29
|
"int": 'text',
|
|
@@ -27,14 +33,17 @@ var TYPES_MAP = {
|
|
|
27
33
|
|
|
28
34
|
var Input = /*#__PURE__*/_react["default"].forwardRef(function WrappedInput(_ref, ref) {
|
|
29
35
|
var name = _ref.name,
|
|
36
|
+
control = _ref.control,
|
|
30
37
|
type = _ref.type,
|
|
31
38
|
extra = _ref.extra,
|
|
32
39
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
33
40
|
|
|
41
|
+
// eslint-disable-next-line prefer-const
|
|
34
42
|
var _ref2 = extra || {},
|
|
35
43
|
_ref2$multiline = _ref2.multiline,
|
|
36
44
|
multiline = _ref2$multiline === void 0 ? false : _ref2$multiline,
|
|
37
|
-
rows = _ref2.rows
|
|
45
|
+
rows = _ref2.rows,
|
|
46
|
+
limit = _ref2.limit;
|
|
38
47
|
|
|
39
48
|
var _ref3 = extra || {},
|
|
40
49
|
className = _ref3.className; // if enforced to multiline use true. Derive from type otherwise.
|
|
@@ -46,8 +55,16 @@ var Input = /*#__PURE__*/_react["default"].forwardRef(function WrappedInput(_ref
|
|
|
46
55
|
|
|
47
56
|
var fieldType = TYPES_MAP[type || 'text'] || 'text';
|
|
48
57
|
|
|
58
|
+
var _useTranslation = (0, _i18n.useTranslation)(),
|
|
59
|
+
t = _useTranslation.t;
|
|
60
|
+
|
|
61
|
+
var currentValue = (0, _reactHookForm.useWatch)({
|
|
62
|
+
control: control,
|
|
63
|
+
name: name
|
|
64
|
+
});
|
|
65
|
+
|
|
49
66
|
if (multiline === true) {
|
|
50
|
-
return /*#__PURE__*/_react["default"].createElement(_TextArea["default"], (0, _extends2["default"])({
|
|
67
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_TextArea["default"], (0, _extends2["default"])({
|
|
51
68
|
name: name,
|
|
52
69
|
className: className,
|
|
53
70
|
rows: rows,
|
|
@@ -56,7 +73,11 @@ var Input = /*#__PURE__*/_react["default"].forwardRef(function WrappedInput(_ref
|
|
|
56
73
|
reset: undefined,
|
|
57
74
|
required: undefined,
|
|
58
75
|
type: fieldType
|
|
59
|
-
})))
|
|
76
|
+
}))), (limit === null || limit === void 0 ? void 0 : limit.max) && /*#__PURE__*/_react["default"].createElement(_reactCore.Hint, null, currentValue === undefined || (currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) >= 0 && (currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) <= (limit === null || limit === void 0 ? void 0 : limit.max) ? /*#__PURE__*/_react["default"].createElement("span", null, t('form.info.text.you_have'), ' ', /*#__PURE__*/_react["default"].createElement("b", null, !currentValue ? limit.max : (limit === null || limit === void 0 ? void 0 : limit.max) - (currentValue === null || currentValue === void 0 ? void 0 : currentValue.length)), ' ', currentValue && (limit === null || limit === void 0 ? void 0 : limit.max) - (currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) === 1 ? "".concat(t('form.info.text.character')) : "".concat(t('form.info.text.characters')), ' ', t('form.info.text.remaining'), ".") : /*#__PURE__*/_react["default"].createElement("span", {
|
|
77
|
+
style: {
|
|
78
|
+
color: '#b60202'
|
|
79
|
+
}
|
|
80
|
+
}, t('form.info.text.you_have'), ' ', /*#__PURE__*/_react["default"].createElement("b", null, currentValue && (currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) - (limit === null || limit === void 0 ? void 0 : limit.max)), ' ', (currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) - (limit === null || limit === void 0 ? void 0 : limit.max) === 1 ? "".concat(t('form.info.text.character')) : "".concat(t('form.info.text.characters')), ' ', t('form.info.text.too_many'), ".")));
|
|
60
81
|
} else {
|
|
61
82
|
return /*#__PURE__*/_react["default"].createElement(_TextInput["default"], (0, _extends2["default"])({
|
|
62
83
|
name: name,
|
package/inputs/Label/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { FieldLabelProps } from '@digigov/form/types';
|
|
|
3
3
|
export interface FieldOptionProps {
|
|
4
4
|
label?: FieldLabelProps;
|
|
5
5
|
value: string;
|
|
6
|
+
show?: string[];
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
selected?: () => React.FC;
|
|
9
|
+
divider?: string;
|
|
8
10
|
}
|
|
9
11
|
export interface LabelProps {
|
|
10
12
|
primary?: string;
|
package/inputs/Label/index.js
CHANGED
|
@@ -9,10 +9,10 @@ exports["default"] = exports.Label = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
var _Hint = _interopRequireDefault(require("@digigov/react-core/Hint"));
|
|
13
|
-
|
|
14
12
|
var _LabelTitle = _interopRequireDefault(require("@digigov/react-core/LabelTitle"));
|
|
15
13
|
|
|
14
|
+
var _Hint = _interopRequireDefault(require("@digigov/react-core/Hint"));
|
|
15
|
+
|
|
16
16
|
var _i18n = require("@digigov/ui/app/i18n");
|
|
17
17
|
|
|
18
18
|
var Label = function Label(_ref) {
|
|
@@ -5,4 +5,6 @@ declare namespace _default {
|
|
|
5
5
|
}
|
|
6
6
|
export default _default;
|
|
7
7
|
export * from "@digigov/form/inputs/Radio/__stories__/Default";
|
|
8
|
+
export * from "@digigov/form/inputs/Radio/__stories__/WithDivider";
|
|
9
|
+
export * from "@digigov/form/inputs/Radio/__stories__/Conditional";
|
|
8
10
|
import Radio from "@digigov/form/inputs/Radio";
|