@gradio/dataframe 0.17.2 → 0.17.3

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,11 @@
1
1
  # @gradio/dataframe
2
2
 
3
+ ## 0.17.3
4
+
5
+ ### Fixes
6
+
7
+ - [#10900](https://github.com/gradio-app/gradio/pull/10900) [`a018a46`](https://github.com/gradio-app/gradio/commit/a018a46a7fae0f7db25baca7e1c08e6fd5912ed2) - Fix wrap behaviour in dataframe. Thanks @hannahblair!
8
+
3
9
  ## 0.17.2
4
10
 
5
11
  ### Dependency updates
@@ -23,6 +23,16 @@
23
23
  description: "Whether the DataFrame is editable",
24
24
  name: "interactive",
25
25
  value: true
26
+ },
27
+ wrap: {
28
+ control: "boolean",
29
+ description: "Whether text should wrap or truncate with ellipsis",
30
+ defaultValue: false
31
+ },
32
+ column_widths: {
33
+ control: "object",
34
+ description: "Width of each column (px, %, or auto)",
35
+ defaultValue: ["200px", "200px", "200px"]
26
36
  }
27
37
  }}
28
38
  />
@@ -238,7 +248,7 @@
238
248
  values: [['<a href="https://www.google.com/">google</a>']],
239
249
  headers: ["link"],
240
250
  datatype: ["markdown"],
241
- interactive: false,
251
+ editable: false,
242
252
  col_count: [1, "dynamic"],
243
253
  row_count: [1, "dynamic"]
244
254
  }}
@@ -446,7 +456,7 @@
446
456
  label: "Pokemon Cards",
447
457
  col_count: [5, "fixed"],
448
458
  row_count: [1, "dynamic"],
449
- interactive: true,
459
+ editable: true,
450
460
  editable: true,
451
461
  components: {
452
462
  image: Image
@@ -740,3 +750,63 @@
740
750
  await userEvent.click(canvas.getByText("Clear sort"));
741
751
  }}
742
752
  />
753
+
754
+ <Story
755
+ name="Dataframe with text wrapping, no max chars"
756
+ args={{
757
+ values: [
758
+ [
759
+ "This is a very long text that should wrap to multiple lines when wrap is enabled",
760
+ "Short text",
761
+ "Another very long text that demonstrates wrapping behavior in the table cells"
762
+ ],
763
+ [
764
+ "Short",
765
+ "This text is also quite long and should demonstrate the wrapping behavior when enabled",
766
+ "Medium length text here"
767
+ ],
768
+ [
769
+ "Medium text",
770
+ "Brief",
771
+ "When wrap is disabled, this text should be truncated with an ellipsis instead of wrapping to multiple lines"
772
+ ]
773
+ ],
774
+ headers: ["Column A", "Column B", "Column C"],
775
+ label: "Text Wrapping Example",
776
+ col_count: [3, "dynamic"],
777
+ row_count: [3, "dynamic"],
778
+ wrap: true,
779
+ column_widths: ["33%", "33%", "33%"]
780
+ }}
781
+ />
782
+
783
+ <Story
784
+ name="Dataframe text truncation and wrapping"
785
+ args={{
786
+ values: [
787
+ [
788
+ "This is a very long text that should be truncated with an ellipsis when wrap is false",
789
+ "Short text",
790
+ "Another very long text that should also be truncated with an ellipsis"
791
+ ],
792
+ [
793
+ "Short",
794
+ "This text is also quite long and should be truncated with an ellipsis",
795
+ "Medium length text here"
796
+ ],
797
+ [
798
+ "Medium text",
799
+ "Brief",
800
+ "When wrap is false this text should definitely be truncated with an ellipsis"
801
+ ]
802
+ ],
803
+ headers: ["Column A", "Column B", "Column C"],
804
+ label: "Text Truncation Example",
805
+ col_count: [3, "dynamic"],
806
+ row_count: [3, "dynamic"],
807
+ wrap: true,
808
+ max_chars: 50,
809
+ editable: false,
810
+ column_widths: ["200px", "200px", "200px"]
811
+ }}
812
+ />
@@ -17,6 +17,7 @@ export let max_chars = null;
17
17
  export let components = {};
18
18
  export let i18n;
19
19
  export let is_dragging = false;
20
+ export let wrap_text = false;
20
21
  export let show_selection_buttons = false;
21
22
  export let coords = null;
22
23
  export let on_select_column = null;
