@simoncomputing/mui-bueno-v3 0.1.12

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 (92) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +33 -0
  3. package/dist/@types/index.d.ts +192 -0
  4. package/dist/common/TestUtils/reactHookForms.d.ts +54 -0
  5. package/dist/common/TestUtils/renderWithReactHookForm.d.ts +7 -0
  6. package/dist/common/Utils/index.d.ts +65 -0
  7. package/dist/common/WindowDimensions/WindowDimensions.d.ts +26 -0
  8. package/dist/components/Alerts/Alert.d.ts +30 -0
  9. package/dist/components/Alerts/ErrorAlert.d.ts +4 -0
  10. package/dist/components/Alerts/InfoAlert.d.ts +4 -0
  11. package/dist/components/Alerts/SuccessAlert.d.ts +4 -0
  12. package/dist/components/Alerts/WarningAlert.d.ts +4 -0
  13. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +10 -0
  14. package/dist/components/Buttons/Button/Button.d.ts +24 -0
  15. package/dist/components/Buttons/ScrollToTop/ScrollToTop.d.ts +14 -0
  16. package/dist/components/Buttons/Submit/Submit.d.ts +11 -0
  17. package/dist/components/Form/Error/Error.d.ts +23 -0
  18. package/dist/components/Form/FormDebugger/FormDebugger.d.ts +8 -0
  19. package/dist/components/Form/Inputs/Autocomplete/Autocomplete.d.ts +81 -0
  20. package/dist/components/Form/Inputs/Autocomplete/DynamicAutocomplete/DynamicAutocomplete.d.ts +31 -0
  21. package/dist/components/Form/Inputs/Autocomplete/MultiAutocomplete/MultiAutocomplete.d.ts +22 -0
  22. package/dist/components/Form/Inputs/Autocomplete/utils.d.ts +2 -0
  23. package/dist/components/Form/Inputs/Checkbox/Checkbox.d.ts +58 -0
  24. package/dist/components/Form/Inputs/CheckboxGroup/CheckboxGroup.d.ts +112 -0
  25. package/dist/components/Form/Inputs/CitationField/CitationBubbleMenuHandler.d.ts +43 -0
  26. package/dist/components/Form/Inputs/CitationField/CitationField.d.ts +78 -0
  27. package/dist/components/Form/Inputs/CitationField/CitationMenu/AttachmentForm.d.ts +13 -0
  28. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationBubbleMenu.d.ts +25 -0
  29. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationForm.d.ts +12 -0
  30. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationMenu.d.ts +62 -0
  31. package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationTable.d.ts +16 -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/MForm/MForm.d.ts +19 -0
  56. package/dist/components/Form/MForm/useMyForm.d.ts +1 -0
  57. package/dist/components/Form/RepeatableFormGroup/RepeatableFormGroup.d.ts +89 -0
  58. package/dist/components/Form/Stepper/Stepper.d.ts +27 -0
  59. package/dist/components/Layout/MGrid/MGrid.d.ts +13 -0
  60. package/dist/components/Layout/MPanel/MPanel.d.ts +13 -0
  61. package/dist/components/Layout/MStack/MStack.d.ts +6 -0
  62. package/dist/components/LoadingIndicator/LoadingIndicator.d.ts +22 -0
  63. package/dist/components/Modals/AlertModal/AlertModal.d.ts +11 -0
  64. package/dist/components/Modals/ConfirmationModal/ConfirmationModal.d.ts +26 -0
  65. package/dist/components/Modals/DecisionModal/DecisionModal.d.ts +37 -0
  66. package/dist/components/Modals/Modal.d.ts +45 -0
  67. package/dist/components/Navigation/Footer/Footer.d.ts +31 -0
  68. package/dist/components/Navigation/Header/DarkModeToggle/DarkModeToggle.d.ts +13 -0
  69. package/dist/components/Navigation/Header/Drawer.d.ts +18 -0
  70. package/dist/components/Navigation/Header/EnvironmentBanner.d.ts +4 -0
  71. package/dist/components/Navigation/Header/Header.d.ts +63 -0
  72. package/dist/components/Navigation/Header/ProfileMenu.d.ts +8 -0
  73. package/dist/components/Navigation/MenuButton/MenuButton.d.ts +9 -0
  74. package/dist/components/Navigation/NavBar/FloatingNavBar/FloatingNavBar.d.ts +24 -0
  75. package/dist/components/Navigation/NavBar/NavBar.d.ts +24 -0
  76. package/dist/components/Navigation/Sidebar/Sidebar.d.ts +14 -0
  77. package/dist/components/Navigation/Tabs/Tabs.d.ts +19 -0
  78. package/dist/components/PageHeader/PageHeader.d.ts +27 -0
  79. package/dist/components/SingleActionCard/SingleActionCard.d.ts +26 -0
  80. package/dist/components/Snackbar/Snackbar.d.ts +28 -0
  81. package/dist/components/Table/ExpandableRow/ExpandableRow.d.ts +16 -0
  82. package/dist/components/Table/PaginatedTable.d.ts +44 -0
  83. package/dist/components/Table/Table.d.ts +129 -0
  84. package/dist/index.cjs.js +410 -0
  85. package/dist/index.css +1 -0
  86. package/dist/index.d.ts +112 -0
  87. package/dist/index.es.js +63994 -0
  88. package/dist/index.umd.js +411 -0
  89. package/dist/styles/3-theme/ThemeDemo.d.ts +3 -0
  90. package/dist/styles/3-theme/theme.d.ts +16 -0
  91. package/dist/styles/theme.d.ts +33 -0
  92. package/package.json +140 -0
