@ibanzajoe/uploader 0.2.0 → 0.3.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
@@ -3,6 +3,96 @@ export { C as CropParams, O as OutputParams, a as PolicySpec, Q as QualityParams
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
@@ -3,6 +3,96 @@ export { C as CropParams, O as OutputParams, a as PolicySpec, Q as QualityParams
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
@@ -1082,6 +1082,43 @@ function FileQueueRow({ entry, onRemove, onRetry, onEdit }) {
1082
1082
  ] });
1083
1083
  }
1084
1084
 
1085
+ // src/react/theme.ts
1086
+ var VAR_MAP = {
1087
+ accent: "--uploader-accent",
1088
+ accentHover: "--uploader-accent-hover",
1089
+ accentSoft: "--uploader-accent-soft",
1090
+ accentRing: "--uploader-accent-ring",
1091
+ radius: "--uploader-radius",
1092
+ background: "--uploader-bg",
1093
+ surface: "--uploader-surface",
1094
+ surfaceHover: "--uploader-surface-hover",
1095
+ border: "--uploader-border",
1096
+ borderSubtle: "--uploader-border-subtle",
1097
+ text: "--uploader-text",
1098
+ textMuted: "--uploader-text-muted",
1099
+ textXMuted: "--uploader-text-xmuted",
1100
+ error: "--uploader-error",
1101
+ errorSoft: "--uploader-error-soft",
1102
+ success: "--uploader-success",
1103
+ shadowSm: "--uploader-shadow-sm",
1104
+ shadow: "--uploader-shadow",
1105
+ shadowLg: "--uploader-shadow-lg",
1106
+ font: "--uploader-font",
1107
+ transition: "--uploader-transition",
1108
+ zBackdrop: "--uploader-z-backdrop",
1109
+ zPanel: "--uploader-z-panel"
1110
+ };
1111
+ function themeToVars(theme) {
1112
+ if (!theme) return {};
1113
+ const vars = {};
1114
+ for (const key of Object.keys(theme)) {
1115
+ const value = theme[key];
1116
+ if (value === void 0 || value === null) continue;
1117
+ vars[VAR_MAP[key]] = String(value);
1118
+ }
1119
+ return vars;
1120
+ }
1121
+
1085
1122
  // src/react/PickerOverlay.tsx
1086
1123
  import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1087
1124
  function dialogTitle(isUploading, isDone, totalFiles, doneCount, errorCount, editingId, cameraOpen) {
@@ -1103,6 +1140,7 @@ function PickerOverlay({
1103
1140
  onFileUploadFinished,
1104
1141
  onFileUploadFailed,
1105
1142
  onCancel,
1143
+ theme,
1106
1144
  className,
1107
1145
  style
1108
1146
  }) {
@@ -1216,6 +1254,7 @@ function PickerOverlay({
1216
1254
  {
1217
1255
  className: "uploader-backdrop",
1218
1256
  "data-testid": "picker-backdrop",
1257
+ style: themeToVars(theme),
1219
1258
  onClick: handleClose,
1220
1259
  children: /* @__PURE__ */ jsxs5(
1221
1260
  "div",
@@ -1402,11 +1441,13 @@ function DropPane({
1402
1441
  onFileUploadFailed,
1403
1442
  onCancel,
1404
1443
  hint = "or click to browse \xB7 max 50 MB",
1444
+ theme,
1405
1445
  className,
1406
1446
  style
1407
1447
  }) {
1408
1448
  const [isDragOver, setIsDragOver] = useState5(false);
1409
1449
  const [cameraOpen, setCameraOpen] = useState5(false);
1450
+ const rootStyle = { ...themeToVars(theme), ...style };
1410
1451
  const { files, addFiles, removeFile, retryFile, upload, progress, isUploading, isDone } = usePicker({
1411
1452
  apikey,
1412
1453
  apiUrl,
@@ -1452,7 +1493,7 @@ function DropPane({
1452
1493
  {
1453
1494
  className: ["uploader-drop-pane", className ?? ""].filter(Boolean).join(" "),
1454
1495
  "data-testid": "drop-pane",
1455
- style,
1496
+ style: rootStyle,
1456
1497
  children: /* @__PURE__ */ jsx7(
1457
1498
  CameraCapture,
1458
1499
  {
@@ -1473,7 +1514,7 @@ function DropPane({
1473
1514
  className: ["uploader-drop-pane", className ?? ""].filter(Boolean).join(" "),
1474
1515
  "data-drag-over": isDragOver ? "true" : void 0,
1475
1516
  "data-testid": "drop-pane",
1476
- style,
1517
+ style: rootStyle,
1477
1518
  children: [
1478
1519
  files.length === 0 && /* @__PURE__ */ jsx7(
1479
1520
  Dropzone,
@@ -1584,6 +1625,7 @@ export {
1584
1625
  resize,
1585
1626
  rotate,
1586
1627
  shouldOfferCamera,
1628
+ themeToVars,
1587
1629
  transformUrl,
1588
1630
  usePicker
1589
1631
  };