@cratis/components 4.38.2 → 4.39.1
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/compat-manifest.json +11 -11
- package/dist/esm/Chat/ChatSidebar.d.ts.map +1 -1
- package/dist/esm/Chat/ChatSidebar.js +2 -2
- package/dist/esm/Chat/ChatSidebar.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts +1 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +5 -2
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandStepperContent.js +1 -1
- package/dist/esm/CommandDialog/CommandStepperContent.js.map +1 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.d.ts +7 -0
- package/dist/esm/CommandDialog/StepperCommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.js +4 -4
- package/dist/esm/CommandDialog/StepperCommandDialog.js.map +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.js +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.js +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ColorPickerField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ColorPickerField.js +1 -1
- package/dist/esm/CommandForm/fields/ColorPickerField.js.map +1 -1
- package/dist/esm/CommandForm/fields/NumberField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/NumberField.js +1 -1
- package/dist/esm/CommandForm/fields/NumberField.js.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordField.js +1 -1
- package/dist/esm/CommandForm/fields/PasswordField.js.map +1 -1
- package/dist/esm/CommandForm/fields/RadioButtonField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/RadioButtonField.js +1 -1
- package/dist/esm/CommandForm/fields/RadioButtonField.js.map +1 -1
- package/dist/esm/CommandForm/fields/RadioGroupField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/RadioGroupField.js +1 -1
- package/dist/esm/CommandForm/fields/RadioGroupField.js.map +1 -1
- package/dist/esm/CommandForm/fields/RatingField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/RatingField.js +1 -1
- package/dist/esm/CommandForm/fields/RatingField.js.map +1 -1
- package/dist/esm/CommandForm/fields/SliderField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/SliderField.js +1 -1
- package/dist/esm/CommandForm/fields/SliderField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ToggleSwitchField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ToggleSwitchField.js +1 -1
- package/dist/esm/CommandForm/fields/ToggleSwitchField.js.map +1 -1
- package/dist/esm/Common/ActionMenubar.d.ts.map +1 -1
- package/dist/esm/Common/ActionMenubar.js +1 -1
- package/dist/esm/Common/ActionMenubar.js.map +1 -1
- package/dist/esm/Common/Breadcrumbs.d.ts.map +1 -1
- package/dist/esm/Common/Breadcrumbs.js +1 -1
- package/dist/esm/Common/Breadcrumbs.js.map +1 -1
- package/dist/esm/Common/Button.d.ts.map +1 -1
- package/dist/esm/Common/Button.js +4 -1
- package/dist/esm/Common/Button.js.map +1 -1
- package/dist/esm/Common/CheckboxImplementation.d.ts.map +1 -1
- package/dist/esm/Common/CheckboxImplementation.js +1 -1
- package/dist/esm/Common/CheckboxImplementation.js.map +1 -1
- package/dist/esm/Common/ComboBox.js +1 -1
- package/dist/esm/Common/ComboBox.js.map +1 -1
- package/dist/esm/Common/CratisComponentsProvider.d.ts +14 -1
- package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
- package/dist/esm/Common/CratisComponentsProvider.js +6 -2
- package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
- package/dist/esm/Common/DatePickerInputImplementation.d.ts.map +1 -1
- package/dist/esm/Common/DatePickerInputImplementation.js +1 -1
- package/dist/esm/Common/DatePickerInputImplementation.js.map +1 -1
- package/dist/esm/Common/FormElement.js +1 -1
- package/dist/esm/Common/FormElement.js.map +1 -1
- package/dist/esm/Common/IconButton.d.ts.map +1 -1
- package/dist/esm/Common/IconButton.js +4 -1
- package/dist/esm/Common/IconButton.js.map +1 -1
- package/dist/esm/Common/NumberInput.d.ts.map +1 -1
- package/dist/esm/Common/NumberInput.js +1 -1
- package/dist/esm/Common/NumberInput.js.map +1 -1
- package/dist/esm/Common/Page.d.ts +1 -1
- package/dist/esm/Common/Page.d.ts.map +1 -1
- package/dist/esm/Common/Page.js +11 -2
- package/dist/esm/Common/Page.js.map +1 -1
- package/dist/esm/Common/RadioImplementation.d.ts.map +1 -1
- package/dist/esm/Common/RadioImplementation.js +1 -1
- package/dist/esm/Common/RadioImplementation.js.map +1 -1
- package/dist/esm/Common/SurfaceImplementation.d.ts.map +1 -1
- package/dist/esm/Common/SurfaceImplementation.js +1 -1
- package/dist/esm/Common/SurfaceImplementation.js.map +1 -1
- package/dist/esm/Common/SwitchImplementation.d.ts.map +1 -1
- package/dist/esm/Common/SwitchImplementation.js +1 -1
- package/dist/esm/Common/SwitchImplementation.js.map +1 -1
- package/dist/esm/Common/Tabs.d.ts.map +1 -1
- package/dist/esm/Common/Tabs.js +1 -1
- package/dist/esm/Common/Tabs.js.map +1 -1
- package/dist/esm/Common/TagGroup.d.ts.map +1 -1
- package/dist/esm/Common/TagGroup.js +1 -1
- package/dist/esm/Common/TagGroup.js.map +1 -1
- package/dist/esm/Common/TextArea.d.ts.map +1 -1
- package/dist/esm/Common/TextArea.js +4 -1
- package/dist/esm/Common/TextArea.js.map +1 -1
- package/dist/esm/Common/TextInput.d.ts.map +1 -1
- package/dist/esm/Common/TextInput.js +4 -1
- package/dist/esm/Common/TextInput.js.map +1 -1
- package/dist/esm/Common/ToggleGroup.d.ts.map +1 -1
- package/dist/esm/Common/ToggleGroup.js +1 -1
- package/dist/esm/Common/ToggleGroup.js.map +1 -1
- package/dist/esm/Common/buttonDescriptor.d.ts +7 -0
- package/dist/esm/Common/buttonDescriptor.d.ts.map +1 -0
- package/dist/esm/Common/buttonDescriptor.js +28 -0
- package/dist/esm/Common/buttonDescriptor.js.map +1 -0
- package/dist/esm/Common/textFieldDescriptors.d.ts +7 -0
- package/dist/esm/Common/textFieldDescriptors.d.ts.map +1 -0
- package/dist/esm/Common/textFieldDescriptors.js +25 -0
- package/dist/esm/Common/textFieldDescriptors.js.map +1 -0
- package/dist/esm/ComponentPicker/ComponentHighlight.d.ts +14 -0
- package/dist/esm/ComponentPicker/ComponentHighlight.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/ComponentHighlight.js +12 -0
- package/dist/esm/ComponentPicker/ComponentHighlight.js.map +1 -0
- package/dist/esm/ComponentPicker/ComponentPicker.d.ts +24 -0
- package/dist/esm/ComponentPicker/ComponentPicker.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/ComponentPicker.js +116 -0
- package/dist/esm/ComponentPicker/ComponentPicker.js.map +1 -0
- package/dist/esm/ComponentPicker/ComponentResolver.d.ts +6 -0
- package/dist/esm/ComponentPicker/ComponentResolver.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/ComponentResolver.js +4 -0
- package/dist/esm/ComponentPicker/ComponentResolver.js.map +1 -0
- package/dist/esm/ComponentPicker/HighlightFrame.d.ts +14 -0
- package/dist/esm/ComponentPicker/HighlightFrame.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/HighlightFrame.js +70 -0
- package/dist/esm/ComponentPicker/HighlightFrame.js.map +1 -0
- package/dist/esm/ComponentPicker/PickedAncestor.d.ts +10 -0
- package/dist/esm/ComponentPicker/PickedAncestor.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/PickedAncestor.js +4 -0
- package/dist/esm/ComponentPicker/PickedAncestor.js.map +1 -0
- package/dist/esm/ComponentPicker/PickedComponent.d.ts +23 -0
- package/dist/esm/ComponentPicker/PickedComponent.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/PickedComponent.js +4 -0
- package/dist/esm/ComponentPicker/PickedComponent.js.map +1 -0
- package/dist/esm/ComponentPicker/PickedPresentationProperty.d.ts +22 -0
- package/dist/esm/ComponentPicker/PickedPresentationProperty.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/PickedPresentationProperty.js +4 -0
- package/dist/esm/ComponentPicker/PickedPresentationProperty.js.map +1 -0
- package/dist/esm/ComponentPicker/PickedRect.d.ts +20 -0
- package/dist/esm/ComponentPicker/PickedRect.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/PickedRect.js +4 -0
- package/dist/esm/ComponentPicker/PickedRect.js.map +1 -0
- package/dist/esm/ComponentPicker/PresentationPropertyEditor.d.ts +25 -0
- package/dist/esm/ComponentPicker/PresentationPropertyEditor.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/PresentationPropertyEditor.js +51 -0
- package/dist/esm/ComponentPicker/PresentationPropertyEditor.js.map +1 -0
- package/dist/esm/ComponentPicker/componentElements.d.ts +14 -0
- package/dist/esm/ComponentPicker/componentElements.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/componentElements.js +18 -0
- package/dist/esm/ComponentPicker/componentElements.js.map +1 -0
- package/dist/esm/ComponentPicker/describeComponentElement.d.ts +11 -0
- package/dist/esm/ComponentPicker/describeComponentElement.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/describeComponentElement.js +63 -0
- package/dist/esm/ComponentPicker/describeComponentElement.js.map +1 -0
- package/dist/esm/ComponentPicker/index.d.ts +24 -0
- package/dist/esm/ComponentPicker/index.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/index.js +12 -0
- package/dist/esm/ComponentPicker/index.js.map +1 -0
- package/dist/esm/ComponentPicker/pickerStacking.d.ts +3 -0
- package/dist/esm/ComponentPicker/pickerStacking.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/pickerStacking.js +10 -0
- package/dist/esm/ComponentPicker/pickerStacking.js.map +1 -0
- package/dist/esm/ComponentPicker/proposedChanges.d.ts +11 -0
- package/dist/esm/ComponentPicker/proposedChanges.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/proposedChanges.js +6 -0
- package/dist/esm/ComponentPicker/proposedChanges.js.map +1 -0
- package/dist/esm/ComponentPicker/useComponentPicker.d.ts +30 -0
- package/dist/esm/ComponentPicker/useComponentPicker.d.ts.map +1 -0
- package/dist/esm/ComponentPicker/useComponentPicker.js +31 -0
- package/dist/esm/ComponentPicker/useComponentPicker.js.map +1 -0
- package/dist/esm/ConfigurationEditor/OrderedItemEditor.d.ts.map +1 -1
- package/dist/esm/ConfigurationEditor/OrderedItemEditor.js +1 -1
- package/dist/esm/ConfigurationEditor/OrderedItemEditor.js.map +1 -1
- package/dist/esm/ConfigurationEditor/PropertyControls.d.ts.map +1 -1
- package/dist/esm/ConfigurationEditor/PropertyControls.js +1 -1
- package/dist/esm/ConfigurationEditor/PropertyControls.js.map +1 -1
- package/dist/esm/DataPage/DataPage.js +1 -1
- package/dist/esm/DataPage/DataPage.js.map +1 -1
- package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableCore.js +1 -1
- package/dist/esm/DataTables/DataTableCore.js.map +1 -1
- package/dist/esm/DataTables/DataTableHeaderCell.d.ts +2 -2
- package/dist/esm/DataTables/DataTableHeaderCell.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableHeaderCell.js +7 -2
- package/dist/esm/DataTables/DataTableHeaderCell.js.map +1 -1
- package/dist/esm/DataTables/TablePaginatorImplementation.d.ts.map +1 -1
- package/dist/esm/DataTables/TablePaginatorImplementation.js +1 -1
- package/dist/esm/DataTables/TablePaginatorImplementation.js.map +1 -1
- package/dist/esm/DataTables/columnDescriptor.d.ts +4 -0
- package/dist/esm/DataTables/columnDescriptor.d.ts.map +1 -0
- package/dist/esm/DataTables/columnDescriptor.js +10 -0
- package/dist/esm/DataTables/columnDescriptor.js.map +1 -0
- package/dist/esm/Dialogs/Dialog.d.ts +18 -0
- package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/Dialogs/DialogGlobalHeaderActions.d.ts +8 -0
- package/dist/esm/Dialogs/DialogGlobalHeaderActions.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogGlobalHeaderActions.js +6 -0
- package/dist/esm/Dialogs/DialogGlobalHeaderActions.js.map +1 -0
- package/dist/esm/Dialogs/DialogImplementation.d.ts +1 -1
- package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogImplementation.js +22 -6
- package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
- package/dist/esm/Dialogs/dialogDescriptor.d.ts +4 -0
- package/dist/esm/Dialogs/dialogDescriptor.d.ts.map +1 -0
- package/dist/esm/Dialogs/dialogDescriptor.js +12 -0
- package/dist/esm/Dialogs/dialogDescriptor.js.map +1 -0
- package/dist/esm/Dialogs/index.d.ts +3 -0
- package/dist/esm/Dialogs/index.d.ts.map +1 -1
- package/dist/esm/Display/Avatar.d.ts.map +1 -1
- package/dist/esm/Display/Avatar.js +1 -1
- package/dist/esm/Display/Avatar.js.map +1 -1
- package/dist/esm/Display/Badge.d.ts.map +1 -1
- package/dist/esm/Display/Badge.js +1 -1
- package/dist/esm/Display/Badge.js.map +1 -1
- package/dist/esm/Display/Chip.d.ts.map +1 -1
- package/dist/esm/Display/Chip.js +1 -1
- package/dist/esm/Display/Chip.js.map +1 -1
- package/dist/esm/Display/Message.d.ts.map +1 -1
- package/dist/esm/Display/Message.js +1 -1
- package/dist/esm/Display/Message.js.map +1 -1
- package/dist/esm/Display/ProgressBarImplementation.d.ts.map +1 -1
- package/dist/esm/Display/ProgressBarImplementation.js +1 -1
- package/dist/esm/Display/ProgressBarImplementation.js.map +1 -1
- package/dist/esm/Display/ProgressSpinner.d.ts.map +1 -1
- package/dist/esm/Display/ProgressSpinner.js +1 -1
- package/dist/esm/Display/ProgressSpinner.js.map +1 -1
- package/dist/esm/Display/Skeleton.d.ts.map +1 -1
- package/dist/esm/Display/Skeleton.js +1 -1
- package/dist/esm/Display/Skeleton.js.map +1 -1
- package/dist/esm/Display/Tag.d.ts.map +1 -1
- package/dist/esm/Display/Tag.js +1 -1
- package/dist/esm/Display/Tag.js.map +1 -1
- package/dist/esm/Dropdown/DropdownImplementation.js +4 -4
- package/dist/esm/Dropdown/DropdownImplementation.js.map +1 -1
- package/dist/esm/IconPicker/IconPicker.d.ts.map +1 -1
- package/dist/esm/IconPicker/IconPicker.js +1 -1
- package/dist/esm/IconPicker/IconPicker.js.map +1 -1
- package/dist/esm/MarkdownEditor/MarkdownEditor.d.ts.map +1 -1
- package/dist/esm/MarkdownEditor/MarkdownEditor.js +1 -1
- package/dist/esm/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/esm/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/esm/Toolbar/Toolbar.js +1 -1
- package/dist/esm/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/configuration/DialogHeaderActionsRenderer.d.ts +8 -0
- package/dist/esm/configuration/DialogHeaderActionsRenderer.d.ts.map +1 -0
- package/dist/esm/configuration/DialogHeaderActionsRenderer.js +4 -0
- package/dist/esm/configuration/DialogHeaderActionsRenderer.js.map +1 -0
- package/dist/esm/configuration/DialogHeaderContext.d.ts +13 -0
- package/dist/esm/configuration/DialogHeaderContext.d.ts.map +1 -0
- package/dist/esm/configuration/DialogHeaderContext.js +4 -0
- package/dist/esm/configuration/DialogHeaderContext.js.map +1 -0
- package/dist/esm/configuration/DialogSliceLocation.d.ts +13 -0
- package/dist/esm/configuration/DialogSliceLocation.d.ts.map +1 -0
- package/dist/esm/configuration/DialogSliceLocation.js +4 -0
- package/dist/esm/configuration/DialogSliceLocation.js.map +1 -0
- package/dist/esm/configuration/identity/ComponentDescriptor.d.ts +12 -0
- package/dist/esm/configuration/identity/ComponentDescriptor.d.ts.map +1 -0
- package/dist/esm/configuration/identity/ComponentDescriptor.js +4 -0
- package/dist/esm/configuration/identity/ComponentDescriptor.js.map +1 -0
- package/dist/esm/configuration/identity/ComponentMarkerAttributes.d.ts +10 -0
- package/dist/esm/configuration/identity/ComponentMarkerAttributes.d.ts.map +1 -0
- package/dist/esm/configuration/identity/ComponentMarkerAttributes.js +4 -0
- package/dist/esm/configuration/identity/ComponentMarkerAttributes.js.map +1 -0
- package/dist/esm/configuration/identity/PresentationChange.d.ts +11 -0
- package/dist/esm/configuration/identity/PresentationChange.d.ts.map +1 -0
- package/dist/esm/configuration/identity/PresentationChange.js +4 -0
- package/dist/esm/configuration/identity/PresentationChange.js.map +1 -0
- package/dist/esm/configuration/identity/PresentationPropertyDescriptor.d.ts +22 -0
- package/dist/esm/configuration/identity/PresentationPropertyDescriptor.d.ts.map +1 -0
- package/dist/esm/configuration/identity/PresentationPropertyDescriptor.js +4 -0
- package/dist/esm/configuration/identity/PresentationPropertyDescriptor.js.map +1 -0
- package/dist/esm/configuration/identity/PresentationPropertyType.d.ts +3 -0
- package/dist/esm/configuration/identity/PresentationPropertyType.d.ts.map +1 -0
- package/dist/esm/configuration/identity/PresentationPropertyType.js +4 -0
- package/dist/esm/configuration/identity/PresentationPropertyType.js.map +1 -0
- package/dist/esm/configuration/identity/PresentationPropertyValue.d.ts +3 -0
- package/dist/esm/configuration/identity/PresentationPropertyValue.d.ts.map +1 -0
- package/dist/esm/configuration/identity/PresentationPropertyValue.js +4 -0
- package/dist/esm/configuration/identity/PresentationPropertyValue.js.map +1 -0
- package/dist/esm/configuration/identity/RegisteredComponent.d.ts +9 -0
- package/dist/esm/configuration/identity/RegisteredComponent.d.ts.map +1 -0
- package/dist/esm/configuration/identity/RegisteredComponent.js +4 -0
- package/dist/esm/configuration/identity/RegisteredComponent.js.map +1 -0
- package/dist/esm/configuration/identity/componentIdentityAttributes.d.ts +7 -0
- package/dist/esm/configuration/identity/componentIdentityAttributes.d.ts.map +1 -0
- package/dist/esm/configuration/identity/componentIdentityAttributes.js +6 -0
- package/dist/esm/configuration/identity/componentIdentityAttributes.js.map +1 -0
- package/dist/esm/configuration/identity/componentInstances.d.ts +30 -0
- package/dist/esm/configuration/identity/componentInstances.d.ts.map +1 -0
- package/dist/esm/configuration/identity/componentInstances.js +61 -0
- package/dist/esm/configuration/identity/componentInstances.js.map +1 -0
- package/dist/esm/configuration/identity/componentMarker.d.ts +9 -0
- package/dist/esm/configuration/identity/componentMarker.d.ts.map +1 -0
- package/dist/esm/configuration/identity/componentMarker.js +7 -0
- package/dist/esm/configuration/identity/componentMarker.js.map +1 -0
- package/dist/esm/configuration/identity/describeComponent.d.ts +11 -0
- package/dist/esm/configuration/identity/describeComponent.d.ts.map +1 -0
- package/dist/esm/configuration/identity/describeComponent.js +4 -0
- package/dist/esm/configuration/identity/describeComponent.js.map +1 -0
- package/dist/esm/configuration/identity/useComponentPresentation.d.ts +15 -0
- package/dist/esm/configuration/identity/useComponentPresentation.d.ts.map +1 -0
- package/dist/esm/configuration/identity/useComponentPresentation.js +18 -0
- package/dist/esm/configuration/identity/useComponentPresentation.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/renderer/dialogStack.d.ts +2 -0
- package/dist/esm/renderer/dialogStack.d.ts.map +1 -1
- package/dist/esm/renderer/dialogStack.js +2 -1
- package/dist/esm/renderer/dialogStack.js.map +1 -1
- package/dist/esm/types/parts.d.ts +25 -2
- package/dist/esm/types/parts.d.ts.map +1 -1
- package/dist/esm/types/parts.js +25 -2
- package/dist/esm/types/parts.js.map +1 -1
- package/package.json +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditor.js","sources":["../../../MarkdownEditor/MarkdownEditor.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 { useId, useLayoutEffect, useRef, useState, type ReactNode } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { OVERLAY_OFFSET, zIndexAboveDialog } from '../renderer/dialogStack';\nimport { useNearestDialogZIndex } from '../renderer/DialogStackContext';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\nimport type { CaretPosition } from './CaretPosition';\nimport type { MarkdownCompletion } from './MarkdownCompletion';\nimport type { MarkdownEditorLabels } from './MarkdownEditorLabels';\nimport { MarkdownEditorMode } from './MarkdownEditorMode';\nimport type { MarkdownEditorParts } from './MarkdownEditorParts';\nimport type { MarkdownFormat } from './MarkdownFormat';\nimport type { MarkdownTextEdit } from './MarkdownTextEdit';\nimport { MarkdownModeToggle } from './MarkdownModeToggle';\nimport { MarkdownSuggestionList } from './MarkdownSuggestionList';\nimport { MarkdownToolbar } from './MarkdownToolbar';\nimport { MarkdownWritingArea } from './MarkdownWritingArea';\nimport { applyMarkdownFormat } from './applyMarkdownFormat';\nimport { caretPositionIn } from './caretPositionIn';\nimport { defaultMarkdownEditorLabels } from './defaultMarkdownEditorLabels';\nimport { defaultMarkdownFormats } from './defaultMarkdownFormats';\nimport { useMarkdownCompletion } from './useMarkdownCompletion';\nimport { useMarkdownUploads } from './useMarkdownUploads';\n\nconst markdownEditorPartsMatchManifest: ExactPartKeys<MarkdownEditorParts, PartsOf<'MarkdownEditor'>> = true;\nvoid markdownEditorPartsMatchManifest;\n\n/** The height the editor falls back to when its container leaves its height to its content. */\nconst defaultHeight = 320;\n\n/** Props for {@link MarkdownEditor}. */\nexport interface MarkdownEditorProps {\n /** The markdown being edited. */\n value: string;\n\n /** Called with the markdown as it is written, formatted, completed or uploaded into. */\n onChange: (value: string) => void;\n\n /** Called when focus leaves the writing area. */\n onBlur?: () => void;\n\n /** Placeholder shown while the markdown is empty. */\n placeholder?: string;\n\n /**\n * The height the editor takes when its container leaves its height to its content - a number of\n * pixels or any CSS length. Inside a container with a height of its own the editor fills that\n * instead. Defaults to 320 pixels.\n */\n height?: number | string;\n\n /** The mode the editor opens in. Defaults to {@link MarkdownEditorMode.Write}. */\n initialMode?: MarkdownEditorMode;\n\n /** Focuses the writing area as the editor mounts. */\n autoFocus?: boolean;\n\n /** Disables writing, formatting and uploading. */\n disabled?: boolean;\n\n /** Shows the markdown without letting it be changed. */\n readOnly?: boolean;\n\n /** Marks the markdown as invalid, as a failed validation does. */\n invalid?: boolean;\n\n /**\n * The formatting toolbar, as groups of formats separated from each other. Pass `false` for no\n * toolbar. Defaults to text styles, blocks and links, and lists.\n */\n formats?: readonly (readonly MarkdownFormat[])[] | false;\n\n /**\n * Renders the preview of the markdown. The editor ships no markdown renderer - rendering, and what\n * HTML is allowed through, belongs to the host - so the preview toggle only shows when this is given.\n * @param markdown The markdown to render. Never empty: the editor shows its own empty text instead.\n * @returns The rendered markdown.\n */\n renderPreview?: (markdown: string) => ReactNode;\n\n /** Autocompletions offered while their trigger is typed, such as `#` for issues or `@` for people. */\n completions?: readonly MarkdownCompletion[];\n\n /**\n * Uploads a file pasted or dropped into the writing area and returns the markdown that stands for\n * it, such as an image or a link. Omit to leave pasting and dropping files to the browser.\n * @param file The file to upload.\n * @returns The markdown that replaces the file's placeholder.\n */\n uploadFile?: (file: File) => Promise<string>;\n\n /**\n * Told about a file whose upload failed. Its placeholder has already been taken out again.\n * @param file The file that failed to upload.\n * @param error What {@link uploadFile} rejected with.\n */\n onUploadFailed?: (file: File, error: unknown) => void;\n\n /** Overrides for the editor's labels. Unset fields fall back to English. */\n labels?: MarkdownEditorLabels;\n\n /** The writing area's element id, for a `<label htmlFor>`. */\n id?: string;\n\n /** The writing area's accessible name. Defaults to the `editor` label unless `aria-labelledby` is given. */\n 'aria-label'?: string;\n\n /** The id of the element naming the writing area. */\n 'aria-labelledby'?: string;\n\n /** The id of the element describing the writing area, such as a validation message. */\n 'aria-describedby'?: string;\n\n /** Extra class name on the editor's root. */\n className?: string;\n\n /** Pass-through attributes for the editor's stable parts. */\n pt?: MarkdownEditorParts;\n}\n\n/**\n * A markdown editor: one bordered box holding a formatting toolbar and the writing area, with a round\n * toggle in its corner that swaps the whole box to the rendered preview. It fills the container it is\n * given, recognizes configured completion triggers at the caret, and uploads pasted or dropped files\n * through the host.\n *\n * Only one pane shows at a time: a markdown surface usually lives in a dialog or panel that is already\n * narrow, and a side-by-side preview would halve the writing width for something wanted only now and\n * then.\n */\nexport const MarkdownEditor = (props: MarkdownEditorProps) => {\n const { value, onChange, height = defaultHeight, disabled = false, readOnly = false, invalid = false } = props;\n const labels = { ...defaultMarkdownEditorLabels, ...props.labels };\n const [mode, setMode] = useState(\n props.renderPreview ? (props.initialMode ?? MarkdownEditorMode.Write) : MarkdownEditorMode.Write,\n );\n const [selection, setSelection] = useState({ start: value.length, end: value.length });\n const [caret, setCaret] = useState<CaretPosition>();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const pendingSelection = useRef<MarkdownTextEdit>(undefined);\n const latest = useRef({ value, caret: value.length });\n latest.current.value = value;\n const baseId = useId();\n const overlayEnvironment = unstable_useOverlayEnvironment();\n const nearestDialogZIndex = useNearestDialogZIndex();\n\n const editable = !disabled && !readOnly;\n const completion = useMarkdownCompletion(\n value,\n selection.start,\n selection.end,\n editable && mode === MarkdownEditorMode.Write ? (props.completions ?? []) : [],\n );\n\n const applyEdit = (edit: MarkdownTextEdit) => {\n latest.current = { value: edit.value, caret: edit.selectionEnd };\n pendingSelection.current = edit;\n setSelection({ start: edit.selectionStart, end: edit.selectionEnd });\n onChange(edit.value);\n };\n\n const uploads = useMarkdownUploads({\n uploadFile: editable ? props.uploadFile : undefined,\n onUploadFailed: props.onUploadFailed,\n currentValue: () => latest.current.value,\n insertAtCaret: text => {\n const { value: current, caret: at } = latest.current;\n const position = Math.min(at, current.length);\n const caretAfter = position + text.length;\n applyEdit({\n value: `${current.slice(0, position)}${text}${current.slice(position)}`,\n selectionStart: caretAfter,\n selectionEnd: caretAfter,\n });\n },\n replaceValue: next => {\n latest.current = { ...latest.current, value: next };\n onChange(next);\n },\n });\n\n // Restores the selection an edit asked for once the edited markdown is in the writing area.\n useLayoutEffect(() => {\n const pending = pendingSelection.current;\n const textarea = textareaRef.current;\n if (!pending || !textarea || textarea.value !== pending.value) return;\n pendingSelection.current = undefined;\n textarea.focus();\n textarea.setSelectionRange(pending.selectionStart, pending.selectionEnd);\n });\n\n // Measured before paint, so the list never flashes at the caret's previous place while typing.\n useLayoutEffect(() => {\n const textarea = textareaRef.current;\n setCaret(completion.isOpen && textarea ? caretPositionIn(textarea, selection.end) : undefined);\n }, [completion.isOpen, value, selection.end]);\n\n const applyFormat = (format: MarkdownFormat) => {\n const textarea = textareaRef.current;\n if (!textarea || !editable) return;\n applyEdit(applyMarkdownFormat(value, textarea.selectionStart, textarea.selectionEnd, format));\n };\n\n const formats = props.formats === false ? [] : (props.formats ?? defaultMarkdownFormats);\n const hasToolbar = formats.some(group => group.length > 0);\n const canPreview = props.renderPreview !== undefined;\n const suggestionsId = `${baseId}-suggestions`;\n const optionId = (index: number) => `${baseId}-suggestion-${index}`;\n const container = overlayEnvironment.getContainer();\n const busy = uploads.uploading.length > 0;\n const minHeight = typeof height === 'number' ? `${height}px` : height;\n\n return (\n <div\n {...props.pt?.root}\n className={classNames(\n 'cratis-markdown-editor',\n canPreview && 'cratis-markdown-editor--toggleable',\n props.className,\n props.pt?.root?.className,\n )}\n style={{ minHeight, ...props.pt?.root?.style }}\n data-cratis-part='root'\n data-disabled={disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={readOnly || undefined}\n data-busy={busy || undefined}\n >\n {canPreview && (\n <MarkdownModeToggle\n mode={mode}\n onModeChange={setMode}\n showPreviewLabel={labels.showPreview}\n showMarkdownLabel={labels.showMarkdown}\n parts={props.pt?.toggle}\n />\n )}\n {mode === MarkdownEditorMode.Write && hasToolbar && (\n <MarkdownToolbar\n formats={formats}\n labels={labels}\n disabled={!editable}\n onFormat={applyFormat}\n parts={props.pt}\n />\n )}\n <div className='cratis-markdown-editor__body'>\n {mode === MarkdownEditorMode.Preview && props.renderPreview ? (\n <div\n {...props.pt?.preview}\n className={classNames('cratis-markdown-editor__preview', props.pt?.preview?.className)}\n data-cratis-part='preview'\n >\n {value.trim().length > 0 ? (\n props.renderPreview(value)\n ) : (\n <p className='cratis-markdown-editor__empty'>{labels.emptyPreview}</p>\n )}\n </div>\n ) : (\n <MarkdownWritingArea\n value={value}\n onChange={onChange}\n onBlur={props.onBlur}\n placeholder={props.placeholder}\n autoFocus={props.autoFocus}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n id={props.id}\n aria-label={props['aria-label']}\n aria-labelledby={props['aria-labelledby']}\n aria-describedby={props['aria-describedby']}\n parts={props.pt?.textarea}\n textareaRef={textareaRef}\n labels={labels}\n completion={completion}\n uploads={uploads}\n suggestionsId={suggestionsId}\n activeOptionId={completion.isOpen ? optionId(completion.activeIndex) : undefined}\n onSelectionChange={(start, end) => {\n latest.current = { ...latest.current, caret: end };\n setSelection({ start, end });\n }}\n onEdit={applyEdit}\n onFormat={applyFormat}\n />\n )}\n </div>\n {busy && (\n <div\n {...props.pt?.status}\n role='status'\n className={classNames('cratis-markdown-editor__status', props.pt?.status?.className)}\n data-cratis-part='status'\n >\n {labels.uploading(uploads.uploading)}\n </div>\n )}\n {completion.isOpen && caret && container && (\n <MarkdownSuggestionList\n id={suggestionsId}\n optionId={optionId}\n label={completion.match?.completion.label ?? labels.suggestions}\n suggestions={completion.suggestions}\n activeIndex={completion.activeIndex}\n caret={caret}\n zIndex={\n nearestDialogZIndex === null\n ? 'var(--cratis-z-index-overlay)'\n : zIndexAboveDialog(nearestDialogZIndex, OVERLAY_OFFSET)\n }\n container={container}\n onHighlight={completion.highlight}\n onChoose={suggestion => {\n const edit = completion.choose(suggestion);\n if (edit) applyEdit(edit);\n }}\n renderSuggestion={completion.match?.completion.renderSuggestion}\n par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AAW,EAC/D,WAAW,EAAE,UAAU,CAAC,WAAW,EACnC,WAAW,EAAE,UAAU,CAAC,WAAW,EACnC,KAAK,EAAE,KAAK,EACZ,MAAM,EACF,mBAAmB,KAAK;AACpB,sBAAE;sBACA,iBAAiB,CAAC,mBAAmB,EAAE,cAAc,CAAC,EAEhE,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,UAAU,CAAC,SAAS,EACjC,QAAQ,EAAE,UAAU,IAAG;oBACnB,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC;AAC1C,oBAAA,IAAI,IAAI;wBAAE,SAAS,CAAC,IAAI,CAAC;gBAC7B,CAAC,EACD,gBAAgB,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,gBAAgB,EAC/D,KAAK,EAAE,KAAK,CAAC,EAAE,GACjB,CACL,CAAA,EAAA,CACC;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"MarkdownEditor.js","sources":["../../../MarkdownEditor/MarkdownEditor.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 { useId, useLayoutEffect, useRef, useState, type ReactNode } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { OVERLAY_OFFSET, zIndexAboveDialog } from '../renderer/dialogStack';\nimport { useNearestDialogZIndex } from '../renderer/DialogStackContext';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\nimport type { CaretPosition } from './CaretPosition';\nimport type { MarkdownCompletion } from './MarkdownCompletion';\nimport type { MarkdownEditorLabels } from './MarkdownEditorLabels';\nimport { MarkdownEditorMode } from './MarkdownEditorMode';\nimport type { MarkdownEditorParts } from './MarkdownEditorParts';\nimport type { MarkdownFormat } from './MarkdownFormat';\nimport type { MarkdownTextEdit } from './MarkdownTextEdit';\nimport { MarkdownModeToggle } from './MarkdownModeToggle';\nimport { MarkdownSuggestionList } from './MarkdownSuggestionList';\nimport { MarkdownToolbar } from './MarkdownToolbar';\nimport { MarkdownWritingArea } from './MarkdownWritingArea';\nimport { applyMarkdownFormat } from './applyMarkdownFormat';\nimport { caretPositionIn } from './caretPositionIn';\nimport { defaultMarkdownEditorLabels } from './defaultMarkdownEditorLabels';\nimport { defaultMarkdownFormats } from './defaultMarkdownFormats';\nimport { useMarkdownCompletion } from './useMarkdownCompletion';\nimport { useMarkdownUploads } from './useMarkdownUploads';\n\nconst markdownEditorPartsMatchManifest: ExactPartKeys<MarkdownEditorParts, PartsOf<'MarkdownEditor'>> = true;\nvoid markdownEditorPartsMatchManifest;\n\n/** The height the editor falls back to when its container leaves its height to its content. */\nconst defaultHeight = 320;\n\n/** Props for {@link MarkdownEditor}. */\nexport interface MarkdownEditorProps {\n /** The markdown being edited. */\n value: string;\n\n /** Called with the markdown as it is written, formatted, completed or uploaded into. */\n onChange: (value: string) => void;\n\n /** Called when focus leaves the writing area. */\n onBlur?: () => void;\n\n /** Placeholder shown while the markdown is empty. */\n placeholder?: string;\n\n /**\n * The height the editor takes when its container leaves its height to its content - a number of\n * pixels or any CSS length. Inside a container with a height of its own the editor fills that\n * instead. Defaults to 320 pixels.\n */\n height?: number | string;\n\n /** The mode the editor opens in. Defaults to {@link MarkdownEditorMode.Write}. */\n initialMode?: MarkdownEditorMode;\n\n /** Focuses the writing area as the editor mounts. */\n autoFocus?: boolean;\n\n /** Disables writing, formatting and uploading. */\n disabled?: boolean;\n\n /** Shows the markdown without letting it be changed. */\n readOnly?: boolean;\n\n /** Marks the markdown as invalid, as a failed validation does. */\n invalid?: boolean;\n\n /**\n * The formatting toolbar, as groups of formats separated from each other. Pass `false` for no\n * toolbar. Defaults to text styles, blocks and links, and lists.\n */\n formats?: readonly (readonly MarkdownFormat[])[] | false;\n\n /**\n * Renders the preview of the markdown. The editor ships no markdown renderer - rendering, and what\n * HTML is allowed through, belongs to the host - so the preview toggle only shows when this is given.\n * @param markdown The markdown to render. Never empty: the editor shows its own empty text instead.\n * @returns The rendered markdown.\n */\n renderPreview?: (markdown: string) => ReactNode;\n\n /** Autocompletions offered while their trigger is typed, such as `#` for issues or `@` for people. */\n completions?: readonly MarkdownCompletion[];\n\n /**\n * Uploads a file pasted or dropped into the writing area and returns the markdown that stands for\n * it, such as an image or a link. Omit to leave pasting and dropping files to the browser.\n * @param file The file to upload.\n * @returns The markdown that replaces the file's placeholder.\n */\n uploadFile?: (file: File) => Promise<string>;\n\n /**\n * Told about a file whose upload failed. Its placeholder has already been taken out again.\n * @param file The file that failed to upload.\n * @param error What {@link uploadFile} rejected with.\n */\n onUploadFailed?: (file: File, error: unknown) => void;\n\n /** Overrides for the editor's labels. Unset fields fall back to English. */\n labels?: MarkdownEditorLabels;\n\n /** The writing area's element id, for a `<label htmlFor>`. */\n id?: string;\n\n /** The writing area's accessible name. Defaults to the `editor` label unless `aria-labelledby` is given. */\n 'aria-label'?: string;\n\n /** The id of the element naming the writing area. */\n 'aria-labelledby'?: string;\n\n /** The id of the element describing the writing area, such as a validation message. */\n 'aria-describedby'?: string;\n\n /** Extra class name on the editor's root. */\n className?: string;\n\n /** Pass-through attributes for the editor's stable parts. */\n pt?: MarkdownEditorParts;\n}\n\n/**\n * A markdown editor: one bordered box holding a formatting toolbar and the writing area, with a round\n * toggle in its corner that swaps the whole box to the rendered preview. It fills the container it is\n * given, recognizes configured completion triggers at the caret, and uploads pasted or dropped files\n * through the host.\n *\n * Only one pane shows at a time: a markdown surface usually lives in a dialog or panel that is already\n * narrow, and a side-by-side preview would halve the writing width for something wanted only now and\n * then.\n */\nexport const MarkdownEditor = (props: MarkdownEditorProps) => {\n const { value, onChange, height = defaultHeight, disabled = false, readOnly = false, invalid = false } = props;\n const labels = { ...defaultMarkdownEditorLabels, ...props.labels };\n const [mode, setMode] = useState(\n props.renderPreview ? (props.initialMode ?? MarkdownEditorMode.Write) : MarkdownEditorMode.Write,\n );\n const [selection, setSelection] = useState({ start: value.length, end: value.length });\n const [caret, setCaret] = useState<CaretPosition>();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const pendingSelection = useRef<MarkdownTextEdit>(undefined);\n const latest = useRef({ value, caret: value.length });\n latest.current.value = value;\n const baseId = useId();\n const overlayEnvironment = unstable_useOverlayEnvironment();\n const nearestDialogZIndex = useNearestDialogZIndex();\n\n const editable = !disabled && !readOnly;\n const completion = useMarkdownCompletion(\n value,\n selection.start,\n selection.end,\n editable && mode === MarkdownEditorMode.Write ? (props.completions ?? []) : [],\n );\n\n const applyEdit = (edit: MarkdownTextEdit) => {\n latest.current = { value: edit.value, caret: edit.selectionEnd };\n pendingSelection.current = edit;\n setSelection({ start: edit.selectionStart, end: edit.selectionEnd });\n onChange(edit.value);\n };\n\n const uploads = useMarkdownUploads({\n uploadFile: editable ? props.uploadFile : undefined,\n onUploadFailed: props.onUploadFailed,\n currentValue: () => latest.current.value,\n insertAtCaret: text => {\n const { value: current, caret: at } = latest.current;\n const position = Math.min(at, current.length);\n const caretAfter = position + text.length;\n applyEdit({\n value: `${current.slice(0, position)}${text}${current.slice(position)}`,\n selectionStart: caretAfter,\n selectionEnd: caretAfter,\n });\n },\n replaceValue: next => {\n latest.current = { ...latest.current, value: next };\n onChange(next);\n },\n });\n\n // Restores the selection an edit asked for once the edited markdown is in the writing area.\n useLayoutEffect(() => {\n const pending = pendingSelection.current;\n const textarea = textareaRef.current;\n if (!pending || !textarea || textarea.value !== pending.value) return;\n pendingSelection.current = undefined;\n textarea.focus();\n textarea.setSelectionRange(pending.selectionStart, pending.selectionEnd);\n });\n\n // Measured before paint, so the list never flashes at the caret's previous place while typing.\n useLayoutEffect(() => {\n const textarea = textareaRef.current;\n setCaret(completion.isOpen && textarea ? caretPositionIn(textarea, selection.end) : undefined);\n }, [completion.isOpen, value, selection.end]);\n\n const applyFormat = (format: MarkdownFormat) => {\n const textarea = textareaRef.current;\n if (!textarea || !editable) return;\n applyEdit(applyMarkdownFormat(value, textarea.selectionStart, textarea.selectionEnd, format));\n };\n\n const formats = props.formats === false ? [] : (props.formats ?? defaultMarkdownFormats);\n const hasToolbar = formats.some(group => group.length > 0);\n const canPreview = props.renderPreview !== undefined;\n const suggestionsId = `${baseId}-suggestions`;\n const optionId = (index: number) => `${baseId}-suggestion-${index}`;\n const container = overlayEnvironment.getContainer();\n const busy = uploads.uploading.length > 0;\n const minHeight = typeof height === 'number' ? `${height}px` : height;\n\n return (\n <div\n {...props.pt?.root}\n className={classNames(\n 'cratis-markdown-editor',\n canPreview && 'cratis-markdown-editor--toggleable',\n props.className,\n props.pt?.root?.className,\n )}\n style={{ minHeight, ...props.pt?.root?.style }}\n data-cratis-part='root'\n data-cratis-component='MarkdownEditor'\n data-disabled={disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={readOnly || undefined}\n data-busy={busy || undefined}\n >\n {canPreview && (\n <MarkdownModeToggle\n mode={mode}\n onModeChange={setMode}\n showPreviewLabel={labels.showPreview}\n showMarkdownLabel={labels.showMarkdown}\n parts={props.pt?.toggle}\n />\n )}\n {mode === MarkdownEditorMode.Write && hasToolbar && (\n <MarkdownToolbar\n formats={formats}\n labels={labels}\n disabled={!editable}\n onFormat={applyFormat}\n parts={props.pt}\n />\n )}\n <div className='cratis-markdown-editor__body'>\n {mode === MarkdownEditorMode.Preview && props.renderPreview ? (\n <div\n {...props.pt?.preview}\n className={classNames('cratis-markdown-editor__preview', props.pt?.preview?.className)}\n data-cratis-part='preview'\n >\n {value.trim().length > 0 ? (\n props.renderPreview(value)\n ) : (\n <p className='cratis-markdown-editor__empty'>{labels.emptyPreview}</p>\n )}\n </div>\n ) : (\n <MarkdownWritingArea\n value={value}\n onChange={onChange}\n onBlur={props.onBlur}\n placeholder={props.placeholder}\n autoFocus={props.autoFocus}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n id={props.id}\n aria-label={props['aria-label']}\n aria-labelledby={props['aria-labelledby']}\n aria-describedby={props['aria-describedby']}\n parts={props.pt?.textarea}\n textareaRef={textareaRef}\n labels={labels}\n completion={completion}\n uploads={uploads}\n suggestionsId={suggestionsId}\n activeOptionId={completion.isOpen ? optionId(completion.activeIndex) : undefined}\n onSelectionChange={(start, end) => {\n latest.current = { ...latest.current, caret: end };\n setSelection({ start, end });\n }}\n onEdit={applyEdit}\n onFormat={applyFormat}\n />\n )}\n </div>\n {busy && (\n <div\n {...props.pt?.status}\n role='status'\n className={classNames('cratis-markdown-editor__status', props.pt?.status?.className)}\n data-cratis-part='status'\n >\n {labels.uploading(uploads.uploading)}\n </div>\n )}\n {completion.isOpen && caret && container && (\n <MarkdownSuggestionList\n id={suggestionsId}\n optionId={optionId}\n label={completion.match?.completion.label ?? labels.suggestions}\n suggestions={completion.suggestions}\n activeIndex={completion.activeIndex}\n caret={caret}\n zIndex={\n nearestDialogZIndex === null\n ? 'var(--cratis-z-index-overlay)'\n : zIndexAboveDialog(nearestDialogZIndex, OVERLAY_OFFSET)\n }\n container={container}\n onHighlight={completion.highlight}\n onChoose={suggestion => {\n const edit = completion.choose(suggestion);\n if (edit) applyEdit(edit);\n }}\n renderSuggestion={completion.match?.completion.renderSuggestion}\n parts={props.pt}\n />\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;AAgCA,MAAM,aAAa,GAAG,GAAG;AAsGlB,MAAM,cAAc,GAAG,CAAC,KAA0B,KAAI;IACzD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,QAAQ,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,KAAK;IAC9G,MAAM,MAAM,GAAG,EAAE,GAAG,2BAA2B,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE;AAClE,IAAA,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAC5B,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,WAAW,IAAI,kBAAkB,CAAC,KA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CACL,CAAA,EAAA,CACC;AAEd;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../Toolbar/Toolbar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA4B,CAAC;AAO9D,kDAAkD;AAClD,MAAM,WAAW,YAAY;IACzB,oBAAoB;IACpB,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACzC;AAKD,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IACzB,8EAA8E;IAC9E,QAAQ,EAAE,SAAS,CAAC;IACpB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iGAAiG;IACjG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sCAAsC;IACtC,EAAE,CAAC,EAAE,YAAY,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC;CACrE;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,iJAUjB,YAAY,
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../../Toolbar/Toolbar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA4B,CAAC;AAO9D,kDAAkD;AAClD,MAAM,WAAW,YAAY;IACzB,oBAAoB;IACpB,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACzC;AAKD,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IACzB,8EAA8E;IAC9E,QAAQ,EAAE,SAAS,CAAC;IACpB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iGAAiG;IACjG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sCAAsC;IACtC,EAAE,CAAC,EAAE,YAAY,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC;CACrE;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,iJAUjB,YAAY,gCAkCd,CAAC"}
|
|
@@ -25,7 +25,7 @@ const Toolbar = ({ children, orientation = 'vertical', focusMode = ToolbarFocusM
|
|
|
25
25
|
className,
|
|
26
26
|
]
|
|
27
27
|
.filter(Boolean)
|
|
28
|
-
.join(' '), "data-cratis-part": 'root', "data-orientation": orientation, children: jsx(ToolbarRovingContext.Provider, { value: roving, children: children }) }) }));
|
|
28
|
+
.join(' '), "data-cratis-part": 'root', "data-cratis-component": 'Toolbar', "data-orientation": orientation, children: jsx(ToolbarRovingContext.Provider, { value: roving, children: children }) }) }));
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export { Toolbar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.js","sources":["../../../Toolbar/Toolbar.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 { type HTMLAttributes, type ReactNode } from 'react';\nimport { ToolbarDragContext } from './ToolbarDragContext';\nimport { ToolbarFocusMode } from '../Common/ToolbarFocusMode';\nimport { useToolbarKeyboardNavigation } from '../Common/useToolbarKeyboardNavigation';\nimport { ToolbarRovingContext } from '../Common/ToolbarRovingContext';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\n\n/** Stable part attributes for {@link Toolbar}. */\nexport interface ToolbarParts {\n /** Toolbar root. */\n root?: HTMLAttributes<HTMLDivElement>;\n}\n\nconst toolbarPartsMatchManifest: ExactPartKeys<ToolbarParts, PartsOf<'Toolbar'>> = true;\nvoid toolbarPartsMatchManifest;\n\n/** Props for the {@link Toolbar} component. */\nexport interface ToolbarProps {\n /** The {@link ToolbarButton} elements to render inside this toolbar group. */\n children: ReactNode;\n /** Keyboard focus behavior (default: {@link ToolbarFocusMode.Arrows}). */\n focusMode?: ToolbarFocusMode;\n /** Layout direction of the toolbar (default: 'vertical'). */\n orientation?: 'vertical' | 'horizontal';\n /** Extra class name for the toolbar root. */\n className?: string;\n /** Accessible toolbar name. Overrides the provider's `messages.toolbar.label` fallback. */\n 'aria-label'?: string;\n /** Identifies an external element that names the toolbar. Takes precedence over `aria-label`. */\n 'aria-labelledby'?: string;\n /** Stable toolbar part attributes. */\n pt?: ToolbarParts;\n /**\n * When `true`, all {@link ToolbarButton} children become draggable by default.\n * Individual buttons can still override this with their own `draggable` prop.\n */\n draggable?: boolean;\n /**\n * Callback invoked when any child toolbar item starts being dragged.\n * Receives the item's associated data and the originating drag event.\n * Only fires for items that are actually draggable.\n */\n onItemDragStart?: (data: unknown, event: React.DragEvent) => void;\n}\n\n/**\n * A toolbar container that groups icon buttons with a rounded border,\n * mimicking the style of tools panels found in canvas-based applications.\n * Supports both vertical (default) and horizontal orientations.\n */\nexport const Toolbar = ({\n children,\n orientation = 'vertical',\n focusMode = ToolbarFocusMode.Arrows,\n draggable = false,\n onItemDragStart,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n pt,\n}: ToolbarProps) => {\n const { rootRef, onKeyDown, roving } = useToolbarKeyboardNavigation(orientation, focusMode);\n const { messages } = useCratisComponentsConfig();\n const resolvedAriaLabel = ariaLabel ?? messages?.toolbar?.label ?? 'Tools';\n\n return (\n <ToolbarDragContext.Provider value={{ draggable, onItemDragStart }}>\n <div\n {...pt?.root}\n ref={rootRef}\n onKeyDown={event => { pt?.root?.onKeyDown?.(event); if (!event.isPropagationStopped()) onKeyDown(event); }}\n role='toolbar'\n aria-orientation={orientation}\n aria-label={ariaLabelledBy ? undefined : resolvedAriaLabel}\n aria-labelledby={ariaLabelledBy}\n className={[\n 'toolbar cratis:inline-flex',\n orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col',\n 'cratis:items-center cratis:gap-1 cratis:p-2 cratis:rounded-2xl',\n pt?.root?.className,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='root'\n data-orientation={orientation}\n >\n <ToolbarRovingContext.Provider value={roving}>\n {children}\n </ToolbarRovingContext.Provider>\n </div>\n </ToolbarDragContext.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;AAuDO,MAAM,OAAO,GAAG,CAAC,EACpB,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,SAAS,GAAG,gBAAgB,CAAC,MAAM,EACnC,SAAS,GAAG,KAAK,EACjB,eAAe,EACf,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,EAAE,GACS,KAAI;AACf,IAAA,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,4BAA4B,CAAC,WAAW,EAAE,SAAS,CAAC;AAC3F,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,yBAAyB,EAAE;IAChD,MAAM,iBAAiB,GAAG,SAAS,IAAI,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,OAAO;IAE1E,QACIA,IAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,YAC9DA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,KAAK,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC1G,IAAI,EAAC,SAAS,EAAA,kBAAA,EACI,WAAW,EAAA,YAAA,EACjB,cAAc,GAAG,SAAS,GAAG,iBAAiB,EAAA,iBAAA,EACzC,cAAc,EAC/B,SAAS,EAAE;gBACP,4BAA4B;gBAC5B,WAAW,KAAK,YAAY,GAAG,iBAAiB,GAAG,iBAAiB;gBACpE,gEAAgE;gBAChE,EAAE,EAAE,IAAI,EAAE,SAAS;gBACnB,SAAS;AACZ;iBACI,MAAM,CAAC,OAAO;iBACd,IAAI,CAAC,GAAG,CAAC,EAAA,kBAAA,EACG,MAAM,EAAA,kBAAA,
|
|
1
|
+
{"version":3,"file":"Toolbar.js","sources":["../../../Toolbar/Toolbar.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 { type HTMLAttributes, type ReactNode } from 'react';\nimport { ToolbarDragContext } from './ToolbarDragContext';\nimport { ToolbarFocusMode } from '../Common/ToolbarFocusMode';\nimport { useToolbarKeyboardNavigation } from '../Common/useToolbarKeyboardNavigation';\nimport { ToolbarRovingContext } from '../Common/ToolbarRovingContext';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\n\n/** Stable part attributes for {@link Toolbar}. */\nexport interface ToolbarParts {\n /** Toolbar root. */\n root?: HTMLAttributes<HTMLDivElement>;\n}\n\nconst toolbarPartsMatchManifest: ExactPartKeys<ToolbarParts, PartsOf<'Toolbar'>> = true;\nvoid toolbarPartsMatchManifest;\n\n/** Props for the {@link Toolbar} component. */\nexport interface ToolbarProps {\n /** The {@link ToolbarButton} elements to render inside this toolbar group. */\n children: ReactNode;\n /** Keyboard focus behavior (default: {@link ToolbarFocusMode.Arrows}). */\n focusMode?: ToolbarFocusMode;\n /** Layout direction of the toolbar (default: 'vertical'). */\n orientation?: 'vertical' | 'horizontal';\n /** Extra class name for the toolbar root. */\n className?: string;\n /** Accessible toolbar name. Overrides the provider's `messages.toolbar.label` fallback. */\n 'aria-label'?: string;\n /** Identifies an external element that names the toolbar. Takes precedence over `aria-label`. */\n 'aria-labelledby'?: string;\n /** Stable toolbar part attributes. */\n pt?: ToolbarParts;\n /**\n * When `true`, all {@link ToolbarButton} children become draggable by default.\n * Individual buttons can still override this with their own `draggable` prop.\n */\n draggable?: boolean;\n /**\n * Callback invoked when any child toolbar item starts being dragged.\n * Receives the item's associated data and the originating drag event.\n * Only fires for items that are actually draggable.\n */\n onItemDragStart?: (data: unknown, event: React.DragEvent) => void;\n}\n\n/**\n * A toolbar container that groups icon buttons with a rounded border,\n * mimicking the style of tools panels found in canvas-based applications.\n * Supports both vertical (default) and horizontal orientations.\n */\nexport const Toolbar = ({\n children,\n orientation = 'vertical',\n focusMode = ToolbarFocusMode.Arrows,\n draggable = false,\n onItemDragStart,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n pt,\n}: ToolbarProps) => {\n const { rootRef, onKeyDown, roving } = useToolbarKeyboardNavigation(orientation, focusMode);\n const { messages } = useCratisComponentsConfig();\n const resolvedAriaLabel = ariaLabel ?? messages?.toolbar?.label ?? 'Tools';\n\n return (\n <ToolbarDragContext.Provider value={{ draggable, onItemDragStart }}>\n <div\n {...pt?.root}\n ref={rootRef}\n onKeyDown={event => { pt?.root?.onKeyDown?.(event); if (!event.isPropagationStopped()) onKeyDown(event); }}\n role='toolbar'\n aria-orientation={orientation}\n aria-label={ariaLabelledBy ? undefined : resolvedAriaLabel}\n aria-labelledby={ariaLabelledBy}\n className={[\n 'toolbar cratis:inline-flex',\n orientation === 'horizontal' ? 'cratis:flex-row' : 'cratis:flex-col',\n 'cratis:items-center cratis:gap-1 cratis:p-2 cratis:rounded-2xl',\n pt?.root?.className,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='root'\n data-cratis-component='Toolbar'\n data-orientation={orientation}\n >\n <ToolbarRovingContext.Provider value={roving}>\n {children}\n </ToolbarRovingContext.Provider>\n </div>\n </ToolbarDragContext.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;AAuDO,MAAM,OAAO,GAAG,CAAC,EACpB,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,SAAS,GAAG,gBAAgB,CAAC,MAAM,EACnC,SAAS,GAAG,KAAK,EACjB,eAAe,EACf,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,EAAE,GACS,KAAI;AACf,IAAA,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,4BAA4B,CAAC,WAAW,EAAE,SAAS,CAAC;AAC3F,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,yBAAyB,EAAE;IAChD,MAAM,iBAAiB,GAAG,SAAS,IAAI,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,OAAO;IAE1E,QACIA,IAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,YAC9DA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,KAAK,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC1G,IAAI,EAAC,SAAS,EAAA,kBAAA,EACI,WAAW,EAAA,YAAA,EACjB,cAAc,GAAG,SAAS,GAAG,iBAAiB,EAAA,iBAAA,EACzC,cAAc,EAC/B,SAAS,EAAE;gBACP,4BAA4B;gBAC5B,WAAW,KAAK,YAAY,GAAG,iBAAiB,GAAG,iBAAiB;gBACpE,gEAAgE;gBAChE,EAAE,EAAE,IAAI,EAAE,SAAS;gBACnB,SAAS;AACZ;iBACI,MAAM,CAAC,OAAO;iBACd,IAAI,CAAC,GAAG,CAAC,EAAA,kBAAA,EACG,MAAM,2BACD,SAAS,EAAA,kBAAA,EACb,WAAW,EAAA,QAAA,EAE7BA,GAAA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,MAAM,EAAA,QAAA,EACvC,QAAQ,EAAA,CACmB,EAAA,CAC9B,EAAA,CACoB;AAEtC;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { DialogHeaderContext } from './DialogHeaderContext.js';
|
|
3
|
+
/**
|
|
4
|
+
* Renders the app-wide header actions of one dialog. It is mounted as a component, so it may use
|
|
5
|
+
* hooks; return `null` to show nothing for this dialog.
|
|
6
|
+
*/
|
|
7
|
+
export type DialogHeaderActionsRenderer = (dialog: DialogHeaderContext) => ReactNode;
|
|
8
|
+
//# sourceMappingURL=DialogHeaderActionsRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogHeaderActionsRenderer.d.ts","sourceRoot":"","sources":["../../../configuration/DialogHeaderActionsRenderer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,MAAM,EAAE,mBAAmB,KAAK,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogHeaderActionsRenderer.js","sourceRoot":"","sources":["../../../configuration/DialogHeaderActionsRenderer.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 type { ReactNode } from 'react';\nimport type { DialogHeaderContext } from './DialogHeaderContext';\n\n/**\n * Renders the app-wide header actions of one dialog. It is mounted as a component, so it may use\n * hooks; return `null` to show nothing for this dialog.\n */\nexport type DialogHeaderActionsRenderer = (dialog: DialogHeaderContext) => ReactNode;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DialogSliceLocation } from './DialogSliceLocation.js';
|
|
2
|
+
/** What a dialog header action receives so it can decide whether and how to show itself. */
|
|
3
|
+
export interface DialogHeaderContext {
|
|
4
|
+
/** Identifier of this dialog instance, also rendered as `data-cratis-dialog-id` on the dialog root. */
|
|
5
|
+
dialogId: string;
|
|
6
|
+
/** The dialog title. */
|
|
7
|
+
title: string;
|
|
8
|
+
/** `true` for `CommandDialog` and `StepperCommandDialog`, `false` for a plain `Dialog`. */
|
|
9
|
+
isCommandDialog: boolean;
|
|
10
|
+
/** The dialog's slice location, when the host or Arc provided one. */
|
|
11
|
+
sliceLocation?: DialogSliceLocation;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=DialogHeaderContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogHeaderContext.d.ts","sourceRoot":"","sources":["../../../configuration/DialogHeaderContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,4FAA4F;AAC5F,MAAM,WAAW,mBAAmB;IAChC,uGAAuG;IACvG,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,eAAe,EAAE,OAAO,CAAC;IACzB,sEAAsE;IACtE,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogHeaderContext.js","sourceRoot":"","sources":["../../../configuration/DialogHeaderContext.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 type { DialogSliceLocation } from './DialogSliceLocation';\n\n/** What a dialog header action receives so it can decide whether and how to show itself. */\nexport interface DialogHeaderContext {\n /** Identifier of this dialog instance, also rendered as `data-cratis-dialog-id` on the dialog root. */\n dialogId: string;\n /** The dialog title. */\n title: string;\n /** `true` for `CommandDialog` and `StepperCommandDialog`, `false` for a plain `Dialog`. */\n isCommandDialog: boolean;\n /** The dialog's slice location, when the host or Arc provided one. */\n sliceLocation?: DialogSliceLocation;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a dialog's opener sits in the application: the module, feature and slice that own it.
|
|
3
|
+
* Components only carries the value; the host (or Arc) supplies it.
|
|
4
|
+
*/
|
|
5
|
+
export interface DialogSliceLocation {
|
|
6
|
+
/** Module name. */
|
|
7
|
+
module: string;
|
|
8
|
+
/** Feature name within the module. */
|
|
9
|
+
feature: string;
|
|
10
|
+
/** Slice name within the feature. */
|
|
11
|
+
slice: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=DialogSliceLocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogSliceLocation.d.ts","sourceRoot":"","sources":["../../../configuration/DialogSliceLocation.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogSliceLocation.js","sourceRoot":"","sources":["../../../configuration/DialogSliceLocation.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 * Where a dialog's opener sits in the application: the module, feature and slice that own it.\n * Components only carries the value; the host (or Arc) supplies it.\n */\nexport interface DialogSliceLocation {\n /** Module name. */\n module: string;\n /** Feature name within the module. */\n feature: string;\n /** Slice name within the feature. */\n slice: string;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PresentationPropertyDescriptor } from './PresentationPropertyDescriptor.js';
|
|
2
|
+
/**
|
|
3
|
+
* The static, typed list of a component's presentation props.
|
|
4
|
+
* @typeParam TProps - The component's props.
|
|
5
|
+
*/
|
|
6
|
+
export interface ComponentDescriptor<TProps extends object = object> {
|
|
7
|
+
/** The public component name, as rendered in `data-cratis-component`. */
|
|
8
|
+
readonly component: string;
|
|
9
|
+
/** The presentation props, in the order an editor lists them. */
|
|
10
|
+
readonly properties: readonly PresentationPropertyDescriptor<TProps>[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ComponentDescriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentDescriptor.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/ComponentDescriptor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,qCAAkC,CAAC;AAEvF;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IAC/D,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,UAAU,EAAE,SAAS,8BAA8B,CAAC,MAAM,CAAC,EAAE,CAAC;CAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentDescriptor.js","sourceRoot":"","sources":["../../../../configuration/identity/ComponentDescriptor.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 type { PresentationPropertyDescriptor } from './PresentationPropertyDescriptor';\n\n/**\n * The static, typed list of a component's presentation props.\n * @typeParam TProps - The component's props.\n */\nexport interface ComponentDescriptor<TProps extends object = object> {\n /** The public component name, as rendered in `data-cratis-component`. */\n readonly component: string;\n /** The presentation props, in the order an editor lists them. */\n readonly properties: readonly PresentationPropertyDescriptor<TProps>[];\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The identity attributes a component spreads onto its root element. */
|
|
2
|
+
export interface ComponentMarkerAttributes {
|
|
3
|
+
/** The public component name. */
|
|
4
|
+
'data-cratis-component': string;
|
|
5
|
+
/** The consumer's `id` or `name`, when there is one. */
|
|
6
|
+
'data-cratis-component-id'?: string;
|
|
7
|
+
/** Links the root to its live presentation registration. Present only on components that declare presentation properties. */
|
|
8
|
+
'data-cratis-component-instance'?: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ComponentMarkerAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentMarkerAttributes.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/ComponentMarkerAttributes.ts"],"names":[],"mappings":"AAGA,yEAAyE;AACzE,MAAM,WAAW,yBAAyB;IACtC,iCAAiC;IACjC,uBAAuB,EAAE,MAAM,CAAC;IAChC,wDAAwD;IACxD,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,6HAA6H;IAC7H,gCAAgC,CAAC,EAAE,MAAM,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentMarkerAttributes.js","sourceRoot":"","sources":["../../../../configuration/identity/ComponentMarkerAttributes.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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/** The identity attributes a component spreads onto its root element. */\nexport interface ComponentMarkerAttributes {\n /** The public component name. */\n 'data-cratis-component': string;\n /** The consumer's `id` or `name`, when there is one. */\n 'data-cratis-component-id'?: string;\n /** Links the root to its live presentation registration. Present only on components that declare presentation properties. */\n 'data-cratis-component-instance'?: string;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PresentationPropertyValue } from './PresentationPropertyValue.js';
|
|
2
|
+
/** A proposed change to one presentation property. */
|
|
3
|
+
export interface PresentationChange {
|
|
4
|
+
/** The property name. */
|
|
5
|
+
property: string;
|
|
6
|
+
/** The value before the change. */
|
|
7
|
+
from: PresentationPropertyValue;
|
|
8
|
+
/** The proposed value. */
|
|
9
|
+
to: PresentationPropertyValue;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=PresentationChange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationChange.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/PresentationChange.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAE7E,sDAAsD;AACtD,MAAM,WAAW,kBAAkB;IAC/B,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,IAAI,EAAE,yBAAyB,CAAC;IAChC,0BAA0B;IAC1B,EAAE,EAAE,yBAAyB,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationChange.js","sourceRoot":"","sources":["../../../../configuration/identity/PresentationChange.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 type { PresentationPropertyValue } from './PresentationPropertyValue';\n\n/** A proposed change to one presentation property. */\nexport interface PresentationChange {\n /** The property name. */\n property: string;\n /** The value before the change. */\n from: PresentationPropertyValue;\n /** The proposed value. */\n to: PresentationPropertyValue;\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PresentationPropertyValue } from './PresentationPropertyValue.js';
|
|
2
|
+
/**
|
|
3
|
+
* One presentation prop of a component: its name, how it is edited and, for an enumeration, the
|
|
4
|
+
* values it allows. Behavior and data props are never described.
|
|
5
|
+
* @typeParam TProps - The component's props. `name` must be one of its keys.
|
|
6
|
+
*/
|
|
7
|
+
export type PresentationPropertyDescriptor<TProps extends object = object> = {
|
|
8
|
+
/** The prop name. */
|
|
9
|
+
name: keyof TProps & string;
|
|
10
|
+
/** Human-readable label for an editor. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** What the prop changes, for an editor to show. */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** The value the component uses when the prop is not set. */
|
|
15
|
+
defaultValue?: PresentationPropertyValue;
|
|
16
|
+
} & ({
|
|
17
|
+
type: 'string' | 'boolean' | 'number';
|
|
18
|
+
} | {
|
|
19
|
+
type: 'enum';
|
|
20
|
+
values: readonly (string | number)[];
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=PresentationPropertyDescriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationPropertyDescriptor.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/PresentationPropertyDescriptor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAE7E;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI;IACzE,qBAAqB;IACrB,IAAI,EAAE,MAAM,MAAM,GAAG,MAAM,CAAC;IAC5B,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,yBAAyB,CAAC;CAC5C,GAAG,CACE;IAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CAAE,CAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationPropertyDescriptor.js","sourceRoot":"","sources":["../../../../configuration/identity/PresentationPropertyDescriptor.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 type { PresentationPropertyValue } from './PresentationPropertyValue';\n\n/**\n * One presentation prop of a component: its name, how it is edited and, for an enumeration, the\n * values it allows. Behavior and data props are never described.\n * @typeParam TProps - The component's props. `name` must be one of its keys.\n */\nexport type PresentationPropertyDescriptor<TProps extends object = object> = {\n /** The prop name. */\n name: keyof TProps & string;\n /** Human-readable label for an editor. */\n label: string;\n /** What the prop changes, for an editor to show. */\n description?: string;\n /** The value the component uses when the prop is not set. */\n defaultValue?: PresentationPropertyValue;\n} & (\n | { type: 'string' | 'boolean' | 'number' }\n | { type: 'enum'; values: readonly (string | number)[] }\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationPropertyType.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/PresentationPropertyType.ts"],"names":[],"mappings":"AAGA,mDAAmD;AACnD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationPropertyType.js","sourceRoot":"","sources":["../../../../configuration/identity/PresentationPropertyType.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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/** The editing kind of a presentation property. */\nexport type PresentationPropertyType = 'string' | 'boolean' | 'number' | 'enum';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationPropertyValue.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/PresentationPropertyValue.ts"],"names":[],"mappings":"AAGA,gDAAgD;AAChD,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresentationPropertyValue.js","sourceRoot":"","sources":["../../../../configuration/identity/PresentationPropertyValue.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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/** A value a presentation property can hold. */\nexport type PresentationPropertyValue = string | number | boolean | undefined;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentDescriptor } from './ComponentDescriptor.js';
|
|
2
|
+
/** What the registry knows about one rendered component that declared presentation props. */
|
|
3
|
+
export interface RegisteredComponent {
|
|
4
|
+
/** The component's descriptor. */
|
|
5
|
+
readonly descriptor: ComponentDescriptor;
|
|
6
|
+
/** The props the component was rendered with, before any live preview was applied. */
|
|
7
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=RegisteredComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisteredComponent.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/RegisteredComponent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,6FAA6F;AAC7F,MAAM,WAAW,mBAAmB;IAChC,kCAAkC;IAClC,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IACzC,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisteredComponent.js","sourceRoot":"","sources":["../../../../configuration/identity/RegisteredComponent.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 type { ComponentDescriptor } from './ComponentDescriptor';\n\n/** What the registry knows about one rendered component that declared presentation props. */\nexport interface RegisteredComponent {\n /** The component's descriptor. */\n readonly descriptor: ComponentDescriptor;\n /** The props the component was rendered with, before any live preview was applied. */\n readonly props: Readonly<Record<string, unknown>>;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** DOM attribute naming the component an element is the root of. */
|
|
2
|
+
export declare const componentAttribute = "data-cratis-component";
|
|
3
|
+
/** DOM attribute carrying the consumer-supplied `id` or `name` of a component. */
|
|
4
|
+
export declare const componentIdAttribute = "data-cratis-component-id";
|
|
5
|
+
/** DOM attribute linking a component root to its live presentation registration. */
|
|
6
|
+
export declare const componentInstanceAttribute = "data-cratis-component-instance";
|
|
7
|
+
//# sourceMappingURL=componentIdentityAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentIdentityAttributes.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/componentIdentityAttributes.ts"],"names":[],"mappings":"AAGA,oEAAoE;AACpE,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAE/D,oFAAoF;AACpF,eAAO,MAAM,0BAA0B,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const componentAttribute = 'data-cratis-component';
|
|
2
|
+
const componentIdAttribute = 'data-cratis-component-id';
|
|
3
|
+
const componentInstanceAttribute = 'data-cratis-component-instance';
|
|
4
|
+
|
|
5
|
+
export { componentAttribute, componentIdAttribute, componentInstanceAttribute };
|
|
6
|
+
//# sourceMappingURL=componentIdentityAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentIdentityAttributes.js","sources":["../../../../configuration/identity/componentIdentityAttributes.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/** DOM attribute naming the component an element is the root of. */\nexport const componentAttribute = 'data-cratis-component';\n\n/** DOM attribute carrying the consumer-supplied `id` or `name` of a component. */\nexport const componentIdAttribute = 'data-cratis-component-id';\n\n/** DOM attribute linking a component root to its live presentation registration. */\nexport const componentInstanceAttribute = 'data-cratis-component-instance';\n"],"names":[],"mappings":"AAIO,MAAM,kBAAkB,GAAG;AAG3B,MAAM,oBAAoB,GAAG;AAG7B,MAAM,0BAA0B,GAAG;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ComponentDescriptor } from './ComponentDescriptor.js';
|
|
2
|
+
import type { PresentationChange } from './PresentationChange.js';
|
|
3
|
+
import type { RegisteredComponent } from './RegisteredComponent.js';
|
|
4
|
+
/** Records the props a component instance was rendered with. Called by `useComponentPresentation`. */
|
|
5
|
+
export declare const registerComponentInstance: (key: string, descriptor: ComponentDescriptor, props: object) => void;
|
|
6
|
+
/** Removes a component instance when it unmounts. */
|
|
7
|
+
export declare const unregisterComponentInstance: (key: string) => void;
|
|
8
|
+
/** Subscribes to live-preview changes of one component instance. */
|
|
9
|
+
export declare const subscribeToComponentPreview: (key: string, listener: () => void) => (() => void);
|
|
10
|
+
/** The live-preview overrides currently applied to one component instance. */
|
|
11
|
+
export declare const componentPreviewOverrides: (key: string) => Readonly<Record<string, unknown>>;
|
|
12
|
+
/**
|
|
13
|
+
* Reads what a rendered component registered, from the component root element.
|
|
14
|
+
* @param element - A component root element (an element carrying `data-cratis-component`).
|
|
15
|
+
* @returns The registration, or `undefined` when the component declares no presentation props.
|
|
16
|
+
*/
|
|
17
|
+
export declare const registeredComponentFor: (element: Element) => RegisteredComponent | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Every descriptor registered so far, by component name. A component appears here once an
|
|
20
|
+
* instance of it has rendered.
|
|
21
|
+
*/
|
|
22
|
+
export declare const knownComponentDescriptors: () => readonly ComponentDescriptor[];
|
|
23
|
+
/**
|
|
24
|
+
* Applies proposed changes to a rendered component so a host can preview them live.
|
|
25
|
+
* @param element - The component root element.
|
|
26
|
+
* @param changes - The changes to apply.
|
|
27
|
+
* @returns A function that removes exactly these changes again. Calling it twice is harmless.
|
|
28
|
+
*/
|
|
29
|
+
export declare const previewPresentationChanges: (element: Element, changes: readonly PresentationChange[]) => (() => void);
|
|
30
|
+
//# sourceMappingURL=componentInstances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentInstances.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/componentInstances.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AA8BjE,sGAAsG;AACtG,eAAO,MAAM,yBAAyB,QAC7B,MAAM,cACC,mBAAmB,SACxB,MAAM,KACd,IAKF,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,2BAA2B,QAAS,MAAM,KAAG,IAEzD,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,2BAA2B,QAAS,MAAM,YAAY,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAM1F,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,yBAAyB,QAAS,MAAM,KAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC1C,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,YAAa,OAAO,KAAG,mBAAmB,GAAG,SAI/E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAAO,SAAS,mBAAmB,EAAmC,CAAC;AAE7G;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,YAC1B,OAAO,WACP,SAAS,kBAAkB,EAAE,KACvC,CAAC,MAAM,IAAI,CAWb,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { componentInstanceAttribute } from './componentIdentityAttributes.js';
|
|
2
|
+
|
|
3
|
+
const noOverrides = Object.freeze({});
|
|
4
|
+
const entries = new Map();
|
|
5
|
+
const seenDescriptors = new Map();
|
|
6
|
+
const ensure = (key) => {
|
|
7
|
+
let entry = entries.get(key);
|
|
8
|
+
if (!entry) {
|
|
9
|
+
entry = { props: {}, previews: new Map(), overrides: noOverrides, listeners: new Set() };
|
|
10
|
+
entries.set(key, entry);
|
|
11
|
+
}
|
|
12
|
+
return entry;
|
|
13
|
+
};
|
|
14
|
+
const recompute = (entry) => {
|
|
15
|
+
const merged = {};
|
|
16
|
+
for (const preview of entry.previews.values())
|
|
17
|
+
Object.assign(merged, preview);
|
|
18
|
+
entry.overrides = Object.keys(merged).length === 0 ? noOverrides : merged;
|
|
19
|
+
for (const listener of [...entry.listeners])
|
|
20
|
+
listener();
|
|
21
|
+
};
|
|
22
|
+
const registerComponentInstance = (key, descriptor, props) => {
|
|
23
|
+
const entry = ensure(key);
|
|
24
|
+
entry.descriptor = descriptor;
|
|
25
|
+
entry.props = props;
|
|
26
|
+
seenDescriptors.set(descriptor.component, descriptor);
|
|
27
|
+
};
|
|
28
|
+
const unregisterComponentInstance = (key) => {
|
|
29
|
+
entries.delete(key);
|
|
30
|
+
};
|
|
31
|
+
const subscribeToComponentPreview = (key, listener) => {
|
|
32
|
+
const entry = ensure(key);
|
|
33
|
+
entry.listeners.add(listener);
|
|
34
|
+
return () => {
|
|
35
|
+
entry.listeners.delete(listener);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const componentPreviewOverrides = (key) => entries.get(key)?.overrides ?? noOverrides;
|
|
39
|
+
const registeredComponentFor = (element) => {
|
|
40
|
+
const key = element.getAttribute(componentInstanceAttribute);
|
|
41
|
+
const entry = key ? entries.get(key) : undefined;
|
|
42
|
+
return entry?.descriptor ? { descriptor: entry.descriptor, props: entry.props } : undefined;
|
|
43
|
+
};
|
|
44
|
+
const knownComponentDescriptors = () => [...seenDescriptors.values()];
|
|
45
|
+
const previewPresentationChanges = (element, changes) => {
|
|
46
|
+
const key = element.getAttribute(componentInstanceAttribute);
|
|
47
|
+
const entry = key ? entries.get(key) : undefined;
|
|
48
|
+
if (!entry)
|
|
49
|
+
return () => undefined;
|
|
50
|
+
const token = Symbol('preview');
|
|
51
|
+
entry.previews.set(token, Object.fromEntries(changes.map((change) => [change.property, change.to])));
|
|
52
|
+
recompute(entry);
|
|
53
|
+
return () => {
|
|
54
|
+
if (!entry.previews.delete(token))
|
|
55
|
+
return;
|
|
56
|
+
recompute(entry);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { componentPreviewOverrides, knownComponentDescriptors, previewPresentationChanges, registerComponentInstance, registeredComponentFor, subscribeToComponentPreview, unregisterComponentInstance };
|
|
61
|
+
//# sourceMappingURL=componentInstances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentInstances.js","sources":["../../../../configuration/identity/componentInstances.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 type { ComponentDescriptor } from './ComponentDescriptor';\nimport { componentInstanceAttribute } from './componentIdentityAttributes';\nimport type { PresentationChange } from './PresentationChange';\nimport type { RegisteredComponent } from './RegisteredComponent';\n\ninterface Entry {\n descriptor?: ComponentDescriptor;\n props: Record<string, unknown>;\n previews: Map<symbol, Record<string, unknown>>;\n overrides: Readonly<Record<string, unknown>>;\n listeners: Set<() => void>;\n}\n\nconst noOverrides: Readonly<Record<string, unknown>> = Object.freeze({});\nconst entries = new Map<string, Entry>();\nconst seenDescriptors = new Map<string, ComponentDescriptor>();\n\nconst ensure = (key: string): Entry => {\n let entry = entries.get(key);\n if (!entry) {\n entry = { props: {}, previews: new Map(), overrides: noOverrides, listeners: new Set() };\n entries.set(key, entry);\n }\n return entry;\n};\n\nconst recompute = (entry: Entry) => {\n const merged: Record<string, unknown> = {};\n for (const preview of entry.previews.values()) Object.assign(merged, preview);\n entry.overrides = Object.keys(merged).length === 0 ? noOverrides : merged;\n for (const listener of [...entry.listeners]) listener();\n};\n\n/** Records the props a component instance was rendered with. Called by `useComponentPresentation`. */\nexport const registerComponentInstance = (\n key: string,\n descriptor: ComponentDescriptor,\n props: object,\n): void => {\n const entry = ensure(key);\n entry.descriptor = descriptor;\n entry.props = props as Record<string, unknown>;\n seenDescriptors.set(descriptor.component, descriptor);\n};\n\n/** Removes a component instance when it unmounts. */\nexport const unregisterComponentInstance = (key: string): void => {\n entries.delete(key);\n};\n\n/** Subscribes to live-preview changes of one component instance. */\nexport const subscribeToComponentPreview = (key: string, listener: () => void): (() => void) => {\n const entry = ensure(key);\n entry.listeners.add(listener);\n return () => {\n entry.listeners.delete(listener);\n };\n};\n\n/** The live-preview overrides currently applied to one component instance. */\nexport const componentPreviewOverrides = (key: string): Readonly<Record<string, unknown>> =>\n entries.get(key)?.overrides ?? noOverrides;\n\n/**\n * Reads what a rendered component registered, from the component root element.\n * @param element - A component root element (an element carrying `data-cratis-component`).\n * @returns The registration, or `undefined` when the component declares no presentation props.\n */\nexport const registeredComponentFor = (element: Element): RegisteredComponent | undefined => {\n const key = element.getAttribute(componentInstanceAttribute);\n const entry = key ? entries.get(key) : undefined;\n return entry?.descriptor ? { descriptor: entry.descriptor, props: entry.props } : undefined;\n};\n\n/**\n * Every descriptor registered so far, by component name. A component appears here once an\n * instance of it has rendered.\n */\nexport const knownComponentDescriptors = (): readonly ComponentDescriptor[] => [...seenDescriptors.values()];\n\n/**\n * Applies proposed changes to a rendered component so a host can preview them live.\n * @param element - The component root element.\n * @param changes - The changes to apply.\n * @returns A function that removes exactly these changes again. Calling it twice is harmless.\n */\nexport const previewPresentationChanges = (\n element: Element,\n changes: readonly PresentationChange[],\n): (() => void) => {\n const key = element.getAttribute(componentInstanceAttribute);\n const entry = key ? entries.get(key) : undefined;\n if (!entry) return () => undefined;\n const token = Symbol('preview');\n entry.previews.set(token, Object.fromEntries(changes.map((change) => [change.property, change.to])));\n recompute(entry);\n return () => {\n if (!entry.previews.delete(token)) return;\n recompute(entry);\n };\n};\n"],"names":[],"mappings":";;AAgBA,MAAM,WAAW,GAAsC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AACxE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAiB;AACxC,MAAM,eAAe,GAAG,IAAI,GAAG,EAA+B;AAE9D,MAAM,MAAM,GAAG,CAAC,GAAW,KAAW;IAClC,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAC5B,IAAI,CAAC,KAAK,EAAE;QACR,KAAK,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,GA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AACL;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentMarkerAttributes } from './ComponentMarkerAttributes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Identity attributes for a component root.
|
|
4
|
+
* @param component - The public component name, for example `Button`.
|
|
5
|
+
* @param id - The consumer's `id` or `name`, when the component was given one.
|
|
6
|
+
* @returns The attributes to spread onto the root element.
|
|
7
|
+
*/
|
|
8
|
+
export declare const componentMarker: (component: string, id?: string | null) => ComponentMarkerAttributes;
|
|
9
|
+
//# sourceMappingURL=componentMarker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentMarker.d.ts","sourceRoot":"","sources":["../../../../configuration/identity/componentMarker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAA6B,CAAC;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,eAAe,cAAe,MAAM,OAAO,MAAM,GAAG,IAAI,KAAG,yBAGtE,CAAC"}
|