@ilo-org/react 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/cjs/components/Checkbox/Checkbox.js +28 -16
  3. package/lib/cjs/components/Checkbox/index.js +25 -3
  4. package/lib/cjs/components/DatePicker/DatePicker.js +21 -16
  5. package/lib/cjs/components/DatePicker/index.js +4 -4
  6. package/lib/cjs/components/Dropdown/Dropdown.js +19 -15
  7. package/lib/cjs/components/Dropdown/index.js +3 -3
  8. package/lib/cjs/components/Fieldset/Fieldset.js +33 -9
  9. package/lib/cjs/components/Fieldset/index.js +2 -2
  10. package/lib/cjs/components/FileUpload/FileUpload.js +29 -15
  11. package/lib/cjs/components/FileUpload/index.js +3 -3
  12. package/lib/cjs/components/Form/Form.js +8 -55
  13. package/lib/cjs/components/Form/index.js +10 -20
  14. package/lib/cjs/components/FormControl/FormControl.js +79 -0
  15. package/lib/cjs/components/FormControl/index.js +16 -0
  16. package/lib/cjs/components/Input/Input.js +1 -1
  17. package/lib/cjs/components/NumberPicker/NumberPicker.js +21 -16
  18. package/lib/cjs/components/NumberPicker/index.js +4 -4
  19. package/lib/cjs/components/Radio/Radio.js +34 -17
  20. package/lib/cjs/components/Radio/index.js +19 -4
  21. package/lib/cjs/components/TextInput/TextInput.js +30 -0
  22. package/lib/cjs/components/TextInput/index.js +52 -0
  23. package/lib/cjs/components/Textarea/Textarea.js +19 -19
  24. package/lib/cjs/components/Textarea/index.js +26 -5
  25. package/lib/cjs/components/Toggle/Toggle.js +33 -0
  26. package/lib/cjs/components/Toggle/index.js +51 -0
  27. package/lib/cjs/components/Tooltip/Tooltip.js +2 -2
  28. package/lib/cjs/components/index.js +10 -11
  29. package/lib/cjs/hooks/usePrevious.js +20 -0
  30. package/lib/cjs/index.js +10 -11
  31. package/lib/esm/components/Checkbox/Checkbox.js +31 -19
  32. package/lib/esm/components/Checkbox/index.js +27 -2
  33. package/lib/esm/components/DatePicker/DatePicker.js +22 -17
  34. package/lib/esm/components/DatePicker/index.js +4 -4
  35. package/lib/esm/components/Dropdown/Dropdown.js +20 -16
  36. package/lib/esm/components/Dropdown/index.js +3 -3
  37. package/lib/esm/components/Fieldset/Fieldset.js +31 -11
  38. package/lib/esm/components/Fieldset/index.js +1 -1
  39. package/lib/esm/components/FileUpload/FileUpload.js +31 -17
  40. package/lib/esm/components/FileUpload/index.js +3 -3
  41. package/lib/esm/components/Form/Form.js +10 -57
  42. package/lib/esm/components/Form/index.js +13 -20
  43. package/lib/esm/components/FormControl/FormControl.js +73 -0
  44. package/lib/esm/components/{ChoiceGroup → FormControl}/index.js +3 -6
  45. package/lib/esm/components/NumberPicker/NumberPicker.js +21 -16
  46. package/lib/esm/components/NumberPicker/index.js +4 -4
  47. package/lib/esm/components/Radio/Radio.js +34 -17
  48. package/lib/esm/components/Radio/index.js +21 -3
  49. package/lib/esm/components/TextInput/TextInput.js +28 -0
  50. package/lib/esm/components/TextInput/index.js +49 -0
  51. package/lib/esm/components/Textarea/Textarea.js +19 -19
  52. package/lib/esm/components/Textarea/index.js +28 -4
  53. package/lib/esm/components/Toggle/Toggle.js +31 -0
  54. package/lib/esm/components/Toggle/index.js +48 -0
  55. package/lib/esm/components/Tooltip/Tooltip.js +2 -2
  56. package/lib/esm/components/index.js +8 -5
  57. package/lib/esm/hooks/usePrevious.js +15 -0
  58. package/lib/esm/index.js +8 -5
  59. package/lib/types/react/src/components/Checkbox/Checkbox.args.d.ts +52 -0
  60. package/lib/types/react/src/components/Checkbox/Checkbox.d.ts +5 -3
  61. package/lib/types/react/src/components/Checkbox/Checkbox.props.d.ts +4 -13
  62. package/lib/types/react/src/components/Checkbox/index.d.ts +1 -0
  63. package/lib/types/react/src/components/DatePicker/DatePicker.d.ts +4 -3
  64. package/lib/types/react/src/components/DatePicker/DatePicker.props.d.ts +10 -43
  65. package/lib/types/react/src/components/Dropdown/Dropdown.d.ts +5 -3
  66. package/lib/types/react/src/components/Dropdown/Dropdown.props.d.ts +16 -42
  67. package/lib/types/react/src/components/Fieldset/Fieldset.d.ts +6 -0
  68. package/lib/types/react/src/components/Fieldset/Fieldset.props.d.ts +14 -21
  69. package/lib/types/react/src/components/FileUpload/FileUpload.d.ts +5 -3
  70. package/lib/types/react/src/components/FileUpload/FileUpload.props.d.ts +7 -44
  71. package/lib/types/react/src/components/Form/Form.args.d.ts +2 -0
  72. package/lib/types/react/src/components/Form/Form.d.ts +1 -2
  73. package/lib/types/react/src/components/Form/Form.props.d.ts +4 -111
  74. package/lib/types/react/src/components/Form/index.d.ts +1 -0
  75. package/lib/types/react/src/components/FormControl/FormControl.d.ts +9 -0
  76. package/lib/types/react/src/components/FormControl/FormControl.props.d.ts +55 -0
  77. package/lib/types/react/src/components/FormControl/index.d.ts +2 -0
  78. package/lib/types/react/src/components/FormElement/FormElement.props.d.ts +2 -2
  79. package/lib/types/react/src/components/Input/Input.props.d.ts +2 -2
  80. package/lib/types/react/src/components/NumberPicker/NumberPicker.d.ts +5 -3
  81. package/lib/types/react/src/components/NumberPicker/NumberPicker.props.d.ts +5 -42
  82. package/lib/types/react/src/components/Radio/Radio.args.d.ts +8 -0
  83. package/lib/types/react/src/components/Radio/Radio.d.ts +5 -3
  84. package/lib/types/react/src/components/Radio/Radio.props.d.ts +4 -14
  85. package/lib/types/react/src/components/Radio/index.d.ts +1 -0
  86. package/lib/types/react/src/components/TextInput/TextInput.args.d.ts +10 -0
  87. package/lib/types/react/src/components/TextInput/TextInput.d.ts +6 -0
  88. package/lib/types/react/src/components/TextInput/TextInput.props.d.ts +17 -0
  89. package/lib/types/react/src/components/TextInput/index.d.ts +2 -0
  90. package/lib/types/react/src/components/Textarea/Textarea.args.d.ts +10 -0
  91. package/lib/types/react/src/components/Textarea/Textarea.d.ts +5 -3
  92. package/lib/types/react/src/components/Textarea/Textarea.props.d.ts +17 -39
  93. package/lib/types/react/src/components/Textarea/index.d.ts +2 -0
  94. package/lib/types/react/src/components/Toggle/Toggle.args.d.ts +12 -0
  95. package/lib/types/react/src/components/Toggle/Toggle.d.ts +5 -0
  96. package/lib/types/react/src/components/Toggle/Toggle.props.d.ts +22 -0
  97. package/lib/types/react/src/components/Toggle/index.d.ts +3 -0
  98. package/lib/types/react/src/components/Tooltip/Tooltip.props.d.ts +4 -0
  99. package/lib/types/react/src/components/index.d.ts +1 -5
  100. package/lib/types/react/src/hooks/usePrevious.d.ts +2 -0
  101. package/lib/types/react/src/types/index.d.ts +57 -1
  102. package/package.json +19 -18
  103. package/src/components/Checkbox/Checkbox.args.ts +31 -9
  104. package/src/components/Checkbox/Checkbox.props.ts +5 -13
  105. package/src/components/Checkbox/Checkbox.tsx +78 -76
  106. package/src/components/Checkbox/index.ts +1 -0
  107. package/src/components/DatePicker/DatePicker.args.ts +6 -32
  108. package/src/components/DatePicker/DatePicker.props.ts +11 -51
  109. package/src/components/DatePicker/DatePicker.tsx +71 -110
  110. package/src/components/Dropdown/Dropdown.args.ts +42 -192
  111. package/src/components/Dropdown/Dropdown.props.ts +18 -49
  112. package/src/components/Dropdown/Dropdown.tsx +73 -62
  113. package/src/components/Fieldset/Fieldset.props.ts +14 -23
  114. package/src/components/Fieldset/Fieldset.tsx +75 -69
  115. package/src/components/FileUpload/FileUpload.args.ts +25 -27
  116. package/src/components/FileUpload/FileUpload.props.ts +8 -53
  117. package/src/components/FileUpload/FileUpload.tsx +103 -72
  118. package/src/components/Form/Form.args.ts +2 -184
  119. package/src/components/Form/Form.props.ts +4 -133
  120. package/src/components/Form/Form.tsx +17 -77
  121. package/src/components/Form/index.ts +1 -0
  122. package/src/components/FormControl/FormControl.props.ts +72 -0
  123. package/src/components/FormControl/FormControl.tsx +169 -0
  124. package/src/components/FormControl/index.ts +2 -0
  125. package/src/components/FormElement/FormElement.props.ts +2 -2
  126. package/src/components/Input/Input.props.ts +2 -2
  127. package/src/components/Navigation/Navigation.args.ts +2 -1
  128. package/src/components/NumberPicker/NumberPicker.args.ts +18 -26
  129. package/src/components/NumberPicker/NumberPicker.props.ts +7 -52
  130. package/src/components/NumberPicker/NumberPicker.tsx +73 -56
  131. package/src/components/Radio/Radio.args.ts +1 -7
  132. package/src/components/Radio/Radio.props.ts +6 -14
  133. package/src/components/Radio/Radio.tsx +90 -52
  134. package/src/components/Radio/index.ts +1 -0
  135. package/src/components/TextInput/TextInput.args.ts +75 -0
  136. package/src/components/TextInput/TextInput.props.ts +20 -0
  137. package/src/components/TextInput/TextInput.tsx +71 -0
  138. package/src/components/TextInput/index.ts +2 -0
  139. package/src/components/Textarea/Textarea.args.ts +19 -37
  140. package/src/components/Textarea/Textarea.props.ts +18 -46
  141. package/src/components/Textarea/Textarea.tsx +44 -59
  142. package/src/components/Textarea/index.ts +2 -0
  143. package/src/components/Toggle/Toggle.args.ts +62 -0
  144. package/src/components/Toggle/Toggle.props.ts +27 -0
  145. package/src/components/Toggle/Toggle.tsx +85 -0
  146. package/src/components/Toggle/index.ts +3 -0
  147. package/src/components/Tooltip/Tooltip.props.ts +5 -0
  148. package/src/components/Tooltip/Tooltip.tsx +2 -0
  149. package/src/components/index.ts +1 -5
  150. package/src/hooks/usePrevious.ts +15 -0
  151. package/src/types/forms.args.ts +288 -0
  152. package/src/types/index.ts +69 -1
  153. package/tsconfig.json +2 -1
  154. package/lib/cjs/components/ChoiceGroup/ChoiceGroup.js +0 -34
  155. package/lib/cjs/components/ChoiceGroup/index.js +0 -19
  156. package/lib/cjs/components/FormGroup/FormGroup.js +0 -58
  157. package/lib/cjs/components/FormGroup/index.js +0 -26
  158. package/lib/esm/components/ChoiceGroup/ChoiceGroup.js +0 -32
  159. package/lib/esm/components/FormGroup/FormGroup.js +0 -56
  160. package/lib/esm/components/FormGroup/index.js +0 -20
  161. package/lib/types/react/src/components/ChoiceGroup/ChoiceGroup.d.ts +0 -4
  162. package/lib/types/react/src/components/ChoiceGroup/ChoiceGroup.props.d.ts +0 -20
  163. package/lib/types/react/src/components/ChoiceGroup/index.d.ts +0 -1
  164. package/lib/types/react/src/components/FormGroup/FormGroup.d.ts +0 -4
  165. package/lib/types/react/src/components/FormGroup/FormGroup.props.d.ts +0 -81
  166. package/lib/types/react/src/components/FormGroup/index.d.ts +0 -1
  167. package/src/components/ChoiceGroup/ChoiceGroup.args.ts +0 -95
  168. package/src/components/ChoiceGroup/ChoiceGroup.props.ts +0 -25
  169. package/src/components/ChoiceGroup/ChoiceGroup.tsx +0 -54
  170. package/src/components/ChoiceGroup/index.ts +0 -1
  171. package/src/components/FormGroup/FormGroup.args.ts +0 -85
  172. package/src/components/FormGroup/FormGroup.props.ts +0 -102
  173. package/src/components/FormGroup/FormGroup.tsx +0 -73
  174. package/src/components/FormGroup/index.ts +0 -1
