@ibanzajoe/uploader 0.2.0 → 1.1.0

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.cts CHANGED
@@ -1,8 +1,98 @@
1
- import { P as PickerResponse, F as FileResult, h as UploaderClientOptions } from './transform-ybCOCWBG.cjs';
2
- export { C as CropParams, O as OutputParams, a as PolicySpec, Q as QualityParams, R as ResizeParams, b as RotateParams, T as TransformChain, c as TransformOp, d as TransformOpName, e as TransformUrlOptions, U as UploadAllOptions, f as UploadOptions, g as UploaderClient, i as crop, j as flip, k as flop, o as output, q as quality, r as resize, l as rotate, t as transformUrl } from './transform-ybCOCWBG.cjs';
1
+ import { P as PickerResponse, F as FileResult, h as UploaderClientOptions } from './transform-BSPaC9-P.cjs';
2
+ export { C as CropParams, D as DeliveryProtection, O as OutputParams, a as PolicySpec, Q as QualityParams, R as ResizeParams, b as RotateParams, T as TransformChain, c as TransformOp, d as TransformOpName, e as TransformUrlOptions, U as UploadAllOptions, f as UploadOptions, g as UploaderClient, i as crop, j as flip, k as flop, o as output, q as quality, r as resize, l as rotate, t as transformUrl, w as withSignedPolicy } from './transform-BSPaC9-P.cjs';
3
3
  import * as React from 'react';
4
4
  import React__default, { CSSProperties } from 'react';
5
5
 
6
+ /**
7
+ * Theming — map a plain token object to scoped CSS custom properties.
8
+ *
9
+ * The SDK is styled entirely from `--uploader-*` CSS custom properties (see
10
+ * styles.css). A host React app can override them in its own stylesheet, but
11
+ * that overrides every instance on the page and requires writing CSS.
12
+ *
13
+ * The `theme` prop on PickerOverlay / DropPane lets a host pass those tokens as
14
+ * a plain object instead. `themeToVars` converts the object into inline CSS
15
+ * variables applied to the component's own root element, so the override is
16
+ * **scoped to that instance** — two pickers on one page can carry different
17
+ * themes, and nothing leaks to the rest of the app.
18
+ *
19
+ * Only the keys you set are emitted; everything else falls back to the shipped
20
+ * defaults. Fully backward compatible — omit `theme` and behaviour is unchanged.
21
+ *
22
+ * @example
23
+ * <PickerOverlay
24
+ * theme={{ accent: '#4f46e5', accentSoft: '#eef2ff', radius: '12px' }}
25
+ * apikey="pk_..."
26
+ * open={open}
27
+ * onClose={close}
28
+ * />
29
+ */
30
+
31
+ /**
32
+ * Host-overridable design tokens. Each maps to one `--uploader-*` CSS variable.
33
+ * All optional — set only what you want to change. Values are raw CSS strings
34
+ * (e.g. '#4f46e5', 'rgba(79,70,229,.28)', '12px', '0.2s ease').
35
+ */
36
+ type UploaderTheme = {
37
+ /** Primary brand color. → `--uploader-accent` */
38
+ accent?: string;
39
+ /** Hover/active shade of the accent. → `--uploader-accent-hover` */
40
+ accentHover?: string;
41
+ /** Tinted fill for icon swatches and hover backgrounds. → `--uploader-accent-soft` */
42
+ accentSoft?: string;
43
+ /** Focus ring / drag-over glow (≈20–30% opacity of accent). → `--uploader-accent-ring` */
44
+ accentRing?: string;
45
+ /** Corner radius for panels, buttons, inputs. → `--uploader-radius` */
46
+ radius?: string;
47
+ /** Base surface / panel background. → `--uploader-bg` */
48
+ background?: string;
49
+ /** Secondary surface (rows, wells). → `--uploader-surface` */
50
+ surface?: string;
51
+ /** Hover state for secondary surfaces. → `--uploader-surface-hover` */
52
+ surfaceHover?: string;
53
+ /** Default border color. → `--uploader-border` */
54
+ border?: string;
55
+ /** Subtle/hairline border color. → `--uploader-border-subtle` */
56
+ borderSubtle?: string;
57
+ /** Primary text color. → `--uploader-text` */
58
+ text?: string;
59
+ /** Muted/secondary text. → `--uploader-text-muted` */
60
+ textMuted?: string;
61
+ /** Extra-muted text (hints, captions). → `--uploader-text-xmuted` */
62
+ textXMuted?: string;
63
+ /** Error color. → `--uploader-error` */
64
+ error?: string;
65
+ /** Tinted error background. → `--uploader-error-soft` */
66
+ errorSoft?: string;
67
+ /** Success color. → `--uploader-success` */
68
+ success?: string;
69
+ /** Small elevation shadow. → `--uploader-shadow-sm` */
70
+ shadowSm?: string;
71
+ /** Default elevation shadow. → `--uploader-shadow` */
72
+ shadow?: string;
73
+ /** Large elevation shadow (modal panel). → `--uploader-shadow-lg` */
74
+ shadowLg?: string;
75
+ /** Font family. Defaults to `inherit`. → `--uploader-font` */
76
+ font?: string;
77
+ /** Transition timing. → `--uploader-transition` */
78
+ transition?: string;
79
+ /** z-index of the modal backdrop. → `--uploader-z-backdrop` */
80
+ zBackdrop?: number | string;
81
+ /** z-index of the modal panel. → `--uploader-z-panel` */
82
+ zPanel?: number | string;
83
+ };
84
+ /**
85
+ * Convert a theme object into a style object of CSS custom properties.
86
+ *
87
+ * Returns an empty object when `theme` is undefined/empty, so it is safe to
88
+ * spread unconditionally. `undefined` token values are skipped (no var emitted),
89
+ * letting the shipped default apply.
90
+ *
91
+ * Merge it ahead of any host `style` so the host can still override per-instance:
92
+ * style={{ ...themeToVars(theme), ...style }}
93
+ */
94
+ declare function themeToVars(theme?: UploaderTheme): React__default.CSSProperties;
95
+
6
96
  /**
7
97
  * React picker prop and state types.
8
98
  *
@@ -131,12 +221,18 @@ type PickerOverlayProps = SharedPickerProps & {
131
221
  open: boolean;
132
222
  /** Called when the modal should close (ESC, backdrop, cancel). */
