@dxos/react-ui 0.1.23 → 0.1.24-next.6b1f434
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/lib/browser/index.mjs +2428 -72
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/IdentityList/DeviceList.d.ts +7 -0
- package/dist/types/src/components/IdentityList/DeviceList.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/IdentityListItem.d.ts +7 -0
- package/dist/types/src/components/IdentityList/IdentityListItem.d.ts.map +1 -0
- package/dist/types/src/components/{IdentityListItem → IdentityList}/IdentityListItem.stories.d.ts +2 -1
- package/dist/types/src/components/IdentityList/IdentityListItem.stories.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.d.ts +7 -0
- package/dist/types/src/components/IdentityList/SpaceMemberList.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/SpaceMemberListContainer.d.ts +9 -0
- package/dist/types/src/components/IdentityList/SpaceMemberListContainer.d.ts.map +1 -0
- package/dist/types/src/components/IdentityList/index.d.ts +5 -0
- package/dist/types/src/components/IdentityList/index.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationList.d.ts +7 -0
- package/dist/types/src/components/InvitationList/InvitationList.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationList.stories.d.ts +10 -0
- package/dist/types/src/components/InvitationList/InvitationList.stories.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListContainer.d.ts +7 -0
- package/dist/types/src/components/InvitationList/InvitationListContainer.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListItem.d.ts +9 -0
- package/dist/types/src/components/InvitationList/InvitationListItem.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationListProps.d.ts +4 -0
- package/dist/types/src/components/InvitationList/InvitationListProps.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationStatusAvatar.d.ts +14 -0
- package/dist/types/src/components/InvitationList/InvitationStatusAvatar.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/InvitationStatusAvatar.stories.d.ts +9 -0
- package/dist/types/src/components/InvitationList/InvitationStatusAvatar.stories.d.ts.map +1 -0
- package/dist/types/src/components/InvitationList/index.d.ts +5 -0
- package/dist/types/src/components/InvitationList/index.d.ts.map +1 -0
- package/dist/types/src/components/PanelSeparator/PanelSeparator.d.ts +3 -0
- package/dist/types/src/components/PanelSeparator/PanelSeparator.d.ts.map +1 -0
- package/dist/types/src/components/PanelSeparator/index.d.ts +2 -0
- package/dist/types/src/components/PanelSeparator/index.d.ts.map +1 -0
- package/dist/types/src/components/SpaceList/SpaceListItem.d.ts +7 -0
- package/dist/types/src/components/SpaceList/SpaceListItem.d.ts.map +1 -0
- package/dist/types/src/components/SpaceList/index.d.ts +2 -0
- package/dist/types/src/components/SpaceList/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +5 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/composites/DevicesDialog/DevicesDialog.d.ts +6 -0
- package/dist/types/src/composites/DevicesDialog/DevicesDialog.d.ts.map +1 -0
- package/dist/types/src/composites/DevicesDialog/index.d.ts +2 -0
- package/dist/types/src/composites/DevicesDialog/index.d.ts.map +1 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.d.ts +6 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.d.ts.map +1 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.stories.d.ts +10 -0
- package/dist/types/src/composites/JoinDialog/JoinDialog.stories.d.ts.map +1 -0
- package/dist/types/src/composites/JoinDialog/index.d.ts +2 -0
- package/dist/types/src/composites/JoinDialog/index.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/Shell.d.ts +6 -0
- package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -0
- package/dist/types/src/composites/Shell/index.d.ts +2 -0
- package/dist/types/src/composites/Shell/index.d.ts.map +1 -0
- package/dist/types/src/composites/SpaceDialog/SpaceDialog.d.ts +6 -0
- package/dist/types/src/composites/SpaceDialog/SpaceDialog.d.ts.map +1 -0
- package/dist/types/src/composites/SpaceDialog/index.d.ts +2 -0
- package/dist/types/src/composites/SpaceDialog/index.d.ts.map +1 -0
- package/dist/types/src/composites/index.d.ts +3 -0
- package/dist/types/src/composites/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/layouts/PanelAlertDialog/PanelAlertDialog.d.ts +14 -0
- package/dist/types/src/layouts/PanelAlertDialog/PanelAlertDialog.d.ts.map +1 -0
- package/dist/types/src/layouts/PanelAlertDialog/index.d.ts +2 -0
- package/dist/types/src/layouts/PanelAlertDialog/index.d.ts.map +1 -0
- package/dist/types/src/layouts/PanelDialog/PanelDialog.d.ts +14 -0
- package/dist/types/src/layouts/PanelDialog/PanelDialog.d.ts.map +1 -0
- package/dist/types/src/layouts/PanelDialog/index.d.ts +2 -0
- package/dist/types/src/layouts/PanelDialog/index.d.ts.map +1 -0
- package/dist/types/src/layouts/PanelSidebar/PanelSidebar.d.ts +2 -3
- package/dist/types/src/layouts/PanelSidebar/PanelSidebar.d.ts.map +1 -1
- package/dist/types/src/layouts/index.d.ts +2 -0
- package/dist/types/src/layouts/index.d.ts.map +1 -1
- package/dist/types/src/panels/DevicesPanel/DevicesPanel.d.ts +10 -0
- package/dist/types/src/panels/DevicesPanel/DevicesPanel.d.ts.map +1 -0
- package/dist/types/src/panels/DevicesPanel/index.d.ts +2 -0
- package/dist/types/src/panels/DevicesPanel/index.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinHeading.d.ts +13 -0
- package/dist/types/src/panels/JoinPanel/JoinHeading.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.d.ts +3 -0
- package/dist/types/src/panels/JoinPanel/JoinPanel.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/JoinPanelProps.d.ts +54 -0
- package/dist/types/src/panels/JoinPanel/JoinPanelProps.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/index.d.ts +3 -0
- package/dist/types/src/panels/JoinPanel/index.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/AdditionMethodSelector.d.ts +7 -0
- package/dist/types/src/panels/JoinPanel/view-states/AdditionMethodSelector.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/IdentityAdded.d.ts +15 -0
- package/dist/types/src/panels/JoinPanel/view-states/IdentityAdded.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/IdentityInput.d.ts +6 -0
- package/dist/types/src/panels/JoinPanel/view-states/IdentityInput.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/IdentitySelector.d.ts +7 -0
- package/dist/types/src/panels/JoinPanel/view-states/IdentitySelector.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationAccepted.d.ts +10 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationAccepted.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationAuthenticator.d.ts +7 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationAuthenticator.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationInput.d.ts +6 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationInput.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationRescuer.d.ts +6 -0
- package/dist/types/src/panels/JoinPanel/view-states/InvitationRescuer.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/ViewState.d.ts +12 -0
- package/dist/types/src/panels/JoinPanel/view-states/ViewState.d.ts.map +1 -0
- package/dist/types/src/panels/JoinPanel/view-states/index.d.ts +9 -0
- package/dist/types/src/panels/JoinPanel/view-states/index.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts +18 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts +9 -0
- package/dist/types/src/panels/SpacePanel/SpacePanel.stories.d.ts.map +1 -0
- package/dist/types/src/panels/SpacePanel/index.d.ts +2 -0
- package/dist/types/src/panels/SpacePanel/index.d.ts.map +1 -0
- package/dist/types/src/panels/index.d.ts +3 -0
- package/dist/types/src/panels/index.d.ts.map +1 -1
- package/dist/types/src/styles/dialogStyles.d.ts +3 -0
- package/dist/types/src/styles/dialogStyles.d.ts.map +1 -0
- package/dist/types/src/styles/index.d.ts +2 -0
- package/dist/types/src/styles/index.d.ts.map +1 -1
- package/dist/types/src/styles/invitationStatusStyles.d.ts +20 -0
- package/dist/types/src/styles/invitationStatusStyles.d.ts.map +1 -0
- package/dist/types/src/styles/panelStyles.d.ts +2 -1
- package/dist/types/src/styles/panelStyles.d.ts.map +1 -1
- package/dist/types/src/translations/locales/en-US.d.ts +52 -0
- package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/invitationStatusValue.d.ts +8 -0
- package/dist/types/src/util/invitationStatusValue.d.ts.map +1 -0
- package/package.json +19 -11
- package/src/components/IdentityList/DeviceList.tsx +31 -0
- package/src/components/{IdentityListItem → IdentityList}/IdentityListItem.stories.tsx +0 -0
- package/src/components/{IdentityListItem → IdentityList}/IdentityListItem.tsx +18 -5
- package/src/components/IdentityList/SpaceMemberList.tsx +33 -0
- package/src/components/IdentityList/SpaceMemberListContainer.tsx +28 -0
- package/src/components/IdentityList/index.ts +8 -0
- package/src/components/InvitationList/InvitationList.stories.tsx +65 -0
- package/src/components/InvitationList/InvitationList.tsx +28 -0
- package/src/components/InvitationList/InvitationListContainer.tsx +27 -0
- package/src/components/InvitationList/InvitationListItem.tsx +106 -0
- package/src/components/InvitationList/InvitationListProps.ts +7 -0
- package/src/components/InvitationList/InvitationStatusAvatar.stories.tsx +52 -0
- package/src/components/InvitationList/InvitationStatusAvatar.tsx +80 -0
- package/src/components/InvitationList/index.ts +8 -0
- package/src/components/PanelSeparator/PanelSeparator.tsx +17 -0
- package/src/components/PanelSeparator/index.ts +5 -0
- package/src/components/SpaceList/SpaceListItem.tsx +32 -0
- package/src/components/SpaceList/index.ts +5 -0
- package/src/components/index.ts +8 -0
- package/src/composites/DevicesDialog/DevicesDialog.tsx +38 -0
- package/src/composites/DevicesDialog/index.ts +5 -0
- package/src/composites/JoinDialog/JoinDialog.stories.tsx +81 -0
- package/src/composites/JoinDialog/JoinDialog.tsx +33 -0
- package/src/composites/JoinDialog/index.ts +5 -0
- package/src/composites/Shell/Shell.tsx +92 -0
- package/src/composites/Shell/index.ts +5 -0
- package/src/composites/SpaceDialog/SpaceDialog.tsx +38 -0
- package/src/composites/SpaceDialog/index.ts +5 -0
- package/src/composites/index.ts +4 -0
- package/src/index.ts +1 -0
- package/src/layouts/PanelAlertDialog/PanelAlertDialog.tsx +40 -0
- package/src/layouts/PanelAlertDialog/index.ts +5 -0
- package/src/layouts/PanelDialog/PanelDialog.tsx +39 -0
- package/src/layouts/PanelDialog/index.ts +5 -0
- package/src/layouts/PanelPopover/PanelPopover.tsx +2 -2
- package/src/layouts/PanelSidebar/PanelSidebar.tsx +17 -25
- package/src/layouts/index.ts +2 -0
- package/src/panels/DevicesPanel/DevicesPanel.tsx +98 -0
- package/src/panels/DevicesPanel/index.ts +5 -0
- package/src/panels/JoinPanel/JoinHeading.tsx +85 -0
- package/src/panels/JoinPanel/JoinPanel.tsx +319 -0
- package/src/panels/JoinPanel/JoinPanelProps.ts +90 -0
- package/src/panels/JoinPanel/index.ts +6 -0
- package/src/panels/JoinPanel/view-states/AdditionMethodSelector.tsx +73 -0
- package/src/panels/JoinPanel/view-states/IdentityAdded.tsx +99 -0
- package/src/panels/JoinPanel/view-states/IdentityInput.tsx +79 -0
- package/src/panels/JoinPanel/view-states/IdentitySelector.tsx +101 -0
- package/src/panels/JoinPanel/view-states/InvitationAccepted.tsx +70 -0
- package/src/panels/JoinPanel/view-states/InvitationAuthenticator.tsx +142 -0
- package/src/panels/JoinPanel/view-states/InvitationInput.tsx +75 -0
- package/src/panels/JoinPanel/view-states/InvitationRescuer.tsx +98 -0
- package/src/panels/JoinPanel/view-states/ViewState.tsx +204 -0
- package/src/panels/JoinPanel/view-states/index.ts +12 -0
- package/src/panels/SpacePanel/SpacePanel.stories.tsx +53 -0
- package/src/panels/SpacePanel/SpacePanel.tsx +174 -0
- package/src/panels/SpacePanel/index.ts +5 -0
- package/src/panels/index.ts +3 -0
- package/src/styles/dialogStyles.ts +8 -0
- package/src/styles/index.ts +2 -0
- package/src/styles/invitationStatusStyles.ts +42 -0
- package/src/styles/panelStyles.ts +2 -1
- package/src/testing/ClientProvider.tsx +1 -1
- package/src/translations/locales/en-US.ts +53 -1
- package/src/util/index.ts +5 -0
- package/src/util/invitationStatusValue.ts +21 -0
- package/theme-extensions.js +11 -0
- package/dist/types/src/components/IdentityListItem/IdentityListItem.d.ts +0 -6
- package/dist/types/src/components/IdentityListItem/IdentityListItem.d.ts.map +0 -1
- package/dist/types/src/components/IdentityListItem/IdentityListItem.stories.d.ts.map +0 -1
|
@@ -4,21 +4,487 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// packages/apps/patterns/react-ui/src/
|
|
8
|
-
import
|
|
9
|
-
import { Avatar as Avatar2, mx as mx3 } from "@dxos/react-components";
|
|
7
|
+
// packages/apps/patterns/react-ui/src/components/IdentityList/DeviceList.tsx
|
|
8
|
+
import React2 from "react";
|
|
10
9
|
|
|
11
|
-
// packages/apps/patterns/react-ui/src/
|
|
10
|
+
// packages/apps/patterns/react-ui/src/components/IdentityList/IdentityListItem.tsx
|
|
12
11
|
import React from "react";
|
|
13
|
-
import {
|
|
12
|
+
import { SpaceMember } from "@dxos/client";
|
|
13
|
+
import { Avatar, mx, useTranslation } from "@dxos/react-components";
|
|
14
|
+
function _extends() {
|
|
15
|
+
_extends = Object.assign || function(target) {
|
|
16
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
17
|
+
var source = arguments[i];
|
|
18
|
+
for (var key in source) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20
|
+
target[key] = source[key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
return _extends.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
var IdentityListItem = ({ identity, presence, onClick }) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const { t } = useTranslation("os");
|
|
31
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
32
|
+
className: mx("flex gap-2 items-center", onClick && "cursor-pointer"),
|
|
33
|
+
onClick: () => onClick == null ? void 0 : onClick(),
|
|
34
|
+
"data-testid": "identity-list-item"
|
|
35
|
+
}, /* @__PURE__ */ React.createElement(Avatar, _extends({}, {
|
|
36
|
+
variant: "circle",
|
|
37
|
+
size: 9,
|
|
38
|
+
fallbackValue: identity.identityKey.toHex(),
|
|
39
|
+
label: /* @__PURE__ */ React.createElement("p", {
|
|
40
|
+
className: "text-sm truncate"
|
|
41
|
+
}, (_a = identity.displayName) != null ? _a : identity.identityKey.truncate()),
|
|
42
|
+
...presence === SpaceMember.PresenceState.OFFLINE && {
|
|
43
|
+
status: "inactive",
|
|
44
|
+
description: /* @__PURE__ */ React.createElement("p", {
|
|
45
|
+
className: "font-system-normal text-xs text-neutral-700 dark:text-neutral-300"
|
|
46
|
+
}, t("identity offline description"))
|
|
47
|
+
},
|
|
48
|
+
...presence === SpaceMember.PresenceState.ONLINE && {
|
|
49
|
+
status: "active"
|
|
50
|
+
},
|
|
51
|
+
slots: {
|
|
52
|
+
labels: {
|
|
53
|
+
className: "block shrink overflow-hidden"
|
|
54
|
+
},
|
|
55
|
+
root: {
|
|
56
|
+
className: "shrink-0"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
})));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// packages/apps/patterns/react-ui/src/components/IdentityList/DeviceList.tsx
|
|
63
|
+
var DeviceList = ({ devices, onSelect }) => {
|
|
64
|
+
return /* @__PURE__ */ React2.createElement("ul", {
|
|
65
|
+
className: "flex flex-col gap-2"
|
|
66
|
+
}, devices.map((device) => {
|
|
67
|
+
const identity = {
|
|
68
|
+
identityKey: device.publicKey,
|
|
69
|
+
displayName: device.displayName
|
|
70
|
+
};
|
|
71
|
+
return /* @__PURE__ */ React2.createElement(IdentityListItem, {
|
|
72
|
+
key: device.publicKey.toHex(),
|
|
73
|
+
identity,
|
|
74
|
+
onClick: onSelect && (() => onSelect(device))
|
|
75
|
+
});
|
|
76
|
+
}));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// packages/apps/patterns/react-ui/src/components/IdentityList/SpaceMemberList.tsx
|
|
80
|
+
import React3 from "react";
|
|
81
|
+
var SpaceMemberList = ({ members, onSelect }) => {
|
|
82
|
+
return /* @__PURE__ */ React3.createElement("ul", {
|
|
83
|
+
className: "flex flex-col gap-2"
|
|
84
|
+
}, members.filter((member) => member.profile).map((member) => {
|
|
85
|
+
return /* @__PURE__ */ React3.createElement(IdentityListItem, {
|
|
86
|
+
key: member.identityKey.toHex(),
|
|
87
|
+
identity: member.profile,
|
|
88
|
+
presence: member.presence,
|
|
89
|
+
onClick: onSelect && (() => onSelect(member))
|
|
90
|
+
});
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// packages/apps/patterns/react-ui/src/components/IdentityList/SpaceMemberListContainer.tsx
|
|
95
|
+
import React4, { useMemo } from "react";
|
|
96
|
+
import { useClient, useMembers } from "@dxos/react-client";
|
|
97
|
+
var SpaceMemberListContainer = ({ spaceKey, includeSelf, onSelect }) => {
|
|
98
|
+
const client = useClient();
|
|
99
|
+
const allUnsortedMembers = useMembers(spaceKey);
|
|
100
|
+
const members = useMemo(() => includeSelf ? allUnsortedMembers.sort((a) => a.identityKey.equals(client.halo.profile.identityKey) ? -1 : 1) : allUnsortedMembers.filter((member) => !member.identityKey.equals(client.halo.profile.identityKey)), [
|
|
101
|
+
allUnsortedMembers
|
|
102
|
+
]);
|
|
103
|
+
return /* @__PURE__ */ React4.createElement(SpaceMemberList, {
|
|
104
|
+
members,
|
|
105
|
+
onSelect
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// packages/apps/patterns/react-ui/src/components/InvitationList/InvitationStatusAvatar.tsx
|
|
110
|
+
import React5 from "react";
|
|
111
|
+
import { Invitation as Invitation3 } from "@dxos/client";
|
|
112
|
+
import { getSize, mx as mx2 } from "@dxos/react-components";
|
|
113
|
+
|
|
114
|
+
// packages/apps/patterns/react-ui/src/styles/dialogStyles.ts
|
|
115
|
+
var defaultOverlay = "fixed inset-0 backdrop-blur z-50 overflow-auto grid place-items-center p-2 md:p-4 lg:p-8";
|
|
116
|
+
var defaultDialogContent = "is-full min-is-[260px] max-is-[320px] rounded-md shadow-md backdrop-blur-md";
|
|
14
117
|
|
|
15
118
|
// packages/apps/patterns/react-ui/src/styles/panelStyles.ts
|
|
16
|
-
var
|
|
119
|
+
var defaultSurface = "bg-neutral-50/[.72] dark:bg-neutral-950/[.72]";
|
|
120
|
+
var subduedSurface = "bg-neutral-100/[.66] dark:bg-neutral-900/[.66]";
|
|
17
121
|
var defaultArrow = "text-neutral-50/[.66] dark:text-neutral-950/[.66]";
|
|
18
122
|
|
|
123
|
+
// packages/apps/patterns/react-ui/src/styles/invitationStatusStyles.ts
|
|
124
|
+
import { Invitation } from "@dxos/client";
|
|
125
|
+
var inactiveBgColor = "bg-neutral-100 dark:bg-neutral-600";
|
|
126
|
+
var activeBgColor = "bg-primary-500 dark:bg-primary-400";
|
|
127
|
+
var successBgColor = "bg-success-500 dark:bg-success-400";
|
|
128
|
+
var errorBgColor = "bg-error-500 dark:bg-error-400";
|
|
129
|
+
var cancelledBgColor = "bg-warning-500 dark:bg-warning-400";
|
|
130
|
+
var inactiveTextColor = "text-neutral-100 dark:text-neutral-600";
|
|
131
|
+
var activeTextColor = "text-primary-400 dark:text-primary-500";
|
|
132
|
+
var successTextColor = "text-success-400 dark:text-success-500";
|
|
133
|
+
var errorTextColor = "text-error-400 dark:text-error-500";
|
|
134
|
+
var cancelledTextColor = "text-warning-400 dark:text-warning-500";
|
|
135
|
+
var inactiveStrokeColor = "stroke-neutral-100 dark:stroke-neutral-700";
|
|
136
|
+
var activeStrokeColor = "stroke-primary-500 dark:stroke-primary-150";
|
|
137
|
+
var successStrokeColor = "stroke-success-400 dark:stroke-primary-400";
|
|
138
|
+
var errorStrokeColor = "stroke-error-400 dark:stroke-error-500";
|
|
139
|
+
var cancelledStrokeColor = "stroke-warning-400 dark:stroke-warning-500";
|
|
140
|
+
var resolvedStrokeColor = (status) => status === Invitation.State.ERROR ? errorStrokeColor : status === Invitation.State.CANCELLED || status === Invitation.State.TIMEOUT ? cancelledStrokeColor : successStrokeColor;
|
|
141
|
+
var resolvedBgColor = (status) => status === Invitation.State.ERROR ? errorBgColor : status === Invitation.State.CANCELLED || status === Invitation.State.TIMEOUT ? cancelledBgColor : successBgColor;
|
|
142
|
+
var resolvedTextColor = (status) => status === Invitation.State.ERROR ? errorTextColor : status === Invitation.State.CANCELLED || status === Invitation.State.TIMEOUT ? cancelledTextColor : successTextColor;
|
|
143
|
+
|
|
144
|
+
// packages/apps/patterns/react-ui/src/util/invitationStatusValue.ts
|
|
145
|
+
import { Invitation as Invitation2 } from "@dxos/client";
|
|
146
|
+
var invitationStatusValue = /* @__PURE__ */ new Map([
|
|
147
|
+
[
|
|
148
|
+
Invitation2.State.ERROR,
|
|
149
|
+
-3
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
Invitation2.State.TIMEOUT,
|
|
153
|
+
-2
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
Invitation2.State.CANCELLED,
|
|
157
|
+
-1
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
Invitation2.State.INIT,
|
|
161
|
+
0
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
Invitation2.State.CONNECTING,
|
|
165
|
+
1
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
Invitation2.State.CONNECTED,
|
|
169
|
+
2
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
Invitation2.State.AUTHENTICATING,
|
|
173
|
+
3
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
Invitation2.State.SUCCESS,
|
|
177
|
+
4
|
|
178
|
+
]
|
|
179
|
+
]);
|
|
180
|
+
|
|
181
|
+
// packages/apps/patterns/react-ui/src/components/InvitationList/InvitationStatusAvatar.tsx
|
|
182
|
+
function _extends2() {
|
|
183
|
+
_extends2 = Object.assign || function(target) {
|
|
184
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
185
|
+
var source = arguments[i];
|
|
186
|
+
for (var key in source) {
|
|
187
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
188
|
+
target[key] = source[key];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return target;
|
|
193
|
+
};
|
|
194
|
+
return _extends2.apply(this, arguments);
|
|
195
|
+
}
|
|
196
|
+
var svgSize = 32;
|
|
197
|
+
var strokeWidth = 5;
|
|
198
|
+
var radius = (svgSize - strokeWidth) / 2;
|
|
199
|
+
var circumference = Math.PI * 2 * radius;
|
|
200
|
+
var gap = circumference / 12;
|
|
201
|
+
var nSegments = 3;
|
|
202
|
+
var segment = circumference / nSegments;
|
|
203
|
+
var baseOffset = 2 * circumference / 3 - (segment - gap) / 2;
|
|
204
|
+
var circleProps = {
|
|
205
|
+
fill: "none",
|
|
206
|
+
strokeLinecap: "round",
|
|
207
|
+
cx: svgSize / 2,
|
|
208
|
+
cy: svgSize / 2,
|
|
209
|
+
r: radius,
|
|
210
|
+
strokeWidth,
|
|
211
|
+
strokeDasharray: `${segment - gap} ${2 * segment + gap}`
|
|
212
|
+
};
|
|
213
|
+
var InvitationStatusAvatar = ({ size = 10, status, haltedAt, slots = {} }) => {
|
|
214
|
+
var _a;
|
|
215
|
+
const resolvedColor = resolvedStrokeColor(status);
|
|
216
|
+
const halted = status === Invitation3.State.CANCELLED || status === Invitation3.State.TIMEOUT || status === Invitation3.State.ERROR;
|
|
217
|
+
const cursor = invitationStatusValue.get(halted ? haltedAt : status);
|
|
218
|
+
return /* @__PURE__ */ React5.createElement("svg", _extends2({}, slots.svg, {
|
|
219
|
+
viewBox: `0 0 ${svgSize} ${svgSize}`,
|
|
220
|
+
className: mx2(getSize(size), (_a = slots.svg) == null ? void 0 : _a.className)
|
|
221
|
+
}), [
|
|
222
|
+
...Array(nSegments)
|
|
223
|
+
].map((_, index) => /* @__PURE__ */ React5.createElement("circle", _extends2({
|
|
224
|
+
key: index
|
|
225
|
+
}, circleProps, {
|
|
226
|
+
strokeDashoffset: index * segment + baseOffset,
|
|
227
|
+
className: index === 0 ? cursor === 1 ? halted ? resolvedColor : activeStrokeColor : cursor > 1 ? resolvedColor : inactiveStrokeColor : index === 1 ? cursor === 3 ? halted ? resolvedColor : activeStrokeColor : cursor > 3 ? resolvedColor : inactiveStrokeColor : cursor > 3 ? resolvedColor : inactiveStrokeColor
|
|
228
|
+
}))));
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// packages/apps/patterns/react-ui/src/components/InvitationList/InvitationListItem.tsx
|
|
232
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
233
|
+
import { Copy, ProhibitInset, QrCode, X } from "phosphor-react";
|
|
234
|
+
import { QRCodeSVG } from "qrcode.react";
|
|
235
|
+
import React6, { useCallback } from "react";
|
|
236
|
+
import { useInvitationStatus } from "@dxos/react-client";
|
|
237
|
+
import { Button, getSize as getSize2, mx as mx3, useId, useTranslation as useTranslation2 } from "@dxos/react-components";
|
|
238
|
+
function _extends3() {
|
|
239
|
+
_extends3 = Object.assign || function(target) {
|
|
240
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
241
|
+
var source = arguments[i];
|
|
242
|
+
for (var key in source) {
|
|
243
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
244
|
+
target[key] = source[key];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return target;
|
|
249
|
+
};
|
|
250
|
+
return _extends3.apply(this, arguments);
|
|
251
|
+
}
|
|
252
|
+
var InvitationListItem = ({ invitation, value, onClickRemove, createInvitationUrl }) => {
|
|
253
|
+
var _a;
|
|
254
|
+
const { t } = useTranslation2("os");
|
|
255
|
+
const qrLabel = useId("qrLabel");
|
|
256
|
+
const { cancel, status, haltedAt, invitationCode, authenticationCode } = useInvitationStatus(invitation);
|
|
257
|
+
const statusValue = (_a = invitationStatusValue.get(status)) != null ? _a : 0;
|
|
258
|
+
const isCancellable = statusValue < 4 && statusValue >= 0;
|
|
259
|
+
const showShare = statusValue < 3 && statusValue >= 0;
|
|
260
|
+
const showAuthCode = statusValue === 3;
|
|
261
|
+
const handleClickRemove = useCallback(() => onClickRemove(invitation), [
|
|
262
|
+
invitation,
|
|
263
|
+
onClickRemove
|
|
264
|
+
]);
|
|
265
|
+
const invitationUrl = invitationCode && createInvitationUrl(invitationCode);
|
|
266
|
+
const handleClickCopy = useCallback(() => {
|
|
267
|
+
if (invitationUrl) {
|
|
268
|
+
void navigator.clipboard.writeText(invitationUrl);
|
|
269
|
+
}
|
|
270
|
+
}, [
|
|
271
|
+
invitationUrl
|
|
272
|
+
]);
|
|
273
|
+
return /* @__PURE__ */ React6.createElement(AccordionPrimitive.Item, {
|
|
274
|
+
value
|
|
275
|
+
}, /* @__PURE__ */ React6.createElement(AccordionPrimitive.Header, {
|
|
276
|
+
className: "flex gap-2 items-center"
|
|
277
|
+
}, /* @__PURE__ */ React6.createElement(InvitationStatusAvatar, _extends3({}, {
|
|
278
|
+
status,
|
|
279
|
+
haltedAt,
|
|
280
|
+
size: 8
|
|
281
|
+
})), showShare && invitationUrl ? /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(AccordionPrimitive.Trigger, {
|
|
282
|
+
asChild: true
|
|
283
|
+
}, /* @__PURE__ */ React6.createElement(Button, {
|
|
284
|
+
className: "grow flex gap-1",
|
|
285
|
+
"data-testid": "show-qrcode"
|
|
286
|
+
}, /* @__PURE__ */ React6.createElement("span", null, t("open share panel label")), /* @__PURE__ */ React6.createElement(QrCode, {
|
|
287
|
+
className: getSize2(4),
|
|
288
|
+
weight: "bold"
|
|
289
|
+
}))), /* @__PURE__ */ React6.createElement(Button, {
|
|
290
|
+
className: "flex gap-1",
|
|
291
|
+
onClick: handleClickCopy,
|
|
292
|
+
"data-testid": "copy-invitation"
|
|
293
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
294
|
+
className: "pli-1"
|
|
295
|
+
}, t("copy invitation code label")), /* @__PURE__ */ React6.createElement(Copy, {
|
|
296
|
+
className: getSize2(4),
|
|
297
|
+
weight: "bold"
|
|
298
|
+
}))) : showAuthCode ? /* @__PURE__ */ React6.createElement("p", {
|
|
299
|
+
className: "grow text-xl text-center text-success-500 dark:text-success-300 font-mono"
|
|
300
|
+
}, authenticationCode) : /* @__PURE__ */ React6.createElement("span", {
|
|
301
|
+
role: "none",
|
|
302
|
+
className: "grow"
|
|
303
|
+
}), isCancellable ? /* @__PURE__ */ React6.createElement(Button, {
|
|
304
|
+
variant: "ghost",
|
|
305
|
+
compact: true,
|
|
306
|
+
className: "flex gap-1",
|
|
307
|
+
onClick: cancel,
|
|
308
|
+
"data-testid": "cancel-invitation"
|
|
309
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
310
|
+
className: "sr-only"
|
|
311
|
+
}, t("cancel invitation label")), /* @__PURE__ */ React6.createElement(ProhibitInset, {
|
|
312
|
+
className: getSize2(4),
|
|
313
|
+
weight: "bold"
|
|
314
|
+
})) : /* @__PURE__ */ React6.createElement(Button, {
|
|
315
|
+
variant: "ghost",
|
|
316
|
+
compact: true,
|
|
317
|
+
className: "flex gap-1",
|
|
318
|
+
onClick: handleClickRemove,
|
|
319
|
+
"data-testid": "remove-invitation"
|
|
320
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
321
|
+
className: "sr-only"
|
|
322
|
+
}, t("remove invitation label")), /* @__PURE__ */ React6.createElement(X, {
|
|
323
|
+
className: getSize2(4),
|
|
324
|
+
weight: "bold"
|
|
325
|
+
}))), showShare && invitationUrl && /* @__PURE__ */ React6.createElement(AccordionPrimitive.Content, {
|
|
326
|
+
className: "flex gap-2 is-full radix-state-open:p-1 items-center"
|
|
327
|
+
}, /* @__PURE__ */ React6.createElement(QRCodeSVG, {
|
|
328
|
+
bgColor: "transparent",
|
|
329
|
+
fgColor: "currentColor",
|
|
330
|
+
value: invitationUrl,
|
|
331
|
+
className: mx3("grow-[2] aspect-square is-24 bs-auto"),
|
|
332
|
+
"aria-labelledby": qrLabel
|
|
333
|
+
}), /* @__PURE__ */ React6.createElement("span", {
|
|
334
|
+
className: "pli-1 flex-1 font-system-normal text-sm text-center",
|
|
335
|
+
id: qrLabel
|
|
336
|
+
}, t("qr label"))));
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// packages/apps/patterns/react-ui/src/components/InvitationList/InvitationListContainer.tsx
|
|
340
|
+
import React8, { useCallback as useCallback2 } from "react";
|
|
341
|
+
import { useSpace, useSpaceInvitations } from "@dxos/react-client";
|
|
342
|
+
|
|
343
|
+
// packages/apps/patterns/react-ui/src/components/InvitationList/InvitationList.tsx
|
|
344
|
+
import { Root as AccordionRoot } from "@radix-ui/react-accordion";
|
|
345
|
+
import React7 from "react";
|
|
346
|
+
import { defaultDescription, mx as mx4, useTranslation as useTranslation3 } from "@dxos/react-components";
|
|
347
|
+
function _extends4() {
|
|
348
|
+
_extends4 = Object.assign || function(target) {
|
|
349
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
350
|
+
var source = arguments[i];
|
|
351
|
+
for (var key in source) {
|
|
352
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
353
|
+
target[key] = source[key];
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return target;
|
|
358
|
+
};
|
|
359
|
+
return _extends4.apply(this, arguments);
|
|
360
|
+
}
|
|
361
|
+
var InvitationList = ({ invitations, ...invitationProps }) => {
|
|
362
|
+
const { t } = useTranslation3("os");
|
|
363
|
+
return invitations.length ? /* @__PURE__ */ React7.createElement(AccordionRoot, {
|
|
364
|
+
type: "single",
|
|
365
|
+
collapsible: true,
|
|
366
|
+
className: "flex flex-col gap-1"
|
|
367
|
+
}, invitations.map((invitation, index) => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
const value = (_b = (_a = invitation.invitation) == null ? void 0 : _a.invitationId) != null ? _b : `inv_${index}`;
|
|
370
|
+
return /* @__PURE__ */ React7.createElement(InvitationListItem, _extends4({
|
|
371
|
+
key: value,
|
|
372
|
+
value,
|
|
373
|
+
invitation
|
|
374
|
+
}, invitationProps));
|
|
375
|
+
})) : /* @__PURE__ */ React7.createElement("p", {
|
|
376
|
+
className: mx4(defaultDescription, "text-center p-2")
|
|
377
|
+
}, t("empty invitations message"));
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// packages/apps/patterns/react-ui/src/components/InvitationList/InvitationListContainer.tsx
|
|
381
|
+
function _extends5() {
|
|
382
|
+
_extends5 = Object.assign || function(target) {
|
|
383
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
384
|
+
var source = arguments[i];
|
|
385
|
+
for (var key in source) {
|
|
386
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
387
|
+
target[key] = source[key];
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return target;
|
|
392
|
+
};
|
|
393
|
+
return _extends5.apply(this, arguments);
|
|
394
|
+
}
|
|
395
|
+
var InvitationListContainer = ({ spaceKey, createInvitationUrl }) => {
|
|
396
|
+
const space = useSpace(spaceKey);
|
|
397
|
+
const invitations = useSpaceInvitations(spaceKey);
|
|
398
|
+
const onClickRemove = useCallback2(({ invitation }) => {
|
|
399
|
+
(invitation == null ? void 0 : invitation.invitationId) && (space == null ? void 0 : space.removeInvitation(invitation.invitationId));
|
|
400
|
+
}, [
|
|
401
|
+
space
|
|
402
|
+
]);
|
|
403
|
+
return /* @__PURE__ */ React8.createElement(InvitationList, _extends5({
|
|
404
|
+
invitations
|
|
405
|
+
}, {
|
|
406
|
+
onClickRemove,
|
|
407
|
+
createInvitationUrl
|
|
408
|
+
}));
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// packages/apps/patterns/react-ui/src/components/PanelSeparator/PanelSeparator.tsx
|
|
412
|
+
import React9 from "react";
|
|
413
|
+
import { mx as mx5 } from "@dxos/react-components";
|
|
414
|
+
function _extends6() {
|
|
415
|
+
_extends6 = Object.assign || function(target) {
|
|
416
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
417
|
+
var source = arguments[i];
|
|
418
|
+
for (var key in source) {
|
|
419
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
420
|
+
target[key] = source[key];
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return target;
|
|
425
|
+
};
|
|
426
|
+
return _extends6.apply(this, arguments);
|
|
427
|
+
}
|
|
428
|
+
var PanelSeparator = ({ className, ...props }) => {
|
|
429
|
+
return /* @__PURE__ */ React9.createElement("span", _extends6({
|
|
430
|
+
role: "none"
|
|
431
|
+
}, props, {
|
|
432
|
+
className: mx5("block bs-px mlb-1 bg-neutral-800/10 dark:bg-neutral-200/10", className)
|
|
433
|
+
}));
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// packages/apps/patterns/react-ui/src/components/SpaceList/SpaceListItem.tsx
|
|
437
|
+
import React10, { forwardRef } from "react";
|
|
438
|
+
import { Avatar as Avatar2, mx as mx6 } from "@dxos/react-components";
|
|
439
|
+
import { humanize } from "@dxos/util";
|
|
440
|
+
function _extends7() {
|
|
441
|
+
_extends7 = Object.assign || function(target) {
|
|
442
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
443
|
+
var source = arguments[i];
|
|
444
|
+
for (var key in source) {
|
|
445
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
446
|
+
target[key] = source[key];
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return target;
|
|
451
|
+
};
|
|
452
|
+
return _extends7.apply(this, arguments);
|
|
453
|
+
}
|
|
454
|
+
var SpaceListItem = /* @__PURE__ */ forwardRef(({ space, onClick }, ref) => {
|
|
455
|
+
var _a;
|
|
456
|
+
return /* @__PURE__ */ React10.createElement("li", {
|
|
457
|
+
className: mx6("flex gap-2 items-center", onClick && "cursor-pointer"),
|
|
458
|
+
onClick: () => onClick == null ? void 0 : onClick(),
|
|
459
|
+
ref,
|
|
460
|
+
"data-testid": "space-list-item"
|
|
461
|
+
}, /* @__PURE__ */ React10.createElement(Avatar2, _extends7({}, {
|
|
462
|
+
variant: "circle",
|
|
463
|
+
size: 9,
|
|
464
|
+
fallbackValue: space.key.toHex(),
|
|
465
|
+
label: /* @__PURE__ */ React10.createElement("p", {
|
|
466
|
+
className: "text-sm truncate"
|
|
467
|
+
}, (_a = space.properties.name) != null ? _a : humanize(space.key)),
|
|
468
|
+
slots: {
|
|
469
|
+
labels: {
|
|
470
|
+
className: "block shrink overflow-hidden"
|
|
471
|
+
},
|
|
472
|
+
root: {
|
|
473
|
+
className: "shrink-0"
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
})));
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// packages/apps/patterns/react-ui/src/composites/IdentityPopover/IdentityPopover.tsx
|
|
480
|
+
import React29 from "react";
|
|
481
|
+
import { Avatar as Avatar8, mx as mx23 } from "@dxos/react-components";
|
|
482
|
+
|
|
19
483
|
// packages/apps/patterns/react-ui/src/layouts/PanelPopover/PanelPopover.tsx
|
|
20
|
-
|
|
21
|
-
|
|
484
|
+
import React11 from "react";
|
|
485
|
+
import { mx as mx7, Popover } from "@dxos/react-components";
|
|
486
|
+
function _extends8() {
|
|
487
|
+
_extends8 = Object.assign || function(target) {
|
|
22
488
|
for (var i = 1; i < arguments.length; i++) {
|
|
23
489
|
var source = arguments[i];
|
|
24
490
|
for (var key in source) {
|
|
@@ -29,25 +495,25 @@ function _extends() {
|
|
|
29
495
|
}
|
|
30
496
|
return target;
|
|
31
497
|
};
|
|
32
|
-
return
|
|
498
|
+
return _extends8.apply(this, arguments);
|
|
33
499
|
}
|
|
34
500
|
var PanelPopover = ({ slots, children, ...popoverProps }) => {
|
|
35
501
|
var _a, _b, _c;
|
|
36
|
-
return /* @__PURE__ */
|
|
502
|
+
return /* @__PURE__ */ React11.createElement(Popover, _extends8({
|
|
37
503
|
slots: {
|
|
38
504
|
arrow: {
|
|
39
505
|
...slots == null ? void 0 : slots.arrow,
|
|
40
|
-
className:
|
|
506
|
+
className: mx7(defaultArrow, (_a = slots == null ? void 0 : slots.arrow) == null ? void 0 : _a.className)
|
|
41
507
|
},
|
|
42
508
|
content: {
|
|
43
509
|
collisionPadding: 8,
|
|
44
510
|
sideOffset: 4,
|
|
45
511
|
...slots == null ? void 0 : slots.content,
|
|
46
|
-
className:
|
|
512
|
+
className: mx7(defaultSurface, (_b = slots == null ? void 0 : slots.content) == null ? void 0 : _b.className)
|
|
47
513
|
},
|
|
48
514
|
trigger: {
|
|
49
515
|
...slots == null ? void 0 : slots.trigger,
|
|
50
|
-
className:
|
|
516
|
+
className: mx7("", (_c = slots == null ? void 0 : slots.trigger) == null ? void 0 : _c.className)
|
|
51
517
|
},
|
|
52
518
|
...slots
|
|
53
519
|
}
|
|
@@ -56,10 +522,10 @@ var PanelPopover = ({ slots, children, ...popoverProps }) => {
|
|
|
56
522
|
|
|
57
523
|
// packages/apps/patterns/react-ui/src/layouts/PanelSidebar/PanelSidebar.tsx
|
|
58
524
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
59
|
-
import
|
|
60
|
-
import { defaultOverlay, mx as
|
|
61
|
-
function
|
|
62
|
-
|
|
525
|
+
import React12, { createContext, useCallback as useCallback3, useContext, useState } from "react";
|
|
526
|
+
import { defaultOverlay as defaultOverlay2, mx as mx8, useMediaQuery, useTranslation as useTranslation4 } from "@dxos/react-components";
|
|
527
|
+
function _extends9() {
|
|
528
|
+
_extends9 = Object.assign || function(target) {
|
|
63
529
|
for (var i = 1; i < arguments.length; i++) {
|
|
64
530
|
var source = arguments[i];
|
|
65
531
|
for (var key in source) {
|
|
@@ -70,7 +536,7 @@ function _extends2() {
|
|
|
70
536
|
}
|
|
71
537
|
return target;
|
|
72
538
|
};
|
|
73
|
-
return
|
|
539
|
+
return _extends9.apply(this, arguments);
|
|
74
540
|
}
|
|
75
541
|
var PanelSidebarContext = /* @__PURE__ */ createContext({
|
|
76
542
|
displayState: "hide",
|
|
@@ -79,16 +545,18 @@ var PanelSidebarContext = /* @__PURE__ */ createContext({
|
|
|
79
545
|
});
|
|
80
546
|
var useTogglePanelSidebar = () => {
|
|
81
547
|
const { displayState, setDisplayState } = useContext(PanelSidebarContext);
|
|
82
|
-
return
|
|
548
|
+
return useCallback3(() => {
|
|
83
549
|
setDisplayState(displayState === "hide" ? "show" : "hide");
|
|
84
550
|
}, [
|
|
85
551
|
displayState
|
|
86
552
|
]);
|
|
87
553
|
};
|
|
88
|
-
var PanelSidebarProvider = ({ children,
|
|
89
|
-
var _a, _b, _c
|
|
90
|
-
const { t } =
|
|
91
|
-
const [isLg] = useMediaQuery("lg"
|
|
554
|
+
var PanelSidebarProvider = ({ children, slots }) => {
|
|
555
|
+
var _a, _b, _c;
|
|
556
|
+
const { t } = useTranslation4("os");
|
|
557
|
+
const [isLg] = useMediaQuery("lg", {
|
|
558
|
+
ssr: false
|
|
559
|
+
});
|
|
92
560
|
const [displayState, setInternalDisplayState] = useState(isLg ? "show" : "hide");
|
|
93
561
|
const isOpen = displayState === "show";
|
|
94
562
|
const [transitionShow, setTransitionShow] = useState(isOpen);
|
|
@@ -108,65 +576,223 @@ var PanelSidebarProvider = ({ children, inlineStart, slots }) => {
|
|
|
108
576
|
}, 0);
|
|
109
577
|
};
|
|
110
578
|
const setDisplayState = (displayState2) => displayState2 === "show" ? internalShow() : internalHide();
|
|
111
|
-
return /* @__PURE__ */
|
|
579
|
+
return /* @__PURE__ */ React12.createElement(PanelSidebarContext.Provider, {
|
|
112
580
|
value: {
|
|
113
581
|
setDisplayState,
|
|
114
582
|
displayState
|
|
115
583
|
}
|
|
116
|
-
}, /* @__PURE__ */
|
|
584
|
+
}, /* @__PURE__ */ React12.createElement(DialogPrimitive.Root, {
|
|
117
585
|
open: domShow,
|
|
118
586
|
modal: !isLg
|
|
119
|
-
}, /* @__PURE__ */
|
|
120
|
-
|
|
121
|
-
|
|
587
|
+
}, /* @__PURE__ */ React12.createElement(DialogPrimitive.Content, _extends9({
|
|
588
|
+
onOpenAutoFocus: (event) => isLg && event.preventDefault(),
|
|
589
|
+
onCloseAutoFocus: (event) => isLg && event.preventDefault()
|
|
590
|
+
}, slots == null ? void 0 : slots.content, {
|
|
591
|
+
className: mx8("fixed block-start-0 block-end-0 is-sidebar z-30 overscroll-contain overflow-x-hidden overflow-y-auto", "transition-[inset-inline-start,inset-inline-end] duration-200 ease-in-out", transitionShow ? "inline-start-0" : "-inline-start-sidebar", (_a = slots == null ? void 0 : slots.content) == null ? void 0 : _a.className)
|
|
592
|
+
}), /* @__PURE__ */ React12.createElement(DialogPrimitive.Title, {
|
|
122
593
|
className: "sr-only"
|
|
123
|
-
}, t("sidebar label")), (_b = slots == null ? void 0 : slots.content) == null ? void 0 : _b.children),
|
|
124
|
-
|
|
125
|
-
}, slots == null ? void 0 : slots.fixedBlockStart, {
|
|
126
|
-
className: mx2("fixed inline-end-0 block-start-0 z-[49] transition-[inset-inline-start,inset-inline-end] duration-200 ease-in-out", transitionShow ? "inline-start-[272px]" : "inline-start-0", (_c = slots == null ? void 0 : slots.fixedBlockStart) == null ? void 0 : _c.className)
|
|
127
|
-
}), (_d = slots == null ? void 0 : slots.fixedBlockStart) == null ? void 0 : _d.children), !isLg && /* @__PURE__ */ React2.createElement(DialogPrimitive.Overlay, {
|
|
128
|
-
className: mx2(defaultOverlay, "transition-opacity duration-200 ease-in-out", transitionShow ? "opacity-100" : "opacity-0"),
|
|
594
|
+
}, t("sidebar label")), (_b = slots == null ? void 0 : slots.content) == null ? void 0 : _b.children), !isLg && /* @__PURE__ */ React12.createElement(DialogPrimitive.Overlay, {
|
|
595
|
+
className: mx8(defaultOverlay2, "transition-opacity duration-200 ease-in-out", transitionShow ? "opacity-100" : "opacity-0"),
|
|
129
596
|
onClick: internalHide
|
|
130
|
-
}), /* @__PURE__ */
|
|
597
|
+
}), /* @__PURE__ */ React12.createElement("div", _extends9({
|
|
598
|
+
role: "none"
|
|
599
|
+
}, slots == null ? void 0 : slots.main, {
|
|
600
|
+
className: mx8("transition-[padding-inline-start] duration-200 ease-in-out", isLg && isOpen ? "pis-sidebar" : "pis-0", (_c = slots == null ? void 0 : slots.main) == null ? void 0 : _c.className)
|
|
601
|
+
}), children)));
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
// packages/apps/patterns/react-ui/src/layouts/PanelAlertDialog/PanelAlertDialog.tsx
|
|
605
|
+
import * as AlertDialog from "@radix-ui/react-alert-dialog";
|
|
606
|
+
import React13 from "react";
|
|
607
|
+
import { mx as mx9 } from "@dxos/react-components";
|
|
608
|
+
function _extends10() {
|
|
609
|
+
_extends10 = Object.assign || function(target) {
|
|
610
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
611
|
+
var source = arguments[i];
|
|
612
|
+
for (var key in source) {
|
|
613
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
614
|
+
target[key] = source[key];
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return target;
|
|
619
|
+
};
|
|
620
|
+
return _extends10.apply(this, arguments);
|
|
621
|
+
}
|
|
622
|
+
var PanelAlertDialog = ({ titleId, slots = {}, children }) => {
|
|
623
|
+
var _a, _b;
|
|
624
|
+
return /* @__PURE__ */ React13.createElement(AlertDialog.Root, _extends10({
|
|
625
|
+
defaultOpen: true
|
|
626
|
+
}, slots.root), slots.trigger && /* @__PURE__ */ React13.createElement(AlertDialog.Trigger, _extends10({}, slots.trigger)), /* @__PURE__ */ React13.createElement(AlertDialog.Overlay, _extends10({}, slots.overlay, {
|
|
627
|
+
className: mx9(defaultOverlay, "z-40", (_a = slots.overlay) == null ? void 0 : _a.className)
|
|
628
|
+
}), /* @__PURE__ */ React13.createElement(AlertDialog.Content, _extends10({
|
|
629
|
+
onEscapeKeyDown: (event) => event.preventDefault()
|
|
630
|
+
}, slots.content, {
|
|
631
|
+
"aria-labelledby": titleId,
|
|
632
|
+
className: mx9(defaultDialogContent, (_b = slots.content) == null ? void 0 : _b.className)
|
|
633
|
+
}), children)));
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
// packages/apps/patterns/react-ui/src/layouts/PanelDialog/PanelDialog.tsx
|
|
637
|
+
import * as Dialog from "@radix-ui/react-dialog";
|
|
638
|
+
import React14 from "react";
|
|
639
|
+
import { mx as mx10 } from "@dxos/react-components";
|
|
640
|
+
function _extends11() {
|
|
641
|
+
_extends11 = Object.assign || function(target) {
|
|
642
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
643
|
+
var source = arguments[i];
|
|
644
|
+
for (var key in source) {
|
|
645
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
646
|
+
target[key] = source[key];
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return target;
|
|
651
|
+
};
|
|
652
|
+
return _extends11.apply(this, arguments);
|
|
653
|
+
}
|
|
654
|
+
var PanelDialog = ({ titleId, slots = {}, children }) => {
|
|
655
|
+
var _a, _b;
|
|
656
|
+
return /* @__PURE__ */ React14.createElement(Dialog.Root, _extends11({
|
|
657
|
+
defaultOpen: true
|
|
658
|
+
}, slots.root), slots.trigger && /* @__PURE__ */ React14.createElement(Dialog.Trigger, _extends11({}, slots.trigger)), /* @__PURE__ */ React14.createElement(Dialog.Overlay, _extends11({}, slots.overlay, {
|
|
659
|
+
className: mx10(defaultOverlay, "z-40", (_a = slots.overlay) == null ? void 0 : _a.className)
|
|
660
|
+
}), /* @__PURE__ */ React14.createElement(Dialog.Content, _extends11({}, slots.content, {
|
|
661
|
+
"aria-labelledby": titleId,
|
|
662
|
+
className: mx10(defaultDialogContent, (_b = slots.content) == null ? void 0 : _b.className)
|
|
663
|
+
}), children)));
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// packages/apps/patterns/react-ui/src/panels/DevicesPanel/DevicesPanel.tsx
|
|
667
|
+
import { UserPlus, X as X2 } from "phosphor-react";
|
|
668
|
+
import React15, { cloneElement, useReducer } from "react";
|
|
669
|
+
import { useClient as useClient2, useDevices, useHaloInvitations, useIdentity } from "@dxos/react-client";
|
|
670
|
+
import { Button as Button2, getSize as getSize3, mx as mx11, Tooltip, useTranslation as useTranslation5 } from "@dxos/react-components";
|
|
671
|
+
function _extends12() {
|
|
672
|
+
_extends12 = Object.assign || function(target) {
|
|
673
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
674
|
+
var source = arguments[i];
|
|
675
|
+
for (var key in source) {
|
|
676
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
677
|
+
target[key] = source[key];
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return target;
|
|
682
|
+
};
|
|
683
|
+
return _extends12.apply(this, arguments);
|
|
684
|
+
}
|
|
685
|
+
var DeviceListView = ({ createInvitationUrl, titleId, onDone, doneActionParent }) => {
|
|
686
|
+
const { t } = useTranslation5("os");
|
|
687
|
+
const client = useClient2();
|
|
688
|
+
const identity = useIdentity();
|
|
689
|
+
const devices = useDevices();
|
|
690
|
+
const invitations = useHaloInvitations();
|
|
691
|
+
const displayName = identity == null ? void 0 : identity.displayName;
|
|
692
|
+
if (!identity) {
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
const doneButton = /* @__PURE__ */ React15.createElement(Button2, {
|
|
696
|
+
compact: true,
|
|
697
|
+
variant: "ghost",
|
|
698
|
+
onClick: () => onDone == null ? void 0 : onDone(),
|
|
699
|
+
"data-testid": "show-all-spaces"
|
|
700
|
+
}, /* @__PURE__ */ React15.createElement(X2, {
|
|
701
|
+
className: getSize3(4),
|
|
702
|
+
weight: "bold"
|
|
703
|
+
}));
|
|
704
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
131
705
|
role: "none",
|
|
132
|
-
className:
|
|
133
|
-
},
|
|
706
|
+
className: "flex flex-col"
|
|
707
|
+
}, /* @__PURE__ */ React15.createElement("div", {
|
|
708
|
+
role: "none",
|
|
709
|
+
className: mx11(subduedSurface, "rounded-bs-md flex items-center p-2 gap-2")
|
|
710
|
+
}, /* @__PURE__ */ React15.createElement("h2", {
|
|
711
|
+
id: titleId,
|
|
712
|
+
className: mx11("grow font-system-medium", !displayName && "font-mono")
|
|
713
|
+
}, displayName != null ? displayName : identity.identityKey.truncate()), /* @__PURE__ */ React15.createElement(Tooltip, {
|
|
714
|
+
content: t("close label"),
|
|
715
|
+
zIndex: "z-50"
|
|
716
|
+
}, doneActionParent ? /* @__PURE__ */ cloneElement(doneActionParent, {}, doneButton) : doneButton)), /* @__PURE__ */ React15.createElement("div", {
|
|
717
|
+
role: "region",
|
|
718
|
+
className: mx11(defaultSurface, "rounded-be-md p-2")
|
|
719
|
+
}, /* @__PURE__ */ React15.createElement(InvitationList, {
|
|
720
|
+
invitations,
|
|
721
|
+
onClickRemove: ({ invitation }) => invitation && client.halo.removeInvitation(invitation.invitationId),
|
|
722
|
+
createInvitationUrl
|
|
723
|
+
}), /* @__PURE__ */ React15.createElement(Button2, {
|
|
724
|
+
className: "is-full flex gap-2 mbs-2",
|
|
725
|
+
compact: true,
|
|
726
|
+
onClick: () => client.halo.createInvitation(),
|
|
727
|
+
"data-testid": "create-space-invitation"
|
|
728
|
+
}, /* @__PURE__ */ React15.createElement("span", null, t("create space invitation label")), /* @__PURE__ */ React15.createElement(UserPlus, {
|
|
729
|
+
className: getSize3(4),
|
|
730
|
+
weight: "bold"
|
|
731
|
+
})), /* @__PURE__ */ React15.createElement(PanelSeparator, null), /* @__PURE__ */ React15.createElement(DeviceList, {
|
|
732
|
+
devices
|
|
733
|
+
})));
|
|
734
|
+
};
|
|
735
|
+
var DevicesPanel = (props) => {
|
|
736
|
+
const reducer = (state, action) => {
|
|
737
|
+
const nextState = {
|
|
738
|
+
...state
|
|
739
|
+
};
|
|
740
|
+
switch (action.type) {
|
|
741
|
+
case null:
|
|
742
|
+
}
|
|
743
|
+
return nextState;
|
|
744
|
+
};
|
|
745
|
+
const [panelState] = useReducer(reducer, {
|
|
746
|
+
activeView: "device list"
|
|
747
|
+
});
|
|
748
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, panelState.activeView === "device list" ? /* @__PURE__ */ React15.createElement(DeviceListView, _extends12({}, props)) : null);
|
|
134
749
|
};
|
|
135
750
|
|
|
136
751
|
// packages/apps/patterns/react-ui/src/panels/IdentityPanel/IdentityPanel.tsx
|
|
137
|
-
import
|
|
138
|
-
import { useClient } from "@dxos/react-client";
|
|
139
|
-
import { Avatar, Button, ThemeContext, useTranslation as
|
|
752
|
+
import React16 from "react";
|
|
753
|
+
import { useClient as useClient3 } from "@dxos/react-client";
|
|
754
|
+
import { Avatar as Avatar3, Button as Button3, ThemeContext, useTranslation as useTranslation6 } from "@dxos/react-components";
|
|
140
755
|
var IdentityPanel = ({ identity, onClickManageProfile }) => {
|
|
141
756
|
var _a;
|
|
142
|
-
const { t } =
|
|
143
|
-
const client =
|
|
757
|
+
const { t } = useTranslation6("os");
|
|
758
|
+
const client = useClient3();
|
|
144
759
|
const defaultManageProfile = () => {
|
|
145
760
|
const remoteSource = new URL((client == null ? void 0 : client.config.get("runtime.client.remoteSource")) || "https://halo.dxos.org");
|
|
146
761
|
const tab = window.open(remoteSource.origin, "_blank");
|
|
147
762
|
tab == null ? void 0 : tab.focus();
|
|
148
763
|
};
|
|
149
|
-
return /* @__PURE__ */
|
|
764
|
+
return /* @__PURE__ */ React16.createElement(ThemeContext.Provider, {
|
|
150
765
|
value: {
|
|
151
766
|
themeVariant: "os"
|
|
152
767
|
}
|
|
153
|
-
}, /* @__PURE__ */
|
|
768
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
154
769
|
className: "flex flex-col gap-2 justify-center items-center"
|
|
155
|
-
}, /* @__PURE__ */
|
|
770
|
+
}, /* @__PURE__ */ React16.createElement(Avatar3, {
|
|
156
771
|
size: 16,
|
|
157
772
|
variant: "circle",
|
|
158
773
|
fallbackValue: identity.identityKey.toHex(),
|
|
159
774
|
label: (_a = identity.displayName) != null ? _a : ""
|
|
160
|
-
}), /* @__PURE__ */
|
|
775
|
+
}), /* @__PURE__ */ React16.createElement(Button3, {
|
|
161
776
|
compact: true,
|
|
162
777
|
onClick: onClickManageProfile != null ? onClickManageProfile : defaultManageProfile,
|
|
163
778
|
className: "is-full"
|
|
164
779
|
}, t("manage profile label"))));
|
|
165
780
|
};
|
|
166
781
|
|
|
167
|
-
// packages/apps/patterns/react-ui/src/
|
|
168
|
-
|
|
169
|
-
|
|
782
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/JoinPanel.tsx
|
|
783
|
+
import React27, { useEffect, useReducer as useReducer2 } from "react";
|
|
784
|
+
import { InvitationEncoder as InvitationEncoder2 } from "@dxos/client";
|
|
785
|
+
import { log } from "@dxos/log";
|
|
786
|
+
import { useClient as useClient6, useIdentity as useIdentity2 } from "@dxos/react-client";
|
|
787
|
+
import { useId as useId4 } from "@dxos/react-components";
|
|
788
|
+
|
|
789
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/JoinHeading.tsx
|
|
790
|
+
import { ProhibitInset as ProhibitInset2 } from "phosphor-react";
|
|
791
|
+
import React17, { cloneElement as cloneElement2, forwardRef as forwardRef2 } from "react";
|
|
792
|
+
import { useSpace as useSpace2 } from "@dxos/react-client";
|
|
793
|
+
import { Avatar as Avatar4, Button as Button4, getSize as getSize4, Heading, mx as mx12, Trans, useId as useId2, useTranslation as useTranslation7 } from "@dxos/react-components";
|
|
794
|
+
function _extends13() {
|
|
795
|
+
_extends13 = Object.assign || function(target) {
|
|
170
796
|
for (var i = 1; i < arguments.length; i++) {
|
|
171
797
|
var source = arguments[i];
|
|
172
798
|
for (var key in source) {
|
|
@@ -177,29 +803,1668 @@ function _extends3() {
|
|
|
177
803
|
}
|
|
178
804
|
return target;
|
|
179
805
|
};
|
|
180
|
-
return
|
|
806
|
+
return _extends13.apply(this, arguments);
|
|
181
807
|
}
|
|
182
|
-
var
|
|
183
|
-
var _a, _b;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
808
|
+
var JoinHeading = /* @__PURE__ */ forwardRef2(({ mode, titleId, invitation, onExit, exitActionParent, preventExit }, ref) => {
|
|
809
|
+
var _a, _b, _c, _d, _e, _f;
|
|
810
|
+
const { t } = useTranslation7("os");
|
|
811
|
+
const space = useSpace2((_a = invitation == null ? void 0 : invitation.invitation) == null ? void 0 : _a.spaceKey);
|
|
812
|
+
const name = mode === "halo-only" ? "(Unknown identity)" : (_b = space == null ? void 0 : space.properties.name) != null ? _b : "(Space name not available)";
|
|
813
|
+
const nameId = useId2(mode === "halo-only" ? "identityDisplayName" : "spaceDisplayName");
|
|
814
|
+
const invitationKey = mode === "halo-only" ? (_d = (_c = invitation == null ? void 0 : invitation.invitation) == null ? void 0 : _c.identityKey) == null ? void 0 : _d.toHex() : (_f = (_e = invitation == null ? void 0 : invitation.invitation) == null ? void 0 : _e.identityKey) == null ? void 0 : _f.toHex();
|
|
815
|
+
const exitButton = /* @__PURE__ */ React17.createElement(Button4, _extends13({
|
|
816
|
+
compact: true,
|
|
817
|
+
variant: "ghost"
|
|
818
|
+
}, onExit && {
|
|
819
|
+
onClick: onExit
|
|
820
|
+
}, {
|
|
821
|
+
className: "grow-0 shrink-0",
|
|
822
|
+
"data-testid": "join-exit"
|
|
823
|
+
}), /* @__PURE__ */ React17.createElement(ProhibitInset2, {
|
|
824
|
+
className: getSize4(5)
|
|
825
|
+
}), /* @__PURE__ */ React17.createElement("span", {
|
|
826
|
+
className: "sr-only"
|
|
827
|
+
}, t("exit label")));
|
|
828
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
829
|
+
role: "none",
|
|
830
|
+
className: mx12(subduedSurface, "p-2 rounded-bs-md"),
|
|
831
|
+
ref
|
|
832
|
+
}, /* @__PURE__ */ React17.createElement("div", {
|
|
833
|
+
role: "group",
|
|
834
|
+
className: "flex items-center gap-2"
|
|
835
|
+
}, invitationKey ? /* @__PURE__ */ React17.createElement(Avatar4, {
|
|
836
|
+
fallbackValue: invitationKey,
|
|
837
|
+
labelId: nameId
|
|
838
|
+
}) : /* @__PURE__ */ React17.createElement("span", {
|
|
839
|
+
role: "none",
|
|
840
|
+
className: mx12(getSize4(10), "bg-neutral-300 dark:bg-neutral-700 rounded-full")
|
|
841
|
+
}), /* @__PURE__ */ React17.createElement(Heading, {
|
|
842
|
+
level: 1,
|
|
843
|
+
className: "font-body font-normal text-base grow",
|
|
844
|
+
id: titleId
|
|
845
|
+
}, invitation ? /* @__PURE__ */ React17.createElement(Trans, _extends13({}, {
|
|
846
|
+
defaults: t("joining heading"),
|
|
847
|
+
components: {
|
|
848
|
+
small: /* @__PURE__ */ React17.createElement("span", {
|
|
849
|
+
className: "block leading-none mbe-1 font-system-medium text-sm"
|
|
850
|
+
}),
|
|
851
|
+
large: /* @__PURE__ */ React17.createElement("span", {
|
|
852
|
+
className: "block leading-none",
|
|
853
|
+
id: nameId
|
|
854
|
+
})
|
|
197
855
|
},
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
856
|
+
values: {
|
|
857
|
+
name
|
|
858
|
+
}
|
|
859
|
+
})) : /* @__PURE__ */ React17.createElement("span", {
|
|
860
|
+
className: "block leading-none font-system-medium text-sm"
|
|
861
|
+
}, mode === "halo-only" ? t("halo heading") : t("join space heading"))), !preventExit && mode !== "halo-only" && (exitActionParent ? /* @__PURE__ */ cloneElement2(exitActionParent, {}, exitButton) : exitButton)));
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/AdditionMethodSelector.tsx
|
|
865
|
+
import { CaretLeft, CaretRight, Plus, QrCode as QrCode2, Textbox } from "phosphor-react";
|
|
866
|
+
import React19 from "react";
|
|
867
|
+
import { Button as Button5, CompoundButton, getSize as getSize6, mx as mx14, useTranslation as useTranslation9 } from "@dxos/react-components";
|
|
868
|
+
|
|
869
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/ViewState.tsx
|
|
870
|
+
import { CheckCircle, HourglassSimple, X as X3 } from "phosphor-react";
|
|
871
|
+
import React18, { useMemo as useMemo2 } from "react";
|
|
872
|
+
import { Invitation as Invitation4 } from "@dxos/client";
|
|
873
|
+
import { useInvitationStatus as useInvitationStatus2 } from "@dxos/react-client";
|
|
874
|
+
import { mx as mx13, useTranslation as useTranslation8, Trans as Trans2, Avatar as Avatar5, useId as useId3, getSize as getSize5, strongShimmer } from "@dxos/react-components";
|
|
875
|
+
function _extends14() {
|
|
876
|
+
_extends14 = Object.assign || function(target) {
|
|
877
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
878
|
+
var source = arguments[i];
|
|
879
|
+
for (var key in source) {
|
|
880
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
881
|
+
target[key] = source[key];
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return target;
|
|
886
|
+
};
|
|
887
|
+
return _extends14.apply(this, arguments);
|
|
888
|
+
}
|
|
889
|
+
var stripe = mx13("rounded-full grow", getSize5(3));
|
|
890
|
+
var ViewStateHeading = ({ children, className, ...props }) => {
|
|
891
|
+
return /* @__PURE__ */ React18.createElement("h2", _extends14({}, props, {
|
|
892
|
+
className: mx13("font-system-medium text-sm md:text-base mbe-1 mli-1 text-center", className)
|
|
893
|
+
}), children);
|
|
894
|
+
};
|
|
895
|
+
var PureViewStateInvitation = ({ halted, cursor, label, resolvedColor }) => {
|
|
896
|
+
const labelId = useId3("invitationState");
|
|
897
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
898
|
+
role: "none",
|
|
899
|
+
className: mx13(defaultSurface, "pli-2 pbs-2")
|
|
900
|
+
}, /* @__PURE__ */ React18.createElement("div", {
|
|
901
|
+
role: "status",
|
|
902
|
+
"aria-labelledby": labelId,
|
|
903
|
+
className: "flex gap-2 items-center mlb-1"
|
|
904
|
+
}, /* @__PURE__ */ React18.createElement("div", {
|
|
905
|
+
role: "none",
|
|
906
|
+
className: mx13(stripe, !halted && cursor === 1 && strongShimmer, cursor === 2 ? halted ? resolvedColor : activeBgColor : cursor > 1 ? resolvedColor : inactiveBgColor)
|
|
907
|
+
}), /* @__PURE__ */ React18.createElement("div", {
|
|
908
|
+
role: "none",
|
|
909
|
+
className: mx13(stripe, !halted && cursor === 3 && strongShimmer, cursor === 3 ? halted ? resolvedColor : activeBgColor : cursor > 3 ? resolvedColor : inactiveBgColor)
|
|
910
|
+
}), /* @__PURE__ */ React18.createElement("div", {
|
|
911
|
+
role: "none",
|
|
912
|
+
className: mx13(stripe, cursor > 3 ? halted ? resolvedColor : resolvedColor : inactiveBgColor)
|
|
913
|
+
})), /* @__PURE__ */ React18.createElement(ViewStateHeading, {
|
|
914
|
+
id: labelId,
|
|
915
|
+
className: "mbs-2 flex justify-center items-center gap-2"
|
|
916
|
+
}, label));
|
|
917
|
+
};
|
|
918
|
+
var ViewStateInvitationStatus = ({ activeInvitation }) => {
|
|
919
|
+
const { t } = useTranslation8("os");
|
|
920
|
+
const { status, haltedAt } = useInvitationStatus2(activeInvitation);
|
|
921
|
+
const halted = status === Invitation4.State.CANCELLED || status === Invitation4.State.TIMEOUT || status === Invitation4.State.ERROR;
|
|
922
|
+
const cursor = invitationStatusValue.get(halted ? haltedAt : status);
|
|
923
|
+
const resolvedColor = resolvedBgColor(status);
|
|
924
|
+
const statusLabelMap = useMemo2(() => /* @__PURE__ */ new Map([
|
|
925
|
+
[
|
|
926
|
+
Invitation4.State.ERROR,
|
|
927
|
+
/* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(X3, {
|
|
928
|
+
weight: "bold",
|
|
929
|
+
className: mx13(getSize5(4), "text-error-600 dark:text-error-400")
|
|
930
|
+
}), /* @__PURE__ */ React18.createElement("span", null, t("error status label")))
|
|
931
|
+
],
|
|
932
|
+
[
|
|
933
|
+
Invitation4.State.TIMEOUT,
|
|
934
|
+
/* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(HourglassSimple, {
|
|
935
|
+
weight: "fill",
|
|
936
|
+
className: mx13(getSize5(4), "text-warning-600 dark:text-warning-400")
|
|
937
|
+
}), /* @__PURE__ */ React18.createElement("span", null, t("timeout status label")))
|
|
938
|
+
],
|
|
939
|
+
[
|
|
940
|
+
Invitation4.State.CANCELLED,
|
|
941
|
+
/* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(X3, {
|
|
942
|
+
weight: "bold",
|
|
943
|
+
className: mx13(getSize5(4), "text-warning-600 dark:text-warning-400")
|
|
944
|
+
}), /* @__PURE__ */ React18.createElement("span", null, t("cancelled status label")))
|
|
945
|
+
],
|
|
946
|
+
[
|
|
947
|
+
Invitation4.State.INIT,
|
|
948
|
+
t("init status label")
|
|
949
|
+
],
|
|
950
|
+
[
|
|
951
|
+
Invitation4.State.CONNECTING,
|
|
952
|
+
t("connecting status label")
|
|
953
|
+
],
|
|
954
|
+
[
|
|
955
|
+
Invitation4.State.CONNECTED,
|
|
956
|
+
t("connected status label")
|
|
957
|
+
],
|
|
958
|
+
[
|
|
959
|
+
Invitation4.State.AUTHENTICATING,
|
|
960
|
+
t("authenticating status label")
|
|
961
|
+
],
|
|
962
|
+
[
|
|
963
|
+
Invitation4.State.SUCCESS,
|
|
964
|
+
/* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(CheckCircle, {
|
|
965
|
+
weight: "fill",
|
|
966
|
+
className: mx13(getSize5(4), "text-success-600 dark:text-success-400")
|
|
967
|
+
}), /* @__PURE__ */ React18.createElement("span", null, t("success status label")))
|
|
968
|
+
]
|
|
969
|
+
]), [
|
|
970
|
+
t
|
|
971
|
+
]);
|
|
972
|
+
return /* @__PURE__ */ React18.createElement(PureViewStateInvitation, _extends14({}, {
|
|
973
|
+
label: statusLabelMap.get(status),
|
|
974
|
+
resolvedColor,
|
|
975
|
+
cursor,
|
|
976
|
+
halted
|
|
977
|
+
}));
|
|
978
|
+
};
|
|
979
|
+
var ViewState = ({ active, children, className, dispatch, selectedIdentity, activeInvitation, ...props }) => {
|
|
980
|
+
var _a;
|
|
981
|
+
const { t } = useTranslation8("os");
|
|
982
|
+
const identityLabel = useId3("selectedIdentityLabel");
|
|
983
|
+
return /* @__PURE__ */ React18.createElement("div", _extends14({
|
|
984
|
+
role: "none"
|
|
985
|
+
}, props, !active && {
|
|
986
|
+
"aria-hidden": true
|
|
987
|
+
}, {
|
|
988
|
+
className: mx13("is-[50%] flex flex-col", active ? "order-2" : "order-4", className)
|
|
989
|
+
}), selectedIdentity && /* @__PURE__ */ React18.createElement("div", {
|
|
990
|
+
role: "none",
|
|
991
|
+
className: mx13(subduedSurface, "flex-none flex items-center gap-1 pli-2 pbe-1.5")
|
|
992
|
+
}, /* @__PURE__ */ React18.createElement(Trans2, _extends14({}, {
|
|
993
|
+
defaults: t("join space as identity heading"),
|
|
994
|
+
components: {
|
|
995
|
+
icon: /* @__PURE__ */ React18.createElement(Avatar5, {
|
|
996
|
+
size: 4,
|
|
997
|
+
fallbackValue: selectedIdentity === true ? "" : selectedIdentity.identityKey.toHex(),
|
|
998
|
+
labelId: identityLabel
|
|
999
|
+
}),
|
|
1000
|
+
label: /* @__PURE__ */ React18.createElement("span", {
|
|
1001
|
+
id: identityLabel
|
|
1002
|
+
}),
|
|
1003
|
+
part: /* @__PURE__ */ React18.createElement("span", {
|
|
1004
|
+
role: "none",
|
|
1005
|
+
className: "flex items-center gap-1 leading-none"
|
|
1006
|
+
})
|
|
1007
|
+
},
|
|
1008
|
+
values: {
|
|
1009
|
+
labelValue: selectedIdentity === true ? "\xA0" : (_a = selectedIdentity.displayName) != null ? _a : selectedIdentity.identityKey.truncate()
|
|
1010
|
+
}
|
|
1011
|
+
}))), activeInvitation && (activeInvitation === true ? /* @__PURE__ */ React18.createElement(PureViewStateInvitation, _extends14({}, {
|
|
1012
|
+
halted: false,
|
|
1013
|
+
status: Invitation4.State.INIT,
|
|
1014
|
+
label: t("invitation input label"),
|
|
1015
|
+
cursor: 0,
|
|
1016
|
+
resolvedColor: inactiveBgColor
|
|
1017
|
+
})) : /* @__PURE__ */ React18.createElement(ViewStateInvitationStatus, _extends14({}, {
|
|
1018
|
+
activeInvitation
|
|
1019
|
+
}))), /* @__PURE__ */ React18.createElement("div", {
|
|
1020
|
+
role: "region",
|
|
1021
|
+
className: mx13(defaultSurface, "rounded-be-md grow shrink-0 flex flex-col gap-1 p-2")
|
|
1022
|
+
}, children));
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/AdditionMethodSelector.tsx
|
|
1026
|
+
function _extends15() {
|
|
1027
|
+
_extends15 = Object.assign || function(target) {
|
|
1028
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1029
|
+
var source = arguments[i];
|
|
1030
|
+
for (var key in source) {
|
|
1031
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1032
|
+
target[key] = source[key];
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return target;
|
|
1037
|
+
};
|
|
1038
|
+
return _extends15.apply(this, arguments);
|
|
1039
|
+
}
|
|
1040
|
+
var AdditionMethodSelector = ({ availableIdentities, ...viewStateProps }) => {
|
|
1041
|
+
const disabled = !viewStateProps.active;
|
|
1042
|
+
const { dispatch } = viewStateProps;
|
|
1043
|
+
const { t } = useTranslation9("os");
|
|
1044
|
+
const sharedButtonProps = {
|
|
1045
|
+
disabled,
|
|
1046
|
+
after: /* @__PURE__ */ React19.createElement(CaretRight, {
|
|
1047
|
+
className: getSize6(4),
|
|
1048
|
+
weight: "bold"
|
|
1049
|
+
}),
|
|
1050
|
+
slots: {
|
|
1051
|
+
label: {
|
|
1052
|
+
className: "text-sm"
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
return /* @__PURE__ */ React19.createElement(ViewState, _extends15({}, viewStateProps), /* @__PURE__ */ React19.createElement(ViewStateHeading, null, t("addition method selector title")), /* @__PURE__ */ React19.createElement("div", {
|
|
1057
|
+
role: "none",
|
|
1058
|
+
className: "flex flex-col gap-1 grow"
|
|
1059
|
+
}, /* @__PURE__ */ React19.createElement(CompoundButton, _extends15({}, sharedButtonProps, {
|
|
1060
|
+
description: t("create identity description"),
|
|
1061
|
+
before: /* @__PURE__ */ React19.createElement(Plus, {
|
|
1062
|
+
className: getSize6(6)
|
|
1063
|
+
}),
|
|
1064
|
+
onClick: () => dispatch({
|
|
1065
|
+
type: "select addition method",
|
|
1066
|
+
method: "create identity"
|
|
1067
|
+
}),
|
|
1068
|
+
"data-autofocus": "addition method selector",
|
|
1069
|
+
"data-testid": "create-identity"
|
|
1070
|
+
}), t("create identity label")), /* @__PURE__ */ React19.createElement(CompoundButton, _extends15({}, sharedButtonProps, {
|
|
1071
|
+
description: t("join identity description"),
|
|
1072
|
+
before: /* @__PURE__ */ React19.createElement(QrCode2, {
|
|
1073
|
+
className: getSize6(6)
|
|
1074
|
+
}),
|
|
1075
|
+
onClick: () => dispatch({
|
|
1076
|
+
type: "select addition method",
|
|
1077
|
+
method: "accept device invitation"
|
|
1078
|
+
}),
|
|
1079
|
+
"data-testid": "join-identity"
|
|
1080
|
+
}), t("join identity label")), /* @__PURE__ */ React19.createElement(CompoundButton, _extends15({}, sharedButtonProps, {
|
|
1081
|
+
description: t("recover identity description"),
|
|
1082
|
+
before: /* @__PURE__ */ React19.createElement(Textbox, {
|
|
1083
|
+
className: getSize6(6)
|
|
1084
|
+
}),
|
|
1085
|
+
onClick: () => dispatch({
|
|
1086
|
+
type: "select addition method",
|
|
1087
|
+
method: "recover identity"
|
|
1088
|
+
}),
|
|
1089
|
+
"data-testid": "recover-identity"
|
|
1090
|
+
}), t("recover identity label"))), /* @__PURE__ */ React19.createElement(Button5, {
|
|
1091
|
+
disabled: disabled || availableIdentities.length < 1,
|
|
1092
|
+
onClick: () => dispatch({
|
|
1093
|
+
type: "deselect identity"
|
|
1094
|
+
}),
|
|
1095
|
+
"data-testid": "deselect-identity"
|
|
1096
|
+
}, /* @__PURE__ */ React19.createElement(CaretLeft, {
|
|
1097
|
+
className: getSize6(4),
|
|
1098
|
+
weight: "bold"
|
|
1099
|
+
}), /* @__PURE__ */ React19.createElement("span", {
|
|
1100
|
+
className: "grow"
|
|
1101
|
+
}, t("deselect identity label")), /* @__PURE__ */ React19.createElement(CaretRight, {
|
|
1102
|
+
className: mx14(getSize6(4), "invisible"),
|
|
1103
|
+
weight: "bold"
|
|
1104
|
+
})));
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/IdentityAdded.tsx
|
|
1108
|
+
import { CaretLeft as CaretLeft2, CaretRight as CaretRight2, Check } from "phosphor-react";
|
|
1109
|
+
import React20, { cloneElement as cloneElement3 } from "react";
|
|
1110
|
+
import { Avatar as Avatar6, Button as Button6, getSize as getSize7, mx as mx15, useTranslation as useTranslation10 } from "@dxos/react-components";
|
|
1111
|
+
function _extends16() {
|
|
1112
|
+
_extends16 = Object.assign || function(target) {
|
|
1113
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1114
|
+
var source = arguments[i];
|
|
1115
|
+
for (var key in source) {
|
|
1116
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1117
|
+
target[key] = source[key];
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return target;
|
|
1122
|
+
};
|
|
1123
|
+
return _extends16.apply(this, arguments);
|
|
1124
|
+
}
|
|
1125
|
+
var Done = ({ onDone, doneActionParent, active }) => {
|
|
1126
|
+
const disabled = !active;
|
|
1127
|
+
const { t } = useTranslation10("os");
|
|
1128
|
+
const doneButton = /* @__PURE__ */ React20.createElement(Button6, _extends16({}, onDone && {
|
|
1129
|
+
onClick: () => onDone(null)
|
|
1130
|
+
}, {
|
|
1131
|
+
disabled,
|
|
1132
|
+
className: "grow flex items-center gap-2 pli-2",
|
|
1133
|
+
"data-autofocus": "identity added",
|
|
1134
|
+
"data-testid": "identity-added-done"
|
|
1135
|
+
}), /* @__PURE__ */ React20.createElement(CaretLeft2, {
|
|
1136
|
+
weight: "bold",
|
|
1137
|
+
className: mx15(getSize7(2), "invisible")
|
|
1138
|
+
}), /* @__PURE__ */ React20.createElement("span", {
|
|
1139
|
+
className: "grow"
|
|
1140
|
+
}, t("done label")), /* @__PURE__ */ React20.createElement(Check, {
|
|
1141
|
+
weight: "bold",
|
|
1142
|
+
className: getSize7(4)
|
|
1143
|
+
}));
|
|
1144
|
+
return doneActionParent ? /* @__PURE__ */ cloneElement3(doneActionParent, {}, doneButton) : doneButton;
|
|
1145
|
+
};
|
|
1146
|
+
var IdentityAdded = ({ mode, addedIdentity, onDone, doneActionParent, ...viewStateProps }) => {
|
|
1147
|
+
var _a, _b, _c;
|
|
1148
|
+
const disabled = !viewStateProps.active;
|
|
1149
|
+
const { dispatch } = viewStateProps;
|
|
1150
|
+
const { t } = useTranslation10("os");
|
|
1151
|
+
return /* @__PURE__ */ React20.createElement(ViewState, _extends16({}, viewStateProps), /* @__PURE__ */ React20.createElement(ViewStateHeading, null, t("identity added label")), /* @__PURE__ */ React20.createElement("div", {
|
|
1152
|
+
role: "none",
|
|
1153
|
+
className: "grow flex flex-col items-center justify-center text-center gap-2"
|
|
1154
|
+
}, /* @__PURE__ */ React20.createElement(Avatar6, {
|
|
1155
|
+
size: 20,
|
|
1156
|
+
fallbackValue: (_a = addedIdentity == null ? void 0 : addedIdentity.identityKey.toHex()) != null ? _a : "",
|
|
1157
|
+
label: /* @__PURE__ */ React20.createElement("p", {
|
|
1158
|
+
className: mx15("text-lg", !(addedIdentity == null ? void 0 : addedIdentity.displayName) && "font-mono")
|
|
1159
|
+
}, (_c = (_b = addedIdentity == null ? void 0 : addedIdentity.displayName) != null ? _b : addedIdentity == null ? void 0 : addedIdentity.identityKey.truncate()) != null ? _c : "\xA0"),
|
|
1160
|
+
variant: "circle",
|
|
1161
|
+
status: "active"
|
|
1162
|
+
})), mode === "halo-only" ? /* @__PURE__ */ React20.createElement(Done, _extends16({
|
|
1163
|
+
onDone,
|
|
1164
|
+
doneActionParent
|
|
1165
|
+
}, viewStateProps)) : /* @__PURE__ */ React20.createElement("div", {
|
|
1166
|
+
className: "flex gap-2"
|
|
1167
|
+
}, /* @__PURE__ */ React20.createElement(Button6, {
|
|
1168
|
+
disabled: disabled || !addedIdentity,
|
|
1169
|
+
className: "grow flex items-center gap-2 pli-2 order-2",
|
|
1170
|
+
onClick: () => addedIdentity && dispatch({
|
|
1171
|
+
type: "select identity",
|
|
1172
|
+
identity: addedIdentity
|
|
1173
|
+
}),
|
|
1174
|
+
"data-autofocus": "identity added"
|
|
1175
|
+
}, /* @__PURE__ */ React20.createElement(CaretLeft2, {
|
|
1176
|
+
weight: "bold",
|
|
1177
|
+
className: mx15(getSize7(2), "invisible")
|
|
1178
|
+
}), /* @__PURE__ */ React20.createElement("span", {
|
|
1179
|
+
className: "grow"
|
|
1180
|
+
}, t("continue label")), /* @__PURE__ */ React20.createElement(CaretRight2, {
|
|
1181
|
+
weight: "bold",
|
|
1182
|
+
className: getSize7(4)
|
|
1183
|
+
})), /* @__PURE__ */ React20.createElement(Button6, {
|
|
1184
|
+
disabled,
|
|
1185
|
+
onClick: () => dispatch({
|
|
1186
|
+
type: "deselect identity"
|
|
1187
|
+
}),
|
|
1188
|
+
className: "flex items-center gap-2 pis-2 pie-4"
|
|
1189
|
+
}, /* @__PURE__ */ React20.createElement(CaretLeft2, {
|
|
1190
|
+
weight: "bold",
|
|
1191
|
+
className: getSize7(4)
|
|
1192
|
+
}), /* @__PURE__ */ React20.createElement("span", null, t("deselect identity label")))));
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/IdentitySelector.tsx
|
|
1196
|
+
import * as RadioGroup from "@radix-ui/react-radio-group";
|
|
1197
|
+
import { CaretLeft as CaretLeft3, CaretRight as CaretRight3, UserPlus as UserPlus2 } from "phosphor-react";
|
|
1198
|
+
import React21, { useCallback as useCallback4, useState as useState2 } from "react";
|
|
1199
|
+
import { Avatar as Avatar7, Button as Button7, themeVariantFocus, getSize as getSize8, mx as mx16, useTranslation as useTranslation11 } from "@dxos/react-components";
|
|
1200
|
+
function _extends17() {
|
|
1201
|
+
_extends17 = Object.assign || function(target) {
|
|
1202
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1203
|
+
var source = arguments[i];
|
|
1204
|
+
for (var key in source) {
|
|
1205
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1206
|
+
target[key] = source[key];
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
return target;
|
|
1211
|
+
};
|
|
1212
|
+
return _extends17.apply(this, arguments);
|
|
1213
|
+
}
|
|
1214
|
+
var IdentitySelector = ({ availableIdentities, ...viewStateProps }) => {
|
|
1215
|
+
const { dispatch } = viewStateProps;
|
|
1216
|
+
const disabled = !viewStateProps.active;
|
|
1217
|
+
const { t } = useTranslation11("os");
|
|
1218
|
+
const [activeIdentity, setActiveIdentity] = useState2(availableIdentities[0]);
|
|
1219
|
+
const onValueChange = useCallback4((nextHex) => setActiveIdentity(availableIdentities.find((identity) => identity.identityKey.toHex() === nextHex) || activeIdentity), [
|
|
1220
|
+
availableIdentities
|
|
1221
|
+
]);
|
|
1222
|
+
return /* @__PURE__ */ React21.createElement(ViewState, _extends17({}, viewStateProps), /* @__PURE__ */ React21.createElement(ViewStateHeading, null, t("identity selector title")), /* @__PURE__ */ React21.createElement(RadioGroup.Root, {
|
|
1223
|
+
disabled,
|
|
1224
|
+
value: activeIdentity == null ? void 0 : activeIdentity.identityKey.toHex(),
|
|
1225
|
+
onValueChange,
|
|
1226
|
+
className: "overflow-y-auto grow shrink min-bs-10 pli-1 -mli-1",
|
|
1227
|
+
"aria-label": t("identity radio group title"),
|
|
1228
|
+
"data-autofocus": "identity selector"
|
|
1229
|
+
}, availableIdentities.map(({ displayName, identityKey }) => {
|
|
1230
|
+
var _a;
|
|
1231
|
+
const hex = identityKey.toHex();
|
|
1232
|
+
const inputId = `identitySelector__item--${hex}`;
|
|
1233
|
+
const labelId = `identitySelector__itemLabel--${hex}`;
|
|
1234
|
+
return /* @__PURE__ */ React21.createElement("label", {
|
|
1235
|
+
htmlFor: inputId,
|
|
1236
|
+
key: hex,
|
|
1237
|
+
className: "flex items-center mbe-2 gap-2 cursor-pointer"
|
|
1238
|
+
}, /* @__PURE__ */ React21.createElement(RadioGroup.Item, {
|
|
1239
|
+
id: inputId,
|
|
1240
|
+
"aria-labelledby": labelId,
|
|
1241
|
+
value: hex,
|
|
1242
|
+
className: mx16("peer relative w-4 h-4 rounded-full", "border border-transparent text-white", "radix-state-checked:bg-primary-600", "radix-state-unchecked:bg-neutral-100 dark:radix-state-unchecked:bg-neutral-900", themeVariantFocus("os")),
|
|
1243
|
+
"data-testid": "identity-selector-item"
|
|
1244
|
+
}, /* @__PURE__ */ React21.createElement(RadioGroup.Indicator, {
|
|
1245
|
+
className: "absolute inset-0 flex items-center justify-center leading-0"
|
|
1246
|
+
}, /* @__PURE__ */ React21.createElement("div", {
|
|
1247
|
+
className: "w-1.5 h-1.5 rounded-full bg-white"
|
|
1248
|
+
}))), /* @__PURE__ */ React21.createElement(Avatar7, {
|
|
1249
|
+
fallbackValue: hex,
|
|
1250
|
+
labelId,
|
|
1251
|
+
variant: "circle"
|
|
1252
|
+
}), /* @__PURE__ */ React21.createElement("span", {
|
|
1253
|
+
id: labelId,
|
|
1254
|
+
className: mx16(!displayName && "font-mono")
|
|
1255
|
+
}, (_a = displayName != null ? displayName : identityKey.truncate()) != null ? _a : ""));
|
|
1256
|
+
})), /* @__PURE__ */ React21.createElement(Button7, {
|
|
1257
|
+
disabled,
|
|
1258
|
+
compact: true,
|
|
1259
|
+
onClick: () => dispatch({
|
|
1260
|
+
type: "add identity"
|
|
1261
|
+
}),
|
|
1262
|
+
className: "flex items-center gap-2 pli-2",
|
|
1263
|
+
"data-testid": "add-identity"
|
|
1264
|
+
}, /* @__PURE__ */ React21.createElement("span", null, t("add identity label")), /* @__PURE__ */ React21.createElement(UserPlus2, {
|
|
1265
|
+
weight: "bold",
|
|
1266
|
+
className: getSize8(3.5)
|
|
1267
|
+
})), /* @__PURE__ */ React21.createElement(Button7, {
|
|
1268
|
+
disabled: disabled || !activeIdentity,
|
|
1269
|
+
className: "flex items-center gap-2 pli-2",
|
|
1270
|
+
onClick: () => dispatch({
|
|
1271
|
+
type: "select identity",
|
|
1272
|
+
identity: activeIdentity
|
|
1273
|
+
}),
|
|
1274
|
+
"data-testid": "select-identity"
|
|
1275
|
+
}, /* @__PURE__ */ React21.createElement(CaretLeft3, {
|
|
1276
|
+
weight: "bold",
|
|
1277
|
+
className: mx16(getSize8(4), "invisible")
|
|
1278
|
+
}), /* @__PURE__ */ React21.createElement("span", {
|
|
1279
|
+
className: "grow"
|
|
1280
|
+
}, t("continue label")), /* @__PURE__ */ React21.createElement(CaretRight3, {
|
|
1281
|
+
weight: "bold",
|
|
1282
|
+
className: getSize8(4)
|
|
1283
|
+
})));
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/IdentityInput.tsx
|
|
1287
|
+
import { CaretLeft as CaretLeft4, CaretRight as CaretRight4 } from "phosphor-react";
|
|
1288
|
+
import React22, { useState as useState3 } from "react";
|
|
1289
|
+
import { useClient as useClient4 } from "@dxos/react-client";
|
|
1290
|
+
import { Button as Button8, getSize as getSize9, Input, mx as mx17, useTranslation as useTranslation12 } from "@dxos/react-components";
|
|
1291
|
+
function _extends18() {
|
|
1292
|
+
_extends18 = Object.assign || function(target) {
|
|
1293
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1294
|
+
var source = arguments[i];
|
|
1295
|
+
for (var key in source) {
|
|
1296
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1297
|
+
target[key] = source[key];
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return target;
|
|
1302
|
+
};
|
|
1303
|
+
return _extends18.apply(this, arguments);
|
|
1304
|
+
}
|
|
1305
|
+
var IdentityInput = ({ method, ...viewStateProps }) => {
|
|
1306
|
+
const disabled = !viewStateProps.active;
|
|
1307
|
+
const { dispatch } = viewStateProps;
|
|
1308
|
+
const { t } = useTranslation12("os");
|
|
1309
|
+
const [inputValue, setInputValue] = useState3("");
|
|
1310
|
+
const client = useClient4();
|
|
1311
|
+
const [validationMessage, setValidationMessage] = useState3("");
|
|
1312
|
+
const isRecover = method === "recover identity";
|
|
1313
|
+
const handleNext = () => {
|
|
1314
|
+
void client.halo.createProfile({
|
|
1315
|
+
[isRecover ? "seedphrase" : "displayName"]: inputValue
|
|
1316
|
+
}).then((identity) => {
|
|
1317
|
+
dispatch({
|
|
1318
|
+
type: "added identity",
|
|
1319
|
+
identity
|
|
1320
|
+
});
|
|
1321
|
+
}, (_error) => {
|
|
1322
|
+
setValidationMessage(t(isRecover ? "failed to recover identity message" : "failed to create identity message"));
|
|
1323
|
+
});
|
|
1324
|
+
};
|
|
1325
|
+
return /* @__PURE__ */ React22.createElement(ViewState, _extends18({}, viewStateProps), /* @__PURE__ */ React22.createElement(Input, _extends18({
|
|
1326
|
+
disabled,
|
|
1327
|
+
label: /* @__PURE__ */ React22.createElement(ViewStateHeading, null, t(isRecover ? "recover identity input label" : "new identity input label")),
|
|
1328
|
+
onChange: ({ target: { value } }) => setInputValue(value),
|
|
1329
|
+
slots: {
|
|
1330
|
+
root: {
|
|
1331
|
+
className: "m-0"
|
|
1332
|
+
},
|
|
1333
|
+
input: {
|
|
1334
|
+
"data-autofocus": isRecover ? "identity input; recover identity" : "identity input; create identity",
|
|
1335
|
+
onKeyUp: ({ key }) => key === "Enter" && handleNext()
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}, validationMessage.length && {
|
|
1339
|
+
validationValence: "error",
|
|
1340
|
+
validationMessage
|
|
1341
|
+
}, {
|
|
1342
|
+
"data-testid": "identity-input"
|
|
1343
|
+
})), /* @__PURE__ */ React22.createElement("div", {
|
|
1344
|
+
role: "none",
|
|
1345
|
+
className: "grow"
|
|
1346
|
+
}), /* @__PURE__ */ React22.createElement("div", {
|
|
1347
|
+
className: "flex gap-2"
|
|
1348
|
+
}, /* @__PURE__ */ React22.createElement(Button8, {
|
|
1349
|
+
disabled,
|
|
1350
|
+
className: "grow flex items-center gap-2 pli-2 order-2",
|
|
1351
|
+
onClick: handleNext,
|
|
1352
|
+
"data-testid": `${method === "recover identity" ? "recover" : "create"}-identity-input-continue`
|
|
1353
|
+
}, /* @__PURE__ */ React22.createElement(CaretLeft4, {
|
|
1354
|
+
weight: "bold",
|
|
1355
|
+
className: mx17(getSize9(2), "invisible")
|
|
1356
|
+
}), /* @__PURE__ */ React22.createElement("span", {
|
|
1357
|
+
className: "grow"
|
|
1358
|
+
}, t("continue label")), /* @__PURE__ */ React22.createElement(CaretRight4, {
|
|
1359
|
+
weight: "bold",
|
|
1360
|
+
className: getSize9(4)
|
|
1361
|
+
})), /* @__PURE__ */ React22.createElement(Button8, {
|
|
1362
|
+
disabled,
|
|
1363
|
+
onClick: () => dispatch({
|
|
1364
|
+
type: "add identity"
|
|
1365
|
+
}),
|
|
1366
|
+
className: "flex items-center gap-2 pis-2 pie-4",
|
|
1367
|
+
"data-testid": `${method === "recover identity" ? "recover" : "create"}-identity-input-back`
|
|
1368
|
+
}, /* @__PURE__ */ React22.createElement(CaretLeft4, {
|
|
1369
|
+
weight: "bold",
|
|
1370
|
+
className: getSize9(4)
|
|
1371
|
+
}), /* @__PURE__ */ React22.createElement("span", null, t("back label")))));
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/InvitationAccepted.tsx
|
|
1375
|
+
import { CaretLeft as CaretLeft5, Check as Check2 } from "phosphor-react";
|
|
1376
|
+
import React23, { cloneElement as cloneElement4 } from "react";
|
|
1377
|
+
import { useInvitationStatus as useInvitationStatus3 } from "@dxos/react-client";
|
|
1378
|
+
import { Button as Button9, getSize as getSize10, mx as mx18, useTranslation as useTranslation13 } from "@dxos/react-components";
|
|
1379
|
+
function _extends19() {
|
|
1380
|
+
_extends19 = Object.assign || function(target) {
|
|
1381
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1382
|
+
var source = arguments[i];
|
|
1383
|
+
for (var key in source) {
|
|
1384
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1385
|
+
target[key] = source[key];
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return target;
|
|
1390
|
+
};
|
|
1391
|
+
return _extends19.apply(this, arguments);
|
|
1392
|
+
}
|
|
1393
|
+
var PureInvitationAcceptedContent = ({ onDone, result, invitationType, doneActionParent, active }) => {
|
|
1394
|
+
const disabled = !active;
|
|
1395
|
+
const { t } = useTranslation13("os");
|
|
1396
|
+
const doneButton = /* @__PURE__ */ React23.createElement(Button9, _extends19({}, onDone && {
|
|
1397
|
+
onClick: () => onDone(result)
|
|
1398
|
+
}, {
|
|
1399
|
+
disabled,
|
|
1400
|
+
className: "grow flex items-center gap-2 pli-2",
|
|
1401
|
+
"data-autofocus": `${invitationType} invitation acceptor; invitation accepted`,
|
|
1402
|
+
"data-testid": `${invitationType}-invitation-accepted-done`
|
|
1403
|
+
}), /* @__PURE__ */ React23.createElement(CaretLeft5, {
|
|
1404
|
+
weight: "bold",
|
|
1405
|
+
className: mx18(getSize10(2), "invisible")
|
|
1406
|
+
}), /* @__PURE__ */ React23.createElement("span", {
|
|
1407
|
+
className: "grow"
|
|
1408
|
+
}, t("done label")), /* @__PURE__ */ React23.createElement(Check2, {
|
|
1409
|
+
weight: "bold",
|
|
1410
|
+
className: getSize10(4)
|
|
1411
|
+
}));
|
|
1412
|
+
return doneActionParent ? /* @__PURE__ */ cloneElement4(doneActionParent, {}, doneButton) : doneButton;
|
|
1413
|
+
};
|
|
1414
|
+
var InvitationAcceptedContent = (props) => {
|
|
1415
|
+
const { result } = useInvitationStatus3(props.activeInvitation);
|
|
1416
|
+
return /* @__PURE__ */ React23.createElement(PureInvitationAcceptedContent, _extends19({}, props, {
|
|
1417
|
+
result
|
|
1418
|
+
}));
|
|
1419
|
+
};
|
|
1420
|
+
var InvitationAccepted = (props) => {
|
|
1421
|
+
const { invitationType: _invitationType, doneActionParent: _doneActionParent, onDone: _onDone, ...viewStateProps } = props;
|
|
1422
|
+
const { activeInvitation } = viewStateProps;
|
|
1423
|
+
return /* @__PURE__ */ React23.createElement(ViewState, _extends19({}, viewStateProps), !activeInvitation || activeInvitation === true ? /* @__PURE__ */ React23.createElement(PureInvitationAcceptedContent, _extends19({}, props, {
|
|
1424
|
+
result: null
|
|
1425
|
+
})) : /* @__PURE__ */ React23.createElement(InvitationAcceptedContent, _extends19({}, props)));
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1428
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/InvitationInput.tsx
|
|
1429
|
+
import { CaretLeft as CaretLeft6, CaretRight as CaretRight5 } from "phosphor-react";
|
|
1430
|
+
import React24, { useState as useState4 } from "react";
|
|
1431
|
+
import { InvitationEncoder } from "@dxos/client";
|
|
1432
|
+
import { useClient as useClient5 } from "@dxos/react-client";
|
|
1433
|
+
import { Button as Button10, getSize as getSize11, Input as Input2, mx as mx19, useTranslation as useTranslation14 } from "@dxos/react-components";
|
|
1434
|
+
function _extends20() {
|
|
1435
|
+
_extends20 = Object.assign || function(target) {
|
|
1436
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1437
|
+
var source = arguments[i];
|
|
1438
|
+
for (var key in source) {
|
|
1439
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1440
|
+
target[key] = source[key];
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
return target;
|
|
1445
|
+
};
|
|
1446
|
+
return _extends20.apply(this, arguments);
|
|
1447
|
+
}
|
|
1448
|
+
var InvitationInput = ({ invitationType, ...viewStateProps }) => {
|
|
1449
|
+
const client = useClient5();
|
|
1450
|
+
const disabled = !viewStateProps.active;
|
|
1451
|
+
const { dispatch } = viewStateProps;
|
|
1452
|
+
const { t } = useTranslation14("os");
|
|
1453
|
+
const [inputValue, setInputValue] = useState4("");
|
|
1454
|
+
const handleNext = () => dispatch({
|
|
1455
|
+
type: "connecting invitation",
|
|
1456
|
+
from: invitationType,
|
|
1457
|
+
invitation: client[invitationType === "halo" ? "halo" : "echo"].acceptInvitation(InvitationEncoder.decode(inputValue))
|
|
1458
|
+
});
|
|
1459
|
+
return /* @__PURE__ */ React24.createElement(ViewState, _extends20({}, viewStateProps), /* @__PURE__ */ React24.createElement(Input2, {
|
|
1460
|
+
disabled,
|
|
1461
|
+
label: /* @__PURE__ */ React24.createElement(ViewStateHeading, null, t("invitation input label")),
|
|
1462
|
+
onChange: ({ target: { value } }) => setInputValue(value),
|
|
1463
|
+
slots: {
|
|
1464
|
+
root: {
|
|
1465
|
+
className: "m-0"
|
|
1466
|
+
},
|
|
1467
|
+
label: {
|
|
1468
|
+
className: "sr-only"
|
|
1469
|
+
},
|
|
1470
|
+
input: {
|
|
1471
|
+
"data-autofocus": `${invitationType} invitation acceptor; invitation input`,
|
|
1472
|
+
onKeyUp: ({ key }) => key === "Enter" && handleNext()
|
|
1473
|
+
}
|
|
1474
|
+
},
|
|
1475
|
+
"data-testid": "invitation-input"
|
|
1476
|
+
}), /* @__PURE__ */ React24.createElement("div", {
|
|
1477
|
+
role: "none",
|
|
1478
|
+
className: "grow"
|
|
1479
|
+
}), /* @__PURE__ */ React24.createElement("div", {
|
|
1480
|
+
className: "flex gap-2"
|
|
1481
|
+
}, /* @__PURE__ */ React24.createElement(Button10, {
|
|
1482
|
+
disabled,
|
|
1483
|
+
className: "grow flex items-center gap-2 pli-2 order-2",
|
|
1484
|
+
onClick: handleNext,
|
|
1485
|
+
"data-testid": `${invitationType}-invitation-input-continue`
|
|
1486
|
+
}, /* @__PURE__ */ React24.createElement(CaretLeft6, {
|
|
1487
|
+
weight: "bold",
|
|
1488
|
+
className: mx19(getSize11(2), "invisible")
|
|
1489
|
+
}), /* @__PURE__ */ React24.createElement("span", {
|
|
1490
|
+
className: "grow"
|
|
1491
|
+
}, t("continue label")), /* @__PURE__ */ React24.createElement(CaretRight5, {
|
|
1492
|
+
weight: "bold",
|
|
1493
|
+
className: getSize11(4)
|
|
1494
|
+
})), /* @__PURE__ */ React24.createElement(Button10, {
|
|
1495
|
+
disabled,
|
|
1496
|
+
onClick: () => dispatch({
|
|
1497
|
+
type: "add identity"
|
|
1498
|
+
}),
|
|
1499
|
+
className: "flex items-center gap-2 pis-2 pie-4",
|
|
1500
|
+
"data-testid": `${invitationType}-invitation-input-back`
|
|
1501
|
+
}, /* @__PURE__ */ React24.createElement(CaretLeft6, {
|
|
1502
|
+
weight: "bold",
|
|
1503
|
+
className: getSize11(4)
|
|
1504
|
+
}), /* @__PURE__ */ React24.createElement("span", null, t("back label")))));
|
|
1505
|
+
};
|
|
1506
|
+
|
|
1507
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/InvitationRescuer.tsx
|
|
1508
|
+
import { ArrowsClockwise, CaretLeft as CaretLeft7, CaretRight as CaretRight6 } from "phosphor-react";
|
|
1509
|
+
import React25 from "react";
|
|
1510
|
+
import { Invitation as Invitation5 } from "@dxos/client";
|
|
1511
|
+
import { useInvitationStatus as useInvitationStatus4 } from "@dxos/react-client";
|
|
1512
|
+
import { Button as Button11, getSize as getSize12, mx as mx20, useTranslation as useTranslation15 } from "@dxos/react-components";
|
|
1513
|
+
function _extends21() {
|
|
1514
|
+
_extends21 = Object.assign || function(target) {
|
|
1515
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1516
|
+
var source = arguments[i];
|
|
1517
|
+
for (var key in source) {
|
|
1518
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1519
|
+
target[key] = source[key];
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
return target;
|
|
1524
|
+
};
|
|
1525
|
+
return _extends21.apply(this, arguments);
|
|
1526
|
+
}
|
|
1527
|
+
var InvitationActions = ({ activeInvitation, disabled, dispatch, invitationType }) => {
|
|
1528
|
+
const { status, cancel } = useInvitationStatus4(activeInvitation);
|
|
1529
|
+
const { t } = useTranslation15("os");
|
|
1530
|
+
switch (status) {
|
|
1531
|
+
case Invitation5.State.CONNECTING:
|
|
1532
|
+
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement("div", {
|
|
1533
|
+
role: "none",
|
|
1534
|
+
className: "grow"
|
|
1535
|
+
}), /* @__PURE__ */ React25.createElement("div", {
|
|
1536
|
+
className: "flex gap-2"
|
|
1537
|
+
}, /* @__PURE__ */ React25.createElement(Button11, {
|
|
1538
|
+
disabled: true,
|
|
1539
|
+
className: "grow flex items-center gap-2 pli-2 order-2",
|
|
1540
|
+
"data-testid": "next"
|
|
1541
|
+
}, /* @__PURE__ */ React25.createElement(CaretLeft7, {
|
|
1542
|
+
weight: "bold",
|
|
1543
|
+
className: mx20(getSize12(2), "invisible")
|
|
1544
|
+
}), /* @__PURE__ */ React25.createElement("span", {
|
|
1545
|
+
className: "grow"
|
|
1546
|
+
}, t("next label")), /* @__PURE__ */ React25.createElement(CaretRight6, {
|
|
1547
|
+
weight: "bold",
|
|
1548
|
+
className: getSize12(4)
|
|
1549
|
+
})), /* @__PURE__ */ React25.createElement(Button11, {
|
|
1550
|
+
disabled,
|
|
1551
|
+
className: "flex items-center gap-2 pis-2 pie-4",
|
|
1552
|
+
onClick: cancel,
|
|
1553
|
+
"data-autofocus": `${invitationType} invitation acceptor; invitation rescuer`,
|
|
1554
|
+
"data-testid": "invitation-rescuer-cancel"
|
|
1555
|
+
}, /* @__PURE__ */ React25.createElement(CaretLeft7, {
|
|
1556
|
+
weight: "bold",
|
|
1557
|
+
className: getSize12(4)
|
|
1558
|
+
}), /* @__PURE__ */ React25.createElement("span", null, t("cancel label")))));
|
|
1559
|
+
case Invitation5.State.TIMEOUT:
|
|
1560
|
+
case Invitation5.State.CANCELLED:
|
|
1561
|
+
case Invitation5.State.ERROR:
|
|
1562
|
+
default:
|
|
1563
|
+
return /* @__PURE__ */ React25.createElement(Button11, {
|
|
1564
|
+
disabled,
|
|
1565
|
+
className: "grow flex items-center gap-2 pli-2",
|
|
1566
|
+
onClick: () => dispatch({
|
|
1567
|
+
type: "reset invitation",
|
|
1568
|
+
from: invitationType
|
|
1569
|
+
}),
|
|
1570
|
+
"data-autofocus": `${invitationType} invitation acceptor; invitation rescuer`,
|
|
1571
|
+
"data-testid": "invitation-rescuer-reset"
|
|
1572
|
+
}, /* @__PURE__ */ React25.createElement(CaretLeft7, {
|
|
1573
|
+
weight: "bold",
|
|
1574
|
+
className: mx20(getSize12(5), "invisible")
|
|
1575
|
+
}), /* @__PURE__ */ React25.createElement("span", {
|
|
1576
|
+
className: "grow"
|
|
1577
|
+
}, t("reset label")), /* @__PURE__ */ React25.createElement(ArrowsClockwise, {
|
|
1578
|
+
weight: "bold",
|
|
1579
|
+
className: getSize12(5)
|
|
1580
|
+
}));
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
var InvitationRescuer = ({ invitationType, ...viewStateProps }) => {
|
|
1584
|
+
const disabled = !viewStateProps.active;
|
|
1585
|
+
const { dispatch, activeInvitation } = viewStateProps;
|
|
1586
|
+
const { t } = useTranslation15("os");
|
|
1587
|
+
return /* @__PURE__ */ React25.createElement(ViewState, _extends21({}, viewStateProps), activeInvitation === true || !activeInvitation ? /* @__PURE__ */ React25.createElement(Button11, {
|
|
1588
|
+
disabled,
|
|
1589
|
+
className: "grow flex items-center gap-2 pli-2",
|
|
1590
|
+
"data-autofocus": "space invitation acceptor; invitation rescuer",
|
|
1591
|
+
"data-testid": "invitation-rescuer-connect"
|
|
1592
|
+
}, /* @__PURE__ */ React25.createElement(CaretLeft7, {
|
|
1593
|
+
weight: "bold",
|
|
1594
|
+
className: mx20(getSize12(5), "invisible")
|
|
1595
|
+
}), /* @__PURE__ */ React25.createElement("span", {
|
|
1596
|
+
className: "grow"
|
|
1597
|
+
}, t("connect label")), /* @__PURE__ */ React25.createElement(ArrowsClockwise, {
|
|
1598
|
+
weight: "bold",
|
|
1599
|
+
className: getSize12(5)
|
|
1600
|
+
})) : /* @__PURE__ */ React25.createElement(InvitationActions, _extends21({}, {
|
|
1601
|
+
activeInvitation,
|
|
1602
|
+
disabled,
|
|
1603
|
+
dispatch,
|
|
1604
|
+
invitationType
|
|
1605
|
+
})));
|
|
1606
|
+
};
|
|
1607
|
+
|
|
1608
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/view-states/InvitationAuthenticator.tsx
|
|
1609
|
+
import { CaretLeft as CaretLeft8, CaretRight as CaretRight7 } from "phosphor-react";
|
|
1610
|
+
import React26, { useCallback as useCallback5, useState as useState5 } from "react";
|
|
1611
|
+
import { useInvitationStatus as useInvitationStatus5 } from "@dxos/react-client";
|
|
1612
|
+
import { Button as Button12, getSize as getSize13, Input as Input3, mx as mx21, useTranslation as useTranslation16 } from "@dxos/react-components";
|
|
1613
|
+
function _extends22() {
|
|
1614
|
+
_extends22 = Object.assign || function(target) {
|
|
1615
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1616
|
+
var source = arguments[i];
|
|
1617
|
+
for (var key in source) {
|
|
1618
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1619
|
+
target[key] = source[key];
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
return target;
|
|
1624
|
+
};
|
|
1625
|
+
return _extends22.apply(this, arguments);
|
|
1626
|
+
}
|
|
1627
|
+
var pinLength = 6;
|
|
1628
|
+
var PureInvitationAuthenticatorContent = ({ disabled, failed, dispatch, invitationType, onChange, onAuthenticate }) => {
|
|
1629
|
+
const { t } = useTranslation16("os");
|
|
1630
|
+
return /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement(Input3, _extends22({
|
|
1631
|
+
label: t("auth code input label"),
|
|
1632
|
+
size: "pin",
|
|
1633
|
+
length: pinLength,
|
|
1634
|
+
onChange,
|
|
1635
|
+
disabled,
|
|
1636
|
+
slots: {
|
|
1637
|
+
root: {
|
|
1638
|
+
className: "m-0"
|
|
1639
|
+
},
|
|
1640
|
+
label: {
|
|
1641
|
+
className: "sr-only"
|
|
1642
|
+
},
|
|
1643
|
+
description: {
|
|
1644
|
+
className: "text-center"
|
|
1645
|
+
},
|
|
1646
|
+
input: {
|
|
1647
|
+
disabled,
|
|
1648
|
+
inputMode: "numeric",
|
|
1649
|
+
pattern: "\\d*",
|
|
1650
|
+
"data-autofocus": `${invitationType} invitation acceptor; invitation authenticator`
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
}, failed && {
|
|
1654
|
+
validationValence: "error",
|
|
1655
|
+
validationMessage: t("failed to authenticate message")
|
|
1656
|
+
}, {
|
|
1657
|
+
"data-testid": "auth-code-input"
|
|
1658
|
+
})), /* @__PURE__ */ React26.createElement("div", {
|
|
1659
|
+
role: "none",
|
|
1660
|
+
className: "grow"
|
|
1661
|
+
}), /* @__PURE__ */ React26.createElement("div", {
|
|
1662
|
+
className: "flex gap-2"
|
|
1663
|
+
}, /* @__PURE__ */ React26.createElement(Button12, {
|
|
1664
|
+
disabled,
|
|
1665
|
+
className: "grow flex items-center gap-2 pli-2 order-2",
|
|
1666
|
+
onClick: onAuthenticate,
|
|
1667
|
+
"data-autofocus-pinlength": invitationType,
|
|
1668
|
+
"data-testid": `${invitationType}-invitation-authenticator-next`
|
|
1669
|
+
}, /* @__PURE__ */ React26.createElement(CaretLeft8, {
|
|
1670
|
+
weight: "bold",
|
|
1671
|
+
className: mx21(getSize13(2), "invisible")
|
|
1672
|
+
}), /* @__PURE__ */ React26.createElement("span", {
|
|
1673
|
+
className: "grow"
|
|
1674
|
+
}, t("next label")), /* @__PURE__ */ React26.createElement(CaretRight7, {
|
|
1675
|
+
weight: "bold",
|
|
1676
|
+
className: getSize13(4)
|
|
1677
|
+
})), /* @__PURE__ */ React26.createElement(Button12, {
|
|
1678
|
+
disabled,
|
|
1679
|
+
className: "flex items-center gap-2 pis-2 pie-4",
|
|
1680
|
+
onClick: () => dispatch({
|
|
1681
|
+
type: "cancel invitation",
|
|
1682
|
+
from: invitationType
|
|
1683
|
+
}),
|
|
1684
|
+
"data-testid": `${invitationType}-invitation-authenticator-cancel`
|
|
1685
|
+
}, /* @__PURE__ */ React26.createElement(CaretLeft8, {
|
|
1686
|
+
weight: "bold",
|
|
1687
|
+
className: getSize13(4)
|
|
1688
|
+
}), /* @__PURE__ */ React26.createElement("span", null, t("cancel label")))));
|
|
1689
|
+
};
|
|
1690
|
+
var InvitationAuthenticatorContent = ({ disabled, invitation, dispatch, invitationType, failed }) => {
|
|
1691
|
+
const [pinValue, setPinValue] = useState5("");
|
|
1692
|
+
const { authenticate } = useInvitationStatus5(invitation);
|
|
1693
|
+
const onAuthenticate = useCallback5(() => {
|
|
1694
|
+
dispatch({
|
|
1695
|
+
type: "authenticating invitation",
|
|
1696
|
+
from: invitationType
|
|
1697
|
+
});
|
|
1698
|
+
void authenticate(pinValue);
|
|
1699
|
+
}, [
|
|
1700
|
+
dispatch,
|
|
1701
|
+
invitationType,
|
|
1702
|
+
authenticate,
|
|
1703
|
+
pinValue
|
|
1704
|
+
]);
|
|
1705
|
+
const onChange = useCallback5(({ target: { value } }) => {
|
|
1706
|
+
var _a;
|
|
1707
|
+
setPinValue(value);
|
|
1708
|
+
if (value.length === pinLength) {
|
|
1709
|
+
(_a = document.querySelector(`[data-autofocus-pinlength="${invitationType}"]`)) == null ? void 0 : _a.focus();
|
|
1710
|
+
}
|
|
1711
|
+
}, [
|
|
1712
|
+
authenticate,
|
|
1713
|
+
pinValue
|
|
1714
|
+
]);
|
|
1715
|
+
return /* @__PURE__ */ React26.createElement(PureInvitationAuthenticatorContent, _extends22({}, {
|
|
1716
|
+
disabled,
|
|
1717
|
+
failed,
|
|
1718
|
+
dispatch,
|
|
1719
|
+
invitationType,
|
|
1720
|
+
onChange,
|
|
1721
|
+
onAuthenticate
|
|
1722
|
+
}));
|
|
1723
|
+
};
|
|
1724
|
+
var InvitationAuthenticator = ({ invitationType, failed, ...viewStateProps }) => {
|
|
1725
|
+
const disabled = !viewStateProps.active;
|
|
1726
|
+
const { activeInvitation, dispatch } = viewStateProps;
|
|
1727
|
+
return /* @__PURE__ */ React26.createElement(ViewState, _extends22({}, viewStateProps), !activeInvitation || activeInvitation === true ? /* @__PURE__ */ React26.createElement(PureInvitationAuthenticatorContent, _extends22({}, {
|
|
1728
|
+
disabled,
|
|
1729
|
+
failed,
|
|
1730
|
+
dispatch,
|
|
1731
|
+
invitationType,
|
|
1732
|
+
onChange: () => {
|
|
1733
|
+
},
|
|
1734
|
+
onAuthenticate: () => {
|
|
1735
|
+
}
|
|
1736
|
+
})) : /* @__PURE__ */ React26.createElement(InvitationAuthenticatorContent, _extends22({}, {
|
|
1737
|
+
disabled,
|
|
1738
|
+
failed,
|
|
1739
|
+
invitation: activeInvitation,
|
|
1740
|
+
dispatch,
|
|
1741
|
+
invitationType
|
|
1742
|
+
})));
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
// packages/apps/patterns/react-ui/src/panels/JoinPanel/JoinPanel.tsx
|
|
1746
|
+
function _extends23() {
|
|
1747
|
+
_extends23 = Object.assign || function(target) {
|
|
1748
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1749
|
+
var source = arguments[i];
|
|
1750
|
+
for (var key in source) {
|
|
1751
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1752
|
+
target[key] = source[key];
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return target;
|
|
1757
|
+
};
|
|
1758
|
+
return _extends23.apply(this, arguments);
|
|
1759
|
+
}
|
|
1760
|
+
var JoinPanel = ({ mode, initialInvitationCode, titleId: propsTitleId, exitActionParent, onExit, doneActionParent, onDone, preventExit }) => {
|
|
1761
|
+
const client = useClient6();
|
|
1762
|
+
const internalTitleId = useId4("joinPanel__title");
|
|
1763
|
+
const titleId = propsTitleId != null ? propsTitleId : internalTitleId;
|
|
1764
|
+
const identity = useIdentity2();
|
|
1765
|
+
const availableIdentities = identity ? [
|
|
1766
|
+
identity
|
|
1767
|
+
] : [];
|
|
1768
|
+
const reducer = (state, action) => {
|
|
1769
|
+
var _a, _b, _c, _d;
|
|
1770
|
+
const nextState = {
|
|
1771
|
+
...state
|
|
1772
|
+
};
|
|
1773
|
+
switch (action.type) {
|
|
1774
|
+
case "added identity":
|
|
1775
|
+
nextState.activeView = "identity added";
|
|
1776
|
+
nextState.selectedIdentity = action.identity;
|
|
1777
|
+
break;
|
|
1778
|
+
case "add identity":
|
|
1779
|
+
nextState.activeView = "addition method selector";
|
|
1780
|
+
break;
|
|
1781
|
+
case "select addition method":
|
|
1782
|
+
if (action.method === "accept device invitation") {
|
|
1783
|
+
nextState.activeView = "halo invitation acceptor";
|
|
1784
|
+
if (state.unredeemedHaloInvitationCode) {
|
|
1785
|
+
nextState.haloInvitation = client.halo.acceptInvitation(InvitationEncoder2.decode(state.unredeemedHaloInvitationCode));
|
|
1786
|
+
nextState.unredeemedHaloInvitationCode = void 0;
|
|
1787
|
+
nextState.haloViewState = "invitation authenticator";
|
|
1788
|
+
} else {
|
|
1789
|
+
nextState.haloViewState = "invitation input";
|
|
1790
|
+
}
|
|
1791
|
+
} else {
|
|
1792
|
+
nextState.activeView = "identity input";
|
|
1793
|
+
nextState.additionMethod = action.method;
|
|
1794
|
+
}
|
|
1795
|
+
break;
|
|
1796
|
+
case "select identity":
|
|
1797
|
+
nextState.selectedIdentity = action.identity;
|
|
1798
|
+
nextState.activeView = "space invitation acceptor";
|
|
1799
|
+
if (state.unredeemedSpaceInvitationCode) {
|
|
1800
|
+
nextState.spaceInvitation = client.echo.acceptInvitation(InvitationEncoder2.decode(state.unredeemedSpaceInvitationCode));
|
|
1801
|
+
nextState.unredeemedSpaceInvitationCode = void 0;
|
|
1802
|
+
nextState.spaceViewState = "invitation authenticator";
|
|
1803
|
+
} else {
|
|
1804
|
+
nextState.spaceViewState = "invitation input";
|
|
1805
|
+
}
|
|
1806
|
+
break;
|
|
1807
|
+
case "deselect identity":
|
|
1808
|
+
nextState.selectedIdentity = void 0;
|
|
1809
|
+
nextState.activeView = "identity selector";
|
|
1810
|
+
break;
|
|
1811
|
+
case "cancel invitation":
|
|
1812
|
+
if (action.from === "space" && ((_a = state.spaceInvitation) == null ? void 0 : _a.invitation)) {
|
|
1813
|
+
void ((_b = state.spaceInvitation) == null ? void 0 : _b.cancel());
|
|
1814
|
+
}
|
|
1815
|
+
if (action.from === "halo" && ((_c = state.haloInvitation) == null ? void 0 : _c.invitation)) {
|
|
1816
|
+
void ((_d = state.haloInvitation) == null ? void 0 : _d.cancel());
|
|
1817
|
+
}
|
|
1818
|
+
break;
|
|
1819
|
+
case "authenticating invitation":
|
|
1820
|
+
nextState[action.from === "halo" ? "haloInvitationAnnotation" : "spaceInvitationAnnotation"] = "authenticating";
|
|
1821
|
+
break;
|
|
1822
|
+
case "connecting invitation":
|
|
1823
|
+
nextState[action.from === "halo" ? "haloInvitation" : "spaceInvitation"] = action.invitation;
|
|
1824
|
+
case "cancelled invitation":
|
|
1825
|
+
case "fail invitation":
|
|
1826
|
+
case "timeout invitation":
|
|
1827
|
+
nextState[action.from === "halo" ? "haloViewState" : "spaceViewState"] = "invitation rescuer";
|
|
1828
|
+
break;
|
|
1829
|
+
case "connect invitation":
|
|
1830
|
+
case "authenticate invitation":
|
|
1831
|
+
if (action.from === "halo" && state.haloInvitationAnnotation === "authenticating") {
|
|
1832
|
+
nextState.haloInvitationAnnotation = "authentication failed";
|
|
1833
|
+
}
|
|
1834
|
+
if (action.from === "space" && state.spaceInvitationAnnotation === "authenticating") {
|
|
1835
|
+
nextState.spaceInvitationAnnotation = "authentication failed";
|
|
1836
|
+
}
|
|
1837
|
+
nextState[action.from === "halo" ? "haloViewState" : "spaceViewState"] = "invitation authenticator";
|
|
1838
|
+
break;
|
|
1839
|
+
case "accepted invitation":
|
|
1840
|
+
nextState[action.from === "halo" ? "haloViewState" : "spaceViewState"] = "invitation accepted";
|
|
1841
|
+
break;
|
|
1842
|
+
case "reset invitation":
|
|
1843
|
+
nextState[action.from === "halo" ? "haloInvitation" : "spaceInvitation"] = void 0;
|
|
1844
|
+
nextState[action.from === "halo" ? "haloInvitationAnnotation" : "spaceInvitationAnnotation"] = void 0;
|
|
1845
|
+
nextState[action.from === "halo" ? "unredeemedHaloInvitationCode" : "unredeemedSpaceInvitationCode"] = void 0;
|
|
1846
|
+
nextState[action.from === "halo" ? "haloViewState" : "spaceViewState"] = "invitation input";
|
|
1847
|
+
break;
|
|
1848
|
+
}
|
|
1849
|
+
log("[join panel reducer]", {
|
|
1850
|
+
action,
|
|
1851
|
+
nextState
|
|
1852
|
+
}, {
|
|
1853
|
+
file: "JoinPanel.tsx",
|
|
1854
|
+
line: 125,
|
|
1855
|
+
scope: void 0,
|
|
1856
|
+
callSite: (f, a) => f(...a)
|
|
1857
|
+
});
|
|
1858
|
+
return nextState;
|
|
1859
|
+
};
|
|
1860
|
+
const unredeemedHaloInvitationCode = mode === "halo-only" ? initialInvitationCode : void 0;
|
|
1861
|
+
const [joinState, dispatch] = useReducer2(reducer, {
|
|
1862
|
+
unredeemedHaloInvitationCode,
|
|
1863
|
+
unredeemedSpaceInvitationCode: mode === "halo-only" ? void 0 : initialInvitationCode,
|
|
1864
|
+
spaceInvitation: void 0,
|
|
1865
|
+
haloInvitation: void 0,
|
|
1866
|
+
activeView: availableIdentities.length > 0 ? "identity selector" : "addition method selector",
|
|
1867
|
+
selectedIdentity: void 0,
|
|
1868
|
+
additionMethod: void 0,
|
|
1869
|
+
spaceViewState: "invitation input",
|
|
1870
|
+
haloViewState: "invitation input"
|
|
1871
|
+
});
|
|
1872
|
+
useEffect(() => {
|
|
1873
|
+
if (unredeemedHaloInvitationCode) {
|
|
1874
|
+
dispatch({
|
|
1875
|
+
type: "select addition method",
|
|
1876
|
+
method: "accept device invitation"
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
}, [
|
|
1880
|
+
unredeemedHaloInvitationCode
|
|
1881
|
+
]);
|
|
1882
|
+
useEffect(() => {
|
|
1883
|
+
const attrValue = joinState.activeView === "identity input" ? `${joinState.activeView}; ${joinState.additionMethod}` : joinState.activeView === "space invitation acceptor" ? `${joinState.activeView}; ${joinState.spaceViewState}` : joinState.activeView === "halo invitation acceptor" ? `${joinState.activeView}; ${joinState.haloViewState}` : joinState.activeView;
|
|
1884
|
+
log("[autofocus value]", {
|
|
1885
|
+
attrValue
|
|
1886
|
+
}, {
|
|
1887
|
+
file: "JoinPanel.tsx",
|
|
1888
|
+
line: 158,
|
|
1889
|
+
scope: void 0,
|
|
1890
|
+
callSite: (f, a) => f(...a)
|
|
1891
|
+
});
|
|
1892
|
+
const $nextAutofocus = document.querySelector(`[data-autofocus="${attrValue}"]`);
|
|
1893
|
+
if ($nextAutofocus) {
|
|
1894
|
+
$nextAutofocus.focus();
|
|
1895
|
+
}
|
|
1896
|
+
}, [
|
|
1897
|
+
joinState.activeView,
|
|
1898
|
+
joinState.spaceViewState,
|
|
1899
|
+
joinState.haloViewState
|
|
1900
|
+
]);
|
|
1901
|
+
useEffect(() => {
|
|
1902
|
+
var _a;
|
|
1903
|
+
return (_a = joinState.spaceInvitation) == null ? void 0 : _a.subscribe({
|
|
1904
|
+
onAuthenticating: () => dispatch({
|
|
1905
|
+
type: "authenticate invitation",
|
|
1906
|
+
from: "space"
|
|
1907
|
+
}),
|
|
1908
|
+
onCancelled: () => dispatch({
|
|
1909
|
+
type: "cancelled invitation",
|
|
1910
|
+
from: "space"
|
|
1911
|
+
}),
|
|
1912
|
+
onConnected: () => dispatch({
|
|
1913
|
+
type: "connect invitation",
|
|
1914
|
+
from: "space"
|
|
1915
|
+
}),
|
|
1916
|
+
onError: () => dispatch({
|
|
1917
|
+
type: "fail invitation",
|
|
1918
|
+
from: "space"
|
|
1919
|
+
}),
|
|
1920
|
+
onSuccess: () => dispatch({
|
|
1921
|
+
type: "accepted invitation",
|
|
1922
|
+
from: "space"
|
|
1923
|
+
}),
|
|
1924
|
+
onTimeout: () => dispatch({
|
|
1925
|
+
type: "timeout invitation",
|
|
1926
|
+
from: "space"
|
|
1927
|
+
})
|
|
1928
|
+
});
|
|
1929
|
+
}, [
|
|
1930
|
+
joinState.spaceInvitation
|
|
1931
|
+
]);
|
|
1932
|
+
useEffect(() => {
|
|
1933
|
+
var _a;
|
|
1934
|
+
return (_a = joinState.haloInvitation) == null ? void 0 : _a.subscribe({
|
|
1935
|
+
onAuthenticating: () => dispatch({
|
|
1936
|
+
type: "authenticate invitation",
|
|
1937
|
+
from: "halo"
|
|
1938
|
+
}),
|
|
1939
|
+
onCancelled: () => dispatch({
|
|
1940
|
+
type: "cancelled invitation",
|
|
1941
|
+
from: "halo"
|
|
1942
|
+
}),
|
|
1943
|
+
onConnected: () => dispatch({
|
|
1944
|
+
type: "connect invitation",
|
|
1945
|
+
from: "halo"
|
|
1946
|
+
}),
|
|
1947
|
+
onError: () => dispatch({
|
|
1948
|
+
type: "fail invitation",
|
|
1949
|
+
from: "halo"
|
|
1950
|
+
}),
|
|
1951
|
+
onSuccess: () => dispatch({
|
|
1952
|
+
type: "accepted invitation",
|
|
1953
|
+
from: "halo"
|
|
1954
|
+
}),
|
|
1955
|
+
onTimeout: () => dispatch({
|
|
1956
|
+
type: "timeout invitation",
|
|
1957
|
+
from: "halo"
|
|
1958
|
+
})
|
|
1959
|
+
});
|
|
1960
|
+
}, [
|
|
1961
|
+
joinState.haloInvitation
|
|
1962
|
+
]);
|
|
1963
|
+
return /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement(JoinHeading, _extends23({}, {
|
|
1964
|
+
mode,
|
|
1965
|
+
titleId,
|
|
1966
|
+
invitation: joinState.spaceInvitation,
|
|
1967
|
+
onExit,
|
|
1968
|
+
exitActionParent,
|
|
1969
|
+
preventExit
|
|
1970
|
+
})), /* @__PURE__ */ React27.createElement("div", {
|
|
1971
|
+
role: "none",
|
|
1972
|
+
className: "is-full overflow-hidden"
|
|
1973
|
+
}, /* @__PURE__ */ React27.createElement("div", {
|
|
1974
|
+
role: "none",
|
|
1975
|
+
className: "flex is-[1300%]",
|
|
1976
|
+
"aria-live": "polite"
|
|
1977
|
+
}, /* @__PURE__ */ React27.createElement(IdentitySelector, _extends23({}, {
|
|
1978
|
+
dispatch,
|
|
1979
|
+
availableIdentities,
|
|
1980
|
+
active: joinState.activeView === "identity selector"
|
|
1981
|
+
})), /* @__PURE__ */ React27.createElement(AdditionMethodSelector, _extends23({}, {
|
|
1982
|
+
dispatch,
|
|
1983
|
+
availableIdentities,
|
|
1984
|
+
active: joinState.activeView === "addition method selector"
|
|
1985
|
+
})), /* @__PURE__ */ React27.createElement(IdentityInput, _extends23({}, {
|
|
1986
|
+
dispatch,
|
|
1987
|
+
active: joinState.activeView === "identity input" && joinState.additionMethod === "create identity",
|
|
1988
|
+
method: "create identity"
|
|
1989
|
+
})), /* @__PURE__ */ React27.createElement(IdentityInput, _extends23({}, {
|
|
1990
|
+
dispatch,
|
|
1991
|
+
active: joinState.activeView === "identity input" && joinState.additionMethod === "recover identity",
|
|
1992
|
+
method: "recover identity"
|
|
1993
|
+
})), /* @__PURE__ */ React27.createElement(InvitationInput, _extends23({}, {
|
|
1994
|
+
dispatch,
|
|
1995
|
+
activeInvitation: joinState.haloInvitation || true,
|
|
1996
|
+
active: joinState.activeView === "halo invitation acceptor" && joinState.haloViewState === "invitation input",
|
|
1997
|
+
invitationType: "halo"
|
|
1998
|
+
})), /* @__PURE__ */ React27.createElement(InvitationRescuer, _extends23({}, {
|
|
1999
|
+
dispatch,
|
|
2000
|
+
activeInvitation: joinState.haloInvitation || true,
|
|
2001
|
+
active: joinState.activeView === "halo invitation acceptor" && joinState.haloViewState === "invitation rescuer",
|
|
2002
|
+
invitationType: "halo"
|
|
2003
|
+
})), /* @__PURE__ */ React27.createElement(InvitationAuthenticator, _extends23({}, {
|
|
2004
|
+
dispatch,
|
|
2005
|
+
activeInvitation: joinState.haloInvitation || true,
|
|
2006
|
+
active: joinState.activeView === "halo invitation acceptor" && joinState.haloViewState === "invitation authenticator",
|
|
2007
|
+
invitationType: "halo",
|
|
2008
|
+
...joinState.spaceInvitationAnnotation === "authentication failed" && {
|
|
2009
|
+
failed: true
|
|
2010
|
+
}
|
|
2011
|
+
})), /* @__PURE__ */ React27.createElement(InvitationAccepted, _extends23({}, {
|
|
2012
|
+
dispatch,
|
|
2013
|
+
activeInvitation: joinState.haloInvitation || true,
|
|
2014
|
+
active: joinState.activeView === "halo invitation acceptor" && joinState.haloViewState === "invitation accepted",
|
|
2015
|
+
invitationType: "halo",
|
|
2016
|
+
doneActionParent,
|
|
2017
|
+
onDone
|
|
2018
|
+
})), /* @__PURE__ */ React27.createElement(IdentityAdded, _extends23({}, {
|
|
2019
|
+
mode,
|
|
2020
|
+
dispatch,
|
|
2021
|
+
addedIdentity: joinState.selectedIdentity,
|
|
2022
|
+
active: joinState.activeView === "identity added",
|
|
2023
|
+
doneActionParent,
|
|
2024
|
+
onDone
|
|
2025
|
+
})), /* @__PURE__ */ React27.createElement(InvitationInput, _extends23({}, {
|
|
2026
|
+
dispatch,
|
|
2027
|
+
activeInvitation: joinState.spaceInvitation || true,
|
|
2028
|
+
selectedIdentity: joinState.selectedIdentity,
|
|
2029
|
+
active: joinState.activeView === "space invitation acceptor" && joinState.spaceViewState === "invitation input",
|
|
2030
|
+
invitationType: "space"
|
|
2031
|
+
})), /* @__PURE__ */ React27.createElement(InvitationRescuer, _extends23({}, {
|
|
2032
|
+
dispatch,
|
|
2033
|
+
activeInvitation: joinState.spaceInvitation || true,
|
|
2034
|
+
selectedIdentity: joinState.selectedIdentity,
|
|
2035
|
+
active: joinState.activeView === "space invitation acceptor" && joinState.spaceViewState === "invitation rescuer",
|
|
2036
|
+
invitationType: "space"
|
|
2037
|
+
})), /* @__PURE__ */ React27.createElement(InvitationAuthenticator, _extends23({}, {
|
|
2038
|
+
dispatch,
|
|
2039
|
+
activeInvitation: joinState.spaceInvitation || true,
|
|
2040
|
+
selectedIdentity: joinState.selectedIdentity,
|
|
2041
|
+
active: joinState.activeView === "space invitation acceptor" && joinState.spaceViewState === "invitation authenticator",
|
|
2042
|
+
invitationType: "space",
|
|
2043
|
+
...joinState.spaceInvitationAnnotation === "authentication failed" && {
|
|
2044
|
+
failed: true
|
|
2045
|
+
}
|
|
2046
|
+
})), /* @__PURE__ */ React27.createElement(InvitationAccepted, _extends23({}, {
|
|
2047
|
+
dispatch,
|
|
2048
|
+
activeInvitation: joinState.spaceInvitation || true,
|
|
2049
|
+
selectedIdentity: joinState.selectedIdentity,
|
|
2050
|
+
active: joinState.activeView === "space invitation acceptor" && joinState.spaceViewState === "invitation accepted",
|
|
2051
|
+
invitationType: "space",
|
|
2052
|
+
doneActionParent,
|
|
2053
|
+
onDone
|
|
2054
|
+
})))));
|
|
2055
|
+
};
|
|
2056
|
+
|
|
2057
|
+
// packages/apps/patterns/react-ui/src/panels/SpacePanel/SpacePanel.tsx
|
|
2058
|
+
import { CaretLeft as CaretLeft9, CaretRight as CaretRight8, Intersect, PlusCircle, UserPlus as UserPlus3 } from "phosphor-react";
|
|
2059
|
+
import React28, { cloneElement as cloneElement5, useReducer as useReducer3 } from "react";
|
|
2060
|
+
import { useClient as useClient7, useSpaceInvitations as useSpaceInvitations2, useSpaces } from "@dxos/react-client";
|
|
2061
|
+
import { Button as Button13, getSize as getSize14, mx as mx22, Tooltip as Tooltip2, useTranslation as useTranslation17 } from "@dxos/react-components";
|
|
2062
|
+
function _extends24() {
|
|
2063
|
+
_extends24 = Object.assign || function(target) {
|
|
2064
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2065
|
+
var source = arguments[i];
|
|
2066
|
+
for (var key in source) {
|
|
2067
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2068
|
+
target[key] = source[key];
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
return target;
|
|
2073
|
+
};
|
|
2074
|
+
return _extends24.apply(this, arguments);
|
|
2075
|
+
}
|
|
2076
|
+
var CurrentSpaceView = ({ space, createInvitationUrl, onClickMember, onShowAll, titleId }) => {
|
|
2077
|
+
const { t } = useTranslation17("os");
|
|
2078
|
+
const invitations = useSpaceInvitations2(space == null ? void 0 : space.key);
|
|
2079
|
+
const name = space == null ? void 0 : space.properties.name;
|
|
2080
|
+
if (!space) {
|
|
2081
|
+
return null;
|
|
2082
|
+
}
|
|
2083
|
+
return /* @__PURE__ */ React28.createElement("div", {
|
|
2084
|
+
role: "none",
|
|
2085
|
+
className: "flex flex-col"
|
|
2086
|
+
}, /* @__PURE__ */ React28.createElement("div", {
|
|
2087
|
+
role: "none",
|
|
2088
|
+
className: mx22(subduedSurface, "rounded-bs-md flex items-center p-2 gap-2")
|
|
2089
|
+
}, /* @__PURE__ */ React28.createElement(Tooltip2, {
|
|
2090
|
+
content: t("show all spaces label"),
|
|
2091
|
+
zIndex: "z-50"
|
|
2092
|
+
}, /* @__PURE__ */ React28.createElement(Button13, {
|
|
2093
|
+
compact: true,
|
|
2094
|
+
variant: "ghost",
|
|
2095
|
+
onClick: onShowAll,
|
|
2096
|
+
"data-testid": "show-all-spaces"
|
|
2097
|
+
}, /* @__PURE__ */ React28.createElement(CaretLeft9, {
|
|
2098
|
+
className: getSize14(4),
|
|
2099
|
+
weight: "bold"
|
|
2100
|
+
}))), /* @__PURE__ */ React28.createElement("h2", {
|
|
2101
|
+
id: titleId,
|
|
2102
|
+
className: mx22("grow font-system-medium", !name && "font-mono")
|
|
2103
|
+
}, name != null ? name : space.key.truncate())), /* @__PURE__ */ React28.createElement("div", {
|
|
2104
|
+
role: "region",
|
|
2105
|
+
className: mx22(defaultSurface, "rounded-be-md p-2")
|
|
2106
|
+
}, /* @__PURE__ */ React28.createElement(InvitationList, {
|
|
2107
|
+
invitations,
|
|
2108
|
+
onClickRemove: ({ invitation }) => invitation && (space == null ? void 0 : space.removeInvitation(invitation.invitationId)),
|
|
2109
|
+
createInvitationUrl
|
|
2110
|
+
}), /* @__PURE__ */ React28.createElement(Button13, {
|
|
2111
|
+
className: "is-full flex gap-2 mbs-2",
|
|
2112
|
+
compact: true,
|
|
2113
|
+
onClick: () => space == null ? void 0 : space.createInvitation(),
|
|
2114
|
+
"data-testid": "create-space-invitation"
|
|
2115
|
+
}, /* @__PURE__ */ React28.createElement("span", null, t("create space invitation label")), /* @__PURE__ */ React28.createElement(UserPlus3, {
|
|
2116
|
+
className: getSize14(4),
|
|
2117
|
+
weight: "bold"
|
|
2118
|
+
})), /* @__PURE__ */ React28.createElement(PanelSeparator, null), /* @__PURE__ */ React28.createElement(SpaceMemberListContainer, {
|
|
2119
|
+
spaceKey: space.key,
|
|
2120
|
+
includeSelf: true,
|
|
2121
|
+
onSelect: onClickMember
|
|
2122
|
+
})));
|
|
2123
|
+
};
|
|
2124
|
+
var SpaceListView = ({ doneActionParent, onDone, onClickJoinSpace, onShowCurrent, titleId }) => {
|
|
2125
|
+
const { t } = useTranslation17("os");
|
|
2126
|
+
const client = useClient7();
|
|
2127
|
+
const spaces = useSpaces();
|
|
2128
|
+
const handleCreateSpace = async () => {
|
|
2129
|
+
const space = await client.echo.createSpace();
|
|
2130
|
+
onDone == null ? void 0 : onDone(space);
|
|
2131
|
+
};
|
|
2132
|
+
return /* @__PURE__ */ React28.createElement("div", {
|
|
2133
|
+
role: "none",
|
|
2134
|
+
className: "flex flex-col"
|
|
2135
|
+
}, /* @__PURE__ */ React28.createElement("div", {
|
|
2136
|
+
role: "none",
|
|
2137
|
+
className: mx22(subduedSurface, "rounded-bs-md flex items-center p-2 gap-2")
|
|
2138
|
+
}, /* @__PURE__ */ React28.createElement("h2", {
|
|
2139
|
+
id: titleId,
|
|
2140
|
+
className: "grow font-system-medium"
|
|
2141
|
+
}, t("all spaces label")), /* @__PURE__ */ React28.createElement(Tooltip2, {
|
|
2142
|
+
content: t("show current space label"),
|
|
2143
|
+
zIndex: "z-50"
|
|
2144
|
+
}, /* @__PURE__ */ React28.createElement(Button13, {
|
|
2145
|
+
compact: true,
|
|
2146
|
+
variant: "ghost",
|
|
2147
|
+
onClick: onShowCurrent,
|
|
2148
|
+
"data-testid": "show-current-space"
|
|
2149
|
+
}, /* @__PURE__ */ React28.createElement(CaretRight8, {
|
|
2150
|
+
className: getSize14(4),
|
|
2151
|
+
weight: "bold"
|
|
2152
|
+
})))), /* @__PURE__ */ React28.createElement("div", {
|
|
2153
|
+
role: "region",
|
|
2154
|
+
className: mx22(defaultSurface, "rounded-be-md p-2")
|
|
2155
|
+
}, /* @__PURE__ */ React28.createElement("ul", {
|
|
2156
|
+
className: "flex flex-col gap-2"
|
|
2157
|
+
}, spaces.map((space) => {
|
|
2158
|
+
const key = space.key.toHex();
|
|
2159
|
+
const listItem = /* @__PURE__ */ React28.createElement(SpaceListItem, {
|
|
2160
|
+
key,
|
|
2161
|
+
space,
|
|
2162
|
+
onClick: () => onDone == null ? void 0 : onDone(space)
|
|
2163
|
+
});
|
|
2164
|
+
return doneActionParent ? /* @__PURE__ */ cloneElement5(doneActionParent, {
|
|
2165
|
+
key
|
|
2166
|
+
}, listItem) : listItem;
|
|
2167
|
+
})), /* @__PURE__ */ React28.createElement(Button13, {
|
|
2168
|
+
className: "is-full flex gap-2 mbs-2",
|
|
2169
|
+
compact: true,
|
|
2170
|
+
onClick: handleCreateSpace,
|
|
2171
|
+
"data-testid": "create-space"
|
|
2172
|
+
}, /* @__PURE__ */ React28.createElement("span", null, t("create space label")), /* @__PURE__ */ React28.createElement(PlusCircle, {
|
|
2173
|
+
className: getSize14(4),
|
|
2174
|
+
weight: "bold"
|
|
2175
|
+
})), onClickJoinSpace && /* @__PURE__ */ React28.createElement(Button13, {
|
|
2176
|
+
className: "is-full flex gap-2 mbs-2",
|
|
2177
|
+
compact: true,
|
|
2178
|
+
onClick: () => onClickJoinSpace == null ? void 0 : onClickJoinSpace(),
|
|
2179
|
+
"data-testid": "join-space"
|
|
2180
|
+
}, /* @__PURE__ */ React28.createElement("span", null, t("join space label")), /* @__PURE__ */ React28.createElement(Intersect, {
|
|
2181
|
+
className: getSize14(4),
|
|
2182
|
+
weight: "bold"
|
|
2183
|
+
}))));
|
|
2184
|
+
};
|
|
2185
|
+
var SpacePanel = (props) => {
|
|
2186
|
+
var _a;
|
|
2187
|
+
const reducer = (state, action) => {
|
|
2188
|
+
const nextState = {
|
|
2189
|
+
...state
|
|
2190
|
+
};
|
|
2191
|
+
switch (action.type) {
|
|
2192
|
+
case "deselect space":
|
|
2193
|
+
nextState.activeView = "space list";
|
|
2194
|
+
break;
|
|
2195
|
+
case "select space":
|
|
2196
|
+
nextState.activeView = "current space";
|
|
2197
|
+
break;
|
|
2198
|
+
}
|
|
2199
|
+
return nextState;
|
|
2200
|
+
};
|
|
2201
|
+
const [panelState, dispatch] = useReducer3(reducer, {
|
|
2202
|
+
activeView: (_a = props.initialState) != null ? _a : "current space"
|
|
2203
|
+
});
|
|
2204
|
+
return /* @__PURE__ */ React28.createElement(React28.Fragment, null, panelState.activeView === "current space" ? /* @__PURE__ */ React28.createElement(CurrentSpaceView, _extends24({}, props, {
|
|
2205
|
+
onShowAll: () => dispatch({
|
|
2206
|
+
type: "deselect space"
|
|
2207
|
+
})
|
|
2208
|
+
})) : /* @__PURE__ */ React28.createElement(SpaceListView, _extends24({}, props, {
|
|
2209
|
+
onShowCurrent: () => dispatch({
|
|
2210
|
+
type: "select space"
|
|
2211
|
+
})
|
|
2212
|
+
})));
|
|
2213
|
+
};
|
|
2214
|
+
|
|
2215
|
+
// packages/apps/patterns/react-ui/src/composites/IdentityPopover/IdentityPopover.tsx
|
|
2216
|
+
function _extends25() {
|
|
2217
|
+
_extends25 = Object.assign || function(target) {
|
|
2218
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2219
|
+
var source = arguments[i];
|
|
2220
|
+
for (var key in source) {
|
|
2221
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2222
|
+
target[key] = source[key];
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
return target;
|
|
2227
|
+
};
|
|
2228
|
+
return _extends25.apply(this, arguments);
|
|
2229
|
+
}
|
|
2230
|
+
var IdentityPopover = ({ identity, openTrigger, slots, triggerIsInToolbar = true, onClickManageProfile, ...popoverProps }) => {
|
|
2231
|
+
var _a, _b;
|
|
2232
|
+
return /* @__PURE__ */ React29.createElement(PanelPopover, _extends25({}, popoverProps, {
|
|
2233
|
+
openTrigger: openTrigger != null ? openTrigger : /* @__PURE__ */ React29.createElement(Avatar8, {
|
|
2234
|
+
size: 10,
|
|
2235
|
+
variant: "circle",
|
|
2236
|
+
fallbackValue: identity.identityKey.toHex(),
|
|
2237
|
+
label: (_a = identity.displayName) != null ? _a : ""
|
|
2238
|
+
}),
|
|
2239
|
+
slots: {
|
|
2240
|
+
...slots,
|
|
2241
|
+
trigger: {
|
|
2242
|
+
...slots == null ? void 0 : slots.trigger,
|
|
2243
|
+
className: mx23("flex justify-self-end pointer-events-auto bg-white dark:bg-neutral-700 p-0.5 button-elevation rounded-full", (_b = slots == null ? void 0 : slots.trigger) == null ? void 0 : _b.className)
|
|
2244
|
+
}
|
|
2245
|
+
},
|
|
2246
|
+
triggerIsInToolbar
|
|
2247
|
+
}), /* @__PURE__ */ React29.createElement(IdentityPanel, _extends25({}, {
|
|
2248
|
+
identity,
|
|
2249
|
+
onClickManageProfile
|
|
2250
|
+
})));
|
|
2251
|
+
};
|
|
2252
|
+
|
|
2253
|
+
// packages/apps/patterns/react-ui/src/composites/JoinDialog/JoinDialog.tsx
|
|
2254
|
+
import { Action, Cancel } from "@radix-ui/react-alert-dialog";
|
|
2255
|
+
import React30 from "react";
|
|
2256
|
+
import { ThemeContext as ThemeContext2, useId as useId5 } from "@dxos/react-components";
|
|
2257
|
+
function _extends26() {
|
|
2258
|
+
_extends26 = Object.assign || function(target) {
|
|
2259
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2260
|
+
var source = arguments[i];
|
|
2261
|
+
for (var key in source) {
|
|
2262
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2263
|
+
target[key] = source[key];
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
return target;
|
|
2268
|
+
};
|
|
2269
|
+
return _extends26.apply(this, arguments);
|
|
2270
|
+
}
|
|
2271
|
+
var JoinDialog = ({ slots, ...joinPanelProps }) => {
|
|
2272
|
+
const titleId = useId5("joinDialog__title");
|
|
2273
|
+
return /* @__PURE__ */ React30.createElement(PanelAlertDialog, _extends26({}, {
|
|
2274
|
+
slots,
|
|
2275
|
+
titleId
|
|
2276
|
+
}), /* @__PURE__ */ React30.createElement(ThemeContext2.Provider, {
|
|
2277
|
+
value: {
|
|
2278
|
+
themeVariant: "os"
|
|
2279
|
+
}
|
|
2280
|
+
}, /* @__PURE__ */ React30.createElement(JoinPanel, _extends26({}, {
|
|
2281
|
+
...joinPanelProps,
|
|
2282
|
+
titleId,
|
|
2283
|
+
exitActionParent: /* @__PURE__ */ React30.createElement(Cancel, {
|
|
2284
|
+
asChild: true
|
|
2285
|
+
}),
|
|
2286
|
+
doneActionParent: /* @__PURE__ */ React30.createElement(Action, {
|
|
2287
|
+
asChild: true
|
|
2288
|
+
})
|
|
2289
|
+
}))));
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2292
|
+
// packages/apps/patterns/react-ui/src/composites/Shell/Shell.tsx
|
|
2293
|
+
import React33, { useEffect as useEffect2, useState as useState6 } from "react";
|
|
2294
|
+
import { ShellDisplay, ShellLayout } from "@dxos/protocols/proto/dxos/iframe";
|
|
2295
|
+
import { useClient as useClient8, useSpace as useSpace3, useSpaces as useSpaces2 } from "@dxos/react-client";
|
|
2296
|
+
|
|
2297
|
+
// packages/apps/patterns/react-ui/src/composites/DevicesDialog/DevicesDialog.tsx
|
|
2298
|
+
import { Close } from "@radix-ui/react-dialog";
|
|
2299
|
+
import React31 from "react";
|
|
2300
|
+
import { ThemeContext as ThemeContext3, useId as useId6 } from "@dxos/react-components";
|
|
2301
|
+
function _extends27() {
|
|
2302
|
+
_extends27 = Object.assign || function(target) {
|
|
2303
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2304
|
+
var source = arguments[i];
|
|
2305
|
+
for (var key in source) {
|
|
2306
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2307
|
+
target[key] = source[key];
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
return target;
|
|
2312
|
+
};
|
|
2313
|
+
return _extends27.apply(this, arguments);
|
|
2314
|
+
}
|
|
2315
|
+
var DevicesDialog = ({ slots, ...devicesDialogProps }) => {
|
|
2316
|
+
const titleId = useId6("spaceDialog__title");
|
|
2317
|
+
return /* @__PURE__ */ React31.createElement(PanelDialog, _extends27({}, {
|
|
2318
|
+
slots: {
|
|
2319
|
+
...slots,
|
|
2320
|
+
root: {
|
|
2321
|
+
onOpenChange: (open) => {
|
|
2322
|
+
var _a;
|
|
2323
|
+
return open || ((_a = devicesDialogProps.onDone) == null ? void 0 : _a.call(devicesDialogProps));
|
|
2324
|
+
},
|
|
2325
|
+
...slots == null ? void 0 : slots.root
|
|
2326
|
+
}
|
|
2327
|
+
},
|
|
2328
|
+
titleId
|
|
2329
|
+
}), /* @__PURE__ */ React31.createElement(ThemeContext3.Provider, {
|
|
2330
|
+
value: {
|
|
2331
|
+
themeVariant: "os"
|
|
2332
|
+
}
|
|
2333
|
+
}, /* @__PURE__ */ React31.createElement(DevicesPanel, _extends27({}, {
|
|
2334
|
+
...devicesDialogProps,
|
|
2335
|
+
titleId,
|
|
2336
|
+
doneActionParent: /* @__PURE__ */ React31.createElement(Close, {
|
|
2337
|
+
asChild: true
|
|
2338
|
+
})
|
|
2339
|
+
}))));
|
|
2340
|
+
};
|
|
2341
|
+
|
|
2342
|
+
// packages/apps/patterns/react-ui/src/composites/SpaceDialog/SpaceDialog.tsx
|
|
2343
|
+
import { Close as Close2 } from "@radix-ui/react-dialog";
|
|
2344
|
+
import React32 from "react";
|
|
2345
|
+
import { ThemeContext as ThemeContext4, useId as useId7 } from "@dxos/react-components";
|
|
2346
|
+
function _extends28() {
|
|
2347
|
+
_extends28 = Object.assign || function(target) {
|
|
2348
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2349
|
+
var source = arguments[i];
|
|
2350
|
+
for (var key in source) {
|
|
2351
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2352
|
+
target[key] = source[key];
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
return target;
|
|
2357
|
+
};
|
|
2358
|
+
return _extends28.apply(this, arguments);
|
|
2359
|
+
}
|
|
2360
|
+
var SpaceDialog = ({ slots, ...spacePanelProps }) => {
|
|
2361
|
+
const titleId = useId7("spaceDialog__title");
|
|
2362
|
+
return /* @__PURE__ */ React32.createElement(PanelDialog, _extends28({}, {
|
|
2363
|
+
slots: {
|
|
2364
|
+
...slots,
|
|
2365
|
+
root: {
|
|
2366
|
+
onOpenChange: (open) => {
|
|
2367
|
+
var _a;
|
|
2368
|
+
return open || ((_a = spacePanelProps.onDone) == null ? void 0 : _a.call(spacePanelProps, null));
|
|
2369
|
+
},
|
|
2370
|
+
...slots == null ? void 0 : slots.root
|
|
2371
|
+
}
|
|
2372
|
+
},
|
|
2373
|
+
titleId
|
|
2374
|
+
}), /* @__PURE__ */ React32.createElement(ThemeContext4.Provider, {
|
|
2375
|
+
value: {
|
|
2376
|
+
themeVariant: "os"
|
|
2377
|
+
}
|
|
2378
|
+
}, /* @__PURE__ */ React32.createElement(SpacePanel, _extends28({}, {
|
|
2379
|
+
...spacePanelProps,
|
|
2380
|
+
titleId,
|
|
2381
|
+
doneActionParent: /* @__PURE__ */ React32.createElement(Close2, {
|
|
2382
|
+
asChild: true
|
|
2383
|
+
})
|
|
2384
|
+
}))));
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2387
|
+
// packages/apps/patterns/react-ui/src/composites/Shell/Shell.tsx
|
|
2388
|
+
var Shell = ({ runtime, origin }) => {
|
|
2389
|
+
const client = useClient8();
|
|
2390
|
+
const spaces = useSpaces2();
|
|
2391
|
+
const [{ layout, invitationCode, spaceKey }, setLayout] = useState6({
|
|
2392
|
+
layout: runtime.layout,
|
|
2393
|
+
invitationCode: runtime.invitationCode,
|
|
2394
|
+
spaceKey: runtime.spaceKey
|
|
2395
|
+
});
|
|
2396
|
+
const space = useSpace3(spaceKey);
|
|
2397
|
+
useEffect2(() => {
|
|
2398
|
+
return runtime.layoutUpdate.on((request) => setLayout(request));
|
|
2399
|
+
}, []);
|
|
2400
|
+
switch (layout) {
|
|
2401
|
+
case ShellLayout.AUTH:
|
|
2402
|
+
return /* @__PURE__ */ React33.createElement(JoinDialog, {
|
|
2403
|
+
mode: "halo-only",
|
|
2404
|
+
initialInvitationCode: invitationCode,
|
|
2405
|
+
onDone: async () => {
|
|
2406
|
+
var _a;
|
|
2407
|
+
const space2 = (_a = spaces[0]) != null ? _a : await client.echo.createSpace();
|
|
2408
|
+
await runtime.setAppContext({
|
|
2409
|
+
display: ShellDisplay.NONE,
|
|
2410
|
+
spaceKey: space2.key
|
|
2411
|
+
});
|
|
2412
|
+
runtime.setLayout(ShellLayout.DEFAULT);
|
|
2413
|
+
}
|
|
2414
|
+
});
|
|
2415
|
+
case ShellLayout.CURRENT_SPACE:
|
|
2416
|
+
case ShellLayout.SPACE_LIST:
|
|
2417
|
+
return /* @__PURE__ */ React33.createElement(SpaceDialog, {
|
|
2418
|
+
space,
|
|
2419
|
+
initialState: layout === ShellLayout.SPACE_LIST ? "space list" : "current space",
|
|
2420
|
+
createInvitationUrl: (invitationCode2) => `${origin}?spaceInvitationCode=${invitationCode2}`,
|
|
2421
|
+
onClickJoinSpace: () => runtime.setLayout(ShellLayout.JOIN_SPACE, {
|
|
2422
|
+
spaceKey: space == null ? void 0 : space.key
|
|
2423
|
+
}),
|
|
2424
|
+
onClickMember: () => runtime.setLayout(ShellLayout.DEVICES_LIST, {
|
|
2425
|
+
spaceKey: space == null ? void 0 : space.key
|
|
2426
|
+
}),
|
|
2427
|
+
onDone: async (space2) => {
|
|
2428
|
+
await runtime.setAppContext({
|
|
2429
|
+
display: ShellDisplay.NONE,
|
|
2430
|
+
spaceKey: space2 ? space2.key : spaceKey
|
|
2431
|
+
});
|
|
2432
|
+
runtime.setLayout(ShellLayout.DEFAULT);
|
|
2433
|
+
}
|
|
2434
|
+
});
|
|
2435
|
+
case ShellLayout.JOIN_SPACE:
|
|
2436
|
+
return /* @__PURE__ */ React33.createElement(JoinDialog, {
|
|
2437
|
+
initialInvitationCode: invitationCode,
|
|
2438
|
+
onDone: async (result) => {
|
|
2439
|
+
var _a;
|
|
2440
|
+
await runtime.setAppContext({
|
|
2441
|
+
display: ShellDisplay.NONE,
|
|
2442
|
+
spaceKey: (_a = result == null ? void 0 : result.spaceKey) != null ? _a : void 0
|
|
2443
|
+
});
|
|
2444
|
+
runtime.setLayout(ShellLayout.DEFAULT);
|
|
2445
|
+
},
|
|
2446
|
+
onExit: async () => {
|
|
2447
|
+
await runtime.setAppContext({
|
|
2448
|
+
display: ShellDisplay.NONE,
|
|
2449
|
+
spaceKey: runtime.spaceKey
|
|
2450
|
+
});
|
|
2451
|
+
runtime.setLayout(ShellLayout.DEFAULT);
|
|
2452
|
+
}
|
|
2453
|
+
});
|
|
2454
|
+
case ShellLayout.DEVICES_LIST:
|
|
2455
|
+
return /* @__PURE__ */ React33.createElement(DevicesDialog, {
|
|
2456
|
+
createInvitationUrl: (invitationCode2) => `${origin}?haloInvitationCode=${invitationCode2}`,
|
|
2457
|
+
onDone: async () => {
|
|
2458
|
+
await runtime.setAppContext({
|
|
2459
|
+
display: ShellDisplay.NONE,
|
|
2460
|
+
spaceKey: runtime.spaceKey
|
|
2461
|
+
});
|
|
2462
|
+
runtime.setLayout(ShellLayout.DEFAULT);
|
|
2463
|
+
}
|
|
2464
|
+
});
|
|
2465
|
+
default:
|
|
2466
|
+
return null;
|
|
2467
|
+
}
|
|
203
2468
|
};
|
|
204
2469
|
|
|
205
2470
|
// packages/apps/patterns/react-ui/src/translations/locales/en-US.ts
|
|
@@ -210,7 +2475,59 @@ __export(en_US_exports, {
|
|
|
210
2475
|
var os = {
|
|
211
2476
|
"manage profile label": "Manage identity",
|
|
212
2477
|
"identity offline description": "Offline",
|
|
213
|
-
"sidebar label": "DXOS sidebar"
|
|
2478
|
+
"sidebar label": "DXOS sidebar",
|
|
2479
|
+
"copy invitation code label": "Copy",
|
|
2480
|
+
"open share panel label": "Share",
|
|
2481
|
+
"joining heading": "<small>Joining</small><large>{{name}}</large>",
|
|
2482
|
+
"join space heading": "Join a space",
|
|
2483
|
+
"halo heading": "Initialize device identity",
|
|
2484
|
+
"exit label": "Exit",
|
|
2485
|
+
"identity selector title": "Join as",
|
|
2486
|
+
"identity radio group title": "Select an identity you\u2019ve associated with this device already",
|
|
2487
|
+
"add identity label": "Add",
|
|
2488
|
+
"continue label": "Continue",
|
|
2489
|
+
"back label": "Back",
|
|
2490
|
+
"next label": "Next",
|
|
2491
|
+
"close label": "Close",
|
|
2492
|
+
"auth choices label": "Choose an identity",
|
|
2493
|
+
"create identity label": "Create an identity",
|
|
2494
|
+
"create identity description": "Create a new identity.",
|
|
2495
|
+
"recover identity label": "Use a seed phrase",
|
|
2496
|
+
"recover identity description": "Enter your seed phrase to log in manually.",
|
|
2497
|
+
"join identity label": "Use an authed device",
|
|
2498
|
+
"join identity description": "Add this device to an identity you\u2019re already logged into on another device.",
|
|
2499
|
+
"deselect identity label": "Back to identities",
|
|
2500
|
+
"addition method selector title": "Add an identity to this device",
|
|
2501
|
+
"new identity input label": "Add a display name",
|
|
2502
|
+
"recover identity input label": "Type or paste your seed phrase",
|
|
2503
|
+
"failed to create identity message": "Failed to create an identity.",
|
|
2504
|
+
"failed to recover identity message": "Failed to recover an identity from the provided seed phrase.",
|
|
2505
|
+
"failed to authenticate message": "Incorrect PIN.",
|
|
2506
|
+
"identity added label": "Created identity & added to this device:",
|
|
2507
|
+
"join space as identity heading": "<part>as </part><part><icon/><label>{{labelValue}}</label></part>",
|
|
2508
|
+
"error status label": "Failed",
|
|
2509
|
+
"timeout status label": "Timed out",
|
|
2510
|
+
"cancelled status label": "Cancelled",
|
|
2511
|
+
"init status label": "Ready to connect",
|
|
2512
|
+
"connecting status label": "Connecting\u2026",
|
|
2513
|
+
"connected status label": "Enter confirmation PIN",
|
|
2514
|
+
"authenticating status label": "Enter confirmation PIN",
|
|
2515
|
+
"success status label": "Success",
|
|
2516
|
+
"connect label": "Connect",
|
|
2517
|
+
"reconnect label": "Reconnect",
|
|
2518
|
+
"cancel label": "Cancel",
|
|
2519
|
+
"done label": "Done",
|
|
2520
|
+
"reset label": "Start over",
|
|
2521
|
+
"auth code input label": "Auth code provided by the invitation sender",
|
|
2522
|
+
"invitation input label": "Paste an invitation code or URL",
|
|
2523
|
+
"create space invitation label": "Invite",
|
|
2524
|
+
"qr label": "Scan to accept invitation",
|
|
2525
|
+
"empty invitations message": "No pending invitations",
|
|
2526
|
+
"show all spaces label": "All spaces",
|
|
2527
|
+
"all spaces label": "All spaces",
|
|
2528
|
+
"create space label": "Create a new space",
|
|
2529
|
+
"join space label": "Join a space",
|
|
2530
|
+
"show current space label": "Current space"
|
|
214
2531
|
};
|
|
215
2532
|
|
|
216
2533
|
// packages/apps/patterns/react-ui/src/translations/index.ts
|
|
@@ -218,14 +2535,53 @@ var osTranslations = {
|
|
|
218
2535
|
"en-US": en_US_exports
|
|
219
2536
|
};
|
|
220
2537
|
export {
|
|
2538
|
+
DeviceList,
|
|
2539
|
+
DevicesPanel,
|
|
2540
|
+
IdentityListItem,
|
|
221
2541
|
IdentityPanel,
|
|
222
2542
|
IdentityPopover,
|
|
2543
|
+
InvitationList,
|
|
2544
|
+
InvitationListContainer,
|
|
2545
|
+
InvitationListItem,
|
|
2546
|
+
InvitationStatusAvatar,
|
|
2547
|
+
JoinDialog,
|
|
2548
|
+
JoinPanel,
|
|
2549
|
+
PanelAlertDialog,
|
|
2550
|
+
PanelDialog,
|
|
223
2551
|
PanelPopover,
|
|
2552
|
+
PanelSeparator,
|
|
224
2553
|
PanelSidebarContext,
|
|
225
2554
|
PanelSidebarProvider,
|
|
2555
|
+
Shell,
|
|
2556
|
+
SpaceDialog,
|
|
2557
|
+
SpaceListItem,
|
|
2558
|
+
SpaceMemberList,
|
|
2559
|
+
SpaceMemberListContainer,
|
|
2560
|
+
SpacePanel,
|
|
2561
|
+
activeBgColor,
|
|
2562
|
+
activeStrokeColor,
|
|
2563
|
+
activeTextColor,
|
|
2564
|
+
cancelledBgColor,
|
|
2565
|
+
cancelledStrokeColor,
|
|
2566
|
+
cancelledTextColor,
|
|
226
2567
|
defaultArrow,
|
|
227
|
-
|
|
2568
|
+
defaultDialogContent,
|
|
2569
|
+
defaultOverlay,
|
|
2570
|
+
defaultSurface,
|
|
2571
|
+
errorBgColor,
|
|
2572
|
+
errorStrokeColor,
|
|
2573
|
+
errorTextColor,
|
|
2574
|
+
inactiveBgColor,
|
|
2575
|
+
inactiveStrokeColor,
|
|
2576
|
+
inactiveTextColor,
|
|
228
2577
|
osTranslations,
|
|
2578
|
+
resolvedBgColor,
|
|
2579
|
+
resolvedStrokeColor,
|
|
2580
|
+
resolvedTextColor,
|
|
2581
|
+
subduedSurface,
|
|
2582
|
+
successBgColor,
|
|
2583
|
+
successStrokeColor,
|
|
2584
|
+
successTextColor,
|
|
229
2585
|
useTogglePanelSidebar
|
|
230
2586
|
};
|
|
231
2587
|
//# sourceMappingURL=index.mjs.map
|