@dhis2/ui-forms 9.11.0 → 9.11.1-beta.1

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 (192) hide show
  1. package/build/cjs/CheckboxFieldFF/{CheckboxFieldFF.stories.e2e.js → CheckboxFieldFF.e2e.stories.js} +22 -15
  2. package/build/cjs/CheckboxFieldFF/CheckboxFieldFF.js +2 -12
  3. package/build/cjs/CheckboxFieldFF/{CheckboxFieldFF.stories.js → CheckboxFieldFF.prod.stories.js} +29 -24
  4. package/build/cjs/CheckboxFieldFF/features/can_toggle_a_boolean/index.js +0 -1
  5. package/build/cjs/CheckboxFieldFF/features/can_toggle_a_value/index.js +0 -1
  6. package/build/cjs/CheckboxFieldFF/features/common/index.js +0 -1
  7. package/build/cjs/CheckboxFieldFF/features/displays_error/index.js +0 -2
  8. package/build/cjs/FieldGroupFF/FieldGroupFF.js +1 -10
  9. package/build/cjs/FieldGroupFF/{FieldGroupFF.stories.js → FieldGroupFF.prod.stories.js} +11 -12
  10. package/build/cjs/FileInputFieldFF/{FileInputFieldFF.stories.e2e.js → FileInputFieldFF.e2e.stories.js} +45 -56
  11. package/build/cjs/FileInputFieldFF/FileInputFieldFF.js +2 -19
  12. package/build/cjs/FileInputFieldFF/{FileInputFieldFF.stories.js → FileInputFieldFF.prod.stories.js} +29 -22
  13. package/build/cjs/FileInputFieldFF/features/accepts_file/index.js +0 -1
  14. package/build/cjs/FileInputFieldFF/features/common/index.js +0 -1
  15. package/build/cjs/FileInputFieldFF/features/displays_error/index.js +0 -1
  16. package/build/cjs/InputFieldFF/InputFieldFF.e2e.stories.js +30 -0
  17. package/build/cjs/InputFieldFF/InputFieldFF.js +2 -12
  18. package/build/cjs/InputFieldFF/{InputFieldFF.stories.js → InputFieldFF.prod.stories.js} +29 -22
  19. package/build/cjs/InputFieldFF/features/can_set_a_value/index.js +0 -1
  20. package/build/cjs/InputFieldFF/features/displays_error/index.js +0 -2
  21. package/build/cjs/MultiSelectFieldFF/{MultiSelectFieldFF.stories.e2e.js → MultiSelectFieldFF.e2e.stories.js} +15 -17
  22. package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.js +3 -15
  23. package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.prod.stories.js +107 -0
  24. package/build/cjs/MultiSelectFieldFF/features/can_set_a_value/index.js +0 -1
  25. package/build/cjs/MultiSelectFieldFF/features/common/index.js +1 -2
  26. package/build/cjs/MultiSelectFieldFF/features/displays_error/index.js +0 -2
  27. package/build/cjs/RadioFieldFF/RadioFieldFF.e2e.stories.js +45 -0
  28. package/build/cjs/RadioFieldFF/RadioFieldFF.js +2 -12
  29. package/build/cjs/RadioFieldFF/{RadioFieldFF.stories.js → RadioFieldFF.prod.stories.js} +29 -16
  30. package/build/cjs/RadioFieldFF/features/can_set_a_value/index.js +0 -1
  31. package/build/cjs/RadioFieldFF/features/common/index.js +0 -1
  32. package/build/cjs/RadioFieldFF/features/displays_error/index.js +0 -2
  33. package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.e2e.stories.js +39 -0
  34. package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.js +2 -12
  35. package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.prod.stories.js +106 -0
  36. package/build/cjs/SingleSelectFieldFF/features/can_set_a_value/index.js +0 -1
  37. package/build/cjs/SingleSelectFieldFF/features/common/index.js +0 -1
  38. package/build/cjs/SingleSelectFieldFF/features/displays_error/index.js +0 -2
  39. package/build/cjs/SwitchFieldFF/SwitchFieldFF.e2e.stories.js +56 -0
  40. package/build/cjs/SwitchFieldFF/SwitchFieldFF.js +2 -12
  41. package/build/cjs/SwitchFieldFF/{SwitchFieldFF.stories.js → SwitchFieldFF.prod.stories.js} +29 -24
  42. package/build/cjs/SwitchFieldFF/features/can_toggle_a_boolean/index.js +0 -1
  43. package/build/cjs/SwitchFieldFF/features/can_toggle_a_value/index.js +0 -1
  44. package/build/cjs/SwitchFieldFF/features/common/index.js +0 -1
  45. package/build/cjs/SwitchFieldFF/features/displays_error/index.js +0 -2
  46. package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.e2e.stories.js +30 -0
  47. package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.js +2 -12
  48. package/build/cjs/TextAreaFieldFF/{TextAreaFieldFF.stories.js → TextAreaFieldFF.prod.stories.js} +29 -24
  49. package/build/cjs/TextAreaFieldFF/features/can_set_a_value/index.js +0 -1
  50. package/build/cjs/TextAreaFieldFF/features/displays_error/index.js +0 -2
  51. package/build/cjs/__tests__/__snapshots__/index.test.js.snap +3 -0
  52. package/build/cjs/__tests__/index.test.js +1 -1
  53. package/build/cjs/formDecorator.js +6 -21
  54. package/build/cjs/index.js +2 -21
  55. package/build/cjs/locales/index.js +3 -75
  56. package/build/cjs/shared/helpers/createBlurHandler.js +0 -3
  57. package/build/cjs/shared/helpers/createChangeHandler.js +0 -2
  58. package/build/cjs/shared/helpers/createFocusHandler.js +0 -3
  59. package/build/cjs/shared/helpers/createSelectChangeHandler.js +0 -2
  60. package/build/cjs/shared/helpers/createToggleChangeHandler.js +0 -3
  61. package/build/cjs/shared/helpers/getValidationText.js +0 -6
  62. package/build/cjs/shared/helpers/hasError.js +0 -2
  63. package/build/cjs/shared/helpers/isLoading.js +0 -2
  64. package/build/cjs/shared/helpers/isValid.js +0 -2
  65. package/build/cjs/shared/helpers.js +0 -9
  66. package/build/cjs/shared/propTypes.js +7 -20
  67. package/build/cjs/transformers/arrayWithIdObjects.js +2 -6
  68. package/build/cjs/transformers/index.js +0 -1
  69. package/build/cjs/validators/__tests__/alphaNumeric.test.js +0 -2
  70. package/build/cjs/validators/__tests__/boolean.test.js +0 -2
  71. package/build/cjs/validators/__tests__/composeValidators.test.js +0 -3
  72. package/build/cjs/validators/__tests__/createCharacterLengthRange.test.js +6 -6
  73. package/build/cjs/validators/__tests__/createEqualTo.test.js +0 -3
  74. package/build/cjs/validators/__tests__/createMaxCharacterLength.test.js +1 -2
  75. package/build/cjs/validators/__tests__/createMaxNumber.test.js +1 -2
  76. package/build/cjs/validators/__tests__/createMinCharacterLength.test.js +1 -2
  77. package/build/cjs/validators/__tests__/createMinNumber.test.js +1 -2
  78. package/build/cjs/validators/__tests__/createNumberRange.test.js +0 -3
  79. package/build/cjs/validators/__tests__/createPattern.test.js +1 -3
  80. package/build/cjs/validators/__tests__/dhis2Password.test.js +0 -2
  81. package/build/cjs/validators/__tests__/dhis2Username.test.js +0 -2
  82. package/build/cjs/validators/__tests__/email.test.js +7 -6
  83. package/build/cjs/validators/__tests__/hasValue.test.js +0 -2
  84. package/build/cjs/validators/__tests__/integer.test.js +0 -2
  85. package/build/cjs/validators/__tests__/internationalPhoneNumber.test.js +6 -5
  86. package/build/cjs/validators/__tests__/number.test.js +0 -2
  87. package/build/cjs/validators/__tests__/string.test.js +0 -2
  88. package/build/cjs/validators/__tests__/url.test.js +1 -2
  89. package/build/cjs/validators/alphaNumeric.js +2 -11
  90. package/build/cjs/validators/boolean.js +2 -10
  91. package/build/cjs/validators/composeValidators.js +0 -4
  92. package/build/cjs/validators/createCharacterLengthRange.js +1 -8
  93. package/build/cjs/validators/createEqualTo.js +1 -8
  94. package/build/cjs/validators/createMaxCharacterLength.js +1 -6
  95. package/build/cjs/validators/createMaxNumber.js +1 -6
  96. package/build/cjs/validators/createMinCharacterLength.js +1 -6
  97. package/build/cjs/validators/createMinNumber.js +1 -6
  98. package/build/cjs/validators/createNumberRange.js +1 -8
  99. package/build/cjs/validators/createPattern.js +2 -10
  100. package/build/cjs/validators/dhis2Password.js +6 -28
  101. package/build/cjs/validators/dhis2Username.js +2 -11
  102. package/build/cjs/validators/email.js +3 -11
  103. package/build/cjs/validators/hasValue.js +2 -10
  104. package/build/cjs/validators/helpers/index.js +1 -16
  105. package/build/cjs/validators/index.js +0 -20
  106. package/build/cjs/validators/integer.js +3 -10
  107. package/build/cjs/validators/internationalPhoneNumber.js +8 -14
  108. package/build/cjs/validators/number.js +2 -10
  109. package/build/cjs/validators/string.js +2 -10
  110. package/build/cjs/validators/test-helpers/index.js +1 -6
  111. package/build/cjs/validators/url.js +2 -11
  112. package/build/es/CheckboxFieldFF/{CheckboxFieldFF.stories.e2e.js → CheckboxFieldFF.e2e.stories.js} +14 -7
  113. package/build/es/CheckboxFieldFF/CheckboxFieldFF.js +1 -3
  114. package/build/es/CheckboxFieldFF/{CheckboxFieldFF.stories.js → CheckboxFieldFF.prod.stories.js} +29 -3
  115. package/build/es/FieldGroupFF/FieldGroupFF.js +0 -2
  116. package/build/es/FieldGroupFF/{FieldGroupFF.stories.js → FieldGroupFF.prod.stories.js} +11 -1
  117. package/build/es/FileInputFieldFF/{FileInputFieldFF.stories.e2e.js → FileInputFieldFF.e2e.stories.js} +14 -16
  118. package/build/es/FileInputFieldFF/FileInputFieldFF.js +1 -8
  119. package/build/es/FileInputFieldFF/{FileInputFieldFF.stories.js → FileInputFieldFF.prod.stories.js} +29 -3
  120. package/build/es/InputFieldFF/{InputFieldFF.stories.e2e.js → InputFieldFF.e2e.stories.js} +8 -4
  121. package/build/es/InputFieldFF/InputFieldFF.js +1 -3
  122. package/build/es/InputFieldFF/{InputFieldFF.stories.js → InputFieldFF.prod.stories.js} +29 -3
  123. package/build/es/MultiSelectFieldFF/{MultiSelectFieldFF.stories.e2e.js → MultiSelectFieldFF.e2e.stories.js} +7 -7
  124. package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.js +2 -6
  125. package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.prod.stories.js +98 -0
  126. package/build/es/MultiSelectFieldFF/features/common/index.js +1 -1
  127. package/build/es/RadioFieldFF/{RadioFieldFF.stories.e2e.js → RadioFieldFF.e2e.stories.js} +6 -3
  128. package/build/es/RadioFieldFF/RadioFieldFF.js +1 -3
  129. package/build/es/RadioFieldFF/{RadioFieldFF.stories.js → RadioFieldFF.prod.stories.js} +29 -3
  130. package/build/es/SingleSelectFieldFF/{SingleSelectFieldFF.stories.e2e.js → SingleSelectFieldFF.e2e.stories.js} +10 -6
  131. package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.js +1 -3
  132. package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.prod.stories.js +97 -0
  133. package/build/es/SwitchFieldFF/{SwitchFieldFF.stories.e2e.js → SwitchFieldFF.e2e.stories.js} +14 -7
  134. package/build/es/SwitchFieldFF/SwitchFieldFF.js +1 -3
  135. package/build/es/SwitchFieldFF/{SwitchFieldFF.stories.js → SwitchFieldFF.prod.stories.js} +29 -3
  136. package/build/es/TextAreaFieldFF/{TextAreaFieldFF.stories.e2e.js → TextAreaFieldFF.e2e.stories.js} +8 -4
  137. package/build/es/TextAreaFieldFF/TextAreaFieldFF.js +1 -3
  138. package/build/es/TextAreaFieldFF/{TextAreaFieldFF.stories.js → TextAreaFieldFF.prod.stories.js} +29 -3
  139. package/build/es/__tests__/__snapshots__/index.test.js.snap +3 -0
  140. package/build/es/__tests__/index.test.js +1 -0
  141. package/build/es/formDecorator.js +5 -12
  142. package/build/es/index.js +2 -2
  143. package/build/es/shared/helpers/createBlurHandler.js +0 -2
  144. package/build/es/shared/helpers/createChangeHandler.js +0 -2
  145. package/build/es/shared/helpers/createFocusHandler.js +0 -2
  146. package/build/es/shared/helpers/createSelectChangeHandler.js +0 -1
  147. package/build/es/shared/helpers/createToggleChangeHandler.js +0 -2
  148. package/build/es/shared/helpers/getValidationText.js +0 -5
  149. package/build/es/shared/helpers/hasError.js +0 -1
  150. package/build/es/shared/helpers/isLoading.js +0 -1
  151. package/build/es/shared/helpers/isValid.js +0 -1
  152. package/build/es/transformers/arrayWithIdObjects.js +0 -2
  153. package/build/es/validators/__tests__/createCharacterLengthRange.test.js +6 -3
  154. package/build/es/validators/__tests__/createMaxCharacterLength.test.js +1 -0
  155. package/build/es/validators/__tests__/createMaxNumber.test.js +1 -0
  156. package/build/es/validators/__tests__/createMinCharacterLength.test.js +1 -0
  157. package/build/es/validators/__tests__/createMinNumber.test.js +1 -0
  158. package/build/es/validators/__tests__/createPattern.test.js +1 -1
  159. package/build/es/validators/__tests__/email.test.js +7 -4
  160. package/build/es/validators/__tests__/internationalPhoneNumber.test.js +6 -3
  161. package/build/es/validators/__tests__/url.test.js +1 -0
  162. package/build/es/validators/alphaNumeric.js +0 -2
  163. package/build/es/validators/boolean.js +0 -2
  164. package/build/es/validators/composeValidators.js +0 -2
  165. package/build/es/validators/createCharacterLengthRange.js +0 -2
  166. package/build/es/validators/createEqualTo.js +0 -2
  167. package/build/es/validators/createMaxCharacterLength.js +0 -2
  168. package/build/es/validators/createMaxNumber.js +0 -2
  169. package/build/es/validators/createMinCharacterLength.js +0 -2
  170. package/build/es/validators/createMinNumber.js +0 -2
  171. package/build/es/validators/createNumberRange.js +0 -2
  172. package/build/es/validators/createPattern.js +0 -3
  173. package/build/es/validators/dhis2Password.js +3 -12
  174. package/build/es/validators/dhis2Username.js +0 -2
  175. package/build/es/validators/email.js +1 -2
  176. package/build/es/validators/hasValue.js +0 -2
  177. package/build/es/validators/integer.js +3 -4
  178. package/build/es/validators/internationalPhoneNumber.js +7 -7
  179. package/build/es/validators/number.js +0 -2
  180. package/build/es/validators/string.js +0 -2
  181. package/build/es/validators/test-helpers/index.js +1 -4
  182. package/build/es/validators/url.js +2 -3
  183. package/package.json +13 -13
  184. package/build/cjs/InputFieldFF/InputFieldFF.stories.e2e.js +0 -27
  185. package/build/cjs/MultiSelectFieldFF/MultiSelectFieldFF.stories.js +0 -91
  186. package/build/cjs/RadioFieldFF/RadioFieldFF.stories.e2e.js +0 -45
  187. package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.stories.e2e.js +0 -37
  188. package/build/cjs/SingleSelectFieldFF/SingleSelectFieldFF.stories.js +0 -90
  189. package/build/cjs/SwitchFieldFF/SwitchFieldFF.stories.e2e.js +0 -49
  190. package/build/cjs/TextAreaFieldFF/TextAreaFieldFF.stories.e2e.js +0 -27
  191. package/build/es/MultiSelectFieldFF/MultiSelectFieldFF.stories.js +0 -70
  192. package/build/es/SingleSelectFieldFF/SingleSelectFieldFF.stories.js +0 -69
