@digigov/form 2.0.0-6e3977bc → 2.0.0-834daea4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/Field/FieldBaseContainer/index.js +3 -3
  2. package/Field/FieldBaseContainer.js.map +2 -2
  3. package/Field/types.d.ts +1 -0
  4. package/FieldArray/index.js +4 -4
  5. package/FieldArray/index.js.map +2 -2
  6. package/FieldObject/index.js +2 -2
  7. package/FieldObject/index.js.map +2 -2
  8. package/Fieldset/index.d.ts +1 -1
  9. package/Fieldset/index.js +5 -5
  10. package/Fieldset/index.js.map +2 -2
  11. package/Fieldset/types.d.ts +2 -2
  12. package/FormBuilder/index.js +3 -3
  13. package/FormBuilder/index.js.map +2 -2
  14. package/MultiplicityField/add-objects/index.js +4 -4
  15. package/MultiplicityField/add-objects.js.map +2 -2
  16. package/MultiplicityField/index.js +12 -10
  17. package/MultiplicityField/index.js.map +2 -2
  18. package/Questions/Step/StepTitle/index.js +4 -3
  19. package/Questions/Step/StepTitle.d.ts +1 -1
  20. package/Questions/Step/StepTitle.js.map +2 -2
  21. package/cjs/Field/FieldBaseContainer/index.js +3 -3
  22. package/cjs/Field/FieldBaseContainer.js.map +3 -3
  23. package/cjs/Field/types.js.map +1 -1
  24. package/cjs/FieldArray/index.js +6 -6
  25. package/cjs/FieldArray/index.js.map +3 -3
  26. package/cjs/FieldObject/index.js +3 -3
  27. package/cjs/FieldObject/index.js.map +3 -3
  28. package/cjs/Fieldset/index.js +10 -10
  29. package/cjs/Fieldset/index.js.map +3 -3
  30. package/cjs/Fieldset/types.js.map +1 -1
  31. package/cjs/FormBuilder/index.js +5 -5
  32. package/cjs/FormBuilder/index.js.map +3 -3
  33. package/cjs/MultiplicityField/add-objects/index.js +8 -8
  34. package/cjs/MultiplicityField/add-objects.js.map +3 -3
  35. package/cjs/MultiplicityField/index.js +11 -14
  36. package/cjs/MultiplicityField/index.js.map +3 -3
  37. package/cjs/Questions/Step/StepTitle/index.js +5 -5
  38. package/cjs/Questions/Step/StepTitle.js.map +3 -3
  39. package/cjs/inputs/AutoCompleteInput/index.js +4 -4
  40. package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
  41. package/cjs/inputs/Checkboxes/index.js +6 -8
  42. package/cjs/inputs/Checkboxes/index.js.map +3 -3
  43. package/cjs/inputs/DateInput/index.js +3 -4
  44. package/cjs/inputs/DateInput/index.js.map +3 -3
  45. package/cjs/inputs/FileInput/index.js +7 -8
  46. package/cjs/inputs/FileInput/index.js.map +3 -3
  47. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  48. package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  49. package/cjs/inputs/ImageInput/index.js +7 -8
  50. package/cjs/inputs/ImageInput/index.js.map +3 -3
  51. package/cjs/inputs/Input/index.js +4 -4
  52. package/cjs/inputs/Input/index.js.map +2 -2
  53. package/cjs/inputs/Label/index.js +3 -3
  54. package/cjs/inputs/Label/index.js.map +3 -3
  55. package/cjs/inputs/Radio/index.js +11 -13
  56. package/cjs/inputs/Radio/index.js.map +3 -3
  57. package/cjs/inputs/Select/index.js +3 -4
  58. package/cjs/inputs/Select/index.js.map +3 -3
  59. package/cjs/lazy/index.js +4 -0
  60. package/cjs/lazy.js.map +2 -2
  61. package/cjs/registry/index.js +2 -0
  62. package/cjs/registry.js.map +2 -2
  63. package/cjs/validators/index.js +6 -65
  64. package/cjs/validators/index.js.map +3 -3
  65. package/cjs/validators/utils/date/index.js +138 -0
  66. package/cjs/validators/utils/date.js.map +7 -0
  67. package/cjs/validators/utils/index.js +3 -1
  68. package/cjs/validators/utils/index.js.map +2 -2
  69. package/index.js +1 -1
  70. package/inputs/AutoCompleteInput/index.js +6 -4
  71. package/inputs/AutoCompleteInput/index.js.map +2 -2
  72. package/inputs/Checkboxes/index.js +7 -5
  73. package/inputs/Checkboxes/index.js.map +2 -2
  74. package/inputs/DateInput/index.js +5 -3
  75. package/inputs/DateInput/index.js.map +2 -2
  76. package/inputs/FileInput/index.js +5 -6
  77. package/inputs/FileInput/index.js.map +2 -2
  78. package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +2 -1
  79. package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +2 -2
  80. package/inputs/ImageInput/index.js +6 -7
  81. package/inputs/ImageInput/index.js.map +2 -2
  82. package/inputs/Input/index.js +4 -4
  83. package/inputs/Input/index.js.map +2 -2
  84. package/inputs/Label/index.js +2 -2
  85. package/inputs/Label/index.js.map +2 -2
  86. package/inputs/Radio/index.js +7 -5
  87. package/inputs/Radio/index.js.map +2 -2
  88. package/inputs/Select/index.js +1 -2
  89. package/inputs/Select/index.js.map +2 -2
  90. package/lazy/index.js +4 -0
  91. package/lazy.d.ts +4 -0
  92. package/lazy.js.map +2 -2
  93. package/package.json +4 -4
  94. package/registry/index.js +2 -0
  95. package/registry.d.ts +1 -0
  96. package/registry.js.map +2 -2
  97. package/src/Field/FieldBaseContainer.tsx +4 -2
  98. package/src/Field/types.tsx +20 -19
  99. package/src/FieldArray/index.tsx +9 -8
  100. package/src/FieldObject/index.tsx +2 -2
  101. package/src/Fieldset/index.tsx +5 -5
  102. package/src/Fieldset/types.tsx +2 -2
  103. package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +20 -33
  104. package/src/FormBuilder/index.tsx +3 -3
  105. package/src/MultiplicityField/add-objects.tsx +5 -6
  106. package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +12 -16
  107. package/src/MultiplicityField/index.tsx +13 -12
  108. package/src/Questions/Step/StepTitle.tsx +4 -3
  109. package/src/Questions/__snapshots__/index.spec.tsx.snap +17 -13
  110. package/src/Questions/{index.mdx → doc.mdx} +9 -12
  111. package/src/create-simple-form.mdx +2 -6
  112. package/src/{index.mdx → doc.mdx} +4 -8
  113. package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
  114. package/src/inputs/AutoCompleteInput/index.tsx +31 -26
  115. package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
  116. package/src/inputs/Checkboxes/index.tsx +29 -27
  117. package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
  118. package/src/inputs/DateInput/index.tsx +5 -3
  119. package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
  120. package/src/inputs/FileInput/index.tsx +5 -6
  121. package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
  122. package/src/inputs/ImageInput/doc.mdx +23 -0
  123. package/src/inputs/ImageInput/index.tsx +9 -11
  124. package/src/inputs/Input/doc.mdx +56 -0
  125. package/src/inputs/Input/index.tsx +19 -11
  126. package/src/inputs/Label/doc.mdx +14 -0
  127. package/src/inputs/Label/index.tsx +2 -3
  128. package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
  129. package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
  130. package/src/inputs/Radio/index.tsx +57 -55
  131. package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
  132. package/src/inputs/Select/index.tsx +1 -2
  133. package/src/installation.mdx +2 -5
  134. package/src/lazy.js +4 -0
  135. package/src/registry.js +2 -0
  136. package/src/validators/index.ts +10 -70
  137. package/src/validators/utils/date.ts +107 -0
  138. package/src/validators/utils/index.ts +1 -0
  139. package/validators/index.js +10 -66
  140. package/validators/index.js.map +2 -2
  141. package/validators/utils/date/index.js +103 -0
  142. package/validators/utils/date/package.json +6 -0
  143. package/validators/utils/date.d.ts +9 -0
  144. package/validators/utils/date.js.map +7 -0
  145. package/validators/utils/index.d.ts +1 -0
  146. package/validators/utils/index.js +1 -0
  147. package/validators/utils/index.js.map +2 -2
  148. package/src/inputs/ImageInput/index.mdx +0 -19
  149. package/src/inputs/Input/index.mdx +0 -95
  150. package/src/inputs/Label/index.mdx +0 -0
  151. /package/src/Field/{index.mdx → doc.mdx} +0 -0
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: Image Input
3
+ ---
4
+
5
+ # Image input
6
+
7
+
8
+
9
+ Input element of type `image` defines an image as a submit button, i.e. submit buttons that take the form of an image rather than text.
10
+
11
+ ## How to use
12
+
13
+ ### Default
14
+
15
+ <code src="@digigov/form/inputs/ImageInput/__stories__/Default.tsx" />
16
+
17
+ ### Display with max size
18
+
19
+ <code src="@digigov/form/inputs/ImageInput/__stories__/MaxSize.tsx" />
20
+
21
+ ### Display with min and max image dimensions
22
+
23
+ <code src="@digigov/form/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx" />
@@ -1,12 +1,11 @@
1
1
  import React, { useState, useCallback } from 'react';
