dash-startup-loading-plugin 0.4.0__tar.gz → 1.0.1__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.
- dash_startup_loading_plugin-1.0.1/MANIFEST.in +1 -0
- dash_startup_loading_plugin-1.0.1/PKG-INFO +274 -0
- dash_startup_loading_plugin-1.0.1/README.md +260 -0
- dash_startup_loading_plugin-1.0.1/README.zh-CN.md +249 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/pyproject.toml +1 -1
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/__init__.py +5 -5
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/antd.py +2 -2
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/fac.py +1 -1
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/mantine.py +2 -2
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/plugin.py +5 -5
- dash_startup_loading_plugin-1.0.1/src/dash_startup_loading_plugin.egg-info/PKG-INFO +274 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin.egg-info/SOURCES.txt +3 -0
- dash_startup_loading_plugin-1.0.1/tests/test_documentation.py +28 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/tests/test_plugin.py +13 -5
- dash_startup_loading_plugin-0.4.0/PKG-INFO +0 -526
- dash_startup_loading_plugin-0.4.0/README.md +0 -512
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin.egg-info/PKG-INFO +0 -526
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/LICENSE +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/setup.cfg +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/__init__.py +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/__main__.py +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/basic.py +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/cli.py +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/examples/shared.py +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/resources/loading.css +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/resources/loading.js +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin/resources/theme.js +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin.egg-info/dependency_links.txt +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin.egg-info/entry_points.txt +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin.egg-info/requires.txt +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/src/dash_startup_loading_plugin.egg-info/top_level.txt +0 -0
- {dash_startup_loading_plugin-0.4.0 → dash_startup_loading_plugin-1.0.1}/tests/test_examples.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include README.zh-CN.md
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dash-startup-loading-plugin
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: A configurable full-screen startup loading overlay for Dash apps, packaged as a Dash Hooks plugin.
|
|
5
|
+
Author-email: Ethan Zhang <ethan.zhang2016@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: dash,plotly,loading,plugin
|
|
8
|
+
Classifier: Framework :: Dash
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: dash>=3.0.3
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# dash-startup-loading-plugin
|
|
16
|
+
|
|
17
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
18
|
+
|
|
19
|
+
An installable [Dash Hooks plugin](https://dash.plotly.com/dash-plugins-using-hooks)
|
|
20
|
+
that replaces Dash's initial loading presentation with a configurable
|
|
21
|
+
full-screen overlay.
|
|
22
|
+
|
|
23
|
+
The plugin injects its CSS and JavaScript into Dash's normal index document
|
|
24
|
+
before React mounts. Applications do not need to copy assets or replace
|
|
25
|
+
`index_string`, and Dash's built-in `<div class="_dash-loading">` remains in the
|
|
26
|
+
document.
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- Python 3.9 or later
|
|
31
|
+
- Dash 3.0.3 or later
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install "dash-startup-loading-plugin>=1.0.1"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Dash discovers the plugin through its `dash_hooks` entry point. Installing the
|
|
40
|
+
package enables the default loading overlay without an explicit import.
|
|
41
|
+
|
|
42
|
+
When Dash Ant Design (`dash_antd_components`) is installed, the plugin detects
|
|
43
|
+
it automatically and applies matching light and dark loading backgrounds.
|
|
44
|
+
|
|
45
|
+
## Quick start
|
|
46
|
+
|
|
47
|
+
The default configuration requires no plugin-specific code:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from dash import Dash, html
|
|
51
|
+
|
|
52
|
+
app = Dash(__name__)
|
|
53
|
+
app.layout = html.Main(
|
|
54
|
+
[
|
|
55
|
+
html.H1("My Dash app"),
|
|
56
|
+
html.P("The overlay closes after this layout is ready."),
|
|
57
|
+
]
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
app.run(debug=True)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Call `configure()` before creating `Dash` when custom behavior is needed:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from dash import Dash, html
|
|
68
|
+
from dash_startup_loading_plugin import configure
|
|
69
|
+
|
|
70
|
+
configure(
|
|
71
|
+
required_selectors=["#header", "#sidebar-menu"],
|
|
72
|
+
pending_selector="[data-async-placeholder]",
|
|
73
|
+
timeout_ms=6000,
|
|
74
|
+
minimum_display_ms=250,
|
|
75
|
+
fade_duration_ms=180,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
app = Dash(__name__)
|
|
79
|
+
app.layout = html.Main(
|
|
80
|
+
[
|
|
81
|
+
html.Header("Header", id="header"),
|
|
82
|
+
html.Nav("Sidebar", id="sidebar-menu"),
|
|
83
|
+
]
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Component-library integrations
|
|
88
|
+
|
|
89
|
+
Component libraries are not dependencies of this package. Install only the
|
|
90
|
+
libraries used by the application.
|
|
91
|
+
|
|
92
|
+
### Dash Ant Design
|
|
93
|
+
|
|
94
|
+
Dash Ant Design is detected automatically. `configure_dac()` is only required
|
|
95
|
+
to override its defaults:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install dash-ant-design
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The plugin does not impose a Dash Ant Design version constraint. Use the
|
|
102
|
+
version compatible with the application's Python and Dash versions.
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from dash_startup_loading_plugin import configure_dac
|
|
106
|
+
|
|
107
|
+
configure_dac(
|
|
108
|
+
background="#f5f5f5",
|
|
109
|
+
dark_background="#202020",
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Dash Mantine Components
|
|
114
|
+
|
|
115
|
+
`configure_dmc()` uses Mantine's active default theme and registers its
|
|
116
|
+
pre-render color-scheme hook:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pip install dash-mantine-components
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from dash_startup_loading_plugin import configure_dmc
|
|
124
|
+
|
|
125
|
+
configure_dmc()
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### feffery-antd-components
|
|
129
|
+
|
|
130
|
+
Use `configure_fac()` to match the loading overlay to
|
|
131
|
+
`AntdConfigProvider`:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pip install feffery-antd-components
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The plugin does not pin a feffery-antd-components version. Compatibility is
|
|
138
|
+
determined by the installed component library.
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from dash_startup_loading_plugin import configure_fac
|
|
142
|
+
|
|
143
|
+
configure_fac(required_selectors=["#fac-app-ready"])
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Installed examples
|
|
147
|
+
|
|
148
|
+
The package includes four runnable examples:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Dash
|
|
152
|
+
dash-startup-loading-plugin examples.dash
|
|
153
|
+
|
|
154
|
+
# Dash Mantine Components
|
|
155
|
+
dash-startup-loading-plugin examples.dash-mantine-components
|
|
156
|
+
|
|
157
|
+
# Dash Ant Design
|
|
158
|
+
dash-startup-loading-plugin examples.dash-ant-design
|
|
159
|
+
|
|
160
|
+
# feffery-antd-components
|
|
161
|
+
dash-startup-loading-plugin examples.feffery-antd-components
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Install the selected example's component library separately. If it cannot be
|
|
165
|
+
imported, the command reports the failed module and the corresponding
|
|
166
|
+
installation command.
|
|
167
|
+
|
|
168
|
+
Server options are available on every example:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
dash-startup-loading-plugin examples.dash \
|
|
172
|
+
--host 127.0.0.1 --port 8050 --debug
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Readiness behavior
|
|
176
|
+
|
|
177
|
+
The overlay closes when:
|
|
178
|
+
|
|
179
|
+
1. `root_selector` exists and no longer contains `._dash-loading`.
|
|
180
|
+
2. The root contains rendered content.
|
|
181
|
+
3. Every `required_selectors` entry exists.
|
|
182
|
+
4. No `pending_selector` node remains under the root.
|
|
183
|
+
5. The conditions remain true for two animation frames.
|
|
184
|
+
|
|
185
|
+
`timeout_ms` is a forced-dismiss fallback. `minimum_display_ms` applies to
|
|
186
|
+
ready and manual dismissal, but does not delay a timeout.
|
|
187
|
+
|
|
188
|
+
`pending_selector` delays dismissal while any matching element remains inside
|
|
189
|
+
`root_selector`. It is useful for lazy or asynchronous placeholders that are
|
|
190
|
+
mounted before the real content. Set it to an application-specific CSS
|
|
191
|
+
selector, or use `None` when no pending-node check is needed:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
configure(pending_selector="[data-async-placeholder]")
|
|
195
|
+
configure(pending_selector=None)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Configuration
|
|
199
|
+
|
|
200
|
+
`configure(**changes)` updates the process-wide immutable
|
|
201
|
+
`StartupLoadingConfig`.
|
|
202
|
+
|
|
203
|
+
| Option | Default | Description |
|
|
204
|
+
|---|---:|---|
|
|
205
|
+
| `enabled` | `True` | Enable index injection. |
|
|
206
|
+
| `overlay_id` | `"dash-loading"` | Injected overlay ID. |
|
|
207
|
+
| `aria_label` | `"Loading"` | Accessible status label. |
|
|
208
|
+
| `root_selector` | `"#react-entry-point"` | Root observed for rendered content. |
|
|
209
|
+
| `required_selectors` | `("#react-entry-point",)` | Selectors that must exist before dismissal. |
|
|
210
|
+
| `pending_selector` | `"[data-dac-async-placeholder]"` | Selector checked under `root_selector`; dismissal waits until all matches disappear. Use `None` to disable. |
|
|
211
|
+
| `timeout_ms` | `6000` | Forced-dismiss timeout; use `None` to disable. |
|
|
212
|
+
| `minimum_display_ms` | `0` | Minimum display time. |
|
|
213
|
+
| `fade_duration_ms` | `160` | Fade-out duration. |
|
|
214
|
+
| `z_index` | `9999` | Overlay stacking order. |
|
|
215
|
+
| `background` | `"#ffffff"` | Light background. |
|
|
216
|
+
| `dark_background` | `"#0f0f0f"` | Dark background. |
|
|
217
|
+
| `color` | `"#1677ff"` | Light spinner color. |
|
|
218
|
+
| `dark_color` | `"#4096ff"` | Dark spinner color. |
|
|
219
|
+
| `theme_mode` | `"auto"` | `"auto"`, `"light"`, or `"dark"`. |
|
|
220
|
+
| `dash_theme_component_id` | `None` | Preferred persisted Dash theme component. |
|
|
221
|
+
| `spinner_size_px` | `28` | Spinner width and height. |
|
|
222
|
+
| `spinner_stroke_px` | `3` | Spinner stroke width. |
|
|
223
|
+
| `hide_default_loading` | `True` | Hide the visual `._dash-loading` indicator while the overlay exists. |
|
|
224
|
+
| `custom_loader_html` | `None` | Trusted HTML replacing the default spinner. |
|
|
225
|
+
|
|
226
|
+
`custom_loader_html` is inserted verbatim and must never contain untrusted
|
|
227
|
+
user input.
|
|
228
|
+
|
|
229
|
+
## Python API
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from dash_startup_loading_plugin import (
|
|
233
|
+
StartupLoadingConfig,
|
|
234
|
+
configure,
|
|
235
|
+
configure_dac,
|
|
236
|
+
configure_fac,
|
|
237
|
+
configure_dmc,
|
|
238
|
+
get_config,
|
|
239
|
+
reset_config,
|
|
240
|
+
)
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Browser API
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
// Recheck readiness.
|
|
247
|
+
window.dashLoading.check();
|
|
248
|
+
|
|
249
|
+
// Dismiss the default or a custom overlay.
|
|
250
|
+
window.dashLoading.finish();
|
|
251
|
+
window.dashLoading.finish("my-loading-overlay");
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Before fading out, the overlay emits a bubbling `dash-loading:ready` event.
|
|
255
|
+
`event.detail.reason` is `"ready"`, `"timeout"`, or `"manual"`.
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
document.addEventListener("dash-loading:ready", function (event) {
|
|
259
|
+
console.log(event.detail.reason);
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Notes
|
|
264
|
+
|
|
265
|
+
- Dash's hook and plugin configuration is process-wide. Use one configuration
|
|
266
|
+
per process.
|
|
267
|
+
- Resources are inlined, so strict Content Security Policy deployments must
|
|
268
|
+
allow the injected style and script.
|
|
269
|
+
- The overlay is only for initial application startup. Use `dcc.Loading` or
|
|
270
|
+
another callback-specific pattern for later callback execution.
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
MIT
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# dash-startup-loading-plugin
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
An installable [Dash Hooks plugin](https://dash.plotly.com/dash-plugins-using-hooks)
|
|
6
|
+
that replaces Dash's initial loading presentation with a configurable
|
|
7
|
+
full-screen overlay.
|
|
8
|
+
|
|
9
|
+
The plugin injects its CSS and JavaScript into Dash's normal index document
|
|
10
|
+
before React mounts. Applications do not need to copy assets or replace
|
|
11
|
+
`index_string`, and Dash's built-in `<div class="_dash-loading">` remains in the
|
|
12
|
+
document.
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Python 3.9 or later
|
|
17
|
+
- Dash 3.0.3 or later
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install "dash-startup-loading-plugin>=1.0.1"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Dash discovers the plugin through its `dash_hooks` entry point. Installing the
|
|
26
|
+
package enables the default loading overlay without an explicit import.
|
|
27
|
+
|
|
28
|
+
When Dash Ant Design (`dash_antd_components`) is installed, the plugin detects
|
|
29
|
+
it automatically and applies matching light and dark loading backgrounds.
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
The default configuration requires no plugin-specific code:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from dash import Dash, html
|
|
37
|
+
|
|
38
|
+
app = Dash(__name__)
|
|
39
|
+
app.layout = html.Main(
|
|
40
|
+
[
|
|
41
|
+
html.H1("My Dash app"),
|
|
42
|
+
html.P("The overlay closes after this layout is ready."),
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
app.run(debug=True)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Call `configure()` before creating `Dash` when custom behavior is needed:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from dash import Dash, html
|
|
54
|
+
from dash_startup_loading_plugin import configure
|
|
55
|
+
|
|
56
|
+
configure(
|
|
57
|
+
required_selectors=["#header", "#sidebar-menu"],
|
|
58
|
+
pending_selector="[data-async-placeholder]",
|
|
59
|
+
timeout_ms=6000,
|
|
60
|
+
minimum_display_ms=250,
|
|
61
|
+
fade_duration_ms=180,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
app = Dash(__name__)
|
|
65
|
+
app.layout = html.Main(
|
|
66
|
+
[
|
|
67
|
+
html.Header("Header", id="header"),
|
|
68
|
+
html.Nav("Sidebar", id="sidebar-menu"),
|
|
69
|
+
]
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Component-library integrations
|
|
74
|
+
|
|
75
|
+
Component libraries are not dependencies of this package. Install only the
|
|
76
|
+
libraries used by the application.
|
|
77
|
+
|
|
78
|
+
### Dash Ant Design
|
|
79
|
+
|
|
80
|
+
Dash Ant Design is detected automatically. `configure_dac()` is only required
|
|
81
|
+
to override its defaults:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install dash-ant-design
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The plugin does not impose a Dash Ant Design version constraint. Use the
|
|
88
|
+
version compatible with the application's Python and Dash versions.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from dash_startup_loading_plugin import configure_dac
|
|
92
|
+
|
|
93
|
+
configure_dac(
|
|
94
|
+
background="#f5f5f5",
|
|
95
|
+
dark_background="#202020",
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Dash Mantine Components
|
|
100
|
+
|
|
101
|
+
`configure_dmc()` uses Mantine's active default theme and registers its
|
|
102
|
+
pre-render color-scheme hook:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pip install dash-mantine-components
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from dash_startup_loading_plugin import configure_dmc
|
|
110
|
+
|
|
111
|
+
configure_dmc()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### feffery-antd-components
|
|
115
|
+
|
|
116
|
+
Use `configure_fac()` to match the loading overlay to
|
|
117
|
+
`AntdConfigProvider`:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install feffery-antd-components
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The plugin does not pin a feffery-antd-components version. Compatibility is
|
|
124
|
+
determined by the installed component library.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from dash_startup_loading_plugin import configure_fac
|
|
128
|
+
|
|
129
|
+
configure_fac(required_selectors=["#fac-app-ready"])
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Installed examples
|
|
133
|
+
|
|
134
|
+
The package includes four runnable examples:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Dash
|
|
138
|
+
dash-startup-loading-plugin examples.dash
|
|
139
|
+
|
|
140
|
+
# Dash Mantine Components
|
|
141
|
+
dash-startup-loading-plugin examples.dash-mantine-components
|
|
142
|
+
|
|
143
|
+
# Dash Ant Design
|
|
144
|
+
dash-startup-loading-plugin examples.dash-ant-design
|
|
145
|
+
|
|
146
|
+
# feffery-antd-components
|
|
147
|
+
dash-startup-loading-plugin examples.feffery-antd-components
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Install the selected example's component library separately. If it cannot be
|
|
151
|
+
imported, the command reports the failed module and the corresponding
|
|
152
|
+
installation command.
|
|
153
|
+
|
|
154
|
+
Server options are available on every example:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
dash-startup-loading-plugin examples.dash \
|
|
158
|
+
--host 127.0.0.1 --port 8050 --debug
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Readiness behavior
|
|
162
|
+
|
|
163
|
+
The overlay closes when:
|
|
164
|
+
|
|
165
|
+
1. `root_selector` exists and no longer contains `._dash-loading`.
|
|
166
|
+
2. The root contains rendered content.
|
|
167
|
+
3. Every `required_selectors` entry exists.
|
|
168
|
+
4. No `pending_selector` node remains under the root.
|
|
169
|
+
5. The conditions remain true for two animation frames.
|
|
170
|
+
|
|
171
|
+
`timeout_ms` is a forced-dismiss fallback. `minimum_display_ms` applies to
|
|
172
|
+
ready and manual dismissal, but does not delay a timeout.
|
|
173
|
+
|
|
174
|
+
`pending_selector` delays dismissal while any matching element remains inside
|
|
175
|
+
`root_selector`. It is useful for lazy or asynchronous placeholders that are
|
|
176
|
+
mounted before the real content. Set it to an application-specific CSS
|
|
177
|
+
selector, or use `None` when no pending-node check is needed:
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
configure(pending_selector="[data-async-placeholder]")
|
|
181
|
+
configure(pending_selector=None)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Configuration
|
|
185
|
+
|
|
186
|
+
`configure(**changes)` updates the process-wide immutable
|
|
187
|
+
`StartupLoadingConfig`.
|
|
188
|
+
|
|
189
|
+
| Option | Default | Description |
|
|
190
|
+
|---|---:|---|
|
|
191
|
+
| `enabled` | `True` | Enable index injection. |
|
|
192
|
+
| `overlay_id` | `"dash-loading"` | Injected overlay ID. |
|
|
193
|
+
| `aria_label` | `"Loading"` | Accessible status label. |
|
|
194
|
+
| `root_selector` | `"#react-entry-point"` | Root observed for rendered content. |
|
|
195
|
+
| `required_selectors` | `("#react-entry-point",)` | Selectors that must exist before dismissal. |
|
|
196
|
+
| `pending_selector` | `"[data-dac-async-placeholder]"` | Selector checked under `root_selector`; dismissal waits until all matches disappear. Use `None` to disable. |
|
|
197
|
+
| `timeout_ms` | `6000` | Forced-dismiss timeout; use `None` to disable. |
|
|
198
|
+
| `minimum_display_ms` | `0` | Minimum display time. |
|
|
199
|
+
| `fade_duration_ms` | `160` | Fade-out duration. |
|
|
200
|
+
| `z_index` | `9999` | Overlay stacking order. |
|
|
201
|
+
| `background` | `"#ffffff"` | Light background. |
|
|
202
|
+
| `dark_background` | `"#0f0f0f"` | Dark background. |
|
|
203
|
+
| `color` | `"#1677ff"` | Light spinner color. |
|
|
204
|
+
| `dark_color` | `"#4096ff"` | Dark spinner color. |
|
|
205
|
+
| `theme_mode` | `"auto"` | `"auto"`, `"light"`, or `"dark"`. |
|
|
206
|
+
| `dash_theme_component_id` | `None` | Preferred persisted Dash theme component. |
|
|
207
|
+
| `spinner_size_px` | `28` | Spinner width and height. |
|
|
208
|
+
| `spinner_stroke_px` | `3` | Spinner stroke width. |
|
|
209
|
+
| `hide_default_loading` | `True` | Hide the visual `._dash-loading` indicator while the overlay exists. |
|
|
210
|
+
| `custom_loader_html` | `None` | Trusted HTML replacing the default spinner. |
|
|
211
|
+
|
|
212
|
+
`custom_loader_html` is inserted verbatim and must never contain untrusted
|
|
213
|
+
user input.
|
|
214
|
+
|
|
215
|
+
## Python API
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
from dash_startup_loading_plugin import (
|
|
219
|
+
StartupLoadingConfig,
|
|
220
|
+
configure,
|
|
221
|
+
configure_dac,
|
|
222
|
+
configure_fac,
|
|
223
|
+
configure_dmc,
|
|
224
|
+
get_config,
|
|
225
|
+
reset_config,
|
|
226
|
+
)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Browser API
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
// Recheck readiness.
|
|
233
|
+
window.dashLoading.check();
|
|
234
|
+
|
|
235
|
+
// Dismiss the default or a custom overlay.
|
|
236
|
+
window.dashLoading.finish();
|
|
237
|
+
window.dashLoading.finish("my-loading-overlay");
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Before fading out, the overlay emits a bubbling `dash-loading:ready` event.
|
|
241
|
+
`event.detail.reason` is `"ready"`, `"timeout"`, or `"manual"`.
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
document.addEventListener("dash-loading:ready", function (event) {
|
|
245
|
+
console.log(event.detail.reason);
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Notes
|
|
250
|
+
|
|
251
|
+
- Dash's hook and plugin configuration is process-wide. Use one configuration
|
|
252
|
+
per process.
|
|
253
|
+
- Resources are inlined, so strict Content Security Policy deployments must
|
|
254
|
+
allow the injected style and script.
|
|
255
|
+
- The overlay is only for initial application startup. Use `dcc.Loading` or
|
|
256
|
+
another callback-specific pattern for later callback execution.
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
MIT
|