@digigov/form 1.2.0-a7ffb5dc → 2.0.0-462194bf

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 (87) hide show
  1. package/Field/FieldBase/index.js +1 -0
  2. package/Field/utils/index.js +5 -5
  3. package/FieldObject/index.js +1 -1
  4. package/MultiplicityField/__stories__/PreviewDisplay/index.js +8 -2
  5. package/MultiplicityField/index.js +6 -1
  6. package/cjs/Field/FieldBase/index.js +1 -0
  7. package/cjs/Field/utils/index.js +5 -10
  8. package/cjs/FieldObject/index.js +2 -2
  9. package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +8 -2
  10. package/cjs/MultiplicityField/index.js +10 -5
  11. package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +12 -0
  12. package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +11 -16
  13. package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +52 -0
  14. package/cjs/inputs/AutoCompleteInput/index.js +22 -8
  15. package/cjs/inputs/AutoCompleteInput/index.mdx +29 -0
  16. package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +3 -2
  17. package/cjs/inputs/Checkboxes/index.js +2 -2
  18. package/cjs/inputs/Checkboxes/index.mdx +33 -0
  19. package/cjs/inputs/DateInput/index.mdx +23 -0
  20. package/cjs/inputs/FileInput/index.mdx +19 -0
  21. package/cjs/inputs/ImageInput/index.mdx +19 -0
  22. package/cjs/inputs/Input/index.js +2 -2
  23. package/cjs/inputs/Input/index.mdx +90 -3
  24. package/cjs/inputs/OtpInput/index.js +1 -0
  25. package/cjs/inputs/OtpInput/index.mdx +23 -0
  26. package/cjs/inputs/Radio/__stories__/Conditional/index.js +3 -2
  27. package/cjs/inputs/Radio/index.js +2 -2
  28. package/cjs/inputs/Radio/index.mdx +33 -0
  29. package/cjs/inputs/Select/index.mdx +17 -0
  30. package/cjs/validators/utils/file/index.js +11 -19
  31. package/index.js +1 -1
  32. package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +2 -1
  33. package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +1 -0
  34. package/inputs/AutoCompleteInput/__stories__/Default/index.js +9 -11
  35. package/inputs/AutoCompleteInput/__stories__/Default.d.ts +1 -0
  36. package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +45 -0
  37. package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +6 -0
  38. package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +3 -0
  39. package/inputs/AutoCompleteInput/index.d.ts +1 -1
  40. package/inputs/AutoCompleteInput/index.js +21 -7
  41. package/inputs/AutoCompleteInput/index.mdx +29 -0
  42. package/inputs/Checkboxes/__stories__/Conditional/index.js +2 -1
  43. package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -0
  44. package/inputs/Checkboxes/index.js +1 -1
  45. package/inputs/Checkboxes/index.mdx +33 -0
  46. package/inputs/DateInput/index.mdx +23 -0
  47. package/inputs/FileInput/index.mdx +19 -0
  48. package/inputs/ImageInput/index.mdx +19 -0
  49. package/inputs/Input/index.js +1 -1
  50. package/inputs/Input/index.mdx +90 -3
  51. package/inputs/OtpInput/index.d.ts +8 -1
  52. package/inputs/OtpInput/index.js +1 -1
  53. package/inputs/OtpInput/index.mdx +23 -0
  54. package/inputs/Radio/__stories__/Conditional/index.js +2 -1
  55. package/inputs/Radio/__stories__/Conditional.d.ts +1 -0
  56. package/inputs/Radio/index.js +1 -1
  57. package/inputs/Radio/index.mdx +33 -0
  58. package/inputs/Select/index.mdx +17 -0
  59. package/lazy.d.ts +1 -1
  60. package/package.json +4 -4
  61. package/src/Field/FieldBase.tsx +1 -0
  62. package/src/Field/utils.ts +4 -4
  63. package/src/FieldObject/index.tsx +1 -1
  64. package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -2
  65. package/src/MultiplicityField/index.tsx +7 -8
  66. package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +1 -0
  67. package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +27 -18
  68. package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +54 -0
  69. package/src/inputs/AutoCompleteInput/index.mdx +29 -0
  70. package/src/inputs/AutoCompleteInput/index.tsx +25 -15
  71. package/src/inputs/Checkboxes/__stories__/Conditional.tsx +2 -3
  72. package/src/inputs/Checkboxes/index.mdx +33 -0
  73. package/src/inputs/Checkboxes/index.tsx +3 -3
  74. package/src/inputs/DateInput/index.mdx +23 -0
  75. package/src/inputs/DateInput/index.tsx +1 -1
  76. package/src/inputs/FileInput/index.mdx +19 -0
  77. package/src/inputs/ImageInput/index.mdx +19 -0
  78. package/src/inputs/Input/index.mdx +90 -3
  79. package/src/inputs/Input/index.tsx +1 -1
  80. package/src/inputs/OtpInput/index.mdx +23 -0
  81. package/src/inputs/OtpInput/index.tsx +2 -2
  82. package/src/inputs/Radio/__stories__/Conditional.tsx +2 -0
  83. package/src/inputs/Radio/index.mdx +33 -0
  84. package/src/inputs/Radio/index.tsx +1 -1
  85. package/src/inputs/Select/index.mdx +17 -0
  86. package/src/validators/utils/file.ts +9 -9
  87. package/validators/utils/file/index.js +11 -19
