flikkui 0.2.0-beta.2 → 0.2.0-beta.5
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/README.md +92 -0
- package/dist/components/ai/PromptInput/PromptInput.js +23 -15
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.d.ts +27 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.js +62 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.d.ts +10 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.js +12 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.types.d.ts +53 -0
- package/dist/components/ai/PromptSuggestions/index.d.ts +4 -2
- package/dist/components/ai/index.d.ts +2 -12
- package/dist/components/charts/ActivityRings/ActivityRings.js +70 -58
- package/dist/components/charts/ActivityRings/ActivityRings.theme.js +0 -1
- package/dist/components/charts/ActivityRings/ActivityRings.types.d.ts +17 -0
- package/dist/components/charts/BarChart/BarChart.js +8 -4
- package/dist/components/charts/BarChart/BarChart.types.d.ts +14 -0
- package/dist/components/charts/DonutChart/DonutChart.js +11 -8
- package/dist/components/charts/DonutChart/DonutChart.theme.d.ts +3 -0
- package/dist/components/charts/DonutChart/DonutChart.theme.js +5 -4
- package/dist/components/charts/DonutChart/donut-utils.d.ts +5 -0
- package/dist/components/charts/DonutChart/donut-utils.js +26 -1
- package/dist/components/charts/Heatmap/Heatmap.theme.js +2 -2
- package/dist/components/charts/shared/ChartAxis/XAxis.d.ts +2 -2
- package/dist/components/charts/shared/ChartAxis/XAxis.js +4 -4
- package/dist/components/charts/shared/ChartAxis/YAxis.d.ts +2 -2
- package/dist/components/charts/shared/ChartAxis/YAxis.js +8 -7
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.d.ts +1 -1
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.js +2 -2
- package/dist/components/charts/theme/chart.theme.d.ts +1 -1
- package/dist/components/charts/theme/chart.theme.js +39 -39
- package/dist/components/core/Accordion/Accordion.d.ts +1 -1
- package/dist/components/core/Accordion/Accordion.js +2 -2
- package/dist/components/core/Accordion/Accordion.types.d.ts +8 -0
- package/dist/components/core/Badge/Badge.js +11 -15
- package/dist/components/core/Badge/Badge.theme.js +7 -21
- package/dist/components/core/Badge/Badge.types.d.ts +9 -1
- package/dist/components/core/Button/Button.js +2 -2
- package/dist/components/core/Button/Button.theme.js +1 -1
- package/dist/components/core/Button/Button.types.d.ts +8 -0
- package/dist/components/core/Card/Card.js +8 -2
- package/dist/components/core/Card/Card.theme.js +1 -1
- package/dist/components/core/Card/Card.types.d.ts +24 -1
- package/dist/components/core/Drawer/Drawer.d.ts +1 -1
- package/dist/components/core/Drawer/Drawer.js +10 -40
- package/dist/components/core/Drawer/Drawer.theme.js +2 -1
- package/dist/components/core/Drawer/Drawer.types.d.ts +8 -0
- package/dist/components/core/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/core/Dropdown/Dropdown.js +2 -2
- package/dist/components/core/Dropdown/Dropdown.types.d.ts +8 -0
- package/dist/components/core/Metric/Metric.d.ts +1 -1
- package/dist/components/core/Metric/Metric.js +9 -5
- package/dist/components/core/Metric/Metric.theme.d.ts +1 -1
- package/dist/components/core/Metric/Metric.theme.js +38 -28
- package/dist/components/core/Metric/Metric.types.d.ts +27 -8
- package/dist/components/core/Modal/Modal.d.ts +1 -1
- package/dist/components/core/Modal/Modal.js +17 -40
- package/dist/components/core/Modal/Modal.theme.js +8 -3
- package/dist/components/core/Modal/Modal.types.d.ts +18 -0
- package/dist/components/core/Modal/index.d.ts +1 -1
- package/dist/components/core/Notification/Notification.js +2 -0
- package/dist/components/core/Pill/Pill.d.ts +6 -11
- package/dist/components/core/Pill/Pill.theme.d.ts +2 -2
- package/dist/components/core/Pill/Pill.types.d.ts +9 -22
- package/dist/components/core/Pill/index.d.ts +1 -1
- package/dist/components/core/Popover/Popover.d.ts +1 -1
- package/dist/components/core/Popover/Popover.js +2 -2
- package/dist/components/core/Popover/Popover.types.d.ts +8 -0
- package/dist/components/core/Progress/Progress.d.ts +28 -0
- package/dist/components/core/Progress/Progress.js +114 -0
- package/dist/components/core/Progress/Progress.theme.d.ts +5 -0
- package/dist/components/core/Progress/Progress.theme.js +33 -0
- package/dist/components/core/Progress/Progress.types.d.ts +92 -0
- package/dist/components/core/Progress/index.d.ts +2 -0
- package/dist/components/core/Table/Table.animations.d.ts +5 -16
- package/dist/components/core/Table/Table.animations.js +46 -0
- package/dist/components/core/Table/Table.d.ts +0 -27
- package/dist/components/core/Table/Table.js +58 -156
- package/dist/components/core/Table/Table.theme.js +28 -19
- package/dist/components/core/Table/Table.types.d.ts +95 -8
- package/dist/components/core/Table/Table.utils.d.ts +7 -0
- package/dist/components/core/Table/Table.utils.js +11 -1
- package/dist/components/core/Table/{components/TableActions/TableActions.d.ts → TableActions.d.ts} +3 -3
- package/dist/components/core/Table/{components/TableActions/TableActions.js → TableActions.js} +14 -24
- package/dist/components/core/Table/{components/TableActions/TableActionsMenu.d.ts → TableActionsMenu.d.ts} +1 -1
- package/dist/components/core/Table/{components/TableActions/TableActionsMenu.js → TableActionsMenu.js} +4 -4
- package/dist/components/core/Table/{components/core/TableBody.d.ts → TableBody.d.ts} +1 -1
- package/dist/components/core/Table/{components/core/TableBody.js → TableBody.js} +14 -20
- package/dist/components/core/Table/{components/core/TableCell.d.ts → TableCell.d.ts} +1 -9
- package/dist/components/core/Table/{components/core/TableCell.js → TableCell.js} +5 -13
- package/dist/components/core/Table/TableColumnManager.d.ts +3 -0
- package/dist/components/core/Table/TableColumnManager.js +34 -0
- package/dist/components/core/Table/{components/DeclarativeComponents.d.ts → TableDeclarative.d.ts} +1 -1
- package/dist/components/core/Table/{components/DeclarativeComponents.js → TableDeclarative.js} +6 -56
- package/dist/components/core/Table/TableFilter.d.ts +3 -0
- package/dist/components/core/Table/TableFilter.js +122 -0
- package/dist/components/core/Table/{components/core/TableHeader.d.ts → TableHeader.d.ts} +1 -1
- package/dist/components/core/Table/{components/core/TableHeader.js → TableHeader.js} +15 -29
- package/dist/components/core/Table/TablePagination.d.ts +7 -0
- package/dist/components/core/Table/{components/TablePagination/TablePagination.js → TablePagination.js} +5 -16
- package/dist/components/core/Table/TableRow.d.ts +8 -0
- package/dist/components/core/Table/TableRow.js +45 -0
- package/dist/components/core/Table/TableSelectionHeader.d.ts +7 -0
- package/dist/components/core/Table/{components/TableSelectionHeader/TableSelectionHeader.js → TableSelectionHeader.js} +4 -5
- package/dist/components/core/Table/hooks/index.d.ts +10 -0
- package/dist/components/core/Table/hooks/useTableColumns.d.ts +16 -0
- package/dist/components/core/Table/hooks/useTableColumns.js +67 -0
- package/dist/components/core/Table/hooks/useTableExpansion.d.ts +8 -0
- package/dist/components/core/Table/hooks/useTableExpansion.js +15 -0
- package/dist/components/core/Table/hooks/useTableFilter.d.ts +12 -0
- package/dist/components/core/Table/hooks/useTableFilter.js +37 -0
- package/dist/components/core/Table/hooks/useTablePagination.d.ts +12 -0
- package/dist/components/core/Table/hooks/useTablePagination.js +13 -0
- package/dist/components/core/Table/hooks/useTableSelection.d.ts +17 -0
- package/dist/components/core/Table/hooks/useTableSelection.js +40 -0
- package/dist/components/core/Table/index.d.ts +9 -8
- package/dist/components/core/Table/index.js +7 -5
- package/dist/components/core/Tabs/Tabs.js +2 -2
- package/dist/components/core/Tabs/Tabs.types.d.ts +8 -0
- package/dist/components/core/Tag/Tag.animations.d.ts +3 -0
- package/dist/components/core/Tag/Tag.animations.js +31 -0
- package/dist/components/core/Tag/Tag.d.ts +14 -0
- package/dist/components/core/Tag/Tag.js +45 -0
- package/dist/components/core/Tag/Tag.theme.d.ts +2 -0
- package/dist/components/core/Tag/Tag.theme.js +21 -0
- package/dist/components/core/Tag/Tag.types.d.ts +40 -0
- package/dist/components/core/Tag/index.d.ts +3 -0
- package/dist/components/core/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.js +3 -3
- package/dist/components/core/Tooltip/Tooltip.theme.js +1 -1
- package/dist/components/core/Tooltip/Tooltip.types.d.ts +17 -0
- package/dist/components/core/index.d.ts +2 -1
- package/dist/components/core/index.js +12 -5
- package/dist/components/effects/CustomCursor/CustomCursor.d.ts +0 -13
- package/dist/components/effects/CustomCursor/CustomCursor.js +26 -2
- package/dist/components/effects/CustomCursor/CustomCursor.theme.js +12 -1
- package/dist/components/effects/CustomCursor/CustomCursor.types.d.ts +14 -1
- package/dist/components/forms/Combobox/Combobox.d.ts +25 -0
- package/dist/components/forms/Combobox/Combobox.js +412 -0
- package/dist/components/forms/Combobox/Combobox.theme.d.ts +6 -0
- package/dist/components/forms/Combobox/Combobox.theme.js +60 -0
- package/dist/components/forms/Combobox/Combobox.types.d.ts +111 -0
- package/dist/components/forms/Combobox/index.d.ts +3 -0
- package/dist/components/forms/FileUpload/FileUpload.js +2 -0
- package/dist/components/forms/Input/Input.js +25 -28
- package/dist/components/forms/Input/inputMasks.d.ts +15 -0
- package/dist/components/forms/Input/inputMasks.js +72 -1
- package/dist/components/forms/InputTag/InputTag.d.ts +40 -0
- package/dist/components/forms/InputTag/InputTag.js +491 -0
- package/dist/components/forms/InputTag/InputTag.theme.d.ts +2 -0
- package/dist/components/forms/InputTag/InputTag.theme.js +16 -0
- package/dist/components/forms/InputTag/InputTag.types.d.ts +107 -0
- package/dist/components/forms/InputTag/index.d.ts +3 -0
- package/dist/components/forms/Select/Select.d.ts +101 -2
- package/dist/components/forms/Select/Select.js +128 -132
- package/dist/components/forms/Select/Select.theme.js +10 -14
- package/dist/components/forms/Select/Select.types.d.ts +6 -2
- package/dist/components/forms/Select/index.d.ts +7 -4
- package/dist/components/forms/Select/useSelectState.d.ts +66 -0
- package/dist/components/forms/Select/useSelectState.js +134 -0
- package/dist/components/forms/SelectExpand/SelectExpand.animations.d.ts +20 -0
- package/dist/components/forms/SelectExpand/SelectExpand.animations.js +74 -0
- package/dist/components/forms/SelectExpand/SelectExpand.d.ts +9 -0
- package/dist/components/forms/SelectExpand/SelectExpand.js +223 -0
- package/dist/components/forms/SelectExpand/SelectExpand.theme.d.ts +5 -0
- package/dist/components/forms/SelectExpand/SelectExpand.theme.js +74 -0
- package/dist/components/forms/SelectExpand/SelectExpand.types.d.ts +126 -0
- package/dist/components/forms/SelectExpand/index.d.ts +4 -0
- package/dist/components/forms/Switch/Switch.js +3 -3
- package/dist/components/forms/Switch/Switch.theme.d.ts +1 -1
- package/dist/components/forms/Switch/Switch.theme.js +2 -2
- package/dist/components/forms/TimePicker/TimePicker.animations.d.ts +0 -46
- package/dist/components/forms/TimePicker/TimePicker.d.ts +15 -6
- package/dist/components/forms/TimePicker/TimePicker.js +285 -124
- package/dist/components/forms/TimePicker/TimePicker.theme.d.ts +1 -1
- package/dist/components/forms/TimePicker/TimePicker.theme.js +39 -22
- package/dist/components/forms/TimePicker/TimePicker.types.d.ts +88 -34
- package/dist/components/forms/TimePicker/TimePickerContent.d.ts +7 -10
- package/dist/components/forms/TimePicker/TimePickerContent.js +149 -16
- package/dist/components/forms/TimePicker/TimePickerTrigger.d.ts +3 -3
- package/dist/components/forms/TimePicker/TimePickerTrigger.js +22 -19
- package/dist/components/forms/TimePicker/WheelColumn.d.ts +14 -0
- package/dist/components/forms/TimePicker/WheelColumn.js +90 -0
- package/dist/components/forms/TimePicker/index.d.ts +4 -1
- package/dist/components/forms/TimePicker/useWheelPicker.d.ts +37 -0
- package/dist/components/forms/TimePicker/useWheelPicker.js +138 -0
- package/dist/components/forms/forms.theme.d.ts +14 -0
- package/dist/components/forms/forms.theme.js +31 -0
- package/dist/components/forms/index.d.ts +9 -3
- package/dist/components/forms/index.js +73 -2
- package/dist/hooks/index.d.ts +0 -4
- package/dist/icons/Icon.d.ts +7 -0
- package/dist/icons/Icon.js +6 -2
- package/dist/index.js +21 -19
- package/dist/styles.css +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/optimisticErrors.js +1 -70
- package/package.json +1 -1
- package/dist/components/ai/EditingIndicator/EditingIndicator.animations.d.ts +0 -31
- package/dist/components/ai/EditingIndicator/EditingIndicator.animations.js +0 -115
- package/dist/components/ai/EditingIndicator/EditingIndicator.d.ts +0 -35
- package/dist/components/ai/EditingIndicator/EditingIndicator.js +0 -94
- package/dist/components/ai/EditingIndicator/EditingIndicator.theme.d.ts +0 -2
- package/dist/components/ai/EditingIndicator/EditingIndicator.theme.js +0 -13
- package/dist/components/ai/EditingIndicator/EditingIndicator.types.d.ts +0 -54
- package/dist/components/ai/EditingIndicator/index.d.ts +0 -9
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.d.ts +0 -3
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.js +0 -126
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.theme.d.ts +0 -2
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.theme.js +0 -8
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.types.d.ts +0 -45
- package/dist/components/ai/GenerativeRenderer/index.d.ts +0 -3
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.animations.d.ts +0 -17
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.animations.js +0 -56
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.d.ts +0 -38
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.js +0 -110
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.theme.d.ts +0 -2
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.theme.js +0 -13
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.types.d.ts +0 -53
- package/dist/components/ai/PresenceIndicator/index.d.ts +0 -8
- package/dist/components/ai/PresenceProvider/PresenceContext.d.ts +0 -24
- package/dist/components/ai/PresenceProvider/PresenceContext.js +0 -34
- package/dist/components/ai/PresenceProvider/PresenceProvider.d.ts +0 -32
- package/dist/components/ai/PresenceProvider/PresenceProvider.js +0 -321
- package/dist/components/ai/PresenceProvider/PresenceProvider.types.d.ts +0 -140
- package/dist/components/ai/PresenceProvider/adapters/MockAdapter.d.ts +0 -102
- package/dist/components/ai/PresenceProvider/adapters/MockAdapter.js +0 -331
- package/dist/components/ai/PresenceProvider/adapters/PresenceAdapter.d.ts +0 -93
- package/dist/components/ai/PresenceProvider/adapters/SupabaseAdapter.d.ts +0 -134
- package/dist/components/ai/PresenceProvider/adapters/WebSocketAdapter.d.ts +0 -149
- package/dist/components/ai/PresenceProvider/adapters/index.d.ts +0 -11
- package/dist/components/ai/PresenceProvider/index.d.ts +0 -10
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.d.ts +0 -27
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.js +0 -61
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.types.d.ts +0 -65
- package/dist/components/ai/VersionSlider/VersionSlider.d.ts +0 -3
- package/dist/components/ai/VersionSlider/VersionSlider.js +0 -97
- package/dist/components/ai/VersionSlider/VersionSlider.theme.d.ts +0 -2
- package/dist/components/ai/VersionSlider/VersionSlider.theme.js +0 -18
- package/dist/components/ai/VersionSlider/VersionSlider.types.d.ts +0 -77
- package/dist/components/ai/VersionSlider/index.d.ts +0 -3
- package/dist/components/core/Pill/Pill.animations.js +0 -25
- package/dist/components/core/Pill/Pill.js +0 -145
- package/dist/components/core/Pill/Pill.theme.js +0 -65
- package/dist/components/core/RetryBoundary/RetryBoundary.d.ts +0 -35
- package/dist/components/core/RetryBoundary/RetryBoundary.js +0 -154
- package/dist/components/core/RetryBoundary/RetryBoundary.theme.d.ts +0 -2
- package/dist/components/core/RetryBoundary/RetryBoundary.theme.js +0 -7
- package/dist/components/core/RetryBoundary/RetryBoundary.types.d.ts +0 -51
- package/dist/components/core/RetryBoundary/index.d.ts +0 -3
- package/dist/components/core/Table/components/TableActions/TableActions.types.d.ts +0 -40
- package/dist/components/core/Table/components/TableActions/index.d.ts +0 -3
- package/dist/components/core/Table/components/TableActionsMenu.d.ts +0 -6
- package/dist/components/core/Table/components/TablePagination/TablePagination.d.ts +0 -17
- package/dist/components/core/Table/components/TablePagination/TablePagination.types.d.ts +0 -21
- package/dist/components/core/Table/components/TablePagination/index.d.ts +0 -2
- package/dist/components/core/Table/components/TableSelectionHeader/TableSelectionHeader.d.ts +0 -15
- package/dist/components/core/Table/components/TableSelectionHeader/index.d.ts +0 -3
- package/dist/components/core/Table/components/core/TableRow.d.ts +0 -3
- package/dist/components/core/Table/components/core/TableRow.js +0 -44
- package/dist/components/core/Table/components/core/index.d.ts +0 -4
- package/dist/components/forms/OptimisticForm/OptimisticForm.d.ts +0 -33
- package/dist/components/forms/OptimisticForm/OptimisticForm.js +0 -87
- package/dist/components/forms/OptimisticForm/OptimisticForm.theme.d.ts +0 -2
- package/dist/components/forms/OptimisticForm/OptimisticForm.theme.js +0 -8
- package/dist/components/forms/OptimisticForm/OptimisticForm.types.d.ts +0 -74
- package/dist/components/forms/OptimisticForm/index.d.ts +0 -3
- package/dist/hooks/useOptimisticMutation.d.ts +0 -109
- package/dist/hooks/useOptimisticMutation.js +0 -171
- package/dist/hooks/usePresence.d.ts +0 -88
- package/dist/utils/presenceUtils.d.ts +0 -66
- package/dist/utils/presenceUtils.js +0 -107
package/dist/utils/index.d.ts
CHANGED
|
@@ -11,4 +11,3 @@ export { MutationError, RollbackError, QueueError, OptimisticNetworkError, norma
|
|
|
11
11
|
export { ActionQueue, createActionQueue, getDefaultQueue, type QueuedAction, type ActionQueueOptions, type AddActionOptions, } from "./actionQueue";
|
|
12
12
|
export * from "./stateMachine";
|
|
13
13
|
export * from "./formValidation";
|
|
14
|
-
export { formatTypingText, formatPresenceCount, validatePresenceUser, validateTypingUser, sortUsers, } from "./presenceUtils";
|
|
@@ -6,32 +6,6 @@
|
|
|
6
6
|
* Mutation error - occurs when the server rejects the mutation
|
|
7
7
|
* Retryable: Depends on error type (network yes, validation no)
|
|
8
8
|
*/
|
|
9
|
-
class MutationError extends Error {
|
|
10
|
-
constructor(message, retryable = true, originalData, rollbackData, details) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.retryable = retryable;
|
|
13
|
-
this.originalData = originalData;
|
|
14
|
-
this.rollbackData = rollbackData;
|
|
15
|
-
this.details = details;
|
|
16
|
-
this.type = "mutation";
|
|
17
|
-
this.name = "MutationError";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Rollback error - occurs when attempting to rollback optimistic state fails
|
|
22
|
-
* Retryable: No (indicates a serious state corruption issue)
|
|
23
|
-
*/
|
|
24
|
-
class RollbackError extends Error {
|
|
25
|
-
constructor(message, originalData, rollbackData, details) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.originalData = originalData;
|
|
28
|
-
this.rollbackData = rollbackData;
|
|
29
|
-
this.details = details;
|
|
30
|
-
this.type = "rollback";
|
|
31
|
-
this.retryable = false;
|
|
32
|
-
this.name = "RollbackError";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
9
|
/**
|
|
36
10
|
* Queue error - occurs when action queue operations fail
|
|
37
11
|
* Retryable: Yes (queue operations can be retried)
|
|
@@ -49,48 +23,5 @@ class QueueError extends Error {
|
|
|
49
23
|
this.rollbackData = undefined;
|
|
50
24
|
}
|
|
51
25
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Network error for optimistic operations - typically connection issues
|
|
54
|
-
* Retryable: Yes
|
|
55
|
-
*/
|
|
56
|
-
class OptimisticNetworkError extends Error {
|
|
57
|
-
constructor(message, originalData, rollbackData, details) {
|
|
58
|
-
super(message);
|
|
59
|
-
this.originalData = originalData;
|
|
60
|
-
this.rollbackData = rollbackData;
|
|
61
|
-
this.details = details;
|
|
62
|
-
this.type = "network";
|
|
63
|
-
this.retryable = true;
|
|
64
|
-
this.name = "OptimisticNetworkError";
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Normalize any error into an OptimisticError
|
|
69
|
-
* Used to convert unknown errors into typed optimistic errors
|
|
70
|
-
*
|
|
71
|
-
* @param error - Any error object
|
|
72
|
-
* @param context - Optional context for rollback (originalData, rollbackData)
|
|
73
|
-
* @returns Normalized OptimisticError
|
|
74
|
-
*/
|
|
75
|
-
const normalizeOptimisticError = (error, context) => {
|
|
76
|
-
// Already an optimistic error - return as-is
|
|
77
|
-
if (error instanceof MutationError ||
|
|
78
|
-
error instanceof RollbackError ||
|
|
79
|
-
error instanceof QueueError ||
|
|
80
|
-
error instanceof OptimisticNetworkError) {
|
|
81
|
-
return error;
|
|
82
|
-
}
|
|
83
|
-
// Handle fetch/network errors
|
|
84
|
-
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
85
|
-
return new OptimisticNetworkError(error.message, context === null || context === void 0 ? void 0 : context.originalData, context === null || context === void 0 ? void 0 : context.rollbackData, error);
|
|
86
|
-
}
|
|
87
|
-
// Handle AbortController abortion
|
|
88
|
-
if (error instanceof DOMException && error.name === "AbortError") {
|
|
89
|
-
return new MutationError("Request was aborted", false, // Not retryable - user initiated
|
|
90
|
-
context === null || context === void 0 ? void 0 : context.originalData, context === null || context === void 0 ? void 0 : context.rollbackData, error);
|
|
91
|
-
}
|
|
92
|
-
// Unknown error - treat as mutation error (retryable)
|
|
93
|
-
return new MutationError(error instanceof Error ? error.message : "Unknown mutation error", true, context === null || context === void 0 ? void 0 : context.originalData, context === null || context === void 0 ? void 0 : context.rollbackData, error);
|
|
94
|
-
};
|
|
95
26
|
|
|
96
|
-
export {
|
|
27
|
+
export { QueueError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flikkui",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "A modern React component library built with TypeScript, Tailwind CSS v4, and Framer Motion. Follows the shadcn philosophy with complete className override support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EditingIndicator Animations
|
|
3
|
-
*
|
|
4
|
-
* Framer Motion animation variants for typing indicators.
|
|
5
|
-
* Import from 'motion/react' (NOT 'framer-motion').
|
|
6
|
-
*/
|
|
7
|
-
import { Variants } from "motion/react";
|
|
8
|
-
/**
|
|
9
|
-
* Container fade in/out animation with subtle scale
|
|
10
|
-
*/
|
|
11
|
-
export declare const containerVariants: Variants;
|
|
12
|
-
/**
|
|
13
|
-
* Ellipsis dot animation
|
|
14
|
-
* Wave effect: Dots move up and down while fading
|
|
15
|
-
*/
|
|
16
|
-
export declare const ellipsisVariants: Variants;
|
|
17
|
-
/**
|
|
18
|
-
* Pulse animation (alternative to ellipsis)
|
|
19
|
-
* Smooth fade in/out of the entire indicator
|
|
20
|
-
*/
|
|
21
|
-
export declare const pulseVariants: Variants;
|
|
22
|
-
/**
|
|
23
|
-
* Avatar Container for staggering
|
|
24
|
-
* Ensures children (avatars) animate in sequence
|
|
25
|
-
*/
|
|
26
|
-
export declare const avatarContainerVariants: Variants;
|
|
27
|
-
/**
|
|
28
|
-
* Individual Avatar animation
|
|
29
|
-
* Pop-in effect
|
|
30
|
-
*/
|
|
31
|
-
export declare const avatarVariants: Variants;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EditingIndicator Animations
|
|
3
|
-
*
|
|
4
|
-
* Framer Motion animation variants for typing indicators.
|
|
5
|
-
* Import from 'motion/react' (NOT 'framer-motion').
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Container fade in/out animation with subtle scale
|
|
9
|
-
*/
|
|
10
|
-
const containerVariants = {
|
|
11
|
-
hidden: {
|
|
12
|
-
opacity: 0,
|
|
13
|
-
y: 8,
|
|
14
|
-
scale: 0.95,
|
|
15
|
-
transition: {
|
|
16
|
-
duration: 0.2,
|
|
17
|
-
ease: "easeOut",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
visible: {
|
|
21
|
-
opacity: 1,
|
|
22
|
-
y: 0,
|
|
23
|
-
scale: 1,
|
|
24
|
-
transition: {
|
|
25
|
-
duration: 0.3,
|
|
26
|
-
ease: "backOut",
|
|
27
|
-
staggerChildren: 0.1, // Stagger avatar entry
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
exit: {
|
|
31
|
-
opacity: 0,
|
|
32
|
-
y: -4,
|
|
33
|
-
scale: 0.98,
|
|
34
|
-
transition: {
|
|
35
|
-
duration: 0.2,
|
|
36
|
-
ease: "easeIn",
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Ellipsis dot animation
|
|
42
|
-
* Wave effect: Dots move up and down while fading
|
|
43
|
-
*/
|
|
44
|
-
const ellipsisVariants = {
|
|
45
|
-
initial: {
|
|
46
|
-
opacity: 0.4,
|
|
47
|
-
y: 0,
|
|
48
|
-
},
|
|
49
|
-
animate: (index) => ({
|
|
50
|
-
opacity: [0.4, 1, 0.4],
|
|
51
|
-
y: [0, -3, 0], // Wave motion
|
|
52
|
-
transition: {
|
|
53
|
-
duration: 1.2,
|
|
54
|
-
repeat: Infinity,
|
|
55
|
-
delay: index * 0.15,
|
|
56
|
-
ease: "easeInOut",
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Pulse animation (alternative to ellipsis)
|
|
62
|
-
* Smooth fade in/out of the entire indicator
|
|
63
|
-
*/
|
|
64
|
-
const pulseVariants = {
|
|
65
|
-
initial: {
|
|
66
|
-
scale: 1,
|
|
67
|
-
opacity: 0.5,
|
|
68
|
-
},
|
|
69
|
-
animate: {
|
|
70
|
-
scale: [1, 1.1, 1],
|
|
71
|
-
opacity: [0.5, 1, 0.5],
|
|
72
|
-
transition: {
|
|
73
|
-
duration: 1.5,
|
|
74
|
-
repeat: Infinity,
|
|
75
|
-
ease: "easeInOut",
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Avatar Container for staggering
|
|
81
|
-
* Ensures children (avatars) animate in sequence
|
|
82
|
-
*/
|
|
83
|
-
const avatarContainerVariants = {
|
|
84
|
-
hidden: { opacity: 0 },
|
|
85
|
-
visible: {
|
|
86
|
-
opacity: 1,
|
|
87
|
-
transition: {
|
|
88
|
-
staggerChildren: 0.1,
|
|
89
|
-
delayChildren: 0.1,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Individual Avatar animation
|
|
95
|
-
* Pop-in effect
|
|
96
|
-
*/
|
|
97
|
-
const avatarVariants = {
|
|
98
|
-
hidden: {
|
|
99
|
-
opacity: 0,
|
|
100
|
-
scale: 0.5,
|
|
101
|
-
x: -10, // Slide in slightly from left
|
|
102
|
-
},
|
|
103
|
-
visible: {
|
|
104
|
-
opacity: 1,
|
|
105
|
-
scale: 1,
|
|
106
|
-
x: 0,
|
|
107
|
-
transition: {
|
|
108
|
-
type: "spring",
|
|
109
|
-
stiffness: 400,
|
|
110
|
-
damping: 25,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export { avatarContainerVariants, avatarVariants, containerVariants, ellipsisVariants, pulseVariants };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EditingIndicator Component
|
|
3
|
-
*
|
|
4
|
-
* Displays "User is typing..." with animated ellipsis.
|
|
5
|
-
* Shows when one or more users are actively typing.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* <PresenceProvider channel="chat" currentUser={user} adapter={adapter}>
|
|
10
|
-
* <EditingIndicator position="above" showAvatars />
|
|
11
|
-
* <input type="text" />
|
|
12
|
-
* </PresenceProvider>
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
import React from "react";
|
|
16
|
-
import { EditingIndicatorProps } from "./EditingIndicator.types";
|
|
17
|
-
/**
|
|
18
|
-
* EditingIndicator - Show typing status
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* // Basic usage
|
|
23
|
-
* <EditingIndicator />
|
|
24
|
-
*
|
|
25
|
-
* // With avatars
|
|
26
|
-
* <EditingIndicator showAvatars avatarSize="xs" />
|
|
27
|
-
*
|
|
28
|
-
* // Custom position
|
|
29
|
-
* <EditingIndicator position="below" />
|
|
30
|
-
*
|
|
31
|
-
* // Custom styling
|
|
32
|
-
* <EditingIndicator className="text-blue-600" />
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare const EditingIndicator: React.ForwardRefExoticComponent<EditingIndicatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React__default, { useMemo } from 'react';
|
|
2
|
-
import { useReducedMotion, AnimatePresence, motion } from 'motion/react';
|
|
3
|
-
import { Avatar } from '../../core/Avatar/Avatar.js';
|
|
4
|
-
import { usePresenceContext } from '../PresenceProvider/PresenceContext.js';
|
|
5
|
-
import { editingIndicatorTheme } from './EditingIndicator.theme.js';
|
|
6
|
-
import { containerVariants, avatarContainerVariants, avatarVariants, ellipsisVariants, pulseVariants } from './EditingIndicator.animations.js';
|
|
7
|
-
import { cn } from '../../../utils/cn.js';
|
|
8
|
-
import { formatTypingText } from '../../../utils/presenceUtils.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* EditingIndicator Component
|
|
12
|
-
*
|
|
13
|
-
* Displays "User is typing..." with animated ellipsis.
|
|
14
|
-
* Shows when one or more users are actively typing.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* <PresenceProvider channel="chat" currentUser={user} adapter={adapter}>
|
|
19
|
-
* <EditingIndicator position="above" showAvatars />
|
|
20
|
-
* <input type="text" />
|
|
21
|
-
* </PresenceProvider>
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* EditingIndicator - Show typing status
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* // Basic usage
|
|
30
|
-
* <EditingIndicator />
|
|
31
|
-
*
|
|
32
|
-
* // With avatars
|
|
33
|
-
* <EditingIndicator showAvatars avatarSize="xs" />
|
|
34
|
-
*
|
|
35
|
-
* // Custom position
|
|
36
|
-
* <EditingIndicator position="below" />
|
|
37
|
-
*
|
|
38
|
-
* // Custom styling
|
|
39
|
-
* <EditingIndicator className="text-blue-600" />
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
const EditingIndicator = React__default.forwardRef(({ position = "above", maxVisible = 3, showAvatars = false, avatarSize = "xs", formatText, animation = "ellipsis", shouldAnimate = true, icon, theme = editingIndicatorTheme, className, ...props }, ref) => {
|
|
43
|
-
var _a;
|
|
44
|
-
// Get typing users from context
|
|
45
|
-
const { typingUsers } = usePresenceContext();
|
|
46
|
-
// Check for reduced motion preference
|
|
47
|
-
const prefersReducedMotion = useReducedMotion();
|
|
48
|
-
const enableAnimations = shouldAnimate && !prefersReducedMotion;
|
|
49
|
-
// Format typing text
|
|
50
|
-
const typingText = useMemo(() => {
|
|
51
|
-
if (typingUsers.length === 0)
|
|
52
|
-
return null;
|
|
53
|
-
return formatText
|
|
54
|
-
? formatText(typingUsers)
|
|
55
|
-
: formatTypingText(typingUsers, maxVisible);
|
|
56
|
-
}, [typingUsers, maxVisible, formatText]);
|
|
57
|
-
// Build ARIA label (without ellipsis)
|
|
58
|
-
const ariaLabel = useMemo(() => {
|
|
59
|
-
if (typingUsers.length === 0)
|
|
60
|
-
return "No one is typing";
|
|
61
|
-
if (typingUsers.length === 1)
|
|
62
|
-
return `${typingUsers[0].name} is typing`;
|
|
63
|
-
if (typingUsers.length === 2)
|
|
64
|
-
return `${typingUsers[0].name} and ${typingUsers[1].name} are typing`;
|
|
65
|
-
return `${typingUsers.length} people are typing`;
|
|
66
|
-
}, [typingUsers]);
|
|
67
|
-
// Merge theme
|
|
68
|
-
const mergedTheme = {
|
|
69
|
-
...editingIndicatorTheme,
|
|
70
|
-
...theme,
|
|
71
|
-
};
|
|
72
|
-
// Build className
|
|
73
|
-
const containerClassName = cn(mergedTheme.baseStyle, (_a = mergedTheme.positions) === null || _a === void 0 ? void 0 : _a[position], className // User overrides take precedence
|
|
74
|
-
);
|
|
75
|
-
// Don't render if no one is typing
|
|
76
|
-
if (typingUsers.length === 0) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
return (React__default.createElement(AnimatePresence, { mode: "wait" },
|
|
80
|
-
React__default.createElement(motion.div, { ref: ref, className: containerClassName, role: "status", "aria-live": "polite", "aria-label": ariaLabel, "data-typing-count": typingUsers.length, variants: enableAnimations ? containerVariants : undefined, initial: enableAnimations ? "hidden" : undefined, animate: enableAnimations ? "visible" : undefined, exit: enableAnimations ? "exit" : undefined, ...props },
|
|
81
|
-
showAvatars && typingUsers.length > 0 && (React__default.createElement(motion.div, { className: mergedTheme.avatarContainerStyle, variants: enableAnimations ? avatarContainerVariants : undefined }, typingUsers.slice(0, maxVisible).map((user) => (React__default.createElement(motion.div, { key: user.id, variants: enableAnimations ? avatarVariants : undefined },
|
|
82
|
-
React__default.createElement(Avatar, { src: user.avatar, alt: user.name, size: avatarSize, className: "border-2 border-white" })))))),
|
|
83
|
-
icon ? (React__default.createElement("div", { className: "flex items-center gap-1" },
|
|
84
|
-
icon,
|
|
85
|
-
React__default.createElement("span", { className: mergedTheme.textStyle }, typingText))) : (React__default.createElement("span", { className: mergedTheme.textStyle },
|
|
86
|
-
typingText,
|
|
87
|
-
enableAnimations && animation === "ellipsis" && (React__default.createElement("span", { className: mergedTheme.ellipsisStyle, "aria-hidden": "true" }, [0, 1, 2].map((index) => (React__default.createElement(motion.span, { key: index, custom: index, variants: ellipsisVariants, initial: "initial", animate: "animate" }, "."))))),
|
|
88
|
-
(!enableAnimations || animation === "none") && (React__default.createElement("span", { "aria-hidden": "true" }, "...")))),
|
|
89
|
-
enableAnimations && animation === "pulse" && (React__default.createElement(motion.span, { variants: pulseVariants, initial: "initial", animate: "animate", className: "inline-block w-2 h-2 rounded-full bg-[var(--color-primary)]", "aria-hidden": "true" })))));
|
|
90
|
-
});
|
|
91
|
-
// Display name for dev tools
|
|
92
|
-
EditingIndicator.displayName = "EditingIndicator";
|
|
93
|
-
|
|
94
|
-
export { EditingIndicator };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const editingIndicatorTheme = {
|
|
2
|
-
baseStyle: "flex items-center gap-2 text-[var(--color-text-secondary)]",
|
|
3
|
-
textStyle: "text-sm font-medium",
|
|
4
|
-
avatarContainerStyle: "inline-flex -space-x-1",
|
|
5
|
-
ellipsisStyle: "inline-flex gap-0.5 ml-0.5",
|
|
6
|
-
positions: {
|
|
7
|
-
above: "mb-2",
|
|
8
|
-
below: "mt-2",
|
|
9
|
-
inline: "",
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { editingIndicatorTheme };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EditingIndicator Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* Defines props and interfaces for the EditingIndicator component.
|
|
5
|
-
*/
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { TypingUser } from '../PresenceProvider/PresenceProvider.types';
|
|
8
|
-
import { AvatarSize } from '../../core/Avatar/Avatar.types';
|
|
9
|
-
/**
|
|
10
|
-
* Position of the indicator relative to input
|
|
11
|
-
*/
|
|
12
|
-
export type EditingIndicatorPosition = 'above' | 'below' | 'inline';
|
|
13
|
-
/**
|
|
14
|
-
* Animation style for the indicator
|
|
15
|
-
*/
|
|
16
|
-
export type EditingIndicatorAnimation = 'ellipsis' | 'pulse' | 'none';
|
|
17
|
-
/**
|
|
18
|
-
* EditingIndicator component props
|
|
19
|
-
*/
|
|
20
|
-
export interface EditingIndicatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
21
|
-
/** Position relative to input (default: 'above') */
|
|
22
|
-
position?: EditingIndicatorPosition;
|
|
23
|
-
/** Maximum users to display in text (default: 3) */
|
|
24
|
-
maxVisible?: number;
|
|
25
|
-
/** Show user avatars alongside text (default: false) */
|
|
26
|
-
showAvatars?: boolean;
|
|
27
|
-
/** Avatar size when shown (default: 'xs') */
|
|
28
|
-
avatarSize?: Extract<AvatarSize, 'xs' | 'sm'>;
|
|
29
|
-
/** Custom text formatter */
|
|
30
|
-
formatText?: (users: TypingUser[]) => string;
|
|
31
|
-
/** Animation style (default: 'ellipsis') */
|
|
32
|
-
animation?: EditingIndicatorAnimation;
|
|
33
|
-
/** Enable animations (default: true) */
|
|
34
|
-
shouldAnimate?: boolean;
|
|
35
|
-
/** Custom icon instead of text */
|
|
36
|
-
icon?: React.ReactNode;
|
|
37
|
-
/** Theme overrides */
|
|
38
|
-
theme?: EditingIndicatorTheme;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Theme configuration for EditingIndicator
|
|
42
|
-
*/
|
|
43
|
-
export interface EditingIndicatorTheme {
|
|
44
|
-
/** Base container style */
|
|
45
|
-
baseStyle?: string;
|
|
46
|
-
/** Text label style */
|
|
47
|
-
textStyle?: string;
|
|
48
|
-
/** Avatar container style */
|
|
49
|
-
avatarContainerStyle?: string;
|
|
50
|
-
/** Ellipsis dots style */
|
|
51
|
-
ellipsisStyle?: string;
|
|
52
|
-
/** Position variants */
|
|
53
|
-
positions?: Partial<Record<EditingIndicatorPosition, string>>;
|
|
54
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EditingIndicator - Typing status indicator
|
|
3
|
-
*
|
|
4
|
-
* @module collaboration/EditingIndicator
|
|
5
|
-
*/
|
|
6
|
-
export { EditingIndicator } from './EditingIndicator';
|
|
7
|
-
export { editingIndicatorTheme } from './EditingIndicator.theme';
|
|
8
|
-
export { containerVariants, ellipsisVariants, pulseVariants, } from './EditingIndicator.animations';
|
|
9
|
-
export type { EditingIndicatorProps, EditingIndicatorTheme, EditingIndicatorPosition, EditingIndicatorAnimation, } from './EditingIndicator.types';
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useRef, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
-
import { ExclamationTriangleIcon } from '@heroicons/react/24/outline';
|
|
3
|
-
import { cn } from '../../../utils/cn.js';
|
|
4
|
-
import { generativeRendererTheme } from './GenerativeRenderer.theme.js';
|
|
5
|
-
import { Spinner } from '../../core/Spinner/Spinner.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Wraps HTML content in a full document structure
|
|
9
|
-
*/
|
|
10
|
-
const createHTMLDocument = (content) => {
|
|
11
|
-
// If content already has <html> or <body>, use as-is
|
|
12
|
-
if (content.includes("<html") || content.includes("<!DOCTYPE")) {
|
|
13
|
-
return content;
|
|
14
|
-
}
|
|
15
|
-
// Check if content has style tags
|
|
16
|
-
content.includes("<style");
|
|
17
|
-
return `
|
|
18
|
-
<!DOCTYPE html>
|
|
19
|
-
<html>
|
|
20
|
-
<head>
|
|
21
|
-
<meta charset="UTF-8">
|
|
22
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
23
|
-
<style>
|
|
24
|
-
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
25
|
-
body {
|
|
26
|
-
font-family: system-ui, -apple-system, sans-serif;
|
|
27
|
-
line-height: 1.5;
|
|
28
|
-
padding: 16px;
|
|
29
|
-
color: #1a1a1a;
|
|
30
|
-
}
|
|
31
|
-
</style>
|
|
32
|
-
</head>
|
|
33
|
-
<body>
|
|
34
|
-
${content}
|
|
35
|
-
</body>
|
|
36
|
-
</html>
|
|
37
|
-
`.trim();
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Converts markdown to basic HTML (lightweight, no external deps)
|
|
41
|
-
*/
|
|
42
|
-
const markdownToHTML = (markdown) => {
|
|
43
|
-
let html = markdown
|
|
44
|
-
// Headers
|
|
45
|
-
.replace(/^### (.*$)/gim, "<h3>$1</h3>")
|
|
46
|
-
.replace(/^## (.*$)/gim, "<h2>$1</h2>")
|
|
47
|
-
.replace(/^# (.*$)/gim, "<h1>$1</h1>")
|
|
48
|
-
// Bold & Italic
|
|
49
|
-
.replace(/\*\*\*(.*)\*\*\*/gim, "<strong><em>$1</em></strong>")
|
|
50
|
-
.replace(/\*\*(.*)\*\*/gim, "<strong>$1</strong>")
|
|
51
|
-
.replace(/\*(.*)\*/gim, "<em>$1</em>")
|
|
52
|
-
// Links
|
|
53
|
-
.replace(/\[([^\]]+)\]\(([^)]+)\)/gim, '<a href="$2" target="_blank" rel="noopener">$1</a>')
|
|
54
|
-
// Code blocks
|
|
55
|
-
.replace(/```(\w+)?\n([\s\S]*?)```/gim, "<pre><code>$2</code></pre>")
|
|
56
|
-
// Inline code
|
|
57
|
-
.replace(/`([^`]+)`/gim, "<code>$1</code>")
|
|
58
|
-
// Line breaks to paragraphs
|
|
59
|
-
.replace(/\n\n/gim, "</p><p>")
|
|
60
|
-
.replace(/\n/gim, "<br>");
|
|
61
|
-
return `<p>${html}</p>`;
|
|
62
|
-
};
|
|
63
|
-
const GenerativeRenderer = ({ content, type = "html", onError, onLoad, sandboxOptions = ["allow-scripts"], showLoading = true, className, title = "Generated content preview", ...props }) => {
|
|
64
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
65
|
-
const [error, setError] = useState(null);
|
|
66
|
-
const iframeRef = useRef(null);
|
|
67
|
-
// Process content based on type
|
|
68
|
-
const processedContent = useMemo(() => {
|
|
69
|
-
try {
|
|
70
|
-
switch (type) {
|
|
71
|
-
case "markdown":
|
|
72
|
-
return createHTMLDocument(markdownToHTML(content));
|
|
73
|
-
case "react":
|
|
74
|
-
// For React, we show the code in a styled container
|
|
75
|
-
// Full React rendering would require a bundler like Sucrase
|
|
76
|
-
return createHTMLDocument(`
|
|
77
|
-
<div style="background: #1e1e1e; padding: 16px; border-radius: 8px; overflow-x: auto;">
|
|
78
|
-
<pre style="color: #d4d4d4; font-family: 'Monaco', 'Consolas', monospace; font-size: 14px; margin: 0;">${content
|
|
79
|
-
.replace(/</g, "<")
|
|
80
|
-
.replace(/>/g, ">")}</pre>
|
|
81
|
-
</div>
|
|
82
|
-
`);
|
|
83
|
-
case "html":
|
|
84
|
-
default:
|
|
85
|
-
return createHTMLDocument(content);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
const error = err instanceof Error ? err : new Error("Failed to process content");
|
|
90
|
-
setError(error);
|
|
91
|
-
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
92
|
-
return "";
|
|
93
|
-
}
|
|
94
|
-
}, [content, type, onError]);
|
|
95
|
-
// Handle iframe load
|
|
96
|
-
const handleLoad = useCallback(() => {
|
|
97
|
-
setIsLoading(false);
|
|
98
|
-
setError(null);
|
|
99
|
-
onLoad === null || onLoad === void 0 ? void 0 : onLoad();
|
|
100
|
-
}, [onLoad]);
|
|
101
|
-
// Handle iframe error
|
|
102
|
-
const handleError = useCallback(() => {
|
|
103
|
-
const error = new Error("Failed to load content in sandbox");
|
|
104
|
-
setError(error);
|
|
105
|
-
setIsLoading(false);
|
|
106
|
-
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
107
|
-
}, [onError]);
|
|
108
|
-
// Reset loading state when content changes
|
|
109
|
-
useEffect(() => {
|
|
110
|
-
setIsLoading(true);
|
|
111
|
-
setError(null);
|
|
112
|
-
}, [content, type]);
|
|
113
|
-
// Build sandbox attribute
|
|
114
|
-
const sandboxAttribute = sandboxOptions.length > 0 ? sandboxOptions.join(" ") : undefined;
|
|
115
|
-
return (React__default.createElement("div", { className: cn(generativeRendererTheme.containerStyle, className), ...props },
|
|
116
|
-
showLoading && isLoading && !error && (React__default.createElement("div", { className: generativeRendererTheme.loadingStyle },
|
|
117
|
-
React__default.createElement(Spinner, { size: "md" }))),
|
|
118
|
-
error && (React__default.createElement("div", { className: generativeRendererTheme.errorStyle },
|
|
119
|
-
React__default.createElement(ExclamationTriangleIcon, { className: "size-8 mb-2" }),
|
|
120
|
-
React__default.createElement("p", { className: "font-medium" }, "Failed to render content"),
|
|
121
|
-
React__default.createElement("p", { className: "text-sm opacity-75 mt-1" }, error.message))),
|
|
122
|
-
!error && (React__default.createElement("iframe", { ref: iframeRef, srcDoc: processedContent, sandbox: sandboxAttribute, className: cn(generativeRendererTheme.iframeStyle, isLoading && "opacity-0"), title: title, onLoad: handleLoad, onError: handleError, "aria-label": title }))));
|
|
123
|
-
};
|
|
124
|
-
GenerativeRenderer.displayName = "GenerativeRenderer";
|
|
125
|
-
|
|
126
|
-
export { GenerativeRenderer };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const generativeRendererTheme = {
|
|
2
|
-
containerStyle: "relative w-full h-full overflow-hidden rounded-lg border border-[var(--color-border)] bg-white",
|
|
3
|
-
iframeStyle: "w-full h-full border-0",
|
|
4
|
-
loadingStyle: "absolute inset-0 flex items-center justify-center bg-[var(--color-background)]",
|
|
5
|
-
errorStyle: "absolute inset-0 flex flex-col items-center justify-center bg-[var(--color-danger-50)] text-[var(--color-danger)] p-4 text-center",
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { generativeRendererTheme };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export type RendererType = "html" | "react" | "markdown";
|
|
3
|
-
export interface GenerativeRendererProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onError" | "onLoad"> {
|
|
4
|
-
/**
|
|
5
|
-
* Content to render (HTML, React component code, or Markdown)
|
|
6
|
-
*/
|
|
7
|
-
content: string;
|
|
8
|
-
/**
|
|
9
|
-
* Type of content to render
|
|
10
|
-
* @default "html"
|
|
11
|
-
*/
|
|
12
|
-
type?: RendererType;
|
|
13
|
-
/**
|
|
14
|
-
* Callback when an error occurs during rendering
|
|
15
|
-
*/
|
|
16
|
-
onError?: (error: Error) => void;
|
|
17
|
-
/**
|
|
18
|
-
* Callback when content loads successfully
|
|
19
|
-
*/
|
|
20
|
-
onLoad?: () => void;
|
|
21
|
-
/**
|
|
22
|
-
* Additional sandbox restrictions for iframe
|
|
23
|
-
* @default ["allow-scripts"]
|
|
24
|
-
*/
|
|
25
|
-
sandboxOptions?: string[];
|
|
26
|
-
/**
|
|
27
|
-
* Show loading state while iframe initializes
|
|
28
|
-
* @default true
|
|
29
|
-
*/
|
|
30
|
-
showLoading?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Additional className
|
|
33
|
-
*/
|
|
34
|
-
className?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Title for the iframe (accessibility)
|
|
37
|
-
*/
|
|
38
|
-
title?: string;
|
|
39
|
-
}
|
|
40
|
-
export interface GenerativeRendererTheme {
|
|
41
|
-
containerStyle?: string;
|
|
42
|
-
iframeStyle?: string;
|
|
43
|
-
loadingStyle?: string;
|
|
44
|
-
errorStyle?: string;
|
|
45
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PresenceIndicator Animations
|
|
3
|
-
*
|
|
4
|
-
* Framer Motion animation variants for the presence indicator.
|
|
5
|
-
* Import from 'motion/react'.
|
|
6
|
-
*/
|
|
7
|
-
import { Variants } from "motion/react";
|
|
8
|
-
/**
|
|
9
|
-
* Container animation
|
|
10
|
-
* Scales in the entire group and staggers children
|
|
11
|
-
*/
|
|
12
|
-
export declare const containerVariants: Variants;
|
|
13
|
-
/**
|
|
14
|
-
* Item animation (for custom avatars)
|
|
15
|
-
* Pops in individual avatars
|
|
16
|
-
*/
|
|
17
|
-
export declare const itemVariants: Variants;
|