@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
@@ -3,13 +3,9 @@ id: ask-users-recursive
3
3
  title: Ask users for recursive data
4
4
  ---
5
5
 
6
- import LeadText from '@site/src/components/LeadText';
7
-
8
- <LeadText>
9
- Multiplicity & FieldArray fields allow users to input data described by a
10
- particular schema for an arbitrary number of times until they are done. It can
11
- be used to input a fixed, a minimum, and a maximum length of instances.
12
- </LeadText>
6
+ Multiplicity & FieldArray fields allow users to input data described by a
7
+ particular schema for an arbitrary number of times until they are done. It can
8
+ be used to input a fixed, a minimum, and a maximum length of instances.
13
9
 
14
10
  ## What we are trying to achieve
15
11
 
@@ -108,7 +104,7 @@ This field is the most complex component we currently offer, and it uses the
108
104
  react-hook-form under the hood. First, let's take a look at what it looks like, and then we can
109
105
  break down its functionality and how you can use it.
110
106
 
111
- ```jsx live
107
+ ```jsx
112
108
  import React from 'react';
113
109
  import Form, { Field } from '@digigov/form';
114
110
  import Button from '@digigov/ui/form/Button';
@@ -209,7 +205,7 @@ are asking users for information about their vehicles, we can also fill in the `
209
205
  `label.primary`, as well as the `type` and `required`
210
206
  props.
211
207
 
212
- ```jsx
208
+ ```jsx pure
213
209
  <Field
214
210
  key="vehicles"
215
211
  name="vehicles"
@@ -232,7 +228,7 @@ inner form, respectively.
232
228
  Inside the `of` key you can add an `extra` key that will then contain a `fields`
233
229
  key describing the field props for all inputs needed.
234
230
 
235
- ```js
231
+ ```js pure
236
232
  // this will be used as value for the `extra` prop
237
233
  {
238
234
  of: {
@@ -290,7 +286,7 @@ As a result, if you learn how to use one, you can easily use the other, and
290
286
  naturally, you can also change their behaviour by changing a single prop in your
291
287
  React code.
292
288
 
293
- ```jsx
289
+ ```jsx pure
294
290
  <Field
295
291
  key="vehicles"
296
292
  name="vehicles"
@@ -305,7 +301,7 @@ React code.
305
301
  The end result looks very different from Multiplicity at first glance, but you
306
302
  can achieve the same results with both of them.
307
303
 
308
- ```jsx live
304
+ ```jsx
309
305
  import React from 'react';
310
306
  import Form, { Field } from '@digigov/form';
311
307
  import Button from '@digigov/ui/form/Button';
@@ -396,7 +392,7 @@ should expect to need some length validation sooner than later.
396
392
  You can easily validate the exact length of the items added to the multipliticy
397
393
  array, simply by using the `extra.length` prop.
398
394
 
399
- ```jsx
395
+ ```jsx pure
400
396
  <Field
401
397
  extra={{
402
398
  length: 2,
@@ -409,7 +405,7 @@ array, simply by using the `extra.length` prop.
409
405
  The example below will validate this and show all the error messages necessary
410
406
  to make sure that the users understand what is going wrong with the process.
411
407
 
412
- ```jsx live
408
+ ```jsx
413
409
  import React from 'react';
414
410
  import Form, { Field } from '@digigov/form';
415
411
  import Button from '@digigov/ui/form/Button';
@@ -497,7 +493,7 @@ Do not mix and match the exact `length` validation with the `min` or `max`.
497
493
 
498
494
  :::
499
495
 
500
- ```jsx
496
+ ```jsx pure
501
497
  <Field
502
498
  extra={{
503
499
  min: 2,
@@ -511,7 +507,7 @@ Do not mix and match the exact `length` validation with the `min` or `max`.
511
507
  The example below will validate this and show all the error messages necessary
512
508
  to make sure that the users understand what is going wrong with the process.
513
509
 
514
- ```jsx live
510
+ ```jsx
515
511
  import React from 'react';
516
512
  import Form, { Field } from '@digigov/form';
517
513
  import Button from '@digigov/ui/form/Button';
@@ -1,19 +1,20 @@
1
1
  import React, { useState } from 'react';
2
2
  import { useFieldArray, UseFormReturn } from 'react-hook-form';
3
- import FieldContainer from '@digigov/form/Field/FieldBaseContainer';
4
-
5
- import FieldObject from '@digigov/form/FieldObject';
6
- import AddObjects from '@digigov/form/MultiplicityField/add-objects';
3
+ import { FieldBaseContainer } from '@digigov/form/Field/FieldBaseContainer';
4
+ import { FieldObject } from '@digigov/form/FieldObject';
5
+ import { AddObjects } from '@digigov/form/MultiplicityField/add-objects';
7
6
  import {
8
7
  MultiplicityProps,
9
8
  StashedObject,
10
9
  } from '@digigov/form/MultiplicityField/types';
11
- import { Button } from '@digigov/react-core/Button';
12
- import { Card } from '@digigov/react-core/Card';
13
- import { CardAction } from '@digigov/react-core/CardAction';
14
- import { CardContent } from '@digigov/react-core/CardContent';
15
- import { CardHeading } from '@digigov/react-core/CardHeading';
16
- import { Heading } from '@digigov/react-core/Heading';
10
+ import {
11
+ Card,
12
+ CardHeading,
13
+ CardContent,
14
+ CardAction,
15
+ } from '@digigov/ui/content/Card';
16
+ import { Button } from '@digigov/ui/form/Button';
17
+ import { Heading } from '@digigov/ui/typography/Heading';
17
18
 
18
19
  // epeidh einai forwardRef to ref mas to dinei xwrista apo ta props
19
20
  export const Multiplicity: React.FC<MultiplicityProps> = ({
@@ -48,7 +49,7 @@ export const Multiplicity: React.FC<MultiplicityProps> = ({
48
49
  setStashedObjects(newStashedObjects);
49
50
  };
50
51
  return (
51
- <FieldContainer
52
+ <FieldBaseContainer
52
53
  label={label}
53
54
  layout={layout}
54
55
  error={
@@ -99,7 +100,7 @@ export const Multiplicity: React.FC<MultiplicityProps> = ({
99
100
  clearErrors={clearErrors}
100
101
  Field={Field}
101
102
  />
102
- </FieldContainer>
103
+ </FieldBaseContainer>
103
104
  );
104
105
  };
105
106
 
@@ -1,12 +1,13 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { StepContext } from '@digigov/form/Questions/Step/StepContext';
3
- import Heading, { HeadingProps } from '@digigov/react-core/Heading';
4
- import HeadingCaption from '@digigov/react-core/HeadingCaption';
5
- import PageTitleContainer, {
3
+ import {
4
+ PageTitleContainer,
6
5
  PageTitleCaption,
7
6
  } from '@digigov/ui/app/PageTitleContainer';
8
7
  import { useTranslation } from '@digigov/ui/i18n';
9
8
  import { BackLink } from '@digigov/ui/navigation/BackLink';
9
+ import { Heading, HeadingProps } from '@digigov/ui/typography/Heading';
10
+ import { HeadingCaption } from '@digigov/ui/typography/HeadingCaption';
10
11
 
11
12
  export interface StepTitleInterface {
12
13
  title?: string;
@@ -1,72 +1,76 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`renders the Questions 1`] = `
4
4
  <body>
