@case-framework/survey-ui 0.2.0 → 0.2.2
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/dist/components/c-ui/alert-provider.d.ts +18 -0
- package/dist/components/c-ui/confirm-dialog.d.ts +19 -0
- package/dist/components/c-ui/confirm-provider.d.ts +15 -0
- package/dist/components/c-ui/filepicker-dropzone.d.ts +38 -0
- package/dist/components/c-ui/loading-button.d.ts +9 -0
- package/dist/components/inputs/Filepicker.d.ts +14 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert.d.ts +9 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/breadcrumb.d.ts +11 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/command.d.ts +20 -0
- package/dist/components/ui/context-menu.d.ts +25 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/sonner.d.ts +3 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/dev/_components/nav-input.d.ts +35 -0
- package/dist/dev/app.d.ts +2 -0
- package/dist/dev/main.d.ts +0 -0
- package/dist/index.d.ts +9 -478
- package/dist/lib/utils.d.ts +2 -0
- package/dist/modules/default-item-registry/built-in-preview-renderers.d.ts +3 -0
- package/dist/modules/default-item-registry/default-item-cores.d.ts +33 -0
- package/dist/modules/default-item-registry/default-registry-entries.d.ts +2 -0
- package/dist/modules/default-item-registry/editors/editor-card-for-group.d.ts +3 -0
- package/dist/modules/default-item-registry/editors/editor-card-for-root.d.ts +3 -0
- package/dist/modules/default-item-registry/editors/editor-card-for-scg-mcg.d.ts +3 -0
- package/dist/modules/default-item-registry/index.d.ts +19 -0
- package/dist/modules/survey-editor/_components/sortable/sortable-item.d.ts +5 -0
- package/dist/modules/survey-editor/_components/sortable/sortable-wrapper.d.ts +21 -0
- package/dist/modules/survey-editor/ai/types.d.ts +88 -0
- package/dist/modules/survey-editor/editor-card/add-items/constants.d.ts +5 -0
- package/dist/modules/survey-editor/editor-card/add-items/hooks/use-add-item-actions.d.ts +25 -0
- package/dist/modules/survey-editor/editor-card/add-items/hooks/use-add-item-target.d.ts +9 -0
- package/dist/modules/survey-editor/editor-card/add-items/hooks/use-option-group-navigation.d.ts +19 -0
- package/dist/modules/survey-editor/editor-card/add-items/types.d.ts +21 -0
- package/dist/modules/survey-editor/editor-card/add-items/views/ai-item-view.d.ts +10 -0
- package/dist/modules/survey-editor/editor-card/add-items/views/back-button.d.ts +5 -0
- package/dist/modules/survey-editor/editor-card/add-items/views/blank-item-view.d.ts +13 -0
- package/dist/modules/survey-editor/editor-card/add-items/views/entry-view.d.ts +15 -0
- package/dist/modules/survey-editor/editor-card/add-items/views/structure-view.d.ts +16 -0
- package/dist/modules/survey-editor/editor-card/add-items.d.ts +1 -0
- package/dist/modules/survey-editor/editor-card/copy-item-dropdown-menu.d.ts +5 -0
- package/dist/modules/survey-editor/editor-card/delete-item-context-menu.d.ts +5 -0
- package/dist/modules/survey-editor/editor-card/delete-item-dropdown-menu.d.ts +5 -0
- package/dist/modules/survey-editor/editor-card/group-items.d.ts +2 -0
- package/dist/modules/survey-editor/editor-card/hooks/use-group-list-keyboard.d.ts +35 -0
- package/dist/modules/survey-editor/editor-card/index.d.ts +2 -0
- package/dist/modules/survey-editor/editor-card/item-color-menu.d.ts +6 -0
- package/dist/modules/survey-editor/editor-card/item-color-selector.d.ts +5 -0
- package/dist/modules/survey-editor/editor-card/item-editor-card-skeleton.d.ts +2 -0
- package/dist/modules/survey-editor/editor-card/item-editor-card.d.ts +21 -0
- package/dist/modules/survey-editor/editor-card/item-editor-context.d.ts +20 -0
- package/dist/modules/survey-editor/editor-card/item-key-editor.d.ts +9 -0
- package/dist/modules/survey-editor/editor-card/item-label-preview-and-editor.d.ts +9 -0
- package/dist/modules/survey-editor/editor-card/item-preview.d.ts +8 -0
- package/dist/modules/survey-editor/editor-card/item-type-icon-with-tooltip.d.ts +8 -0
- package/dist/modules/survey-editor/editor-instance-provider.d.ts +7 -0
- package/dist/modules/survey-editor/hooks/useClipboardValue.d.ts +2 -0
- package/dist/modules/survey-editor/hooks/useDeleteItem.d.ts +9 -0
- package/dist/modules/survey-editor/hooks/useEditor.d.ts +12 -0
- package/dist/modules/survey-editor/hooks/useEditorStateChange.d.ts +17 -0
- package/dist/modules/survey-editor/hooks/useKeyboardShortcuts.d.ts +7 -0
- package/dist/modules/survey-editor/index.d.ts +7 -0
- package/dist/modules/survey-editor/navigation/navigation-provider.d.ts +11 -0
- package/dist/modules/survey-editor/navigation/navigation.d.ts +13 -0
- package/dist/modules/survey-editor/navigation/types.d.ts +18 -0
- package/dist/modules/survey-editor/primitives/input-with-ai-popover.d.ts +35 -0
- package/dist/modules/survey-editor/registry/index.d.ts +7 -0
- package/dist/modules/survey-editor/registry/registry-mappers.d.ts +19 -0
- package/dist/modules/survey-editor/registry/search-adapter.d.ts +19 -0
- package/dist/modules/survey-editor/registry/types.d.ts +154 -0
- package/dist/modules/survey-editor/routes/editor/_components/footer.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/_components/history-stack.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/_components/main.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/_components/sidebar.d.ts +7 -0
- package/dist/modules/survey-editor/routes/editor/index.d.ts +5 -0
- package/dist/modules/survey-editor/routes/editor/item-editor/_components/item-editor-toolbar/breadcrumbs-nav.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/item-editor/_components/item-editor-toolbar/item-editor-toolbar.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/item-editor/_components/item-editor-toolbar/language-picker.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/item-editor/_components/item-editor-toolbar/search-trigger.d.ts +3 -0
- package/dist/modules/survey-editor/routes/editor/item-editor/_components/item-editor-toolbar/survey-search.d.ts +7 -0
- package/dist/modules/survey-editor/routes/editor/item-editor/index.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/simulator/index.d.ts +2 -0
- package/dist/modules/survey-editor/routes/editor/translation-mode/index.d.ts +2 -0
- package/dist/modules/survey-editor/session-file.d.ts +13 -0
- package/dist/modules/survey-editor/store/editor-store-context.d.ts +10 -0
- package/dist/modules/survey-editor/store/editor-store-provider.d.ts +7 -0
- package/dist/modules/survey-editor/store/editor-store.d.ts +96 -0
- package/dist/modules/survey-editor/store/use-editor-store.d.ts +4 -0
- package/dist/modules/survey-editor/store/useItemNavigation.d.ts +7 -0
- package/dist/modules/survey-editor/survey-editor-config.d.ts +17 -0
- package/dist/modules/survey-editor/survey-editor.d.ts +20 -0
- package/dist/modules/survey-editor/utils/item-type-infos.d.ts +23 -0
- package/dist/modules/survey-player/index.d.ts +1 -0
- package/dist/modules/survey-player/survey-context.d.ts +23 -0
- package/dist/modules/survey-player/survey-item/survey-item-context.d.ts +17 -0
- package/dist/modules/survey-player/survey-item/survey-item-types/question-wrapper.d.ts +5 -0
- package/dist/modules/survey-player/survey-item/survey-item-types/single-choice-question-renderer.d.ts +7 -0
- package/dist/modules/survey-player/survey-item/survey-item.d.ts +7 -0
- package/dist/modules/survey-player/survey-player.d.ts +2 -0
- package/dist/styles.cjs.js +0 -0
- package/dist/styles.css +2 -0
- package/dist/styles.d.ts +0 -0
- package/dist/styles.es.js +0 -0
- package/dist/survey-ui.cjs.js.map +1 -1
- package/dist/survey-ui.es.js.map +1 -1
- package/package.json +2 -2
- package/dist/survey-ui.css +0 -3
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { ItemCoreConstructor, ItemTypeRegistry, RawSurveyItem, SurveyItemCore, RenderedSurveyItem, SurveyItemTranslations } from '@case-framework/survey-core';
|
|
2
|
+
import { Target } from '@case-framework/survey-core/editor';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
import { ItemSearchAdapter } from './search-adapter';
|
|
5
|
+
export type ItemCategory = string;
|
|
6
|
+
export type ItemLocaleMap = Record<string, string>;
|
|
7
|
+
export type ItemIconComponent = React.ComponentType<{
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export interface ItemEditorComponentProps<TItem extends SurveyItemCore = SurveyItemCore> {
|
|
11
|
+
item: TItem;
|
|
12
|
+
}
|
|
13
|
+
export interface ItemRendererComponentProps {
|
|
14
|
+
renderedItem: RenderedSurveyItem;
|
|
15
|
+
}
|
|
16
|
+
export type ItemPreviewMode = "interactive" | "static";
|
|
17
|
+
export interface ItemPreviewComponentProps<TItem extends SurveyItemCore = SurveyItemCore> {
|
|
18
|
+
item: TItem;
|
|
19
|
+
itemConfig: TItem["config"];
|
|
20
|
+
itemContent?: SurveyItemTranslations;
|
|
21
|
+
locale: string;
|
|
22
|
+
mode?: ItemPreviewMode;
|
|
23
|
+
}
|
|
24
|
+
export interface ItemEditorCapabilities {
|
|
25
|
+
usesValidationPanel?: boolean;
|
|
26
|
+
usesTranslationPanel?: boolean;
|
|
27
|
+
usesConditionsPanel?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface ItemInitialData {
|
|
30
|
+
rawItem: RawSurveyItem;
|
|
31
|
+
translations?: SurveyItemTranslations;
|
|
32
|
+
children?: ItemInitialData[];
|
|
33
|
+
}
|
|
34
|
+
export interface ItemInfos {
|
|
35
|
+
icon: ItemIconComponent;
|
|
36
|
+
labelByLocale: ItemLocaleMap;
|
|
37
|
+
descriptionByLocale: ItemLocaleMap;
|
|
38
|
+
defaultItemClassName?: string;
|
|
39
|
+
categories: ItemCategory[];
|
|
40
|
+
}
|
|
41
|
+
export interface CreateItemContext {
|
|
42
|
+
editor: {
|
|
43
|
+
addItem: (target: Target, item: SurveyItemCore, content?: SurveyItemTranslations) => void;
|
|
44
|
+
};
|
|
45
|
+
targetParentId: string;
|
|
46
|
+
constructor: ItemCoreConstructor;
|
|
47
|
+
}
|
|
48
|
+
export interface EditorItemDefinition {
|
|
49
|
+
itemType: string;
|
|
50
|
+
infos: ItemInfos;
|
|
51
|
+
editorComponent?: React.ComponentType<ItemEditorComponentProps>;
|
|
52
|
+
renderComponent?: React.ComponentType<ItemRendererComponentProps>;
|
|
53
|
+
previewComponent?: React.ComponentType<ItemPreviewComponentProps>;
|
|
54
|
+
capabilities?: ItemEditorCapabilities;
|
|
55
|
+
isRootOnly?: boolean;
|
|
56
|
+
getInitialItem?: () => ItemInitialData;
|
|
57
|
+
createItem?: (ctx: CreateItemContext) => string;
|
|
58
|
+
searchAdapters?: ItemSearchAdapter[];
|
|
59
|
+
includeDefaultSearchAdapter?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export type EditorItemDefinitionRegistry = Record<string, EditorItemDefinition>;
|
|
62
|
+
export interface ComposedEditorItemRegistry {
|
|
63
|
+
coreRegistry: ItemTypeRegistry;
|
|
64
|
+
definitions: EditorItemDefinitionRegistry;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Unified registry entry type, reusable across contexts:
|
|
68
|
+
*
|
|
69
|
+
* - Participant app: needs only `constructor` + `renderComponent`
|
|
70
|
+
* - Editor: needs constructor, infos, `previewComponent`, editorComponent, searchAdapters, etc.
|
|
71
|
+
*
|
|
72
|
+
* Use the mapper helpers to derive ItemTypeRegistry, participant registry, or editor registry.
|
|
73
|
+
*/
|
|
74
|
+
export interface ItemRegistryEntry {
|
|
75
|
+
itemType: string;
|
|
76
|
+
/** Item core constructor. Omit for built-in types (group, pageBreak) — they use survey-core's built-in registry. Omit for virtual "root" — it maps to Group with isRoot. */
|
|
77
|
+
constructor?: ItemCoreConstructor;
|
|
78
|
+
/** Participant renderer. Required for participant app. */
|
|
79
|
+
renderComponent?: React.ComponentType<ItemRendererComponentProps>;
|
|
80
|
+
/** Editor-only: item preview renderer */
|
|
81
|
+
previewComponent?: React.ComponentType<ItemPreviewComponentProps>;
|
|
82
|
+
/** Editor-only: display metadata */
|
|
83
|
+
infos?: ItemInfos;
|
|
84
|
+
/** Editor-only: card/editor UI */
|
|
85
|
+
editorComponent?: React.ComponentType<ItemEditorComponentProps>;
|
|
86
|
+
/** Editor-only: search integration */
|
|
87
|
+
searchAdapters?: ItemSearchAdapter[];
|
|
88
|
+
/** Editor-only: include built-in key/label/itemType search adapter in addition to custom adapters. Defaults to true. */
|
|
89
|
+
includeDefaultSearchAdapter?: boolean;
|
|
90
|
+
/** Editor-only */
|
|
91
|
+
capabilities?: ItemEditorCapabilities;
|
|
92
|
+
/** Editor-only: default raw item when creating new */
|
|
93
|
+
getInitialItem?: () => ItemInitialData;
|
|
94
|
+
/** Editor-only: custom creation flow (advanced) */
|
|
95
|
+
createItem?: (ctx: CreateItemContext) => string;
|
|
96
|
+
/** Editor-only: hide from add-item options in non-root context */
|
|
97
|
+
isRootOnly?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export type ItemRegistry = Record<string, ItemRegistryEntry>;
|
|
100
|
+
/** Participant registry: core + renderer per item type. Lightweight for survey player. */
|
|
101
|
+
export interface SurveyPlayerItemRegistry {
|
|
102
|
+
coreRegistry: ItemTypeRegistry;
|
|
103
|
+
getRenderer: (itemType: string) => React.ComponentType<ItemRendererComponentProps> | undefined;
|
|
104
|
+
}
|
|
105
|
+
export interface EntriesToParticipantRegistryOptions {
|
|
106
|
+
/** Throw when an entry in the provided list does not define a renderComponent. */
|
|
107
|
+
requireRenderer?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface EntriesToComposedEditorRegistryOptions {
|
|
110
|
+
/** Require built-in editor definitions for group/pageBreak. Defaults to true. */
|
|
111
|
+
requireBuiltInTypes?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export type RegistryValidationMode = "editor" | "player";
|
|
114
|
+
export interface RegistryValidationOptions {
|
|
115
|
+
mode: RegistryValidationMode;
|
|
116
|
+
requireBuiltInTypes?: boolean;
|
|
117
|
+
requireRenderer?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface RegistryValidationIssue {
|
|
120
|
+
code: string;
|
|
121
|
+
message: string;
|
|
122
|
+
itemType?: string;
|
|
123
|
+
}
|
|
124
|
+
export interface RegistryValidationResult {
|
|
125
|
+
errors: RegistryValidationIssue[];
|
|
126
|
+
warnings: RegistryValidationIssue[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Example: unified entry for participant + editor
|
|
130
|
+
*
|
|
131
|
+
* const myEntries: ItemRegistryEntry[] = [
|
|
132
|
+
* {
|
|
133
|
+
* itemType: "singleChoiceQuestion",
|
|
134
|
+
* constructor: SingleChoiceQuestionCore,
|
|
135
|
+
* renderComponent: SingleChoiceQuestionRenderer,
|
|
136
|
+
* previewComponent: SingleChoiceQuestionPreview,
|
|
137
|
+
* infos: { icon: CheckCircle2, labelByLocale: { en: "Single choice" }, ... },
|
|
138
|
+
* editorComponent: EditorCardForScgMcg,
|
|
139
|
+
* searchAdapters: [myCustomSearchAdapter],
|
|
140
|
+
* },
|
|
141
|
+
* // ...
|
|
142
|
+
* ];
|
|
143
|
+
*
|
|
144
|
+
* // Participant app:
|
|
145
|
+
* const participantReg = entriesToParticipantRegistry(myEntries);
|
|
146
|
+
* Survey.fromJson(json, participantReg.coreRegistry);
|
|
147
|
+
* const Renderer = participantReg.getRenderer("singleChoiceQuestion");
|
|
148
|
+
*
|
|
149
|
+
* // Editor:
|
|
150
|
+
* const editorReg = entriesToComposedEditorRegistry(myEntries);
|
|
151
|
+
* // ... use editorReg.coreRegistry + editorReg.definitions
|
|
152
|
+
*/
|
|
153
|
+
export declare const DEFAULT_LOCALE = "en";
|
|
154
|
+
export declare function resolveLocalizedText(map: ItemLocaleMap, locale?: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Survey, ItemTypeRegistry } from '@case-framework/survey-core';
|
|
2
|
+
import { SerializedSurveyEditor } from '@case-framework/survey-core/editor';
|
|
3
|
+
export type ParsedSurveySessionFormat = 'raw-survey' | 'serialized-editor';
|
|
4
|
+
export interface ParsedSurveySession {
|
|
5
|
+
format: ParsedSurveySessionFormat;
|
|
6
|
+
state: SerializedSurveyEditor;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createBlankEditorState(pluginRegistry?: ItemTypeRegistry, surveyKey?: string): SerializedSurveyEditor;
|
|
10
|
+
export declare function createEditorStateFromRawSurvey(rawSurvey: Parameters<typeof Survey.fromJson>[0], pluginRegistry?: ItemTypeRegistry): SerializedSurveyEditor;
|
|
11
|
+
export declare function parseEditorStateFromJsonText(jsonText: string, pluginRegistry?: ItemTypeRegistry): ParsedSurveySession;
|
|
12
|
+
export declare function serializeSurveyStateForFile(state: SerializedSurveyEditor): string;
|
|
13
|
+
export declare function buildSurveyFileName(state: SerializedSurveyEditor, fallback?: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
2
|
+
import { EditorStore } from './editor-store';
|
|
3
|
+
/**
|
|
4
|
+
* Context is split from the provider to avoid React Fast Refresh (HMR) issues.
|
|
5
|
+
* When the provider file is hot-reloaded, re-executing createContext would create
|
|
6
|
+
* a new context instance, causing "must be used within EditorStoreProvider" errors
|
|
7
|
+
* during the brief reconciliation window. Keeping the context in a separate module
|
|
8
|
+
* preserves its identity across HMR updates.
|
|
9
|
+
*/
|
|
10
|
+
export declare const EditorStoreContext: import('react').Context<StoreApi<EditorStore> | null>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Provider only. Hooks live in use-editor-store.ts so that .tsx files
|
|
4
|
+
* export only components — avoiding Fast Refresh invalidation that
|
|
5
|
+
* causes context loss during HMR.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EditorStoreProvider: React.FC<PropsWithChildren>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
2
|
+
import { SurveyEditor, Target, SurveyItemClipboardData, CommitMeta, UndoRedoConfig } from '@case-framework/survey-core/editor';
|
|
3
|
+
import { SurveyItemCore, SurveyItemTranslations, RawSurveyItem, TemplateValueDefinition, GroupItemCore, SurveyCardContent, NavigationContent, Content } from '@case-framework/survey-core';
|
|
4
|
+
import { ComposedEditorItemRegistry, ItemRegistryEntry } from '../registry';
|
|
5
|
+
interface StartNewSessionOptions {
|
|
6
|
+
surveyKey?: string;
|
|
7
|
+
/** Unified registry entries (recommended, matches SurveyEditor) */
|
|
8
|
+
itemRegistryEntries?: ItemRegistryEntry[];
|
|
9
|
+
}
|
|
10
|
+
export interface EditorStore {
|
|
11
|
+
/** Current survey/session id when editor is loaded */
|
|
12
|
+
sessionId: string | null;
|
|
13
|
+
/** The SurveyEditor instance - null when no editor is loaded */
|
|
14
|
+
editor: SurveyEditor | null;
|
|
15
|
+
/** Incremented on every mutation; select this to force re-renders when editor changes */
|
|
16
|
+
changeTick: number;
|
|
17
|
+
/** Composed item registry used by editor UI features. */
|
|
18
|
+
editorItemRegistry: ComposedEditorItemRegistry;
|
|
19
|
+
selectedLocale: string;
|
|
20
|
+
/** Set the active editor (call when opening a session) */
|
|
21
|
+
setEditor: (surveyId: string | null, editor: SurveyEditor | null) => void;
|
|
22
|
+
/** Clear the active editor (call when closing/unmounting to avoid stale state on next mount) */
|
|
23
|
+
clearEditor: () => void;
|
|
24
|
+
/** Create and set a new blank survey editor (starts a new session) */
|
|
25
|
+
startNewSession: (options: StartNewSessionOptions) => void;
|
|
26
|
+
setEditorItemRegistry: (registry: ComposedEditorItemRegistry) => void;
|
|
27
|
+
setSelectedLocale: (locale: string) => void;
|
|
28
|
+
undo: () => boolean;
|
|
29
|
+
redo: () => boolean;
|
|
30
|
+
canUndo: () => boolean;
|
|
31
|
+
canRedo: () => boolean;
|
|
32
|
+
commit: (meta: CommitMeta) => void;
|
|
33
|
+
commitByUser: (meta: Omit<CommitMeta, "source">) => void;
|
|
34
|
+
commitIfNeeded: () => void;
|
|
35
|
+
jumpToIndexInHistory: (targetIndex: number) => boolean;
|
|
36
|
+
getUndoMeta: () => CommitMeta | null;
|
|
37
|
+
getRedoMeta: () => CommitMeta | null;
|
|
38
|
+
getUndoRedoHistory: () => Array<{
|
|
39
|
+
index: number;
|
|
40
|
+
meta: CommitMeta;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
memorySize: number;
|
|
43
|
+
isCurrent: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
addItem: (target: Target | null, item: SurveyItemCore, content?: SurveyItemTranslations) => void;
|
|
46
|
+
removeItem: (itemId: string, nested?: boolean) => boolean;
|
|
47
|
+
moveItem: (itemId: string, newTarget: Target) => boolean;
|
|
48
|
+
updateItemTranslations: (itemId: string, updatedContent?: SurveyItemTranslations) => boolean;
|
|
49
|
+
copyItem: (itemId: string) => SurveyItemClipboardData;
|
|
50
|
+
pasteItem: (clipboardData: SurveyItemClipboardData, target: Target) => string;
|
|
51
|
+
getRootItem: () => GroupItemCore | undefined;
|
|
52
|
+
getItemDataCopy: (itemId: string) => RawSurveyItem;
|
|
53
|
+
updateItem: (itemId: string, rawItemData: RawSurveyItem | Partial<RawSurveyItem>) => void;
|
|
54
|
+
updateSurveyTranslations: (updates: {
|
|
55
|
+
surveyCard?: {
|
|
56
|
+
locale: string;
|
|
57
|
+
content?: SurveyCardContent;
|
|
58
|
+
};
|
|
59
|
+
navigation?: {
|
|
60
|
+
locale: string;
|
|
61
|
+
content?: NavigationContent;
|
|
62
|
+
};
|
|
63
|
+
validationMessages?: {
|
|
64
|
+
locale: string;
|
|
65
|
+
content?: {
|
|
66
|
+
invalidResponse?: Content;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}) => void;
|
|
70
|
+
getMaxItemsPerPage: () => {
|
|
71
|
+
large: number;
|
|
72
|
+
small: number;
|
|
73
|
+
} | undefined;
|
|
74
|
+
updateMaxItemsPerPage: (value: {
|
|
75
|
+
large: number;
|
|
76
|
+
small: number;
|
|
77
|
+
} | undefined) => void;
|
|
78
|
+
getMetadata: () => {
|
|
79
|
+
[key: string]: string;
|
|
80
|
+
} | undefined;
|
|
81
|
+
updateMetadata: (metadata: {
|
|
82
|
+
[key: string]: string;
|
|
83
|
+
} | undefined) => void;
|
|
84
|
+
getTemplateValue: (key: string) => TemplateValueDefinition | undefined;
|
|
85
|
+
getTemplateValues: () => Map<string, TemplateValueDefinition>;
|
|
86
|
+
setTemplateValue: (key: string, templateValue: TemplateValueDefinition) => void;
|
|
87
|
+
removeTemplateValue: (key: string) => void;
|
|
88
|
+
getMemoryUsage: () => {
|
|
89
|
+
totalMB: number;
|
|
90
|
+
entries: number;
|
|
91
|
+
};
|
|
92
|
+
getUndoRedoConfig: () => UndoRedoConfig;
|
|
93
|
+
}
|
|
94
|
+
export type EditorStoreApi = StoreApi<EditorStore>;
|
|
95
|
+
export declare function createEditorStore(): EditorStoreApi;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SurveyEditorAIProvider } from './ai/types';
|
|
3
|
+
interface SurveyEditorConfigType {
|
|
4
|
+
helpLink: string;
|
|
5
|
+
aiProvider: SurveyEditorAIProvider | null;
|
|
6
|
+
fallbackLocale: string;
|
|
7
|
+
}
|
|
8
|
+
interface SurveyEditorConfigProviderProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
helpLink: string;
|
|
11
|
+
aiProvider?: SurveyEditorAIProvider | null;
|
|
12
|
+
fallbackLocale?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const SurveyEditorConfigProvider: React.FC<SurveyEditorConfigProviderProps>;
|
|
15
|
+
export declare const useSurveyEditorConfig: () => SurveyEditorConfigType;
|
|
16
|
+
export declare const useSurveyEditorAIProvider: () => SurveyEditorAIProvider | null;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SerializedSurveyEditor } from '@case-framework/survey-core/editor';
|
|
2
|
+
import { EditorStateChangePayload } from './hooks/useEditorStateChange';
|
|
3
|
+
import { SurveyEditorNavigationAdapter } from './navigation/types';
|
|
4
|
+
import { ItemRegistryEntry } from './registry';
|
|
5
|
+
import { SurveyEditorAIProvider } from './ai/types';
|
|
6
|
+
export type SurveyEditorStateChange = EditorStateChangePayload;
|
|
7
|
+
export interface SurveyEditorProps {
|
|
8
|
+
initialEditorState?: SerializedSurveyEditor;
|
|
9
|
+
initialSessionId?: string;
|
|
10
|
+
fallbackLocale?: string;
|
|
11
|
+
itemRegistryEntries?: ItemRegistryEntry[];
|
|
12
|
+
onEditorStateChange?: (change: SurveyEditorStateChange) => void;
|
|
13
|
+
persistDebounceMs?: number;
|
|
14
|
+
helpLink?: string;
|
|
15
|
+
navigationAdapter?: SurveyEditorNavigationAdapter | null;
|
|
16
|
+
aiProvider?: SurveyEditorAIProvider | null;
|
|
17
|
+
onSaveRequested?: () => void;
|
|
18
|
+
}
|
|
19
|
+
declare const SurveyEditor: React.FC<SurveyEditorProps>;
|
|
20
|
+
export { SurveyEditor };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SurveyItemCore } from '@case-framework/survey-core';
|
|
2
|
+
import { ComposedEditorItemRegistry, ItemIconComponent } from '../registry';
|
|
3
|
+
export declare const builtInItemColors: string[];
|
|
4
|
+
export declare const getItemColorFromID: (id: string) => string;
|
|
5
|
+
export declare const getItemColor: (surveyItem: SurveyItemCore) => string | undefined;
|
|
6
|
+
/** Returns the registry key for an item ("root" for root groups, otherwise item.type). */
|
|
7
|
+
export declare const getItemTypeKey: (item: SurveyItemCore) => string;
|
|
8
|
+
export interface ItemTypeInfos {
|
|
9
|
+
key: string;
|
|
10
|
+
label: string;
|
|
11
|
+
description: string;
|
|
12
|
+
defaultItemClassName?: string;
|
|
13
|
+
icon: ItemIconComponent;
|
|
14
|
+
}
|
|
15
|
+
export declare const getItemTypeInfos: (item: SurveyItemCore, registry?: ComposedEditorItemRegistry) => ItemTypeInfos;
|
|
16
|
+
export declare const getItemTypeInfosByType: (itemType: string | undefined, registry?: ComposedEditorItemRegistry) => ItemTypeInfos | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Hook to access item type infos for a specific item type.
|
|
19
|
+
* Pass an item type string (e.g. "singleChoiceQuestion", "root") or undefined.
|
|
20
|
+
* Returns undefined when itemType is undefined.
|
|
21
|
+
* Must be used within EditorStoreProvider.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useItemTypeInfos(itemType: string | undefined): ItemTypeInfos | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SurveyPlayer } from './survey-player';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Survey, SurveyEngineCore } from '@case-framework/survey-core';
|
|
3
|
+
export type HandlerFuncArgType = string | number | boolean | null | undefined;
|
|
4
|
+
export type HandlerFunction = (handlerId: string, args?: HandlerFuncArgType[]) => Promise<{
|
|
5
|
+
error?: string;
|
|
6
|
+
result?: HandlerFuncArgType;
|
|
7
|
+
}>;
|
|
8
|
+
interface SurveyContextValue {
|
|
9
|
+
survey: Survey;
|
|
10
|
+
locale: string;
|
|
11
|
+
surveyEngine: SurveyEngineCore;
|
|
12
|
+
runExternalHandler?: HandlerFunction;
|
|
13
|
+
}
|
|
14
|
+
interface SurveyContextProviderProps {
|
|
15
|
+
survey: Survey;
|
|
16
|
+
locale: string;
|
|
17
|
+
surveyEngine: SurveyEngineCore;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
onRunExternalHandler?: HandlerFunction;
|
|
20
|
+
}
|
|
21
|
+
export declare const SurveyContextProvider: React.FC<SurveyContextProviderProps>;
|
|
22
|
+
export declare const useSurveyCtx: () => SurveyContextValue;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RenderedSurveyItem, ResponseItem, SurveyItemCore, SurveyItemTranslations } from '@case-framework/survey-core';
|
|
2
|
+
interface SurveyItemContextValue {
|
|
3
|
+
item: SurveyItemCore;
|
|
4
|
+
renderedItemInfos: RenderedSurveyItem;
|
|
5
|
+
itemTranslations?: SurveyItemTranslations;
|
|
6
|
+
currentResponse?: ResponseItem;
|
|
7
|
+
headerId: string;
|
|
8
|
+
width: number;
|
|
9
|
+
setResponse(response?: ResponseItem): void;
|
|
10
|
+
}
|
|
11
|
+
interface SurveyItemContextProviderProps {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
renderedItemInfos: RenderedSurveyItem;
|
|
14
|
+
}
|
|
15
|
+
export declare const SurveyItemContextProvider: React.FC<SurveyItemContextProviderProps>;
|
|
16
|
+
export declare const useSurveyItemCtx: () => SurveyItemContextValue;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { RenderedSurveyItem } from '@case-framework/survey-core';
|
|
3
|
+
interface SingleChoiceQuestionRendererProps {
|
|
4
|
+
renderedItem?: RenderedSurveyItem;
|
|
5
|
+
}
|
|
6
|
+
declare const SingleChoiceQuestionRenderer: React.FC<SingleChoiceQuestionRendererProps>;
|
|
7
|
+
export default SingleChoiceQuestionRenderer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { RenderedSurveyItem } from '@case-framework/survey-core';
|
|
3
|
+
interface SurveyItemRendererProps {
|
|
4
|
+
item: RenderedSurveyItem;
|
|
5
|
+
}
|
|
6
|
+
declare const SurveyItemRenderer: React.FC<SurveyItemRendererProps>;
|
|
7
|
+
export default SurveyItemRenderer;
|
|
File without changes
|