2
2
  import { UncontrolledFieldProps } from '@digigov/form/Field/types';
3
- import FileUpload from '@digigov/react-core/FileUpload';
4
- import FileUploadContainer from '@digigov/react-core/FileUploadContainer';
5
- import CoreHint from '@digigov/react-core/Hint';
6
- import Button, { ButtonGroup } from '@digigov/ui/form/Button';
3
+ import { Button, ButtonGroup } from '@digigov/ui/form/Button';
4
+ import { FileUpload, FileUploadContainer } from '@digigov/ui/form/FileUpload';
7
5
  import { useTranslation } from '@digigov/ui/i18n';
8
- import Paragraph from '@digigov/ui/typography/Paragraph';
9
- import { Base } from '@digigov/react-core/Base';
6
+ import { Hint } from '@digigov/ui/typography/Hint';
7
+ import { Paragraph } from '@digigov/ui/typography/Paragraph';
8
+ import { Base } from '@digigov/ui/utils/Base';
10
9
  export interface ImageProps {
11
10
  src?: any;
12
11
  }
@@ -20,7 +19,7 @@ export interface Limit {
20
19
  }
21
20
 
22
21
  export const Image: React.FC<ImageProps> = React.memo(function Image({ src }) {
23
- return <Base as='img' src={src} className="ds-image--ratio" />;
22
+ return <Base as="img" src={src} className="ds-image--ratio" />;
24
23
  });