@@ -2,9 +2,9 @@ export { default as AccordionButton } from './Accordion/AccordionButton.js';
2
2
  export { default as AccordionPanel } from './Accordion/AccordionPanel.js';
3
3
  export { default as AccordionItem } from './Accordion/AccordionItem.js';
4
4
  export { default as Accordion } from './Accordion/Accordion.js';
5
+ export { default as Form } from './Form/Form.js';
5
6
  export { default as Collapse } from './Collapse/Collapse.js';
6
7
  export { default as Empty } from './Empty/Empty.js';
7
- export { default as FormGroup } from './FormGroup/FormGroup.js';
8
8
  export { default as Image } from './Image/Image.js';
9
9
  export { default as Loading } from './Loading/Loading.js';
10
10
  export { default as Radio } from './Radio/Radio.js';
@@ -19,10 +19,10 @@ import '../TagCtx-34c545fe.js';
19
19
  export { default as Button } from './Button/Button.js';
20
20
  export { default as ContextMenu } from './ContextMenu/ContextMenu.js';
21
21
  export { default as Fieldset } from './Fieldset/Fieldset.js';
22
- export { default as Input } from './Input/Input.js';
23
22
  export { default as Notification } from './Notification/Notification.js';
24
23
  export { default as ReadMore } from './ReadMore/ReadMore.js';
