dce-reactkit 3.9.0-beta-loading-modal.2 → 3.9.0-beta-loading-modal.3

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 (62) hide show
  1. package/dist/cjs/index.js +783 -201
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/client/initClient.d.ts +16 -2
  4. package/dist/cjs/types/components/AppWrapper.d.ts +32 -0
  5. package/dist/cjs/types/components/CheckboxButton.d.ts +1 -0
  6. package/dist/cjs/types/components/Dropdown.d.ts +32 -0
  7. package/dist/cjs/types/components/RadioButton.d.ts +2 -0
  8. package/dist/cjs/types/helpers/genRouteHandler.d.ts +8 -0
  9. package/dist/cjs/types/helpers/validators/ChicagoTitleCase.d.ts +9 -0
  10. package/dist/cjs/types/helpers/validators/validURL.d.ts +8 -0
  11. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +24 -0
  12. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +33 -0
  13. package/dist/cjs/types/index.d.ts +5 -2
  14. package/dist/cjs/types/types/DropdownItemType.d.ts +6 -0
  15. package/dist/cjs/types/types/ModalType.d.ts +1 -0
  16. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +6 -1
  17. package/dist/esm/index.js +779 -202
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/types/client/initClient.d.ts +16 -2
  20. package/dist/esm/types/components/AppWrapper.d.ts +32 -0
  21. package/dist/esm/types/components/CheckboxButton.d.ts +1 -0
  22. package/dist/esm/types/components/Dropdown.d.ts +32 -0
  23. package/dist/esm/types/components/RadioButton.d.ts +2 -0
  24. package/dist/esm/types/helpers/genRouteHandler.d.ts +8 -0
  25. package/dist/esm/types/helpers/validators/ChicagoTitleCase.d.ts +9 -0
  26. package/dist/esm/types/helpers/validators/validURL.d.ts +8 -0
  27. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +24 -0
  28. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +33 -0
  29. package/dist/esm/types/index.d.ts +5 -2
  30. package/dist/esm/types/types/DropdownItemType.d.ts +6 -0
  31. package/dist/esm/types/types/ModalType.d.ts +1 -0
  32. package/dist/esm/types/types/ReactKitErrorCode.d.ts +6 -1
  33. package/dist/index.d.ts +163 -46
  34. package/package.json +2 -1
  35. package/src/client/initClient.tsx +49 -11
  36. package/src/components/AppWrapper.tsx +258 -2
  37. package/src/components/CheckboxButton.tsx +24 -6
  38. package/src/components/Dropdown.tsx +317 -0
  39. package/src/components/IntelliTable.tsx +1 -1
  40. package/src/components/ItemPicker/NestableItemList.tsx +1 -0
  41. package/src/components/LogReviewer.tsx +17 -4
  42. package/src/components/Modal/index.tsx +4 -1
  43. package/src/components/MultiSwitch.tsx +1 -1
  44. package/src/components/RadioButton.tsx +33 -6
  45. package/src/components/SimpleDateChooser.tsx +8 -2
  46. package/src/helpers/genRouteHandler.ts +116 -17
  47. package/src/helpers/logClientEvent.tsx +8 -0
  48. package/src/helpers/validators/ChicagoTitleCase.test.ts +85 -0
  49. package/src/helpers/validators/ChicagoTitleCase.ts +32 -0
  50. package/src/helpers/validators/findURL.test.ts +83 -0
  51. package/src/helpers/validators/findURL.ts +43 -0
  52. package/src/helpers/validators/validURL.test.ts +90 -0
  53. package/src/helpers/validators/validURL.ts +18 -0
  54. package/src/helpers/visitEndpointOnAnotherServer/index.ts +93 -0
  55. package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +164 -0
  56. package/src/helpers/visitServerEndpoint.tsx +1 -0
  57. package/src/index.ts +8 -0
  58. package/src/server/initLogCollection.ts +5 -0
  59. package/src/server/initServer.ts +11 -5
  60. package/src/types/DropdownItemType.ts +11 -0
  61. package/src/types/ModalType.tsx +1 -0
  62. package/src/types/ReactKitErrorCode.tsx +8 -1
@@ -19,6 +19,12 @@ type SendRequestFunction = (opts: {
19
19
  [x: string]: any;
20
20
  };
21
21
  }>;
