@rpcbase/client 0.227.0 → 0.231.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 (237) hide show
  1. package/package.json +11 -113
  2. package/src/apiClient/getServerApiClient.ts +131 -0
  3. package/src/apiClient/index.ts +86 -0
  4. package/src/index.ts +3 -0
  5. package/src/initClient.ts +32 -0
  6. package/src/types.ts +7 -0
  7. package/AppProvider/AnalyticsContainer.js +0 -56
  8. package/AppProvider/debug.js +0 -4
  9. package/AppProvider/index.tsx +0 -79
  10. package/access-control/ACLForm/components/GrantField/OpSelector.tsx +0 -129
  11. package/access-control/ACLForm/components/GrantField/ResourceSelector.tsx +0 -86
  12. package/access-control/ACLForm/components/GrantField/UsersSelector.tsx +0 -96
  13. package/access-control/ACLForm/components/GrantField/grant-field.scss +0 -26
  14. package/access-control/ACLForm/components/GrantField/icons/CheckMark.tsx +0 -16
  15. package/access-control/ACLForm/components/GrantField/icons/CollapseArrow.tsx +0 -14
  16. package/access-control/ACLForm/components/GrantField/icons/ExpandArrow.tsx +0 -14
  17. package/access-control/ACLForm/components/GrantField/index.tsx +0 -91
  18. package/access-control/ACLForm/components/GrantsList.tsx +0 -48
  19. package/access-control/ACLForm/components/RoleForm.tsx +0 -134
  20. package/access-control/ACLForm/components/RoleView.tsx +0 -115
  21. package/access-control/ACLForm/components/RolesList.tsx +0 -79
  22. package/access-control/ACLForm/components/constants.tsx +0 -1
  23. package/access-control/ACLForm/components/resolver.ts +0 -57
  24. package/access-control/ACLForm/components/role-form.scss +0 -19
  25. package/access-control/ACLForm/index.tsx +0 -48
  26. package/access-control/ACLModal/acl-modal.scss +0 -7
  27. package/access-control/ACLModal/index.tsx +0 -66
  28. package/access-control/PolicyEditor/TargetSelector/QueryBuilder.tsx +0 -48
  29. package/access-control/PolicyEditor/TargetSelector/index.tsx +0 -5
  30. package/access-control/PolicyEditor/TargetSelector/query-builder.scss +0 -9
  31. package/access-control/PolicyEditor/index.tsx +0 -165
  32. package/access-control/index.ts +0 -3
  33. package/apiClient.js +0 -15
  34. package/auth/authProps.js +0 -8
  35. package/auth/components/AccountsList/AccountListItem.js +0 -61
  36. package/auth/components/AccountsList/account-list-item.scss +0 -5
  37. package/auth/components/AccountsList/index.js +0 -17
  38. package/auth/components/Footer/index.js +0 -11
  39. package/auth/components/ForgotPassword/forgot-password.scss +0 -37
  40. package/auth/components/ForgotPassword/index.js +0 -114
  41. package/auth/components/SetNewPassword/index.js +0 -130
  42. package/auth/components/SetNewPassword/set-new-password.scss +0 -47
  43. package/auth/components/SignIn/SignInEmailForm.tsx +0 -115
  44. package/auth/components/SignIn/index.js +0 -69
  45. package/auth/components/SignIn/sign-in.scss +0 -56
  46. package/auth/components/SignOut/index.js +0 -144
  47. package/auth/components/SignOut/sign-out.scss +0 -34
  48. package/auth/components/SignUp/SignUpEmailForm.tsx +0 -98
  49. package/auth/components/SignUp/index.js +0 -66
  50. package/auth/components/SignUp/sign-up.scss +0 -56
  51. package/auth/getTenantId.js +0 -12
  52. package/auth/getUid.js +0 -11
  53. package/auth/helpers/redirectSignIn.native.js +0 -9
  54. package/auth/helpers/redirectSignIn.web.js +0 -7
  55. package/auth/index.js +0 -146
  56. package/auth/signOut.js +0 -20
  57. package/auth/useAuthRouter.js +0 -56
  58. package/env.d.ts +0 -3
  59. package/firebase/index.js +0 -1
  60. package/firebase/sw.js +0 -1
  61. package/form/FileInput/FileUploadContext.tsx +0 -162
  62. package/form/FileInput/FileUploadForm/index.tsx +0 -139
  63. package/form/FileInput/FileUploadForm/usePreventUnload.js +0 -21
  64. package/form/FileInput/UploadButton.tsx +0 -23
  65. package/form/FileInput/constants.ts +0 -16
  66. package/form/FileInput/file-input.scss +0 -1
  67. package/form/FileInput/index.tsx +0 -21
  68. package/form/FileInput/upload-worker/get_file_hash.js +0 -63
  69. package/form/FileInput/upload-worker/index.js +0 -16
  70. package/form/FileInput/upload-worker/no_compress_exts.ts +0 -33
  71. package/form/FileInput/upload-worker/upload_file.js +0 -129
  72. package/form/Form.tsx +0 -23
  73. package/form/Input.tsx +0 -62
  74. package/form/SubmitButton/index.tsx +0 -58
  75. package/form/hook-form.tsx +0 -7
  76. package/form/index.tsx +0 -5
  77. package/getBaseUrl.js +0 -14
  78. package/getObjectId.ts +0 -31
  79. package/hashState.js +0 -158
  80. package/helpers/createBatcher/index.js +0 -36
  81. package/helpers/getInitials.js +0 -39
  82. package/helpers/onReady.js +0 -15
  83. package/helpers/post.js +0 -18
  84. package/helpers/postRPC.js +0 -42
  85. package/helpers/useRPC.js +0 -41
  86. package/helpers/useStoredValue/batchedGetStoredValues.js +0 -30
  87. package/helpers/useStoredValue/index.js +0 -107
  88. package/helpers/useStoredValue/setStoredValues.js +0 -14
  89. package/i18n/en/rb.nav.json +0 -13
  90. package/i18n/en/rb.sign_in.json +0 -11
  91. package/i18n/en/rb.sign_out.json +0 -5
  92. package/i18n/fr/rb.sign_in.json +0 -11
  93. package/i18n/fr/rb.sign_out.json +0 -5
  94. package/i18n/index.js +0 -63
  95. package/index.js +0 -6
  96. package/isEqualValues.js +0 -47
  97. package/jest.config.js +0 -16
  98. package/notifications/Notification/index.js +0 -36
  99. package/notifications/Notification/notification.scss +0 -1
  100. package/notifications/NotificationItem/HeaderStatus.js +0 -93
  101. package/notifications/NotificationItem/index.js +0 -65
  102. package/notifications/NotificationItem/notification-item.scss +0 -25
  103. package/notifications/NotificationsContainer/index.js +0 -37
  104. package/notifications/NotificationsContainer/notifications-container.scss +0 -38
  105. package/notifications/NotificationsContainer/useLLTs.js +0 -28
  106. package/notifications/NotificationsContext/index.js +0 -71
  107. package/notifications/NotificationsContext/useNotificationsList.js +0 -75
  108. package/notifications/NotificationsSettingsModal/SettingsForm.js +0 -52
  109. package/notifications/NotificationsSettingsModal/index.js +0 -48
  110. package/notifications/NotificationsSettingsModal/notifications-settings.scss +0 -1
  111. package/notifications/config.js +0 -1
  112. package/notifications/index.js +0 -4
  113. package/page.js +0 -9
  114. package/publish-output.txt +0 -0
  115. package/rpc.js +0 -32
  116. package/rr-trace/get_fingerprint.js +0 -10
  117. package/rr-trace/get_perf_vitals.js +0 -24
  118. package/rr-trace/get_session_id.js +0 -29
  119. package/rr-trace/index.js +0 -138
  120. package/rr-trace/write_session_data.js +0 -86
  121. package/rts/boot.js +0 -3
  122. package/rts/getUseDocument.js +0 -21
  123. package/rts/getUseQuery/index.js +0 -233
  124. package/rts/getUseQuery/useData.js +0 -55
  125. package/rts/index.js +0 -10
  126. package/rts/rts.js +0 -243
  127. package/rts/signout.ts +0 -8
  128. package/rts/store/constants.js +0 -3
  129. package/rts/store/debug.js +0 -24
  130. package/rts/store/get_collection.js +0 -55
  131. package/rts/store/index.js +0 -100
  132. package/rts/store/replace_query_keys.js +0 -30
  133. package/rts/store/satisfies_projection.js +0 -32
  134. package/rts/store/update_docs.js +0 -47
  135. package/storage/index.jest.js +0 -15
  136. package/storage/index.native.js +0 -38
  137. package/storage/index.web.js +0 -25
  138. package/types.ts +0 -6
  139. package/ui/ActivityIndicator/index.js +0 -113
  140. package/ui/Avatar/index.native.js +0 -31
  141. package/ui/Avatar/index.web.js +0 -37
  142. package/ui/Avatar/styles.js +0 -41
  143. package/ui/ErrorBoundary/index.js +0 -12
  144. package/ui/ExpandableFloatView/exp.scss +0 -15
  145. package/ui/ExpandableFloatView/index.tsx +0 -123
  146. package/ui/ExpandableFloatView/useBackdrop.js +0 -45
  147. package/ui/LottiePlayer/LottiePlayer.js +0 -4
  148. package/ui/LottiePlayer/index.js +0 -8
  149. package/ui/Modal/HashStateModal.js +0 -30
  150. package/ui/Modal/Modal.js +0 -93
  151. package/ui/Modal/ModalForm/AlertBanner.js +0 -82
  152. package/ui/Modal/ModalForm/index.js +0 -188
  153. package/ui/Modal/ModalForm/modal-form.scss +0 -63
  154. package/ui/Modal/index.js +0 -10
  155. package/ui/Modal/modal.scss +0 -101
  156. package/ui/Modal/withHashStateModal.js +0 -24
  157. package/ui/RedboxError/index.js +0 -3
  158. package/ui/Search/SearchHistory/index.js +0 -45
  159. package/ui/Search/SearchHistory/search-history.scss +0 -9
  160. package/ui/Search/SearchHistory/useSearchHistory.tsx +0 -57
  161. package/ui/Search/SearchResults/index.tsx +0 -90
  162. package/ui/Search/index.tsx +0 -298
  163. package/ui/Search/search.scss +0 -0
  164. package/ui/SelectPills/index.tsx +0 -96
  165. package/ui/SelectPills/select-pills.scss +0 -66
  166. package/ui/Tabs/index.tsx +0 -161
  167. package/ui/Tabs/tabs.scss +0 -53
  168. package/ui/Tree/index.js +0 -257
  169. package/ui/Tree/model.js +0 -71
  170. package/ui/Tree/node.js +0 -112
  171. package/ui/Tree/tree.scss +0 -98
  172. package/ui/UserAvatar/default_colors.json +0 -82
  173. package/ui/UserAvatar/index.js +0 -55
  174. package/ui/View/index.tsx +0 -17
  175. package/ui/View/index.web.js +0 -44
  176. package/ui/animations/checkmark.json +0 -1
  177. package/ui/helpers/SizeContext/index.tsx +0 -11
  178. package/ui/helpers/helpers.scss +0 -61
  179. package/ui/helpers/index.ts +0 -6
  180. package/ui/helpers/stopEventPropagation.js +0 -5
  181. package/ui/helpers/useActiveListItemIndex/index.tsx +0 -45
  182. package/ui/helpers/useScrollSelectorIntoView/index.tsx +0 -14
  183. package/ui/helpers/useThrottledMeasure/index.js +0 -47
  184. package/ui/helpers/withSuspense/index.js +0 -37
  185. package/ui/icons/AddAccount.tsx +0 -5
  186. package/ui/icons/Billing.tsx +0 -6
  187. package/ui/icons/Close.tsx +0 -14
  188. package/ui/icons/Organization.tsx +0 -5
  189. package/ui/icons/Signout.tsx +0 -5
  190. package/ui/icons/index.tsx +0 -6
  191. package/ui/nav/AccountsDropdown/SwitchAccounts.tsx +0 -28
  192. package/ui/nav/AccountsDropdown/accounts-dropdown.scss +0 -51
  193. package/ui/nav/AccountsDropdown/index.tsx +0 -90
  194. package/ui/nav/AccountsToggle/index.tsx +0 -24
  195. package/ui/nav/ContentView/ContentViewContext.ts +0 -23
  196. package/ui/nav/ContentView/index.tsx +0 -115
  197. package/ui/nav/HeaderContainer/header.scss +0 -52
  198. package/ui/nav/HeaderContainer/index.tsx +0 -23
  199. package/ui/nav/HeaderContainer/variables.scss +0 -1
  200. package/ui/nav/MorphingDropdown/MorphingDropdownContext.tsx +0 -151
  201. package/ui/nav/MorphingDropdown/MorphingDropdownMenu.tsx +0 -38
  202. package/ui/nav/MorphingDropdown/MorphingDropdownPortal.tsx +0 -166
  203. package/ui/nav/MorphingDropdown/MorphingDropdownToggle.tsx +0 -34
  204. package/ui/nav/MorphingDropdown/index.tsx +0 -16
  205. package/ui/nav/MorphingDropdown/morphing-dropdown.scss +0 -35
  206. package/ui/nav/NotificationsDropdown/index.tsx +0 -52
  207. package/ui/nav/NotificationsDropdown/notifications-dropdown.scss +0 -5
  208. package/ui/nav/NotificationsToggle/NotificationsGlyph.tsx +0 -54
  209. package/ui/nav/NotificationsToggle/index.tsx +0 -12
  210. package/ui/nav/NotificationsToggle/notification-animation.json +0 -1
  211. package/ui/nav/NotificationsToggle/notifications-toggle.scss +0 -26
  212. package/ui/nav/SidebarContainer/index.tsx +0 -48
  213. package/ui/nav/SidebarContainer/sidebar-container.scss +0 -21
  214. package/ui/nav/SlideoutContainer/components/Body.tsx +0 -19
  215. package/ui/nav/SlideoutContainer/components/Header.tsx +0 -23
  216. package/ui/nav/SlideoutContainer/components/Wrapper.tsx +0 -46
  217. package/ui/nav/SlideoutContainer/index.tsx +0 -50
  218. package/ui/nav/SlideoutContainer/slideout-container.scss +0 -40
  219. package/ui/nav/index.ts +0 -13
  220. package/ui/oauth/GitHub.js +0 -38
  221. package/ui/oauth/getGitHubSigninUrl.js +0 -30
  222. package/ui/oauth/index.js +0 -9
  223. package/ui/oauth/oauth.scss +0 -16
  224. package/ui/sortable-hoc/AutoScroller.js +0 -76
  225. package/ui/sortable-hoc/DragHandle.js +0 -31
  226. package/ui/sortable-hoc/Manager.js +0 -54
  227. package/ui/sortable-hoc/README.md +0 -1
  228. package/ui/sortable-hoc/SortableContainer/defaultGetHelperDimensions.js +0 -7
  229. package/ui/sortable-hoc/SortableContainer/defaultShouldCancelStart.js +0 -24
  230. package/ui/sortable-hoc/SortableContainer/index.js +0 -994
  231. package/ui/sortable-hoc/SortableContainer/props.js +0 -81
  232. package/ui/sortable-hoc/SortableElement.js +0 -111
  233. package/ui/sortable-hoc/SortableHandle.js +0 -45
  234. package/ui/sortable-hoc/drag-handle.scss +0 -14
  235. package/ui/sortable-hoc/index.js +0 -9
  236. package/ui/sortable-hoc/utils.js +0 -292
  237. package/ui/springs.ts +0 -17
