@luomus/laji-form 15.1.0 → 15.1.2

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 (248) hide show
  1. package/CHANGELOG.md +0 -4
  2. package/dist/laji-form.js +1 -1
  3. package/jsonconfig.json +26 -0
  4. package/migrate.sh +0 -1
  5. package/package.json +8 -8
  6. package/test-export/test-utils.d.ts +100 -54
  7. package/test-export/test-utils.js +102 -84
  8. package/xsel -b +9 -0
  9. package/cypress/fixtures/example.json +0 -5
  10. package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and closes suggestion list (failed).png +0 -0
  11. package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and is marked as suggested (failed).png +0 -0
  12. package/lib/ApiClient.d.ts +0 -46
  13. package/lib/ApiClient.js +0 -93
  14. package/lib/Context.d.ts +0 -8
  15. package/lib/Context.js +0 -18
  16. package/lib/ReactContext.d.ts +0 -7
  17. package/lib/ReactContext.js +0 -5
  18. package/lib/components/BaseComponent.d.ts +0 -9
  19. package/lib/components/BaseComponent.js +0 -29
  20. package/lib/components/LajiForm.d.ts +0 -221
  21. package/lib/components/LajiForm.js +0 -615
  22. package/lib/components/VirtualSchemaField.d.ts +0 -42
  23. package/lib/components/VirtualSchemaField.js +0 -74
  24. package/lib/components/components.d.ts +0 -119
  25. package/lib/components/components.js +0 -606
  26. package/lib/components/fields/AnnotationField.d.ts +0 -34
  27. package/lib/components/fields/AnnotationField.js +0 -242
  28. package/lib/components/fields/AnyToBooleanField.d.ts +0 -18
  29. package/lib/components/fields/AnyToBooleanField.js +0 -20
  30. package/lib/components/fields/ArrayBulkField.d.ts +0 -23
  31. package/lib/components/fields/ArrayBulkField.js +0 -82
  32. package/lib/components/fields/ArrayCombinerField.d.ts +0 -36
  33. package/lib/components/fields/ArrayCombinerField.js +0 -138
  34. package/lib/components/fields/ArrayField.d.ts +0 -39
  35. package/lib/components/fields/ArrayField.js +0 -148
  36. package/lib/components/fields/AudioArrayField.d.ts +0 -22
  37. package/lib/components/fields/AudioArrayField.js +0 -100
  38. package/lib/components/fields/AutoArrayField.d.ts +0 -24
  39. package/lib/components/fields/AutoArrayField.js +0 -56
  40. package/lib/components/fields/AutosuggestField.d.ts +0 -69
  41. package/lib/components/fields/AutosuggestField.js +0 -299
  42. package/lib/components/fields/CombinedValueDisplayField.d.ts +0 -41
  43. package/lib/components/fields/CombinedValueDisplayField.js +0 -100
  44. package/lib/components/fields/ConditionalOnChangeField.d.ts +0 -42
  45. package/lib/components/fields/ConditionalOnChangeField.js +0 -107
  46. package/lib/components/fields/ConditionalUiSchemaField.d.ts +0 -123
  47. package/lib/components/fields/ConditionalUiSchemaField.js +0 -143
  48. package/lib/components/fields/ContextInjectionField.d.ts +0 -24
  49. package/lib/components/fields/ContextInjectionField.js +0 -68
  50. package/lib/components/fields/DataLeakerField.d.ts +0 -40
  51. package/lib/components/fields/DataLeakerField.js +0 -68
  52. package/lib/components/fields/DefaultValueArrayField.d.ts +0 -34
  53. package/lib/components/fields/DefaultValueArrayField.js +0 -59
  54. package/lib/components/fields/DependentBooleanField.d.ts +0 -38
  55. package/lib/components/fields/DependentBooleanField.js +0 -87
  56. package/lib/components/fields/DependentDisableField.d.ts +0 -35
  57. package/lib/components/fields/DependentDisableField.js +0 -71
  58. package/lib/components/fields/EnumRangeArrayField.d.ts +0 -27
  59. package/lib/components/fields/EnumRangeArrayField.js +0 -115
  60. package/lib/components/fields/ExtraLabelRowField.d.ts +0 -38
  61. package/lib/components/fields/ExtraLabelRowField.js +0 -100
  62. package/lib/components/fields/FakePropertyField.d.ts +0 -18
  63. package/lib/components/fields/FakePropertyField.js +0 -48
  64. package/lib/components/fields/FilterArrayField.d.ts +0 -73
  65. package/lib/components/fields/FilterArrayField.js +0 -121
  66. package/lib/components/fields/FlatField.d.ts +0 -29
  67. package/lib/components/fields/FlatField.js +0 -171
  68. package/lib/components/fields/GeocoderField.d.ts +0 -47
  69. package/lib/components/fields/GeocoderField.js +0 -372
  70. package/lib/components/fields/GridLayoutField.d.ts +0 -18
  71. package/lib/components/fields/GridLayoutField.js +0 -32
  72. package/lib/components/fields/HiddenField.d.ts +0 -10
  73. package/lib/components/fields/HiddenField.js +0 -11
  74. package/lib/components/fields/ImageArrayField.d.ts +0 -172
  75. package/lib/components/fields/ImageArrayField.js +0 -697
  76. package/lib/components/fields/ImageDisplayField.d.ts +0 -18
  77. package/lib/components/fields/ImageDisplayField.js +0 -44
  78. package/lib/components/fields/InitiallyHiddenField.d.ts +0 -21
  79. package/lib/components/fields/InitiallyHiddenField.js +0 -58
  80. package/lib/components/fields/InjectDefaultValueField.d.ts +0 -37
  81. package/lib/components/fields/InjectDefaultValueField.js +0 -68
  82. package/lib/components/fields/InjectField.d.ts +0 -46
  83. package/lib/components/fields/InjectField.js +0 -88
  84. package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +0 -25
  85. package/lib/components/fields/InputWithDefaultValueButtonField.js +0 -61
  86. package/lib/components/fields/LocalityField.d.ts +0 -22
  87. package/lib/components/fields/LocalityField.js +0 -94
  88. package/lib/components/fields/LocationChooserField.d.ts +0 -27
  89. package/lib/components/fields/LocationChooserField.js +0 -440
  90. package/lib/components/fields/MapArrayField.d.ts +0 -78
  91. package/lib/components/fields/MapArrayField.js +0 -1783
  92. package/lib/components/fields/MapField.d.ts +0 -48
  93. package/lib/components/fields/MapField.js +0 -434
  94. package/lib/components/fields/MultiAnyToBooleanField.d.ts +0 -25
  95. package/lib/components/fields/MultiAnyToBooleanField.js +0 -100
  96. package/lib/components/fields/MultiArrayField.d.ts +0 -53
  97. package/lib/components/fields/MultiArrayField.js +0 -224
  98. package/lib/components/fields/MultiLanguageField.d.ts +0 -13
  99. package/lib/components/fields/MultiLanguageField.js +0 -52
  100. package/lib/components/fields/MultiTagArrayField.d.ts +0 -36
  101. package/lib/components/fields/MultiTagArrayField.js +0 -142
  102. package/lib/components/fields/NamedPlaceChooserField.d.ts +0 -29
  103. package/lib/components/fields/NamedPlaceChooserField.js +0 -380
  104. package/lib/components/fields/NamedPlaceSaverField.d.ts +0 -29
  105. package/lib/components/fields/NamedPlaceSaverField.js +0 -237
  106. package/lib/components/fields/NestField.d.ts +0 -148
  107. package/lib/components/fields/NestField.js +0 -289
  108. package/lib/components/fields/ObjectField.d.ts +0 -2
  109. package/lib/components/fields/ObjectField.js +0 -119
  110. package/lib/components/fields/PdfArrayField.d.ts +0 -21
  111. package/lib/components/fields/PdfArrayField.js +0 -40
  112. package/lib/components/fields/PrefillingArrayField.d.ts +0 -22
  113. package/lib/components/fields/PrefillingArrayField.js +0 -65
  114. package/lib/components/fields/SchemaField.d.ts +0 -7
  115. package/lib/components/fields/SchemaField.js +0 -109
  116. package/lib/components/fields/ScopeField.d.ts +0 -85
  117. package/lib/components/fields/ScopeField.js +0 -521
  118. package/lib/components/fields/SectionArrayField.d.ts +0 -38
  119. package/lib/components/fields/SectionArrayField.js +0 -618
  120. package/lib/components/fields/SelectTreeField.d.ts +0 -39
  121. package/lib/components/fields/SelectTreeField.js +0 -143
  122. package/lib/components/fields/SingleActiveArrayField.d.ts +0 -49
  123. package/lib/components/fields/SingleActiveArrayField.js +0 -974
  124. package/lib/components/fields/SingleItemArrayField.d.ts +0 -15
  125. package/lib/components/fields/SingleItemArrayField.js +0 -60
  126. package/lib/components/fields/SortArrayField.d.ts +0 -73
  127. package/lib/components/fields/SortArrayField.js +0 -351
  128. package/lib/components/fields/SplitField.d.ts +0 -28
  129. package/lib/components/fields/SplitField.js +0 -65
  130. package/lib/components/fields/StringToArrayField.d.ts +0 -24
  131. package/lib/components/fields/StringToArrayField.js +0 -48
  132. package/lib/components/fields/SumField.d.ts +0 -35
  133. package/lib/components/fields/SumField.js +0 -83
  134. package/lib/components/fields/TableField.d.ts +0 -18
  135. package/lib/components/fields/TableField.js +0 -136
  136. package/lib/components/fields/TagArrayField.d.ts +0 -38
  137. package/lib/components/fields/TagArrayField.js +0 -128
  138. package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +0 -26
  139. package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +0 -81
  140. package/lib/components/fields/UiFieldApplierField.d.ts +0 -30
  141. package/lib/components/fields/UiFieldApplierField.js +0 -106
  142. package/lib/components/fields/UiFieldMapperArrayField.d.ts +0 -42
  143. package/lib/components/fields/UiFieldMapperArrayField.js +0 -121
  144. package/lib/components/fields/UnitCountShorthandField.d.ts +0 -22
  145. package/lib/components/fields/UnitCountShorthandField.js +0 -149
  146. package/lib/components/fields/UnitListShorthandArrayField.d.ts +0 -26
  147. package/lib/components/fields/UnitListShorthandArrayField.js +0 -108
  148. package/lib/components/fields/UnitShorthandField.d.ts +0 -32
  149. package/lib/components/fields/UnitShorthandField.js +0 -220
  150. package/lib/components/templates/ArrayFieldTemplate.d.ts +0 -85
  151. package/lib/components/templates/ArrayFieldTemplate.js +0 -417
  152. package/lib/components/templates/BaseInputTemplate.d.ts +0 -11
  153. package/lib/components/templates/BaseInputTemplate.js +0 -80
  154. package/lib/components/templates/DescriptionField.d.ts +0 -1
  155. package/lib/components/templates/DescriptionField.js +0 -37
  156. package/lib/components/templates/ErrorListTemplate.d.ts +0 -9
  157. package/lib/components/templates/ErrorListTemplate.js +0 -95
  158. package/lib/components/templates/FieldTemplate.d.ts +0 -6
  159. package/lib/components/templates/FieldTemplate.js +0 -112
  160. package/lib/components/templates/ObjectFieldTemplate.d.ts +0 -7
  161. package/lib/components/templates/ObjectFieldTemplate.js +0 -66
  162. package/lib/components/templates/TitleField.d.ts +0 -9
  163. package/lib/components/templates/TitleField.js +0 -51
  164. package/lib/components/widgets/AnyToBooleanWidget.d.ts +0 -20
  165. package/lib/components/widgets/AnyToBooleanWidget.js +0 -49
  166. package/lib/components/widgets/AutosuggestWidget.d.ts +0 -66
  167. package/lib/components/widgets/AutosuggestWidget.js +0 -1127
  168. package/lib/components/widgets/CheckboxWidget.d.ts +0 -37
  169. package/lib/components/widgets/CheckboxWidget.js +0 -139
  170. package/lib/components/widgets/DateTimeWidget.d.ts +0 -62
  171. package/lib/components/widgets/DateTimeWidget.js +0 -251
  172. package/lib/components/widgets/DateWidget.d.ts +0 -23
  173. package/lib/components/widgets/DateWidget.js +0 -41
  174. package/lib/components/widgets/HiddenWidget.d.ts +0 -15
  175. package/lib/components/widgets/HiddenWidget.js +0 -19
  176. package/lib/components/widgets/ImageSelectWidget.d.ts +0 -14
  177. package/lib/components/widgets/ImageSelectWidget.js +0 -57
  178. package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +0 -43
  179. package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +0 -237
  180. package/lib/components/widgets/InputGroupWidget.d.ts +0 -21
  181. package/lib/components/widgets/InputGroupWidget.js +0 -36
  182. package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +0 -21
  183. package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +0 -47
  184. package/lib/components/widgets/NumberWidget.d.ts +0 -13
  185. package/lib/components/widgets/NumberWidget.js +0 -21
  186. package/lib/components/widgets/PlainTextWidget.d.ts +0 -12
  187. package/lib/components/widgets/PlainTextWidget.js +0 -24
  188. package/lib/components/widgets/SelectWidget.d.ts +0 -52
  189. package/lib/components/widgets/SelectWidget.js +0 -158
  190. package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +0 -19
  191. package/lib/components/widgets/SeparatedDateTimeWidget.js +0 -59
  192. package/lib/components/widgets/TaxonImageWidget.d.ts +0 -13
  193. package/lib/components/widgets/TaxonImageWidget.js +0 -30
  194. package/lib/components/widgets/TextSelectWidget.d.ts +0 -25
  195. package/lib/components/widgets/TextSelectWidget.js +0 -94
  196. package/lib/components/widgets/TextareaWidget.d.ts +0 -32
  197. package/lib/components/widgets/TextareaWidget.js +0 -87
  198. package/lib/components/widgets/TimeWidget.d.ts +0 -11
  199. package/lib/components/widgets/TimeWidget.js +0 -19
  200. package/lib/components/widgets/URLWidget.d.ts +0 -14
  201. package/lib/components/widgets/URLWidget.js +0 -12
  202. package/lib/components/widgets/UpperCaseWidget.d.ts +0 -13
  203. package/lib/components/widgets/UpperCaseWidget.js +0 -21
  204. package/lib/index.d.ts +0 -20
  205. package/lib/index.js +0 -50
  206. package/lib/services/blocker-service.d.ts +0 -11
  207. package/lib/services/blocker-service.js +0 -55
  208. package/lib/services/custom-event-service.d.ts +0 -17
  209. package/lib/services/custom-event-service.js +0 -35
  210. package/lib/services/dom-id-service.d.ts +0 -8
  211. package/lib/services/dom-id-service.js +0 -30
  212. package/lib/services/focus-service.d.ts +0 -13
  213. package/lib/services/focus-service.js +0 -60
  214. package/lib/services/id-service.d.ts +0 -22
  215. package/lib/services/id-service.js +0 -130
  216. package/lib/services/key-handler-service.d.ts +0 -56
  217. package/lib/services/key-handler-service.js +0 -184
  218. package/lib/services/root-instance-service.d.ts +0 -25
  219. package/lib/services/root-instance-service.js +0 -49
  220. package/lib/services/settings-service.d.ts +0 -34
  221. package/lib/services/settings-service.js +0 -154
  222. package/lib/services/singleton-map-service.d.ts +0 -23
  223. package/lib/services/singleton-map-service.js +0 -44
  224. package/lib/services/submit-hook-service.d.ts +0 -24
  225. package/lib/services/submit-hook-service.js +0 -73
  226. package/lib/styles.d.ts +0 -1
  227. package/lib/styles.js +0 -4
  228. package/lib/themes/bs3.d.ts +0 -3
  229. package/lib/themes/bs3.js +0 -133
  230. package/lib/themes/bs5.d.ts +0 -3
  231. package/lib/themes/bs5.js +0 -111
  232. package/lib/themes/glyphicon-fa-mapping.d.ts +0 -3
  233. package/lib/themes/glyphicon-fa-mapping.js +0 -271
  234. package/lib/themes/stub.d.ts +0 -3
  235. package/lib/themes/stub.js +0 -82
  236. package/lib/themes/theme.d.ts +0 -233
  237. package/lib/themes/theme.js +0 -2
  238. package/lib/translations.json +0 -847
  239. package/lib/utils.d.ts +0 -171
  240. package/lib/utils.js +0 -1191
  241. package/lib/validation.d.ts +0 -7
  242. package/lib/validation.js +0 -141
  243. package/llol +0 -10
  244. package/llol.pdf +0 -10
  245. package/playwright-report/index.html +0 -62
  246. package/q +0 -196
  247. package/rename.sh +0 -24
  248. package/trip-report.spec.ts +0 -594
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  return t;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.getRemoveUnit = exports.maybeJSONPointerToLocator = exports.filterUUIDs = exports.createForm = exports.DemoPageForm = exports.Form = exports.getFocusedElement = exports.lajiFormLocator = exports.navigateToForm = exports.emptyForm = void 0;
23
+ exports.getRemoveUnit = exports.updateValue = exports.maybeJSONPointerToLocator = exports.filterUUIDs = exports.mockImageMetadata = exports.createForm = exports.DemoPageForm = exports.Form = exports.getFocusedId = exports.getFocusedElement = exports.lajiFormLocate = exports.lajiFormLocator = exports.navigateToForm = exports.emptyForm = void 0;
24
24
  const path = require("path");
