@gradio/code 0.2.0-beta.5 → 0.2.0-beta.6

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,52 +1,46 @@
1
1
  # @gradio/code
2
2
 
3
- ## 0.2.0-beta.5
3
+ ## 0.2.0-beta.6
4
4
 
5
5
  ### Features
6
6
 
7
- - [#5648](https://github.com/gradio-app/gradio/pull/5648) [`c573e2339`](https://github.com/gradio-app/gradio/commit/c573e2339b86c85b378dc349de5e9223a3c3b04a) - Publish all components to npm. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
7
+ - [#5960](https://github.com/gradio-app/gradio/pull/5960) [`319c30f3f`](https://github.com/gradio-app/gradio/commit/319c30f3fccf23bfe1da6c9b132a6a99d59652f7) - rererefactor frontend files. Thanks [@pngwn](https://github.com/pngwn)!
8
+ - [#5938](https://github.com/gradio-app/gradio/pull/5938) [`13ed8a485`](https://github.com/gradio-app/gradio/commit/13ed8a485d5e31d7d75af87fe8654b661edcca93) - V4: Use beta release versions for '@gradio' packages. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
8
9
 
9
- ## 0.2.0-beta.4
10
+ ## 0.2.3
10
11
 
11
12
  ### Patch Changes
12
13
 
13
- - Updated dependencies [[`0b4fd5b6d`](https://github.com/gradio-app/gradio/commit/0b4fd5b6db96fc95a155e5e935e17e1ab11d1161)]:
14
- - @gradio/utils@0.2.0-beta.3
15
- - @gradio/atoms@0.2.0-beta.3
16
- - @gradio/statustracker@0.3.0-beta.4
17
- - @gradio/upload@0.3.0-beta.3
14
+ - Updated dependencies [[`e70805d54`](https://github.com/gradio-app/gradio/commit/e70805d54cc792452545f5d8eccc1aa0212a4695)]:
15
+ - @gradio/atoms@0.2.0
16
+ - @gradio/statustracker@0.2.3
17
+ - @gradio/upload@0.3.3
18
18
 
19
- ## 0.2.0-beta.3
19
+ ## 0.2.2
20
20
 
21
21
  ### Patch Changes
22
22
 
23
- - Updated dependencies [[`14fc612d8`](https://github.com/gradio-app/gradio/commit/14fc612d84bf6b1408eccd3a40fab41f25477571)]:
24
- - @gradio/utils@0.2.0-beta.2
25
- - @gradio/atoms@0.2.0-beta.2
26
- - @gradio/statustracker@0.3.0-beta.3
27
- - @gradio/upload@0.3.0-beta.2
28
-
29
- ## 0.2.0-beta.2
30
-
31
- ### Features
32
-
33
- - [#5620](https://github.com/gradio-app/gradio/pull/5620) [`c4c25ecdf`](https://github.com/gradio-app/gradio/commit/c4c25ecdf8c2fab5e3c41b519564e3b6a9ebfce3) - fix build and broken imports. Thanks [@pngwn](https://github.com/pngwn)!
23
+ - Updated dependencies []:
24
+ - @gradio/utils@0.1.2
25
+ - @gradio/atoms@0.1.4
26
+ - @gradio/statustracker@0.2.2
27
+ - @gradio/upload@0.3.2
34
28
 
35
- ## 0.2.0-beta.1
29
+ ## 0.2.1
36
30
 
37
31
  ### Patch Changes
38
32
 
39
- - Updated dependencies []:
40
- - @gradio/utils@0.2.0-beta.1
41
- - @gradio/atoms@0.2.0-beta.1
42
- - @gradio/statustracker@0.3.0-beta.1
43
- - @gradio/upload@0.3.0-beta.1
33
+ - Updated dependencies [[`8f0fed857`](https://github.com/gradio-app/gradio/commit/8f0fed857d156830626eb48b469d54d211a582d2)]:
34
+ - @gradio/icons@0.2.0
35
+ - @gradio/atoms@0.1.3
36
+ - @gradio/statustracker@0.2.1
37
+ - @gradio/upload@0.3.1
44
38
 
45
- ## 0.2.0-beta.0
39
+ ## 0.2.0
46
40
 
47
41
  ### Features
48
42
 
49
- - [#5507](https://github.com/gradio-app/gradio/pull/5507) [`1385dc688`](https://github.com/gradio-app/gradio/commit/1385dc6881f2d8ae7a41106ec21d33e2ef04d6a9) - Custom components. Thanks [@pngwn](https://github.com/pngwn)!
43
+ - [#5554](https://github.com/gradio-app/gradio/pull/5554) [`75ddeb390`](https://github.com/gradio-app/gradio/commit/75ddeb390d665d4484667390a97442081b49a423) - Accessibility Improvements. Thanks [@hannahblair](https://github.com/hannahblair)!
50
44
 
51
45
  ## 0.1.2
52
46
 
@@ -4,7 +4,8 @@
4
4
 
5
5
  import type { LoadingStatus } from "@gradio/statustracker";
6
6
 
7
- import Code, { Widget } from "../shared";
7
+ import Code from "./shared/Code.svelte";
8
+ import Widget from "./shared/Widgets.svelte";
8
9
  import { StatusTracker } from "@gradio/statustracker";
9
10
  import { Block, BlockLabel, Empty } from "@gradio/atoms";
10
11
  import { Code as CodeIcon } from "@gradio/icons";
@@ -24,6 +25,9 @@
24
25
  export let label = gradio.i18n("code.code");
25
26
  export let show_label = true;
26
27
  export let loading_status: LoadingStatus;
28
+ export let scale: number | null = null;
29
+
30
+ export let mode: "static" | "interactive";
27
31
 
28
32
  let dark_mode = target.classList.contains("dark");
29
33
 
@@ -39,7 +43,14 @@
39
43
  $: value, handle_change();
40
44
  </script>
41
45
 
42
- <Block variant={"solid"} padding={false} {elem_id} {elem_classes} {visible}>
46
+ <Block
47
+ variant={"solid"}
48
+ padding={false}
49
+ {elem_id}
50
+ {elem_classes}
51
+ {visible}
52
+ {scale}
53
+ >
43
54
  <StatusTracker
44
55
  autoscroll={gradio.autoscroll}
45
56
  i18n={gradio.i18n}
@@ -55,6 +66,12 @@
55
66
  {:else}
56
67
  <Widget {language} {value} />
57
68
 
58
- <Code bind:value {language} {lines} {dark_mode} readonly />
69
+ <Code
70
+ bind:value
71
+ {language}
72
+ {lines}
73
+ {dark_mode}
74
+ readonly={mode === "static"}
75
+ />
59
76
  {/if}
60
77
  </Block>
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@gradio/code",
3
- "version": "0.2.0-beta.5",
3
+ "version": "0.2.0-beta.6",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
- "main": "./index.svelte",
7
6
  "author": "",
8
7
  "license": "ISC",
9
8
  "private": false,
@@ -28,17 +27,16 @@
28
27
  "cm6-theme-basic-dark": "^0.2.0",
29
28
  "cm6-theme-basic-light": "^0.2.0",
30
29
  "codemirror": "^6.0.1",
31
- "@gradio/atoms": "^0.2.0-beta.3",
32
- "@gradio/icons": "^0.2.0-beta.0",
33
- "@gradio/statustracker": "^0.3.0-beta.5",
34
- "@gradio/upload": "^0.3.0-beta.3",
35
- "@gradio/utils": "^0.2.0-beta.3"
30
+ "@gradio/atoms": "^0.2.0-beta.4",
31
+ "@gradio/icons": "^0.2.0-beta.1",
32
+ "@gradio/statustracker": "^0.3.0-beta.6",
33
+ "@gradio/upload": "^0.3.0-beta.4",
34
+ "@gradio/utils": "^0.2.0-beta.4"
36
35
  },
37
36
  "main_changeset": true,
38
37
  "exports": {
39
- "./package.json": "./package.json",
40
- "./interactive": "./interactive/index.ts",
41
- "./static": "./static/index.ts",
42
- "./example": "./example/index.ts"
38
+ ".": "./Index.svelte",
39
+ "./example": "./Example.svelte",
40
+ "./package.json": "./package.json"
43
41
  }
44
42
  }
@@ -4,7 +4,7 @@
4
4
  import {
5
5
  EditorView,
6
6
  keymap,
7
- placeholder as placeholderExt
7
+ placeholder as placeholderExt,
8
8
  } from "@codemirror/view";
9
9
  import { StateEffect, EditorState, type Extension } from "@codemirror/state";
10
10
  import { indentWithTab } from "@codemirror/commands";
@@ -42,7 +42,7 @@
42
42
 
43
43
  $: reconfigure(), lang_extension;
44
44
  $: setDoc(value);
45
- $: updateLines(lines);
45
+ $: updateLines();
46
46
 
47
47
  function setDoc(newDoc: string): void {
48
48
  if (view && newDoc !== view.state.doc.toString()) {
@@ -50,13 +50,13 @@
50
50
  changes: {
51
51
  from: 0,
52
52
  to: view.state.doc.length,
53
- insert: newDoc
54
- }
53
+ insert: newDoc,
54
+ },
55
55
  });
56
56
  }
57
57
  }
58
58
 
59
- function updateLines(newLines: number): void {
59
+ function updateLines(): void {
60
60
  if (view) {
61
61
  view.requestMeasure({ read: updateGutters });
62
62
  }
@@ -65,7 +65,7 @@
65
65
  function createEditorView(): EditorView {
66
66
  return new EditorView({
67
67
  parent: element,
68
- state: createEditorState(value)
68
+ state: createEditorState(value),
69
69
  });
70
70
  }
71
71
 
@@ -119,7 +119,7 @@
119
119
  ),
120
120
  FontTheme,
121
121
  ...getTheme(),
122
- ...extensions
122
+ ...extensions,
123
123
  ];
124
124
  return stateExtensions;
125
125
  }
@@ -127,36 +127,36 @@
127
127
  const FontTheme = EditorView.theme({
128
128
  "&": {
129
129
  fontSize: "var(--text-sm)",
130
- backgroundColor: "var(--border-color-secondary)"
130
+ backgroundColor: "var(--border-color-secondary)",
131
131
  },
132
132
  ".cm-content": {
133
133
  paddingTop: "5px",
134
134
  paddingBottom: "5px",
135
135
  color: "var(--body-text-color)",
136
136
  fontFamily: "var(--font-mono)",
137
- minHeight: "100%"
137
+ minHeight: "100%",
138
138
  },
139
139
  ".cm-gutters": {
140
140
  marginRight: "1px",
141
141
  borderRight: "1px solid var(--border-color-primary)",
142
142
  backgroundColor: "transparent",
143
- color: "var(--body-text-color-subdued)"
143
+ color: "var(--body-text-color-subdued)",
144
144
  },
145
145
  ".cm-focused": {
146
- outline: "none"
146
+ outline: "none",
147
147
  },
148
148
  ".cm-scroller": {
149
- height: "auto"
149
+ height: "auto",
150
150
  },
151
151
  ".cm-cursor": {
152
- borderLeftColor: "var(--body-text-color)"
153
- }
152
+ borderLeftColor: "var(--body-text-color)",
153
+ },
154
154
  });
155
155
 
156
156
  function createEditorState(_value: string | null | undefined): EditorState {
157
157
  return EditorState.create({
158
158
  doc: _value ?? undefined,
159
- extensions: getExtensions()
159
+ extensions: getExtensions(),
160
160
  });
161
161
  }
162
162
 
@@ -169,7 +169,8 @@
169
169
  ): Extension[] {
170
170
  const extensions: Extension[] = [
171
171
  EditorView.editable.of(!readonly),
172
- EditorState.readOnly.of(readonly)
172
+ EditorState.readOnly.of(readonly),
173
+ EditorView.contentAttributes.of({ "aria-label": "Code input container" }),
173
174
  ];
174
175
 
175
176
  if (basic) {
@@ -202,7 +203,7 @@
202
203
 
203
204
  function reconfigure(): void {
204
205
  view?.dispatch({
205
- effects: StateEffect.reconfigure.of(getExtensions())
206
+ effects: StateEffect.reconfigure.of(getExtensions()),
206
207
  });
207
208
  }
208
209
 
@@ -27,12 +27,21 @@
27
27
  });
28
28
  </script>
29
29
 
30
- <button on:click={handle_copy} title="copy">
31
- <!-- {#if !copied} -->
32
- <span class="copy-text" class:copied><Copy /> </span>
33
- <!-- {/if} -->
30
+ <button
31
+ on:click={handle_copy}
32
+ title="copy"
33
+ class:copied
34
+ aria-roledescription="Copy value"
35
+ aria-label="Copy"
36
+ >
37
+ <Copy />
34
38
  {#if copied}
35
- <span class="check" transition:fade><Check /></span>
39
+ <span
40
+ class="check"
41
+ transition:fade
42
+ aria-roledescription="Value copied"
43
+ aria-label="Copied"><Check /></span
44
+ >
36
45
  {/if}
37
46
  </button>
38
47
 
package/example/index.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from "./Code.svelte";
@@ -1,52 +0,0 @@
1
- <script lang="ts">
2
- import type { Gradio } from "@gradio/utils";
3
- import { afterUpdate } from "svelte";
4
-
5
- import type { LoadingStatus } from "@gradio/statustracker";
6
-
7
- import Code from "../shared";
8
- import { StatusTracker } from "@gradio/statustracker";
9
- import { Block, BlockLabel } from "@gradio/atoms";
10
- import { Code as CodeIcon } from "@gradio/icons";
11
-
12
- export let gradio: Gradio<{
13
- change: typeof value;
14
- input: never;
15
- }>;
16
- export let value = "";
17
- export let value_is_output = false;
18
- export let language = "";
19
- export let lines = 5;
20
- export let target: HTMLElement;
21
- export let elem_id = "";
22
- export let elem_classes: string[] = [];
23
- export let visible = true;
24
- export let label = gradio.i18n("code.code");
25
- export let show_label = true;
26
- export let loading_status: LoadingStatus;
27
-
28
- let dark_mode = target.classList.contains("dark");
29
-
30
- function handle_change(): void {
31
- gradio.dispatch("change", value);
32
- if (!value_is_output) {
33
- gradio.dispatch("input");
34
- }
35
- }
36
- afterUpdate(() => {
37
- value_is_output = false;
38
- });
39
- $: value, handle_change();
40
- </script>
41
-
42
- <Block variant={"solid"} padding={false} {elem_id} {elem_classes} {visible}>
43
- <StatusTracker
44
- autoscroll={gradio.autoscroll}
45
- i18n={gradio.i18n}
46
- {...loading_status}
47
- />
48
-
49
- <BlockLabel Icon={CodeIcon} {show_label} {label} float={false} />
50
-
51
- <Code bind:value {language} {lines} {dark_mode} />
52
- </Block>
@@ -1 +0,0 @@
1
- export { default } from "./InteractiveCode.svelte";
package/shared/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { default } from "./Code.svelte";
2
- export { default as Widget } from "./Widgets.svelte";
package/static/index.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from "./StaticCode.svelte";
File without changes