@pushwoosh/dumb-components 1.1.147 → 1.1.149
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/AccessForbidden/AccessForbidden.d.ts +3 -0
- package/AccessForbidden/AccessForbidden.js +3 -0
- package/Alert/Alert.d.ts +7 -0
- package/Alert/Alert.js +7 -0
- package/Alert/types.d.ts +6 -0
- package/ApplicationPreloader/ApplicationPreloader.d.ts +8 -0
- package/ApplicationPreloader/ApplicationPreloader.js +6 -0
- package/Badge/Badge.d.ts +6 -0
- package/Badge/Badge.js +6 -0
- package/Badge/types.d.ts +6 -0
- package/Banner/Banner.d.ts +7 -0
- package/Banner/Banner.js +7 -0
- package/Banner/types.d.ts +16 -0
- package/Button/Button.d.ts +19 -0
- package/Button/GhostButton.d.ts +1 -0
- package/Button/GhostButton.js +1 -0
- package/Button/RemoveButton.d.ts +6 -0
- package/Button/RemoveButton.js +6 -0
- package/Button/types.d.ts +21 -0
- package/Calendar/CalendarDropdown/CalendarDropdown.d.ts +12 -0
- package/Calendar/CalendarDropdown/CalendarDropdown.js +12 -0
- package/Calendar/CalendarDropdown/helpers.d.ts +4 -0
- package/Calendar/CalendarDropdown/helpers.js +4 -0
- package/Calendar/CalendarDropdown/types.d.ts +33 -0
- package/Calendar/CalendarSuperForm/CalendarSuperForm.d.ts +7 -0
- package/Calendar/CalendarSuperForm/CalendarSuperForm.js +10 -1
- package/Calendar/CalendarSuperForm/components/CalendarRangePicker/CalendarRangePicker.d.ts +1 -0
- package/Calendar/CalendarSuperForm/components/CalendarRangePicker/CalendarRangePicker.js +3 -2
- package/Calendar/CalendarSuperForm/types.d.ts +37 -9
- package/Calendar/helpers.d.ts +10 -0
- package/Calendar/helpers.js +10 -0
- package/Calendar/types.d.ts +16 -1
- package/CardMetric/CardMetric.d.ts +7 -0
- package/CardMetric/CardMetric.js +7 -0
- package/CardMetric/types.d.ts +13 -0
- package/Checkbox/Checkbox.d.ts +6 -0
- package/Checkbox/Checkbox.js +6 -0
- package/Checkbox/types.d.ts +13 -0
- package/Chip/Chip.d.ts +7 -0
- package/Chip/Chip.js +7 -0
- package/Chip/Chip.types.d.ts +9 -0
- package/CodeEditor/CodeEditor.d.ts +7 -0
- package/CodeEditor/CodeEditor.js +7 -0
- package/CodeEditor/languages/html.d.ts +1 -0
- package/CodeEditor/languages/html.js +1 -0
- package/CodeEditor/languages/json.d.ts +1 -0
- package/CodeEditor/languages/json.js +1 -0
- package/CodeEditor/languages/liquid.d.ts +1 -0
- package/CodeEditor/languages/liquid.js +1 -0
- package/CodeEditor/types.d.ts +11 -0
- package/CrashScreen/CrashScreen.d.ts +4 -0
- package/CrashScreen/CrashScreen.js +4 -0
- package/DateTimePicker/components/DatePicker/DatePicker.d.ts +5 -0
- package/DateTimePicker/components/DatePicker/DatePicker.js +5 -0
- package/DateTimePicker/components/DatePicker/types.d.ts +9 -0
- package/DateTimePicker/components/DatePickerField/DatePickerField.d.ts +5 -0
- package/DateTimePicker/components/DatePickerField/DatePickerField.js +5 -0
- package/DateTimePicker/components/DatePickerField/types.d.ts +9 -0
- package/DateTimePicker/components/DateTimePicker/DateTimePicker.d.ts +5 -0
- package/DateTimePicker/components/DateTimePicker/DateTimePicker.js +5 -0
- package/DateTimePicker/components/DateTimePicker/types.d.ts +6 -0
- package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.d.ts +5 -0
- package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.js +5 -0
- package/DateTimePicker/components/DateTimePickerField/types.d.ts +9 -0
- package/DateTimePicker/types.d.ts +5 -0
- package/Drawer/components/Drawer/Drawer.d.ts +11 -0
- package/Drawer/components/Drawer/Drawer.js +11 -0
- package/Drawer/components/Drawer/types.d.ts +9 -0
- package/Drawer/components/DrawerContent/styles.d.ts +3 -0
- package/Drawer/components/DrawerContent/styles.js +3 -0
- package/Drawer/components/DrawerDocs/DrawerDocs.d.ts +7 -0
- package/Drawer/components/DrawerDocs/DrawerDocs.js +7 -0
- package/Drawer/components/DrawerDocs/hooks.d.ts +4 -0
- package/Drawer/components/DrawerDocs/hooks.js +4 -0
- package/Drawer/components/DrawerDocs/types.d.ts +4 -0
- package/DropdownMenu/components/DropdownMenu/DropdownMenu.d.ts +12 -0
- package/DropdownMenu/components/DropdownMenu/DropdownMenu.js +12 -0
- package/DropdownMenu/components/DropdownMenu/types.d.ts +15 -0
- package/DropdownMenu/components/DropdownMenuButton/DropdownMenuButton.d.ts +8 -0
- package/DropdownMenu/components/DropdownMenuButton/DropdownMenuButton.js +8 -0
- package/DropdownMenu/components/DropdownMenuButton/types.d.ts +16 -0
- package/DropdownMenu/components/DropdownMenuItem/DropdownMenuItem.d.ts +7 -0
- package/DropdownMenu/components/DropdownMenuItem/DropdownMenuItem.js +7 -0
- package/DropdownMenu/components/DropdownMenuItem/types.d.ts +6 -0
- package/DropdownMenu/components/DropdownMenuSection/DropdownMenuSection.d.ts +8 -0
- package/DropdownMenu/components/DropdownMenuSection/DropdownMenuSection.js +8 -0
- package/DropdownMenu/components/DropdownMenuSection/types.d.ts +3 -0
- package/DropdownMenu/components/DropdownMenuSubmenu/DropdownMenuSubmenu.d.ts +9 -0
- package/DropdownMenu/components/DropdownMenuSubmenu/DropdownMenuSubmenu.js +9 -0
- package/DropdownMenu/components/DropdownMenuSubmenu/types.d.ts +5 -0
- package/EditableField/EditableField.d.ts +9 -0
- package/EditableField/EditableField.js +9 -0
- package/EditableField/types.d.ts +12 -0
- package/EmailTemplatePreview/EmailTemplatePreview.d.ts +7 -0
- package/EmailTemplatePreview/EmailTemplatePreview.js +7 -0
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/NoEmailTemplatePreview.d.ts +4 -0
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/NoEmailTemplatePreview.js +4 -0
- package/EmailTemplatePreview/helpers.d.ts +8 -0
- package/EmailTemplatePreview/helpers.js +8 -0
- package/EmailTemplatePreview/types.d.ts +7 -0
- package/EnhancedInput/EnhancedInput.d.ts +7 -0
- package/EnhancedInput/EnhancedInput.js +7 -0
- package/EnhancedInput/SearchInput.d.ts +6 -0
- package/EnhancedInput/SearchInput.js +6 -0
- package/EnhancedInput/types.d.ts +5 -0
- package/ExportResult/ExportResult.d.ts +7 -0
- package/ExportResult/ExportResult.js +7 -0
- package/ExportResult/types.d.ts +7 -0
- package/ExternalImagePreview/ExternalImagePreview.d.ts +7 -0
- package/ExternalImagePreview/ExternalImagePreview.js +7 -0
- package/ExternalImagePreview/types.d.ts +7 -0
- package/FieldBox/FieldBox.d.ts +9 -0
- package/FieldBox/FieldBox.js +9 -0
- package/FieldBox/types.d.ts +10 -0
- package/FrequencyCapping/FrequencyCappingEdit.d.ts +7 -0
- package/FrequencyCapping/FrequencyCappingEdit.js +7 -0
- package/FrequencyCapping/FrequencyCappingInApps.d.ts +7 -0
- package/FrequencyCapping/FrequencyCappingInApps.js +7 -0
- package/FrequencyCapping/FrequencyCappingReadonly.d.ts +3 -0
- package/FrequencyCapping/FrequencyCappingReadonly.js +3 -0
- package/FrequencyCapping/types.d.ts +37 -0
- package/FrequencyCapping/types.js +1 -0
- package/GetStartedPage/GetStartedPage.d.ts +7 -0
- package/GetStartedPage/GetStartedPage.js +7 -0
- package/GetStartedPage/types.d.ts +7 -0
- package/InputFile/InputFile.d.ts +7 -0
- package/InputFile/InputFile.js +7 -0
- package/InputFile/types.d.ts +18 -0
- package/Link/Link.d.ts +18 -0
- package/Link/types.d.ts +17 -0
- package/Modal/components/Modal/Modal.d.ts +11 -0
- package/Modal/components/Modal/Modal.js +11 -0
- package/Modal/components/Modal/types.d.ts +6 -0
- package/Modal/components/ModalConfirm/ModalConfirm.d.ts +8 -0
- package/Modal/components/ModalConfirm/ModalConfirm.js +8 -0
- package/Modal/components/ModalConfirm/ModalConfirmProvider.d.ts +7 -0
- package/Modal/components/ModalConfirm/ModalConfirmProvider.js +7 -0
- package/Modal/components/ModalConfirm/hooks.d.ts +8 -0
- package/Modal/components/ModalConfirm/hooks.js +8 -0
- package/Modal/components/ModalConfirm/types.d.ts +16 -0
- package/Modal/components/ModalContent/styles.d.ts +5 -0
- package/Modal/components/ModalContent/styles.js +5 -0
- package/Modal/components/ModalTitle/ModalTitle.d.ts +6 -0
- package/Modal/components/ModalTitle/ModalTitle.js +6 -0
- package/Modal/components/ModalTitle/types.d.ts +3 -0
- package/NotificationInbox/NotificationBar.d.ts +7 -0
- package/NotificationInbox/NotificationBar.js +7 -0
- package/NotificationInbox/NotificationBell.d.ts +7 -0
- package/NotificationInbox/NotificationBell.js +7 -0
- package/NotificationInbox/NotificationInbox.d.ts +7 -0
- package/NotificationInbox/NotificationInbox.js +7 -0
- package/NotificationInbox/types.d.ts +31 -0
- package/NumberPicker/NumberPicker.d.ts +7 -0
- package/NumberPicker/NumberPicker.js +7 -0
- package/NumberPicker/types.d.ts +12 -0
- package/PageHeader/components/AutosizeInput/AutosizeInput.d.ts +7 -0
- package/PageHeader/components/AutosizeInput/AutosizeInput.js +7 -0
- package/PageHeader/components/AutosizeInput/types.d.ts +7 -0
- package/PageHeader/components/PageHeader/PageHeader.d.ts +7 -0
- package/PageHeader/components/PageHeader/PageHeader.js +7 -0
- package/PageHeader/components/PageHeader/types.d.ts +13 -0
- package/PageHeader/components/PageHeaderEditable/PageHeaderEditable.d.ts +7 -0
- package/PageHeader/components/PageHeaderEditable/PageHeaderEditable.js +7 -0
- package/PageHeader/components/PageHeaderEditable/types.d.ts +19 -0
- package/Pagination/Pagination.d.ts +7 -0
- package/Pagination/Pagination.js +7 -0
- package/Pagination/types.d.ts +7 -0
- package/Popover/Popover.d.ts +10 -0
- package/Popover/Popover.js +10 -0
- package/Popover/styles.d.ts +1 -0
- package/Popover/styles.js +1 -0
- package/Popover/types.d.ts +9 -0
- package/ProgressBar/ProgressBar.d.ts +6 -0
- package/ProgressBar/ProgressBar.js +6 -0
- package/ProgressBar/types.d.ts +7 -0
- package/PushPreview/PushPreview.d.ts +7 -0
- package/PushPreview/PushPreview.js +7 -0
- package/PushPreview/types.d.ts +17 -0
- package/Radio/Radio.d.ts +7 -0
- package/Radio/Radio.js +7 -0
- package/Radio/types.d.ts +14 -0
- package/RadioCard/RadioCard.d.ts +7 -0
- package/RadioCard/RadioCard.js +7 -0
- package/RadioCard/types.d.ts +7 -0
- package/ReCaptcha/ReCaptcha.d.ts +8 -0
- package/ReCaptcha/ReCaptcha.js +8 -0
- package/ReCaptcha/helpers.d.ts +4 -0
- package/ReCaptcha/helpers.js +4 -0
- package/ReCaptcha/hooks.d.ts +4 -0
- package/ReCaptcha/hooks.js +4 -0
- package/ReCaptcha/types.d.ts +5 -0
- package/RichMessageEditor/RichMessageEditor.d.ts +8 -0
- package/RichMessageEditor/RichMessageEditor.js +8 -0
- package/RichMessageEditor/RichMessageEditor.types.d.ts +10 -0
- package/RichMessageEditor/RichMessageViewer.d.ts +10 -0
- package/RichMessageEditor/RichMessageViewer.js +7 -0
- package/RichMessageEditor/slate/types.d.ts +5 -0
- package/RichMessageEditor/types.d.ts +1 -0
- package/RichmediaPreview/RichmediaPreview.d.ts +7 -0
- package/RichmediaPreview/RichmediaPreview.js +7 -0
- package/RichmediaPreview/hooks.d.ts +4 -0
- package/RichmediaPreview/hooks.js +4 -0
- package/RichmediaPreview/types.d.ts +13 -0
- package/Select/Select.d.ts +22 -0
- package/Select/Select.js +22 -0
- package/Select/constants.d.ts +1 -0
- package/Select/constants.js +1 -0
- package/Select/types.d.ts +19 -0
- package/SendRate/SendRateEdit.d.ts +7 -0
- package/SendRate/SendRateEdit.js +7 -0
- package/SendRate/SendRateReadonly.d.ts +3 -0
- package/SendRate/SendRateReadonly.js +3 -0
- package/SendRate/types.d.ts +20 -0
- package/Skeleton/TextSkeleton.d.ts +6 -0
- package/Skeleton/TextSkeleton.js +6 -0
- package/Skeleton/styles.d.ts +2 -0
- package/Skeleton/styles.js +2 -0
- package/Skeleton/types.d.ts +11 -0
- package/SortButton/SortButton.d.ts +6 -0
- package/SortButton/SortButton.js +6 -0
- package/SortButton/types.d.ts +11 -0
- package/Spinner/Spinner.d.ts +6 -0
- package/Spinner/Spinner.js +6 -0
- package/Spinner/types.d.ts +4 -0
- package/StatisticCard/StatisticCard.d.ts +7 -0
- package/StatisticCard/StatisticCard.js +7 -0
- package/StatisticCard/types.d.ts +21 -0
- package/Switch/Switch.d.ts +6 -0
- package/Switch/Switch.js +6 -0
- package/Switch/types.d.ts +8 -0
- package/Tabs/components/Tab/Tab.d.ts +4 -0
- package/Tabs/components/Tab/Tab.js +4 -0
- package/Tabs/components/Tab/types.d.ts +6 -0
- package/Tabs/components/TabBar/TabBar.d.ts +3 -0
- package/Tabs/components/TabBar/TabBar.js +3 -0
- package/Tabs/components/TabBar/types.d.ts +2 -0
- package/Tabs/components/TabPanel/TabPanel.d.ts +4 -0
- package/Tabs/components/TabPanel/TabPanel.js +4 -0
- package/Tabs/components/TabPanel/types.d.ts +3 -0
- package/Tabs/components/Tabs/Tabs.d.ts +11 -0
- package/Tabs/components/Tabs/Tabs.js +11 -0
- package/Tabs/components/Tabs/types.d.ts +4 -0
- package/Tabs/types.d.ts +4 -0
- package/Toast/Toast.d.ts +5 -0
- package/Toast/Toast.js +5 -0
- package/Toast/ToastProvider.d.ts +7 -0
- package/Toast/ToastProvider.js +7 -0
- package/Toast/hooks.d.ts +8 -0
- package/Toast/hooks.js +8 -0
- package/Toast/types.d.ts +24 -0
- package/Tooltip/Tooltip.d.ts +7 -0
- package/Tooltip/Tooltip.js +7 -0
- package/Tooltip/TooltipTrigger.d.ts +13 -0
- package/Tooltip/TooltipTrigger.js +7 -0
- package/Tooltip/types.d.ts +12 -0
- package/hooks/useElementWidth.d.ts +4 -3
- package/hooks/useElementWidth.js +4 -3
- package/hooks/useLayer.d.ts +7 -0
- package/hooks/useLayer.js +7 -0
- package/hooks/useOnClickOutside.d.ts +7 -0
- package/hooks/useOnClickOutside.js +7 -0
- package/native/Input.d.ts +3 -0
- package/native/Input.js +1 -0
- package/native/NativeTimeInput.d.ts +1 -0
- package/native/NativeTimeInput.js +1 -0
- package/native/Select.d.ts +1 -0
- package/native/Select.js +1 -0
- package/native/Textarea.d.ts +1 -0
- package/native/Textarea.js +1 -0
- package/package.json +2 -3
- package/polyglot/react.d.ts +19 -0
- package/polyglot/react.js +19 -0
- package/polyglot/types.d.ts +4 -0
- package/shared/dropdownField/FieldInput.d.ts +1 -0
- package/shared/dropdownField/FieldInput.js +1 -0
- package/shared/dropdownField/FieldShell.d.ts +4 -0
- package/shared/dropdownField/FieldShell.js +4 -0
- package/shared/dropdownField/SuggestionsDropdown.d.ts +4 -0
- package/shared/dropdownField/SuggestionsDropdown.js +4 -0
- package/shared/dropdownField/constants.d.ts +1 -0
- package/shared/dropdownField/constants.js +1 -0
- package/shared/dropdownField/shared.d.ts +7 -0
- package/shared/dropdownField/shared.js +7 -0
- package/shared/dropdownField/types.d.ts +7 -0
- package/shared/dropdownField/useActiveIndex.d.ts +4 -0
- package/shared/dropdownField/useActiveIndex.js +4 -0
- package/shared/dropdownField/useAsyncItems.d.ts +4 -0
- package/shared/dropdownField/useAsyncItems.js +4 -0
- package/shared/dropdownField/useDebouncedValue.d.ts +1 -0
- package/shared/dropdownField/useDebouncedValue.js +1 -0
- package/shared/dropdownField/useDropdownItems.d.ts +4 -0
- package/shared/dropdownField/useDropdownItems.js +4 -0
- package/shared/dropdownField/useDropdownPosition.d.ts +4 -0
- package/shared/dropdownField/useDropdownPosition.js +4 -0
- package/shared/dropdownField/useFieldOpenEffects.d.ts +4 -0
- package/shared/dropdownField/useFieldOpenEffects.js +4 -0
- package/shared/dropdownField/useListNavigation.d.ts +5 -0
- package/shared/dropdownField/useListNavigation.js +5 -0
- package/Alert/ai-documentation.md +0 -132
- package/Badge/ai-documentation.md +0 -155
- package/Banner/ai-documentation.md +0 -285
- package/Button/ai-documentation.md +0 -247
- package/CardMetric/ai-documentation.md +0 -277
- package/Checkbox/ai-documentation.md +0 -231
- package/Chip/ai-documentation.md +0 -281
- package/CodeEditor/ai-documentation.md +0 -350
- package/DateTimePicker/ai-documentation.md +0 -400
- package/Drawer/ai-documentation.md +0 -417
- package/EnhancedInput/ai-documentation.md +0 -352
- package/InputFile/ai-documentation.md +0 -420
- package/Modal/ai-documentation.md +0 -285
- package/PageHeader/ai-documentation.md +0 -511
- package/Pagination/ai-documentation.md +0 -509
- package/Popover/ai-documentation.md +0 -625
- package/ProgressBar/ai-documentation.md +0 -533
- package/Radio/ai-documentation.md +0 -243
- package/Select/ai-documentation.md +0 -374
- package/Skeleton/ai-documentation.md +0 -574
- package/Spinner/ai-documentation.md +0 -607
- package/Switch/ai-documentation.md +0 -312
- package/Tabs/ai-documentation.md +0 -475
- package/Toast/ai-documentation.md +0 -220
- package/Tooltip/ai-documentation.md +0 -340
- package/ai-documentation.md +0 -124
- package/native/ai-documentation.md +0 -485
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
# CodeEditor - AI Documentation
|
|
2
|
-
|
|
3
|
-
> Auto-generated AI agent documentation for CodeEditor component
|
|
4
|
-
> Part of @pushwoosh/dumb-components library
|
|
5
|
-
|
|
6
|
-
## Overview
|
|
7
|
-
|
|
8
|
-
**Component:** CodeEditor
|
|
9
|
-
**Import Path:** `import { CodeEditor } from '@pushwoosh/dumb-components'`
|
|
10
|
-
**Files:** CodeEditor.tsx, types.ts, styles.ts, constants.ts, index.ts, languages/
|
|
11
|
-
**Type:** Form Component / Text Editor
|
|
12
|
-
**Description:** Code editor component built on CodeMirror with syntax highlighting, theme support, and language extensions
|
|
13
|
-
|
|
14
|
-
## TypeScript Interface
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
interface CodeEditorProps {
|
|
18
|
-
value: string;
|
|
19
|
-
readOnly?: boolean;
|
|
20
|
-
width?: string;
|
|
21
|
-
height?: string;
|
|
22
|
-
hasError?: boolean;
|
|
23
|
-
extensions: Extension[];
|
|
24
|
-
placeholder?: string;
|
|
25
|
-
themeOptions?: CreateThemeOptions;
|
|
26
|
-
onChange?: (value: string, viewUpdate: ViewUpdate) => void;
|
|
27
|
-
onBlur?: () => void;
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Import & Usage
|
|
32
|
-
|
|
33
|
-
**Import:**
|
|
34
|
-
```typescript
|
|
35
|
-
import { CodeEditor, html, liquid, json } from '@pushwoosh/dumb-components';
|
|
36
|
-
import type { CodeEditorProps } from '@pushwoosh/dumb-components';
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**Basic Usage:**
|
|
40
|
-
```tsx
|
|
41
|
-
import { json } from '@pushwoosh/dumb-components';
|
|
42
|
-
|
|
43
|
-
function App() {
|
|
44
|
-
const [code, setCode] = useState('{\n "hello": "world"\n}');
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<CodeEditor
|
|
48
|
-
value={code}
|
|
49
|
-
onChange={(val) => setCode(val)}
|
|
50
|
-
extensions={[json()]}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Advanced Examples:**
|
|
57
|
-
```tsx
|
|
58
|
-
// HTML editor with custom size
|
|
59
|
-
<CodeEditor
|
|
60
|
-
value={htmlCode}
|
|
61
|
-
onChange={setHtmlCode}
|
|
62
|
-
extensions={[html()]}
|
|
63
|
-
width="100%"
|
|
64
|
-
height="400px"
|
|
65
|
-
placeholder="Enter HTML code..."
|
|
66
|
-
/>
|
|
67
|
-
|
|
68
|
-
// Read-only editor for code display
|
|
69
|
-
<CodeEditor
|
|
70
|
-
value={exampleCode}
|
|
71
|
-
readOnly={true}
|
|
72
|
-
extensions={[json()]}
|
|
73
|
-
height="200px"
|
|
74
|
-
/>
|
|
75
|
-
|
|
76
|
-
// Editor with error state
|
|
77
|
-
<CodeEditor
|
|
78
|
-
value={invalidJson}
|
|
79
|
-
onChange={handleJsonChange}
|
|
80
|
-
extensions={[json()]}
|
|
81
|
-
hasError={jsonParseError}
|
|
82
|
-
onBlur={() => validateJson(invalidJson)}
|
|
83
|
-
/>
|
|
84
|
-
|
|
85
|
-
// Liquid template editor
|
|
86
|
-
<CodeEditor
|
|
87
|
-
value={liquidTemplate}
|
|
88
|
-
onChange={setLiquidTemplate}
|
|
89
|
-
extensions={[liquid()]}
|
|
90
|
-
placeholder="Enter Liquid template..."
|
|
91
|
-
height="300px"
|
|
92
|
-
/>
|
|
93
|
-
|
|
94
|
-
// Custom theme editor
|
|
95
|
-
<CodeEditor
|
|
96
|
-
value={code}
|
|
97
|
-
onChange={setCode}
|
|
98
|
-
extensions={[html()]}
|
|
99
|
-
themeOptions={{
|
|
100
|
-
theme: 'dark',
|
|
101
|
-
settings: {
|
|
102
|
-
background: '#1e1e1e',
|
|
103
|
-
foreground: '#d4d4d4',
|
|
104
|
-
caret: '#ffffff',
|
|
105
|
-
selection: '#264f78',
|
|
106
|
-
lineHighlight: '#2d2d30'
|
|
107
|
-
}
|
|
108
|
-
}}
|
|
109
|
-
/>
|
|
110
|
-
|
|
111
|
-
// Form integration with validation
|
|
112
|
-
function CodeForm() {
|
|
113
|
-
const [jsonValue, setJsonValue] = useState('');
|
|
114
|
-
const [error, setError] = useState(null);
|
|
115
|
-
|
|
116
|
-
const handleChange = (value: string) => {
|
|
117
|
-
setJsonValue(value);
|
|
118
|
-
try {
|
|
119
|
-
JSON.parse(value);
|
|
120
|
-
setError(null);
|
|
121
|
-
} catch (e) {
|
|
122
|
-
setError('Invalid JSON syntax');
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<div>
|
|
128
|
-
<label>JSON Configuration:</label>
|
|
129
|
-
<CodeEditor
|
|
130
|
-
value={jsonValue}
|
|
131
|
-
onChange={handleChange}
|
|
132
|
-
extensions={[json()]}
|
|
133
|
-
hasError={!!error}
|
|
134
|
-
placeholder='{\n "key": "value"\n}'
|
|
135
|
-
height="200px"
|
|
136
|
-
/>
|
|
137
|
-
{error && <span style={{ color: 'red' }}>{error}</span>}
|
|
138
|
-
</div>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Multi-language editor with switcher
|
|
143
|
-
function MultiLanguageEditor() {
|
|
144
|
-
const [language, setLanguage] = useState('json');
|
|
145
|
-
const [code, setCode] = useState('');
|
|
146
|
-
|
|
147
|
-
const getExtensions = () => {
|
|
148
|
-
switch (language) {
|
|
149
|
-
case 'html': return [html()];
|
|
150
|
-
case 'json': return [json()];
|
|
151
|
-
case 'liquid': return [liquid()];
|
|
152
|
-
default: return [];
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div>
|
|
158
|
-
<select value={language} onChange={(e) => setLanguage(e.target.value)}>
|
|
159
|
-
<option value="json">JSON</option>
|
|
160
|
-
<option value="html">HTML</option>
|
|
161
|
-
<option value="liquid">Liquid</option>
|
|
162
|
-
</select>
|
|
163
|
-
|
|
164
|
-
<CodeEditor
|
|
165
|
-
value={code}
|
|
166
|
-
onChange={setCode}
|
|
167
|
-
extensions={getExtensions()}
|
|
168
|
-
height="300px"
|
|
169
|
-
/>
|
|
170
|
-
</div>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Props Reference
|
|
176
|
-
|
|
177
|
-
| Prop | Type | Default | Description |
|
|
178
|
-
|------|------|---------|-------------|
|
|
179
|
-
| value | string | required | Current editor content |
|
|
180
|
-
| onChange | (value: string, viewUpdate: ViewUpdate) => void | undefined | Content change callback |
|
|
181
|
-
| extensions | Extension[] | required | CodeMirror language/feature extensions |
|
|
182
|
-
| readOnly | boolean | false | Whether editor is read-only |
|
|
183
|
-
| width | string | undefined | Editor width (CSS value) |
|
|
184
|
-
| height | string | undefined | Editor height (CSS value) |
|
|
185
|
-
| hasError | boolean | false | Whether editor shows error styling |
|
|
186
|
-
| placeholder | string | undefined | Placeholder text when empty |
|
|
187
|
-
| themeOptions | CreateThemeOptions | undefined | Custom theme configuration |
|
|
188
|
-
| onBlur | () => void | undefined | Blur event callback |
|
|
189
|
-
|
|
190
|
-
## Language Extensions
|
|
191
|
-
|
|
192
|
-
The library provides pre-configured language extensions:
|
|
193
|
-
|
|
194
|
-
| Extension | Usage | Description |
|
|
195
|
-
|-----------|-------|-------------|
|
|
196
|
-
| `html()` | HTML editing | HTML syntax highlighting and completion |
|
|
197
|
-
| `json()` | JSON editing | JSON syntax highlighting and validation |
|
|
198
|
-
| `liquid()` | Liquid templates | Liquid template language support |
|
|
199
|
-
|
|
200
|
-
**Usage:**
|
|
201
|
-
```typescript
|
|
202
|
-
import { html, json, liquid } from '@pushwoosh/dumb-components';
|
|
203
|
-
|
|
204
|
-
// Use in extensions prop
|
|
205
|
-
<CodeEditor extensions={[json()]} />
|
|
206
|
-
<CodeEditor extensions={[html()]} />
|
|
207
|
-
<CodeEditor extensions={[liquid()]} />
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
## Theme Customization
|
|
211
|
-
|
|
212
|
-
```typescript
|
|
213
|
-
// Custom theme example
|
|
214
|
-
const customTheme = {
|
|
215
|
-
theme: 'dark', // or 'light'
|
|
216
|
-
settings: {
|
|
217
|
-
background: '#1a1a1a',
|
|
218
|
-
foreground: '#ffffff',
|
|
219
|
-
caret: '#ffcc00',
|
|
220
|
-
selection: '#3d4c5f',
|
|
221
|
-
selectionMatch: '#3d4c5f',
|
|
222
|
-
lineHighlight: '#2a2a2a',
|
|
223
|
-
gutterBackground: '#1a1a1a',
|
|
224
|
-
gutterForeground: '#999999'
|
|
225
|
-
},
|
|
226
|
-
styles: [
|
|
227
|
-
{ tag: 'comment', color: '#6a9955' },
|
|
228
|
-
{ tag: 'string', color: '#ce9178' },
|
|
229
|
-
{ tag: 'number', color: '#b5cea8' }
|
|
230
|
-
]
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
<CodeEditor
|
|
234
|
-
themeOptions={customTheme}
|
|
235
|
-
extensions={[json()]}
|
|
236
|
-
value={code}
|
|
237
|
-
onChange={setCode}
|
|
238
|
-
/>
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
## AI Agent Guidelines
|
|
242
|
-
|
|
243
|
-
### ✅ Recommended Patterns
|
|
244
|
-
- Always provide appropriate `extensions` for the content type
|
|
245
|
-
- Use `hasError` to indicate validation problems
|
|
246
|
-
- Set reasonable `height` for better UX (200px-500px typically)
|
|
247
|
-
- Include `placeholder` text for empty editors
|
|
248
|
-
- Handle `onChange` to maintain controlled component state
|
|
249
|
-
- Use `readOnly` for code display/preview scenarios
|
|
250
|
-
|
|
251
|
-
### ❌ Common Mistakes to Avoid
|
|
252
|
-
- Don't forget to import and use language extensions
|
|
253
|
-
- Don't use without `onChange` unless read-only
|
|
254
|
-
- Avoid very small heights that make editing difficult
|
|
255
|
-
- Don't mix different language extensions inappropriately
|
|
256
|
-
- Avoid setting both `readOnly` and `onChange` (unnecessary)
|
|
257
|
-
|
|
258
|
-
### Integration Tips
|
|
259
|
-
- Works well in forms for configuration editing
|
|
260
|
-
- Good for template editing interfaces
|
|
261
|
-
- Can be combined with preview components
|
|
262
|
-
- Use with validation libraries for syntax checking
|
|
263
|
-
- Effective in admin interfaces for code customization
|
|
264
|
-
|
|
265
|
-
## Common Use Cases
|
|
266
|
-
|
|
267
|
-
### JSON Configuration Editor
|
|
268
|
-
```tsx
|
|
269
|
-
function JsonConfigEditor({ config, onConfigChange }) {
|
|
270
|
-
const [jsonString, setJsonString] = useState(
|
|
271
|
-
JSON.stringify(config, null, 2)
|
|
272
|
-
);
|
|
273
|
-
const [error, setError] = useState(null);
|
|
274
|
-
|
|
275
|
-
const handleChange = (value: string) => {
|
|
276
|
-
setJsonString(value);
|
|
277
|
-
try {
|
|
278
|
-
const parsed = JSON.parse(value);
|
|
279
|
-
onConfigChange(parsed);
|
|
280
|
-
setError(null);
|
|
281
|
-
} catch (e) {
|
|
282
|
-
setError('Invalid JSON');
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
<div>
|
|
288
|
-
<CodeEditor
|
|
289
|
-
value={jsonString}
|
|
290
|
-
onChange={handleChange}
|
|
291
|
-
extensions={[json()]}
|
|
292
|
-
hasError={!!error}
|
|
293
|
-
height="300px"
|
|
294
|
-
/>
|
|
295
|
-
{error && <div className="error">{error}</div>}
|
|
296
|
-
</div>
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### Template Editor
|
|
302
|
-
```tsx
|
|
303
|
-
function TemplateEditor() {
|
|
304
|
-
const [template, setTemplate] = useState('');
|
|
305
|
-
const [preview, setPreview] = useState('');
|
|
306
|
-
|
|
307
|
-
useEffect(() => {
|
|
308
|
-
// Generate preview from template
|
|
309
|
-
setPreview(processLiquidTemplate(template));
|
|
310
|
-
}, [template]);
|
|
311
|
-
|
|
312
|
-
return (
|
|
313
|
-
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '16px' }}>
|
|
314
|
-
<div>
|
|
315
|
-
<h3>Template</h3>
|
|
316
|
-
<CodeEditor
|
|
317
|
-
value={template}
|
|
318
|
-
onChange={setTemplate}
|
|
319
|
-
extensions={[liquid()]}
|
|
320
|
-
height="400px"
|
|
321
|
-
placeholder="Enter Liquid template..."
|
|
322
|
-
/>
|
|
323
|
-
</div>
|
|
324
|
-
<div>
|
|
325
|
-
<h3>Preview</h3>
|
|
326
|
-
<CodeEditor
|
|
327
|
-
value={preview}
|
|
328
|
-
readOnly
|
|
329
|
-
extensions={[html()]}
|
|
330
|
-
height="400px"
|
|
331
|
-
/>
|
|
332
|
-
</div>
|
|
333
|
-
</div>
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
## Accessibility Features
|
|
339
|
-
- **Keyboard Navigation**: Full keyboard support for code editing
|
|
340
|
-
- **Screen Reader Support**: Accessible to screen readers
|
|
341
|
-
- **Focus Management**: Proper focus handling and indication
|
|
342
|
-
- **High Contrast**: Supports high contrast themes
|
|
343
|
-
|
|
344
|
-
## Related Components
|
|
345
|
-
- Textarea - for simple multi-line text input
|
|
346
|
-
- Input - for single-line text input
|
|
347
|
-
- Modal - often contains code editors
|
|
348
|
-
- Button - for editor actions (save, format, etc.)
|
|
349
|
-
|
|
350
|
-
---
|