25
25
  const test_utils_1 = require("@luomus/laji-map/test-export/test-utils");
26
26
  const emptyForm = (page, params = "") => __awaiter(void 0, void 0, void 0, function* () { return page.goto(`/?test=true&settings=false&mockApi=true&${params}`); });
@@ -29,36 +29,39 @@ const navigateToForm = (page, formID, params = "") => __awaiter(void 0, void 0,
29
29
  exports.navigateToForm = navigateToForm;
30
30
  const lajiFormLocator = (path) => `#_laji-form_root${typeof path === "string" && path.length ? `_${path.replace(/\./g, "_")}` : ""}`;
31
31
  exports.lajiFormLocator = lajiFormLocator;
32
+ const lajiFormLocate = (page, str) => page.locator(exports.lajiFormLocator(str));
33
+ exports.lajiFormLocate = lajiFormLocate;
32
34
  const getFocusedElement = (page) => page.locator("*:focus");
33
35
  exports.getFocusedElement = getFocusedElement;
36
+ const getFocusedId = (page) => exports.getFocusedElement(page).getAttribute("id");
37
+ exports.getFocusedId = getFocusedId;
34
38
  function getEnumWidgetForContainer($container) {
35
39
  return {
36
40
  $container,
37
- openEnums: () => __awaiter(this, void 0, void 0, function* () {
38
- yield $container.click();
39
- }),
41
+ openEnums: () => $container.click(),
40
42
  $enumContainer: $container.locator(".rw-popup-container"),
41
- $enums: $container.locator(".rw-list-option"),
43
+ $$enums: $container.locator(".rw-list-option"),
42
44
  $input: $container.locator("input")
43
45
  };
44
46
  }
45
47
  class Form {
46
- constructor(page, $locator = page.locator(".laji-form")) {
48
+ constructor(page, locator = page.locator(".laji-form")) {
47
49
  this.page = page;
48
- this.$locator = $locator;
49
- this.$form = this.$locator.locator(".rjsf");
50
+ this.locator = locator;
51
+ this.$form = this.page.locator(".laji-form .rjsf");
52
+ this.getMockStr = (path, query) => `window.mockResponses[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
50
53
  this.createValidatorPO = (type) => ({
51
- $all: this.$locator.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel .list-group button`),
52
- $panel: this.$locator.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel`)
54
+ $$all: this.page.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel .list-group button`),
55
+ $panel: this.page.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel`)
53
56
  });
54
57
  this.errors = this.createValidatorPO("error");
55
58
  this.warnings = this.createValidatorPO("warning");
56
59
  this.failedJobs = {
57
- $container: this.$locator.locator(".laji-form-failed-jobs-list"),
58
- $errors: this.$locator.locator(".laji-form-failed-jobs-list").locator(".list-group-item")
60
+ $container: this.page.locator(".laji-form-failed-jobs-list"),
61
+ $$errors: this.page.locator(".laji-form-failed-jobs-list .list-group-item")
59
62
  };
60
- this.$runningJobs = this.$locator.locator(".running-jobs");
61
- this.$acknowledgeWarnings = this.$locator.locator(".laji-form-warning-list .panel-footer button");
63
+ this.$runningJobs = this.page.locator(".running-jobs");
64
+ this.$acknowledgeWarnings = this.page.locator(".laji-form-warning-list .panel-footer button");
62
65
  this.$blocker = this.page.locator(".laji-form.blocking-loader");
63
66
  this.$mapFieldFullscreenMap = this.page.locator(".laji-form.fullscreen .laji-form-map");
64
67
  this.getImageArrayField = (lajiFormLocator) => {
@@ -69,9 +72,9 @@ class Form {
69
72
  return {
70
73
  $container,
71
74
  $imgContainers,
72
- $imgs: $imgContainers.locator("img"),
73
- $imgLoading: $imgContainers.locator(".react-spinner"),
74
- $imgRemoves: $imgContainers.locator(".button-corner"),
75
+ $$imgs: $imgContainers.locator("img"),
76
+ $$imgLoading: $imgContainers.locator(".react-spinner"),
77
+ $$imgRemoves: $imgContainers.locator(".button-corner"),
75
78
  $imgRemoveConfirmButton: (id) => this.$locateAddition(id, "delete-confirm-yes", true),
76
79
  $dropzone: this.$locate(lajiFormLocator).locator(".laji-form-drop-zone"),
77
80
  $modal,
@@ -80,26 +83,30 @@ class Form {
80
83
  $addModalCancel: $addModal.locator(".cancel")
81
84
  };
82
85
  };
83
- this.getTaxonAutosuggestWidget = (lajiFormLocator) => {
86
+ this.getAutosuggestWidget = (lajiFormLocator) => {
84
87
  return {
85
88
  $input: this.$locate(lajiFormLocator).locator("input"),
86
89
  $suggestionsContainer: this.$locate(lajiFormLocator).locator(".rw-list"),
87
90
  $suggestions: this.$locate(lajiFormLocator).locator(".rw-list-option"),
88
- $getGlyph: (glyph) => this.$locate(lajiFormLocator).locator(glyph),
89
- $suggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-ok"),
90
- $nonsuggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-warning-sign"),
91
- $powerUserButton: this.$locator.locator(".power-user-addon")
92
91
  };
93
92
  };
93
+ this.getTaxonAutosuggestWidget = (lajiFormLocator) => {
94
+ const autosuggest = this.getAutosuggestWidget(lajiFormLocator);
95
+ return Object.assign(Object.assign({}, autosuggest), { $powerUserButton: this.page.locator(".power-user-addon"), $suggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-ok"), $nonsuggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-warning-sign") });
96
+ };
97
+ this.getPersonAutosuggestWidget = (lajiFormLocator) => {
98
+ const autosuggest = this.getAutosuggestWidget(lajiFormLocator);
99
+ return Object.assign(Object.assign({}, autosuggest), { $suggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-user") });
100
+ };
94
101
  this.getScopeField = (lajiFormLocator) => ({
95
102
  $button: this.$locateButton(lajiFormLocator, "additionals"),
96
- $listItems: this.$locate(lajiFormLocator).locator(".dropdown.open li a"),
103
+ $$listItems: this.$locate(lajiFormLocator).locator(".dropdown.open li a"),
97
104
  modal: {
98
105
  $container: this.page.locator(".scope-field-modal"),
99
106
  $close: this.page.locator(".scope-field-modal .close"),
100
- $loadingGroup: this.page.locator(".scope-field-modal .list-group .react-spinner"),
101
- $groupTitles: this.page.locator(".scope-field-modal .list-group .list-group-item strong"),
102
- $listItems: this.page.locator(".scope-field-modal .list-group-item"),
107
+ $$loadingGroups: this.page.locator(".scope-field-modal .list-group .react-spinner"),
108
+ $$groupTitles: this.page.locator(".scope-field-modal .list-group .list-group-item strong"),
109
+ $$listItems: this.page.locator(".scope-field-modal .list-group-item"),
103
110
  }
104
111
  });
105
112
  this.getLocationChooser = (lajiFormLocator) => {
@@ -113,7 +120,7 @@ class Form {
113
120
  peeker: {
114
121
  $popover: $peeker,
115
122
  $map: $peeker.locator(".laji-map"),
116
- $markers: $peeker.locator(".vector-marker path"),
123
+ $$markers: $peeker.locator(".vector-marker path"),
117
124
  }
118
125
  };
119
126
  };
@@ -143,18 +150,48 @@ class Form {
143
150
  };
144
151
  };
145
152
  }
146
- /** Locates a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
147
153
  $locate(path) {
148
- return this.$locator.locator(exports.lajiFormLocator(path));
154
+ return this.page.locator(exports.lajiFormLocator(path));
149
155
  }
150
- /** Locates a button for a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
151
156
  $locateButton(path, selector, locateFromBody = false) {
152
- return (locateFromBody ? this.page : this.$locator).locator(`#root${typeof path === "string" && path.length > 0 ? `_${path.replace(/\./g, "_")}` : ""}-${selector}`);
157
+ return (locateFromBody ? this.page : this.locator).locator(`#root${typeof path === "string" && path.length > 0 ? `_${path.replace(/\./g, "_")}` : ""}-${selector}`);
153
158
  }
154
- /** Locates some additional element for a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
155
159
  $locateAddition(path, selector, locateFromBody = false) {
156
160
  return this.$locateButton(path, selector, locateFromBody);
157
161
  }
162
+ setMockResponse(path, query) {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ yield this.page.evaluate(`window.setMockResponse(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
165
+ const mock = (method, response, raw) => this.page.evaluate(`${this.getMockStr(path, query)}.${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
166
+ return {
167
+ resolve: (response, raw) => mock("resolve", response, raw),
168
+ reject: (response, raw) => mock("reject", response, raw),
169
+ remove: () => mock("remove")
170
+ };
171
+ });
172
+ }
173
+ createMockResponseQueue(path, query) {
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ yield this.page.evaluate(`window.createMockResponseQueue(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
176
+ const queueStr = `window.mockQueues[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
177
+ const mock = (method, response, raw, pointer) => {
178
+ return this.page.evaluate(`${this.getMockStr(path, query)}[${pointer}].${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
179
+ };
180
+ let pointer = 0;
181
+ return {
182
+ create: () => __awaiter(this, void 0, void 0, function* () {
183
+ yield this.page.evaluate(`${queueStr}.create()`);
184
+ const _pointer = pointer;
185
+ pointer = pointer + 1;
186
+ return {
187
+ resolve: (response, raw) => mock("resolve", response, raw, _pointer),
188
+ reject: (response, raw) => mock("reject", response, raw, _pointer),
189
+ };
190
+ }),
191
+ remove: () => this.page.evaluate(`${queueStr}.remove()`)
192
+ };
193
+ });
194
+ }
158
195
  getBooleanWidget(str) {
159
196
  const $container = this.$locate(str).locator(".btn-toolbar");
160
197
  return {
@@ -208,46 +245,37 @@ class Form {
208
245
  yield map.drawMarker();
209
246
  });
210
247
  }
211
- updateValue($input, value, blur = true) {
212
- return __awaiter(this, void 0, void 0, function* () {
213
- yield $input.fill(value);
214
- if (blur) {
215
- yield $input.press("Tab");
216
- }
217
- });
218
- }
219
248
  }
220
249
  exports.Form = Form;
221
250
  class DemoPageForm extends Form {
222
- constructor(page, params = {}) {
251
+ constructor(page, props) {
223
252
  super(page);
224
- this.getMockStr = (path, query) => `window.mockResponses[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
253
+ this.props = props;
225
254
  this.mockImageUpload = (lajiFormLocator) => __awaiter(this, void 0, void 0, function* () {
226
- const filePath = path.resolve(__dirname, "./mocks/pixel.png");
255
+ const filePath = path.resolve(__dirname, "./mock/pixel.png");
227
256
  const imageResponse = [{ name: "data", filename: "pixel.png", id: "mock", expires: 1575979685 }];
228
257
  const { resolve, remove } = yield this.setMockResponse("/images", false);
229
- const mdResponse = require("./mocks/image-metadata.json");
230
- const { resolve: metadataResolve, remove: metadataRemove } = yield this.setMockResponse("/images/mock", false);
258
+ const mdResponse = exports.mockImageMetadata;
259
+ const { resolve: mdResolve, remove: mdRemove } = yield this.setMockResponse("/images/mock", false);
231
260
  yield this.getImageArrayField(lajiFormLocator).$dropzone.locator("input").setInputFiles(filePath);
232
261
  return {
233
262
  resolve: () => __awaiter(this, void 0, void 0, function* () {
234
263
  yield resolve(imageResponse);
235
- yield metadataResolve(mdResponse);
264
+ yield mdResolve(mdResponse);
236
265
  }),
237
266
  remove: () => __awaiter(this, void 0, void 0, function* () {
238
267
  yield remove();
239
- yield metadataRemove();
268
+ yield mdRemove();
240
269
  })
241
270
  };
242
271
  });
243
- // this.page = page;
244
- this.props = params;
245
272
  }
246
273
  initialize(beforeInit) {
274
+ var _a;
247
275
  return __awaiter(this, void 0, void 0, function* () {
248
276
  const query = (params) => Object.keys(params).reduce((q, key) => `${q}&${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`, "");
249
- if (this.props.id) {
250
- const _a = this.props, { id } = _a, _props = __rest(_a, ["id"]);
277
+ if ((_a = this.props) === null || _a === void 0 ? void 0 : _a.id) {
278
+ const _b = this.props, { id } = _b, _props = __rest(_b, ["id"]);
251
279
  yield exports.navigateToForm(this.page, id, query(_props));
252
280
  }
253
281
  else {
@@ -276,6 +304,9 @@ class DemoPageForm extends Form {
276
304
  yield this.e("submit()");
277
305
  });
278
306
  }
307
+ startSubmit() {
308
+ this.e("submit()");
309
+ }
279
310
  submitOnlySchemaValidations() {
280
311
  return this.e("submitOnlySchemaValidations()");
281
312
  }
@@ -288,39 +319,6 @@ class DemoPageForm extends Form {
288
319
  getPropsData() {
289
320
  return this.e("lajiForm.props.formData");
290
321
  }
291
- setMockResponse(path, query) {
292
- return __awaiter(this, void 0, void 0, function* () {
293
- yield this.page.evaluate(`window.setMockResponse(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
294
- const mock = (method, response, raw) => this.page.evaluate(`${this.getMockStr(path, query)}.${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
295
- return {
296
- resolve: (response, raw) => mock("resolve", response, raw),
297
- reject: (response, raw) => mock("reject", response, raw),
298
- remove: () => mock("remove")
299
- };
300
- });
301
- }
302
- createMockResponseQueue(path, query) {
303
- return __awaiter(this, void 0, void 0, function* () {
304
- yield this.page.evaluate(`window.createMockResponseQueue(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
305
- const queueStr = `window.mockQueues[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
306
- const mock = (method, response, raw, pointer) => {
307
- return this.page.evaluate(`${this.getMockStr(path, query)}[${pointer}].${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
308
- };
309
- let pointer = 0;
310
- return {
311
- create: () => __awaiter(this, void 0, void 0, function* () {
312
- yield this.page.evaluate(`${queueStr}.create()`);
313
- const _pointer = pointer;
314
- pointer = pointer + 1;
315
- return {
316
- resolve: (response, raw) => mock("resolve", response, raw, _pointer),
317
- reject: (response, raw) => mock("reject", response, raw, _pointer),
318
- };
319
- }),
320
- remove: () => this.page.evaluate(`${queueStr}.remove()`)
321
- };
322
- });
323
- }
324
322
  }
325
323
  exports.DemoPageForm = DemoPageForm;
326
324
  function createForm(page, props, beforeInit) {
@@ -331,6 +329,21 @@ function createForm(page, props, beforeInit) {
331
329
  });
332
330
  }
333
331
  exports.createForm = createForm;
332
+ exports.mockImageMetadata = {
333
+ "id": "mock",
334
+ "capturerVerbatim": [
335
+ "mock"
336
+ ],
337
+ "intellectualOwner": "mock",
338
+ "intellectualRights": "MZ.intellectualRightsCC-BY-SA-4.0",
339
+ "fullURL": "https://imagetest.laji.fi/MM.97056/pixel_full.jpg",
340
+ "largeURL": "https://imagetest.laji.fi/MM.97056/pixel_large.jpg",
341
+ "squareThumbnailURL": "https://imagetest.laji.fi/MM.97056/pixel_square.jpg",
342
+ "thumbnailURL": "https://imagetest.laji.fi/MM.97056/pixel_thumb.jpg",
343
+ "originalURL": "https://imagetest.laji.fi/MM.97056/pixel.png",
344
+ "uploadedBy": "MA.308",
345
+ "@context": "http://schema.laji.fi/context/image-en.jsonld"
346
+ };
334
347
  const filterUUIDs = (any) => {
335
348
  if (typeof any === "object" && !Array.isArray(any) && any !== null) {
336
349
  return Object.keys(any).filter(key => key !== "_lajiFormId").reduce((_any, key) => (Object.assign(Object.assign({}, _any), { [key]: exports.filterUUIDs(any[key]) })), {});
@@ -343,6 +356,11 @@ const filterUUIDs = (any) => {
343
356
  exports.filterUUIDs = filterUUIDs;
344
357
  const maybeJSONPointerToLocator = (pointer) => pointer[0] === "/" ? pointer.slice(1).replace(/\//g, "_") : pointer;
345
358
  exports.maybeJSONPointerToLocator = maybeJSONPointerToLocator;
359
+ const updateValue = ($input, value) => __awaiter(void 0, void 0, void 0, function* () {
360
+ yield $input.fill(value);
361
+ yield $input.press("Tab");
362
+ });
363
+ exports.updateValue = updateValue;
346
364
  const getRemoveUnit = (page) => (gatheringIdx, unitIdx) => __awaiter(void 0, void 0, void 0, function* () {
347
365
  yield page.locator(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete`).click();
348
366
  return page.locator(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete-confirm-yes`).click();
package/xsel -b ADDED
@@ -0,0 +1,9 @@
1
+ "toggleable": {
2
+ "query": {
3
+ "informalTaxonGroup": "MVL.1",
4
+ "onlyFinnish": true
5
+ },
6
+ "glyphClass": "informal-group-image MVL.1",
7
+ "placeholder": "",
8
+ "tooltip": "Aloita suomalaisten lintujen syöttö"
9
+ },
@@ -1,5 +0,0 @@
1
- {
2
- "name": "Using fixtures to represent data",
3
- "email": "hello@cypress.io",
4
- "body": "Fixtures are a great way to mock data for responses to routes"
5
- }
@@ -1,46 +0,0 @@
1
- import { Translations, Lang } from "./components/LajiForm";
2
- interface Query {
3
- [param: string]: any;
4
- }
5
- interface Options {
6
- failSilently?: boolean;
7
- [option: string]: any;
8
- }
9
- export interface ApiClientImplementation {
10
- fetch: (path: string, query: Query, options: any) => Promise<any>;
11
- }
12
- /**
13
- * ApiClient "interface". Wraps the given apiClient as a singleton object.
14
- * Given apiClient must implement fetch().
15
- */
16
- export default class ApiClient {
17
- apiClient: ApiClientImplementation;
18
- lang: Lang;
19
- translations: Translations;
20
- cache: {
21
- [path: string]: {
22
- [cacheKey: string]: Promise<any>;
23
- };
24
- };
25
- on: {
26
- [path: string]: (() => void)[];
27
- };
28
- constructor(apiClient: ApiClientImplementation, lang: Lang | undefined, translations: Translations);
29
- /**
30
- * Implementing apiClient must return a promise that passes the raw response as 1st arg.
31
- * @param path URL for GET.
32
- * @param query Object, where keys are param names and values are param values.
33
- * @returns a Promise.
34
- */
35
- fetchRaw(path: string, query?: Query, options?: any): Promise<any>;
36
- fetch<T>(path: string, query?: Query, options?: Options): Promise<T>;
37
- getCacheKey(query?: Query, options?: Options): string;
38
- fetchCached<T>(path: string, query?: Query, options?: Options): Promise<T>;
39
- invalidateCachePath(path: string): void;
40
- invalidateCachePathQuery(path: string, query: string): void;
41
- flushCache: () => void;
42
- onCachePathInvalidation(path: string, callback: () => void): void;
43
- removeOnCachePathInvalidation(path: string, callback: () => void): void;
44
- setLang(lang: Lang): void;
45
- }
46
- export {};
package/lib/ApiClient.js DELETED
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- /**
15
- * ApiClient "interface". Wraps the given apiClient as a singleton object.
16
- * Given apiClient must implement fetch().
17
- */
18
- class ApiClient {
19
- constructor(apiClient, lang = "en", translations) {
20
- this.cache = {};
21
- this.on = {};
22
- this.flushCache = () => {
23
- this.cache = {};
24
- };
25
- this.apiClient = apiClient;
26
- this.lang = lang;
27
- this.translations = translations;
28
- }
29
- /**
30
- * Implementing apiClient must return a promise that passes the raw response as 1st arg.
31
- * @param path URL for GET.
32
- * @param query Object, where keys are param names and values are param values.
33
- * @returns a Promise.
34
- */
35
- fetchRaw(path, query, options) {
36
- const _query = Object.assign({ lang: this.lang }, (query || {}));
37
- if (!_query.lang) {
38
- delete _query.lang;
39
- }
40
- return this.apiClient.fetch(path, _query, options).catch(() => {
41
- throw new Error(this.translations[this.lang].RequestFailed);
42
- });
43
- }
44
- fetch(path, query, options = {}) {
45
- const { failSilently = false } = options, fetchOptions = __rest(options, ["failSilently"]);
46
- return this.fetchRaw(path, query, fetchOptions).then(response => {
47
- if (!failSilently && response.status >= 400) {
48
- throw new Error("Request failed");
49
- }
50
- return response.json();
51
- }).catch(() => {
52
- if (this.cache[path])
53
- delete this.cache[path][this.getCacheKey(query, options)];
54
- throw new Error(this.translations[this.lang].RequestFailed);
55
- });
56
- }
57
- getCacheKey(query, options) {
58
- return JSON.stringify(query) + JSON.stringify(options);
59
- }
60
- fetchCached(path, query, options) {
61
- const cacheKey = this.getCacheKey(query, options);
62
- if (!this.cache[path])
63
- this.cache[path] = {};
64
- this.cache[path][cacheKey] = cacheKey in this.cache[path] ? this.cache[path][cacheKey] : this.fetch(path, query, options);
65
- return this.cache[path][cacheKey];
66
- }
67
- invalidateCachePath(path) {
68
- delete this.cache[path];
69
- if (this.on[path]) {
70
- this.on[path].forEach(callback => callback());
71
- }
72
- }
73
- //TODO on invalidation callbacks
74
- invalidateCachePathQuery(path, query) {
75
- if (this.cache[path])
76
- delete this.cache[path][query];
77
- }
78
- onCachePathInvalidation(path, callback) {
79
- if (!this.on[path])
80
- this.on[path] = [];
81
- this.on[path].push(callback);
82
- }
83
- removeOnCachePathInvalidation(path, callback) {
84
- if (this.on[path]) {
85
- this.on[path] = this.on[path].filter(fn => fn !== callback);
86
- }
87
- }
88
- setLang(lang) {
89
- this.lang = lang;
90
- this.flushCache();
91
- }
92
- }
93
- exports.default = ApiClient;
package/lib/Context.d.ts DELETED
@@ -1,8 +0,0 @@
1
- declare const _default: (nameSpace?: number | string) => Record<string, unknown>;
2
- /**
3
- * A singleton context container for accessing state between components. Should be used for vars that shouldn't affect React change detection, e.g. not suitable to be stored in React context or are updated mutably.
4
- *
5
- * Empty namespace "" is used for global vars.
6
- */
7
- export default _default;
8
- export declare function clear(): void;
package/lib/Context.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clear = void 0;
4
- let singletonContext = {};
5
- /**
6
- * A singleton context container for accessing state between components. Should be used for vars that shouldn't affect React change detection, e.g. not suitable to be stored in React context or are updated mutably.
7
- *
8
- * Empty namespace "" is used for global vars.
9
- */
10
- exports.default = (nameSpace = "") => {
11
- if (!singletonContext[nameSpace])
12
- singletonContext[nameSpace] = {};
13
- return singletonContext[nameSpace];
14
- };
15
- function clear() {
16
- singletonContext = {};
17
- }
18
- exports.clear = clear;
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { Theme } from "./themes/theme";
3
- export interface ContextProps {
4
- theme: Theme;
5
- }
6
- declare const Context: React.Context<ContextProps>;
7
- export default Context;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const React = require("react");
4
- const Context = React.createContext({});
5
- exports.default = Context;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { FieldProps, WidgetProps } from "./LajiForm";
3
- declare type Constructor<T> = new (...args: any[]) => T;
4
- interface LajiFormComponentForBaseComponent<P, S> extends React.Component<P, S> {
5
- getStateFromProps?(props: P): S;
6
- UNSAFE_componentWillReceiveProps?(props: Readonly<P>, nextContext?: any): void;
7
- }
8
- export declare function BaseComponent<P extends FieldProps | WidgetProps, S, LFC extends Constructor<LajiFormComponentForBaseComponent<P, S>>>(ComposedComponent: LFC): any;
9
- export default BaseComponent;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseComponent = void 0;
4
- const utils_1 = require("../utils");
5
- function BaseComponent(ComposedComponent) {
6
- var _a;
7
- return _a = class BaseComponent extends ComposedComponent {
8
- constructor(...args) {
9
- const props = args[0];
10
- super(props);
11
- if (!this.state && this.getStateFromProps)
12
- this.state = this.getStateFromProps(props);
13
- }
14
- UNSAFE_componentWillReceiveProps(props, nextContext) {
15
- if (super.UNSAFE_componentWillReceiveProps) {
16
- super.UNSAFE_componentWillReceiveProps(props, nextContext);
17
- }
18
- else if (this.getStateFromProps) {
19
- const state = this.getStateFromProps(props);
20
- if (state)
21
- this.setState(state);
22
- }
23
- }
24
- },
25
- _a.displayName = utils_1.getReactComponentName(ComposedComponent),
26
- _a;
27
- }
28
- exports.BaseComponent = BaseComponent;
29
- exports.default = BaseComponent;