Spaces:
Running
Running
Commit
·
45df88a
1
Parent(s):
cd20a5a
Commit
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Dockerfile +1 -1
- __pycache__/autocomplete.cpython-310.pyc +0 -0
- __pycache__/bootstrap.cpython-310.pyc +0 -0
- __pycache__/button_toggle.cpython-310.pyc +0 -0
- __pycache__/card.cpython-310.pyc +0 -0
- __pycache__/chat.cpython-310.pyc +0 -0
- __pycache__/date_picker.cpython-310.pyc +0 -0
- __pycache__/date_range_picker.cpython-310.pyc +0 -0
- __pycache__/expansion_panel.cpython-310.pyc +0 -0
- __pycache__/grid_table.cpython-310.pyc +0 -0
- __pycache__/input.cpython-310.pyc +0 -0
- __pycache__/llm_rewriter.cpython-310.pyc +0 -0
- __pycache__/main.cpython-310.pyc +0 -0
- __pycache__/markdown_demo.cpython-310.pyc +0 -0
- __pycache__/select_demo.cpython-310.pyc +0 -0
- __pycache__/sidenav.cpython-310.pyc +0 -0
- __pycache__/tailwind.cpython-310.pyc +0 -0
- __pycache__/text.cpython-310.pyc +0 -0
- __pycache__/text_to_image.cpython-310.pyc +0 -0
- __pycache__/text_to_text.cpython-310.pyc +0 -0
- __pycache__/textarea.cpython-310.pyc +0 -0
- __pycache__/uploader.cpython-310.pyc +0 -0
- autocomplete.py +1 -0
- bootstrap.py +78 -0
- button_toggle.py +41 -0
- card.py +103 -0
- date_picker.py +52 -0
- date_range_picker.py +61 -0
- expansion_panel.py +165 -0
- grid_table.py +25 -88
- input.py +4 -3
- llm_rewriter.py +1 -1
- main.py +19 -0
- requirements.txt +2 -2
- screenshots/autocomplete.png +0 -0
- screenshots/autocomplete.webp +0 -0
- screenshots/bootstrap.png +0 -0
- screenshots/bootstrap.webp +0 -0
- screenshots/button_toggle.png +0 -0
- screenshots/button_toggle.webp +0 -0
- screenshots/card.png +0 -0
- screenshots/card.webp +0 -0
- screenshots/date_picker.png +0 -0
- screenshots/date_picker.webp +0 -0
- screenshots/date_range_picker.png +0 -0
- screenshots/date_range_picker.webp +0 -0
- screenshots/embed.png +0 -0
- screenshots/embed.webp +0 -0
- screenshots/expansion_panel.png +0 -0
- screenshots/expansion_panel.webp +0 -0
Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
FROM python:3.10.
|
2 |
|
3 |
RUN apt-get update && \
|
4 |
apt-get install -y \
|
|
|
1 |
+
FROM python:3.10.15-bullseye
|
2 |
|
3 |
RUN apt-get update && \
|
4 |
apt-get install -y \
|
__pycache__/autocomplete.cpython-310.pyc
CHANGED
Binary files a/__pycache__/autocomplete.cpython-310.pyc and b/__pycache__/autocomplete.cpython-310.pyc differ
|
|
__pycache__/bootstrap.cpython-310.pyc
ADDED
Binary file (3.04 kB). View file
|
|
__pycache__/button_toggle.cpython-310.pyc
ADDED
Binary file (1.61 kB). View file
|
|
__pycache__/card.cpython-310.pyc
ADDED
Binary file (2.55 kB). View file
|
|
__pycache__/chat.cpython-310.pyc
CHANGED
Binary files a/__pycache__/chat.cpython-310.pyc and b/__pycache__/chat.cpython-310.pyc differ
|
|
__pycache__/date_picker.cpython-310.pyc
ADDED
Binary file (1.83 kB). View file
|
|
__pycache__/date_range_picker.cpython-310.pyc
ADDED
Binary file (2.14 kB). View file
|
|
__pycache__/expansion_panel.cpython-310.pyc
ADDED
Binary file (4.18 kB). View file
|
|
__pycache__/grid_table.cpython-310.pyc
CHANGED
Binary files a/__pycache__/grid_table.cpython-310.pyc and b/__pycache__/grid_table.cpython-310.pyc differ
|
|
__pycache__/input.cpython-310.pyc
CHANGED
Binary files a/__pycache__/input.cpython-310.pyc and b/__pycache__/input.cpython-310.pyc differ
|
|
__pycache__/llm_rewriter.cpython-310.pyc
CHANGED
Binary files a/__pycache__/llm_rewriter.cpython-310.pyc and b/__pycache__/llm_rewriter.cpython-310.pyc differ
|
|
__pycache__/main.cpython-310.pyc
CHANGED
Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ
|
|
__pycache__/markdown_demo.cpython-310.pyc
CHANGED
Binary files a/__pycache__/markdown_demo.cpython-310.pyc and b/__pycache__/markdown_demo.cpython-310.pyc differ
|
|
__pycache__/select_demo.cpython-310.pyc
CHANGED
Binary files a/__pycache__/select_demo.cpython-310.pyc and b/__pycache__/select_demo.cpython-310.pyc differ
|
|
__pycache__/sidenav.cpython-310.pyc
CHANGED
Binary files a/__pycache__/sidenav.cpython-310.pyc and b/__pycache__/sidenav.cpython-310.pyc differ
|
|
__pycache__/tailwind.cpython-310.pyc
ADDED
Binary file (4.28 kB). View file
|
|
__pycache__/text.cpython-310.pyc
CHANGED
Binary files a/__pycache__/text.cpython-310.pyc and b/__pycache__/text.cpython-310.pyc differ
|
|
__pycache__/text_to_image.cpython-310.pyc
CHANGED
Binary files a/__pycache__/text_to_image.cpython-310.pyc and b/__pycache__/text_to_image.cpython-310.pyc differ
|
|
__pycache__/text_to_text.cpython-310.pyc
CHANGED
Binary files a/__pycache__/text_to_text.cpython-310.pyc and b/__pycache__/text_to_text.cpython-310.pyc differ
|
|
__pycache__/textarea.cpython-310.pyc
CHANGED
Binary files a/__pycache__/textarea.cpython-310.pyc and b/__pycache__/textarea.cpython-310.pyc differ
|
|
__pycache__/uploader.cpython-310.pyc
CHANGED
Binary files a/__pycache__/uploader.cpython-310.pyc and b/__pycache__/uploader.cpython-310.pyc differ
|
|
autocomplete.py
CHANGED
@@ -29,6 +29,7 @@ def app():
|
|
29 |
on_selection_change=on_value_change,
|
30 |
on_enter=on_value_change,
|
31 |
on_input=on_input,
|
|
|
32 |
)
|
33 |
|
34 |
if state.selected_value:
|
|
|
29 |
on_selection_change=on_value_change,
|
30 |
on_enter=on_value_change,
|
31 |
on_input=on_input,
|
32 |
+
appearance="outline",
|
33 |
)
|
34 |
|
35 |
if state.selected_value:
|
bootstrap.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mesop as me
|
2 |
+
|
3 |
+
|
4 |
+
@me.page(
|
5 |
+
security_policy=me.SecurityPolicy(
|
6 |
+
allowed_iframe_parents=["https://google.github.io", "https://huggingface.co"]
|
7 |
+
),
|
8 |
+
stylesheets=[
|
9 |
+
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css",
|
10 |
+
],
|
11 |
+
path="/bootstrap",
|
12 |
+
)
|
13 |
+
def page():
|
14 |
+
with me.box(classes="container"):
|
15 |
+
with me.box(
|
16 |
+
classes="d-flex flex-wrap justify-content-between py-3 mb-4 border-bottom",
|
17 |
+
):
|
18 |
+
with me.box(
|
19 |
+
classes="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none fs-4",
|
20 |
+
):
|
21 |
+
me.text("Mesop")
|
22 |
+
|
23 |
+
with me.box(classes="nav nav-pills"):
|
24 |
+
with me.box(classes="nav-item"):
|
25 |
+
with me.box(classes="nav-link active"):
|
26 |
+
me.text("Features")
|
27 |
+
with me.box(classes="nav-item"):
|
28 |
+
with me.box(classes="nav-link"):
|
29 |
+
me.text("About")
|
30 |
+
|
31 |
+
with me.box(classes="container px-4 py-5"):
|
32 |
+
with me.box(classes="pb-2 border-bottom"):
|
33 |
+
me.text("Columns", type="headline-5")
|
34 |
+
|
35 |
+
with me.box(classes="row g-4 py-5 row-cols-1 row-cols-lg-3"):
|
36 |
+
with me.box(classes="feature col"):
|
37 |
+
with me.box(classes="fs-2 text-body-emphasis"):
|
38 |
+
me.text("Featured title")
|
39 |
+
me.text(
|
40 |
+
"Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words."
|
41 |
+
)
|
42 |
+
me.link(text="Call to action", url="/#")
|
43 |
+
|
44 |
+
with me.box(classes="feature col"):
|
45 |
+
with me.box(classes="fs-2 text-body-emphasis"):
|
46 |
+
me.text("Featured title")
|
47 |
+
me.text(
|
48 |
+
"Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words."
|
49 |
+
)
|
50 |
+
me.link(text="Call to action", url="/#")
|
51 |
+
|
52 |
+
with me.box(classes="feature col"):
|
53 |
+
with me.box(classes="fs-2 text-body-emphasis"):
|
54 |
+
me.text("Featured title")
|
55 |
+
me.text(
|
56 |
+
"Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words."
|
57 |
+
)
|
58 |
+
me.link(text="Call to action", url="/#")
|
59 |
+
|
60 |
+
with me.box(
|
61 |
+
classes="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top"
|
62 |
+
):
|
63 |
+
with me.box(classes="col-md-4 mb-0 text-body-secondary"):
|
64 |
+
me.text("Copyright 2024 Mesop")
|
65 |
+
|
66 |
+
with me.box(classes="nav col-md-4 justify-content-end"):
|
67 |
+
with me.box(classes="nav-item"):
|
68 |
+
with me.box(classes="nav-link px-2 text-body-secondary"):
|
69 |
+
me.text("Home")
|
70 |
+
with me.box(classes="nav-item"):
|
71 |
+
with me.box(classes="nav-link px-2 text-body-secondary"):
|
72 |
+
me.text("Features")
|
73 |
+
with me.box(classes="nav-item"):
|
74 |
+
with me.box(classes="nav-link px-2 text-body-secondary"):
|
75 |
+
me.text("FAQs")
|
76 |
+
with me.box(classes="nav-item"):
|
77 |
+
with me.box(classes="nav-link px-2 text-body-secondary"):
|
78 |
+
me.text("About")
|
button_toggle.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import field
|
2 |
+
|
3 |
+
import mesop as me
|
4 |
+
|
5 |
+
|
6 |
+
@me.stateclass
|
7 |
+
class State:
|
8 |
+
selected_values: list[str] = field(
|
9 |
+
default_factory=lambda: ["bold", "underline"]
|
10 |
+
)
|
11 |
+
|
12 |
+
|
13 |
+
def load(e: me.LoadEvent):
|
14 |
+
me.set_theme_mode("system")
|
15 |
+
|
16 |
+
|
17 |
+
@me.page(on_load=load, path="/button_toggle")
|
18 |
+
def app():
|
19 |
+
state = me.state(State)
|
20 |
+
|
21 |
+
with me.box(style=me.Style(margin=me.Margin.all(15))):
|
22 |
+
me.button_toggle(
|
23 |
+
value=state.selected_values,
|
24 |
+
buttons=[
|
25 |
+
me.ButtonToggleButton(label="Bold", value="bold"),
|
26 |
+
me.ButtonToggleButton(label="Italic", value="italic"),
|
27 |
+
me.ButtonToggleButton(label="Underline", value="underline"),
|
28 |
+
],
|
29 |
+
multiple=True,
|
30 |
+
hide_selection_indicator=False,
|
31 |
+
disabled=False,
|
32 |
+
on_change=on_change,
|
33 |
+
style=me.Style(margin=me.Margin(bottom=20)),
|
34 |
+
)
|
35 |
+
|
36 |
+
me.text("Select buttons: " + " ".join(state.selected_values))
|
37 |
+
|
38 |
+
|
39 |
+
def on_change(e: me.ButtonToggleChangeEvent):
|
40 |
+
state = me.state(State)
|
41 |
+
state.selected_values = e.values
|
card.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mesop as me
|
2 |
+
|
3 |
+
|
4 |
+
def load(e: me.LoadEvent):
|
5 |
+
me.set_theme_mode("system")
|
6 |
+
|
7 |
+
|
8 |
+
@me.page(
|
9 |
+
on_load=load,
|
10 |
+
security_policy=me.SecurityPolicy(
|
11 |
+
allowed_iframe_parents=["https://google.github.io", "https://huggingface.co"],
|
12 |
+
),
|
13 |
+
path="/card",
|
14 |
+
)
|
15 |
+
def app():
|
16 |
+
with me.box(
|
17 |
+
style=me.Style(
|
18 |
+
display="flex",
|
19 |
+
flex_direction="column",
|
20 |
+
gap=15,
|
21 |
+
margin=me.Margin.all(15),
|
22 |
+
max_width=500,
|
23 |
+
)
|
24 |
+
):
|
25 |
+
with me.card(appearance="outlined"):
|
26 |
+
me.card_header(
|
27 |
+
title="Grapefruit",
|
28 |
+
subtitle="Kind of fruit",
|
29 |
+
image="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
|
30 |
+
)
|
31 |
+
me.image(
|
32 |
+
style=me.Style(
|
33 |
+
width="100%",
|
34 |
+
),
|
35 |
+
src="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
|
36 |
+
)
|
37 |
+
with me.card_content():
|
38 |
+
me.text(
|
39 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
40 |
+
)
|
41 |
+
|
42 |
+
with me.card_actions(align="end"):
|
43 |
+
me.button(label="Add to cart")
|
44 |
+
me.button(label="Buy")
|
45 |
+
|
46 |
+
with me.card(appearance="raised"):
|
47 |
+
me.card_header(
|
48 |
+
title="Grapefruit",
|
49 |
+
subtitle="Kind of fruit",
|
50 |
+
image="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
|
51 |
+
image_type="small",
|
52 |
+
)
|
53 |
+
|
54 |
+
with me.card_content():
|
55 |
+
me.text(
|
56 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
57 |
+
)
|
58 |
+
|
59 |
+
with me.card_actions(align="start"):
|
60 |
+
me.button(label="Add to cart")
|
61 |
+
me.button(label="Buy")
|
62 |
+
|
63 |
+
with me.card(appearance="outlined"):
|
64 |
+
me.card_header(
|
65 |
+
title="Grapefruit",
|
66 |
+
subtitle="Kind of fruit",
|
67 |
+
image="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
|
68 |
+
image_type="medium",
|
69 |
+
)
|
70 |
+
|
71 |
+
with me.card_content():
|
72 |
+
me.text(
|
73 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
74 |
+
)
|
75 |
+
|
76 |
+
with me.card_actions(align="start"):
|
77 |
+
me.button(label="Add to cart")
|
78 |
+
me.button(label="Buy")
|
79 |
+
|
80 |
+
me.card_header(
|
81 |
+
title="Grapefruit",
|
82 |
+
image="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
|
83 |
+
image_type="large",
|
84 |
+
)
|
85 |
+
|
86 |
+
with me.card_content():
|
87 |
+
me.text(
|
88 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
89 |
+
)
|
90 |
+
|
91 |
+
with me.card_actions(align="end"):
|
92 |
+
me.button(label="Add to cart")
|
93 |
+
me.button(label="Buy")
|
94 |
+
|
95 |
+
me.card_header(
|
96 |
+
title="Grapefruit",
|
97 |
+
image_type="large",
|
98 |
+
)
|
99 |
+
|
100 |
+
with me.card_content():
|
101 |
+
me.text(
|
102 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
103 |
+
)
|
date_picker.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import field
|
2 |
+
from datetime import date
|
3 |
+
|
4 |
+
import mesop as me
|
5 |
+
|
6 |
+
|
7 |
+
@me.stateclass
|
8 |
+
class State:
|
9 |
+
picked_date: date | None = field(default_factory=lambda: date(2024, 10, 1))
|
10 |
+
|
11 |
+
|
12 |
+
def on_load(e: me.LoadEvent):
|
13 |
+
me.set_theme_mode("system")
|
14 |
+
|
15 |
+
|
16 |
+
@me.page(path="/date_picker", on_load=on_load)
|
17 |
+
def app():
|
18 |
+
state = me.state(State)
|
19 |
+
with me.box(
|
20 |
+
style=me.Style(
|
21 |
+
display="flex",
|
22 |
+
flex_direction="column",
|
23 |
+
gap=15,
|
24 |
+
padding=me.Padding.all(15),
|
25 |
+
)
|
26 |
+
):
|
27 |
+
me.date_picker(
|
28 |
+
label="Date",
|
29 |
+
disabled=False,
|
30 |
+
placeholder="9/1/2024",
|
31 |
+
required=True,
|
32 |
+
value=state.picked_date,
|
33 |
+
readonly=False,
|
34 |
+
hide_required_marker=False,
|
35 |
+
color="accent",
|
36 |
+
float_label="always",
|
37 |
+
appearance="outline",
|
38 |
+
on_change=on_date_change,
|
39 |
+
)
|
40 |
+
|
41 |
+
me.text("Selected date: " + _render_date(state.picked_date))
|
42 |
+
|
43 |
+
|
44 |
+
def on_date_change(e: me.DatePickerChangeEvent):
|
45 |
+
state = me.state(State)
|
46 |
+
state.picked_date = e.date
|
47 |
+
|
48 |
+
|
49 |
+
def _render_date(maybe_date: date | None) -> str:
|
50 |
+
if maybe_date:
|
51 |
+
return maybe_date.strftime("%Y-%m-%d")
|
52 |
+
return "None"
|
date_range_picker.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import field
|
2 |
+
from datetime import date
|
3 |
+
|
4 |
+
import mesop as me
|
5 |
+
|
6 |
+
|
7 |
+
@me.stateclass
|
8 |
+
class State:
|
9 |
+
picked_start_date: date | None = field(
|
10 |
+
default_factory=lambda: date(2024, 10, 1)
|
11 |
+
)
|
12 |
+
picked_end_date: date | None = field(
|
13 |
+
default_factory=lambda: date(2024, 11, 1)
|
14 |
+
)
|
15 |
+
|
16 |
+
|
17 |
+
def on_load(e: me.LoadEvent):
|
18 |
+
me.set_theme_mode("system")
|
19 |
+
|
20 |
+
|
21 |
+
@me.page(path="/date_range_picker", on_load=on_load)
|
22 |
+
def app():
|
23 |
+
state = me.state(State)
|
24 |
+
with me.box(
|
25 |
+
style=me.Style(
|
26 |
+
display="flex",
|
27 |
+
flex_direction="column",
|
28 |
+
gap=15,
|
29 |
+
padding=me.Padding.all(15),
|
30 |
+
)
|
31 |
+
):
|
32 |
+
me.date_range_picker(
|
33 |
+
label="Date Range",
|
34 |
+
disabled=False,
|
35 |
+
placeholder_start_date="9/1/2024",
|
36 |
+
placeholder_end_date="10/1/2024",
|
37 |
+
required=True,
|
38 |
+
start_date=state.picked_start_date,
|
39 |
+
end_date=state.picked_end_date,
|
40 |
+
readonly=False,
|
41 |
+
hide_required_marker=False,
|
42 |
+
color="accent",
|
43 |
+
float_label="always",
|
44 |
+
appearance="outline",
|
45 |
+
on_change=on_date_range_change,
|
46 |
+
)
|
47 |
+
|
48 |
+
me.text("Start date: " + _render_date(state.picked_start_date))
|
49 |
+
me.text("End date: " + _render_date(state.picked_end_date))
|
50 |
+
|
51 |
+
|
52 |
+
def on_date_range_change(e: me.DateRangePickerChangeEvent):
|
53 |
+
state = me.state(State)
|
54 |
+
state.picked_start_date = e.start_date
|
55 |
+
state.picked_end_date = e.end_date
|
56 |
+
|
57 |
+
|
58 |
+
def _render_date(maybe_date: date | None) -> str:
|
59 |
+
if maybe_date:
|
60 |
+
return maybe_date.strftime("%Y-%m-%d")
|
61 |
+
return "None"
|
expansion_panel.py
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import field
|
2 |
+
|
3 |
+
import mesop as me
|
4 |
+
|
5 |
+
|
6 |
+
@me.stateclass
|
7 |
+
class State:
|
8 |
+
normal_accordion: dict[str, bool] = field(
|
9 |
+
default_factory=lambda: {"pie": True, "donut": False, "icecream": False}
|
10 |
+
)
|
11 |
+
multi_accordion: dict[str, bool] = field(
|
12 |
+
default_factory=lambda: {"pie": False, "donut": False, "icecream": False}
|
13 |
+
)
|
14 |
+
|
15 |
+
|
16 |
+
def load(e: me.LoadEvent):
|
17 |
+
me.set_theme_mode("system")
|
18 |
+
|
19 |
+
|
20 |
+
@me.page(
|
21 |
+
on_load=load,
|
22 |
+
security_policy=me.SecurityPolicy(
|
23 |
+
allowed_iframe_parents=["https://google.github.io", "https://huggingface.co"]
|
24 |
+
),
|
25 |
+
path="/expansion_panel",
|
26 |
+
)
|
27 |
+
def app():
|
28 |
+
state = me.state(State)
|
29 |
+
with me.box(
|
30 |
+
style=me.Style(
|
31 |
+
display="flex",
|
32 |
+
flex_direction="column",
|
33 |
+
gap=15,
|
34 |
+
margin=me.Margin.all(15),
|
35 |
+
max_width=500,
|
36 |
+
)
|
37 |
+
):
|
38 |
+
me.text("Normal Accordion", type="headline-5")
|
39 |
+
with me.accordion():
|
40 |
+
with me.expansion_panel(
|
41 |
+
key="pie",
|
42 |
+
title="Pie",
|
43 |
+
description="Type of snack",
|
44 |
+
icon="pie_chart",
|
45 |
+
disabled=False,
|
46 |
+
expanded=state.normal_accordion["pie"],
|
47 |
+
hide_toggle=False,
|
48 |
+
on_toggle=on_accordion_toggle,
|
49 |
+
):
|
50 |
+
me.text(
|
51 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
52 |
+
)
|
53 |
+
|
54 |
+
with me.expansion_panel(
|
55 |
+
key="donut",
|
56 |
+
title="Donut",
|
57 |
+
description="Type of breakfast",
|
58 |
+
icon="donut_large",
|
59 |
+
disabled=False,
|
60 |
+
expanded=state.normal_accordion["donut"],
|
61 |
+
hide_toggle=False,
|
62 |
+
on_toggle=on_accordion_toggle,
|
63 |
+
):
|
64 |
+
me.text(
|
65 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
66 |
+
)
|
67 |
+
|
68 |
+
with me.expansion_panel(
|
69 |
+
key="icecream",
|
70 |
+
title="Ice cream",
|
71 |
+
description="Type of dessert",
|
72 |
+
icon="icecream",
|
73 |
+
disabled=False,
|
74 |
+
expanded=state.normal_accordion["icecream"],
|
75 |
+
hide_toggle=False,
|
76 |
+
on_toggle=on_accordion_toggle,
|
77 |
+
):
|
78 |
+
me.text(
|
79 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
80 |
+
)
|
81 |
+
|
82 |
+
me.text("Multi Accordion", type="headline-5")
|
83 |
+
with me.box(
|
84 |
+
style=me.Style(display="flex", gap=20, margin=me.Margin(bottom=15)),
|
85 |
+
):
|
86 |
+
me.button(
|
87 |
+
label="Open All", type="flat", on_click=on_multi_accordion_open_all
|
88 |
+
)
|
89 |
+
me.button(
|
90 |
+
label="Close All", type="flat", on_click=on_multi_accordion_close_all
|
91 |
+
)
|
92 |
+
|
93 |
+
with me.accordion():
|
94 |
+
with me.expansion_panel(
|
95 |
+
key="pie",
|
96 |
+
title="Pie",
|
97 |
+
description="Type of snack",
|
98 |
+
icon="pie_chart",
|
99 |
+
expanded=state.multi_accordion["pie"],
|
100 |
+
on_toggle=on_multi_accordion_toggle,
|
101 |
+
):
|
102 |
+
me.text(
|
103 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
104 |
+
)
|
105 |
+
|
106 |
+
with me.expansion_panel(
|
107 |
+
key="donut",
|
108 |
+
title="Donut",
|
109 |
+
description="Type of breakfast",
|
110 |
+
icon="donut_large",
|
111 |
+
expanded=state.multi_accordion["donut"],
|
112 |
+
on_toggle=on_multi_accordion_toggle,
|
113 |
+
):
|
114 |
+
me.text(
|
115 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
116 |
+
)
|
117 |
+
|
118 |
+
with me.expansion_panel(
|
119 |
+
key="icecream",
|
120 |
+
title="Ice cream",
|
121 |
+
description="Type of dessert",
|
122 |
+
icon="icecream",
|
123 |
+
expanded=state.multi_accordion["icecream"],
|
124 |
+
on_toggle=on_multi_accordion_toggle,
|
125 |
+
):
|
126 |
+
me.text(
|
127 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
128 |
+
)
|
129 |
+
|
130 |
+
me.text("Expansion Panel", type="headline-5")
|
131 |
+
|
132 |
+
with me.expansion_panel(
|
133 |
+
key="pie",
|
134 |
+
title="Pie",
|
135 |
+
description="Type of snack",
|
136 |
+
icon="pie_chart",
|
137 |
+
):
|
138 |
+
me.text(
|
139 |
+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed augue ultricies, laoreet nunc eget, ultricies augue. In ornare bibendum mauris vel sodales. Donec ut interdum felis. Nulla facilisi. Morbi a laoreet turpis, sed posuere arcu. Nam nisi neque, molestie vitae euismod eu, sollicitudin eu lectus. Pellentesque orci metus, finibus id faucibus et, ultrices quis dui. Duis in augue ac metus tristique lacinia."
|
140 |
+
)
|
141 |
+
|
142 |
+
|
143 |
+
def on_accordion_toggle(e: me.ExpansionPanelToggleEvent):
|
144 |
+
"""Implements accordion behavior where only one panel can be open at a time"""
|
145 |
+
state = me.state(State)
|
146 |
+
state.normal_accordion = {"pie": False, "donut": False, "icecream": False}
|
147 |
+
state.normal_accordion[e.key] = e.opened
|
148 |
+
|
149 |
+
|
150 |
+
def on_multi_accordion_toggle(e: me.ExpansionPanelToggleEvent):
|
151 |
+
"""Implements accordion behavior where multiple panels can be open at a time"""
|
152 |
+
state = me.state(State)
|
153 |
+
state.multi_accordion[e.key] = e.opened
|
154 |
+
|
155 |
+
|
156 |
+
def on_multi_accordion_open_all(e: me.ClickEvent):
|
157 |
+
state = me.state(State)
|
158 |
+
for key in state.multi_accordion:
|
159 |
+
state.multi_accordion[key] = True
|
160 |
+
|
161 |
+
|
162 |
+
def on_multi_accordion_close_all(e: me.ClickEvent):
|
163 |
+
state = me.state(State)
|
164 |
+
for key in state.multi_accordion:
|
165 |
+
state.multi_accordion[key] = False
|
grid_table.py
CHANGED
@@ -22,7 +22,7 @@ TODOs:
|
|
22 |
|
23 |
from dataclasses import dataclass, field
|
24 |
from datetime import datetime
|
25 |
-
from typing import Any, Callable, Literal
|
26 |
|
27 |
import pandas as pd
|
28 |
|
@@ -57,7 +57,12 @@ class State:
|
|
57 |
theme: str = "light"
|
58 |
|
59 |
|
|
|
|
|
|
|
|
|
60 |
@me.page(
|
|
|
61 |
security_policy=me.SecurityPolicy(
|
62 |
allowed_iframe_parents=["https://google.github.io", "https://huggingface.co"]
|
63 |
),
|
@@ -108,17 +113,15 @@ def app():
|
|
108 |
),
|
109 |
sort_column=state.sort_column,
|
110 |
sort_direction=state.sort_direction,
|
111 |
-
theme=
|
112 |
-
if state.theme == "light"
|
113 |
-
else GridTableThemeDark(striped=True),
|
114 |
)
|
115 |
|
116 |
# Used for demonstrating "table button" click example.
|
117 |
if state.string_output:
|
118 |
with me.box(
|
119 |
style=me.Style(
|
120 |
-
background="
|
121 |
-
color="
|
122 |
margin=me.Margin(top=20),
|
123 |
padding=me.Padding.all(15),
|
124 |
)
|
@@ -206,30 +209,16 @@ class GridTableCellMeta:
|
|
206 |
value: Any
|
207 |
|
208 |
|
209 |
-
class GridTableTheme
|
210 |
-
"""
|
211 |
-
|
212 |
-
def header(self, sortable: bool = False) -> me.Style:
|
213 |
-
return me.Style()
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
return me.Style()
|
220 |
-
|
221 |
-
def expander(self, df_row_index: int) -> me.Style:
|
222 |
-
return me.Style()
|
223 |
-
|
224 |
-
|
225 |
-
class GridTableThemeDark(GridTableTheme):
|
226 |
-
_HEADER_BG: str = "#28313e"
|
227 |
-
_CELL_BG: str = "#141d2c"
|
228 |
-
_CELL_BG_ALT: str = "#02060c"
|
229 |
-
_COLOR: str = "#fff"
|
230 |
_PADDING: me.Padding = me.Padding.all(10)
|
231 |
_BORDER: me.Border = me.Border.all(
|
232 |
-
me.BorderSide(width=1, style="solid", color=
|
233 |
)
|
234 |
|
235 |
def __init__(self, striped: bool = False):
|
@@ -246,9 +235,9 @@ class GridTableThemeDark(GridTableTheme):
|
|
246 |
|
247 |
def sort_icon(self, current_column: str, sort_column: str) -> me.Style:
|
248 |
return me.Style(
|
249 |
-
color="
|
250 |
if sort_column == current_column
|
251 |
-
else "
|
252 |
# Hack to make the icon align correctly. Will break if user changes the
|
253 |
# font size with custom styles.
|
254 |
height=16,
|
@@ -273,61 +262,6 @@ class GridTableThemeDark(GridTableTheme):
|
|
273 |
)
|
274 |
|
275 |
|
276 |
-
class GridTableThemeLight(GridTableTheme):
|
277 |
-
_HEADER_BG: str = "#fff"
|
278 |
-
_CELL_BG: str = "#fff"
|
279 |
-
_CELL_BG_ALT: str = "#f6f6f6"
|
280 |
-
_COLOR: str = "#000"
|
281 |
-
_PADDING: me.Padding = me.Padding.all(10)
|
282 |
-
_HEADER_BORDER: me.Border = me.Border(
|
283 |
-
bottom=me.BorderSide(width=1, style="solid", color="#b2b2b2")
|
284 |
-
)
|
285 |
-
_CELL_BORDER: me.Border = me.Border(
|
286 |
-
bottom=me.BorderSide(width=1, style="solid", color="#d9d9d9")
|
287 |
-
)
|
288 |
-
|
289 |
-
def __init__(self, striped: bool = False):
|
290 |
-
self.striped = striped
|
291 |
-
|
292 |
-
def header(self, sortable: bool = False) -> me.Style:
|
293 |
-
return me.Style(
|
294 |
-
background=self._HEADER_BG,
|
295 |
-
color=self._COLOR,
|
296 |
-
cursor="pointer" if sortable else "default",
|
297 |
-
font_weight="bold",
|
298 |
-
padding=self._PADDING,
|
299 |
-
border=self._HEADER_BORDER,
|
300 |
-
)
|
301 |
-
|
302 |
-
def sort_icon(self, current_column: str, sort_column: str) -> me.Style:
|
303 |
-
return me.Style(
|
304 |
-
color="rgba(0, 0, 0, .8)"
|
305 |
-
if sort_column == current_column
|
306 |
-
else "rgba(0, 0, 0, .4)",
|
307 |
-
# Hack to make the icon align correctly. Will break if user changes the
|
308 |
-
# font size with custom styles.
|
309 |
-
height=18,
|
310 |
-
)
|
311 |
-
|
312 |
-
def cell(self, cell_meta: GridTableCellMeta) -> me.Style:
|
313 |
-
return me.Style(
|
314 |
-
background=self._CELL_BG_ALT
|
315 |
-
if self.striped and cell_meta.row_index % 2
|
316 |
-
else self._CELL_BG,
|
317 |
-
color=self._COLOR,
|
318 |
-
padding=self._PADDING,
|
319 |
-
border=self._CELL_BORDER,
|
320 |
-
)
|
321 |
-
|
322 |
-
def expander(self, df_row_index: int) -> me.Style:
|
323 |
-
return me.Style(
|
324 |
-
background=self._CELL_BG,
|
325 |
-
color=self._COLOR,
|
326 |
-
padding=self._PADDING,
|
327 |
-
border=self._CELL_BORDER,
|
328 |
-
)
|
329 |
-
|
330 |
-
|
331 |
def get_data_frame():
|
332 |
"""Helper function to get a sorted/filtered version of the main data frame.
|
333 |
|
@@ -357,6 +291,7 @@ def on_theme_changed(e: me.SelectSelectionChangeEvent):
|
|
357 |
"""Changes the theme of the grid table"""
|
358 |
state = me.state(State)
|
359 |
state.theme = e.value
|
|
|
360 |
|
361 |
|
362 |
def on_filter_by_strings(e: me.InputBlurEvent | me.InputEnterEvent):
|
@@ -432,12 +367,14 @@ def strings_component(meta: GridTableCellMeta):
|
|
432 |
on_click=on_click_strings,
|
433 |
style=me.Style(
|
434 |
border_radius=3,
|
435 |
-
background="
|
436 |
border=me.Border.all(
|
437 |
-
me.BorderSide(
|
|
|
|
|
438 |
),
|
439 |
font_weight="bold",
|
440 |
-
color="
|
441 |
),
|
442 |
)
|
443 |
|
@@ -506,7 +443,7 @@ def grid_table(
|
|
506 |
grid_template_columns=f"repeat({len(data.columns)}, 1fr)",
|
507 |
)
|
508 |
):
|
509 |
-
_theme: GridTableTheme =
|
510 |
if theme:
|
511 |
_theme = theme
|
512 |
|
|
|
22 |
|
23 |
from dataclasses import dataclass, field
|
24 |
from datetime import datetime
|
25 |
+
from typing import Any, Callable, Literal
|
26 |
|
27 |
import pandas as pd
|
28 |
|
|
|
57 |
theme: str = "light"
|
58 |
|
59 |
|
60 |
+
def load(e: me.LoadEvent):
|
61 |
+
me.set_theme_mode("system")
|
62 |
+
|
63 |
+
|
64 |
@me.page(
|
65 |
+
on_load=load,
|
66 |
security_policy=me.SecurityPolicy(
|
67 |
allowed_iframe_parents=["https://google.github.io", "https://huggingface.co"]
|
68 |
),
|
|
|
113 |
),
|
114 |
sort_column=state.sort_column,
|
115 |
sort_direction=state.sort_direction,
|
116 |
+
theme=GridTableTheme(striped=True),
|
|
|
|
|
117 |
)
|
118 |
|
119 |
# Used for demonstrating "table button" click example.
|
120 |
if state.string_output:
|
121 |
with me.box(
|
122 |
style=me.Style(
|
123 |
+
background=me.theme_var("surface-container-high"),
|
124 |
+
color=me.theme_var("on-surface"),
|
125 |
margin=me.Margin(top=20),
|
126 |
padding=me.Padding.all(15),
|
127 |
)
|
|
|
209 |
value: Any
|
210 |
|
211 |
|
212 |
+
class GridTableTheme:
|
213 |
+
"""This default theme utilizes Mesop's built in dark mode to toggle between dark/light themes."""
|
|
|
|
|
|
|
214 |
|
215 |
+
_HEADER_BG: str = me.theme_var("surface-container-highest")
|
216 |
+
_CELL_BG: str = me.theme_var("surface-container-low")
|
217 |
+
_CELL_BG_ALT: str = me.theme_var("surface-container-lowest")
|
218 |
+
_COLOR: str = me.theme_var("on-surface-variant")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
_PADDING: me.Padding = me.Padding.all(10)
|
220 |
_BORDER: me.Border = me.Border.all(
|
221 |
+
me.BorderSide(width=1, style="solid", color=me.theme_var("outline-variant"))
|
222 |
)
|
223 |
|
224 |
def __init__(self, striped: bool = False):
|
|
|
235 |
|
236 |
def sort_icon(self, current_column: str, sort_column: str) -> me.Style:
|
237 |
return me.Style(
|
238 |
+
color=me.theme_var("outline")
|
239 |
if sort_column == current_column
|
240 |
+
else me.theme_var("outline-variant"),
|
241 |
# Hack to make the icon align correctly. Will break if user changes the
|
242 |
# font size with custom styles.
|
243 |
height=16,
|
|
|
262 |
)
|
263 |
|
264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
def get_data_frame():
|
266 |
"""Helper function to get a sorted/filtered version of the main data frame.
|
267 |
|
|
|
291 |
"""Changes the theme of the grid table"""
|
292 |
state = me.state(State)
|
293 |
state.theme = e.value
|
294 |
+
me.set_theme_mode(state.theme) # type: ignore
|
295 |
|
296 |
|
297 |
def on_filter_by_strings(e: me.InputBlurEvent | me.InputEnterEvent):
|
|
|
367 |
on_click=on_click_strings,
|
368 |
style=me.Style(
|
369 |
border_radius=3,
|
370 |
+
background=me.theme_var("primary-container"),
|
371 |
border=me.Border.all(
|
372 |
+
me.BorderSide(
|
373 |
+
width=1, style="solid", color=me.theme_var("primary-fixed-dim")
|
374 |
+
)
|
375 |
),
|
376 |
font_weight="bold",
|
377 |
+
color=me.theme_var("on-primary-container"),
|
378 |
),
|
379 |
)
|
380 |
|
|
|
443 |
grid_template_columns=f"repeat({len(data.columns)}, 1fr)",
|
444 |
)
|
445 |
):
|
446 |
+
_theme: GridTableTheme = GridTableTheme()
|
447 |
if theme:
|
448 |
_theme = theme
|
449 |
|
input.py
CHANGED
@@ -23,6 +23,7 @@ def load(e: me.LoadEvent):
|
|
23 |
path="/input",
|
24 |
)
|
25 |
def app():
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
23 |
path="/input",
|
24 |
)
|
25 |
def app():
|
26 |
+
with me.box(style=me.Style(margin=me.Margin.all(15))):
|
27 |
+
s = me.state(State)
|
28 |
+
me.input(label="Basic input", appearance="outline", on_blur=on_blur)
|
29 |
+
me.text(text=s.input)
|
llm_rewriter.py
CHANGED
@@ -30,7 +30,7 @@ class State:
|
|
30 |
|
31 |
|
32 |
def load(e: me.LoadEvent):
|
33 |
-
me.set_theme_mode("
|
34 |
|
35 |
|
36 |
@me.page(
|
|
|
30 |
|
31 |
|
32 |
def load(e: me.LoadEvent):
|
33 |
+
me.set_theme_mode("system")
|
34 |
|
35 |
|
36 |
@me.page(
|
main.py
CHANGED
@@ -24,16 +24,22 @@ import audio as audio
|
|
24 |
import autocomplete as autocomplete
|
25 |
import badge as badge
|
26 |
import basic_animation as basic_animation
|
|
|
27 |
import box as box
|
28 |
import button as button
|
|
|
|
|
29 |
import chat as chat
|
30 |
import chat_inputs as chat_inputs
|
31 |
import checkbox as checkbox
|
32 |
import code_demo as code_demo # cannot call it code due to python library naming conflict
|
|
|
|
|
33 |
import density as density
|
34 |
import dialog as dialog
|
35 |
import divider as divider
|
36 |
import embed as embed
|
|
|
37 |
import fancy_chat as fancy_chat
|
38 |
import feedback as feedback
|
39 |
import form_billing as form_billing
|
@@ -59,6 +65,7 @@ import slide_toggle as slide_toggle
|
|
59 |
import slider as slider
|
60 |
import snackbar as snackbar
|
61 |
import table as table
|
|
|
62 |
import text as text
|
63 |
import text_to_image as text_to_image
|
64 |
import text_to_text as text_to_text
|
@@ -123,6 +130,13 @@ FIRST_SECTIONS = [
|
|
123 |
Example(name="feedback"),
|
124 |
],
|
125 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
]
|
127 |
|
128 |
COMPONENTS_SECTIONS = [
|
@@ -154,7 +168,10 @@ COMPONENTS_SECTIONS = [
|
|
154 |
examples=[
|
155 |
Example(name="autocomplete"),
|
156 |
Example(name="button"),
|
|
|
157 |
Example(name="checkbox"),
|
|
|
|
|
158 |
Example(name="input"),
|
159 |
Example(name="textarea"),
|
160 |
Example(name="radio"),
|
@@ -168,7 +185,9 @@ COMPONENTS_SECTIONS = [
|
|
168 |
name="Visual",
|
169 |
examples=[
|
170 |
Example(name="badge"),
|
|
|
171 |
Example(name="divider"),
|
|
|
172 |
Example(name="icon"),
|
173 |
Example(name="progress_bar"),
|
174 |
Example(name="progress_spinner"),
|
|
|
24 |
import autocomplete as autocomplete
|
25 |
import badge as badge
|
26 |
import basic_animation as basic_animation
|
27 |
+
import bootstrap as bootstrap
|
28 |
import box as box
|
29 |
import button as button
|
30 |
+
import button_toggle as button_toggle
|
31 |
+
import card as card
|
32 |
import chat as chat
|
33 |
import chat_inputs as chat_inputs
|
34 |
import checkbox as checkbox
|
35 |
import code_demo as code_demo # cannot call it code due to python library naming conflict
|
36 |
+
import date_picker as date_picker
|
37 |
+
import date_range_picker as date_range_picker
|
38 |
import density as density
|
39 |
import dialog as dialog
|
40 |
import divider as divider
|
41 |
import embed as embed
|
42 |
+
import expansion_panel as expansion_panel
|
43 |
import fancy_chat as fancy_chat
|
44 |
import feedback as feedback
|
45 |
import form_billing as form_billing
|
|
|
65 |
import slider as slider
|
66 |
import snackbar as snackbar
|
67 |
import table as table
|
68 |
+
import tailwind as tailwind
|
69 |
import text as text
|
70 |
import text_to_image as text_to_image
|
71 |
import text_to_text as text_to_text
|
|
|
130 |
Example(name="feedback"),
|
131 |
],
|
132 |
),
|
133 |
+
Section(
|
134 |
+
name="Integrations",
|
135 |
+
examples=[
|
136 |
+
Example(name="bootstrap"),
|
137 |
+
Example(name="tailwind"),
|
138 |
+
],
|
139 |
+
),
|
140 |
]
|
141 |
|
142 |
COMPONENTS_SECTIONS = [
|
|
|
168 |
examples=[
|
169 |
Example(name="autocomplete"),
|
170 |
Example(name="button"),
|
171 |
+
Example(name="button_toggle"),
|
172 |
Example(name="checkbox"),
|
173 |
+
Example(name="date_picker"),
|
174 |
+
Example(name="date_range_picker"),
|
175 |
Example(name="input"),
|
176 |
Example(name="textarea"),
|
177 |
Example(name="radio"),
|
|
|
185 |
name="Visual",
|
186 |
examples=[
|
187 |
Example(name="badge"),
|
188 |
+
Example(name="card"),
|
189 |
Example(name="divider"),
|
190 |
+
Example(name="expansion_panel"),
|
191 |
Example(name="icon"),
|
192 |
Example(name="progress_bar"),
|
193 |
Example(name="progress_spinner"),
|
requirements.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
mesop>=0.
|
2 |
Flask==3.0.0
|
3 |
gunicorn==22.0.0
|
4 |
-
Werkzeug==3.0.
|
5 |
# For examples:
|
6 |
matplotlib
|
7 |
numpy
|
|
|
1 |
+
mesop>=0.13.0
|
2 |
Flask==3.0.0
|
3 |
gunicorn==22.0.0
|
4 |
+
Werkzeug==3.0.6
|
5 |
# For examples:
|
6 |
matplotlib
|
7 |
numpy
|
screenshots/autocomplete.png
CHANGED
![]() |
![]() |
screenshots/autocomplete.webp
CHANGED
![]() |
![]() |
screenshots/bootstrap.png
ADDED
![]() |
screenshots/bootstrap.webp
ADDED
![]() |
screenshots/button_toggle.png
ADDED
![]() |
screenshots/button_toggle.webp
ADDED
![]() |
screenshots/card.png
ADDED
![]() |
screenshots/card.webp
ADDED
![]() |
screenshots/date_picker.png
ADDED
![]() |
screenshots/date_picker.webp
ADDED
![]() |
screenshots/date_range_picker.png
ADDED
![]() |
screenshots/date_range_picker.webp
ADDED
![]() |
screenshots/embed.png
CHANGED
![]() |
![]() |
screenshots/embed.webp
CHANGED
![]() |
![]() |
screenshots/expansion_panel.png
ADDED
![]() |
screenshots/expansion_panel.webp
ADDED
![]() |