@cratis/showrunner.notes.react 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Buttons/NotesButton.tsx +117 -0
- package/Buttons/index.ts +6 -0
- package/Buttons/menuItems.ts +55 -0
- package/Buttons/notesDialogHeaderActions.tsx +33 -0
- package/Context/componentContext.ts +57 -0
- package/Context/formatLocation.ts +27 -0
- package/Context/index.ts +6 -0
- package/Context/noteContext.ts +139 -0
- package/Feedback/ComponentFeedbackDialog.tsx +150 -0
- package/Feedback/ComponentModeSwitch.tsx +39 -0
- package/Feedback/ContextSummary.tsx +31 -0
- package/Feedback/FeedbackDialog.tsx +64 -0
- package/Feedback/KindAndText.tsx +38 -0
- package/Feedback/SliceChooser.tsx +90 -0
- package/Feedback/SlicesFeedbackDialog.tsx +63 -0
- package/Feedback/index.ts +13 -0
- package/Feedback/kindOptions.ts +35 -0
- package/Feedback/propertySuggestions.ts +38 -0
- package/Feedback/sliceChoice.ts +73 -0
- package/Icons.tsx +29 -0
- package/Labels/NotesLabels.ts +185 -0
- package/Labels/defaultNotesLabels.ts +93 -0
- package/Labels/format.ts +13 -0
- package/Labels/index.ts +7 -0
- package/Labels/resolveLabels.ts +36 -0
- package/MyFeedback/MyFeedbackDialog.tsx +51 -0
- package/MyFeedback/MyFeedbackList.tsx +62 -0
- package/MyFeedback/index.ts +6 -0
- package/MyFeedback/noteStates.ts +75 -0
- package/Provider/NotesContext.ts +111 -0
- package/Provider/NotesProvider.tsx +122 -0
- package/Provider/index.ts +6 -0
- package/Provider/notesVisibility.ts +13 -0
- package/README.md +49 -2
- package/dist/cjs/Buttons/NotesButton.d.ts +8 -0
- package/dist/cjs/Buttons/NotesButton.d.ts.map +1 -0
- package/dist/cjs/Buttons/NotesButton.js +126 -0
- package/dist/cjs/Buttons/NotesButton.js.map +1 -0
- package/dist/cjs/Buttons/index.d.ts +4 -0
- package/dist/cjs/Buttons/index.d.ts.map +1 -0
- package/dist/cjs/Buttons/menuItems.d.ts +10 -0
- package/dist/cjs/Buttons/menuItems.d.ts.map +1 -0
- package/dist/cjs/Buttons/menuItems.js +57 -0
- package/dist/cjs/Buttons/menuItems.js.map +1 -0
- package/dist/cjs/Buttons/notesDialogHeaderActions.d.ts +4 -0
- package/dist/cjs/Buttons/notesDialogHeaderActions.d.ts.map +1 -0
- package/dist/cjs/Buttons/notesDialogHeaderActions.js +37 -0
- package/dist/cjs/Buttons/notesDialogHeaderActions.js.map +1 -0
- package/dist/cjs/Context/componentContext.d.ts +8 -0
- package/dist/cjs/Context/componentContext.d.ts.map +1 -0
- package/dist/cjs/Context/componentContext.js +56 -0
- package/dist/cjs/Context/componentContext.js.map +1 -0
- package/dist/cjs/Context/formatLocation.d.ts +7 -0
- package/dist/cjs/Context/formatLocation.d.ts.map +1 -0
- package/dist/cjs/Context/formatLocation.js +23 -0
- package/dist/cjs/Context/formatLocation.js.map +1 -0
- package/dist/cjs/Context/index.d.ts +4 -0
- package/dist/cjs/Context/index.d.ts.map +1 -0
- package/dist/cjs/Context/noteContext.d.ts +22 -0
- package/dist/cjs/Context/noteContext.d.ts.map +1 -0
- package/dist/cjs/Context/noteContext.js +117 -0
- package/dist/cjs/Context/noteContext.js.map +1 -0
- package/dist/cjs/Feedback/ComponentFeedbackDialog.d.ts +10 -0
- package/dist/cjs/Feedback/ComponentFeedbackDialog.d.ts.map +1 -0
- package/dist/cjs/Feedback/ComponentFeedbackDialog.js +183 -0
- package/dist/cjs/Feedback/ComponentFeedbackDialog.js.map +1 -0
- package/dist/cjs/Feedback/ComponentModeSwitch.d.ts +7 -0
- package/dist/cjs/Feedback/ComponentModeSwitch.d.ts.map +1 -0
- package/dist/cjs/Feedback/ComponentModeSwitch.js +29 -0
- package/dist/cjs/Feedback/ComponentModeSwitch.js.map +1 -0
- package/dist/cjs/Feedback/ContextSummary.d.ts +7 -0
- package/dist/cjs/Feedback/ContextSummary.d.ts.map +1 -0
- package/dist/cjs/Feedback/ContextSummary.js +31 -0
- package/dist/cjs/Feedback/ContextSummary.js.map +1 -0
- package/dist/cjs/Feedback/FeedbackDialog.d.ts +11 -0
- package/dist/cjs/Feedback/FeedbackDialog.d.ts.map +1 -0
- package/dist/cjs/Feedback/FeedbackDialog.js +55 -0
- package/dist/cjs/Feedback/FeedbackDialog.js.map +1 -0
- package/dist/cjs/Feedback/KindAndText.d.ts +7 -0
- package/dist/cjs/Feedback/KindAndText.d.ts.map +1 -0
- package/dist/cjs/Feedback/KindAndText.js +33 -0
- package/dist/cjs/Feedback/KindAndText.js.map +1 -0
- package/dist/cjs/Feedback/SliceChooser.d.ts +9 -0
- package/dist/cjs/Feedback/SliceChooser.d.ts.map +1 -0
- package/dist/cjs/Feedback/SliceChooser.js +113 -0
- package/dist/cjs/Feedback/SliceChooser.js.map +1 -0
- package/dist/cjs/Feedback/SlicesFeedbackDialog.d.ts +8 -0
- package/dist/cjs/Feedback/SlicesFeedbackDialog.d.ts.map +1 -0
- package/dist/cjs/Feedback/SlicesFeedbackDialog.js +74 -0
- package/dist/cjs/Feedback/SlicesFeedbackDialog.js.map +1 -0
- package/dist/cjs/Feedback/index.d.ts +11 -0
- package/dist/cjs/Feedback/index.d.ts.map +1 -0
- package/dist/cjs/Feedback/kindOptions.d.ts +9 -0
- package/dist/cjs/Feedback/kindOptions.d.ts.map +1 -0
- package/dist/cjs/Feedback/kindOptions.js +37 -0
- package/dist/cjs/Feedback/kindOptions.js.map +1 -0
- package/dist/cjs/Feedback/propertySuggestions.d.ts +6 -0
- package/dist/cjs/Feedback/propertySuggestions.d.ts.map +1 -0
- package/dist/cjs/Feedback/propertySuggestions.js +32 -0
- package/dist/cjs/Feedback/propertySuggestions.js.map +1 -0
- package/dist/cjs/Feedback/sliceChoice.d.ts +7 -0
- package/dist/cjs/Feedback/sliceChoice.d.ts.map +1 -0
- package/dist/cjs/Feedback/sliceChoice.js +71 -0
- package/dist/cjs/Feedback/sliceChoice.js.map +1 -0
- package/dist/cjs/Icons.d.ts +4 -0
- package/dist/cjs/Icons.d.ts.map +1 -0
- package/dist/cjs/Icons.js +53 -0
- package/dist/cjs/Icons.js.map +1 -0
- package/dist/cjs/Labels/NotesLabels.d.ts +90 -0
- package/dist/cjs/Labels/NotesLabels.d.ts.map +1 -0
- package/dist/cjs/Labels/defaultNotesLabels.d.ts +3 -0
- package/dist/cjs/Labels/defaultNotesLabels.d.ts.map +1 -0
- package/dist/cjs/Labels/defaultNotesLabels.js +94 -0
- package/dist/cjs/Labels/defaultNotesLabels.js.map +1 -0
- package/dist/cjs/Labels/format.d.ts +2 -0
- package/dist/cjs/Labels/format.d.ts.map +1 -0
- package/dist/cjs/Labels/format.js +15 -0
- package/dist/cjs/Labels/format.js.map +1 -0
- package/dist/cjs/Labels/index.d.ts +5 -0
- package/dist/cjs/Labels/index.d.ts.map +1 -0
- package/dist/cjs/Labels/resolveLabels.d.ts +3 -0
- package/dist/cjs/Labels/resolveLabels.d.ts.map +1 -0
- package/dist/cjs/Labels/resolveLabels.js +35 -0
- package/dist/cjs/Labels/resolveLabels.js.map +1 -0
- package/dist/cjs/MyFeedback/MyFeedbackDialog.d.ts +2 -0
- package/dist/cjs/MyFeedback/MyFeedbackDialog.d.ts.map +1 -0
- package/dist/cjs/MyFeedback/MyFeedbackDialog.js +55 -0
- package/dist/cjs/MyFeedback/MyFeedbackDialog.js.map +1 -0
- package/dist/cjs/MyFeedback/MyFeedbackList.d.ts +10 -0
- package/dist/cjs/MyFeedback/MyFeedbackList.d.ts.map +1 -0
- package/dist/cjs/MyFeedback/MyFeedbackList.js +62 -0
- package/dist/cjs/MyFeedback/MyFeedbackList.js.map +1 -0
- package/dist/cjs/MyFeedback/index.d.ts +4 -0
- package/dist/cjs/MyFeedback/index.d.ts.map +1 -0
- package/dist/cjs/MyFeedback/noteStates.d.ts +8 -0
- package/dist/cjs/MyFeedback/noteStates.d.ts.map +1 -0
- package/dist/cjs/MyFeedback/noteStates.js +90 -0
- package/dist/cjs/MyFeedback/noteStates.js.map +1 -0
- package/dist/cjs/Provider/NotesContext.d.ts +23 -0
- package/dist/cjs/Provider/NotesContext.d.ts.map +1 -0
- package/dist/cjs/Provider/NotesContext.js +51 -0
- package/dist/cjs/Provider/NotesContext.js.map +1 -0
- package/dist/cjs/Provider/NotesProvider.d.ts +11 -0
- package/dist/cjs/Provider/NotesProvider.d.ts.map +1 -0
- package/dist/cjs/Provider/NotesProvider.js +133 -0
- package/dist/cjs/Provider/NotesProvider.js.map +1 -0
- package/dist/cjs/Provider/index.d.ts +4 -0
- package/dist/cjs/Provider/index.d.ts.map +1 -0
- package/dist/cjs/Provider/notesVisibility.d.ts +2 -0
- package/dist/cjs/Provider/notesVisibility.d.ts.map +1 -0
- package/dist/cjs/Provider/notesVisibility.js +16 -0
- package/dist/cjs/Provider/notesVisibility.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +85 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/Buttons/NotesButton.d.ts +8 -0
- package/dist/esm/Buttons/NotesButton.d.ts.map +1 -0
- package/dist/esm/Buttons/NotesButton.js +124 -0
- package/dist/esm/Buttons/NotesButton.js.map +1 -0
- package/dist/esm/Buttons/index.d.ts +4 -0
- package/dist/esm/Buttons/index.d.ts.map +1 -0
- package/dist/esm/Buttons/index.js +4 -0
- package/dist/esm/Buttons/index.js.map +1 -0
- package/dist/esm/Buttons/menuItems.d.ts +10 -0
- package/dist/esm/Buttons/menuItems.d.ts.map +1 -0
- package/dist/esm/Buttons/menuItems.js +54 -0
- package/dist/esm/Buttons/menuItems.js.map +1 -0
- package/dist/esm/Buttons/notesDialogHeaderActions.d.ts +4 -0
- package/dist/esm/Buttons/notesDialogHeaderActions.d.ts.map +1 -0
- package/dist/esm/Buttons/notesDialogHeaderActions.js +34 -0
- package/dist/esm/Buttons/notesDialogHeaderActions.js.map +1 -0
- package/dist/esm/Context/componentContext.d.ts +8 -0
- package/dist/esm/Context/componentContext.d.ts.map +1 -0
- package/dist/esm/Context/componentContext.js +51 -0
- package/dist/esm/Context/componentContext.js.map +1 -0
- package/dist/esm/Context/formatLocation.d.ts +7 -0
- package/dist/esm/Context/formatLocation.d.ts.map +1 -0
- package/dist/esm/Context/formatLocation.js +21 -0
- package/dist/esm/Context/formatLocation.js.map +1 -0
- package/dist/esm/Context/index.d.ts +4 -0
- package/dist/esm/Context/index.d.ts.map +1 -0
- package/dist/esm/Context/index.js +4 -0
- package/dist/esm/Context/index.js.map +1 -0
- package/dist/esm/Context/noteContext.d.ts +22 -0
- package/dist/esm/Context/noteContext.d.ts.map +1 -0
- package/dist/esm/Context/noteContext.js +110 -0
- package/dist/esm/Context/noteContext.js.map +1 -0
- package/dist/esm/Feedback/ComponentFeedbackDialog.d.ts +10 -0
- package/dist/esm/Feedback/ComponentFeedbackDialog.d.ts.map +1 -0
- package/dist/esm/Feedback/ComponentFeedbackDialog.js +181 -0
- package/dist/esm/Feedback/ComponentFeedbackDialog.js.map +1 -0
- package/dist/esm/Feedback/ComponentModeSwitch.d.ts +7 -0
- package/dist/esm/Feedback/ComponentModeSwitch.d.ts.map +1 -0
- package/dist/esm/Feedback/ComponentModeSwitch.js +27 -0
- package/dist/esm/Feedback/ComponentModeSwitch.js.map +1 -0
- package/dist/esm/Feedback/ContextSummary.d.ts +7 -0
- package/dist/esm/Feedback/ContextSummary.d.ts.map +1 -0
- package/dist/esm/Feedback/ContextSummary.js +29 -0
- package/dist/esm/Feedback/ContextSummary.js.map +1 -0
- package/dist/esm/Feedback/FeedbackDialog.d.ts +11 -0
- package/dist/esm/Feedback/FeedbackDialog.d.ts.map +1 -0
- package/dist/esm/Feedback/FeedbackDialog.js +53 -0
- package/dist/esm/Feedback/FeedbackDialog.js.map +1 -0
- package/dist/esm/Feedback/KindAndText.d.ts +7 -0
- package/dist/esm/Feedback/KindAndText.d.ts.map +1 -0
- package/dist/esm/Feedback/KindAndText.js +31 -0
- package/dist/esm/Feedback/KindAndText.js.map +1 -0
- package/dist/esm/Feedback/SliceChooser.d.ts +9 -0
- package/dist/esm/Feedback/SliceChooser.d.ts.map +1 -0
- package/dist/esm/Feedback/SliceChooser.js +111 -0
- package/dist/esm/Feedback/SliceChooser.js.map +1 -0
- package/dist/esm/Feedback/SlicesFeedbackDialog.d.ts +8 -0
- package/dist/esm/Feedback/SlicesFeedbackDialog.d.ts.map +1 -0
- package/dist/esm/Feedback/SlicesFeedbackDialog.js +72 -0
- package/dist/esm/Feedback/SlicesFeedbackDialog.js.map +1 -0
- package/dist/esm/Feedback/index.d.ts +11 -0
- package/dist/esm/Feedback/index.d.ts.map +1 -0
- package/dist/esm/Feedback/index.js +11 -0
- package/dist/esm/Feedback/index.js.map +1 -0
- package/dist/esm/Feedback/kindOptions.d.ts +9 -0
- package/dist/esm/Feedback/kindOptions.d.ts.map +1 -0
- package/dist/esm/Feedback/kindOptions.js +34 -0
- package/dist/esm/Feedback/kindOptions.js.map +1 -0
- package/dist/esm/Feedback/propertySuggestions.d.ts +6 -0
- package/dist/esm/Feedback/propertySuggestions.d.ts.map +1 -0
- package/dist/esm/Feedback/propertySuggestions.js +29 -0
- package/dist/esm/Feedback/propertySuggestions.js.map +1 -0
- package/dist/esm/Feedback/sliceChoice.d.ts +7 -0
- package/dist/esm/Feedback/sliceChoice.d.ts.map +1 -0
- package/dist/esm/Feedback/sliceChoice.js +65 -0
- package/dist/esm/Feedback/sliceChoice.js.map +1 -0
- package/dist/esm/Icons.d.ts +4 -0
- package/dist/esm/Icons.d.ts.map +1 -0
- package/dist/esm/Icons.js +49 -0
- package/dist/esm/Icons.js.map +1 -0
- package/dist/esm/Labels/NotesLabels.d.ts +90 -0
- package/dist/esm/Labels/NotesLabels.d.ts.map +1 -0
- package/dist/esm/Labels/NotesLabels.js +2 -0
- package/dist/esm/Labels/NotesLabels.js.map +1 -0
- package/dist/esm/Labels/defaultNotesLabels.d.ts +3 -0
- package/dist/esm/Labels/defaultNotesLabels.d.ts.map +1 -0
- package/dist/esm/Labels/defaultNotesLabels.js +92 -0
- package/dist/esm/Labels/defaultNotesLabels.js.map +1 -0
- package/dist/esm/Labels/format.d.ts +2 -0
- package/dist/esm/Labels/format.d.ts.map +1 -0
- package/dist/esm/Labels/format.js +13 -0
- package/dist/esm/Labels/format.js.map +1 -0
- package/dist/esm/Labels/index.d.ts +5 -0
- package/dist/esm/Labels/index.d.ts.map +1 -0
- package/dist/esm/Labels/index.js +5 -0
- package/dist/esm/Labels/index.js.map +1 -0
- package/dist/esm/Labels/resolveLabels.d.ts +3 -0
- package/dist/esm/Labels/resolveLabels.d.ts.map +1 -0
- package/dist/esm/Labels/resolveLabels.js +33 -0
- package/dist/esm/Labels/resolveLabels.js.map +1 -0
- package/dist/esm/MyFeedback/MyFeedbackDialog.d.ts +2 -0
- package/dist/esm/MyFeedback/MyFeedbackDialog.d.ts.map +1 -0
- package/dist/esm/MyFeedback/MyFeedbackDialog.js +53 -0
- package/dist/esm/MyFeedback/MyFeedbackDialog.js.map +1 -0
- package/dist/esm/MyFeedback/MyFeedbackList.d.ts +10 -0
- package/dist/esm/MyFeedback/MyFeedbackList.d.ts.map +1 -0
- package/dist/esm/MyFeedback/MyFeedbackList.js +60 -0
- package/dist/esm/MyFeedback/MyFeedbackList.js.map +1 -0
- package/dist/esm/MyFeedback/index.d.ts +4 -0
- package/dist/esm/MyFeedback/index.d.ts.map +1 -0
- package/dist/esm/MyFeedback/index.js +4 -0
- package/dist/esm/MyFeedback/index.js.map +1 -0
- package/dist/esm/MyFeedback/noteStates.d.ts +8 -0
- package/dist/esm/MyFeedback/noteStates.d.ts.map +1 -0
- package/dist/esm/MyFeedback/noteStates.js +84 -0
- package/dist/esm/MyFeedback/noteStates.js.map +1 -0
- package/dist/esm/Provider/NotesContext.d.ts +23 -0
- package/dist/esm/Provider/NotesContext.d.ts.map +1 -0
- package/dist/esm/Provider/NotesContext.js +44 -0
- package/dist/esm/Provider/NotesContext.js.map +1 -0
- package/dist/esm/Provider/NotesProvider.d.ts +11 -0
- package/dist/esm/Provider/NotesProvider.d.ts.map +1 -0
- package/dist/esm/Provider/NotesProvider.js +131 -0
- package/dist/esm/Provider/NotesProvider.js.map +1 -0
- package/dist/esm/Provider/index.d.ts +4 -0
- package/dist/esm/Provider/index.d.ts.map +1 -0
- package/dist/esm/Provider/index.js +4 -0
- package/dist/esm/Provider/index.js.map +1 -0
- package/dist/esm/Provider/notesVisibility.d.ts +2 -0
- package/dist/esm/Provider/notesVisibility.d.ts.map +1 -0
- package/dist/esm/Provider/notesVisibility.js +14 -0
- package/dist/esm/Provider/notesVisibility.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +27 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/index.ts +10 -0
- package/package.json +84 -5
- package/styles.css +192 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { NotesLabels } from './NotesLabels.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The English labels of the Notes components.
|
|
8
|
+
*/
|
|
9
|
+
export const defaultNotesLabels: NotesLabels = {
|
|
10
|
+
common: {
|
|
11
|
+
cancel: 'Cancel',
|
|
12
|
+
close: 'Close',
|
|
13
|
+
locationSeparator: ' › ',
|
|
14
|
+
unknownLocation: 'Unknown location',
|
|
15
|
+
aboutHeading: 'About'
|
|
16
|
+
},
|
|
17
|
+
button: {
|
|
18
|
+
giveFeedback: 'Give feedback',
|
|
19
|
+
moreOptions: 'More ways to give feedback',
|
|
20
|
+
aboutSlices: 'About specific slices…',
|
|
21
|
+
aboutScreen: 'About this screen…',
|
|
22
|
+
pointAtSomething: 'Point at something…',
|
|
23
|
+
myFeedback: 'My feedback'
|
|
24
|
+
},
|
|
25
|
+
context: {
|
|
26
|
+
onScreen: '{location}, on screen {screen}',
|
|
27
|
+
atLocation: '{location}',
|
|
28
|
+
inDialog: '{location}, in the dialog {dialog}, on screen {screen}',
|
|
29
|
+
screenOnly: 'Screen {screen}'
|
|
30
|
+
},
|
|
31
|
+
kinds: {
|
|
32
|
+
title: 'What kind of feedback is it?',
|
|
33
|
+
problem: 'Problem',
|
|
34
|
+
suggestion: 'Suggestion',
|
|
35
|
+
question: 'Question',
|
|
36
|
+
praise: 'Praise'
|
|
37
|
+
},
|
|
38
|
+
feedback: {
|
|
39
|
+
contextTitle: 'Give feedback on this',
|
|
40
|
+
screenTitle: 'Give feedback on this screen',
|
|
41
|
+
send: 'Send feedback',
|
|
42
|
+
text: 'What do you think?',
|
|
43
|
+
sent: 'Thank you for your feedback'
|
|
44
|
+
},
|
|
45
|
+
slices: {
|
|
46
|
+
title: 'Give feedback on specific slices',
|
|
47
|
+
active: 'On this screen',
|
|
48
|
+
search: 'Search all slices',
|
|
49
|
+
searchPlaceholder: 'Search by module, feature or slice',
|
|
50
|
+
results: 'Matching slices',
|
|
51
|
+
noMatches: 'No slice matches.',
|
|
52
|
+
noneActive: 'No slice is active on this screen.',
|
|
53
|
+
chosen: '{count} chosen',
|
|
54
|
+
remove: 'Remove {slice}'
|
|
55
|
+
},
|
|
56
|
+
component: {
|
|
57
|
+
title: 'Give feedback on a component',
|
|
58
|
+
about: 'About {component}',
|
|
59
|
+
describe: 'Describe it',
|
|
60
|
+
change: 'Change it',
|
|
61
|
+
mode: 'How to give feedback',
|
|
62
|
+
nothingToChange: 'This component has no properties to change.',
|
|
63
|
+
previewNotice: 'Changes show here as a preview, and go away when you close this dialog.',
|
|
64
|
+
sendChanges: 'Send changes',
|
|
65
|
+
noChanges: 'Change a property to send a suggestion.',
|
|
66
|
+
failed: '{count} changes could not be sent. Try again.'
|
|
67
|
+
},
|
|
68
|
+
picker: {
|
|
69
|
+
started: 'Click a component to give feedback on it. Press Escape to cancel.'
|
|
70
|
+
},
|
|
71
|
+
myFeedback: {
|
|
72
|
+
title: 'My feedback',
|
|
73
|
+
description: 'The feedback you gave and where it stands.',
|
|
74
|
+
empty: 'You have not given any feedback yet.',
|
|
75
|
+
withdraw: 'Withdraw',
|
|
76
|
+
withdrawNote: 'Withdraw the note: {text}',
|
|
77
|
+
suggestionsOnly: 'Suggested changes',
|
|
78
|
+
targets: {
|
|
79
|
+
context: 'What was on screen',
|
|
80
|
+
slices: 'Slices',
|
|
81
|
+
screen: 'Screen',
|
|
82
|
+
component: 'Component {component}'
|
|
83
|
+
},
|
|
84
|
+
statuses: {
|
|
85
|
+
given: 'Given',
|
|
86
|
+
acknowledged: 'Acknowledged',
|
|
87
|
+
addressed: 'Addressed in {version}',
|
|
88
|
+
declined: 'Declined: {reason}',
|
|
89
|
+
withdrawn: 'Withdrawn'
|
|
90
|
+
},
|
|
91
|
+
propertyChanges: '{count} suggested property changes'
|
|
92
|
+
}
|
|
93
|
+
};
|
package/Labels/format.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fills the placeholders of a label, such as `{count}`, with values. A placeholder without a value is left as it is.
|
|
6
|
+
* @param template The label.
|
|
7
|
+
* @param values The values by placeholder name.
|
|
8
|
+
* @returns The label with its placeholders filled in.
|
|
9
|
+
*/
|
|
10
|
+
export function format(template: string, values: Record<string, string | number>): string {
|
|
11
|
+
return template.replace(/\{(\w+)\}/g, (placeholder, name: string) =>
|
|
12
|
+
Object.hasOwn(values, name) ? String(values[name]) : placeholder);
|
|
13
|
+
}
|
package/Labels/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
export * from './defaultNotesLabels.js';
|
|
5
|
+
export * from './format.js';
|
|
6
|
+
export * from './NotesLabels.js';
|
|
7
|
+
export * from './resolveLabels.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { defaultNotesLabels } from './defaultNotesLabels.js';
|
|
5
|
+
import { NotesLabelOverrides, NotesLabels } from './NotesLabels.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the labels to show: the overrides given, and the English default for every label left out.
|
|
9
|
+
* @param overrides The labels a solution replaces.
|
|
10
|
+
* @returns The {@link NotesLabels}.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveLabels(overrides?: NotesLabelOverrides): NotesLabels {
|
|
13
|
+
return merge(defaultNotesLabels, overrides) as NotesLabels;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function merge(defaults: object, overrides?: object): object {
|
|
17
|
+
if (!overrides) {
|
|
18
|
+
return defaults;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const merged: Record<string, unknown> = { ...defaults };
|
|
22
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const defaultValue = (defaults as Record<string, unknown>)[key];
|
|
28
|
+
merged[key] = isObject(defaultValue) && isObject(value) ? merge(defaultValue, value) : value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return merged;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isObject(value: unknown): value is object {
|
|
35
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
36
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Dialog, DialogInitialFocus } from '@cratis/components/Dialogs';
|
|
5
|
+
import { MyNote, MyNotes, WithdrawNote } from '@cratis/showrunner.notes';
|
|
6
|
+
import { useRef, useState } from 'react';
|
|
7
|
+
import { useNotesLabels } from '../Provider/NotesContext.js';
|
|
8
|
+
import { MyFeedbackList } from './MyFeedbackList.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The my feedback side sheet: the user's notes with their status, kept current as the receiving side acknowledges,
|
|
12
|
+
* addresses or declines them. Open it with `useDialog`.
|
|
13
|
+
*/
|
|
14
|
+
export const MyFeedbackDialog = () => {
|
|
15
|
+
const labels = useNotesLabels();
|
|
16
|
+
const [result] = MyNotes.use();
|
|
17
|
+
const [withdraw, setWithdraw] = WithdrawNote.use();
|
|
18
|
+
const inFlight = useRef(new Set<string>());
|
|
19
|
+
const [withdrawing, setWithdrawing] = useState<ReadonlySet<string>>(new Set());
|
|
20
|
+
|
|
21
|
+
const onWithdraw = async (note: MyNote) => {
|
|
22
|
+
const id = note.id.toString();
|
|
23
|
+
if (inFlight.current.has(id)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
inFlight.current.add(id);
|
|
28
|
+
setWithdrawing(new Set(inFlight.current));
|
|
29
|
+
try {
|
|
30
|
+
setWithdraw({ noteId: note.id });
|
|
31
|
+
await withdraw.execute();
|
|
32
|
+
} finally {
|
|
33
|
+
inFlight.current.delete(id);
|
|
34
|
+
setWithdrawing(new Set(inFlight.current));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Dialog
|
|
40
|
+
title={labels.myFeedback.title}
|
|
41
|
+
subtitle={labels.myFeedback.description}
|
|
42
|
+
placement='end'
|
|
43
|
+
width='640px'
|
|
44
|
+
buttons={null}
|
|
45
|
+
dismissable
|
|
46
|
+
initialFocus={DialogInitialFocus.Content}
|
|
47
|
+
closeAriaLabel={labels.common.close}>
|
|
48
|
+
<MyFeedbackList notes={result.data ?? []} labels={labels} withdrawing={withdrawing} onWithdraw={onWithdraw} />
|
|
49
|
+
</Dialog>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Button } from '@cratis/components/Common';
|
|
5
|
+
import { Guid } from '@cratis/fundamentals';
|
|
6
|
+
import { MyNote, NoteStatus } from '@cratis/showrunner.notes';
|
|
7
|
+
import { format, NotesLabels } from '../Labels/index.js';
|
|
8
|
+
import { canWithdraw, newestFirst, noteText, statusText, targetText } from './noteStates.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props for {@link MyFeedbackList}.
|
|
12
|
+
*/
|
|
13
|
+
export interface MyFeedbackListProps {
|
|
14
|
+
/** The user's notes. */
|
|
15
|
+
notes: readonly MyNote[];
|
|
16
|
+
|
|
17
|
+
/** The labels to show. */
|
|
18
|
+
labels: NotesLabels;
|
|
19
|
+
|
|
20
|
+
/** The notes being withdrawn right now. */
|
|
21
|
+
withdrawing?: ReadonlySet<string>;
|
|
22
|
+
|
|
23
|
+
/** Called with the note the user chooses to withdraw. */
|
|
24
|
+
onWithdraw: (note: MyNote) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Lists the user's notes with where each stands, and a button to withdraw the ones that can still be withdrawn.
|
|
29
|
+
*/
|
|
30
|
+
export const MyFeedbackList = ({ notes, labels, withdrawing = new Set(), onWithdraw }: MyFeedbackListProps) => {
|
|
31
|
+
if (notes.length === 0) {
|
|
32
|
+
return <p className='notes-my-feedback__empty'>{labels.myFeedback.empty}</p>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ul className='notes-my-feedback__list'>
|
|
37
|
+
{newestFirst(notes).map(note => {
|
|
38
|
+
const id = (note.id as Guid).toString();
|
|
39
|
+
const text = noteText(note, labels);
|
|
40
|
+
return (
|
|
41
|
+
<li key={id} className='notes-my-feedback__note' data-status={NoteStatus[note.status]}>
|
|
42
|
+
<div className='notes-my-feedback__header'>
|
|
43
|
+
<span className='notes-my-feedback__status'>{statusText(note, labels)}</span>
|
|
44
|
+
<span className='notes-my-feedback__target'>{targetText(note, labels)}</span>
|
|
45
|
+
</div>
|
|
46
|
+
<p className='notes-my-feedback__text'>{text}</p>
|
|
47
|
+
{canWithdraw(note) && (
|
|
48
|
+
<Button
|
|
49
|
+
variant='outline'
|
|
50
|
+
size='small'
|
|
51
|
+
label={labels.myFeedback.withdraw}
|
|
52
|
+
aria-label={format(labels.myFeedback.withdrawNote, { text: text.slice(0, 40) })}
|
|
53
|
+
disabled={withdrawing.has(id)}
|
|
54
|
+
loading={withdrawing.has(id)}
|
|
55
|
+
onClick={() => onWithdraw(note)} />
|
|
56
|
+
)}
|
|
57
|
+
</li>
|
|
58
|
+
);
|
|
59
|
+
})}
|
|
60
|
+
</ul>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { MyNote, NoteStatus, NoteTarget } from '@cratis/showrunner.notes';
|
|
5
|
+
import { formatLocation } from '../Context/formatLocation.js';
|
|
6
|
+
import { format, NotesLabels } from '../Labels/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Says where a note stands: given, acknowledged, addressed in a version, declined with a reason, or withdrawn.
|
|
10
|
+
* @param note The note.
|
|
11
|
+
* @param labels The labels to show.
|
|
12
|
+
* @returns The status in plain language.
|
|
13
|
+
*/
|
|
14
|
+
export function statusText(note: Pick<MyNote, 'status' | 'statusDetail'>, labels: NotesLabels): string {
|
|
15
|
+
const statuses = labels.myFeedback.statuses;
|
|
16
|
+
switch (note.status) {
|
|
17
|
+
case NoteStatus.acknowledged: return statuses.acknowledged;
|
|
18
|
+
case NoteStatus.addressed: return format(statuses.addressed, { version: note.statusDetail });
|
|
19
|
+
case NoteStatus.declined: return format(statuses.declined, { reason: note.statusDetail });
|
|
20
|
+
case NoteStatus.withdrawn: return statuses.withdrawn;
|
|
21
|
+
default: return statuses.given;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Says what a note is about.
|
|
27
|
+
* @param note The note.
|
|
28
|
+
* @param labels The labels to show.
|
|
29
|
+
* @returns The subject in plain language.
|
|
30
|
+
*/
|
|
31
|
+
export function targetText(note: Pick<MyNote, 'target' | 'location' | 'screen' | 'slices' | 'component'>, labels: NotesLabels): string {
|
|
32
|
+
const targets = labels.myFeedback.targets;
|
|
33
|
+
const location = (parts: Parameters<typeof formatLocation>[0]) => formatLocation(parts, labels.common.locationSeparator, labels.common.unknownLocation);
|
|
34
|
+
switch (note.target) {
|
|
35
|
+
case NoteTarget.slices: return `${targets.slices}: ${note.slices.map(location).join(', ')}`;
|
|
36
|
+
case NoteTarget.screen: return `${targets.screen}: ${note.screen.screenName || note.screen.screenPath || labels.common.unknownLocation}`;
|
|
37
|
+
case NoteTarget.component: return `${format(targets.component, { component: note.component })} · ${location(note.location)}`;
|
|
38
|
+
default: return `${targets.context}: ${location(note.location)}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets what to show of what the user wrote.
|
|
44
|
+
* @param note The note.
|
|
45
|
+
* @param labels The labels to show.
|
|
46
|
+
* @returns The text; the count of suggested property changes for a note that has no text.
|
|
47
|
+
*/
|
|
48
|
+
export function noteText(note: Pick<MyNote, 'text' | 'propertyChanges'>, labels: NotesLabels): string {
|
|
49
|
+
if (note.text) {
|
|
50
|
+
return note.text;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return note.propertyChanges.length > 0
|
|
54
|
+
? format(labels.myFeedback.propertyChanges, { count: note.propertyChanges.length })
|
|
55
|
+
: labels.myFeedback.suggestionsOnly;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether the user can still withdraw a note: once the receiving side has answered it, or it is withdrawn, there is
|
|
60
|
+
* nothing to withdraw.
|
|
61
|
+
* @param note The note.
|
|
62
|
+
* @returns True when the note can be withdrawn.
|
|
63
|
+
*/
|
|
64
|
+
export function canWithdraw(note: Pick<MyNote, 'status'>): boolean {
|
|
65
|
+
return note.status === NoteStatus.given || note.status === NoteStatus.acknowledged;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Sorts the notes the way the user wants to read them: most recent activity first.
|
|
70
|
+
* @param notes The notes.
|
|
71
|
+
* @returns A new list, most recent activity first.
|
|
72
|
+
*/
|
|
73
|
+
export function newestFirst<TNote extends Pick<MyNote, 'lastActivityAt'>>(notes: readonly TNote[]): TNote[] {
|
|
74
|
+
return [...notes].sort((a, b) => new Date(b.lastActivityAt).getTime() - new Date(a.lastActivityAt).getTime());
|
|
75
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { DialogHeaderContext } from '@cratis/components/Dialogs';
|
|
5
|
+
import { createContext, useContext } from 'react';
|
|
6
|
+
import { LocationParts } from '../Context/formatLocation.js';
|
|
7
|
+
import { NotesLabels, resolveLabels } from '../Labels/index.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* What {@link NotesProvider} gives the Notes components.
|
|
11
|
+
*/
|
|
12
|
+
export interface NotesContextValue {
|
|
13
|
+
/** Whether a {@link NotesProvider} provides the value; the defaults otherwise. */
|
|
14
|
+
readonly isProvided: boolean;
|
|
15
|
+
|
|
16
|
+
/** The labels to show. */
|
|
17
|
+
readonly labels: NotesLabels;
|
|
18
|
+
|
|
19
|
+
/** Whether the Notes components render: the user is signed in and Notes is switched on. */
|
|
20
|
+
readonly isAvailable: boolean;
|
|
21
|
+
|
|
22
|
+
/** Whether the feedback button registers itself in the header of dialogs that have a slice. */
|
|
23
|
+
readonly showsInDialogHeaders: boolean;
|
|
24
|
+
|
|
25
|
+
/** Whether picking a component is going on. */
|
|
26
|
+
readonly isPicking: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Opens the dialog that gives feedback on what the user is looking at.
|
|
30
|
+
* @param dialog The dialog the button is in; the feedback is about the dialog when given.
|
|
31
|
+
*/
|
|
32
|
+
giveFeedback(dialog?: DialogHeaderContext): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Opens the dialog that gives feedback on specific slices.
|
|
36
|
+
* @param dialog The dialog the button is in.
|
|
37
|
+
*/
|
|
38
|
+
giveFeedbackOnSlices(dialog?: DialogHeaderContext): void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Opens the dialog that gives feedback on the screen.
|
|
42
|
+
* @param dialog The dialog the button is in.
|
|
43
|
+
*/
|
|
44
|
+
giveFeedbackOnScreen(dialog?: DialogHeaderContext): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Starts pointing at a component, and opens the dialog that gives feedback on it once one is picked.
|
|
48
|
+
* @param dialog The dialog the button is in.
|
|
49
|
+
*/
|
|
50
|
+
pointAtSomething(dialog?: DialogHeaderContext): void;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Opens the user's own feedback.
|
|
54
|
+
*/
|
|
55
|
+
showMyFeedback(): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const noop = () => {
|
|
59
|
+
/* Without a NotesProvider there are no dialogs to open. */
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The value without a {@link NotesProvider}: English labels, nothing available and nothing to open.
|
|
64
|
+
*/
|
|
65
|
+
export const defaultNotesContextValue: NotesContextValue = {
|
|
66
|
+
isProvided: false,
|
|
67
|
+
labels: resolveLabels(),
|
|
68
|
+
isAvailable: false,
|
|
69
|
+
showsInDialogHeaders: false,
|
|
70
|
+
isPicking: false,
|
|
71
|
+
giveFeedback: noop,
|
|
72
|
+
giveFeedbackOnSlices: noop,
|
|
73
|
+
giveFeedbackOnScreen: noop,
|
|
74
|
+
pointAtSomething: noop,
|
|
75
|
+
showMyFeedback: noop
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The React context {@link NotesProvider} provides.
|
|
80
|
+
*/
|
|
81
|
+
export const NotesContext = createContext<NotesContextValue>(defaultNotesContextValue);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Gets what {@link NotesProvider} provides, or the defaults outside one.
|
|
85
|
+
* @returns The {@link NotesContextValue}.
|
|
86
|
+
*/
|
|
87
|
+
export const useNotesContext = (): NotesContextValue => useContext(NotesContext);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Gets the labels to show.
|
|
91
|
+
* @returns The {@link NotesLabels}.
|
|
92
|
+
*/
|
|
93
|
+
export const useNotesLabels = (): NotesLabels => useContext(NotesContext).labels;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* What a component that opens Notes dialogs from its own code can do.
|
|
97
|
+
*/
|
|
98
|
+
export type Notes = Pick<NotesContextValue, 'labels' | 'isAvailable' | 'giveFeedback' | 'giveFeedbackOnSlices' | 'giveFeedbackOnScreen' | 'pointAtSomething' | 'showMyFeedback'>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Uses Notes from any component inside a {@link NotesProvider}, to open its dialogs from a menu or shortcut of your own.
|
|
102
|
+
* @returns The {@link Notes}.
|
|
103
|
+
*/
|
|
104
|
+
export const useNotes = (): Notes => useContext(NotesContext);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The slice location parts of a dialog header context, when it has one.
|
|
108
|
+
* @param dialog The dialog the button is in.
|
|
109
|
+
* @returns The parts; undefined when the dialog has no slice.
|
|
110
|
+
*/
|
|
111
|
+
export const dialogLocationOf = (dialog?: DialogHeaderContext): LocationParts | undefined => dialog?.sliceLocation;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { ApplicationContext, useApplicationContextStore } from '@cratis/arc.react';
|
|
5
|
+
import { DialogResult, useDialog } from '@cratis/arc.react/dialogs';
|
|
6
|
+
import { useIdentity } from '@cratis/arc.react/identity';
|
|
7
|
+
import { useComponentPicker } from '@cratis/components/ComponentPicker';
|
|
8
|
+
import { DialogHeaderContext } from '@cratis/components/Dialogs';
|
|
9
|
+
import { toast } from '@cratis/components/Notifications';
|
|
10
|
+
import { Guid } from '@cratis/fundamentals';
|
|
11
|
+
import { Availability } from '@cratis/showrunner.notes';
|
|
12
|
+
import { ReactNode, useCallback, useMemo, useRef } from 'react';
|
|
13
|
+
import { buildNoteContext, DialogReference, resolveComponentContext } from '../Context/index.js';
|
|
14
|
+
import { LocationParts } from '../Context/formatLocation.js';
|
|
15
|
+
import { ComponentFeedbackDialog } from '../Feedback/ComponentFeedbackDialog.js';
|
|
16
|
+
import { FeedbackDialog, FeedbackGiven } from '../Feedback/FeedbackDialog.js';
|
|
17
|
+
import { SlicesFeedbackDialog } from '../Feedback/SlicesFeedbackDialog.js';
|
|
18
|
+
import { NotesLabelOverrides, resolveLabels } from '../Labels/index.js';
|
|
19
|
+
import { MyFeedbackDialog } from '../MyFeedback/MyFeedbackDialog.js';
|
|
20
|
+
import { NotesContext, NotesContextValue } from './NotesContext.js';
|
|
21
|
+
import { isNotesAvailable } from './notesVisibility.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Props for {@link NotesProvider}.
|
|
25
|
+
*/
|
|
26
|
+
export interface NotesProviderProps {
|
|
27
|
+
/** Whether the feedback button registers itself in the header of dialogs that have a slice. Defaults to false. It takes effect through `notesDialogHeaderActions` on `CratisComponentsProvider`. */
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
|
|
30
|
+
/** The labels that replace the English defaults, for instance to localize them. */
|
|
31
|
+
labels?: NotesLabelOverrides;
|
|
32
|
+
|
|
33
|
+
/** Every slice the host knows about, for the search of the give feedback on slices dialog. */
|
|
34
|
+
knownSlices?: readonly LocationParts[];
|
|
35
|
+
|
|
36
|
+
/** The application. */
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const emptySnapshot = new ApplicationContext().getSnapshot();
|
|
41
|
+
|
|
42
|
+
const dialogReferenceOf = (dialog?: DialogHeaderContext): DialogReference | undefined =>
|
|
43
|
+
dialog?.sliceLocation ? { title: dialog.title, location: dialog.sliceLocation } : undefined;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Slots Notes into an application: renders the feedback dialogs and the component picker once, asks whether Notes is
|
|
47
|
+
* switched on, and gives the Notes buttons and `useNotes` what they need. Render it inside `<Arc>`, the `DialogComponents`
|
|
48
|
+
* registration, an `IdentityProvider` and a `CratisComponentsProvider` with a toaster. Turn on `<Arc sliceMarkers>` for
|
|
49
|
+
* Notes to know the slice of a component the user points at.
|
|
50
|
+
*/
|
|
51
|
+
export const NotesProvider = ({ enabled = false, labels, knownSlices = [], children }: NotesProviderProps) => {
|
|
52
|
+
const store = useApplicationContextStore();
|
|
53
|
+
const identity = useIdentity();
|
|
54
|
+
const [availability] = Availability.use();
|
|
55
|
+
const isAvailable = isNotesAvailable(identity.isSet, availability.data?.isEnabled);
|
|
56
|
+
const resolvedLabels = useMemo(() => resolveLabels(labels), [labels]);
|
|
57
|
+
const busy = useRef(false);
|
|
58
|
+
|
|
59
|
+
const [FeedbackDialogWrapper, showFeedbackDialog] = useDialog<FeedbackGiven, Parameters<typeof FeedbackDialog>[0]>(FeedbackDialog);
|
|
60
|
+
const [SlicesDialogWrapper, showSlicesDialog] = useDialog<FeedbackGiven, Parameters<typeof SlicesFeedbackDialog>[0]>(SlicesFeedbackDialog);
|
|
61
|
+
const [ComponentDialogWrapper, showComponentDialog] = useDialog<FeedbackGiven, Parameters<typeof ComponentFeedbackDialog>[0]>(ComponentFeedbackDialog);
|
|
62
|
+
const [MyFeedbackDialogWrapper, showMyFeedbackDialog] = useDialog<object, object>(MyFeedbackDialog);
|
|
63
|
+
const picker = useComponentPicker({ resolve: resolveComponentContext });
|
|
64
|
+
|
|
65
|
+
const capture = useCallback((dialog?: DialogHeaderContext) => buildNoteContext({
|
|
66
|
+
snapshot: store?.getSnapshot() ?? emptySnapshot,
|
|
67
|
+
route: window.location.pathname,
|
|
68
|
+
correlationId: Guid.create(),
|
|
69
|
+
dialog: dialogReferenceOf(dialog)
|
|
70
|
+
}), [store]);
|
|
71
|
+
|
|
72
|
+
const whileOpen = useCallback(async <TResult,>(open: () => Promise<[DialogResult, TResult?]>, announceSent = true) => {
|
|
73
|
+
if (busy.current) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
busy.current = true;
|
|
78
|
+
try {
|
|
79
|
+
const [result] = await open();
|
|
80
|
+
if (announceSent && result === DialogResult.Ok) {
|
|
81
|
+
toast.success({ title: resolvedLabels.feedback.sent });
|
|
82
|
+
}
|
|
83
|
+
} finally {
|
|
84
|
+
busy.current = false;
|
|
85
|
+
}
|
|
86
|
+
}, [resolvedLabels]);
|
|
87
|
+
|
|
88
|
+
const value = useMemo<NotesContextValue>(() => ({
|
|
89
|
+
isProvided: true,
|
|
90
|
+
labels: resolvedLabels,
|
|
91
|
+
isAvailable,
|
|
92
|
+
showsInDialogHeaders: enabled,
|
|
93
|
+
isPicking: picker.isPicking,
|
|
94
|
+
giveFeedback: dialog => void whileOpen(() => showFeedbackDialog({ context: capture(dialog) })),
|
|
95
|
+
giveFeedbackOnScreen: dialog => void whileOpen(() => showFeedbackDialog({ context: capture(dialog), about: 'screen' })),
|
|
96
|
+
giveFeedbackOnSlices: dialog => void whileOpen(() => showSlicesDialog({ context: capture(dialog), knownSlices })),
|
|
97
|
+
pointAtSomething: dialog => {
|
|
98
|
+
if (busy.current || picker.isPicking) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const context = capture(dialog);
|
|
103
|
+
void picker.start().then(picked => {
|
|
104
|
+
if (picked) {
|
|
105
|
+
void whileOpen(() => showComponentDialog({ context, picked }));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
showMyFeedback: () => void whileOpen(() => showMyFeedbackDialog({}), false)
|
|
110
|
+
}), [resolvedLabels, isAvailable, enabled, picker, knownSlices, capture, whileOpen, showFeedbackDialog, showSlicesDialog, showComponentDialog, showMyFeedbackDialog]);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<NotesContext.Provider value={value}>
|
|
114
|
+
{children}
|
|
115
|
+
<FeedbackDialogWrapper />
|
|
116
|
+
<SlicesDialogWrapper />
|
|
117
|
+
<ComponentDialogWrapper />
|
|
118
|
+
<MyFeedbackDialogWrapper />
|
|
119
|
+
{picker.picker}
|
|
120
|
+
</NotesContext.Provider>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Decides whether the Notes components render anything: only for a signed-in user, and only while Notes is switched
|
|
6
|
+
* on.
|
|
7
|
+
* @param isSignedIn Whether the user is signed in.
|
|
8
|
+
* @param isEnabled Whether Notes is switched on, as `NotesAvailability` tells; false until it is known.
|
|
9
|
+
* @returns True when the Notes components render.
|
|
10
|
+
*/
|
|
11
|
+
export function isNotesAvailable(isSignedIn: boolean, isEnabled: boolean | undefined): boolean {
|
|
12
|
+
return isSignedIn && isEnabled === true;
|
|
13
|
+
}
|
package/README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cratis/showrunner.notes.react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components for Notes, the Showrunner product feedback part: a feedback button with a context drop-down, the
|
|
4
|
+
feedback dialogs, the component picker and the user's own feedback. Built on `@cratis/components` and the generated
|
|
5
|
+
proxies in `@cratis/showrunner.notes`. How to use it: [Documentation/Notes/react.md](../../../Documentation/Notes/react.md).
|
|
6
|
+
|
|
7
|
+
## Component hierarchy
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
NotesProvider provides NotesContext, renders the dialogs and the component picker once
|
|
11
|
+
├── FeedbackDialog CommandDialog<GiveNoteOnContext | GiveNoteOnScreen>
|
|
12
|
+
├── SlicesFeedbackDialog CommandDialog<GiveNoteOnSlices>, with SliceChooser
|
|
13
|
+
├── ComponentFeedbackDialog highlight; Describe it = CommandDialog<GiveNoteOnComponent>,
|
|
14
|
+
│ Change it = Dialog + PresentationPropertyEditor (preview), SuggestComponentPropertyChange per property
|
|
15
|
+
└── MyFeedbackDialog Dialog placement='end', MyNotes observable query, WithdrawNote
|
|
16
|
+
NotesButton split button; opens the dialogs through NotesContext
|
|
17
|
+
notesDialogHeaderActions renderer for CratisComponentsProvider's dialogHeaderActions
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Architecture decisions
|
|
21
|
+
|
|
22
|
+
- **The context is captured at the click.** `NotesProvider` reads Arc's application context store when the user clicks,
|
|
23
|
+
before Notes opens a dialog of its own, so a Notes dialog never ends up as the "open dialog" of its own note.
|
|
24
|
+
- **The provider cannot register the dialog header action itself.** `dialogHeaderActions` is a prop of the host's
|
|
25
|
+
`CratisComponentsProvider`, so Notes exports a renderer, `notesDialogHeaderActions`, and `<NotesProvider enabled>`
|
|
26
|
+
is what makes it show.
|
|
27
|
+
- **A component's slice comes from the picker's `resolve`.** `resolveComponentContext` reads the closest Arc slice
|
|
28
|
+
marker; without markers the focused location is used.
|
|
29
|
+
- **Previews belong to the property editor.** `PresentationPropertyEditor preview` reverts when it unmounts, which is
|
|
30
|
+
when the dialog closes, whether it was sent or cancelled.
|
|
31
|
+
- **Visibility is one rule.** `isNotesAvailable(isSignedIn, isEnabled)`: the user is signed in and `NotesAvailability`
|
|
32
|
+
says Notes is on.
|
|
33
|
+
|
|
34
|
+
## State
|
|
35
|
+
|
|
36
|
+
| Module | Decides |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `Context/noteContext.ts` | the `NoteContext` of a click, the plain-language sentence |
|
|
39
|
+
| `Context/componentContext.ts` | the slice of a picked component, the component a note carries |
|
|
40
|
+
| `Feedback/sliceChoice.ts` | choosing and searching slices |
|
|
41
|
+
| `Feedback/propertySuggestions.ts` | one suggestion per changed property |
|
|
42
|
+
| `MyFeedback/noteStates.ts` | status and target text, what can be withdrawn |
|
|
43
|
+
| `Buttons/menuItems.ts` | drop-down items and keyboard movement |
|
|
44
|
+
| `Provider/notesVisibility.ts` | whether anything renders |
|
|
45
|
+
| `Labels/` | English defaults, deep overrides, placeholders |
|
|
46
|
+
|
|
47
|
+
## CSS conventions
|
|
48
|
+
|
|
49
|
+
One stylesheet, `styles.css`, exported as `@cratis/showrunner.notes.react/styles`. Classes are prefixed `notes-`, and
|
|
50
|
+
every color, border and radius comes from the `--cratis-*` tokens.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DialogHeaderContext } from '@cratis/components/Dialogs';
|
|
2
|
+
export interface NotesButtonProps {
|
|
3
|
+
size?: 'large' | 'small';
|
|
4
|
+
dialog?: DialogHeaderContext;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const NotesButton: ({ size, dialog, className }: NotesButtonProps) => import("react").JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=NotesButton.d.ts.map
|