@homebound/beam 2.299.0 → 2.301.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.
@@ -0,0 +1,24 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ export declare enum AutoSaveStatus {
3
+ IDLE = "idle",
4
+ SAVING = "saving",
5
+ DONE = "done",
6
+ ERROR = "error"
7
+ }
8
+ export interface AutoSaveStatusContextType {
9
+ status: AutoSaveStatus;
10
+ /** Resets status to IDLE, particularly useful if "Error" or "Done" is stale */
11
+ resetStatus: VoidFunction;
12
+ errors: unknown[];
13
+ /** Notifies AutoSaveContext that a request is in-flight */
14
+ triggerAutoSave: VoidFunction;
15
+ /** Notifies AutoSaveContext that a request has settled, optionally taking an error */
16
+ resolveAutoSave: (error?: unknown) => void;
17
+ }
18
+ export declare const AutoSaveStatusContext: React.Context<AutoSaveStatusContextType>;
19
+ type AutoSaveStatusProviderProps = PropsWithChildren<{
20
+ /** After a successful save, reset Status back to `Idle` after this many milliseconds */
21
+ resetToIdleTimeout?: number;
22
+ }>;
23
+ export declare function AutoSaveStatusProvider({ children, resetToIdleTimeout }: AutoSaveStatusProviderProps): import("@emotion/react/jsx-runtime").JSX.Element;
24
+ export {};
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.AutoSaveStatusProvider = exports.AutoSaveStatusContext = exports.AutoSaveStatus = void 0;
27
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ var AutoSaveStatus;
30
+ (function (AutoSaveStatus) {
31
+ AutoSaveStatus["IDLE"] = "idle";
32
+ AutoSaveStatus["SAVING"] = "saving";
33
+ AutoSaveStatus["DONE"] = "done";
34
+ AutoSaveStatus["ERROR"] = "error";
35
+ })(AutoSaveStatus = exports.AutoSaveStatus || (exports.AutoSaveStatus = {}));
36
+ exports.AutoSaveStatusContext = react_1.default.createContext({
37
+ status: AutoSaveStatus.IDLE,
38
+ resetStatus() { },
39
+ errors: [],
40
+ triggerAutoSave() { },
41
+ resolveAutoSave() { },
42
+ });
43
+ function AutoSaveStatusProvider({ children, resetToIdleTimeout = 6000 }) {
44
+ const [status, setStatus] = (0, react_1.useState)(AutoSaveStatus.IDLE);
45
+ const [errors, setErrors] = (0, react_1.useState)([]);
46
+ const [inFlight, setInFlight] = (0, react_1.useState)(0);
47
+ const resetToIdleTimeoutRef = (0, react_1.useRef)(null);
48
+ /** Handles setting Status */
49
+ (0, react_1.useEffect)(() => {
50
+ if (inFlight > 0)
51
+ return setStatus(AutoSaveStatus.SAVING);
52
+ if (status === AutoSaveStatus.IDLE)
53
+ return;
54
+ if (errors.length)
55
+ return setStatus(AutoSaveStatus.ERROR);
56
+ return setStatus(AutoSaveStatus.DONE);
57
+ }, [errors.length, inFlight, status]);
58
+ const triggerAutoSave = (0, react_1.useCallback)(() => {
59
+ setInFlight((c) => c + 1);
60
+ setErrors([]);
61
+ }, []);
62
+ const resolveAutoSave = (0, react_1.useCallback)((error) => {
63
+ setInFlight((c) => Math.max(0, c - 1));
64
+ if (error)
65
+ setErrors((errs) => errs.concat(error));
66
+ }, []);
67
+ const resetStatus = (0, react_1.useCallback)(() => {
68
+ setStatus(AutoSaveStatus.IDLE);
69
+ setErrors([]);
70
+ }, []);
71
+ /** Resets AutoSaveStatus from "Done" to "Idle" after a timeout, if one is provided */
72
+ (0, react_1.useEffect)(() => {
73
+ if (resetToIdleTimeout === undefined)
74
+ return;
75
+ // Specifically avoid auto-reset if Errors are present
76
+ if (status !== AutoSaveStatus.DONE)
77
+ return;
78
+ // Only run the latest Timeout
79
+ if (resetToIdleTimeoutRef.current)
80
+ clearTimeout(resetToIdleTimeoutRef.current);
81
+ resetToIdleTimeoutRef.current = window.setTimeout(() => {
82
+ resetStatus();
83
+ resetToIdleTimeoutRef.current = null;
84
+ }, resetToIdleTimeout);
85
+ }, [resetStatus, resetToIdleTimeout, status]);
86
+ const value = (0, react_1.useMemo)(() => ({ status, resetStatus, errors, triggerAutoSave, resolveAutoSave }), [errors, resetStatus, resolveAutoSave, status, triggerAutoSave]);
87
+ return (0, jsx_runtime_1.jsx)(exports.AutoSaveStatusContext.Provider, { value: value, children: children });
88
+ }
89
+ exports.AutoSaveStatusProvider = AutoSaveStatusProvider;
@@ -0,0 +1,2 @@
1
+ export { AutoSaveStatus, AutoSaveStatusContext, AutoSaveStatusProvider } from "./AutoSaveStatusProvider";
2
+ export { useAutoSaveStatus } from "./useAutoSaveStatus";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAutoSaveStatus = exports.AutoSaveStatusProvider = exports.AutoSaveStatusContext = exports.AutoSaveStatus = void 0;
4
+ var AutoSaveStatusProvider_1 = require("./AutoSaveStatusProvider");
5
+ Object.defineProperty(exports, "AutoSaveStatus", { enumerable: true, get: function () { return AutoSaveStatusProvider_1.AutoSaveStatus; } });
6
+ Object.defineProperty(exports, "AutoSaveStatusContext", { enumerable: true, get: function () { return AutoSaveStatusProvider_1.AutoSaveStatusContext; } });
7
+ Object.defineProperty(exports, "AutoSaveStatusProvider", { enumerable: true, get: function () { return AutoSaveStatusProvider_1.AutoSaveStatusProvider; } });
8
+ var useAutoSaveStatus_1 = require("./useAutoSaveStatus");
9
+ Object.defineProperty(exports, "useAutoSaveStatus", { enumerable: true, get: function () { return useAutoSaveStatus_1.useAutoSaveStatus; } });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Provides access to the current auto-save status, i.e. idle/saving/done.
3
+ *
4
+ * Applications should generally instrument their network layer, i.e. GraphQL
5
+ * mutations, to automatically update the auto-save status on any wire call,
6
+ * and then just use this `useAutoSaveStatus` to "show spinners" in appropriate
7
+ * places.
8
+ *
9
+ * See the `apolloHooks.ts` file in `internal-frontend` for an example.
10
+ */
11
+ export declare function useAutoSaveStatus(): import("./AutoSaveStatusProvider").AutoSaveStatusContextType;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAutoSaveStatus = void 0;
4
+ const react_1 = require("react");
5
+ const AutoSaveStatusProvider_1 = require("./AutoSaveStatusProvider");
6
+ /**
7
+ * Provides access to the current auto-save status, i.e. idle/saving/done.
8
+ *
9
+ * Applications should generally instrument their network layer, i.e. GraphQL
10
+ * mutations, to automatically update the auto-save status on any wire call,
11
+ * and then just use this `useAutoSaveStatus` to "show spinners" in appropriate
12
+ * places.
13
+ *
14
+ * See the `apolloHooks.ts` file in `internal-frontend` for an example.
15
+ */
16
+ function useAutoSaveStatus() {
17
+ return (0, react_1.useContext)(AutoSaveStatusProvider_1.AutoSaveStatusContext);
18
+ }
19
+ exports.useAutoSaveStatus = useAutoSaveStatus;
@@ -2,26 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useBeamContext = exports.BeamProvider = exports.BeamContext = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
- const form_state_1 = require("@homebound/form-state");
6
5
  const react_1 = require("react");
