@gradio/gallery 0.17.0 → 0.17.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @gradio/gallery
2
2
 
3
+ ## 0.17.2
4
+
5
+ ### Fixes
6
+
7
+ - [#12927](https://github.com/gradio-app/gradio/pull/12927) [`ca84f3e`](https://github.com/gradio-app/gradio/commit/ca84f3e36c6a3f3c3f0b57084b6f514d6cded1d4) - Fix Gallery CSS Issue. Thanks @freddyaboulton!
8
+
9
+ ## 0.17.1
10
+
11
+ ### Dependency updates
12
+
13
+ - @gradio/client@2.1.0
14
+
15
+ ## 0.17.1
16
+
17
+ ### Fixes
18
+
19
+ - [#12865](https://github.com/gradio-app/gradio/pull/12865) [`db7ab39`](https://github.com/gradio-app/gradio/commit/db7ab39c7e6ea3d1a2f0ce1991b5dbc0483b1e27) - Fix Gallery fullscreen button not working in preview mode. Thanks @veeceey!
20
+ - [#12866](https://github.com/gradio-app/gradio/pull/12866) [`9810396`](https://github.com/gradio-app/gradio/commit/981039647a4212c649a33dc4b56a4714980519eb) - Fix Gallery preview=True parameter not working on initial load. Thanks @veeceey!
21
+
22
+ ### Dependency updates
23
+
24
+ - @gradio/utils@0.11.3
25
+ - @gradio/atoms@0.22.0
26
+ - @gradio/statustracker@0.12.4
27
+ - @gradio/upload@0.17.6
28
+ - @gradio/video@0.20.3
29
+ - @gradio/file@0.14.3
30
+ - @gradio/image@0.25.3
31
+
3
32
  ## 0.17.0
4
33
 
5
34
  ### Features
@@ -154,13 +154,16 @@
154
154
  args={{
155
155
  label: "My Cheetah Gallery",
156
156
  show_label: true,
157
- buttons: ["fullscreen", "download", "share"]
157
+ buttons: ["fullscreen", "download", "share"],
158
+ sources: ["upload"]
158
159
  }}
159
160
  play={async ({ canvasElement }) => {
160
161
  const canvas = within(canvasElement);
161
- const image = canvas.getByLabelText("Thumbnail 1 of 8");
162
+ const image = await canvas.findByLabelText("Thumbnail 1 of 8");
162
163
  await userEvent.click(image);
163
- const expand_btn = canvas.getByRole("button", { name: "Fullscreen" });
164
+ const expand_btn = await canvas.findByRole("button", {
165
+ name: "Fullscreen"
166
+ });
164
167
  await userEvent.click(expand_btn);
165
168
  }}
166
169
  >
@@ -171,7 +174,12 @@
171
174
 
172
175
  <Story
173
176
  name="Gallery without label"
174
- args={{ label: "My Cheetah Gallery", show_label: false, buttons: [] }}
177
+ args={{
178
+ label: "My Cheetah Gallery",
179
+ show_label: false,
180
+ buttons: [],
181
+ sources: ["upload"]
182
+ }}
175
183
  >
176
184
  {#snippet template(args)}
177
185
  <Gallery {...wrapProps({ value: galleryValue, ...args })} />
@@ -185,7 +193,8 @@
185
193
  show_label: true,
186
194
  rows: 3,
187
195
  columns: 3,
188
- buttons: []
196
+ buttons: [],
197
+ sources: ["upload"]
189
198
  }}
190
199
  >
191
200
  {#snippet template(args)}
@@ -199,7 +208,8 @@
199
208
  label: "My Cheetah Gallery",
200
209
  show_label: true,
201
210
  columns: 4,
202
- buttons: []
211
+ buttons: [],
212
+ sources: ["upload"]
203
213
  }}
204
214
  >
205
215
  {#snippet template(args)}
@@ -209,7 +219,12 @@
209
219
 
210
220
  <Story
211
221
  name="Gallery with height=600"
212
- args={{ label: "My Cheetah Gallery", height: 600, buttons: [] }}
222
+ args={{
223
+ label: "My Cheetah Gallery",
224
+ height: 600,
225
+ buttons: [],
226
+ sources: ["upload"]
227
+ }}
213
228
  >
214
229
  {#snippet template(args)}
215
230
  <Gallery {...wrapProps({ value: galleryValue, ...args })} />
@@ -222,7 +237,8 @@
222
237
  label: "My Cheetah Gallery",
223
238
  show_label: true,
224
239
  allow_preview: false,
225
- buttons: []
240
+ buttons: [],
241
+ sources: ["upload"]
226
242
  }}
227
243
  >
228
244
  {#snippet template(args)}
@@ -236,7 +252,8 @@
236
252
  label: "My Cheetah Gallery",
237
253
  show_label: true,
238
254
  preview: true,
239
- buttons: []
255
+ buttons: [],
256
+ sources: ["upload"]
240
257
  }}
