@manuscripts/body-editor 3.12.67 → 3.13.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 (289) hide show
  1. package/dist/cjs/components/toolbar/type-selector/styles.js +2 -1
  2. package/dist/cjs/versions.js +1 -1
  3. package/dist/es/components/toolbar/type-selector/styles.js +2 -1
  4. package/dist/es/versions.js +1 -1
  5. package/dist/types/components/toolbar/type-selector/styles.d.ts +2 -2
  6. package/dist/types/lib/footnotes.d.ts +4 -2
  7. package/dist/types/lib/utils.d.ts +5 -4
  8. package/dist/types/versions.d.ts +1 -1
  9. package/package.json +37 -36
  10. package/{dist/es/lib/statistics.js → src/__mocks__/styleMock.ts} +2 -14
  11. package/src/assets.ts +20 -0
  12. package/src/classes/collabProvider.ts +38 -0
  13. package/src/clipboard.ts +54 -0
  14. package/src/commands.ts +2109 -0
  15. package/src/components/ChangeHandlingForm.tsx +54 -0
  16. package/src/components/LanguageDropdown/index.tsx +343 -0
  17. package/src/components/affiliations/AffiliationForm.tsx +238 -0
  18. package/src/components/affiliations/AffiliationItem.tsx +151 -0
  19. package/src/components/affiliations/AffiliationList.tsx +71 -0
  20. package/src/components/affiliations/AffiliationsModal.tsx +676 -0
  21. package/src/components/affiliations/AffiliationsPanel.tsx +76 -0
  22. package/src/components/affiliations/CreateAffiliationModal.tsx +135 -0
  23. package/src/components/authors/AuthorDetailsForm.tsx +438 -0
  24. package/src/components/authors/AuthorList.tsx +81 -0
  25. package/src/components/authors/AuthorsModal.tsx +642 -0
  26. package/src/components/authors/AuthorsPanel.tsx +69 -0
  27. package/src/components/authors/CreateAuthorModal.tsx +172 -0
  28. package/src/components/authors/CreditDrawer.tsx +71 -0
  29. package/src/components/authors/DraggableAuthor.tsx +228 -0
  30. package/src/components/authors/useManageAffiliations.tsx +77 -0
  31. package/src/components/authors/useManageCredit.tsx +63 -0
  32. package/src/components/authors-affiliations/AuthorsAndAffiliationsModals.tsx +170 -0
  33. package/src/components/authors-affiliations/GenericPanel.tsx +164 -0
  34. package/src/components/authors-affiliations/ModalTabs.tsx +100 -0
  35. package/src/components/awards/AwardForm.tsx +338 -0
  36. package/src/components/awards/AwardModal.tsx +120 -0
  37. package/src/components/awards/DeleteAwardDiaolog.tsx +52 -0
  38. package/src/components/dialog/ConfirmationDialog.tsx +131 -0
  39. package/src/components/form/CreateModalStyles.tsx +37 -0
  40. package/src/components/form/FormFooter.tsx +54 -0
  41. package/src/components/form/FormPlaceholder.tsx +71 -0
  42. package/src/components/form/ModalFormActions.tsx +88 -0
  43. package/src/components/form/UnsavedLabel.tsx +49 -0
  44. package/src/components/hooks/use-debounce.ts +56 -0
  45. package/src/components/hooks/useAffiliationShowsErrorIndicator.ts +51 -0
  46. package/src/components/hooks/useAuthorShowsErrorIndicator.ts +73 -0
  47. package/src/components/keyboard-shortcuts-modal/FormattedShortcut.tsx +56 -0
  48. package/src/components/keyboard-shortcuts-modal/KeyboardShortcutsModal.tsx +283 -0
  49. package/src/components/keyboard-shortcuts-modal/keyboard-shortcuts.ts +304 -0
  50. package/src/components/keywords/AddKeywordInline.tsx +284 -0
  51. package/src/components/keywords/DeleteKeywordDialog.tsx +52 -0
  52. package/src/components/modal-drawer/GenericDrawer.tsx +65 -0
  53. package/src/components/modal-drawer/GenericDrawerGroup.tsx +125 -0
  54. package/src/components/outline/DraggableTree.tsx +438 -0
  55. package/src/components/outline/ManuscriptOutline.tsx +127 -0
  56. package/src/components/outline/Outline.tsx +141 -0
  57. package/src/components/references/BibliographyItemSource.ts +80 -0
  58. package/src/components/references/CitationEditor.tsx +301 -0
  59. package/src/components/references/CitationViewer.tsx +62 -0
  60. package/src/components/references/ImportBibliographyForm.tsx +232 -0
  61. package/src/components/references/ImportBibliographyModal.tsx +159 -0
  62. package/src/components/references/ReferenceForm/PersonDropDown.tsx +93 -0
  63. package/src/components/references/ReferenceForm/ReferenceForm.tsx +701 -0
  64. package/src/components/references/ReferenceForm/config.ts +133 -0
  65. package/src/components/references/ReferenceForm/styled-components.ts +156 -0
  66. package/src/components/references/ReferenceLine.tsx +43 -0
  67. package/src/components/references/ReferenceSearch.tsx +163 -0
  68. package/src/components/references/ReferenceSearchResults.tsx +113 -0
  69. package/src/components/references/ReferenceSearchResultsPlaceholder.tsx +71 -0
  70. package/src/components/references/ReferenceSearchSection.tsx +124 -0
  71. package/src/components/references/ReferencesEditor.tsx +61 -0
  72. package/src/components/references/ReferencesModal.tsx +352 -0
  73. package/src/components/references/SearchInput.tsx +98 -0
  74. package/src/components/toolbar/InsertEmbedDialog.tsx +222 -0
  75. package/src/components/toolbar/InsertTableDialog.tsx +208 -0
  76. package/src/components/toolbar/ListMenuItem.tsx +203 -0
  77. package/src/components/toolbar/helpers.ts +547 -0
  78. package/src/components/toolbar/type-selector/OptionComponent.tsx +89 -0
  79. package/src/components/toolbar/type-selector/TypeSelector.tsx +157 -0
  80. package/src/components/toolbar/type-selector/styles.ts +79 -0
  81. package/src/components/views/CrossReferenceItems.tsx +199 -0
  82. package/src/components/views/DeleteEmbedDialog.tsx +83 -0
  83. package/src/components/views/DeleteFootnoteDialog.tsx +54 -0
  84. package/src/components/views/FigureDropdown.tsx +423 -0
  85. package/src/components/views/FootnotesSelector.tsx +255 -0
  86. package/src/components/views/InsertSpecialCharacter.tsx +245 -0
  87. package/src/components/views/LinkForm.tsx +220 -0
  88. package/src/components/views/TableCellContextMenu.tsx +241 -0
  89. package/src/configs/ManuscriptsEditor.ts +140 -0
  90. package/src/configs/editor-plugins.ts +119 -0
  91. package/src/configs/editor-views.ts +139 -0
  92. package/src/icons.ts +62 -0
  93. package/src/index.ts +65 -0
  94. package/src/keys/highlight.ts +65 -0
  95. package/src/keys/index.ts +33 -0
  96. package/src/keys/keyword.ts +69 -0
  97. package/src/keys/list.ts +156 -0
  98. package/src/keys/misc.ts +112 -0
  99. package/src/keys/title.ts +221 -0
  100. package/src/lib/__tests__/__fixtures__/doc.json +388 -0
  101. package/src/lib/__tests__/__snapshots__/paste.test.ts.snap +24 -0
  102. package/src/lib/__tests__/authors.test.ts +202 -0
  103. package/src/lib/__tests__/helpers.test.ts +46 -0
  104. package/src/lib/__tests__/paste.test.ts +57 -0
  105. package/src/lib/__tests__/plugins.test.ts +176 -0
  106. package/src/lib/__tests__/url.test.ts +31 -0
  107. package/src/lib/array-reducer.ts +68 -0
  108. package/src/lib/authors-and-affiliations.ts +81 -0
  109. package/src/lib/authors.ts +67 -0
  110. package/src/lib/capabilities.ts +55 -0
  111. package/src/lib/codemirror.ts +37 -0
  112. package/src/lib/comments.ts +123 -0
  113. package/src/lib/context-menu.ts +745 -0
  114. package/src/lib/copy.ts +30 -0
  115. package/src/lib/crossref.ts +90 -0
  116. package/src/lib/dnd.ts +29 -0
  117. package/src/lib/doc.ts +167 -0
  118. package/src/lib/dompurify.ts +28 -0
  119. package/src/lib/files.ts +180 -0
  120. package/src/lib/footnotes.ts +83 -0
  121. package/src/lib/get-media-type.ts +105 -0
  122. package/src/lib/helpers.ts +199 -0
  123. package/src/lib/hierarchy.ts +117 -0
  124. package/src/lib/languages.ts +37 -0
  125. package/src/lib/lists.ts +56 -0
  126. package/src/lib/math.ts +111 -0
  127. package/src/lib/media.ts +334 -0
  128. package/src/lib/navigation-utils.ts +235 -0
  129. package/src/lib/normalize.ts +70 -0
  130. package/src/lib/paste.ts +304 -0
  131. package/src/lib/placeholder.ts +32 -0
  132. package/src/lib/platform.ts +18 -0
  133. package/src/lib/plugins.ts +22 -0
  134. package/src/lib/popper.ts +180 -0
  135. package/src/lib/position-menu.ts +184 -0
  136. package/src/lib/references.ts +94 -0
  137. package/src/lib/template.ts +29 -0
  138. package/src/lib/track-changes-utils.ts +34 -0
  139. package/{dist/types/lib/statistics.d.ts → src/lib/url.ts} +11 -8
  140. package/src/lib/use-do-with-debounce.ts +39 -0
  141. package/src/lib/utils.ts +323 -0
  142. package/src/lib/view.ts +100 -0
  143. package/src/menus.tsx +684 -0
  144. package/src/node-type-icons.tsx +83 -0
  145. package/src/plugins/__tests__/__fixtures__/deleted-footnote.json +140 -0
  146. package/src/plugins/__tests__/__fixtures__/inserted-footnote.json +153 -0
  147. package/src/plugins/__tests__/footnotes.test.ts +67 -0
  148. package/src/plugins/accessibility_element.ts +219 -0
  149. package/src/plugins/add-subtitle.ts +102 -0
  150. package/src/plugins/affiliations.ts +136 -0
  151. package/src/plugins/alt-titles.ts +219 -0
  152. package/src/plugins/bibliography.ts +235 -0
  153. package/src/plugins/comments.ts +328 -0
  154. package/src/plugins/cross-references.ts +70 -0
  155. package/src/plugins/detect-inconsistency/detect-inconsistency-utils.ts +102 -0
  156. package/src/plugins/detect-inconsistency/index.ts +55 -0
  157. package/src/plugins/detect-inconsistency/validators.ts +283 -0
  158. package/src/plugins/doi.ts +66 -0
  159. package/src/plugins/editor-props.ts +39 -0
  160. package/src/plugins/elements.ts +60 -0
  161. package/src/plugins/footnotes.ts +298 -0
  162. package/src/plugins/link.ts +53 -0
  163. package/src/plugins/lock-body.ts +136 -0
  164. package/src/plugins/move-node.ts +55 -0
  165. package/src/plugins/objects.ts +125 -0
  166. package/src/plugins/paragraphs.ts +90 -0
  167. package/src/plugins/persist.ts +64 -0
  168. package/src/plugins/persistent-cursor.ts +66 -0
  169. package/src/plugins/placeholder.ts +219 -0
  170. package/src/plugins/prevent-empty.ts +50 -0
  171. package/src/plugins/search-replace/index.ts +157 -0
  172. package/src/plugins/search-replace/lib.ts +95 -0
  173. package/src/plugins/section_category.ts +212 -0
  174. package/src/plugins/section_title/autocompletion.ts +87 -0
  175. package/src/plugins/section_title/index.ts +105 -0
  176. package/src/plugins/selected-suggestion.ts +243 -0
  177. package/src/plugins/tables-cursor-fix.ts +143 -0
  178. package/src/plugins/translations.ts +263 -0
  179. package/src/rules.ts +60 -0
  180. package/src/selection.ts +112 -0
  181. package/src/testing/default-capabilities.ts +48 -0
  182. package/src/testing/default-editor-data.ts +73 -0
  183. package/src/testing/empty-editor-doc.json +62 -0
  184. package/src/testing/polyfill-dom.ts +43 -0
  185. package/src/testing/section-categories.json +161 -0
  186. package/src/testing/setup-editor.ts +55 -0
  187. package/src/tests.ts +42 -0
  188. package/src/toolbar.tsx +259 -0
  189. package/src/types/@citation-js/core.d.ts +16 -0
  190. package/src/types/@citation-js/index.d.ts +16 -0
  191. package/src/types/@citation-js/plugin-bibtex.d.ts +16 -0
  192. package/src/types/@citation-js/plugin-csl.d.ts +16 -0
  193. package/src/types/@citation-js/plugin-doi.d.ts +16 -0
  194. package/src/types/@citation-js/plugin-enw.d.ts +16 -0
  195. package/src/types/@citation-js/plugin-pubmed.d.ts +16 -0
  196. package/src/types/@citation-js/plugin-ris.d.ts +16 -0
  197. package/src/types/citeproc.d.ts +124 -0
  198. package/src/types/css.d.ts +16 -0
  199. package/src/types/json.d.ts +17 -0
  200. package/src/types/prosemirror-dev-tools.d.ts +16 -0
  201. package/src/types/prosemirror-dropcursor.d.ts +16 -0
  202. package/src/types/styled-components.d.ts +23 -0
  203. package/src/types.ts +49 -0
  204. package/src/useEditor.ts +244 -0
  205. package/src/versions.ts +3 -0
  206. package/src/views/ReactSubView.tsx +145 -0
  207. package/src/views/abstracts.ts +46 -0
  208. package/src/views/accessibility_element.ts +86 -0
  209. package/src/views/affiliations.ts +254 -0
  210. package/src/views/alt_title.ts +85 -0
  211. package/src/views/alt_titles_section.ts +97 -0
  212. package/src/views/attachment.ts +160 -0
  213. package/src/views/attachments.ts +72 -0
  214. package/src/views/author_notes.ts +96 -0
  215. package/src/views/award.ts +194 -0
  216. package/src/views/awards.ts +59 -0
  217. package/src/views/base_node_view.ts +85 -0
  218. package/src/views/bibliography_element.ts +313 -0
  219. package/src/views/block_view.ts +100 -0
  220. package/src/views/blockquote_element.ts +26 -0
  221. package/src/views/blockquote_element_editable.ts +24 -0
  222. package/src/views/box_element.ts +33 -0
  223. package/src/views/caption.ts +37 -0
  224. package/src/views/caption_title.ts +33 -0
  225. package/src/views/citation.ts +67 -0
  226. package/src/views/citation_editable.ts +312 -0
  227. package/src/views/contributors.ts +341 -0
  228. package/src/views/creators.ts +82 -0
  229. package/src/views/cross_reference.ts +74 -0
  230. package/src/views/cross_reference_editable.ts +113 -0
  231. package/src/views/editable_block.ts +141 -0
  232. package/src/views/embed.ts +345 -0
  233. package/src/views/empty.ts +26 -0
  234. package/src/views/equation.ts +47 -0
  235. package/src/views/equation_editable.ts +84 -0
  236. package/src/views/equation_element.ts +29 -0
  237. package/src/views/equation_element_editable.ts +21 -0
  238. package/src/views/figure.ts +84 -0
  239. package/src/views/figure_editable.ts +361 -0
  240. package/src/views/figure_element.ts +197 -0
  241. package/src/views/figure_element_editable.ts +21 -0
  242. package/src/views/footnote.ts +236 -0
  243. package/src/views/footnotes_element.ts +54 -0
  244. package/src/views/general_table_footnote.ts +140 -0
  245. package/src/views/hero_image.ts +76 -0
  246. package/src/views/hero_image_editable.ts +21 -0
  247. package/src/views/image_element.ts +373 -0
  248. package/src/views/image_element_editable.ts +21 -0
  249. package/src/views/inline_equation.ts +47 -0
  250. package/src/views/inline_equation_editable.ts +70 -0
  251. package/src/views/inline_footnote.ts +264 -0
  252. package/src/views/inline_footnote_editable.ts +20 -0
  253. package/src/views/keyword.ts +127 -0
  254. package/src/views/keyword_group.ts +109 -0
  255. package/src/views/link.ts +27 -0
  256. package/src/views/link_editable.ts +169 -0
  257. package/src/views/list.ts +46 -0
  258. package/src/views/list_item.ts +26 -0
  259. package/src/views/paragraph.ts +26 -0
  260. package/src/views/paragraph_editable.ts +21 -0
  261. package/src/views/placeholder.ts +35 -0
  262. package/src/views/placeholder_element.ts +38 -0
  263. package/src/views/placeholder_element_editable.ts +21 -0
  264. package/src/views/pullquote_element.ts +106 -0
  265. package/src/views/pullquote_element_editable.ts +24 -0
  266. package/src/views/quote_image_editable.ts +84 -0
  267. package/src/views/section.ts +64 -0
  268. package/src/views/section_label.ts +20 -0
  269. package/src/views/section_title.ts +87 -0
  270. package/src/views/section_title_editable.ts +21 -0
  271. package/src/views/subtitle.ts +42 -0
  272. package/src/views/subtitle_editable.ts +20 -0
  273. package/src/views/subtitles.ts +34 -0
  274. package/src/views/subtitles_editable.ts +21 -0
  275. package/src/views/supplement.ts +236 -0
  276. package/src/views/supplement_editable.ts +20 -0
  277. package/src/views/supplements.ts +65 -0
  278. package/src/views/supplements_editable.ts +21 -0
  279. package/src/views/table_cell.ts +150 -0
  280. package/src/views/table_element.ts +33 -0
  281. package/src/views/table_element_editable.ts +21 -0
  282. package/src/views/table_element_footer.ts +41 -0
  283. package/src/views/title.ts +46 -0
  284. package/src/views/title_editable.ts +20 -0
  285. package/src/views/trans_graphical_abstract.ts +55 -0
  286. package/src/views/trans_graphical_abstract_editable.ts +21 -0
  287. package/src/views/translated_abstract.ts +53 -0
  288. package/src/views/translated_abstract_editable.ts +21 -0
  289. package/dist/cjs/lib/statistics.js +0 -38
