@ttt-productions/file-input 0.11.14 → 0.11.16
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/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/image-utils.d.ts +5 -2
- package/dist/lib/image-utils.d.ts.map +1 -1
- package/dist/lib/image-utils.js +16 -9
- package/dist/lib/image-utils.js.map +1 -1
- package/dist/lib/infer-content-type.d.ts +1 -1
- package/dist/lib/infer-content-type.js +29 -29
- package/dist/lib/infer-content-type.js.map +1 -1
- package/dist/lib/read-media-meta.d.ts +1 -1
- package/dist/lib/read-media-meta.d.ts.map +1 -1
- package/dist/lib/read-media-meta.js +20 -13
- package/dist/lib/read-media-meta.js.map +1 -1
- package/dist/lib/validate-media-duration.js +3 -3
- package/dist/lib/validate-media-duration.js.map +1 -1
- package/dist/lib/validate-upload-kind.d.ts.map +1 -1
- package/dist/lib/validate-upload-kind.js.map +1 -1
- package/dist/progress-bar.d.ts +2 -0
- package/dist/progress-bar.d.ts.map +1 -0
- package/dist/progress-bar.js +2 -0
- package/dist/progress-bar.js.map +1 -0
- package/dist/react/components/audio-input.d.ts +2 -2
- package/dist/react/components/audio-input.js +2 -2
- package/dist/react/components/audio-input.js.map +1 -1
- package/dist/react/components/file-input.d.ts +1 -1
- package/dist/react/components/file-input.d.ts.map +1 -1
- package/dist/react/components/file-input.js +59 -42
- package/dist/react/components/file-input.js.map +1 -1
- package/dist/react/components/image-cropper-modal.d.ts +4 -2
- package/dist/react/components/image-cropper-modal.d.ts.map +1 -1
- package/dist/react/components/image-cropper-modal.js +7 -7
- package/dist/react/components/image-cropper-modal.js.map +1 -1
- package/dist/react/components/image-input.d.ts +2 -2
- package/dist/react/components/image-input.js +2 -2
- package/dist/react/components/image-input.js.map +1 -1
- package/dist/react/components/media-constraints-hint.d.ts +1 -1
- package/dist/react/components/media-constraints-hint.d.ts.map +1 -1
- package/dist/react/components/media-constraints-hint.js +26 -24
- package/dist/react/components/media-constraints-hint.js.map +1 -1
- package/dist/react/components/media-input.d.ts +2 -2
- package/dist/react/components/media-input.d.ts.map +1 -1
- package/dist/react/components/media-input.js +107 -89
- package/dist/react/components/media-input.js.map +1 -1
- package/dist/react/components/photo-capture-modal.d.ts +1 -1
- package/dist/react/components/photo-capture-modal.d.ts.map +1 -1
- package/dist/react/components/photo-capture-modal.js +29 -16
- package/dist/react/components/photo-capture-modal.js.map +1 -1
- package/dist/react/components/record-dialog.d.ts +3 -3
- package/dist/react/components/record-dialog.d.ts.map +1 -1
- package/dist/react/components/record-dialog.js +49 -50
- package/dist/react/components/record-dialog.js.map +1 -1
- package/dist/react/components/video-input.d.ts +2 -2
- package/dist/react/components/video-input.js +2 -2
- package/dist/react/components/video-input.js.map +1 -1
- package/dist/react/index.d.ts +8 -8
- package/dist/react/index.js +8 -8
- package/dist/react/index.js.map +1 -1
- package/dist/types.d.ts +3 -3
- 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,14 +1,14 @@
|
|
|
1
|
-
import type { ClientMediaClaim, FileCategory as ContractsFileCategory, MediaKind, MediaProcessingSpec, MediaOriginSpec, SimplifiedMediaType, VideoOrientation, MediaCropSpec, UploadState } from
|
|
1
|
+
import type { ClientMediaClaim, FileCategory as ContractsFileCategory, MediaKind, MediaProcessingSpec, MediaOriginSpec, SimplifiedMediaType, VideoOrientation, MediaCropSpec, UploadState } from '@ttt-productions/media-schemas';
|
|
2
2
|
/** FileCategory is owned by contracts. */
|
|
3
3
|
export type FileCategory = ContractsFileCategory;
|
|
4
4
|
export interface CropConfig {
|
|
5
5
|
aspectRatio: number;
|
|
6
6
|
aspectRatioDisplay?: string;
|
|
7
|
-
shape:
|
|
7
|
+
shape: 'rect' | 'round';
|
|
8
8
|
outputWidth: number;
|
|
9
9
|
outputHeight: number;
|
|
10
10
|
}
|
|
11
|
-
export type FileInputErrorCode =
|
|
11
|
+
export type FileInputErrorCode = 'invalid_type' | 'too_large' | 'too_long' | 'orientation_mismatch' | 'aspect_ratio_mismatch' | 'dimensions_mismatch' | 'read_failed' | 'crop_failed' | 'unknown';
|
|
12
12
|
export interface FileInputError {
|
|
13
13
|
code: FileInputErrorCode;
|
|
14
14
|
message: string;
|
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,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC;
|
|
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,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAEjD,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,GAC1B,cAAc,GACd,WAAW,GACX,UAAU,GACV,sBAAsB,GACtB,uBAAuB,GACvB,qBAAqB,GACrB,aAAa,GACb,aAAa,GACb,SAAS,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M,IAAI,CAAC;IACrB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAElD,QAAQ,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,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
|
|
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\n/** FileCategory is owned by contracts. */\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 /** Accessible name of the icon-only button that clears the selected file. Default \"Clear selected file\". */\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\n/** Used by MediaInput (spec-driven selection/capture/record). */\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 /**\n * What the user actually DID (canonical-upload-content-classification):\n * `media-recorder` / `camera-capture` are STRONG claims (the component itself\n * requested that capture kind — an audio recording asked for `video:false`);\n * `file-picker` is an ADVISORY inference from browser metadata (`kind:'file'`\n * when nothing narrower is known). Crop/normalization preserves the original\n * claim. Untrusted context for the server — never classification authority.\n * Present on every successful selection; absent only on the error payload.\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 /** Accessible name of the icon-only button that clears the selected file. Default \"Clear selected file\". */\n clearLabel?: string;\n\n /**\n * Extra advisory notes shown in the \"Info\" affordance alongside the built-in default\n * (\"keep your own copy — this isn't a backup/storage service\"). Every MediaInput shows that\n * default note; pass surface-specific notes here to append to it. The Info button always renders.\n */\n helpNotes?: string[];\n\n /** Phase-aware upload state. When provided, drives the upload/processing UI. */\n uploadState?: UploadState | null;\n /**\n * Minimum file size (bytes) before showing a real progress bar.\n * Files smaller than this show an indeterminate spinner during upload instead.\n * Defaults to `DEFAULT_PROGRESS_BAR_MIN_BYTES` (512 KB) when omitted.\n * Pass `Infinity` to always use the spinner. Pass `0` to always use the bar.\n */\n progressBarMinBytes?: number;\n /** Currently selected file. Shows a semantic media label + clear button when set. */\n selectedFile?: File | null;\n /** Called when user clears the selected file. */\n onClear?: () => void;\n /**\n * Optional cancel callback. When provided AND the upload is in 'preparing' or\n * 'uploading' phase AND `isLoading` is true, an inline X button renders next to\n * the status text. Click invokes onCancel — the consumer is responsible for\n * aborting the underlying upload (e.g. via AbortController.abort()). Never\n * renders during 'finalizing'.\n */\n onCancel?: () => void;\n\n /**\n * Optional guard fired before opening the OS picker / capture UI for ANY\n * action (choose file, take photo, record video, record audio). Return false\n * — or a Promise resolving to false — to abort before the picker/capture\n * opens. Consumers use this to run a precondition (e.g. an email-verification\n * gate) on the click, not after a file has already been selected.\n */\n onBeforeSelect?: () => boolean | Promise<boolean>;\n\n onChange: (payload: MediaInputChangePayload) => void;\n}\n\n/**\n * Imperative handle exposed by {@link MediaInput} via `ref`. Additive — existing\n * ref-less usage is unaffected.\n */\nexport interface MediaInputHandle {\n /**\n * Programmatically open the canonical selection path, exactly as clicking the\n * trigger button does:\n * - exactly one enabled action → runs that action directly (choose file / photo\n * / record), honoring `onBeforeSelect`, validation, and crop;\n * - multiple enabled actions → opens the existing choice dropdown.\n *\n * No-op while `disabled` or `isLoading`, or when no action is enabled. Must be\n * called synchronously from a user gesture so the browser file dialog can open.\n * It never bypasses the trigger gates (no hidden-input shortcut).\n */\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.16",
|
|
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.34",
|
|
35
|
+
"@ttt-productions/media-schemas": "^0.14.11",
|
|
36
|
+
"@ttt-productions/media-viewer": "^0.10.17",
|
|
37
37
|
"react-easy-crop": "^6.2.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|