neutralino-python 0.1.0rc1__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.
- neutralino/__init__.py +88 -0
- neutralino/_catalog.py +297 -0
- neutralino/_data/LICENSE.neutralino-js-client +21 -0
- neutralino/_data/LICENSE.neutralinojs +1066 -0
- neutralino/_data/docs/cli.md +315 -0
- neutralino/_data/docs/custom-components.md +107 -0
- neutralino/_data/docs/custom-frontends.md +80 -0
- neutralino/_data/docs/desktop-helpers.md +296 -0
- neutralino/_data/docs/guide.md +131 -0
- neutralino/_data/docs/llms-full.txt +3921 -0
- neutralino/_data/docs/llms.txt +43 -0
- neutralino/_data/docs/manifests/components.json +20128 -0
- neutralino/_data/docs/manifests/examples.json +52 -0
- neutralino/_data/docs/manifests/native.json +3024 -0
- neutralino/_data/docs/manifests/schema.json +43 -0
- neutralino/_data/docs/manual-checklist.md +189 -0
- neutralino/_data/docs/packaging.md +252 -0
- neutralino/_data/docs/performance.md +15 -0
- neutralino/_data/docs/platforms.md +15 -0
- neutralino/_data/docs/reference/components.md +1685 -0
- neutralino/_data/docs/reference/native.md +148 -0
- neutralino/_data/docs/security.md +60 -0
- neutralino/_data/docs/ui.md +249 -0
- neutralino/_data/docs/updates.md +366 -0
- neutralino/_data/examples/README.md +6 -0
- neutralino/_data/examples/crud/README.md +36 -0
- neutralino/_data/examples/crud/app.py +243 -0
- neutralino/_data/examples/dashboard/README.md +36 -0
- neutralino/_data/examples/dashboard/app.py +367 -0
- neutralino/_data/examples/editor/README.md +35 -0
- neutralino/_data/examples/editor/app.py +190 -0
- neutralino/_data/examples/file-manager/README.md +40 -0
- neutralino/_data/examples/file-manager/app.py +120 -0
- neutralino/_data/examples/file-manager/frontend/index.html +20 -0
- neutralino/_data/examples/file-manager/frontend/main.js +55 -0
- neutralino/_data/examples/file-manager/frontend/neutralino.js +1 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/file-manager/frontend/style.css +4 -0
- neutralino/_data/examples/hybrid/README.md +48 -0
- neutralino/_data/examples/hybrid/app.py +80 -0
- neutralino/_data/examples/hybrid/components/counter.mjs +37 -0
- neutralino/_data/examples/hybrid/components/widget.mjs +23 -0
- neutralino/_data/examples/hybrid/styles.css +21 -0
- neutralino/_data/examples/hybrid/widget/package.json +20 -0
- neutralino/_data/examples/hybrid/widget/src/Widget.jsx +25 -0
- neutralino/_data/examples/hybrid/widget/vite.config.mjs +19 -0
- neutralino/_data/examples/monitor/README.md +36 -0
- neutralino/_data/examples/monitor/app.py +375 -0
- neutralino/_data/examples/react/README.md +90 -0
- neutralino/_data/examples/react/app.py +68 -0
- neutralino/_data/examples/react/frontend/.gitignore +5 -0
- neutralino/_data/examples/react/frontend/index.html +17 -0
- neutralino/_data/examples/react/frontend/package-lock.json +1232 -0
- neutralino/_data/examples/react/frontend/package.json +25 -0
- neutralino/_data/examples/react/frontend/scripts/prepare-bridge.mjs +49 -0
- neutralino/_data/examples/react/frontend/src/App.tsx +157 -0
- neutralino/_data/examples/react/frontend/src/backend.ts +21 -0
- neutralino/_data/examples/react/frontend/src/calls.test.ts +206 -0
- neutralino/_data/examples/react/frontend/src/calls.ts +306 -0
- neutralino/_data/examples/react/frontend/src/globals.d.ts +14 -0
- neutralino/_data/examples/react/frontend/src/hooks.ts +45 -0
- neutralino/_data/examples/react/frontend/src/main.tsx +13 -0
- neutralino/_data/examples/react/frontend/src/styles.css +11 -0
- neutralino/_data/examples/react/frontend/tsconfig.json +18 -0
- neutralino/_data/examples/react/frontend/vite.config.ts +9 -0
- neutralino/_data/examples/settings/README.md +38 -0
- neutralino/_data/examples/settings/app.py +440 -0
- neutralino/_data/examples/updater/.gitignore +2 -0
- neutralino/_data/examples/updater/README.md +82 -0
- neutralino/_data/examples/updater/app.py +160 -0
- neutralino/_data/examples/updater/app.toml +21 -0
- neutralino/_data/examples/updater/demo.py +107 -0
- neutralino/_data/examples/updater/requirements.txt +2 -0
- neutralino/_data/examples/updater/sources/github-private.toml +21 -0
- neutralino/_data/examples/updater/sources/github-public.toml +21 -0
- neutralino/_data/examples/vanilla/README.md +35 -0
- neutralino/_data/examples/vanilla/app.py +46 -0
- neutralino/_data/examples/vanilla/frontend/index.html +17 -0
- neutralino/_data/examples/vanilla/frontend/main.js +29 -0
- neutralino/_data/examples/vanilla/frontend/neutralino.js +1 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/vanilla/frontend/style.css +4 -0
- neutralino/_data/explorer/app.py +1328 -0
- neutralino/_data/explorer/catalogue.json +48179 -0
- neutralino/_data/explorer/explorer_previews.py +247 -0
- neutralino/_data/explorer/sources/native/always_on_top.py +55 -0
- neutralino/_data/explorer/sources/native/binary.py +125 -0
- neutralino/_data/explorer/sources/native/borderless.py +99 -0
- neutralino/_data/explorer/sources/native/broadcast.py +90 -0
- neutralino/_data/explorer/sources/native/config.py +78 -0
- neutralino/_data/explorer/sources/native/controls.py +140 -0
- neutralino/_data/explorer/sources/native/directory.py +163 -0
- neutralino/_data/explorer/sources/native/displays.py +75 -0
- neutralino/_data/explorer/sources/native/env.py +98 -0
- neutralino/_data/explorer/sources/native/events.py +124 -0
- neutralino/_data/explorer/sources/native/exec_command.py +79 -0
- neutralino/_data/explorer/sources/native/folder.py +70 -0
- neutralino/_data/explorer/sources/native/icon_badge.py +101 -0
- neutralino/_data/explorer/sources/native/image.py +119 -0
- neutralino/_data/explorer/sources/native/lifecycle.py +99 -0
- neutralino/_data/explorer/sources/native/locale.py +70 -0
- neutralino/_data/explorer/sources/native/main_menu.py +103 -0
- neutralino/_data/explorer/sources/native/message_box.py +101 -0
- neutralino/_data/explorer/sources/native/mouse.py +70 -0
- neutralino/_data/explorer/sources/native/multi_window.py +134 -0
- neutralino/_data/explorer/sources/native/notification.py +74 -0
- neutralino/_data/explorer/sources/native/open_external.py +81 -0
- neutralino/_data/explorer/sources/native/open_file.py +102 -0
- neutralino/_data/explorer/sources/native/paths.py +77 -0
- neutralino/_data/explorer/sources/native/print_snapshot.py +84 -0
- neutralino/_data/explorer/sources/native/read_write.py +192 -0
- neutralino/_data/explorer/sources/native/resources.py +110 -0
- neutralino/_data/explorer/sources/native/save_file.py +101 -0
- neutralino/_data/explorer/sources/native/server_mount.py +106 -0
- neutralino/_data/explorer/sources/native/sound.py +84 -0
- neutralino/_data/explorer/sources/native/spawn_process.py +128 -0
- neutralino/_data/explorer/sources/native/states.py +122 -0
- neutralino/_data/explorer/sources/native/stats_permissions.py +147 -0
- neutralino/_data/explorer/sources/native/storage.py +108 -0
- neutralino/_data/explorer/sources/native/system_info.py +115 -0
- neutralino/_data/explorer/sources/native/text.py +133 -0
- neutralino/_data/explorer/sources/native/trash.py +98 -0
- neutralino/_data/explorer/sources/native/tray.py +109 -0
- neutralino/_data/explorer/sources/native/watcher.py +167 -0
- neutralino/_data/explorer/sources/patterns/content_blocks.py +119 -0
- neutralino/_data/explorer/sources/patterns/dynamic_dashboard.py +121 -0
- neutralino/_data/explorer/sources/patterns/dynamic_form.py +120 -0
- neutralino/_data/explorer/sources/patterns/dynamic_table.py +109 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.mjs +24 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.py +124 -0
- neutralino/_data/explorer/sources/patterns/errors_timeouts.py +108 -0
- neutralino/_data/explorer/sources/patterns/feature_flags.py +99 -0
- neutralino/_data/explorer/sources/patterns/file_drop.py +126 -0
- neutralino/_data/explorer/sources/patterns/http_from_python.py +152 -0
- neutralino/_data/explorer/sources/patterns/keyboard_shortcuts.py +153 -0
- neutralino/_data/explorer/sources/patterns/live_config_reload.py +160 -0
- neutralino/_data/explorer/sources/patterns/logging.py +184 -0
- neutralino/_data/explorer/sources/patterns/long_tasks.py +121 -0
- neutralino/_data/explorer/sources/patterns/multi_window_sync.py +68 -0
- neutralino/_data/explorer/sources/patterns/navigation_from_backend.py +109 -0
- neutralino/_data/explorer/sources/patterns/onboarding.py +123 -0
- neutralino/_data/explorer/sources/patterns/optimistic_updates.py +89 -0
- neutralino/_data/explorer/sources/patterns/persistence.py +114 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.mjs +10 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.py +64 -0
- neutralino/_data/explorer/sources/patterns/python_push.py +84 -0
- neutralino/_data/explorer/sources/patterns/recurring_events.py +114 -0
- neutralino/_data/explorer/sources/patterns/roles_permissions.py +104 -0
- neutralino/_data/explorer/sources/patterns/scheduled_jobs.py +194 -0
- neutralino/_data/explorer/sources/patterns/settings_page.py +165 -0
- neutralino/_data/explorer/sources/patterns/sqlite.py +181 -0
- neutralino/_data/explorer/sources/patterns/streaming.py +102 -0
- neutralino/_data/explorer/sources/patterns/texts_i18n.py +81 -0
- neutralino/_data/explorer/sources/patterns/theme_from_backend.py +86 -0
- neutralino/_data/explorer/sources/patterns/updater.py +232 -0
- neutralino/_data/explorer/sources/workspace/calendar/app.py +547 -0
- neutralino/_data/explorer/sources/workspace/customers/app.py +467 -0
- neutralino/_data/explorer/sources/workspace/dashboard/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/dashboard/app.py +367 -0
- neutralino/_data/explorer/sources/workspace/documents/app.py +511 -0
- neutralino/_data/explorer/sources/workspace/inbox/app.py +439 -0
- neutralino/_data/explorer/sources/workspace/orders/app.py +491 -0
- neutralino/_data/explorer/sources/workspace/reports/app.py +386 -0
- neutralino/_data/explorer/sources/workspace/settings/README.md +38 -0
- neutralino/_data/explorer/sources/workspace/settings/app.py +440 -0
- neutralino/_data/explorer/sources/workspace/system/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/system/app.py +375 -0
- neutralino/_data/explorer/sources/workspace/tasks/app.py +462 -0
- neutralino/_data/renderer/LICENSES/@babel__runtime@7.29.17/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/@codemirror__autocomplete@6.20.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__commands@6.11.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-css@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-html@6.4.12/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-javascript@6.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-json@6.0.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-markdown@6.5.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-python@6.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-sql@6.10.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-yaml@6.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__language@6.13.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__search@6.7.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__state@6.7.6/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__view@6.44.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__accessibility@3.1.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__core@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__sortable@10.0.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__utilities@3.2.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@emoji-mart__data@1.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__core@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__dom@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react-dom@2.1.9/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react@0.27.20/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__utils@0.2.12/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@lezer__common@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__css@1.3.9/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__highlight@1.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__html@1.3.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__javascript@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__json@1.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__lr@1.4.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__markdown@1.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__python@1.1.21/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__yaml@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__carousel@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__charts@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__code-highlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__core@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dates@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dropzone@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__emoji@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__hooks@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__lightbox@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__notifications@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__nprogress@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__schedule@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__spotlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__store@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__tiptap@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@marijn__find-cluster-break@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@reduxjs__toolkit@2.16.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tabler__icons-react@3.55.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__react-virtual@3.14.32/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__virtual-core@3.19.17/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__core@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-blockquote@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-bold@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code-block@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-document@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-hard-break@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-heading@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-horizontal-rule@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-italic@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-link@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-list@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-paragraph@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-strike@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-text@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-underline@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extensions@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__react@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__starter-kit@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/attr-accept@4.0.1/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/clsx@2.1.1/license +9 -0
- neutralino/_data/renderer/LICENSES/crelt@1.0.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/d3-array@3.2.5/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-color@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-format@3.1.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-interpolate@3.0.2/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-path@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-scale@4.0.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-shape@3.2.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time-format@4.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/dayjs@1.11.23/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/decimal.js-light@2.5.1/LICENCE.md +23 -0
- neutralino/_data/renderer/LICENSES/diff@9.0.0/LICENSE +29 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE +202 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE-MPL +373 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-react@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-reactive-utils@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/NOTICE +39 -0
- neutralino/_data/renderer/LICENSES/eventemitter3@5.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/fast-equals@5.4.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/file-selector@5.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/get-nonce@1.0.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/immer@11.2.14/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/linkifyjs@4.4.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/marked@18.4.0/LICENSE +44 -0
- neutralino/_data/renderer/LICENSES/neutralino.js@6.11.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/orderedmap@2.1.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/packages.json +1838 -0
- neutralino/_data/renderer/LICENSES/prosemirror-commands@1.7.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-dropcursor@1.8.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-gapcursor@1.4.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-history@1.5.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-keymap@1.2.3/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-model@1.25.13/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-schema-list@1.6.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-state@1.4.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-transform@1.12.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-view@1.44.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/react-dom@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-dropzone@20.1.4/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/react-is@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-number-format@5.4.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-redux@9.3.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll-bar@2.3.8/MIT-react-remove-scroll-bar.txt +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll@2.7.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-style-singleton@2.2.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-transition-group@4.4.5/LICENSE +30 -0
- neutralino/_data/renderer/LICENSES/react@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/recharts@3.11.3/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/redux-thunk@3.1.0/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/redux@5.0.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/reselect@5.2.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/rolldown@1.3.4/LICENSE +25 -0
- neutralino/_data/renderer/LICENSES/rope-sequence@1.3.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/rrule@2.8.1/LICENCE +65 -0
- neutralino/_data/renderer/LICENSES/scheduler@0.28.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/style-mod@4.1.5/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/tiny-invariant@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/tslib@2.9.1/LICENSE.txt +12 -0
- neutralino/_data/renderer/LICENSES/use-callback-ref@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sidecar@1.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sync-external-store@1.7.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/victory-vendor@38.1.1/LICENSE.txt +150 -0
- neutralino/_data/renderer/LICENSES/vite@8.4.1/LICENSE.md +2320 -0
- neutralino/_data/renderer/LICENSES/w3c-keyname@2.2.8/LICENSE +19 -0
- neutralino/_data/renderer/assets/IconGripVertical-C2NUKJAE.js +1 -0
- neutralino/_data/renderer/assets/carousel-D1j1SkWR.css +1 -0
- neutralino/_data/renderer/assets/carousel-DHnOKa8c.js +1 -0
- neutralino/_data/renderer/assets/chunk-CCkLOSkX.css +1 -0
- neutralino/_data/renderer/assets/chunk-CLVygP7p.js +9 -0
- neutralino/_data/renderer/assets/codehighlight-CXJaU0yv.js +10 -0
- neutralino/_data/renderer/assets/codehighlight-THJMNDh8.css +1 -0
- neutralino/_data/renderer/assets/codemirror-DX0MbxKq.js +2 -0
- neutralino/_data/renderer/assets/css-BotC7byr.js +1 -0
- neutralino/_data/renderer/assets/dist-3kB5bJpS.js +23 -0
- neutralino/_data/renderer/assets/dist-6zrr4MrK.js +1 -0
- neutralino/_data/renderer/assets/dist-Beotrn8G.js +1 -0
- neutralino/_data/renderer/assets/dist-CCJHv8n0.js +11 -0
- neutralino/_data/renderer/assets/dist-CdYA9or5.js +1 -0
- neutralino/_data/renderer/assets/dist-D2p_6o_g.js +1 -0
- neutralino/_data/renderer/assets/dnd-DkNumIKC.js +5 -0
- neutralino/_data/renderer/assets/dropzone-aPCBPjDN.css +1 -0
- neutralino/_data/renderer/assets/dropzone-agrigkXv.js +1 -0
- neutralino/_data/renderer/assets/embla-carousel-react.esm-_ztrE73N.js +1 -0
- neutralino/_data/renderer/assets/emoji-Cj3VQHg8.js +1 -0
- neutralino/_data/renderer/assets/emoji-DV8OzU1E.css +1 -0
- neutralino/_data/renderer/assets/esm-DbOmMyz5.js +82 -0
- neutralino/_data/renderer/assets/highlight-Dlb5DJwL.css +1 -0
- neutralino/_data/renderer/assets/highlight-LH6Cyuz6.js +3 -0
- neutralino/_data/renderer/assets/html-CpATC083.js +1 -0
- neutralino/_data/renderer/assets/icon-chunk-C-4QDF6w.js +1 -0
- neutralino/_data/renderer/assets/index-CqHW60Dy.js +69 -0
- neutralino/_data/renderer/assets/index-TWpF4Lef.css +1 -0
- neutralino/_data/renderer/assets/javascript-D2QSKlDI.js +1 -0
- neutralino/_data/renderer/assets/json-D8zfYii3.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BijRfmPy.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BzKDpkAD.css +1 -0
- neutralino/_data/renderer/assets/markdown-Cpthnhzg.js +77 -0
- neutralino/_data/renderer/assets/markdown-CsS2tf5C.js +5 -0
- neutralino/_data/renderer/assets/python-B477ud9A.js +9 -0
- neutralino/_data/renderer/assets/richtext-BwtgvH7-.js +137 -0
- neutralino/_data/renderer/assets/richtext-DIAsHMuK.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Ccstaz1-.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Db1pwUWd.js +1 -0
- neutralino/_data/renderer/assets/sql-DbpHRl6F.js +2 -0
- neutralino/_data/renderer/assets/with-selector-CUfuSYau.js +1 -0
- neutralino/_data/renderer/assets/yaml-BPsr1O3S.js +1 -0
- neutralino/_data/renderer/index.html +22 -0
- neutralino/_data/renderer/manifest.json +202 -0
- neutralino/_data/renderer/neutralino.js +1 -0
- neutralino/_data/renderer/shared/mantine-core.mjs +5 -0
- neutralino/_data/renderer/shared/mantine-hooks.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom-client.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom.mjs +6 -0
- neutralino/_data/renderer/shared/react-jsx-runtime.mjs +5 -0
- neutralino/_data/renderer/shared/react.mjs +6 -0
- neutralino/_data/skills/README.md +6 -0
- neutralino/_data/skills/neutralino-app-patterns/SKILL.md +101 -0
- neutralino/_data/skills/neutralino-app-patterns/references/dashboards-and-background-work.md +55 -0
- neutralino/_data/skills/neutralino-app-patterns/references/storage-and-settings.md +57 -0
- neutralino/_data/skills/neutralino-app-patterns/references/tables-and-crud.md +81 -0
- neutralino/_data/skills/neutralino-frontend/SKILL.md +121 -0
- neutralino/_data/skills/neutralino-frontend/references/bridge.md +63 -0
- neutralino/_data/skills/neutralino-frontend/references/custom-components.md +84 -0
- neutralino/_data/skills/neutralino-frontend/references/frameworks.md +61 -0
- neutralino/_data/skills/neutralino-maintenance/SKILL.md +85 -0
- neutralino/_data/skills/neutralino-maintenance/references/platforms-and-gates.md +35 -0
- neutralino/_data/skills/neutralino-maintenance/references/records.md +38 -0
- neutralino/_data/skills/neutralino-maintenance/references/review-process.md +36 -0
- neutralino/_data/skills/neutralino-native/SKILL.md +107 -0
- neutralino/_data/skills/neutralino-native/references/api-conventions.md +72 -0
- neutralino/_data/skills/neutralino-native/references/desktop-helpers.md +53 -0
- neutralino/_data/skills/neutralino-native/references/permissions-windows.md +53 -0
- neutralino/_data/skills/neutralino-packaging/SKILL.md +99 -0
- neutralino/_data/skills/neutralino-packaging/references/build-layout.md +51 -0
- neutralino/_data/skills/neutralino-packaging/references/managed-install.md +59 -0
- neutralino/_data/skills/neutralino-packaging/references/templates-and-config.md +63 -0
- neutralino/_data/skills/neutralino-python/SKILL.md +109 -0
- neutralino/_data/skills/neutralino-python/references/architecture.md +53 -0
- neutralino/_data/skills/neutralino-python/references/cli.md +60 -0
- neutralino/_data/skills/neutralino-python/references/platforms-security.md +44 -0
- neutralino/_data/skills/neutralino-rpc/SKILL.md +114 -0
- neutralino/_data/skills/neutralino-rpc/references/errors-and-limits.md +44 -0
- neutralino/_data/skills/neutralino-rpc/references/expose-and-context.md +74 -0
- neutralino/_data/skills/neutralino-rpc/references/streams-and-cancellation.md +53 -0
- neutralino/_data/skills/neutralino-ui/SKILL.md +115 -0
- neutralino/_data/skills/neutralino-ui/references/components-and-tree.md +74 -0
- neutralino/_data/skills/neutralino-ui/references/state-forms-events.md +85 -0
- neutralino/_data/skills/neutralino-ui/references/themes-profiles-assets.md +105 -0
- neutralino/_data/skills/neutralino-updates/SKILL.md +94 -0
- neutralino/_data/skills/neutralino-updates/references/config-and-api.md +80 -0
- neutralino/_data/skills/neutralino-updates/references/releases-and-install.md +77 -0
- neutralino/_data/skills/neutralino-updates/references/security-rollback.md +48 -0
- neutralino/_data/ui/contracts.json +32927 -0
- neutralino/_data/ui/emoji.json +1 -0
- neutralino/_data/upstream-lock.json +97 -0
- neutralino/_managed.py +1099 -0
- neutralino/_paths.py +220 -0
- neutralino/_platform.py +150 -0
- neutralino/_scaffold.py +344 -0
- neutralino/api/_base.py +99 -0
- neutralino/api/_custom.py +1350 -0
- neutralino/api/_dec.py +21 -0
- neutralino/api/_enc.py +80 -0
- neutralino/api/app.py +119 -0
- neutralino/api/clipboard.py +101 -0
- neutralino/api/computer.py +261 -0
- neutralino/api/custom.py +36 -0
- neutralino/api/debug.py +41 -0
- neutralino/api/extensions.py +57 -0
- neutralino/api/filesystem.py +633 -0
- neutralino/api/net.py +22 -0
- neutralino/api/os.py +508 -0
- neutralino/api/resources.py +124 -0
- neutralino/api/server.py +66 -0
- neutralino/api/storage.py +98 -0
- neutralino/api/types.py +342 -0
- neutralino/api/updater.py +22 -0
- neutralino/api/window.py +397 -0
- neutralino/application.py +1261 -0
- neutralino/bundle.py +187 -0
- neutralino/cli.py +629 -0
- neutralino/client.py +496 -0
- neutralino/config.py +671 -0
- neutralino/devtools.py +1973 -0
- neutralino/errors.py +142 -0
- neutralino/events.py +579 -0
- neutralino/execution.py +293 -0
- neutralino/extension.py +134 -0
- neutralino/frontend/python-bridge.d.ts +207 -0
- neutralino/frontend/python-bridge.mjs +854 -0
- neutralino/protocol.py +456 -0
- neutralino/py.typed +0 -0
- neutralino/rpc.py +1625 -0
- neutralino/runtime.py +591 -0
- neutralino/supervisor.py +866 -0
- neutralino/sync_client.py +376 -0
- neutralino/templates/default/app.py +32 -0
- neutralino/templates/default/frontend/app.js +28 -0
- neutralino/templates/default/frontend/index.html +26 -0
- neutralino/templates/default/frontend/neutralino.js +1 -0
- neutralino/templates/default/frontend/styles.css +8 -0
- neutralino/templates/default/gitignore.txt +3 -0
- neutralino/templates/default/neutralino.config.json +25 -0
- neutralino/templates/hybrid/README.md +17 -0
- neutralino/templates/hybrid/app.py +49 -0
- neutralino/templates/hybrid/components/counter.mjs +37 -0
- neutralino/templates/hybrid/styles.css +21 -0
- neutralino/templates/python-ui/README.md +15 -0
- neutralino/templates/python-ui/app.py +44 -0
- neutralino/templates/python-ui/gitignore.txt +3 -0
- neutralino/templates/python-ui/requirements.txt +4 -0
- neutralino/templates/react/README.md +28 -0
- neutralino/templates/react/app.py +52 -0
- neutralino/templates/react/components/widget.mjs +23 -0
- neutralino/templates/react/widget/package.json +20 -0
- neutralino/templates/react/widget/src/Widget.jsx +25 -0
- neutralino/templates/react/widget/vite.config.mjs +19 -0
- neutralino/transport.py +661 -0
- neutralino/types.py +93 -0
- neutralino/ui/__init__.py +139 -0
- neutralino/ui/_app.py +1529 -0
- neutralino/ui/_assets.py +407 -0
- neutralino/ui/_bases.py +1210 -0
- neutralino/ui/_behaviours.py +1066 -0
- neutralino/ui/_charts.py +732 -0
- neutralino/ui/_component.py +882 -0
- neutralino/ui/_dates.py +168 -0
- neutralino/ui/_desktop.py +879 -0
- neutralino/ui/_events.py +192 -0
- neutralino/ui/_filters.py +427 -0
- neutralino/ui/_forms.py +282 -0
- neutralino/ui/_protocol.py +201 -0
- neutralino/ui/_schedule.py +543 -0
- neutralino/ui/_security.py +106 -0
- neutralino/ui/_session.py +969 -0
- neutralino/ui/_state.py +199 -0
- neutralino/ui/_tables.py +256 -0
- neutralino/ui/_theme.py +154 -0
- neutralino/ui/blocks/__init__.py +19 -0
- neutralino/ui/blocks/_data.py +2239 -0
- neutralino/ui/blocks/_interactive.py +622 -0
- neutralino/ui/blocks/_layout.py +2967 -0
- neutralino/ui/components/__init__.py +81 -0
- neutralino/ui/components/_dates.py +879 -0
- neutralino/ui/components/_editors.py +217 -0
- neutralino/ui/components/_extensions.py +790 -0
- neutralino/ui/components/_extras.py +303 -0
- neutralino/ui/components/_generated.py +30565 -0
- neutralino/ui/components/_types.py +17 -0
- neutralino/ui/schema.py +824 -0
- neutralino/ui/validators.py +362 -0
- neutralino/updates/__init__.py +96 -0
- neutralino/updates/_http.py +320 -0
- neutralino/updates/_layout.py +762 -0
- neutralino/updates/archive.py +216 -0
- neutralino/updates/config.py +256 -0
- neutralino/updates/errors.py +97 -0
- neutralino/updates/install.sh.in +201 -0
- neutralino/updates/launcher.py +18 -0
- neutralino/updates/manager.py +808 -0
- neutralino/updates/manifest.py +196 -0
- neutralino/updates/release.py +314 -0
- neutralino/updates/semver.py +84 -0
- neutralino/updates/sources.py +392 -0
- neutralino/windows.py +316 -0
- neutralino_python-0.1.0rc1.dist-info/METADATA +117 -0
- neutralino_python-0.1.0rc1.dist-info/RECORD +521 -0
- neutralino_python-0.1.0rc1.dist-info/WHEEL +4 -0
- neutralino_python-0.1.0rc1.dist-info/entry_points.txt +3 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/LICENSE +21 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/THIRD_PARTY_NOTICES.md +16 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/src/neutralino/_data/renderer/LICENSES/packages.json +1838 -0
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
"""Typed behaviour of the dates and schedule components.
|
|
2
|
+
|
|
3
|
+
The generated classes declare the contracts; these subclasses (same names,
|
|
4
|
+
same ``TYPE``) add what a declarative contract cannot express:
|
|
5
|
+
|
|
6
|
+
* date/datetime/time values as Python objects (``datetime.date`` etc.),
|
|
7
|
+
ranges as ``(start, end)`` tuples and ``type='multiple'`` values as lists,
|
|
8
|
+
with ISO strings on the wire (see :mod:`neutralino.ui._dates` for the
|
|
9
|
+
time-zone policy);
|
|
10
|
+
* server-side re-checks of what the page enforces (min/max, excluded dates,
|
|
11
|
+
time limits, range order): a rejected change puts the Python value back
|
|
12
|
+
in the page;
|
|
13
|
+
* schedule views: typed events, visible-range loading through a provider
|
|
14
|
+
(only events of the shown range are sent), and typed click / drag-move /
|
|
15
|
+
resize / slot payloads.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import datetime as _dt
|
|
21
|
+
import inspect
|
|
22
|
+
import logging
|
|
23
|
+
import threading
|
|
24
|
+
from collections.abc import Awaitable, Callable, Iterable, Mapping, Sequence
|
|
25
|
+
from typing import Any, ClassVar, cast
|
|
26
|
+
|
|
27
|
+
from ...errors import ValidationError
|
|
28
|
+
from ...types import UNSET
|
|
29
|
+
from .._component import TREE_LOCK, Component, PropSpec
|
|
30
|
+
from .._dates import (
|
|
31
|
+
from_wall,
|
|
32
|
+
parse_date,
|
|
33
|
+
parse_datetime,
|
|
34
|
+
parse_time,
|
|
35
|
+
to_wall,
|
|
36
|
+
wire_datetime,
|
|
37
|
+
zone,
|
|
38
|
+
)
|
|
39
|
+
from .._dates import (
|
|
40
|
+
visible_range as _visible_range,
|
|
41
|
+
)
|
|
42
|
+
from .._events import Event, ScheduleEventChange, ScheduleRangeEvent, ScheduleSlotEvent
|
|
43
|
+
from .._schedule import ScheduleEvent, as_event
|
|
44
|
+
from . import _generated as g # pyright: ignore[reportPrivateUsage]
|
|
45
|
+
|
|
46
|
+
log = logging.getLogger("neutralino.ui")
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
"AgendaView",
|
|
50
|
+
"Calendar",
|
|
51
|
+
"DateInput",
|
|
52
|
+
"DatePicker",
|
|
53
|
+
"DatePickerInput",
|
|
54
|
+
"DateTimePicker",
|
|
55
|
+
"DayView",
|
|
56
|
+
"EventProvider",
|
|
57
|
+
"InlineDateTimePicker",
|
|
58
|
+
"MaskedDateInput",
|
|
59
|
+
"MiniCalendar",
|
|
60
|
+
"MobileMonthView",
|
|
61
|
+
"MonthPicker",
|
|
62
|
+
"MonthPickerInput",
|
|
63
|
+
"MonthView",
|
|
64
|
+
"QuarterPicker",
|
|
65
|
+
"QuarterPickerInput",
|
|
66
|
+
"ResourcesDayView",
|
|
67
|
+
"ResourcesMonthView",
|
|
68
|
+
"ResourcesSchedule",
|
|
69
|
+
"ResourcesWeekView",
|
|
70
|
+
"Scheduler",
|
|
71
|
+
"TimeGrid",
|
|
72
|
+
"TimeInput",
|
|
73
|
+
"TimePicker",
|
|
74
|
+
"TimeValue",
|
|
75
|
+
"WeekPicker",
|
|
76
|
+
"WeekPickerInput",
|
|
77
|
+
"WeekView",
|
|
78
|
+
"YearPicker",
|
|
79
|
+
"YearPickerInput",
|
|
80
|
+
"YearView",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
_FIXED = ("timezone", "type") # the value's meaning depends on them
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _time_wire(v: Any, path: str) -> str:
|
|
87
|
+
if isinstance(v, _dt.time):
|
|
88
|
+
return v.replace(tzinfo=None).isoformat(timespec="seconds")
|
|
89
|
+
if isinstance(v, str) and len(v) <= 16:
|
|
90
|
+
return parse_time(v).isoformat(timespec="seconds")
|
|
91
|
+
raise ValidationError(f"{path}: expected a time (HH:MM[:SS]) or datetime.time")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class _DatesBehaviour(Component):
|
|
95
|
+
"""Typed values, time zone and server-side checks for date components."""
|
|
96
|
+
|
|
97
|
+
def _tz(self) -> _dt.tzinfo | None:
|
|
98
|
+
name = self._props.get("timezone")
|
|
99
|
+
return zone(name) if isinstance(name, str) else None
|
|
100
|
+
|
|
101
|
+
def _datetime_mode(self, name: str) -> bool:
|
|
102
|
+
"""Whether a ``dates`` prop holds datetimes (``with_time``) or dates."""
|
|
103
|
+
if self._spec(name).kind == "datetimes":
|
|
104
|
+
return True
|
|
105
|
+
return name in ("value", "presets") and self._props.get("with_time") is True
|
|
106
|
+
|
|
107
|
+
# ------------------------------------------------------- python -> wire
|
|
108
|
+
def _one(self, v: Any, datetime_mode: bool, path: str) -> str | None:
|
|
109
|
+
if v is None:
|
|
110
|
+
return None
|
|
111
|
+
if datetime_mode:
|
|
112
|
+
if isinstance(v, str):
|
|
113
|
+
if len(v) > 64:
|
|
114
|
+
raise ValidationError(f"{path}: invalid datetime")
|
|
115
|
+
try:
|
|
116
|
+
v = _dt.datetime.fromisoformat(v)
|
|
117
|
+
except ValueError:
|
|
118
|
+
raise ValidationError(f"{path}: invalid datetime {v[:40]!r}") from None
|
|
119
|
+
if isinstance(v, _dt.datetime):
|
|
120
|
+
return wire_datetime(to_wall(v, self._tz()))
|
|
121
|
+
if isinstance(v, _dt.date):
|
|
122
|
+
return wire_datetime(_dt.datetime.combine(v, _dt.time()))
|
|
123
|
+
raise ValidationError(f"{path}: expected a datetime")
|
|
124
|
+
if isinstance(v, _dt.datetime):
|
|
125
|
+
return to_wall(v, self._tz()).date().isoformat()
|
|
126
|
+
if isinstance(v, _dt.date):
|
|
127
|
+
return v.isoformat()
|
|
128
|
+
if isinstance(v, str) and len(v) <= 64:
|
|
129
|
+
if len(v) == 10:
|
|
130
|
+
return parse_date(v).isoformat()
|
|
131
|
+
return self._one(_dt.datetime.fromisoformat(v), False, path)
|
|
132
|
+
raise ValidationError(f"{path}: expected a date")
|
|
133
|
+
|
|
134
|
+
def _shaped(self, name: str, v: Any) -> Any:
|
|
135
|
+
"""A value of a ``date(s)``/``datetime(s)`` prop as wire, shaped by ``type``."""
|
|
136
|
+
dtm = self._datetime_mode(name)
|
|
137
|
+
kind = self._spec(name).kind
|
|
138
|
+
if kind in ("date", "datetime"):
|
|
139
|
+
return self._one(v, kind == "datetime", name)
|
|
140
|
+
if name != "value": # lists of dates (excluded_dates, selected_dates)
|
|
141
|
+
if isinstance(v, (str, _dt.date)) or not isinstance(v, Iterable):
|
|
142
|
+
raise ValidationError(f"{name}: expected a list of dates")
|
|
143
|
+
items = list(cast("Iterable[Any]", v))
|
|
144
|
+
if len(items) > 1000:
|
|
145
|
+
raise ValidationError(f"{name}: more than 1000 dates")
|
|
146
|
+
return [self._one(x, dtm, f"{name}[{i}]") for i, x in enumerate(items)]
|
|
147
|
+
typ = self._props.get("type", "default")
|
|
148
|
+
if typ == "default" or "type" not in self.PROPS:
|
|
149
|
+
if v is not None and not isinstance(v, (str, _dt.date)):
|
|
150
|
+
raise ValidationError("value: expected one date (type='default')")
|
|
151
|
+
return self._one(v, dtm, name)
|
|
152
|
+
if isinstance(v, (str, _dt.date)) or not isinstance(v, Iterable):
|
|
153
|
+
raise ValidationError(f"value: type={typ!r} expects a sequence")
|
|
154
|
+
items = list(cast("Iterable[Any]", v))
|
|
155
|
+
out = [self._one(x, dtm, f"value[{i}]") for i, x in enumerate(items)]
|
|
156
|
+
if typ == "range":
|
|
157
|
+
if len(out) != 2:
|
|
158
|
+
raise ValidationError("value: a range is a (start, end) pair")
|
|
159
|
+
a, b = out
|
|
160
|
+
if a is not None and b is not None and b < a:
|
|
161
|
+
raise ValidationError("value: range end is before its start")
|
|
162
|
+
elif any(x is None for x in out):
|
|
163
|
+
raise ValidationError("value: None in a multiple selection")
|
|
164
|
+
return out
|
|
165
|
+
|
|
166
|
+
def _convert(self, name: str, value: Any, spec: PropSpec | None = None) -> Any:
|
|
167
|
+
spec = spec or self._spec(name)
|
|
168
|
+
if name in _FIXED and name in self._props and value != self._props[name]:
|
|
169
|
+
raise ValidationError(f"{self.TYPE}.{name} is fixed after construction")
|
|
170
|
+
if name == "timezone" and value is not UNSET and value is not None:
|
|
171
|
+
zone(value)
|
|
172
|
+
if spec.kind in ("date", "datetime", "dates", "datetimes") and value is not None:
|
|
173
|
+
value = self._shaped(name, value)
|
|
174
|
+
elif name == "weekend_days":
|
|
175
|
+
value = _weekdays(value, name)
|
|
176
|
+
elif name == "presets" and spec.kind == "records":
|
|
177
|
+
value = self._presets(value)
|
|
178
|
+
elif name == "indicators":
|
|
179
|
+
value = self._indicators(value)
|
|
180
|
+
elif name in ("data", "disable_time", "business_hours") or (
|
|
181
|
+
name == "presets" and spec.kind == "string_list"
|
|
182
|
+
):
|
|
183
|
+
value = _times(value, name, exact=2 if name == "business_hours" else None)
|
|
184
|
+
elif name == "fields_order":
|
|
185
|
+
if sorted(cast("list[Any]", value)) != ["day", "month", "year"]:
|
|
186
|
+
raise ValidationError("fields_order: a permutation of 'day', 'month', 'year'")
|
|
187
|
+
elif spec.kind == "time" and value is not None:
|
|
188
|
+
value = _time_wire(value, name)
|
|
189
|
+
return super()._convert(name, value, spec)
|
|
190
|
+
|
|
191
|
+
def _presets(self, value: Any) -> list[dict[str, Any]]:
|
|
192
|
+
if isinstance(value, (str, Mapping)) or not isinstance(value, Iterable):
|
|
193
|
+
raise ValidationError("presets: expected a list of {'value', 'label'} mappings")
|
|
194
|
+
out: list[dict[str, Any]] = []
|
|
195
|
+
for i, p in enumerate(cast("Iterable[Any]", value)):
|
|
196
|
+
if not isinstance(p, Mapping) or set(cast("Mapping[str, Any]", p)) != {
|
|
197
|
+
"value",
|
|
198
|
+
"label",
|
|
199
|
+
}:
|
|
200
|
+
raise ValidationError(f"presets[{i}]: expected {{'value': ..., 'label': str}}")
|
|
201
|
+
m = cast("Mapping[str, Any]", p)
|
|
202
|
+
if not isinstance(m["label"], str):
|
|
203
|
+
raise ValidationError(f"presets[{i}].label: expected str")
|
|
204
|
+
out.append({"value": self._shaped("value", m["value"]), "label": m["label"]})
|
|
205
|
+
return out
|
|
206
|
+
|
|
207
|
+
def _indicators(self, value: Any) -> list[dict[str, Any]]:
|
|
208
|
+
if isinstance(value, (str, Mapping)) or not isinstance(value, Iterable):
|
|
209
|
+
raise ValidationError("indicators: expected a list of {'date', 'label'?, 'color'?}")
|
|
210
|
+
out: list[dict[str, Any]] = []
|
|
211
|
+
for i, p in enumerate(cast("Iterable[Any]", value)):
|
|
212
|
+
m = cast("Mapping[str, Any]", p) if isinstance(p, Mapping) else None
|
|
213
|
+
if m is None or "date" not in m or set(m) - {"date", "label", "color"}:
|
|
214
|
+
raise ValidationError(f"indicators[{i}]: expected {{'date', 'label'?, 'color'?}}")
|
|
215
|
+
d: dict[str, Any] = {"date": self._one(m["date"], False, f"indicators[{i}].date")}
|
|
216
|
+
for k in ("label", "color"):
|
|
217
|
+
if k in m:
|
|
218
|
+
if not isinstance(m[k], str) or len(m[k]) > 64:
|
|
219
|
+
raise ValidationError(f"indicators[{i}].{k}: a short str")
|
|
220
|
+
d[k] = m[k]
|
|
221
|
+
out.append(d)
|
|
222
|
+
return out
|
|
223
|
+
|
|
224
|
+
# ------------------------------------------------------- wire -> python
|
|
225
|
+
def _typed_one(self, v: Any, kind: str, datetime_mode: bool) -> Any:
|
|
226
|
+
if v is None or not isinstance(v, str):
|
|
227
|
+
return v
|
|
228
|
+
if kind == "time":
|
|
229
|
+
return parse_time(v)
|
|
230
|
+
if kind == "datetime" or datetime_mode:
|
|
231
|
+
return from_wall(parse_datetime(v), self._tz())
|
|
232
|
+
return parse_date(v)
|
|
233
|
+
|
|
234
|
+
def _from_wire(self, name: str, wire_value: Any) -> Any:
|
|
235
|
+
spec = self.PROPS.get(name)
|
|
236
|
+
if spec is None or spec.kind not in ("date", "datetime", "time", "dates", "datetimes"):
|
|
237
|
+
return wire_value
|
|
238
|
+
dtm = spec.kind in ("dates", "datetimes") and self._datetime_mode(name)
|
|
239
|
+
if not isinstance(wire_value, list):
|
|
240
|
+
return self._typed_one(wire_value, spec.kind, dtm)
|
|
241
|
+
items = [self._typed_one(x, spec.kind, dtm) for x in cast("list[Any]", wire_value)]
|
|
242
|
+
if name == "value" and self._props.get("type") == "range":
|
|
243
|
+
return tuple(items)
|
|
244
|
+
return items
|
|
245
|
+
|
|
246
|
+
# ---------------------------------------------------- page -> python
|
|
247
|
+
def _check_client_value(self, value: Any) -> None:
|
|
248
|
+
try:
|
|
249
|
+
self._check_value(value)
|
|
250
|
+
except ValidationError:
|
|
251
|
+
self._revert_page()
|
|
252
|
+
raise
|
|
253
|
+
|
|
254
|
+
def _check_submitted_value(self, value: Any) -> None:
|
|
255
|
+
self._check_value(value) # a submit reports the error; the draft stays
|
|
256
|
+
|
|
257
|
+
def _check_value(self, value: Any) -> None:
|
|
258
|
+
spec = self._spec("value")
|
|
259
|
+
if value is None or value == "":
|
|
260
|
+
return
|
|
261
|
+
if spec.kind == "time":
|
|
262
|
+
t = parse_time(value) if isinstance(value, str) else None
|
|
263
|
+
if t is None:
|
|
264
|
+
raise ValidationError("value: expected a time")
|
|
265
|
+
self._check_time(t)
|
|
266
|
+
return
|
|
267
|
+
wire: Any = self._shaped("value", self._from_wire("value", self._shaped_from_page(value)))
|
|
268
|
+
items = cast("list[str | None]", wire if isinstance(wire, list) else [wire])
|
|
269
|
+
for x in items:
|
|
270
|
+
if x is not None:
|
|
271
|
+
self._check_day(x)
|
|
272
|
+
|
|
273
|
+
def _shaped_from_page(self, value: Any) -> Any:
|
|
274
|
+
"""Validate the page's wire shape before typing it."""
|
|
275
|
+
typ = self._props.get("type", "default")
|
|
276
|
+
if isinstance(value, list):
|
|
277
|
+
if typ == "default" or "type" not in self.PROPS:
|
|
278
|
+
raise ValidationError("value: a list for a single-value picker")
|
|
279
|
+
items = cast("list[Any]", value)
|
|
280
|
+
if not all(x is None or isinstance(x, str) for x in items):
|
|
281
|
+
raise ValidationError("value: dates are strings")
|
|
282
|
+
return items
|
|
283
|
+
if not isinstance(value, str):
|
|
284
|
+
raise ValidationError("value: expected an ISO date string")
|
|
285
|
+
if typ != "default" and "type" in self.PROPS:
|
|
286
|
+
raise ValidationError(f"value: type={typ!r} expects a list")
|
|
287
|
+
return value
|
|
288
|
+
|
|
289
|
+
def _check_day(self, wire: str) -> None:
|
|
290
|
+
day = parse_date(wire)
|
|
291
|
+
lo, hi = self._props.get("min_date"), self._props.get("max_date")
|
|
292
|
+
if isinstance(lo, str):
|
|
293
|
+
if len(lo) > 10 and len(wire) > 10:
|
|
294
|
+
if parse_datetime(wire) < parse_datetime(lo):
|
|
295
|
+
raise ValidationError(f"value: {wire} is before min_date {lo}")
|
|
296
|
+
elif day < parse_date(lo):
|
|
297
|
+
raise ValidationError(f"value: {wire} is before min_date {lo}")
|
|
298
|
+
if isinstance(hi, str):
|
|
299
|
+
if len(hi) > 10 and len(wire) > 10:
|
|
300
|
+
if parse_datetime(wire) > parse_datetime(hi):
|
|
301
|
+
raise ValidationError(f"value: {wire} is after max_date {hi}")
|
|
302
|
+
elif day > parse_date(hi):
|
|
303
|
+
raise ValidationError(f"value: {wire} is after max_date {hi}")
|
|
304
|
+
excluded = self._props.get("excluded_dates")
|
|
305
|
+
if isinstance(excluded, list) and day.isoformat() in cast("list[str]", excluded):
|
|
306
|
+
raise ValidationError(f"value: {day} is excluded")
|
|
307
|
+
|
|
308
|
+
def _check_time(self, t: _dt.time) -> None:
|
|
309
|
+
w = t.isoformat(timespec="seconds")
|
|
310
|
+
lo = self._props.get("min_time", self._props.get("min"))
|
|
311
|
+
hi = self._props.get("max_time", self._props.get("max"))
|
|
312
|
+
if isinstance(lo, str) and w < lo:
|
|
313
|
+
raise ValidationError(f"value: {w} is before {lo}")
|
|
314
|
+
if isinstance(hi, str) and w > hi:
|
|
315
|
+
raise ValidationError(f"value: {w} is after {hi}")
|
|
316
|
+
data = self._props.get("data")
|
|
317
|
+
if isinstance(data, list) and w not in cast("list[str]", data):
|
|
318
|
+
raise ValidationError(f"value: {w} is not one of the slots")
|
|
319
|
+
off = self._props.get("disable_time")
|
|
320
|
+
if isinstance(off, list) and w in cast("list[str]", off):
|
|
321
|
+
raise ValidationError(f"value: {w} is disabled")
|
|
322
|
+
|
|
323
|
+
def _revert_page(self) -> None:
|
|
324
|
+
"""Show the Python value again (a rejected page edit)."""
|
|
325
|
+
with TREE_LOCK:
|
|
326
|
+
self._value_rev += 1
|
|
327
|
+
w = self._window
|
|
328
|
+
if w is not None:
|
|
329
|
+
w.queue_set(
|
|
330
|
+
self,
|
|
331
|
+
{self._spec("value").wire: self._props.get("value"), "__vrev": self._value_rev},
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
def _on_client_event(self, name: str, payload: Mapping[str, Any]) -> Any:
|
|
335
|
+
ev = super()._on_client_event(name, payload)
|
|
336
|
+
if not isinstance(ev, Event):
|
|
337
|
+
return ev
|
|
338
|
+
spec = self.EVENTS.get(name)
|
|
339
|
+
if spec is not None and spec.payload is not None and "value" in ev.payload:
|
|
340
|
+
raw = ev.payload["value"]
|
|
341
|
+
if name == "date_change" and "date" in self.PROPS and isinstance(raw, str):
|
|
342
|
+
self._commit_from_client("date", raw)
|
|
343
|
+
ev.payload["value"] = self._typed_one(raw, spec.payload.kind, False)
|
|
344
|
+
return ev
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def _weekdays(value: Any, name: str) -> list[int]:
|
|
348
|
+
if isinstance(value, (str, Mapping)) or not isinstance(value, Iterable):
|
|
349
|
+
raise ValidationError(f"{name}: expected a list of weekday numbers 0..6")
|
|
350
|
+
out = list(cast("Iterable[Any]", value))
|
|
351
|
+
if any(isinstance(x, bool) or not isinstance(x, int) or not 0 <= x <= 6 for x in out):
|
|
352
|
+
raise ValidationError(f"{name}: weekday numbers are ints 0 (Sunday) .. 6 (Saturday)")
|
|
353
|
+
return [int(x) for x in out]
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def _times(value: Any, name: str, exact: int | None = None) -> list[str]:
|
|
357
|
+
if isinstance(value, (str, Mapping)) or not isinstance(value, Iterable):
|
|
358
|
+
raise ValidationError(f"{name}: expected a list of times")
|
|
359
|
+
out = [_time_wire(x, f"{name}[{i}]") for i, x in enumerate(cast("Iterable[Any]", value))]
|
|
360
|
+
if exact is not None and len(out) != exact:
|
|
361
|
+
raise ValidationError(f"{name}: expected {exact} times")
|
|
362
|
+
if len(out) > 2000:
|
|
363
|
+
raise ValidationError(f"{name}: more than 2000 times")
|
|
364
|
+
return out
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
# ------------------------------------------------------------------ dates
|
|
368
|
+
def _doc(cls: type) -> str | None:
|
|
369
|
+
return cls.__doc__
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
class Calendar(_DatesBehaviour, g.Calendar):
|
|
373
|
+
__doc__ = _doc(g.Calendar)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
class DatePicker(_DatesBehaviour, g.DatePicker):
|
|
377
|
+
__doc__ = _doc(g.DatePicker)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
class DatePickerInput(_DatesBehaviour, g.DatePickerInput):
|
|
381
|
+
__doc__ = _doc(g.DatePickerInput)
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
class DateInput(_DatesBehaviour, g.DateInput):
|
|
385
|
+
__doc__ = _doc(g.DateInput)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
class DateTimePicker(_DatesBehaviour, g.DateTimePicker):
|
|
389
|
+
__doc__ = _doc(g.DateTimePicker)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
class InlineDateTimePicker(_DatesBehaviour, g.InlineDateTimePicker):
|
|
393
|
+
__doc__ = _doc(g.InlineDateTimePicker)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
class MaskedDateInput(_DatesBehaviour, g.MaskedDateInput):
|
|
397
|
+
__doc__ = _doc(g.MaskedDateInput)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class MiniCalendar(_DatesBehaviour, g.MiniCalendar):
|
|
401
|
+
__doc__ = _doc(g.MiniCalendar)
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
class MonthPicker(_DatesBehaviour, g.MonthPicker):
|
|
405
|
+
__doc__ = _doc(g.MonthPicker)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
class MonthPickerInput(_DatesBehaviour, g.MonthPickerInput):
|
|
409
|
+
__doc__ = _doc(g.MonthPickerInput)
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
class QuarterPicker(_DatesBehaviour, g.QuarterPicker):
|
|
413
|
+
__doc__ = _doc(g.QuarterPicker)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
class QuarterPickerInput(_DatesBehaviour, g.QuarterPickerInput):
|
|
417
|
+
__doc__ = _doc(g.QuarterPickerInput)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
class YearPicker(_DatesBehaviour, g.YearPicker):
|
|
421
|
+
__doc__ = _doc(g.YearPicker)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
class YearPickerInput(_DatesBehaviour, g.YearPickerInput):
|
|
425
|
+
__doc__ = _doc(g.YearPickerInput)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
class WeekPicker(_DatesBehaviour, g.WeekPicker):
|
|
429
|
+
__doc__ = _doc(g.WeekPicker)
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
class WeekPickerInput(_DatesBehaviour, g.WeekPickerInput):
|
|
433
|
+
__doc__ = _doc(g.WeekPickerInput)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
class TimeInput(_DatesBehaviour, g.TimeInput):
|
|
437
|
+
__doc__ = _doc(g.TimeInput)
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
class TimePicker(_DatesBehaviour, g.TimePicker):
|
|
441
|
+
__doc__ = _doc(g.TimePicker)
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
class TimeGrid(_DatesBehaviour, g.TimeGrid):
|
|
445
|
+
__doc__ = _doc(g.TimeGrid)
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
class TimeValue(_DatesBehaviour, g.TimeValue):
|
|
449
|
+
__doc__ = _doc(g.TimeValue)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
# --------------------------------------------------------------- schedule
|
|
453
|
+
_Loaded = Iterable[ScheduleEvent | Mapping[str, Any]]
|
|
454
|
+
EventProvider = Callable[[_dt.date, _dt.date], "_Loaded | Awaitable[_Loaded]"]
|
|
455
|
+
MAX_EVENTS = 5_000
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
class _ScheduleBehaviour(_DatesBehaviour):
|
|
459
|
+
"""Typed events, visible-range provider and interaction payloads."""
|
|
460
|
+
|
|
461
|
+
DEFAULT_VIEW: ClassVar[str] = "week"
|
|
462
|
+
|
|
463
|
+
def _sched_state(self) -> dict[str, Any]:
|
|
464
|
+
st = self.__dict__.get("_sched")
|
|
465
|
+
if st is None:
|
|
466
|
+
st = self.__dict__.setdefault(
|
|
467
|
+
"_sched",
|
|
468
|
+
{"cache": None, "provider": None, "sub": None, "gen": 0, "lock": threading.Lock()},
|
|
469
|
+
)
|
|
470
|
+
return cast("dict[str, Any]", st)
|
|
471
|
+
|
|
472
|
+
# ------------------------------------------------------------ events
|
|
473
|
+
def _convert(self, name: str, value: Any, spec: PropSpec | None = None) -> Any:
|
|
474
|
+
spec = spec or self._spec(name)
|
|
475
|
+
if name == "events":
|
|
476
|
+
if isinstance(value, (str, Mapping)) or not isinstance(value, Iterable):
|
|
477
|
+
raise ValidationError("events: expected a list of ScheduleEvent")
|
|
478
|
+
typed = [as_event(e) for e in cast("Iterable[Any]", value)]
|
|
479
|
+
if len(typed) > MAX_EVENTS:
|
|
480
|
+
raise ValidationError(f"events: more than {MAX_EVENTS} events")
|
|
481
|
+
ids = [e.id for e in typed]
|
|
482
|
+
if len(set(ids)) != len(ids):
|
|
483
|
+
raise ValidationError("events: duplicate event ids")
|
|
484
|
+
tz = self._tz()
|
|
485
|
+
wire = Component._convert(self, name, [e.to_wire(tz) for e in typed], spec)
|
|
486
|
+
self._sched_state()["cache"] = (wire, typed)
|
|
487
|
+
return wire
|
|
488
|
+
if name == "resources":
|
|
489
|
+
value = _resources(value)
|
|
490
|
+
elif name == "groups":
|
|
491
|
+
value = _groups(value)
|
|
492
|
+
return super()._convert(name, value, spec)
|
|
493
|
+
|
|
494
|
+
def _from_wire(self, name: str, wire_value: Any) -> Any:
|
|
495
|
+
if name == "events":
|
|
496
|
+
cache = self._sched_state()["cache"]
|
|
497
|
+
if cache is not None and cache[0] is wire_value:
|
|
498
|
+
return list(cast("list[ScheduleEvent]", cache[1]))
|
|
499
|
+
return [as_event(_unwire_event(e)) for e in cast("list[Any]", wire_value)]
|
|
500
|
+
return super()._from_wire(name, wire_value)
|
|
501
|
+
|
|
502
|
+
@property
|
|
503
|
+
def schedule_events(self) -> list[ScheduleEvent]:
|
|
504
|
+
"""The current events as :class:`ScheduleEvent` objects."""
|
|
505
|
+
v = self.get_prop("events")
|
|
506
|
+
return [] if v is UNSET else cast("list[ScheduleEvent]", v)
|
|
507
|
+
|
|
508
|
+
def find_event(self, event_id: str | int) -> ScheduleEvent | None:
|
|
509
|
+
for e in self.schedule_events:
|
|
510
|
+
if e.id == event_id or str(e.id) == str(event_id):
|
|
511
|
+
return e
|
|
512
|
+
return None
|
|
513
|
+
|
|
514
|
+
def apply_change(self, change: ScheduleEventChange) -> ScheduleEvent | None:
|
|
515
|
+
"""Apply a proposed move/resize (``ScheduleEventChange.accept``)."""
|
|
516
|
+
ev = change.event
|
|
517
|
+
if ev is None or change.start is None or change.end is None:
|
|
518
|
+
return None
|
|
519
|
+
events = self.schedule_events
|
|
520
|
+
if ev.recurring_event_id is not None and self.find_event(ev.id) is None:
|
|
521
|
+
# an occurrence generated by the page: store an override for it
|
|
522
|
+
new = ev.moved(change.start, change.end, change.resource_id)
|
|
523
|
+
events.append(new)
|
|
524
|
+
else:
|
|
525
|
+
new = ev.moved(change.start, change.end, change.resource_id)
|
|
526
|
+
events = [new if e.id == ev.id else e for e in events]
|
|
527
|
+
self.update(events=events)
|
|
528
|
+
return new
|
|
529
|
+
|
|
530
|
+
# ---------------------------------------------------------- the range
|
|
531
|
+
def visible_range(self) -> tuple[_dt.date, _dt.date]:
|
|
532
|
+
"""First and last day this view shows now (inclusive)."""
|
|
533
|
+
if "range_start" in self.PROPS:
|
|
534
|
+
lo, hi = self.get_prop("range_start"), self.get_prop("range_end")
|
|
535
|
+
if not isinstance(lo, _dt.date) or not isinstance(hi, _dt.date):
|
|
536
|
+
raise ValidationError(f"{self.TYPE}: range_start/range_end are not set")
|
|
537
|
+
return lo, hi
|
|
538
|
+
d = self.get_prop("date")
|
|
539
|
+
day = d if isinstance(d, _dt.date) else _dt.date.today()
|
|
540
|
+
fdow = self._props.get("first_day_of_week", 1)
|
|
541
|
+
view = self._view()
|
|
542
|
+
outside = self._props.get("with_outside_days")
|
|
543
|
+
if self.TYPE == "MobileMonthView":
|
|
544
|
+
outside = outside is True
|
|
545
|
+
if self.TYPE in ("ResourcesMonthView",) or (
|
|
546
|
+
self.TYPE == "ResourcesSchedule" and view == "month"
|
|
547
|
+
):
|
|
548
|
+
outside = False
|
|
549
|
+
return _visible_range(view, day, int(fdow), with_outside_days=outside is not False)
|
|
550
|
+
|
|
551
|
+
def _view(self) -> str:
|
|
552
|
+
v = self._props.get("view")
|
|
553
|
+
return v if isinstance(v, str) else self.DEFAULT_VIEW
|
|
554
|
+
|
|
555
|
+
def set_provider(self, provider: EventProvider | None) -> None:
|
|
556
|
+
"""Load events with ``provider(start, end)`` (inclusive dates) for the
|
|
557
|
+
visible range: now, after every navigation and on :meth:`refresh`.
|
|
558
|
+
|
|
559
|
+
Only events touching the range are kept (others are dropped and
|
|
560
|
+
logged), so the page never receives more than it shows. A coroutine
|
|
561
|
+
provider loads on navigation and on ``await refresh_async()``.
|
|
562
|
+
"""
|
|
563
|
+
st = self._sched_state()
|
|
564
|
+
old = st["sub"]
|
|
565
|
+
if old is not None:
|
|
566
|
+
old.dispose()
|
|
567
|
+
st["provider"], st["sub"] = provider, None
|
|
568
|
+
if provider is None:
|
|
569
|
+
return
|
|
570
|
+
if inspect.iscoroutinefunction(provider):
|
|
571
|
+
|
|
572
|
+
async def load_async(ev: ScheduleRangeEvent) -> None:
|
|
573
|
+
await self.refresh_async()
|
|
574
|
+
|
|
575
|
+
st["sub"] = self.on("range_change", load_async)
|
|
576
|
+
else:
|
|
577
|
+
|
|
578
|
+
def load(ev: ScheduleRangeEvent) -> None:
|
|
579
|
+
self.refresh()
|
|
580
|
+
|
|
581
|
+
st["sub"] = self.on("range_change", load)
|
|
582
|
+
self.refresh()
|
|
583
|
+
|
|
584
|
+
def refresh(self) -> None:
|
|
585
|
+
"""Ask the (synchronous) provider for the visible range again."""
|
|
586
|
+
st = self._sched_state()
|
|
587
|
+
provider = st["provider"]
|
|
588
|
+
if provider is None:
|
|
589
|
+
return
|
|
590
|
+
if inspect.iscoroutinefunction(provider):
|
|
591
|
+
raise ValidationError("this provider is async: use 'await refresh_async()'")
|
|
592
|
+
start, end = self.visible_range()
|
|
593
|
+
gen = self._next_gen()
|
|
594
|
+
result = provider(start, end)
|
|
595
|
+
if inspect.isawaitable(result):
|
|
596
|
+
close = getattr(result, "close", None)
|
|
597
|
+
if callable(close):
|
|
598
|
+
close()
|
|
599
|
+
raise ValidationError("the provider returned an awaitable: use 'await refresh_async()'")
|
|
600
|
+
self._apply_loaded(gen, start, end, cast("Iterable[Any]", result))
|
|
601
|
+
|
|
602
|
+
async def refresh_async(self) -> None:
|
|
603
|
+
st = self._sched_state()
|
|
604
|
+
provider = st["provider"]
|
|
605
|
+
if provider is None:
|
|
606
|
+
return
|
|
607
|
+
start, end = self.visible_range()
|
|
608
|
+
gen = self._next_gen()
|
|
609
|
+
result = provider(start, end)
|
|
610
|
+
if inspect.isawaitable(result):
|
|
611
|
+
result = await result
|
|
612
|
+
self._apply_loaded(gen, start, end, cast("Iterable[Any]", result))
|
|
613
|
+
|
|
614
|
+
def _next_gen(self) -> int:
|
|
615
|
+
st = self._sched_state()
|
|
616
|
+
with st["lock"]:
|
|
617
|
+
st["gen"] += 1
|
|
618
|
+
return cast("int", st["gen"])
|
|
619
|
+
|
|
620
|
+
def _apply_loaded(
|
|
621
|
+
self, gen: int, start: _dt.date, end: _dt.date, result: Iterable[Any]
|
|
622
|
+
) -> None:
|
|
623
|
+
st = self._sched_state()
|
|
624
|
+
tz = self._tz()
|
|
625
|
+
events = [as_event(e) for e in result]
|
|
626
|
+
kept = [e for e in events if e.overlaps(start, end, tz)]
|
|
627
|
+
if len(kept) != len(events):
|
|
628
|
+
log.debug(
|
|
629
|
+
"%s: provider returned %d events outside %s..%s (dropped)",
|
|
630
|
+
self.TYPE,
|
|
631
|
+
len(events) - len(kept),
|
|
632
|
+
start,
|
|
633
|
+
end,
|
|
634
|
+
)
|
|
635
|
+
with st["lock"]:
|
|
636
|
+
if gen != st["gen"]:
|
|
637
|
+
return # a newer navigation won
|
|
638
|
+
self.update(events=kept)
|
|
639
|
+
|
|
640
|
+
# --------------------------------------------------- page -> python
|
|
641
|
+
def _on_client_event(self, name: str, payload: Mapping[str, Any]) -> Any:
|
|
642
|
+
if name == "range_change":
|
|
643
|
+
return self._range_event(payload)
|
|
644
|
+
if name in ("event_click", "event_drop", "event_resize"):
|
|
645
|
+
return self._event_change(name, payload)
|
|
646
|
+
if name in ("slot_click", "slot_select", "day_click"):
|
|
647
|
+
return self._slot_event(name, payload)
|
|
648
|
+
return super()._on_client_event(name, payload)
|
|
649
|
+
|
|
650
|
+
def _range_event(self, payload: Mapping[str, Any]) -> ScheduleRangeEvent:
|
|
651
|
+
_keys(payload, {"date", "view"})
|
|
652
|
+
d = payload.get("date")
|
|
653
|
+
if not isinstance(d, str):
|
|
654
|
+
raise ValidationError("range_change: date must be an ISO date")
|
|
655
|
+
day = parse_date(d)
|
|
656
|
+
view = payload.get("view")
|
|
657
|
+
if view is not None:
|
|
658
|
+
spec = self.PROPS.get("view")
|
|
659
|
+
if spec is None or view not in spec.values:
|
|
660
|
+
raise ValidationError(f"range_change: invalid view {view!r}")
|
|
661
|
+
self._commit_from_client("view", view)
|
|
662
|
+
if "date" in self.PROPS:
|
|
663
|
+
self._commit_from_client("date", day.isoformat())
|
|
664
|
+
start, end = self.visible_range()
|
|
665
|
+
return ScheduleRangeEvent(
|
|
666
|
+
name="range_change",
|
|
667
|
+
sender=self,
|
|
668
|
+
payload=dict(payload),
|
|
669
|
+
date=day,
|
|
670
|
+
view=self._view(),
|
|
671
|
+
start=start,
|
|
672
|
+
end=end,
|
|
673
|
+
)
|
|
674
|
+
|
|
675
|
+
def _moment(self, v: Any, what: str) -> _dt.datetime:
|
|
676
|
+
if not isinstance(v, str):
|
|
677
|
+
raise ValidationError(f"{what}: expected a datetime string")
|
|
678
|
+
return from_wall(parse_datetime(v), self._tz())
|
|
679
|
+
|
|
680
|
+
def _event_change(self, name: str, payload: Mapping[str, Any]) -> ScheduleEventChange:
|
|
681
|
+
_keys(payload, {"id", "start", "end", "resource_id", "series_id", "recurrence_id"})
|
|
682
|
+
eid = _event_id(payload.get("id"), f"{name}.id")
|
|
683
|
+
ev = self.find_event(eid)
|
|
684
|
+
series_id = payload.get("series_id")
|
|
685
|
+
rec_id = payload.get("recurrence_id")
|
|
686
|
+
if ev is None and series_id is not None and isinstance(rec_id, str):
|
|
687
|
+
series = self.find_event(_event_id(series_id, f"{name}.series_id"))
|
|
688
|
+
if series is not None and series.recurrence is not None:
|
|
689
|
+
ev = _occurrence_of(series, parse_datetime(rec_id), self._tz())
|
|
690
|
+
rid = payload.get("resource_id")
|
|
691
|
+
resource = None if rid is None else _event_id(rid, f"{name}.resource_id")
|
|
692
|
+
if name == "event_click":
|
|
693
|
+
start = ev.start if ev is not None else None
|
|
694
|
+
end = ev.end if ev is not None else None
|
|
695
|
+
else:
|
|
696
|
+
s = self._moment(payload.get("start"), f"{name}.start")
|
|
697
|
+
e = self._moment(payload.get("end"), f"{name}.end")
|
|
698
|
+
if e < s:
|
|
699
|
+
raise ValidationError(f"{name}: end before start")
|
|
700
|
+
start, end = s, e
|
|
701
|
+
if ev is not None and ev.all_day:
|
|
702
|
+
# all-day events keep dates: the page's end is the next midnight
|
|
703
|
+
start = s.date()
|
|
704
|
+
end = (e - _dt.timedelta(seconds=1)).date() if e > s else s.date()
|
|
705
|
+
return ScheduleEventChange(
|
|
706
|
+
name=name,
|
|
707
|
+
sender=self,
|
|
708
|
+
payload=dict(payload),
|
|
709
|
+
event=ev,
|
|
710
|
+
event_id=eid,
|
|
711
|
+
start=start,
|
|
712
|
+
end=end,
|
|
713
|
+
resource_id=resource,
|
|
714
|
+
)
|
|
715
|
+
|
|
716
|
+
def _slot_event(self, name: str, payload: Mapping[str, Any]) -> ScheduleSlotEvent:
|
|
717
|
+
_keys(payload, {"start", "end", "date", "resource_id"})
|
|
718
|
+
rid = payload.get("resource_id")
|
|
719
|
+
resource = None if rid is None else _event_id(rid, f"{name}.resource_id")
|
|
720
|
+
if name == "day_click":
|
|
721
|
+
d = payload.get("date")
|
|
722
|
+
if not isinstance(d, str):
|
|
723
|
+
raise ValidationError("day_click: date must be an ISO date")
|
|
724
|
+
day = parse_date(d)
|
|
725
|
+
if "selected_date" in self.PROPS:
|
|
726
|
+
self._commit_from_client("selected_date", day.isoformat())
|
|
727
|
+
return ScheduleSlotEvent(
|
|
728
|
+
name=name,
|
|
729
|
+
sender=self,
|
|
730
|
+
payload=dict(payload),
|
|
731
|
+
start=day,
|
|
732
|
+
end=day,
|
|
733
|
+
resource_id=resource,
|
|
734
|
+
all_day=True,
|
|
735
|
+
)
|
|
736
|
+
s = self._moment(payload.get("start"), f"{name}.start")
|
|
737
|
+
e = self._moment(payload.get("end"), f"{name}.end")
|
|
738
|
+
if e < s:
|
|
739
|
+
raise ValidationError(f"{name}: end before start")
|
|
740
|
+
return ScheduleSlotEvent(
|
|
741
|
+
name=name, sender=self, payload=dict(payload), start=s, end=e, resource_id=resource
|
|
742
|
+
)
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
def _keys(payload: Mapping[str, Any], allowed: set[str]) -> None:
|
|
746
|
+
extra = set(payload) - allowed
|
|
747
|
+
if extra:
|
|
748
|
+
raise ValidationError(f"unexpected payload keys {sorted(extra)}")
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
def _event_id(v: Any, what: str) -> str | int:
|
|
752
|
+
if isinstance(v, bool) or not isinstance(v, (str, int)):
|
|
753
|
+
raise ValidationError(f"{what}: expected a str or int id")
|
|
754
|
+
if isinstance(v, str) and len(v) > 300:
|
|
755
|
+
raise ValidationError(f"{what}: too long")
|
|
756
|
+
return v
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def _occurrence_of(
|
|
760
|
+
series: ScheduleEvent, start: _dt.datetime, tz: _dt.tzinfo | None
|
|
761
|
+
) -> ScheduleEvent:
|
|
762
|
+
s, e = series.wall_span(tz)
|
|
763
|
+
from .._schedule import _occurrence # pyright: ignore[reportPrivateUsage]
|
|
764
|
+
|
|
765
|
+
return _occurrence(series, start, start + (e - s), tz)
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
def _unwire_event(m: Any) -> dict[str, Any]:
|
|
769
|
+
w = cast("Mapping[str, Any]", m)
|
|
770
|
+
out: dict[str, Any] = {
|
|
771
|
+
"id": w["id"],
|
|
772
|
+
"title": w["title"],
|
|
773
|
+
"start": parse_datetime(w["start"]),
|
|
774
|
+
"end": parse_datetime(w["end"]),
|
|
775
|
+
"color": w.get("color", "blue"),
|
|
776
|
+
}
|
|
777
|
+
for k, py in (("resourceId", "resource_id"), ("variant", "variant"), ("display", "display")):
|
|
778
|
+
if k in w:
|
|
779
|
+
out[py] = w[k]
|
|
780
|
+
return out
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
def _resources(value: Any) -> list[dict[str, Any]]:
|
|
784
|
+
if isinstance(value, (str, Mapping)) or not isinstance(value, Iterable):
|
|
785
|
+
raise ValidationError("resources: expected a list of {'id', 'label', 'color'?}")
|
|
786
|
+
out: list[dict[str, Any]] = []
|
|
787
|
+
seen: set[str] = set()
|
|
788
|
+
for i, r in enumerate(cast("Iterable[Any]", value)):
|
|
789
|
+
m = cast("Mapping[str, Any]", r) if isinstance(r, Mapping) else None
|
|
790
|
+
if m is None or not {"id", "label"} <= set(m) or set(m) - {"id", "label", "color"}:
|
|
791
|
+
raise ValidationError(f"resources[{i}]: expected {{'id', 'label', 'color'?}}")
|
|
792
|
+
rid = _event_id(m["id"], f"resources[{i}].id")
|
|
793
|
+
if str(rid) in seen:
|
|
794
|
+
raise ValidationError(f"resources[{i}]: duplicate id {rid!r}")
|
|
795
|
+
seen.add(str(rid))
|
|
796
|
+
if not isinstance(m["label"], str):
|
|
797
|
+
raise ValidationError(f"resources[{i}].label: expected str")
|
|
798
|
+
d: dict[str, Any] = {"id": rid, "label": m["label"]}
|
|
799
|
+
if "color" in m:
|
|
800
|
+
if not isinstance(m["color"], str):
|
|
801
|
+
raise ValidationError(f"resources[{i}].color: expected str")
|
|
802
|
+
d["color"] = m["color"]
|
|
803
|
+
out.append(d)
|
|
804
|
+
return out
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
def _groups(value: Any) -> list[dict[str, Any]]:
|
|
808
|
+
if isinstance(value, (str, Mapping)) or not isinstance(value, Iterable):
|
|
809
|
+
raise ValidationError("groups: expected a list of {'label', 'resource_ids'}")
|
|
810
|
+
out: list[dict[str, Any]] = []
|
|
811
|
+
for i, r in enumerate(cast("Iterable[Any]", value)):
|
|
812
|
+
m = cast("Mapping[str, Any]", r) if isinstance(r, Mapping) else None
|
|
813
|
+
if m is None or set(m) != {"label", "resource_ids"} or not isinstance(m["label"], str):
|
|
814
|
+
raise ValidationError(f"groups[{i}]: expected {{'label': str, 'resource_ids': [...]}}")
|
|
815
|
+
ids = m["resource_ids"]
|
|
816
|
+
if isinstance(ids, (str, Mapping)) or not isinstance(ids, Sequence):
|
|
817
|
+
raise ValidationError(f"groups[{i}].resource_ids: expected a list")
|
|
818
|
+
out.append(
|
|
819
|
+
{
|
|
820
|
+
"label": m["label"],
|
|
821
|
+
"resourceIds": [
|
|
822
|
+
_event_id(x, f"groups[{i}].resource_ids") for x in cast("Sequence[Any]", ids)
|
|
823
|
+
],
|
|
824
|
+
}
|
|
825
|
+
)
|
|
826
|
+
return out
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
class Scheduler(_ScheduleBehaviour, g.Scheduler):
|
|
830
|
+
__doc__ = _doc(g.Scheduler)
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
class DayView(_ScheduleBehaviour, g.DayView):
|
|
834
|
+
__doc__ = _doc(g.DayView)
|
|
835
|
+
DEFAULT_VIEW = "day"
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
class WeekView(_ScheduleBehaviour, g.WeekView):
|
|
839
|
+
__doc__ = _doc(g.WeekView)
|
|
840
|
+
DEFAULT_VIEW = "week"
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
class MonthView(_ScheduleBehaviour, g.MonthView):
|
|
844
|
+
__doc__ = _doc(g.MonthView)
|
|
845
|
+
DEFAULT_VIEW = "month"
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
class YearView(_ScheduleBehaviour, g.YearView):
|
|
849
|
+
__doc__ = _doc(g.YearView)
|
|
850
|
+
DEFAULT_VIEW = "year"
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
class AgendaView(_ScheduleBehaviour, g.AgendaView):
|
|
854
|
+
__doc__ = _doc(g.AgendaView)
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
class MobileMonthView(_ScheduleBehaviour, g.MobileMonthView):
|
|
858
|
+
__doc__ = _doc(g.MobileMonthView)
|
|
859
|
+
DEFAULT_VIEW = "month"
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
class ResourcesSchedule(_ScheduleBehaviour, g.ResourcesSchedule):
|
|
863
|
+
__doc__ = _doc(g.ResourcesSchedule)
|
|
864
|
+
DEFAULT_VIEW = "day"
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
class ResourcesDayView(_ScheduleBehaviour, g.ResourcesDayView):
|
|
868
|
+
__doc__ = _doc(g.ResourcesDayView)
|
|
869
|
+
DEFAULT_VIEW = "day"
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
class ResourcesWeekView(_ScheduleBehaviour, g.ResourcesWeekView):
|
|
873
|
+
__doc__ = _doc(g.ResourcesWeekView)
|
|
874
|
+
DEFAULT_VIEW = "week"
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
class ResourcesMonthView(_ScheduleBehaviour, g.ResourcesMonthView):
|
|
878
|
+
__doc__ = _doc(g.ResourcesMonthView)
|
|
879
|
+
DEFAULT_VIEW = "month"
|