133
223
  onClose: () => void;
224
+ /**
225
+ * Design tokens to override, scoped to this picker instance. Maps to
226
+ * `--uploader-*` CSS variables applied on the overlay root — see UploaderTheme.
227
+ * Omit to use the shipped defaults (or page-level CSS-variable overrides).
228
+ */
229
+ theme?: UploaderTheme;
134
230
  /** Additional CSS class(es) applied to the modal panel. */
135
231
  className?: string;
136
232
  /** Inline styles applied to the modal panel. */
137
233
  style?: React__default.CSSProperties;
138
234
  };
139
- declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
235
+ declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, theme, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
140
236
 
141
237
  /**
142
238
  * DropPane — inline drag-and-drop upload zone.
@@ -168,12 +264,18 @@ type DropPaneProps = SharedPickerProps & {
168
264
  * Default: "or click to browse · max 50 MB"
169
265
  */
170
266
  hint?: string;
267
+ /**
268
+ * Design tokens to override, scoped to this pane instance. Maps to
269
+ * `--uploader-*` CSS variables applied on the root element — see UploaderTheme.
270
+ * Omit to use the shipped defaults (or page-level CSS-variable overrides).
271
+ */
272
+ theme?: UploaderTheme;
171
273
  /** Additional CSS class(es) applied to the root element. */
172
274
  className?: string;
173
275
  /** Inline styles applied to the root element. */
174
276
  style?: React__default.CSSProperties;
175
277
  };
176
- declare function DropPane({ apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, className, style, }: DropPaneProps): React__default.JSX.Element;
278
+ declare function DropPane({ apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, theme, className, style, }: DropPaneProps): React__default.JSX.Element;
177
279
 