5
5
  <div>
6
6
  <a
7
- class="ds-back-link ds-print-hidden"
7
+ class="ds-print-hidden ds-back-link"
8
8
  tabindex="0"
9
9
  >
10
10
  <svg
11
11
  aria-hidden="true"
12
+ as="svg"
12
13
  class="ds-svg-icon--caret ds-svg-icon"
13
14
  focusable="false"
14
15
  viewBox="0 0 24 24"
15
16
  >
16
17
  <path
18
+ as="path"
19
+ class=""
17
20
  d="M18,22V2L6,12L18,22z"
18
21
  />
19
22
  </svg>
20
23
  Πίσω
21
24
  </a>
22
25
  <div
23
- class="ds-page-title"
26
+ class=" ds-page-title"
24
27
  >
25
28
  <span
26
- class="ds-caption-xl"
29
+ class=" ds-caption-xl"
27
30
  >
28
31
  intro.caption
29
32
  </span>
30
33
  <h1
31
- class="ds-heading-xl"
34
+ class=" ds-heading-xl"
32
35
  >
33
36
  intro.title
34
37
  </h1>
35
38
  </div>
36
39
  <p
37
- class="ds-body"
40
+ class=" ds-body"
38
41
  >
39
42
  This is the intro
40
43
  </p>