7
6
  const react_aria_1 = require("react-aria");
7
+ const index_1 = require("./AutoSaveStatus/index");
8
8
  const Modal_1 = require("./Modal/Modal");
9
9
  const PresentationContext_1 = require("./PresentationContext");
10
10
  const SnackbarContext_1 = require("./Snackbar/SnackbarContext");
11
11
  const SuperDrawer_1 = require("./SuperDrawer/SuperDrawer");
12
- const index_1 = require("../utils/index");
12
+ const index_2 = require("../utils/index");
13
13
  const Layout_1 = require("./Layout");
14
14
  const ToastContext_1 = require("./Toast/ToastContext");
15
15
  /** This is only exported internally, for useModal and useSuperDrawer, it's not a public API. */
16
16
  exports.BeamContext = (0, react_1.createContext)({
17
- modalState: new index_1.EmptyRef(),
18
- modalCanCloseChecks: new index_1.EmptyRef(),
17
+ modalState: new index_2.EmptyRef(),
18
+ modalCanCloseChecks: new index_2.EmptyRef(),
19
19
  modalHeaderDiv: undefined,
20
20
  modalBodyDiv: undefined,
21
21
  modalFooterDiv: undefined,
22
- drawerContentStack: new index_1.EmptyRef(),
23
- drawerCanCloseChecks: new index_1.EmptyRef(),
24
- drawerCanCloseDetailsChecks: new index_1.EmptyRef(),
22
+ drawerContentStack: new index_2.EmptyRef(),
23
+ drawerCanCloseChecks: new index_2.EmptyRef(),
24
+ drawerCanCloseDetailsChecks: new index_2.EmptyRef(),
25
25
  sdHeaderDiv: undefined,
26
26
  });