@@ -1,4 +1,3 @@
1
- import { storiesOf } from '@storybook/react';
2
1
  import React from 'react';
3
2
  import { Field } from 'react-final-form';
4
3
  import { CheckboxFieldFF } from '../CheckboxFieldFF/CheckboxFieldFF.js';
@@ -12,8 +11,7 @@ import { SwitchFieldFF } from '../SwitchFieldFF/SwitchFieldFF.js';
12
11
  import { TextAreaFieldFF } from '../TextAreaFieldFF/TextAreaFieldFF.js';
13
12
  import { composeValidators, email, hasValue } from '../validators/index.js';
14
13
  import { FileInputFieldFF } from './FileInputFieldFF.js';
15
-
16
- const StandardForm = _ref => {
14
+ const Form = _ref => {
17
15
  let {
18
16
  values
19
17
  } = _ref;
@@ -194,11 +192,9 @@ const StandardForm = _ref => {
194
192
  if (!files) {
195
193
  return undefined;
196
194
  }
197
-
198
195
  const [file] = files;
199
-
200
196
  if (file.type !== 'text/plain') {
201
- return "The file you provided is not a txt file, received \"".concat(file.type, "\"");
197
+ return `The file you provided is not a txt file, received "${file.type}"`;
202
198
  }
203
199
  },
204
200
  component: FileInputFieldFF
@@ -211,14 +207,12 @@ const StandardForm = _ref => {
211
207
  if (!files) {
212
208
  return undefined;
213
209
  }
214
-
215
210
  return files.reduce((error, file) => {
216
211
  if (error) {
217
212
  return error;
218
213
  }
219
-
220
214
  if (file.type !== 'application/jpg') {
221
- return "One of the files is not a jpg, received \"".concat(file.type, "\"");
215
+ return `One of the files is not a jpg, received "${file.type}"`;
222
216
  }
223
217
  }, undefined);
224
218
  },
@@ -233,14 +227,18 @@ const StandardForm = _ref => {
233
227
  className: "checkbox"
234
228
  }));