41
44
  <form
42
- class="ds-form"
45
+ class=" ds-form"
43
46
  >
44
47
  <div
45
- class="ds-field xs:ds-grid__col-span-12"
48
+ class=" ds-field xs:ds-grid__col-span-12"
46
49
  >
47
50
  <label
48
- class="ds-label"
51
+ class=" ds-label"
49
52
  >
50
53
  <span
51
- class="ds-heading-sm"
54
+ class=" ds-label__title ds-label__title--sm"
52
55
  >
53
56
  name.field.primary
54
57
  </span>
55
58
  <p
56
- class="ds-hint"
59
+ class=" ds-hint"
57
60
  >
58
61
  name.field.secondary
59
62
  </p>
60
63
  <input
61
64
  aria-required="true"
62
- class="ds-input"
65
+ class=" ds-input"
66
+ data-type="string"
63
67
  name="name"
64
68
  type="text"
65
69
  />
66
70
  </label>
67
71
  </div>
68
72
  <button
69
- class="ds-btn-primary ds-btn ds-print-hidden"
73
+ class="ds-print-hidden ds-btn ds-btn-primary"
70
74
  type="submit"
71
75
  >
72
76
  Συνέχεια
@@ -14,14 +14,11 @@ import {
14
14
  TableDataCell,
15
15
  } from '@digigov/react-core';
16
16
 
17
- import LeadText from '@site/src/components/LeadText';
18
17
 
19
- <LeadText>
20
- Question pages are used to ask users meaningful questions needed by your
21
- GOV.GR service, or even gather data about their persona or their application
22
- status. Use step questions to make bigger forms less scary and easier to fill
23
- out.
24
- </LeadText>
18
+ Question pages are used to ask users meaningful questions needed by your
19
+ GOV.GR service, or even gather data about their persona or their application
20
+ status. Use step questions to make bigger forms less scary and easier to fill
21
+ out.
25
22
 
26
23
  ## Introduction to Question pages
27
24
 
@@ -41,7 +38,7 @@ Even if users struggle through to the end of a form and answer honestly, if it
41
38
  more work than they expected, they’ll be annoyed about it. That's the exact
42
39
  opposite of our goals of making concise, easy-to-use services.
43
40
 
44
- ```jsx live
41
+ ```jsx
45
42
  import React from 'react';
46
43
  import Questions, { Step, StepForm, StepTitle } from '@digigov/form/Questions';
47
44
  import { Field } from '@digigov/form';
@@ -159,7 +156,7 @@ its subsequent subcomponents that you customise as needed, like the step title,
159
156
  description or form. You can also add components that are not form-specific,
160
157
  adding paragraphs or other custom components.
161
158
 
162
- ```jsx
159
+ ```jsx pure
163
160
  <Questions name="example" steps={steps} onSubmit={(data) => doSomething(data)}>
164
161
  {/* more steps could be rendered here ... */}
165
162
  <Step name="age">
@@ -184,7 +181,7 @@ object. The most basic properties are the following:
184
181
  - `fields` - an array that describes each input field that will be rendered in
185
182
  the `StepForm`. Each fields implements the `FieldSpec` interface as a JSON object.
186
183
 