178
280
  /**
179
281
  * CameraCapture — in-picker webcam capture.
@@ -287,4 +389,4 @@ type EditImageOptions = {
287
389
  };
288
390
  declare function editImage(file: File, opts?: EditImageOptions): Promise<File>;
289
391
 
290
- export { CameraCapture, type CameraCaptureProps, type CropArea, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, usePicker };
392
+ export { CameraCapture, type CameraCaptureProps, type CropArea, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UploaderTheme, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, themeToVars, usePicker };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,98 @@
1
- import { P as PickerResponse, F as FileResult, h as UploaderClientOptions } from './transform-ybCOCWBG.js';
2
- export { C as CropParams, O as OutputParams, a as PolicySpec, Q as QualityParams, R as ResizeParams, b as RotateParams, T as TransformChain, c as TransformOp, d as TransformOpName, e as TransformUrlOptions, U as UploadAllOptions, f as UploadOptions, g as UploaderClient, i as crop, j as flip, k as flop, o as output, q as quality, r as resize, l as rotate, t as transformUrl } from './transform-ybCOCWBG.js';
1
+ import { P as PickerResponse, F as FileResult, h as UploaderClientOptions } from './transform-BSPaC9-P.js';
2
+ export { C as CropParams, D as DeliveryProtection, O as OutputParams, a as PolicySpec, Q as QualityParams, R as ResizeParams, b as RotateParams, T as TransformChain, c as TransformOp, d as TransformOpName, e as TransformUrlOptions, U as UploadAllOptions, f as UploadOptions, g as UploaderClient, i as crop, j as flip, k as flop, o as output, q as quality, r as resize, l as rotate, t as transformUrl, w as withSignedPolicy } from './transform-BSPaC9-P.js';
3
3
  import * as React from 'react';
4
4
  import React__default, { CSSProperties } from 'react';
5
5
 
6
+ /**
7
+ * Theming — map a plain token object to scoped CSS custom properties.
8
+ *
9
+ * The SDK is styled entirely from `--uploader-*` CSS custom properties (see
10
+ * styles.css). A host React app can override them in its own stylesheet, but
11
+ * that overrides every instance on the page and requires writing CSS.
12
+ *
13
+ * The `theme` prop on PickerOverlay / DropPane lets a host pass those tokens as
14
+ * a plain object instead. `themeToVars` converts the object into inline CSS
15
+ * variables applied to the component's own root element, so the override is
16
+ * **scoped to that instance** — two pickers on one page can carry different
17
+ * themes, and nothing leaks to the rest of the app.
18
+ *
19
+ * Only the keys you set are emitted; everything else falls back to the shipped
20
+ * defaults. Fully backward compatible — omit `theme` and behaviour is unchanged.
21
+ *
22
+ * @example
23
+ * <PickerOverlay
24
+ * theme={{ accent: '#4f46e5', accentSoft: '#eef2ff', radius: '12px' }}
25
+ * apikey="pk_..."
26
+ * open={open}
27
+ * onClose={close}
28
+ * />
29
+ */
30
+
31
+ /**
32
+ * Host-overridable design tokens. Each maps to one `--uploader-*` CSS variable.
33
+ * All optional — set only what you want to change. Values are raw CSS strings
34
+ * (e.g. '#4f46e5', 'rgba(79,70,229,.28)', '12px', '0.2s ease').
35
+ */
36
+ type UploaderTheme = {
37
+ /** Primary brand color. → `--uploader-accent` */
38
+ accent?: string;
39
+ /** Hover/active shade of the accent. → `--uploader-accent-hover` */
40
+ accentHover?: string;
41
+ /** Tinted fill for icon swatches and hover backgrounds. → `--uploader-accent-soft` */
42
+ accentSoft?: string;
43
+ /** Focus ring / drag-over glow (≈20–30% opacity of accent). → `--uploader-accent-ring` */
44
+ accentRing?: string;
45
+ /** Corner radius for panels, buttons, inputs. → `--uploader-radius` */
46
+ radius?: string;
47
+ /** Base surface / panel background. → `--uploader-bg` */
48
+ background?: string;
49
+ /** Secondary surface (rows, wells). → `--uploader-surface` */
50
+ surface?: string;
51
+ /** Hover state for secondary surfaces. → `--uploader-surface-hover` */
52
+ surfaceHover?: string;
53
+ /** Default border color. → `--uploader-border` */
54
+ border?: string;
55
+ /** Subtle/hairline border color. → `--uploader-border-subtle` */
56
+ borderSubtle?: string;
57
+ /** Primary text color. → `--uploader-text` */
58
+ text?: string;
59
+ /** Muted/secondary text. → `--uploader-text-muted` */
60
+ textMuted?: string;
61
+ /** Extra-muted text (hints, captions). → `--uploader-text-xmuted` */
62
+ textXMuted?: string;
63
+ /** Error color. → `--uploader-error` */
64
+ error?: string;
65
+ /** Tinted error background. → `--uploader-error-soft` */
66
+ errorSoft?: string;
67
+ /** Success color. → `--uploader-success` */
68
+ success?: string;
69
+ /** Small elevation shadow. → `--uploader-shadow-sm` */
70
+ shadowSm?: string;
71
+ /** Default elevation shadow. → `--uploader-shadow` */
72
+ shadow?: string;
73
+ /** Large elevation shadow (modal panel). → `--uploader-shadow-lg` */
74
+ shadowLg?: string;
75
+ /** Font family. Defaults to `inherit`. → `--uploader-font` */
76
+ font?: string;
77
+ /** Transition timing. → `--uploader-transition` */
78
+ transition?: string;
79
+ /** z-index of the modal backdrop. → `--uploader-z-backdrop` */
80
+ zBackdrop?: number | string;
81
+ /** z-index of the modal panel. → `--uploader-z-panel` */
82
+ zPanel?: number | string;
83
+ };
84
+ /**
85
+ * Convert a theme object into a style object of CSS custom properties.
86
+ *
87
+ * Returns an empty object when `theme` is undefined/empty, so it is safe to
88
+ * spread unconditionally. `undefined` token values are skipped (no var emitted),
89
+ * letting the shipped default apply.
90
+ *
91
+ * Merge it ahead of any host `style` so the host can still override per-instance:
92
+ * style={{ ...themeToVars(theme), ...style }}
93
+ */
94
+ declare function themeToVars(theme?: UploaderTheme): React__default.CSSProperties;
95
+
6
96
  /**
7
97
  * React picker prop and state types.
8
98
  *
@@ -131,12 +221,18 @@ type PickerOverlayProps = SharedPickerProps & {
131
221
  open: boolean;
132
222
  /** Called when the modal should close (ESC, backdrop, cancel). */