22
+ declare let noServer: boolean;
23
+ /**
24
+ * Check if there is no server for this app
25
+ * @author Gabe Abrams
26
+ */
27
+ export declare const appHasNoServer: () => boolean;
22
28
  /**
23
29
  * Get the send request function
24
30
  * @author Gabe Abrams
@@ -44,10 +50,18 @@ export declare const isDarkModeOn: () => boolean;
44
50
  * @param opts object containing all arguments
45
51
  * @param opts.sendRequest caccl send request functions
46
52
  * @param [opts.sessionExpiredMessage] a custom session expired message
53
+ * @param [opts.darkModeOn] if true, dark mode is enabled
54
+ * @param [opts.noServer] if true, there is no server for this app
47
55
  */
48
- declare const initClient: (opts: {
56
+ declare const initClient: (opts: ({
49
57
  sendRequest: SendRequestFunction;
50
58
  sessionExpiredMessage?: string;
51
59
  darkModeOn?: boolean;
52
- }) => void;
60
+ noServer?: false;
61
+ } | {
62
+ darkModeOn?: boolean;
63
+ noServer: true;
64
+ sendRequest?: undefined;
65
+ sessionExpiredMessage?: undefined;
66
+ })) => void;
53
67
  export default initClient;
@@ -44,6 +44,38 @@ export declare const confirm: (title: string, text: string, opts?: {
44
44
  cancelButtonText?: string;
45
45
  cancelButtonVariant?: Variant;
46
46
  }) => Promise<boolean>;
47
+ /**
48
+ * Show a prompt modal asking the user for input
49
+ * @author Yuen Ler Chow
50
+ * @param title the title text to display at the top of the prompt
51
+ * @param [opts={}] additional options for the prompt dialog
52
+ * @param [opts.textAboveInputField] the text to display in the prompt
53
+ * @param [opts.defaultText] the default text for the input field
54
+ * @param [opts.placeholder] the placeholder text for the input field
55
+ * @param [opts.confirmButtonText=Okay] the text of the confirm button
56
+ * @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
57
+ * @param [opts.cancelButtonText=Cancel] the text of the cancel button
58
+ * @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
59
+ * @param [opts.minNumChars] the minimum number of characters required for
60
+ * the input to be valid
61
+ * @param [opts.findValidationError] a function that takes the input text and
62
+ * returns an error message if the input is invalid, returns undefined if the
63
+ * input is valid
64
+ * @param [opts.ariaLabel] the aria label for the input field
65
+ * @returns Promise that resolves with the input string or null if canceled
66
+ */
67
+ export declare const prompt: (title: string, opts?: {
68
+ textAboveInputField?: string | undefined;
69
+ defaultText?: string | undefined;
70
+ placeholder?: string | undefined;
71
+ confirmButtonText?: string | undefined;
72
+ confirmButtonVariant?: Variant | undefined;
73
+ cancelButtonText?: string | undefined;
74
+ cancelButtonVariant?: Variant | undefined;
75
+ minNumChars?: number | undefined;
76
+ findValidationError?: ((text: string) => string | undefined) | undefined;
77
+ ariaLabel?: string | undefined;
78
+ } | undefined) => Promise<string | null>;
47
79
  /**
48
80
  * Show a fatal error message
49
81
  * @author Gabe Abrams
@@ -17,6 +17,7 @@ type Props = {
17
17
  uncheckedVariant?: Variant;
18
18
  small?: boolean;
19
19
  dashed?: boolean;
20
+ useComplexFormatting?: boolean;
20
21
  };
21
22
  declare const CheckboxButton: React.FC<Props>;
22
23
  export default CheckboxButton;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A simple dropdown menu
3
+ * @author Alessandra De Lucas
4
+ * @author Yuen Ler Chow
5
+ * @author Gabe Abrams
6
+ */
7
+ import React from 'react';
8
+ import Variant from '../types/Variant';
9
+ import DropdownItemType from '../types/DropdownItemType';
10
+ type Props = {
11
+ items: DropdownItem[];
12
+ dropdownButton: {
13
+ ariaLabel: string;
14
+ id: string;
15
+ content?: React.ReactNode;
16
+ variant?: Variant;
17
+ };
18
+ };
19
+ type DropdownItem = ({
20
+ type: DropdownItemType.Header;
21
+ content: React.ReactNode;
22
+ } | {
23
+ type: DropdownItemType.Divider;
24
+ } | {
25
+ type: DropdownItemType.Item;
26
+ content: React.ReactNode;
27
+ ariaLabel: string;
28
+ id: string;
29
+ onClick: () => void;
30
+ });
31
+ declare const Dropdown: React.FC<Props>;
32
+ export default Dropdown;
@@ -11,10 +11,12 @@ type Props = {
11
11
  title?: string;
12
12
  selected?: boolean;
13
13
  id?: string;
14
+ className?: string;
14
15
  noMarginOnRight?: boolean;
15
16
  selectedVariant?: Variant;
16
17
  unselectedVariant?: Variant;
17
18
  small?: boolean;
19
+ useComplexFormatting?: boolean;
18
20
  };
