@simoncomputing/mui-bueno-v2 0.17.4 → 0.18.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.
Files changed (21) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/@types/index.d.ts +2 -0
  3. package/dist/components/Form/Inputs/CitationField/CitationBubbleMenuHandler.d.ts +1 -1
  4. package/dist/components/Form/Inputs/CitationField/CitationField.d.ts +10 -4
  5. package/dist/components/Form/Inputs/CitationField/CitationFieldContext/CitationFieldContext.d.ts +2 -1
  6. package/dist/components/Form/Inputs/CitationField/CitationFieldContext/CitationFieldProvider.d.ts +9 -0
  7. package/dist/components/Form/Inputs/CitationField/CitationManager/AttachmentForm.d.ts +13 -0
  8. package/dist/components/Form/Inputs/CitationField/{CitationMenu/CitationMenu.d.ts → CitationManager/BaseCitationManager.d.ts} +19 -17
  9. package/dist/components/Form/Inputs/CitationField/CitationManager/CitationAlert.d.ts +17 -0
  10. package/dist/components/Form/Inputs/CitationField/{CitationMenu → CitationManager}/CitationBubbleMenu.d.ts +4 -4
  11. package/dist/components/Form/Inputs/CitationField/{CitationMenu → CitationManager}/CitationForm.d.ts +3 -2
  12. package/dist/components/Form/Inputs/CitationField/CitationManager/CitationManager.d.ts +7 -0
  13. package/dist/components/Form/Inputs/CitationField/{CitationMenu → CitationManager}/CitationTable.d.ts +18 -3
  14. package/dist/components/Form/Inputs/CitationField/CitationManager/SelectableCitationManager.d.ts +9 -0
  15. package/dist/index.cjs.js +121 -121
  16. package/dist/index.d.ts +5 -2
  17. package/dist/index.es.js +15229 -14550
  18. package/dist/index.umd.js +122 -122
  19. package/dist/styles/3-theme/theme.d.ts +8 -0
  20. package/package.json +1 -1
  21. package/dist/components/Form/Inputs/CitationField/CitationMenu/AttachmentForm.d.ts +0 -12
package/CHANGELOG.md CHANGED
@@ -11,6 +11,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
  - Minor increment --> singlular/minor changes. Minimal breaking changes.
12
12
  - Patch increment --> singlular/minor changes. Zero breaking changes.
13
13
 
14
+ ## [0.18.0] - 2025-09-22
15
+
16
+ ### Added
17
+
18
+ - `TableColumn`
19
+ - Added `tableCellSx` styling `TableCell` in `Table` and/or `PaginatedTable`
20
+ - `CitationManager`:
21
+ - Basic table offering CRUD operations for citations. Replaces `CitationMenu`.
22
+ - `SelectableCitationManager`
23
+ - Condensed table offering CRUD operations for citations, including selecting citations. Intended to be used in modals/popups. Replaces `CitationMenu`.
24
+ - `CitationField`, `CitationManager`, `SelectableCitationManager`:
25
+ - added `onDownloadAttachment` prop to support downloading attachments
26
+
27
+ ### Changed
28
+
29
+ - `CitationField`, `CitationManager`, `SelectableCitationManager`:
30
+ - made `onDeleteCitation` prop optional
31
+
32
+ ### Removed
33
+
34
+ - `CitationMenu`
35
+ - Replaced with `CitationManager` & `SelectableCitationManager`. See `Added` section.
36
+
37
+ ## [0.17.5] - 2025-09-22
38
+
39
+ ### Added
40
+
41
+ - `CitationMenu`:
42
+ - added `renderAsSelectablePopup` prop
43
+
14
44
  ## [0.17.4] - 2025-09-16
15
45
 
16
46
  ### Changed