@@ -1,8 +1,95 @@
1
1
  ---
2
2
  title: Input
3
- parent: docs/ui/components
4
3
  ---
4
+
5
+ # Input
6
+
7
+
8
+
9
+ The input element of type `string` is used to create interactive controls for web-based forms in order to accept data from the user;
10
+ 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.
11
+
12
+ ## How to use
13
+
14
+ ### Default
15
+
16
+ <Story
17
+ packageName="@digigov/form"
18
+ component="inputs/Input"
19
+ story="Default.tsx"
20
+ />
21
+
22
+ ### Boolean
23
+
24
+ <Story
25
+ packageName="@digigov/form"
26
+ component="inputs/Input"
27
+ story="Boolean.tsx"
28
+ />
29
+ ### AFM
30
+
31
+ <Story
32
+ packageName="@digigov/form"
33
+ component="inputs/Input"
34
+ story="AFM.tsx"
35
+ />
36
+
37
+ ### IBAN
38
+
39
+ <Story
40
+ packageName="@digigov/form"
41
+ component="inputs/Input"
42
+ story="IBAN.tsx"
43
+ />
44
+
45
+ ### Integer
46
+
47
+ <Story
48
+ packageName="@digigov/form"
49
+ component="inputs/Input"
50
+ story="Default.tsx"
51
+ />
52
+
53
+ ### Landline number
54
+
55
+ <Story
56
+ packageName="@digigov/form"
57
+ component="inputs/Input"
58
+ story="LandlineNumber.tsx"
59
+ />
60
+
61
+ ### Mobile phone
62
+
63
+ <Story
64
+ packageName="@digigov/form"
65
+ component="inputs/Input"
66
+ story="MobilePhone.tsx"
67
+ />
68
+
69
+ ### Phone number
70
+
71
+ <Story
72
+ packageName="@digigov/form"
73
+ component="inputs/Input"
74
+ story="PhoneNumber.tsx"
75
+ />
76
+
77
+ ### Postal code
78
+
79
+ <Story
80
+ packageName="@digigov/form"
81
+ component="inputs/Input"
82
+ story="PostalCode.tsx"
83
+ />
84
+
85
+ ### Text with character limit
86
+
87
+ <Story
88
+ packageName="@digigov/form"
89
+ component="inputs/Input"
90
+ story="TextWithCharacterLimit.tsx"
91
+ />
92
+
93
+
5
94
 
6
- ## Example
7
95
 
8
- <Input type="text" />
@@ -1,6 +1,13 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare const RE_DIGIT: RegExp;
3
3
  export declare const REMOVE_SPACES: RegExp;
