@protobase/ui 0.59.2 → 0.59.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.
- package/dist/app/app.js +11 -3
- package/dist/app-shell/app-shell.js +2 -1
- package/dist/app-shell/profile-menu.d.ts +1 -0
- package/dist/app-shell/profile-menu.js +25 -3
- package/dist/app-shell/sidebar.js +3 -2
- package/dist/data/api-provider.d.ts +12 -0
- package/dist/data/meta-data.d.ts +2 -0
- package/dist/data/query-keys.js +8 -0
- package/dist/data/use-meta.js +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/organizations/members-page.js +7 -3
- package/dist/package.js +1 -1
- package/dist/people/person-row.js +8 -2
- package/dist/people/use-members.d.ts +9 -4
- package/dist/people/use-members.js +19 -3
- package/dist/shell/assets/app-CA2weCDB.js +9 -0
- package/dist/shell/assets/{index-mZM1MZhj.css → index-D0sx7n9i.css} +1 -1
- package/dist/shell/assets/{index-C-4shB1O.js → index-Dto4tygi.js} +2 -2
- package/dist/shell/assets/{records-map-CnJCsPQi.js → records-map-lppqdLea.js} +2 -2
- package/dist/shell/assets/shared-protobase-ui-C99fw_w0.js +2 -0
- package/dist/shell/index.html +4 -4
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/app-CA2weCDB.js.map +1 -0
- package/dist/shell-source-maps/assets/{index-C-4shB1O.js.map → index-Dto4tygi.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-CnJCsPQi.js.map → records-map-lppqdLea.js.map} +1 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-C99fw_w0.js.map +1 -0
- package/dist/status/clear-time.js +40 -0
- package/dist/status/messages.js +58 -0
- package/dist/status/status-dialog.js +190 -0
- package/dist/status/status-draft.js +40 -0
- package/dist/status/status-mark.d.ts +24 -0
- package/dist/status/status-mark.js +51 -0
- package/dist/status/use-status-menu.js +55 -0
- package/dist/status/use-statuses.d.ts +15 -0
- package/dist/status/use-statuses.js +43 -0
- package/package.json +4 -4
- package/dist/shell/assets/app-b2Amc-iC.js +0 -9
- package/dist/shell/assets/shared-protobase-ui-CQPxMGrM.js +0 -2
- package/dist/shell-source-maps/assets/app-b2Amc-iC.js.map +0 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-CQPxMGrM.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useClient } from "../data/api-provider.js";
|
|
2
|
+
import { useOwnStatus } from "./use-statuses.js";
|
|
3
|
+
import { text } from "./messages.js";
|
|
4
|
+
import { AvailabilityMark, StatusMark, availabilityLabel } from "./status-mark.js";
|
|
5
|
+
import { StatusDialog } from "./status-dialog.js";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { heldStatus } from "@protobase/schema/internal";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
10
|
+
//#region src/status/use-status-menu.tsx
|
|
11
|
+
/**
|
|
12
|
+
* The person's own status in the user menu, in an app with `status: {}`, for someone signed in as themselves: the
|
|
13
|
+
* menu's mark and item, and the picker the item opens. Nothing for staff signed in as them, or in an app without it.
|
|
14
|
+
*/
|
|
15
|
+
const useStatusMenu = (own) => {
|
|
16
|
+
const client = useClient();
|
|
17
|
+
const queryClient = useQueryClient();
|
|
18
|
+
const status = useOwnStatus();
|
|
19
|
+
const [open, setOpen] = useState(false);
|
|
20
|
+
if (!own || !status.isSuccess) return {};
|
|
21
|
+
const held = heldStatus(status.data);
|
|
22
|
+
const done = () => queryClient.invalidateQueries({ queryKey: ["statuses"] });
|
|
23
|
+
const save = async (input) => {
|
|
24
|
+
await client.status.set(input);
|
|
25
|
+
await done();
|
|
26
|
+
};
|
|
27
|
+
const clear = async () => {
|
|
28
|
+
await client.status.clear();
|
|
29
|
+
await done();
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
menu: {
|
|
33
|
+
mark: held && /* @__PURE__ */ jsx(StatusMark, {
|
|
34
|
+
status: held,
|
|
35
|
+
textShown: "hover"
|
|
36
|
+
}),
|
|
37
|
+
label: held ? /* @__PURE__ */ jsxs("span", {
|
|
38
|
+
className: "flex min-w-0 items-center gap-1.5 text-foreground",
|
|
39
|
+
children: [/* @__PURE__ */ jsx(AvailabilityMark, { availability: held.availability }), /* @__PURE__ */ jsx("span", {
|
|
40
|
+
className: "truncate",
|
|
41
|
+
children: held.text ?? availabilityLabel(held.availability)
|
|
42
|
+
})]
|
|
43
|
+
}) : text("setStatus"),
|
|
44
|
+
onOpen: () => setOpen(true)
|
|
45
|
+
},
|
|
46
|
+
...open && { dialog: /* @__PURE__ */ jsx(StatusDialog, {
|
|
47
|
+
current: held,
|
|
48
|
+
onSave: save,
|
|
49
|
+
onClear: clear,
|
|
50
|
+
onClose: () => setOpen(false)
|
|
51
|
+
}) }
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { useStatusMenu };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/status/use-statuses.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* How often a page reads the statuses again, over the connections it already has: another person's change, or a
|
|
4
|
+
* status whose time has passed, shows within this, while the page is in view.
|
|
5
|
+
*/
|
|
6
|
+
export declare const statusRefreshMs = 15000;
|
|
7
|
+
/**
|
|
8
|
+
* The statuses of everyone who shares an organization with the signed-in person, their own included, as the server
|
|
9
|
+
* holds them now: read again every `statusRefreshMs` while the page is in view, and on focus. Disabled, with no data,
|
|
10
|
+
* in an app without `status: {}` and for a visitor.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useStatuses: () => import("@tanstack/react-query").UseQueryResult<import("@protobase/client").PersonStatus[], Error>;
|
|
13
|
+
/** The signed-in person's own status, `null` without one, read as `useStatuses` reads the others'. */
|
|
14
|
+
export declare const useOwnStatus: () => import("@tanstack/react-query").UseQueryResult<import("@protobase/client").PersonStatus | null, Error>;
|
|
15
|
+
//#endregion
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useOptionalAuth } from "../auth/auth-provider.js";
|
|
2
|
+
import { keys } from "../data/query-keys.js";
|
|
3
|
+
import { useClient } from "../data/api-provider.js";
|
|
4
|
+
import { useMeta } from "../data/use-meta.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
//#region src/status/use-statuses.ts
|
|
7
|
+
/**
|
|
8
|
+
* How often a page reads the statuses again, over the connections it already has: another person's change, or a
|
|
9
|
+
* status whose time has passed, shows within this, while the page is in view.
|
|
10
|
+
*/
|
|
11
|
+
const statusRefreshMs = 15e3;
|
|
12
|
+
const useStatusUser = () => {
|
|
13
|
+
const auth = useOptionalAuth();
|
|
14
|
+
return Boolean(useMeta().data?.status) && auth?.state.kind === "signed-in" ? String(auth.state.user.id) : void 0;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The statuses of everyone who shares an organization with the signed-in person, their own included, as the server
|
|
18
|
+
* holds them now: read again every `statusRefreshMs` while the page is in view, and on focus. Disabled, with no data,
|
|
19
|
+
* in an app without `status: {}` and for a visitor.
|
|
20
|
+
*/
|
|
21
|
+
const useStatuses = () => {
|
|
22
|
+
const client = useClient();
|
|
23
|
+
const userId = useStatusUser();
|
|
24
|
+
return useQuery({
|
|
25
|
+
queryKey: keys.statuses(userId ?? ""),
|
|
26
|
+
enabled: userId !== void 0,
|
|
27
|
+
refetchInterval: statusRefreshMs,
|
|
28
|
+
queryFn: () => client.status.people()
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
/** The signed-in person's own status, `null` without one, read as `useStatuses` reads the others'. */
|
|
32
|
+
const useOwnStatus = () => {
|
|
33
|
+
const client = useClient();
|
|
34
|
+
const userId = useStatusUser();
|
|
35
|
+
return useQuery({
|
|
36
|
+
queryKey: keys.ownStatus(userId ?? ""),
|
|
37
|
+
enabled: userId !== void 0,
|
|
38
|
+
refetchInterval: statusRefreshMs,
|
|
39
|
+
queryFn: () => client.status.own()
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { statusRefreshMs, useOwnStatus, useStatuses };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/ui",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.3",
|
|
4
4
|
"description": "The Protobase admin app and the React hooks and components for custom UI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@dnd-kit/core": "^6.3.1",
|
|
41
41
|
"@dnd-kit/sortable": "^10.0.0",
|
|
42
|
-
"@protobase/client": "0.59.
|
|
43
|
-
"@protobase/layout": "0.59.
|
|
44
|
-
"@protobase/schema": "0.59.
|
|
42
|
+
"@protobase/client": "0.59.3",
|
|
43
|
+
"@protobase/layout": "0.59.3",
|
|
44
|
+
"@protobase/schema": "0.59.3",
|
|
45
45
|
"@sentry/browser": "^11.7.0",
|
|
46
46
|
"@tanstack/react-query": "^5.104.1",
|
|
47
47
|
"@tanstack/react-table": "^9.2.6",
|