@dxos/plugin-status-bar 0.8.1-staging.391c573 → 0.8.1-staging.5be625a

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.
@@ -1,3 +1,4 @@
1
+ export * from './FeedbackForm';
1
2
  export * from './StatusBar';
2
3
  export * from './StatusBarPanel';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
@@ -1,8 +1,4 @@
1
+ import { type PluginMeta } from '@dxos/app-framework';
1
2
  export declare const STATUS_BAR_PLUGIN = "dxos.org/plugin/status-bar";
2
- export declare const meta: {
3
- id: string;
4
- name: string;
5
- description: string;
6
- icon: string;
7
- };
3
+ export declare const meta: PluginMeta;
8
4
  //# sourceMappingURL=meta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAE9D,eAAO,MAAM,IAAI;;;;;CAKK,CAAC"}
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAE9D,eAAO,MAAM,IAAI,EAAE,UAKlB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-status-bar",
3
- "version": "0.8.1-staging.391c573",
3
+ "version": "0.8.1-staging.5be625a",
4
4
  "description": "Status bar plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -30,13 +30,13 @@
30
30
  "date-fns": "^3.3.1",
31
31
  "effect": "3.13.3",
32
32
  "react-resize-detector": "^11.0.1",
33
- "@dxos/app-framework": "0.8.1-staging.391c573",
34
- "@dxos/async": "0.8.1-staging.391c573",
35
- "@dxos/echo-schema": "0.8.1-staging.391c573",
36
- "@dxos/plugin-observability": "0.8.1-staging.391c573",
37
- "@dxos/react-client": "0.8.1-staging.391c573",
38
- "@dxos/react-ui-form": "0.8.1-staging.391c573",
39
- "@dxos/schema": "0.8.1-staging.391c573"
33
+ "@dxos/app-framework": "0.8.1-staging.5be625a",
34
+ "@dxos/async": "0.8.1-staging.5be625a",
35
+ "@dxos/echo-schema": "0.8.1-staging.5be625a",
36
+ "@dxos/plugin-observability": "0.8.1-staging.5be625a",
37
+ "@dxos/react-ui-form": "0.8.1-staging.5be625a",
38
+ "@dxos/schema": "0.8.1-staging.5be625a",
39
+ "@dxos/react-client": "0.8.1-staging.5be625a"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@phosphor-icons/react": "^2.1.5",
@@ -45,16 +45,16 @@
45
45
  "react": "~18.2.0",
46
46
  "react-dom": "~18.2.0",
47
47
  "vite": "5.4.7",
48
- "@dxos/react-ui": "0.8.1-staging.391c573",
49
- "@dxos/react-ui-theme": "0.8.1-staging.391c573",
50
- "@dxos/storybook-utils": "0.8.1-staging.391c573"
48
+ "@dxos/react-ui": "0.8.1-staging.5be625a",
49
+ "@dxos/storybook-utils": "0.8.1-staging.5be625a",
50
+ "@dxos/react-ui-theme": "0.8.1-staging.5be625a"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@phosphor-icons/react": "^2.0.5",
54
54
  "react": "~18.2.0",
55
55
  "react-dom": "~18.2.0",
56
- "@dxos/react-ui": "0.8.1-staging.391c573",
57
- "@dxos/react-ui-theme": "0.8.1-staging.391c573"
56
+ "@dxos/react-ui-theme": "0.8.1-staging.5be625a",
57
+ "@dxos/react-ui": "0.8.1-staging.5be625a"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
@@ -3,81 +3,77 @@
3
3
  //
4
4
 
5
5
  import { PaperPlaneTilt, X } from '@phosphor-icons/react';
6
- import React, { useCallback } from 'react';
6
+ import React, { useRef } from 'react';
7
7
 
8
- import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
9
- import { ObservabilityAction, UserFeedback } from '@dxos/plugin-observability/types';
8
+ import { getSnapshot } from '@dxos/echo-schema';
9
+ import { UserFeedback } from '@dxos/plugin-observability/types';
10
10
  import { Button, Input, Popover, useTranslation } from '@dxos/react-ui';
