@gradio/code 0.2.3 → 0.2.4

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/code
2
2
 
3
+ ## 0.2.4
4
+
5
+ ### Fixes
6
+
7
+ - [#6323](https://github.com/gradio-app/gradio/pull/6323) [`55fda81fa`](https://github.com/gradio-app/gradio/commit/55fda81fa5918b48952729232d6e2fc55af9351d) - Textbox and Code Component Blur/Focus Fixes. Thanks [@dawoodkhan82](https://github.com/dawoodkhan82)!
8
+
3
9
  ## 0.2.3
4
10
 
5
11
  ### Patch Changes
@@ -145,4 +151,4 @@ Thanks [@pngwn](https://github.com/pngwn)!
145
151
 
146
152
  - Updated dependencies []:
147
153
  - @gradio/atoms@0.0.2
148
- - @gradio/upload@0.0.2
154
+ - @gradio/upload@0.0.2
package/Index.svelte CHANGED
@@ -21,6 +21,8 @@
21
21
  export let gradio: Gradio<{
22
22
  change: typeof value;
23
23
  input: never;
24
+ blur: never;
25
+ focus: never;
24
26
  }>;
25
27
  export let value = "";
26
28
  export let value_is_output = false;
@@ -74,6 +76,14 @@
74
76
  {:else}
75
77
  <Widget {language} {value} />
76
78
 
77
- <Code bind:value {language} {lines} {dark_mode} readonly={!interactive} />
79
+ <Code
80
+ bind:value
81
+ {language}
82
+ {lines}
83
+ {dark_mode}
84
+ readonly={!interactive}
85
+ on:blur={() => gradio.dispatch("blur")}
86
+ on:focus={() => gradio.dispatch("focus")}
87
+ />
78
88
  {/if}
79
89
  </Block>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/code",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -30,7 +30,7 @@
30
30
  "@gradio/atoms": "^0.2.1",
31
31
  "@gradio/icons": "^0.2.0",
32
32
  "@gradio/statustracker": "^0.3.1",
33
- "@gradio/upload": "^0.3.3",
33
+ "@gradio/upload": "^0.4.0",
34
34
  "@gradio/utils": "^0.2.0"
35
35
  },
36
36
  "main_changeset": true,
@@ -28,7 +28,11 @@
28
28
  export let readonly = false;
29
29
  export let placeholder: string | HTMLElement | null | undefined = undefined;
30
30
 
31
- const dispatch = createEventDispatcher<{ change: string }>();
31
+ const dispatch = createEventDispatcher<{
32
+ change: string;
33
+ blur: undefined;
34
+ focus: undefined;
35
+ }>();
32
36
  let lang_extension: Extension | undefined;
33
37
  let element: HTMLDivElement;
34
38
  let view: EditorView;
@@ -63,10 +67,21 @@
63
67
  }
64
68
 
65
69
  function createEditorView(): EditorView {
66
- return new EditorView({
70
+ const editorView = new EditorView({
67
71
  parent: element,
68
72
  state: createEditorState(value)
69
73
  });
74
+ editorView.dom.addEventListener("focus", handleFocus, true);
75
+ editorView.dom.addEventListener("blur", handleBlur, true);
76
+ return editorView;
77
+ }
78
+
79
+ function handleFocus(): void {
80
+ dispatch("focus");
81
+ }
82
+
83
+ function handleBlur(): void {
84
+ dispatch("blur");
70
85
  }
71
86
 
72
87
  function getGutterLineHeight(_view: EditorView): string | null {