@@ -0,0 +1,701 @@
1
+ /*!
2
+ * © 2023 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ AddAuthorIcon,
19
+ ButtonGroup,
20
+ Category,
21
+ DeleteIcon,
22
+ Dialog,
23
+ IconButton,
24
+ LinkIcon,
25
+ OptionType,
26
+ PrimaryButton,
27
+ SecondaryButton,
28
+ SelectField,
29
+ Label,
30
+ FormRow,
31
+ YearField,
32
+ } from '@manuscripts/style-guide'
33
+ import {
34
+ BibliographyItemAttrs,
35
+ BibliographyItemType,
36
+ } from '@manuscripts/transform'
37
+ import { Field, FieldArray, FieldProps, Formik, FormikProps } from 'formik'
38
+ import React, { MutableRefObject, useEffect, useRef, useState } from 'react'
39
+
40
+ import { bibliographyItemTypes } from '../../../lib/references'
41
+ import { shouldRenderField } from '../../../lib/utils'
42
+ import { ChangeHandlingForm } from '../../ChangeHandlingForm'
43
+ import { PersonDropDown } from './PersonDropDown'
44
+ import {
45
+ Actions,
46
+ Button,
47
+ DeleteButton,
48
+ FormFields,
49
+ ReferenceTextArea,
50
+ ReferenceTextField,
51
+ } from './styled-components'
52
+
53
+ const bibliographyItemTypeOptions: OptionType[] = bibliographyItemTypes.map(
54
+ (i) => ({
55
+ label: i[1],
56
+ value: i[0],
57
+ })
58
+ )
59
+ export interface ReferenceFormActions {
60
+ reset: () => void
61
+ }
62
+
63
+ export const ReferenceForm: React.FC<{
64
+ values: BibliographyItemAttrs
65
+ showDelete: boolean
66
+ onChange: (values: BibliographyItemAttrs) => void
67
+ onCancel: () => void
68
+ onDelete: () => void
69
+ onSave: (values: BibliographyItemAttrs) => void
70
+ actionsRef?: MutableRefObject<ReferenceFormActions | undefined>
71
+ }> = ({
72
+ values,
73
+ showDelete,
74
+ onChange,
75
+ onDelete,
76
+ onCancel,
77
+ onSave,
78
+ actionsRef,
79
+ }) => {
80
+ const fieldsRef = useRef<HTMLDivElement>(null)
81
+ const formRef = useRef<FormikProps<BibliographyItemAttrs>>(null)
82
+ const [newAuthorIndex, setNewAuthorIndex] = useState<number>()
83
+ const [newEditorIndex, setNewEditorIndex] = useState<number>()
84
+
85
+ useEffect(() => {
86
+ if (fieldsRef.current) {
87
+ fieldsRef.current.scrollTop = 0
88
+ }
89
+ }, [values])
90
+
91
+ const [showDeleteDialog, setShowDeleteDialog] = useState(false)
92
+
93
+ const validateReference = (values: BibliographyItemAttrs) => {
94
+ const errors: Partial<BibliographyItemAttrs> = {}
95
+
96
+ if (values.type === 'literal') {
97
+ if (!values.literal?.trim()) {
98
+ errors.literal = 'Literal is required for unstructured references'
99
+ }
100
+ } else {
101
+ if (!values.title?.trim()) {
102
+ errors.title = 'Title is required'
103
+ }
104
+ }
105
+ return errors
106
+ }
107
+
108
+ if (actionsRef && !actionsRef.current) {
109
+ actionsRef.current = {
110
+ reset: () => {
111
+ formRef.current?.resetForm()
112
+ },
113
+ }
114
+ }
115
+
116
+ return (
117
+ <Formik<BibliographyItemAttrs>
118
+ initialValues={values}
119
+ onSubmit={onSave}
120
+ enableReinitialize={true}
121
+ innerRef={formRef}
122
+ validate={validateReference}
123
+ >
124
+ {(formik) => {
125
+ return (
126
+ <ChangeHandlingForm onChange={onChange}>
127
+ <Dialog
128
+ isOpen={showDeleteDialog}
129
+ category={Category.confirmation}
130
+ header="Delete Reference"
131
+ message="Are you sure you want to delete this reference from the list?"
132
+ actions={{
133
+ secondary: {
134
+ action: () => {
135
+ onDelete()
136
+ setShowDeleteDialog(false)
137
+ },
138
+ title: 'Delete',
139
+ },
140
+ primary: {
141
+ action: () => setShowDeleteDialog(false),
142
+ title: 'Cancel',
143
+ },
144
+ }}
145
+ />
146
+ <Actions>
147
+ <ButtonGroup>
148
+ <IconButton
149
+ as="a"
150
+ href={`https://doi.org/${formik.values.DOI}`}
151
+ target={'_blank'}
152
+ >
153
+ <LinkIcon />
154
+ </IconButton>
155
+ <DeleteButton
156
+ defaultColor
157
+ disabled={!showDelete}
158
+ data-tooltip-content="Unable to delete because the item is used in the document"
159
+ data-tooltip-hidden={showDelete}
160
+ onClick={() => setShowDeleteDialog(true)}
161
+ >
162
+ <DeleteIcon />
163
+ </DeleteButton>
164
+ </ButtonGroup>
165
+ <ButtonGroup>
166
+ <SecondaryButton onClick={onCancel}>Cancel</SecondaryButton>
167
+ <PrimaryButton
168
+ type="submit"
169
+ disabled={!formik.isValid || !formik.dirty}
170
+ >
171
+ Save
172
+ </PrimaryButton>
173
+ </ButtonGroup>
174
+ </Actions>
175
+
176
+ <FormFields ref={fieldsRef}>
177
+ <FormRow>
178
+ <Label htmlFor={'citation-item-type'}>Type</Label>
179
+
180
+ <Field
181
+ id={'citation-item-type'}
182
+ name={'type'}
183
+ component={SelectField}
184
+ options={bibliographyItemTypeOptions}
185
+ />
186
+ </FormRow>
187
+
188
+ {shouldRenderField(
189
+ 'title',
190
+ formik.values.type as BibliographyItemType
191
+ ) && (
192
+ <FormRow>
193
+ <Label>Title</Label>
194
+
195
+ <Field name={'title'}>
196
+ {(props: FieldProps) => (
197
+ <ReferenceTextArea id={'title'} {...props.field} />
198
+ )}
199
+ </Field>
200
+ </FormRow>
201
+ )}
202
+
203
+ {shouldRenderField(
204
+ 'literal',
205
+ formik.values.type as BibliographyItemType
206
+ ) && (
207
+ <FormRow>
208
+ <Label>Text</Label>
209
+
210
+ <Field name={'literal'}>
211
+ {(props: FieldProps) => (
212
+ <ReferenceTextArea id={'literal'} {...props.field} />
213
+ )}
214
+ </Field>
215
+ </FormRow>
216
+ )}
217
+ {shouldRenderField(
218
+ 'std',
219
+ formik.values.type as BibliographyItemType
220
+ ) && (
221
+ <FormRow>
222
+ <Label htmlFor={'std'}>Standard</Label>
223
+ <Field name={'std'}>
224
+ {(props: FieldProps) => (
225
+ <ReferenceTextArea id={'std'} {...props.field} />
226
+ )}
227
+ </Field>
228
+ </FormRow>
229
+ )}
230
+
231
+ {shouldRenderField(
232
+ 'author',
233
+ formik.values.type as BibliographyItemType
234
+ ) && (
235
+ <FieldArray
236
+ name={'author'}
237
+ render={({ push, remove }) => (
238
+ <FormRow
239
+ direction="row"
240
+ justify="space-between"
241
+ align="center"
242
+ >
243
+ <Label>Authors</Label>
244
+
245
+ <Button
246
+ onClick={() => {
247
+ setNewAuthorIndex(formik.values.author?.length)
248
+ push({
249
+ given: '',
250
+ family: '',
251
+ })
252
+ }}
253
+ >
254
+ <AddAuthorIcon height={17} width={17} />
255
+ </Button>
256
+
257
+ <div style={{ width: '100%' }}>
258
+ {formik.values.author?.map((author, index) => (
259
+ <PersonDropDown
260
+ key={index}
261
+ index={index}
262
+ person={author}
263
+ isNew={newAuthorIndex === index}
264
+ remove={remove}
265
+ onChange={formik.handleChange}
266
+ type="author"
267
+ />
268
+ ))}
269
+ </div>
270
+ </FormRow>
271
+ )}
272
+ />
273
+ )}
274
+
275
+ {shouldRenderField(
276
+ 'editor',
277
+ formik.values.type as BibliographyItemType
278
+ ) && (
279
+ <FieldArray
280
+ name={'editor'}
281
+ render={({ push, remove }) => (
282
+ <FormRow>
283
+ <Label>Editors</Label>
284
+
285
+ <Button
286
+ onClick={() => {
287
+ setNewEditorIndex(formik.values.editor?.length)
288
+ push({
289
+ given: '',
290
+ family: '',
291
+ })
292
+ }}
293
+ >
294
+ <AddAuthorIcon height={17} width={17} />
295
+ </Button>
296
+
297
+ <div>
298
+ {formik.values.editor?.map((editor, index) => (
299
+ <PersonDropDown
300
+ key={index}
301
+ index={index}
302
+ person={editor}
303
+ isNew={newEditorIndex === index}
304
+ remove={remove}
305
+ onChange={formik.handleChange}
306
+ type="editor"
307
+ />
308
+ ))}
309
+ </div>
310
+ </FormRow>
311
+ )}
312
+ />
313
+ )}
314
+
315
+ {shouldRenderField(
316
+ 'issued',
317
+ formik.values.type as BibliographyItemType
318
+ ) && (
319
+ <FormRow>
320
+ <Label htmlFor="issued-year-field">Issued (Year)</Label>
321
+
322
+ <YearField
323
+ name={"issued['date-parts'][0][0]"}
324
+ id="issued-year-field"
325
+ type={'number'}
326
+ step={1}
327
+ onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
328
+ const { value } = event.target
329
+ if (value) {
330
+ if (formik.values.issued) {
331
+ // NOTE: this assumes that "issued" is already a complete object
332
+ formik.setFieldValue(
333
+ "issued['date-parts'][0][0]",
334
+ Number(value)
335
+ )
336
+ } else {
337
+ formik.setFieldValue('issued', {
338
+ 'date-parts': [[Number(value)]],
339
+ })
340
+ }
341
+ } else {
342
+ // NOTE: not undefined due to https://github.com/jaredpalmer/formik/issues/2180
343
+ formik.setFieldValue('issued', '')
344
+ }
345
+ }}
346
+ />
347
+ </FormRow>
348
+ )}
349
+
350
+ {shouldRenderField(
351
+ 'container-title',
352
+ formik.values.type as BibliographyItemType
353
+ ) && (
354
+ <FormRow>
355
+ <Label htmlFor={'container-title'}>Container Title</Label>
356
+
357
+ <Field name={'container-title'}>
358
+ {(props: FieldProps) => (
359
+ <ReferenceTextArea
360
+ id={'container-title'}
361
+ {...props.field}
362
+ />
363
+ )}
364
+ </Field>
365
+ </FormRow>
366
+ )}
367
+ {shouldRenderField(
368
+ 'collection-title',
369
+ formik.values.type as BibliographyItemType
370
+ ) && (
371
+ <FormRow>
372
+ <Label htmlFor={'collection-title'}>Collection Title</Label>
373
+
374
+ <Field name={'collection-title'}>
375
+ {(props: FieldProps) => (
376
+ <ReferenceTextArea
377
+ id={'collection-title'}
378
+ {...props.field}
379
+ />
380
+ )}
381
+ </Field>
382
+ </FormRow>
383
+ )}
384
+
385
+ {shouldRenderField(
386
+ 'volume',
387
+ formik.values.type as BibliographyItemType
388
+ ) && (
389
+ <FormRow>
390
+ <Label htmlFor={'volume'}>Volume</Label>
391
+
392
+ <Field name={'volume'}>
393
+ {(props: FieldProps) => (
394
+ <ReferenceTextField id={'volume'} {...props.field} />
395
+ )}
396
+ </Field>
397
+ </FormRow>
398
+ )}
399
+
400
+ {shouldRenderField(
401
+ 'issue',
402
+ formik.values.type as BibliographyItemType
403
+ ) && (
404
+ <FormRow>
405
+ <Label htmlFor={'issue'}>Issue</Label>
406
+
407
+ <Field name={'issue'}>
408
+ {(props: FieldProps) => (
409
+ <ReferenceTextField id={'issue'} {...props.field} />
410
+ )}
411
+ </Field>
412
+ </FormRow>
413
+ )}
414
+
415
+ {shouldRenderField(
416
+ 'supplement',
417
+ formik.values.type as BibliographyItemType
418
+ ) && (
419
+ <FormRow>
420
+ <Label htmlFor={'supplement'}>Supplement</Label>
421
+
422
+ <Field name={'supplement'}>
423
+ {(props: FieldProps) => (
424
+ <ReferenceTextField
425
+ type={'supplement'}
426
+ id={'supplement'}
427
+ {...props.field}
428
+ />
429
+ )}
430
+ </Field>
431
+ </FormRow>
432
+ )}
433
+
434
+ {shouldRenderField(
435
+ 'edition',
436
+ formik.values.type as BibliographyItemType
437
+ ) && (
438
+ <FormRow>
439
+ <Label htmlFor={'edition'}>Edition</Label>
440
+
441
+ <Field name={'edition'}>
442
+ {(props: FieldProps) => (
443
+ <ReferenceTextField id={'edition'} {...props.field} />
444
+ )}
445
+ </Field>
446
+ </FormRow>
447
+ )}
448
+
449
+ {shouldRenderField(
450
+ 'publisher-place',
451
+ formik.values.type as BibliographyItemType
452
+ ) && (
453
+ <FormRow>
454
+ <Label htmlFor={'publisher-place'}>Publisher Location</Label>
455
+
456
+ <Field name={'publisher-place'}>
457
+ {(props: FieldProps) => (
458
+ <ReferenceTextField
459
+ id={'publisher-place'}
460
+ {...props.field}
461
+ />
462
+ )}
463
+ </Field>
464
+ </FormRow>
465
+ )}
466
+
467
+ {shouldRenderField(
468
+ 'publisher',
469
+ formik.values.type as BibliographyItemType
470
+ ) && (
471
+ <FormRow>
472
+ <Label htmlFor={'publisher'}>Publisher</Label>
473
+
474
+ <Field name={'publisher'}>
475
+ {(props: FieldProps) => (
476
+ <ReferenceTextField id="publisher" {...props.field} />
477
+ )}
478
+ </Field>
479
+ </FormRow>
480
+ )}
481
+ {shouldRenderField(
482
+ 'event',
483
+ formik.values.type as BibliographyItemType
484
+ ) && (
485
+ <FormRow>
486
+ <Label htmlFor={'event'}>Event</Label>
487
+
488
+ <Field name={'event'}>
489
+ {(props: FieldProps) => (
490
+ <ReferenceTextField id={'event'} {...props.field} />
491
+ )}
492
+ </Field>
493
+ </FormRow>
494
+ )}
495
+
496
+ {shouldRenderField(
497
+ 'event-place',
498
+ formik.values.type as BibliographyItemType
499
+ ) && (
500
+ <FormRow>
501
+ <Label htmlFor={'event-place'}>Event Place</Label>
502
+
503
+ <Field name={'event-place'}>
504
+ {(props: FieldProps) => (
505
+ <ReferenceTextField id={'event-place'} {...props.field} />
506
+ )}
507
+ </Field>
508
+ </FormRow>
509
+ )}
510
+
511
+ {shouldRenderField(
512
+ 'event-date',
513
+ formik.values.type as BibliographyItemType
514
+ ) && (
515
+ <FormRow>
516
+ <Label htmlFor={"event-date['date-parts'][0][0]"}>
517
+ Event date (Year)
518
+ </Label>
519
+
520
+ <YearField
521
+ name={"event-date['date-parts'][0][0]"}
522
+ type={'number'}
523
+ step={1}
524
+ onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
525
+ const { value } = event.target
526
+
527
+ if (value) {
528
+ if (formik.values['event-date']) {
529
+ // NOTE: this assumes that "event-date" is already a complete object
530
+ formik.setFieldValue(
531
+ "event-date['date-parts'][0][0]",
532
+ Number(value)
533
+ )
534
+ } else {
535
+ formik.setFieldValue('event-date', {
536
+ 'date-parts': [[Number(value)]],
537
+ })
538
+ }
539
+ } else {
540
+ // NOTE: not undefined due to https://github.com/jaredpalmer/formik/issues/2180
541
+ formik.setFieldValue('event-date', '')
542
+ }
543
+ }}
544
+ />
545
+ </FormRow>
546
+ )}
547
+
548
+ {shouldRenderField(
549
+ 'institution',
550
+ formik.values.type as BibliographyItemType
551
+ ) && (
552
+ <FormRow>
553
+ <Label htmlFor={'institution'}>Institution</Label>
554
+
555
+ <Field name={'institution'}>
556
+ {(props: FieldProps) => (
557
+ <ReferenceTextField id={'institution'} {...props.field} />
558
+ )}
559
+ </Field>
560
+ </FormRow>
561
+ )}
562
+
563
+ {shouldRenderField(
564
+ 'page',
565
+ formik.values.type as BibliographyItemType
566
+ ) && (
567
+ <FormRow>
568
+ <Label htmlFor={'page'}>Page</Label>
569
+
570
+ <Field name={'page'}>
571
+ {(props: FieldProps) => (
572
+ <ReferenceTextField id={'page'} {...props.field} />
573
+ )}
574
+ </Field>
575
+ </FormRow>
576
+ )}
577
+
578
+ {shouldRenderField(
579
+ 'number-of-pages',
580
+ formik.values.type as BibliographyItemType
581
+ ) && (
582
+ <FormRow>
583
+ <Label htmlFor={'number-of-pages'}>Number of pages</Label>
584
+
585
+ <Field name={'umber-of-pages'}>
586
+ {(props: FieldProps) => (
587
+ <ReferenceTextField
588
+ id={'number-of-pages'}
589
+ {...props.field}
590
+ />
591
+ )}
592
+ </Field>
593
+ </FormRow>
594
+ )}
595
+
596
+ {shouldRenderField(
597
+ 'locator',
598
+ formik.values.type as BibliographyItemType
599
+ ) && (
600
+ <FormRow>
601
+ <Label htmlFor={'locator'}>Locator</Label>
602
+
603
+ <Field name={'locator'}>
604
+ {(props: FieldProps) => (
605
+ <ReferenceTextField id={'locator'} {...props.field} />
606
+ )}
607
+ </Field>
608
+ </FormRow>
609
+ )}
610
+
611
+ {shouldRenderField(
612
+ 'DOI',
613
+ formik.values.type as BibliographyItemType
614
+ ) && (
615
+ <FormRow>
616
+ <Label htmlFor={'DOI'}>DOI</Label>
617
+
618
+ <Field name={'DOI'}>
619
+ {(props: FieldProps) => (
620
+ <ReferenceTextField
621
+ id={'DOI'}
622
+ pattern={'(https://doi.org/)?10..+'}
623
+ {...props.field}
624
+ />
625
+ )}
626
+ </Field>
627
+ </FormRow>
628
+ )}
629
+
630
+ {shouldRenderField(
631
+ 'URL',
632
+ formik.values.type as BibliographyItemType
633
+ ) && (
634
+ <FormRow>
635
+ <Label htmlFor={'URL'}>URL</Label>
636
+
637
+ <Field name={'URL'}>
638
+ {(props: FieldProps) => (
639
+ <ReferenceTextField id={'URL'} {...props.field} />
640
+ )}
641
+ </Field>
642
+ </FormRow>
643
+ )}
644
+
645
+ {shouldRenderField(
646
+ 'accessed',
647
+ formik.values.type as BibliographyItemType
648
+ ) && (
649
+ <FormRow>
650
+ <Label htmlFor={"accessed['date-parts'][0][0]"}>
651
+ Accessed (Year)
652
+ </Label>
653
+
654
+ <YearField
655
+ name={"accessed['date-parts'][0][0]"}
656
+ type={'number'}
657
+ step={1}
658
+ onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
659
+ const { value } = event.target
660
+
661
+ if (value) {
662
+ if (formik.values['event-date']) {
663
+ // NOTE: this assumes that "accessed" is already a complete object
664
+ formik.setFieldValue(
665
+ "accessed['date-parts'][0][0]",
666
+ Number(value)
667
+ )
668
+ } else {
669
+ formik.setFieldValue('accessed', {
670
+ 'date-parts': [[Number(value)]],
671
+ })
672
+ }
673
+ } else {
674
+ // NOTE: not undefined due to https://github.com/jaredpalmer/formik/issues/2180
675
+ formik.setFieldValue('accessed', '')
676
+ }
677
+ }}
678
+ />
679
+ </FormRow>
680
+ )}
681
+ {shouldRenderField(
682
+ 'comment',
683
+ formik.values.type as BibliographyItemType
684
+ ) && (
685
+ <FormRow>
686
+ <Label>Comment</Label>
687
+
688
+ <Field name={'comment'}>
689
+ {(props: FieldProps) => (
690
+ <ReferenceTextArea id={'comment'} {...props.field} />
691
+ )}
692
+ </Field>
693
+ </FormRow>
694
+ )}
695
+ </FormFields>
696
+ </ChangeHandlingForm>
697
+ )
698
+ }}
699
+ </Formik>
700
+ )
701
+ }