25
24
  export interface ImageInputProps extends Omit<UncontrolledFieldProps, 'extra'> {
26
25
  extra?: {
@@ -72,13 +71,12 @@ export const ImageInput: React.FC<ImageInputProps> = React.forwardRef(
72
71
  {selectedImage !== null ? (
73
72
  <>
74
73
  <Paragraph>
75
- <Base as='b'>{t('upload.image')}:</Base> {`${selectedImage?.name}`}
74
+ <Base as="b">{t('upload.image')}:</Base>{' '}
75
+ {`${selectedImage?.name}`}
76
76
  </Paragraph>
77
77
  </>
78
78
  ) : (
79
- <CoreHint className="ds-dashed--border">
80
- {t('upload.no_image')}
81
- </CoreHint>
79
+ <Hint className="ds-dashed--border">{t('upload.no_image')}</Hint>
82
80
  )}
83
81
  <>
84
82
  {selectedImage !== null && <Image src={imageUrl} />}
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: Input
3
+ ---
4
+
5
+ # Input
6
+
7
+ The input element of type `string` is used to create interactive controls for web-based forms in order to accept data from the user;
8
+ a wide variety of types of input data and control widgets are available, depending on the device and user agent. The input element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.
9
+
10
+ ## How to use
11
+
12
+ ### String
13
+
14
+ <code src="@digigov/form/inputs/Input/__stories__/String.tsx" />
15
+
16
+ ### Boolean
17
+
18
+ <code src="@digigov/form/inputs/Input/__stories__/Boolean.tsx" />
19
+
20
+ ### AFM
21
+
22
+ <code src="@digigov/form/inputs/Input/__stories__/AFM.tsx" />
23
+
24
+
25
+ ### IBAN
26
+
27
+ <code src="@digigov/form/inputs/Input/__stories__/IBAN.tsx" />
28
+
29
+
30
+ ### Integer
31
+
32
+ <code src="@digigov/form/inputs/Input/__stories__/Integer.tsx" />
33
+
34
+
35
+ ### Landline number
36
+
37
+ <code src="@digigov/form/inputs/Input/__stories__/LandlineNumber.tsx" />
38
+
39
+
40
+ ### Mobile phone
41
+
42
+ <code src="@digigov/form/inputs/Input/__stories__/MobilePhone.tsx" />
43
+
44
+
45
+ ### Phone number
46
+
47
+ <code src="@digigov/form/inputs/Input/__stories__/PhoneNumber.tsx" />
48
+
49
+
50
+ ### Postal code
51
+
52
+ <code src="@digigov/form/inputs/Input/__stories__/PostalCode.tsx" />
53
+
54
+ ### Text with character limit
55
+
56
+ <code src="@digigov/form/inputs/Input/__stories__/TextWithLimit.tsx" />
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { useWatch } from 'react-hook-form';
3
3
  import { UncontrolledFieldProps } from '@digigov/form/Field/types';
4
- import { Hint } from '@digigov/react-core/Hint';
5
- import { TextArea } from '@digigov/react-core/TextArea';
6
- import { TextInput } from '@digigov/react-core/TextInput';
4
+ import { TextArea } from '@digigov/ui/form/TextArea';
5
+ import { TextInput } from '@digigov/ui/form/TextInput';
7
6
  import { useTranslation } from '@digigov/ui/i18n';
7
+ import { Hint } from '@digigov/ui/typography/Hint';
8
+
8
9
  const TYPES_MAP = {
9
10
  string: 'text',
10
11
  int: 'text',
@@ -27,7 +28,7 @@ export interface InputProps extends Omit<UncontrolledFieldProps, 'extra'> {
27
28
  }
28
29
 
29
30
  export const Input: React.ExoticComponent<InputProps> = React.forwardRef(
30
- function WrappedInput({ name, control, type, extra, ...props }, ref: never) {
31
+ function WrappedInput({ name, control, type, extra, Field, ...props }, ref: never) {
31
32
  // eslint-disable-next-line prefer-const
32
33
  let { multiline = false, rows, limit } = extra || {};
33
34
  const { className } = extra || {};
@@ -42,17 +43,23 @@ export const Input: React.ExoticComponent<InputProps> = React.forwardRef(
42
43
 
43
44
  const getRemainingChars = (currentValue, limit) => {
44
45
  if (currentValue) {
45
- return limit?.max - currentValue.length
46
+ return limit?.max - currentValue.length;
46
47
  }
47
48
  return limit?.max;
48
- }
49
+ };
49
50
 
50
51
  const constructRemainingText = (currentValue, limit) => {
51
52
  const remainingChars = getRemainingChars(currentValue, limit);
52
- let remainingText = Math.abs(remainingChars) === 1 ? t('form.info.text.character') : t('form.info.text.characters');
53
- remainingText += remainingChars > 0 ? ` ${t('form.info.text.remaining')}.` : ` ${t('form.info.text.too_many')}.`;
53
+ let remainingText =
54
+ Math.abs(remainingChars) === 1
55
+ ? t('form.info.text.character')
56
+ : t('form.info.text.characters');
57
+ remainingText +=
58
+ remainingChars > 0
59
+ ? ` ${t('form.info.text.remaining')}.`
60
+ : ` ${t('form.info.text.too_many')}.`;
54
61
  return remainingText;
55
- }
62
+ };
56
63
 
57
64
  if (multiline === true) {
58
65
  return (
@@ -72,8 +79,9 @@ export const Input: React.ExoticComponent<InputProps> = React.forwardRef(
72
79
  {limit?.max && (
73
80
  <Hint display={'flex'}>
74
81
  {t('form.info.text.you_have')}
75
- <Hint fontWeight='bold'>
76
- &nbsp;{`${Math.abs(getRemainingChars(currentValue, limit))}`}&nbsp;
82
+ <Hint fontWeight="bold">
83
+ &nbsp;{`${Math.abs(getRemainingChars(currentValue, limit))}`}
84
+ &nbsp;
77
85
  </Hint>
78
86
  {constructRemainingText(currentValue, limit)}
79
87
  </Hint>
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: Label
3
+ ---
4
+
5
+ # Label
6
+
7
+
8
+ The Label component is used to display descriptive text for form sections or fields. It supports both primary and secondary text, allowing for a title and optional subtitle.
9
+
10
+ ## How to use
11
+
12
+ ### Default
13
+
14
+ <code src="@digigov/form/inputs/Label/__stories__/Default.tsx" />
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { FieldLabelProps } from '@digigov/form/types';
3
- import Hint from '@digigov/react-core/Hint';
4
- import LabelTitle from '@digigov/react-core/LabelTitle';
3
+ import { LabelTitle } from '@digigov/ui/form/LabelContainer';
5
4
  import { useTranslation } from '@digigov/ui/i18n';
5
+ import { Hint } from '@digigov/ui/typography/Hint';
6
6
 
7
7
  export interface FieldOptionProps {
8
8
  label?: FieldLabelProps;
@@ -39,5 +39,4 @@ export const Label: React.FC<LabelProps> = ({ className, label, value }) => {
39
39
  );
40
40
  };
41
41
 
42
-
43
42
  export default Label;
@@ -13,11 +13,4 @@ on a computer system or other digital device.
13
13
 
14
14
  ### Default
15
15
 
16
- <Story
17
- packageName="@digigov/form"
18
- component="inputs/OtpInput"
19
- story="Default.tsx"
20
- />
21
-
22
-
23
-
16
+ <code src="@digigov/form/inputs/OtpInput/__stories__/Default.tsx" />
@@ -10,24 +10,14 @@ Radios are used to let a user select one option of a limited number of choices.
10
10
 
11
11
  ### Default
12
12
 
13
- <Story
14
- packageName="@digigov/form"
15
- component="inputs/Radio"
16
- story="Default.tsx"
17
- />
13
+ <code src="@digigov/form/inputs/Radio/__stories__/Default.tsx" />
14
+
18
15
 
19
16
  ### Conditional
20
17
 
21
- <Story
22
- packageName="@digigov/form"
23
- component="inputs/Radio"
24
- story="Conditional.tsx"
25
- />
18
+ <code src="@digigov/form/inputs/Radio/__stories__/Conditional.tsx" />
19
+
26
20
 
27
21
  ### With divider
28
22
 
29
- <Story
30
- packageName="@digigov/form"
31
- component="inputs/Radio"
32
- story="WithDivider.tsx"
33
- />
23
+ <code src="@digigov/form/inputs/Radio/__stories__/WithDivider.tsx" />
@@ -2,12 +2,14 @@ import React from 'react';
2
2
  import { useWatch } from 'react-hook-form';
3
3
  import { UncontrolledFieldProps } from '@digigov/form/Field/types';
4
4
  import { FieldOptionProps } from '@digigov/form/inputs/Label';
5
- import { Base } from '@digigov/react-core/Base';
6
- import Hint from '@digigov/react-core/Hint';
7
- import { RadioConditional } from '@digigov/react-core/RadioConditional';
8
- import RadioContainer from '@digigov/react-core/RadioContainer';
9
- import RadioItem from '@digigov/react-core/RadioItem';
5
+ import {
6
+ RadioContainer,
7
+ RadioItem,
8
+ RadioConditional,
9
+ } from '@digigov/ui/form/RadioContainer';
10
10
  import { useTranslation } from '@digigov/ui/i18n';
11
+ import { Hint } from '@digigov/ui/typography/Hint';
12
+ import { Base } from '@digigov/ui/utils/Base';
11
13
 
12
14
  export interface RadioButtonsGroupProps
13
15
  extends Omit<UncontrolledFieldProps, 'extra'> {
@@ -87,55 +89,55 @@ export const ControlledRadioButtonsGroup: React.FC<
87
89
  Field,
88
90
  ...props
89
91
  }) => {
90
- const currentValue: string | undefined = value;
91
- const { t } = useTranslation();
92
- return (
93
- <RadioContainer className={className} id={name}>
94
- {options.map(
95
- ({
96
- label,
97
- value: v,
98
- show,
99
- disabled: optionDisabled,
100
- selected,
101
- ...option
102
- }) => (
103
- <React.Fragment key={`${name}.${v}`}>
104
- <RadioItem
105
- onChange={(e) => {
106
- console.log(e);
107
- onChange(e);
108
- }}
109
- id={`${name}.${v}`}
110
- value={v}
111
- checked={currentValue === v}
112
- disabled={disabled || optionDisabled}
113
- {...option}
114
- {...{
115
- ...props,
116
- reset: undefined,
117
- required: undefined,
118
- error: undefined,
119
- 'aria-describedby': undefined,
120
- type: 'radio',
121
- }}
122
- >
123
- {(label && label.primary && t(label.primary)) || v}
124
- {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}
125
- </RadioItem>
126
- {selected && selected()}
127
- {currentValue === v && show && (
128
- <RadioConditional>
129
- {show.map((fieldName) => (
130
- <Field name={fieldName} key={fieldName} />
131
- ))}
132
- </RadioConditional>
133
- )}
134
- </React.Fragment>
135
- )
136
- )}
137
- </RadioContainer>
138
- );
139
- };
92
+ const currentValue: string | undefined = value;
93
+ const { t } = useTranslation();
94
+ return (
95
+ <RadioContainer className={className} id={name}>
96
+ {options.map(
97
+ ({
98
+ label,
99
+ value: v,
100
+ show,
101
+ disabled: optionDisabled,
102
+ selected,
103
+ ...option
104
+ }) => (
105
+ <React.Fragment key={`${name}.${v}`}>
106
+ <RadioItem
107
+ onChange={(e) => {
108
+ console.log(e);
109
+ onChange(e);
110
+ }}
111
+ id={`${name}.${v}`}
112
+ value={v}
113
+ checked={currentValue === v}
114
+ disabled={disabled || optionDisabled}
115
+ {...option}
116
+ {...{
117
+ ...props,
118
+ reset: undefined,
119
+ required: undefined,
120
+ error: undefined,
121
+ 'aria-describedby': undefined,
122
+ type: 'radio',
123
+ }}
124
+ >
125
+ {(label && label.primary && t(label.primary)) || v}
126
+ {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}
127
+ </RadioItem>
128
+ {selected && selected()}
129
+ {currentValue === v && show && (
130
+ <RadioConditional>
131
+ {show.map((fieldName) => (
132
+ <Field name={fieldName} key={fieldName} />
133
+ ))}
134
+ </RadioConditional>
135
+ )}
136
+ </React.Fragment>
137
+ )
138
+ )}
139
+ </RadioContainer>
140
+ );
141
+ };
140
142
 
141
143
  export default RadioButtonsGroup;
@@ -10,8 +10,4 @@ The select element represents a control that provides a menu of options.
10
10
 
11
11
  ### Default
12
12
 
13
- <Story
14
- packageName="@digigov/form"
15
- component="inputs/Select"
16
- story="Default.tsx"
17
- />
13
+ <code src="@digigov/form/inputs/Select/__stories__/Default.tsx" />
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { UncontrolledFieldProps } from '@digigov/form/Field/types';
3
3
  import { FieldOptionProps } from '@digigov/form/inputs/Label';
4
- import SelectContainer from '@digigov/react-core/SelectContainer';
5
- import SelectOption from '@digigov/react-core/SelectOption';
4
+ import { SelectContainer, SelectOption } from '@digigov/ui/form/SelectContainer';
6
5
 
7
6
  export interface SelectProps extends Omit<UncontrolledFieldProps, 'extra'> {
8
7
  extra: {
@@ -7,12 +7,9 @@ sidebar_label: Installation
7
7
  import Tabs from '@theme/Tabs';
8
8
  import TabItem from '@theme/TabItem';
9
9
  import CodeBlock from '@theme/CodeBlock';
10
- import LeadText from '@site/src/components/LeadText';
11
10
 
12
- <LeadText>
13
- This page will help you install Digigov Form depending on the framework that
14
- you use and the application architecture.
15
- </LeadText>
11
+ This page will help you install Digigov Form depending on the framework that
12
+ you use and the application architecture.
16
13
 
17
14
  We assume that your stack uses some of the following tools.
18
15
 
package/src/lazy.js CHANGED
@@ -29,6 +29,7 @@ export default {
29
29
  'Radio': lazy(() => import('@digigov/form/inputs').then((module)=> ({default: module['Radio']}))),
30
30
  'Select': lazy(() => import('@digigov/form/inputs/Select').then((module)=> ({default: module['Select']}))),
31
31
  'INPUTS_FIELDS': lazy(() => import('@digigov/form/inputs/inputsScenarios').then((module)=> ({default: module['INPUTS_FIELDS']}))),
32
+ 'MultipleInput': lazy(() => import('@digigov/form/inputs/MultipleInput').then((module)=> ({default: module['MultipleInput']}))),
32
33
  'REMOVE_SPACES': lazy(() => import('@digigov/form/inputs/OtpInput').then((module)=> ({default: module['REMOVE_SPACES']}))),
33
34
  'RE_DIGIT': lazy(() => import('@digigov/form/inputs/OtpInput').then((module)=> ({default: module['RE_DIGIT']}))),
34
35
  'ControlledRadioButtonsGroup': lazy(() => import('@digigov/form/inputs/Radio').then((module)=> ({default: module['ControlledRadioButtonsGroup']}))),
@@ -50,6 +51,9 @@ export default {
50
51
  'Questions': lazy(() => import('@digigov/form/Questions/Questions').then((module)=> ({default: module['Questions']}))),
51
52
  'QuestionsContext': lazy(() => import('@digigov/form/Questions/QuestionsContext').then((module)=> ({default: module['QuestionsContext']}))),
52
53
  'AFM_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/afm').then((module)=> ({default: module['AFM_VALIDATOR']}))),
54
+ 'DATE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/date').then((module)=> ({default: module['DATE_VALIDATOR']}))),
55
+ 'EARLIER_THAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/date').then((module)=> ({default: module['EARLIER_THAN_VALIDATOR']}))),
56
+ 'LATER_THAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/date').then((module)=> ({default: module['LATER_THAN_VALIDATOR']}))),
53
57
  'FILE_MAX_SIZE_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/file').then((module)=> ({default: module['FILE_MAX_SIZE_VALIDATOR']}))),
54
58
  'IBAN_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/iban').then((module)=> ({default: module['IBAN_VALIDATOR']}))),
55
59
  'IMAGE_DIMENSION_VALIDATOR': lazy(() => import('@digigov/form/validators/utils/image').then((module)=> ({default: module['IMAGE_DIMENSION_VALIDATOR']}))),
package/src/registry.js CHANGED
@@ -55,6 +55,7 @@ import * as _digigov_form_utils from '@digigov/form/utils';
55
55
  import * as _digigov_form_validators from '@digigov/form/validators';
56
56
  import * as _digigov_form_validators_types from '@digigov/form/validators/types';
57
57
  import * as _digigov_form_validators_utils_afm from '@digigov/form/validators/utils/afm';
58
+ import * as _digigov_form_validators_utils_date from '@digigov/form/validators/utils/date';
58
59
  import * as _digigov_form_validators_utils_file from '@digigov/form/validators/utils/file';
59
60
  import * as _digigov_form_validators_utils_iban from '@digigov/form/validators/utils/iban';
60
61
  import * as _digigov_form_validators_utils_image from '@digigov/form/validators/utils/image';
@@ -142,6 +143,7 @@ export default {
142
143
  '@digigov/form/validators': lazyImport(_digigov_form_validators),
143
144
  '@digigov/form/validators/types': lazyImport(_digigov_form_validators_types),
144
145
  '@digigov/form/validators/utils/afm': lazyImport(_digigov_form_validators_utils_afm),
146
+ '@digigov/form/validators/utils/date': lazyImport(_digigov_form_validators_utils_date),
145
147
  '@digigov/form/validators/utils/file': lazyImport(_digigov_form_validators_utils_file),
146
148
  '@digigov/form/validators/utils/iban': lazyImport(_digigov_form_validators_utils_iban),
147
149
  '@digigov/form/validators/utils/image': lazyImport(_digigov_form_validators_utils_image),
@@ -1,6 +1,4 @@
1
1
  import { MutableRefObject, useMemo } from 'react';
2
- import dayjs from 'dayjs';
3
- import customParseFormat from 'dayjs/plugin/customParseFormat';
4
2
  import * as yup from 'yup';
5
3
  import { AnyObjectSchema, StringSchema } from 'yup';
6
4
  import { RequiredArraySchema } from 'yup/lib/array';
@@ -22,16 +20,12 @@ import {
22
20
  POSTALCODE_VALIDATOR,
23
21
  UUID4_VALIDATOR,
24
22
  IMAGE_DIMENSION_VALIDATOR,
23
+ DATE_VALIDATOR,
24
+ LATER_THAN_VALIDATOR,
25
+ EARLIER_THAN_VALIDATOR,
25
26
  } from '@digigov/form/validators/utils';
26
27
  import { INT_VALIDATOR } from '@digigov/form/validators/utils/int';
27
28
  import { NUMBER_VALIDATOR } from '@digigov/form/validators/utils/number';
28
- dayjs.extend(customParseFormat);
29
-
30
- const VALID_DATE_FORMATS = ['DD/MM/YYYY'];
31
- const DATE_CACHE = {};
32
- const getDate = (v) => {
33
- return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
34
- };
35
29
 
36
30
  export const getYUPTypeMap = (): Record<string, any> => {
37
31
  const yupTypeMap = {
@@ -150,69 +144,15 @@ export const getYUPTypeMap = (): Record<string, any> => {
150
144
  AnyObject,
151
145
  string | null | undefined
152
146
  > => yup.string().nullable(),
153
- date: (field) => {
154
- let simpleDate = yup
155
- .string()
156
- .nullable(true)
157
- .test('date', 'form.error.date.invalid', function (value) {
158
- if (!value) return true;
159
- const date = getDate(value);
160
- return date.isValid();
161
- });
162
- const params = field.extra || {};
163
- if (params.max) {
164
- let maxDate;
165
- if (params.max === 'now') {
166
- const today = new Date();
167
- maxDate = new Date(today);
168
- } else {
169
- maxDate = getDate(params.max).toDate();
170
- }
171
- const maxNextDate = new Date(maxDate);
172
- maxNextDate.setDate(maxDate.getDate() + 1);
173
- simpleDate = simpleDate.test({
174
- name: 'earlier-than',
175
- message: {
176
- key: 'form.error.date.earlier_than',
177
- context: {
178
- maxDate: maxNextDate.toLocaleDateString(),
179
- },
180
- },
181
- test: function (value) {
182
- if (!value) return true;
183
- const date = getDate(value);
184
- const isValid = +date.toDate() < +maxDate;
185
- return isValid;
186
- },
187
- });
147
+ date: (field): yup.StringSchema => {
148
+ if (field?.extra?.min) {
149
+ return yup.string().test(LATER_THAN_VALIDATOR(field));
188
150
  }
189
- if (params.min) {
190
- let minDate;
191
- if (params.min === 'now') {
192
- const today = new Date();
193
- minDate = new Date(today);
194
- } else {
195
- minDate = getDate(params.min).toDate();
196
- }
197
- const minPreviousDate = new Date(minDate);
198
- minPreviousDate.setDate(minDate.getDate() - 1);
199
- simpleDate = simpleDate.test({
200
- name: 'later-than',
201
- message: {
202
- key: 'form.error.date.later_than',
203
- context: {
204
- minDate: minPreviousDate.toLocaleDateString(),
205
- },
206
- },
207
- test: function (value) {
208
- if (!value) return true;
209
- const date = getDate(value);
210
- const isValid = +date.toDate() > +minDate;
211
- return isValid;
212
- },
213
- });
151
+ if (field?.extra?.max) {
152
+ return yup.string().test(EARLIER_THAN_VALIDATOR(field));
153
+ } else {
154
+ return yup.string().test(DATE_VALIDATOR);
214
155
  }
215
- return simpleDate;
216
156
  },
217
157
  };
218
158
  return yupTypeMap;