appkit-ui 0.7.0__py3-none-any.whl

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.
appkit_ui/__init__.py ADDED
File without changes
@@ -0,0 +1,17 @@
1
+ from __future__ import annotations
2
+
3
+ from appkit_ui.components.collabsible import collabsible
4
+ from appkit_ui.components.editor import (
5
+ EditorButtonList,
6
+ EditorOptions,
7
+ EventHandler,
8
+ editor,
9
+ )
10
+
11
+ __all__ = [
12
+ "EditorButtonList",
13
+ "EditorOptions",
14
+ "EventHandler",
15
+ "collabsible",
16
+ "editor",
17
+ ]
@@ -0,0 +1,84 @@
1
+ from collections.abc import Callable
2
+
3
+ import reflex as rx
4
+
5
+
6
+ def collabsible(
7
+ *children: rx.Component,
8
+ title: str,
9
+ info_text: str = "",
10
+ show_condition: bool = True,
11
+ expanded: bool = False,
12
+ on_toggle: Callable | None = None,
13
+ **props,
14
+ ) -> rx.Component:
15
+ """
16
+ Erstellt eine Collapsible Komponente mit beliebig vielen Child-Komponenten
17
+
18
+ Args:
19
+ *children: Beliebige Anzahl von Reflex Komponenten als positionale Argumente
20
+ title: Titel der Collapsible Sektion
21
+ info_text: Info-Text rechts neben dem Titel
22
+ show_condition: Bedingung, wann die Komponente angezeigt wird
23
+ expanded: Zustand, ob die Komponente erweitert ist
24
+ on_toggle: Event handler für das Umschalten
25
+ **props: Zusätzliche Props für das Container-Element
26
+ """
27
+ return rx.vstack(
28
+ # Collapsible header - klickbarer Bereich
29
+ rx.vstack(
30
+ rx.hstack(
31
+ rx.icon(
32
+ rx.cond(
33
+ expanded,
34
+ "chevron-down",
35
+ "chevron-right",
36
+ ),
37
+ size=16,
38
+ ),
39
+ rx.text(
40
+ title,
41
+ size="1",
42
+ font_weight="medium",
43
+ color=rx.color("gray", 11),
44
+ flex_grow="1",
45
+ ),
46
+ rx.text(
47
+ info_text,
48
+ size="1",
49
+ color=rx.color("gray", 9),
50
+ text_align="right",
51
+ width="40%",
52
+ ),
53
+ spacing="2",
54
+ align="start",
55
+ width="100%",
56
+ ),
57
+ on_click=on_toggle,
58
+ padding="8px",
59
+ width="100%",
60
+ _hover={"background_color": rx.color("gray", 2)},
61
+ ),
62
+ # Expandierbarer Inhalt - alle Children werden in einem vstack angeordnet
63
+ rx.cond(
64
+ expanded,
65
+ *children, # Alle übergebenen Komponenten werden hier eingefügt
66
+ ),
67
+ # Container Styling
68
+ spacing="3",
69
+ width="calc(90% + 18px)",
70
+ background_color=rx.color("gray", 1),
71
+ border=f"1px solid {rx.color('gray', 6)}",
72
+ border_radius="8px",
73
+ # Animationen
74
+ opacity=rx.cond(show_condition, "1", "0"),
75
+ transform=rx.cond(show_condition, "translateY(0)", "translateY(-20px)"),
76
+ height=rx.cond(show_condition, "auto", "0"),
77
+ max_height=rx.cond(show_condition, "500px", "0"),
78
+ padding=rx.cond(show_condition, "3px", "0"),
79
+ margin_top=rx.cond(show_condition, "16px", "-16px"),
80
+ overflow="hidden",
81
+ pointer_events=rx.cond(show_condition, "auto", "none"),
82
+ # transition="all 1s ease-out",
83
+ **props,
84
+ )
@@ -0,0 +1,123 @@
1
+ import reflex as rx
2
+
3
+
4
+ def delete_dialog(
5
+ title: str,
6
+ content: str,
7
+ on_click: rx.EventHandler,
8
+ icon_button: bool = False,
9
+ class_name: str = "dialog",
10
+ **kwargs,
11
+ ) -> rx.Component:
12
+ """Generic delete confirmation dialog.
13
+
14
+ Args:
15
+ title: Dialog title
16
+ content: The name/identifier of the item to delete
17
+ on_click: Event handler for delete action
18
+ icon_button: If True, use icon_button instead of button for trigger
19
+ **kwargs: Additional props for the trigger button
20
+ """
21
+ # Create the appropriate trigger based on icon_button parameter
22
+ if icon_button:
23
+ trigger = rx.icon_button(rx.icon("trash-2", size=19), **kwargs)
24
+ else:
25
+ trigger = rx.button(rx.icon("trash-2", size=16), **kwargs)
26
+
27
+ return rx.alert_dialog.root(
28
+ rx.alert_dialog.trigger(trigger),
29
+ rx.alert_dialog.content(
30
+ rx.alert_dialog.title(title),
31
+ rx.alert_dialog.description(
32
+ rx.text(
33
+ "Bist du sicher, dass du ",
34
+ rx.text.strong(content),
35
+ " löschen möchtest? ",
36
+ "Diese Aktion wird das ausgewählte Element und alle zugehörigen ",
37
+ "Daten dauerhaft löschen. Dieser Vorgang kann nicht rückgängig ",
38
+ "gemacht werden!",
39
+ ),
40
+ class_name="mb-4",
41
+ ),
42
+ rx.flex(
43
+ rx.alert_dialog.cancel(
44
+ rx.button(
45
+ "Abbrechen",
46
+ class_name=(
47
+ "bg-gray-100 dark:bg-neutral-700 text-gray-700 "
48
+ "dark:text-neutral-300 hover:bg-gray-200 "
49
+ "dark:hover:bg-neutral-600 px-4 py-2 rounded"
50
+ ),
51
+ ),
52
+ ),
53
+ rx.alert_dialog.action(
54
+ rx.button(
55
+ "Löschen",
56
+ class_name=(
57
+ "bg-red-500 text-white hover:bg-red-600 px-4 py-2 rounded"
58
+ ),
59
+ on_click=on_click,
60
+ )
61
+ ),
62
+ class_name="justify-end gap-3",
63
+ ),
64
+ class_name=class_name,
65
+ ),
66
+ )
67
+
68
+
69
+ def dialog_header(icon: str, title: str, description: str) -> rx.Component:
70
+ """Reusable dialog header component."""
71
+ return rx.hstack(
72
+ rx.badge(
73
+ rx.icon(tag=icon, size=34),
74
+ color_scheme="grass",
75
+ radius="full",
76
+ padding="0.65rem",
77
+ ),
78
+ rx.vstack(
79
+ rx.dialog.title(
80
+ title,
81
+ weight="bold",
82
+ margin="0",
83
+ ),
84
+ rx.dialog.description(description),
85
+ spacing="1",
86
+ height="100%",
87
+ align_items="start",
88
+ ),
89
+ height="100%",
90
+ spacing="4",
91
+ margin_bottom="1.5em",
92
+ align_items="center",
93
+ width="100%",
94
+ )
95
+
96
+
97
+ def dialog_buttons(
98
+ submit_text: str, spacing: str = "3", has_errors: bool = False
99
+ ) -> rx.Component:
100
+ """Reusable dialog action buttons."""
101
+ return rx.flex(
102
+ rx.dialog.close(
103
+ rx.button(
104
+ "Abbrechen",
105
+ class_name=(
106
+ "bg-gray-100 dark:bg-neutral-700 text-gray-700 "
107
+ "dark:text-neutral-300 hover:bg-gray-200 "
108
+ "dark:hover:bg-neutral-600 px-4 py-2 rounded"
109
+ ),
110
+ ),
111
+ ),
112
+ rx.form.submit(
113
+ rx.dialog.close(
114
+ rx.button(
115
+ submit_text,
116
+ class_name="px-4 py-2 rounded",
117
+ disabled=has_errors,
118
+ ),
119
+ ),
120
+ as_child=True,
121
+ ),
122
+ class_name=f"pt-8 gap-{spacing} mt-4 justify-end",
123
+ )
@@ -0,0 +1,274 @@
1
+ """A Rich Text Editor based on SunEditor."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import enum
6
+ from typing import Literal
7
+
8
+ from pydantic import BaseModel
9
+ from reflex.components.component import Component, NoSSRComponent
10
+ from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec
11
+ from reflex.utils.format import to_camel_case
12
+ from reflex.utils.imports import ImportDict, ImportVar
13
+ from reflex.vars.base import Var
14
+
15
+
16
+ class EditorButtonList(list, enum.Enum):
17
+ """List enum that provides three predefined button lists."""
18
+
19
+ BASIC = [
20
+ ["font", "fontSize"],
21
+ ["fontColor"],
22
+ ["horizontalRule"],
23
+ ["link", "image"],
24
+ ]
25
+ FORMATTING = [
26
+ ["undo", "redo"],
27
+ ["bold", "underline", "italic", "strike", "subscript", "superscript"],
28
+ ["removeFormat"],
29
+ ["outdent", "indent"],
30
+ ["fullScreen", "showBlocks", "codeView"],
31
+ ["preview", "print"],
32
+ ]
33
+ COMPLEX = [
34
+ ["undo", "redo"],
35
+ ["font", "fontSize", "formatBlock"],
36
+ ["bold", "underline", "italic", "strike", "subscript", "superscript"],
37
+ ["removeFormat"],
38
+ "/",
39
+ ["fontColor", "hiliteColor"],
40
+ ["outdent", "indent"],
41
+ ["align", "horizontalRule", "list", "table"],
42
+ ["link", "image", "video"],
43
+ ["fullScreen", "showBlocks", "codeView"],
44
+ ["preview", "print"],
45
+ ["save", "template"],
46
+ ]
47
+
48
+
49
+ class EditorOptions(BaseModel):
50
+ """Some of the additional options to configure the Editor.
51
+
52
+ Complete list of options found here:
53
+ https://github.com/JiHong88/SunEditor/blob/master/README.md#options.
54
+ """
55
+
56
+ # Specifies default tag name of the editor.
57
+ # default: 'p' {String}
58
+ default_tag: str | None = None
59
+
60
+ # The mode of the editor ('classic', 'inline', 'balloon', 'balloon-always').
61
+ # default: 'classic' {String}
62
+ mode: str | None = None
63
+
64
+ # If true, the editor is set to RTL(Right To Left) mode.
65
+ # default: false {Boolean}
66
+ rtl: bool | None = None
67
+
68
+ # List of buttons to use in the toolbar.
69
+ button_list: list[list[str] | str] | None
70
+
71
+
72
+ def on_blur_spec(_e: Var, content: Var[str]) -> tuple[Var[str]]:
73
+ """A helper function to specify the on_blur event handler.
74
+
75
+ Args:
76
+ _e: The event.
77
+ content: The content of the editor.
78
+
79
+ Returns:
80
+ A tuple containing the content of the editor.
81
+ """
82
+ return (content,)
83
+
84
+
85
+ def on_paste_spec(
86
+ _e: Var, clean_data: Var[str], max_char_count: Var[bool]
87
+ ) -> tuple[Var[str], Var[bool]]:
88
+ """A helper function to specify the on_paste event handler.
89
+
90
+ Args:
91
+ _e: The event.
92
+ clean_data: The clean data.
93
+ max_char_count: The maximum character count.
94
+
95
+ Returns:
96
+ A tuple containing the clean data and the maximum character count.
97
+ """
98
+ return (clean_data, max_char_count)
99
+
100
+
101
+ class Editor(NoSSRComponent):
102
+ """A Rich Text Editor component based on SunEditor.
103
+
104
+ Not every JS prop is listed here (some are not easily usable from python),
105
+ refer to the library docs for a complete list.
106
+ """
107
+
108
+ library = "suneditor-react@3.6.1"
109
+
110
+ tag = "SunEditor"
111
+
112
+ is_default = True
113
+
114
+ lib_dependencies: list[str] = ["suneditor"]
115
+
116
+ # Language of the editor.
117
+ # Alternatively to a string, a dict of your language can be passed to this prop.
118
+ # Please refer to the library docs for this.
119
+ # options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" |
120
+ # "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it"
121
+ # default: "en".
122
+ lang: Var[
123
+ Literal[
124
+ "en",
125
+ "da",
126
+ "de",
127
+ "es",
128
+ "fr",
129
+ "ja",
130
+ "ko",
131
+ "pt_br",
132
+ "ru",
133
+ "zh_cn",
134
+ "ro",
135
+ "pl",
136
+ "ckb",
137
+ "lv",
138
+ "se",
139
+ "ua",
140
+ "he",
141
+ "it",
142
+ ]
143
+ | dict
144
+ ]
145
+
146
+ # This is used to set the HTML form name of the editor.
147
+ # This means on HTML form submission,
148
+ # it will be submitted together with contents of the editor by the name provided.
149
+ name: Var[str]
150
+
151
+ # Sets the default value of the editor.
152
+ # This is useful if you don't want the on_change method to be called on render.
153
+ # If you want the on_change method to be called on render use the set_contents prop
154
+ default_value: Var[str]
155
+
156
+ # Sets the width of the editor.
157
+ # px and percentage values are accepted, eg width="100%" or width="500px"
158
+ # default: 100%
159
+ width: Var[str]
160
+
161
+ # Sets the height of the editor.
162
+ # px and percentage values are accepted, eg height="100%" or height="100px"
163
+ height: Var[str]
164
+
165
+ # Sets the placeholder of the editor.
166
+ placeholder: Var[str]
167
+
168
+ # Should the editor receive focus when initialized?
169
+ auto_focus: Var[bool]
170
+
171
+ # Pass an EditorOptions instance to modify the behaviour of Editor even more.
172
+ set_options: Var[dict]
173
+
174
+ # Whether all SunEditor plugins should be loaded.
175
+ # default: True.
176
+ set_all_plugins: Var[bool]
177
+
178
+ # Set the content of the editor.
179
+ # Note: To set the initial contents of the editor
180
+ # without calling the on_change event,
181
+ # please use the default_value prop.
182
+ # set_contents is used to set the contents of the editor programmatically.
183
+ # You must be aware that, when the set_contents's prop changes,
184
+ # the on_change event is triggered.
185
+ set_contents: Var[str]
186
+
187
+ # Append editor content
188
+ append_contents: Var[str]
189
+
190
+ # Sets the default style of the editor's edit area
191
+ set_default_style: Var[str]
192
+
193
+ # Disable the editor
194
+ # default: False.
195
+ disable: Var[bool]
196
+
197
+ # Hide the editor
198
+ # default: False.
199
+ hide: Var[bool]
200
+
201
+ # Hide the editor toolbar
202
+ # default: False.
203
+ hide_toolbar: Var[bool]
204
+
205
+ # Disable the editor toolbar
206
+ # default: False.
207
+ disable_toolbar: Var[bool]
208
+
209
+ # Fired when the editor content changes.
210
+ on_change: EventHandler[passthrough_event_spec(str)]
211
+
212
+ # Fired when the something is inputted in the editor.
213
+ on_input: EventHandler[no_args_event_spec]
214
+
215
+ # Fired when the editor loses focus.
216
+ on_blur: EventHandler[on_blur_spec]
217
+
218
+ # Fired when the editor is loaded.
219
+ on_load: EventHandler[passthrough_event_spec(bool)]
220
+
221
+ # Fired when the editor content is copied.
222
+ on_copy: EventHandler[no_args_event_spec]
223
+
224
+ # Fired when the editor content is cut.
225
+ on_cut: EventHandler[no_args_event_spec]
226
+
227
+ # Fired when the editor content is pasted.
228
+ on_paste: EventHandler[on_paste_spec]
229
+
230
+ # Fired when the code view is toggled.
231
+ toggle_code_view: EventHandler[passthrough_event_spec(bool)]
232
+
233
+ # Fired when the full screen mode is toggled.
234
+ toggle_full_screen: EventHandler[passthrough_event_spec(bool)]
235
+
236
+ def add_imports(self) -> ImportDict:
237
+ """Add imports for the Editor component.
238
+
239
+ Returns:
240
+ The import dict.
241
+ """
242
+ return {
243
+ "": ImportVar(tag="suneditor/dist/css/suneditor.min.css", install=False)
244
+ }
245
+
246
+ @classmethod
247
+ def create(
248
+ cls, set_options: EditorOptions | None = None, **props: object
249
+ ) -> Component:
250
+ """Create an instance of Editor. No children allowed.
251
+
252
+ Args:
253
+ set_options: Configuration object to further configure the instance.
254
+ **props: Any properties to be passed to the Editor
255
+
256
+ Returns:
257
+ An Editor instance.
258
+
259
+ Raises:
260
+ ValueError: If set_options is a state Var.
261
+ """
262
+ if set_options is not None:
263
+ if isinstance(set_options, Var):
264
+ msg = "EditorOptions cannot be a state Var"
265
+ raise ValueError(msg)
266
+ props["set_options"] = {
267
+ to_camel_case(k): v
268
+ for k, v in set_options.dict().items()
269
+ if v is not None
270
+ }
271
+ return super().create(*[], **props)
272
+
273
+
274
+ editor = Editor.create
@@ -0,0 +1,434 @@
1
+ import logging
2
+
3
+ import reflex as rx
4
+ from pydantic import BaseModel
5
+
6
+ import appkit_mantine as mn
7
+ import appkit_ui.components as knai
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ class SelectItem(BaseModel):
13
+ label: str
14
+ value: str
15
+
16
+
17
+ def hidden_field(
18
+ **kwargs,
19
+ ) -> rx.Component:
20
+ """Creates a hidden input field."""
21
+ return rx.el.input(
22
+ type="hidden",
23
+ **kwargs,
24
+ )
25
+
26
+
27
+ def inline_form_field(
28
+ icon: str,
29
+ label: str,
30
+ hint: str = "",
31
+ **kwargs,
32
+ ) -> rx.Component:
33
+ if "value" in kwargs:
34
+ kwargs["default_value"] = None
35
+ elif "default_value" in kwargs:
36
+ kwargs["value"] = None
37
+
38
+ minlength = kwargs.get("min_length", 0)
39
+ maxlength = kwargs.get("max_length", 0)
40
+ pattern = kwargs.get("pattern", "")
41
+
42
+ logger.debug(
43
+ "Creating form field: %s, minlength=%s, maxlength=%s, pattern=%s",
44
+ label,
45
+ minlength,
46
+ maxlength,
47
+ pattern,
48
+ )
49
+
50
+ return rx.form.field(
51
+ rx.flex(
52
+ rx.hstack(
53
+ rx.icon(icon, size=17, stroke_width=1.5),
54
+ rx.form.label(label),
55
+ class_name="label",
56
+ ),
57
+ rx.hstack(
58
+ rx.cond(
59
+ hint,
60
+ rx.form.message(
61
+ hint,
62
+ color="gray",
63
+ class_name="hint",
64
+ ),
65
+ ),
66
+ rx.form.control(
67
+ rx.input(
68
+ **kwargs,
69
+ ),
70
+ as_child=True,
71
+ ),
72
+ rx.cond(
73
+ kwargs.get("required", False),
74
+ rx.form.message(
75
+ f"{label} ist ein Pflichtfeld.",
76
+ name=kwargs.get("name", ""),
77
+ color="red",
78
+ class_name="error required",
79
+ ),
80
+ ),
81
+ rx.cond(
82
+ minlength > 0,
83
+ rx.form.message(
84
+ f"{label} muss mindestens {minlength} Zeichen enthalten.",
85
+ name=kwargs.get("name", ""),
86
+ color="red",
87
+ class_name="error minlength",
88
+ ),
89
+ ),
90
+ rx.cond(
91
+ maxlength > 0,
92
+ rx.form.message(
93
+ f"{label} darf maximal {maxlength} Zeichen enthalten.",
94
+ name=kwargs.get("name", ""),
95
+ color="red",
96
+ class_name="error maxlength",
97
+ ),
98
+ ),
99
+ rx.cond(
100
+ pattern,
101
+ rx.form.message(
102
+ f"{label} entspricht nicht dem geforderten Format: {pattern}",
103
+ name=kwargs.get("name", ""),
104
+ color="red",
105
+ class_name="error pattern",
106
+ ),
107
+ ),
108
+ direction="column",
109
+ spacing="0",
110
+ ),
111
+ ),
112
+ width="100%",
113
+ class_name="form-group",
114
+ )
115
+
116
+
117
+ def form_field(
118
+ icon: str,
119
+ label: str,
120
+ hint: str = "",
121
+ validation_error: str | None = None,
122
+ **kwargs,
123
+ ) -> rx.Component:
124
+ if "value" in kwargs:
125
+ kwargs["default_value"] = None
126
+ elif "default_value" in kwargs:
127
+ kwargs["value"] = None
128
+
129
+ if "size" in kwargs:
130
+ # convert to mantine size "xs", "sm", "md", "lg", "xl"
131
+ size_map = {"1": "xs", "2": "sm", "3": "md", "4": "lg", "5": "xl"}
132
+ kwargs["size"] = size_map.get(kwargs["size"], "md")
133
+
134
+ return mn.form.wrapper(
135
+ mn.form.input(
136
+ **kwargs,
137
+ left_section=rx.cond(icon, rx.icon(icon, size=17, stroke_width=1.5), None),
138
+ ),
139
+ label=label,
140
+ description=hint,
141
+ error=validation_error,
142
+ required=True,
143
+ width="100%",
144
+ )
145
+
146
+
147
+ def form_inline_field(
148
+ icon: str,
149
+ **kwargs,
150
+ ) -> rx.Component:
151
+ if kwargs.get("width") is None:
152
+ kwargs["width"] = "100%"
153
+ if kwargs.get("size") is None:
154
+ kwargs["size"] = "3"
155
+
156
+ return rx.form.field(
157
+ rx.input(
158
+ rx.input.slot(rx.icon(icon)),
159
+ **kwargs,
160
+ ),
161
+ class_name="form-group",
162
+ width="100%",
163
+ )
164
+
165
+
166
+ def form_textarea(
167
+ *components,
168
+ name: str,
169
+ icon: str,
170
+ label: str,
171
+ hint: str = "",
172
+ monospace: bool = True,
173
+ **kwargs,
174
+ ) -> rx.Component:
175
+ if "value" in kwargs:
176
+ kwargs["default_value"] = None
177
+ elif "default_value" in kwargs:
178
+ kwargs["value"] = None
179
+
180
+ minlength = kwargs.get("min_length", 0)
181
+ maxlength = kwargs.get("max_length", 0)
182
+
183
+ logger.debug(
184
+ "Creating form textarea: %s, minlength=%s, maxlength=%s",
185
+ label,
186
+ minlength,
187
+ maxlength,
188
+ )
189
+
190
+ return rx.flex(
191
+ rx.form.field(
192
+ rx.flex(
193
+ rx.hstack(
194
+ rx.icon(icon, size=16, stroke_width=1.5),
195
+ rx.form.label(label),
196
+ class_name="label",
197
+ ),
198
+ rx.spacer(),
199
+ *components,
200
+ direction="row",
201
+ ),
202
+ rx.cond(
203
+ hint,
204
+ rx.form.message(
205
+ hint,
206
+ color="gray",
207
+ class_name="hint",
208
+ ),
209
+ ),
210
+ rx.form.message(
211
+ f"{label} ist ein Pflichtfeld.",
212
+ name=name,
213
+ color="red",
214
+ class_name="error required",
215
+ ),
216
+ rx.cond(
217
+ minlength > 0,
218
+ rx.form.message(
219
+ f"{label} muss mindestens {minlength} Zeichen enthalten.",
220
+ name=name,
221
+ color="red",
222
+ match="tooShort",
223
+ class_name="error minlength",
224
+ ),
225
+ ),
226
+ rx.cond(
227
+ maxlength > 0,
228
+ rx.form.message(
229
+ f"{label} darf maximal {maxlength} Zeichen enthalten.",
230
+ name=name,
231
+ color="red",
232
+ match="tooLong",
233
+ class_name="error maxlength",
234
+ ),
235
+ ),
236
+ rx.text_area(
237
+ name=name,
238
+ id=name,
239
+ font_family=rx.cond(
240
+ monospace,
241
+ "Consolas, Monaco, 'Courier New', monospace;",
242
+ "inherit",
243
+ ),
244
+ **kwargs,
245
+ ),
246
+ class_name="form-group",
247
+ ),
248
+ direction="column",
249
+ spacing="0",
250
+ )
251
+
252
+
253
+ def form_checkbox(
254
+ name: str,
255
+ label: str,
256
+ hint: str | None = None,
257
+ **kwargs,
258
+ ) -> rx.Component:
259
+ return rx.form.field(
260
+ rx.hstack(
261
+ rx.switch(
262
+ name=name,
263
+ margin_top="8px",
264
+ margin_right="9px",
265
+ **kwargs,
266
+ ),
267
+ rx.flex(
268
+ rx.form.label(label, padding_bottom="3px"),
269
+ rx.cond(
270
+ hint,
271
+ rx.form.message(
272
+ hint, color="gray", margin_top="-10px", class_name="hint"
273
+ ),
274
+ ),
275
+ direction="column",
276
+ ),
277
+ spacing="2",
278
+ align="start",
279
+ justify="start",
280
+ margin_top="1em",
281
+ ),
282
+ name=name,
283
+ width="100%",
284
+ class_name="form-group",
285
+ )
286
+
287
+
288
+ def render_select_item(option: SelectItem) -> rx.Component:
289
+ return rx.select.item(
290
+ rx.hstack(
291
+ rx.text(option.label),
292
+ ),
293
+ value=option.value,
294
+ )
295
+
296
+
297
+ def form_select(
298
+ *components,
299
+ options: list[SelectItem],
300
+ icon: str = "circle-dot",
301
+ label: str = "",
302
+ hint: str = "",
303
+ placeholder: str = "",
304
+ on_change: rx.EventHandler | None = None,
305
+ with_label: bool = True,
306
+ column_width: str = "100%",
307
+ **kwargs,
308
+ ) -> rx.Component:
309
+ if "value" in kwargs:
310
+ kwargs["default_value"] = None
311
+ elif "default_value" in kwargs:
312
+ kwargs["value"] = None
313
+
314
+ if on_change is not None:
315
+ kwargs["on_change"] = on_change
316
+
317
+ classes = "rt-SelectTrigger"
318
+ if "size" in kwargs:
319
+ classes += f" rt-r-size-{kwargs['size']}"
320
+ else:
321
+ classes += " rt-r-size-2"
322
+
323
+ if "variant" in kwargs:
324
+ classes += f" rt-variant-{kwargs['variant'].lower()}"
325
+ else:
326
+ classes += " rt-variant-surface"
327
+
328
+ return rx.flex(
329
+ rx.form.field(
330
+ rx.cond(
331
+ with_label,
332
+ rx.hstack(
333
+ rx.icon(icon, size=16, stroke_width=1.5),
334
+ rx.form.label(label),
335
+ class_name="label",
336
+ ),
337
+ ),
338
+ rx.cond(
339
+ hint,
340
+ rx.form.message(
341
+ hint,
342
+ color="gray",
343
+ class_name="hint",
344
+ ),
345
+ ),
346
+ rx.hstack(
347
+ rx.el.select(
348
+ rx.cond(placeholder, rx.el.option(placeholder, value="")),
349
+ rx.foreach(
350
+ options.to(list[SelectItem]),
351
+ lambda option: rx.el.option(
352
+ label=option.label,
353
+ value=option.value,
354
+ class_name="rt-SelectItem",
355
+ ),
356
+ ),
357
+ appearance="base-select",
358
+ class_name=classes,
359
+ **kwargs,
360
+ ),
361
+ *components,
362
+ ),
363
+ rx.form.message(
364
+ f"{label} darf nicht leer sein.",
365
+ name=kwargs.get("name", ""),
366
+ color="red",
367
+ class_name="error required",
368
+ ),
369
+ spacing="2",
370
+ margin_bottom="0.75em",
371
+ class_name="form-group",
372
+ ),
373
+ width=column_width,
374
+ flex_grow="1",
375
+ )
376
+
377
+
378
+ def form_text_editor(
379
+ icon: str,
380
+ label: str,
381
+ name: str = "editor",
382
+ hint: str = "",
383
+ on_blur: rx.EventHandler | None = None,
384
+ **kwargs,
385
+ ) -> rx.Component:
386
+ if kwargs.get("width") is None:
387
+ kwargs["width"] = "100%"
388
+ if kwargs.get("height") is None:
389
+ kwargs["height"] = "240px"
390
+
391
+ if on_blur is not None:
392
+ kwargs["on_blur"] = on_blur
393
+
394
+ return rx.form.field(
395
+ rx.hstack(
396
+ rx.icon(icon, size=16, stroke_width=1.5),
397
+ rx.form.label(label),
398
+ class_name="label",
399
+ ),
400
+ rx.cond(
401
+ hint,
402
+ rx.form.message(
403
+ hint,
404
+ color="gray",
405
+ class_name="hint",
406
+ ),
407
+ ),
408
+ knai.editor(
409
+ id=name,
410
+ set_options=knai.EditorOptions(
411
+ button_list=[
412
+ ["formatBlock"],
413
+ [
414
+ "bold",
415
+ "underline",
416
+ "align",
417
+ "outdent",
418
+ "indent",
419
+ "list",
420
+ "table",
421
+ "blockquote",
422
+ ],
423
+ [
424
+ "link",
425
+ "horizontalRule",
426
+ ],
427
+ ["removeFormat", "undo", "redo"],
428
+ ],
429
+ ),
430
+ **kwargs,
431
+ ),
432
+ width="100%",
433
+ class_name="form-group",
434
+ )
@@ -0,0 +1,28 @@
1
+ import reflex as rx
2
+
3
+
4
+ def header(
5
+ text: str,
6
+ indent: bool = False,
7
+ ) -> rx.Component:
8
+ return rx.box(
9
+ rx.color_mode_cond(
10
+ light=rx.heading(
11
+ text,
12
+ size="5",
13
+ class_name="text-black",
14
+ ),
15
+ dark=rx.heading(
16
+ text,
17
+ size="5",
18
+ class_name="text-white",
19
+ ),
20
+ ),
21
+ class_name=(
22
+ "fixed top-0 z-[1000] w-full "
23
+ "border-b border-gray-300 dark:border-neutral-700 "
24
+ "bg-gray-50 dark:bg-neutral-800 "
25
+ "p-3 pl-8 transition-colors duration-300"
26
+ ),
27
+ margin_left=rx.cond(indent, "0", "-32px"),
28
+ )
@@ -0,0 +1,9 @@
1
+ import reflex as rx
2
+
3
+
4
+ class LoadingState(rx.State):
5
+ is_loading: bool = False
6
+ is_loading_message: str = "Lade..."
7
+
8
+ def set_is_loading(self, is_loading: bool) -> None:
9
+ self.is_loading = is_loading
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: appkit-ui
3
+ Version: 0.7.0
4
+ Summary: Add your description here
5
+ Author: Jens Rehpöhler
6
+ Requires-Python: >=3.13
7
+ Requires-Dist: appkit-commons
8
+ Requires-Dist: reflex>=0.8.12
@@ -0,0 +1,11 @@
1
+ appkit_ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ appkit_ui/global_states.py,sha256=V-Tmz4nmAcn4NAtW-Q12xNZSbQdJe7Oexvf25WdEdVY,215
3
+ appkit_ui/components/__init__.py,sha256=DPKkO65DGtXfla1esbS9wkEpxbVlMTs45g6oqgJVQYo,321
4
+ appkit_ui/components/collabsible.py,sha256=JAAIEvwShHMhtcGfZwXkR59AC2hEgZrH4DGmuVTGWFE,2833
5
+ appkit_ui/components/dialogs.py,sha256=nc4-5PNUwzz-8ZB-Y3bUGkw6z6RlEfNto7icPHjycog,3916
6
+ appkit_ui/components/editor.py,sha256=Z9cew7hrLuBoXBYk7xW-OsbhIcdW4LFlBqi_8eYtCTY,7956
7
+ appkit_ui/components/form_inputs.py,sha256=3xBCqfQGi9j4qhTeyktdjQ5MN4lUJS-u2sHynJZoViU,11677
8
+ appkit_ui/components/header.py,sha256=JLAiDEVku99pRgAsQAMUIui7i70hS6H6Bbbe8FVj0DU,715
9
+ appkit_ui-0.7.0.dist-info/METADATA,sha256=rDF-SpiuZTBEix_WtHOCIxd2bJnZS_phSiyZ8q6VHAA,196
10
+ appkit_ui-0.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
+ appkit_ui-0.7.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any