25
24
  export { default as Textarea } from './Textarea/Textarea.js';
25
+ import './Textarea/index.js';
26
26
  export { default as Callout } from './Callout/Callout.js';
27
27
  import './Callout/index.js';
28
28
  export { default as Credit } from './Credit/Credit.js';
@@ -33,17 +33,15 @@ export { default as NumberPicker } from './NumberPicker/NumberPicker.js';
33
33
  export { default as RichText } from './RichText/RichText.js';
34
34
  export { default as Tooltip } from './Tooltip/Tooltip.js';
35
35
  export { default as Checkbox } from './Checkbox/Checkbox.js';
36
+ import './Checkbox/index.js';
36
37
  export { default as DatePicker } from './DatePicker/DatePicker.js';
37
- export { default as Form } from './Form/Form.js';
38
38
  export { default as Hero } from './Hero/Hero.js';
39
39
  import './SocialMedia/index.js';
40
40
  export { default as LinkList } from './LinkList/LinkList.js';
41
41
  export { default as Pagination } from './Pagination/Pagination.js';
42
42
  export { default as SearchField } from './SearchField/SearchField.js';
43
43
  export { default as Video } from './Video/Video.js';
44
- export { default as ChoiceGroup } from './ChoiceGroup/ChoiceGroup.js';
45
44
  export { default as Dropdown } from './Dropdown/Dropdown.js';
