@dxos/shell 0.7.3-staging.cc8dd3e → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/bundle/shell.mjs +71384 -71355
  2. package/dist/bundle/shell.mjs.map +1 -1
  3. package/dist/bundle/shell.umd.js +123 -123
  4. package/dist/bundle/shell.umd.js.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/react.mjs +641 -758
  7. package/dist/lib/browser/react.mjs.map +4 -4
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/react.cjs +732 -848
  10. package/dist/lib/node/react.cjs.map +4 -4
  11. package/dist/lib/node-esm/meta.json +1 -1
  12. package/dist/lib/node-esm/react.mjs +641 -758
  13. package/dist/lib/node-esm/react.mjs.map +4 -4
  14. package/dist/types/src/components/InvitationList/InvitationListItem.d.ts.map +1 -1
  15. package/dist/types/src/components/InvitationList/InvitationListItem.js +1 -2
  16. package/dist/types/src/components/InvitationList/InvitationListItem.js.map +1 -1
  17. package/dist/types/src/components/StorybookDialog.d.ts.map +1 -1
  18. package/dist/types/src/components/StorybookDialog.js +1 -2
  19. package/dist/types/src/components/StorybookDialog.js.map +1 -1
  20. package/dist/types/src/components/index.d.ts +0 -1
  21. package/dist/types/src/components/index.d.ts.map +1 -1
  22. package/dist/types/src/components/index.js +0 -1
  23. package/dist/types/src/components/index.js.map +1 -1
  24. package/dist/types/src/composites/IdentityDialog/IdentityDialog.d.ts.map +1 -1
  25. package/dist/types/src/composites/IdentityDialog/IdentityDialog.js +1 -2
  26. package/dist/types/src/composites/IdentityDialog/IdentityDialog.js.map +1 -1
  27. package/dist/types/src/composites/Shell/run-shell.d.ts.map +1 -1
  28. package/dist/types/src/composites/Shell/run-shell.js +1 -2
  29. package/dist/types/src/composites/Shell/run-shell.js.map +1 -1
  30. package/dist/types/src/composites/SpaceDialog/SpaceDialog.d.ts.map +1 -1
  31. package/dist/types/src/composites/SpaceDialog/SpaceDialog.js +1 -2
  32. package/dist/types/src/composites/SpaceDialog/SpaceDialog.js.map +1 -1
  33. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
  34. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +2 -18
  35. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  36. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +0 -1
  37. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
  38. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts.map +1 -1
  39. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js +1 -1
  40. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js.map +1 -1
  41. package/dist/types/src/panels/JoinPanel/JoinPanel.js +5 -5
  42. package/dist/types/src/panels/JoinPanel/JoinPanel.js.map +1 -1
  43. package/dist/types/src/panels/JoinPanel/steps/IdentityInput.d.ts +2 -1
  44. package/dist/types/src/panels/JoinPanel/steps/IdentityInput.d.ts.map +1 -1
  45. package/dist/types/src/panels/JoinPanel/steps/IdentityInput.js +14 -9
  46. package/dist/types/src/panels/JoinPanel/steps/IdentityInput.js.map +1 -1
  47. package/dist/types/src/panels/JoinPanel/steps/InvitationInput.d.ts.map +1 -1
  48. package/dist/types/src/panels/JoinPanel/steps/InvitationInput.js +1 -3
  49. package/dist/types/src/panels/JoinPanel/steps/InvitationInput.js.map +1 -1
  50. package/dist/types/src/steps/InvitationManager.d.ts.map +1 -1
  51. package/dist/types/src/steps/InvitationManager.js +1 -1
  52. package/dist/types/src/steps/InvitationManager.js.map +1 -1
  53. package/dist/types/src/stories/Invitations.e2e-stories.js +2 -2
  54. package/dist/types/src/stories/Invitations.e2e-stories.js.map +1 -1
  55. package/dist/types/src/translations/locales/en-US.d.ts +4 -0
  56. package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
  57. package/dist/types/src/translations/locales/en-US.js +8 -4
  58. package/dist/types/src/translations/locales/en-US.js.map +1 -1
  59. package/package.json +25 -25
  60. package/src/components/InvitationList/InvitationListItem.tsx +2 -2
  61. package/src/components/StorybookDialog.tsx +3 -5
  62. package/src/components/index.ts +0 -1
  63. package/src/composites/IdentityDialog/IdentityDialog.tsx +3 -4
  64. package/src/composites/Shell/run-shell.tsx +3 -4
  65. package/src/composites/SpaceDialog/SpaceDialog.tsx +3 -4
  66. package/src/panels/IdentityPanel/IdentityPanel.tsx +4 -37
  67. package/src/panels/IdentityPanel/IdentityPanelProps.ts +0 -1
  68. package/src/panels/IdentityPanel/steps/ProfileForm.tsx +3 -11
  69. package/src/panels/JoinPanel/JoinPanel.tsx +2 -2
  70. package/src/panels/JoinPanel/steps/IdentityInput.tsx +23 -13
  71. package/src/panels/JoinPanel/steps/InvitationInput.tsx +1 -2
  72. package/src/steps/InvitationManager.tsx +3 -13
  73. package/src/stories/Invitations.e2e-stories.tsx +5 -5
  74. package/src/translations/locales/en-US.ts +8 -4
  75. package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts +0 -9
  76. package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +0 -1
  77. package/dist/types/src/components/Clipboard/ClipboardProvider.js +0 -46
  78. package/dist/types/src/components/Clipboard/ClipboardProvider.js.map +0 -1
  79. package/dist/types/src/components/Clipboard/CopyButton.d.ts +0 -10
  80. package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +0 -1
  81. package/dist/types/src/components/Clipboard/CopyButton.js +0 -65
  82. package/dist/types/src/components/Clipboard/CopyButton.js.map +0 -1
  83. package/dist/types/src/components/Clipboard/index.d.ts +0 -3
  84. package/dist/types/src/components/Clipboard/index.d.ts.map +0 -1
  85. package/dist/types/src/components/Clipboard/index.js +0 -22
  86. package/dist/types/src/components/Clipboard/index.js.map +0 -1
  87. package/src/components/Clipboard/ClipboardProvider.tsx +0 -26
  88. package/src/components/Clipboard/CopyButton.tsx +0 -70
  89. package/src/components/Clipboard/index.ts +0 -6