27
27
  function BeamProvider({ children, ...presentationProps }) {
@@ -61,7 +61,7 @@ function BeamProvider({ children, ...presentationProps }) {
61
61
  sdHeaderDiv,
62
62
  };
63
63
  }, [modalBodyDiv, modalFooterDiv]);
64
- return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, { value: { ...context }, children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, { ...presentationProps, children: (0, jsx_runtime_1.jsx)(Layout_1.RightPaneProvider, { children: (0, jsx_runtime_1.jsx)(form_state_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsx)(SnackbarContext_1.SnackbarProvider, { children: (0, jsx_runtime_1.jsxs)(ToastContext_1.ToastProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && (0, jsx_runtime_1.jsx)(Modal_1.Modal, { ...modalRef.current })] }), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {})] }) }) }) }) }) }));
64
+ return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, { value: { ...context }, children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, { ...presentationProps, children: (0, jsx_runtime_1.jsx)(Layout_1.RightPaneProvider, { children: (0, jsx_runtime_1.jsx)(index_1.AutoSaveStatusProvider, { children: (0, jsx_runtime_1.jsx)(SnackbarContext_1.SnackbarProvider, { children: (0, jsx_runtime_1.jsxs)(ToastContext_1.ToastProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && (0, jsx_runtime_1.jsx)(Modal_1.Modal, { ...modalRef.current })] }), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {})] }) }) }) }) }) }));
65
65
  }
66
66
  exports.BeamProvider = BeamProvider;
67
67
  /** Looks like a ref, but invokes a re-render on set (w/o changing the setter identity). */
