@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
@@ -1,43 +0,0 @@
1
- export function getInformalGroups(apiClient: any): any;
2
- export default class InformalTaxonGroupChooserWidget extends React.Component<any, any, any> {
3
- static contextType: React.Context<import("../../ReactContext").ContextProps>;
4
- static propTypes: {
5
- schema: PropTypes.Requireable<PropTypes.InferProps<{
6
- type: PropTypes.Requireable<string>;
7
- }>>;
8
- value: PropTypes.Requireable<string>;
9
- };
10
- constructor(props: any);
11
- mounted: boolean | undefined;
12
- getDefaultOptions: (props: any) => {
13
- button: any;
14
- rootOnly: any;
15
- grid: any;
16
- };
17
- onSelected: (id: any) => void;
18
- show: () => void;
19
- hide: () => void;
20
- onClear: (e: any) => void;
21
- }
22
- export class InformalTaxonGroupChooser extends React.Component<any, any, any> {
23
- static contextType: React.Context<import("../../ReactContext").ContextProps>;
24
- static propTypes: {
25
- onSelected: PropTypes.Validator<(...args: any[]) => any>;
26
- formContext: PropTypes.Validator<object>;
27
- };
28
- constructor(props: any);
29
- mounted: boolean | undefined;
30
- onSelected: (id: any) => () => void;
31
- onSubgroupSelected: (id: any) => () => void;
32
- Container: ({ children }: {
33
- children: any;
34
- }) => JSX.Element;
35
- getButtonGroup: (id: any) => JSX.Element;
36
- getLabel: (id: any) => JSX.Element;
37
- GroupsContainer: ({ children }: {
38
- children: any;
39
- }) => JSX.Element;
40
- Item: (id: any) => JSX.Element;
41
- }
42
- import * as React from "react";
43
- import * as PropTypes from "prop-types";
@@ -1,237 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.InformalTaxonGroupChooser = exports.getInformalGroups = void 0;
10
- const React = require("react");
11
- const PropTypes = require("prop-types");
12
- const components_1 = require("../components");
13
- const Context_1 = require("../../Context");
14
- const ReactContext_1 = require("../../ReactContext");
15
- const Spinner = require("react-spinner");
16
- const BaseComponent_1 = require("../BaseComponent");
17
- const utils_1 = require("../../utils");
18
- let InformalTaxonGroupChooserWidget = class InformalTaxonGroupChooserWidget extends React.Component {
19
- constructor(props) {
20
- super(props);
21
- this.getDefaultOptions = (props) => {
22
- const { button = true, rootOnly = false, grid = { lg: 1, md: 2, sm: 3, xs: 12 } } = utils_1.getUiOptions(props);
23
- return { button, rootOnly, grid };
24
- };
25
- this.onSelected = (id) => {
26
- this.props.onChange(id);
27
- const { button } = this.getDefaultOptions(this.props);
28
- if (button)
29
- this.hide();
30
- if (this.state.informalTaxonGroupsById && id)
31
- this.setState({ informalTaxonGroup: this.state.informalTaxonGroupsById[id] });
32
- };
33
- this.show = () => {
34
- this.setState({ show: true });
35
- };
36
- this.hide = () => {
37
- this.setState({ show: false });
38
- };
39
- this.onClear = (e) => {
40
- e.stopPropagation();
41
- this.onSelected(undefined);
42
- };
43
- this.state = {};
44
- }
45
- componentDidMount() {
46
- this.mounted = true;
47
- getInformalGroups(this.props.formContext.apiClient).then(state => {
48
- if (!this.mounted)
49
- return;
50
- this.setState(state);
51
- });
52
- this.UNSAFE_componentWillReceiveProps(this.props);
53
- }
54
- UNSAFE_componentWillReceiveProps(props) {
55
- if (props.value !== this.state.informalTaxonGroup) {
56
- if (!props.value)
57
- this.setState({ name: undefined });
58
- getInformalGroups(props.formContext.apiClient).then(({ informalTaxonGroupsById }) => {
59
- if (!this.mounted)
60
- return;
61
- this.setState({ informalTaxonGroup: informalTaxonGroupsById[this.props.value] });
62
- });
63
- }
64
- }
65
- componentWillUnmount() {
66
- this.mounted = false;
67
- }
68
- render() {
69
- let imageID = this.props.value;
70
- const { disabled, readonly } = this.props;
71
- const { button, rootOnly, grid } = this.getDefaultOptions(this.props);
72
- const { informalTaxonGroupsById = {} } = this.state;
73
- if (informalTaxonGroupsById[this.props.value] && informalTaxonGroupsById[this.props.value].parent) {
74
- imageID = informalTaxonGroupsById[this.props.value].parent.id;
75
- }
76
- const InformalTaxonGroupChooserComponent = (React.createElement(InformalTaxonGroupChooser, { modal: button, onHide: this.hide, activeId: this.props.value, onSelected: this.onSelected, formContext: this.props.formContext, lang: this.props.formContext.lang, rootOnly: rootOnly, grid: grid }));
77
- const { Button } = this.context.theme;
78
- if (button) {
79
- const title = !this.props.value
80
- ? React.createElement("div", { className: "informal-group-chooser-button-content" },
81
- React.createElement("span", null, this.props.formContext.translations.PickInformalTaxonGroup))
82
- : (React.createElement("div", { className: "informal-group-chooser-button-content" },
83
- React.createElement("div", { className: `informal-group-image ${imageID}` }),
84
- this.state.informalTaxonGroup ? React.createElement("span", null, this.state.informalTaxonGroup.name) : React.createElement(Spinner, null),
85
- React.createElement("div", { className: "close", onClick: this.onClear }, "\u00D7")));
86
- return (React.createElement(components_1.TooltipComponent, { tooltip: this.state.informalTaxonGroup && this.state.informalTaxonGroup.name },
87
- React.createElement("div", { className: "informal-taxon-groups-list" },
88
- React.createElement(Button, { onClick: this.show, disabled: disabled || readonly }, title),
89
- this.state.show && InformalTaxonGroupChooserComponent)));
90
- }
91
- else {
92
- return InformalTaxonGroupChooserComponent;
93
- }
94
- }
95
- };
96
- InformalTaxonGroupChooserWidget.contextType = ReactContext_1.default;
97
- InformalTaxonGroupChooserWidget.propTypes = {
98
- schema: PropTypes.shape({
99
- type: PropTypes.oneOf(["string"])
100
- }),
101
- value: PropTypes.string
102
- };
103
- InformalTaxonGroupChooserWidget = __decorate([
104
- BaseComponent_1.default
105
- ], InformalTaxonGroupChooserWidget);
106
- exports.default = InformalTaxonGroupChooserWidget;
107
- function walk(allGroups, _group, parent) {
108
- _group.forEach(group => {
109
- allGroups[group.id] = group;
110
- if (parent)
111
- group.parent = parent;
112
- if (group.hasSubGroup) {
113
- allGroups = walk(allGroups, group.hasSubGroup, parent || group);
114
- }
115
- });
116
- return allGroups;
117
- }
118
- const mapGroupsById = _groups => _groups.reduce((groups, group) => {
119
- groups[group.id] = group;
120
- return groups;
121
- }, {});
122
- let informalTaxonGroups, informalTaxonGroupsById;
123
- function getInformalGroups(apiClient) {
124
- if (informalTaxonGroups) {
125
- return Promise.resolve({ informalTaxonGroups, informalTaxonGroupsById });
126
- }
127
- return apiClient.fetchCached("/informal-taxon-groups/tree").then(response => {
128
- // Contains the current taxon group.
129
- const informalTaxonGroups = mapGroupsById(response.results);
130
- // Contains all groups in flat object.
131
- const informalTaxonGroupsById = walk({}, response.results);
132
- Context_1.default().informalTaxonGroupsById = informalTaxonGroupsById;
133
- return Promise.resolve({ informalTaxonGroups, informalTaxonGroupsById });
134
- });
135
- }
136
- exports.getInformalGroups = getInformalGroups;
137
- class InformalTaxonGroupChooser extends React.Component {
138
- constructor(props) {
139
- super(props);
140
- this.onSelected = (id) => () => {
141
- this.props.onSelected(id);
142
- };
143
- this.onSubgroupSelected = (id) => () => {
144
- let path;
145
- const existingIdx = this.state.path.indexOf(id);
146
- path = (existingIdx >= 0)
147
- ? this.state.path.slice(0, existingIdx + 1)
148
- : [...this.state.path, id];
149
- this.setState({
150
- informalTaxonGroups: id
151
- ? mapGroupsById(this.state.informalTaxonGroupsById[id].hasSubGroup)
152
- : this.state.root,
153
- path
154
- });
155
- };
156
- this.Container = ({ children }) => {
157
- const { modal, onHide } = this.props;
158
- const { translations } = this.props.formContext;
159
- const { Modal } = this.context.theme;
160
- return modal ? (React.createElement(Modal, { show: true, onHide: onHide, dialogClassName: "laji-form informal-taxon-group-chooser" },
161
- React.createElement(Modal.Header, { closeButton: true },
162
- React.createElement(Modal.Title, null, translations.PickInformalTaxonGroup)),
163
- React.createElement(Modal.Body, null, children))) : (React.createElement("div", { className: "informal-taxon-group-chooser" }, children));
164
- };
165
- this.getButtonGroup = (id) => {
166
- const { translations } = this.props.formContext;
167
- const { informalTaxonGroupsById } = this.state;
168
- const { Button, ButtonGroup } = this.context.theme;
169
- return (React.createElement(ButtonGroup, null,
170
- informalTaxonGroupsById[id].hasSubGroup && React.createElement(Button, { key: "subgroups", onClick: this.onSubgroupSelected(id) }, translations.ShowSubgroups),
171
- React.createElement(Button, { key: "select", onClick: this.onSelected(id) }, translations.Select)));
172
- };
173
- this.getLabel = (id) => {
174
- const { path, informalTaxonGroupsById } = this.state;
175
- const name = informalTaxonGroupsById[id].name;
176
- return path.length <= 1 ? React.createElement("h5", null, name) : React.createElement("span", null, name);
177
- };
178
- this.GroupsContainer = ({ children }) => {
179
- const { rootOnly } = this.props;
180
- const { Row } = this.context.theme;
181
- const { ListGroup } = this.context.theme;
182
- return rootOnly ? React.createElement(Row, null, children) : React.createElement(ListGroup, null, children);
183
- };
184
- this.Item = (id) => {
185
- const { path } = this.state;
186
- const { rootOnly, grid, activeId } = this.props;
187
- const { Panel, Col, ListGroupItem } = this.context.theme;
188
- return !rootOnly ? (React.createElement(ListGroupItem, { key: id, className: path.length > 1 ? "not-root" : "" },
189
- path.length === 1 ? React.createElement("div", { className: `informal-group-image ${id}` }) : null,
190
- this.getLabel(id),
191
- this.getButtonGroup(id))) : (React.createElement(Col, Object.assign({ key: id }, grid),
192
- React.createElement(Panel, { onClick: this.onSelected(id), variant: id === activeId ? "primary" : undefined },
193
- React.createElement(Panel.Heading, null, this.getLabel(id)),
194
- React.createElement(Panel.Body, null,
195
- React.createElement("div", { className: `informal-group-image ${id}` })))));
196
- };
197
- this.state = { path: [undefined] };
198
- }
199
- componentDidMount() {
200
- this.mounted = true;
201
- getInformalGroups(this.props.formContext.apiClient).then(state => {
202
- if (!this.mounted)
203
- return;
204
- this.setState(Object.assign(Object.assign({}, state), { root: state.informalTaxonGroups }));
205
- });
206
- }
207
- UNSAFE_componentWillReceiveProps(props) {
208
- if (this.props.lang === props.lang)
209
- return;
210
- getInformalGroups(this.props.formContext.apiClient).then(state => {
211
- if (!this.mounted)
212
- return;
213
- this.setState(Object.assign(Object.assign({}, state), { root: state.informalTaxonGroups }));
214
- });
215
- }
216
- componentWillUnmount() {
217
- this.mounted = false;
218
- }
219
- render() {
220
- const { path, informalTaxonGroupsById, informalTaxonGroups } = this.state;
221
- const { rootOnly } = this.props;
222
- const { translations } = this.props.formContext;
223
- const { Container, GroupsContainer, Item } = this;
224
- const { Breadcrumb } = this.context.theme;
225
- return (React.createElement(Container, null,
226
- !rootOnly && (React.createElement(Breadcrumb, null, path.map(id => React.createElement(Breadcrumb.Item, { key: id === undefined ? "root" : id, onClick: this.onSubgroupSelected(id) }, id === undefined ? translations.All : informalTaxonGroupsById[id].name)))),
227
- informalTaxonGroups
228
- ? React.createElement(GroupsContainer, null, Object.keys(informalTaxonGroups).map(Item))
229
- : React.createElement(Spinner, null)));
230
- }
231
- }
232
- exports.InformalTaxonGroupChooser = InformalTaxonGroupChooser;
233
- InformalTaxonGroupChooser.contextType = ReactContext_1.default;
234
- InformalTaxonGroupChooser.propTypes = {
235
- onSelected: PropTypes.func.isRequired,
236
- formContext: PropTypes.object.isRequired
237
- };
@@ -1,21 +0,0 @@
1
- export default class InputGroupWidget extends React.Component<any, any, any> {
2
- static contextType: React.Context<import("../../ReactContext").ContextProps>;
3
- static propTypes: {
4
- uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
5
- "ui:options": PropTypes.Requireable<PropTypes.InferProps<{
6
- inputGroupText: PropTypes.Requireable<string>;
7
- inputType: PropTypes.Requireable<string>;
8
- className: PropTypes.Requireable<string>;
9
- }>>;
10
- }>>;
11
- schema: PropTypes.Validator<PropTypes.InferProps<{
12
- type: PropTypes.Requireable<string>;
13
- }>>;
14
- value: PropTypes.Requireable<string>;
15
- required: PropTypes.Requireable<boolean>;
16
- };
17
- constructor(props: any);
18
- constructor(props: any, context: any);
19
- }
20
- import * as React from "react";
21
- import * as PropTypes from "prop-types";
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const React = require("react");
4
- const PropTypes = require("prop-types");
5
- const BaseInputTemplate_1 = require("../templates/BaseInputTemplate");
6
- const ReactContext_1 = require("../../ReactContext");
7
- const utils_1 = require("../../utils");
8
- const TextareaWidget_1 = require("./TextareaWidget");
9
- class InputGroupWidget extends React.Component {
10
- render() {
11
- const { InputGroup } = this.context.theme;
12
- const { inputGroupText = "", inputType = "basic", className = "" } = utils_1.getUiOptions(this.props);
13
- const input = inputType === "textarea" ? React.createElement(TextareaWidget_1.default, Object.assign({}, this.props)) : React.createElement(BaseInputTemplate_1.default, Object.assign({}, this.props));
14
- return (React.createElement(InputGroup, { key: inputGroupText, className: utils_1.classNames("input-group-widget", `input-group-${inputType}`, className) },
15
- React.createElement(InputGroup.Addon, { className: "input-group-text" },
16
- inputGroupText,
17
- this.props.required && React.createElement("span", { className: "text-danger" }, "*")),
18
- input));
19
- }
20
- }
21
- exports.default = InputGroupWidget;
22
- InputGroupWidget.contextType = ReactContext_1.default;
23
- InputGroupWidget.propTypes = {
24
- uiSchema: PropTypes.shape({
25
- "ui:options": PropTypes.shape({
26
- inputGroupText: PropTypes.string,
27
- inputType: PropTypes.oneOf(["basic", "textarea"]),
28
- className: PropTypes.string
29
- })
30
- }),
31
- schema: PropTypes.shape({
32
- type: PropTypes.oneOf(["string", "number", "integer"]),
33
- }).isRequired,
34
- value: PropTypes.string,
35
- required: PropTypes.bool
36
- };
@@ -1,21 +0,0 @@
1
- export default class InputWithDefaultValueButtonWidget extends React.Component<any, any, any> {
2
- static contextType: React.Context<import("../../ReactContext").ContextProps>;
3
- static propTypes: {
4
- uiSchema: PropTypes.Validator<PropTypes.InferProps<{
5
- "ui:options": PropTypes.Validator<PropTypes.InferProps<{
6
- buttonLabel: PropTypes.Validator<string>;
7
- contextFieldForDefaultValue: PropTypes.Requireable<string>;
8
- onClick: PropTypes.Requireable<(...args: any[]) => any>;
9
- }>>;
10
- }>>;
11
- schema: PropTypes.Validator<PropTypes.InferProps<{
12
- type: PropTypes.Requireable<string>;
13
- }>>;
14
- value: PropTypes.Requireable<string>;
15
- };
16
- constructor(props: any);
17
- constructor(props: any, context: any);
18
- onClick: () => void;
19
- }
20
- import * as React from "react";
21
- import * as PropTypes from "prop-types";
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const React = require("react");
4
- const PropTypes = require("prop-types");
5
- const BaseInputTemplate_1 = require("../templates/BaseInputTemplate");
6
- const ReactContext_1 = require("../../ReactContext");
7
- const utils_1 = require("../../utils");
8
- class InputWithDefaultValueButtonWidget extends React.Component {
9
- constructor() {
10
- super(...arguments);
11
- this.onClick = () => {
12
- const { contextFieldForDefaultValue, onClick } = utils_1.getUiOptions(this.props);
13
- if (contextFieldForDefaultValue) {
14
- const uiSchemaContext = this.props.formContext.uiSchemaContext || {};
15
- const defaultValue = uiSchemaContext[contextFieldForDefaultValue];
16
- this.props.onChange(defaultValue);
17
- }
18
- if (onClick) {
19
- onClick();
20
- }
21
- };
22
- }
23
- render() {
24
- const { InputGroup, Button } = this.context.theme;
25
- const { buttonLabel } = utils_1.getUiOptions(this.props);
26
- const { disabled, readonly } = this.props;
27
- return (React.createElement(InputGroup, null,
28
- React.createElement(BaseInputTemplate_1.default, Object.assign({}, this.props)),
29
- React.createElement(InputGroup.Button, { className: "input-group-button" },
30
- React.createElement(Button, { onClick: this.onClick, disabled: disabled || readonly }, buttonLabel))));
31
- }
32
- }
33
- exports.default = InputWithDefaultValueButtonWidget;
34
- InputWithDefaultValueButtonWidget.contextType = ReactContext_1.default;
35
- InputWithDefaultValueButtonWidget.propTypes = {
36
- uiSchema: PropTypes.shape({
37
- "ui:options": PropTypes.shape({
38
- buttonLabel: PropTypes.string.isRequired,
39
- contextFieldForDefaultValue: PropTypes.string,
40
- onClick: PropTypes.func
41
- }).isRequired
42
- }).isRequired,
43
- schema: PropTypes.shape({
44
- type: PropTypes.oneOf(["string", "number", "integer"]),
45
- }).isRequired,
46
- value: PropTypes.string
47
- };
@@ -1,13 +0,0 @@
1
- export default class NumberWidget extends React.Component<any, any, any> {
2
- static propTypes: {
3
- schema: PropTypes.Validator<PropTypes.InferProps<{
4
- type: PropTypes.Requireable<string>;
5
- }>>;
6
- value: PropTypes.Requireable<string>;
7
- };
8
- constructor(props: any);
9
- constructor(props: any, context: any);
10
- formatValue: (value: any) => any;
11
- }
12
- import * as React from "react";
13
- import * as PropTypes from "prop-types";
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const React = require("react");
4
- const PropTypes = require("prop-types");
5
- const BaseInputTemplate_1 = require("../templates/BaseInputTemplate");
6
- class NumberWidget extends React.Component {
7
- constructor() {
8
- super(...arguments);
9
- this.formatValue = (value) => !isNaN(value) ? value : null;
10
- }
11
- render() {
12
- return React.createElement(BaseInputTemplate_1.default, Object.assign({}, this.props, { formatValue: this.formatValue }));
13
- }
14
- }
15
- exports.default = NumberWidget;
16
- NumberWidget.propTypes = {
17
- schema: PropTypes.shape({
18
- type: PropTypes.oneOf(["string"])
19
- }).isRequired,
20
- value: PropTypes.string
21
- };
@@ -1,12 +0,0 @@
1
- export default PlainTextWidget;
2
- declare function PlainTextWidget(props: any): JSX.Element;
3
- declare namespace PlainTextWidget {
4
- namespace propTypes {
5
- const id: PropTypes.Validator<string>;
6
- const value: PropTypes.Requireable<string | number>;
7
- const schema: PropTypes.Requireable<PropTypes.InferProps<{
8
- type: PropTypes.Requireable<string>;
9
- }>>;
10
- }
11
- }
12
- import * as PropTypes from "prop-types";
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const React = require("react");
4
- const PropTypes = require("prop-types");
5
- const utils_1 = require("../../utils");
6
- function PlainTextWidget(props) {
7
- const { id, value } = props;
8
- const { strong, "ui:widget": formatterWidget, "ui:options": formatterOptions, centered, tag } = utils_1.getUiOptions(props);
9
- const formattedValue = utils_1.formatValue(Object.assign(Object.assign({}, props), { uiSchema: formatterWidget ? { "ui:widget": formatterWidget, options: formatterOptions } : props.uiSchema, schema: props.schema, formData: props.value }));
10
- const Tag = tag || "span";
11
- return (React.createElement(Tag, { className: `plainText${centered ? " horizontally-centered row-height" : ""}` },
12
- strong ? React.createElement("strong", null, formattedValue) : formattedValue,
13
- React.createElement("input", { type: "hidden", id: id, value: typeof value === "undefined" ? "" : value })));
14
- }
15
- if (process.env.NODE_ENV !== "production") {
16
- PlainTextWidget.propTypes = {
17
- id: PropTypes.string.isRequired,
18
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
19
- schema: PropTypes.shape({
20
- type: PropTypes.oneOf(["string", "number", "integer"])
21
- })
22
- };
23
- }
24
- exports.default = PlainTextWidget;
@@ -1,52 +0,0 @@
1
- export default SelectWidget;
2
- declare class SelectWidget extends React.Component<any, any, any> {
3
- static contextType: React.Context<import("../../ReactContext").ContextProps>;
4
- constructor(props: any);
5
- _context: Record<string, unknown>;
6
- mounted: boolean | undefined;
7
- getEnumOptions(props: any): any;
8
- getStateFromProps(props: any): {
9
- valsToItems: any;
10
- enumOptions: any;
11
- value: any;
12
- };
13
- multiSelectOnChange: (values: any) => void;
14
- selectOnChange: (item: any) => void;
15
- onClick: () => void;
16
- onFocus: () => void;
17
- onBlur: () => void;
18
- onSelect: (item: any) => void;
19
- onToggle: () => void;
20
- onKeyDown: (e: any) => void;
21
- setRef: (elem: any) => void;
22
- elemRef: any;
23
- getEnum: (val: any) => any;
24
- }
25
- declare namespace SelectWidget {
26
- namespace defaultProps {
27
- const autofocus: boolean;
28
- }
29
- namespace propTypes {
30
- export const schema: PropTypes.Requireable<PropTypes.InferProps<{
31
- type: PropTypes.Requireable<string>;
32
- }>>;
33
- export const id: PropTypes.Validator<string>;
34
- export const uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
35
- "ui:options": PropTypes.Requireable<PropTypes.InferProps<{
36
- enumOptions: PropTypes.Requireable<any[]>;
37
- order: PropTypes.Requireable<any[]>;
38
- filter: PropTypes.Requireable<any[]>;
39
- filterType: PropTypes.Requireable<string>;
40
- labels: PropTypes.Requireable<object>;
41
- }>>;
42
- }>>;
43
- export const value: PropTypes.Requireable<string | any[]>;
44
- export const required: PropTypes.Requireable<boolean>;
45
- export const multiple: PropTypes.Requireable<boolean>;
46
- const autofocus_1: PropTypes.Requireable<boolean>;
47
- export { autofocus_1 as autofocus };
48
- export const onChange: PropTypes.Requireable<(...args: any[]) => any>;
49
- }
50
- }
51
- import * as React from "react";
52
- import * as PropTypes from "prop-types";