11
- import { useForm } from '@dxos/react-ui-form';
11
+ import { FormProvider, useFormContext, useInputProps } from '@dxos/react-ui-form';
12
12
  import { getSize } from '@dxos/react-ui-theme';
13
13
 
14
14
  import { STATUS_BAR_PLUGIN } from '../meta';
15
15
  import { mkTranslation } from '../translations';
16
16
 
17
- const initialValues: UserFeedback = { name: '', email: '', message: '' };
17
+ const defaultValues: UserFeedback = { name: '', email: '', message: '' };
18
18
 
19
- export const FeedbackForm = ({ onClose }: { onClose: () => void }) => {
19
+ const FormContent = () => {
20
20
  const { t } = useTranslation(STATUS_BAR_PLUGIN);
21
21
  const translation = mkTranslation(t);
22
- const { dispatchPromise: dispatch } = useIntentDispatcher();
22
+ const { handleSave, canSave } = useFormContext<UserFeedback>();
23
23
 
24
- const onSave = useCallback(
25
- (values: UserFeedback) => {
26
- void dispatch(createIntent(ObservabilityAction.CaptureUserFeedback, values));
27
- onClose();
28
- },
29
- [dispatch, onClose],
30
- );
31
-
32
- const { handleSave, canSave, getStatus, ...inputProps } = useForm<UserFeedback>({
33
- initialValues,
34
- schema: UserFeedback,
35
- onSave,
36
- });
24
+ const nameProps = useInputProps(['name']);
25
+ const emailProps = useInputProps(['email']);
26
+ const messageProps = useInputProps(['message']);
37
27
 
38
28
  return (
39
29
  <div role='form' className='p-3 flex flex-col gap-2'>
40
30
  <div role='none' className='space-b-1'>
41
- <Input.Root validationValence={getStatus('name').status}>
31
+ <Input.Root validationValence={nameProps.getStatus().status}>
42
32
  <Input.Label>{translation('name label')}</Input.Label>
43
33
  <Input.TextInput
44
34
  classNames={'text-sm'}
45
35
  placeholder={translation('name placeholder')}
46
36
  autoFocus
47
- {...inputProps}
37
+ value={nameProps.getValue() ?? ''}
38
+ onChange={(e) => nameProps.onValueChange('string', e.target.value)}
39
+ onBlur={nameProps.onBlur}
48
40
  />
49
41
  <Input.DescriptionAndValidation>
50
- <Input.Validation>{getStatus('name').error}</Input.Validation>
42
+ <Input.Validation>{nameProps.getStatus().error}</Input.Validation>
51
43
  </Input.DescriptionAndValidation>
52
44
  </Input.Root>
53
45
  </div>
54
46
 
55
47
  <div role='none' className='space-b-1'>
56
- <Input.Root validationValence={getStatus('email').status}>
48
+ <Input.Root validationValence={emailProps.getStatus().status}>
57
49
  <Input.Label>{translation('email input label')}</Input.Label>
58
50
  <Input.TextInput
59
51
  classNames={'text-sm'}
60
52
  placeholder={translation('email input placeholder')}
61
- {...inputProps}
53
+ value={emailProps.getValue() ?? ''}
54
+ onChange={(e) => emailProps.onValueChange('string', e.target.value)}
55
+ onBlur={emailProps.onBlur}
62
56
  />
63
57
  <Input.DescriptionAndValidation>
64
- <Input.Validation>{getStatus('email').error}</Input.Validation>
58
+ <Input.Validation>{emailProps.getStatus().error}</Input.Validation>
65
59
  </Input.DescriptionAndValidation>
66
60
  </Input.Root>
67
61
  </div>
68
62
 
69
63
  <div role='none' className='space-b-1'>
70
- <Input.Root validationValence={getStatus('message').status}>
64
+ <Input.Root validationValence={messageProps.getStatus().status}>
71
65
  <Input.Label>{translation('feedback text area label')}</Input.Label>
72
66
  <Input.TextArea
73
67
  classNames={'text-sm'}
74
68
  rows={5}
75
69
  cols={30}
76
70
  placeholder={translation('feedback text area placeholder')}
77
- {...inputProps}
71
+ value={messageProps.getValue() ?? ''}
72
+ onChange={(e) => messageProps.onValueChange('string', e.target.value)}
73
+ onBlur={messageProps.onBlur}
78
74
  />
79
75
  <Input.DescriptionAndValidation>
80
- <Input.Validation>{getStatus('message').error}</Input.Validation>
76
+ <Input.Validation>{messageProps.getStatus().error}</Input.Validation>
81
77
  </Input.DescriptionAndValidation>
82
78
  </Input.Root>
83
79
  </div>
@@ -105,3 +101,17 @@ export const FeedbackForm = ({ onClose }: { onClose: () => void }) => {
105
101
  </div>
106
102
  );
107
103
  };
104
+
105
+ export const FeedbackForm = ({ onSave }: { onSave: (values: UserFeedback) => void }) => {
106
+ const formRef = useRef<HTMLDivElement>(null);
107
+
108
+ const initialValues = getSnapshot(defaultValues);
109
+
110
+ return (
111
+ <FormProvider formRef={formRef} schema={UserFeedback} initialValues={initialValues} onSave={onSave}>
112
+ <div ref={formRef}>
113
+ <FormContent />
114
+ </div>
115
+ </FormProvider>
116
+ );
117
+ };
@@ -2,9 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useState } from 'react';
5
+ import React, { useCallback, useState } from 'react';
6
6
 
7
- import { Surface } from '@dxos/app-framework';
7
+ import { createIntent, Surface, useIntentDispatcher } from '@dxos/app-framework';
8
+ import { ObservabilityAction, type UserFeedback } from '@dxos/plugin-observability/types';
8
9
  import { Icon, Popover, useTranslation } from '@dxos/react-ui';
9
10
 
10
11
  import { FeedbackForm } from './FeedbackForm';
@@ -15,6 +16,16 @@ import { STATUS_BAR_PLUGIN } from '../meta';
15
16
  export const StatusBarActions = () => {
16
17
  const { t } = useTranslation(STATUS_BAR_PLUGIN);
17
18
  const [open, setOpen] = useState(false);
19
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
20
+
21
+ const handleSave = useCallback(
22
+ (values: UserFeedback) => {
23
+ void dispatch(createIntent(ObservabilityAction.CaptureUserFeedback, values));
24
+ setOpen(false);
25
+ },
26
+ [dispatch],
27
+ );
28
+
18
29
  return (
19
30
  <Popover.Root open={open} onOpenChange={setOpen}>
20
31
  <Popover.Trigger asChild>
@@ -33,7 +44,7 @@ export const StatusBarActions = () => {
33
44
  <VersionNumber />
34
45
  <Popover.Portal>
35
46
  <Popover.Content classNames='shadow-lg'>
36
- <FeedbackForm onClose={() => setOpen(false)} />
47
+ <FeedbackForm onSave={handleSave} />
37
48
  <Popover.Arrow />
38
49
  </Popover.Content>
39
50
  </Popover.Portal>
@@ -2,5 +2,6 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ export * from './FeedbackForm';
5
6
  export * from './StatusBar';
6
7
  export * from './StatusBarPanel';
package/src/meta.ts CHANGED
@@ -6,9 +6,9 @@ import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
7
  export const STATUS_BAR_PLUGIN = 'dxos.org/plugin/status-bar';
8
8
 
9
- export const meta = {
9
+ export const meta: PluginMeta = {
10
10
  id: STATUS_BAR_PLUGIN,
11
11
  name: 'Status Bar',
12
12
  description: 'Display a bar with status and actions.',
13
13
  icon: 'ph--info--regular',
14
- } satisfies PluginMeta;
14
+ };