46
- export { default as FormElement } from './FormElement/FormElement.js';
47
45
  export { default as Icon } from './Icon/Icon.js';
48
46
  export { default as List } from './List/List.js';
49
47
  import '../ListCtx-da435fdf.js';
@@ -66,8 +64,13 @@ import '../utils/getDefaultDimensionValue.js';
66
64
  import '../css-7414f50b.js';
67
65
  import '../utils/transitionEndListener.js';
68
66
  import '../utils/triggerBrowserReflow.js';
67
+ import './FormControl/FormControl.js';
68
+ import 'nanoid';
69
+ import '../hooks/usePrevious.js';
69
70
  import './Hero/HeroCard.js';
70
71
  import './SocialMedia/SocialMedia.js';
72
+ import './Input/Input.js';
73
+ import './FormElement/FormElement.js';
71
74
  import '../VideoPlayer-a5fa87ce.js';
72
75
  import '../utils/hoursMinutesSeconds.js';
73
76
  import 'screenfull';
@@ -0,0 +1,15 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ // This code was shamelessly borrowed from the blog post
4
+ // "How to access previous props or state with React Hooks" by
5
+ // Ohans Emmanuel, published on LogRocket May 11, 2023
6
+ // https://blog.logrocket.com/accessing-previous-props-state-react-hooks/
7
+ function usePrevious(value) {
8
+ const ref = useRef();
9
+ useEffect(() => {
10
+ ref.current = value; //assign the value of ref to the argument
11
+ }, [value]); //this code will run when the value of 'value' changes
12
+ return ref.current; //in the end, return the current ref value.
13
+ }
14
+
15
+ export { usePrevious as default, usePrevious };
package/lib/esm/index.js CHANGED
@@ -2,9 +2,9 @@ export { default as AccordionButton } from './components/Accordion/AccordionButt
2
2
  export { default as AccordionPanel } from './components/Accordion/AccordionPanel.js';
3
3
  export { default as AccordionItem } from './components/Accordion/AccordionItem.js';
4
4
  export { default as Accordion } from './components/Accordion/Accordion.js';
5
+ export { default as Form } from './components/Form/Form.js';
5
6
  export { default as Collapse } from './components/Collapse/Collapse.js';
6
7
  export { default as Empty } from './components/Empty/Empty.js';
7
- export { default as FormGroup } from './components/FormGroup/FormGroup.js';
8
8
  export { default as Image } from './components/Image/Image.js';
9
9
  export { default as Loading } from './components/Loading/Loading.js';
10
10
  export { default as Radio } from './components/Radio/Radio.js';
@@ -19,10 +19,10 @@ import './TagCtx-34c545fe.js';
19
19
  export { default as Button } from './components/Button/Button.js';
20
20
  export { default as ContextMenu } from './components/ContextMenu/ContextMenu.js';
21
21
  export { default as Fieldset } from './components/Fieldset/Fieldset.js';
22
- export { default as Input } from './components/Input/Input.js';
23
22
  export { default as Notification } from './components/Notification/Notification.js';
24
23
  export { default as ReadMore } from './components/ReadMore/ReadMore.js';
25
24
  export { default as Textarea } from './components/Textarea/Textarea.js';
25
+ import './components/Textarea/index.js';
26
26
  export { default as Callout } from './components/Callout/Callout.js';
27
27
  import './components/Callout/index.js';
28
28
  export { default as Credit } from './components/Credit/Credit.js';
@@ -33,17 +33,15 @@ export { default as NumberPicker } from './components/NumberPicker/NumberPicker.
33
33
  export { default as RichText } from './components/RichText/RichText.js';
34
34
  export { default as Tooltip } from './components/Tooltip/Tooltip.js';
35
35
  export { default as Checkbox } from './components/Checkbox/Checkbox.js';
36
+ import './components/Checkbox/index.js';
36
37
  export { default as DatePicker } from './components/DatePicker/DatePicker.js';
37
- export { default as Form } from './components/Form/Form.js';
38
38
  export { default as Hero } from './components/Hero/Hero.js';
39
39
  import './components/SocialMedia/index.js';
40
40
  export { default as LinkList } from './components/LinkList/LinkList.js';
41
41
  export { default as Pagination } from './components/Pagination/Pagination.js';
42
42
  export { default as SearchField } from './components/SearchField/SearchField.js';
43
43
  export { default as Video } from './components/Video/Video.js';