@@ -0,0 +1,31 @@
1
+ import { AutocompleteProps } from '../Autocomplete';
2
+ export type DynamicAutocompleteProps<T> = {
3
+ /**
4
+ * Execute your API call to retrieve your list of options
5
+ * @param searchInput Search string entered by the user
6
+ * @returns List of options T[]
7
+ */
8
+ onFilter: (searchInput: string) => Promise<T[]>;
9
+ /**
10
+ * Callback when `onFilter` fails
11
+ * @param error Error thrown by retrieving the list of options (onFilter)
12
+ */
13
+ onFilterError: (error: any) => void;
14
+ /**
15
+ * Fetches when the users input is at least `fetchOnCount` characters long. Default is 1. Recommend no larger than 3.
16
+ */
17
+ fetchOnCount?: number;
18
+ /**
19
+ * This message displays in the dropdown when the user input is empty, or less than `fetchOnCount` to let the
20
+ * user know they need to input more characters to get options back.
21
+ *
22
+ * @default the message defined in `noOptionsText` is used
23
+ */
24
+ preFilterMessage?: string;
25
+ } & Omit<AutocompleteProps<T>, 'options' | 'useFieldAsValue'>;
26
+ /**
27
+ * Like a normal Autocomplete, but filters the options as the user types (intended for server-side filtering).
28
+ *
29
+ * Useful when you have thousands of options, as it reduces the memory load and amount of data coming over the network.
30
+ */
31
+ export declare const DynamicAutocomplete: <T>(props: DynamicAutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { AutocompleteProps as MuiAutocompleteProps } from '@mui/material';
2
+ import { BaseAutocompleteProps } from '../Autocomplete';
3
+ /**
4
+ * Type used to define props passed into Autocomplete component
5
+ */
6
+ export type MultiAutocompleteProps<T> = Omit<BaseAutocompleteProps<T>, 'clearOnSelect'> & Omit<MuiAutocompleteProps<T, // Option type
7
+ true, // Multiple -- allows multiple options to be selected (enables `multiple` prop)
8
+ false, // DisableClearable -- disables the clear button (enables `disableClearable` prop)
9
+ false>, 'renderInput' | 'options' | 'value' | 'multiple' | 'freeSolo' | 'inputValue'>;
10
+ /**
11
+ * `Autocomplete` is a mix between a `TextField` and `Select` component.
12
+ * As the user types, options that match their query are presented.
13
+ *
14
+ * Use this component when you have a lot of options and want to reduce the amount of scrolling
15
+ * users would have to do if they were to use a `Select`.
16
+ *
17
+ * Can be used with primitives or objects. For objects, make sure to override `getOptionLabel`.
18
+ *
19
+ * __IMPORTANT__: If you need to dynamically load options as the user types, check out `DynamicAutocomplete`, as this
20
+ * has automated a lot of the settings.
21
+ */
22
+ export declare const MultiAutocomplete: <T>(props: MultiAutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { AutocompleteOption } from '../../../../@types';
2
+ export declare const getMultiAutocompleteValue: <T>(value: T[] | undefined, options: AutocompleteOption<T>[] | undefined, isEqual: (obj1?: T | null, obj2?: T | null) => boolean) => AutocompleteOption<T>[];
@@ -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,112 @@
1
+ import { TypographyProps, TextFieldProps } from '@mui/material';
2
+ import * as React from "react";
3
+ export type CheckboxOption = string | {
4
+ label: string;
5
+ sublabel?: string;
6
+ textField?: TextFieldProps;
7
+ };
8
+ export type CheckboxGroupProps = {
9
+ /**
10
+ * Name and ID of the component. It should match a key in initialValues.
11
+ * @required
12
+ */
13
+ name: string;
14
+ /**
15
+ * Label for the checkbox group.
16
+ * @recommended
17
+ * @default props.name
18
+ */
19
+ label?: string;
20
+ /**
21
+ * Array of labels for the checkboxes in the group
22
+ * @recommended
23
+ */
24
+ checkboxes?: CheckboxOption[];
25
+ /**
26
+ * Disables all checkboxes.
27
+ * @default false
28
+ */
29
+ disabled?: boolean;
30
+ /**
31
+ * If true, the label above the checkboxes is disabled.
32
+ */
33
+ disableLabel?: boolean;
34
+ /**
35
+ * If true, the label of the the checkbox group will not be displayed in an error state if there are errors present.
36
+ */
37
+ disableRedLabelOnError?: boolean;
38
+ /**
39
+ * If true, causes the label to enter a focused state.
40
+ */
41
+ focused?: boolean;
42
+ /**
43
+ * Location of the label with respect to the checkboxes
44
+ * @default 'end'
45
+ */
46
+ labelPlacement?: "top" | "start" | "bottom" | "end";
47
+ /**
48
+ * Vertical alignment of the label with respect to the checkboxes. This is mainly for longer labels, or checkboxes with sublabels.
49
+ * Only applied when `labelPlacement` is 'start' or 'end'.
50
+ *
51
+ * Center: Verticaly aligns the checkbox with the center of the label (& sublabel)
52
+ *
53
+ * Top: Vertically aligns the checkbox with the first line of the label
54
+ *
55
+ * Defaults to 'top' when labelPlacement is 'start' | 'end. Otherwise, defaults to 'center'.
56
+ * @default 'top'
57
+ */
58
+ labelAlignment?: "center" | "top";
59
+ /**
60
+ * If true, an asterisk will be displayed next to the label
61
+ * Most browsers will automatically validate this, but it's recommended to also
62
+ * have Formik also validate as well so that `Error` displays for consistency.
63
+ * @default false
64
+ */
65
+ required?: boolean;
66
+ /**
67
+ * If `true`, the component becomes readonly.
68
+ * @default false
69
+ */
70
+ readOnly?: boolean;
71
+ /**
72
+ * If set, the user can select up to `max` options
73
+ */
74
+ max?: number;
75
+ /**
76
+ * If set, the user must select, at minimum, `min` options
77
+ */
78
+ min?: number;
79
+ /**
80
+ * If set, this subtitle is displayed under the label to notify the user of how many options they can select max.
81
+ * @default `Up to ${max} max`
82
+ */
83
+ maxSubtitle?: string;
84
+ /**
85
+ * If set, this subtitle is displayed under the label to notify the user of how many options they can select minimum.
86
+ * @requires min
87
+ * @default `Please select ${min} or more`
88
+ */
89
+ minSubtitle?: string;
90
+ /**
91
+ * If set, this subtitle is displayed under the label to notify the user of how many options they can select within a range.
92
+ * @requires min
93
+ * @requires max
94
+ * @default `Please select between ${min} and ${max} options`
95
+ */
96
+ minMaxSubtitle?: string;
97
+ /**
98
+ * Margin for the FormControl
99
+ */
100
+ margin?: "dense" | "none" | "normal";
101
+ /**
102
+ * Props from MUI-Bueno's Typography component.
103
+ * Used to customize the label when the static label option is selected or the field is readOnly.
104
+ */
105
+ staticLabelProps?: TypographyProps;
106
+ };
107
+ /**
108
+ * CheckboxGroup produces a group of checkboxes that's defined as an array of strings or Checkboxes.
109
+ *
110
+ * This component is ideal for limited options. For more than 4 options, use a MultiAutocomplete instead.
111
+ */
112
+ export declare const CheckboxGroup: React.FC<CheckboxGroupProps>;
@@ -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,78 @@
1
+ import { TypographyProps } from '@mui/material';
2
+ import { Citation, PageState, PageResponse, UnsavedCitation, UnsavedAttachment } from '../../../../@types';
3
+ export type CitationFieldProps = {
4
+ /**
5
+ * Name and ID of the component. Must match a key from initialValues in Formik.
6
+ * @required
7
+ */
8
+ name: string;
9
+ /**
10
+ * (Optional) Label. NOTE: this won't be floating, it's always static.
11
+ */
12
+ label?: string;
13
+ /**
14
+ * Styling for label
15
+ */
16
+ labelProps?: TypographyProps;
17
+ /**
18
+ * If `true`, the component becomes readonly.
19
+ * @default false
20
+ */
21
+ readOnly?: boolean;
22
+ /**
23
+ * Margin for the FormControl
24
+ */
25
+ margin?: 'dense' | 'none' | 'normal';
26
+ renderContentOnly?: never;
27
+ /**
28
+ * API call for fetching paginated citations. These will populate the "Insert Citation/Attachment(s)" table.
29
+ *
30
+ * If an error occurs during the API call, notify the user then throw the error so that
31
+ * Mui Bueno can handle updating state.
32
+ */
33
+ fetchExistingCitations: (req: PageState) => Promise<PageResponse<Citation>>;
34
+ /**
35
+ * API call for creating a new citation/attachment.
36
+ *
37
+ * If an error occurs during the API call, notify the user then throw the error so that
38
+ * Mui Bueno can handle updating state.
39
+ */
40
+ onCreateCitation: (citation: UnsavedCitation) => Promise<Citation>;
41
+ /**
42
+ * API call for updating a citation/attachment.
43
+ *
44
+ * If an error occurs during the API call, notify the user then throw the error so that
45
+ * Mui Bueno can handle updating state.
46
+ */
47
+ onUpdateCitation: (citation: Citation) => Promise<Citation>;
48
+ /**
49
+ * API call for retrieving a citation by id
50
+ *
51
+ * If an error occurs during the API call, notify the user then throw the error so that
52
+ * Mui Bueno can handle updating state.
53
+ */
54
+ getCitationById: (id: number) => Promise<Citation>;
55
+ /**
56
+ * API call for storing an attachment (ex. in an s3 bucket)
57
+ *
58
+ * If an error occurs during the API call, notify the user then throw the error so that
59
+ * Mui Bueno can handle updating state.
60
+ */
61
+ onStoreAttachment: (citation: UnsavedAttachment) => Promise<Citation>;
62
+ /**
63
+ * API call for retrieving an array citations by an array ids
64
+ *
65
+ * If an error occurs during the API call, notify the user then throw the error so that
66
+ * Mui Bueno can handle updating state.
67
+ */
68
+ getCitationsByIds: (ids: number[]) => Promise<Citation[]>;
69
+ };
70
+ /**
71
+ * Rich Text field -- uses MUI Tip Tap
72
+ *
73
+ * Formik -- This field cannot be completely controlled, so keep in mind that the Formik value will not update until the field
74
+ * __loses focus__. This is to prevent issues with converting from rich text to HTML as the user types as it could override
75
+ * their changes unintentionally.
76
+ */
77
+ export declare const CitationField: (props: CitationFieldProps) => import("react/jsx-runtime").JSX.Element;
78
+ export default CitationField;
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { Citation, UnsavedAttachment } from '../../../../../@types';
3
+ export type NewAttachmentFormProps = {
4
+ id?: number;
5
+ editMenuTitle: ReactNode;
6
+ onSave: (citation: UnsavedAttachment) => Promise<void>;
7
+ onCancel: () => void;
8
+ getCitationById: (id: number) => Promise<Citation>;
9
+ disableFileUpload?: boolean;
10
+ onTitleChanged?: (id: number) => void;
11
+ };
12
+ declare const NewAttachmentForm: (props: NewAttachmentFormProps) => import("react/jsx-runtime").JSX.Element;
13
+ export default NewAttachmentForm;
@@ -0,0 +1,25 @@
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, 'onSelectCitations' | 'onCancel'>;
5
+ /**
6
+ * TipTap Wrapper for CitationMenu so that it renders as a bubble/pop-up menu integrated
7
+ * with TipTap
8
+ *
9
+ * A component that renders a bubble menu when viewing, creating, or editing a
10
+ * link. Requires the mui-tiptap CitationBubbleMenuHandler extension and Tiptap's
11
+ * Link extension (@tiptap/extension-link, https://tiptap.dev/api/marks/link) to
12
+ * both be included in your editor `extensions` array.
13
+ *
14
+ * Pairs well with the `<MenuButtonEditLink />` component.
15
+ *
16
+ * If you're using `RichTextEditor`, include this component via
17
+ * `RichTextEditor`’s `children` render-prop. Otherwise, include the
18
+ * `LinkBubbleMenu` as a child of the component where you call `useEditor` and
19
+ * render your `RichTextField` or `RichTextContent`. (The bubble menu itself
20
+ * will be positioned appropriately no matter where you put it in your React
21
+ * tree, as long as it is re-rendered whenever the Tiptap `editor` forces an
22
+ * update, which will happen if it's a child of the component using
23
+ * `useEditor`).
24
+ */
25
+ export default function CitationBubbleMenuTipTap({ fetchExistingCitations, onCreateCitation, onUpdateCitation, getCitationById, onStoreAttachment, onTitleChanged, ...controlledBubbleMenuProps }: CitationBubbleMenuProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ import { Citation, UnsavedCitation } from '../../../../../@types';
3
+ export type NewCitationFormProps = {
4
+ id?: number;
5
+ editMenuTitle: ReactNode;
6
+ onSave: (citation: UnsavedCitation) => Promise<void>;
7
+ onCancel: () => void;
8
+ getCitationById: (id: number) => Promise<Citation>;
9
+ onTitleChanged?: (id: number) => void;
10
+ };
11
+ declare const NewCitationForm: (props: NewCitationFormProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default NewCitationForm;
@@ -0,0 +1,62 @@
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?: (id: number) => void;
48
+ }
49
+ export declare enum CitationMenuState {
50
+ CITATIONS_TABLE = 0,
51
+ ADD_CITATION = 1,
52
+ EDIT_CITATION = 2,
53
+ ADD_ATTACHMENT = 3,
54
+ EDIT_ATTACHMENT = 4
55
+ }
56
+ /**
57
+ * CitationMenu handles creating, updating, and selecting citations.
58
+ *
59
+ * Intended to be used within a bubble/pop-up/modal/dialog. For in-line citations, see CitationField instead.
60
+ */
61
+ export declare function CitationMenu({ fetchExistingCitations, onCreateCitation, onUpdateCitation, getCitationById, onStoreAttachment, onSelectCitations, onCancel, initialSelectedIds, onContentUpdate, onTitleChanged, }: CitationMenuProps): import("react/jsx-runtime").JSX.Element | null;
62
+ export default CitationMenu;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ import { PageState, PageResponse, Citation } from '../../../../../@types';
3
+ export type CitationTableProps = {
4
+ editMenuTitle: ReactNode;
5
+ onCancel: () => void;
6
+ onNewCitation: () => void;
7
+ onNewAttachment: () => void;
8
+ onEditCitation: (citation: Citation) => void;
9
+ onEditAttachment: (citation: Citation) => void;
10
+ onSelect: (selectedIds: number[]) => void;
11
+ fetchExistingCitations: (req: PageState) => Promise<PageResponse<Citation>>;
12
+ selectedIds: number[];
13
+ toggleCheckbox: (citation: Citation) => void;
14
+ };
15
+ declare const CitationTable: (props: CitationTableProps) => import("react/jsx-runtime").JSX.Element;
16
+ 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 MForm.
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 MForm 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
+ * MForm will use ISO dates (in UTC) internally as the value.
71
+ */
72
+ export declare const DateField: React.FC<DateFieldProps>;
73
+ export {};