@@ -131,6 +131,7 @@ export declare const Icons: {
131
131
  palette: import("@emotion/react/jsx-runtime").JSX.Element;
132
132
  bath: import("@emotion/react/jsx-runtime").JSX.Element;
133
133
  car: import("@emotion/react/jsx-runtime").JSX.Element;
134
+ basement: import("@emotion/react/jsx-runtime").JSX.Element;
134
135
  projects: import("@emotion/react/jsx-runtime").JSX.Element;
135
136
  tasks: import("@emotion/react/jsx-runtime").JSX.Element;
136
137
  finances: import("@emotion/react/jsx-runtime").JSX.Element;
@@ -140,6 +140,7 @@ exports.Icons = {
140
140
  palette: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M13.4001 2.09599C10.0421 1.63799 6.67106 2.89999 4.46306 5.42699C2.56506 7.60299 1.70206 10.509 2.09606 13.4C2.62606 17.294 5.55406 20.607 9.38106 21.646C10.2451 21.881 11.1261 22 11.9991 22L12.1411 21.999C13.1731 21.983 14.1141 21.45 14.6571 20.573C15.1981 19.697 15.2561 18.62 14.8101 17.694L14.6111 17.278C14.1931 16.41 14.4901 15.708 14.7051 15.366C15.2441 14.508 16.3321 14.156 17.2811 14.611L17.6931 14.808C18.1051 15.006 18.5431 15.107 18.9941 15.107C20.6271 15.107 21.9751 13.776 22.0001 12.14C22.0141 11.22 21.8951 10.291 21.6471 9.37999C20.6071 5.55399 17.2941 2.62599 13.4001 2.09599ZM18.5581 13.005L18.1461 12.808C16.3181 11.93 14.0761 12.61 13.0111 14.302C12.2731 15.478 12.1981 16.878 12.8071 18.144L13.0061 18.56C13.1571 18.874 13.1391 19.224 12.9551 19.521C12.7701 19.82 12.4631 19.995 12.1111 20H11.9991C11.3031 20 10.5981 19.904 9.90406 19.717C6.84106 18.886 4.50106 16.238 4.07806 13.131C3.75706 10.776 4.43006 8.50799 5.97106 6.74199C7.49106 4.99999 9.68906 3.99999 12.0001 3.99999C12.3741 3.99999 12.7541 4.02599 13.1311 4.07799C16.2381 4.50099 18.8861 6.84199 19.7171 9.90399C19.9151 10.634 20.0101 11.378 19.9991 12.111C19.9871 12.918 19.1541 13.294 18.5581 13.005Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M7.5 16C8.32843 16 9 15.3284 9 14.5C9 13.6716 8.32843 13 7.5 13C6.67157 13 6 13.6716 6 14.5C6 15.3284 6.67157 16 7.5 16Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M7.5 12C8.32843 12 9 11.3284 9 10.5C9 9.67157 8.32843 9 7.5 9C6.67157 9 6 9.67157 6 10.5C6 11.3284 6.67157 12 7.5 12Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M10.5 9C11.3284 9 12 8.32843 12 7.5C12 6.67157 11.3284 6 10.5 6C9.67157 6 9 6.67157 9 7.5C9 8.32843 9.67157 9 10.5 9Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M14.5 9C15.3284 9 16 8.32843 16 7.5C16 6.67157 15.3284 6 14.5 6C13.6716 6 13 6.67157 13 7.5C13 8.32843 13.6716 9 14.5 9Z" })] })),
141
141
  bath: ((0, jsx_runtime_1.jsx)("path", { d: "M21 10H7V7C7 5.897 7.897 5 9 5C10.103 5 11 5.897 11 7H13C13 4.794 11.206 3 9 3C6.794 3 5 4.794 5 7V10H3C2.447 10 2 10.447 2 11V13C2 15.606 3.674 17.823 6 18.65V22H8V19H16V22H18V18.65C20.326 17.823 22 15.606 22 13V11C22 10.447 21.553 10 21 10ZM20 13C20 15.206 18.206 17 16 17H8C5.794 17 4 15.206 4 13V12H20V13Z" })),
142
142
  car: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M20.772 10.156L19.404 6.051C18.995 4.824 17.852 4 16.559 4H7.441C6.148 4 5.005 4.824 4.596 6.051L3.228 10.156C2.508 10.459 2 11.171 2 12V17C2 17.753 2.423 18.402 3.039 18.743C3.026 18.809 3 18.869 3 18.938V21C3 21.553 3.447 22 4 22H5C5.553 22 6 21.553 6 21V19H18V21C18 21.553 18.447 22 19 22H20C20.553 22 21 21.553 21 21V18.938C21 18.869 20.974 18.808 20.961 18.743C21.577 18.402 22 17.753 22 17V12C22 11.171 21.492 10.459 20.772 10.156ZM4 17V12H20L20.002 17H4ZM7.441 6H16.558C16.989 6 17.371 6.274 17.507 6.684L18.613 10H5.387L6.492 6.684C6.629 6.274 7.011 6 7.441 6Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M6.5 16C7.32843 16 8 15.3284 8 14.5C8 13.6716 7.32843 13 6.5 13C5.67157 13 5 13.6716 5 14.5C5 15.3284 5.67157 16 6.5 16Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M17.5 16C18.3284 16 19 15.3284 19 14.5C19 13.6716 18.3284 13 17.5 13C16.6716 13 16 13.6716 16 14.5C16 15.3284 16.6716 16 17.5 16Z" })] })),
143
+ basement: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("rect", { width: "10", height: "2" }), (0, jsx_runtime_1.jsx)("rect", { x: "6", y: "5", width: "10", height: "2" }), (0, jsx_runtime_1.jsx)("rect", { x: "12", y: "10", width: "10", height: "2" })] })),
143
144
  // Navigation
144
145
  projects: ((0, jsx_runtime_1.jsx)("path", { d: "M4 6H6V8H4V6ZM4 11H6V13H4V11ZM4 16H6V18H4V16ZM20 8V6H18.8H9.2H8.023V8H9.2H18.8H20ZM8 11H20V13H8V11ZM8 16H20V18H8V16Z" })),
145
146
  tasks: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M5 22H19C20.103 22 21 21.103 21 20V5C21 3.897 20.103 3 19 3H17C17 2.447 16.553 2 16 2H8C7.447 2 7 2.447 7 3H5C3.897 3 3 3.897 3 5V20C3 21.103 3.897 22 5 22ZM5 5H7V7H17V5H19V20H5V5Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M11 13.586L9.20697 11.793L7.79297 13.207L11 16.414L16.207 11.207L14.793 9.79297L11 13.586Z" })] })),
@@ -1,3 +1,4 @@
1
+ export * from "./AutoSaveStatus";
1
2
  export * from "./Chip";
2
3
  export * from "./Chips";
3
4
  export * from "./Table/GridTable";
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.useToast = exports.TabsWithContent = exports.Tabs = exports.TabContent = exports.PresentationProvider = exports.NavLink = exports.HB_QUIPS_MISSION = exports.HB_QUIPS_FLAVOR = exports.HbSpinnerProvider = exports.HbLoadingSpinner = exports.BeamProvider = void 0;
18
+ __exportStar(require("./AutoSaveStatus"), exports);
18
19
  __exportStar(require("./Chip"), exports);
19
20
  __exportStar(require("./Chips"), exports);
20
21
  __exportStar(require("./Table/GridTable"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.299.0",
3
+ "version": "2.301.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",