44
- export { default as ChoiceGroup } from './components/ChoiceGroup/ChoiceGroup.js';
45
44
  export { default as Dropdown } from './components/Dropdown/Dropdown.js';
46
- export { default as FormElement } from './components/FormElement/FormElement.js';
47
45
  export { default as Icon } from './components/Icon/Icon.js';
48
46
  export { default as List } from './components/List/List.js';
49
47
  import './ListCtx-da435fdf.js';
@@ -66,9 +64,14 @@ import './utils/getDefaultDimensionValue.js';
66
64
  import './css-7414f50b.js';
67
65
  import './utils/transitionEndListener.js';
68
66
  import './utils/triggerBrowserReflow.js';
67
+ import './components/FormControl/FormControl.js';
68
+ import 'nanoid';
69
+ import './hooks/usePrevious.js';
69
70
  import '@ilo-org/icons-react';
70
71
  import './components/Hero/HeroCard.js';
71
72
  import './components/SocialMedia/SocialMedia.js';
73
+ import './components/Input/Input.js';
74
+ import './components/FormElement/FormElement.js';
72
75
  import './VideoPlayer-a5fa87ce.js';
73
76
  import './utils/hoursMinutesSeconds.js';
74
77
  import 'screenfull';
@@ -0,0 +1,52 @@
1
+ import { LabelledCheckboxProps } from "./Checkbox.props";
2
+ /**
3
+ * Sample prop definitions Checkbox's enumerable properties (imported in stories and test)
4
+ */
5
+ declare const CheckboxArgs: {
6
+ basic: LabelledCheckboxProps;
7
+ basicCheckBoxes: {
8
+ id: string;
9
+ defaultChecked?: boolean | undefined;
10
+ checked?: boolean | undefined;
11
+ value?: string | undefined;
12
+ onChange?: ((e: import("react").ChangeEvent<HTMLInputElement>) => any) | undefined;
13
+ onBlur?: ((e: import("react").FocusEvent<HTMLInputElement>) => any) | undefined;
14
+ className?: string | undefined;
15
+ disabled?: boolean | undefined;
16
+ error?: boolean | undefined;
17
+ name: string;
18
+ required?: boolean | undefined;
19
+ style?: import("react").CSSProperties | undefined;
20
+ errorMessage?: string | undefined;
21
+ helper?: string | undefined;
22
+ label: string;
23
+ labelPlacement?: "top" | "start" | "bottom" | "end" | undefined;
24
+ labelSize?: "small" | "medium" | "large" | undefined;
25
+ tooltip?: string | undefined;
26
+ inputStyle?: import("react").CSSProperties | undefined;
27
+ }[];
28
+ errorCheckBoxes: {
29
+ id: string;
30
+ defaultChecked?: boolean | undefined;
31
+ checked?: boolean | undefined;
32
+ value?: string | undefined;
33
+ onChange?: ((e: import("react").ChangeEvent<HTMLInputElement>) => any) | undefined;
34
+ onBlur?: ((e: import("react").FocusEvent<HTMLInputElement>) => any) | undefined;
35
+ className?: string | undefined;
36
+ disabled?: boolean | undefined;
37
+ error?: boolean | undefined;
38
+ name: string;
39
+ required?: boolean | undefined;
40
+ style?: import("react").CSSProperties | undefined;
41
+ errorMessage?: string | undefined;
42
+ helper?: string | undefined;
43
+ label: string;
44
+ labelPlacement?: "top" | "start" | "bottom" | "end" | undefined;
45
+ labelSize?: "small" | "medium" | "large" | undefined;
46
+ tooltip?: string | undefined;
47
+ inputStyle?: import("react").CSSProperties | undefined;
48
+ }[];
49
+ checked: LabelledCheckboxProps;
50
+ error: LabelledCheckboxProps;
51
+ };
52
+ export default CheckboxArgs;
@@ -1,4 +1,6 @@
1
- import { FC } from "react";
1
+ import React from "react";
2
2
  import { CheckboxProps } from "./Checkbox.props";
3
- declare const Checkbox: FC<CheckboxProps>;
4
- export default Checkbox;
3
+ declare const LabelledCheckbox: React.ForwardRefExoticComponent<CheckboxProps & import("../FormControl/FormControl.props").FormControlPublicProps & {
4
+ inputStyle?: React.CSSProperties | undefined;
5
+ } & React.RefAttributes<HTMLInputElement>>;
6
+ export default LabelledCheckbox;
@@ -1,13 +1,4 @@
1
- export interface CheckboxProps {
2
- callback?: (e: React.ChangeEvent<HTMLInputElement>) => any;
3
- className?: string;
4
- disabled?: boolean;
5
- error?: string | false;
6
- grouped?: boolean;
7
- helper?: string;
8
- id?: string;
9
- label?: string;
10
- name: string;
11
- required?: boolean;
12
- tooltip?: string;
13
- }
1
+ import { ChoiceFieldProps } from "../../types";
2
+ import { LabelledFormFieldProps } from "../../types";
3
+ export type CheckboxProps = ChoiceFieldProps<HTMLInputElement>;
4
+ export type LabelledCheckboxProps = LabelledFormFieldProps<CheckboxProps>;
@@ -1 +1,2 @@
1
1
  export { default as Checkbox } from "./Checkbox";
