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

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,18 @@
1
1
  # @gradio/code
2
2
 
3
+ ## 0.2.0-beta.8
4
+
5
+ ### Features
6
+
7
+ - [#6136](https://github.com/gradio-app/gradio/pull/6136) [`667802a6c`](https://github.com/gradio-app/gradio/commit/667802a6cdbfb2ce454a3be5a78e0990b194548a) - JS Component Documentation. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
8
+ - [#6149](https://github.com/gradio-app/gradio/pull/6149) [`90318b1dd`](https://github.com/gradio-app/gradio/commit/90318b1dd118ae08a695a50e7c556226234ab6dc) - swap `mode` on the frontned to `interactive` to match the backend. Thanks [@pngwn](https://github.com/pngwn)!
9
+
10
+ ## 0.2.0-beta.7
11
+
12
+ ### Features
13
+
14
+ - [#6016](https://github.com/gradio-app/gradio/pull/6016) [`83e947676`](https://github.com/gradio-app/gradio/commit/83e947676d327ca2ab6ae2a2d710c78961c771a0) - Format js in v4 branch. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
15
+
3
16
  ## 0.2.0-beta.6
4
17
 
5
18
  ### Features
package/Index.svelte CHANGED
@@ -1,3 +1,11 @@
1
+ <script context="module" lang="ts">
2
+ export { default as BaseCode } from "./shared/Code.svelte";
3
+ export { default as BaseCopy } from "./shared/Copy.svelte";
4
+ export { default as BaseDownload } from "./shared/Download.svelte";
5
+ export { default as BaseWidget } from "./shared/Widgets.svelte";
6
+ export { default as BaseExample } from "./Example.svelte";
7
+ </script>
8
+
1
9
  <script lang="ts">
2
10
  import type { Gradio } from "@gradio/utils";
3
11
  import { afterUpdate } from "svelte";
@@ -27,7 +35,7 @@
27
35
  export let loading_status: LoadingStatus;
28
36
  export let scale: number | null = null;
29
37
 
30
- export let mode: "static" | "interactive";
38
+ export let interactive: boolean;
31
39
 
32
40
  let dark_mode = target.classList.contains("dark");
33
41
 
@@ -59,19 +67,13 @@
59
67
 
60
68
  <BlockLabel Icon={CodeIcon} {show_label} {label} float={false} />
61
69
 
62
- {#if !value}
70
+ {#if !value && !interactive}
63
71
  <Empty unpadded_box={true} size="large">
64
72
  <CodeIcon />
65
73
  </Empty>
66
74
  {:else}
67
75
  <Widget {language} {value} />
68
76
 
69
- <Code
70
- bind:value
71
- {language}
72
- {lines}
73
- {dark_mode}
74
- readonly={mode === "static"}
75
- />
77
+ <Code bind:value {language} {lines} {dark_mode} readonly={!interactive} />
76
78
  {/if}
77
79
  </Block>
package/README.md CHANGED
@@ -1 +1,48 @@
1
1
  # `@gradio/code`
2
+
3
+ ```html
4
+ <script>
5
+ import { BaseCode, BaseCopy, BaseDownload, BaseWidget, BaseExample} from "gradio/code";
6
+ </script>
7
+ ```
8
+
9
+ BaseCode
10
+ ```javascript
11
+ export let classNames = "";
12
+ export let value = "";
13
+ export let dark_mode: boolean;
14
+
15
+ export let basic = true;
16
+ export let language: string;
17
+ export let lines = 5;
18
+ export let extensions: Extension[] = [];
19
+
20
+ export let useTab = true;
21
+
22
+ export let readonly = false;
23
+ export let placeholder: string | HTMLElement | null | undefined = undefined;
24
+ ```
25
+
26
+ BaseCopy
27
+ ```javascript
28
+ export let value: string;
29
+ ```
30
+
31
+ BaseDownload
32
+ ```javascript
33
+ export let value: string;
34
+ export let language: string;
35
+ ```
36
+
37
+ BaseWidget
38
+ ```javascript
39
+ export let value: string;
40
+ export let language: string;
41
+ ```
42
+
43
+ BaseExample
44
+ ```
45
+ export let value: string;
46
+ export let type: "gallery" | "table";
47
+ export let selected = false;
48
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/code",
3
- "version": "0.2.0-beta.6",
3
+ "version": "0.2.0-beta.8",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -27,13 +27,14 @@
27
27
  "cm6-theme-basic-dark": "^0.2.0",
28
28
  "cm6-theme-basic-light": "^0.2.0",
29
29
  "codemirror": "^6.0.1",
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"
30
+ "@gradio/atoms": "^0.2.0-beta.6",
31
+ "@gradio/icons": "^0.2.0-beta.3",
32
+ "@gradio/statustracker": "^0.3.0-beta.8",
33
+ "@gradio/upload": "^0.3.0-beta.6",
34
+ "@gradio/utils": "^0.2.0-beta.6"
35
35
  },
36
36
  "main_changeset": true,
37
+ "main": "./Index.svelte",
37
38
  "exports": {
38
39
  ".": "./Index.svelte",
39
40
  "./example": "./Example.svelte",
@@ -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";
@@ -50,8 +50,8 @@
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
  }
@@ -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
 
@@ -170,7 +170,7 @@
170
170
  const extensions: Extension[] = [
171
171
  EditorView.editable.of(!readonly),
172
172
  EditorState.readOnly.of(readonly),
173
- EditorView.contentAttributes.of({ "aria-label": "Code input container" }),
173
+ EditorView.contentAttributes.of({ "aria-label": "Code input container" })
174
174
  ];
175
175
 
176
176
  if (basic) {
@@ -203,7 +203,7 @@
203
203
 
204
204
  function reconfigure(): void {
205
205
  view?.dispatch({
206
- effects: StateEffect.reconfigure.of(getExtensions()),
206
+ effects: StateEffect.reconfigure.of(getExtensions())
207
207
  });
208
208
  }
209
209