133
223
  onClose: () => void;
224
+ /**
225
+ * Design tokens to override, scoped to this picker instance. Maps to
226
+ * `--uploader-*` CSS variables applied on the overlay root — see UploaderTheme.
227
+ * Omit to use the shipped defaults (or page-level CSS-variable overrides).
228
+ */
229
+ theme?: UploaderTheme;
134
230
  /** Additional CSS class(es) applied to the modal panel. */
135
231
  className?: string;
136
232
  /** Inline styles applied to the modal panel. */
137
233
  style?: React__default.CSSProperties;
138
234
  };
139
- declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
235
+ declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, theme, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
140
236
 
141
237
  /**
142
238
  * DropPane — inline drag-and-drop upload zone.
@@ -168,12 +264,18 @@ type DropPaneProps = SharedPickerProps & {
168
264
  * Default: "or click to browse · max 50 MB"
169
265
  */
170
266
  hint?: string;
267
+ /**
268
+ * Design tokens to override, scoped to this pane instance. Maps to
269
+ * `--uploader-*` CSS variables applied on the root element — see UploaderTheme.
270
+ * Omit to use the shipped defaults (or page-level CSS-variable overrides).
271
+ */
272
+ theme?: UploaderTheme;
171
273
  /** Additional CSS class(es) applied to the root element. */
172
274
  className?: string;
173
275
  /** Inline styles applied to the root element. */
174
276
  style?: React__default.CSSProperties;
175
277
  };
176
- declare function DropPane({ apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, className, style, }: DropPaneProps): React__default.JSX.Element;
278
+ declare function DropPane({ apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, theme, className, style, }: DropPaneProps): React__default.JSX.Element;
177
279
 
