@djangocfg/ui-tools 2.1.381 → 2.1.383

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.
Files changed (178) hide show
  1. package/README.md +132 -899
  2. package/dist/ChatRoot-6IZFM5HM.mjs +5 -0
  3. package/dist/{ChatRoot-EJC5Y2YM.cjs.map → ChatRoot-6IZFM5HM.mjs.map} +1 -1
  4. package/dist/ChatRoot-LW4XNIKP.cjs +14 -0
  5. package/dist/{ChatRoot-QOSKJPM6.mjs.map → ChatRoot-LW4XNIKP.cjs.map} +1 -1
  6. package/dist/DictationField-U25MEYAL.mjs +4 -0
  7. package/dist/DictationField-U25MEYAL.mjs.map +1 -0
  8. package/dist/DictationField-XWR5VOID.cjs +13 -0
  9. package/dist/DictationField-XWR5VOID.cjs.map +1 -0
  10. package/dist/{DocsLayout-2YKPXZYO.mjs → DocsLayout-2P3ONDWJ.mjs} +3 -3
  11. package/dist/{DocsLayout-2YKPXZYO.mjs.map → DocsLayout-2P3ONDWJ.mjs.map} +1 -1
  12. package/dist/{DocsLayout-Q4KS3QWW.cjs → DocsLayout-2YZNS5VK.cjs} +8 -8
  13. package/dist/{DocsLayout-Q4KS3QWW.cjs.map → DocsLayout-2YZNS5VK.cjs.map} +1 -1
  14. package/dist/chunk-4PFW7MIJ.cjs +837 -0
  15. package/dist/chunk-4PFW7MIJ.cjs.map +1 -0
  16. package/dist/chunk-C2YN6WEO.mjs +833 -0
  17. package/dist/chunk-C2YN6WEO.mjs.map +1 -0
  18. package/dist/{chunk-XACCHZH2.cjs → chunk-FIRK5CEH.cjs} +42 -4
  19. package/dist/chunk-FIRK5CEH.cjs.map +1 -0
  20. package/dist/{chunk-NWUT327A.mjs → chunk-HIK6BPL7.mjs} +38 -5
  21. package/dist/chunk-HIK6BPL7.mjs.map +1 -0
  22. package/dist/chunk-OZAU3QWD.cjs +2493 -0
  23. package/dist/chunk-OZAU3QWD.cjs.map +1 -0
  24. package/dist/chunk-UWVP6LCW.mjs +2447 -0
  25. package/dist/chunk-UWVP6LCW.mjs.map +1 -0
  26. package/dist/index.cjs +1668 -99
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +1215 -107
  29. package/dist/index.d.ts +1215 -107
  30. package/dist/index.mjs +1555 -50
  31. package/dist/index.mjs.map +1 -1
  32. package/package.json +16 -15
  33. package/src/audio-assets.d.ts +8 -0
  34. package/src/components/markdown/MarkdownMessage/CollapseToggle.tsx +3 -1
  35. package/src/components/markdown/MarkdownMessage/components.tsx +2 -5
  36. package/src/tools/Chat/README.md +347 -530
  37. package/src/tools/Chat/components/Attachments.tsx +6 -1
  38. package/src/tools/Chat/components/ChatRoot.tsx +30 -2
  39. package/src/tools/Chat/components/Composer.tsx +20 -3
  40. package/src/tools/Chat/components/ErrorBanner.tsx +7 -3
  41. package/src/tools/Chat/components/MessageActions.tsx +3 -1
  42. package/src/tools/Chat/components/MessageBubble.tsx +6 -5
  43. package/src/tools/Chat/components/MessageList.tsx +87 -1
  44. package/src/tools/Chat/components/ToolCalls.tsx +21 -3
  45. package/src/tools/Chat/context/ChatProvider.tsx +21 -3
  46. package/src/tools/Chat/core/audio/audioBus.ts +10 -163
  47. package/src/tools/Chat/core/audio/defaults.ts +43 -0
  48. package/src/tools/Chat/core/audio/index.ts +1 -0
  49. package/src/tools/Chat/core/audio/preferences.ts +5 -59
  50. package/src/tools/Chat/core/audio/sounds/error.mp3 +0 -0
  51. package/src/tools/Chat/core/audio/sounds/mention.mp3 +0 -0
  52. package/src/tools/Chat/core/audio/sounds/notification.mp3 +0 -0
  53. package/src/tools/Chat/core/audio/sounds/received.mp3 +0 -0
  54. package/src/tools/Chat/core/audio/sounds/sent.mp3 +0 -0
  55. package/src/tools/Chat/core/audio/sounds/start.mp3 +0 -0
  56. package/src/tools/Chat/core/audio/types.ts +28 -0
  57. package/src/tools/Chat/core/reducer.ts +33 -0
  58. package/src/tools/Chat/core/transport/index.ts +13 -0
  59. package/src/tools/Chat/core/transport/mappers/index.ts +6 -0
  60. package/src/tools/Chat/core/transport/mappers/pydantic-ai.ts +142 -0
  61. package/src/tools/Chat/core/transport/pydantic-ai-transport.ts +208 -0
  62. package/src/tools/Chat/core/transport/sse.ts +18 -5
  63. package/src/tools/Chat/hooks/index.ts +25 -0
  64. package/src/tools/Chat/hooks/useAutoFocusOnStreamEnd.ts +5 -3
  65. package/src/tools/Chat/hooks/useChat.ts +28 -0
  66. package/src/tools/Chat/hooks/useChatAudio.ts +59 -180
  67. package/src/tools/Chat/hooks/useChatDockPrefs.ts +74 -0
  68. package/src/tools/Chat/hooks/useChatReset.ts +70 -0
  69. package/src/tools/Chat/hooks/useChatUnread.ts +87 -0
  70. package/src/tools/Chat/hooks/useFocusOnEmptyClick.ts +111 -0
  71. package/src/tools/Chat/hooks/useVisitorFingerprint.ts +48 -0
  72. package/src/tools/Chat/index.ts +84 -1
  73. package/src/tools/Chat/launcher/ChatDock.tsx +263 -0
  74. package/src/tools/Chat/launcher/ChatFAB.tsx +349 -0
  75. package/src/tools/Chat/launcher/ChatGreeting.tsx +200 -0
  76. package/src/tools/Chat/launcher/ChatHeader.tsx +76 -0
  77. package/src/tools/Chat/launcher/ChatHeaderActionButton.tsx +87 -0
  78. package/src/tools/Chat/launcher/ChatHeaderAudioToggle.tsx +47 -0
  79. package/src/tools/Chat/launcher/ChatHeaderLanguageButton.tsx +179 -0
  80. package/src/tools/Chat/launcher/ChatHeaderModeToggle.tsx +57 -0
  81. package/src/tools/Chat/launcher/ChatHeaderResetButton.tsx +93 -0
  82. package/src/tools/Chat/launcher/ChatLauncher.tsx +321 -0
  83. package/src/tools/Chat/launcher/ChatUnreadPreview.tsx +197 -0
  84. package/src/tools/Chat/launcher/index.ts +46 -0
  85. package/src/tools/Chat/launcher/useChatPresence.ts +44 -0
  86. package/src/tools/Chat/styles/bubbleTokens.ts +71 -0
  87. package/src/tools/Chat/styles/index.ts +16 -0
  88. package/src/tools/Chat/styles/useChatStyles.ts +101 -0
  89. package/src/tools/Chat/types/attachment.ts +25 -0
  90. package/src/tools/Chat/types/config.ts +48 -0
  91. package/src/tools/Chat/types/events.ts +35 -0
  92. package/src/tools/Chat/types/index.ts +34 -0
  93. package/src/tools/Chat/types/labels.ts +38 -0
  94. package/src/tools/Chat/types/message.ts +32 -0
  95. package/src/tools/Chat/types/persona.ts +31 -0
  96. package/src/tools/Chat/types/session.ts +43 -0
  97. package/src/tools/Chat/types/tool-call.ts +17 -0
  98. package/src/tools/Chat/types/transport.ts +28 -0
  99. package/src/tools/Chat/types.ts +5 -240
  100. package/src/tools/MarkdownEditor/MarkdownEditor.tsx +50 -14
  101. package/src/tools/MarkdownEditor/index.ts +1 -1
  102. package/src/tools/SpeechRecognition/README.md +336 -0
  103. package/src/tools/SpeechRecognition/__tests__/ids.test.ts +15 -0
  104. package/src/tools/SpeechRecognition/__tests__/language.test.ts +59 -0
  105. package/src/tools/SpeechRecognition/__tests__/reducer.test.ts +71 -0
  106. package/src/tools/SpeechRecognition/__tests__/transcript.test.ts +52 -0
  107. package/src/tools/SpeechRecognition/components/DevicePicker.tsx +49 -0
  108. package/src/tools/SpeechRecognition/components/DictationButton.tsx +93 -0
  109. package/src/tools/SpeechRecognition/components/EngineBadge.tsx +30 -0
  110. package/src/tools/SpeechRecognition/components/ErrorBanner.tsx +52 -0
  111. package/src/tools/SpeechRecognition/components/LanguagePicker.tsx +63 -0
  112. package/src/tools/SpeechRecognition/components/MicMeter.tsx +63 -0
  113. package/src/tools/SpeechRecognition/components/PushToTalkHint.tsx +51 -0
  114. package/src/tools/SpeechRecognition/components/TranscriptView.tsx +55 -0
  115. package/src/tools/SpeechRecognition/components/index.ts +16 -0
  116. package/src/tools/SpeechRecognition/context/SpeechRecognitionProvider.tsx +47 -0
  117. package/src/tools/SpeechRecognition/context/index.ts +6 -0
  118. package/src/tools/SpeechRecognition/core/audio/defaults.ts +24 -0
  119. package/src/tools/SpeechRecognition/core/engine/external.ts +222 -0
  120. package/src/tools/SpeechRecognition/core/engine/http.ts +147 -0
  121. package/src/tools/SpeechRecognition/core/engine/index.ts +52 -0
  122. package/src/tools/SpeechRecognition/core/engine/mediarecorder.ts +105 -0
  123. package/src/tools/SpeechRecognition/core/engine/websocket.ts +211 -0
  124. package/src/tools/SpeechRecognition/core/engine/webspeech.ts +188 -0
  125. package/src/tools/SpeechRecognition/core/ids.ts +11 -0
  126. package/src/tools/SpeechRecognition/core/index.ts +14 -0
  127. package/src/tools/SpeechRecognition/core/language.ts +78 -0
  128. package/src/tools/SpeechRecognition/core/languages-catalog.ts +229 -0
  129. package/src/tools/SpeechRecognition/core/logger.ts +3 -0
  130. package/src/tools/SpeechRecognition/core/reducer.ts +105 -0
  131. package/src/tools/SpeechRecognition/core/transcript.ts +36 -0
  132. package/src/tools/SpeechRecognition/hooks/index.ts +14 -0
  133. package/src/tools/SpeechRecognition/hooks/useDictation.ts +59 -0
  134. package/src/tools/SpeechRecognition/hooks/useEnginePrefs.ts +15 -0
  135. package/src/tools/SpeechRecognition/hooks/useMicDevices.ts +57 -0
  136. package/src/tools/SpeechRecognition/hooks/useMicLevel.ts +52 -0
  137. package/src/tools/SpeechRecognition/hooks/usePushToTalk.ts +85 -0
  138. package/src/tools/SpeechRecognition/hooks/useResolvedLanguage.ts +28 -0
  139. package/src/tools/SpeechRecognition/hooks/useSpeechLanguageInfo.ts +108 -0
  140. package/src/tools/SpeechRecognition/hooks/useSpeechRecognition.ts +188 -0
  141. package/src/tools/SpeechRecognition/hooks/useVoiceSupport.ts +78 -0
  142. package/src/tools/SpeechRecognition/index.ts +82 -0
  143. package/src/tools/SpeechRecognition/lazy.tsx +19 -0
  144. package/src/tools/SpeechRecognition/store/index.ts +2 -0
  145. package/src/tools/SpeechRecognition/store/prefsStore.ts +54 -0
  146. package/src/tools/SpeechRecognition/types.ts +133 -0
  147. package/src/tools/SpeechRecognition/widgets/DictationField.tsx +105 -0
  148. package/src/tools/SpeechRecognition/widgets/VoiceComposerSlot.tsx +305 -0
  149. package/src/tools/SpeechRecognition/widgets/VoiceMessageRecorder.tsx +88 -0
  150. package/src/tools/SpeechRecognition/widgets/index.ts +6 -0
  151. package/dist/ChatRoot-EJC5Y2YM.cjs +0 -14
  152. package/dist/ChatRoot-QOSKJPM6.mjs +0 -5
  153. package/dist/chunk-NWUT327A.mjs.map +0 -1
  154. package/dist/chunk-QLMKCSR6.mjs +0 -2420
  155. package/dist/chunk-QLMKCSR6.mjs.map +0 -1
  156. package/dist/chunk-SI5RD2GD.cjs +0 -2460
  157. package/dist/chunk-SI5RD2GD.cjs.map +0 -1
  158. package/dist/chunk-XACCHZH2.cjs.map +0 -1
  159. package/src/components/markdown/MarkdownMessage/MarkdownMessage.story.tsx +0 -771
  160. package/src/stories/index.ts +0 -33
  161. package/src/tools/AudioPlayer/AudioPlayer.story.tsx +0 -481
  162. package/src/tools/Chat/Chat.story.tsx +0 -1457
  163. package/src/tools/CodeEditor/CodeEditor.story.tsx +0 -202
  164. package/src/tools/CronScheduler/CronScheduler.story.tsx +0 -300
  165. package/src/tools/Gallery/Gallery.story.tsx +0 -237
  166. package/src/tools/ImageViewer/ImageViewer.story.tsx +0 -85
  167. package/src/tools/JsonForm/JsonForm.story.tsx +0 -350
  168. package/src/tools/JsonTree/JsonTree.story.tsx +0 -141
  169. package/src/tools/LottiePlayer/LottiePlayer.story.tsx +0 -95
  170. package/src/tools/Map/Map.story.tsx +0 -458
  171. package/src/tools/MarkdownEditor/MarkdownEditor.story.tsx +0 -225
  172. package/src/tools/Mermaid/Mermaid.story.tsx +0 -251
  173. package/src/tools/OpenapiViewer/OpenapiViewer.story.tsx +0 -230
  174. package/src/tools/PrettyCode/PrettyCode.story.tsx +0 -304
  175. package/src/tools/Tour/Tour.story.tsx +0 -279
  176. package/src/tools/Tree/Tree.story.tsx +0 -620
  177. package/src/tools/Uploader/Uploader.story.tsx +0 -415
  178. package/src/tools/VideoPlayer/VideoPlayer.story.tsx +0 -87
