@vettly/react 0.1.12
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 +90 -0
- package/dist/index.cjs +878 -0
- package/dist/index.d.cts +125 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.js +848 -0
- package/dist/styles.css +305 -0
- package/package.json +69 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { CheckResponse, CheckRequest } from '@vettly/shared';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
interface ModerationResult {
|
|
6
|
+
safe: boolean;
|
|
7
|
+
flagged: boolean;
|
|
8
|
+
action: 'allow' | 'warn' | 'flag' | 'block';
|
|
9
|
+
categories: Array<{
|
|
10
|
+
category: string;
|
|
11
|
+
score: number;
|
|
12
|
+
triggered: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
isChecking: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
}
|
|
17
|
+
interface UseModerationOptions {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
policyId: string;
|
|
20
|
+
debounceMs?: number;
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
onCheck?: (result: CheckResponse) => void;
|
|
23
|
+
onError?: (error: Error) => void;
|
|
24
|
+
}
|
|
25
|
+
declare function useModeration(options: UseModerationOptions): {
|
|
26
|
+
result: ModerationResult;
|
|
27
|
+
check: (content: string | CheckRequest) => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* ModeratedTextarea - A textarea with real-time content moderation
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
interface ModeratedTextareaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'> {
|
|
35
|
+
apiKey: string;
|
|
36
|
+
policyId: string;
|
|
37
|
+
value?: string;
|
|
38
|
+
onChange?: (value: string, result: {
|
|
39
|
+
safe: boolean;
|
|
40
|
+
flagged: boolean;
|
|
41
|
+
action: string;
|
|
42
|
+
}) => void;
|
|
43
|
+
debounceMs?: number;
|
|
44
|
+
showFeedback?: boolean;
|
|
45
|
+
blockUnsafe?: boolean;
|
|
46
|
+
customFeedback?: (result: {
|
|
47
|
+
safe: boolean;
|
|
48
|
+
flagged: boolean;
|
|
49
|
+
action: string;
|
|
50
|
+
isChecking: boolean;
|
|
51
|
+
error: string | null;
|
|
52
|
+
}) => React.ReactNode;
|
|
53
|
+
onModerationResult?: UseModerationOptions['onCheck'];
|
|
54
|
+
onModerationError?: UseModerationOptions['onError'];
|
|
55
|
+
}
|
|
56
|
+
declare const ModeratedTextarea: React.ForwardRefExoticComponent<ModeratedTextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
57
|
+
|
|
58
|
+
interface ModeratedImageUploadProps {
|
|
59
|
+
apiKey: string;
|
|
60
|
+
policyId: string;
|
|
61
|
+
onUpload?: (file: File, result: {
|
|
62
|
+
safe: boolean;
|
|
63
|
+
flagged: boolean;
|
|
64
|
+
action: string;
|
|
65
|
+
}) => void;
|
|
66
|
+
onReject?: (file: File, reason: string) => void;
|
|
67
|
+
maxSizeMB?: number;
|
|
68
|
+
acceptedFormats?: string[];
|
|
69
|
+
showPreview?: boolean;
|
|
70
|
+
blockUnsafe?: boolean;
|
|
71
|
+
customPreview?: (props: {
|
|
72
|
+
file: File;
|
|
73
|
+
preview: string;
|
|
74
|
+
result: {
|
|
75
|
+
safe: boolean;
|
|
76
|
+
flagged: boolean;
|
|
77
|
+
action: string;
|
|
78
|
+
isChecking: boolean;
|
|
79
|
+
error: string | null;
|
|
80
|
+
};
|
|
81
|
+
onRemove: () => void;
|
|
82
|
+
}) => React.ReactNode;
|
|
83
|
+
className?: string;
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
onModerationResult?: UseModerationOptions['onCheck'];
|
|
86
|
+
onModerationError?: UseModerationOptions['onError'];
|
|
87
|
+
}
|
|
88
|
+
declare function ModeratedImageUpload({ apiKey, policyId, onUpload, onReject, maxSizeMB, acceptedFormats, showPreview, blockUnsafe, customPreview, className, disabled, onModerationResult, onModerationError, }: ModeratedImageUploadProps): react_jsx_runtime.JSX.Element;
|
|
89
|
+
|
|
90
|
+
interface ModeratedVideoUploadProps {
|
|
91
|
+
apiKey: string;
|
|
92
|
+
policyId: string;
|
|
93
|
+
onUpload?: (file: File, result: {
|
|
94
|
+
safe: boolean;
|
|
95
|
+
flagged: boolean;
|
|
96
|
+
action: string;
|
|
97
|
+
}) => void;
|
|
98
|
+
onReject?: (file: File, reason: string) => void;
|
|
99
|
+
maxSizeMB?: number;
|
|
100
|
+
maxDurationSeconds?: number;
|
|
101
|
+
acceptedFormats?: string[];
|
|
102
|
+
showPreview?: boolean;
|
|
103
|
+
blockUnsafe?: boolean;
|
|
104
|
+
extractFramesCount?: number;
|
|
105
|
+
customPreview?: (props: {
|
|
106
|
+
file: File;
|
|
107
|
+
preview: string;
|
|
108
|
+
duration: number;
|
|
109
|
+
result: {
|
|
110
|
+
safe: boolean;
|
|
111
|
+
flagged: boolean;
|
|
112
|
+
action: string;
|
|
113
|
+
isChecking: boolean;
|
|
114
|
+
error: string | null;
|
|
115
|
+
};
|
|
116
|
+
onRemove: () => void;
|
|
117
|
+
}) => React.ReactNode;
|
|
118
|
+
className?: string;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
onModerationResult?: UseModerationOptions['onCheck'];
|
|
121
|
+
onModerationError?: UseModerationOptions['onError'];
|
|
122
|
+
}
|
|
123
|
+
declare function ModeratedVideoUpload({ apiKey, policyId, onUpload, onReject, maxSizeMB, maxDurationSeconds, acceptedFormats, showPreview, blockUnsafe, extractFramesCount, customPreview, className, disabled, onModerationResult, onModerationError, }: ModeratedVideoUploadProps): react_jsx_runtime.JSX.Element;
|
|
124
|
+
|
|
125
|
+
export { ModeratedImageUpload, type ModeratedImageUploadProps, ModeratedTextarea, type ModeratedTextareaProps, ModeratedVideoUpload, type ModeratedVideoUploadProps, type ModerationResult, type UseModerationOptions, useModeration };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { CheckResponse, CheckRequest } from '@vettly/shared';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
interface ModerationResult {
|
|
6
|
+
safe: boolean;
|
|
7
|
+
flagged: boolean;
|
|
8
|
+
action: 'allow' | 'warn' | 'flag' | 'block';
|
|
9
|
+
categories: Array<{
|
|
10
|
+
category: string;
|
|
11
|
+
score: number;
|
|
12
|
+
triggered: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
isChecking: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
}
|
|
17
|
+
interface UseModerationOptions {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
policyId: string;
|
|
20
|
+
debounceMs?: number;
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
onCheck?: (result: CheckResponse) => void;
|
|
23
|
+
onError?: (error: Error) => void;
|
|
24
|
+
}
|
|
25
|
+
declare function useModeration(options: UseModerationOptions): {
|
|
26
|
+
result: ModerationResult;
|
|
27
|
+
check: (content: string | CheckRequest) => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* ModeratedTextarea - A textarea with real-time content moderation
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
interface ModeratedTextareaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'> {
|
|
35
|
+
apiKey: string;
|
|
36
|
+
policyId: string;
|
|
37
|
+
value?: string;
|
|
38
|
+
onChange?: (value: string, result: {
|
|
39
|
+
safe: boolean;
|
|
40
|
+
flagged: boolean;
|
|
41
|
+
action: string;
|
|
42
|
+
}) => void;
|
|
43
|
+
debounceMs?: number;
|
|
44
|
+
showFeedback?: boolean;
|
|
45
|
+
blockUnsafe?: boolean;
|
|
46
|
+
customFeedback?: (result: {
|
|
47
|
+
safe: boolean;
|
|
48
|
+
flagged: boolean;
|
|
49
|
+
action: string;
|
|
50
|
+
isChecking: boolean;
|
|
51
|
+
error: string | null;
|
|
52
|
+
}) => React.ReactNode;
|
|
53
|
+
onModerationResult?: UseModerationOptions['onCheck'];
|
|
54
|
+
onModerationError?: UseModerationOptions['onError'];
|
|
55
|
+
}
|
|
56
|
+
declare const ModeratedTextarea: React.ForwardRefExoticComponent<ModeratedTextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
57
|
+
|
|
58
|
+
interface ModeratedImageUploadProps {
|
|
59
|
+
apiKey: string;
|
|
60
|
+
policyId: string;
|
|
61
|
+
onUpload?: (file: File, result: {
|
|
62
|
+
safe: boolean;
|
|
63
|
+
flagged: boolean;
|
|
64
|
+
action: string;
|
|
65
|
+
}) => void;
|
|
66
|
+
onReject?: (file: File, reason: string) => void;
|
|
67
|
+
maxSizeMB?: number;
|
|
68
|
+
acceptedFormats?: string[];
|
|
69
|
+
showPreview?: boolean;
|
|
70
|
+
blockUnsafe?: boolean;
|
|
71
|
+
customPreview?: (props: {
|
|
72
|
+
file: File;
|
|
73
|
+
preview: string;
|
|
74
|
+
result: {
|
|
75
|
+
safe: boolean;
|
|
76
|
+
flagged: boolean;
|
|
77
|
+
action: string;
|
|
78
|
+
isChecking: boolean;
|
|
79
|
+
error: string | null;
|
|
80
|
+
};
|
|
81
|
+
onRemove: () => void;
|
|
82
|
+
}) => React.ReactNode;
|
|
83
|
+
className?: string;
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
onModerationResult?: UseModerationOptions['onCheck'];
|
|
86
|
+
onModerationError?: UseModerationOptions['onError'];
|
|
87
|
+
}
|
|
88
|
+
declare function ModeratedImageUpload({ apiKey, policyId, onUpload, onReject, maxSizeMB, acceptedFormats, showPreview, blockUnsafe, customPreview, className, disabled, onModerationResult, onModerationError, }: ModeratedImageUploadProps): react_jsx_runtime.JSX.Element;
|
|
89
|
+
|
|
90
|
+
interface ModeratedVideoUploadProps {
|
|
91
|
+
apiKey: string;
|
|
92
|
+
policyId: string;
|
|
93
|
+
onUpload?: (file: File, result: {
|
|
94
|
+
safe: boolean;
|
|
95
|
+
flagged: boolean;
|
|
96
|
+
action: string;
|
|
97
|
+
}) => void;
|
|
98
|
+
onReject?: (file: File, reason: string) => void;
|
|
99
|
+
maxSizeMB?: number;
|
|
100
|
+
maxDurationSeconds?: number;
|
|
101
|
+
acceptedFormats?: string[];
|
|
102
|
+
showPreview?: boolean;
|
|
103
|
+
blockUnsafe?: boolean;
|
|
104
|
+
extractFramesCount?: number;
|
|
105
|
+
customPreview?: (props: {
|
|
106
|
+
file: File;
|
|
107
|
+
preview: string;
|
|
108
|
+
duration: number;
|
|
109
|
+
result: {
|
|
110
|
+
safe: boolean;
|
|
111
|
+
flagged: boolean;
|
|
112
|
+
action: string;
|
|
113
|
+
isChecking: boolean;
|
|
114
|
+
error: string | null;
|
|
115
|
+
};
|
|
116
|
+
onRemove: () => void;
|
|
117
|
+
}) => React.ReactNode;
|
|
118
|
+
className?: string;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
onModerationResult?: UseModerationOptions['onCheck'];
|
|
121
|
+
onModerationError?: UseModerationOptions['onError'];
|
|
122
|
+
}
|
|
123
|
+
declare function ModeratedVideoUpload({ apiKey, policyId, onUpload, onReject, maxSizeMB, maxDurationSeconds, acceptedFormats, showPreview, blockUnsafe, extractFramesCount, customPreview, className, disabled, onModerationResult, onModerationError, }: ModeratedVideoUploadProps): react_jsx_runtime.JSX.Element;
|
|
124
|
+
|
|
125
|
+
export { ModeratedImageUpload, type ModeratedImageUploadProps, ModeratedTextarea, type ModeratedTextareaProps, ModeratedVideoUpload, type ModeratedVideoUploadProps, type ModerationResult, type UseModerationOptions, useModeration };
|