19
21
  declare const RadioButton: React.FC<Props>;
20
22
  export default RadioButton;
@@ -9,6 +9,12 @@ import LogFunction from '../types/LogFunction';
9
9
  * @param opts.handler function that processes the request
10
10
  * @param [opts.skipSessionCheck] if true, skip the session check (allow users
11
11
  * to not be logged in and launched via LTI)
12
+ * @param [opts.allowedHosts] if included, only allow requests from these hosts
13
+ * (start a hostname with a "*" to only check the end of the hostname)
14
+ * you can include just one string instead of an array
15
+ * @param [opts.bannedHosts] if included, do not allow requests from these hosts
16
+ * (start a hostname with a "*" to only check the end of the hostname)
17
+ * you can include just one string instead of an array
12
18
  * @param [opts.unhandledErrorMessagePrefix] if included, when an error that
13
19
  * is not of type ErrorWithCode is thrown, the client will receive an error
14
20
  * where the error message is prefixed with this string. For example,
@@ -63,6 +69,8 @@ declare const genRouteHandler: (opts: {
63
69
  logServerEvent: LogFunction;
64
70
  }) => any;
65
71
  skipSessionCheck?: boolean | undefined;
72
+ allowedHosts?: string | string[] | undefined;
73
+ bannedHosts?: string | string[] | undefined;
66
74
  unhandledErrorMessagePrefix?: string | undefined;
67
75
  }) => (req: any, res: any, next: () => void) => Promise<undefined>;
68
76
  export default genRouteHandler;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This function converts a string to title case based on Chicago Title Case