2
+ export { default as CheckboxArgs } from "./Checkbox.args";
@@ -1,4 +1,5 @@
1
- import { FC } from "react";
2
1
  import { DatePickerProps } from "./DatePicker.props";
3
- declare const DatePicker: FC<DatePickerProps>;
4
- export default DatePicker;
2
+ declare const LabelledDatePicker: import("react").ForwardRefExoticComponent<DatePickerProps & import("../FormControl/FormControl.props").FormControlPublicProps & {
3
+ inputStyle?: import("react").CSSProperties | undefined;
4
+ } & import("react").RefAttributes<HTMLInputElement>>;
5
+ export default LabelledDatePicker;
@@ -1,54 +1,21 @@
1
- export interface DatePickerProps {
1
+ import { FormFieldProps } from "../../types";
2
+ import { LabelledFormFieldProps } from "../../types";
3
+ export interface DatePickerProps extends FormFieldProps<HTMLInputElement> {
2
4
  /**
3
- * The input's onChange callback.
5
+ * The latest date to accept
4
6
  */
5
- callback?: (e: React.ChangeEvent<HTMLInputElement>, picker?: string) => any;
7
+ max?: string | number;
6
8
  /**
7
- * Specify an optional className to be added to your input.
9
+ * The earliest date to accept.
8
10
  */
9
- className?: string;
11
+ min?: string | number;
10
12
  /**
11
- * Is the input disabled?
13
+ * The granularity of the date picker
12
14
  */
13
- disabled?: boolean;
14
- /**
15
- * If this is a range, the data for the second field
16
- */
17
- enddata?: DatePickerProps;
18
- /**
19
- * Does the input have an error?
20
- */
21
- error?: string | false;
22
- /**
23
- * The input's helper text
24
- */
25
- helper: string | false;
26
- /**
27
- * The input's id attribute
28
- */
29
- id?: string;
30
- /**
31
- * Does this input have a label?
32
- */
33
- label: string;
34
- /**
35
- * The input's name attribute
36
- */
37
- name?: Required<string>;
15
+ step?: number;
38
16
  /**
39
17
  * Specify an optional className to be added to your DatePicker component.
40
18
  */
41
19
  placeholder?: string;
42
- /**
43
- * Specify whether this is a date range
44
- */
45
- range?: boolean;
46
- /**
47
- * Specify whether this input is required
48
- */
49
- required?: boolean;
50
- /**
51
- * Does this DatePicker have a tooltip?
52
- */
53
- tooltip?: string;
54
20
  }
21
+ export type LabelledDatePickerProps = LabelledFormFieldProps<DatePickerProps>;
@@ -1,4 +1,6 @@
1
- import { FC } from "react";
1
+ import React from "react";
2
2
  import { DropdownProps } from "./Dropdown.props";
3
- declare const Dropdown: FC<DropdownProps>;
4
- export default Dropdown;
3
+ declare const LabelledDropdown: React.ForwardRefExoticComponent<DropdownProps & import("../FormControl/FormControl.props").FormControlPublicProps & {
4
+ inputStyle?: React.CSSProperties | undefined;
5
+ } & React.RefAttributes<HTMLSelectElement>>;
6
+ export default LabelledDropdown;
@@ -1,3 +1,5 @@
1
+ import { FormFieldProps } from "../../types";
2
+ import { LabelledFormFieldProps } from "../../types";
1
3
  export interface OptionProps {
2
4
  /**
3
5
  * Is this option disabled?
@@ -6,64 +8,36 @@ export interface OptionProps {
6
8
  /**
7
9
  * The option's label
8
10
  */
9
- label: Required<string>;
11
+ label: string;
10
12
  /**
11
13
  * The option's value
12
14
  */
13
- value?: Required<string>;
15
+ value?: string;
14
16
  }
15
- export interface DropdownProps {
17
+ export interface DropdownProps extends FormFieldProps<HTMLSelectElement> {
16
18
  /**
17
- * Should the Dropdown allow default browser autocomplete functionality?
18
- * Ideally this would be boolean but for some reason React expects a string. So: "true" if true.
19
+ * A string providing a hint for a user agent's autocomplete feature.
19
20
  */
20
- autocomplete: string;
21
+ autocomplete?: string;
21
22
  /**
22
- * The Dropdown's onChange callback.
23
+ * The form element to associate the Dropdown with if it's not nested in a form element.
23
24
  */
24
- callback?: (e: React.ChangeEvent<HTMLSelectElement>) => any;
25
+ form?: string;
25
26
  /**
26
- * Specify an optional className to be added to your Profile component.
27
+ * Indicates that multiple options can be selected from the list.
27
28
  */
28
- className?: string;
29
- /**
30
- * Is the Dropdown disabled?
31
- */
32
- disabled?: boolean;
33
- /**
34
- * Does the Dropdown have an error?
35
- */
36
- error?: string | false;
37
- /**
38
- * The Dropdown's helper text
39
- */
40
- helper: string | false;
41
- /**
42
- * The Dropdown's id attribute
43
- */
44
- id?: string;
45
- /**
46
- * The Dropdown's label
47
- */
48
- label: string;
49
- /**
50
- * The Dropdown's name attribute
51
- */
52
- name?: Required<string>;
29
+ multiple?: boolean;
53
30
  /**
54
31
  * The Dropdown's options
55
32
  */
56
- options?: Required<Array<OptionProps>>;
57
- /**
58
- * Is a selection required?
59
- */
60
- required?: boolean;
33
+ options?: OptionProps[];
61
34
  /**
62
- * Does this Dropdown have a tooltip?
35
+ * Number of rows in the list that should be visible at one time. Corresponds to the select element's size attribute.
63
36
  */
64
- tooltip?: string;
37
+ selectSize?: number;
65
38
  /**
66
39
  * The Dropdown's default selection; should match one of the values in `options`
67
40
  */
68
- value: string;
41
+ value?: string;
69
42
  }
43
+ export type LabelledDropdownProps = LabelledFormFieldProps<DropdownProps>;
@@ -1,4 +1,10 @@
1
1
  import { FC } from "react";
2
2
  import { FieldsetProps } from "./Fieldset.props";
3
+ type FieldsetContextType = {
4
+ hasError: boolean;
5
+ setHasError: (value: boolean) => void;
6
+ };
7
+ export declare const FieldsetErrorContext: import("react").Context<FieldsetContextType>;
8
+ export declare const useFieldsetError: () => FieldsetContextType;
3
9
  declare const Fieldset: FC<FieldsetProps>;
4
10
  export default Fieldset;
@@ -1,34 +1,27 @@
1
- import { ReactElement } from "react";
2
- import { InputProps } from "../Input/Input.props";
3
- import { TextareaProps } from "../Textarea/Textarea.props";
4
- export type FieldsetChild = ReactElement<InputProps | TextareaProps>;
5
- export interface FieldsetProps {
1
+ import { HTMLProps } from "react";
2
+ export interface FieldsetProps extends HTMLProps<HTMLFieldSetElement> {
6
3
  /**
7
- * Specify the content of your Fieldset.
8
- */
9
- children: (null | false | FieldsetChild) | (null | false | FieldsetChild)[];
10
- /**
11
- * Specify an optional className to be added to your Fieldset component.
12
- */
13
- className?: string;
14
- /**
15
- * The fieldset's id
4
+ * Optional helper text for the fieldset
16
5
  */
17
- fieldsetid?: string;
6
+ helper?: string;
18
7
  /**
19
8
  * Optional error text for the fieldset
20
9
  */
21
- grouperror?: string;
22
- /**
23
- * Optional helper text for the fieldset
24
- */
25
- grouphelper?: string;
10
+ errorMessage?: string;
26
11
  /**
27
12
  * Optional tooltip text for the fieldset
28
13
  */
29
- grouptooltip?: string;
14
+ tooltip?: string;
30
15
  /**
31
16
  * The fieldset's legend
32
17
  */
33
18
  legend?: string;
19
+ /**
20
+ * The direction of the Fieldset's children
21
+ */
22
+ direction?: "row" | "column" | "row-reverse" | "column-reverse";
23
+ /**
24
+ * How the Fieldset children will wrap
25
+ */
26
+ wrap?: "reverse" | "nowrap" | "wrap" | "wrap-reverse";
34
27
  }
@@ -1,4 +1,6 @@
1
- import { FC } from "react";
1
+ import React from "react";
2
2
  import { FileUploadProps } from "./FileUpload.props";
3
- declare const FileUpload: FC<FileUploadProps>;
4
- export default FileUpload;
3
+ declare const LabelledFileUpload: React.ForwardRefExoticComponent<FileUploadProps & import("../FormControl/FormControl.props").FormControlPublicProps & {
4
+ inputStyle?: React.CSSProperties | undefined;
5
+ } & React.RefAttributes<HTMLInputElement>>;
6
+ export default LabelledFileUpload;
@@ -1,50 +1,13 @@
1
- export interface FileUploadProps {
1
+ import { FormFieldProps } from "../../types";
2
+ import { LabelledFormFieldProps } from "../../types";
3
+ export interface FileUploadProps extends FormFieldProps<HTMLInputElement> {
2
4
  /**
3
- * The FileUpload's onChange callback.
4
- */
5
- callback?: (e: React.ChangeEvent<HTMLInputElement>) => any;
6
- /**
7
- * Specify an optional className to be added to your FileUpload.
8
- */
9
- className?: string;
10
- /**
11
- * Is the FileUpload disabled?
12
- */
13
- disabled?: boolean;
14
- /**
15
- * Does the FileUpload have an error?
16
- */
17
- error?: string | false;
18
- /**
19
- * The FileUpload's helper text
20
- */
21
- helper: string | false;
22
- /**
23
- * The FileUpload's id attribute
24
- */
25
- id?: string;
26
- /**
27
- * Does this FileUpload have a label?
28
- */
29
- label: string;
30
- /**
31
- * Should the FileUpload allow multiple uploads?
32
- */
33
- multiple?: boolean;
34
- /**
35
- * The FileUpload's name attribute
36
- */
37
- name?: Required<string>;
38
- /**
39
- * Specify an optional className to be added to your FileUpload component.
5
+ * The placeholder for the input
40
6
  */
41
7
  placeholder?: string;
42
8
  /**
43
- * Specify whether this FileUpload is required
9
+ * Can the user upload more than one file?
44
10
  */
45
- required?: boolean;
46
- /**
47
- * Does this FileUpload have a tooltip?
48
- */
49
- tooltip?: string;
11
+ multiple?: boolean;
50
12
  }
13
+ export type LabelledFileUploadProps = LabelledFormFieldProps<FileUploadProps>;
@@ -0,0 +1,2 @@
1
+ import { FormProps } from "./Form.props";
2
+ export declare const basic: FormProps;
@@ -1,4 +1,3 @@
1
- import { FC } from "react";
2
1
  import { FormProps } from "./Form.props";
3
- declare const Form: FC<FormProps>;
2
+ declare const Form: import("react").ForwardRefExoticComponent<FormProps & import("react").RefAttributes<HTMLFormElement>>;
4
3
  export default Form;
@@ -1,114 +1,7 @@
1
- import { CheckboxProps } from "../Checkbox/Checkbox.props";
2
- import { DatePickerProps } from "../DatePicker/DatePicker.props";
3
- import { DropdownProps } from "../Dropdown/Dropdown.props";
4
- import { FileUploadProps } from "../FileUpload/FileUpload.props";
5
- import { NumberPickerProps } from "../NumberPicker/NumberPicker.props";
6
- import { RadioProps } from "../Radio/Radio.props";
7
- import { TextareaProps } from "../Textarea/Textarea.props";
8
- import { InputProps } from "../Input/Input.props";
9
- import { FormGroupProps } from "../FormGroup/FormGroup.props";
10
- export interface InputItem {
11
- type: "input";
12
- field: InputProps;
13
- choicegroupid?: never;
14
- legend?: never;
15
- grouptooltip?: never;
16
- grouperror?: never;
17
- grouphelper?: never;
18
- }
19
- export interface DropdownItem {
20
- type: "dropdown";
21
- field: DropdownProps;
22
- choicegroupid?: never;
23
- legend?: never;
24
- grouptooltip?: never;
25
- grouperror?: never;
26
- grouphelper?: never;
27
- }
28
- export interface CheckboxItem {
29
- type: "checkbox";
30
- field: CheckboxProps | CheckboxProps[];
31
- choicegroupid: string;
32
- legend?: string;
33
- grouptooltip?: string;
34
- grouperror?: string;
35
- grouphelper?: string;
36
- }
37
- export interface RadioItem {
38
- type: "radio";
39
- field: RadioProps | RadioProps[];
40
- choicegroupid: string;
41
- legend?: string;
42
- grouptooltip?: string;
43
- grouperror?: string;
44
- grouphelper?: string;
45
- }
46
- export interface FileUploadItem {
47
- type: "file";
48
- field: FileUploadProps;
49
- choicegroupid?: never;
50
- legend?: never;
51
- grouptooltip?: never;
52
- grouperror?: never;
53
- grouphelper?: never;
54
- }
55
- export interface NumberPickerItem {
56
- type: "number";
57
- field: NumberPickerProps;
58
- choicegroupid?: never;
59
- legend?: never;
60
- grouptooltip?: never;
61
- grouperror?: never;
62
- grouphelper?: never;
63
- }
64
- export interface DatePickerItem {
65
- type: "date";
66
- field: DatePickerProps;
67
- choicegroupid?: never;
68
- legend?: never;
69
- grouptooltip?: never;
70
- grouperror?: never;
71
- grouphelper?: never;
72
- }
73
- export interface TextareaItem {
74
- type: "textarea";
75
- field: TextareaProps;
76
- choicegroupid?: never;
77
- legend?: never;
78
- grouptooltip?: never;
79
- grouperror?: never;
80
- grouphelper?: never;
81
- }
82
- export interface FormGroupItem {
83
- type: "formgroup";
84
- field: FormGroupProps;
85
- choicegroupid?: string;
86
- legend?: string;
87
- grouptooltip?: string;
88
- grouperror?: string;
89
- grouphelper?: string;
90
- }
91
- type FormItem = InputItem | DropdownItem | CheckboxItem | RadioItem | FileUploadItem | NumberPickerItem | DatePickerItem | TextareaItem | FormGroupItem;
92
- export interface FormProps {
93
- /**
94
- * The form's action attribute
95
- */
96
- action: Required<string>;
97
- /**
98
- * Specify an optional className to be added to your Form component.
99
- */
100
- className?: string;
101
- /**
102
- * The ID of the form
103
- */
104
- formid: Required<string>;
105
- /**
106
- * The inputs in this form group
107
- */
108
- items: FormItem[];
1
+ export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
2
+ children?: React.ReactNode;
109
3
  /**
110
- * The label for the form's submit button
4
+ * The theme of the form. Also sets the theme of the form's children.
111
5
  */
112
- submitlabel: string;
6
+ theme?: "light" | "dark";
113
7
  }
114
- export {};
@@ -1 +1,2 @@
1
1
  export { default as Form } from "./Form";
2
+ export * as FormArgs from "./Form.args";