@@ -110,6 +111,7 @@ function handle_click() {
110
111
  data-expanded={is_expanded}
111
112
  placeholder=" "
112
113
  class:text={datatype === "str"}
114
+ class:wrap={wrap_text}
113
115
  >
114
116
  {#if datatype === "image" && components.image}
115
117
  <svelte:component
@@ -177,14 +179,6 @@ function handle_click() {
177
179
  width: 100%;
178
180
  height: 100%;
179
181
  overflow: hidden;
180
- text-overflow: ellipsis;
181
- white-space: nowrap;
182
- }
183
-
184
- span.text:not(.expanded) {
185
- overflow: hidden;
186
- text-overflow: ellipsis;
187
- white-space: nowrap;
188
182
  }
189
183
 
190
184
  span.text.expanded {
@@ -224,4 +218,12 @@ function handle_click() {
224
218
  input:read-only {
225
219
  cursor: not-allowed;
226
220
  }
221
+
222
+ .wrap,
223
+ .wrap.expanded {
224
+ white-space: normal;
225
+ word-wrap: break-word;
226
+ overflow-wrap: break-word;
227
+ word-wrap: break-word;
228
+ }
227
229
  </style>
@@ -22,6 +22,7 @@ declare const __propDef: {
22
22
  components?: Record<string, any> | undefined;
23
23
  i18n: I18nFormatter;
24
24
  is_dragging?: boolean | undefined;
25
+ wrap_text?: boolean | undefined;
25
26
  show_selection_buttons?: boolean | undefined;
26
27
  coords?: ([number, number] | null) | undefined;
27
28
  on_select_column?: (((col: number) => void) | null) | undefined;
@@ -826,6 +826,7 @@ $:
826
826
  {handle_select_row}
827
827
  bind:el={els[id]}
828
828
  {is_dragging}
829
+ {wrap}
829
830
  />
830
831
  {/each}
831
832
  </tr>
@@ -29,6 +29,7 @@ export let el;
29
29
  export let handle_select_column;
30
30
  export let handle_select_row;
31
31
  export let is_dragging;
32
+ export let wrap = false;
32
33
  function get_cell_position(col_index) {
33
34
  if (col_index >= actual_pinned_columns) {
34
35
  return "auto";
@@ -111,6 +112,7 @@ $:
111
112
  on_select_column={handle_select_column}
112
113
  on_select_row={handle_select_row}
113
114
  {is_dragging}
115
+ wrap_text={wrap}
114
116
  />
115
117
  {#if editable && should_show_cell_menu([index, j], selected_cells, editable)}
116
118
  <CellMenuButton on_click={(event) => toggle_cell_menu(event, index, j)} />
@@ -43,6 +43,7 @@ declare const __propDef: {
43
43
  handle_select_column: (col: number) => void;
44
44
  handle_select_row: (row: number) => void;
45
45
  is_dragging: boolean;
46
+ wrap?: boolean | undefined;
46
47
  };
47
48
  events: {
48
49
  [evt: string]: CustomEvent<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/dataframe",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -18,12 +18,12 @@
18
18
  "katex": "^0.16.7",
19
19
  "marked": "^12.0.0",
20
20
  "@gradio/atoms": "^0.14.1",
21
- "@gradio/button": "^0.4.11",
22
21
  "@gradio/client": "^1.14.0",
23
- "@gradio/upload": "^0.15.6",
24
- "@gradio/statustracker": "^0.10.6",
22
+ "@gradio/button": "^0.4.11",
25
23
  "@gradio/markdown-code": "^0.4.2",
24
+ "@gradio/statustracker": "^0.10.6",
26
25
  "@gradio/icons": "^0.10.0",
26
+ "@gradio/upload": "^0.15.6",
27
27
  "@gradio/utils": "^0.10.1"
28
28
  },
29
29
  "exports": {
@@ -30,6 +30,7 @@
30
30
  export let components: Record<string, any> = {};
31
31
  export let i18n: I18nFormatter;
32
32
  export let is_dragging = false;
33
+ export let wrap_text = false;
33
34
 
34
35
  export let show_selection_buttons = false;
35
36
  export let coords: [number, number] | null = null;
@@ -146,6 +147,7 @@
146
147
  data-expanded={is_expanded}
147
148
  placeholder=" "
148
149
  class:text={datatype === "str"}
150
+ class:wrap={wrap_text}
149
151
  >
150
152
  {#if datatype === "image" && components.image}
151
153
  <svelte:component
@@ -213,14 +215,6 @@
213
215
  width: 100%;
214
216
  height: 100%;
215
217
  overflow: hidden;
216
- text-overflow: ellipsis;
217
- white-space: nowrap;
218
- }
219
-
220
- span.text:not(.expanded) {
221
- overflow: hidden;
222
- text-overflow: ellipsis;
223
- white-space: nowrap;
224
218
  }
225
219
 
226
220
  span.text.expanded {
@@ -260,4 +254,12 @@
260
254
  input:read-only {
261
255
  cursor: not-allowed;
262
256
  }
257
+
258
+ .wrap,
259
+ .wrap.expanded {
260
+ white-space: normal;
261
+ word-wrap: break-word;
262
+ overflow-wrap: break-word;
263
+ word-wrap: break-word;
264
+ }
263
265
  </style>
@@ -952,6 +952,7 @@
952
952
  {handle_select_row}
953
953
  bind:el={els[id]}
954
954
  {is_dragging}
955
+ {wrap}
955
956
  />
956
957
  {/each}
957
958
  </tr>
@@ -60,6 +60,7 @@
60
60
  export let handle_select_column: (col: number) => void;
61
61
  export let handle_select_row: (row: number) => void;
62
62
  export let is_dragging: boolean;
63
+ export let wrap = false;
63
64
 
64
65
  function get_cell_position(col_index: number): string {
65
66
  if (col_index >= actual_pinned_columns) {
@@ -144,6 +145,7 @@
144
145
  on_select_column={handle_select_column}
145
146
  on_select_row={handle_select_row}
146
147
  {is_dragging}
148
+ wrap_text={wrap}
147
149
  />
148
150
  {#if editable && should_show_cell_menu([index, j], selected_cells, editable)}
149
151
  <CellMenuButton on_click={(event) => toggle_cell_menu(event, index, j)} />