@pushwoosh/dumb-components 1.1.148 → 1.1.150
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 +7 -0
- package/Calendar/CalendarSuperForm/types.d.ts +36 -10
- 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 +12 -1
- package/Drawer/components/Drawer/types.d.ts +10 -1
- 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,533 +0,0 @@
|
|
|
1
|
-
# ProgressBar Component - @pushwoosh/dumb-components
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
- **Component Name**: ProgressBar
|
|
6
|
-
- **Import Path**: `@pushwoosh/dumb-components`
|
|
7
|
-
- **Files**:
|
|
8
|
-
- `/src/ProgressBar/ProgressBar.tsx` - Main component implementation
|
|
9
|
-
- `/src/ProgressBar/types.ts` - TypeScript type definitions
|
|
10
|
-
- `/src/ProgressBar/styles.tsx` - Styled components
|
|
11
|
-
- `/src/ProgressBar/index.ts` - Component exports
|
|
12
|
-
- **Type**: Display/Feedback
|
|
13
|
-
- **Description**: A progress bar component that displays the completion percentage of a task. Features a spinning indicator, customizable colors, title display with percentage, and optional right slot for additional controls or information.
|
|
14
|
-
|
|
15
|
-
## TypeScript Interfaces
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
export type ProgressBarProps = {
|
|
19
|
-
percentValue: number;
|
|
20
|
-
title: string;
|
|
21
|
-
rightSlot?: ReactNode;
|
|
22
|
-
color?: string;
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
};
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Import & Usage
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { ProgressBar } from '@pushwoosh/dumb-components';
|
|
31
|
-
|
|
32
|
-
// Basic usage
|
|
33
|
-
function MyComponent() {
|
|
34
|
-
const [progress, setProgress] = useState(0);
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const interval = setInterval(() => {
|
|
38
|
-
setProgress(prev => {
|
|
39
|
-
if (prev >= 100) {
|
|
40
|
-
clearInterval(interval);
|
|
41
|
-
return 100;
|
|
42
|
-
}
|
|
43
|
-
return prev + 10;
|
|
44
|
-
});
|
|
45
|
-
}, 500);
|
|
46
|
-
|
|
47
|
-
return () => clearInterval(interval);
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<ProgressBar
|
|
52
|
-
percentValue={progress}
|
|
53
|
-
title="Loading"
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// File upload progress
|
|
59
|
-
function FileUploadProgress() {
|
|
60
|
-
const [uploadProgress, setUploadProgress] = useState(0);
|
|
61
|
-
const [fileName, setFileName] = useState('document.pdf');
|
|
62
|
-
|
|
63
|
-
const handleFileUpload = async (file: File) => {
|
|
64
|
-
setFileName(file.name);
|
|
65
|
-
|
|
66
|
-
// Simulate upload progress
|
|
67
|
-
for (let i = 0; i <= 100; i += 5) {
|
|
68
|
-
setUploadProgress(i);
|
|
69
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<ProgressBar
|
|
75
|
-
percentValue={uploadProgress}
|
|
76
|
-
title={`Uploading ${fileName}`}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Advanced Examples
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
// Progress with cancel button
|
|
86
|
-
function CancellableProgress() {
|
|
87
|
-
const [progress, setProgress] = useState(0);
|
|
88
|
-
const [isRunning, setIsRunning] = useState(false);
|
|
89
|
-
const [taskName, setTaskName] = useState('Processing');
|
|
90
|
-
|
|
91
|
-
const intervalRef = useRef<NodeJS.Timeout>();
|
|
92
|
-
|
|
93
|
-
const startProcess = () => {
|
|
94
|
-
setIsRunning(true);
|
|
95
|
-
setProgress(0);
|
|
96
|
-
|
|
97
|
-
intervalRef.current = setInterval(() => {
|
|
98
|
-
setProgress(prev => {
|
|
99
|
-
if (prev >= 100) {
|
|
100
|
-
setIsRunning(false);
|
|
101
|
-
clearInterval(intervalRef.current);
|
|
102
|
-
return 100;
|
|
103
|
-
}
|
|
104
|
-
return prev + 2;
|
|
105
|
-
});
|
|
106
|
-
}, 100);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const cancelProcess = () => {
|
|
110
|
-
setIsRunning(false);
|
|
111
|
-
setProgress(0);
|
|
112
|
-
if (intervalRef.current) {
|
|
113
|
-
clearInterval(intervalRef.current);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
return () => {
|
|
119
|
-
if (intervalRef.current) {
|
|
120
|
-
clearInterval(intervalRef.current);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}, []);
|
|
124
|
-
|
|
125
|
-
const rightSlot = (
|
|
126
|
-
<button
|
|
127
|
-
onClick={cancelProcess}
|
|
128
|
-
disabled={!isRunning}
|
|
129
|
-
style={{
|
|
130
|
-
padding: '4px 8px',
|
|
131
|
-
fontSize: '12px',
|
|
132
|
-
border: '1px solid #dc3545',
|
|
133
|
-
backgroundColor: 'transparent',
|
|
134
|
-
color: '#dc3545',
|
|
135
|
-
borderRadius: '4px',
|
|
136
|
-
cursor: isRunning ? 'pointer' : 'not-allowed',
|
|
137
|
-
}}
|
|
138
|
-
>
|
|
139
|
-
Cancel
|
|
140
|
-
</button>
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
return (
|
|
144
|
-
<div>
|
|
145
|
-
{!isRunning && progress === 0 && (
|
|
146
|
-
<button onClick={startProcess} style={{ marginBottom: '16px' }}>
|
|
147
|
-
Start Process
|
|
148
|
-
</button>
|
|
149
|
-
)}
|
|
150
|
-
|
|
151
|
-
{(isRunning || progress > 0) && (
|
|
152
|
-
<ProgressBar
|
|
153
|
-
percentValue={progress}
|
|
154
|
-
title={taskName}
|
|
155
|
-
rightSlot={rightSlot}
|
|
156
|
-
color="#28a745"
|
|
157
|
-
backgroundColor="#e9ecef"
|
|
158
|
-
/>
|
|
159
|
-
)}
|
|
160
|
-
|
|
161
|
-
{progress === 100 && (
|
|
162
|
-
<div style={{ marginTop: '16px', color: '#28a745' }}>
|
|
163
|
-
✅ Process completed successfully!
|
|
164
|
-
</div>
|
|
165
|
-
)}
|
|
166
|
-
</div>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Multi-step progress
|
|
171
|
-
function MultiStepProgress() {
|
|
172
|
-
const [currentStep, setCurrentStep] = useState(0);
|
|
173
|
-
const [stepProgress, setStepProgress] = useState(0);
|
|
174
|
-
|
|
175
|
-
const steps = [
|
|
176
|
-
'Initializing',
|
|
177
|
-
'Loading data',
|
|
178
|
-
'Processing',
|
|
179
|
-
'Validating',
|
|
180
|
-
'Finalizing'
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
const totalSteps = steps.length;
|
|
184
|
-
const overallProgress = Math.floor(((currentStep + stepProgress / 100) / totalSteps) * 100);
|
|
185
|
-
|
|
186
|
-
const simulateStep = async () => {
|
|
187
|
-
setStepProgress(0);
|
|
188
|
-
|
|
189
|
-
// Simulate step progress
|
|
190
|
-
for (let i = 0; i <= 100; i += 5) {
|
|
191
|
-
setStepProgress(i);
|
|
192
|
-
await new Promise(resolve => setTimeout(resolve, 50));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (currentStep < totalSteps - 1) {
|
|
196
|
-
setCurrentStep(prev => prev + 1);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
useEffect(() => {
|
|
201
|
-
if (currentStep < totalSteps) {
|
|
202
|
-
simulateStep();
|
|
203
|
-
}
|
|
204
|
-
}, [currentStep]);
|
|
205
|
-
|
|
206
|
-
const rightSlot = (
|
|
207
|
-
<span style={{ fontSize: '12px', color: '#666' }}>
|
|
208
|
-
Step {currentStep + 1} of {totalSteps}
|
|
209
|
-
</span>
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
return (
|
|
213
|
-
<div>
|
|
214
|
-
<ProgressBar
|
|
215
|
-
percentValue={overallProgress}
|
|
216
|
-
title={steps[currentStep] || 'Complete'}
|
|
217
|
-
rightSlot={rightSlot}
|
|
218
|
-
color="#007bff"
|
|
219
|
-
/>
|
|
220
|
-
|
|
221
|
-
<div style={{ marginTop: '12px', fontSize: '14px' }}>
|
|
222
|
-
<div>Current step: <strong>{steps[currentStep]}</strong></div>
|
|
223
|
-
<div>Step progress: {stepProgress}%</div>
|
|
224
|
-
<div>Overall progress: {overallProgress}%</div>
|
|
225
|
-
</div>
|
|
226
|
-
</div>
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Data processing progress
|
|
231
|
-
function DataProcessingProgress() {
|
|
232
|
-
const [processed, setProcessed] = useState(0);
|
|
233
|
-
const [total, setTotal] = useState(1000);
|
|
234
|
-
const [isProcessing, setIsProcessing] = useState(false);
|
|
235
|
-
const [processingRate, setProcessingRate] = useState(0);
|
|
236
|
-
const [startTime, setStartTime] = useState<Date | null>(null);
|
|
237
|
-
|
|
238
|
-
const progress = Math.min((processed / total) * 100, 100);
|
|
239
|
-
|
|
240
|
-
const startProcessing = () => {
|
|
241
|
-
setIsProcessing(true);
|
|
242
|
-
setProcessed(0);
|
|
243
|
-
setStartTime(new Date());
|
|
244
|
-
|
|
245
|
-
const interval = setInterval(() => {
|
|
246
|
-
setProcessed(prev => {
|
|
247
|
-
if (prev >= total) {
|
|
248
|
-
setIsProcessing(false);
|
|
249
|
-
clearInterval(interval);
|
|
250
|
-
return total;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Variable processing rate
|
|
254
|
-
const increment = Math.floor(Math.random() * 10) + 1;
|
|
255
|
-
return Math.min(prev + increment, total);
|
|
256
|
-
});
|
|
257
|
-
}, 100);
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
// Calculate processing rate
|
|
261
|
-
useEffect(() => {
|
|
262
|
-
if (startTime && isProcessing) {
|
|
263
|
-
const elapsed = (Date.now() - startTime.getTime()) / 1000;
|
|
264
|
-
const rate = processed / elapsed;
|
|
265
|
-
setProcessingRate(Math.floor(rate));
|
|
266
|
-
}
|
|
267
|
-
}, [processed, startTime, isProcessing]);
|
|
268
|
-
|
|
269
|
-
// Estimate time remaining
|
|
270
|
-
const timeRemaining = processingRate > 0 ? Math.ceil((total - processed) / processingRate) : 0;
|
|
271
|
-
|
|
272
|
-
const rightSlot = (
|
|
273
|
-
<div style={{ textAlign: 'right', fontSize: '12px' }}>
|
|
274
|
-
<div>{processed.toLocaleString()} / {total.toLocaleString()}</div>
|
|
275
|
-
{isProcessing && (
|
|
276
|
-
<div style={{ color: '#666' }}>
|
|
277
|
-
{processingRate}/sec • {timeRemaining}s left
|
|
278
|
-
</div>
|
|
279
|
-
)}
|
|
280
|
-
</div>
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
return (
|
|
284
|
-
<div>
|
|
285
|
-
<div style={{ marginBottom: '16px' }}>
|
|
286
|
-
<label>
|
|
287
|
-
Total items:
|
|
288
|
-
<input
|
|
289
|
-
type="number"
|
|
290
|
-
value={total}
|
|
291
|
-
onChange={(e) => setTotal(parseInt(e.target.value) || 1000)}
|
|
292
|
-
disabled={isProcessing}
|
|
293
|
-
style={{ marginLeft: '8px', width: '100px' }}
|
|
294
|
-
/>
|
|
295
|
-
</label>
|
|
296
|
-
|
|
297
|
-
<button
|
|
298
|
-
onClick={startProcessing}
|
|
299
|
-
disabled={isProcessing}
|
|
300
|
-
style={{ marginLeft: '16px', padding: '8px 16px' }}
|
|
301
|
-
>
|
|
302
|
-
{isProcessing ? 'Processing...' : 'Start Processing'}
|
|
303
|
-
</button>
|
|
304
|
-
</div>
|
|
305
|
-
|
|
306
|
-
<ProgressBar
|
|
307
|
-
percentValue={progress}
|
|
308
|
-
title="Processing records"
|
|
309
|
-
rightSlot={rightSlot}
|
|
310
|
-
color="#17a2b8"
|
|
311
|
-
/>
|
|
312
|
-
|
|
313
|
-
{progress === 100 && (
|
|
314
|
-
<div style={{ marginTop: '16px', padding: '12px', backgroundColor: '#d4edda', borderRadius: '4px', color: '#155724' }}>
|
|
315
|
-
Processing completed! {total.toLocaleString()} records processed.
|
|
316
|
-
</div>
|
|
317
|
-
)}
|
|
318
|
-
</div>
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// Download progress
|
|
323
|
-
function DownloadProgress() {
|
|
324
|
-
const [downloads, setDownloads] = useState<{[key: string]: number}>({});
|
|
325
|
-
|
|
326
|
-
const startDownload = (fileName: string, fileSize: number) => {
|
|
327
|
-
setDownloads(prev => ({ ...prev, [fileName]: 0 }));
|
|
328
|
-
|
|
329
|
-
const interval = setInterval(() => {
|
|
330
|
-
setDownloads(prev => {
|
|
331
|
-
const current = prev[fileName] || 0;
|
|
332
|
-
if (current >= 100) {
|
|
333
|
-
clearInterval(interval);
|
|
334
|
-
return prev;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return {
|
|
338
|
-
...prev,
|
|
339
|
-
[fileName]: Math.min(current + Math.random() * 5, 100)
|
|
340
|
-
};
|
|
341
|
-
});
|
|
342
|
-
}, 200);
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
const removeDownload = (fileName: string) => {
|
|
346
|
-
setDownloads(prev => {
|
|
347
|
-
const { [fileName]: removed, ...rest } = prev;
|
|
348
|
-
return rest;
|
|
349
|
-
});
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const downloadFiles = [
|
|
353
|
-
{ name: 'report.pdf', size: 2.5 },
|
|
354
|
-
{ name: 'data-export.xlsx', size: 8.2 },
|
|
355
|
-
{ name: 'presentation.pptx', size: 15.7 },
|
|
356
|
-
];
|
|
357
|
-
|
|
358
|
-
return (
|
|
359
|
-
<div>
|
|
360
|
-
<h3>File Downloads</h3>
|
|
361
|
-
|
|
362
|
-
<div style={{ marginBottom: '20px' }}>
|
|
363
|
-
{downloadFiles.map(file => (
|
|
364
|
-
<button
|
|
365
|
-
key={file.name}
|
|
366
|
-
onClick={() => startDownload(file.name, file.size)}
|
|
367
|
-
disabled={file.name in downloads}
|
|
368
|
-
style={{
|
|
369
|
-
margin: '4px',
|
|
370
|
-
padding: '8px 12px',
|
|
371
|
-
backgroundColor: file.name in downloads ? '#6c757d' : '#007bff',
|
|
372
|
-
color: 'white',
|
|
373
|
-
border: 'none',
|
|
374
|
-
borderRadius: '4px'
|
|
375
|
-
}}
|
|
376
|
-
>
|
|
377
|
-
Download {file.name} ({file.size}MB)
|
|
378
|
-
</button>
|
|
379
|
-
))}
|
|
380
|
-
</div>
|
|
381
|
-
|
|
382
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
383
|
-
{Object.entries(downloads).map(([fileName, progress]) => {
|
|
384
|
-
const file = downloadFiles.find(f => f.name === fileName);
|
|
385
|
-
const rightSlot = (
|
|
386
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
387
|
-
<span style={{ fontSize: '12px' }}>
|
|
388
|
-
{file?.size}MB
|
|
389
|
-
</span>
|
|
390
|
-
<button
|
|
391
|
-
onClick={() => removeDownload(fileName)}
|
|
392
|
-
style={{
|
|
393
|
-
padding: '2px 6px',
|
|
394
|
-
fontSize: '12px',
|
|
395
|
-
border: '1px solid #dc3545',
|
|
396
|
-
backgroundColor: 'transparent',
|
|
397
|
-
color: '#dc3545',
|
|
398
|
-
borderRadius: '2px',
|
|
399
|
-
cursor: 'pointer'
|
|
400
|
-
}}
|
|
401
|
-
>
|
|
402
|
-
×
|
|
403
|
-
</button>
|
|
404
|
-
</div>
|
|
405
|
-
);
|
|
406
|
-
|
|
407
|
-
return (
|
|
408
|
-
<ProgressBar
|
|
409
|
-
key={fileName}
|
|
410
|
-
percentValue={Math.floor(progress)}
|
|
411
|
-
title={`Downloading ${fileName}`}
|
|
412
|
-
rightSlot={rightSlot}
|
|
413
|
-
color={progress === 100 ? '#28a745' : '#007bff'}
|
|
414
|
-
/>
|
|
415
|
-
);
|
|
416
|
-
})}
|
|
417
|
-
</div>
|
|
418
|
-
</div>
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
## Props Reference
|
|
424
|
-
|
|
425
|
-
| Prop | Type | Default | Required | Description |
|
|
426
|
-
|------|------|---------|----------|-------------|
|
|
427
|
-
| `percentValue` | `number` | - | Yes | Progress percentage (0-100) |
|
|
428
|
-
| `title` | `string` | - | Yes | Title text displayed above the progress bar |
|
|
429
|
-
| `rightSlot` | `ReactNode` | `undefined` | No | Content displayed on the right side of the header |
|
|
430
|
-
| `color` | `string` | `Color.BRIGHT` | No | Color of the progress bar fill |
|
|
431
|
-
| `backgroundColor` | `string` | `Color.BRIGHT_LIGHT` | No | Background color of the progress bar |
|
|
432
|
-
|
|
433
|
-
## AI Agent Guidelines
|
|
434
|
-
|
|
435
|
-
### Recommended Patterns
|
|
436
|
-
|
|
437
|
-
1. **Progress Validation**: Ensure percentage values are within valid range
|
|
438
|
-
```typescript
|
|
439
|
-
const clampedProgress = Math.min(Math.max(progress, 0), 100);
|
|
440
|
-
|
|
441
|
-
<ProgressBar percentValue={clampedProgress} title="Loading" />
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
2. **Smooth Updates**: Use intervals or animation for smooth progress updates
|
|
445
|
-
```typescript
|
|
446
|
-
useEffect(() => {
|
|
447
|
-
const interval = setInterval(() => {
|
|
448
|
-
setProgress(prev => Math.min(prev + 1, 100));
|
|
449
|
-
}, 100);
|
|
450
|
-
|
|
451
|
-
return () => clearInterval(interval);
|
|
452
|
-
}, []);
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
3. **Descriptive Titles**: Use meaningful, action-oriented titles
|
|
456
|
-
```typescript
|
|
457
|
-
// Good - descriptive
|
|
458
|
-
<ProgressBar title="Uploading document" />
|
|
459
|
-
<ProgressBar title="Processing payment" />
|
|
460
|
-
|
|
461
|
-
// Avoid - generic
|
|
462
|
-
<ProgressBar title="Loading" />
|
|
463
|
-
<ProgressBar title="Please wait" />
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
### Common Mistakes to Avoid
|
|
467
|
-
|
|
468
|
-
1. **Invalid Percentage**: Don't pass values outside 0-100 range
|
|
469
|
-
2. **Missing Progress Updates**: Ensure progress actually updates over time
|
|
470
|
-
3. **Blocking UI**: Don't block user interaction during progress display
|
|
471
|
-
4. **Memory Leaks**: Always clean up intervals and timeouts
|
|
472
|
-
5. **Poor UX**: Provide cancel options for long-running tasks
|
|
473
|
-
|
|
474
|
-
### Integration Tips
|
|
475
|
-
|
|
476
|
-
1. **Async Operations**: Use with promises and async/await
|
|
477
|
-
```typescript
|
|
478
|
-
const handleAsyncTask = async () => {
|
|
479
|
-
setProgress(0);
|
|
480
|
-
|
|
481
|
-
try {
|
|
482
|
-
for (let step of steps) {
|
|
483
|
-
await performStep(step);
|
|
484
|
-
setProgress(prev => prev + (100 / steps.length));
|
|
485
|
-
}
|
|
486
|
-
} catch (error) {
|
|
487
|
-
// Handle error
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
2. **File Uploads**: Integrate with file upload progress
|
|
493
|
-
```typescript
|
|
494
|
-
const uploadFile = (file: File) => {
|
|
495
|
-
const xhr = new XMLHttpRequest();
|
|
496
|
-
|
|
497
|
-
xhr.upload.addEventListener('progress', (e) => {
|
|
498
|
-
if (e.lengthComputable) {
|
|
499
|
-
const progress = (e.loaded / e.total) * 100;
|
|
500
|
-
setUploadProgress(progress);
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
xhr.open('POST', '/upload');
|
|
505
|
-
xhr.send(file);
|
|
506
|
-
};
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
3. **Real-time Updates**: Use WebSockets or polling for server progress
|
|
510
|
-
```typescript
|
|
511
|
-
useEffect(() => {
|
|
512
|
-
const ws = new WebSocket('/progress');
|
|
513
|
-
|
|
514
|
-
ws.onmessage = (event) => {
|
|
515
|
-
const { progress, status } = JSON.parse(event.data);
|
|
516
|
-
setProgress(progress);
|
|
517
|
-
setStatus(status);
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
return () => ws.close();
|
|
521
|
-
}, []);
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
4. **Form Validation**: Show validation progress for complex forms
|
|
525
|
-
5. **Accessibility**: Component includes ARIA attributes for screen readers
|
|
526
|
-
|
|
527
|
-
## Related Components
|
|
528
|
-
|
|
529
|
-
- **Spinner**: Used internally for the loading indicator
|
|
530
|
-
- **Button**: Often used with progress for cancel actions
|
|
531
|
-
- **Modal**: For progress dialogs
|
|
532
|
-
- **Alert**: For progress completion notifications
|
|
533
|
-
- **Skeleton**: Alternative for content loading states
|