4
+ export declare function useOtp(onChange: any, maxLength: any): {
5
+ otpValues: string[];
6
+ handleOtpChange: (e: React.ChangeEvent<HTMLInputElement>, idx: number) => void;
7
+ handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>, idx: number) => void;
8
+ handleFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
9
+ handlePaste: (e: React.ClipboardEvent<HTMLInputElement>) => void;
10
+ };
4
11
  export declare const OtpInput: ({ name, maxLength, ...props }: {
5
12
  [x: string]: any;
6
13
  name: any;
@@ -8,7 +8,7 @@ import React, { useState, useCallback } from 'react';
8
8
  import SingleCharacterInputs, { SingleCharacterInput } from '@digigov/ui/form/SingleCharacterInputs';
9
9
  export var RE_DIGIT = new RegExp(/^\d+$/);
10
10
  export var REMOVE_SPACES = new RegExp(/\s+/g);
11
- function useOtp(onChange, maxLength) {
11
+ export function useOtp(onChange, maxLength) {
12
12
  var _useState = useState(Array(maxLength).fill('')),
13
13
  _useState2 = _slicedToArray(_useState, 2),
14
14
  otpValues = _useState2[0],
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: OTP Input
3
+ ---
4
+
5
+ # OTP input
6
+
7
+
8
+
9
+ A one-time password (OTP) input element of type `otp`, also known as a one-time PIN, one-time authorization code (OTAC) or dynamic password, is a password that is valid for only one login session or transaction,
10
+ on a computer system or other digital device.
11
+
12
+ ## How to use
13
+
14
+ ### Default
15
+
16
+ <Story
17
+ packageName="@digigov/form"
18
+ component="inputs/OtpInput"
19
+ story="Default.tsx"
20
+ />
21
+
22
+
23
+
@@ -89,4 +89,5 @@ export var Conditional = function Conditional() {
89
89
  },
90
90
  fields: fields
91
91
  }, _ref, _ref2);
92
- };
92
+ };
93
+ export default Conditional;
@@ -1,2 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  export declare const Conditional: () => JSX.Element;
3
+ export default Conditional;
@@ -5,7 +5,7 @@ var _excluded = ["name", "control", "register", "extra", "disabled"],
5
5
  import React from 'react';
6
6
  import { useWatch } from 'react-hook-form';
7
7
  import { Field } from '@digigov/form';
8
- import { RadioConditional } from '@digigov/react-core';
8
+ import { RadioConditional } from '@digigov/react-core/RadioConditional';
9
9
  import Hint from '@digigov/react-core/Hint';
10
10
  import RadioContainer from '@digigov/react-core/RadioContainer';
