@cratis/showrunner.notes.react 0.0.0-stage → 1.15.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 +83 -4
- package/styles.css +192 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotesProvider.js","sources":["../../../Provider/NotesProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ApplicationContext, useApplicationContextStore } from '@cratis/arc.react';\nimport { DialogResult, useDialog } from '@cratis/arc.react/dialogs';\nimport { useIdentity } from '@cratis/arc.react/identity';\nimport { useComponentPicker } from '@cratis/components/ComponentPicker';\nimport { DialogHeaderContext } from '@cratis/components/Dialogs';\nimport { toast } from '@cratis/components/Notifications';\nimport { Guid } from '@cratis/fundamentals';\nimport { Availability } from '@cratis/showrunner.notes';\nimport { ReactNode, useCallback, useMemo, useRef } from 'react';\nimport { buildNoteContext, DialogReference, resolveComponentContext } from '../Context/index.js';\nimport { LocationParts } from '../Context/formatLocation.js';\nimport { ComponentFeedbackDialog } from '../Feedback/ComponentFeedbackDialog.js';\nimport { FeedbackDialog, FeedbackGiven } from '../Feedback/FeedbackDialog.js';\nimport { SlicesFeedbackDialog } from '../Feedback/SlicesFeedbackDialog.js';\nimport { NotesLabelOverrides, resolveLabels } from '../Labels/index.js';\nimport { MyFeedbackDialog } from '../MyFeedback/MyFeedbackDialog.js';\nimport { NotesContext, NotesContextValue } from './NotesContext.js';\nimport { isNotesAvailable } from './notesVisibility.js';\n\n/**\n * Props for {@link NotesProvider}.\n */\nexport interface NotesProviderProps {\n /** 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`. */\n enabled?: boolean;\n\n /** The labels that replace the English defaults, for instance to localize them. */\n labels?: NotesLabelOverrides;\n\n /** Every slice the host knows about, for the search of the give feedback on slices dialog. */\n knownSlices?: readonly LocationParts[];\n\n /** The application. */\n children?: ReactNode;\n}\n\nconst emptySnapshot = new ApplicationContext().getSnapshot();\n\nconst dialogReferenceOf = (dialog?: DialogHeaderContext): DialogReference | undefined =>\n dialog?.sliceLocation ? { title: dialog.title, location: dialog.sliceLocation } : undefined;\n\n/**\n * Slots Notes into an application: renders the feedback dialogs and the component picker once, asks whether Notes is\n * switched on, and gives the Notes buttons and `useNotes` what they need. Render it inside `<Arc>`, the `DialogComponents`\n * registration, an `IdentityProvider` and a `CratisComponentsProvider` with a toaster. Turn on `<Arc sliceMarkers>` for\n * Notes to know the slice of a component the user points at.\n */\nexport const NotesProvider = ({ enabled = false, labels, knownSlices = [], children }: NotesProviderProps) => {\n const store = useApplicationContextStore();\n const identity = useIdentity();\n const [availability] = Availability.use();\n const isAvailable = isNotesAvailable(identity.isSet, availability.data?.isEnabled);\n const resolvedLabels = useMemo(() => resolveLabels(labels), [labels]);\n const busy = useRef(false);\n\n const [FeedbackDialogWrapper, showFeedbackDialog] = useDialog<FeedbackGiven, Parameters<typeof FeedbackDialog>[0]>(FeedbackDialog);\n const [SlicesDialogWrapper, showSlicesDialog] = useDialog<FeedbackGiven, Parameters<typeof SlicesFeedbackDialog>[0]>(SlicesFeedbackDialog);\n const [ComponentDialogWrapper, showComponentDialog] = useDialog<FeedbackGiven, Parameters<typeof ComponentFeedbackDialog>[0]>(ComponentFeedbackDialog);\n const [MyFeedbackDialogWrapper, showMyFeedbackDialog] = useDialog<object, object>(MyFeedbackDialog);\n const picker = useComponentPicker({ resolve: resolveComponentContext });\n\n const capture = useCallback((dialog?: DialogHeaderContext) => buildNoteContext({\n snapshot: store?.getSnapshot() ?? emptySnapshot,\n route: window.location.pathname,\n correlationId: Guid.create(),\n dialog: dialogReferenceOf(dialog)\n }), [store]);\n\n const whileOpen = useCallback(async <TResult,>(open: () => Promise<[DialogResult, TResult?]>, announceSent = true) => {\n if (busy.current) {\n return;\n }\n\n busy.current = true;\n try {\n const [result] = await open();\n if (announceSent && result === DialogResult.Ok) {\n toast.success({ title: resolvedLabels.feedback.sent });\n }\n } finally {\n busy.current = false;\n }\n }, [resolvedLabels]);\n\n const value = useMemo<NotesContextValue>(() => ({\n isProvided: true,\n labels: resolvedLabels,\n isAvailable,\n showsInDialogHeaders: enabled,\n isPicking: picker.isPicking,\n giveFeedback: dialog => void whileOpen(() => showFeedbackDialog({ context: capture(dialog) })),\n giveFeedbackOnScreen: dialog => void whileOpen(() => showFeedbackDialog({ context: capture(dialog), about: 'screen' })),\n giveFeedbackOnSlices: dialog => void whileOpen(() => showSlicesDialog({ context: capture(dialog), knownSlices })),\n pointAtSomething: dialog => {\n if (busy.current || picker.isPicking) {\n return;\n }\n\n const context = capture(dialog);\n void picker.start().then(picked => {\n if (picked) {\n void whileOpen(() => showComponentDialog({ context, picked }));\n }\n });\n },\n showMyFeedback: () => void whileOpen(() => showMyFeedbackDialog({}), false)\n }), [resolvedLabels, isAvailable, enabled, picker, knownSlices, capture, whileOpen, showFeedbackDialog, showSlicesDialog, showComponentDialog, showMyFeedbackDialog]);\n\n return (\n <NotesContext.Provider value={value}>\n {children}\n <FeedbackDialogWrapper />\n <SlicesDialogWrapper />\n <ComponentDialogWrapper />\n <MyFeedbackDialogWrapper />\n {picker.picker}\n </NotesContext.Provider>\n );\n};\n"],"names":["emptySnapshot","ApplicationContext","getSnapshot","dialogReferenceOf","dialog","sliceLocation","title","location","undefined","NotesProvider","enabled","labels","knownSlices","children","store","useApplicationContextStore","identity","useIdentity","availability","Availability","use","isAvailable","isNotesAvailable","isSet","data","isEnabled","resolvedLabels","useMemo","resolveLabels","busy","useRef","FeedbackDialogWrapper","showFeedbackDialog","useDialog","FeedbackDialog","SlicesDialogWrapper","showSlicesDialog","SlicesFeedbackDialog","ComponentDialogWrapper","showComponentDialog","ComponentFeedbackDialog","MyFeedbackDialogWrapper","showMyFeedbackDialog","MyFeedbackDialog","picker","useComponentPicker","resolve","resolveComponentContext","capture","useCallback","buildNoteContext","snapshot","route","window","pathname","correlationId","Guid","create","whileOpen","open","announceSent","current","result","DialogResult","Ok","toast","success","feedback","sent","value","isProvided","showsInDialogHeaders","isPicking","giveFeedback","context","giveFeedbackOnScreen","about","giveFeedbackOnSlices","pointAtSomething","start","then","picked","showMyFeedback","_jsxs","NotesContext","Provider","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAMA,aAAAA,GAAgB,IAAIC,4BAAAA,EAAAA,CAAqBC,WAAW,EAAA;AAE1D,MAAMC,iBAAAA,GAAoB,CAACC,MAAAA,GACvBA,MAAAA,EAAQC,aAAAA,GAAgB;AAAEC,QAAAA,KAAAA,EAAOF,OAAOE,KAAK;AAAEC,QAAAA,QAAAA,EAAUH,OAAOC;KAAc,GAAIG,SAAAA;AAEtF;;;;;AAKC,IACM,MAAMC,aAAAA,GAAgB,CAAC,EAAEC,OAAAA,GAAU,KAAK,EAAEC,MAAM,EAAEC,WAAAA,GAAc,EAAE,EAAEC,QAAQ,EAAsB,GAAA;AACrG,IAAA,MAAMC,KAAAA,GAAQC,oCAAAA,EAAAA;AACd,IAAA,MAAMC,UAAAA,GAAWC,oBAAAA,EAAAA;AACjB,IAAA,MAAM,CAACC,YAAAA,CAAa,GAAGC,6BAAAA,CAAaC,GAAG,EAAA;AACvC,IAAA,M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CAAAA;0BACDgD,cAAA,CAAC7C,uBAAAA,EAAAA,EAAAA,CAAAA;AACAG,YAAAA,MAAAA,CAAOA;;;AAGpB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Provider/index.ts"],"names":[],"mappings":"AAGA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notesVisibility.d.ts","sourceRoot":"","sources":["../../../Provider/notesVisibility.ts"],"names":[],"mappings":"AAUA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAE7F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Decides whether the Notes components render anything: only for a signed-in user, and only while Notes is switched
|
|
7
|
+
* on.
|
|
8
|
+
* @param isSignedIn Whether the user is signed in.
|
|
9
|
+
* @param isEnabled Whether Notes is switched on, as `NotesAvailability` tells; false until it is known.
|
|
10
|
+
* @returns True when the Notes components render.
|
|
11
|
+
*/ function isNotesAvailable(isSignedIn, isEnabled) {
|
|
12
|
+
return isSignedIn && isEnabled === true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.isNotesAvailable = isNotesAvailable;
|
|
16
|
+
//# sourceMappingURL=notesVisibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notesVisibility.js","sources":["../../../Provider/notesVisibility.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Decides whether the Notes components render anything: only for a signed-in user, and only while Notes is switched\n * on.\n * @param isSignedIn Whether the user is signed in.\n * @param isEnabled Whether Notes is switched on, as `NotesAvailability` tells; false until it is known.\n * @returns True when the Notes components render.\n */\nexport function isNotesAvailable(isSignedIn: boolean, isEnabled: boolean | undefined): boolean {\n return isSignedIn && isEnabled === true;\n}\n"],"names":["isNotesAvailable","isSignedIn","isEnabled"],"mappings":";;AAAA;AACA;AAEA;;;;;;AAMC,IACM,SAASA,gBAAAA,CAAiBC,UAAmB,EAAEC,SAA8B,EAAA;AAChF,IAAA,OAAOD,cAAcC,SAAAA,KAAc,IAAA;AACvC;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './Buttons/index.js';
|
|
2
|
+
export * from './Context/index.js';
|
|
3
|
+
export * from './Feedback/index.js';
|
|
4
|
+
export * from './Icons.js';
|
|
5
|
+
export * from './Labels/index.js';
|
|
6
|
+
export * from './MyFeedback/index.js';
|
|
7
|
+
export * from './Provider/index.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var menuItems = require('./Buttons/menuItems.js');
|
|
4
|
+
var NotesButton = require('./Buttons/NotesButton.js');
|
|
5
|
+
var notesDialogHeaderActions = require('./Buttons/notesDialogHeaderActions.js');
|
|
6
|
+
var componentContext = require('./Context/componentContext.js');
|
|
7
|
+
var formatLocation = require('./Context/formatLocation.js');
|
|
8
|
+
var noteContext = require('./Context/noteContext.js');
|
|
9
|
+
var ComponentFeedbackDialog = require('./Feedback/ComponentFeedbackDialog.js');
|
|
10
|
+
var ComponentModeSwitch = require('./Feedback/ComponentModeSwitch.js');
|
|
11
|
+
var ContextSummary = require('./Feedback/ContextSummary.js');
|
|
12
|
+
var FeedbackDialog = require('./Feedback/FeedbackDialog.js');
|
|
13
|
+
var kindOptions = require('./Feedback/kindOptions.js');
|
|
14
|
+
var KindAndText = require('./Feedback/KindAndText.js');
|
|
15
|
+
var propertySuggestions = require('./Feedback/propertySuggestions.js');
|
|
16
|
+
var SliceChooser = require('./Feedback/SliceChooser.js');
|
|
17
|
+
var SlicesFeedbackDialog = require('./Feedback/SlicesFeedbackDialog.js');
|
|
18
|
+
var sliceChoice = require('./Feedback/sliceChoice.js');
|
|
19
|
+
var Icons = require('./Icons.js');
|
|
20
|
+
var defaultNotesLabels = require('./Labels/defaultNotesLabels.js');
|
|
21
|
+
var format = require('./Labels/format.js');
|
|
22
|
+
var resolveLabels = require('./Labels/resolveLabels.js');
|
|
23
|
+
var MyFeedbackDialog = require('./MyFeedback/MyFeedbackDialog.js');
|
|
24
|
+
var MyFeedbackList = require('./MyFeedback/MyFeedbackList.js');
|
|
25
|
+
var noteStates = require('./MyFeedback/noteStates.js');
|
|
26
|
+
var NotesContext = require('./Provider/NotesContext.js');
|
|
27
|
+
var NotesProvider = require('./Provider/NotesProvider.js');
|
|
28
|
+
var notesVisibility = require('./Provider/notesVisibility.js');
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.menuItems = menuItems.menuItems;
|
|
33
|
+
exports.nextMenuIndex = menuItems.nextMenuIndex;
|
|
34
|
+
exports.NotesButton = NotesButton.NotesButton;
|
|
35
|
+
exports.notesDialogHeaderActions = notesDialogHeaderActions.notesDialogHeaderActions;
|
|
36
|
+
exports.showsFeedbackButton = notesDialogHeaderActions.showsFeedbackButton;
|
|
37
|
+
exports.resolveComponentContext = componentContext.resolveComponentContext;
|
|
38
|
+
exports.sliceContextKey = componentContext.sliceContextKey;
|
|
39
|
+
exports.sliceMarkedOn = componentContext.sliceMarkedOn;
|
|
40
|
+
exports.toNotePickedComponent = componentContext.toNotePickedComponent;
|
|
41
|
+
exports.formatLocation = formatLocation.formatLocation;
|
|
42
|
+
exports.buildNoteContext = noteContext.buildNoteContext;
|
|
43
|
+
exports.describeContext = noteContext.describeContext;
|
|
44
|
+
exports.describeScreen = noteContext.describeScreen;
|
|
45
|
+
exports.modelReferencesKey = noteContext.modelReferencesKey;
|
|
46
|
+
exports.modelReferencesOf = noteContext.modelReferencesOf;
|
|
47
|
+
exports.toSliceLocation = noteContext.toSliceLocation;
|
|
48
|
+
exports.ComponentFeedbackDialog = ComponentFeedbackDialog.ComponentFeedbackDialog;
|
|
49
|
+
exports.ComponentModeSwitch = ComponentModeSwitch.ComponentModeSwitch;
|
|
50
|
+
exports.ContextSummary = ContextSummary.ContextSummary;
|
|
51
|
+
exports.FeedbackDialog = FeedbackDialog.FeedbackDialog;
|
|
52
|
+
exports.defaultKind = kindOptions.defaultKind;
|
|
53
|
+
exports.kindOptions = kindOptions.kindOptions;
|
|
54
|
+
exports.KindAndText = KindAndText.KindAndText;
|
|
55
|
+
exports.propertySuggestions = propertySuggestions.propertySuggestions;
|
|
56
|
+
exports.propertyValueText = propertySuggestions.propertyValueText;
|
|
57
|
+
exports.SliceChooser = SliceChooser.SliceChooser;
|
|
58
|
+
exports.SlicesFeedbackDialog = SlicesFeedbackDialog.SlicesFeedbackDialog;
|
|
59
|
+
exports.distinctSlices = sliceChoice.distinctSlices;
|
|
60
|
+
exports.isChosen = sliceChoice.isChosen;
|
|
61
|
+
exports.searchSlices = sliceChoice.searchSlices;
|
|
62
|
+
exports.sliceKey = sliceChoice.sliceKey;
|
|
63
|
+
exports.toggleSlice = sliceChoice.toggleSlice;
|
|
64
|
+
exports.ChevronIcon = Icons.ChevronIcon;
|
|
65
|
+
exports.CloseIcon = Icons.CloseIcon;
|
|
66
|
+
exports.FeedbackIcon = Icons.FeedbackIcon;
|
|
67
|
+
exports.defaultNotesLabels = defaultNotesLabels.defaultNotesLabels;
|
|
68
|
+
exports.format = format.format;
|
|
69
|
+
exports.resolveLabels = resolveLabels.resolveLabels;
|
|
70
|
+
exports.MyFeedbackDialog = MyFeedbackDialog.MyFeedbackDialog;
|
|
71
|
+
exports.MyFeedbackList = MyFeedbackList.MyFeedbackList;
|
|
72
|
+
exports.canWithdraw = noteStates.canWithdraw;
|
|
73
|
+
exports.newestFirst = noteStates.newestFirst;
|
|
74
|
+
exports.noteText = noteStates.noteText;
|
|
75
|
+
exports.statusText = noteStates.statusText;
|
|
76
|
+
exports.targetText = noteStates.targetText;
|
|
77
|
+
exports.NotesContext = NotesContext.NotesContext;
|
|
78
|
+
exports.defaultNotesContextValue = NotesContext.defaultNotesContextValue;
|
|
79
|
+
exports.dialogLocationOf = NotesContext.dialogLocationOf;
|
|
80
|
+
exports.useNotes = NotesContext.useNotes;
|
|
81
|
+
exports.useNotesContext = NotesContext.useNotesContext;
|
|
82
|
+
exports.useNotesLabels = NotesContext.useNotesLabels;
|
|
83
|
+
exports.NotesProvider = NotesProvider.NotesProvider;
|
|
84
|
+
exports.isNotesAvailable = notesVisibility.isNotesAvailable;
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotesButton.d.ts","sourceRoot":"","sources":["../../../Buttons/NotesButton.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AASjE,MAAM,WAAW,gBAAgB;IAE7B,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAGzB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAG7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAOD,eAAO,MAAM,WAAW,GAAI,6BAAuC,gBAAgB,uCAuFlF,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { IconButton, Button } from '@cratis/components/Common';
|
|
3
|
+
import { useState, useRef, useId, useEffect } from 'react';
|
|
4
|
+
import { FeedbackIcon, ChevronIcon } from '../Icons.js';
|
|
5
|
+
import { useNotesContext } from '../Provider/NotesContext.js';
|
|
6
|
+
import { menuItems, nextMenuIndex } from './menuItems.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The feedback button, a split button. Its main action gives feedback on what the user is looking at; its drop-down offers
|
|
10
|
+
* feedback on specific slices, on this screen, on a component the user points at, and the user's own feedback. It
|
|
11
|
+
* renders nothing unless the user is signed in and Notes is switched on. Place it in any top bar.
|
|
12
|
+
*/ const NotesButton = ({ size = 'large', dialog, className })=>{
|
|
13
|
+
const notes = useNotesContext();
|
|
14
|
+
const { labels } = notes;
|
|
15
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
16
|
+
const root = useRef(null);
|
|
17
|
+
const menuId = useId();
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
if (!isOpen) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const dismiss = (event)=>{
|
|
23
|
+
if (!root.current?.contains(event.target)) {
|
|
24
|
+
setIsOpen(false);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
document.addEventListener('pointerdown', dismiss);
|
|
28
|
+
return ()=>document.removeEventListener('pointerdown', dismiss);
|
|
29
|
+
}, [
|
|
30
|
+
isOpen
|
|
31
|
+
]);
|
|
32
|
+
useEffect(()=>{
|
|
33
|
+
if (isOpen) {
|
|
34
|
+
root.current?.querySelector('[role="menuitem"]:not([disabled])')?.focus();
|
|
35
|
+
}
|
|
36
|
+
}, [
|
|
37
|
+
isOpen
|
|
38
|
+
]);
|
|
39
|
+
if (!notes.isAvailable) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const items = menuItems(labels, notes.isPicking);
|
|
43
|
+
const choose = (action)=>{
|
|
44
|
+
setIsOpen(false);
|
|
45
|
+
switch(action){
|
|
46
|
+
case 'slices':
|
|
47
|
+
return notes.giveFeedbackOnSlices(dialog);
|
|
48
|
+
case 'screen':
|
|
49
|
+
return notes.giveFeedbackOnScreen(dialog);
|
|
50
|
+
case 'component':
|
|
51
|
+
return notes.pointAtSomething(dialog);
|
|
52
|
+
default:
|
|
53
|
+
return notes.showMyFeedback();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const onMenuKeyDown = (event)=>{
|
|
57
|
+
if (event.key === 'Escape') {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
setIsOpen(false);
|
|
61
|
+
root.current?.querySelector('[data-notes-toggle]')?.focus();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const elements = Array.from(event.currentTarget.querySelectorAll('[role="menuitem"]'));
|
|
65
|
+
const next = nextMenuIndex(event.key, elements.indexOf(document.activeElement), elements.length);
|
|
66
|
+
if (next !== undefined) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
elements[next].focus();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
72
|
+
ref: root,
|
|
73
|
+
className: [
|
|
74
|
+
'notes-button',
|
|
75
|
+
className
|
|
76
|
+
].filter(Boolean).join(' '),
|
|
77
|
+
"data-size": size,
|
|
78
|
+
children: [
|
|
79
|
+
size === 'small' ? /*#__PURE__*/ jsx(IconButton, {
|
|
80
|
+
variant: "ghost",
|
|
81
|
+
icon: /*#__PURE__*/ jsx(FeedbackIcon, {}),
|
|
82
|
+
"aria-label": labels.button.giveFeedback,
|
|
83
|
+
tooltip: labels.button.giveFeedback,
|
|
84
|
+
onClick: ()=>notes.giveFeedback(dialog)
|
|
85
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
86
|
+
variant: "outline",
|
|
87
|
+
icon: /*#__PURE__*/ jsx(FeedbackIcon, {}),
|
|
88
|
+
label: labels.button.giveFeedback,
|
|
89
|
+
onClick: ()=>notes.giveFeedback(dialog)
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
92
|
+
variant: "ghost",
|
|
93
|
+
icon: /*#__PURE__*/ jsx(ChevronIcon, {}),
|
|
94
|
+
"aria-label": labels.button.moreOptions,
|
|
95
|
+
"aria-haspopup": "menu",
|
|
96
|
+
"aria-expanded": isOpen,
|
|
97
|
+
"aria-controls": isOpen ? menuId : undefined,
|
|
98
|
+
"data-notes-toggle": "",
|
|
99
|
+
onClick: ()=>setIsOpen((open)=>!open)
|
|
100
|
+
}),
|
|
101
|
+
isOpen && /*#__PURE__*/ jsx("ul", {
|
|
102
|
+
id: menuId,
|
|
103
|
+
className: "notes-button__menu",
|
|
104
|
+
role: "menu",
|
|
105
|
+
"aria-label": labels.button.moreOptions,
|
|
106
|
+
onKeyDown: onMenuKeyDown,
|
|
107
|
+
children: items.map((item)=>/*#__PURE__*/ jsx("li", {
|
|
108
|
+
role: "none",
|
|
109
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
110
|
+
type: "button",
|
|
111
|
+
role: "menuitem",
|
|
112
|
+
className: "notes-button__item",
|
|
113
|
+
disabled: item.disabled,
|
|
114
|
+
onClick: ()=>choose(item.action),
|
|
115
|
+
children: item.label
|
|
116
|
+
})
|
|
117
|
+
}, item.action))
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { NotesButton };
|
|
124
|
+
//# sourceMappingURL=NotesButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotesButton.js","sources":["../../../Buttons/NotesButton.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Button, IconButton } from '@cratis/components/Common';\nimport { DialogHeaderContext } from '@cratis/components/Dialogs';\nimport { KeyboardEvent, useEffect, useId, useRef, useState } from 'react';\nimport { ChevronIcon, FeedbackIcon } from '../Icons.js';\nimport { useNotesContext } from '../Provider/NotesContext.js';\nimport { menuItems, nextMenuIndex, NotesMenuAction } from './menuItems.js';\n\n/**\n * Props for {@link NotesButton}.\n */\nexport interface NotesButtonProps {\n /** `large` shows the icon and the text; `small` shows the icon, with the text as tooltip and accessible name. Defaults to `large`. */\n size?: 'large' | 'small';\n\n /** The dialog the button is in; the feedback is about the dialog and its slice when given. */\n dialog?: DialogHeaderContext;\n\n /** Additional class name for the button. */\n className?: string;\n}\n\n/**\n * The feedback button, a split button. Its main action gives feedback on what the user is looking at; its drop-down offers\n * feedback on specific slices, on this screen, on a component the user points at, and the user's own feedback. It\n * renders nothing unless the user is signed in and Notes is switched on. Place it in any top bar.\n */\nexport const NotesButton = ({ size = 'large', dialog, className }: NotesButtonProps) => {\n const notes = useNotesContext();\n const { labels } = notes;\n const [isOpen, setIsOpen] = useState(false);\n const root = useRef<HTMLSpanElement>(null);\n const menuId = useId();\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const dismiss = (event: PointerEvent) => {\n if (!root.current?.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('pointerdown', dismiss);\n return () => document.removeEventListener('pointerdown', dismiss);\n }, [isOpen]);\n\n useEffect(() => {\n if (isOpen) {\n root.current?.querySelector<HTMLElement>('[role=\"menuitem\"]:not([disabled])')?.focus();\n }\n }, [isOpen]);\n\n if (!notes.isAvailable) {\n return null;\n }\n\n const items = menuItems(labels, notes.isPicking);\n const choose = (action: NotesMenuAction) => {\n setIsOpen(false);\n switch (action) {\n case 'slices': return notes.giveFeedbackOnSlices(dialog);\n case 'screen': return notes.giveFeedbackOnScreen(dialog);\n case 'component': return notes.pointAtSomething(dialog);\n default: return notes.showMyFeedback();\n }\n };\n\n const onMenuKeyDown = (event: KeyboardEvent<HTMLUListElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n setIsOpen(false);\n root.current?.querySelector<HTMLElement>('[data-notes-toggle]')?.focus();\n return;\n }\n\n const elements = Array.from(event.currentTarget.querySelectorAll<HTMLElement>('[role=\"menuitem\"]'));\n const next = nextMenuIndex(event.key, elements.indexOf(document.activeElement as HTMLElement), elements.length);\n if (next !== undefined) {\n event.preventDefault();\n elements[next].focus();\n }\n };\n\n return (\n <span ref={root} className={['notes-button', className].filter(Boolean).join(' ')} data-size={size}>\n {size === 'small'\n ? <IconButton variant='ghost' icon={<FeedbackIcon />} aria-label={labels.button.giveFeedback} tooltip={labels.button.giveFeedback} onClick={() => notes.giveFeedback(dialog)} />\n : <Button variant='outline' icon={<FeedbackIcon />} label={labels.button.giveFeedback} onClick={() => notes.giveFeedback(dialog)} />}\n <IconButton\n variant='ghost'\n icon={<ChevronIcon />}\n aria-label={labels.button.moreOptions}\n aria-haspopup='menu'\n aria-expanded={isOpen}\n aria-controls={isOpen ? menuId : undefined}\n data-notes-toggle=''\n onClick={() => setIsOpen(open => !open)} />\n {isOpen && (\n <ul id={menuId} className='notes-button__menu' role='menu' aria-label={labels.button.moreOptions} onKeyDown={onMenuKeyDown}>\n {items.map(item => (\n <li key={item.action} role='none'>\n <button type='button' role='menuitem' className='notes-button__item' disabled={item.disabled} onClick={() => choose(item.action)}>\n {item.label}\n </button>\n </li>\n ))}\n </ul>\n )}\n </span>\n );\n};\n"],"names":["NotesButton","size","dialog","className","notes","useNotesContext","labels","isOpen","setIsOpen","useState","root","useRef","menuId","useId","useEffect","dismiss","event","current","contains","target","document","addEventListener","removeEventListener","querySelector","focus","isAvailable","items","menuItems","isPicking","choose","action","giveFeedbackOnSlices","giveFeedbackOnScreen","pointAtSomething","showMyFeedback","onMenuKeyDown","key","preventDefault","stopPropagation","elements","Array","from","currentTarget","querySelectorAll","next","nextMenuIndex","indexOf","activeElement","length","undefined","_jsxs","span","ref","filter","Boolean","join","data-size","_jsx","IconButton","variant","icon","FeedbackIcon","aria-label","button","giveFeedback","tooltip","onClick","Button","label","ChevronIcon","moreOptions","aria-haspopup","aria-expanded","aria-controls","data-notes-toggle","open","ul","id","role","onKeyDown","map","item","li","type","disabled"],"mappings":";;;;;;;AAwBA;;;;IAKO,MAAMA,WAAAA,GAAc,CAAC,EAAEC,IAAAA,GAAO,OAAO,EAAEC,MAAM,EAAEC,SAAS,EAAoB,GAAA;AAC/E,IAAA,MAAMC,KAAAA,GAAQC,eAAAA,EAAAA;IACd,MAAM,EAAEC,MAAM,EAAE,GAAGF,KAAAA;AACnB,IAAA,MAAM,CAACG,MAAAA,EAAQC,SAAAA,CAAU,GAAGC,QAAAA,CAAS,KAAA,CAAA;AACrC,IAAA,MAAMC,OAAOC,MAAAA,CAAwB,IAAA,CAAA;AACrC,IAAA,MAAMC,MAAAA,GAASC,KAAAA,EAAAA;IAEfC,SAAAA,CAAU,IAAA;AACN,QAAA,IAAI,CAACP,MAAAA,EAAQ;AACT,YAAA;AACJ,QAAA;AAEA,QAAA,MAAMQ,UAAU,CAACC,KAAAA,GAAAA;AACb,YAAA,IAAI,CAACN,IAAAA,CAAKO,OAAO,EAAEC,QAAAA,CAASF,KAAAA,CAAMG,MAAM,CAAA,EAAW;gBAC/CX,SAAAA,CAAU,KAAA,CAAA;AACd,YAAA;AACJ,QAAA,CAAA;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,IAAAA,CAAKb;;AAFLa,qBAAAA,EAAAA,IAAAA,CAAKnD,MAAM,CAAA;;;;AAU5C;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Buttons/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../Buttons/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NotesLabels } from '../Labels/index.js';
|
|
2
|
+
export type NotesMenuAction = 'slices' | 'screen' | 'component' | 'myFeedback';
|
|
3
|
+
export interface NotesMenuItem {
|
|
4
|
+
readonly action: NotesMenuAction;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly disabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function menuItems(labels: NotesLabels, isPicking: boolean): NotesMenuItem[];
|
|
9
|
+
export declare function nextMenuIndex(key: string, current: number, count: number): number | undefined;
|
|
10
|
+
//# sourceMappingURL=menuItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menuItems.d.ts","sourceRoot":"","sources":["../../../Buttons/menuItems.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAC;AAK/E,MAAM,WAAW,aAAa;IAE1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAGjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAGvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC9B;AAQD,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,GAAG,aAAa,EAAE,CAOlF;AASD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ7F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
* Gets the items of the drop-down: specific slices, this screen, pointing at a component, and the user's own feedback.
|
|
5
|
+
* @param labels The labels to show.
|
|
6
|
+
* @param isPicking Whether the user is pointing at a component already.
|
|
7
|
+
* @returns The {@link NotesMenuItem}s in the order they are shown.
|
|
8
|
+
*/ function menuItems(labels, isPicking) {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
action: 'slices',
|
|
12
|
+
label: labels.button.aboutSlices,
|
|
13
|
+
disabled: false
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
action: 'screen',
|
|
17
|
+
label: labels.button.aboutScreen,
|
|
18
|
+
disabled: false
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
action: 'component',
|
|
22
|
+
label: labels.button.pointAtSomething,
|
|
23
|
+
disabled: isPicking
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
action: 'myFeedback',
|
|
27
|
+
label: labels.button.myFeedback,
|
|
28
|
+
disabled: false
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets which item a key moves to in an open drop-down.
|
|
34
|
+
* @param key The key.
|
|
35
|
+
* @param current The index of the item that has focus; -1 when none has.
|
|
36
|
+
* @param count How many items there are.
|
|
37
|
+
* @returns The index to move focus to; undefined when the key does not move focus.
|
|
38
|
+
*/ function nextMenuIndex(key, current, count) {
|
|
39
|
+
switch(key){
|
|
40
|
+
case 'ArrowDown':
|
|
41
|
+
return (current + 1) % count;
|
|
42
|
+
case 'ArrowUp':
|
|
43
|
+
return current <= 0 ? count - 1 : current - 1;
|
|
44
|
+
case 'Home':
|
|
45
|
+
return 0;
|
|
46
|
+
case 'End':
|
|
47
|
+
return count - 1;
|
|
48
|
+
default:
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { menuItems, nextMenuIndex };
|
|
54
|
+
//# sourceMappingURL=menuItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menuItems.js","sources":["../../../Buttons/menuItems.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { NotesLabels } from '../Labels/index.js';\n\n/**\n * What a drop-down item of the feedback button does.\n */\nexport type NotesMenuAction = 'slices' | 'screen' | 'component' | 'myFeedback';\n\n/**\n * One item of the drop-down of the feedback button.\n */\nexport interface NotesMenuItem {\n /** What the item does. */\n readonly action: NotesMenuAction;\n\n /** The text. */\n readonly label: string;\n\n /** Whether the item is switched off, such as pointing at something while the user is already pointing. */\n readonly disabled: boolean;\n}\n\n/**\n * Gets the items of the drop-down: specific slices, this screen, pointing at a component, and the user's own feedback.\n * @param labels The labels to show.\n * @param isPicking Whether the user is pointing at a component already.\n * @returns The {@link NotesMenuItem}s in the order they are shown.\n */\nexport function menuItems(labels: NotesLabels, isPicking: boolean): NotesMenuItem[] {\n return [\n { action: 'slices', label: labels.button.aboutSlices, disabled: false },\n { action: 'screen', label: labels.button.aboutScreen, disabled: false },\n { action: 'component', label: labels.button.pointAtSomething, disabled: isPicking },\n { action: 'myFeedback', label: labels.button.myFeedback, disabled: false }\n ];\n}\n\n/**\n * Gets which item a key moves to in an open drop-down.\n * @param key The key.\n * @param current The index of the item that has focus; -1 when none has.\n * @param count How many items there are.\n * @returns The index to move focus to; undefined when the key does not move focus.\n */\nexport function nextMenuIndex(key: string, current: number, count: number): number | undefined {\n switch (key) {\n case 'ArrowDown': return (current + 1) % count;\n case 'ArrowUp': return current <= 0 ? count - 1 : current - 1;\n case 'Home': return 0;\n case 'End': return count - 1;\n default: return undefined;\n }\n}\n"],"names":["menuItems","labels","isPicking","action","label","button","aboutSlices","disabled","aboutScreen","pointAtSomething","myFeedback","nextMenuIndex","key","current","count","undefined"],"mappings":"AAAA;AACA;AAuBA;;;;;AAKC,IACM,SAASA,SAAAA,CAAUC,MAAmB,EAAEC,SAAkB,EAAA;IAC7D,OAAO;AACH,QAAA;YAAEC,MAAAA,EAAQ,QAAA;YAAUC,KAAAA,EAAOH,MAAAA,CAAOI,MAAM,CAACC,WAAW;YAAEC,QAAAA,EAAU;AAAM,SAAA;AACtE,QAAA;YAAEJ,MAAAA,EAAQ,QAAA;YAAUC,KAAAA,EAAOH,MAAAA,CAAOI,MAAM,CAACG,WAAW;YAAED,QAAAA,EAAU;AAAM,SAAA;AACtE,QAAA;YAAEJ,MAAAA,EAAQ,WAAA;YAAaC,KAAAA,EAAOH,MAAAA,CAAOI,MAAM,CAACI,gBAAgB;YAAEF,QAAAA,EAAUL;AAAU,SAAA;AAClF,QAAA;YAAEC,MAAAA,EAAQ,YAAA;YAAcC,KAAAA,EAAOH,MAAAA,CAAOI,MAAM,CAACK,UAAU;YAAEH,QAAAA,EAAU;AAAM;AAC5E,KAAA;AACL;AAEA;;;;;;AAMC,IACM,SAASI,aAAAA,CAAcC,GAAW,EAAEC,OAAe,EAAEC,KAAa,EAAA;IACrE,OAAQF,GAAAA;QACJ,KAAK,WAAA;AAAa,YAAA,OAAO,CAACC,OAAAA,GAAU,CAAA,IAAKC,KAAAA;QACzC,KAAK,SAAA;AAAW,YAAA,OAAOD,OAAAA,IAAW,CAAA,GAAIC,KAAAA,GAAQ,CAAA,GAAID,OAAAA,GAAU,CAAA;QAC5D,KAAK,MAAA;YAAQ,OAAO,CAAA;QACpB,KAAK,KAAA;AAAO,YAAA,OAAOC,KAAAA,GAAQ,CAAA;AAC3B,QAAA;YAAS,OAAOC,SAAAA;AACpB;AACJ;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DialogHeaderActionsRenderer, DialogHeaderContext } from '@cratis/components/Dialogs';
|
|
2
|
+
export declare function showsFeedbackButton(dialog: DialogHeaderContext, enabled: boolean): boolean;
|
|
3
|
+
export declare const notesDialogHeaderActions: DialogHeaderActionsRenderer;
|
|
4
|
+
//# sourceMappingURL=notesDialogHeaderActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notesDialogHeaderActions.d.ts","sourceRoot":"","sources":["../../../Buttons/notesDialogHeaderActions.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAW9F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAG1F;AAeD,eAAO,MAAM,wBAAwB,EAAE,2BAAmF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useNotesContext } from '../Provider/NotesContext.js';
|
|
3
|
+
import { NotesButton } from './NotesButton.js';
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/**
|
|
8
|
+
* Decides whether a dialog gets the feedback button in its header: only a dialog that has a slice location, and only when
|
|
9
|
+
* `<NotesProvider enabled>` turned it on.
|
|
10
|
+
* @param dialog The dialog.
|
|
11
|
+
* @param enabled Whether the provider turned the header button on.
|
|
12
|
+
* @returns True when the dialog shows the button.
|
|
13
|
+
*/ function showsFeedbackButton(dialog, enabled) {
|
|
14
|
+
const location = dialog.sliceLocation;
|
|
15
|
+
return enabled && location !== undefined && (!!location.module || !!location.feature || !!location.slice);
|
|
16
|
+
}
|
|
17
|
+
const NotesDialogHeaderButton = ({ dialog })=>{
|
|
18
|
+
const { showsInDialogHeaders } = useNotesContext();
|
|
19
|
+
return showsFeedbackButton(dialog, showsInDialogHeaders) ? /*#__PURE__*/ jsx(NotesButton, {
|
|
20
|
+
size: "small",
|
|
21
|
+
dialog: dialog
|
|
22
|
+
}) : null;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The renderer to pass to `CratisComponentsProvider` as `dialogHeaderActions`: it puts the feedback button in the header of
|
|
26
|
+
* every dialog that belongs to a slice. The context it captures is the dialog's location.
|
|
27
|
+
* @param dialog What the dialog tells about itself.
|
|
28
|
+
* @returns The button, or nothing for a dialog without a slice.
|
|
29
|
+
*/ const notesDialogHeaderActions = (dialog)=>/*#__PURE__*/ jsx(NotesDialogHeaderButton, {
|
|
30
|
+
dialog: dialog
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { notesDialogHeaderActions, showsFeedbackButton };
|
|
34
|
+
//# sourceMappingURL=notesDialogHeaderActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notesDialogHeaderActions.js","sources":["../../../Buttons/notesDialogHeaderActions.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogHeaderActionsRenderer, DialogHeaderContext } from '@cratis/components/Dialogs';\nimport { useNotesContext } from '../Provider/NotesContext.js';\nimport { NotesButton } from './NotesButton.js';\n\n/**\n * Decides whether a dialog gets the feedback button in its header: only a dialog that has a slice location, and only when\n * `<NotesProvider enabled>` turned it on.\n * @param dialog The dialog.\n * @param enabled Whether the provider turned the header button on.\n * @returns True when the dialog shows the button.\n */\nexport function showsFeedbackButton(dialog: DialogHeaderContext, enabled: boolean): boolean {\n const location = dialog.sliceLocation;\n return enabled && location !== undefined && (!!location.module || !!location.feature || !!location.slice);\n}\n\nconst NotesDialogHeaderButton = ({ dialog }: { dialog: DialogHeaderContext }) => {\n const { showsInDialogHeaders } = useNotesContext();\n return showsFeedbackButton(dialog, showsInDialogHeaders)\n ? <NotesButton size='small' dialog={dialog} />\n : null;\n};\n\n/**\n * The renderer to pass to `CratisComponentsProvider` as `dialogHeaderActions`: it puts the feedback button in the header of\n * every dialog that belongs to a slice. The context it captures is the dialog's location.\n * @param dialog What the dialog tells about itself.\n * @returns The button, or nothing for a dialog without a slice.\n */\nexport const notesDialogHeaderActions: DialogHeaderActionsRenderer = dialog => <NotesDialogHeaderButton dialog={dialog} />;\n"],"names":["showsFeedbackButton","dialog","enabled","location","sliceLocation","undefined","module","feature","slice","NotesDialogHeaderButton","showsInDialogHeaders","useNotesContext","_jsx","NotesButton","size","notesDialogHeaderActions"],"mappings":";;;;AAAA;AACA;AAMA;;;;;;AAMC,IACM,SAASA,mBAAAA,CAAoBC,MAA2B,EAAEC,OAAgB,EAAA;IAC7E,MAAMC,QAAAA,GAAWF,OAAOG,aAAa;AACrC,IAAA,OAAOF,WAAWC,QAAAA,KAAaE,SAAAA,KAAc,CAAC,CAACF,SAASG,MAAM,IAAI,CAAC,CAACH,SAASI,OAAO,IAAI,CAAC,CAACJ,QAAAA,CAASK,KAAK,CAAD;AAC3G;AAEA,MAAMC,uBAAAA,GAA0B,CAAC,EAAER,MAAM,EAAmC,GAAA;IACxE,MAAM,EAAES,oBAAoB,EAAE,GAAGC,eAAAA,EAAAA;IACjC,OAAOX,mBAAAA,CAAoBC,MAAAA,EAAQS,oBAAAA,CAAAA,iBAC7BE,GAAA,CAACC,WAAAA,EAAAA;QAAYC,IAAAA,EAAK,OAAA;QAAQb,MAAAA,EAAQA;AAClC,KAAA,CAAA,GAAA,IAAA;AACV,CAAA;AAEA;;;;;AAKC,IACM,MAAMc,wBAAAA,GAAwDd,CAAAA,uBAAUW,GAAA,CAACH,uBAAAA,EAAAA;QAAwBR,MAAAA,EAAQA;AAAW,KAAA;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PickedComponent as PickedByUser } from '@cratis/components/ComponentPicker';
|
|
2
|
+
import { PickedComponent } from '@cratis/showrunner.notes';
|
|
3
|
+
import { LocationParts } from './formatLocation.js';
|
|
4
|
+
export declare const sliceContextKey = "slice";
|
|
5
|
+
export declare function sliceMarkedOn(element: Element): LocationParts | undefined;
|
|
6
|
+
export declare function resolveComponentContext(element: Element): Record<string, unknown> | undefined;
|
|
7
|
+
export declare function toNotePickedComponent(picked: PickedByUser, focused: LocationParts): PickedComponent;
|
|
8
|
+
//# sourceMappingURL=componentContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentContext.d.ts","sourceRoot":"","sources":["../../../Context/componentContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,IAAI,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,eAAO,MAAM,eAAe,UAAU,CAAC;AAOvC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAWzE;AAOD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAG7F;AAQD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,GAAG,eAAe,CASnG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PickedComponent } from '@cratis/showrunner.notes';
|
|
2
|
+
import { toSliceLocation } from './noteContext.js';
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
/**
|
|
7
|
+
* The key of what the picker's resolver adds to a picked component: the slice its element belongs to.
|
|
8
|
+
*/ const sliceContextKey = 'slice';
|
|
9
|
+
/**
|
|
10
|
+
* Reads the slice location Arc marks an element with, when `<Arc sliceMarkers>` is on.
|
|
11
|
+
* @param element The element.
|
|
12
|
+
* @returns The location of the closest slice marker; undefined when there is none.
|
|
13
|
+
*/ function sliceMarkedOn(element) {
|
|
14
|
+
const marker = element.closest('[data-cratis-module]');
|
|
15
|
+
if (!marker) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
module: marker.getAttribute('data-cratis-module') ?? '',
|
|
20
|
+
feature: marker.getAttribute('data-cratis-feature') ?? '',
|
|
21
|
+
slice: marker.getAttribute('data-cratis-slice') ?? ''
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The picker's `resolve`: tells the slice of a picked component from the closest Arc slice marker.
|
|
26
|
+
* @param element The root element of the picked component.
|
|
27
|
+
* @returns The context to add to the picked component; undefined when the element is in no marked slice.
|
|
28
|
+
*/ function resolveComponentContext(element) {
|
|
29
|
+
const slice = sliceMarkedOn(element);
|
|
30
|
+
return slice ? {
|
|
31
|
+
[sliceContextKey]: slice
|
|
32
|
+
} : undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Makes the component a note carries from what the picker found.
|
|
36
|
+
* @param picked What the picker found.
|
|
37
|
+
* @param focused The focused location, used when the component's slice is not known.
|
|
38
|
+
* @returns The {@link PickedComponent}.
|
|
39
|
+
*/ function toNotePickedComponent(picked, focused) {
|
|
40
|
+
const slice = picked.context[sliceContextKey];
|
|
41
|
+
return Object.assign(new PickedComponent(), {
|
|
42
|
+
componentName: picked.component,
|
|
43
|
+
componentId: picked.id ?? '',
|
|
44
|
+
part: picked.part ?? '',
|
|
45
|
+
ancestors: picked.ancestors.map((ancestor)=>ancestor.component),
|
|
46
|
+
location: toSliceLocation(slice ?? focused)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { resolveComponentContext, sliceContextKey, sliceMarkedOn, toNotePickedComponent };
|
|
51
|
+
//# sourceMappingURL=componentContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentContext.js","sources":["../../../Context/componentContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PickedComponent as PickedByUser } from '@cratis/components/ComponentPicker';\nimport { PickedComponent } from '@cratis/showrunner.notes';\nimport { LocationParts } from './formatLocation.js';\nimport { toSliceLocation } from './noteContext.js';\n\n/**\n * The key of what the picker's resolver adds to a picked component: the slice its element belongs to.\n */\nexport const sliceContextKey = 'slice';\n\n/**\n * Reads the slice location Arc marks an element with, when `<Arc sliceMarkers>` is on.\n * @param element The element.\n * @returns The location of the closest slice marker; undefined when there is none.\n */\nexport function sliceMarkedOn(element: Element): LocationParts | undefined {\n const marker = element.closest('[data-cratis-module]');\n if (!marker) {\n return undefined;\n }\n\n return {\n module: marker.getAttribute('data-cratis-module') ?? '',\n feature: marker.getAttribute('data-cratis-feature') ?? '',\n slice: marker.getAttribute('data-cratis-slice') ?? ''\n };\n}\n\n/**\n * The picker's `resolve`: tells the slice of a picked component from the closest Arc slice marker.\n * @param element The root element of the picked component.\n * @returns The context to add to the picked component; undefined when the element is in no marked slice.\n */\nexport function resolveComponentContext(element: Element): Record<string, unknown> | undefined {\n const slice = sliceMarkedOn(element);\n return slice ? { [sliceContextKey]: slice } : undefined;\n}\n\n/**\n * Makes the component a note carries from what the picker found.\n * @param picked What the picker found.\n * @param focused The focused location, used when the component's slice is not known.\n * @returns The {@link PickedComponent}.\n */\nexport function toNotePickedComponent(picked: PickedByUser, focused: LocationParts): PickedComponent {\n const slice = picked.context[sliceContextKey] as LocationParts | undefined;\n return Object.assign(new PickedComponent(), {\n componentName: picked.component,\n componentId: picked.id ?? '',\n part: picked.part ?? '',\n ancestors: picked.ancestors.map(ancestor => ancestor.component),\n location: toSliceLocation(slice ?? focused)\n });\n}\n"],"names":["sliceContextKey","sliceMarkedOn","element","marker","closest","undefined","module","getAttribute","feature","slice","resolveComponentContext","toNotePickedComponent","picked","focused","context","Object","assign","PickedComponent","componentName","component","componentId","id","part","ancestors","map","ancestor","location","toSliceLocation"],"mappings":";;;AAAA;AACA;AAOA;;IAGO,MAAMA,eAAAA,GAAkB;AAE/B;;;;IAKO,SAASC,aAAAA,CAAcC,OAAgB,EAAA;IAC1C,MAAMC,MAAAA,GAASD,OAAAA,CAAQE,OAAO,CAAC,sBAAA,CAAA;AAC/B,IAAA,IAAI,CAACD,MAAAA,EAAQ;QACT,OAAOE,SAAAA;AACX,IAAA;IAEA,OAAO;QACHC,MAAAA,EAAQH,MAAAA,CAAOI,YAAY,CAAC,oBAAA,CAAA,IAAyB,EAAA;QACrDC,OAAAA,EAASL,MAAAA,CAAOI,YAAY,CAAC,qBAAA,CAAA,IAA0B,EAAA;QACvDE,KAAAA,EAAON,MAAAA,CAAOI,YAAY,CAAC,mBAAA,CAAA,IAAwB;AACvD,KAAA;AACJ;AAEA;;;;IAKO,SAASG,uBAAAA,CAAwBR,OAAgB,EAAA;AACpD,IAAA,MAAMO,QAAQR,aAAAA,CAAcC,OAAAA,CAAAA;AAC5B,IAAA,OAAOO,KAAAA,GAAQ;AAAE,QAAA,CAACT,kBAAkBS;KAAM,GAAIJ,SAAAA;AAClD;AAEA;;;;;AAKC,IACM,SAASM,qBAAAA,CAAsBC,MAAoB,EAAEC,OAAsB,EAAA;AAC9E,IAAA,MAAMJ,KAAAA,GAAQG,MAAAA,CAAOE,OAAO,CAACd,eAAAA,CAAgB;AAC7C,IAAA,OAAOe,MAAAA,CAAOC,MAAM,CAAC,IAAIC,eAAAA,EAAAA,EAAmB;AACxCC,QAAAA,aAAAA,EAAeN,OAAOO,SAAS;QAC/BC,WAAAA,EAAaR,MAAAA,CAAOS,EAAE,IAAI,EAAA;QAC1BC,IAAAA,EAAMV,MAAAA,CAAOU,IAAI,IAAI,EAAA;QACrBC,SAAAA,EAAWX,MAAAA,CAAOW,SAAS,CAACC,GAAG,CAACC,CAAAA,QAAAA,GAAYA,SAASN,SAAS,CAAA;AAC9DO,QAAAA,QAAAA,EAAUC,gBAAgBlB,KAAAA,IAASI,OAAAA;AACvC,KAAA,CAAA;AACJ;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface LocationParts {
|
|
2
|
+
readonly module: string;
|
|
3
|
+
readonly feature: string;
|
|
4
|
+
readonly slice: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function formatLocation(location: LocationParts | undefined, separator: string, unknown: string): string;
|
|
7
|
+
//# sourceMappingURL=formatLocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatLocation.d.ts","sourceRoot":"","sources":["../../../Context/formatLocation.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,aAAa;IAE1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;AASD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAI9G"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
* The parts of where in the application something is.
|
|
5
|
+
*/ /**
|
|
6
|
+
* Formats a location for people, such as `Orders › Editing › Change order`.
|
|
7
|
+
* @param location The location; parts that are empty are left out.
|
|
8
|
+
* @param separator What separates the parts.
|
|
9
|
+
* @param unknown What to show when no part is known.
|
|
10
|
+
* @returns The formatted location.
|
|
11
|
+
*/ function formatLocation(location, separator, unknown) {
|
|
12
|
+
const parts = [
|
|
13
|
+
location?.module,
|
|
14
|
+
location?.feature,
|
|
15
|
+
location?.slice
|
|
16
|
+
].filter((part)=>typeof part === 'string' && part.length > 0);
|
|
17
|
+
return parts.length > 0 ? parts.join(separator) : unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { formatLocation };
|
|
21
|
+
//# sourceMappingURL=formatLocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatLocation.js","sources":["../../../Context/formatLocation.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * The parts of where in the application something is.\n */\nexport interface LocationParts {\n /** The module. */\n readonly module: string;\n /** The feature within the module. */\n readonly feature: string;\n /** The slice within the feature. */\n readonly slice: string;\n}\n\n/**\n * Formats a location for people, such as `Orders › Editing › Change order`.\n * @param location The location; parts that are empty are left out.\n * @param separator What separates the parts.\n * @param unknown What to show when no part is known.\n * @returns The formatted location.\n */\nexport function formatLocation(location: LocationParts | undefined, separator: string, unknown: string): string {\n const parts = [location?.module, location?.feature, location?.slice]\n .filter((part): part is string => typeof part === 'string' && part.length > 0);\n return parts.length > 0 ? parts.join(separator) : unknown;\n}\n"],"names":["formatLocation","location","separator","unknown","parts","module","feature","slice","filter","part","length","join"],"mappings":"AAAA;AACA;AAEA;;;;;;;;AAkBC,IACM,SAASA,cAAAA,CAAeC,QAAmC,EAAEC,SAAiB,EAAEC,OAAe,EAAA;AAClG,IAAA,MAAMC,KAAAA,GAAQ;QAACH,QAAAA,EAAUI,MAAAA;QAAQJ,QAAAA,EAAUK,OAAAA;QAASL,QAAAA,EAAUM;KAAM,CAC/DC,MAAM,CAAC,CAACC,IAAAA,GAAyB,OAAOA,IAAAA,KAAS,QAAA,IAAYA,IAAAA,CAAKC,MAAM,GAAG,CAAA,CAAA;AAChF,IAAA,OAAON,MAAMM,MAAM,GAAG,IAAIN,KAAAA,CAAMO,IAAI,CAACT,SAAAA,CAAAA,GAAaC,OAAAA;AACtD;;"}
|