178
280
  /**
179
281
  * CameraCapture — in-picker webcam capture.
@@ -287,4 +389,4 @@ type EditImageOptions = {
287
389
  };
288
390
  declare function editImage(file: File, opts?: EditImageOptions): Promise<File>;
289
391
 
290
- export { CameraCapture, type CameraCaptureProps, type CropArea, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, usePicker };
392
+ export { CameraCapture, type CameraCaptureProps, type CropArea, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UploaderTheme, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, themeToVars, usePicker };
package/dist/index.js CHANGED
@@ -7,8 +7,9 @@ import {
7
7
  quality,
8
8
  resize,
9
9
  rotate,
10
- transformUrl
11
- } from "./chunk-EM6NZZSU.js";
10
+ transformUrl,
11
+ withSignedPolicy
12
+ } from "./chunk-QRUZUI5L.js";
12
13
 
13
14
  // src/react/PickerOverlay.tsx
14
15
  import {
@@ -1082,6 +1083,43 @@ function FileQueueRow({ entry, onRemove, onRetry, onEdit }) {
1082
1083
  ] });
1083
1084
  }
1084
1085
 
1086
+ // src/react/theme.ts
1087
+ var VAR_MAP = {
1088
+ accent: "--uploader-accent",
1089
+ accentHover: "--uploader-accent-hover",
1090
+ accentSoft: "--uploader-accent-soft",
1091
+ accentRing: "--uploader-accent-ring",
1092
+ radius: "--uploader-radius",
1093
+ background: "--uploader-bg",
1094
+ surface: "--uploader-surface",
1095
+ surfaceHover: "--uploader-surface-hover",
1096
+ border: "--uploader-border",
1097
+ borderSubtle: "--uploader-border-subtle",
1098
+ text: "--uploader-text",
1099
+ textMuted: "--uploader-text-muted",
1100
+ textXMuted: "--uploader-text-xmuted",
1101
+ error: "--uploader-error",
1102
+ errorSoft: "--uploader-error-soft",
1103
+ success: "--uploader-success",
1104
+ shadowSm: "--uploader-shadow-sm",
1105
+ shadow: "--uploader-shadow",
1106
+ shadowLg: "--uploader-shadow-lg",
1107
+ font: "--uploader-font",
1108
+ transition: "--uploader-transition",
1109
+ zBackdrop: "--uploader-z-backdrop",
1110
+ zPanel: "--uploader-z-panel"
1111
+ };
1112
+ function themeToVars(theme) {
1113
+ if (!theme) return {};
1114
+ const vars = {};
1115
+ for (const key of Object.keys(theme)) {
1116
+ const value = theme[key];
1117
+ if (value === void 0 || value === null) continue;
1118
+ vars[VAR_MAP[key]] = String(value);
1119
+ }
1120
+ return vars;
1121
+ }
1122
+
1085
1123
  // src/react/PickerOverlay.tsx
1086
1124
  import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1087
1125
  function dialogTitle(isUploading, isDone, totalFiles, doneCount, errorCount, editingId, cameraOpen) {
@@ -1103,6 +1141,7 @@ function PickerOverlay({
1103
1141
  onFileUploadFinished,
1104
1142
  onFileUploadFailed,
1105
1143
  onCancel,
1144
+ theme,
1106
1145
  className,
1107
1146
  style
1108
1147
  }) {
@@ -1216,6 +1255,7 @@ function PickerOverlay({
1216
1255
  {
1217
1256
  className: "uploader-backdrop",
1218
1257
  "data-testid": "picker-backdrop",
1258
+ style: themeToVars(theme),
1219
1259
  onClick: handleClose,
1220
1260
  children: /* @__PURE__ */ jsxs5(
1221
1261
  "div",
@@ -1402,11 +1442,13 @@ function DropPane({
1402
1442
  onFileUploadFailed,
1403
1443
  onCancel,
1404
1444
  hint = "or click to browse \xB7 max 50 MB",
1445
+ theme,
1405
1446
  className,
1406
1447
  style
1407
1448
  }) {
1408
1449
  const [isDragOver, setIsDragOver] = useState5(false);
1409
1450
  const [cameraOpen, setCameraOpen] = useState5(false);
1451
+ const rootStyle = { ...themeToVars(theme), ...style };
1410
1452
  const { files, addFiles, removeFile, retryFile, upload, progress, isUploading, isDone } = usePicker({
1411
1453
  apikey,
1412
1454
  apiUrl,
@@ -1452,7 +1494,7 @@ function DropPane({
1452
1494
  {
1453
1495
  className: ["uploader-drop-pane", className ?? ""].filter(Boolean).join(" "),
1454
1496
  "data-testid": "drop-pane",
1455
- style,
1497
+ style: rootStyle,
1456
1498
  children: /* @__PURE__ */ jsx7(
1457
1499
  CameraCapture,
1458
1500
  {
@@ -1473,7 +1515,7 @@ function DropPane({
1473
1515
  className: ["uploader-drop-pane", className ?? ""].filter(Boolean).join(" "),
1474
1516
  "data-drag-over": isDragOver ? "true" : void 0,
1475
1517
  "data-testid": "drop-pane",
1476
- style,
1518
+ style: rootStyle,
1477
1519
  children: [
1478
1520
  files.length === 0 && /* @__PURE__ */ jsx7(
1479
1521
  Dropzone,
@@ -1584,7 +1626,9 @@ export {
1584
1626
  resize,
1585
1627
  rotate,
1586
1628
  shouldOfferCamera,
1629
+ themeToVars,
1587
1630
  transformUrl,
1588
- usePicker
1631
+ usePicker,
1632
+ withSignedPolicy
1589
1633
  };
1590
1634
  //# sourceMappingURL=index.js.map