241
258
  >
242
259
  {#snippet template(args)}
@@ -250,7 +267,8 @@
250
267
  label: "My Cheetah Gallery",
251
268
  show_label: true,
252
269
  object_fit: "scale-down",
253
- buttons: []
270
+ buttons: [],
271
+ sources: ["upload"]
254
272
  }}
255
273
  >
256
274
  {#snippet template(args)}
@@ -264,7 +282,8 @@
264
282
  label: "My Cheetah Gallery",
265
283
  show_label: true,
266
284
  object_fit: "contain",
267
- buttons: []
285
+ buttons: [],
286
+ sources: ["upload"]
268
287
  }}
269
288
  >
270
289
  {#snippet template(args)}
@@ -278,7 +297,8 @@
278
297
  label: "My Cheetah Gallery",
279
298
  show_label: true,
280
299
  object_fit: "cover",
281
- buttons: []
300
+ buttons: [],
301
+ sources: ["upload"]
282
302
  }}
283
303
  >
284
304
  {#snippet template(args)}
@@ -292,7 +312,8 @@
292
312
  label: "My Cheetah Gallery",
293
313
  show_label: true,
294
314
  object_fit: "none",
295
- buttons: []
315
+ buttons: [],
316
+ sources: ["upload"]
296
317
  }}
297
318
  >
298
319
  {#snippet template(args)}
@@ -306,7 +327,8 @@
306
327
  label: "My Cheetah Gallery",
307
328
  show_label: true,
308
329
  object_fit: "fill",
309
- buttons: []
330
+ buttons: [],
331
+ sources: ["upload"]
310
332
  }}
311
333
  >
312
334
  {#snippet template(args)}
@@ -316,7 +338,12 @@
316
338
 
317
339
  <Story
318
340
  name="Gallery with share button"
319
- args={{ label: "My Cheetah Gallery", show_label: true, buttons: ["share"] }}
341
+ args={{
342
+ label: "My Cheetah Gallery",
343
+ show_label: true,
344
+ buttons: ["share"],
345
+ sources: ["upload"]
346
+ }}
320
347
  >
321
348
  {#snippet template(args)}
322
349
  <Gallery {...wrapProps({ value: galleryValue, ...args })} />
@@ -331,7 +358,8 @@
331
358
  rows: 2,
332
359
  columns: 2,
333
360
  height: 400,
334
- buttons: []
361
+ buttons: [],
362
+ sources: ["upload"]
335
363
  }}
336
364
  >
337
365
  {#snippet template(args)}
@@ -347,7 +375,8 @@
347
375
  rows: 2,
348
376
  columns: 2,
349
377
  height: 200,
350
- buttons: []
378
+ buttons: [],
379
+ sources: ["upload"]
351
380
  }}
352
381
  >
353
382
  {#snippet template(args)}
@@ -361,7 +390,8 @@
361
390
  label: "My Cheetah Gallery",
362
391
  rows: 2,
363
392
  height: 400,
364
- buttons: ["download"]
393
+ buttons: ["download"],
394
+ sources: ["upload"]
365
395
  }}
366
396
  >
367
397
  {#snippet template(args)}
@@ -375,7 +405,8 @@
375
405
  label: "My Cheetah Gallery",
376
406
  columns: 10,
377
407
  buttons: ["download"],
378
- fit_columns: false
408
+ fit_columns: false,
409
+ sources: ["upload"]
379
410
  }}
380
411
  >
381
412
  {#snippet template(args)}
@@ -389,7 +420,8 @@
389
420
  label: "My Cheetah Gallery",
390
421
  columns: 10,
391
422
  buttons: ["download"],
392
- fit_columns: true
423
+ fit_columns: true,
424
+ sources: ["upload"]
393
425
  }}
394
426
  >
