cs-ui 0.2.0__tar.gz → 0.3.0__tar.gz

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.
Files changed (142) hide show
  1. {cs_ui-0.2.0 → cs_ui-0.3.0}/PKG-INFO +13 -12
  2. {cs_ui-0.2.0 → cs_ui-0.3.0}/README.md +12 -7
  3. {cs_ui-0.2.0 → cs_ui-0.3.0}/pyproject.toml +46 -48
  4. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/cs_ui.egg-info/PKG-INFO +13 -12
  5. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/cs_ui.egg-info/SOURCES.txt +3 -8
  6. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/cs_ui.egg-info/entry_points.txt +0 -1
  7. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/cs_ui.egg-info/requires.txt +0 -4
  8. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/__init__.py +156 -146
  9. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/_lazy.py +67 -67
  10. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/_registry.py +12 -25
  11. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/app.py +8 -5
  12. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/__init__.py +10 -0
  13. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/catalog.py +1 -12
  14. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/doc.py +88 -33
  15. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/empty.py +167 -167
  16. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/float_layer.py +185 -185
  17. cs_ui-0.3.0/src/ui/core/fonts.py +134 -0
  18. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/locales.py +0 -45
  19. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/responsive.py +363 -363
  20. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/theme.py +26 -5
  21. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/tokens.py +22 -0
  22. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/typography.py +15 -1
  23. cs_ui-0.3.0/src/ui/data/fonts/AlibabaPuHuiTi-3-55-Regular.otf +0 -0
  24. cs_ui-0.3.0/src/ui/display/__init__.py +44 -0
  25. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/log_container.py +1 -1
  26. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/tag.py +233 -233
  27. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/text.py +1165 -1563
  28. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/_overlay.py +386 -386
  29. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/message.py +526 -526
  30. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/notification.py +613 -613
  31. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/progress_bar.py +269 -269
  32. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/__init__.py +2 -0
  33. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/calendar_panel.py +740 -740
  34. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/cascader.py +1327 -1327
  35. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/search_bar.py +292 -292
  36. cs_ui-0.3.0/src/ui/input/search_field.py +271 -0
  37. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/segmented_button.py +356 -356
  38. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/slider.py +493 -493
  39. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/column.py +368 -368
  40. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/grid.py +328 -328
  41. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/row.py +360 -360
  42. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/navigation/app_bar.py +245 -245
  43. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/navigation/menu.py +1277 -1277
  44. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/navigation/menu_bar.py +526 -526
  45. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/navigation/status_bar.py +341 -341
  46. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/version.py +1 -1
  47. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/aliases.py +1 -8
  48. cs_ui-0.3.0/src/ui_mcp/data/api.json +1 -0
  49. cs_ui-0.3.0/src/ui_mcp/data/docs.json +1 -0
  50. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/server.py +1 -1
  51. cs_ui-0.2.0/src/ui/display/__init__.py +0 -63
  52. cs_ui-0.2.0/src/ui/display/media/__init__.py +0 -37
  53. cs_ui-0.2.0/src/ui/display/media/audio.py +0 -702
  54. cs_ui-0.2.0/src/ui/display/media/pdf.py +0 -468
  55. cs_ui-0.2.0/src/ui/display/media/player.py +0 -373
  56. cs_ui-0.2.0/src/ui/display/media/video.py +0 -289
  57. cs_ui-0.2.0/src/ui/utils/__init__.py +0 -16
  58. cs_ui-0.2.0/src/ui/utils/code_editor.py +0 -300
  59. cs_ui-0.2.0/src/ui/utils/code_view.py +0 -350
  60. cs_ui-0.2.0/src/ui_mcp/data/api.json +0 -1
  61. cs_ui-0.2.0/src/ui_mcp/data/docs.json +0 -1
  62. {cs_ui-0.2.0 → cs_ui-0.3.0}/setup.cfg +0 -0
  63. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/cs_ui.egg-info/dependency_links.txt +0 -0
  64. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/cs_ui.egg-info/top_level.txt +0 -0
  65. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/chart/__init__.py +0 -0
  66. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/chart/_data.py +0 -0
  67. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/chart/area_chart.py +0 -0
  68. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/chart/bar_chart.py +0 -0
  69. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/chart/line_chart.py +0 -0
  70. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/chart/scatter_chart.py +0 -0
  71. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/cli.py +0 -0
  72. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/color.py +0 -0
  73. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/config.py +0 -0
  74. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/constants.py +0 -0
  75. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/format.py +0 -0
  76. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/i18n.py +0 -0
  77. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/icons.py +0 -0
  78. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/logger.py +0 -0
  79. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/palette.py +0 -0
  80. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/paths.py +0 -0
  81. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/core/styles.py +0 -0
  82. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/calendar.py +0 -0
  83. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/carousel.py +0 -0
  84. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/descriptions.py +0 -0
  85. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/heatmap.py +0 -0
  86. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/image.py +0 -0
  87. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/image_gridview.py +0 -0
  88. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/kbd.py +0 -0
  89. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/list_tile.py +0 -0
  90. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/number_animation.py +0 -0
  91. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/display/tree.py +0 -0
  92. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/__init__.py +0 -0
  93. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/_look.py +0 -0
  94. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/alert_dialog.py +0 -0
  95. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/feedback/loading.py +0 -0
  96. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/button.py +0 -0
  97. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/checkbox.py +0 -0
  98. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/chip.py +0 -0
  99. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/color_picker.py +0 -0
  100. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/date_input.py +0 -0
  101. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/datetime_input.py +0 -0
  102. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/file_picker.py +0 -0
  103. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/image_picker.py +0 -0
  104. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/input.py +0 -0
  105. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/multi_select.py +0 -0
  106. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/number_input.py +0 -0
  107. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/panel_field.py +0 -0
  108. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/radio.py +0 -0
  109. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/rating.py +0 -0
  110. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/select_box.py +0 -0
  111. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/switch.py +0 -0
  112. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/input/transfer.py +0 -0
  113. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/__init__.py +0 -0
  114. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/card.py +0 -0
  115. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/container.py +0 -0
  116. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/divider.py +0 -0
  117. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/expander.py +0 -0
  118. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/form_row.py +0 -0
  119. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/grid_view.py +0 -0
  120. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/list_view.py +0 -0
  121. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/metric_card.py +0 -0
  122. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/page.py +0 -0
  123. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/stack.py +0 -0
  124. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/step.py +0 -0
  125. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/table.py +0 -0
  126. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/layout/tabs.py +0 -0
  127. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/navigation/__init__.py +0 -0
  128. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/navigation/bread_crumb.py +0 -0
  129. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui/navigation/pagination.py +0 -0
  130. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/__about__.py +0 -0
  131. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/__init__.py +0 -0
  132. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/__main__.py +0 -0
  133. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/build.py +0 -0
  134. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/cli.py +0 -0
  135. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/data/examples.json +0 -0
  136. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/docs.py +0 -0
  137. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/examples.py +0 -0
  138. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/guidelines.py +0 -0
  139. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/introspect.py +0 -0
  140. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/paths.py +0 -0
  141. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/search.py +0 -0
  142. {cs_ui-0.2.0 → cs_ui-0.3.0}/src/ui_mcp/store.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cs-ui
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A Python UI framework inspired by Flet
5
5
  Author-email: Shawn Chen <cs@cstos.com>