@@ -2,11 +2,12 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { useState } from 'react';
5
+ import React, { useCallback, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
8
  import { useClient } from '@dxos/react-client';
9
9
  import { useTranslation } from '@dxos/react-ui';
10
+ import { type MaybePromise } from '@dxos/util';
10
11
 
11
12
  import { Action, Actions, StepHeading, Input } from '../../../components';
12
13
  import { type JoinStepProps } from '../JoinPanelProps';
@@ -18,7 +19,7 @@ export interface IdentityCreatorProps extends JoinStepProps {
18
19
  export type IdentityInputProps = IdentityCreatorProps;
19
20
 
20
21
  export type IdentityInputImplProps = IdentityCreatorProps & {
21
- onDisplayNameConfirm?: (displayName: string) => void;
22
+ onConfirm?: (value: string) => MaybePromise<void>;
22
23
  validationMessage?: string;
23
24
  };
24
25
 
@@ -28,9 +29,9 @@ export const IdentityInput = (props: IdentityInputProps) => {
28
29
  const client = useClient();
29
30
  const { t } = useTranslation('os');
30
31
  const [validationMessage, setValidationMessage] = useState('');
31
- const createIdentity = (value: string) => {
32
+ const handleConfirm = async (value: string) => {
32
33
  if (isRecover) {
33
- void client.halo.recoverIdentity({ seedphrase: value }).then(
34
+ await client.halo.recoverIdentity({ seedphrase: value }).then(
34
35
  (identity) => {
35
36
  send?.({ type: 'selectIdentity' as const, identity });
36
37
  },
@@ -40,7 +41,7 @@ export const IdentityInput = (props: IdentityInputProps) => {
40
41
  },
41
42
  );
42
43
  } else {
43
- void client.halo.createIdentity({ displayName: value }).then(
44
+ await client.halo.createIdentity({ displayName: value }).then(
44
45
  (identity) => {
45
46
  send?.({ type: 'selectIdentity' as const, identity });
46
47
  },
@@ -51,16 +52,24 @@ export const IdentityInput = (props: IdentityInputProps) => {
51
52
  );
52
53
  }
53
54
  };
54
- return <IdentityInputImpl {...props} onDisplayNameConfirm={createIdentity} validationMessage={validationMessage} />;
55
+ return <IdentityInputImpl {...props} onConfirm={handleConfirm} validationMessage={validationMessage} />;
55
56
  };
56
57
 
57
58
  // TODO(zhenyasav): impl shouldn't need send()
58
59
  export const IdentityInputImpl = (props: IdentityInputImplProps) => {
59
- const { method, send, active, onDisplayNameConfirm, validationMessage } = props;
60
- const disabled = !active;
60
+ const { method, active, onConfirm, validationMessage } = props;
61
61
  const { t } = useTranslation('os');
62
62
  const [inputValue, setInputValue] = useState('');
63
+ const [pending, setPending] = useState(false);
64
+ const disabled = !active || pending;
63
65
  const isRecover = method === 'recover identity';
66
+
67
+ const handleConfirm = useCallback(async () => {
68
+ setPending(true);
69
+ await onConfirm?.(inputValue);
70
+ setPending(false);
71
+ }, [onConfirm, inputValue]);
72
+
64
73
  return (
65
74
  <>
66
75
  <div role='none' className='grow flex flex-col justify-center'>
@@ -71,11 +80,12 @@ export const IdentityInputImpl = (props: IdentityInputImplProps) => {
71
80
  }
72
81
  disabled={disabled}
73
82
  data-testid='identity-input'
74
- placeholder={isRecover ? 'Type your recovery phrase' : 'Type a display name'}
83
+ placeholder={isRecover ? t('recovery code placeholder') : t('display name placeholder')}
75
84
  onChange={({ target: { value } }) => setInputValue(value)}
76
85
  />
77
86
  </div>
78
87
  <Actions>
88
+ {/* TODO(wittjosiah): This disables returning to deprecated identity creation flow.
79
89
  <Action
80
90
  variant='ghost'
81
91
  disabled={disabled}
@@ -83,14 +93,14 @@ export const IdentityInputImpl = (props: IdentityInputImplProps) => {
83
93
  data-testid={`${method === 'recover identity' ? 'recover' : 'create'}-identity-input-back`}
84
94
  >
85
95
  {t('back label')}
86
- </Action>
96
+ </Action> */}
87
97
  <Action
88
98
  variant='primary'
89
- disabled={disabled}
90
- onClick={() => onDisplayNameConfirm?.(inputValue)}
99
+ disabled={disabled || inputValue.trim().length === 0}
100
+ onClick={handleConfirm}
91
101
  data-testid={`${method === 'recover identity' ? 'recover' : 'create'}-identity-input-continue`}
92
102
  >
93
- {t('continue label')}
103
+ {pending ? t('pending label') : t('continue label')}
94
104
  </Action>
95
105
  </Actions>
96
106
  </>
@@ -67,8 +67,7 @@ export const InvitationInput = (props: InvitationInputProps) => {
67
67
  <div role='none' className='grow flex flex-col justify-center'>
68
68
  <Input
69
69
  label={<StepHeading>{t('invitation input label')}</StepHeading>}
70
- // TODO(burdon): Translation.
71
- placeholder='Type an invitation code'
70
+ placeholder={t('invitation input placeholder')}
72
71
  disabled={disabled}
73
72
  value={inputValue}
74
73
  onChange={({ target: { value } }) => setInputValue(value)}
@@ -7,22 +7,12 @@ import React, { useMemo } from 'react';
7
7
  import { QR } from 'react-qr-rounded';
8
8
 
9
9
  import { type InvitationStatus } from '@dxos/react-client/invitations';
10
- import { useId, useTranslation } from '@dxos/react-ui';
10
+ import { Clipboard, useId, useTranslation } from '@dxos/react-ui';
11
11
  import { descriptionText, getSize, mx } from '@dxos/react-ui-theme';
12
12
  import { hexToEmoji } from '@dxos/util';
13
13
 
14
14
  import { type StepProps } from './StepProps';
15
- import {
16
- Actions,
17
- Action,
18
- AuthCode,
19
- Emoji,
20
- Label,
21
- Viewport,
22
- type ViewportViewProps,
23
- CopyButton,
24
- Centered,
25
- } from '../components';
15
+ import { Actions, Action, AuthCode, Emoji, Label, Viewport, type ViewportViewProps, Centered } from '../components';
26
16
  import { invitationStatusValue } from '../util';
27
17
 
28
18
  export type InvitationManagerProps = StepProps &
@@ -93,7 +83,7 @@ export const InvitationManager = ({
93
83
  <span id={qrLabel} className='sr-only'>
94
84
  {t('qr label')}
95
85
  </span>
96
- <CopyButton variant='ghost' value={invitationUrl ?? 'never'} />
86
+ <Clipboard.Button variant='ghost' value={invitationUrl ?? 'never'} />
97
87
  </InvitationManagerView>
98
88
  <InvitationManagerView id='showing auth code'>
99
89
  <Label>{t('auth code message')}</Label>
@@ -15,11 +15,11 @@ import { useIdentity } from '@dxos/react-client/halo';
15
15
  import { Invitation, InvitationEncoder } from '@dxos/react-client/invitations';
16
16
  import { ConnectionState, useNetworkStatus } from '@dxos/react-client/mesh';
17
17
  import { useMultiClient, withMultiClientProvider } from '@dxos/react-client/testing';
18
- import { Button, ButtonGroup, List } from '@dxos/react-ui';
18
+ import { Button, ButtonGroup, Clipboard, List } from '@dxos/react-ui';
19
19
  import { getSize, groupSurface } from '@dxos/react-ui-theme';
20
20
  import { withLayout, withTheme } from '@dxos/storybook-utils';
21
21
 
22
- import { ClipboardProvider, IdentityListItem, SpaceListItem } from '../components';
22
+ import { IdentityListItem, SpaceListItem } from '../components';
23
23
  import { IdentityPanel, JoinPanel, SpacePanel } from '../panels';
24
24
  import { osTranslations } from '../translations';
25
25
 
@@ -222,10 +222,10 @@ const Invitations = () => {
222
222
  export const Default = {
223
223
  render: () => {
224
224
  return (
225
- // TODO(wittjosiah): Factor out ClipboardProvider to react-ui and include in layout decorator.
226
- <ClipboardProvider>
225
+ // TODO(wittjosiah): Include Clipboard.Provider in layout decorator.
226
+ <Clipboard.Provider>
227
227
  <Invitations />
228
- </ClipboardProvider>
228
+ </Clipboard.Provider>
229
229
  );
230
230
  },
231
231
  decorators: [
@@ -18,22 +18,26 @@ export const os = {
18
18
  'identity radio group title': 'Select an identity you’ve associated with this device already',
19
19
  'add identity label': 'Add',
20
20
  'continue label': 'Continue',
21
+ 'pending label': 'Pending',
21
22
  'back label': 'Back',
22
23
  'next label': 'Next',
23
24
  'close label': 'Close',
24
25
  'auth choices label': 'Choose an identity',
25
26
  'create identity label': 'Create an identity',
26
27
  'create identity description': 'Create a new identity.',
27
- 'recover identity label': 'Use a seed phrase',
28
- 'recover identity description': 'Enter your seed phrase to log in manually.',
28
+ 'recover identity label': 'Use a recovery code',
29
+ 'recover identity description': 'Enter your recovery code to log in manually.',
30
+ 'invitation input placeholder': 'Invitation code',
31
+ 'recovery code placeholder': 'Recovery code',
32
+ 'display name placeholder': 'Display name',
29
33
  'join identity label': 'Use another device',
30
34
  'join identity description': 'Add this device to an identity you’re already logged into on another device.',
31
35
  'deselect identity label': 'Back to identities',
32
36
  'addition method chooser title': 'An identity is required to continue',
33
37
  'new identity input label': 'Set display name',
34
- 'recover identity input label': 'Type or paste your seed phrase',
38
+ 'recover identity input label': 'Type or paste your recovery code',
35
39
  'failed to create identity message': 'Failed to create an identity.',
36
- 'failed to recover identity message': 'Failed to recover an identity from the provided seed phrase.',
40
+ 'failed to recover identity message': 'Failed to recover an identity from the provided recovery code.',
37
41
  'failed to authenticate message': 'Incorrect code.',
38
42
  'identity added label': 'Created identity & added to this device:',
39
43
  'join space as identity heading': '<part>as </part><part><icon/><label>{{labelValue}}</label></part>',
@@ -1,9 +0,0 @@
1
- import React, { type PropsWithChildren } from 'react';
2
- export type ClipboardContextValue = {
3
- textValue: string;
4
- setTextValue: (nextValue: string) => Promise<void>;
5
- };
6
- export declare const ClipboardContext: React.Context<ClipboardContextValue>;
7
- export declare const useClipboardContext: () => ClipboardContextValue;
8
- export declare const ClipboardProvider: ({ children }: PropsWithChildren<{}>) => React.JSX.Element;
9
- //# sourceMappingURL=ClipboardProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClipboardProvider.d.ts","sourceRoot":"","sources":["../../../../../src/components/Clipboard/ClipboardProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAiB,KAAK,iBAAiB,EAAqC,MAAM,OAAO,CAAC;AAExG,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,gBAAgB,sCAG3B,CAAC;AAEH,eAAO,MAAM,mBAAmB,6BAAqC,CAAC;AAEtE,eAAO,MAAM,iBAAiB,iBAAkB,iBAAiB,CAAC,EAAE,CAAC,sBAOpE,CAAC"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2023 DXOS.org
4
- //
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ClipboardProvider = exports.useClipboardContext = exports.ClipboardContext = void 0;
30
- const react_1 = __importStar(require("react"));
31
- exports.ClipboardContext = (0, react_1.createContext)({
32
- textValue: '',
33
- setTextValue: async (_) => { },
34
- });
35
- const useClipboardContext = () => (0, react_1.useContext)(exports.ClipboardContext);
36
- exports.useClipboardContext = useClipboardContext;
37
- const ClipboardProvider = ({ children }) => {
38
- const [textValue, setInternalTextValue] = (0, react_1.useState)('');
39
- const setTextValue = (0, react_1.useCallback)(async (nextValue) => {
40
- await navigator.clipboard.writeText(nextValue);
41
- return setInternalTextValue(nextValue);
42
- }, []);
43
- return react_1.default.createElement(exports.ClipboardContext.Provider, { value: { textValue, setTextValue } }, children);
44
- };
45
- exports.ClipboardProvider = ClipboardProvider;
46
- //# sourceMappingURL=ClipboardProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClipboardProvider.js","sourceRoot":"","sources":["../../../../../src/components/Clipboard/ClipboardProvider.tsx"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,+CAAwG;AAO3F,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAAwB;IACnE,SAAS,EAAE,EAAE;IACb,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAE,CAAC;CAC9B,CAAC,CAAC;AAEI,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAA,kBAAU,EAAC,wBAAgB,CAAC,CAAC;AAAzD,QAAA,mBAAmB,uBAAsC;AAE/D,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAAyB,EAAE,EAAE;IACvE,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IACvD,MAAM,YAAY,GAAG,IAAA,mBAAW,EAAC,KAAK,EAAE,SAAiB,EAAE,EAAE;QAC3D,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC/C,OAAO,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,8BAAC,wBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,IAAG,QAAQ,CAA6B,CAAC;AAC/G,CAAC,CAAC;AAPW,QAAA,iBAAiB,qBAO5B"}
@@ -1,10 +0,0 @@
1
- import { type IconProps } from '@phosphor-icons/react';
2
- import React from 'react';
3
- import { type ButtonProps } from '@dxos/react-ui';
4
- export type CopyButtonProps = ButtonProps & {
5
- value: string;
6
- iconProps?: IconProps;
7
- };
8
- export declare const CopyButton: ({ value, classNames, iconProps, ...props }: CopyButtonProps) => React.JSX.Element;
9
- export declare const CopyButtonIconOnly: ({ value, classNames, iconProps, variant, ...props }: CopyButtonProps) => React.JSX.Element;
10
- //# sourceMappingURL=CopyButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopyButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Clipboard/CopyButton.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAU,KAAK,WAAW,EAA2B,MAAM,gBAAgB,CAAC;AAKnF,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAIF,eAAO,MAAM,UAAU,+CAAgD,eAAe,sBAqBrF,CAAC;AAEF,eAAO,MAAM,kBAAkB,wDAAyD,eAAe,sBA2BtG,CAAC"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2023 DXOS.org
4
- //
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.CopyButtonIconOnly = exports.CopyButton = void 0;
30
- const react_1 = require("@phosphor-icons/react");
31
- const react_2 = __importStar(require("react"));
32
- const react_ui_1 = require("@dxos/react-ui");
33
- const react_ui_theme_1 = require("@dxos/react-ui-theme");
34
- const ClipboardProvider_1 = require("./ClipboardProvider");
35
- const inactiveLabelStyles = 'invisible bs-px -mbe-px overflow-hidden';
36
- const CopyButton = ({ value, classNames, iconProps, ...props }) => {
37
- const { t } = (0, react_ui_1.useTranslation)('os');
38
- const { textValue, setTextValue } = (0, ClipboardProvider_1.useClipboardContext)();
39
- const isCopied = textValue === value;
40
- return (react_2.default.createElement(react_ui_1.Button, { ...props, classNames: ['inline-flex flex-col justify-center', classNames], onClick: () => setTextValue(value), "data-testid": 'copy-invitation' },
41
- react_2.default.createElement("div", { role: 'none', className: (0, react_ui_theme_1.mx)('flex gap-1 items-center', isCopied && inactiveLabelStyles) },
42
- react_2.default.createElement("span", { className: 'pli-1' }, t('copy invitation code label')),
43
- react_2.default.createElement(react_1.Copy, { className: (0, react_ui_theme_1.getSize)(5), ...iconProps })),
44
- react_2.default.createElement("div", { role: 'none', className: (0, react_ui_theme_1.mx)('flex gap-1 items-center', !isCopied && inactiveLabelStyles) },
45
- react_2.default.createElement("span", { className: 'pli-1' }, t('copy success label')),
46
- react_2.default.createElement(react_1.Check, { className: (0, react_ui_theme_1.getSize)(5), ...iconProps }))));
47
- };
48
- exports.CopyButton = CopyButton;
49
- const CopyButtonIconOnly = ({ value, classNames, iconProps, variant, ...props }) => {
50
- const { t } = (0, react_ui_1.useTranslation)('os');
51
- const { textValue, setTextValue } = (0, ClipboardProvider_1.useClipboardContext)();
52
- const isCopied = textValue === value;
53
- const label = isCopied ? t('copy success label') : t('copy invitation code label');
54
- const [open, setOpen] = (0, react_2.useState)(false);
55
- return (react_2.default.createElement(react_ui_1.Tooltip.Root, { delayDuration: 1500, open: open, onOpenChange: setOpen },
56
- react_2.default.createElement(react_ui_1.Tooltip.Portal, null,
57
- react_2.default.createElement(react_ui_1.Tooltip.Content, { side: 'bottom', sideOffset: 12, classNames: 'z-30' },
58
- react_2.default.createElement("span", null, label),
59
- react_2.default.createElement(react_ui_1.Tooltip.Arrow, null))),
60
- react_2.default.createElement(react_ui_1.Tooltip.Trigger, { "aria-label": label, ...props, onClick: () => setTextValue(value).then(() => setOpen(true)), "data-testid": 'copy-invitation', asChild: true },
61
- react_2.default.createElement(react_ui_1.Button, { variant: variant, classNames: ['inline-flex flex-col justify-center', classNames] },
62
- react_2.default.createElement(react_1.Copy, { className: (0, react_ui_theme_1.getSize)(5), ...iconProps })))));
63
- };
64
- exports.CopyButtonIconOnly = CopyButtonIconOnly;
65
- //# sourceMappingURL=CopyButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopyButton.js","sourceRoot":"","sources":["../../../../../src/components/Clipboard/CopyButton.tsx"],"names":[],"mappings":"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"}
@@ -1,3 +0,0 @@
1
- export * from './CopyButton';
2
- export * from './ClipboardProvider';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Clipboard/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2023 DXOS.org
4
- //
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- __exportStar(require("./CopyButton"), exports);
21
- __exportStar(require("./ClipboardProvider"), exports);
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Clipboard/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;AAEF,+CAA6B;AAC7B,sDAAoC"}
@@ -1,26 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { createContext, type PropsWithChildren, useCallback, useContext, useState } from 'react';
6
-
7
- export type ClipboardContextValue = {
8
- textValue: string;
9
- setTextValue: (nextValue: string) => Promise<void>;
10
- };
11
-
12
- export const ClipboardContext = createContext<ClipboardContextValue>({
13
- textValue: '',
14
- setTextValue: async (_) => {},
15
- });
16
-
17
- export const useClipboardContext = () => useContext(ClipboardContext);
18
-
19
- export const ClipboardProvider = ({ children }: PropsWithChildren<{}>) => {
20
- const [textValue, setInternalTextValue] = useState('');
21
- const setTextValue = useCallback(async (nextValue: string) => {
22
- await navigator.clipboard.writeText(nextValue);
23
- return setInternalTextValue(nextValue);
24
- }, []);
25
- return <ClipboardContext.Provider value={{ textValue, setTextValue }}>{children}</ClipboardContext.Provider>;
26
- };
@@ -1,70 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { Check, Copy, type IconProps } from '@phosphor-icons/react';
6
- import React, { useState } from 'react';
7
-
8
- import { Button, type ButtonProps, Tooltip, useTranslation } from '@dxos/react-ui';
9
- import { getSize, mx } from '@dxos/react-ui-theme';
10
-
11
- import { useClipboardContext } from './ClipboardProvider';
12
-
13
- export type CopyButtonProps = ButtonProps & {
14
- value: string;
15
- iconProps?: IconProps;
16
- };
17
-
18
- const inactiveLabelStyles = 'invisible bs-px -mbe-px overflow-hidden';
19
-
20
- export const CopyButton = ({ value, classNames, iconProps, ...props }: CopyButtonProps) => {
21
- const { t } = useTranslation('os');
22
- const { textValue, setTextValue } = useClipboardContext();
23
- const isCopied = textValue === value;
24
- return (
25
- <Button
26
- {...props}
27
- classNames={['inline-flex flex-col justify-center', classNames]}
28
- onClick={() => setTextValue(value)}
29
- data-testid='copy-invitation'
30
- >
31
- <div role='none' className={mx('flex gap-1 items-center', isCopied && inactiveLabelStyles)}>
32
- <span className='pli-1'>{t('copy invitation code label')}</span>
33
- <Copy className={getSize(5)} {...iconProps} />
34
- </div>
35
- <div role='none' className={mx('flex gap-1 items-center', !isCopied && inactiveLabelStyles)}>
36
- <span className='pli-1'>{t('copy success label')}</span>
37
- <Check className={getSize(5)} {...iconProps} />
38
- </div>
39
- </Button>
40
- );
41
- };
42
-
43
- export const CopyButtonIconOnly = ({ value, classNames, iconProps, variant, ...props }: CopyButtonProps) => {
44
- const { t } = useTranslation('os');
45
- const { textValue, setTextValue } = useClipboardContext();
46
- const isCopied = textValue === value;
47
- const label = isCopied ? t('copy success label') : t('copy invitation code label');
48
- const [open, setOpen] = useState(false);
49
- return (
50
- <Tooltip.Root delayDuration={1500} open={open} onOpenChange={setOpen}>
51
- <Tooltip.Portal>
52
- <Tooltip.Content side='bottom' sideOffset={12} classNames='z-30'>
53
- <span>{label}</span>
54
- <Tooltip.Arrow />
55
- </Tooltip.Content>
56
- </Tooltip.Portal>
57
- <Tooltip.Trigger
58
- aria-label={label}
59
- {...props}
60
- onClick={() => setTextValue(value).then(() => setOpen(true))}
61
- data-testid='copy-invitation'
62
- asChild
63
- >
64
- <Button variant={variant} classNames={['inline-flex flex-col justify-center', classNames]}>
65
- <Copy className={getSize(5)} {...iconProps} />
66
- </Button>
67
- </Tooltip.Trigger>
68
- </Tooltip.Root>
69
- );
70
- };
@@ -1,6 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './CopyButton';
6
- export * from './ClipboardProvider';