@moldable-ai/ui 0.2.19 → 0.2.20
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-manifest.d.ts +6 -0
- package/dist/catalog/catalog-manifest.d.ts.map +1 -0
- package/dist/catalog/catalog-manifest.js +105 -0
- package/dist/catalog/catalog-types.d.ts +54 -0
- package/dist/catalog/catalog-types.d.ts.map +1 -0
- package/dist/catalog/catalog-types.js +14 -0
- package/dist/catalog/component-catalog.d.ts +14 -0
- package/dist/catalog/component-catalog.d.ts.map +1 -0
- package/dist/catalog/component-catalog.js +39 -0
- package/dist/catalog/core-catalog.d.ts +6 -0
- package/dist/catalog/core-catalog.d.ts.map +1 -0
- package/dist/catalog/core-catalog.js +105 -0
- package/dist/catalog/index.d.ts +5 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +4 -0
- package/dist/components/app-error-boundary.d.ts +1 -0
- package/dist/components/app-error-boundary.d.ts.map +1 -1
- package/dist/components/app-error-boundary.js +13 -0
- package/dist/components/chat/chat-image-lightbox.d.ts +9 -0
- package/dist/components/chat/chat-image-lightbox.d.ts.map +1 -0
- package/dist/components/chat/chat-image-lightbox.js +9 -0
- package/dist/components/chat/chat-message.d.ts +19 -1
- package/dist/components/chat/chat-message.d.ts.map +1 -1
- package/dist/components/chat/chat-message.js +66 -16
- package/dist/components/chat/chat-messages.d.ts +5 -2
- package/dist/components/chat/chat-messages.d.ts.map +1 -1
- package/dist/components/chat/chat-messages.js +61 -6
- package/dist/components/chat/chat-panel.d.ts +50 -6
- package/dist/components/chat/chat-panel.d.ts.map +1 -1
- package/dist/components/chat/chat-panel.js +200 -163
- package/dist/components/chat/conversation-history.d.ts +39 -5
- package/dist/components/chat/conversation-history.d.ts.map +1 -1
- package/dist/components/chat/conversation-history.js +192 -26
- package/dist/components/chat/index.d.ts +2 -2
- package/dist/components/chat/index.d.ts.map +1 -1
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/tool-handlers.d.ts.map +1 -1
- package/dist/components/chat/tool-handlers.js +40 -2
- package/dist/components/chat/vertical-scroll-fade.d.ts +6 -0
- package/dist/components/chat/vertical-scroll-fade.d.ts.map +1 -0
- package/dist/components/chat/vertical-scroll-fade.js +12 -0
- package/dist/components/native-capabilities/bluetooth-panel-helpers.d.ts +9 -0
- package/dist/components/native-capabilities/bluetooth-panel-helpers.d.ts.map +1 -0
- package/dist/components/native-capabilities/bluetooth-panel-helpers.js +37 -0
- package/dist/components/native-capabilities/bluetooth-panel.d.ts +56 -0
- package/dist/components/native-capabilities/bluetooth-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/bluetooth-panel.js +470 -0
- package/dist/components/native-capabilities/camera-preview.d.ts +39 -0
- package/dist/components/native-capabilities/camera-preview.d.ts.map +1 -0
- package/dist/components/native-capabilities/camera-preview.js +228 -0
- package/dist/components/native-capabilities/capability-badge.d.ts +23 -0
- package/dist/components/native-capabilities/capability-badge.d.ts.map +1 -0
- package/dist/components/native-capabilities/capability-badge.js +39 -0
- package/dist/components/native-capabilities/capability-matrix.d.ts +14 -0
- package/dist/components/native-capabilities/capability-matrix.d.ts.map +1 -0
- package/dist/components/native-capabilities/capability-matrix.js +97 -0
- package/dist/components/native-capabilities/clipboard-button.d.ts +26 -0
- package/dist/components/native-capabilities/clipboard-button.d.ts.map +1 -0
- package/dist/components/native-capabilities/clipboard-button.js +99 -0
- package/dist/components/native-capabilities/device-io-controls.d.ts +4 -0
- package/dist/components/native-capabilities/device-io-controls.d.ts.map +1 -0
- package/dist/components/native-capabilities/device-io-controls.js +28 -0
- package/dist/components/native-capabilities/device-list.d.ts +20 -0
- package/dist/components/native-capabilities/device-list.d.ts.map +1 -0
- package/dist/components/native-capabilities/device-list.js +14 -0
- package/dist/components/native-capabilities/display-map.d.ts +23 -0
- package/dist/components/native-capabilities/display-map.d.ts.map +1 -0
- package/dist/components/native-capabilities/display-map.js +114 -0
- package/dist/components/native-capabilities/haptic-button.d.ts +26 -0
- package/dist/components/native-capabilities/haptic-button.d.ts.map +1 -0
- package/dist/components/native-capabilities/haptic-button.js +94 -0
- package/dist/components/native-capabilities/hid-panel.d.ts +40 -0
- package/dist/components/native-capabilities/hid-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/hid-panel.js +373 -0
- package/dist/components/native-capabilities/index.d.ts +27 -0
- package/dist/components/native-capabilities/index.d.ts.map +1 -0
- package/dist/components/native-capabilities/index.js +26 -0
- package/dist/components/native-capabilities/live-indicator.d.ts +15 -0
- package/dist/components/native-capabilities/live-indicator.d.ts.map +1 -0
- package/dist/components/native-capabilities/live-indicator.js +26 -0
- package/dist/components/native-capabilities/local-auth-button.d.ts +33 -0
- package/dist/components/native-capabilities/local-auth-button.d.ts.map +1 -0
- package/dist/components/native-capabilities/local-auth-button.js +115 -0
- package/dist/components/native-capabilities/location-panel.d.ts +29 -0
- package/dist/components/native-capabilities/location-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/location-panel.js +146 -0
- package/dist/components/native-capabilities/microphone-meter.d.ts +35 -0
- package/dist/components/native-capabilities/microphone-meter.d.ts.map +1 -0
- package/dist/components/native-capabilities/microphone-meter.js +244 -0
- package/dist/components/native-capabilities/midi-monitor.d.ts +54 -0
- package/dist/components/native-capabilities/midi-monitor.d.ts.map +1 -0
- package/dist/components/native-capabilities/midi-monitor.js +534 -0
- package/dist/components/native-capabilities/native-capability-panel.d.ts +11 -0
- package/dist/components/native-capabilities/native-capability-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/native-capability-panel.js +28 -0
- package/dist/components/native-capabilities/notification-panel.d.ts +24 -0
- package/dist/components/native-capabilities/notification-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/notification-panel.js +124 -0
- package/dist/components/native-capabilities/power-blocker-controller.d.ts +19 -0
- package/dist/components/native-capabilities/power-blocker-controller.d.ts.map +1 -0
- package/dist/components/native-capabilities/power-blocker-controller.js +83 -0
- package/dist/components/native-capabilities/power-panel.d.ts +67 -0
- package/dist/components/native-capabilities/power-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/power-panel.js +309 -0
- package/dist/components/native-capabilities/readout.d.ts +10 -0
- package/dist/components/native-capabilities/readout.d.ts.map +1 -0
- package/dist/components/native-capabilities/readout.js +11 -0
- package/dist/components/native-capabilities/screen-share-preview.d.ts +36 -0
- package/dist/components/native-capabilities/screen-share-preview.d.ts.map +1 -0
- package/dist/components/native-capabilities/screen-share-preview.js +191 -0
- package/dist/components/native-capabilities/secure-storage-panel.d.ts +36 -0
- package/dist/components/native-capabilities/secure-storage-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/secure-storage-panel.js +193 -0
- package/dist/components/native-capabilities/serial-console.d.ts +64 -0
- package/dist/components/native-capabilities/serial-console.d.ts.map +1 -0
- package/dist/components/native-capabilities/serial-console.js +399 -0
- package/dist/components/native-capabilities/shortcut-recorder.d.ts +35 -0
- package/dist/components/native-capabilities/shortcut-recorder.d.ts.map +1 -0
- package/dist/components/native-capabilities/shortcut-recorder.js +217 -0
- package/dist/components/native-capabilities/stream-log.d.ts +35 -0
- package/dist/components/native-capabilities/stream-log.d.ts.map +1 -0
- package/dist/components/native-capabilities/stream-log.js +65 -0
- package/dist/components/native-capabilities/system-audio-monitor.d.ts +34 -0
- package/dist/components/native-capabilities/system-audio-monitor.d.ts.map +1 -0
- package/dist/components/native-capabilities/system-audio-monitor.js +275 -0
- package/dist/components/native-capabilities/usb-panel.d.ts +54 -0
- package/dist/components/native-capabilities/usb-panel.d.ts.map +1 -0
- package/dist/components/native-capabilities/usb-panel.js +363 -0
- package/dist/components/native-capabilities/use-capability.d.ts +20 -0
- package/dist/components/native-capabilities/use-capability.d.ts.map +1 -0
- package/dist/components/native-capabilities/use-capability.js +61 -0
- package/dist/components/ui/app-frame.d.ts +22 -0
- package/dist/components/ui/app-frame.d.ts.map +1 -0
- package/dist/components/ui/app-frame.js +56 -0
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/color-well.d.ts +13 -0
- package/dist/components/ui/color-well.d.ts.map +1 -0
- package/dist/components/ui/color-well.js +30 -0
- package/dist/components/ui/date-field.d.ts +19 -0
- package/dist/components/ui/date-field.d.ts.map +1 -0
- package/dist/components/ui/date-field.js +54 -0
- package/dist/components/ui/edge-fade.d.ts +11 -0
- package/dist/components/ui/edge-fade.d.ts.map +1 -0
- package/dist/components/ui/edge-fade.js +41 -0
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/grid.d.ts +24 -0
- package/dist/components/ui/grid.d.ts.map +1 -0
- package/dist/components/ui/grid.js +234 -0
- package/dist/components/ui/icon-button.d.ts +15 -0
- package/dist/components/ui/icon-button.d.ts.map +1 -0
- package/dist/components/ui/icon-button.js +15 -0
- package/dist/components/ui/index.d.ts +19 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +19 -0
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/inspector.d.ts +15 -0
- package/dist/components/ui/inspector.d.ts.map +1 -0
- package/dist/components/ui/inspector.js +26 -0
- package/dist/components/ui/kbd.d.ts +1 -1
- package/dist/components/ui/list.d.ts +24 -0
- package/dist/components/ui/list.d.ts.map +1 -0
- package/dist/components/ui/list.js +224 -0
- package/dist/components/ui/message-scroller-layout-stability.d.ts +33 -0
- package/dist/components/ui/message-scroller-layout-stability.d.ts.map +1 -0
- package/dist/components/ui/message-scroller-layout-stability.js +153 -0
- package/dist/components/ui/message-scroller.d.ts +11 -0
- package/dist/components/ui/message-scroller.d.ts.map +1 -0
- package/dist/components/ui/message-scroller.js +37 -0
- package/dist/components/ui/notification-dot.d.ts +4 -0
- package/dist/components/ui/notification-dot.d.ts.map +1 -0
- package/dist/components/ui/notification-dot.js +7 -0
- package/dist/components/ui/number-input.d.ts +16 -0
- package/dist/components/ui/number-input.d.ts.map +1 -0
- package/dist/components/ui/number-input.js +56 -0
- package/dist/components/ui/panel.d.ts +18 -0
- package/dist/components/ui/panel.d.ts.map +1 -0
- package/dist/components/ui/panel.js +40 -0
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/search-field.d.ts +19 -0
- package/dist/components/ui/search-field.d.ts.map +1 -0
- package/dist/components/ui/search-field.js +64 -0
- package/dist/components/ui/segmented-control.d.ts +21 -0
- package/dist/components/ui/segmented-control.d.ts.map +1 -0
- package/dist/components/ui/segmented-control.js +61 -0
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sonner.d.ts +4 -3
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/sonner.js +7 -6
- package/dist/components/ui/split-view.d.ts +11 -0
- package/dist/components/ui/split-view.d.ts.map +1 -0
- package/dist/components/ui/split-view.js +13 -0
- package/dist/components/ui/status.d.ts +13 -0
- package/dist/components/ui/status.d.ts.map +1 -0
- package/dist/components/ui/status.js +36 -0
- package/dist/components/ui/table.d.ts +11 -2
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +28 -6
- package/dist/components/ui/text.d.ts +17 -0
- package/dist/components/ui/text.d.ts.map +1 -0
- package/dist/components/ui/text.js +55 -0
- package/dist/components/ui/toggle.js +1 -1
- package/dist/components/ui/toolbar.d.ts +20 -0
- package/dist/components/ui/toolbar.d.ts.map +1 -0
- package/dist/components/ui/toolbar.js +52 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/lib/frame-lifecycle.d.ts +28 -0
- package/dist/lib/frame-lifecycle.d.ts.map +1 -1
- package/dist/lib/frame-lifecycle.js +84 -0
- package/dist/lib/native-capabilities/access.d.ts +13 -0
- package/dist/lib/native-capabilities/access.d.ts.map +1 -0
- package/dist/lib/native-capabilities/access.js +53 -0
- package/dist/lib/native-capabilities/bluetooth-access.d.ts +14 -0
- package/dist/lib/native-capabilities/bluetooth-access.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-access.js +43 -0
- package/dist/lib/native-capabilities/bluetooth-connection.d.ts +19 -0
- package/dist/lib/native-capabilities/bluetooth-connection.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-connection.js +88 -0
- package/dist/lib/native-capabilities/bluetooth-gatt.d.ts +7 -0
- package/dist/lib/native-capabilities/bluetooth-gatt.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-gatt.js +77 -0
- package/dist/lib/native-capabilities/bluetooth-internal.d.ts +10 -0
- package/dist/lib/native-capabilities/bluetooth-internal.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-internal.js +105 -0
- package/dist/lib/native-capabilities/bluetooth-native-fallback.d.ts +33 -0
- package/dist/lib/native-capabilities/bluetooth-native-fallback.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-native-fallback.js +214 -0
- package/dist/lib/native-capabilities/bluetooth-types.d.ts +85 -0
- package/dist/lib/native-capabilities/bluetooth-types.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth-types.js +2 -0
- package/dist/lib/native-capabilities/bluetooth.d.ts +7 -0
- package/dist/lib/native-capabilities/bluetooth.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bluetooth.js +4 -0
- package/dist/lib/native-capabilities/bridge.d.ts +23 -0
- package/dist/lib/native-capabilities/bridge.d.ts.map +1 -0
- package/dist/lib/native-capabilities/bridge.js +266 -0
- package/dist/lib/native-capabilities/capabilities.d.ts +7 -0
- package/dist/lib/native-capabilities/capabilities.d.ts.map +1 -0
- package/dist/lib/native-capabilities/capabilities.js +95 -0
- package/dist/lib/native-capabilities/clipboard.d.ts +11 -0
- package/dist/lib/native-capabilities/clipboard.d.ts.map +1 -0
- package/dist/lib/native-capabilities/clipboard.js +58 -0
- package/dist/lib/native-capabilities/device-io-errors.d.ts +11 -0
- package/dist/lib/native-capabilities/device-io-errors.d.ts.map +1 -0
- package/dist/lib/native-capabilities/device-io-errors.js +82 -0
- package/dist/lib/native-capabilities/displays.d.ts +38 -0
- package/dist/lib/native-capabilities/displays.d.ts.map +1 -0
- package/dist/lib/native-capabilities/displays.js +12 -0
- package/dist/lib/native-capabilities/global-shortcuts.d.ts +86 -0
- package/dist/lib/native-capabilities/global-shortcuts.d.ts.map +1 -0
- package/dist/lib/native-capabilities/global-shortcuts.js +351 -0
- package/dist/lib/native-capabilities/haptics.d.ts +25 -0
- package/dist/lib/native-capabilities/haptics.d.ts.map +1 -0
- package/dist/lib/native-capabilities/haptics.js +18 -0
- package/dist/lib/native-capabilities/hid-native.d.ts +26 -0
- package/dist/lib/native-capabilities/hid-native.d.ts.map +1 -0
- package/dist/lib/native-capabilities/hid-native.js +229 -0
- package/dist/lib/native-capabilities/hid.d.ts +52 -0
- package/dist/lib/native-capabilities/hid.d.ts.map +1 -0
- package/dist/lib/native-capabilities/hid.js +163 -0
- package/dist/lib/native-capabilities/index.d.ts +40 -0
- package/dist/lib/native-capabilities/index.d.ts.map +1 -0
- package/dist/lib/native-capabilities/index.js +21 -0
- package/dist/lib/native-capabilities/local-authentication.d.ts +32 -0
- package/dist/lib/native-capabilities/local-authentication.d.ts.map +1 -0
- package/dist/lib/native-capabilities/local-authentication.js +46 -0
- package/dist/lib/native-capabilities/location.d.ts +49 -0
- package/dist/lib/native-capabilities/location.d.ts.map +1 -0
- package/dist/lib/native-capabilities/location.js +114 -0
- package/dist/lib/native-capabilities/media-permissions.d.ts +28 -0
- package/dist/lib/native-capabilities/media-permissions.d.ts.map +1 -0
- package/dist/lib/native-capabilities/media-permissions.js +37 -0
- package/dist/lib/native-capabilities/media.d.ts +17 -0
- package/dist/lib/native-capabilities/media.d.ts.map +1 -0
- package/dist/lib/native-capabilities/media.js +104 -0
- package/dist/lib/native-capabilities/midi-access.d.ts +13 -0
- package/dist/lib/native-capabilities/midi-access.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-access.js +68 -0
- package/dist/lib/native-capabilities/midi-internal.d.ts +12 -0
- package/dist/lib/native-capabilities/midi-internal.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-internal.js +88 -0
- package/dist/lib/native-capabilities/midi-native-fallback.d.ts +27 -0
- package/dist/lib/native-capabilities/midi-native-fallback.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-native-fallback.js +127 -0
- package/dist/lib/native-capabilities/midi-ports.d.ts +6 -0
- package/dist/lib/native-capabilities/midi-ports.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-ports.js +115 -0
- package/dist/lib/native-capabilities/midi-types.d.ts +25 -0
- package/dist/lib/native-capabilities/midi-types.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi-types.js +1 -0
- package/dist/lib/native-capabilities/midi.d.ts +6 -0
- package/dist/lib/native-capabilities/midi.d.ts.map +1 -0
- package/dist/lib/native-capabilities/midi.js +3 -0
- package/dist/lib/native-capabilities/native-device-io.d.ts +28 -0
- package/dist/lib/native-capabilities/native-device-io.d.ts.map +1 -0
- package/dist/lib/native-capabilities/native-device-io.js +91 -0
- package/dist/lib/native-capabilities/native-device-lifecycle.d.ts +13 -0
- package/dist/lib/native-capabilities/native-device-lifecycle.d.ts.map +1 -0
- package/dist/lib/native-capabilities/native-device-lifecycle.js +40 -0
- package/dist/lib/native-capabilities/notifications.d.ts +38 -0
- package/dist/lib/native-capabilities/notifications.d.ts.map +1 -0
- package/dist/lib/native-capabilities/notifications.js +50 -0
- package/dist/lib/native-capabilities/power-session.d.ts +113 -0
- package/dist/lib/native-capabilities/power-session.d.ts.map +1 -0
- package/dist/lib/native-capabilities/power-session.js +264 -0
- package/dist/lib/native-capabilities/secure-storage.d.ts +36 -0
- package/dist/lib/native-capabilities/secure-storage.d.ts.map +1 -0
- package/dist/lib/native-capabilities/secure-storage.js +64 -0
- package/dist/lib/native-capabilities/serial-native.d.ts +23 -0
- package/dist/lib/native-capabilities/serial-native.d.ts.map +1 -0
- package/dist/lib/native-capabilities/serial-native.js +181 -0
- package/dist/lib/native-capabilities/serial.d.ts +76 -0
- package/dist/lib/native-capabilities/serial.d.ts.map +1 -0
- package/dist/lib/native-capabilities/serial.js +215 -0
- package/dist/lib/native-capabilities/system-audio.d.ts +127 -0
- package/dist/lib/native-capabilities/system-audio.d.ts.map +1 -0
- package/dist/lib/native-capabilities/system-audio.js +330 -0
- package/dist/lib/native-capabilities/types.d.ts +62 -0
- package/dist/lib/native-capabilities/types.d.ts.map +1 -0
- package/dist/lib/native-capabilities/types.js +27 -0
- package/dist/lib/native-capabilities/usb-native.d.ts +39 -0
- package/dist/lib/native-capabilities/usb-native.d.ts.map +1 -0
- package/dist/lib/native-capabilities/usb-native.js +217 -0
- package/dist/lib/native-capabilities/usb.d.ts +85 -0
- package/dist/lib/native-capabilities/usb.d.ts.map +1 -0
- package/dist/lib/native-capabilities/usb.js +225 -0
- package/docs/README.md +37 -0
- package/docs/accessibility.md +32 -0
- package/docs/app-anatomy.md +72 -0
- package/docs/component-catalog.md +59 -0
- package/docs/component-guide-template.md +37 -0
- package/docs/design-tokens.md +172 -0
- package/docs/foundations.md +56 -0
- package/docs/native-integration.md +33 -0
- package/docs/standalone-app-windows.md +128 -0
- package/package.json +9 -3
- package/src/components/ui/alert.md +55 -0
- package/src/components/ui/app-frame.md +33 -0
- package/src/components/ui/badge.md +57 -0
- package/src/components/ui/button.md +76 -0
- package/src/components/ui/color-well.md +11 -0
- package/src/components/ui/combobox.md +43 -0
- package/src/components/ui/date-field.md +32 -0
- package/src/components/ui/edge-fade.md +7 -0
- package/src/components/ui/empty.md +82 -0
- package/src/components/ui/field.md +77 -0
- package/src/components/ui/grid.md +105 -0
- package/src/components/ui/icon-button.md +36 -0
- package/src/components/ui/inspector.md +11 -0
- package/src/components/ui/item.md +87 -0
- package/src/components/ui/list.md +107 -0
- package/src/components/ui/notification-dot.md +7 -0
- package/src/components/ui/number-input.md +19 -0
- package/src/components/ui/panel.md +11 -0
- package/src/components/ui/resizable.md +66 -0
- package/src/components/ui/scroll-area.md +68 -0
- package/src/components/ui/search-field.md +33 -0
- package/src/components/ui/segmented-control.md +39 -0
- package/src/components/ui/sidebar.md +113 -0
- package/src/components/ui/sonner.md +37 -0
- package/src/components/ui/split-view.md +15 -0
- package/src/components/ui/status.md +12 -0
- package/src/components/ui/table.md +35 -0
- package/src/components/ui/tabs.md +66 -0
- package/src/components/ui/text.md +17 -0
- package/src/components/ui/toggle-group.md +80 -0
- package/src/components/ui/toggle.md +73 -0
- package/src/components/ui/toolbar.md +21 -0
- package/src/styles/index.css +491 -3
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { RefreshCw, RotateCcw, Trash2, Usb } from 'lucide-react';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { NativeCapabilityBridgeError, clearMoldableUsbHalt, closeMoldableUsbDevice, forgetMoldableUsbDevice, getMoldableUsbDevices, openMoldableUsbDevice, readMoldableUsbControlTransfer, readMoldableUsbEndpoint, requestMoldableUsbDevice, resetMoldableUsbDevice, writeMoldableUsbControlTransfer, writeMoldableUsbEndpoint, } from '../../lib/native-capabilities';
|
|
6
|
+
import { Button } from '../ui/button';
|
|
7
|
+
import { Input } from '../ui/input';
|
|
8
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/select';
|
|
9
|
+
import { Spinner } from '../ui/spinner';
|
|
10
|
+
import { CapabilityBadge } from './capability-badge';
|
|
11
|
+
import { formatHexBytes, parseHexBytes, parseIntegerInput, } from './device-io-controls';
|
|
12
|
+
import { DeviceList, DeviceListEmpty, DeviceListItem } from './device-list';
|
|
13
|
+
import { NativeCapabilityPanel, NativeCapabilityPanelAction, NativeCapabilityPanelContent, NativeCapabilityPanelFooter, NativeCapabilityPanelHeader, NativeCapabilityPanelIcon, NativeCapabilityPanelTitle, } from './native-capability-panel';
|
|
14
|
+
import { Readout, ReadoutItem } from './readout';
|
|
15
|
+
function toError(cause) {
|
|
16
|
+
return cause instanceof Error ? cause : new Error(String(cause));
|
|
17
|
+
}
|
|
18
|
+
function formatHexId(value) {
|
|
19
|
+
return `0x${value.toString(16).padStart(4, '0')}`;
|
|
20
|
+
}
|
|
21
|
+
function usbDeviceDescriptionId(device) {
|
|
22
|
+
return [
|
|
23
|
+
device.vendorId,
|
|
24
|
+
device.productId,
|
|
25
|
+
device.serialNumber ?? '',
|
|
26
|
+
device.productName ?? '',
|
|
27
|
+
].join(':');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* USB state machine behind `UsbDevicePanel`: granted-device enumeration,
|
|
31
|
+
* chooser requests, minimal-claim open/close tracking. Use directly to build
|
|
32
|
+
* custom USB UI on the same best-effort error handling.
|
|
33
|
+
*/
|
|
34
|
+
export function useMoldableUsb(options = {}) {
|
|
35
|
+
const [devices, setDevices] = useState([]);
|
|
36
|
+
const [status, setStatus] = useState('idle');
|
|
37
|
+
const [error, setError] = useState(null);
|
|
38
|
+
const [openDeviceIds, setOpenDeviceIds] = useState([]);
|
|
39
|
+
const [nativeDeviceChoices, setNativeDeviceChoices] = useState([]);
|
|
40
|
+
const openDevicesRef = useRef(new Map());
|
|
41
|
+
const idsRef = useRef(new WeakMap());
|
|
42
|
+
const idCounterRef = useRef(0);
|
|
43
|
+
const pendingSelectionRef = useRef(null);
|
|
44
|
+
const generationRef = useRef(0);
|
|
45
|
+
const unmountedRef = useRef(false);
|
|
46
|
+
const optionsRef = useRef(options);
|
|
47
|
+
optionsRef.current = options;
|
|
48
|
+
const deviceId = useCallback((device) => {
|
|
49
|
+
let id = idsRef.current.get(device);
|
|
50
|
+
if (!id) {
|
|
51
|
+
id = `usb-${++idCounterRef.current}`;
|
|
52
|
+
idsRef.current.set(device, id);
|
|
53
|
+
}
|
|
54
|
+
return id;
|
|
55
|
+
}, []);
|
|
56
|
+
const refresh = useCallback(async () => {
|
|
57
|
+
const generation = ++generationRef.current;
|
|
58
|
+
setStatus('loading');
|
|
59
|
+
setError(null);
|
|
60
|
+
try {
|
|
61
|
+
const known = await getMoldableUsbDevices();
|
|
62
|
+
if (generationRef.current !== generation)
|
|
63
|
+
return;
|
|
64
|
+
setDevices((previous) => [
|
|
65
|
+
...known,
|
|
66
|
+
...previous.filter((device) => openDevicesRef.current.has(deviceId(device)) &&
|
|
67
|
+
!known.includes(device)),
|
|
68
|
+
]);
|
|
69
|
+
setStatus('idle');
|
|
70
|
+
}
|
|
71
|
+
catch (cause) {
|
|
72
|
+
if (generationRef.current !== generation)
|
|
73
|
+
return;
|
|
74
|
+
if (cause instanceof NativeCapabilityBridgeError &&
|
|
75
|
+
cause.code === 'unsupported') {
|
|
76
|
+
// No WebUSB enumeration here (native fallback runtime). Devices
|
|
77
|
+
// granted through `request` stay listed; this is not an error.
|
|
78
|
+
setStatus('idle');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setError(toError(cause));
|
|
82
|
+
setStatus('error');
|
|
83
|
+
}
|
|
84
|
+
}, [deviceId]);
|
|
85
|
+
const handleDisconnect = useCallback((device) => {
|
|
86
|
+
if (unmountedRef.current)
|
|
87
|
+
return;
|
|
88
|
+
const id = deviceId(device);
|
|
89
|
+
const record = openDevicesRef.current.get(id);
|
|
90
|
+
if (record) {
|
|
91
|
+
device.removeEventListener('disconnect', record.onDisconnect);
|
|
92
|
+
}
|
|
93
|
+
openDevicesRef.current.delete(id);
|
|
94
|
+
setOpenDeviceIds((previous) => previous.filter((existing) => existing !== id));
|
|
95
|
+
setDevices((previous) => previous.filter((existing) => existing !== device));
|
|
96
|
+
}, [deviceId]);
|
|
97
|
+
const chooseNativeDevice = useCallback((devices) => new Promise((resolve, reject) => {
|
|
98
|
+
pendingSelectionRef.current = { devices, resolve, reject };
|
|
99
|
+
setNativeDeviceChoices(devices);
|
|
100
|
+
}), []);
|
|
101
|
+
const selectNativeDevice = useCallback((device) => {
|
|
102
|
+
const pending = pendingSelectionRef.current;
|
|
103
|
+
if (!pending || !pending.devices.includes(device))
|
|
104
|
+
return;
|
|
105
|
+
pendingSelectionRef.current = null;
|
|
106
|
+
setNativeDeviceChoices([]);
|
|
107
|
+
pending.resolve(device);
|
|
108
|
+
}, []);
|
|
109
|
+
const cancelNativeSelection = useCallback(() => {
|
|
110
|
+
const pending = pendingSelectionRef.current;
|
|
111
|
+
if (!pending)
|
|
112
|
+
return;
|
|
113
|
+
pendingSelectionRef.current = null;
|
|
114
|
+
setNativeDeviceChoices([]);
|
|
115
|
+
pending.reject(new NativeCapabilityBridgeError({
|
|
116
|
+
code: 'cancelled',
|
|
117
|
+
message: 'USB device selection was cancelled.',
|
|
118
|
+
retryable: true,
|
|
119
|
+
}));
|
|
120
|
+
}, []);
|
|
121
|
+
const request = useCallback(async (filters) => {
|
|
122
|
+
const generation = ++generationRef.current;
|
|
123
|
+
setStatus('requesting');
|
|
124
|
+
setError(null);
|
|
125
|
+
try {
|
|
126
|
+
const device = await requestMoldableUsbDevice({
|
|
127
|
+
filters: filters ?? optionsRef.current.filters ?? [],
|
|
128
|
+
selectNativeDevice: optionsRef.current.selectNativeDevice ?? chooseNativeDevice,
|
|
129
|
+
});
|
|
130
|
+
if (generationRef.current !== generation)
|
|
131
|
+
return;
|
|
132
|
+
setDevices((previous) => previous.includes(device) ? previous : [...previous, device]);
|
|
133
|
+
setStatus('idle');
|
|
134
|
+
return device;
|
|
135
|
+
}
|
|
136
|
+
catch (cause) {
|
|
137
|
+
if (generationRef.current !== generation)
|
|
138
|
+
return;
|
|
139
|
+
if (cause instanceof NativeCapabilityBridgeError &&
|
|
140
|
+
(cause.code === 'cancelled' || cause.code === 'aborted')) {
|
|
141
|
+
// The user dismissed the chooser; that is not an error state.
|
|
142
|
+
setStatus('idle');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
setError(toError(cause));
|
|
146
|
+
setStatus('error');
|
|
147
|
+
}
|
|
148
|
+
}, [chooseNativeDevice]);
|
|
149
|
+
const open = useCallback(async (device) => {
|
|
150
|
+
const id = deviceId(device);
|
|
151
|
+
if (openDevicesRef.current.has(id))
|
|
152
|
+
return;
|
|
153
|
+
try {
|
|
154
|
+
await openMoldableUsbDevice(device, optionsRef.current.openOptions);
|
|
155
|
+
if (unmountedRef.current) {
|
|
156
|
+
void closeMoldableUsbDevice(device, optionsRef.current.openOptions?.claimInterfaces).catch(() => undefined);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const onDisconnect = () => handleDisconnect(device);
|
|
160
|
+
device.addEventListener('disconnect', onDisconnect, { once: true });
|
|
161
|
+
openDevicesRef.current.set(id, {
|
|
162
|
+
device,
|
|
163
|
+
onDisconnect,
|
|
164
|
+
releaseInterfaces: optionsRef.current.openOptions?.claimInterfaces ?? [],
|
|
165
|
+
});
|
|
166
|
+
setOpenDeviceIds((previous) => previous.includes(id) ? previous : [...previous, id]);
|
|
167
|
+
setError(null);
|
|
168
|
+
setStatus('idle');
|
|
169
|
+
optionsRef.current.onDeviceOpen?.(device);
|
|
170
|
+
}
|
|
171
|
+
catch (cause) {
|
|
172
|
+
if (unmountedRef.current)
|
|
173
|
+
return;
|
|
174
|
+
setError(toError(cause));
|
|
175
|
+
setStatus('error');
|
|
176
|
+
}
|
|
177
|
+
}, [deviceId, handleDisconnect]);
|
|
178
|
+
const close = useCallback(async (device) => {
|
|
179
|
+
const id = deviceId(device);
|
|
180
|
+
const record = openDevicesRef.current.get(id);
|
|
181
|
+
try {
|
|
182
|
+
await closeMoldableUsbDevice(device, record?.releaseInterfaces);
|
|
183
|
+
if (record) {
|
|
184
|
+
device.removeEventListener('disconnect', record.onDisconnect);
|
|
185
|
+
}
|
|
186
|
+
openDevicesRef.current.delete(id);
|
|
187
|
+
setOpenDeviceIds((previous) => previous.filter((existing) => existing !== id));
|
|
188
|
+
setError(null);
|
|
189
|
+
setStatus('idle');
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
catch (cause) {
|
|
193
|
+
if (record)
|
|
194
|
+
record.releaseInterfaces = [];
|
|
195
|
+
if (unmountedRef.current)
|
|
196
|
+
return false;
|
|
197
|
+
setError(toError(cause));
|
|
198
|
+
setStatus('error');
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}, [deviceId]);
|
|
202
|
+
const runOperation = useCallback(async (operation) => {
|
|
203
|
+
setError(null);
|
|
204
|
+
try {
|
|
205
|
+
const result = await operation();
|
|
206
|
+
if (!unmountedRef.current)
|
|
207
|
+
setStatus('idle');
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
catch (cause) {
|
|
211
|
+
if (!unmountedRef.current) {
|
|
212
|
+
setError(toError(cause));
|
|
213
|
+
setStatus('error');
|
|
214
|
+
}
|
|
215
|
+
throw cause;
|
|
216
|
+
}
|
|
217
|
+
}, []);
|
|
218
|
+
const forget = useCallback(async (device) => {
|
|
219
|
+
const id = deviceId(device);
|
|
220
|
+
if ((openDevicesRef.current.has(id) || device.opened) &&
|
|
221
|
+
!(await close(device))) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
await runOperation(() => forgetMoldableUsbDevice(device));
|
|
226
|
+
if (unmountedRef.current)
|
|
227
|
+
return false;
|
|
228
|
+
setDevices((previous) => previous.filter((known) => known !== device));
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
}, [close, deviceId, runOperation]);
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
unmountedRef.current = false;
|
|
237
|
+
void refresh();
|
|
238
|
+
const liveGeneration = generationRef;
|
|
239
|
+
const openDevices = openDevicesRef.current;
|
|
240
|
+
return () => {
|
|
241
|
+
unmountedRef.current = true;
|
|
242
|
+
liveGeneration.current++;
|
|
243
|
+
const pending = pendingSelectionRef.current;
|
|
244
|
+
pendingSelectionRef.current = null;
|
|
245
|
+
pending?.reject(new NativeCapabilityBridgeError({
|
|
246
|
+
code: 'aborted',
|
|
247
|
+
message: 'USB device selection was interrupted.',
|
|
248
|
+
retryable: true,
|
|
249
|
+
}));
|
|
250
|
+
const stillOpen = [...openDevices.values()];
|
|
251
|
+
openDevices.clear();
|
|
252
|
+
for (const { device, onDisconnect, releaseInterfaces } of stillOpen) {
|
|
253
|
+
device.removeEventListener('disconnect', onDisconnect);
|
|
254
|
+
void closeMoldableUsbDevice(device, releaseInterfaces).catch(() => undefined);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}, [refresh]);
|
|
258
|
+
return {
|
|
259
|
+
devices,
|
|
260
|
+
status,
|
|
261
|
+
error,
|
|
262
|
+
openDeviceIds,
|
|
263
|
+
nativeDeviceChoices,
|
|
264
|
+
deviceId,
|
|
265
|
+
refresh,
|
|
266
|
+
request,
|
|
267
|
+
selectNativeDevice,
|
|
268
|
+
cancelNativeSelection,
|
|
269
|
+
open,
|
|
270
|
+
close,
|
|
271
|
+
forget,
|
|
272
|
+
readEndpoint: (device, endpoint, length) => runOperation(() => readMoldableUsbEndpoint(device, endpoint, length)),
|
|
273
|
+
writeEndpoint: (device, endpoint, data) => runOperation(() => writeMoldableUsbEndpoint(device, endpoint, data)),
|
|
274
|
+
readControl: (device, setup, length) => runOperation(() => readMoldableUsbControlTransfer(device, setup, length)),
|
|
275
|
+
writeControl: (device, setup, data) => runOperation(() => writeMoldableUsbControlTransfer(device, setup, data)),
|
|
276
|
+
clearHalt: (device, direction, endpoint) => runOperation(() => clearMoldableUsbHalt(device, direction, endpoint)),
|
|
277
|
+
reset: (device) => runOperation(() => resetMoldableUsbDevice(device)),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function UsbDeviceControls({ device, usb }) {
|
|
281
|
+
const [endpoint, setEndpoint] = useState('1');
|
|
282
|
+
const [length, setLength] = useState('64');
|
|
283
|
+
const [payload, setPayload] = useState('');
|
|
284
|
+
const [requestType, setRequestType] = useState('vendor');
|
|
285
|
+
const [recipient, setRecipient] = useState('device');
|
|
286
|
+
const [request, setRequest] = useState('0');
|
|
287
|
+
const [value, setValue] = useState('0');
|
|
288
|
+
const [index, setIndex] = useState('0');
|
|
289
|
+
const [result, setResult] = useState('Ready');
|
|
290
|
+
const [busy, setBusy] = useState(false);
|
|
291
|
+
const run = async (operation) => {
|
|
292
|
+
setBusy(true);
|
|
293
|
+
try {
|
|
294
|
+
setResult(await operation());
|
|
295
|
+
}
|
|
296
|
+
catch (cause) {
|
|
297
|
+
setResult(toError(cause).message);
|
|
298
|
+
}
|
|
299
|
+
finally {
|
|
300
|
+
setBusy(false);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
const endpointNumber = () => parseIntegerInput(endpoint, 'Endpoint', 1, 15);
|
|
304
|
+
const transferLength = () => parseIntegerInput(length, 'Length', 1, 65_535);
|
|
305
|
+
const setup = () => ({
|
|
306
|
+
requestType,
|
|
307
|
+
recipient,
|
|
308
|
+
request: parseIntegerInput(request, 'Request', 0, 255),
|
|
309
|
+
value: parseIntegerInput(value, 'Value', 0, 65_535),
|
|
310
|
+
index: parseIntegerInput(index, 'Index', 0, 65_535),
|
|
311
|
+
});
|
|
312
|
+
return (_jsxs("div", { "data-slot": "usb-device-controls", className: "bg-muted/30 mt-2 space-y-3 rounded-md border p-2.5", children: [_jsxs("div", { className: "grid gap-2 sm:grid-cols-3", children: [_jsx(Input, { "aria-label": "USB endpoint number", value: endpoint, onChange: (event) => setEndpoint(event.target.value), placeholder: "Endpoint", className: "h-8 font-mono text-xs" }), _jsx(Input, { "aria-label": "USB transfer length", value: length, onChange: (event) => setLength(event.target.value), placeholder: "Length", className: "h-8 font-mono text-xs" }), _jsx(Input, { "aria-label": "USB endpoint payload", value: payload, onChange: (event) => setPayload(event.target.value), placeholder: "Hex payload", className: "h-8 font-mono text-xs" })] }), _jsxs("div", { className: "flex flex-wrap gap-1.5", children: [_jsx(Button, { size: "xs", variant: "outline", disabled: busy, onClick: () => void run(async () => {
|
|
313
|
+
const transfer = await usb.readEndpoint(device, endpointNumber(), transferLength());
|
|
314
|
+
return `Endpoint IN · ${transfer.status} · ${formatHexBytes(transfer.data)}`;
|
|
315
|
+
}), children: "Endpoint IN" }), _jsx(Button, { size: "xs", variant: "outline", disabled: busy, onClick: () => void run(async () => {
|
|
316
|
+
const transfer = await usb.writeEndpoint(device, endpointNumber(), parseHexBytes(payload));
|
|
317
|
+
return `Endpoint OUT · ${transfer.status} · ${transfer.bytesWritten ?? 0} bytes`;
|
|
318
|
+
}), children: "Endpoint OUT" }), _jsx(Button, { size: "xs", variant: "ghost", disabled: busy, onClick: () => void run(async () => {
|
|
319
|
+
await usb.clearHalt(device, 'in', endpointNumber());
|
|
320
|
+
return 'IN halt cleared';
|
|
321
|
+
}), children: "Clear IN halt" }), _jsx(Button, { size: "xs", variant: "ghost", disabled: busy, onClick: () => void run(async () => {
|
|
322
|
+
await usb.clearHalt(device, 'out', endpointNumber());
|
|
323
|
+
return 'OUT halt cleared';
|
|
324
|
+
}), children: "Clear OUT halt" })] }), _jsxs("div", { className: "grid gap-2 sm:grid-cols-5", children: [_jsxs(Select, { value: requestType, onValueChange: (next) => setRequestType(next), children: [_jsx(SelectTrigger, { size: "sm", "aria-label": "USB control request type", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "standard", children: "Standard" }), _jsx(SelectItem, { value: "class", children: "Class" }), _jsx(SelectItem, { value: "vendor", children: "Vendor" })] })] }), _jsxs(Select, { value: recipient, onValueChange: (next) => setRecipient(next), children: [_jsx(SelectTrigger, { size: "sm", "aria-label": "USB control recipient", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "device", children: "Device" }), _jsx(SelectItem, { value: "interface", children: "Interface" }), _jsx(SelectItem, { value: "endpoint", children: "Endpoint" }), _jsx(SelectItem, { value: "other", children: "Other" })] })] }), [
|
|
325
|
+
['Request', request, setRequest],
|
|
326
|
+
['Value', value, setValue],
|
|
327
|
+
['Index', index, setIndex],
|
|
328
|
+
].map(([label, current, update]) => (_jsx(Input, { "aria-label": `USB control ${String(label).toLowerCase()}`, value: current, onChange: (event) => update(event.target.value), placeholder: label, className: "h-8 font-mono text-xs" }, label)))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [_jsx(Button, { size: "xs", variant: "outline", disabled: busy, onClick: () => void run(async () => {
|
|
329
|
+
const transfer = await usb.readControl(device, setup(), transferLength());
|
|
330
|
+
return `Control IN · ${transfer.status} · ${formatHexBytes(transfer.data)}`;
|
|
331
|
+
}), children: "Control IN" }), _jsx(Button, { size: "xs", variant: "outline", disabled: busy, onClick: () => void run(async () => {
|
|
332
|
+
const transfer = await usb.writeControl(device, setup(), parseHexBytes(payload));
|
|
333
|
+
return `Control OUT · ${transfer.status} · ${transfer.bytesWritten ?? 0} bytes`;
|
|
334
|
+
}), children: "Control OUT" }), _jsxs(Button, { size: "xs", variant: "ghost", disabled: busy, onClick: () => void run(async () => {
|
|
335
|
+
await usb.reset(device);
|
|
336
|
+
return 'Device reset';
|
|
337
|
+
}), children: [_jsx(RotateCcw, {}), "Reset"] }), _jsx("span", { className: "text-muted-foreground ml-auto truncate font-mono text-[10px]", children: busy ? 'Working…' : result })] })] }));
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* USB device panel: request access, list granted devices, open/close each
|
|
341
|
+
* with minimal claims, and read out live device details while open.
|
|
342
|
+
*/
|
|
343
|
+
function UsbDevicePanel({ className, filters, selectNativeDevice, openOptions, onDeviceOpen, ...props }) {
|
|
344
|
+
const usb = useMoldableUsb({
|
|
345
|
+
filters,
|
|
346
|
+
selectNativeDevice,
|
|
347
|
+
openOptions,
|
|
348
|
+
onDeviceOpen,
|
|
349
|
+
});
|
|
350
|
+
const requesting = usb.status === 'requesting';
|
|
351
|
+
const loading = usb.status === 'loading';
|
|
352
|
+
return (_jsxs(NativeCapabilityPanel, { "data-slot": "usb-device-panel", "data-status": usb.status, className: className, ...props, children: [_jsxs(NativeCapabilityPanelHeader, { children: [_jsx(NativeCapabilityPanelIcon, { children: _jsx(Usb, {}) }), _jsx(NativeCapabilityPanelTitle, { children: "USB" }), _jsx(CapabilityBadge, { capability: "usb" }), _jsxs(NativeCapabilityPanelAction, { children: [_jsxs(Button, { size: "sm", disabled: requesting, onClick: () => void usb.request(), children: [requesting ? _jsx(Spinner, {}) : _jsx(Usb, {}), requesting ? 'Requesting…' : 'Request device'] }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Refresh devices", disabled: loading || requesting, onClick: () => void usb.refresh(), children: _jsx(RefreshCw, { className: loading ? 'animate-spin motion-reduce:animate-none' : undefined }) })] })] }), _jsxs(NativeCapabilityPanelContent, { children: [usb.nativeDeviceChoices.length > 0 ? (_jsxs("div", { "data-slot": "usb-native-device-picker", className: "bg-muted/30 mb-4 space-y-2 rounded-lg border p-3", children: [_jsx("p", { className: "text-sm font-medium", children: "Choose a USB device" }), _jsx("p", { className: "text-muted-foreground text-xs", children: "More than one native device matched. Select the device explicitly." }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [usb.nativeDeviceChoices.map((device, index) => (_jsxs(Button, { size: "xs", variant: "outline", onClick: () => usb.selectNativeDevice(device), children: [device.productName || 'USB device', " \u00B7", ' ', formatHexId(device.vendorId), ":", formatHexId(device.productId)] }, `${usbDeviceDescriptionId(device)}:${index}`))), _jsx(Button, { size: "xs", variant: "ghost", onClick: usb.cancelNativeSelection, children: "Cancel" })] })] })) : null, _jsx(DeviceList, { children: usb.devices.length === 0 ? (_jsxs(DeviceListEmpty, { icon: _jsx(Usb, {}), children: [_jsx("span", { className: "font-medium", children: "No devices yet" }), _jsx("span", { className: "text-muted-foreground/70 text-xs", children: "Request access to a USB device to get started." })] })) : (usb.devices.map((device, index) => {
|
|
353
|
+
const id = usb.deviceId(device);
|
|
354
|
+
const open = usb.openDeviceIds.includes(id) || device.opened;
|
|
355
|
+
return (_jsx(DeviceListItem, { icon: _jsx(Usb, {}), name: device.productName || 'USB device', description: `${formatHexId(device.vendorId)}:${formatHexId(device.productId)}` +
|
|
356
|
+
(device.manufacturerName
|
|
357
|
+
? ` · ${device.manufacturerName}`
|
|
358
|
+
: ''), connected: open, action: _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { size: "xs", variant: "outline", onClick: () => void (open ? usb.close(device) : usb.open(device)), children: open ? 'Close' : 'Open' }), _jsx(Button, { size: "icon-xs", variant: "ghost", "aria-label": `Forget ${device.productName || 'USB device'}`, onClick: () => void usb.forget(device), children: _jsx(Trash2, {}) })] }), children: open ? (_jsxs("div", { "data-slot": "usb-device-details", className: "animate-in fade-in slide-in-from-top-1 bg-muted/30 mt-2 rounded-md border p-2.5 duration-200 motion-reduce:animate-none", children: [_jsxs(Readout, { className: "gap-y-2 sm:grid-cols-4", children: [_jsx(ReadoutItem, { label: "Configuration", value: device.configuration?.configurationValue ?? null }), _jsx(ReadoutItem, { label: "Vendor ID", value: formatHexId(device.vendorId) }), _jsx(ReadoutItem, { label: "Product ID", value: formatHexId(device.productId) }), _jsx(ReadoutItem, { label: "Serial", value: device.serialNumber ?? null })] }), _jsx(UsbDeviceControls, { device: device, usb: usb })] })) : null }, `${id}:${index}`));
|
|
359
|
+
})) })] }), _jsxs(NativeCapabilityPanelFooter, { children: [usb.error ? (_jsx("span", { className: "text-status-error truncate", children: usb.error.message })) : (_jsx("span", { className: "truncate", children: usb.devices.length === 0
|
|
360
|
+
? 'No devices authorized'
|
|
361
|
+
: `${usb.devices.length} device${usb.devices.length === 1 ? '' : 's'} known` })), _jsxs("span", { className: "ml-auto shrink-0 font-mono tabular-nums", children: [usb.openDeviceIds.length, " open"] })] })] }));
|
|
362
|
+
}
|
|
363
|
+
export { UsbDevicePanel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type NativeCapabilityDescriptor, type NativeCapabilityId, type NativeCapabilityManifest } from '../../lib/native-capabilities';
|
|
2
|
+
export type MoldableCapabilityStatus = 'checking' | 'supported' | 'partial' | 'unsupported' | 'unavailable';
|
|
3
|
+
/**
|
|
4
|
+
* Loads the native capability manifest once per page and shares it across all
|
|
5
|
+
* hardware components. Pass `force` to bypass the cache (e.g. after a grant).
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadMoldableCapabilities(force?: boolean): Promise<NativeCapabilityManifest>;
|
|
8
|
+
export interface MoldableCapability {
|
|
9
|
+
status: MoldableCapabilityStatus;
|
|
10
|
+
descriptor: NativeCapabilityDescriptor | null;
|
|
11
|
+
manifest: NativeCapabilityManifest | null;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
refresh: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads the support level for one native capability. `unavailable` means the
|
|
17
|
+
* manifest could not be loaded at all (typically: not running inside Moldable).
|
|
18
|
+
*/
|
|
19
|
+
export declare function useMoldableCapability(id: NativeCapabilityId): MoldableCapability;
|
|
20
|
+
//# sourceMappingURL=use-capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-capability.d.ts","sourceRoot":"","sources":["../../../src/components/native-capabilities/use-capability.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAE9B,MAAM,+BAA+B,CAAA;AAEtC,MAAM,MAAM,wBAAwB,GAChC,UAAU,GACV,WAAW,GACX,SAAS,GACT,aAAa,GACb,aAAa,CAAA;AAIjB;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,UAAQ,GACZ,OAAO,CAAC,wBAAwB,CAAC,CAUnC;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,wBAAwB,CAAA;IAChC,UAAU,EAAE,0BAA0B,GAAG,IAAI,CAAA;IAC7C,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAAA;IACzC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,kBAAkB,GACrB,kBAAkB,CA4CpB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { getMoldableNativeCapabilities, } from '../../lib/native-capabilities';
|
|
4
|
+
let manifestPromise = null;
|
|
5
|
+
/**
|
|
6
|
+
* Loads the native capability manifest once per page and shares it across all
|
|
7
|
+
* hardware components. Pass `force` to bypass the cache (e.g. after a grant).
|
|
8
|
+
*/
|
|
9
|
+
export function loadMoldableCapabilities(force = false) {
|
|
10
|
+
if (force || !manifestPromise) {
|
|
11
|
+
manifestPromise = getMoldableNativeCapabilities().catch((error) => {
|
|
12
|
+
manifestPromise = null;
|
|
13
|
+
throw error;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return manifestPromise;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads the support level for one native capability. `unavailable` means the
|
|
20
|
+
* manifest could not be loaded at all (typically: not running inside Moldable).
|
|
21
|
+
*/
|
|
22
|
+
export function useMoldableCapability(id) {
|
|
23
|
+
const [manifest, setManifest] = useState(null);
|
|
24
|
+
const [error, setError] = useState(null);
|
|
25
|
+
const [checking, setChecking] = useState(true);
|
|
26
|
+
const generation = useRef(0);
|
|
27
|
+
const load = useCallback((force) => {
|
|
28
|
+
const current = ++generation.current;
|
|
29
|
+
setChecking(true);
|
|
30
|
+
setError(null);
|
|
31
|
+
loadMoldableCapabilities(force)
|
|
32
|
+
.then((value) => {
|
|
33
|
+
if (generation.current !== current)
|
|
34
|
+
return;
|
|
35
|
+
setManifest(value);
|
|
36
|
+
setChecking(false);
|
|
37
|
+
})
|
|
38
|
+
.catch((cause) => {
|
|
39
|
+
if (generation.current !== current)
|
|
40
|
+
return;
|
|
41
|
+
setManifest(null);
|
|
42
|
+
setError(cause instanceof Error ? cause : new Error(String(cause)));
|
|
43
|
+
setChecking(false);
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
load(false);
|
|
48
|
+
const liveGeneration = generation;
|
|
49
|
+
return () => {
|
|
50
|
+
liveGeneration.current++;
|
|
51
|
+
};
|
|
52
|
+
}, [load]);
|
|
53
|
+
const refresh = useCallback(() => load(true), [load]);
|
|
54
|
+
const descriptor = manifest ? manifest.capabilities[id] : null;
|
|
55
|
+
const status = checking
|
|
56
|
+
? 'checking'
|
|
57
|
+
: descriptor
|
|
58
|
+
? descriptor.support
|
|
59
|
+
: 'unavailable';
|
|
60
|
+
return { status, descriptor, manifest, error, refresh };
|
|
61
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type AppFrameMode = 'auto' | 'embedded' | 'window';
|
|
3
|
+
declare function resolveAppFrameMode(mode: AppFrameMode): Exclude<AppFrameMode, 'auto'>;
|
|
4
|
+
export interface AppFrameProps extends React.ComponentProps<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* `auto` detects whether the app is hosted in a frame. Set an explicit mode
|
|
7
|
+
* in catalogs, previews, and tests where the runtime environment is ambiguous.
|
|
8
|
+
*/
|
|
9
|
+
mode?: AppFrameMode;
|
|
10
|
+
}
|
|
11
|
+
declare function AppFrame({ mode, className, style, ...props }: AppFrameProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export type AppFrameTitlebarProps = React.ComponentPropsWithoutRef<'header'>;
|
|
13
|
+
declare function AppFrameTitlebar({ className, style, ...props }: AppFrameTitlebarProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function AppFrameToolbar({ className, ...props }: React.ComponentPropsWithoutRef<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export interface AppFrameContentProps extends React.ComponentPropsWithoutRef<'main'> {
|
|
16
|
+
scrollable?: boolean;
|
|
17
|
+
chatSafe?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare function AppFrameContent({ scrollable, chatSafe, className, style, ...props }: AppFrameContentProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare function AppFrameStatusbar({ className, style, ...props }: React.ComponentPropsWithoutRef<'footer'>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export { AppFrame, AppFrameContent, AppFrameStatusbar, AppFrameTitlebar, AppFrameToolbar, resolveAppFrameMode, };
|
|
22
|
+
//# sourceMappingURL=app-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-frame.d.ts","sourceRoot":"","sources":["../../../src/components/ui/app-frame.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEzD,iBAAS,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAM9E;AAED,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;IAChE;;;OAGG;IACH,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,iBAAS,QAAQ,CAAC,EAChB,IAAa,EACb,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,aAAa,2CA+Bf;AAED,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAA;AAE5E,iBAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,qBAAqB,2CAoBvB;AAED,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,2CAWvC;AAED,MAAM,WAAW,oBACf,SAAQ,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,iBAAS,eAAe,CAAC,EACvB,UAAiB,EACjB,QAAe,EACf,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,oBAAoB,2CAoBtB;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,2CAgB1C;AAED,OAAO,EACL,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
function resolveAppFrameMode(mode) {
|
|
6
|
+
if (mode !== 'auto')
|
|
7
|
+
return mode;
|
|
8
|
+
if (typeof window === 'undefined')
|
|
9
|
+
return 'window';
|
|
10
|
+
const hostMode = document.documentElement.dataset.moldableDisplayMode;
|
|
11
|
+
if (hostMode === 'embedded' || hostMode === 'window')
|
|
12
|
+
return hostMode;
|
|
13
|
+
return window.parent === window ? 'window' : 'embedded';
|
|
14
|
+
}
|
|
15
|
+
function AppFrame({ mode = 'auto', className, style, ...props }) {
|
|
16
|
+
const [resolvedMode, setResolvedMode] = React.useState(() => resolveAppFrameMode(mode));
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
setResolvedMode(resolveAppFrameMode(mode));
|
|
19
|
+
if (mode !== 'auto')
|
|
20
|
+
return;
|
|
21
|
+
const updateMode = () => setResolvedMode(resolveAppFrameMode('auto'));
|
|
22
|
+
window.addEventListener('moldable:host-context-change', updateMode);
|
|
23
|
+
return () => window.removeEventListener('moldable:host-context-change', updateMode);
|
|
24
|
+
}, [mode]);
|
|
25
|
+
return (_jsx("div", { "data-slot": "app-frame", "data-mode": resolvedMode, className: cn('bg-[var(--surface-canvas,var(--background))] text-foreground flex h-dvh min-h-0 min-w-0 flex-col overflow-hidden', className), style: {
|
|
26
|
+
paddingInlineStart: 'var(--window-safe-area-inline-start, 0px)',
|
|
27
|
+
paddingInlineEnd: 'var(--window-safe-area-inline-end, 0px)',
|
|
28
|
+
...style,
|
|
29
|
+
}, ...props }));
|
|
30
|
+
}
|
|
31
|
+
function AppFrameTitlebar({ className, style, ...props }) {
|
|
32
|
+
return (_jsx("header", { "data-slot": "app-frame-titlebar", className: cn('border-border/70 bg-[var(--surface-toolbar,var(--background))] flex shrink-0 items-center gap-2 border-b', className), style: {
|
|
33
|
+
minHeight: 'max(var(--density-toolbar-height, 2.5rem), var(--window-drag-region-height, 0px))',
|
|
34
|
+
paddingInlineStart: 'max(var(--density-pane-padding, 0.75rem), var(--window-control-inset-inline-start, 0px))',
|
|
35
|
+
paddingInlineEnd: 'max(var(--density-pane-padding, 0.75rem), var(--window-control-inset-inline-end, 0px))',
|
|
36
|
+
...style,
|
|
37
|
+
}, ...props }));
|
|
38
|
+
}
|
|
39
|
+
function AppFrameToolbar({ className, ...props }) {
|
|
40
|
+
return (_jsx("div", { "data-slot": "app-frame-toolbar", className: cn('flex min-h-9 min-w-0 flex-1 items-center gap-2 px-3 py-1.5', className), ...props }));
|
|
41
|
+
}
|
|
42
|
+
function AppFrameContent({ scrollable = true, chatSafe = true, className, style, ...props }) {
|
|
43
|
+
return (_jsx("main", { "data-slot": "app-frame-content", "data-scrollable": scrollable, "data-chat-safe": chatSafe, className: cn('min-h-0 min-w-0 flex-1', scrollable ? 'overflow-auto' : 'overflow-hidden', className), style: {
|
|
44
|
+
paddingBlockEnd: chatSafe
|
|
45
|
+
? 'calc(var(--window-content-inset-bottom, 0px) + var(--chat-safe-padding, 0px))'
|
|
46
|
+
: 'var(--window-content-inset-bottom, 0px)',
|
|
47
|
+
...style,
|
|
48
|
+
}, ...props }));
|
|
49
|
+
}
|
|
50
|
+
function AppFrameStatusbar({ className, style, ...props }) {
|
|
51
|
+
return (_jsx("footer", { "data-slot": "app-frame-statusbar", className: cn('border-border/70 bg-[var(--surface-toolbar,var(--background))] flex min-h-7 shrink-0 items-center gap-2 border-t px-3 py-1 text-xs text-muted-foreground', className), style: {
|
|
52
|
+
paddingBlockEnd: 'calc(var(--window-content-inset-bottom, 0px) + 0.25rem)',
|
|
53
|
+
...style,
|
|
54
|
+
}, ...props }));
|
|
55
|
+
}
|
|
56
|
+
export { AppFrame, AppFrameContent, AppFrameStatusbar, AppFrameTitlebar, AppFrameToolbar, resolveAppFrameMode, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Separator } from './separator';
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
declare const buttonGroupVariants: (props?: ({
|
|
4
|
-
orientation?: "
|
|
4
|
+
orientation?: "vertical" | "horizontal" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
declare function ButtonGroup({ className, orientation, ...props }: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
declare function ButtonGroupText({ className, asChild, ...props }: React.ComponentProps<'div'> & {
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Slot } from '@radix-ui/react-slot';
|
|
3
3
|
import { cn } from '../../lib/utils';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
|
-
const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
5
|
+
const buttonVariants = cva("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
6
6
|
variants: {
|
|
7
7
|
variant: {
|
|
8
8
|
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
declare const colorWellVariants: (props?: ({
|
|
4
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export interface ColorWellProps extends Omit<React.ComponentProps<'input'>, 'onChange' | 'size' | 'type' | 'value'>, VariantProps<typeof colorWellVariants> {
|
|
7
|
+
value?: string | null;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare function ColorWell({ value, onValueChange, readOnly, size, className, 'aria-label': ariaLabel, disabled, ...props }: ColorWellProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export { ColorWell, colorWellVariants };
|
|
13
|
+
//# sourceMappingURL=color-well.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-well.d.ts","sourceRoot":"","sources":["../../../src/components/ui/color-well.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,KAAK,YAAY,EAAO,MAAM,0BAA0B,CAAA;AAEjE,QAAA,MAAM,iBAAiB;;8EActB,CAAA;AAED,MAAM,WAAW,cACf,SAAQ,IAAI,CACR,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAC7B,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CACvC,EACD,YAAY,CAAC,OAAO,iBAAiB,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,iBAAS,SAAS,CAAC,EACjB,KAAK,EACL,aAAa,EACb,QAAgB,EAChB,IAAI,EACJ,SAAS,EACT,YAAY,EAAE,SAA0B,EACxC,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,2CAkDhB;AAED,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
const colorWellVariants = cva('border-border has-[:focus-visible]:ring-ring/50 relative inline-flex shrink-0 overflow-hidden rounded-md border shadow-xs outline-none has-[:focus-visible]:ring-[3px]', {
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
sm: 'size-6',
|
|
9
|
+
default: 'size-8',
|
|
10
|
+
lg: 'size-10',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
size: 'default',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
function ColorWell({ value, onValueChange, readOnly = false, size, className, 'aria-label': ariaLabel = 'Choose color', disabled, ...props }) {
|
|
18
|
+
const swatch = (_jsx("span", { "aria-hidden": "true", "data-slot": "color-well-swatch", className: "absolute inset-0", style: {
|
|
19
|
+
backgroundColor: value ?? 'transparent',
|
|
20
|
+
backgroundImage: value
|
|
21
|
+
? undefined
|
|
22
|
+
: 'conic-gradient(var(--muted) 25%, transparent 0 50%, var(--muted) 0 75%, transparent 0)',
|
|
23
|
+
backgroundSize: value ? undefined : '8px 8px',
|
|
24
|
+
} }));
|
|
25
|
+
if (readOnly) {
|
|
26
|
+
return (_jsx("span", { "data-slot": "color-well", role: "img", "aria-label": ariaLabel, className: cn(colorWellVariants({ size }), className), children: swatch }));
|
|
27
|
+
}
|
|
28
|
+
return (_jsxs("label", { "data-slot": "color-well", className: cn(colorWellVariants({ size }), disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer', className), children: [swatch, _jsx("input", { type: "color", value: value ?? '#000000', "aria-label": ariaLabel, disabled: disabled, className: "absolute inset-0 cursor-[inherit] opacity-0", onChange: (event) => onValueChange?.(event.currentTarget.value), ...props })] }));
|
|
29
|
+
}
|
|
30
|
+
export { ColorWell, colorWellVariants };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
declare const dateFieldVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "filled" | null | undefined;
|
|
5
|
+
density?: "compact" | "default" | "comfortable" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
interface DateFieldProps extends Omit<React.ComponentProps<'input'>, 'defaultValue' | 'size' | 'type' | 'value'>, VariantProps<typeof dateFieldVariants> {
|
|
8
|
+
/** ISO calendar date in YYYY-MM-DD form. No timezone conversion is applied. */
|
|
9
|
+
value?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
onValueChange?: (value: string) => void;
|
|
12
|
+
onClear?: () => void;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
clearLabel?: string;
|
|
15
|
+
inputClassName?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function DateField({ className, inputClassName, value, defaultValue, onChange, onValueChange, onClear, clearable, clearLabel, variant, density, disabled, readOnly, ref, ...props }: DateFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export { DateField, dateFieldVariants, type DateFieldProps };
|
|
19
|
+
//# sourceMappingURL=date-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-field.d.ts","sourceRoot":"","sources":["../../../src/components/ui/date-field.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,KAAK,YAAY,EAAO,MAAM,0BAA0B,CAAA;AAEjE,QAAA,MAAM,iBAAiB;;;8EAmBtB,CAAA;AAED,UAAU,cACR,SAAQ,IAAI,CACR,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAC7B,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAC3C,EACD,YAAY,CAAC,OAAO,iBAAiB,CAAC;IACxC,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,iBAAS,SAAS,CAAC,EACjB,SAAS,EACT,cAAc,EACd,KAAK,EACL,YAAiB,EACjB,QAAQ,EACR,aAAa,EACb,OAAO,EACP,SAAiB,EACjB,UAAyB,EACzB,OAAmB,EACnB,OAAmB,EACnB,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,GAAG,KAAK,EACT,EAAE,cAAc,2CAkFhB;AAED,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,CAAA"}
|