@@ -1,202 +0,0 @@
1
- import { defineStory, useSelect, useBoolean } from '@djangocfg/playground';
2
- import { Editor, DiffEditor } from './components';
3
-
4
- export default defineStory({
5
- title: 'Tools/Code Editor',
6
- component: Editor,
7
- description: 'Monaco-based code editor with syntax highlighting, diff view, and full IDE features.',
8
- });
9
-
10
- const SAMPLE_CODE = {
11
- typescript: `import { useState, useCallback, useMemo } from 'react';
12
-
13
- interface User {
14
- id: string;
15
- name: string;
16
- email: string;
17
- role: 'admin' | 'user' | 'viewer';
18
- }
19
-
20
- export function useUsers() {
21
- const [users, setUsers] = useState<User[]>([]);
22
-
23
- const addUser = useCallback((user: Omit<User, 'id'>) => {
24
- setUsers(prev => [...prev, { ...user, id: crypto.randomUUID() }]);
25
- }, []);
26
-
27
- const admins = useMemo(
28
- () => users.filter(u => u.role === 'admin'),
29
- [users],
30
- );
31
-
32
- return { users, admins, addUser };
33
- }`,
34
-
35
- python: `from __future__ import annotations
36
-
37
- from dataclasses import dataclass
38
- from datetime import datetime
39
- from typing import AsyncIterator
40
-
41
- import httpx
42
- from pydantic import BaseModel, Field
43
-
44
-
45
- class User(BaseModel):
46
- id: str
47
- name: str
48
- email: str
49
- role: str = "user"
50
- created_at: datetime = Field(default_factory=datetime.utcnow)
51
-
52
-
53
- @dataclass
54
- class UserService:
55
- base_url: str
56
- client: httpx.AsyncClient | None = None
57
-
58
- async def list_users(self, page: int = 1) -> list[User]:
59
- async with httpx.AsyncClient(base_url=self.base_url) as client:
60
- response = await client.get("/users", params={"page": page})
61
- response.raise_for_status()
62
- return [User(**u) for u in response.json()["data"]]`,
63
-
64
- json: `{
65
- "name": "@djangocfg/ui-tools",
66
- "version": "2.1.0",
67
- "description": "Heavy React tools with lazy loading",
68
- "dependencies": {
69
- "monaco-editor": "^0.55.1",
70
- "react": "^19.1.0"
71
- },
72
- "exports": {
73
- ".": "./src/index.ts",
74
- "./code-editor": "./src/tools/CodeEditor/index.ts"
75
- }
76
- }`,
77
-
78
- css: `/* Design tokens */
79
- :root {
80
- --radius: 0.5rem;
81
- --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
82
- }
83
-
84
- .editor-container {
85
- position: relative;
86
- border-radius: var(--radius);
87
- border: 1px solid hsl(var(--border));
88
- overflow: hidden;
89
-
90
- &:focus-within {
91
- outline: 2px solid hsl(var(--ring));
92
- outline-offset: 2px;
93
- }
94
- }`,
95
- };
96
-
97
- const DIFF_ORIGINAL = `function greet(name: string) {
98
- console.log("Hello, " + name);
99
- }
100
-
101
- greet("World");`;
102
-
103
- const DIFF_MODIFIED = `function greet(name: string, greeting = "Hello") {
104
- console.log(\`\${greeting}, \${name}!\`);
105
- }
106
-
107
- function farewell(name: string) {
108
- console.log(\`Goodbye, \${name}!\`);
109
- }
110
-
111
- greet("World");
112
- farewell("World");`;
113
-
114
- export const Interactive = () => {
115
- const [language] = useSelect('language', {
116
- options: ['typescript', 'python', 'json', 'css'] as const,
117
- defaultValue: 'typescript',
118
- label: 'Language',
119
- });
120
-
121
- const [readOnly] = useBoolean('readOnly', {
122
- defaultValue: false,
123
- label: 'Read Only',
124
- });
125
-
126
- const [minimap] = useBoolean('minimap', {
127
- defaultValue: false,
128
- label: 'Minimap',
129
- });
130
-
131
- const [autoHeight] = useBoolean('autoHeight', {
132
- defaultValue: false,
133
- label: 'Auto Height',
134
- description: 'Resize editor to fit content',
135
- });
136
-
137
- return autoHeight ? (
138
- <Editor
139
- value={SAMPLE_CODE[language]}
140
- language={language}
141
- autoHeight
142
- minHeight={100}
143
- maxHeight={500}
144
- options={{ readOnly, minimap, fontSize: 14 }}
145
- />
146
- ) : (
147
- <div style={{ height: 400 }}>
148
- <Editor
149
- value={SAMPLE_CODE[language]}
150
- language={language}
151
- options={{ readOnly, minimap, fontSize: 14 }}
152
- />
153
- </div>
154
- );
155
- };
156
-
157
- export const TypeScript = () => (
158
- <div style={{ height: 350 }}>
159
- <Editor value={SAMPLE_CODE.typescript} language="typescript" />
160
- </div>
161
- );
162
-
163
- export const Python = () => (
164
- <div style={{ height: 350 }}>
165
- <Editor value={SAMPLE_CODE.python} language="python" />
166
- </div>
167
- );
168
-
169
- export const ReadOnly = () => (
170
- <div style={{ height: 300 }}>
171
- <Editor
172
- value={SAMPLE_CODE.json}
173
- language="json"
174
- options={{ readOnly: true, lineNumbers: 'on' }}
175
- />
176
- </div>
177
- );
178
-
179
- export const AutoHeight = () => (
180
- <div className="flex flex-col gap-4 max-w-3xl">
181
- <p className="text-sm text-muted-foreground">
182
- Editor grows with content (min 100px, max 400px). Try typing new lines.
183
- </p>
184
- <Editor
185
- value={`const x = 1;\nconst y = 2;\nconst z = x + y;`}
186
- language="typescript"
187
- autoHeight
188
- minHeight={100}
189
- maxHeight={400}
190
- />
191
- </div>
192
- );
193
-
194
- export const DiffView = () => (
195
- <div style={{ height: 400 }}>
196
- <DiffEditor
197
- original={DIFF_ORIGINAL}
198
- modified={DIFF_MODIFIED}
199
- language="typescript"
200
- />
201
- </div>
202
- );
@@ -1,300 +0,0 @@
1
- import { useState } from 'react';
2
- import { defineStory, useBoolean, useSelect } from '@djangocfg/playground';
3
- import {
4
- Dialog,
5
- DialogContent,
6
- DialogDescription,
7
- DialogHeader,
8
- DialogTitle,
9
- DialogTrigger,
10
- } from '@djangocfg/ui-core/components';
11
- import { CronScheduler } from './index';
12
-
13
- export default defineStory({
14
- title: 'Tools/Cron Scheduler',
15
- component: CronScheduler,
16
- description: 'Compact cron expression builder with Apple HIG-style UI.',
17
- });
18
-
19
- export const Interactive = () => {
20
- const [cron, setCron] = useState('0 9 * * 1-5');
21
-
22
- const [defaultType] = useSelect('defaultType', {
23
- options: ['daily', 'weekly', 'monthly', 'custom'] as const,
24
- defaultValue: 'weekly',
25
- label: 'Default Type',
26
- description: 'Initial schedule type',
27
- });
28
-
29
- const [showPreview] = useBoolean('showPreview', {
30
- defaultValue: true,
31
- label: 'Show Preview',
32
- description: 'Show human-readable preview',
33
- });
34
-
35
- const [showCronExpression] = useBoolean('showCronExpression', {
36
- defaultValue: true,
37
- label: 'Show Cron Expression',
38
- description: 'Show raw cron expression in preview',
39
- });
40
-
41
- const [allowCopy] = useBoolean('allowCopy', {
42
- defaultValue: true,
43
- label: 'Allow Copy',
44
- description: 'Enable copy to clipboard',
45
- });
46
-
47
- const [timeFormat] = useSelect('timeFormat', {
48
- options: ['24h', '12h'] as const,
49
- defaultValue: '24h',
50
- label: 'Time Format',
51
- description: 'Time display format',
52
- });
53
-
54
- const [disabled] = useBoolean('disabled', {
55
- defaultValue: false,
56
- label: 'Disabled',
57
- description: 'Disable all interactions',
58
- });
59
-
60
- return (
61
- <div className="w-[400px]">
62
- <CronScheduler
63
- value={cron}
64
- onChange={setCron}
65
- defaultType={defaultType}
66
- showPreview={showPreview}
67
- showCronExpression={showCronExpression}
68
- allowCopy={allowCopy}
69
- timeFormat={timeFormat}
70
- disabled={disabled}
71
- />
72
- </div>
73
- );
74
- };
75
-
76
- export const Daily = () => {
77
- const [cron, setCron] = useState('0 9 * * *');
78
-
79
- return (
80
- <div className="w-[400px]">
81
- <CronScheduler
82
- value={cron}
83
- onChange={setCron}
84
- defaultType="daily"
85
- showPreview
86
- />
87
- </div>
88
- );
89
- };
90
-
91
- export const Weekly = () => {
92
- const [cron, setCron] = useState('30 14 * * 1,3,5');
93
-
94
- return (
95
- <div className="w-[400px]">
96
- <CronScheduler
97
- value={cron}
98
- onChange={setCron}
99
- defaultType="weekly"
100
- showPreview
101
- />
102
- </div>
103
- );
104
- };
105
-
106
- export const Monthly = () => {
107
- const [cron, setCron] = useState('0 9 1,15 * *');
108
-
109
- return (
110
- <div className="w-[400px]">
111
- <CronScheduler
112
- value={cron}
113
- onChange={setCron}
114
- defaultType="monthly"
115
- showPreview
116
- />
117
- </div>
118
- );
119
- };
120
-
121
- export const Custom = () => {
122
- const [cron, setCron] = useState('*/15 9-17 * * 1-5');
123
-
124
- return (
125
- <div className="w-[400px]">
126
- <CronScheduler
127
- value={cron}
128
- onChange={setCron}
129
- defaultType="custom"
130
- showPreview
131
- showCronExpression
132
- />
133
- </div>
134
- );
135
- };
136
-
137
- export const WithCronExpression = () => {
138
- const [cron, setCron] = useState('0 9 * * 1-5');
139
-
140
- return (
141
- <div className="w-[400px]">
142
- <CronScheduler
143
- value={cron}
144
- onChange={setCron}
145
- showPreview
146
- showCronExpression
147
- allowCopy
148
- />
149
- </div>
150
- );
151
- };
152
-
153
- export const TwelveHourFormat = () => {
154
- const [cron, setCron] = useState('0 14 * * *');
155
-
156
- return (
157
- <div className="w-[400px]">
158
- <CronScheduler
159
- value={cron}
160
- onChange={setCron}
161
- showPreview
162
- timeFormat="12h"
163
- />
164
- </div>
165
- );
166
- };
167
-
168
- export const Disabled = () => (
169
- <div className="w-[400px]">
170
- <CronScheduler
171
- value="0 9 * * 1-5"
172
- showPreview
173
- disabled
174
- />
175
- </div>
176
- );
177
-
178
- export const Compact = () => {
179
- const [cron, setCron] = useState('0 9 * * 1-5');
180
-
181
- return (
182
- <div className="w-[400px]">
183
- <CronScheduler
184
- value={cron}
185
- onChange={setCron}
186
- defaultType="weekly"
187
- showPreview={false}
188
- />
189
- </div>
190
- );
191
- };
192
-
193
- export const Controlled = () => {
194
- const [cron, setCron] = useState('0 9 * * *');
195
-
196
- const presets = [
197
- { label: 'Every day at 9am', value: '0 9 * * *' },
198
- { label: 'Weekdays at 6pm', value: '0 18 * * 1-5' },
199
- { label: 'Every Monday', value: '0 0 * * 1' },
200
- { label: '1st of month', value: '0 0 1 * *' },
201
- ];
202
-
203
- return (
204
- <div className="w-[400px] space-y-4">
205
- <div className="flex flex-wrap gap-2">
206
- {presets.map(({ label, value }) => (
207
- <button
208
- key={value}
209
- onClick={() => setCron(value)}
210
- className={`px-2 py-1 text-xs rounded-md transition-colors ${
211
- cron === value
212
- ? 'bg-primary text-primary-foreground'
213
- : 'bg-muted hover:bg-muted/80'
214
- }`}
215
- >
216
- {label}
217
- </button>
218
- ))}
219
- </div>
220
- <CronScheduler
221
- value={cron}
222
- onChange={setCron}
223
- showPreview
224
- allowCopy
225
- />
226
- </div>
227
- );
228
- };
229
-
230
- export const InDialog = () => {
231
- const [cron, setCron] = useState('0 9 * * 1-5');
232
- const [open, setOpen] = useState(false);
233
-
234
- return (
235
- <div className="p-4">
236
- <Dialog open={open} onOpenChange={setOpen}>
237
- <DialogTrigger asChild>
238
- <button className="px-4 py-2 bg-primary text-primary-foreground rounded-md">
239
- Open Schedule Dialog
240
- </button>
241
- </DialogTrigger>
242
- <DialogContent className="max-w-2xl">
243
- <DialogHeader>
244
- <DialogTitle>Create Schedule</DialogTitle>
245
- <DialogDescription>
246
- Configure a cron schedule for automated execution
247
- </DialogDescription>
248
- </DialogHeader>
249
- <div className="py-4">
250
- <CronScheduler
251
- value={cron}
252
- onChange={setCron}
253
- showPreview
254
- showCronExpression
255
- allowCopy
256
- />
257
- </div>
258
- </DialogContent>
259
- </Dialog>
260
- <div className="mt-4 text-sm text-muted-foreground">
261
- Current cron: <code className="bg-muted px-1 rounded">{cron}</code>
262
- </div>
263
- </div>
264
- );
265
- };
266
-
267
- export const InDialogMonthly = () => {
268
- const [cron, setCron] = useState('0 9 1,15 * *');
269
- const [open, setOpen] = useState(false);
270
-
271
- return (
272
- <div className="p-4">
273
- <Dialog open={open} onOpenChange={setOpen}>
274
- <DialogTrigger asChild>
275
- <button className="px-4 py-2 bg-primary text-primary-foreground rounded-md">
276
- Open Monthly Schedule
277
- </button>
278
- </DialogTrigger>
279
- <DialogContent className="max-w-2xl">
280
- <DialogHeader>
281
- <DialogTitle>Monthly Schedule</DialogTitle>
282
- <DialogDescription>
283
- Test monthly calendar grid inside dialog
284
- </DialogDescription>
285
- </DialogHeader>
286
- <div className="py-4">
287
- <CronScheduler
288
- value={cron}
289
- onChange={setCron}
290
- defaultType="monthly"
291
- showPreview
292
- showCronExpression
293
- allowCopy
294
- />
295
- </div>
296
- </DialogContent>
297
- </Dialog>
298
- </div>
299
- );
300
- };