@simoncomputing/mui-bueno-v2 0.14.7

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 (87) hide show
  1. package/CHANGELOG.md +1206 -0
  2. package/README.md +35 -0
  3. package/dist/@types/index.d.ts +192 -0
  4. package/dist/common/Utils/index.d.ts +65 -0
  5. package/dist/common/WindowDimensions/WindowDimensions.d.ts +26 -0
  6. package/dist/components/Alerts/Alert.d.ts +30 -0
  7. package/dist/components/Alerts/ErrorAlert.d.ts +4 -0
  8. package/dist/components/Alerts/InfoAlert.d.ts +4 -0
  9. package/dist/components/Alerts/SuccessAlert.d.ts +4 -0
  10. package/dist/components/Alerts/WarningAlert.d.ts +4 -0
  11. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +10 -0
  12. package/dist/components/Buttons/Button/Button.d.ts +24 -0
  13. package/dist/components/Buttons/ScrollToTop/ScrollToTop.d.ts +14 -0
  14. package/dist/components/Buttons/Submit/Submit.d.ts +11 -0
  15. package/dist/components/Form/Error/Error.d.ts +23 -0
  16. package/dist/components/Form/FormDebugger/FormDebugger.d.ts +8 -0
  17. package/dist/components/Form/Inputs/Autocomplete/Autocomplete.d.ts +81 -0
  18. package/dist/components/Form/Inputs/Autocomplete/DynamicAutocomplete/DynamicAutocomplete.d.ts +31 -0
  19. package/dist/components/Form/Inputs/Autocomplete/MultiAutocomplete/MultiAutocomplete.d.ts +22 -0
  20. package/dist/components/Form/Inputs/Autocomplete/utils.d.ts +2 -0
  21. package/dist/components/Form/Inputs/Checkbox/Checkbox.d.ts +58 -0
  22. package/dist/components/Form/Inputs/CheckboxGroup/CheckboxGroup.d.ts +107 -0
  23. package/dist/components/Form/Inputs/CitationField/CitationBubbleMenuHandler.d.ts +43 -0
  24. package/dist/components/Form/Inputs/CitationField/CitationField.d.ts +89 -0
  25. package/dist/components/Form/Inputs/CitationField/CitationFieldContext/CitationFieldContext.d.ts +9 -0
  26. package/dist/components/Form/Inputs/CitationField/CitationFieldContext/CitationFieldProvider.d.ts +8 -0
  27. package/dist/components/Form/Inputs/CitationField/CitationMenu/AttachmentForm.d.ts +12 -0
  28. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationBubbleMenu.d.ts +27 -0
  29. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationForm.d.ts +11 -0
  30. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationMenu.d.ts +78 -0
  31. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationTable.d.ts +21 -0
  32. package/dist/components/Form/Inputs/CitationField/CitationNode.d.ts +2 -0
  33. package/dist/components/Form/Inputs/CitationField/CitationNodeComponent.d.ts +7 -0
  34. package/dist/components/Form/Inputs/CitationField/CitationRefreshContext/CitationRefreshContext.d.ts +29 -0
  35. package/dist/components/Form/Inputs/CitationField/MenuButtonEditCitation.d.ts +3 -0
  36. package/dist/components/Form/Inputs/DateField/DateField.d.ts +73 -0
  37. package/dist/components/Form/Inputs/DateField/DateRangeField/DateRangeField.d.ts +62 -0
  38. package/dist/components/Form/Inputs/DateField/dayjs-utils.d.ts +2 -0
  39. package/dist/components/Form/Inputs/FileUpload/FileList/FileList.d.ts +13 -0
  40. package/dist/components/Form/Inputs/FileUpload/FileUpload.d.ts +62 -0
  41. package/dist/components/Form/Inputs/Location/Location.d.ts +69 -0
  42. package/dist/components/Form/Inputs/Location/Location.types.d.ts +85 -0
  43. package/dist/components/Form/Inputs/Location/LocationOption.d.ts +38 -0
  44. package/dist/components/Form/Inputs/RadioGroup/RadioGroup.d.ts +119 -0
  45. package/dist/components/Form/Inputs/RangeSlider/RangeSlider.d.ts +34 -0
  46. package/dist/components/Form/Inputs/RichTextField/RichTextControls.d.ts +6 -0
  47. package/dist/components/Form/Inputs/RichTextField/RichTextField.d.ts +56 -0
  48. package/dist/components/Form/Inputs/RichTextField/SuggestionList.d.ts +8 -0
  49. package/dist/components/Form/Inputs/RichTextField/mentionSuggestionOptions.d.ts +6 -0
  50. package/dist/components/Form/Inputs/RichTextField/useExtensions.d.ts +10 -0
  51. package/dist/components/Form/Inputs/SearchField/SearchField.d.ts +16 -0
  52. package/dist/components/Form/Inputs/Select/Select.d.ts +91 -0
  53. package/dist/components/Form/Inputs/Switch/Switch.d.ts +61 -0
  54. package/dist/components/Form/Inputs/TextField/TextField.d.ts +60 -0
  55. package/dist/components/Form/RepeatableFormGroup/RepeatableFormGroup.d.ts +89 -0
  56. package/dist/components/Form/Stepper/Stepper.d.ts +27 -0
  57. package/dist/components/LoadingIndicator/LoadingIndicator.d.ts +22 -0
  58. package/dist/components/Modals/AlertModal/AlertModal.d.ts +11 -0
  59. package/dist/components/Modals/ConfirmationModal/ConfirmationModal.d.ts +26 -0
  60. package/dist/components/Modals/DecisionModal/DecisionModal.d.ts +37 -0
  61. package/dist/components/Modals/Modal.d.ts +45 -0
  62. package/dist/components/Navigation/Footer/Footer.d.ts +31 -0
  63. package/dist/components/Navigation/Header/DarkModeToggle/DarkModeToggle.d.ts +13 -0
  64. package/dist/components/Navigation/Header/Drawer.d.ts +18 -0
  65. package/dist/components/Navigation/Header/EnvironmentBanner.d.ts +4 -0
  66. package/dist/components/Navigation/Header/Header.d.ts +63 -0
  67. package/dist/components/Navigation/Header/ProfileMenu.d.ts +8 -0
  68. package/dist/components/Navigation/MenuButton/MenuButton.d.ts +9 -0
  69. package/dist/components/Navigation/NavBar/FloatingNavBar/FloatingNavBar.d.ts +24 -0
  70. package/dist/components/Navigation/NavBar/NavBar.d.ts +24 -0
  71. package/dist/components/Navigation/Sidebar/Sidebar.d.ts +14 -0
  72. package/dist/components/Navigation/Tabs/Tabs.d.ts +19 -0
  73. package/dist/components/PageHeader/PageHeader.d.ts +27 -0
  74. package/dist/components/SingleActionCard/SingleActionCard.d.ts +26 -0
  75. package/dist/components/Snackbar/Snackbar.d.ts +28 -0
  76. package/dist/components/Table/ExpandableRow/ExpandableRow.d.ts +16 -0
  77. package/dist/components/Table/PaginatedTable.d.ts +44 -0
  78. package/dist/components/Table/Table.d.ts +129 -0
  79. package/dist/index.cjs.js +402 -0
  80. package/dist/index.css +1 -0
  81. package/dist/index.d.ts +105 -0
  82. package/dist/index.es.js +60187 -0
  83. package/dist/index.umd.js +403 -0
  84. package/dist/styles/3-theme/ThemeDemo.d.ts +3 -0
  85. package/dist/styles/3-theme/theme.d.ts +8 -0
  86. package/dist/styles/theme.d.ts +33 -0
  87. package/package.json +138 -0