187
- ```json title="step-name.json"
184
+ ```json pure title="step-name.json"
188
185
  {
189
186
  "name": "name",
190
187
  "title": "What is your name?",
@@ -209,7 +206,7 @@ basic branching between each step. The `nextStep` property will need to be a
209
206
  function that will take the form state as an argument and will return the key of
210
207
  the next `step`.
211
208
 
212
- ```json title="next-step.json"
209
+ ```json pure title="next-step.json"
213
210
  const steps = [
214
211
  {
215
212
  name: 'age',
@@ -263,7 +260,7 @@ For example, you may use a form to determine if citizens are adults or not, and
263
260
  we want to ask users different questions according to their persona. We can use
264
261
  a branch between the `age` step and the other two steps.
265
262
 
266
- ```jsx live
263
+ ```jsx
267
264
  import React from 'react';
268
265
  import GovGRFooter from '@digigov/ui/govgr/Footer';
269
266
  import Header from '@digigov/ui/app/Header';
@@ -4,12 +4,8 @@ title: Create a simple Digigov Form
4
4
  sidebar_label: Creating simple forms
5
5
  ---
6
6
 
7
- import LeadText from '@site/src/components/LeadText';
8
-
9
- <LeadText>
10
- This guide walks through building a simple form page, complete with validation
11
- and data serialisation.
12
- </LeadText>
7
+ This guide walks through building a simple form page, complete with validation
8
+ and data serialisation.
13
9
 
14
10
  ## What we are building
15
11
 
@@ -4,14 +4,10 @@ title: Digigov Form
4
4
  sidebar_label: Introduction to Digigov Form
5
5
  ---
6
6
 
7
- import LeadText from '@site/src/components/LeadText';
8
-
9
- <LeadText>
10
- Digigov Form is an off-the-shelf solution for managing web forms using
11
- Reactjs. It supports flexible and multi-step forms and easy-to-use validation.
12
- This page will guide you through everything you need to create accessible and
13
- dynamic forms that can handle all sorts of user inputs.
14
- </LeadText>
7
+ Digigov Form is an off-the-shelf solution for managing web forms using
8
+ Reactjs. It supports flexible and multi-step forms and easy-to-use validation.
9
+ This page will guide you through everything you need to create accessible and
10
+ dynamic forms that can handle all sorts of user inputs.
15
11
 
16
12
  <img
17
13
  src="/img/form.svg"
@@ -11,19 +11,8 @@ options as the users type and also let them select an option from the list.
11
11
 
12
12
  ### Default
13
13
 
14
- <Story
15
- packageName="@digigov/form"
16
- component="inputs/AutoCompleteInput"
17
- story="Default.tsx"
18
- />
14
+ <code src="@digigov/form/inputs/AutoCompleteInput/__stories__/Default.tsx" />
19
15
 
20
16
  ### Display multiple values
21
17
 
22
- <Story
23
- packageName="@digigov/form"
24
- component="inputs/AutoCompleteInput"
25
- story="Multiple.tsx"
26
- />
27
-
28
-
29
-
18
+ <code src="@digigov/form/inputs/AutoCompleteInput/__stories__/Multiple.tsx" />
@@ -1,12 +1,12 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { ControlledFieldProps } from '@digigov/form/Field/types';
3
3
  import { FieldOptionProps } from '@digigov/form/inputs/Label';
4
- import { Hint } from '@digigov/react-core/Hint';
5
- import UIAutoComplete, {
4
+ import {
5
+ AutoComplete,
6
6
  AutoCompleteProps as UIAutoCompleteProps,
7
7
  } from '@digigov/ui/form/AutoComplete';
8
- import { Base } from '@digigov/react-core/Base';
9
-
8
+ import { Hint } from '@digigov/ui/typography/Hint';
9
+ import { Base } from '@digigov/ui/utils/Base';
10
10
  export interface AutoCompleteInputExtra
11
11
  extends Omit<
12
12
  UIAutoCompleteProps,
@@ -36,33 +36,38 @@ export const AutoCompleteInput: React.FC<AutoCompleteInputProps> = ({
36
36
  error,
37
37
  ...props
38
38
  }) => {
39
- const suggest = useCallback(function suggest(
40
- query: string,
41
- syncResults: (options: any[]) => void
42
- ): void {
43
- syncResults(
44
- query
45
- ? options.filter(function (option) {
46
- return (
47
- `${option.value} ${option.label?.primary || ''} ${option.label?.secondary || ''
48
- }`
49
- .toLowerCase()
50
- .indexOf(query.toLowerCase()) !== -1
51
- );
52
- })
53
- : options
54
- );
55
- },
56
- [options]);
39
+ const suggest = useCallback(
40
+ function suggest(
41
+ query: string,
42
+ syncResults: (options: any[]) => void
43
+ ): void {
44
+ syncResults(
45
+ query
46
+ ? options.filter(function (option) {
47
+ return (
48
+ `${option.value} ${option.label?.primary || ''} ${
49
+ option.label?.secondary || ''
50
+ }`
51
+ .toLowerCase()
52
+ .indexOf(query.toLowerCase()) !== -1
53
+ );
54
+ })
55
+ : options
56
+ );
57
+ },
58
+ [options]
59
+ );
57
60
 
58
61
  return (
59
- <UIAutoComplete
62
+ <AutoComplete
60
63
  multiple={type === 'choice:multiple' ? true : false}
61
64
  source={suggest}
62
65
  onConfirm={(value) => {
63
66
  if (Array.isArray(value)) {
64
- const selectedValues = value.map(item => item.value);
65
- selectedValues.length > 0 ? onChange(selectedValues) : onChange(undefined);
67
+ const selectedValues = value.map((item) => item.value);
68
+ selectedValues.length > 0
69
+ ? onChange(selectedValues)
70
+ : onChange(undefined);
66
71
  } else {
67
72
  onChange(value.value);
68
73
  }
@@ -95,4 +100,4 @@ export const AutoCompleteInput: React.FC<AutoCompleteInputProps> = ({
95
100
  );
96
101
  };
97
102
 
98
- export default AutoCompleteInput;
103
+ export default AutoCompleteInput;
@@ -10,24 +10,14 @@ Checkboxes are used to let a user select one or more options of a limited number
10
10
 
11
11
  ### Default
12
12
 
13
- <Story
14
- packageName="@digigov/form"
15
- component="inputs/Checkboxes"
16
- story="Default.tsx"
17
- />
13
+ <code src="@digigov/form/inputs/Checkboxes/__stories__/Default.tsx" />
14
+
18
15
 
19
16
  ### Conditional
20
17
 
21
- <Story
22
- packageName="@digigov/form"
23
- component="inputs/Checkboxes"
24
- story="Conditional.tsx"
25
- />
18
+ <code src="@digigov/form/inputs/Checkboxes/__stories__/Conditional.tsx" />
19
+
26
20
 
27
21
  ### With divider
28
22
 
29
- <Story
30
- packageName="@digigov/form"
31
- component="inputs/Checkboxes"
32
- story="WithDivider.tsx"
33
- />
23
+ <code src="@digigov/form/inputs/Checkboxes/__stories__/WithDivider.tsx" />
@@ -1,11 +1,13 @@
1
1
  import React, { useState } from 'react';
2
2
  import { ControlledFieldProps } from '@digigov/form/Field/types';
3
3
  import { FieldOptionProps } from '@digigov/form/inputs/Label';
4
- import CoreCheckboxes from '@digigov/react-core/Checkbox';
5
- import { CheckboxConditional } from '@digigov/react-core/CheckboxConditional';
6
- import CheckboxItem from '@digigov/react-core/CheckboxItem';
7
- import Hint from '@digigov/react-core/Hint';
4
+ import {
5
+ Checkbox,
6
+ CheckboxItem,
7
+ CheckboxConditional,
8
+ } from '@digigov/ui/form/Checkbox';
8
9
  import { useTranslation } from '@digigov/ui/i18n';
10
+ import { Hint } from '@digigov/ui/typography/Hint';
9
11
 
10
12
  export interface CheckboxesProps
11
13
  extends Omit<ControlledFieldProps, 'extra' | 'value'> {
@@ -29,34 +31,34 @@ export const Checkboxes: React.FC<CheckboxesProps> = ({
29
31
  if (!value) value = [];
30
32
  const handleChange =
31
33
  (optionValue, idx, show) =>
32
- (evt): void => {
33
- let newValue;
34
- if (evt.currentTarget.checked) {
35
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
- // @ts-ignore
37
- newValue = value.concat([optionValue]);
38
- } else {
39
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
- // @ts-ignore
41
- newValue = value.filter((val) => val !== optionValue);
42
- }
43
- if (show && show.length > 0) {
44
- setChecked((items) =>
45
- items.map((item, index) => (index === idx ? !item : item))
46
- );
47
- }
34
+ (evt): void => {
35
+ let newValue;
36
+ if (evt.currentTarget.checked) {
37
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
38
+ // @ts-ignore
39
+ newValue = value.concat([optionValue]);
40
+ } else {
41
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
+ // @ts-ignore
43
+ newValue = value.filter((val) => val !== optionValue);
44
+ }
45
+ if (show && show.length > 0) {
46
+ setChecked((items) =>
47
+ items.map((item, index) => (index === idx ? !item : item))
48
+ );
49
+ }
48
50
 
49
- // reset value to undefined instead of an empty array
50
- // so the error state mechanism can throw validation errors
51
- if (newValue.length === 0) newValue = undefined;
52
- onChange(newValue);
53
- };
51
+ // reset value to undefined instead of an empty array
52
+ // so the error state mechanism can throw validation errors
53
+ if (newValue.length === 0) newValue = undefined;
54
+ onChange(newValue);
55
+ };
54
56
  const { t } = useTranslation();
55
57
  const [checked, setChecked] = useState(
56
58
  Array<boolean>(options.length).fill(false)
57
59
  );
58
60
  return (
59
- <CoreCheckboxes className={className}>
61
+ <Checkbox className={className}>
60
62
  {options.map(
61
63
  (
62
64
  {
@@ -103,7 +105,7 @@ export const Checkboxes: React.FC<CheckboxesProps> = ({
103
105
  </React.Fragment>
104
106
  )
105
107
  )}
106
- </CoreCheckboxes>
108
+ </Checkbox>
107
109
  );
108
110
  };
109
111
 
@@ -13,11 +13,4 @@ either with a textbox that validates the input or a special date picker interfac
13
13
 
14
14
  ### Default
15
15
 
16
- <Story
17
- packageName="@digigov/form"
18
- component="inputs/DateInput"
19
- story="Default.tsx"
20
- />
21
-
22
-
23
-
16
+ <code src="@digigov/form/inputs/DateInput/__stories__/Default.tsx" />
@@ -2,8 +2,10 @@ import React, { useMemo, useState } from 'react';
2
2
  import dayjs from 'dayjs';
3
3
  import customParseFormat from 'dayjs/plugin/customParseFormat';
4
4
  import { UncontrolledFieldProps } from '@digigov/form/Field/types';
5
- import DateInputContainer from '@digigov/react-core/DateInputContainer';
6
- import CoreDateInputItem from '@digigov/react-core/DateInputItem';
5
+ import {
6
+ DateInputContainer,
7
+ DateInputItem,
8
+ } from '@digigov/ui/form/DateInputContainer';
7
9
  import { useTranslation } from '@digigov/ui/i18n';
8
10
  dayjs.extend(customParseFormat);
9
11
 
@@ -75,7 +77,7 @@ const makeDate = (val) => {
75
77
  };
76
78
 
77
79
  const DatePart = ({ label, ...props }) => {
78
- return <CoreDateInputItem {...props}>{label}</CoreDateInputItem>;
80
+ return <DateInputItem {...props}>{label}</DateInputItem>;
79
81
  };
80
82
 
81
83
  export const DateInput = ({ name, type, ...props }) => {
@@ -12,8 +12,4 @@ Input element of type `file` let the user choose one or more files from their de
12
12
 
13
13
  ### Default
14
14
 
15
- <Story
16
- packageName="@digigov/form"
17
- component="inputs/FileInput"
18
- story="Default.tsx"
19
- />
15
+ <code src="@digigov/form/inputs/FileInput/__stories__/Default.tsx" />
@@ -1,11 +1,10 @@
1
1
  import React, { useState } 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 from '@digigov/ui/form/Button';
3
+ import { Button } 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';
6
+ import { Hint } from '@digigov/ui/typography/Hint';
7
+ import { Paragraph } from '@digigov/ui/typography/Paragraph';
9
8
  export interface FileInputProps extends Omit<UncontrolledFieldProps, 'extra'> {
10
9
  extra?: {
11
10
  className?: string;
@@ -44,7 +43,7 @@ export const FileInput: React.FC<any> = React.forwardRef(function FileInput(
44
43
  </Paragraph>
45
44
  </>
46
45
  ) : (
47
- <CoreHint>{t('upload.no_file')}</CoreHint>
46
+ <Hint>{t('upload.no_file')}</Hint>
48
47
  )}
49
48
  <FileUpload
50
49
  ref={ref}
@@ -9,6 +9,8 @@ const FIELDS: FieldSpec[] = [
9
9
  required: true,
10
10
  label: {
11
11
  primary: 'Ανέβασμα φωτογραφίας',
12
+ secondary:
13
+ 'Οι επιτρεπόμενες διαστάσεις είναι για το ύψος από 100 μέχρι 400 και για το πλάτος από 100 μέχρι 400.',
12
14
  },
13
15
  extra: {
14
16
  limit: {