@@ -1,45 +0,0 @@
1
- /* @flow */
2
- import {useRef, useEffect} from "react"
3
-
4
-
5
- const useBackdrop = (isOpenRef, onToggle) => {
6
- const elRef = useRef(document.createElement("div"))
7
-
8
- useEffect(() => {
9
- const onTransitionEnd = (ev) => {
10
- // hide backdrop when css opacity transition has ended
11
- if (!isOpenRef.current) {
12
- requestAnimationFrame(() => {
13
- elRef.current.style.visibility = "hidden"
14
- })
15
- }
16
- }
17
-
18
- elRef.current.id = "exp-float-view-backdrop"
19
- elRef.current.style.opacity = 0
20
- elRef.current.style.visibility = "hidden"
21
-
22
- elRef.current.addEventListener("transitionend", onTransitionEnd)
23
-
24
- elRef.current.onclick = () => {
25
- elRef.current.style.opacity = 0
26
- onToggle()
27
- }
28
-
29
- document.body.appendChild(elRef.current)
30
-
31
- return () => {
32
- elRef.current.remove()
33
- }
34
- }, [])
35
-
36
- const showBackdrop = () => {
37
- // console.lgo
38
- elRef.current.style.visibility = "visible"
39
- elRef.current.style.opacity = 0.3
40
- }
41
-
42
- return {showBackdrop}
43
- }
44
-
45
- export default useBackdrop
@@ -1,4 +0,0 @@
1
- /* @flow */
2
- import {Player} from "@rpcbase/lottie"
3
-
4
- export default Player
@@ -1,8 +0,0 @@
1
- /* @flow */
2
- import {withSuspense} from "../helpers/withSuspense"
3
-
4
-
5
- export default withSuspense(
6
- () => import(/* webpackChunkName: "lottie-player" */ "./LottiePlayer"),
7
- {hideLoader: true},
8
- )
@@ -1,30 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
-
4
- import {useHashState} from "@rpcbase/client/hashState"
5
-
6
-
7
- const HashStateModal = ({hashPropName, children}) => {
8
- const {hashState, serializeHashState} = useHashState()
9
-
10
- if (children) {
11
- assert(typeof children === "function", "HashStateModal children must be a function")
12
- }
13
-
14
- const show = !!hashState[hashPropName]
15
-
16
- if (!show) return null
17
-
18
- const onHide = () => {
19
- serializeHashState({
20
- [hashPropName]: null,
21
- })
22
- }
23
-
24
- const hashProps = {}
25
- hashProps[hashPropName] = hashState[hashPropName]
26
-
27
- return children({onHide, ...hashProps})
28
- }
29
-
30
- export default HashStateModal
package/ui/Modal/Modal.js DELETED
@@ -1,93 +0,0 @@
1
- /* @flow */
2
- import {useEffect, useRef} from "react"
3
- import _debounce from "lodash/debounce"
4
- import BSModal from "react-bootstrap/Modal"
5
-
6
- import "./modal.scss"
7
-
8
-
9
- const MAX_RETRIES = 256
10
- const DELAY_MS = 20
11
-
12
- const Modal = ({
13
- ref: _ref,
14
- show = true,
15
- dark = false,
16
- scrollable = true,
17
- animation = true,
18
- className = "",
19
- children,
20
- ...props
21
- }) => {
22
- const internalRef = useRef(null)
23
- const ref = _ref || internalRef
24
-
25
- useEffect(() => {
26
- if (!show) return
27
-
28
- let attemptsCount = 0
29
- let ro
30
-
31
- const setup = () => {
32
- const bodyEl = ref.current?.dialog?.querySelector(".modal-body")
33
- if (!bodyEl) {
34
- attemptsCount++
35
- if (attemptsCount > MAX_RETRIES) {
36
- throw new Error("unable to initialize after max attempts")
37
- }
38
- setTimeout(setup, DELAY_MS)
39
- return
40
- }
41
-
42
- const checkApplyScroller = _debounce(() => {
43
- const contentEl = ref.current?.dialog?.querySelector(".modal-content")
44
- // TODO: this shouldn't happen, but it only happens with modalforms... investigate
45
- // additionally we're eventually going to ditch the react-bootstrap modals and use our own so don't waste so much time on this
46
- if (!contentEl) return
47
-
48
- if (bodyEl.scrollHeight > bodyEl.clientHeight) {
49
- if (!contentEl.classList.contains("has-scroller")) {
50
- contentEl.classList.add("has-scroller")
51
- }
52
- } else {
53
- if (contentEl.classList.contains("has-scroller")) {
54
- contentEl.classList.remove("has-scroller")
55
- }
56
- }
57
- }, DELAY_MS)
58
-
59
- ro = new ResizeObserver((entries) => {
60
- checkApplyScroller()
61
- })
62
-
63
- ro.observe(bodyEl)
64
- }
65
-
66
- setup()
67
-
68
- return () => {
69
- ro?.disconnect()
70
- }
71
- }, [show])
72
-
73
- return (
74
- <BSModal
75
- className={cx({"is-dark": dark}, className)}
76
- centered={true}
77
- scrollable={scrollable}
78
- animation={animation}
79
- ref={ref}
80
- show={show}
81
- {...props}
82
- >
83
- {children}
84
- </BSModal>
85
- )
86
- }
87
-
88
- Modal.Dialog = BSModal.Dialog
89
- Modal.Header = BSModal.Header
90
- Modal.Body = BSModal.Body
91
- Modal.Footer = BSModal.Footer
92
-
93
- export default Modal
@@ -1,82 +0,0 @@
1
- import {useImperativeHandle, useState, useEffect} from "react"
2
- import {useFormContext} from "react-hook-form"
3
- import Alert from "react-bootstrap/Alert"
4
-
5
-
6
- const AlertBanner = ({ref, modalRef, ...props}) => {
7
- const {formState} = useFormContext()
8
-
9
- const [alertContent, setAlertContent] = useState(null)
10
-
11
- // remove alert if we are done submitting and there are no dirty fields
12
- useEffect(() => {
13
- const hasDirtyFields = Object.keys(formState.dirtyFields).length > 0
14
- if (alertContent && !formState.isSubmitting && !hasDirtyFields) {
15
- setAlertContent(null)
16
- }
17
- }, [alertContent, formState.isSubmitting, formState.dirtyFields])
18
-
19
- const onClickDiscardAndClose = () => {
20
- modalRef.current.forceClose()
21
- }
22
-
23
- const bounce = () => {
24
- requestAnimationFrame(() => {
25
- const el = document.querySelector(".bouncy-alert")
26
-
27
- el.classList.add("bounce")
28
-
29
- setTimeout(() => {
30
- requestAnimationFrame(() => {
31
- el.classList.remove("bounce")
32
- })
33
- // WARNING: timeout must match value in css
34
- }, 220)
35
- })
36
- }
37
-
38
- useImperativeHandle(ref, () => ({
39
- onRequestHide: () => {
40
- const {isSubmitting, dirtyFields} = formState
41
-
42
- // do not close when form submitting
43
- if (isSubmitting) {
44
- setAlertContent(
45
- <Alert variant={"danger"} className="bouncy-alert d-flex">
46
- <div>Cannot close while submitting, please do not close this page.</div>
47
- </Alert>,
48
- )
49
-
50
- bounce()
51
- return false
52
- }
53
- // when form is dirty do not close
54
- else if (Object.keys(dirtyFields).length > 0) {
55
- setAlertContent(
56
- <Alert variant={"light"} className="bouncy-alert d-flex">
57
- <div>Are you sure you want to close without saving?</div>
58
- <div role="button" onClick={onClickDiscardAndClose} className="link-primary ms-2">
59
- Discard and Close
60
- </div>
61
- </Alert>,
62
- )
63
-
64
- bounce()
65
- return false
66
- }
67
-
68
- setAlertContent(null)
69
- return true
70
- },
71
- }))
72
-
73
- return (
74
- <div className="modal-form-alerts w-100" style={{top: -70}}>
75
- {alertContent}
76
- </div>
77
- )
78
- }
79
-
80
- AlertBanner.displayName = "AlertBanner"
81
-
82
- export default AlertBanner
@@ -1,188 +0,0 @@
1
- /* @flow */
2
- import debug from "debug"
3
- import {useImperativeHandle, useEffect, useState, useRef} from "react"
4
- import {FormProvider} from "react-hook-form"
5
-
6
- import ActivityIndicator from "../../ActivityIndicator"
7
- import {SubmitButton} from "../../../form/SubmitButton"
8
-
9
- import Modal from "../Modal"
10
-
11
- import AlertBanner from "./AlertBanner"
12
-
13
- import "./modal-form.scss"
14
-
15
-
16
- const log = debug("form")
17
-
18
- const ExtLink = ({to}) => {
19
- return (
20
- <a target="_blank" rel="noopener noreferrer" href={to}>
21
- {to}
22
- </a>
23
- )
24
- }
25
-
26
- const SHOW_LOADER_DELAY = 120 // ms
27
-
28
- // Bootstrap Modal integrated with hook form
29
- const ModalForm = ({
30
- ref: _ref,
31
- title,
32
- icon,
33
- footerLink,
34
- submitTitle,
35
- submittingTitle,
36
- show,
37
- onHide,
38
- isLiveSubmit = false,
39
- form,
40
- onSubmit,
41
- children,
42
- ...props
43
- }) => {
44
- const {formState, watch, handleSubmit} = form
45
-
46
- const internalRef = useRef(null)
47
- const ref = _ref || internalRef
48
-
49
- const alertBannerRef = useRef(null)
50
-
51
- // timeoutRef: only start displaying isBusy after a short delay
52
- // to avoid screen flashing when the data loads fast enough
53
- const timeoutRef = useRef(null)
54
- const [isBusy, setIsBusy] = useState(false)
55
-
56
- useImperativeHandle(ref, () => ({
57
- ...ref.current,
58
- forceClose: () => {
59
- onHide()
60
- },
61
- }))
62
-
63
- useEffect(() => {
64
- // busy when either submitting or loading (async getDefaultValues)
65
- if (formState.isSubmitting || formState.isLoading) {
66
- timeoutRef.current = setTimeout(() => {
67
- setIsBusy(true)
68
- }, SHOW_LOADER_DELAY)
69
- } else {
70
- if (timeoutRef.current) {
71
- window.clearTimeout(timeoutRef.current)
72
- }
73
- setIsBusy(false)
74
- }
75
- }, [formState.isSubmitting, formState.isLoading, setIsBusy])
76
-
77
- useEffect(() => {
78
- if (isLiveSubmit) {
79
- const subscription = watch(handleSubmit(onSubmit))
80
- return () => subscription.unsubscribe()
81
- }
82
- }, [isLiveSubmit, handleSubmit, watch])
83
-
84
- const onHideHandler = () => {
85
- log("onHideHandler")
86
- if (!isLiveSubmit) {
87
- onHide()
88
- return
89
- }
90
-
91
- if (alertBannerRef.current.onRequestHide()) {
92
- onHide()
93
- }
94
- }
95
-
96
- const onClickSubmit = async() => {
97
- log("onClickSubmit")
98
- await handleSubmit(onSubmit)()
99
- }
100
-
101
- return (
102
- <Modal
103
- className="modal-form"
104
- show={show}
105
- onHide={onHideHandler}
106
- ref={ref}
107
- backdrop={isBusy ? "static" : true}
108
- {...props}
109
- >
110
- <FormProvider {...form}>
111
- <AlertBanner ref={alertBannerRef} modalRef={ref} />
112
- <Modal.Header closeButton>
113
- <div>
114
- {icon && (
115
- <img
116
- width={20}
117
- height={20}
118
- style={{marginTop: 0}}
119
- className="me-2"
120
- src={`/static/icons/${icon}.svg`}
121
- />
122
- )}
123
- {title}
124
- </div>
125
- </Modal.Header>
126
- <Modal.Body className="pb-3" style={{position: "relative"}}>
127
- <div className={cx("modal-form-body", {"is-busy": isBusy})}>
128
- <fieldset disabled={isBusy}>{children}</fieldset>
129
- </div>
130
-
131
- {isBusy && (
132
- <div className="loading-overlay">
133
- {isLiveSubmit && (
134
- <>
135
- <ActivityIndicator />
136
- <div className="mt-2 fw-normal">
137
- {formState.isLoading && <>Loading...</>}
138
- {formState.isSubmitting && (
139
- <>{submittingTitle || "Submitting..."}</>
140
- )}
141
- </div>
142
- </>
143
- )}
144
- </div>
145
- )}
146
- </Modal.Body>
147
-
148
- {footerLink && isLiveSubmit && (
149
- <Modal.Footer className="justify-content-start bg-light">
150
- For more information, check out&nbsp;
151
- <ExtLink to={footerLink} />
152
- </Modal.Footer>
153
- )}
154
-
155
- {footerLink && !isLiveSubmit && (
156
- <Modal.Footer className="p-0 justify-content-start align-items-start flex-column">
157
- <div className="d-flex flex-row-reverse justify-content-start w-100 py-2">
158
- <SubmitButton
159
- className="me-3"
160
- disabled={formState.isSubmitting || formState.isLoading}
161
- isLoading={formState.isSubmitting}
162
- onClick={onClickSubmit}
163
- >
164
- {formState.isSubmitting
165
- ? submittingTitle || submitTitle
166
- : submitTitle}
167
- </SubmitButton>
168
-
169
- <button
170
- className="btn btn-link btn-cancel"
171
- disabled={formState.isSubmitting}
172
- onClick={onHideHandler}
173
- >
174
- Cancel
175
- </button>
176
- </div>
177
- <div className="w-100 bg-light border-top mx-0 my-0 p-3">
178
- For more information, check out&nbsp;
179
- <ExtLink to={footerLink} />
180
- </div>
181
- </Modal.Footer>
182
- )}
183
- </FormProvider>
184
- </Modal>
185
- )
186
- }
187
-
188
- export default ModalForm
@@ -1,63 +0,0 @@
1
- @import "helpers";
2
-
3
- @keyframes bounce {
4
- 0% {
5
- transform: scale(1);
6
- }
7
-
8
- 50% {
9
- transform: scale(1.02);
10
- }
11
-
12
- 100% {
13
- transform: scale(1);
14
- }
15
- }
16
-
17
- $bounce-duration: 220ms;
18
-
19
- .modal-form {
20
- .modal-content {
21
- overflow: visible;
22
- }
23
-
24
- .modal-footer {
25
- border-bottom-left-radius: var(--bs-modal-border-radius);
26
- border-bottom-right-radius: var(--bs-modal-border-radius);
27
- overflow: hidden;
28
- }
29
-
30
- .modal-form-body {
31
- &.is-busy {
32
- // doesn't look that good, does it
33
- // filter: blur(0.5px);
34
- opacity: 0.8;
35
- }
36
- }
37
-
38
- .modal-form-alerts {
39
- position: absolute;
40
- top: -40px;
41
- }
42
-
43
- .alert {
44
- border-radius: var(--bs-modal-border-radius);
45
- box-shadow: var(--bs-modal-box-shadow);
46
- }
47
-
48
- .alert.alert-light {
49
- // background: var(--bs-modal-bg) !important;
50
- background: var(--bs-gray-200) !important;
51
- border-color: $gray-700;
52
- opacity: 1;
53
- }
54
-
55
- .bouncy-alert {
56
- transform: scale(1);
57
- transition: transform $bounce-duration ease-out;
58
-
59
- &.bounce {
60
- animation: bounce $bounce-duration;
61
- }
62
- }
63
- }
package/ui/Modal/index.js DELETED
@@ -1,10 +0,0 @@
1
- /* @flow */
2
- import Modal from "./Modal"
3
- import ModalForm from "./ModalForm"
4
- import withHashStateModal from "./withHashStateModal"
5
- import HashStateModal from "./HashStateModal"
6
-
7
-
8
- export {ModalForm, HashStateModal, withHashStateModal}
9
-
10
- export default Modal
@@ -1,101 +0,0 @@
1
- @import "helpers";
2
-
3
- $navbar-height: 45px !default;
4
-
5
- .modal.is-dark {
6
- $border-color: $gray-800;
7
- $bg-darker: darken($gray-900, 4%);
8
-
9
- .modal-content {
10
- background-color: $gray-900;
11
- color: $gray-100;
12
- border-color: $black;
13
- }
14
-
15
- .modal-header {
16
- color: $gray-400;
17
- background-color: $bg-darker;
18
- border-color: $black;
19
- }
20
-
21
- .modal-footer {
22
- background-color: $bg-darker;
23
- border-color: $black;
24
- }
25
-
26
- .btn-close {
27
- background-color: $gray-700;
28
- }
29
-
30
- .text-secondary {
31
- color: $gray-600 !important;
32
- }
33
-
34
- hr {
35
- border-color: $gray-600;
36
- }
37
- }
38
-
39
- .modal-header {
40
- font-size: 1rem;
41
- font-weight: 600;
42
-
43
- &.close-top {
44
- .btn-close {
45
- align-self: flex-start;
46
- }
47
- }
48
- }
49
-
50
- .fullsize-modal {
51
- .modal-header {
52
- font-size: 15px;
53
-
54
- // padding-top: 10px;
55
- // padding-bottom: 9px;
56
- padding-top: 0;
57
- padding-bottom: 0;
58
-
59
- height: $navbar-height;
60
- }
61
-
62
- .modal-content {
63
- overflow: hidden;
64
- border-top: none;
65
- border-bottom: none;
66
- }
67
-
68
- .modal-dialog {
69
- margin-top: 0;
70
- margin-bottom: 0;
71
- width: 100%;
72
- max-width: calc(100vw - 82px);
73
- height: 100%;
74
- }
75
-
76
- .modal-header,
77
- .modal-content {
78
- border-radius: 0;
79
- }
80
-
81
- // @include media-breakpoint-up(lg) {
82
- @media (min-width: 992px) {
83
- .modal-dialog {
84
- max-width: calc(100vw - 182px) !important;
85
- }
86
- }
87
- }
88
-
89
- @media (height < 600px) {
90
- .modal-content.has-scroller {
91
- border-color: $white !important;
92
- border-radius: 0 !important;
93
- }
94
-
95
- .modal-dialog-centered {
96
- height: 100% !important;
97
- min-height: 100% !important;
98
- margin-top: 0;
99
- margin-bottom: 0;
100
- }
101
- }
@@ -1,24 +0,0 @@
1
- /* @flow */
2
- import {useHashState} from "@rpcbase/client/hashState"
3
-
4
-
5
- const withHashStateModal = (Component, hashPropName) => () => {
6
- const {hashState, serializeHashState} = useHashState()
7
-
8
- const show = !!hashState[hashPropName]
9
-
10
- if (!show) return null
11
-
12
- const onHide = () => {
13
- serializeHashState({
14
- [hashPropName]: null,
15
- })
16
- }
17
-
18
- const hashProps = {}
19
- hashProps[hashPropName] = hashState[hashPropName]
20
-
21
- return <Component onHide={onHide} {...hashProps} />
22
- }
23
-
24
- export default withHashStateModal
@@ -1,3 +0,0 @@
1
- import {RedBoxError} from "@rpcbase/redbox-react"
2
-
3
- export {RedBoxError}
@@ -1,45 +0,0 @@
1
- import {formatDistance} from "date-fns/formatDistance"
2
-
3
- import {useSearchHistory} from "./useSearchHistory"
4
-
5
- import "./search-history.scss"
6
-
7
- // TODO: refactor out of rbt to be able to control the input
8
- // TODO: search history must support keyboard navigation
9
-
10
- // we pass the searchHistory prop from the top component
11
- // because we are unmounted when results aren't shown,
12
- // but we want history to be loaded anyway
13
- export const SearchHistory = ({setSearchInput}) => {
14
- const searchHistory = useSearchHistory()
15
-
16
- const getClickHandler = (item) => (e) => {
17
- e.preventDefault()
18
- setSearchInput(item.query)
19
- }
20
-
21
- if (!searchHistory.length > 0) {
22
- return null
23
- }
24
-
25
- return (
26
- <>
27
- <div className="search-history-header ps-3 pb-2 mt-2 fw-bold border-bottom">
28
- Previous Queries
29
- </div>
30
- {searchHistory.map((item, i) => (
31
- <div
32
- role="button"
33
- key={`search-history-${i}`}
34
- className="list-group-item list-group-item-action"
35
- onClick={getClickHandler(item)}
36
- >
37
- <span>{item.query}</span>
38
- <small className="text-secondary ms-2">
39
- {formatDistance(item.timestamp, new Date(), {addSuffix: true})}
40
- </small>
41
- </div>
42
- ))}
43
- </>
44
- )
45
- }