@manuscripts/style-guide 1.8.0-LEAN-3423-3 → 1.8.1-LEAN-3429-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,8 +96,7 @@ const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) => {
96
96
  return selections.has(item.attrs.id);
97
97
  };
98
98
  const handleClick = () => {
99
- const items = Array.from(selections.values());
100
- return onInsert(items);
99
+ return onInsert(notes.filter(({ node }) => selections.has(node.attrs.id)));
101
100
  };
102
101
  return (react_1.default.createElement(Container, null,
103
102
  react_1.default.createElement(NotesContainer, null,
@@ -113,11 +112,11 @@ const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) => {
113
112
  };
114
113
  exports.TableFootnotesSelector = TableFootnotesSelector;
115
114
  const TableFootnotesList = ({ notes, isSelected, onSelect }) => {
116
- return (react_1.default.createElement(NotesListContainer, null, notes.map((note, index) => {
115
+ return (react_1.default.createElement(NotesListContainer, null, notes.map(({ node, index }) => {
117
116
  var _a;
118
- return (react_1.default.createElement(FootnoteItem, { onClick: () => onSelect(note), key: note.attrs.id },
119
- react_1.default.createElement(StatusIcon, null, isSelected(note) ? (react_1.default.createElement(AddedIcon_1.default, { "data-cy": 'plus-icon-ok', width: 24, height: 24 })) : (react_1.default.createElement(AddIcon_1.default, { "data-cy": 'plus-icon', width: 24, height: 24 }))),
120
- react_1.default.createElement(NoteText, null, ++index + '. ' + ((_a = note.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
117
+ return (react_1.default.createElement(FootnoteItem, { onClick: () => onSelect(node), key: node.attrs.id },
118
+ react_1.default.createElement(StatusIcon, null, isSelected(node) ? (react_1.default.createElement(AddedIcon_1.default, { "data-cy": 'plus-icon-ok', width: 24, height: 24 })) : (react_1.default.createElement(AddIcon_1.default, { "data-cy": 'plus-icon', width: 24, height: 24 }))),
119
+ react_1.default.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
121
120
  })));
122
121
  };
123
122
  const NotesListContainer = styled_components_1.default.div `
@@ -19,7 +19,8 @@ exports.useDropdown = void 0;
19
19
  const react_1 = require("react");
20
20
  const useDropdown = () => {
21
21
  const [isOpen, setOpen] = (0, react_1.useState)(false);
22
- const toggleOpen = (0, react_1.useCallback)(() => {
22
+ const toggleOpen = (0, react_1.useCallback)((e) => {
23
+ e === null || e === void 0 ? void 0 : e.stopPropagation();
23
24
  setOpen((open) => !open);
24
25
  }, []);
25
26
  const wrapperRef = (0, react_1.useRef)(null);
@@ -67,8 +67,7 @@ export const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) =>
67
67
  return selections.has(item.attrs.id);
68
68
  };
69
69
  const handleClick = () => {
70
- const items = Array.from(selections.values());
71
- return onInsert(items);
70
+ return onInsert(notes.filter(({ node }) => selections.has(node.attrs.id)));
72
71
  };
73
72
  return (React.createElement(Container, null,
74
73
  React.createElement(NotesContainer, null,
@@ -83,11 +82,11 @@ export const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) =>
83
82
  React.createElement(PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 }, "Insert")))));
84
83
  };
85
84
  const TableFootnotesList = ({ notes, isSelected, onSelect }) => {
86
- return (React.createElement(NotesListContainer, null, notes.map((note, index) => {
85
+ return (React.createElement(NotesListContainer, null, notes.map(({ node, index }) => {
87
86
  var _a;
88
- return (React.createElement(FootnoteItem, { onClick: () => onSelect(note), key: note.attrs.id },
89
- React.createElement(StatusIcon, null, isSelected(note) ? (React.createElement(AddedIcon, { "data-cy": 'plus-icon-ok', width: 24, height: 24 })) : (React.createElement(AddIcon, { "data-cy": 'plus-icon', width: 24, height: 24 }))),
90
- React.createElement(NoteText, null, ++index + '. ' + ((_a = note.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
87
+ return (React.createElement(FootnoteItem, { onClick: () => onSelect(node), key: node.attrs.id },
88
+ React.createElement(StatusIcon, null, isSelected(node) ? (React.createElement(AddedIcon, { "data-cy": 'plus-icon-ok', width: 24, height: 24 })) : (React.createElement(AddIcon, { "data-cy": 'plus-icon', width: 24, height: 24 }))),
89
+ React.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
91
90
  })));
92
91
  };
93
92
  const NotesListContainer = styled.div `
@@ -16,7 +16,8 @@
16
16
  import { useCallback, useEffect, useRef, useState } from 'react';
17
17
  export const useDropdown = () => {
18
18
  const [isOpen, setOpen] = useState(false);
19
- const toggleOpen = useCallback(() => {
19
+ const toggleOpen = useCallback((e) => {
20
+ e === null || e === void 0 ? void 0 : e.stopPropagation();
20
21
  setOpen((open) => !open);
21
22
  }, []);
22
23
  const wrapperRef = useRef(null);
@@ -15,9 +15,13 @@
15
15
  */
16
16
  import { FootnoteNode } from '@manuscripts/transform';
17
17
  import React from 'react';
18
+ export type FootnoteWithIndex = {
19
+ node: FootnoteNode;
20
+ index?: string;
21
+ };
18
22
  export declare const TableFootnotesSelector: React.FC<{
19
- notes: FootnoteNode[];
23
+ notes: FootnoteWithIndex[];
20
24
  onAdd: () => void;
21
- onInsert: (notes: FootnoteNode[]) => void;
25
+ onInsert: (notes: FootnoteWithIndex[]) => void;
22
26
  onCancel: () => void;
23
27
  }>;
@@ -16,6 +16,6 @@
16
16
  /// <reference types="react" />
17
17
  export declare const useDropdown: () => {
18
18
  isOpen: boolean;
19
- toggleOpen: () => void;
19
+ toggleOpen: (e: any) => void;
20
20
  wrapperRef: import("react").RefObject<HTMLDivElement>;
21
21
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "1.8.0-LEAN-3423-3",
4
+ "version": "1.8.1-LEAN-3429-0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@manuscripts/assets": "^0.6.4",
36
- "@manuscripts/json-schema": "2.2.6-LEAN-3423-0",
37
- "@manuscripts/transform": "2.1.8-LEAN-3423-0",
36
+ "@manuscripts/json-schema": "^2.2.6",
37
+ "@manuscripts/transform": "^2.1.6",
38
38
  "@reach/tabs": "^0.18.0",
39
39
  "date-fns": "^2.29.3",
40
40
  "formik": "^2.2.9",