11
11
  import RadioItem from '@digigov/react-core/RadioItem';
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: Radio
3
+ ---
4
+
5
+ # Radio
6
+ Input element of type `radio` are generally used in radio groups—collections of radio buttons describing a set of related options.
7
+ Radios are used to let a user select one option of a limited number of choices.
8
+
9
+ ## How to use
10
+
11
+ ### Default
12
+
13
+ <Story
14
+ packageName="@digigov/form"
15
+ component="inputs/Radio"
16
+ story="Default.tsx"
17
+ />
18
+
19
+ ### Conditional
20
+
21
+ <Story
22
+ packageName="@digigov/form"
23
+ component="inputs/Radio"
24
+ story="Conditional.tsx"
25
+ />
26
+
27
+ ### With divider
28
+
29
+ <Story
30
+ packageName="@digigov/form"
31
+ component="inputs/Radio"
32
+ story="WithDivider.tsx"
33
+ />
@@ -0,0 +1,17 @@
1
+ ---
2
+ title: Select
3
+ ---
4
+
5
+ # Select
6
+
7
+ The select element represents a control that provides a menu of options.
8
+
9
+ ## How to use
10
+
11
+ ### Default
12
+
13
+ <Story
14
+ packageName="@digigov/form"
15
+ component="inputs/Select"
16
+ story="Default.tsx"
17
+ />
package/lazy.d.ts CHANGED
@@ -8,7 +8,7 @@ declare namespace _default {
8
8
  let FieldsetWithContext: import("react").LazyExoticComponent<import("react").FC<{
9
9
  name: string;
10
10
  }>>;
11
- let Fieldset: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("@digigov/ui").FieldsetProps, "onBlur" | "onChange" | "onSubmit" | "key" | "name" | "defaultValue" | "as" | "margin" | "marginTop" | "marginBottom" | "marginLeft" | "marginRight" | "padding" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "printHidden" | "printVisible" | "hidden" | "xsUpHidden" | "smUpHidden" | "mdUpHidden" | "lgUpHidden" | "xlUpHidden" | "xsHidden" | "smHidden" | "mdHidden" | "lgHidden" | "xlHidden" | "form" | "slot" | "style" | "title" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled"> & import("react").RefAttributes<HTMLFieldSetElement>>>;
11
+ let Fieldset: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("@digigov/ui").FieldsetProps, "onBlur" | "onChange" | "onSubmit" | "key" | "name" | "defaultValue" | "as" | "margin" | "marginTop" | "marginBottom" | "marginLeft" | "marginRight" | "m" | "mt" | "mb" | "ml" | "mr" | "mx" | "my" | "padding" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "p" | "pt" | "pb" | "pl" | "pr" | "px" | "py" | "printHidden" | "printVisible" | "hidden" | "xsUpHidden" | "smUpHidden" | "mdUpHidden" | "lgUpHidden" | "xlUpHidden" | "xsHidden" | "smHidden" | "mdHidden" | "lgHidden" | "xlHidden" | "form" | "slot" | "style" | "title" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled"> & import("react").RefAttributes<HTMLFieldSetElement>>>;
12
12
  let FieldsetBody: import("react").LazyExoticComponent<import("react").FC<import("./Fieldset/types").FieldsetBodyProps>>;
13
13
  let FieldsetCaption: import("react").LazyExoticComponent<import("react").FC<import("./Fieldset/types").FieldsetCaptionProps>>;
14
14
  let FieldsetLabel: import("react").LazyExoticComponent<import("react").FC<import("./Fieldset/types").FieldsetLabelProps>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digigov/form",
3
- "version": "1.2.0-a7ffb5dc",
3
+ "version": "2.0.0-462194bf",
4
4
  "description": "@digigov form builder",
5
5
  "author": "GRNET Developers <devs@lists.grnet.gr>",
6
6
  "license": "BSD-2-Clause",
@@ -15,11 +15,11 @@
15
15
  "dayjs": "1.10.4",
16
16
  "@hookform/resolvers": "2.9.6",
17
17
  "publint": "0.1.8",
18
- "@digigov/react-icons": "1.2.0-a7ffb5dc"
18
+ "@digigov/react-icons": "2.0.0-462194bf"
19
19
  },