235
229
  };
236
-
237
- storiesOf('Testing:FileInput', module).addDecorator(formDecorator).addParameters({
238
- options: {
239
- showPanel: false
230
+ export default {
231
+ title: 'Testing:FileInput',
232
+ decorators: [formDecorator],
233
+ parameters: {
234
+ options: {
235
+ showPanel: false
236
+ }
240
237
  }
241
- }).add('Standard form', (_, _ref2) => {
238
+ };
239
+ export const StandardForm = (_, _ref2) => {
242
240
  let {
243
241
  formRenderProps
244
242
  } = _ref2;
245
- return /*#__PURE__*/React.createElement(StandardForm, formRenderProps);
246
- });
243
+ return /*#__PURE__*/React.createElement(Form, formRenderProps);
244
+ };
@@ -1,5 +1,4 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
2
  import { FileListItem, FileInputField } from '@dhis2-ui/file-input';
4
3
  import PropTypes from 'prop-types';
5
4
  import React from 'react';
@@ -8,21 +7,18 @@ import { hasError, isValid, getValidationText } from '../shared/helpers.js';
8
7
  import { inputPropType, metaPropType } from '../shared/propTypes.js';
9
8
  const btnLabel = i18n.t('Upload file');
10
9
  const btnLabelMulti = i18n.t('Upload files');
11
-
12
10
  const dedupeAndConcat = (currentFiles, newFileList) => {
13
11
  return [...currentFiles, ...newFileList].reduceRight((acc, file) => {
14
12
  if (!acc.unique.has(file.name)) {
15
13
  acc.unique.add(file.name);
16
14
  acc.files.unshift(file);
17
15
  }
18
-
19
16
  return acc;
20
17
  }, {
21
18
  files: [],
22
19
  unique: new Set()
23
20
  }).files;
24
21
  };
25
-
26
22
  const createChangeHandler = (input, multifile) => _ref => {
27
23
  let {
28
24
  files
@@ -34,13 +30,11 @@ const createChangeHandler = (input, multifile) => _ref => {
34
30
  const value = multifile ? dedupeAndConcat(currentFiles, files) : [...files];
35
31
  input.onChange(value);
36
32
  };
37
-
38
33
  const createRemoveHandler = (input, fileToDelete) => () => {
39
34
  const files = input.value.filter(file => file !== fileToDelete);
40
35
  const value = files.length > 0 ? files : '';
41
36
  input.onChange(value);
42
37
  };
43
-
44
38
  export const FileInputFieldFF = _ref2 => {
45
39
  let {
46
40
  buttonLabel,
@@ -74,7 +68,6 @@ export const FileInputFieldFF = _ref2 => {
74
68
  FileInputFieldFF.propTypes = {
75
69
  /** `input` props provided by Final Form `Field` */
76
70
  input: inputPropType.isRequired,
77
-
78
71
  /** `meta` props provided by Final Form `Field` */
79
72
  meta: metaPropType.isRequired,
80
73
  buttonLabel: PropTypes.string,
@@ -4,7 +4,31 @@ import { formDecorator } from '../formDecorator.js';
4
4
  import { inputArgType, metaArgType } from '../shared/propTypes.js';
5
5
  import { hasValue } from '../validators/index.js';
6
6
  import { FileInputFieldFF } from './FileInputFieldFF.js';
7
- const description = "\nThe `FileInputFieldFF` is a wrapper around a `FileInputField` that enables it to work with Final Form, the preferred library in DHIS 2 apps for form validation and utilities.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={FileInputFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `FileInputFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `FileInputFieldFF`, which passes any extra props to the underlying `FileInputField` using `{...rest}`.\n\nTherefore, to add any props to the `FileInputFieldFF` or `FileInputField`, add those props to the parent Final Form `Field` component.\n\nAlso see `FileInput` and `FileInputField` for notes about props and implementation.\n\n```js\nimport { FileInputFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
7
+ const description = `
8
+ The \`FileInputFieldFF\` is a wrapper around a \`FileInputField\` that enables it to work with Final Form, the preferred library in DHIS 2 apps for form validation and utilities.
9
+
10
+ #### Final Form
11
+
12
+ See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
13
+
14
+ Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={FileInputFieldFF} />\`. See the code samples below for examples.
15
+
16
+ #### Props
17
+
18
+ The props shown in the table below are generally provided to the \`FileInputFieldFF\` wrapper by the Final Form \`Field\`.
19
+
20
+ Note that any props beyond the API of the \`Field\` component will be spread to the \`FileInputFieldFF\`, which passes any extra props to the underlying \`FileInputField\` using \`{...rest}\`.
21
+
22
+ Therefore, to add any props to the \`FileInputFieldFF\` or \`FileInputField\`, add those props to the parent Final Form \`Field\` component.
23
+
24
+ Also see \`FileInput\` and \`FileInputField\` for notes about props and implementation.
25
+
26
+ \`\`\`js
27
+ import { FileInputFieldFF } from '@dhis2/ui'
28
+ \`\`\`
29
+
30
+ Press **Submit** to see the form values logged to the console.
31
+ `;
8
32
  const files = [new File([], 'file1.txt'), new File([], 'file2.txt')];
9
33
  export default {
10
34
  title: 'File Input Field (Final Form)',
@@ -18,9 +42,11 @@ export default {
18
42
  }
19
43
  },
20
44
  argTypes: {
21
- input: { ...inputArgType
45
+ input: {
46
+ ...inputArgType
22
47
  },
23
- meta: { ...metaArgType
48
+ meta: {
49
+ ...metaArgType
24
50
  }
25
51
  }
26
52
  };
@@ -1,17 +1,21 @@
1
- import { storiesOf } from '@storybook/react';
2
1
  import React from 'react';
3
2
  import { Field } from 'react-final-form';
4
3
  import { formDecorator } from '../formDecorator.js';
5
4
  import { hasValue } from '../validators/index.js';
6
5
  import { InputFieldFF } from './InputFieldFF.js';
7
- storiesOf('Testing:InputFieldFF', module).addDecorator(formDecorator).add('Default', () => /*#__PURE__*/React.createElement(Field, {
6
+ export default {
7
+ title: 'Testing:InputFieldFF',
8
+ decorators: [formDecorator]
9
+ };
10
+ export const Default = () => /*#__PURE__*/React.createElement(Field, {
8
11
  component: InputFieldFF,
9
12
  name: "agree",
10
13
  label: "Do you agree?"
11
- })).add('Required', () => /*#__PURE__*/React.createElement(Field, {
14
+ });
15
+ export const Required = () => /*#__PURE__*/React.createElement(Field, {
12
16
  name: "agree",
13
17
  component: InputFieldFF,
14
18
  required: true,
15
19
  validate: hasValue,
16
20
  label: "Do you agree?"
17
- }));
21
+ });
@@ -1,5 +1,4 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
2
  import { InputField } from '@dhis2-ui/input';
4
3
  import PropTypes from 'prop-types';
5
4
  import React from 'react';
@@ -35,7 +34,6 @@ export const InputFieldFF = _ref => {
35
34
  InputFieldFF.propTypes = {
36
35
  /** `input` props received from Final Form `Field` */
37
36
  input: inputPropType.isRequired,
38
-
39
37
  /** `meta` props received from Final Form `Field` */
40
38
  meta: metaPropType.isRequired,
41
39
  error: PropTypes.bool,
@@ -4,7 +4,31 @@ import { formDecorator } from '../formDecorator.js';
4
4
  import { inputArgType, metaArgType } from '../shared/propTypes.js';
5
5
  import { hasValue } from '../validators/index.js';
6
6
  import { InputFieldFF } from './InputFieldFF.js';
7
- const description = "\nThe `InputFieldFF` is a wrapper around a `InputField` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={InputFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `InputFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `InputFieldFF`, which passes any extra props to the underlying `InputField` using `{...rest}`.\n\nTherefore, to add any props to the `InputFieldFF` or `InputField`, add those props to the parent Final Form `Field` component.\n\nAlso see `InputField` for notes about props and implementation.\n\n```js\nimport { InputFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
7
+ const description = `
8
+ The \`InputFieldFF\` is a wrapper around a \`InputField\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
9
+
10
+ #### Final Form
11
+
12
+ See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
13
+
14
+ Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={InputFieldFF} />\`. See the code samples below for examples.
15
+
16
+ #### Props
17
+
18
+ The props shown in the table below are generally provided to the \`InputFieldFF\` wrapper by the Final Form \`Field\`.
19
+
20
+ Note that any props beyond the API of the \`Field\` component will be spread to the \`InputFieldFF\`, which passes any extra props to the underlying \`InputField\` using \`{...rest}\`.
21
+
22
+ Therefore, to add any props to the \`InputFieldFF\` or \`InputField\`, add those props to the parent Final Form \`Field\` component.
23
+
24
+ Also see \`InputField\` for notes about props and implementation.
25
+
26
+ \`\`\`js
27
+ import { InputFieldFF } from '@dhis2/ui'
28
+ \`\`\`
29
+
30
+ Press **Submit** to see the form values logged to the console.
31
+ `;
8
32
  export default {
9
33
  title: 'Input Field (Final Form)',
10
34
  component: InputFieldFF,
@@ -17,9 +41,11 @@ export default {
17
41
  }
18
42
  },
19
43
  argTypes: {
20
- input: { ...inputArgType
44
+ input: {
45
+ ...inputArgType
21
46
  },
22
- meta: { ...metaArgType
47
+ meta: {
48
+ ...metaArgType
23
49
  }
24
50
  }
25
51
  };
@@ -1,4 +1,3 @@
1
- import { storiesOf } from '@storybook/react';
2
1
  import React from 'react';
3
2
  import { Field } from 'react-final-form';
4
3
  import { formDecorator } from '../formDecorator.js';
@@ -11,11 +10,12 @@ const defaultOptions = [{
11
10
  value: 'second',
12
11
  label: 'Second'
13
12
  }];
14
- storiesOf('Testing:MultiSelectFieldFF', module).addDecorator(formDecorator).addParameters({
15
- options: {
16
- showPanel: false
17
- }
18
- }).add('Required', (_, _ref) => {
13
+ export default {
14
+ title: 'MultiSelectFieldFF',
15
+ component: MultiSelectFieldFF,
16
+ decorators: [formDecorator]
17
+ };
18
+ export const Required = (_, _ref) => {
19
19
  let {
20
20
  cypressProps
21
21
  } = _ref;
@@ -27,4 +27,4 @@ storiesOf('Testing:MultiSelectFieldFF', module).addDecorator(formDecorator).addP
27
27
  validate: hasValue,
28
28
  options: cypressProps.options || defaultOptions
29
29
  });
30
- });
30
+ };
@@ -1,5 +1,4 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
2
  import { MultiSelectOption, MultiSelectField } from '@dhis2-ui/select';
4
3
  import PropTypes from 'prop-types';
5
4
  import React from 'react';
@@ -29,9 +28,7 @@ export const MultiSelectFieldFF = _ref => {
29
28
  onFocus: createFocusHandler(input, onFocus),
30
29
  onChange: createSelectChangeHandler(input),
31
30
  onBlur: createBlurHandler(input, onBlur),
32
- selected: input.value || []
33
- /* input.value is an empty string initially, so we're providing an empty array if falsey */
34
-
31
+ selected: input.value || [] /* input.value is an empty string initially, so we're providing an empty array if falsey */
35
32
  }), options.map(option => /*#__PURE__*/React.createElement(MultiSelectOption, _extends({
36
33
  key: option.value
37
34
  }, option))));
@@ -39,7 +36,6 @@ export const MultiSelectFieldFF = _ref => {
39
36
  MultiSelectFieldFF.propTypes = {
40
37
  /** `input` props provided by Final Form `Field` */
41
38
  input: inputPropType.isRequired,
42
-
43
39
  /** `meta` props provided by Final Form `Field` */
44
40
  meta: metaPropType.isRequired,
45
41
  error: PropTypes.bool,
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+ import { Field } from 'react-final-form';
3
+ import { formDecorator } from '../formDecorator.js';
4
+ import { inputArgType, metaArgType } from '../shared/propTypes.js';
5
+ import { MultiSelectFieldFF } from './MultiSelectFieldFF.js';
6
+ const description = `
7
+ The \`MultiSelectFieldFF\` is a wrapper around a \`MultiSelectField\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
8
+
9
+ #### Final Form
10
+
11
+ See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
12
+
13
+ Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={MultiSelectFieldFF} />\`. See the code samples below for examples.
14
+
15
+ #### Props
16
+
17
+ The props shown in the table below are generally provided to the \`MultiSelectFieldFF\` wrapper by the Final Form \`Field\`.
18
+
19
+ Note that any props beyond the API of the \`Field\` component will be spread to the \`MultiSelectFieldFF\`, which passes any extra props to the underlying \`MultiSelectField\` using \`{...rest}\`.
20
+
21
+ Therefore, to add any props to the \`MultiSelectFieldFF\` or \`MultiSelectField\`, add those props to the parent Final Form \`Field\` component.
22
+
23
+ Also see \`MultiSelect\` and \`MultiSelectField\` for notes about props and implementation.
24
+
25
+ \`\`\`js
26
+ import { MultiSelectFieldFF } from '@dhis2/ui'
27
+ \`\`\`
28
+
29
+ Press **Submit** to see the form values logged to the console.
30
+
31
+ _**Note:** Dropdowns may not appear correctly on this page. See the affected demos in the 'Canvas' tab for propper dropdown placement._
32
+ `;
33
+ const options = [{
34
+ value: '1',
35
+ label: 'one'
36
+ }, {
37
+ value: '2',
38
+ label: 'two'
39
+ }, {
40
+ value: '3',
41
+ label: 'three'
42
+ }, {
43
+ value: '4',
44
+ label: 'four'
45
+ }, {
46
+ value: '5',
47
+ label: 'five'
48
+ }, {
49
+ value: '6',
50
+ label: 'six'
51
+ }, {
52
+ value: '7',
53
+ label: 'seven'
54
+ }, {
55
+ value: '8',
56
+ label: 'eight'
57
+ }, {
58
+ value: '9',
59
+ label: 'nine'
60
+ }, {
61
+ value: '10',
62
+ label: 'ten'
63
+ }];
64
+ const initialValue = ['3', '4', '9', '10'];
65
+ export default {
66
+ title: 'Multi Select Field (Final Form)',
67
+ component: MultiSelectFieldFF,
68
+ decorators: [formDecorator],
69
+ parameters: {
70
+ docs: {
71
+ description: {
72
+ component: description
73
+ }
74
+ }
75
+ },
76
+ argTypes: {
77
+ input: {
78
+ ...inputArgType
79
+ },
80
+ meta: {
81
+ ...metaArgType
82
+ }
83
+ }
84
+ };
85
+ export const Default = () => /*#__PURE__*/React.createElement(Field, {
86
+ component: MultiSelectFieldFF,
87
+ name: "agree",
88
+ label: "Do you agree?",
89
+ options: options
90
+ });
91
+ export const InitialValue = () => /*#__PURE__*/React.createElement(Field, {
92
+ component: MultiSelectFieldFF,
93
+ name: "agree",
94
+ label: "Do you agree?",
95
+ options: options,
96
+ initialValue: initialValue
97
+ });
98
+ InitialValue.storyName = 'InitialValue';
@@ -1,6 +1,6 @@
1
1
  import { Given } from '@badeball/cypress-cucumber-preprocessor';
2
2
  Given('a required MultiSelect with no selected value', () => {
3
- cy.visitStory('Testing:MultiSelectFieldFF', 'Required');
3
+ cy.visitStory('MultiSelectFieldFF', 'Required');
4
4
  cy.getFormValue('multiSelect');
5
5
  cy.verifyFormValue('multiSelect', undefined);
6
6
  });
@@ -1,11 +1,14 @@
1
- import { storiesOf } from '@storybook/react';
2
1
  import React from 'react';
3
2
  import { Field } from 'react-final-form';
4
3
  import { FieldGroupFF } from '../FieldGroupFF/FieldGroupFF.js';
5
4
  import { formDecorator } from '../formDecorator.js';
6
5
  import { hasValue } from '../validators/index.js';
7
6
  import { RadioFieldFF } from './RadioFieldFF.js';
8
- storiesOf('Testing:RadioFieldFF', module).addDecorator(formDecorator).add('Required and no selected value', () => /*#__PURE__*/React.createElement(FieldGroupFF, {
7
+ export default {
8
+ title: 'Testing:RadioFieldFF',
9
+ decorators: [formDecorator]
10
+ };
11
+ export const RequiredAndNoSelectedValue = () => /*#__PURE__*/React.createElement(FieldGroupFF, {
9
12
  name: "choice"
10
13
  }, /*#__PURE__*/React.createElement(Field, {
11
14
  type: "radio",
@@ -31,4 +34,4 @@ storiesOf('Testing:RadioFieldFF', module).addDecorator(formDecorator).add('Requi
31
34
  value: "three",
32
35
  validate: hasValue,
33
36
  required: true
34
- })));
37
+ }));
@@ -1,5 +1,4 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
2
  import { Radio } from '@dhis2-ui/radio';
4
3
  import PropTypes from 'prop-types';
5
4
  import React from 'react';
@@ -32,7 +31,6 @@ export const RadioFieldFF = _ref => {
32
31
  RadioFieldFF.propTypes = {
33
32
  /** `input` props received from Final Form `Field` */
34
33
  input: inputPropType.isRequired,
35
-
36
34
  /** `meta` props received from Final Form `Field` */
37
35
  meta: metaPropType.isRequired,
38
36
  error: PropTypes.bool,
@@ -4,7 +4,31 @@ import { Field } from 'react-final-form';
4
4
  import { formDecorator } from '../formDecorator.js';
5
5
  import { inputArgType, metaArgType } from '../shared/propTypes.js';
6
6
  import { RadioFieldFF } from './RadioFieldFF.js';
7
- const description = "\nThe `RadioFieldFF` is a wrapper around a `Radio` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.\n\n#### Final Form\n\nSee how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).\n\nInside a Final Form `<Form>` component, these 'FF' UI components are intended to be used in the `component` prop of the [Final Form `<Field>` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. `<Field component={RadioFieldFF} />`. See the code samples below for examples.\n\n#### Props\n\nThe props shown in the table below are generally provided to the `RadioFieldFF` wrapper by the Final Form `Field`.\n\nNote that any props beyond the API of the `Field` component will be spread to the `RadioFieldFF`, which passes any extra props to the underlying `Radio` using `{...rest}`.\n\nTherefore, to add any props to the `RadioFieldFF` or `Radio`, add those props to the parent Final Form `Field` component.\n\nAlso see `Radio` for notes about props and implementation.\n\n```js\nimport { RadioFieldFF } from '@dhis2/ui'\n```\n\nPress **Submit** to see the form values logged to the console.\n";
7
+ const description = `
8
+ The \`RadioFieldFF\` is a wrapper around a \`Radio\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
9
+
10
+ #### Final Form
11
+
12
+ See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
13
+
14
+ Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={RadioFieldFF} />\`. See the code samples below for examples.
15
+
16
+ #### Props
17
+
18
+ The props shown in the table below are generally provided to the \`RadioFieldFF\` wrapper by the Final Form \`Field\`.
19
+
20
+ Note that any props beyond the API of the \`Field\` component will be spread to the \`RadioFieldFF\`, which passes any extra props to the underlying \`Radio\` using \`{...rest}\`.
21
+
22
+ Therefore, to add any props to the \`RadioFieldFF\` or \`Radio\`, add those props to the parent Final Form \`Field\` component.
23
+
24
+ Also see \`Radio\` for notes about props and implementation.
25
+
26
+ \`\`\`js
27
+ import { RadioFieldFF } from '@dhis2/ui'
28
+ \`\`\`
29
+
30
+ Press **Submit** to see the form values logged to the console.
31
+ `;
8
32
  export default {
9
33
  title: 'Radio Field (Final Form)',
10
34
  component: RadioFieldFF,
@@ -17,9 +41,11 @@ export default {
17
41
  }
18
42
  },
19
43
  argTypes: {
20
- input: { ...inputArgType
44
+ input: {
45
+ ...inputArgType
21
46
  },
22
- meta: { ...metaArgType
47
+ meta: {
48
+ ...metaArgType
23
49
  }
24
50
  }
25
51
  };
@@ -1,4 +1,3 @@
1
- import { storiesOf } from '@storybook/react';
2
1
  import React from 'react';
3
2
  import { Field } from 'react-final-form';
4
3
  import { formDecorator } from '../formDecorator.js';
@@ -8,11 +7,16 @@ const defaultOptions = [{
8
7
  value: 'initial',
9
8
  label: 'Initial'
10
9
  }];
11
- storiesOf('Testing:SingleSelectFieldFF', module).addDecorator(formDecorator).addParameters({
12
- options: {
13
- showPanel: false
10
+ export default {
11
+ title: 'Testing:SingleSelectFieldFF',
12
+ decorators: [formDecorator],
13
+ parameters: {
14
+ options: {
15
+ showPanel: false
16
+ }
14
17
  }
15
- }).add('Required', (_, _ref) => {
18
+ };
19
+ export const Required = (_, _ref) => {
16
20
  let {
17
21
  cypressProps
18
22
  } = _ref;
@@ -24,4 +28,4 @@ storiesOf('Testing:SingleSelectFieldFF', module).addDecorator(formDecorator).add
24
28
  validate: hasValue,
25
29
  options: cypressProps.options || defaultOptions
26
30
  });
27
- });
31
+ };
@@ -1,5 +1,4 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
2
  import { SingleSelectOption, SingleSelectField } from '@dhis2-ui/select';
4
3
  import PropTypes from 'prop-types';
5
4
  import React from 'react';
@@ -37,7 +36,6 @@ export const SingleSelectFieldFF = _ref => {
37
36
  SingleSelectFieldFF.propTypes = {
38
37
  /** `input` props received from Final Form `Field` */
39
38
  input: inputPropType.isRequired,
40
-
41
39
  /** `meta` props received from Final Form `Field` */
42
40
  meta: metaPropType.isRequired,
43
41
  options: PropTypes.arrayOf(PropTypes.shape({
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import { Field } from 'react-final-form';
3
+ import { formDecorator } from '../formDecorator.js';
4
+ import { inputArgType, metaArgType } from '../shared/propTypes.js';
5
+ import { SingleSelectFieldFF } from './SingleSelectFieldFF.js';
6
+ const description = `
7
+ The \`SingleSelectFieldFF\` is a wrapper around a \`SingleSelectField\` that enables it to work with Final Form, the preferred library for form validation and utilities in DHIS 2 apps.
8
+
9
+ #### Final Form
10
+
11
+ See how to use Final Form at [Final Form - Getting Started](https://final-form.org/docs/react-final-form/getting-started).
12
+
13
+ Inside a Final Form \`<Form>\` component, these 'FF' UI components are intended to be used in the \`component\` prop of the [Final Form \`<Field>\` components](https://final-form.org/docs/react-final-form/api/Field) where they will receive some props from the Field, e.g. \`<Field component={SingleSelectFieldFF} />\`. See the code samples below for examples.
14
+
15
+ #### Props
16
+
17
+ The props shown in the table below are generally provided to the \`SingleSelectFieldFF\` wrapper by the Final Form \`Field\`.
18
+
19
+ Note that any props beyond the API of the \`Field\` component will be spread to the \`SingleSelectFieldFF\`, which passes any extra props to the underlying \`SingleSelectField\` using \`{...rest}\`.
20
+
21
+ Therefore, to add any props to the \`SingleSelectFieldFF\` or \`SingleSelectField\`, add those props to the parent Final Form \`Field\` component.
22
+
23
+ Also see \`SingleSelect\` and \`SingleSelectField\` for notes about props and implementation.
24
+
25
+ \`\`\`js
26
+ import { SingleSelectFieldFF } from '@dhis2/ui'
27
+ \`\`\`
28
+
29
+ Press **Submit** to see the form values logged to the console.
30
+
31
+ _**Note:** Dropdowns may not appear correctly on this page. See the affected demos in the 'Canvas' tab for propper dropdown placement._
32
+ `;
33
+ const options = [{
34
+ value: '1',
35
+ label: 'one'
36
+ }, {
37
+ value: '2',
38
+ label: 'two'
39
+ }, {
40
+ value: '3',
41
+ label: 'three'
42
+ }, {
43
+ value: '4',
44
+ label: 'four'
45
+ }, {
46
+ value: '5',
47
+ label: 'five'
48
+ }, {
49
+ value: '6',
50
+ label: 'six'
51
+ }, {
52
+ value: '7',
53
+ label: 'seven'
54
+ }, {
55
+ value: '8',
56
+ label: 'eight'
57
+ }, {
58
+ value: '9',
59
+ label: 'nine'
60
+ }, {
61
+ value: '10',
62
+ label: 'ten'
63
+ }];
64
+ export default {
65
+ title: 'Single Select Field (Final Form)',
66
+ component: SingleSelectFieldFF,
67
+ decorators: [formDecorator],
68
+ parameters: {
69
+ docs: {
70
+ description: {
71
+ component: description
72
+ }
73
+ }
74
+ },
75
+ argTypes: {
76
+ input: {
77
+ ...inputArgType
78
+ },
79
+ meta: {
80
+ ...metaArgType
81
+ }
82
+ }
83
+ };
84
+ export const Default = () => /*#__PURE__*/React.createElement(Field, {
85
+ component: SingleSelectFieldFF,
86
+ name: "agree",
87
+ label: "Do you agree?",
88
+ options: options
89
+ });
90
+ export const InitialValue = () => /*#__PURE__*/React.createElement(Field, {
91
+ component: SingleSelectFieldFF,
92
+ name: "agree",
93
+ label: "Do you agree?",
94
+ options: options,
95
+ initialValue: "4"
96
+ });
97
+ InitialValue.storyName = 'InitialValue';