6
6
  Project-URL: Homepage, https://www.github.com/icstos/cs-ui
@@ -10,11 +10,7 @@ Project-URL: Issues, https://www.github.com/icstos/cs-ui/issues
10
10
  Requires-Python: >=3.12
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: flet[all]<1.2,>=1.1.2
13
- Requires-Dist: flet-code-editor
14
13
  Requires-Dist: flet-charts
15
- Requires-Dist: flet-video
16
- Requires-Dist: flet-audio
17
- Requires-Dist: flet-webview
18
14
  Provides-Extra: mcp
19
15
  Requires-Dist: fastmcp>=2.0; extra == "mcp"
20
16
 
@@ -60,7 +56,15 @@ typographic law.
60
56
 
61
57
  - Python >= 3.12
62
58
  - flet[all] >= 1.1.2, < 1.2
63
- - flet-code-editor / flet-charts / flet-video / flet-audio / flet-webview
59
+ - flet-charts
60
+
61
+ > Code components (`Code` / `Json` / `CodeEditor` / `CodeView`) now live in the
62
+ > separate [`cs-code`](../cs-code) project (cs-ui + flet-code-editor). This package
63
+ > has no editor dependency.
64
+
65
+ > No media playback here: audio / video own the timeline, devices and queue state, which
66
+ > makes them applications rather than controls. Wrap your own engine (see
67
+ > `cs-music-player`'s `infra/audio`).
64
68
 
65
69
  ## Install
66
70
 
@@ -127,14 +131,11 @@ panel (it takes layout height and pushes content down); `float_panel=False` turn
127
131
  |---|---|
128
132
  | `ui.core` | Base: `tokens`, `palette` (color engine), `typography`, `theme`, `i18n`, `format`, `responsive`, `doc` (documentation kit) |
129
133
  | `ui.chart` | `BarChart` / `LineChart` / `AreaChart` / `ScatterChart` sharing one data parser and derived palette |
130
- | `ui.display` | `Text` family (`Header_1..6` / `Quote` / `Link` / `Code` / `Markdown` / `Json`), `Calendar`, `Carousel`, `Heatmap`, `Descriptions`, `Tree`, `ListTile`, `Image`, `LogContainer` |
131
- | `ui.display.media` | `Audio` / `AudioPlayer` / `Video` / `Pdf` |
134
+ | `ui.display` | `Text` family (`Header_1..6` / `Quote` / `Link` / `Markdown`), `Calendar`, `Carousel`, `Heatmap`, `Descriptions`, `Tree`, `ListTile`, `Image`, `LogContainer` |
132
135
  | `ui.feedback` | `AlertDialog`, `Message` (receipt for an explicit action), `Notification` (system-level), `Loading`, `ProgressBar` |
133
136
  | `ui.input` | Every form control: `Input`, `Checkbox`, `Radio`, `Switch`, `SelectBox`, `MultiSelect`, `Cascader`, `Transfer`, `Slider`, `Rating`, `Chip`, `ColorPicker`, `DateInput`, `DateTimeInput`, `FilePicker`, `ImagePicker`, `NumberInput`, `SearchBar`, `SegmentedButton`, `Button` |
134
137
  | `ui.layout` | `PageLayout`, `Grid`, `Card`, `Column` / `Row` / `Stack` / `Container`, `Table` (with paging), `Tabs`, `Step`, `Expander`, `Divider` |
135
138
  | `ui.navigation` | `AppBar`, `BreadCrumb`, `Menu`, `Pagination` |
136
- | `ui.utils` | `CodeEditor`, `CodeView` (collapsible, copyable code display) |
137
-
138
139
  To locate a specific component, function or token, `ui-mcp`'s `list_components` is faster than
139
140
  walking the tree.
140
141
 
@@ -411,8 +412,8 @@ needs `read()` / `write()`.
411
412
  from ui import Button, Card, Column, Container, Divider, Row, Text, TextField, ft
412
413
  ```
413
414
 
414
- `ui.__all__` holds 780 names (everything public in flet + each package's `__all__` + submodule names +
415
- `ft`).
415
+ `ui.__all__` merges every public flet name with each subpackage's `__all__`, the submodule
416
+ names and `ft` (count it with `len(ui.__all__)` — the number moves with the flet version).
416
417
 
417
418
  **Imports are lazy**: `import ui` loads only `flet` itself (~0.2s); a component imports its package on
418
419
  first access. A full star-import measured **1.4s** — `ui.chart` alone drags in matplotlib + plotly
@@ -40,7 +40,15 @@ typographic law.
40
40
 
41
41
  - Python >= 3.12
42
42
  - flet[all] >= 1.1.2, < 1.2
43
- - flet-code-editor / flet-charts / flet-video / flet-audio / flet-webview
43
+ - flet-charts
44
+
45
+ > Code components (`Code` / `Json` / `CodeEditor` / `CodeView`) now live in the
46
+ > separate [`cs-code`](../cs-code) project (cs-ui + flet-code-editor). This package
47
+ > has no editor dependency.
48
+
49
+ > No media playback here: audio / video own the timeline, devices and queue state, which
50
+ > makes them applications rather than controls. Wrap your own engine (see
51
+ > `cs-music-player`'s `infra/audio`).
44
52
 
45
53
  ## Install
46
54
 
@@ -107,14 +115,11 @@ panel (it takes layout height and pushes content down); `float_panel=False` turn
107
115
  |---|---|
108
116
  | `ui.core` | Base: `tokens`, `palette` (color engine), `typography`, `theme`, `i18n`, `format`, `responsive`, `doc` (documentation kit) |
109
117
  | `ui.chart` | `BarChart` / `LineChart` / `AreaChart` / `ScatterChart` sharing one data parser and derived palette |
110
- | `ui.display` | `Text` family (`Header_1..6` / `Quote` / `Link` / `Code` / `Markdown` / `Json`), `Calendar`, `Carousel`, `Heatmap`, `Descriptions`, `Tree`, `ListTile`, `Image`, `LogContainer` |
111
- | `ui.display.media` | `Audio` / `AudioPlayer` / `Video` / `Pdf` |
118
+ | `ui.display` | `Text` family (`Header_1..6` / `Quote` / `Link` / `Markdown`), `Calendar`, `Carousel`, `Heatmap`, `Descriptions`, `Tree`, `ListTile`, `Image`, `LogContainer` |
112
119
  | `ui.feedback` | `AlertDialog`, `Message` (receipt for an explicit action), `Notification` (system-level), `Loading`, `ProgressBar` |
113
120
  | `ui.input` | Every form control: `Input`, `Checkbox`, `Radio`, `Switch`, `SelectBox`, `MultiSelect`, `Cascader`, `Transfer`, `Slider`, `Rating`, `Chip`, `ColorPicker`, `DateInput`, `DateTimeInput`, `FilePicker`, `ImagePicker`, `NumberInput`, `SearchBar`, `SegmentedButton`, `Button` |
114
121
  | `ui.layout` | `PageLayout`, `Grid`, `Card`, `Column` / `Row` / `Stack` / `Container`, `Table` (with paging), `Tabs`, `Step`, `Expander`, `Divider` |
115
122
  | `ui.navigation` | `AppBar`, `BreadCrumb`, `Menu`, `Pagination` |
116
- | `ui.utils` | `CodeEditor`, `CodeView` (collapsible, copyable code display) |
117
-
118
123
  To locate a specific component, function or token, `ui-mcp`'s `list_components` is faster than
119
124
  walking the tree.
120
125
 
@@ -391,8 +396,8 @@ needs `read()` / `write()`.
391
396
  from ui import Button, Card, Column, Container, Divider, Row, Text, TextField, ft
392
397
  ```
393
398
 
394
- `ui.__all__` holds 780 names (everything public in flet + each package's `__all__` + submodule names +
395
- `ft`).
399
+ `ui.__all__` merges every public flet name with each subpackage's `__all__`, the submodule
400
+ names and `ft` (count it with `len(ui.__all__)` — the number moves with the flet version).
396
401
 
397
402
  **Imports are lazy**: `import ui` loads only `flet` itself (~0.2s); a component imports its package on
398
403
  first access. A full star-import measured **1.4s** — `ui.chart` alone drags in matplotlib + plotly
@@ -1,48 +1,46 @@
1
- [project]
2
- name = "cs-ui"
3
- version = "0.2.0"
4
- description = "A Python UI framework inspired by Flet"
5
- readme = "README.md"
6
- requires-python = ">=3.12"
7
- authors = [{ name = "Shawn Chen", email = "cs@cstos.com" }]
8
- dependencies = [
9
- "flet[all]>=1.1.2,<1.2",
10
- "flet-code-editor",
11
- "flet-charts",
12
- "flet-video",
13
- "flet-audio",
14
- "flet-webview",
15
- ]
16
-
17
- # ui-mcp(给 AI agent 的组件库 MCP 服务)是可选能力:装它不影响 ui 本身的使用。
18
- [project.optional-dependencies]
19
- mcp = ["fastmcp>=2.0"]
20
-
21
- [project.urls]
22
- Homepage = "https://www.github.com/icstos/cs-ui"
23
- Repository = "https://www.github.com/icstos/cs-ui"
24
- Documentation = "https://www.github.com/icstos/cs-ui"
25
- Issues = "https://www.github.com/icstos/cs-ui/issues"
26
-
27
- [build-system]
28
- requires = ["setuptools>=61.0", "wheel"]
29
- build-backend = "setuptools.build_meta"
30
-
31
- [tool.setuptools]
32
- package-dir = { "ui" = "src/ui", "ui_mcp" = "src/ui_mcp" }
33
- include-package-data = true
34
-
35
-
36
- [tool.setuptools.packages.find]
37
- where = ["src"] # 从 src 目录开始查找
38
- include = ["ui*"] # 匹配顶层包名 + 所有子包(*通配符)
39
-
40
- # 索引产物随包分发(和 flet-mcp 一样:装完即用,不需要额外构建步骤)
41
- [tool.setuptools.package-data]
42
- ui_mcp = ["data/*.json"]
43
-
44
- # [tool.setuptools.package-dir]
45
- # ui = "cs_ui"
46
- [project.scripts]
47
- ui-mcp = "ui_mcp.cli:main"
48
- moss-tts-nano = "ui.cli:main"
1
+ [project]
2
+ name = "cs-ui"
3
+ version = "0.3.0"
4
+ description = "A Python UI framework inspired by Flet"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ authors = [{ name = "Shawn Chen", email = "cs@cstos.com" }]
8
+ dependencies = [
9
+ "flet[all]>=1.1.2,<1.2",
10
+ "flet-charts",
11
+ ]
12
+
13
+ # ui-mcp(给 AI agent 的组件库 MCP 服务)是可选能力:装它不影响 ui 本身的使用。
14
+ [project.optional-dependencies]
15
+ mcp = ["fastmcp>=2.0"]
16
+
17
+ [project.urls]
18
+ Homepage = "https://www.github.com/icstos/cs-ui"
19
+ Repository = "https://www.github.com/icstos/cs-ui"
20
+ Documentation = "https://www.github.com/icstos/cs-ui"
21
+ Issues = "https://www.github.com/icstos/cs-ui/issues"
22
+
23
+ [build-system]
24
+ requires = ["setuptools>=61.0", "wheel"]
25
+ build-backend = "setuptools.build_meta"
26
+
27
+ [tool.setuptools]
28
+ package-dir = { "ui" = "src/ui", "ui_mcp" = "src/ui_mcp" }
29
+ include-package-data = true
30
+
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"] # 从 src 目录开始查找
34
+ include = ["ui*"] # 匹配顶层包名 + 所有子包(*通配符)
35
+
36
+ # 索引产物随包分发(和 flet-mcp 一样:装完即用,不需要额外构建步骤)
37
+ # ui/data/fonts:内置字体必须随 wheel 走。运行时 page.fonts 指向的是**包内**的字体
38
+ # 文件(见 ui/core/fonts.py),漏打包的后果是"开发环境有字体、装出来的程序没有"。
39
+ [tool.setuptools.package-data]
40
+ ui = ["data/fonts/*"]
41
+ ui_mcp = ["data/*.json"]
42
+
43
+ # [tool.setuptools.package-dir]
44
+ # ui = "cs_ui"
45
+ [project.scripts]
46
+ ui-mcp = "ui_mcp.cli:main"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cs-ui
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A Python UI framework inspired by Flet
5
5
  Author-email: Shawn Chen <cs@cstos.com>
6
6
  Project-URL: Homepage, https://www.github.com/icstos/cs-ui
@@ -10,11 +10,7 @@ Project-URL: Issues, https://www.github.com/icstos/cs-ui/issues
10
10
  Requires-Python: >=3.12
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: flet[all]<1.2,>=1.1.2
13
- Requires-Dist: flet-code-editor
14
13
  Requires-Dist: flet-charts
15
- Requires-Dist: flet-video
16
- Requires-Dist: flet-audio
17
- Requires-Dist: flet-webview
18
14
  Provides-Extra: mcp
19
15
  Requires-Dist: fastmcp>=2.0; extra == "mcp"
20
16
 
@@ -60,7 +56,15 @@ typographic law.
60
56
 
61
57
  - Python >= 3.12
62
58
  - flet[all] >= 1.1.2, < 1.2
63
- - flet-code-editor / flet-charts / flet-video / flet-audio / flet-webview
59
+ - flet-charts
60
+
61
+ > Code components (`Code` / `Json` / `CodeEditor` / `CodeView`) now live in the
62
+ > separate [`cs-code`](../cs-code) project (cs-ui + flet-code-editor). This package
63
+ > has no editor dependency.
64
+
65
+ > No media playback here: audio / video own the timeline, devices and queue state, which
66
+ > makes them applications rather than controls. Wrap your own engine (see
67
+ > `cs-music-player`'s `infra/audio`).
64
68
 
65
69
  ## Install
66
70
 
@@ -127,14 +131,11 @@ panel (it takes layout height and pushes content down); `float_panel=False` turn
127
131
  |---|---|
128
132
  | `ui.core` | Base: `tokens`, `palette` (color engine), `typography`, `theme`, `i18n`, `format`, `responsive`, `doc` (documentation kit) |
129
133
  | `ui.chart` | `BarChart` / `LineChart` / `AreaChart` / `ScatterChart` sharing one data parser and derived palette |
130
- | `ui.display` | `Text` family (`Header_1..6` / `Quote` / `Link` / `Code` / `Markdown` / `Json`), `Calendar`, `Carousel`, `Heatmap`, `Descriptions`, `Tree`, `ListTile`, `Image`, `LogContainer` |
131
- | `ui.display.media` | `Audio` / `AudioPlayer` / `Video` / `Pdf` |
134
+ | `ui.display` | `Text` family (`Header_1..6` / `Quote` / `Link` / `Markdown`), `Calendar`, `Carousel`, `Heatmap`, `Descriptions`, `Tree`, `ListTile`, `Image`, `LogContainer` |
132
135
  | `ui.feedback` | `AlertDialog`, `Message` (receipt for an explicit action), `Notification` (system-level), `Loading`, `ProgressBar` |
133
136
  | `ui.input` | Every form control: `Input`, `Checkbox`, `Radio`, `Switch`, `SelectBox`, `MultiSelect`, `Cascader`, `Transfer`, `Slider`, `Rating`, `Chip`, `ColorPicker`, `DateInput`, `DateTimeInput`, `FilePicker`, `ImagePicker`, `NumberInput`, `SearchBar`, `SegmentedButton`, `Button` |
134
137
  | `ui.layout` | `PageLayout`, `Grid`, `Card`, `Column` / `Row` / `Stack` / `Container`, `Table` (with paging), `Tabs`, `Step`, `Expander`, `Divider` |
135
138
  | `ui.navigation` | `AppBar`, `BreadCrumb`, `Menu`, `Pagination` |
136
- | `ui.utils` | `CodeEditor`, `CodeView` (collapsible, copyable code display) |
137
-
138
139
  To locate a specific component, function or token, `ui-mcp`'s `list_components` is faster than
139
140
  walking the tree.
140
141
 
@@ -411,8 +412,8 @@ needs `read()` / `write()`.
411
412
  from ui import Button, Card, Column, Container, Divider, Row, Text, TextField, ft
412
413
  ```
413
414
 
414
- `ui.__all__` holds 780 names (everything public in flet + each package's `__all__` + submodule names +
415
- `ft`).
415
+ `ui.__all__` merges every public flet name with each subpackage's `__all__`, the submodule
416
+ names and `ft` (count it with `len(ui.__all__)` — the number moves with the flet version).
416
417
 
417
418
  **Imports are lazy**: `import ui` loads only `flet` itself (~0.2s); a component imports its package on
418
419
  first access. A full star-import measured **1.4s** — `ui.chart` alone drags in matplotlib + plotly
@@ -26,6 +26,7 @@ src/ui/core/constants.py
26
26
  src/ui/core/doc.py
27
27
  src/ui/core/empty.py
28
28
  src/ui/core/float_layer.py
29
+ src/ui/core/fonts.py
29
30
  src/ui/core/format.py
30
31
  src/ui/core/i18n.py
31
32
  src/ui/core/icons.py
@@ -38,6 +39,7 @@ src/ui/core/styles.py
38
39
  src/ui/core/theme.py
39
40
  src/ui/core/tokens.py
40
41
  src/ui/core/typography.py
42
+ src/ui/data/fonts/AlibabaPuHuiTi-3-55-Regular.otf
41
43
  src/ui/display/__init__.py
42
44
  src/ui/display/calendar.py
43
45
  src/ui/display/carousel.py
@@ -52,11 +54,6 @@ src/ui/display/number_animation.py
52
54
  src/ui/display/tag.py
53
55
  src/ui/display/text.py
54
56
  src/ui/display/tree.py
55
- src/ui/display/media/__init__.py
56
- src/ui/display/media/audio.py
57
- src/ui/display/media/pdf.py
58
- src/ui/display/media/player.py
59
- src/ui/display/media/video.py
60
57
  src/ui/feedback/__init__.py
61
58
  src/ui/feedback/_look.py
62
59
  src/ui/feedback/_overlay.py
@@ -83,6 +80,7 @@ src/ui/input/panel_field.py
83
80
  src/ui/input/radio.py
84
81
  src/ui/input/rating.py
85
82
  src/ui/input/search_bar.py
83
+ src/ui/input/search_field.py
86
84
  src/ui/input/segmented_button.py
87
85
  src/ui/input/select_box.py
88
86
  src/ui/input/slider.py
@@ -112,9 +110,6 @@ src/ui/navigation/menu.py
112
110
  src/ui/navigation/menu_bar.py
113
111
  src/ui/navigation/pagination.py
114
112
  src/ui/navigation/status_bar.py
115
- src/ui/utils/__init__.py
116
- src/ui/utils/code_editor.py
117
- src/ui/utils/code_view.py
118
113
  src/ui_mcp/__about__.py
119
114
  src/ui_mcp/__init__.py
120
115
  src/ui_mcp/__main__.py
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
- moss-tts-nano = ui.cli:main
3
2
  ui-mcp = ui_mcp.cli:main
@@ -1,9 +1,5 @@
1
1
  flet[all]<1.2,>=1.1.2
2
- flet-code-editor
3
2
  flet-charts
4
- flet-video
5
- flet-audio
6
- flet-webview
7
3
 
8
4
  [mcp]
9
5
  fastmcp>=2.0
@@ -1,146 +1,156 @@
1
- """CS UI —— 基于 flet 的组件库。
2
-
3
- 导入策略(**改前先读**,这里的取舍是实测结论):
4
-
5
- ``import ui`` 只加载 ``flet`` 本身(0.19s),组件在第一次被访问时才导入所属子包。
6
- 全量 star-import 实测 1.4~1.6s,钱都花在「用不到也得付」的地方:
7
-
8
- - ``ui.chart`` → ``flet_charts`` → matplotlib + plotly ~0.62s
9
- - 536 个 ``ft.X = ...`` 逐属性反射(触发 flet 懒导入全部子模块) ~0.59s
10
- - 其余子包(display / feedback / input / layout / navigation / utils) ~0.18s
11
-
12
- 改成 PEP 562 模块级 ``__getattr__``:
13
-
14
- 1. ``ui.X`` 首次被访问 → 按 ``_registry.COMPONENT_MODULES`` 导入所属子包并缓存到
15
- ``globals()``,此后就是普通属性查找;
16
- 2. ``ui.<子包名>`` → 直接返回 ui 自己的子模块(**必须先于 flet 判断**:flet 的
17
- ``__all__`` 里也有 ``utils`` / ``input`` / ``icons`` 这类同名项,ui 的子包赢);
18
- 3. 其余交给 ``flet`` —— 只在用到时反射。
19
-
20
- ``dir(ui)`` 仍返回完整名字表(含未加载的),IDE 补全与 ``from ui import *`` 行为不变。
21
- 新增 / 删除组件后必须重新生成注册表:``python scripts/gen_ui_registry.py``。
22
- """
23
-
24
- from __future__ import annotations
25
-
26
- import importlib
27
- from typing import Any as _Any
28
-
29
- import flet as flet
30
-
31
- from ._registry import COMPONENT_MODULES as _COMPONENT_MODULES
32
- from .version import FLET_MIN as FLET_MIN
33
- from .version import FLET_SERIES as FLET_SERIES
34
- from .version import FLET_VERSION as FLET_VERSION
35
- from .version import require_flet as require_flet
36
-
37
- #: 公共别名:README 里 ``from ui import ft`` 取的就是 flet 模块本身
38
- ft = flet
39
-
40
- # 版本守卫:装错 flet 时把问题说清楚,而不是在若干层之后抛 AttributeError。
41
- # 这里用 ``strict=False`` —— 跨版本系列只警告不中断(同系列补丁版行为一致),
42
- # 需要硬门槛的应用自己调 ``require_flet()``。
43
- require_flet(strict=False)
44
-
45
- #: ui 自己的子模块(``ui.layout`` 等)。必须显式登记:flet 的 ``__all__`` 里也有
46
- #: 同名项(``utils`` / ``icons`` / ``padding`` …),不能靠「flet 没有再试子模块」判定。
47
- _SUBMODULES: tuple[str, ...] = (
48
- "app",
49
- "chart",
50
- "cli",
51
- "core",
52
- "display",
53
- "feedback",
54
- "input",
55
- "layout",
56
- "navigation",
57
- "utils",
58
- )
59
-
60
- #: 不属于任何子包 ``__all__``、但要能从 ``ui`` 直接取到的名字
61
- _EXTRA_LAZY: dict[str, str] = {"App": "ui.app"}
62
-
63
- #: 惰性求值的模块级属性。``__version__`` 要读安装元数据(首次约 37ms),
64
- #: 而 `import ui` 本身并不需要它 —— 只有显示版本号的地方(关于页 / CLI)才触发。
65
- #: 不进 ``__all__``:star-import 一直不带下划线名字,这里保持原样。
66
- _LATE_ATTRS: dict[str, str] = {"__version__": "ui.version"}
67
-
68
- #: flet 的**子模块**(不是 ``__all__`` 里的名字,`getattr(flet, ...)` 拿不到)。
69
- #: 原先用 ``from flet import canvas`` 显式导入,光这一行就要 85ms(flet.canvas 会拖进
70
- #: 一整套绘图控件),改成用到时再导入。
71
- _FLET_SUBMODULES: tuple[str, ...] = ("canvas",)
72
-
73
-
74
- def __getattr__(name: str) -> _Any:
75
- """按需加载 ``ui.<name>``(PEP 562)。
76
-
77
- 顺序不可调换:ui 子模块 → ui 组件 → flet 名字。调换会让 ``ui.utils`` 变成
78
- ``flet.utils``、``ui.input`` 变成 ``flet.input``(flet 的 ``__all__`` 就带着这些
79
- 子模块名),而这两个名字在改造前指向的是 ui 自己的子包。
80
- """
81
- if name in _SUBMODULES:
82
- value: _Any = importlib.import_module(f"{__name__}.{name}")
83
- elif name in _FLET_SUBMODULES:
84
- value = importlib.import_module(f"flet.{name}")
85
- else:
86
- module_path = (
87
- _COMPONENT_MODULES.get(name)
88
- or _EXTRA_LAZY.get(name)
89
- or _LATE_ATTRS.get(name)
90
- )
91
- if module_path is not None:
92
- value = getattr(importlib.import_module(module_path), name)
93
- else:
94
- try:
95
- value = getattr(flet, name)
96
- except AttributeError:
97
- raise AttributeError(
98
- f"module {__name__!r} has no attribute {name!r}"
99
- ) from None
100
- globals()[name] = value # 缓存:后续访问不再走 __getattr__
101
- return value
102
-
103
-
104
- def __dir__() -> list[str]:
105
- """完整名字表(含尚未加载的),供 IDE 补全与 ``from ui import *`` 使用。"""
106
- return sorted(
107
- {
108
- *globals(),
109
- *_COMPONENT_MODULES,
110
- *_EXTRA_LAZY,
111
- *_SUBMODULES,
112
- *_FLET_SUBMODULES,
113
- *flet.__all__,
114
- }
115
- )
116
-
117
-
118
- # ``from ui import *`` 的导出面 = flet 全部公开名 + 各子包 __all__ + 子模块名 + 'ft'
119
- # 由几份来源拼成并集,ruff 静态看不到里面的元素类型
120
- __all__ = [ # noqa: PLE0604
121
- *sorted(
122
- {
123
- *flet.__all__,
124
- *_COMPONENT_MODULES,
125
- *_EXTRA_LAZY,
126
- *_SUBMODULES,
127
- *_FLET_SUBMODULES,
128
- "ft",
129
- }
130
- )
131
- ]
132
-
133
-
134
- # ⚠️ 不要在这里写 `__name__ = "cs-ui"`。
135
- # `from ui import X` 在 X 不存在时,CPython 的 _handle_fromlist 会用
136
- # `f"{module.__name__}.{X}"` 去 import 子模块;一旦 __name__ 被改成 "cs-ui",
137
- # 报错就变成极具误导性的 `ModuleNotFoundError: No module named 'cs-ui'`,
138
- # 真正缺失的名字(例如已下线的 ECharts)完全看不出来。
139
- # 产品名放独立字段,别占用 __name__。
140
- __pkg_name__ = "cs-ui"
141
- # ``__version__`` / ``FLET_VERSION`` / ``FLET_MIN`` 由 ``ui.version`` 提供(见文件顶部
142
- # 的导入)—— 版本只允许有一个事实源,别在这里再写一遍字面量。
143
- __author__ = "Shawn Chen"
144
- __email__ = "cs@cstos.com"
145
- __copyright__ = "Shawn Chen"
146
- __url__ = "https://github.com/icstos/cs-ui"
1
+ """CS UI —— 基于 flet 的组件库。
2
+
3
+ 导入策略(**改前先读**,这里的取舍是实测结论):
4
+
5
+ ``import ui`` 只加载 ``flet`` 本身(0.19s),组件在第一次被访问时才导入所属子包。
6
+ 全量 star-import 实测 1.4~1.6s,钱都花在「用不到也得付」的地方:
7
+
8
+ - ``ui.chart`` → ``flet_charts`` → matplotlib + plotly ~0.62s
9
+ - 536 个 ``ft.X = ...`` 逐属性反射(触发 flet 懒导入全部子模块) ~0.59s
10
+ - 其余子包(display / feedback / input / layout / navigation) ~0.18s
11
+
12
+ 改成 PEP 562 模块级 ``__getattr__``:
13
+
14
+ 1. ``ui.X`` 首次被访问 → 按 ``_registry.COMPONENT_MODULES`` 导入所属子包并缓存到
15
+ ``globals()``,此后就是普通属性查找;
16
+ 2. ``ui.<子包名>`` → 直接返回 ui 自己的子模块(**必须先于 flet 判断**:flet 的
17
+ ``__all__`` 里也有 ``input`` / ``icons`` 这类同名项,ui 的子包赢);
18
+ 3. 其余交给 ``flet`` —— 只在用到时反射。
19
+
20
+ ``dir(ui)`` 仍返回完整名字表(含未加载的),IDE 补全与 ``from ui import *`` 行为不变。
21
+ 新增 / 删除组件后必须重新生成注册表:``python scripts/gen_ui_registry.py``。
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ import importlib
27
+ from typing import Any as _Any
28
+
29
+ import flet as flet
30
+
31
+ from ._registry import COMPONENT_MODULES as _COMPONENT_MODULES
32
+ from .version import FLET_MIN as FLET_MIN
33
+ from .version import FLET_SERIES as FLET_SERIES
34
+ from .version import FLET_VERSION as FLET_VERSION
35
+ from .version import require_flet as require_flet
36
+
37
+ #: 公共别名:README 里 ``from ui import ft`` 取的就是 flet 模块本身
38
+ ft = flet
39
+
40
+ # 版本守卫:装错 flet 时把问题说清楚,而不是在若干层之后抛 AttributeError。
41
+ # 这里用 ``strict=False`` —— 跨版本系列只警告不中断(同系列补丁版行为一致),
42
+ # 需要硬门槛的应用自己调 ``require_flet()``。
43
+ require_flet(strict=False)
44
+
45
+ #: ui 自己的子模块(``ui.layout`` 等)。必须显式登记:flet 的 ``__all__`` 里也有
46
+ #: 同名项(``icons`` / ``padding`` …),不能靠「flet 没有再试子模块」判定。
47
+ _SUBMODULES: tuple[str, ...] = (
48
+ "app",
49
+ "chart",
50
+ "cli",
51
+ "core",
52
+ "display",
53
+ "feedback",
54
+ "input",
55
+ "layout",
56
+ "navigation",
57
+ )
58
+
59
+ #: 不属于任何子包 ``__all__``、但要能从 ``ui`` 直接取到的名字。
60
+ #: 字体这几个是应用入口最常用的:「注册内置字体」和「主题」是同一件事的两半,
61
+ #: 让它们和 ``apply_theme`` 一样能一行取到,应用就不必知道字体住在包内哪个角落。
62
+ _EXTRA_LAZY: dict[str, str] = {
63
+ "App": "ui.app",
64
+ "FONT_FAMILY": "ui.core.fonts",
65
+ "apply_fonts": "ui.core.fonts",
66
+ "font_file": "ui.core.fonts",
67
+ # 声明式范式的核心容器:应用构造 observable 文档/列表时需要它,而 flet
68
+ # 并未把它放进顶层 __all__。由 cs-ui 统一暴露,应用就不必去 import
69
+ # flet 的内部模块路径(那条路径随版本重组会静默断裂)。
70
+ "ObservableList": "flet.components.observable",
71
+ }
72
+
73
+ #: 惰性求值的模块级属性。``__version__`` 要读安装元数据(首次约 37ms),
74
+ #: 而 `import ui` 本身并不需要它 —— 只有显示版本号的地方(关于页 / CLI)才触发。
75
+ #: 不进 ``__all__``:star-import 一直不带下划线名字,这里保持原样。
76
+ _LATE_ATTRS: dict[str, str] = {"__version__": "ui.version"}
77
+
78
+ #: flet 的**子模块**(不是 ``__all__`` 里的名字,`getattr(flet, ...)` 拿不到)。
79
+ #: 原先用 ``from flet import canvas`` 显式导入,光这一行就要 85ms(flet.canvas 会拖进
80
+ #: 一整套绘图控件),改成用到时再导入。
81
+ _FLET_SUBMODULES: tuple[str, ...] = ("canvas",)
82
+
83
+
84
+ def __getattr__(name: str) -> _Any:
85
+ """按需加载 ``ui.<name>``(PEP 562)。
86
+
87
+ 顺序不可调换:ui 子模块 → ui 组件 → flet 名字。调换会让 ``ui.input`` 变成
88
+ ``flet.input``(flet 的 ``__all__`` 就带着这个子模块名),而它本该指向
89
+ ui 自己的子包。
90
+ """
91
+ if name in _SUBMODULES:
92
+ value: _Any = importlib.import_module(f"{__name__}.{name}")
93
+ elif name in _FLET_SUBMODULES:
94
+ value = importlib.import_module(f"flet.{name}")
95
+ else:
96
+ module_path = (
97
+ _COMPONENT_MODULES.get(name)
98
+ or _EXTRA_LAZY.get(name)
99
+ or _LATE_ATTRS.get(name)
100
+ )
101
+ if module_path is not None:
102
+ value = getattr(importlib.import_module(module_path), name)
103
+ else:
104
+ try:
105
+ value = getattr(flet, name)
106
+ except AttributeError:
107
+ raise AttributeError(
108
+ f"module {__name__!r} has no attribute {name!r}"
109
+ ) from None
110
+ globals()[name] = value # 缓存:后续访问不再走 __getattr__
111
+ return value
112
+
113
+
114
+ def __dir__() -> list[str]:
115
+ """完整名字表(含尚未加载的),供 IDE 补全与 ``from ui import *`` 使用。"""
116
+ return sorted(
117
+ {
118
+ *globals(),
119
+ *_COMPONENT_MODULES,
120
+ *_EXTRA_LAZY,
121
+ *_SUBMODULES,
122
+ *_FLET_SUBMODULES,
123
+ *flet.__all__,
124
+ }
125
+ )
126
+
127
+
128
+ # ``from ui import *`` 的导出面 = flet 全部公开名 + 各子包 __all__ + 子模块名 + 'ft'
129
+ # 由几份来源拼成并集,ruff 静态看不到里面的元素类型
130
+ __all__ = [ # noqa: PLE0604
131
+ *sorted(
132
+ {
133
+ *flet.__all__,
134
+ *_COMPONENT_MODULES,
135
+ *_EXTRA_LAZY,
136
+ *_SUBMODULES,
137
+ *_FLET_SUBMODULES,
138
+ "ft",
139
+ }
140
+ )
141
+ ]
142
+
143
+
144
+ # ⚠️ 不要在这里写 `__name__ = "cs-ui"`。
145
+ # `from ui import X` 在 X 不存在时,CPython 的 _handle_fromlist 会用
146
+ # `f"{module.__name__}.{X}"` 去 import 子模块;一旦 __name__ 被改成 "cs-ui",
147
+ # 报错就变成极具误导性的 `ModuleNotFoundError: No module named 'cs-ui'`,
148
+ # 真正缺失的名字(例如已下线的 ECharts)完全看不出来。
149
+ # 产品名放独立字段,别占用 __name__。
150
+ __pkg_name__ = "cs-ui"
151
+ # ``__version__`` / ``FLET_VERSION`` / ``FLET_MIN`` 由 ``ui.version`` 提供(见文件顶部
152
+ # 的导入)—— 版本只允许有一个事实源,别在这里再写一遍字面量。
153
+ __author__ = "Shawn Chen"
154
+ __email__ = "cs@cstos.com"
155
+ __copyright__ = "Shawn Chen"
156
+ __url__ = "https://github.com/icstos/cs-ui"