@moldable-ai/ui 0.2.21 → 0.2.24
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.
- package/dist/catalog/catalog-coverage.d.ts +1 -1
- package/dist/catalog/catalog-manifest.d.ts +1 -1
- package/dist/catalog/catalog-manifest.js +1 -1
- package/dist/catalog/catalog-types.d.ts +7 -0
- package/dist/catalog/catalog-types.d.ts.map +1 -1
- package/dist/catalog/catalog-types.js +1 -0
- package/dist/catalog/component-catalog.d.ts +1 -1
- package/dist/catalog/component-catalog.js +2 -2
- package/dist/catalog/core-catalog-exclusions.d.ts +1 -1
- package/dist/catalog/core-catalog-exclusions.d.ts.map +1 -1
- package/dist/catalog/core-catalog-exclusions.js +1 -146
- package/dist/catalog/core-catalog.d.ts +1 -1
- package/dist/catalog/core-catalog.d.ts.map +1 -1
- package/dist/catalog/core-catalog.js +11 -7
- package/dist/catalog/core-collection-stories.d.ts +1 -1
- package/dist/catalog/core-collection-stories.d.ts.map +1 -1
- package/dist/catalog/core-collection-stories.js +41 -9
- package/dist/catalog/core-control-stories.d.ts +1 -1
- package/dist/catalog/core-control-stories.d.ts.map +1 -1
- package/dist/catalog/core-control-stories.js +53 -22
- package/dist/catalog/core-feedback-stories.d.ts +1 -1
- package/dist/catalog/core-feedback-stories.d.ts.map +1 -1
- package/dist/catalog/core-feedback-stories.js +89 -10
- package/dist/catalog/core-form-stories.d.ts +3 -0
- package/dist/catalog/core-form-stories.d.ts.map +1 -0
- package/dist/catalog/core-form-stories.js +56 -0
- package/dist/catalog/core-foundation-stories.d.ts +1 -1
- package/dist/catalog/core-foundation-stories.js +7 -7
- package/dist/catalog/core-layout-stories.d.ts +3 -0
- package/dist/catalog/core-layout-stories.d.ts.map +1 -0
- package/dist/catalog/core-layout-stories.js +78 -0
- package/dist/catalog/core-navigation-stories.d.ts +1 -1
- package/dist/catalog/core-navigation-stories.d.ts.map +1 -1
- package/dist/catalog/core-navigation-stories.js +25 -3
- package/dist/catalog/core-overlay-stories.d.ts +1 -1
- package/dist/catalog/core-overlay-stories.d.ts.map +1 -1
- package/dist/catalog/core-overlay-stories.js +113 -8
- package/dist/catalog/index.d.ts +6 -6
- package/dist/catalog/index.js +6 -6
- package/dist/components/app-error-boundary.d.ts.map +1 -1
- package/dist/components/app-error-boundary.js +4 -3
- package/dist/components/chat/chat-image-lightbox.js +3 -3
- package/dist/components/chat/chat-input.js +5 -5
- package/dist/components/chat/chat-message.js +17 -17
- package/dist/components/chat/chat-messages.d.ts +1 -1
- package/dist/components/chat/chat-messages.js +3 -3
- package/dist/components/chat/chat-panel.d.ts +6 -6
- package/dist/components/chat/chat-panel.d.ts.map +1 -1
- package/dist/components/chat/chat-panel.js +33 -33
- package/dist/components/chat/checkpoint-badge.js +3 -3
- package/dist/components/chat/conversation-history.d.ts.map +1 -1
- package/dist/components/chat/conversation-history.js +13 -13
- package/dist/components/chat/index.d.ts +20 -15
- package/dist/components/chat/index.d.ts.map +1 -1
- package/dist/components/chat/index.js +20 -15
- package/dist/components/chat/markdown.js +1 -1
- package/dist/components/chat/model-effort-selector.js +10 -10
- package/dist/components/chat/model-selector.js +4 -4
- package/dist/components/chat/reasoning-effort-selector.js +4 -4
- package/dist/components/chat/restore-dialog.js +3 -3
- package/dist/components/chat/thinking-timeline.js +2 -2
- package/dist/components/chat/tool-approval.d.ts +1 -1
- package/dist/components/chat/tool-approval.d.ts.map +1 -1
- package/dist/components/chat/tool-approval.js +9 -9
- package/dist/components/chat/tool-handlers.d.ts +2 -2
- package/dist/components/chat/tool-handlers.js +90 -90
- package/dist/components/chat/voice-orb-audio.d.ts +16 -0
- package/dist/components/chat/voice-orb-audio.d.ts.map +1 -0
- package/dist/components/chat/voice-orb-audio.js +110 -0
- package/dist/components/chat/voice-orb-renderer.d.ts +51 -0
- package/dist/components/chat/voice-orb-renderer.d.ts.map +1 -0
- package/dist/components/chat/voice-orb-renderer.js +410 -0
- package/dist/components/chat/voice-orb-shaders.d.ts +3 -0
- package/dist/components/chat/voice-orb-shaders.d.ts.map +1 -0
- package/dist/components/chat/voice-orb-shaders.js +355 -0
- package/dist/components/chat/voice-orb-types.d.ts +24 -0
- package/dist/components/chat/voice-orb-types.d.ts.map +1 -0
- package/dist/components/chat/voice-orb-types.js +73 -0
- package/dist/components/chat/voice-orb.d.ts +20 -0
- package/dist/components/chat/voice-orb.d.ts.map +1 -0
- package/dist/components/chat/voice-orb.js +67 -0
- package/dist/components/code-block.js +1 -1
- package/dist/components/hardware/bluetooth-panel.d.ts +2 -2
- package/dist/components/hardware/bluetooth-panel.js +10 -10
- package/dist/components/hardware/camera-preview.js +6 -6
- package/dist/components/hardware/capability-badge.d.ts +2 -2
- package/dist/components/hardware/capability-badge.js +2 -2
- package/dist/components/hardware/capability-matrix.d.ts +1 -1
- package/dist/components/hardware/capability-matrix.js +5 -5
- package/dist/components/hardware/clipboard-button.d.ts +1 -1
- package/dist/components/hardware/clipboard-button.js +2 -2
- package/dist/components/hardware/device-list.js +1 -1
- package/dist/components/hardware/display-map.d.ts +1 -1
- package/dist/components/hardware/display-map.js +7 -7
- package/dist/components/hardware/haptic-button.d.ts +2 -2
- package/dist/components/hardware/haptic-button.js +3 -3
- package/dist/components/hardware/hardware-panel.js +1 -1
- package/dist/components/hardware/hid-panel.d.ts +2 -2
- package/dist/components/hardware/hid-panel.js +10 -10
- package/dist/components/hardware/index.d.ts +26 -26
- package/dist/components/hardware/index.js +26 -26
- package/dist/components/hardware/live-indicator.js +1 -1
- package/dist/components/hardware/local-auth-button.d.ts +2 -2
- package/dist/components/hardware/local-auth-button.js +4 -4
- package/dist/components/hardware/location-panel.d.ts +1 -1
- package/dist/components/hardware/location-panel.js +6 -6
- package/dist/components/hardware/microphone-meter.js +7 -7
- package/dist/components/hardware/midi-monitor.d.ts +2 -2
- package/dist/components/hardware/midi-monitor.js +9 -9
- package/dist/components/hardware/notification-panel.d.ts +1 -1
- package/dist/components/hardware/notification-panel.js +8 -8
- package/dist/components/hardware/power-blocker-controller.d.ts +1 -1
- package/dist/components/hardware/power-blocker-controller.js +1 -1
- package/dist/components/hardware/power-panel.d.ts +1 -1
- package/dist/components/hardware/power-panel.js +9 -9
- package/dist/components/hardware/readout.js +1 -1
- package/dist/components/hardware/screen-share-preview.js +5 -5
- package/dist/components/hardware/secure-storage-panel.d.ts +1 -1
- package/dist/components/hardware/secure-storage-panel.js +9 -9
- package/dist/components/hardware/serial-console.d.ts +2 -2
- package/dist/components/hardware/serial-console.js +10 -10
- package/dist/components/hardware/shortcut-recorder.d.ts +1 -1
- package/dist/components/hardware/shortcut-recorder.js +4 -4
- package/dist/components/hardware/stream-log.js +1 -1
- package/dist/components/hardware/system-audio-monitor.d.ts +1 -1
- package/dist/components/hardware/system-audio-monitor.js +9 -9
- package/dist/components/hardware/usb-panel.d.ts +5 -5
- package/dist/components/hardware/usb-panel.js +10 -10
- package/dist/components/hardware/use-capability.d.ts +1 -1
- package/dist/components/hardware/use-capability.js +1 -1
- package/dist/components/markdown.js +5 -5
- package/dist/components/native-capabilities/bluetooth-panel.d.ts +2 -2
- package/dist/components/native-capabilities/bluetooth-panel.d.ts.map +1 -1
- package/dist/components/native-capabilities/bluetooth-panel.js +17 -17
- package/dist/components/native-capabilities/camera-preview.d.ts.map +1 -1
- package/dist/components/native-capabilities/camera-preview.js +7 -7
- package/dist/components/native-capabilities/capability-badge.d.ts +2 -2
- package/dist/components/native-capabilities/capability-badge.js +4 -4
- package/dist/components/native-capabilities/capability-matrix.d.ts +1 -1
- package/dist/components/native-capabilities/capability-matrix.js +7 -7
- package/dist/components/native-capabilities/clipboard-button.d.ts +1 -1
- package/dist/components/native-capabilities/clipboard-button.js +2 -2
- package/dist/components/native-capabilities/device-list.js +4 -4
- package/dist/components/native-capabilities/display-map.d.ts +1 -1
- package/dist/components/native-capabilities/display-map.d.ts.map +1 -1
- package/dist/components/native-capabilities/display-map.js +11 -11
- package/dist/components/native-capabilities/haptic-button.d.ts +2 -2
- package/dist/components/native-capabilities/haptic-button.js +3 -3
- package/dist/components/native-capabilities/hid-panel.d.ts +2 -2
- package/dist/components/native-capabilities/hid-panel.d.ts.map +1 -1
- package/dist/components/native-capabilities/hid-panel.js +14 -14
- package/dist/components/native-capabilities/index.d.ts +26 -26
- package/dist/components/native-capabilities/index.js +26 -26
- package/dist/components/native-capabilities/live-indicator.js +3 -3
- package/dist/components/native-capabilities/local-auth-button.d.ts +2 -2
- package/dist/components/native-capabilities/local-auth-button.js +4 -4
- package/dist/components/native-capabilities/location-panel.d.ts +1 -1
- package/dist/components/native-capabilities/location-panel.d.ts.map +1 -1
- package/dist/components/native-capabilities/location-panel.js +8 -8
- package/dist/components/native-capabilities/microphone-meter.js +9 -9
- package/dist/components/native-capabilities/midi-monitor.d.ts +2 -2
- package/dist/components/native-capabilities/midi-monitor.d.ts.map +1 -1
- package/dist/components/native-capabilities/midi-monitor.js +11 -11
- package/dist/components/native-capabilities/native-capability-panel.js +6 -6
- package/dist/components/native-capabilities/notification-panel.d.ts +1 -1
- package/dist/components/native-capabilities/notification-panel.js +9 -9
- package/dist/components/native-capabilities/power-blocker-controller.d.ts +1 -1
- package/dist/components/native-capabilities/power-blocker-controller.js +1 -1
- package/dist/components/native-capabilities/power-panel.d.ts +1 -1
- package/dist/components/native-capabilities/power-panel.d.ts.map +1 -1
- package/dist/components/native-capabilities/power-panel.js +12 -12
- package/dist/components/native-capabilities/readout.d.ts.map +1 -1
- package/dist/components/native-capabilities/readout.js +2 -2
- package/dist/components/native-capabilities/screen-share-preview.js +6 -6
- package/dist/components/native-capabilities/secure-storage-panel.d.ts +1 -1
- package/dist/components/native-capabilities/secure-storage-panel.d.ts.map +1 -1
- package/dist/components/native-capabilities/secure-storage-panel.js +11 -11
- package/dist/components/native-capabilities/serial-console.d.ts +2 -2
- package/dist/components/native-capabilities/serial-console.d.ts.map +1 -1
- package/dist/components/native-capabilities/serial-console.js +11 -11
- package/dist/components/native-capabilities/shortcut-recorder.d.ts +1 -1
- package/dist/components/native-capabilities/shortcut-recorder.js +5 -5
- package/dist/components/native-capabilities/stream-log.js +3 -3
- package/dist/components/native-capabilities/system-audio-monitor.d.ts +1 -1
- package/dist/components/native-capabilities/system-audio-monitor.js +12 -12
- package/dist/components/native-capabilities/usb-panel.d.ts +5 -5
- package/dist/components/native-capabilities/usb-panel.js +15 -15
- package/dist/components/native-capabilities/use-capability.d.ts +1 -1
- package/dist/components/native-capabilities/use-capability.js +1 -1
- package/dist/components/rich-media-player.js +3 -3
- package/dist/components/ui/accordion.js +3 -3
- package/dist/components/ui/alert-dialog.d.ts +5 -3
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.js +20 -10
- package/dist/components/ui/alert.d.ts +2 -2
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +11 -11
- package/dist/components/ui/app-frame.d.ts +7 -1
- package/dist/components/ui/app-frame.d.ts.map +1 -1
- package/dist/components/ui/app-frame.js +52 -16
- package/dist/components/ui/avatar.js +5 -5
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/badge.js +4 -4
- package/dist/components/ui/breadcrumb.js +2 -2
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button-group.js +4 -4
- package/dist/components/ui/button.d.ts +6 -4
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +50 -18
- package/dist/components/ui/calendar.d.ts +1 -1
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar.js +15 -15
- package/dist/components/ui/card.js +3 -3
- package/dist/components/ui/carousel.d.ts +1 -1
- package/dist/components/ui/carousel.js +4 -4
- package/dist/components/ui/chart.js +5 -5
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +2 -2
- package/dist/components/ui/collapsible.js +3 -3
- package/dist/components/ui/color-well.js +2 -2
- package/dist/components/ui/combobox.js +9 -9
- package/dist/components/ui/command.d.ts +1 -1
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/command.js +9 -9
- package/dist/components/ui/confirm-dialog.d.ts +1 -1
- package/dist/components/ui/confirm-dialog.d.ts.map +1 -1
- package/dist/components/ui/confirm-dialog.js +2 -2
- package/dist/components/ui/context-menu.d.ts +16 -5
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +92 -16
- package/dist/components/ui/date-field.d.ts.map +1 -1
- package/dist/components/ui/date-field.js +8 -8
- package/dist/components/ui/date-picker.d.ts +2 -2
- package/dist/components/ui/date-picker.js +7 -7
- package/dist/components/ui/dialog-primary-action.d.ts +4 -0
- package/dist/components/ui/dialog-primary-action.d.ts.map +1 -0
- package/dist/components/ui/dialog-primary-action.js +37 -0
- package/dist/components/ui/dialog.d.ts +6 -2
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +20 -7
- package/dist/components/ui/drawer.js +4 -4
- package/dist/components/ui/dropdown-menu.d.ts +15 -5
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +98 -16
- package/dist/components/ui/edge-fade.js +1 -1
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/empty.js +5 -5
- package/dist/components/ui/error-boundary-view.d.ts +12 -0
- package/dist/components/ui/error-boundary-view.d.ts.map +1 -0
- package/dist/components/ui/error-boundary-view.js +8 -0
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.d.ts.map +1 -1
- package/dist/components/ui/field.js +9 -9
- package/dist/components/ui/form.js +4 -4
- package/dist/components/ui/grid.d.ts.map +1 -1
- package/dist/components/ui/grid.js +5 -5
- package/dist/components/ui/hover-card.js +2 -2
- package/dist/components/ui/icon-button.d.ts +1 -1
- package/dist/components/ui/icon-button.d.ts.map +1 -1
- package/dist/components/ui/icon-button.js +3 -4
- package/dist/components/ui/index.d.ts +77 -76
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +77 -76
- package/dist/components/ui/input-group.d.ts +3 -3
- package/dist/components/ui/input-group.js +14 -14
- package/dist/components/ui/input-otp.js +3 -3
- package/dist/components/ui/input.js +2 -2
- package/dist/components/ui/inspector.d.ts +1 -1
- package/dist/components/ui/inspector.js +6 -6
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/item.js +7 -7
- package/dist/components/ui/kbd.js +2 -2
- package/dist/components/ui/label.js +2 -2
- package/dist/components/ui/list.d.ts.map +1 -1
- package/dist/components/ui/list.js +5 -5
- package/dist/components/ui/material.js +3 -3
- package/dist/components/ui/menu-items.d.ts +28 -0
- package/dist/components/ui/menu-items.d.ts.map +1 -0
- package/dist/components/ui/menu-items.js +111 -0
- package/dist/components/ui/menubar.js +11 -11
- package/dist/components/ui/message-scroller-controller.d.ts +1 -1
- package/dist/components/ui/message-scroller-controller.js +1 -1
- package/dist/components/ui/message-scroller-primitive.d.ts +1 -1
- package/dist/components/ui/message-scroller-primitive.js +1 -1
- package/dist/components/ui/message-scroller.d.ts +2 -2
- package/dist/components/ui/message-scroller.js +3 -3
- package/dist/components/ui/navigation-button-group.d.ts +2 -2
- package/dist/components/ui/navigation-button-group.js +2 -2
- package/dist/components/ui/navigation-menu.js +6 -6
- package/dist/components/ui/notification-dot.js +2 -2
- package/dist/components/ui/number-input.js +8 -8
- package/dist/components/ui/pagination.d.ts +1 -1
- package/dist/components/ui/pagination.js +2 -2
- package/dist/components/ui/panel.d.ts +1 -1
- package/dist/components/ui/panel.js +3 -3
- package/dist/components/ui/popover.d.ts +1 -1
- package/dist/components/ui/popover.js +3 -3
- package/dist/components/ui/progress.js +2 -2
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js +2 -2
- package/dist/components/ui/resizable.d.ts +1 -1
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +15 -4
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +3 -3
- package/dist/components/ui/search-field.js +7 -7
- package/dist/components/ui/segmented-control.js +9 -9
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +6 -6
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/sheet.js +4 -4
- package/dist/components/ui/sidebar.d.ts +5 -5
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/sidebar.js +111 -24
- package/dist/components/ui/skeleton.js +2 -2
- package/dist/components/ui/slider.d.ts +3 -1
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +3 -3
- package/dist/components/ui/sonner.js +1 -1
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner.js +2 -2
- package/dist/components/ui/split-view.js +1 -1
- package/dist/components/ui/status.d.ts +1 -1
- package/dist/components/ui/status.d.ts.map +1 -1
- package/dist/components/ui/status.js +10 -9
- package/dist/components/ui/switch.js +2 -2
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +7 -7
- package/dist/components/ui/tabs.js +3 -3
- package/dist/components/ui/text.d.ts +2 -2
- package/dist/components/ui/text.js +19 -19
- package/dist/components/ui/textarea.js +2 -2
- package/dist/components/ui/toggle-group.d.ts +1 -1
- package/dist/components/ui/toggle-group.js +4 -4
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.js +10 -10
- package/dist/components/ui/toolbar.d.ts +7 -7
- package/dist/components/ui/toolbar.js +7 -7
- package/dist/components/ui/tooltip.d.ts +2 -2
- package/dist/components/ui/tooltip.js +5 -5
- package/dist/index.d.ts +21 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -15
- package/dist/lib/frame-lifecycle.d.ts +49 -0
- package/dist/lib/frame-lifecycle.d.ts.map +1 -1
- package/dist/lib/frame-lifecycle.js +163 -1
- package/dist/lib/host-date-time-picker.d.ts +36 -0
- package/dist/lib/host-date-time-picker.d.ts.map +1 -0
- package/dist/lib/host-date-time-picker.js +162 -0
- package/dist/lib/host-file-dialog.d.ts +66 -0
- package/dist/lib/host-file-dialog.d.ts.map +1 -0
- package/dist/lib/host-file-dialog.js +221 -0
- package/dist/lib/host-native-menu.d.ts +116 -0
- package/dist/lib/host-native-menu.d.ts.map +1 -0
- package/dist/lib/host-native-menu.js +242 -0
- package/dist/lib/host-services.d.ts +13 -0
- package/dist/lib/host-services.d.ts.map +1 -0
- package/dist/lib/host-services.js +161 -0
- package/dist/lib/host-share.d.ts +39 -0
- package/dist/lib/host-share.d.ts.map +1 -0
- package/dist/lib/host-share.js +161 -0
- package/dist/lib/host-web-surface.d.ts +31 -0
- package/dist/lib/host-web-surface.d.ts.map +1 -0
- package/dist/lib/host-web-surface.js +116 -0
- package/dist/lib/native-capabilities/access.d.ts +2 -2
- package/dist/lib/native-capabilities/access.js +2 -2
- package/dist/lib/native-capabilities/bluetooth-access.d.ts +1 -1
- package/dist/lib/native-capabilities/bluetooth-access.js +2 -2
- package/dist/lib/native-capabilities/bluetooth-connection.d.ts +1 -1
- package/dist/lib/native-capabilities/bluetooth-connection.js +1 -1
- package/dist/lib/native-capabilities/bluetooth-gatt.d.ts +1 -1
- package/dist/lib/native-capabilities/bluetooth-gatt.js +1 -1
- package/dist/lib/native-capabilities/bluetooth-internal.d.ts +2 -2
- package/dist/lib/native-capabilities/bluetooth-internal.js +1 -1
- package/dist/lib/native-capabilities/bluetooth-native-fallback.d.ts +2 -2
- package/dist/lib/native-capabilities/bluetooth-native-fallback.js +2 -2
- package/dist/lib/native-capabilities/bluetooth.d.ts +6 -6
- package/dist/lib/native-capabilities/bluetooth.js +4 -4
- package/dist/lib/native-capabilities/bridge.d.ts +1 -1
- package/dist/lib/native-capabilities/bridge.js +2 -2
- package/dist/lib/native-capabilities/capabilities.d.ts +1 -1
- package/dist/lib/native-capabilities/capabilities.js +1 -1
- package/dist/lib/native-capabilities/clipboard.js +2 -2
- package/dist/lib/native-capabilities/device-io-errors.d.ts +1 -1
- package/dist/lib/native-capabilities/device-io-errors.js +1 -1
- package/dist/lib/native-capabilities/displays.d.ts +1 -1
- package/dist/lib/native-capabilities/displays.js +1 -1
- package/dist/lib/native-capabilities/global-shortcuts.d.ts +2 -2
- package/dist/lib/native-capabilities/global-shortcuts.js +1 -1
- package/dist/lib/native-capabilities/haptics.d.ts +1 -1
- package/dist/lib/native-capabilities/haptics.js +1 -1
- package/dist/lib/native-capabilities/hid-native.d.ts +2 -2
- package/dist/lib/native-capabilities/hid-native.js +3 -3
- package/dist/lib/native-capabilities/hid.js +5 -5
- package/dist/lib/native-capabilities/index.d.ts +39 -39
- package/dist/lib/native-capabilities/index.js +21 -21
- package/dist/lib/native-capabilities/local-authentication.d.ts +1 -1
- package/dist/lib/native-capabilities/local-authentication.js +1 -1
- package/dist/lib/native-capabilities/location.js +1 -1
- package/dist/lib/native-capabilities/media-permissions.d.ts +1 -1
- package/dist/lib/native-capabilities/media-permissions.js +1 -1
- package/dist/lib/native-capabilities/media.d.ts +1 -1
- package/dist/lib/native-capabilities/media.js +2 -2
- package/dist/lib/native-capabilities/midi-access.d.ts +1 -1
- package/dist/lib/native-capabilities/midi-access.js +3 -3
- package/dist/lib/native-capabilities/midi-internal.d.ts +1 -1
- package/dist/lib/native-capabilities/midi-internal.js +1 -1
- package/dist/lib/native-capabilities/midi-native-fallback.d.ts +1 -1
- package/dist/lib/native-capabilities/midi-native-fallback.js +2 -2
- package/dist/lib/native-capabilities/midi-ports.d.ts +1 -1
- package/dist/lib/native-capabilities/midi-ports.js +1 -1
- package/dist/lib/native-capabilities/midi.d.ts +5 -5
- package/dist/lib/native-capabilities/midi.js +3 -3
- package/dist/lib/native-capabilities/native-device-io.d.ts +1 -1
- package/dist/lib/native-capabilities/native-device-io.js +1 -1
- package/dist/lib/native-capabilities/native-device-lifecycle.js +1 -1
- package/dist/lib/native-capabilities/notifications.d.ts +2 -2
- package/dist/lib/native-capabilities/notifications.js +1 -1
- package/dist/lib/native-capabilities/power-session.d.ts +2 -2
- package/dist/lib/native-capabilities/power-session.js +1 -1
- package/dist/lib/native-capabilities/secure-storage.d.ts +1 -1
- package/dist/lib/native-capabilities/secure-storage.js +1 -1
- package/dist/lib/native-capabilities/serial-native.d.ts +2 -2
- package/dist/lib/native-capabilities/serial-native.js +3 -3
- package/dist/lib/native-capabilities/serial.js +5 -5
- package/dist/lib/native-capabilities/system-audio.d.ts +1 -1
- package/dist/lib/native-capabilities/system-audio.js +1 -1
- package/dist/lib/native-capabilities/usb-native.d.ts +2 -2
- package/dist/lib/native-capabilities/usb-native.js +3 -3
- package/dist/lib/native-capabilities/usb.js +5 -5
- package/dist/lib/native-hardware/bluetooth-access.d.ts +1 -1
- package/dist/lib/native-hardware/bluetooth-access.js +1 -1
- package/dist/lib/native-hardware/bluetooth-connection.d.ts +1 -1
- package/dist/lib/native-hardware/bluetooth-connection.js +1 -1
- package/dist/lib/native-hardware/bluetooth-gatt.d.ts +1 -1
- package/dist/lib/native-hardware/bluetooth-gatt.js +1 -1
- package/dist/lib/native-hardware/bluetooth-internal.d.ts +2 -2
- package/dist/lib/native-hardware/bluetooth-internal.js +1 -1
- package/dist/lib/native-hardware/bluetooth-native-fallback.d.ts +2 -2
- package/dist/lib/native-hardware/bluetooth-native-fallback.js +2 -2
- package/dist/lib/native-hardware/bluetooth.d.ts +6 -6
- package/dist/lib/native-hardware/bluetooth.js +4 -4
- package/dist/lib/native-hardware/bridge.d.ts +1 -1
- package/dist/lib/native-hardware/bridge.js +2 -2
- package/dist/lib/native-hardware/capabilities.d.ts +1 -1
- package/dist/lib/native-hardware/capabilities.js +1 -1
- package/dist/lib/native-hardware/clipboard.js +1 -1
- package/dist/lib/native-hardware/device-io-errors.d.ts +1 -1
- package/dist/lib/native-hardware/device-io-errors.js +1 -1
- package/dist/lib/native-hardware/displays.d.ts +1 -1
- package/dist/lib/native-hardware/displays.js +1 -1
- package/dist/lib/native-hardware/global-shortcuts.d.ts +2 -2
- package/dist/lib/native-hardware/global-shortcuts.js +1 -1
- package/dist/lib/native-hardware/haptics.d.ts +1 -1
- package/dist/lib/native-hardware/haptics.js +1 -1
- package/dist/lib/native-hardware/hid-native.d.ts +2 -2
- package/dist/lib/native-hardware/hid-native.js +3 -3
- package/dist/lib/native-hardware/hid.js +4 -4
- package/dist/lib/native-hardware/index.d.ts +37 -37
- package/dist/lib/native-hardware/index.js +20 -20
- package/dist/lib/native-hardware/local-authentication.d.ts +1 -1
- package/dist/lib/native-hardware/local-authentication.js +1 -1
- package/dist/lib/native-hardware/location.js +1 -1
- package/dist/lib/native-hardware/media-permissions.d.ts +1 -1
- package/dist/lib/native-hardware/media-permissions.js +1 -1
- package/dist/lib/native-hardware/media.d.ts +1 -1
- package/dist/lib/native-hardware/media.js +1 -1
- package/dist/lib/native-hardware/midi-access.d.ts +1 -1
- package/dist/lib/native-hardware/midi-access.js +2 -2
- package/dist/lib/native-hardware/midi-internal.d.ts +1 -1
- package/dist/lib/native-hardware/midi-internal.js +1 -1
- package/dist/lib/native-hardware/midi-native-fallback.d.ts +1 -1
- package/dist/lib/native-hardware/midi-native-fallback.js +2 -2
- package/dist/lib/native-hardware/midi-ports.d.ts +1 -1
- package/dist/lib/native-hardware/midi-ports.js +1 -1
- package/dist/lib/native-hardware/midi.d.ts +5 -5
- package/dist/lib/native-hardware/midi.js +3 -3
- package/dist/lib/native-hardware/native-device-io.d.ts +1 -1
- package/dist/lib/native-hardware/native-device-io.js +1 -1
- package/dist/lib/native-hardware/native-device-lifecycle.js +1 -1
- package/dist/lib/native-hardware/notifications.d.ts +2 -2
- package/dist/lib/native-hardware/notifications.js +1 -1
- package/dist/lib/native-hardware/power-session.d.ts +2 -2
- package/dist/lib/native-hardware/power-session.js +1 -1
- package/dist/lib/native-hardware/secure-storage.d.ts +1 -1
- package/dist/lib/native-hardware/secure-storage.js +1 -1
- package/dist/lib/native-hardware/serial-native.d.ts +2 -2
- package/dist/lib/native-hardware/serial-native.js +3 -3
- package/dist/lib/native-hardware/serial.js +4 -4
- package/dist/lib/native-hardware/system-audio.d.ts +1 -1
- package/dist/lib/native-hardware/system-audio.js +1 -1
- package/dist/lib/native-hardware/usb-native.d.ts +2 -2
- package/dist/lib/native-hardware/usb-native.js +3 -3
- package/dist/lib/native-hardware/usb.js +4 -4
- package/dist/lib/theme.js +1 -1
- package/docs/README.md +1 -0
- package/docs/design-tokens.md +28 -6
- package/docs/foundations.md +4 -2
- package/docs/visual-regression.md +78 -0
- package/package.json +15 -4
- package/src/components/ui/alert-dialog.md +27 -0
- package/src/components/ui/button.md +10 -3
- package/src/components/ui/confirm-dialog.md +97 -0
- package/src/components/ui/context-menu.md +158 -0
- package/src/components/ui/dialog.md +23 -4
- package/src/components/ui/dropdown-menu.md +165 -0
- package/src/components/ui/error-boundary-view.md +98 -0
- package/src/components/ui/hover-card.md +90 -0
- package/src/components/ui/select.md +111 -0
- package/src/lib/host-date-time-picker.md +29 -0
- package/src/lib/host-file-dialog.md +76 -0
- package/src/lib/host-native-menu.md +67 -0
- package/src/lib/host-share.md +36 -0
- package/src/lib/host-web-surface.md +66 -0
- package/src/styles/index.css +141 -68
|
@@ -1,4 +1,117 @@
|
|
|
1
|
+
export const MOLDABLE_NAVIGATION_CHORD_ALLOWLIST = [
|
|
2
|
+
{
|
|
3
|
+
chord: 'back',
|
|
4
|
+
code: 'BracketLeft',
|
|
5
|
+
metaKey: true,
|
|
6
|
+
altKey: false,
|
|
7
|
+
ctrlKey: false,
|
|
8
|
+
shiftKey: false,
|
|
9
|
+
},
|
|
10
|
+
];
|
|
1
11
|
let frameLifecycleInstalled = false;
|
|
12
|
+
let advertisedHostServices;
|
|
13
|
+
let sidebarMaterialPreviousBodyBackgroundColor = null;
|
|
14
|
+
export const MOLDABLE_MATERIAL_REGION_CHANGE_EVENT = 'moldable:material-region-change';
|
|
15
|
+
export const MOLDABLE_MATERIAL_REGION_MESSAGE_TYPE = 'moldable:material-region';
|
|
16
|
+
export const MOLDABLE_MATERIAL_REGION_ACK_TYPE = 'moldable:material-region-ack';
|
|
17
|
+
export const MOLDABLE_SIDEBAR_REGION_WIDTH_PROPERTY = '--moldable-material-region-sidebar-width';
|
|
18
|
+
function normalizeHostServices(value) {
|
|
19
|
+
if (typeof value !== 'object' ||
|
|
20
|
+
value === null ||
|
|
21
|
+
!('version' in value) ||
|
|
22
|
+
value.version !== 1 ||
|
|
23
|
+
!('services' in value) ||
|
|
24
|
+
typeof value.services !== 'object' ||
|
|
25
|
+
value.services === null ||
|
|
26
|
+
Array.isArray(value.services)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const services = {};
|
|
30
|
+
for (const [name, details] of Object.entries(value.services)) {
|
|
31
|
+
if (typeof details === 'object' &&
|
|
32
|
+
details !== null &&
|
|
33
|
+
!Array.isArray(details)) {
|
|
34
|
+
services[name] = { ...details };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { version: 1, services };
|
|
38
|
+
}
|
|
39
|
+
export function getMoldableHostServices() {
|
|
40
|
+
return advertisedHostServices;
|
|
41
|
+
}
|
|
42
|
+
function clearSidebarMaterialRegion() {
|
|
43
|
+
const root = document.documentElement;
|
|
44
|
+
const hadActiveRegion = root.dataset.moldableMaterialRegionSidebar === 'active';
|
|
45
|
+
delete root.dataset.moldableMaterialRegionSidebar;
|
|
46
|
+
delete root.dataset.moldableMaterialRegionSidebarId;
|
|
47
|
+
root.style.removeProperty(MOLDABLE_SIDEBAR_REGION_WIDTH_PROPERTY);
|
|
48
|
+
if (sidebarMaterialPreviousBodyBackgroundColor !== null) {
|
|
49
|
+
if (sidebarMaterialPreviousBodyBackgroundColor) {
|
|
50
|
+
document.body.style.backgroundColor =
|
|
51
|
+
sidebarMaterialPreviousBodyBackgroundColor;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
document.body.style.removeProperty('background-color');
|
|
55
|
+
}
|
|
56
|
+
sidebarMaterialPreviousBodyBackgroundColor = null;
|
|
57
|
+
}
|
|
58
|
+
if (hadActiveRegion) {
|
|
59
|
+
window.dispatchEvent(new CustomEvent(MOLDABLE_MATERIAL_REGION_CHANGE_EVENT, {
|
|
60
|
+
detail: { role: 'sidebar', active: false },
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function applyMoldableMaterialRegionAck(value) {
|
|
65
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const ack = value;
|
|
69
|
+
if (ack.type !== MOLDABLE_MATERIAL_REGION_ACK_TYPE ||
|
|
70
|
+
typeof ack.regionId !== 'string' ||
|
|
71
|
+
ack.regionId.length === 0 ||
|
|
72
|
+
ack.regionId.length > 128 ||
|
|
73
|
+
ack.role !== 'sidebar' ||
|
|
74
|
+
ack.side !== 'leading' ||
|
|
75
|
+
typeof ack.active !== 'boolean') {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (!ack.active) {
|
|
79
|
+
const activeRegionId = document.documentElement.dataset.moldableMaterialRegionSidebarId;
|
|
80
|
+
if (activeRegionId && activeRegionId !== ack.regionId)
|
|
81
|
+
return false;
|
|
82
|
+
clearSidebarMaterialRegion();
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (document.documentElement.dataset.moldableNativeMaterialSidebar !==
|
|
86
|
+
'available' ||
|
|
87
|
+
typeof ack.width !== 'number' ||
|
|
88
|
+
!Number.isFinite(ack.width) ||
|
|
89
|
+
ack.width < 120 ||
|
|
90
|
+
ack.width > 600) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const normalizedAck = {
|
|
94
|
+
type: MOLDABLE_MATERIAL_REGION_ACK_TYPE,
|
|
95
|
+
regionId: ack.regionId,
|
|
96
|
+
role: 'sidebar',
|
|
97
|
+
side: 'leading',
|
|
98
|
+
active: true,
|
|
99
|
+
width: ack.width,
|
|
100
|
+
};
|
|
101
|
+
const root = document.documentElement;
|
|
102
|
+
root.dataset.moldableMaterialRegionSidebar = 'active';
|
|
103
|
+
root.dataset.moldableMaterialRegionSidebarId = normalizedAck.regionId;
|
|
104
|
+
root.style.setProperty(MOLDABLE_SIDEBAR_REGION_WIDTH_PROPERTY, `${normalizedAck.width}px`);
|
|
105
|
+
if (sidebarMaterialPreviousBodyBackgroundColor === null) {
|
|
106
|
+
sidebarMaterialPreviousBodyBackgroundColor =
|
|
107
|
+
document.body.style.backgroundColor;
|
|
108
|
+
}
|
|
109
|
+
document.body.style.backgroundColor = 'transparent';
|
|
110
|
+
window.dispatchEvent(new CustomEvent(MOLDABLE_MATERIAL_REGION_CHANGE_EVENT, {
|
|
111
|
+
detail: normalizedAck,
|
|
112
|
+
}));
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
2
115
|
export function applyMoldableChatSafePadding(safePadding) {
|
|
3
116
|
if (typeof document === 'undefined')
|
|
4
117
|
return false;
|
|
@@ -25,14 +138,24 @@ function applyMoldableChatState(message) {
|
|
|
25
138
|
: 'docked';
|
|
26
139
|
document.documentElement.dataset.moldableChat = presentation;
|
|
27
140
|
}
|
|
28
|
-
function applyMoldableHostContext(message) {
|
|
141
|
+
export function applyMoldableHostContext(message) {
|
|
29
142
|
const root = document.documentElement;
|
|
143
|
+
advertisedHostServices = normalizeHostServices(message.hostServices);
|
|
30
144
|
root.dataset.moldableDisplayMode = message.displayMode;
|
|
31
145
|
root.dataset.moldableWindowTitlebar = message.titlebar ?? 'host';
|
|
32
146
|
if (message.platform)
|
|
33
147
|
root.dataset.moldablePlatform = message.platform;
|
|
34
148
|
if (message.windowId)
|
|
35
149
|
root.dataset.moldableWindowId = message.windowId;
|
|
150
|
+
const sidebarMaterialAvailable = message.displayMode === 'window' &&
|
|
151
|
+
message.nativeMaterial?.regions?.sidebar === true;
|
|
152
|
+
if (sidebarMaterialAvailable) {
|
|
153
|
+
root.dataset.moldableNativeMaterialSidebar = 'available';
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
delete root.dataset.moldableNativeMaterialSidebar;
|
|
157
|
+
clearSidebarMaterialRegion();
|
|
158
|
+
}
|
|
36
159
|
const insets = message.safeInsets;
|
|
37
160
|
if (insets) {
|
|
38
161
|
applyBoundedLength('--window-safe-area-top', insets.top);
|
|
@@ -81,6 +204,9 @@ function installHostStateLifecycle() {
|
|
|
81
204
|
applyMoldableHostContext(message);
|
|
82
205
|
}
|
|
83
206
|
}
|
|
207
|
+
else if (event.data.type === MOLDABLE_MATERIAL_REGION_ACK_TYPE) {
|
|
208
|
+
applyMoldableMaterialRegionAck(event.data);
|
|
209
|
+
}
|
|
84
210
|
});
|
|
85
211
|
}
|
|
86
212
|
function postMoldableFrameMessage(message) {
|
|
@@ -88,6 +214,41 @@ function postMoldableFrameMessage(message) {
|
|
|
88
214
|
return;
|
|
89
215
|
window.parent.postMessage(message, '*');
|
|
90
216
|
}
|
|
217
|
+
function isEditableKeyTarget(target) {
|
|
218
|
+
if (!(target instanceof Element))
|
|
219
|
+
return false;
|
|
220
|
+
if (target.closest('input, textarea, select'))
|
|
221
|
+
return true;
|
|
222
|
+
if (target instanceof HTMLElement && target.isContentEditable)
|
|
223
|
+
return true;
|
|
224
|
+
const contentEditable = target.closest('[contenteditable]');
|
|
225
|
+
const contentEditableValue = contentEditable
|
|
226
|
+
?.getAttribute('contenteditable')
|
|
227
|
+
?.toLowerCase();
|
|
228
|
+
return (contentEditableValue === '' ||
|
|
229
|
+
contentEditableValue === 'true' ||
|
|
230
|
+
contentEditableValue === 'plaintext-only');
|
|
231
|
+
}
|
|
232
|
+
export function installMoldableNavigationChordLifecycle() {
|
|
233
|
+
const handleKeyDown = (event) => {
|
|
234
|
+
if (event.defaultPrevented || isEditableKeyTarget(event.target))
|
|
235
|
+
return;
|
|
236
|
+
const match = MOLDABLE_NAVIGATION_CHORD_ALLOWLIST.find((candidate) => event.code === candidate.code &&
|
|
237
|
+
event.metaKey === candidate.metaKey &&
|
|
238
|
+
event.altKey === candidate.altKey &&
|
|
239
|
+
event.ctrlKey === candidate.ctrlKey &&
|
|
240
|
+
event.shiftKey === candidate.shiftKey);
|
|
241
|
+
if (!match)
|
|
242
|
+
return;
|
|
243
|
+
event.preventDefault();
|
|
244
|
+
postMoldableFrameMessage({
|
|
245
|
+
type: 'moldable:navigation-chord',
|
|
246
|
+
chord: match.chord,
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
250
|
+
return () => document.removeEventListener('keydown', handleKeyDown, true);
|
|
251
|
+
}
|
|
91
252
|
function reportAppReady(reason) {
|
|
92
253
|
postMoldableFrameMessage({ type: 'moldable:app-ready', reason });
|
|
93
254
|
}
|
|
@@ -122,6 +283,7 @@ export function installMoldableFrameLifecycle() {
|
|
|
122
283
|
return;
|
|
123
284
|
frameLifecycleInstalled = true;
|
|
124
285
|
installHostStateLifecycle();
|
|
286
|
+
installMoldableNavigationChordLifecycle();
|
|
125
287
|
installViteHmrLifecycle();
|
|
126
288
|
scheduleRenderReady();
|
|
127
289
|
if (document.readyState === 'complete') {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type HostServiceRequestOptions } from './host-services.js';
|
|
2
|
+
export type HostDateTimePickerMode = 'date' | 'time' | 'datetime';
|
|
3
|
+
export interface HostDateTimePickerAnchorRect {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface HostDateTimePickerOptions extends HostServiceRequestOptions {
|
|
10
|
+
value?: string;
|
|
11
|
+
min?: string;
|
|
12
|
+
max?: string;
|
|
13
|
+
anchor?: Element | HostDateTimePickerAnchorRect;
|
|
14
|
+
}
|
|
15
|
+
export type HostDateTimePickerResult = {
|
|
16
|
+
status: 'completed';
|
|
17
|
+
method: 'native';
|
|
18
|
+
value: string;
|
|
19
|
+
} | {
|
|
20
|
+
status: 'cancelled';
|
|
21
|
+
method: 'native';
|
|
22
|
+
} | {
|
|
23
|
+
status: 'fallback';
|
|
24
|
+
method: 'portable';
|
|
25
|
+
mode: HostDateTimePickerMode;
|
|
26
|
+
value?: string;
|
|
27
|
+
min?: string;
|
|
28
|
+
max?: string;
|
|
29
|
+
};
|
|
30
|
+
export interface HostDateTimePicker {
|
|
31
|
+
available: boolean;
|
|
32
|
+
pick: (mode: HostDateTimePickerMode, options?: HostDateTimePickerOptions) => Promise<HostDateTimePickerResult>;
|
|
33
|
+
}
|
|
34
|
+
export declare function pickDateTimeWithHost(mode: HostDateTimePickerMode, options?: HostDateTimePickerOptions): Promise<HostDateTimePickerResult>;
|
|
35
|
+
export declare function useHostDateTimePicker(): HostDateTimePicker;
|
|
36
|
+
//# sourceMappingURL=host-date-time-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-date-time-picker.d.ts","sourceRoot":"","sources":["../../src/lib/host-date-time-picker.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,yBAAyB,EAG/B,MAAM,iBAAiB,CAAA;AAMxB,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAA;AAEjE,MAAM,WAAW,4BAA4B;IAC3C,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,GAAG,4BAA4B,CAAA;CAChD;AAED,MAAM,MAAM,wBAAwB,GAChC;IACE,MAAM,EAAE,WAAW,CAAA;IACnB,MAAM,EAAE,QAAQ,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd,GACD;IACE,MAAM,EAAE,WAAW,CAAA;IACnB,MAAM,EAAE,QAAQ,CAAA;CACjB,GACD;IACE,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,sBAAsB,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAEL,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,CACJ,IAAI,EAAE,sBAAsB,EAC5B,OAAO,CAAC,EAAE,yBAAyB,KAChC,OAAO,CAAC,wBAAwB,CAAC,CAAA;CACvC;AAgJD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,sBAAsB,EAC5B,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CAgDnC;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,CAoB1D"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { HostServiceRequestError, isHostServiceAvailable, requestHostService, } from './host-services.js';
|
|
3
|
+
const HOST_CONTEXT_CHANGE_EVENT = 'moldable:host-context-change';
|
|
4
|
+
const DATE_TIME_PICKER_SERVICE_NAME = 'dateTimePicker';
|
|
5
|
+
const MAX_ISO_VALUE_LENGTH = 128;
|
|
6
|
+
function validateMode(mode) {
|
|
7
|
+
if (mode !== 'date' && mode !== 'time' && mode !== 'datetime') {
|
|
8
|
+
throw new TypeError('Date/time picker mode must be date, time, or datetime.');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function isoValueNumber(mode, value) {
|
|
12
|
+
if (typeof value !== 'string' ||
|
|
13
|
+
value.length === 0 ||
|
|
14
|
+
value.length > MAX_ISO_VALUE_LENGTH) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const [datePart, timePart, extraPart] = mode === 'time' ? [undefined, value, undefined] : value.split('T');
|
|
18
|
+
if (extraPart !== undefined)
|
|
19
|
+
return null;
|
|
20
|
+
let date;
|
|
21
|
+
if (mode !== 'time') {
|
|
22
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(datePart ?? '');
|
|
23
|
+
if (!match)
|
|
24
|
+
return null;
|
|
25
|
+
const year = Number(match[1]);
|
|
26
|
+
const month = Number(match[2]);
|
|
27
|
+
const day = Number(match[3]);
|
|
28
|
+
date = new Date(0);
|
|
29
|
+
date.setHours(0, 0, 0, 0);
|
|
30
|
+
date.setFullYear(year, month - 1, day);
|
|
31
|
+
if (date.getFullYear() !== year ||
|
|
32
|
+
date.getMonth() !== month - 1 ||
|
|
33
|
+
date.getDate() !== day) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (mode === 'date')
|
|
37
|
+
return date.getTime();
|
|
38
|
+
}
|
|
39
|
+
const match = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/.exec(timePart ?? '');
|
|
40
|
+
if (!match)
|
|
41
|
+
return null;
|
|
42
|
+
const hour = Number(match[1]);
|
|
43
|
+
const minute = Number(match[2]);
|
|
44
|
+
const second = Number(match[3] ?? 0);
|
|
45
|
+
const millisecond = Math.floor(Number(`0.${match[4] ?? 0}`) * 1000);
|
|
46
|
+
if (hour > 23 || minute > 59 || second > 59)
|
|
47
|
+
return null;
|
|
48
|
+
if (mode === 'time') {
|
|
49
|
+
return ((hour * 60 + minute) * 60 + second) * 1000 + millisecond;
|
|
50
|
+
}
|
|
51
|
+
if (!date)
|
|
52
|
+
return null;
|
|
53
|
+
date.setHours(hour, minute, second, millisecond);
|
|
54
|
+
return date.getHours() === hour &&
|
|
55
|
+
date.getMinutes() === minute &&
|
|
56
|
+
date.getSeconds() === second
|
|
57
|
+
? date.getTime()
|
|
58
|
+
: null;
|
|
59
|
+
}
|
|
60
|
+
function validateIsoValue(mode, name, value) {
|
|
61
|
+
if (value !== undefined && isoValueNumber(mode, value) === null) {
|
|
62
|
+
throw new TypeError(`${name} must be a valid ISO ${mode} value.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function validateRange(mode, options) {
|
|
66
|
+
validateIsoValue(mode, 'value', options.value);
|
|
67
|
+
validateIsoValue(mode, 'min', options.min);
|
|
68
|
+
validateIsoValue(mode, 'max', options.max);
|
|
69
|
+
if (options.min !== undefined &&
|
|
70
|
+
options.max !== undefined &&
|
|
71
|
+
isoValueNumber(mode, options.min) >
|
|
72
|
+
isoValueNumber(mode, options.max)) {
|
|
73
|
+
throw new TypeError('Date/time picker min must not be after max.');
|
|
74
|
+
}
|
|
75
|
+
if (options.value !== undefined) {
|
|
76
|
+
const value = isoValueNumber(mode, options.value);
|
|
77
|
+
if ((options.min !== undefined &&
|
|
78
|
+
value < isoValueNumber(mode, options.min)) ||
|
|
79
|
+
(options.max !== undefined &&
|
|
80
|
+
value > isoValueNumber(mode, options.max))) {
|
|
81
|
+
throw new TypeError('Date/time picker value must be inside the min/max range.');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function anchorRect(anchor) {
|
|
86
|
+
if (!anchor)
|
|
87
|
+
return undefined;
|
|
88
|
+
const rect = typeof Element !== 'undefined' && anchor instanceof Element
|
|
89
|
+
? anchor.getBoundingClientRect()
|
|
90
|
+
: anchor;
|
|
91
|
+
if (!Number.isFinite(rect.x) ||
|
|
92
|
+
!Number.isFinite(rect.y) ||
|
|
93
|
+
!Number.isFinite(rect.width) ||
|
|
94
|
+
!Number.isFinite(rect.height) ||
|
|
95
|
+
rect.width < 0 ||
|
|
96
|
+
rect.height < 0) {
|
|
97
|
+
throw new TypeError('Date/time picker anchors require a finite, non-negative rect.');
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
x: rect.x,
|
|
101
|
+
y: rect.y,
|
|
102
|
+
width: rect.width,
|
|
103
|
+
height: rect.height,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function abortError() {
|
|
107
|
+
return new DOMException('The date/time picker request was aborted.', 'AbortError');
|
|
108
|
+
}
|
|
109
|
+
export async function pickDateTimeWithHost(mode, options = {}) {
|
|
110
|
+
validateMode(mode);
|
|
111
|
+
validateRange(mode, options);
|
|
112
|
+
if (options.signal?.aborted)
|
|
113
|
+
throw abortError();
|
|
114
|
+
if (!isHostServiceAvailable(DATE_TIME_PICKER_SERVICE_NAME)) {
|
|
115
|
+
return {
|
|
116
|
+
status: 'fallback',
|
|
117
|
+
method: 'portable',
|
|
118
|
+
mode,
|
|
119
|
+
...(options.value === undefined ? {} : { value: options.value }),
|
|
120
|
+
...(options.min === undefined ? {} : { min: options.min }),
|
|
121
|
+
...(options.max === undefined ? {} : { max: options.max }),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const result = await requestHostService(DATE_TIME_PICKER_SERVICE_NAME, {
|
|
126
|
+
mode,
|
|
127
|
+
...(options.value === undefined ? {} : { value: options.value }),
|
|
128
|
+
...(options.min === undefined ? {} : { min: options.min }),
|
|
129
|
+
...(options.max === undefined ? {} : { max: options.max }),
|
|
130
|
+
...(options.anchor ? { anchor: anchorRect(options.anchor) } : {}),
|
|
131
|
+
}, {
|
|
132
|
+
signal: options.signal,
|
|
133
|
+
timeoutMs: options.timeoutMs,
|
|
134
|
+
});
|
|
135
|
+
if (typeof result !== 'string' || isoValueNumber(mode, result) === null) {
|
|
136
|
+
throw new Error('The native date/time picker returned an invalid result.');
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
status: 'completed',
|
|
140
|
+
method: 'native',
|
|
141
|
+
value: result,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
if (error instanceof HostServiceRequestError &&
|
|
146
|
+
error.status === 'cancelled') {
|
|
147
|
+
return { status: 'cancelled', method: 'native' };
|
|
148
|
+
}
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export function useHostDateTimePicker() {
|
|
153
|
+
const [available, setAvailable] = useState(() => isHostServiceAvailable(DATE_TIME_PICKER_SERVICE_NAME));
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
const update = () => setAvailable(isHostServiceAvailable(DATE_TIME_PICKER_SERVICE_NAME));
|
|
156
|
+
update();
|
|
157
|
+
window.addEventListener(HOST_CONTEXT_CHANGE_EVENT, update);
|
|
158
|
+
return () => window.removeEventListener(HOST_CONTEXT_CHANGE_EVENT, update);
|
|
159
|
+
}, []);
|
|
160
|
+
const pick = useCallback((mode, options) => pickDateTimeWithHost(mode, options), []);
|
|
161
|
+
return { available, pick };
|
|
162
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type HostServiceRequestOptions } from './host-services.js';
|
|
2
|
+
export type HostFileDialogDefaultLocation = 'documents' | 'downloads' | 'desktop' | 'home' | 'appData';
|
|
3
|
+
export interface HostFileDialogFilter {
|
|
4
|
+
name: string;
|
|
5
|
+
extensions: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface HostOpenFileDialogProperties {
|
|
8
|
+
/**
|
|
9
|
+
* Allow more than one selection. Defaults to false.
|
|
10
|
+
*/
|
|
11
|
+
multiple?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Choose directories instead of files. Defaults to false.
|
|
14
|
+
*/
|
|
15
|
+
directories?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Show the New Folder control. Defaults to false.
|
|
18
|
+
*/
|
|
19
|
+
createDirectories?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Initially reveal hidden entries. Defaults to false.
|
|
22
|
+
*/
|
|
23
|
+
showHidden?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface HostFileDialogCommonOptions extends HostServiceRequestOptions {
|
|
26
|
+
title?: string;
|
|
27
|
+
buttonLabel?: string;
|
|
28
|
+
filters?: HostFileDialogFilter[];
|
|
29
|
+
defaultLocation?: HostFileDialogDefaultLocation;
|
|
30
|
+
}
|
|
31
|
+
export interface HostOpenFileDialogOptions extends HostFileDialogCommonOptions {
|
|
32
|
+
properties?: HostOpenFileDialogProperties;
|
|
33
|
+
}
|
|
34
|
+
export interface HostSaveFileDialogOptions extends HostFileDialogCommonOptions {
|
|
35
|
+
defaultName?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Show the New Folder control. Defaults to false.
|
|
38
|
+
*/
|
|
39
|
+
createDirectories?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type HostOpenFileDialogResult = {
|
|
42
|
+
status: 'completed';
|
|
43
|
+
paths: string[];
|
|
44
|
+
} | {
|
|
45
|
+
status: 'cancelled';
|
|
46
|
+
} | {
|
|
47
|
+
status: 'fallback';
|
|
48
|
+
};
|
|
49
|
+
export type HostSaveFileDialogResult = {
|
|
50
|
+
status: 'completed';
|
|
51
|
+
path: string;
|
|
52
|
+
} | {
|
|
53
|
+
status: 'cancelled';
|
|
54
|
+
} | {
|
|
55
|
+
status: 'fallback';
|
|
56
|
+
};
|
|
57
|
+
export interface HostFileDialog {
|
|
58
|
+
available: boolean;
|
|
59
|
+
open: (options?: HostOpenFileDialogOptions) => Promise<HostOpenFileDialogResult>;
|
|
60
|
+
save: (options?: HostSaveFileDialogOptions) => Promise<HostSaveFileDialogResult>;
|
|
61
|
+
}
|
|
62
|
+
export declare function openFileDialogWithHost(options?: HostOpenFileDialogOptions): Promise<HostOpenFileDialogResult>;
|
|
63
|
+
export declare function saveFileDialogWithHost(options?: HostSaveFileDialogOptions): Promise<HostSaveFileDialogResult>;
|
|
64
|
+
export declare function useHostFileDialog(): HostFileDialog;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=host-file-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-file-dialog.d.ts","sourceRoot":"","sources":["../../src/lib/host-file-dialog.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,yBAAyB,EAG/B,MAAM,iBAAiB,CAAA;AAWxB,MAAM,MAAM,6BAA6B,GACrC,WAAW,GACX,WAAW,GACX,SAAS,GACT,MAAM,GACN,SAAS,CAAA;AAEb,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,UAAU,2BAA4B,SAAQ,yBAAyB;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAA;IAChC,eAAe,CAAC,EAAE,6BAA6B,CAAA;CAChD;AAED,MAAM,WAAW,yBAA0B,SAAQ,2BAA2B;IAC5E,UAAU,CAAC,EAAE,4BAA4B,CAAA;CAC1C;AAED,MAAM,WAAW,yBAA0B,SAAQ,2BAA2B;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,MAAM,wBAAwB,GAChC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAAA;AAE1B,MAAM,MAAM,wBAAwB,GAChC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAAA;AAE1B,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,CACJ,OAAO,CAAC,EAAE,yBAAyB,KAChC,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACtC,IAAI,EAAE,CACJ,OAAO,CAAC,EAAE,yBAAyB,KAChC,OAAO,CAAC,wBAAwB,CAAC,CAAA;CACvC;AAmLD,wBAAsB,sBAAsB,CAC1C,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA4CnC;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA0CnC;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAuBlD"}
|