395
427
  {#snippet template(args)}
package/Index.svelte CHANGED
@@ -158,9 +158,7 @@
158
158
  scale={gradio.shared.scale}
159
159
  min_width={gradio.shared.min_width}
160
160
  allow_overflow={false}
161
- height={typeof gradio.props.height === "number"
162
- ? gradio.props.height
163
- : undefined}
161
+ height={gradio.props.height || undefined}
164
162
  bind:fullscreen
165
163
  >
166
164
  <StatusTracker
@@ -175,7 +173,7 @@
175
173
  class={!gradio.props.value ||
176
174
  (active_source && active_source.includes("webcam"))
177
175
  ? "hidden-upload-input"
178
- : ""}
176
+ : "upload-wrapper"}
179
177
  >
180
178
  <BaseFileUpload
181
179
  bind:upload_promise
@@ -328,4 +326,7 @@
328
326
  .hidden-upload-input {
329
327
  display: none;
330
328
  }
329
+ .upload-wrapper {
330
+ height: 100%;
331
+ }
331
332
  </style>
package/dist/Index.svelte CHANGED
@@ -158,9 +158,7 @@
158
158
  scale={gradio.shared.scale}
159
159
  min_width={gradio.shared.min_width}
160
160
  allow_overflow={false}
161
- height={typeof gradio.props.height === "number"
162
- ? gradio.props.height
163
- : undefined}
161
+ height={gradio.props.height || undefined}
164
162
  bind:fullscreen
165
163
  >
166
164
  <StatusTracker
@@ -175,7 +173,7 @@
175
173
  class={!gradio.props.value ||
176
174
  (active_source && active_source.includes("webcam"))
177
175
  ? "hidden-upload-input"
178
- : ""}
176
+ : "upload-wrapper"}
179
177
  >
180
178
  <BaseFileUpload
181
179
  bind:upload_promise
@@ -328,4 +326,7 @@
328
326
  .hidden-upload-input {
329
327
  display: none;
330
328
  }
329
+ .upload-wrapper {
330
+ height: 100%;
331
+ }
331
332
  </style>
@@ -77,7 +77,7 @@
77
77
  value: GalleryData[] | null;
78
78
  columns: number | number[] | undefined;
79
79
  rows: number | number[] | undefined;
80
- height: number | "auto";
80
+ height: number | string;
81
81
  preview: boolean;
82
82
  allow_preview: boolean;
83
83
  object_fit: "contain" | "cover" | "fill" | "none" | "scale-down";
@@ -157,9 +157,9 @@
157
157
  );
158
158
 
159
159
  let prev_value: GalleryData[] | null = $state(value);
160
- // if (selected_index == null && preview && value?.length) {
161
- // selected_index = 0;
162
- // }
160
+ if (selected_index == null && preview && value?.length) {
161
+ selected_index = 0;
162
+ }
163
163
  let old_selected_index: number | null = $state(selected_index);
164
164
 