3
+ * Style rules.
4
+ * @author Leisha Bhandari
5
+ * @param input: The input string that needs to be converted to Chicago title
6
+ * case.
7
+ * @returns Input string converted to title case
8
+ */
9
+ declare const chicagoTitleCase: (input: string) => string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This function checks if a given input string is a valid URL.
3
+ * @author Leisha Bhandari
4
+ * @param URL: The input string that needs checked as a URL or not.
5
+ * @returns A true boolean value if the input string is a valid URL, and a false
6
+ * boolean value if the input string is a invalid URL
7
+ */
8
+ declare function isValid(url: string): boolean;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Send a server-to-server request from this sever to another server that uses
3
+ * dce-reactkit [for server only]
4
+ * @author Gabe Abrams
5
+ * @param opts object containing all arguments
6
+ * @param opts.host - the host of the other server
7
+ * @param opts.path - the path of the other server's endpoint
8
+ * @param [opts.method=GET] - the method of the endpoint
9
+ * @param [opts.params] - query/body parameters to include
10
+ * @param [opts.headers] - headers to include
11
+ * @returns response from server
12
+ */
13
+ declare const visitEndpointOnAnotherServer: (opts: {
14
+ host: string;
15
+ path: string;
16
+ method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
17
+ params?: {
18
+ [x: string]: any;
19
+ } | undefined;
20
+ headers?: {
21
+ [x: string]: any;
22
+ } | undefined;
23
+ }) => Promise<any>;
24
+ export default visitEndpointOnAnotherServer;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Sends and retries an http request
3
+ * @author Gabriel Abrams
4
+ * @param opts object containing all arguments
5
+ * @param opts.path path to send request to
6
+ * @param [opts.host] host to send request to
7
+ * @param [opts.method=GET] http method to use
8
+ * @param [opts.params] body/data to include in the request
9
+ * @param [opts.headers] headers to include in the request
10
+ * @param [opts.sendCrossDomainCredentials=true if in development mode] if true,
11
+ * send cross-domain credentials even if not in dev mode
12
+ * @param [opts.responseType=JSON] expected response type
13
+ * @returns { body, status, headers } on success
14
+ */
15
+ declare const sendServerToServerRequest: (opts: {
16
+ path: string;
17
+ host?: string | undefined;
18
+ method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
19
+ params?: {
20
+ [x: string]: any;
21
+ } | undefined;
22
+ headers?: {
23
+ [x: string]: any;
24
+ } | undefined;
25
+ responseType?: "Text" | "JSON" | undefined;
26
+ }) => Promise<{
27
+ body: any;
28
+ status: number;
29
+ headers: {
30
+ [x: string]: any;
31
+ };
32
+ }>;
33
+ export default sendServerToServerRequest;
@@ -1,4 +1,4 @@
1
- import AppWrapper, { alert, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
1
+ import AppWrapper, { alert, prompt, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
2
2
  import LoadingSpinner from './components/LoadingSpinner';
3
3
  import ErrorBox from './components/ErrorBox';
4
4
  import Modal from './components/Modal';
@@ -21,6 +21,7 @@ import Tooltip from './components/Tooltip';
21
21
  import ToggleSwitch from './components/ToggleSwitch';
22
22
  import AutoscrollToBottomContainer from './components/AutoscrollToBottomContainer';
23
23
  import MultiSwitch from './components/MultiSwitch';
24
+ import Dropdown from './components/Dropdown';
24
25
  import ErrorWithCode from './errors/ErrorWithCode';
25
26
  import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
26
27
  import HOUR_IN_MS from './constants/HOUR_IN_MS';
@@ -77,6 +78,7 @@ import mapAsync from './helpers/asyncArrayFunctions/mapAsync';
77
78
  import someAsync from './helpers/asyncArrayFunctions/someAsync';
78
79
  import capitalize from './helpers/capitalize';
79
80
  import shuffleArray from './helpers/shuffleArray';
81
+ import visitEndpointOnAnotherServer from './helpers/visitEndpointOnAnotherServer';
80
82
  import ModalButtonType from './types/ModalButtonType';
81
83
  import ModalSize from './types/ModalSize';
82
84
  import ModalType from './types/ModalType';
@@ -92,8 +94,9 @@ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
92
94
  import LogMetadataType from './types/LogMetadataType';
93
95
  import LogFunction from './types/LogFunction';
94
96
  import IntelliTableColumn from './types/IntelliTableColumn';
97
+ import DropdownItemType from './types/DropdownItemType';
95
98
  import PickableItem from './components/ItemPicker/types/PickableItem';
96
99
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
97
100
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
98
101
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
99
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
102
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
@@ -0,0 +1,6 @@
1
+ declare enum DropdownItemType {
2
+ Header = "Header",
3
+ Divider = "Divider",
4
+ Item = "Item"
5
+ }
6
+ export default DropdownItemType;
@@ -4,6 +4,7 @@
4
4
  */
5
5
  declare enum ModalType {
6
6
  Okay = "okay",
7
+ Cancel = "cancel",
7
8
  OkayCancel = "okay-cancel",
8
9
  YesNo = "yes-no",
9
10
  YesNoCancel = "yes-no-cancel",
@@ -8,6 +8,8 @@ declare enum ReactKitErrorCode {
8
8
  SessionExpired = "DRK3",
9
9
  MissingParameter = "DRK4",
10
10
  InvalidParameter = "DRK5",
11
+ HostNotAllowed = "DRK17",
12
+ HostBanned = "DRK18",
11
13
  WrongCourse = "DRK6",
12
14
  NoCACCLSendRequestFunction = "DRK7",
13
15
  NoCACCLGetLaunchInfoFunction = "DRK8",
@@ -15,6 +17,9 @@ declare enum ReactKitErrorCode {
15
17
  NotAdmin = "DRK10",
16
18
  NotAllowedToReviewLogs = "DRK11",
17
19
  ThemeCheckedBeforeReactKitReady = "DRK12",
18
- SessionExpiredMessageGottenBeforeReactKitReady = "DRK13"
20
+ SessionExpiredMessageGottenBeforeReactKitReady = "DRK13",
21
+ NotConnected = "DRK14",
22
+ SelfSigned = "DRK15",
23
+ ResponseParseError = "DRK16"
19
24
  }
20
25
  export default ReactKitErrorCode;