20
20
  "peerDependencies": {
21
- "@digigov/ui": "1.2.0-a7ffb5dc",
22
- "@digigov/react-core": "1.3.0-a7ffb5dc",
21
+ "@digigov/ui": "2.0.0-462194bf",
22
+ "@digigov/react-core": "2.0.0-462194bf",
23
23
  "clsx": "1.1.1",
24
24
  "react": "^16.8.0 || ^17.0.0",
25
25
  "react-dom": "^16.8.0 || ^17.0.0"
@@ -41,6 +41,7 @@ export const FieldBase: React.FC<FieldBaseProps> = (props) => {
41
41
  return (
42
42
  <Component
43
43
  {...field}
44
+ ref={undefined}
44
45
  defaultValue={defaultValue}
45
46
  extra={extra}
46
47
  error={!!error}
@@ -1,4 +1,4 @@
1
- import { lazy, useContext, useMemo } from 'react';
1
+ import { useContext, useMemo } from 'react';
2
2
  import {
3
3
  CalculatedField,
4
4
  FieldComponentRegistry,
@@ -15,11 +15,9 @@ import Input from '@digigov/form/inputs/Input';
15
15
  import OtpInput from '@digigov/form/inputs/OtpInput';
16
16
  import Radio from '@digigov/form/inputs/Radio';
17
17
  import Select from '@digigov/form/inputs/Select';
18
+ import AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';
18
19
  import { FieldSpec } from '@digigov/form/types';
19
20
 
20
- const AutoCompleteInput = lazy(() =>
21
- import('@digigov/form/inputs/AutoCompleteInput')
22
- );
23
21
 
24
22
  const FIELD_COMPONENTS: FieldComponentRegistry = {
25
23
  text: {
@@ -66,6 +64,7 @@ const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {
66
64
  AutoComplete: {
67
65
  component: AutoCompleteInput,
68
66
  controlled: true,
67
+ wrapper: 'fieldset'
69
68
  },
70
69
  };
71
70
 
@@ -93,6 +92,7 @@ export function calculateField(
93
92
  ALTERNATIVE_COMPONENTS[field.extra.component]?.controlled || false;
94
93
  calculatedField.component =
95
94
  ALTERNATIVE_COMPONENTS[field.extra.component].component;
95
+ calculatedField.wrapper = ALTERNATIVE_COMPONENTS[field.extra.component].wrapper;
96
96
  } else if (
97
97
  !field.component &&
98
98
  field.type &&
@@ -5,7 +5,7 @@ import { CalculatedField, FieldProps } from '@digigov/form/Field/types';
5
5
  import { calculateField } from '@digigov/form/Field/utils';
6
6
  import Fieldset, { FieldsetCaption } from '@digigov/form/Fieldset';
7
7
  import { FieldSpec } from '@digigov/form/types';
8
- import { FieldsetLegend } from '@digigov/react-core';
8
+ import { FieldsetLegend } from '@digigov/react-core/FieldsetLegend';
9
9
  import { useTranslation } from '@digigov/ui/i18n';
10
10
 
11
11
  export interface FieldObjectProps extends Omit<FieldProps, 'key'> {
@@ -83,7 +83,7 @@ export const PreviewDisplay = () => (
83
83
  <Card variant="border" borderColor="dark">
84
84
  <CardHeading>Συνυπογράφοντας 1</CardHeading>
85
85
  <CardContent>
86
- <SummaryList>
86
+ <SummaryList noLastBorder marginBottom={0}>
87
87
  {fields &&
88
88
  fields.map((field, index) => {
89
89
  return (
@@ -99,7 +99,7 @@ export const PreviewDisplay = () => (
99
99
  <Card variant="border" borderColor="dark">
100
100
  <CardHeading>Συνυπογράφοντας 2</CardHeading>
101
101
  <CardContent>
102
- <SummaryList>
102
+ <SummaryList noLastBorder marginBottom={0}>
103
103
  {fields &&
104
104
  fields.map((field, index) => {
105
105
  return (
@@ -5,14 +5,13 @@ import FieldContainer from '@digigov/form/Field/FieldBaseContainer';
5
5
  import { ControlledFieldProps } from '@digigov/form/Field/types';
6
6
  import FieldObject from '@digigov/form/FieldObject';
7
7
  import AddObjects from '@digigov/form/MultiplicityField/add-objects';
8
- import {
9
- Card,
10
- CardContent,
11
- CardAction,
12
- Button,
13
- Heading,
14
- CardHeading,
15
- } from '@digigov/react-core';
8
+ import { Card } from '@digigov/react-core/Card';
9
+ import { CardContent } from '@digigov/react-core/CardContent';
10
+ import { CardAction } from '@digigov/react-core/CardAction';
11
+ import { Button } from '@digigov/react-core/Button';
12
+ import { Heading } from '@digigov/react-core/Heading';
13
+ import { CardHeading } from '@digigov/react-core/CardHeading';
14
+
16
15
 
17
16
  export interface MultiplicityProps
18
17
  extends Omit<ControlledFieldProps, 'value' | 'onChange' | 'error' | 'extra'> {
@@ -5,3 +5,4 @@ export default {
5
5
  displayName: 'AutoCompleteInput',
6
6
  };
7
7
  export * from '@digigov/form/inputs/AutoCompleteInput/__stories__/Default';
8
+ export * from '@digigov/form/inputs/AutoCompleteInput/__stories__/Multiple';
@@ -1,13 +1,21 @@
1
- import React, { Suspense } from 'react';
1
+ import React from 'react';
2
2
  import { Field } from '@digigov/form/Field';
3
3
  import FormBuilder from '@digigov/form/FormBuilder';
4
4
  import { FieldSpec } from '@digigov/form/types';
5
- import { results } from '@digigov/ui/form/AutoComplete/utils';
6
5
  import Button from '@digigov/ui/form/Button';
6
+
7
+ const results = [
8
+ 'Αμερική',
9
+ 'Ασία',
10
+ 'Αυστραλία',
11
+ 'Αφρική',
12
+ 'Ευρώπη',
13
+ ];
14
+
7
15
  const fields: FieldSpec[] = [
8
16
  {
9
17
  key: 'autocomplete',
10
- label: { primary: 'An autocomplete field' },
18
+ label: { primary: 'Επιλέξτε ήπειρο' },
11
19
  required: true,
12
20
  type: 'choice:single',
13
21
  extra: {
@@ -16,7 +24,7 @@ const fields: FieldSpec[] = [
16
24
  return {
17
25
  label: {
18
26
  primary: r,
19
- secondary: `Country: ${r}`,
27
+ secondary: `'Ηπειρος: ${r}`,
20
28
  },
21
29
  value: r.toLowerCase(),
22
30
  };
@@ -28,18 +36,19 @@ const fields: FieldSpec[] = [
28
36
  const initialValues = {};
29
37
 
30
38
  export const Default = () => (
31
- <Suspense fallback={<div>loading</div>}>
32
- <FormBuilder
33
- fields={fields}
34
- onSubmit={(data) => {
35
- console.log(data);
36
- }}
37
- initial={initialValues}
38
- >
39
- {fields.map((field) => (
40
- <Field key={field.key} name={field.key} />
41
- ))}
42
- <Button type="submit">Submit</Button>
43
- </FormBuilder>
44
- </Suspense>
39
+
40
+ <FormBuilder
41
+ fields={fields}
42
+ onSubmit={(data) => {
43
+ console.log(data);
44
+ }}
45
+ initial={initialValues}
46
+ >
47
+ {fields.map((field) => (
48
+ <Field key={field.key} name={field.key} />
49
+ ))}
50
+ <Button type="submit">Submit</Button>
51
+ </FormBuilder>
52
+
45
53
  );
54
+ export default Default;
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { Field } from '@digigov/form/Field';
3
+ import FormBuilder from '@digigov/form/FormBuilder';
4
+ import { FieldSpec } from '@digigov/form/types';
5
+ import Button from '@digigov/ui/form/Button';
6
+
7
+ const results = [
8
+ 'Αμερική',
9
+ 'Ασία',
10
+ 'Αυστραλία',
11
+ 'Αφρική',
12
+ 'Ευρώπη',
13
+ ];
14
+
15
+ const fields: FieldSpec[] = [
16
+ {
17
+ key: 'autocomplete',
18
+ label: { primary: 'Επιλέξτε ήπειρο' },
19
+ required: true,
20
+ type: 'choice:multiple',
21
+ extra: {
22
+ component: 'AutoComplete',
23
+ multiple: true,
24
+ options: results.map((r) => {
25
+ return {
26
+ label: {
27
+ primary: r,
28
+ secondary: `Ήπειρος: ${r}`,
29
+ },
30
+ value: r.toLowerCase(),
31
+ };
32
+ }),
33
+ },
34
+ },
35
+ ];
36
+
37
+ const initialValues = {};
38
+
39
+ export const Multiple = () => (
40
+ <FormBuilder
41
+ fields={fields}
42
+ onSubmit={(data) => {
43
+ console.log(data);
44
+ }}
45
+ initial={initialValues}
46
+ >
47
+ {fields.map((field) => (
48
+ <Field key={field.key} name={field.key} />
49
+ ))}
50
+ <Button type="submit">Submit</Button>
51
+ </FormBuilder>
52
+ );
53
+
54
+ export default Multiple;
@@ -0,0 +1,29 @@
1
+ ---
2
+ title: AutoComplete Input
3
+ ---
4
+
5
+ # AutoComplete input
6
+
7
+ AutoCompleteInput element is an enhanced version of text input that shows suggested
8
+ options as the users type and also let them select an option from the list.
9
+
10
+ ## How to use
11
+
12
+ ### Default
13
+
14
+ <Story
15
+ packageName="@digigov/form"
16
+ component="inputs/AutoCompleteInput"
17
+ story="Default.tsx"
18
+ />
19
+
20
+ ### Display multiple values
21
+
22
+ <Story
23
+ packageName="@digigov/form"
24
+ component="inputs/AutoCompleteInput"
25
+ story="Multiple.tsx"
26
+ />
27
+
28
+
29
+
@@ -1,7 +1,7 @@
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';
4
+ import { Hint } from '@digigov/react-core/Hint';
5
5
  import UIAutoComplete, {
6
6
  AutoCompleteProps as UIAutoCompleteProps,
7
7
  } from '@digigov/ui/form/AutoComplete';
@@ -23,14 +23,15 @@ export interface AutoCompleteInputProps
23
23
  extends Omit<ControlledFieldProps, 'value' | 'onChange' | 'extra'> {
24
24
  extra: AutoCompleteInputExtra;
25
25
  value: string;
26
- onChange: (v: string) => void;
26
+ onChange: (v: string | string[] | undefined) => void;
27
27
  }
28
28
 
29
29
  export const AutoCompleteInput: React.FC<AutoCompleteInputProps> = ({
30
30
  name,
31
- extra: { options },
31
+ extra: { options, multiple },
32
32
  onChange,
33
33
  value,
34
+ error,
34
35
  ...props
35
36
  }) => {
36
37
  const suggest = useCallback(function suggest(
@@ -40,24 +41,29 @@ export const AutoCompleteInput: React.FC<AutoCompleteInputProps> = ({
40
41
  syncResults(
41
42
  query
42
43
  ? options.filter(function (option) {
43
- return (
44
- `${option.value} ${option.label?.primary || ''} ${
45
- option.label?.secondary || ''
44
+ return (
45
+ `${option.value} ${option.label?.primary || ''} ${option.label?.secondary || ''
46
46
  }`
47
- .toLowerCase()
48
- .indexOf(query.toLowerCase()) !== -1
49
- );
50
- })
51
- : []
47
+ .toLowerCase()
48
+ .indexOf(query.toLowerCase()) !== -1
49
+ );
50
+ })
51
+ : options
52
52
  );
53
53
  },
54
- []);
54
+ [options]);
55
55
 
56
56
  return (
57
57
  <UIAutoComplete
58
+ multiple={multiple}
58
59
  source={suggest}
59
60
  onConfirm={(value) => {
60
- onChange(value.value);
61
+ if (Array.isArray(value)) {
62
+ const selectedValues = value.map(item => item.value);
63
+ selectedValues.length > 0 ? onChange(selectedValues) : onChange(undefined);
64
+ } else {
65
+ onChange(value.value);
66
+ }
61
67
  }}
62
68
  templates={{
63
69
  suggestion({ label, value }) {
@@ -75,11 +81,15 @@ export const AutoCompleteInput: React.FC<AutoCompleteInputProps> = ({
75
81
  return option.label.primary || option.value;
76
82
  },
77
83
  }}
78
- {...props}
84
+ {...{
85
+ ...props,
86
+ reset: undefined,
87
+ required: undefined,
88
+ }}
79
89
  id={`${name}-id`}
80
90
  defaultValue={value}
81
91
  />
82
92
  );
83
93
  };
84
94
 
85
- export default AutoCompleteInput;
95
+ export default AutoCompleteInput;
@@ -6,7 +6,6 @@ const fields: FieldSpec[] = [
6
6
  {
7
7
  key: 'landline',
8
8
  type: 'phone_number',
9
-
10
9
  label: {
11
10
  secondary: 'Εισάγετε το νούμερο του σταθερού σας τηλεφώνου.',
12
11
  },
@@ -24,7 +23,6 @@ const fields: FieldSpec[] = [
24
23
  {
25
24
  key: 'mobile_phone',
26
25
  type: 'mobile_phone',
27
-
28
26
  label: {
29
27
  secondary: 'Εισάγετε το νούμερο του κινητού σας τηλεφώνου.',
30
28
  },
@@ -41,7 +39,6 @@ const fields: FieldSpec[] = [
41
39
  },
42
40
  {
43
41
  key: 'email',
44
-
45
42
  type: 'email',
46
43
  label: {
47
44
  secondary: 'Εισάγετε την διεύθυνση του ηλεκτρονικού σας ταχυδρομείου.',
@@ -98,3 +95,5 @@ export const Conditional = () => (
98
95
  <Button type="submit">Συνέχεια</Button>
99
96
  </FormBuilder>
100
97
  );
98
+
99
+ export default Conditional;