@@ -113,6 +113,7 @@ export type EnvironmentInfo = {
113
113
  * within the object. isMobile in case your styling depends on whether the user is viewing
114
114
  * on a phone vs tablet/desktop
115
115
  * @property {string} sortName - (Optional) Passed instead of `fieldName` to onSortChange(fieldName, ...). Useful if you're rendering the same object in 2+ columns and need a way to differentiate when sorting.
116
+ * @property {SxProps<Theme>} tableCellSx - (Optional) styles applies to TableCell (non-mobile)
116
117
  */
117
118
  export type TableColumn<T, K extends keyof T> = {
118
119
  key?: string;
@@ -120,6 +121,7 @@ export type TableColumn<T, K extends keyof T> = {
120
121
  fieldName: K;
121
122
  render?: (value: T[K], object: T, isMobile: boolean) => React.ReactNode;
122
123
  sortName?: string;
124
+ tableCellSx?: SxProps<Theme>;
123
125
  };
124
126
 
125
127
  // Sort order for Tables
@@ -1,5 +1,5 @@
1
1
  import { Extension } from '@tiptap/core';
2
- import { CitationBubbleMenuProps } from './CitationMenu/CitationBubbleMenu';
2
+ import { CitationBubbleMenuProps } from './CitationManager/CitationBubbleMenu';
3
3
  declare module '@tiptap/core' {
4
4
  interface Commands<ReturnType> {
5
5
  citationBubbleMenu: {
@@ -60,13 +60,17 @@ export type CitationFieldProps = {
60
60
  *
61
61
  * Error handling is supported internally.
62
62
  */
63
- onDeleteCitation: (id: number) => Promise<void>;
63
+ onDeleteCitation?: (id: number) => Promise<void>;
64
64
  /**
65
65
  * API call for retrieving a citation by id
66
66
  *
67
67
  * Error handling is supported internally.
68
68
  */
69
69
  getCitationById: (id: number) => Promise<Citation>;
70
+ /**
71
+ * API call to download the attachment
72
+ */
73
+ onDownloadAttachment?: (citation: Citation) => Promise<void>;
70
74
  /**
71
75
  * Error callback.
72
76
  *
@@ -78,9 +82,11 @@ export type CitationFieldProps = {
78
82
  /**
79
83
  * Rich Text field -- uses MUI Tip Tap
80
84
  *
81
- * Formik -- This field cannot be completely controlled, so keep in mind that the Formik value will not update until the field
82
- * __loses focus__. This is to prevent issues with converting from rich text to HTML as the user types as it could override
83
- * their changes unintentionally.
85
+ * IMPORTANT: As per Mui TipTap's documentation, it's not efficient to use it as a fully controlled component since the
86
+ * editor content has to be serialized to HTML (which is what is stored in Formik). Therefore, keep in mind that what is
87
+ * shown in the editor will not match the Formik value until the field __loses focus__.
88
+ *
89
+ * Recommended to use with `CitationFieldProvider` for cross-field synchronization.
84
90
  */
85
91
  export declare const CitationField: (props: CitationFieldProps) => import("react/jsx-runtime").JSX.Element;
86
92
  export default CitationField;
@@ -1,9 +1,10 @@
1
1
  import { Citation } from '../../../../../@types';
2
2
  interface SyncContextType {
3
3
  citations: Citation[];
4
- resync: () => void;
4
+ isLoaded: boolean;
5
5
  addUpdateCitation: (citation: Citation) => void;
6
6
  deleteCitation: (id: number) => void;
7
+ batchUpdate: (newCitations: Citation[]) => void;
7
8
  }
8
9
  export declare const SyncContext: import('react').Context<SyncContextType | undefined>;
9
10
  export declare const useCitationSync: () => SyncContextType;
@@ -4,5 +4,14 @@ type CitationFieldProviderProps = {
4
4
  children: React.ReactNode;
5
5
  getCitations: () => Promise<Citation[]>;
6
6
  };
7
+ /**
8
+ * CitationFieldProvider ensures `CitationField` stays in sync with other `CitationField` components. Always
9
+ * use when multiple `CitationField` components are on the same page.
10
+ *
11
+ * NOTE: The provider is optimized to reduce excessive API calls. Currently, it will only perform the inital full
12
+ * data fetch on initial load. Subsequent changes are updated locally based on what add/update/delete actions
13
+ * are made by the user, but any remote additions/updates/deletions will not be fetched. Keep this in mind when
14
+ * deciding what level to place the provider in your app so that you can control how often the provider is initialized.
15
+ */
7
16
  export declare const CitationFieldProvider: React.FC<CitationFieldProviderProps>;
8
17
  export {};
@@ -0,0 +1,13 @@
1
+ import { Citation, UnsavedAttachmentCitation } from '../../../../../@types';
2
+ import { CitationManagerError } from './CitationAlert';
3
+ export type AttachmentFormProps = {
4
+ id?: number;
5
+ title?: string;
6
+ onSave: (unsavedAttachment: UnsavedAttachmentCitation) => Promise<void>;
7
+ onCancel: () => void;
8
+ getCitationById: (id: number) => Promise<Citation>;
9
+ disableFileUpload?: boolean;
10
+ setError: React.Dispatch<React.SetStateAction<CitationManagerError | undefined>>;
11
+ };
12
+ declare const AttachmentForm: (props: AttachmentFormProps) => import("react/jsx-runtime").JSX.Element;
13
+ export default AttachmentForm;
@@ -1,5 +1,5 @@
1
1
  import { Citation, PageState, PageResponse, UnsavedCitation } from '../../../../../@types';
2
- export interface CitationMenuProps {
2
+ export interface BaseCitationManagerProps {
3
3
  /**
4
4
  * API call for fetching citations. These will populate the "Insert Citation/Attachment(s)" table.
5
5
  */
@@ -15,11 +15,15 @@ export interface CitationMenuProps {
15
15
  /**
16
16
  * API call for deleting a citation/attachment.
17
17
  */
18
- onDeleteCitation: (id: number) => Promise<void>;
18
+ onDeleteCitation?: (id: number) => Promise<void>;
19
19
  /**
20
20
  * API call for retrieving a citation by id
21
21
  */
22
22
  getCitationById: (id: number) => Promise<Citation>;
23
+ /**
24
+ * API call to download the attachment
25
+ */
26
+ onDownloadAttachment?: (citation: Citation) => Promise<void>;
23
27
  /**
24
28
  * Set which citations should be pre-checked in the citations table when this component is first rendered (used
25
29
  * to initialize useState).
@@ -40,7 +44,7 @@ export interface CitationMenuProps {
40
44
  *
41
45
  * Currently, this will be called when the data in the citations table changes, and when the content itself changes (ex. clicks on "Add Citation")
42
46
  */
43
- onContentUpdate?: () => void;
47
+ onContentChange?: () => void;
44
48
  /**
45
49
  * Error callback.
46
50
  *
@@ -48,17 +52,13 @@ export interface CitationMenuProps {
48
52
  * help debug issues so developers can see specific details about an error.
49
53
  */
50
54
  onError?: (err: string) => void;
55
+ /**
56
+ * When true, the table will be rendered for pop-ups with the ability to select citations from the table.
57
+ * When false, teh table will be rendered as a basic paginated table with all columns displayed.
58
+ */
59
+ renderAsSelectablePopup?: boolean;
51
60
  }
52
- /**
53
- * Error for CitationMenu
54
- * title = human-friendly/shortened version of the error (ex. "Failed to create citation")
55
- * err = the actual error thrown by the exception that was caught
56
- */
57
- export type CitationMenuError = {
58
- title: string;
59
- err: string;
60
- };
61
- export declare enum CitationMenuState {
61
+ export declare enum CitationManagerState {
62
62
  CITATIONS_TABLE = "Insert Citation/Attachment(s)",
63
63
  ADD_CITATION = "Add Citation",
64
64
  EDIT_CITATION = "Edit Citation",
@@ -66,9 +66,11 @@ export declare enum CitationMenuState {
66
66
  EDIT_ATTACHMENT = "Edit Attachment"
67
67
  }
68
68
  /**
69
- * CitationMenu handles creating, updating, and selecting citations.
69
+ * BaseCitationManager handles creating, updating, deleting, downloading and selecting citations.
70
+ *
71
+ * INTERNAL COMPONENT. Use wrapper instead: `SelectableCitationManager` or `CitationManager`
70
72
  *
71
- * Intended to be used within a bubble/pop-up/modal/dialog. For in-line citations, see CitationField instead.
73
+ * For in-line citations, see CitationField instead.
72
74
  */
73
- export declare function CitationMenu({ getCitationsPaginated, onCreateCitation, onUpdateCitation, onDeleteCitation, getCitationById, onSelectCitations, onCancel, initialSelectedIds, onContentUpdate, onError, }: CitationMenuProps): import("react/jsx-runtime").JSX.Element;
74
- export default CitationMenu;
75
+ export declare function BaseCitationManager({ getCitationsPaginated, onCreateCitation, onUpdateCitation, onDeleteCitation, getCitationById, onDownloadAttachment, onSelectCitations, onCancel, initialSelectedIds, onContentChange, onError, renderAsSelectablePopup, }: BaseCitationManagerProps): import("react/jsx-runtime").JSX.Element;
76
+ export default BaseCitationManager;
@@ -0,0 +1,17 @@
1
+ type Props = {
2
+ error?: CitationManagerError;
3
+ setError: React.Dispatch<React.SetStateAction<CitationManagerError | undefined>>;
4
+ success?: string;
5
+ setSuccess: React.Dispatch<React.SetStateAction<string | undefined>>;
6
+ };
7
+ /**
8
+ * Error for BaseCitationManager, CitationManager & SelectableCitationManager
9
+ * title = human-friendly/shortened version of the error (ex. "Failed to create citation")
10
+ * err = the actual error thrown by the exception that was caught
11
+ */
12
+ export type CitationManagerError = {
13
+ title: string;
14
+ err: string;
15
+ };
16
+ declare const CitationAlert: (props: Props) => import("react/jsx-runtime").JSX.Element;
17
+ export default CitationAlert;
@@ -1,11 +1,11 @@
1
1
  import { Except } from 'type-fest';
2
2
  import { ControlledBubbleMenuProps } from 'mui-tiptap';
3
- import { CitationMenuProps } from './CitationMenu';
4
- export type CitationBubbleMenuProps = Partial<Except<ControlledBubbleMenuProps, 'open' | 'editor' | 'children'>> & Omit<CitationMenuProps, 'onCancel' | 'onSelectCitations'> & {
3
+ import { BaseCitationManagerProps } from './BaseCitationManager';
4
+ export type CitationBubbleMenuProps = Partial<Except<ControlledBubbleMenuProps, 'open' | 'editor' | 'children'>> & Omit<BaseCitationManagerProps, 'onCancel' | 'onSelectCitations'> & {
5
5
  onChanged?: (ids: number[]) => void;
6
6
  };
7
7
  /**
8
- * TipTap Wrapper for CitationMenu so that it renders as a bubble/pop-up menu integrated
8
+ * TipTap Wrapper for SelectableCitationManager so that it renders as a bubble/pop-up menu integrated
9
9
  * with TipTap
10
10
  *
11
11
  * A component that renders a bubble menu when viewing, creating, or editing a
@@ -24,4 +24,4 @@ export type CitationBubbleMenuProps = Partial<Except<ControlledBubbleMenuProps,
24
24
  * update, which will happen if it's a child of the component using
25
25
  * `useEditor`).
26
26
  */
27
- export default function CitationBubbleMenuTipTap({ getCitationsPaginated, onCreateCitation, onUpdateCitation, onDeleteCitation, getCitationById, ...controlledBubbleMenuProps }: CitationBubbleMenuProps): import("react/jsx-runtime").JSX.Element | null;
27
+ export default function CitationBubbleMenuTipTap({ getCitationsPaginated, onCreateCitation, onUpdateCitation, onDeleteCitation, getCitationById, onDownloadAttachment, ...controlledBubbleMenuProps }: CitationBubbleMenuProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,11 +1,12 @@
1
1
  import { Citation, UnsavedUrlCitation } from '../../../../../@types';
2
- import { CitationMenuError } from './CitationMenu';
2
+ import { CitationManagerError } from './CitationAlert';
3
3
  export type CitationFormProps = {
4
4
  id?: number;
5
+ title?: string;
5
6
  onSave: (unsavedUrl: UnsavedUrlCitation) => Promise<void>;
6
7
  onCancel: () => void;
7
8
  getCitationById: (id: number) => Promise<Citation>;
8
- setError: React.Dispatch<React.SetStateAction<CitationMenuError | undefined>>;
9
+ setError: React.Dispatch<React.SetStateAction<CitationManagerError | undefined>>;
9
10
  };
10
11
  declare const CitationForm: (props: CitationFormProps) => import("react/jsx-runtime").JSX.Element;
11
12
  export default CitationForm;
@@ -0,0 +1,7 @@
1
+ import { BaseCitationManagerProps } from './BaseCitationManager';
2
+ export type CitationManagerProps = Omit<BaseCitationManagerProps, 'initialSelectedIds' | 'onSelectCitations' | 'onCancel' | 'onContentChange' | 'renderAsSelectablePopup'>;
3
+ /**
4
+ * CitationManager is a basic table that handles creating, updating, and deleting citations.
5
+ */
6
+ export declare function CitationManager({ ...rest }: CitationManagerProps): import("react/jsx-runtime").JSX.Element;
7
+ export default CitationManager;
@@ -1,12 +1,14 @@
1
1
  import { PageState, PageResponse, Citation } from '../../../../../@types';
2
- import { CitationMenuError } from './CitationMenu';
2
+ import { CitationManagerError } from './CitationAlert';
3
3
  export type CitationTableProps = {
4
+ title: string;
4
5
  onCancel: () => void;
5
6
  onNewCitation: () => void;
6
7
  onNewAttachment: () => void;
7
8
  onEditCitation: (citation: Citation) => void;
8
9
  onEditAttachment: (citation: Citation) => void;
9
- onDeleteCitation: (id: number) => Promise<void>;
10
+ onDeleteCitation?: (id: number) => Promise<void>;
11
+ onDownloadAttachment?: (citation: Citation) => Promise<void>;
10
12
  onSelect: (selectedIds: number[]) => void;
11
13
  getCitationsPaginated: (req: PageState) => Promise<PageResponse<Citation>>;
12
14
  selectedIds: number[];
@@ -18,7 +20,20 @@ export type CitationTableProps = {
18
20
  * help debug issues so developers can see specific details about an error.
19
21
  */
20
22
  onError?: (err: string) => void;
21
- setError: React.Dispatch<React.SetStateAction<CitationMenuError | undefined>>;
23
+ setError: React.Dispatch<React.SetStateAction<CitationManagerError | undefined>>;
24
+ setSuccess: React.Dispatch<React.SetStateAction<string | undefined>>;
25
+ /**
26
+ * When true, the Source, Accessed At & Classification columns will not be displayed
27
+ * to preserve horizontal space.
28
+ */
29
+ condenseTable?: boolean;
30
+ /**
31
+ * When true, first column will be checkboxes, allowing users to select citations.
32
+ *
33
+ * Select/Cancel buttons will appear at the bottom of the component.
34
+ * NOTE: add buttons will move to the bottom of the component, inline with the Select/Cancel buttons.
35
+ */
36
+ canSelect?: boolean;
22
37
  };
23
38
  declare const CitationTable: (props: CitationTableProps) => import("react/jsx-runtime").JSX.Element;
24
39
  export default CitationTable;
@@ -0,0 +1,9 @@
1
+ import { BaseCitationManagerProps } from './BaseCitationManager';
2
+ export type SelectableCitationManagerProps = Omit<BaseCitationManagerProps, 'renderAsSelectablePopup'>;
3
+ /**
4
+ * SelectableCitationManager is a condensed table that handles creating, updating, deleting and selecting citations.
5
+ *
6
+ * It's intended to be used in a pop-up/modal.
7
+ */
8
+ export declare function SelectableCitationManager({ ...rest }: SelectableCitationManagerProps): import("react/jsx-runtime").JSX.Element;
9
+ export default SelectableCitationManager;