@ttt-productions/file-input 0.11.16 → 0.11.17
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/dist/lib/image-utils.d.ts +0 -1
- package/dist/lib/image-utils.d.ts.map +1 -1
- package/dist/lib/image-utils.js +1 -2
- package/dist/lib/image-utils.js.map +1 -1
- package/dist/lib/infer-content-type.d.ts +0 -23
- package/dist/lib/infer-content-type.d.ts.map +1 -1
- package/dist/lib/infer-content-type.js +2 -56
- package/dist/lib/infer-content-type.js.map +1 -1
- package/dist/lib/validate-media-duration.d.ts.map +1 -1
- package/dist/lib/validate-media-duration.js +2 -7
- package/dist/lib/validate-media-duration.js.map +1 -1
- package/dist/lib/validate-upload-kind.d.ts +0 -34
- package/dist/lib/validate-upload-kind.d.ts.map +1 -1
- package/dist/lib/validate-upload-kind.js +0 -17
- package/dist/lib/validate-upload-kind.js.map +1 -1
- package/dist/react/components/file-input.d.ts.map +1 -1
- package/dist/react/components/file-input.js +0 -2
- package/dist/react/components/file-input.js.map +1 -1
- package/dist/react/components/image-cropper-modal.d.ts.map +1 -1
- package/dist/react/components/image-cropper-modal.js +0 -2
- package/dist/react/components/image-cropper-modal.js.map +1 -1
- package/dist/react/components/media-constraints-hint.d.ts.map +1 -1
- package/dist/react/components/media-constraints-hint.js +0 -1
- package/dist/react/components/media-constraints-hint.js.map +1 -1
- package/dist/react/components/media-input.d.ts.map +1 -1
- package/dist/react/components/media-input.js +4 -69
- package/dist/react/components/media-input.js.map +1 -1
- package/dist/react/components/photo-capture-modal.d.ts.map +1 -1
- package/dist/react/components/photo-capture-modal.js +1 -5
- package/dist/react/components/photo-capture-modal.js.map +1 -1
- package/dist/react/components/record-dialog.d.ts +0 -4
- package/dist/react/components/record-dialog.d.ts.map +1 -1
- package/dist/react/components/record-dialog.js +11 -88
- package/dist/react/components/record-dialog.js.map +1 -1
- package/dist/types.d.ts +0 -56
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ClientMediaClaim, FileCategory as ContractsFileCategory, MediaKind, MediaProcessingSpec, MediaOriginSpec, SimplifiedMediaType, VideoOrientation, MediaCropSpec, UploadState } from '@ttt-productions/media-schemas';
|
|
2
|
-
/** FileCategory is owned by contracts. */
|
|
3
2
|
export type FileCategory = ContractsFileCategory;
|
|
4
3
|
export interface CropConfig {
|
|
5
4
|
aspectRatio: number;
|
|
@@ -31,7 +30,6 @@ export interface FileInputProps {
|
|
|
31
30
|
disabled?: boolean;
|
|
32
31
|
isLoading?: boolean;
|
|
33
32
|
buttonLabel?: string;
|
|
34
|
-
/** Accessible name of the icon-only button that clears the selected file. Default "Clear selected file". */
|
|
35
33
|
clearLabel?: string;
|
|
36
34
|
className?: string;
|
|
37
35
|
variant?: any;
|
|
@@ -42,7 +40,6 @@ export interface FileInputProps {
|
|
|
42
40
|
cropConfig?: CropConfig;
|
|
43
41
|
defaultShowDetails?: boolean;
|
|
44
42
|
}
|
|
45
|
-
/** Used by MediaInput (spec-driven selection/capture/record). */
|
|
46
43
|
export interface SelectedMediaMeta {
|
|
47
44
|
kind: MediaKind;
|
|
48
45
|
mime?: string;
|
|
@@ -58,15 +55,6 @@ export interface MediaInputChangePayload {
|
|
|
58
55
|
file?: File;
|
|
59
56
|
previewUrl?: string;
|
|
60
57
|
meta?: SelectedMediaMeta;
|
|
61
|
-
/**
|
|
62
|
-
* What the user actually DID (canonical-upload-content-classification):
|
|
63
|
-
* `media-recorder` / `camera-capture` are STRONG claims (the component itself
|
|
64
|
-
* requested that capture kind — an audio recording asked for `video:false`);
|
|
65
|
-
* `file-picker` is an ADVISORY inference from browser metadata (`kind:'file'`
|
|
66
|
-
* when nothing narrower is known). Crop/normalization preserves the original
|
|
67
|
-
* claim. Untrusted context for the server — never classification authority.
|
|
68
|
-
* Present on every successful selection; absent only on the error payload.
|
|
69
|
-
*/
|
|
70
58
|
claim?: ClientMediaClaim;
|
|
71
59
|
autoFormat?: boolean;
|
|
72
60
|
croppedBlob?: Blob;
|
|
@@ -79,61 +67,17 @@ export interface MediaInputProps {
|
|
|
79
67
|
isLoading?: boolean;
|
|
80
68
|
className?: string;
|
|
81
69
|
buttonLabel?: string;
|
|
82
|
-
/** Accessible name of the icon-only button that clears the selected file. Default "Clear selected file". */
|
|
83
70
|
clearLabel?: string;
|
|
84
|
-
/**
|
|
85
|
-
* Extra advisory notes shown in the "Info" affordance alongside the built-in default
|
|
86
|
-
* ("keep your own copy — this isn't a backup/storage service"). Every MediaInput shows that
|
|
87
|
-
* default note; pass surface-specific notes here to append to it. The Info button always renders.
|
|
88
|
-
*/
|
|
89
71
|
helpNotes?: string[];
|
|
90
|
-
/** Phase-aware upload state. When provided, drives the upload/processing UI. */
|
|
91
72
|
uploadState?: UploadState | null;
|
|
92
|
-
/**
|
|
93
|
-
* Minimum file size (bytes) before showing a real progress bar.
|
|
94
|
-
* Files smaller than this show an indeterminate spinner during upload instead.
|
|
95
|
-
* Defaults to `DEFAULT_PROGRESS_BAR_MIN_BYTES` (512 KB) when omitted.
|
|
96
|
-
* Pass `Infinity` to always use the spinner. Pass `0` to always use the bar.
|
|
97
|
-
*/
|
|
98
73
|
progressBarMinBytes?: number;
|
|
99
|
-
/** Currently selected file. Shows a semantic media label + clear button when set. */
|
|
100
74
|
selectedFile?: File | null;
|
|
101
|
-
/** Called when user clears the selected file. */
|
|
102
75
|
onClear?: () => void;
|
|
103
|
-
/**
|
|
104
|
-
* Optional cancel callback. When provided AND the upload is in 'preparing' or
|
|
105
|
-
* 'uploading' phase AND `isLoading` is true, an inline X button renders next to
|
|
106
|
-
* the status text. Click invokes onCancel — the consumer is responsible for
|
|
107
|
-
* aborting the underlying upload (e.g. via AbortController.abort()). Never
|
|
108
|
-
* renders during 'finalizing'.
|
|
109
|
-
*/
|
|
110
76
|
onCancel?: () => void;
|
|
111
|
-
/**
|
|
112
|
-
* Optional guard fired before opening the OS picker / capture UI for ANY
|
|
113
|
-
* action (choose file, take photo, record video, record audio). Return false
|
|
114
|
-
* — or a Promise resolving to false — to abort before the picker/capture
|
|
115
|
-
* opens. Consumers use this to run a precondition (e.g. an email-verification
|
|
116
|
-
* gate) on the click, not after a file has already been selected.
|
|
117
|
-
*/
|
|
118
77
|
onBeforeSelect?: () => boolean | Promise<boolean>;
|
|
119
78
|
onChange: (payload: MediaInputChangePayload) => void;
|
|
120
79
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Imperative handle exposed by {@link MediaInput} via `ref`. Additive — existing
|
|
123
|
-
* ref-less usage is unaffected.
|
|
124
|
-
*/
|
|
125
80
|
export interface MediaInputHandle {
|
|
126
|
-
/**
|
|
127
|
-
* Programmatically open the canonical selection path, exactly as clicking the
|
|
128
|
-
* trigger button does:
|
|
129
|
-
* - exactly one enabled action → runs that action directly (choose file / photo
|
|
130
|
-
* / record), honoring `onBeforeSelect`, validation, and crop;
|
|
131
|
-
* - multiple enabled actions → opens the existing choice dropdown.
|
|
132
|
-
*
|
|
133
|
-
* No-op while `disabled` or `isLoading`, or when no action is enabled. Must be
|
|
134
|
-
* called synchronously from a user gesture so the browser file dialog can open.
|
|
135
|
-
* It never bypasses the trigger gates (no hidden-input shortcut).
|
|
136
|
-
*/
|
|
137
81
|
openSelection: () => void;
|
|
138
82
|
}
|
|
139
83
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,IAAI,qBAAqB,EACrC,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACZ,MAAM,gCAAgC,CAAC;AAExC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.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,CAAC;IACtB,YAAY,CAAC,EAAE,aAAa,CAAC;IAE7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB,cAAc,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAElD,QAAQ,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ClientMediaClaim,\n FileCategory as ContractsFileCategory,\n MediaKind,\n MediaProcessingSpec,\n MediaOriginSpec,\n SimplifiedMediaType,\n VideoOrientation,\n MediaCropSpec,\n UploadState,\n} from '@ttt-productions/media-schemas';\n\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ClientMediaClaim,\n FileCategory as ContractsFileCategory,\n MediaKind,\n MediaProcessingSpec,\n MediaOriginSpec,\n SimplifiedMediaType,\n VideoOrientation,\n MediaCropSpec,\n UploadState,\n} from '@ttt-productions/media-schemas';\n\nexport type FileCategory = ContractsFileCategory;\n\nexport interface CropConfig {\n aspectRatio: number;\n aspectRatioDisplay?: string;\n shape: 'rect' | 'round';\n outputWidth: number;\n outputHeight: number;\n}\n\nexport type FileInputErrorCode =\n | 'invalid_type'\n | 'too_large'\n | 'too_long'\n | 'orientation_mismatch'\n | 'aspect_ratio_mismatch'\n | 'dimensions_mismatch'\n | 'read_failed'\n | 'crop_failed'\n | 'unknown';\n\nexport interface FileInputError {\n code: FileInputErrorCode;\n message: string;\n details?: Record<string, unknown>;\n}\n\nexport interface FileInputChangePayload {\n type: SimplifiedMediaType;\n file?: File;\n blob?: Blob;\n previewUrl?: string;\n revokePreviewUrl?: () => void;\n error?: FileInputError;\n}\n\nexport interface FileInputProps {\n acceptTypes: SimplifiedMediaType[];\n maxSizeMB: Partial<Record<SimplifiedMediaType, number>>;\n selectedFile?: File | null;\n\n onChange: (payload: FileInputChangePayload) => void;\n onError?: (error: FileInputError) => void;\n\n disabled?: boolean;\n isLoading?: boolean;\n buttonLabel?: string;\n clearLabel?: string;\n className?: string;\n\n variant?: any;\n size?: any;\n\n uploadProgress?: number | null;\n\n videoMaxDurationSec?: number;\n audioMaxDurationSec?: number;\n\n cropConfig?: CropConfig;\n defaultShowDetails?: boolean;\n}\n\nexport interface SelectedMediaMeta {\n kind: MediaKind;\n mime?: string;\n sizeBytes: number;\n width?: number;\n height?: number;\n durationSec?: number;\n orientation?: VideoOrientation;\n aspectRatio?: number;\n}\n\nexport interface MediaInputChangePayload {\n spec: MediaProcessingSpec;\n file?: File;\n previewUrl?: string;\n meta?: SelectedMediaMeta;\n\n claim?: ClientMediaClaim;\n\n autoFormat?: boolean;\n croppedBlob?: Blob;\n\n error?: FileInputError;\n}\n\nexport interface MediaInputProps {\n spec: MediaOriginSpec;\n cropOverride?: MediaCropSpec;\n\n disabled?: boolean;\n isLoading?: boolean;\n className?: string;\n buttonLabel?: string;\n clearLabel?: string;\n\n helpNotes?: string[];\n\n uploadState?: UploadState | null;\n progressBarMinBytes?: number;\n selectedFile?: File | null;\n onClear?: () => void;\n onCancel?: () => void;\n\n onBeforeSelect?: () => boolean | Promise<boolean>;\n\n onChange: (payload: MediaInputChangePayload) => void;\n}\n\nexport interface MediaInputHandle {\n openSelection: () => void;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/file-input",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.17",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ttt-productions/ttt-packages.git",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"prepublishOnly": "npm run clean && npm run build"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ttt-productions/ui-core": "^0.11.
|
|
35
|
-
"@ttt-productions/media-schemas": "^0.14.
|
|
36
|
-
"@ttt-productions/media-viewer": "^0.10.
|
|
34
|
+
"@ttt-productions/ui-core": "^0.11.35",
|
|
35
|
+
"@ttt-productions/media-schemas": "^0.14.12",
|
|
36
|
+
"@ttt-productions/media-viewer": "^0.10.19",
|
|
37
37
|
"react-easy-crop": "^6.2.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|