165
165
  $effect(() => {
@@ -414,7 +414,11 @@
414
414
  {/if}
415
415
 
416
416
  {#if show_fullscreen_button}
417
- <FullscreenButton {fullscreen} onclick={(e) => onfullscreen(e)} />
417
+ <FullscreenButton
418
+ {fullscreen}
419
+ onclick={(is_fullscreen) =>
420
+ onfullscreen({ detail: is_fullscreen })}
421
+ />
418
422
  {/if}
419
423
 
420
424
  {#if show_share_button}
@@ -535,7 +539,11 @@
535
539
  class:minimal={mode === "minimal"}
536
540
  class:fixed-height={mode !== "minimal" && (!height || height == "auto")}
537
541
  class:hidden={is_full_screen}
538
- style:height={height !== "auto" ? height + "px" : null}
542
+ style:height={height !== "auto"
543
+ ? typeof height === "number"
544
+ ? height + "px"
545
+ : height
546
+ : null}
539
547
  >
540
548
  {#if interactive && selected_index === null}
541
549
  <ModifyUpload
@@ -659,11 +667,11 @@
659
667
  {/if}
660
668
 
661
669
  <style lang="postcss">
662
- .image-container {
670
+ .gallery-container {
663
671
  height: 100%;
664
672
  position: relative;
665
673
  }
666
- .image-container :global(img),
674
+ .gallery-container :global(img),
667
675
  button {
668
676
  width: var(--size-full);
669
677
  height: var(--size-full);
@@ -10,7 +10,7 @@ type $$ComponentProps = {
10
10
  value: GalleryData[] | null;
11
11
  columns: number | number[] | undefined;
12
12
  rows: number | number[] | undefined;
13
- height: number | "auto";
13
+ height: number | string;
14
14
  preview: boolean;
15
15
  allow_preview: boolean;
16
16
  object_fit: "contain" | "cover" | "fill" | "none" | "scale-down";
package/dist/types.d.ts CHANGED
@@ -14,7 +14,7 @@ export interface GalleryProps {
14
14
  file_types: string[] | null;
15
15
  columns: number | number[] | undefined;
16
16
  rows: number | number[] | undefined;
17
- height: number | "auto";
17
+ height: number | string;
18
18
  preview: boolean;
19
19
  allow_preview: boolean;
20
20
  selected_index: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/gallery",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -8,15 +8,15 @@
8
8
  "private": false,
9
9
  "dependencies": {
10
10
  "dequal": "^2.0.3",
11
- "@gradio/atoms": "^0.21.0",
12
- "@gradio/client": "^2.0.4",
13
- "@gradio/file": "^0.14.2",
14
- "@gradio/image": "^0.25.2",
15
- "@gradio/statustracker": "^0.12.3",
11
+ "@gradio/atoms": "^0.22.1",
12
+ "@gradio/client": "^2.1.0",
13
+ "@gradio/file": "^0.14.3",
14
+ "@gradio/statustracker": "^0.12.4",
15
+ "@gradio/upload": "^0.17.6",
16
+ "@gradio/image": "^0.25.3",
16
17
  "@gradio/icons": "^0.15.1",
17
- "@gradio/utils": "^0.11.2",
18
- "@gradio/video": "^0.20.2",
19
- "@gradio/upload": "^0.17.5"
18
+ "@gradio/utils": "^0.11.3",
19
+ "@gradio/video": "^0.20.3"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@gradio/preview": "^0.15.2"
@@ -77,7 +77,7 @@
77
77
  value: GalleryData[] | null;
78
78
  columns: number | number[] | undefined;
79
79
  rows: number | number[] | undefined;
80
- height: number | "auto";
80
+ height: number | string;
81
81
  preview: boolean;
82
82
  allow_preview: boolean;
83
83
  object_fit: "contain" | "cover" | "fill" | "none" | "scale-down";
@@ -157,9 +157,9 @@
157
157
  );
158
158
 
159
159
  let prev_value: GalleryData[] | null = $state(value);
160
- // if (selected_index == null && preview && value?.length) {
161
- // selected_index = 0;
162
- // }
160
+ if (selected_index == null && preview && value?.length) {
161
+ selected_index = 0;
162
+ }
163
163
  let old_selected_index: number | null = $state(selected_index);
164
164
 
165
165
  $effect(() => {
@@ -414,7 +414,11 @@
414
414
  {/if}
415
415
 
416
416
  {#if show_fullscreen_button}
417
- <FullscreenButton {fullscreen} onclick={(e) => onfullscreen(e)} />
417
+ <FullscreenButton
418
+ {fullscreen}
419
+ onclick={(is_fullscreen) =>
420
+ onfullscreen({ detail: is_fullscreen })}
421
+ />
418
422
  {/if}
419
423
 
420
424
  {#if show_share_button}
@@ -535,7 +539,11 @@
535
539
  class:minimal={mode === "minimal"}
536
540
  class:fixed-height={mode !== "minimal" && (!height || height == "auto")}
537
541
  class:hidden={is_full_screen}
538
- style:height={height !== "auto" ? height + "px" : null}
542
+ style:height={height !== "auto"
543
+ ? typeof height === "number"
544
+ ? height + "px"
545
+ : height
546
+ : null}
539
547
  >
540
548
  {#if interactive && selected_index === null}
541
549
  <ModifyUpload
@@ -659,11 +667,11 @@
659
667
  {/if}
660
668
 
661
669
  <style lang="postcss">
662
- .image-container {
670
+ .gallery-container {
663
671
  height: 100%;
664
672
  position: relative;
665
673
  }
666
- .image-container :global(img),
674
+ .gallery-container :global(img),
667
675
  button {
668
676
  width: var(--size-full);
669
677
  height: var(--size-full);
package/types.ts CHANGED
@@ -18,7 +18,7 @@ export interface GalleryProps {
18
18
  file_types: string[] | null;
19
19
  columns: number | number[] | undefined;
20
20
  rows: number | number[] | undefined;
21
- height: number | "auto";
21
+ height: number | string;
22
22
  preview: boolean;
23
23
  allow_preview: boolean;
24
24
  selected_index: number | null;