@@ -0,0 +1,58 @@
1
+ import { CheckboxProps as MuiCheckboxProps, TypographyProps } from '@mui/material';
2
+ import * as React from 'react';
3
+ type BaseCheckboxProps = {
4
+ /**
5
+ * Must match a key from initialValues in Formik.
6
+ * @required
7
+ */
8
+ name: string;
9
+ /**
10
+ * The label for the checkbox.
11
+ * @recommended
12
+ */
13
+ label?: string;
14
+ /**
15
+ * Optional, additional label that appears below `label` and provides additional
16
+ * context, if necessary.
17
+ */
18
+ sublabel?: string;
19
+ /**
20
+ * Where the label is placed in relation to the box.
21
+ * @default 'end'
22
+ */
23
+ labelPlacement?: 'start' | 'end' | 'top' | 'bottom';
24
+ /**
25
+ * Vertical alignment of the label with respect to the checkbox. This is mainly for longer labels, or checkboxes with sublabels.
26
+ * Only applied when `labelPlacement` is 'start' or 'end'.
27
+ *
28
+ * Center: Verticaly aligns the checkbox with the center of the label (& sublabel)
29
+ *
30
+ * Top: Vertically aligns the checkbox with the first line of the label
31
+ *
32
+ * Defaults to 'top' when labelPlacement is 'start' | 'end. Otherwise, defaults to 'center'.
33
+ * @default 'top'
34
+ */
35
+ labelAlignment?: 'center' | 'top';
36
+ /**
37
+ * If true, an asterisk will be displayed next to the label
38
+ * Most browsers will automatically validate this, but it's recommended to also
39
+ * have Formik also validate as well so that `Error` displays for consistency.
40
+ * @default false
41
+ */
42
+ required?: boolean;
43
+ /**
44
+ * If set, this component is read only and will only display if the checkbox is checked.
45
+ */
46
+ readOnly?: boolean;
47
+ /**
48
+ * Props from MUI-Bueno's Typography component.
49
+ * Used to customize the label when the static label option is selected or the field is readOnly.
50
+ */
51
+ staticLabelProps?: TypographyProps;
52
+ };
53
+ export type CheckboxProps = BaseCheckboxProps & Omit<MuiCheckboxProps, 'checked' | 'name'>;
54
+ /**
55
+ * `Checkbox` provides a Material-UI Checkbox.
56
+ */
57
+ export declare const Checkbox: React.FC<CheckboxProps>;
58
+ export {};
@@ -0,0 +1,107 @@
1
+ import { TypographyProps } from '@mui/material';
2
+ import { CheckboxOption } from '../../../../@types';
3
+ export type CheckboxGroupProps = {
4
+ /**
5
+ * Name and ID of the component. It should match a key in initialValues.
6
+ * @required
7
+ */
8
+ name: string;
9
+ /**
10
+ * Label for the checkbox group.
11
+ * @recommended
12
+ * @default props.name
13
+ */
14
+ label?: string;
15
+ /**
16
+ * Array of labels for the checkboxes in the group
17
+ * @recommended
18
+ */
19
+ checkboxes?: CheckboxOption[];
20
+ /**
21
+ * Disables all checkboxes.
22
+ * @default false
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * If true, the label above the checkboxes is disabled.
27
+ */
28
+ disableLabel?: boolean;
29
+ /**
30
+ * If true, the label of the the checkbox group will not be displayed in an error state if there are errors present.
31
+ */
32
+ disableRedLabelOnError?: boolean;
33
+ /**
34
+ * If true, causes the label to enter a focused state.
35
+ */
36
+ focused?: boolean;
37
+ /**
38
+ * Location of the label with respect to the checkboxes
39
+ * @default 'end'
40
+ */
41
+ labelPlacement?: 'top' | 'start' | 'bottom' | 'end';
42
+ /**
43
+ * Vertical alignment of the label with respect to the checkboxes. This is mainly for longer labels, or checkboxes with sublabels.
44
+ * Only applied when `labelPlacement` is 'start' or 'end'.
45
+ *
46
+ * Center: Verticaly aligns the checkbox with the center of the label (& sublabel)
47
+ *
48
+ * Top: Vertically aligns the checkbox with the first line of the label
49
+ *
50
+ * Defaults to 'top' when labelPlacement is 'start' | 'end. Otherwise, defaults to 'center'.
51
+ * @default 'top'
52
+ */
53
+ labelAlignment?: 'center' | 'top';
54
+ /**
55
+ * If true, an asterisk will be displayed next to the label
56
+ * Most browsers will automatically validate this, but it's recommended to also
57
+ * have Formik also validate as well so that `Error` displays for consistency.
58
+ * @default false
59
+ */
60
+ required?: boolean;
61
+ /**
62
+ * If `true`, the component becomes readonly.
63
+ * @default false
64
+ */
65
+ readOnly?: boolean;
66
+ /**
67
+ * If set, the user can select up to `max` options
68
+ */
69
+ max?: number;
70
+ /**
71
+ * If set, the user must select, at minimum, `min` options
72
+ */
73
+ min?: number;
74
+ /**
75
+ * If set, this subtitle is displayed under the label to notify the user of how many options they can select max.
76
+ * @default `Up to ${max} max`
77
+ */
78
+ maxSubtitle?: string;
79
+ /**
80
+ * If set, this subtitle is displayed under the label to notify the user of how many options they can select minimum.
81
+ * @requires min
82
+ * @default `Please select ${min} or more`
83
+ */
84
+ minSubtitle?: string;
85
+ /**
86
+ * If set, this subtitle is displayed under the label to notify the user of how many options they can select within a range.
87
+ * @requires min
88
+ * @requires max
89
+ * @default `Please select between ${min} and ${max} options`
90
+ */
91
+ minMaxSubtitle?: string;
92
+ /**
93
+ * Margin for the FormControl
94
+ */
95
+ margin?: 'dense' | 'none' | 'normal';
96
+ /**
97
+ * Props from MUI-Bueno's Typography component.
98
+ * Used to customize the label when the static label option is selected or the field is readOnly.
99
+ */
100
+ staticLabelProps?: TypographyProps;
101
+ };
102
+ /**
103
+ * CheckboxGroup produces a group of checkboxes that's defined as an array of strings or Checkboxes.
104
+ *
105
+ * This component is ideal for limited options. For more than 4 options, use a MultiAutocomplete instead.
106
+ */
107
+ export declare const CheckboxGroup: (props: CheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { CitationBubbleMenuProps } from './CitationMenu/CitationBubbleMenu';
3
+ declare module '@tiptap/core' {
4
+ interface Commands<ReturnType> {
5
+ citation: {
6
+ /**
7
+ * Open/show the link bubble menu. Create a link if one doesn't exist at
8
+ * the current cursor selection, or edit the existing link if there is
9
+ * already a link at the current selection.
10
+ *
11
+ * If the options are provided, they're used to override the bubble menu
12
+ * props, which can be useful for specific positioning needs. Each call to
13
+ * `openLinkBubbleMenu` will reset the options based on the provided
14
+ * argument, falling back to default behavior if not provided.
15
+ *
16
+ * For instance, if the anchorEl option is provided, it overrides the
17
+ * anchor point for positioning the bubble menu. (The default anchorEl for
18
+ * LinkBubbleMenu is to anchor to the location in the editor content where
19
+ * the link appears or will appear.)
20
+ */
21
+ openCitationBubbleMenu: (options?: Partial<CitationBubbleMenuProps>, selectedNodePos?: number) => ReturnType;
22
+ /** Close/hide the link bubble menu, canceling any ongoing edits. */
23
+ closeCitationBubbleMenu: () => ReturnType;
24
+ };
25
+ }
26
+ }
27
+ export type CitationBubbleMenuHandlerStorage = {
28
+ isOpen: boolean;
29
+ selectedIds: number[];
30
+ bubbleMenuOptions: Partial<CitationBubbleMenuProps> | undefined;
31
+ selectedNodePos: number | undefined;
32
+ };
33
+ /**
34
+ * To be used in conjunction with the `CitationBubbleMenuTipTap` component, as this
35
+ * extension provides editor commands to control the state of the link bubble
36
+ * menu.
37
+ *
38
+ * The Tiptap Link extension (@tiptap/extension-link) should also be installed
39
+ * and included in your extensions when using CitationBubbleMenuHandler:
40
+ * https://tiptap.dev/api/marks/link.
41
+ */
42
+ declare const CitationBubbleMenuHandler: () => Extension<undefined, CitationBubbleMenuHandlerStorage>;
43
+ export default CitationBubbleMenuHandler;
@@ -0,0 +1,89 @@
1
+ import { Citation, PageState, PageResponse, UnsavedCitation, UnsavedAttachment } from '../../../../@types';
2
+ export type CitationFieldProps = {
3
+ /**
4
+ * Name and ID of the component. Must match a key from initialValues in Formik.
5
+ * @required
6
+ */
7
+ name: string;
8
+ /**
9
+ * (Optional) Label. NOTE: this won't be floating, it's always static.
10
+ */
11
+ label?: string;
12
+ /**
13
+ * If `true`, the component becomes readonly.
14
+ * @default false
15
+ */
16
+ readOnly?: boolean;
17
+ /**
18
+ * If true, an asterisk will be displayed next to the label
19
+ * @default false
20
+ */
21
+ required?: boolean;
22
+ /**
23
+ * By default, the label is auto-generated via `name`, even if you don't specify a label. If you don't want a label,
24
+ * set hideLabel to true.
25
+ */
26
+ hideLabel?: boolean;
27
+ /**
28
+ * Margin for the FormControl
29
+ */
30
+ margin?: 'dense' | 'none' | 'normal';
31
+ /**
32
+ * API call for fetching paginated citations. These will populate the "Insert Citation/Attachment(s)" table.
33
+ *
34
+ * If an error occurs during the API call, notify the user then throw the error so that
35
+ * Mui Bueno can handle updating state.
36
+ */
37
+ fetchExistingCitations: (req: PageState) => Promise<PageResponse<Citation>>;
38
+ /**
39
+ * API call for creating a new citation/attachment.
40
+ *
41
+ * If an error occurs during the API call, notify the user then throw the error so that
42
+ * Mui Bueno can handle updating state.
43
+ */
44
+ onCreateCitation: (citation: UnsavedCitation) => Promise<Citation>;
45
+ /**
46
+ * API call for updating a citation/attachment.
47
+ *
48
+ * If an error occurs during the API call, notify the user then throw the error so that
49
+ * Mui Bueno can handle updating state.
50
+ */
51
+ onUpdateCitation: (citation: Citation) => Promise<Citation>;
52
+ /**
53
+ * API call for retrieving a citation by id
54
+ *
55
+ * If an error occurs during the API call, notify the user then throw the error so that
56
+ * Mui Bueno can handle updating state.
57
+ */
58
+ getCitationById: (id: number) => Promise<Citation>;
59
+ /**
60
+ * API call for storing an attachment (ex. in an s3 bucket)
61
+ *
62
+ * If an error occurs during the API call, notify the user then throw the error so that
63
+ * Mui Bueno can handle updating state.
64
+ */
65
+ onStoreAttachment: (citation: UnsavedAttachment) => Promise<Citation>;
66
+ /**
67
+ * API call for retrieving an array citations by an array ids
68
+ *
69
+ * If an error occurs during the API call, notify the user then throw the error so that
70
+ * Mui Bueno can handle updating state.
71
+ */
72
+ getCitationsByIds: (ids: number[]) => Promise<Citation[]>;
73
+ /**
74
+ * Error callback.
75
+ *
76
+ * NOTE: All errors are handled internally, so this prop is mainly intended to
77
+ * help debug issues so developers can see specific details about an error.
78
+ */
79
+ onError?: (err: string) => void;
80
+ };
81
+ /**
82
+ * Rich Text field -- uses MUI Tip Tap
83
+ *
84
+ * Formik -- This field cannot be completely controlled, so keep in mind that the Formik value will not update until the field
85
+ * __loses focus__. This is to prevent issues with converting from rich text to HTML as the user types as it could override
86
+ * their changes unintentionally.
87
+ */
88
+ export declare const CitationField: (props: CitationFieldProps) => import("react/jsx-runtime").JSX.Element;
89
+ export default CitationField;
@@ -0,0 +1,9 @@
1
+ import { Citation } from '../../../../../@types';
2
+ interface SyncContextType {
3
+ citations: Citation[];
4
+ resync: () => void;
5
+ addUpdateCitation: (citation: Citation) => void;
6
+ }
7
+ export declare const SyncContext: import('react').Context<SyncContextType | undefined>;
8
+ export declare const useCitationSync: () => SyncContextType;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ import { Citation } from '../../../../../@types';
3
+ type CitationFieldProviderProps = {
4
+ children: React.ReactNode;
5
+ fetchExistingCitations: () => Promise<Citation[]>;
6
+ };
7
+ export declare const CitationFieldProvider: React.FC<CitationFieldProviderProps>;
8
+ export {};
@@ -0,0 +1,12 @@
1
+ import { Citation, UnsavedAttachment } from '../../../../../@types';
2
+ import { CitationMenuError } from './CitationMenu';
3
+ export type NewAttachmentFormProps = {
4
+ id?: number;
5
+ onSave: (citation: UnsavedAttachment, isTitleChanged: boolean) => Promise<void>;
6
+ onCancel: () => void;
7
+ getCitationById: (id: number) => Promise<Citation>;
8
+ disableFileUpload?: boolean;
9
+ setError: React.Dispatch<React.SetStateAction<CitationMenuError | undefined>>;
10
+ };
11
+ declare const NewAttachmentForm: (props: NewAttachmentFormProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default NewAttachmentForm;
@@ -0,0 +1,27 @@
1
+ import { Except } from 'type-fest';
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'> & {
5
+ onChanged?: (ids: number[]) => void;
6
+ };
7
+ /**
8
+ * TipTap Wrapper for CitationMenu so that it renders as a bubble/pop-up menu integrated
9
+ * with TipTap
10
+ *
11
+ * A component that renders a bubble menu when viewing, creating, or editing a
12
+ * link. Requires the mui-tiptap CitationBubbleMenuHandler extension and Tiptap's
13
+ * Link extension (@tiptap/extension-link, https://tiptap.dev/api/marks/link) to
14
+ * both be included in your editor `extensions` array.
15
+ *
16
+ * Pairs well with the `<MenuButtonEditLink />` component.
17
+ *
18
+ * If you're using `RichTextEditor`, include this component via
19
+ * `RichTextEditor`’s `children` render-prop. Otherwise, include the
20
+ * `LinkBubbleMenu` as a child of the component where you call `useEditor` and
21
+ * render your `RichTextField` or `RichTextContent`. (The bubble menu itself
22
+ * will be positioned appropriately no matter where you put it in your React
23
+ * tree, as long as it is re-rendered whenever the Tiptap `editor` forces an
24
+ * update, which will happen if it's a child of the component using
25
+ * `useEditor`).
26
+ */
27
+ export default function CitationBubbleMenuTipTap({ fetchExistingCitations, onCreateCitation, onUpdateCitation, getCitationById, onStoreAttachment, onTitleChanged, ...controlledBubbleMenuProps }: CitationBubbleMenuProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ import { Citation, UnsavedCitation } from '../../../../../@types';
2
+ import { CitationMenuError } from './CitationMenu';
3
+ export type NewCitationFormProps = {
4
+ id?: number;
5
+ onSave: (citation: UnsavedCitation, isTitleChanged: boolean) => Promise<void>;
6
+ onCancel: () => void;
7
+ getCitationById: (id: number) => Promise<Citation>;
8
+ setError: React.Dispatch<React.SetStateAction<CitationMenuError | undefined>>;
9
+ };
10
+ declare const NewCitationForm: (props: NewCitationFormProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default NewCitationForm;
@@ -0,0 +1,78 @@
1
+ import { Citation, PageState, PageResponse, UnsavedCitation, UnsavedAttachment } from '../../../../../@types';
2
+ export interface CitationMenuProps {
3
+ /**
4
+ * API call for fetching citations. These will populate the "Insert Citation/Attachment(s)" table.
5
+ */
6
+ fetchExistingCitations: (req: PageState) => Promise<PageResponse<Citation>>;
7
+ /**
8
+ * API call for creating a new citation/attachment.
9
+ */
10
+ onCreateCitation: (citation: UnsavedCitation) => Promise<Citation>;
11
+ /**
12
+ * API call for updating a citation/attachment.
13
+ */
14
+ onUpdateCitation: (citation: Citation) => Promise<Citation>;
15
+ /**
16
+ * API call for retrieving a citation by id
17
+ */
18
+ getCitationById: (id: number) => Promise<Citation>;
19
+ /**
20
+ * API call for storing an attachment (ex. in an s3 bucket)
21
+ */
22
+ onStoreAttachment: (citation: UnsavedAttachment) => Promise<Citation>;
23
+ /**
24
+ * Set which citations should be pre-checked in the citations table when this component is first rendered (used
25
+ * to initialize useState).
26
+ */
27
+ initialSelectedIds?: number[];
28
+ /**
29
+ * Callback for when the user clicks the "Select" button. This passes an array of selected citations
30
+ * that the user chose to the parent component.
31
+ */
32
+ onSelectCitations: (citationIds: number[]) => void;
33
+ /**
34
+ * Callback for when the user clicks the "Cancel" button. If you're using a modal, close your modal here.
35
+ */
36
+ onCancel: () => void;
37
+ /**
38
+ * Callback whenever the size of the content potentially changes. Use this if you're using something like
39
+ * a Popper, so that it can reposition itself when the dimensions of its content changes.
40
+ *
41
+ * 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
+ */
43
+ onContentUpdate?: () => void;
44
+ /**
45
+ * Optional callback, used to notify parent that the user has changed their Citation's title.
46
+ */
47
+ onTitleChanged?: (citation: Citation) => void;
48
+ /**
49
+ * Error callback.
50
+ *
51
+ * NOTE: All errors are handled internally, so this prop is mainly intended to
52
+ * help debug issues so developers can see specific details about an error.
53
+ */
54
+ onError?: (err: string) => void;
55
+ }
56
+ /**
57
+ * Error for CitationMenu
58
+ * title = human-friendly/shortened version of the error (ex. "Failed to create citation")
59
+ * err = the actual error thrown by the exception that was caught
60
+ */
61
+ export type CitationMenuError = {
62
+ title: string;
63
+ err: string;
64
+ };
65
+ export declare enum CitationMenuState {
66
+ CITATIONS_TABLE = "Insert Citation/Attachment(s)",
67
+ ADD_CITATION = "Add Citation",
68
+ EDIT_CITATION = "Edit Citation",
69
+ ADD_ATTACHMENT = "Add Attachment",
70
+ EDIT_ATTACHMENT = "Edit Attachment"
71
+ }
72
+ /**
73
+ * CitationMenu handles creating, updating, and selecting citations.
74
+ *
75
+ * Intended to be used within a bubble/pop-up/modal/dialog. For in-line citations, see CitationField instead.
76
+ */
77
+ export declare function CitationMenu({ fetchExistingCitations, onCreateCitation, onUpdateCitation, getCitationById, onStoreAttachment, onSelectCitations, onCancel, initialSelectedIds, onContentUpdate, onTitleChanged, onError, }: CitationMenuProps): import("react/jsx-runtime").JSX.Element;
78
+ export default CitationMenu;
@@ -0,0 +1,21 @@
1
+ import { PageState, PageResponse, Citation } from '../../../../../@types';
2
+ export type CitationTableProps = {
3
+ onCancel: () => void;
4
+ onNewCitation: () => void;
5
+ onNewAttachment: () => void;
6
+ onEditCitation: (citation: Citation) => void;
7
+ onEditAttachment: (citation: Citation) => void;
8
+ onSelect: (selectedIds: number[]) => void;
9
+ fetchExistingCitations: (req: PageState) => Promise<PageResponse<Citation>>;
10
+ selectedIds: number[];
11
+ toggleCheckbox: (citation: Citation) => void;
12
+ /**
13
+ * Error callback.
14
+ *
15
+ * NOTE: All errors are handled internally, so this prop is mainly intended to
16
+ * help debug issues so developers can see specific details about an error.
17
+ */
18
+ onError?: (err: string) => void;
19
+ };
20
+ declare const CitationTable: (props: CitationTableProps) => import("react/jsx-runtime").JSX.Element;
21
+ export default CitationTable;
@@ -0,0 +1,2 @@
1
+ import { Node } from '@tiptap/core';
2
+ export declare const CitationNode: Node<any, any>;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ import { NodeViewProps } from '@tiptap/react';
3
+ /**
4
+ * Handles API fetch for CitationNode in order to dynamically load the title, based on a citation's id
5
+ */
6
+ declare const CitationNodeComponent: React.FC<NodeViewProps>;
7
+ export default CitationNodeComponent;
@@ -0,0 +1,29 @@
1
+ import { Citation } from '../../../../../@types';
2
+ type CitationRefreshProviderProps = {
3
+ /**
4
+ * CitationField(s)
5
+ */
6
+ children: React.ReactNode;
7
+ /**
8
+ * array of unqiue ids of citations currently being referenced in the editor
9
+ */
10
+ citationIds: number[];
11
+ /**
12
+ * API call for fetching citations. Triggered internally when citationIds changes.
13
+ */
14
+ getCitationsByIds: (ids: number[]) => Promise<Citation[]>;
15
+ /**
16
+ * Id of the citation that had a title changed. Used internally to determine whether or
17
+ * not to trigger an API refresh of the citation list.
18
+ */
19
+ titleChangedId: number | undefined;
20
+ };
21
+ export declare function CitationRefreshProvider({ children, citationIds, getCitationsByIds, titleChangedId, }: CitationRefreshProviderProps): import("react/jsx-runtime").JSX.Element;
22
+ export declare const useCitationRefreshContext: () => {
23
+ /**
24
+ * Array of ALL UNIQUE citations being referenced in the editor.
25
+ * (Not to be confused with table of citations in the bubble menu -- this is only the citations actually in the editor itself)
26
+ */
27
+ citations: Citation[];
28
+ };
29
+ export {};
@@ -0,0 +1,3 @@
1
+ import { MenuButtonProps } from 'mui-tiptap';
2
+ export type MenuButtonEditCitationProps = Partial<MenuButtonProps>;
3
+ export default function MenuButtonEditCitation(props: MenuButtonEditCitationProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,73 @@
1
+ import { TypographyProps } from '@mui/material';
2
+ import { DateFieldProps as MuiDateFieldProps } from '@mui/x-date-pickers/DateField';
3
+ import { Dayjs } from 'dayjs';
4
+ import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
5
+ import { DateValidationError, PickerChangeHandlerContext } from '@mui/x-date-pickers';
6
+ import * as React from 'react';
7
+ type BaseDateFieldProps = {
8
+ /**
9
+ * Name and ID of the component. Must match a key from initialValues in Formik.
10
+ * @required
11
+ */
12
+ name: string;
13
+ /**
14
+ * Label for the Date field. `name` will be used if none is provided
15
+ */
16
+ label?: string;
17
+ /**
18
+ * If true, an asterisk will be displayed next to the labels
19
+ * Most browsers will automatically validate this, but it's recommended to also
20
+ * have Formik also validate as well so that `Error` displays for consistency.
21
+ * @default false
22
+ */
23
+ required?: boolean;
24
+ /**
25
+ * If `true`, the component becomes readonly.
26
+ * @default false
27
+ */
28
+ readOnly?: boolean;
29
+ /**
30
+ * Format of the date as shown to the user (not used internally)
31
+ */
32
+ format?: string;
33
+ /**
34
+ * Customize error messages for each key (maxDate, minDate, invalidDate, etc.)
35
+ */
36
+ errorMessages?: {
37
+ [key: string]: string;
38
+ };
39
+ /**
40
+ * If true, field will render as a Date Picker (Date Field w/ calendar) rather than a Date Field (no calendar, just input w/ mask)
41
+ */
42
+ isDatePicker?: boolean;
43
+ /**
44
+ * Margin for the FormControl
45
+ */
46
+ margin?: 'dense' | 'none' | 'normal';
47
+ /**
48
+ * If true, the prepackaged dynamic input label that comes with Material UI's input components
49
+ * will be replaced with a static typography label above the input.
50
+ * @default false
51
+ */
52
+ staticLabel?: boolean;
53
+ /**
54
+ * Props from MUI-Bueno's Typography component.
55
+ * Used to customize the label when the static label option is selected or the field is readOnly.
56
+ */
57
+ staticLabelProps?: TypographyProps;
58
+ onChange?: (val: string | undefined, context: PickerChangeHandlerContext<DateValidationError>) => void;
59
+ };
60
+ interface DateFieldOnlyProps extends BaseDateFieldProps, Omit<DatePickerProps<Dayjs>, 'label' | 'name' | 'onChange'> {
61
+ isDatePicker?: false;
62
+ }
63
+ interface DatePickerOnlyProps extends BaseDateFieldProps, Omit<MuiDateFieldProps<Dayjs>, 'label' | 'name' | 'onChange'> {
64
+ isDatePicker: true;
65
+ }
66
+ export type DateFieldProps = DateFieldOnlyProps | DatePickerOnlyProps;
67
+ /**
68
+ * Date Field with optional Picker
69
+ *
70
+ * Formik will use ISO dates (in UTC) internally as the value.
71
+ */
72
+ export declare const DateField: React.FC<DateFieldProps>;
73
+ export {};
@@ -0,0 +1,62 @@
1
+ import { DateFieldProps } from '../DateField';
2
+ import * as React from 'react';
3
+ type BaseDateRangeFieldProps = {
4
+ /**
5
+ * Name and ID of the "from" date field. Must match a key from initialValues in Formik.
6
+ * @required
7
+ */
8
+ nameFrom: string;
9
+ /**
10
+ * Name and ID of the "to" date field. Must match a key from initialValues in Formik.
11
+ * @required
12
+ */
13
+ nameTo: string;
14
+ /**
15
+ * Label for the `from` field.
16
+ */
17
+ labelFrom?: string;
18
+ /**
19
+ * Label for the `to` field.
20
+ */
21
+ labelTo?: string;
22
+ /**
23
+ * If true, an asterisk will be displayed next to the labels
24
+ * Most browsers will automatically validate this, but it's recommended to also
25
+ * have Formik also validate as well so that `Error` displays for consistency.
26
+ * @default false
27
+ */
28
+ required?: boolean;
29
+ /**
30
+ * If `true`, the component becomes readonly.
31
+ * @default false
32
+ */
33
+ readOnly?: boolean;
34
+ /**
35
+ * Format of the date (applies to both fields)
36
+ */
37
+ format?: string;
38
+ /**
39
+ * If true, calendar icon that displays an interactable calendar will appear when interacted with
40
+ */
41
+ isDatePicker?: boolean;
42
+ /**
43
+ * Props for the `from` field. Use this to apply props *only* to this field. To apply props to both, pass the prop directly on this component.
44
+ */
45
+ fromFieldProps?: DateFieldProps;
46
+ /**
47
+ * Props for the `to` field. Use this to apply props *only* to this field. To apply props to both, pass the prop directly on this component.
48
+ */
49
+ toFieldProps?: DateFieldProps;
50
+ /**
51
+ * If true, the prepackaged dynamic input label that comes with Material UI's input components
52
+ * will be replaced with a static typography label above the input.
53
+ * @default false
54
+ */
55
+ staticLabels?: boolean;
56
+ };
57
+ export type DateRangeFieldProps = BaseDateRangeFieldProps & Omit<DateFieldProps, 'label' | 'name' | 'isDatePicker' | 'format' | 'readOnly'>;
58
+ /**
59
+ * `DateRangeField` provides an input for a range of dates (2). For individual Date fields, see `DateField`.
60
+ */
61
+ export declare const DateRangeField: React.FC<DateRangeFieldProps>;
62
+ export {};
@@ -0,0 +1,2 @@
1
+ import { default as dayjs } from 'dayjs';
2
+ export default dayjs;