Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr.Number() max/min limit #3991

Merged
merged 177 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from 165 commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
b7c27e4
Add min max handling for Number (#3871)
artegoser Apr 27, 2023
674f9bd
number limit
dawoodkhan82 Apr 27, 2023
c2f4a5d
Merge branch 'main' into number-limit
dawoodkhan82 Apr 27, 2023
0b894e4
Merge branch 'main' into number-limit
abidlabs Apr 27, 2023
d1ac15a
Update gradio/components.py
dawoodkhan82 Apr 27, 2023
894bf12
Merge branch 'main' into number-limit
abidlabs Apr 29, 2023
68e2c23
New Version Docs (#4027)
github-actions[bot] May 1, 2023
11503f6
Safer `HuggingFaceDatasetSaver` (and deprecate `HuggingFaceDatasetJso…
Wauplin May 1, 2023
e7ae9da
merge
dawoodkhan82 Jun 2, 2023
7934de8
Allow state to be rendered multiple times (#4030)
abidlabs May 1, 2023
aca91b5
Allow decoding b64 string without header in processing utils (#4031)
1lint May 1, 2023
92c95b6
Sets matplotlib backend to agg before rendering math (#4029)
abidlabs May 2, 2023
e090021
Upgrade pyright to 1.1.305 (#4042)
akx May 2, 2023
4808b18
Fastapi Python Client Guide (#3892)
abidlabs May 2, 2023
306ada4
fix overflowing gutter and dark mode base color (#4051)
pngwn May 3, 2023
3538183
Add ability to blocklist filepaths, ability to specify where gradio t…
abidlabs May 3, 2023
b89061b
Chatbot code syntax highlighting (#4048)
dawoodkhan82 May 4, 2023
f8d915f
Fixes issue with indentation in code field with streaming (#4043)
dawoodkhan82 May 4, 2023
beeb426
[create-pull-request] automated change (#4059)
github-actions[bot] May 4, 2023
b9249f5
changelog (#4064)
abidlabs May 4, 2023
7674a87
New Version Docs (#4069)
github-actions[bot] May 4, 2023
0a8e114
Soft theme fix (#4070)
aliabid94 May 4, 2023
298dce9
Empty gallery fix (#4072)
aliabid94 May 5, 2023
2196e3c
Fix bug where functions with type hints caused errors (#4068)
freddyaboulton May 5, 2023
d3aef21
More Ruff rules (#4038)
akx May 5, 2023
c493933
[WIP] Language Agnostic Typing in `/info` route (#4039)
freddyaboulton May 6, 2023
392c727
Keep hidden Accordion content in DOM (#4073)
aliabid94 May 6, 2023
b668149
Theme builder fixes (#4080)
abidlabs May 6, 2023
2f20e0e
Misc file and docs fixes (#4086)
abidlabs May 7, 2023
a211038
Removing "State" from view API info (#4107)
abidlabs May 8, 2023
cf53a81
Dont send request to `/info` if version before 3.28.3 (#4109)
freddyaboulton May 8, 2023
7546a4e
Upload audio ios (#4071)
aliabid94 May 9, 2023
32c37e2
Allow textbox / number submits to trigger Interface submit (#4090)
aliabid94 May 9, 2023
6197a5d
Fix slider released event not triggering when released on mobile (#4098)
space-nuko May 9, 2023
6004152
Fix then logic to work after failures (#4115)
aliabid94 May 9, 2023
25443f8
Fixes to view API page (#4112)
abidlabs May 9, 2023
2864969
Add support for async generators (#3821)
freddyaboulton May 9, 2023
ff579f8
release (#4116)
abidlabs May 9, 2023
8439608
Bumpt client version (#4125)
freddyaboulton May 9, 2023
adbd546
New Version Docs (#4131)
github-actions[bot] May 9, 2023
1c4a8b6
Fix create version docs action (#4130)
aliabd May 9, 2023
287a210
Fix dev docs (#4132)
whitphx May 9, 2023
01491ca
changelog (#4136)
abidlabs May 10, 2023
18713a2
Fix website build issue (#4142)
aliabd May 10, 2023
6f3ad4a
Fix python client test (#4138)
freddyaboulton May 10, 2023
a839912
Fix isssue with running with nginx (#4133)
abidlabs May 10, 2023
a17d286
Record username when flagging (#4135)
abidlabs May 10, 2023
3de2ba3
Fix api info for File component (#4153)
freddyaboulton May 10, 2023
395a63f
Update .prettierignore adding client/js/dist and .venv (#4160)
whitphx May 11, 2023
104f097
Fix the prettier.ignorePath field in the VSCode workspace settings (#…
whitphx May 11, 2023
1e009cb
simplify format of changelog (#4163)
abidlabs May 11, 2023
30e96e1
Fix the wildcard in .editorconfig to match files in nested directorie…
whitphx May 11, 2023
43de84a
Fix flaky interface test (#4168)
freddyaboulton May 11, 2023
d203a8c
Adds missing components to gradio client serializing's component mapp…
abidlabs May 11, 2023
0d312bc
Release 3.30 (#4166)
abidlabs May 11, 2023
37bd6a9
[Docs] Resolve numerous typos (#4170)
tomaarsen May 11, 2023
a324174
New Version Docs (#4172)
github-actions[bot] May 11, 2023
0ae70fd
Dispatch dropdown change on value change for any reason (#4128)
aliabid94 May 11, 2023
6b2e737
hotfix for test (#4173)
abidlabs May 11, 2023
4f3d355
3712 js client (#3899)
pngwn May 12, 2023
677b5a8
update ci (#4184)
pngwn May 12, 2023
2e8c19c
bump client version (#4185)
pngwn May 12, 2023
3a3e4d6
Fix (#4186)
pngwn May 12, 2023
db795b8
update token for npm action (#4187)
pngwn May 12, 2023
d2e028a
change (#4189)
pngwn May 12, 2023
1a6fd1c
ci typo (#4190)
pngwn May 12, 2023
78ff6a6
Fix npm publish again again (#4191)
pngwn May 12, 2023
65c1348
Fix npm publish again again (#4192)
pngwn May 12, 2023
b9bb8a1
Fix npm publish again again (#4193)
pngwn May 12, 2023
356cc12
Add format argument to Audio (#4178)
freddyaboulton May 12, 2023
399f5fc
chore: update versions (#4188)
pngwn May 12, 2023
41f63f8
Fix npm publish again again (#4195)
pngwn May 12, 2023
fefec18
client docs tweaks (#4196)
pngwn May 12, 2023
4cce88d
Fix "TypeError: issubclass() arg 1 must be a class" When Optional arg…
lingfengchencn May 13, 2023
03d36cb
Fix semiver import (#4201)
pngwn May 14, 2023
9eb9967
fix token (#4208)
pngwn May 14, 2023
81dbc76
Fix Explanation Regarding NumPy Image Component (#4204)
der3318 May 15, 2023
1c57e36
Correct stacklevel for check_deprecated_parameters (#4203)
akx May 15, 2023
4d034a7
Programmatically launch reload to allow factories and arguments to be…
micky2be May 15, 2023
10977c0
Update CONTRIBUTING.md (#4220)
whitphx May 15, 2023
b45da2d
Input listener (#4157)
aliabid94 May 16, 2023
c095cf7
Do not do any analytics requests if analytics are disabled (#4194)
akx May 16, 2023
858f202
Increase websocket messaging timeout (#4235)
abidlabs May 16, 2023
d08906e
Fix for `typing.get_type_hints()` on Python 3.9 or lower (#4228)
abidlabs May 16, 2023
a0c2eb8
Some tweaks to the Client (#4230)
abidlabs May 16, 2023
8db9ded
Only allow messaging update if analytics is enabled (#4236)
akx May 16, 2023
16197c2
Fix client filepaths (#4202)
pngwn May 16, 2023
e73f793
fix cancels (#4225)
pngwn May 16, 2023
b4f1afc
chore: update versions (#4207)
pngwn May 16, 2023
81a3701
Fix publish (#4240)
pngwn May 16, 2023
93847dd
release (#4219)
abidlabs May 16, 2023
3d27c82
Fixes chatbot_dialogpt demo (#4238)
dawoodkhan82 May 17, 2023
08cb8c4
Fix JSONDecodeError (#4241)
davidai May 17, 2023
8cf13c7
make workbench private (#4247)
pngwn May 17, 2023
e754f16
Refactoring (#4223)
whitphx May 17, 2023
ade9b72
Move mount_css() from main.ts to css.ts (#4222)
whitphx May 17, 2023
223eac4
[create-pull-request] automated change (#4250)
github-actions[bot] May 17, 2023
b7cfbbd
Fix run on click (#4258)
abidlabs May 17, 2023
723bf12
Upgrade black to 23.3 (#4259)
akx May 18, 2023
ac8e2d9
Using marked for chatbot markdown parsing (#4150)
dawoodkhan82 May 18, 2023
65bc3ac
fix info request in js client (#4271)
pngwn May 19, 2023
f71f4a3
Temp file fixes (#4256)
freddyaboulton May 19, 2023
1d5a3de
Ensure error modal display as expected when using the queue (#4273)
pngwn May 19, 2023
bdac032
Allow passing FastAPI app options (#4282)
akx May 20, 2023
e8cd163
Katex support in chatbot (#4285)
dawoodkhan82 May 21, 2023
2bbc86e
Release 3.32.0 (#4293)
abidlabs May 21, 2023
38851af
New Version Docs (#4296)
github-actions[bot] May 22, 2023
e106ddd
Add overridden type annotations on `normalise_file()` to remove @ts-i…
whitphx May 29, 2023
aec21de
typo (minor): extra newline puts the documentation of colums to grid …
thiswillbeyourgithub May 29, 2023
944ac1f
return a Dependency instance from Blocks.load event listener (#4304)
anentropic May 29, 2023
473fc71
Fix typo in client/js/README.md (#4310)
whitphx May 29, 2023
6103e6d
chore: update versions (#4283)
pngwn May 29, 2023
9a053b2
Optimize frontend's is_dep calls (#4334)
akx May 30, 2023
665c427
various client refactors + tweaks (#4357)
pngwn May 30, 2023
ffc92d9
Remove a bunch of unused frontend code (#4275)
akx May 30, 2023
f408492
Respect `interactive=True` in output of `gr.Interface` (#4356)
abidlabs May 30, 2023
69c4fde
Don't allow dotfiles for /file= route (#4303)
akx May 30, 2023
0b14929
Push to spaces (#4033)
aliabid94 May 31, 2023
ba45887
Do not send HF token to other domains via `/proxy` (#4368)
abidlabs May 31, 2023
b61fe39
Make chatbot input fields non-interactive while bot is streaming (#4363)
freddyaboulton May 31, 2023
4907fee
Prevent path traversal in `/file` routes (#4370)
abidlabs Jun 1, 2023
74eeeb0
Favicon fix for Windows (#4369)
abidlabs Jun 1, 2023
87da6dc
Add pypi classifiers to pyproject.toml (#4383)
WilliamRoyNelson Jun 1, 2023
6bb71cd
Use DOMPurify to sanitize html in chatbot (#4360)
dawoodkhan82 Jun 1, 2023
b909456
fix copy button invalid & copy button (invisible) duplication bug in …
binary-husky Jun 1, 2023
bc1213e
release 3.33.0 (#4392)
abidlabs Jun 1, 2023
5b79622
Restore offline support (#4398)
aliabid94 Jun 1, 2023
fdac023
New Version Docs (#4397)
github-actions[bot] Jun 1, 2023
57a764c
Fix Base parent in Docs, add Group (#4391)
aliabd Jun 1, 2023
1fe0fa8
Remove old versioned docs and fix repo classification (#4362)
aliabd Jun 2, 2023
e68dbaf
Update message when share link binary is blocked (#4380)
abidlabs Jun 2, 2023
5e9a6da
Update utils.py for validate_url (#4388)
alvindaiyan Jun 2, 2023
3a6876d
v3.33.1 + Guide on setting up Gradio behind nginx... (#4379)
abidlabs Jun 2, 2023
babd443
Prevent label change event from triggering itself (#4371)
freddyaboulton Jun 2, 2023
338e282
Fix the Node and pnpm setup actions (#4394)
whitphx Jun 2, 2023
fe17093
Run `pnpm i` with [email protected] to re-generate the lock file (#4393)
whitphx Jun 2, 2023
f55ddf6
fix indent (#4404)
aliabd Jun 2, 2023
40cc953
Throttle scroll event (#4158)
shavit Jun 2, 2023
709cb6f
merge
dawoodkhan82 Jun 2, 2023
10c1bd2
merge
dawoodkhan82 Jun 2, 2023
ac35e8f
fixes
dawoodkhan82 Jun 2, 2023
20416f2
changes
dawoodkhan82 Jun 3, 2023
fee0bd9
more changes
dawoodkhan82 Jun 3, 2023
b6a1393
notebook
dawoodkhan82 Jun 3, 2023
b92d4af
Merge branch 'main' into number-limit
dawoodkhan82 Jun 3, 2023
d1ac4c5
Merge branch 'main' into number-limit
abidlabs Jun 5, 2023
10a2f56
merge
dawoodkhan82 Jun 6, 2023
060a7d3
changelog
dawoodkhan82 Jun 6, 2023
b998aaa
error handle backend
dawoodkhan82 Jun 6, 2023
6934c53
Merge branch 'main' into number-limit
abidlabs Jun 6, 2023
f80264e
Update gradio/components.py
dawoodkhan82 Jun 6, 2023
e3b1d60
Update gradio/components.py
dawoodkhan82 Jun 6, 2023
8b78933
Adds `variant` and `interactive` props to `gr.UploadButton` (#4436)
abidlabs Jun 6, 2023
78a227e
fix get_continuous_fn bug when having every (#4434)
dkjshk Jun 6, 2023
3b9139a
Fix Safari video playback (#4433)
aliabid94 Jun 6, 2023
a7840b2
merge
dawoodkhan82 Jun 6, 2023
1124efa
test fix
dawoodkhan82 Jun 6, 2023
a65515e
test
dawoodkhan82 Jun 6, 2023
04e2708
tests
dawoodkhan82 Jun 7, 2023
6e10ad6
fix ui test
dawoodkhan82 Jun 7, 2023
24d8912
Merge branch 'main' into number-limit
dawoodkhan82 Jun 7, 2023
66786b0
format
dawoodkhan82 Jun 7, 2023
ec1789e
Increase version gradio-client version/changelog (#4441)
WilliamRoyNelson Jun 7, 2023
5ad85c5
Merge branch 'main' into number-limit
dawoodkhan82 Jun 7, 2023
eed9739
Merge branch 'main' into number-limit
abidlabs Jun 7, 2023
cb7e62a
merge
dawoodkhan82 Jun 8, 2023
1778ab1
fixes
dawoodkhan82 Jun 8, 2023
2bf5d00
notebook
dawoodkhan82 Jun 8, 2023
223213b
fixed tests finally
dawoodkhan82 Jun 8, 2023
ae6a18c
format
dawoodkhan82 Jun 8, 2023
b793995
Merge branch 'main' into number-limit
dawoodkhan82 Jun 8, 2023
3721d69
python test fix
dawoodkhan82 Jun 8, 2023
48e5302
test fix
dawoodkhan82 Jun 8, 2023
b424878
remove style from test
dawoodkhan82 Jun 9, 2023
f3b73cc
Merge branch 'main' into number-limit
dawoodkhan82 Jun 9, 2023
d59d57d
Update CHANGELOG.md
dawoodkhan82 Jun 9, 2023
9629445
theme test fix
dawoodkhan82 Jun 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## New Features:

- Min and max value for gr.Number by [@artegoser](https://github.com/artegoser) and [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3991](https://github.com/gradio-app/gradio/pull/3991)
- The `gr.UploadButton` component now supports the `variant` and `interactive` parameters by [@abidlabs](https://github.com/abidlabs) in [PR 4436](https://github.com/gradio-app/gradio/pull/4436).

## Bug Fixes:
Expand Down
2 changes: 1 addition & 1 deletion demo/blocks_form/run.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_form"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "with gr.Blocks() as demo:\n", " error_box = gr.Textbox(label=\"Error\", visible=False)\n", "\n", " name_box = gr.Textbox(label=\"Name\")\n", " age_box = gr.Number(label=\"Age\")\n", " symptoms_box = gr.CheckboxGroup([\"Cough\", \"Fever\", \"Runny Nose\"])\n", " submit_btn = gr.Button(\"Submit\")\n", "\n", " with gr.Column(visible=False) as output_col:\n", " diagnosis_box = gr.Textbox(label=\"Diagnosis\")\n", " patient_summary_box = gr.Textbox(label=\"Patient Summary\")\n", "\n", " def submit(name, age, symptoms):\n", " if len(name) == 0:\n", " return {error_box: gr.update(value=\"Enter name\", visible=True)}\n", " if age < 0 or age > 200:\n", " return {error_box: gr.update(value=\"Enter valid age\", visible=True)}\n", " return {\n", " output_col: gr.update(visible=True),\n", " diagnosis_box: \"covid\" if \"Cough\" in symptoms else \"flu\",\n", " patient_summary_box: f\"{name}, {age} y/o\"\n", " }\n", "\n", " submit_btn.click(\n", " submit,\n", " [name_box, age_box, symptoms_box],\n", " [error_box, diagnosis_box, patient_summary_box, output_col],\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_form"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "with gr.Blocks() as demo:\n", " error_box = gr.Textbox(label=\"Error\", visible=False)\n", "\n", " name_box = gr.Textbox(label=\"Name\")\n", " age_box = gr.Number(label=\"Age\", min=0, max=100)\n", " symptoms_box = gr.CheckboxGroup([\"Cough\", \"Fever\", \"Runny Nose\"])\n", " submit_btn = gr.Button(\"Submit\")\n", "\n", " with gr.Column(visible=False) as output_col:\n", " diagnosis_box = gr.Textbox(label=\"Diagnosis\")\n", " patient_summary_box = gr.Textbox(label=\"Patient Summary\")\n", "\n", " def submit(name, age, symptoms):\n", " if len(name) == 0:\n", " return {error_box: gr.update(value=\"Enter name\", visible=True)}\n", " return {\n", " output_col: gr.update(visible=True),\n", " diagnosis_box: \"covid\" if \"Cough\" in symptoms else \"flu\",\n", " patient_summary_box: f\"{name}, {age} y/o\",\n", " }\n", "\n", " submit_btn.click(\n", " submit,\n", " [name_box, age_box, symptoms_box],\n", " [error_box, diagnosis_box, patient_summary_box, output_col],\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
8 changes: 3 additions & 5 deletions demo/blocks_form/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
error_box = gr.Textbox(label="Error", visible=False)

name_box = gr.Textbox(label="Name")
age_box = gr.Number(label="Age")
age_box = gr.Number(label="Age", min=0, max=100)
symptoms_box = gr.CheckboxGroup(["Cough", "Fever", "Runny Nose"])
submit_btn = gr.Button("Submit")

Expand All @@ -15,12 +15,10 @@
def submit(name, age, symptoms):
if len(name) == 0:
return {error_box: gr.update(value="Enter name", visible=True)}
if age < 0 or age > 200:
return {error_box: gr.update(value="Enter valid age", visible=True)}
return {
output_col: gr.update(visible=True),
diagnosis_box: "covid" if "Cough" in symptoms else "flu",
patient_summary_box: f"{name}, {age} y/o"
patient_summary_box: f"{name}, {age} y/o",
}

submit_btn.click(
Expand All @@ -30,4 +28,4 @@ def submit(name, age, symptoms):
)

if __name__ == "__main__":
demo.launch()
demo.launch()
18 changes: 18 additions & 0 deletions gradio/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
)
from gradio.interpretation import NeighborInterpretable, TokenInterpretable
from gradio.layouts import Column, Form, Row
from gradio.exceptions import Error

if TYPE_CHECKING:
from typing import TypedDict
Expand Down Expand Up @@ -656,6 +657,8 @@ def __init__(
elem_id: str | None = None,
elem_classes: list[str] | str | None = None,
precision: int | None = None,
min: float | int = float("-inf"),
max: float | int = float("inf"),
**kwargs,
):
"""
Expand All @@ -670,8 +673,13 @@ def __init__(
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
precision: Precision to round input/output to. If set to 0, will round to nearest integer and convert type to int. If None, no rounding happens.
min: Minimum value. Only applied when component is used as an input. If a user provides a smaller value, a gr.Error exception is raised by the backend.
max: Maximum value. Only applied when component is used as an input. If a user provides a larger value, a gr.Error exception is raised by the backend.
"""
self.precision = precision
self.min = min
self.max = max

IOComponent.__init__(
self,
label=label,
Expand Down Expand Up @@ -710,12 +718,16 @@ def _round_to_precision(num: float | int, precision: int | None) -> float | int:
def get_config(self):
return {
"value": self.value,
"max": self.max,
"min": self.min,
**IOComponent.get_config(self),
}

@staticmethod
def update(
value: float | Literal[_Keywords.NO_VALUE] | None = _Keywords.NO_VALUE,
max: float | int | None = None,
min: float | int | None = None,
label: str | None = None,
show_label: bool | None = None,
interactive: bool | None = None,
Expand All @@ -726,6 +738,8 @@ def update(
"show_label": show_label,
"visible": visible,
"value": value,
"max": max,
"min": min,
"interactive": interactive,
"__type__": "update",
}
Expand All @@ -739,6 +753,10 @@ def preprocess(self, x: float | None) -> float | None:
"""
if x is None:
return None
elif self.min != None and x < self.min:
raise Error(f"Value {x} is less than minimum value {self.min}.")
elif self.max != None and x > self.max:
raise Error(f"Value {x} is greater than maximum value {self.max}.")
return self._round_to_precision(x, self.precision)

def postprocess(self, y: float | None) -> float | None:
Expand Down
2 changes: 1 addition & 1 deletion gradio/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ def set(
self, "error_border_color", colors.red.c200
)
self.error_border_color_dark = error_border_color_dark or getattr(
self, "error_border_color_dark", "*border_color_primary"
self, "error_border_color_dark", colors.red.c200
)
self.error_border_width = error_border_width or getattr(
self, "error_border_width", "1px"
Expand Down
4 changes: 4 additions & 0 deletions js/app/src/components/Number/Number.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
export let style: Styles = {};
export let value: number = 0;
export let show_label: boolean;
export let max: number | undefined = undefined;
export let min: number | undefined = undefined;

export let loading_status: LoadingStatus;
export let mode: "static" | "dynamic";
Expand All @@ -29,6 +31,8 @@

<Number
bind:value
bind:max
dawoodkhan82 marked this conversation as resolved.
Show resolved Hide resolved
bind:min
bind:value_is_output
{label}
{info}
Expand Down
3 changes: 2 additions & 1 deletion js/app/test/mocks/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
--button-small-text-weight: 400;
--button-transition: none;
}

.dark {
--color-accent-soft: var(--neutral-900);
--background-fill-primary: var(--neutral-950);
Expand Down Expand Up @@ -297,7 +298,7 @@
--checkbox-label-text-color: var(--body-text-color);
--checkbox-label-text-color-selected: var(--checkbox-label-text-color);
--error-background-fill: var(--background-fill-primary);
--error-border-color: var(--border-color-primary);
--error-border-color: #fecaca;
--error-border-width: var(--error-border-width);
--error-text-color: #ef4444;
--input-background-fill: var(--neutral-800);
Expand Down
9 changes: 8 additions & 1 deletion js/form/src/Number.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import { BlockTitle } from "@gradio/atoms";

export let value: number = 0;
export let max: number | undefined = undefined;
export let min: number | undefined = undefined;
export let value_is_output: boolean = false;
export let disabled: boolean = false;
export let label: string;
Expand Down Expand Up @@ -31,7 +33,6 @@

async function handle_keypress(e: KeyboardEvent) {
await tick();

if (e.key === "Enter") {
e.preventDefault();
dispatch("submit");
Expand All @@ -49,6 +50,8 @@
<input
type="number"
bind:value
{max}
{min}
on:keypress={handle_keypress}
on:blur={handle_blur}
{disabled}
Expand Down Expand Up @@ -84,4 +87,8 @@
input::placeholder {
color: var(--input-placeholder-color);
}

input:out-of-range {
border: var(--input-border-width) solid var(--error-border-color);
}
</style>
4 changes: 4 additions & 0 deletions test/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ def test_component_functions(self):
"name": "number",
"show_label": True,
"label": None,
"max": float("inf"),
"min": float("-inf"),
"style": {},
"elem_id": "num",
"elem_classes": ["first"],
Expand Down Expand Up @@ -252,6 +254,8 @@ def test_component_functions_integer(self):
"name": "number",
"show_label": True,
"label": None,
"max": float("inf"),
"min": float("-inf"),
"style": {},
"elem_id": None,
"elem_classes": None,
Expand Down