@nordmanai/nif 0.0.0-stage → 0.2.0
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/README.md +79 -2
- package/bin/nif.mjs +196 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +12961 -0
- package/dist/styles.css +2 -0
- package/dist/tokens.css +72 -0
- package/dist/ui/components/nm-ai/nm-ai.d.ts +222 -0
- package/dist/ui/components/nm-avatar/nm-avatar.d.ts +12 -0
- package/dist/ui/components/nm-bar-overflow/nm-bar-overflow.d.ts +15 -0
- package/dist/ui/components/nm-bar-overflow/use-bar-overflow.d.ts +7 -0
- package/dist/ui/components/nm-brand-logo/nm-brand-logo.d.ts +10 -0
- package/dist/ui/components/nm-breadcrumb/nm-breadcrumb.d.ts +11 -0
- package/dist/ui/components/nm-button/nm-button.d.ts +19 -0
- package/dist/ui/components/nm-button-group/nm-button-group.d.ts +17 -0
- package/dist/ui/components/nm-calendar/nm-calendar.d.ts +3 -0
- package/dist/ui/components/nm-card/nm-card.d.ts +34 -0
- package/dist/ui/components/nm-chatbox/nm-chatbox-icon.d.ts +7 -0
- package/dist/ui/components/nm-chatbox/nm-chatbox.d.ts +19 -0
- package/dist/ui/components/nm-checkbox/nm-checkbox.d.ts +2 -0
- package/dist/ui/components/nm-chip/nm-chip.d.ts +38 -0
- package/dist/ui/components/nm-code-block/nm-code-block.d.ts +55 -0
- package/dist/ui/components/nm-collection/nm-collection-bar.d.ts +16 -0
- package/dist/ui/components/nm-collection/nm-collection-grid.d.ts +9 -0
- package/dist/ui/components/nm-collection/nm-collection-query.d.ts +18 -0
- package/dist/ui/components/nm-collection/nm-collection-row-menu.d.ts +7 -0
- package/dist/ui/components/nm-collection/nm-collection-table.d.ts +13 -0
- package/dist/ui/components/nm-collection/nm-collection-tile-actions.d.ts +7 -0
- package/dist/ui/components/nm-collection/nm-collection-title.d.ts +10 -0
- package/dist/ui/components/nm-collection/use-collection-scroll-reveal.d.ts +3 -0
- package/dist/ui/components/nm-color-picker/nm-color-picker.d.ts +15 -0
- package/dist/ui/components/nm-combobox/nm-combobox.d.ts +26 -0
- package/dist/ui/components/nm-command/nm-command.d.ts +37 -0
- package/dist/ui/components/nm-composer/nm-composer.d.ts +33 -0
- package/dist/ui/components/nm-context-menu/nm-context-menu.d.ts +9 -0
- package/dist/ui/components/nm-date-picker/nm-date-picker.d.ts +35 -0
- package/dist/ui/components/nm-dialog/nm-dialog.d.ts +13 -0
- package/dist/ui/components/nm-dropdown/nm-dropdown-item.d.ts +26 -0
- package/dist/ui/components/nm-dropdown/nm-dropdown-options.d.ts +12 -0
- package/dist/ui/components/nm-dropdown/nm-dropdown-panel.d.ts +16 -0
- package/dist/ui/components/nm-dropdown/nm-dropdown-placement.d.ts +55 -0
- package/dist/ui/components/nm-dropdown/nm-dropdown.d.ts +31 -0
- package/dist/ui/components/nm-dropdown-menu/nm-dropdown-menu.d.ts +30 -0
- package/dist/ui/components/nm-field/nm-field.d.ts +52 -0
- package/dist/ui/components/nm-form-field/nm-form-field.d.ts +18 -0
- package/dist/ui/components/nm-gallery/nm-gallery.d.ts +8 -0
- package/dist/ui/components/nm-hover-card/nm-hover-card.d.ts +5 -0
- package/dist/ui/components/nm-icon/nm-icon.d.ts +7 -0
- package/dist/ui/components/nm-icon/nm-lucide.d.ts +7 -0
- package/dist/ui/components/nm-icon-border/nm-icon-border.d.ts +21 -0
- package/dist/ui/components/nm-input/nm-input.d.ts +5 -0
- package/dist/ui/components/nm-input-group/nm-input-group.d.ts +9 -0
- package/dist/ui/components/nm-label/nm-label.d.ts +2 -0
- package/dist/ui/components/nm-list-item/nm-list-item.d.ts +23 -0
- package/dist/ui/components/nm-menubar/nm-menubar.d.ts +9 -0
- package/dist/ui/components/nm-message/nm-message-actions.d.ts +7 -0
- package/dist/ui/components/nm-message/nm-message-meta.d.ts +10 -0
- package/dist/ui/components/nm-message/nm-text-shimmer.d.ts +4 -0
- package/dist/ui/components/nm-message/nm-trace.d.ts +58 -0
- package/dist/ui/components/nm-modal/nm-modal.d.ts +35 -0
- package/dist/ui/components/nm-native-select/nm-native-select.d.ts +5 -0
- package/dist/ui/components/nm-panel/nm-panel.d.ts +14 -0
- package/dist/ui/components/nm-panel-bar/nm-panel-bar.d.ts +17 -0
- package/dist/ui/components/nm-popover/nm-popover.d.ts +8 -0
- package/dist/ui/components/nm-progress/nm-progress.d.ts +3 -0
- package/dist/ui/components/nm-prose/nm-prose.d.ts +6 -0
- package/dist/ui/components/nm-questionnaire/nm-questionnaire.d.ts +17 -0
- package/dist/ui/components/nm-radio-group/nm-radio-group.d.ts +4 -0
- package/dist/ui/components/nm-rail-icon/nm-rail-icon.d.ts +6 -0
- package/dist/ui/components/nm-resize-handle/nm-resize-handle.d.ts +18 -0
- package/dist/ui/components/nm-segmented/nm-segmented.d.ts +20 -0
- package/dist/ui/components/nm-select/nm-select.d.ts +22 -0
- package/dist/ui/components/nm-separator/nm-separator.d.ts +2 -0
- package/dist/ui/components/nm-side-panel/nm-side-panel.d.ts +33 -0
- package/dist/ui/components/nm-slider/nm-slider.d.ts +6 -0
- package/dist/ui/components/nm-small-icon-button/nm-small-icon-button.d.ts +21 -0
- package/dist/ui/components/nm-status-bar/nm-status-bar.d.ts +8 -0
- package/dist/ui/components/nm-switch/nm-switch.d.ts +2 -0
- package/dist/ui/components/nm-table/nm-table.d.ts +38 -0
- package/dist/ui/components/nm-tabs/nm-tabs.d.ts +9 -0
- package/dist/ui/components/nm-textarea/nm-textarea.d.ts +2 -0
- package/dist/ui/components/nm-toggle/nm-toggle.d.ts +9 -0
- package/dist/ui/components/nm-toolbar/nm-toolbar.d.ts +21 -0
- package/dist/ui/components/nm-tooltip/nm-tooltip.d.ts +5 -0
- package/dist/ui/components/nm-top-bar/nm-top-bar.d.ts +12 -0
- package/dist/ui/components/nordman-icon-button/nordman-icon-button.d.ts +29 -0
- package/dist/ui/components/nordman-login/nordman-login.d.ts +36 -0
- package/dist/ui/components/nordman-login-field/nordman-login-field.d.ts +13 -0
- package/dist/ui/components/nordman-login-forgot/nordman-login-forgot.d.ts +9 -0
- package/dist/ui/components/nordman-login-google/nordman-login-google.d.ts +6 -0
- package/dist/ui/components/nordman-login-hero/nordman-login-hero.d.ts +6 -0
- package/dist/ui/components/nordman-login-register/nordman-login-register.d.ts +11 -0
- package/dist/ui/components/nordman-login-reset/nordman-login-reset.d.ts +9 -0
- package/dist/ui/components/nordman-login-reveal/nordman-login-reveal.d.ts +6 -0
- package/dist/ui/components/nordman-login-sign-in/nordman-login-sign-in.d.ts +11 -0
- package/dist/ui/components/nordman-toggle/nordman-toggle.d.ts +12 -0
- package/dist/ui/config/nm-ai.d.ts +44 -0
- package/dist/ui/config/nm-app-panel.d.ts +36 -0
- package/dist/ui/config/nm-appearance.d.ts +100 -0
- package/dist/ui/config/nm-bar-overflow.d.ts +9 -0
- package/dist/ui/config/nm-button.d.ts +31 -0
- package/dist/ui/config/nm-chatbox-icons.d.ts +42 -0
- package/dist/ui/config/nm-chatbox.d.ts +40 -0
- package/dist/ui/config/nm-collection.d.ts +88 -0
- package/dist/ui/config/nm-composer.d.ts +42 -0
- package/dist/ui/config/nm-dropdown.d.ts +56 -0
- package/dist/ui/config/nm-fade.d.ts +6 -0
- package/dist/ui/config/nm-field.d.ts +38 -0
- package/dist/ui/config/nm-header-icons.d.ts +15 -0
- package/dist/ui/config/nm-icon-border.d.ts +3 -0
- package/dist/ui/config/nm-icon-button.d.ts +26 -0
- package/dist/ui/config/nm-icons.d.ts +371 -0
- package/dist/ui/config/nm-list-item.d.ts +14 -0
- package/dist/ui/config/nm-message.d.ts +87 -0
- package/dist/ui/config/nm-modal.d.ts +67 -0
- package/dist/ui/config/nm-panel-bar.d.ts +9 -0
- package/dist/ui/config/nm-questionnaire.d.ts +57 -0
- package/dist/ui/config/nm-radius.d.ts +49 -0
- package/dist/ui/config/nm-rail-icons.d.ts +14 -0
- package/dist/ui/config/nm-rail.d.ts +5 -0
- package/dist/ui/config/nm-segmented.d.ts +17 -0
- package/dist/ui/config/nm-side-panel.d.ts +33 -0
- package/dist/ui/config/nm-site-palette.d.ts +30 -0
- package/dist/ui/config/nm-small-icon-button.d.ts +12 -0
- package/dist/ui/config/nm-tabs.d.ts +8 -0
- package/dist/ui/config/nm-top-bar.d.ts +4 -0
- package/dist/ui/config/nordman-chrome.d.ts +12 -0
- package/dist/ui/config/nordman-login.d.ts +23 -0
- package/dist/ui/content/nm-modal.d.ts +1 -0
- package/dist/ui/content/nordman-login.d.ts +38 -0
- package/dist/ui/kit-logger.d.ts +1 -0
- package/dist/ui/lib/appearance/appearanceState.d.ts +28 -0
- package/dist/ui/lib/appearance/applyAppearance.d.ts +5 -0
- package/dist/ui/lib/appearance/cloudOrbAppearance.d.ts +4 -0
- package/dist/ui/lib/appearance/color.d.ts +13 -0
- package/dist/ui/lib/appearance/deriveTokens.d.ts +6 -0
- package/dist/ui/lib/appearance/index.d.ts +6 -0
- package/dist/ui/lib/appearance/markTokens.d.ts +2 -0
- package/dist/ui/lib/appearance/readLayoutMetrics.d.ts +4 -0
- package/dist/ui/lib/bar-overflow.d.ts +13 -0
- package/dist/ui/lib/logger.d.ts +8 -0
- package/dist/ui/lib/menu-motion.d.ts +72 -0
- package/dist/ui/lib/nm-class.d.ts +2 -0
- package/dist/ui/lib/nordman-ui-locale.d.ts +9 -0
- package/interface/app-panel/code.svg +5 -0
- package/interface/app-panel/console.svg +5 -0
- package/interface/app-panel/copy.svg +5 -0
- package/interface/app-panel/ellipsis.svg +7 -0
- package/interface/app-panel/message.svg +5 -0
- package/interface/app-panel/network.svg +10 -0
- package/interface/app-panel/play.svg +5 -0
- package/interface/app-panel/plus.svg +5 -0
- package/interface/chatbox/app.svg +5 -0
- package/interface/chatbox/audio-lines.svg +5 -0
- package/interface/chatbox/check.svg +5 -0
- package/interface/chatbox/globe.svg +5 -0
- package/interface/chatbox/integration.svg +5 -0
- package/interface/chatbox/mic.svg +5 -0
- package/interface/chatbox/paperclip.svg +5 -0
- package/interface/chatbox/pointer.svg +5 -0
- package/interface/chatbox/send.svg +5 -0
- package/interface/chatbox/settings.svg +5 -0
- package/interface/chatbox/spreadsheet.svg +5 -0
- package/interface/chatbox/x.svg +5 -0
- package/interface/collection/audio.svg +5 -0
- package/interface/collection/download.svg +5 -0
- package/interface/collection/expand.svg +5 -0
- package/interface/collection/grid.svg +10 -0
- package/interface/collection/image.svg +5 -0
- package/interface/collection/spreadsheet.svg +5 -0
- package/interface/collection/video.svg +5 -0
- package/interface/header/app.svg +5 -0
- package/interface/header/bot.svg +5 -0
- package/interface/header/chat.svg +10 -0
- package/interface/header/folder.svg +5 -0
- package/interface/header/layers.svg +10 -0
- package/interface/header/panel.svg +5 -0
- package/interface/header/play.svg +3 -0
- package/interface/header/schedule.svg +8 -0
- package/interface/header/search.svg +5 -0
- package/interface/header/settings.svg +5 -0
- package/interface/header/users.svg +5 -0
- package/interface/message/chevron.svg +5 -0
- package/interface/message/copy.svg +5 -0
- package/interface/message/fork.svg +5 -0
- package/interface/message/refresh.svg +5 -0
- package/interface/message/volume.svg +5 -0
- package/interface/rail/app.svg +5 -0
- package/interface/rail/bot.svg +5 -0
- package/interface/rail/chats.svg +5 -0
- package/interface/rail/folder.svg +5 -0
- package/interface/rail/library.svg +5 -0
- package/interface/rail/plus-sm.svg +5 -0
- package/interface/rail/plus.svg +5 -0
- package/interface/rail/search.svg +5 -0
- package/interface/rail/settings.svg +8 -0
- package/interface/rail/spreadsheet.svg +5 -0
- package/package.json +79 -4
- package/registry/index.json +1634 -0
- package/registry/tokens.css +72 -0
- package/registry/ui/components/nm-ai/nm-ai.css +358 -0
- package/registry/ui/components/nm-ai/nm-ai.tsx +632 -0
- package/registry/ui/components/nm-app-panel/nm-app-panel.css +169 -0
- package/registry/ui/components/nm-ask/nm-ask.css +277 -0
- package/registry/ui/components/nm-avatar/nm-avatar.css +85 -0
- package/registry/ui/components/nm-avatar/nm-avatar.tsx +30 -0
- package/registry/ui/components/nm-bar-overflow/nm-bar-overflow.css +43 -0
- package/registry/ui/components/nm-bar-overflow/nm-bar-overflow.tsx +61 -0
- package/registry/ui/components/nm-bar-overflow/use-bar-overflow.ts +92 -0
- package/registry/ui/components/nm-brand-logo/nm-brand-logo.css +20 -0
- package/registry/ui/components/nm-brand-logo/nm-brand-logo.tsx +21 -0
- package/registry/ui/components/nm-breadcrumb/nm-breadcrumb.css +57 -0
- package/registry/ui/components/nm-breadcrumb/nm-breadcrumb.tsx +42 -0
- package/registry/ui/components/nm-button/nm-button.css +110 -0
- package/registry/ui/components/nm-button/nm-button.tsx +58 -0
- package/registry/ui/components/nm-button-group/nm-button-group.css +87 -0
- package/registry/ui/components/nm-button-group/nm-button-group.tsx +32 -0
- package/registry/ui/components/nm-calendar/nm-calendar.css +178 -0
- package/registry/ui/components/nm-calendar/nm-calendar.tsx +43 -0
- package/registry/ui/components/nm-card/nm-card.css +130 -0
- package/registry/ui/components/nm-card/nm-card.tsx +83 -0
- package/registry/ui/components/nm-chatbox/nm-chatbox-icon.tsx +39 -0
- package/registry/ui/components/nm-chatbox/nm-chatbox.css +682 -0
- package/registry/ui/components/nm-chatbox/nm-chatbox.tsx +101 -0
- package/registry/ui/components/nm-checkbox/nm-checkbox.css +61 -0
- package/registry/ui/components/nm-checkbox/nm-checkbox.tsx +14 -0
- package/registry/ui/components/nm-chip/nm-chip.css +112 -0
- package/registry/ui/components/nm-chip/nm-chip.tsx +86 -0
- package/registry/ui/components/nm-code-block/nm-code-block.css +240 -0
- package/registry/ui/components/nm-code-block/nm-code-block.tsx +196 -0
- package/registry/ui/components/nm-collection/nm-collection-bar.tsx +65 -0
- package/registry/ui/components/nm-collection/nm-collection-grid.tsx +69 -0
- package/registry/ui/components/nm-collection/nm-collection-query.tsx +99 -0
- package/registry/ui/components/nm-collection/nm-collection-row-menu.tsx +55 -0
- package/registry/ui/components/nm-collection/nm-collection-table.tsx +99 -0
- package/registry/ui/components/nm-collection/nm-collection-tile-actions.tsx +50 -0
- package/registry/ui/components/nm-collection/nm-collection-title.tsx +25 -0
- package/registry/ui/components/nm-collection/nm-collection.css +353 -0
- package/registry/ui/components/nm-collection/use-collection-scroll-reveal.ts +38 -0
- package/registry/ui/components/nm-color-picker/nm-color-picker.css +67 -0
- package/registry/ui/components/nm-color-picker/nm-color-picker.tsx +79 -0
- package/registry/ui/components/nm-combobox/nm-combobox.css +72 -0
- package/registry/ui/components/nm-combobox/nm-combobox.tsx +80 -0
- package/registry/ui/components/nm-command/nm-command.css +190 -0
- package/registry/ui/components/nm-command/nm-command.tsx +125 -0
- package/registry/ui/components/nm-composer/nm-composer.css +178 -0
- package/registry/ui/components/nm-composer/nm-composer.tsx +151 -0
- package/registry/ui/components/nm-context-menu/nm-context-menu.tsx +25 -0
- package/registry/ui/components/nm-date-picker/nm-date-picker.css +140 -0
- package/registry/ui/components/nm-date-picker/nm-date-picker.tsx +153 -0
- package/registry/ui/components/nm-dialog/nm-dialog.css +84 -0
- package/registry/ui/components/nm-dialog/nm-dialog.tsx +40 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-item.ts +68 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-options.tsx +242 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-panel.tsx +171 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown-placement.ts +157 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown.css +312 -0
- package/registry/ui/components/nm-dropdown/nm-dropdown.tsx +412 -0
- package/registry/ui/components/nm-dropdown-menu/nm-dropdown-menu.css +145 -0
- package/registry/ui/components/nm-dropdown-menu/nm-dropdown-menu.tsx +118 -0
- package/registry/ui/components/nm-field/nm-field.css +356 -0
- package/registry/ui/components/nm-field/nm-field.tsx +355 -0
- package/registry/ui/components/nm-form-field/nm-form-field.css +103 -0
- package/registry/ui/components/nm-form-field/nm-form-field.tsx +71 -0
- package/registry/ui/components/nm-gallery/nm-gallery.css +66 -0
- package/registry/ui/components/nm-gallery/nm-gallery.tsx +31 -0
- package/registry/ui/components/nm-hover-card/nm-hover-card.css +26 -0
- package/registry/ui/components/nm-hover-card/nm-hover-card.tsx +28 -0
- package/registry/ui/components/nm-icon/nm-icon.css +6 -0
- package/registry/ui/components/nm-icon/nm-icon.tsx +69 -0
- package/registry/ui/components/nm-icon/nm-lucide.tsx +180 -0
- package/registry/ui/components/nm-icon-border/nm-icon-border.tsx +56 -0
- package/registry/ui/components/nm-input/nm-input.css +75 -0
- package/registry/ui/components/nm-input/nm-input.tsx +7 -0
- package/registry/ui/components/nm-input-group/nm-input-group.css +66 -0
- package/registry/ui/components/nm-input-group/nm-input-group.tsx +20 -0
- package/registry/ui/components/nm-label/nm-label.css +11 -0
- package/registry/ui/components/nm-label/nm-label.tsx +6 -0
- package/registry/ui/components/nm-list-item/nm-list-item.css +177 -0
- package/registry/ui/components/nm-list-item/nm-list-item.tsx +112 -0
- package/registry/ui/components/nm-menubar/nm-menubar.css +32 -0
- package/registry/ui/components/nm-menubar/nm-menubar.tsx +19 -0
- package/registry/ui/components/nm-message/nm-message-actions.tsx +24 -0
- package/registry/ui/components/nm-message/nm-message-meta.tsx +49 -0
- package/registry/ui/components/nm-message/nm-message.css +686 -0
- package/registry/ui/components/nm-message/nm-text-shimmer.tsx +6 -0
- package/registry/ui/components/nm-message/nm-trace.tsx +219 -0
- package/registry/ui/components/nm-modal/nm-modal.css +763 -0
- package/registry/ui/components/nm-modal/nm-modal.tsx +497 -0
- package/registry/ui/components/nm-native-select/nm-native-select.css +47 -0
- package/registry/ui/components/nm-native-select/nm-native-select.tsx +23 -0
- package/registry/ui/components/nm-panel/nm-panel.css +73 -0
- package/registry/ui/components/nm-panel/nm-panel.tsx +35 -0
- package/registry/ui/components/nm-panel-bar/nm-panel-bar.css +20 -0
- package/registry/ui/components/nm-panel-bar/nm-panel-bar.tsx +48 -0
- package/registry/ui/components/nm-popover/nm-popover.css +43 -0
- package/registry/ui/components/nm-popover/nm-popover.tsx +40 -0
- package/registry/ui/components/nm-progress/nm-progress.css +21 -0
- package/registry/ui/components/nm-progress/nm-progress.tsx +14 -0
- package/registry/ui/components/nm-prose/nm-prose.css +81 -0
- package/registry/ui/components/nm-prose/nm-prose.tsx +10 -0
- package/registry/ui/components/nm-questionnaire/nm-questionnaire.css +182 -0
- package/registry/ui/components/nm-questionnaire/nm-questionnaire.tsx +221 -0
- package/registry/ui/components/nm-radio-group/nm-radio-group.css +48 -0
- package/registry/ui/components/nm-radio-group/nm-radio-group.tsx +15 -0
- package/registry/ui/components/nm-rail-icon/nm-rail-icon.css +6 -0
- package/registry/ui/components/nm-rail-icon/nm-rail-icon.tsx +28 -0
- package/registry/ui/components/nm-resize-handle/nm-resize-handle.css +45 -0
- package/registry/ui/components/nm-resize-handle/nm-resize-handle.tsx +102 -0
- package/registry/ui/components/nm-segmented/nm-segmented.css +104 -0
- package/registry/ui/components/nm-segmented/nm-segmented.tsx +77 -0
- package/registry/ui/components/nm-select/nm-select.css +78 -0
- package/registry/ui/components/nm-select/nm-select.tsx +64 -0
- package/registry/ui/components/nm-separator/nm-separator.css +14 -0
- package/registry/ui/components/nm-separator/nm-separator.tsx +6 -0
- package/registry/ui/components/nm-side-panel/nm-side-panel.css +93 -0
- package/registry/ui/components/nm-side-panel/nm-side-panel.tsx +86 -0
- package/registry/ui/components/nm-slider/nm-slider.css +53 -0
- package/registry/ui/components/nm-slider/nm-slider.tsx +40 -0
- package/registry/ui/components/nm-small-icon-button/nm-small-icon-button.tsx +66 -0
- package/registry/ui/components/nm-status-bar/nm-status-bar.css +50 -0
- package/registry/ui/components/nm-status-bar/nm-status-bar.tsx +28 -0
- package/registry/ui/components/nm-switch/nm-switch.css +45 -0
- package/registry/ui/components/nm-switch/nm-switch.tsx +10 -0
- package/registry/ui/components/nm-table/nm-table.css +155 -0
- package/registry/ui/components/nm-table/nm-table.tsx +95 -0
- package/registry/ui/components/nm-tabs/nm-tabs.css +28 -0
- package/registry/ui/components/nm-tabs/nm-tabs.tsx +32 -0
- package/registry/ui/components/nm-textarea/nm-textarea.css +41 -0
- package/registry/ui/components/nm-textarea/nm-textarea.tsx +6 -0
- package/registry/ui/components/nm-toggle/nm-toggle.css +55 -0
- package/registry/ui/components/nm-toggle/nm-toggle.tsx +16 -0
- package/registry/ui/components/nm-toolbar/nm-toolbar.css +42 -0
- package/registry/ui/components/nm-toolbar/nm-toolbar.tsx +54 -0
- package/registry/ui/components/nm-tooltip/nm-tooltip.css +37 -0
- package/registry/ui/components/nm-tooltip/nm-tooltip.tsx +35 -0
- package/registry/ui/components/nm-top-bar/nm-top-bar.css +29 -0
- package/registry/ui/components/nm-top-bar/nm-top-bar.tsx +34 -0
- package/registry/ui/components/nordman-icon-button/nordman-icon-button.css +119 -0
- package/registry/ui/components/nordman-icon-button/nordman-icon-button.tsx +185 -0
- package/registry/ui/components/nordman-login/nordman-login.css +195 -0
- package/registry/ui/components/nordman-login/nordman-login.tsx +136 -0
- package/registry/ui/components/nordman-login-field/nordman-login-field.tsx +55 -0
- package/registry/ui/components/nordman-login-forgot/nordman-login-forgot.tsx +56 -0
- package/registry/ui/components/nordman-login-google/nordman-login-google.tsx +28 -0
- package/registry/ui/components/nordman-login-hero/nordman-login-hero.tsx +38 -0
- package/registry/ui/components/nordman-login-register/nordman-login-register.tsx +70 -0
- package/registry/ui/components/nordman-login-reset/nordman-login-reset.tsx +71 -0
- package/registry/ui/components/nordman-login-reveal/nordman-login-reveal.tsx +41 -0
- package/registry/ui/components/nordman-login-sign-in/nordman-login-sign-in.tsx +69 -0
- package/registry/ui/components/nordman-toggle/nordman-toggle.css +28 -0
- package/registry/ui/components/nordman-toggle/nordman-toggle.tsx +35 -0
- package/registry/ui/config/nm-ai.ts +59 -0
- package/registry/ui/config/nm-appearance.ts +275 -0
- package/registry/ui/config/nm-bar-overflow.ts +10 -0
- package/registry/ui/config/nm-button.ts +38 -0
- package/registry/ui/config/nm-chatbox-icons.ts +67 -0
- package/registry/ui/config/nm-chatbox.ts +42 -0
- package/registry/ui/config/nm-collection.ts +101 -0
- package/registry/ui/config/nm-composer.ts +39 -0
- package/registry/ui/config/nm-dropdown.ts +62 -0
- package/registry/ui/config/nm-field.ts +43 -0
- package/registry/ui/config/nm-icon-button.ts +35 -0
- package/registry/ui/config/nm-icons.ts +417 -0
- package/registry/ui/config/nm-list-item.ts +14 -0
- package/registry/ui/config/nm-message.ts +106 -0
- package/registry/ui/config/nm-modal.ts +76 -0
- package/registry/ui/config/nm-panel-bar.ts +11 -0
- package/registry/ui/config/nm-questionnaire.ts +53 -0
- package/registry/ui/config/nm-radius.ts +56 -0
- package/registry/ui/config/nm-rail-icons.ts +27 -0
- package/registry/ui/config/nm-segmented.ts +19 -0
- package/registry/ui/config/nm-side-panel.ts +16 -0
- package/registry/ui/config/nm-site-palette.ts +30 -0
- package/registry/ui/config/nm-small-icon-button.ts +17 -0
- package/registry/ui/config/nm-tabs.ts +9 -0
- package/registry/ui/config/nm-top-bar.ts +4 -0
- package/registry/ui/config/nordman-chrome.ts +14 -0
- package/registry/ui/config/nordman-login.ts +28 -0
- package/registry/ui/content/nm-modal.ts +5 -0
- package/registry/ui/content/nordman-login.ts +85 -0
- package/registry/ui/kit-logger.ts +1 -0
- package/registry/ui/lib/appearance/appearanceState.ts +240 -0
- package/registry/ui/lib/appearance/applyAppearance.ts +36 -0
- package/registry/ui/lib/appearance/cloudOrbAppearance.ts +36 -0
- package/registry/ui/lib/appearance/color.ts +96 -0
- package/registry/ui/lib/appearance/deriveTokens.ts +218 -0
- package/registry/ui/lib/appearance/index.ts +6 -0
- package/registry/ui/lib/appearance/markTokens.ts +49 -0
- package/registry/ui/lib/appearance/readLayoutMetrics.ts +28 -0
- package/registry/ui/lib/bar-overflow.ts +41 -0
- package/registry/ui/lib/logger.ts +53 -0
- package/registry/ui/lib/menu-motion.ts +187 -0
- package/registry/ui/lib/nm-class.ts +4 -0
- package/registry/ui/lib/nordman-ui-locale.ts +43 -0
- package/registry/ui/styles/interface-theme.css +196 -0
- package/registry/ui/styles/light-appearance.css +72 -0
- package/registry/ui/styles/tokens.css +424 -0
- package/registry/ui/styles/utilities.css +12 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { useRef, type ReactNode } from 'react';
|
|
2
|
+
import { isNmDropdownSeparator, type NmDropdownItem } from './nm-dropdown-item';
|
|
3
|
+
import { NM_DROPDOWN_CLASSES } from '../../config/nm-dropdown.ts';
|
|
4
|
+
import { NmDropdownBranch } from './nm-dropdown-panel';
|
|
5
|
+
import { NmIcon } from '../nm-icon/nm-icon.tsx';
|
|
6
|
+
|
|
7
|
+
export function findDropdownItem(
|
|
8
|
+
items: readonly NmDropdownItem[],
|
|
9
|
+
selected?: string | null,
|
|
10
|
+
): NmDropdownItem | undefined {
|
|
11
|
+
for (const item of items) {
|
|
12
|
+
if (isNmDropdownSeparator(item)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (item.id === selected) {
|
|
16
|
+
return item;
|
|
17
|
+
}
|
|
18
|
+
const child = item.children?.find((entry) => entry.id === selected);
|
|
19
|
+
if (child) {
|
|
20
|
+
return child;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function itemClassName(item: NmDropdownItem, branched: boolean): string {
|
|
27
|
+
return [
|
|
28
|
+
NM_DROPDOWN_CLASSES.item,
|
|
29
|
+
branched ? NM_DROPDOWN_CLASSES.itemBranch : '',
|
|
30
|
+
item.danger ? NM_DROPDOWN_CLASSES.itemDanger : '',
|
|
31
|
+
item.disabled && item.mark == null ? NM_DROPDOWN_CLASSES.itemDisabled : '',
|
|
32
|
+
item.disabled && item.mark != null ? NM_DROPDOWN_CLASSES.itemQuiet : '',
|
|
33
|
+
]
|
|
34
|
+
.filter((value) => value !== '')
|
|
35
|
+
.join(' ');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function optionIcon(item: NmDropdownItem): ReactNode {
|
|
39
|
+
if (item.leading != null) {
|
|
40
|
+
return <span className={NM_DROPDOWN_CLASSES.icon}>{item.leading}</span>;
|
|
41
|
+
}
|
|
42
|
+
if (item.imageSrc) {
|
|
43
|
+
return (
|
|
44
|
+
<span className={NM_DROPDOWN_CLASSES.icon}>
|
|
45
|
+
<img src={item.imageSrc} alt="" />
|
|
46
|
+
</span>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (item.icon) {
|
|
50
|
+
return (
|
|
51
|
+
<span className={NM_DROPDOWN_CLASSES.icon}>
|
|
52
|
+
<NmIcon id={item.icon} />
|
|
53
|
+
</span>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function markTone(mark: NonNullable<NmDropdownItem['mark']>): string {
|
|
60
|
+
if (mark === 'busy') {
|
|
61
|
+
return NM_DROPDOWN_CLASSES.markBusy;
|
|
62
|
+
}
|
|
63
|
+
if (mark === 'live') {
|
|
64
|
+
return NM_DROPDOWN_CLASSES.markLive;
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function optionTrailing(item: NmDropdownItem): ReactNode {
|
|
70
|
+
const detail = item.detail != null && item.detail.length > 0;
|
|
71
|
+
const shortcut = item.shortcut != null && item.shortcut.length > 0;
|
|
72
|
+
if (!detail && !shortcut) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return (
|
|
76
|
+
<span className={NM_DROPDOWN_CLASSES.trailing}>
|
|
77
|
+
{detail ? <span className={NM_DROPDOWN_CLASSES.detail}>{item.detail}</span> : null}
|
|
78
|
+
{shortcut ? <span className={NM_DROPDOWN_CLASSES.shortcut}>{item.shortcut}</span> : null}
|
|
79
|
+
</span>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function optionMark(
|
|
84
|
+
item: NmDropdownItem,
|
|
85
|
+
branched: boolean,
|
|
86
|
+
active: boolean,
|
|
87
|
+
selectionMark: 'check' | 'none',
|
|
88
|
+
): ReactNode {
|
|
89
|
+
if (item.mark != null) {
|
|
90
|
+
const tone = markTone(item.mark);
|
|
91
|
+
return <span className={[NM_DROPDOWN_CLASSES.mark, tone].filter(Boolean).join(' ')} />;
|
|
92
|
+
}
|
|
93
|
+
if (branched) {
|
|
94
|
+
return <NmIcon id="chevron" className={NM_DROPDOWN_CLASSES.check} />;
|
|
95
|
+
}
|
|
96
|
+
if (selectionMark === 'check' && active) {
|
|
97
|
+
return <NmIcon id="check" className={NM_DROPDOWN_CLASSES.check} />;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function NmDropdownOption({
|
|
103
|
+
item,
|
|
104
|
+
selected,
|
|
105
|
+
focusedOptionId,
|
|
106
|
+
expandedIds,
|
|
107
|
+
onSelect,
|
|
108
|
+
onOpenBranch,
|
|
109
|
+
onCloseBranches,
|
|
110
|
+
selectionMark = 'check',
|
|
111
|
+
}: {
|
|
112
|
+
item: NmDropdownItem;
|
|
113
|
+
selected?: string | null;
|
|
114
|
+
/** Combobox keyboard highlight — scroll target only; does not set `aria-selected`. */
|
|
115
|
+
focusedOptionId?: string | null;
|
|
116
|
+
expandedIds?: readonly string[];
|
|
117
|
+
selectionMark?: 'check' | 'none';
|
|
118
|
+
onSelect: (id: string) => void;
|
|
119
|
+
onOpenBranch: (id: string) => void;
|
|
120
|
+
onCloseBranches: () => void;
|
|
121
|
+
}): ReactNode {
|
|
122
|
+
const anchorRef = useRef<HTMLLIElement>(null);
|
|
123
|
+
const children = item.children ?? [];
|
|
124
|
+
const branched = children.length > 0;
|
|
125
|
+
const expanded = expandedIds?.includes(item.id) === true;
|
|
126
|
+
const childActive = children.some((child) => child.id === selected);
|
|
127
|
+
const valueSelected = item.id === selected || childActive;
|
|
128
|
+
const comboboxFocus = focusedOptionId != null && item.id === focusedOptionId;
|
|
129
|
+
const ariaSelected =
|
|
130
|
+
focusedOptionId != null ? item.checked === true : valueSelected || item.checked === true;
|
|
131
|
+
const showCheck = valueSelected || item.checked === true;
|
|
132
|
+
return (
|
|
133
|
+
<li
|
|
134
|
+
ref={anchorRef}
|
|
135
|
+
className={branched ? NM_DROPDOWN_CLASSES.branch : undefined}
|
|
136
|
+
role="none"
|
|
137
|
+
onPointerEnter={(event) => {
|
|
138
|
+
if (item.disabled) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (branched) {
|
|
142
|
+
onOpenBranch(item.id);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const insideSubmenu =
|
|
146
|
+
event.currentTarget.closest(`.${NM_DROPDOWN_CLASSES.subpanel}`) != null;
|
|
147
|
+
if (!insideSubmenu) {
|
|
148
|
+
onCloseBranches();
|
|
149
|
+
}
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
<button
|
|
153
|
+
className={itemClassName(item, branched)}
|
|
154
|
+
type="button"
|
|
155
|
+
role={branched ? undefined : 'option'}
|
|
156
|
+
aria-selected={branched ? undefined : ariaSelected}
|
|
157
|
+
data-combobox-focus={comboboxFocus ? 'true' : undefined}
|
|
158
|
+
aria-disabled={item.disabled ? true : undefined}
|
|
159
|
+
aria-haspopup={branched ? 'listbox' : undefined}
|
|
160
|
+
aria-expanded={branched ? expanded : undefined}
|
|
161
|
+
disabled={item.disabled}
|
|
162
|
+
onClick={() => {
|
|
163
|
+
if (item.disabled) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (branched) {
|
|
167
|
+
onOpenBranch(item.id);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
onSelect(item.id);
|
|
171
|
+
}}
|
|
172
|
+
>
|
|
173
|
+
{optionIcon(item)}
|
|
174
|
+
<span className={NM_DROPDOWN_CLASSES.copy}>
|
|
175
|
+
<span className={NM_DROPDOWN_CLASSES.label}>{item.label}</span>
|
|
176
|
+
{optionTrailing(item)}
|
|
177
|
+
</span>
|
|
178
|
+
{optionMark(item, branched, showCheck, selectionMark)}
|
|
179
|
+
</button>
|
|
180
|
+
<NmDropdownBranch open={branched && expanded} label={item.label} anchorRef={anchorRef}>
|
|
181
|
+
<NmDropdownOptions
|
|
182
|
+
items={children}
|
|
183
|
+
selected={selected}
|
|
184
|
+
expandedIds={expandedIds}
|
|
185
|
+
selectionMark={selectionMark}
|
|
186
|
+
onSelect={onSelect}
|
|
187
|
+
onOpenBranch={onOpenBranch}
|
|
188
|
+
onCloseBranches={onCloseBranches}
|
|
189
|
+
/>
|
|
190
|
+
</NmDropdownBranch>
|
|
191
|
+
</li>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function NmDropdownOptions({
|
|
196
|
+
items,
|
|
197
|
+
selected,
|
|
198
|
+
focusedOptionId,
|
|
199
|
+
expandedIds,
|
|
200
|
+
selectionMark = 'check',
|
|
201
|
+
onSelect,
|
|
202
|
+
onOpenBranch,
|
|
203
|
+
onCloseBranches,
|
|
204
|
+
}: {
|
|
205
|
+
items: readonly NmDropdownItem[];
|
|
206
|
+
selected?: string | null;
|
|
207
|
+
focusedOptionId?: string | null;
|
|
208
|
+
expandedIds?: readonly string[];
|
|
209
|
+
selectionMark?: 'check' | 'none';
|
|
210
|
+
onSelect: (id: string) => void;
|
|
211
|
+
onOpenBranch: (id: string) => void;
|
|
212
|
+
onCloseBranches: () => void;
|
|
213
|
+
}) {
|
|
214
|
+
return (
|
|
215
|
+
<>
|
|
216
|
+
{items.map((item, index) => {
|
|
217
|
+
if (isNmDropdownSeparator(item)) {
|
|
218
|
+
return (
|
|
219
|
+
<li
|
|
220
|
+
key={`${item.id}-${index}`}
|
|
221
|
+
className={NM_DROPDOWN_CLASSES.separator}
|
|
222
|
+
role="separator"
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
return (
|
|
227
|
+
<NmDropdownOption
|
|
228
|
+
key={item.id}
|
|
229
|
+
item={item}
|
|
230
|
+
selected={selected}
|
|
231
|
+
focusedOptionId={focusedOptionId}
|
|
232
|
+
expandedIds={expandedIds}
|
|
233
|
+
selectionMark={selectionMark}
|
|
234
|
+
onSelect={onSelect}
|
|
235
|
+
onOpenBranch={onOpenBranch}
|
|
236
|
+
onCloseBranches={onCloseBranches}
|
|
237
|
+
/>
|
|
238
|
+
);
|
|
239
|
+
})}
|
|
240
|
+
</>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Fragment,
|
|
3
|
+
useEffect,
|
|
4
|
+
useRef,
|
|
5
|
+
useState,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
type Ref,
|
|
8
|
+
type RefObject,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import { createPortal } from 'react-dom';
|
|
11
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
12
|
+
import { useMenuMotion } from '../../lib/menu-motion.ts';
|
|
13
|
+
import type { NmDropdownPlacement } from './nm-dropdown-placement';
|
|
14
|
+
import { dropdownPortalHost, placeNmDropdownSubpanel } from './nm-dropdown-placement';
|
|
15
|
+
import { NM_DROPDOWN_CLASSES } from '../../config/nm-dropdown.ts';
|
|
16
|
+
import { createLogger } from '../../kit-logger.ts';
|
|
17
|
+
|
|
18
|
+
const logger = createLogger('interface-nm-dropdown');
|
|
19
|
+
|
|
20
|
+
export function NmDropdownPanel({
|
|
21
|
+
open,
|
|
22
|
+
placement,
|
|
23
|
+
className,
|
|
24
|
+
id,
|
|
25
|
+
label,
|
|
26
|
+
panelRef,
|
|
27
|
+
children,
|
|
28
|
+
}: {
|
|
29
|
+
open: boolean;
|
|
30
|
+
placement: string;
|
|
31
|
+
className: string;
|
|
32
|
+
id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
panelRef: Ref<HTMLUListElement>;
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}): ReactNode {
|
|
37
|
+
const motionProps = useMenuMotion(placement);
|
|
38
|
+
return (
|
|
39
|
+
<AnimatePresence>
|
|
40
|
+
{open ? (
|
|
41
|
+
<Fragment key={id}>
|
|
42
|
+
<motion.ul
|
|
43
|
+
className={className}
|
|
44
|
+
id={id}
|
|
45
|
+
ref={panelRef}
|
|
46
|
+
role="listbox"
|
|
47
|
+
aria-label={label}
|
|
48
|
+
initial={motionProps.variants.closed}
|
|
49
|
+
animate={motionProps.variants.open}
|
|
50
|
+
exit={motionProps.variants.closed}
|
|
51
|
+
style={motionProps.style}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</motion.ul>
|
|
55
|
+
</Fragment>
|
|
56
|
+
) : null}
|
|
57
|
+
</AnimatePresence>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function readSubpanelPlace(anchor: HTMLElement, submenu: HTMLElement): NmDropdownPlacement | null {
|
|
62
|
+
const menu = anchor.closest(`.${NM_DROPDOWN_CLASSES.panel}, .${NM_DROPDOWN_CLASSES.subpanel}`);
|
|
63
|
+
if (!(menu instanceof HTMLElement)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const row = anchor.getBoundingClientRect();
|
|
67
|
+
const panel = menu.getBoundingClientRect();
|
|
68
|
+
const size = submenu.getBoundingClientRect();
|
|
69
|
+
return placeNmDropdownSubpanel({
|
|
70
|
+
rowTop: row.top,
|
|
71
|
+
rowBottom: row.bottom,
|
|
72
|
+
panelLeft: panel.left,
|
|
73
|
+
panelRight: panel.left + menu.offsetWidth,
|
|
74
|
+
submenuWidth: size.width,
|
|
75
|
+
submenuHeight: size.height,
|
|
76
|
+
viewportWidth: window.innerWidth,
|
|
77
|
+
viewportHeight: window.innerHeight,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function useSubpanelPlace(
|
|
82
|
+
open: boolean,
|
|
83
|
+
anchorRef: RefObject<HTMLElement | null>,
|
|
84
|
+
measureRef: RefObject<HTMLElement | null>,
|
|
85
|
+
submenu: HTMLElement | null,
|
|
86
|
+
): NmDropdownPlacement | null {
|
|
87
|
+
const [frame, setFrame] = useState<NmDropdownPlacement | null>(null);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!open) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const anchor = anchorRef.current;
|
|
93
|
+
const submenuNode = submenu ?? measureRef.current;
|
|
94
|
+
if (anchor == null || submenuNode == null) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const place = () => {
|
|
98
|
+
const next = readSubpanelPlace(anchor, submenuNode);
|
|
99
|
+
if (next == null) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setFrame((current) =>
|
|
103
|
+
current?.top === next.top && current.left === next.left ? current : next,
|
|
104
|
+
);
|
|
105
|
+
logger.debug('place', 'subpanel', next);
|
|
106
|
+
};
|
|
107
|
+
place();
|
|
108
|
+
const settled = window.setTimeout(place, 300);
|
|
109
|
+
window.addEventListener('resize', place);
|
|
110
|
+
window.addEventListener('scroll', place, true);
|
|
111
|
+
return () => {
|
|
112
|
+
window.clearTimeout(settled);
|
|
113
|
+
window.removeEventListener('resize', place);
|
|
114
|
+
window.removeEventListener('scroll', place, true);
|
|
115
|
+
};
|
|
116
|
+
}, [open, anchorRef, measureRef, submenu]);
|
|
117
|
+
return frame;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function NmDropdownBranch({
|
|
121
|
+
open,
|
|
122
|
+
label,
|
|
123
|
+
anchorRef,
|
|
124
|
+
children,
|
|
125
|
+
}: {
|
|
126
|
+
open: boolean;
|
|
127
|
+
label?: string;
|
|
128
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
129
|
+
children: ReactNode;
|
|
130
|
+
}): ReactNode {
|
|
131
|
+
const measureRef = useRef<HTMLUListElement>(null);
|
|
132
|
+
const [submenu, setSubmenu] = useState<HTMLUListElement | null>(null);
|
|
133
|
+
const motionProps = useMenuMotion('right-start');
|
|
134
|
+
const frame = useSubpanelPlace(open, anchorRef, measureRef, submenu);
|
|
135
|
+
const reduced = motionProps.variants.closed.scale === 1;
|
|
136
|
+
const transition = reduced ? { duration: 0 } : motionProps.variants.open.transition;
|
|
137
|
+
const at = { top: frame?.top ?? 0, left: frame?.left ?? 0 };
|
|
138
|
+
const host = dropdownPortalHost(undefined, anchorRef.current);
|
|
139
|
+
return createPortal(
|
|
140
|
+
<>
|
|
141
|
+
{open && frame == null ? (
|
|
142
|
+
<ul ref={measureRef} className={NM_DROPDOWN_CLASSES.subpanel} aria-hidden="true">
|
|
143
|
+
{children}
|
|
144
|
+
</ul>
|
|
145
|
+
) : null}
|
|
146
|
+
<AnimatePresence>
|
|
147
|
+
{open && frame != null ? (
|
|
148
|
+
<Fragment key="submenu">
|
|
149
|
+
<motion.ul
|
|
150
|
+
ref={setSubmenu}
|
|
151
|
+
className={NM_DROPDOWN_CLASSES.subpanel}
|
|
152
|
+
role="listbox"
|
|
153
|
+
aria-label={label}
|
|
154
|
+
style={{
|
|
155
|
+
...motionProps.style,
|
|
156
|
+
maxHeight: frame.maxHeight != null ? `${frame.maxHeight}px` : undefined,
|
|
157
|
+
}}
|
|
158
|
+
initial={{ ...motionProps.variants.closed, ...at }}
|
|
159
|
+
animate={{ ...motionProps.variants.open, ...at }}
|
|
160
|
+
exit={{ ...motionProps.variants.closed, ...at }}
|
|
161
|
+
transition={transition}
|
|
162
|
+
>
|
|
163
|
+
{children}
|
|
164
|
+
</motion.ul>
|
|
165
|
+
</Fragment>
|
|
166
|
+
) : null}
|
|
167
|
+
</AnimatePresence>
|
|
168
|
+
</>,
|
|
169
|
+
host,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { NM_DROPDOWN_ALIGN, NM_DROPDOWN_GAP_PX } from '../../config/nm-dropdown.ts';
|
|
2
|
+
|
|
3
|
+
export type NmDropdownBox = {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type NmDropdownViewport = {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type NmDropdownPlacement = {
|
|
18
|
+
top: number;
|
|
19
|
+
left: number;
|
|
20
|
+
maxHeight?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Scroll cap for a panel anchored at `panelTop`; only needed when content exceeds this. */
|
|
24
|
+
export function nmDropdownViewportMaxHeight(input: {
|
|
25
|
+
trigger: Pick<NmDropdownBox, 'top' | 'bottom'>;
|
|
26
|
+
viewport: NmDropdownViewport;
|
|
27
|
+
panelTop: number;
|
|
28
|
+
gap?: number;
|
|
29
|
+
edgePadding?: number;
|
|
30
|
+
}): number {
|
|
31
|
+
const gap = input.gap ?? NM_DROPDOWN_GAP_PX;
|
|
32
|
+
const edge = input.edgePadding ?? gap;
|
|
33
|
+
const belowTop = input.trigger.bottom + gap;
|
|
34
|
+
const opensBelow = input.panelTop + 1 >= belowTop;
|
|
35
|
+
if (opensBelow) {
|
|
36
|
+
return Math.max(0, input.viewport.height - input.panelTop - edge);
|
|
37
|
+
}
|
|
38
|
+
return Math.max(0, input.trigger.top - gap - edge);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function placeNmDropdownPanel({
|
|
42
|
+
trigger,
|
|
43
|
+
panel,
|
|
44
|
+
viewport,
|
|
45
|
+
align,
|
|
46
|
+
gap = NM_DROPDOWN_GAP_PX,
|
|
47
|
+
}: {
|
|
48
|
+
trigger: NmDropdownBox;
|
|
49
|
+
panel: Pick<NmDropdownBox, 'width' | 'height'>;
|
|
50
|
+
viewport: NmDropdownViewport;
|
|
51
|
+
align: (typeof NM_DROPDOWN_ALIGN)[keyof typeof NM_DROPDOWN_ALIGN];
|
|
52
|
+
gap?: number;
|
|
53
|
+
}): NmDropdownPlacement {
|
|
54
|
+
const belowTop = trigger.bottom + gap;
|
|
55
|
+
const aboveTop = trigger.top - gap - panel.height;
|
|
56
|
+
const spaceBelow = viewport.height - belowTop;
|
|
57
|
+
const spaceAbove = trigger.top - gap;
|
|
58
|
+
const top =
|
|
59
|
+
spaceBelow >= panel.height || spaceBelow >= spaceAbove
|
|
60
|
+
? clamp(belowTop, 0, Math.max(0, viewport.height - panel.height))
|
|
61
|
+
: clamp(aboveTop, 0, Math.max(0, viewport.height - panel.height));
|
|
62
|
+
|
|
63
|
+
const startLeft = trigger.left;
|
|
64
|
+
const endLeft = trigger.right - panel.width;
|
|
65
|
+
const preferredLeft = align === NM_DROPDOWN_ALIGN.end ? endLeft : startLeft;
|
|
66
|
+
let flippedLeft = preferredLeft;
|
|
67
|
+
const overflows = preferredLeft < 0 || preferredLeft + panel.width > viewport.width;
|
|
68
|
+
if (overflows && preferredLeft < 0) {
|
|
69
|
+
flippedLeft = startLeft;
|
|
70
|
+
} else if (overflows) {
|
|
71
|
+
flippedLeft = endLeft;
|
|
72
|
+
}
|
|
73
|
+
const left = clamp(flippedLeft, 0, Math.max(0, viewport.width - panel.width));
|
|
74
|
+
|
|
75
|
+
return { top, left };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Opens below (or above) a history row; panel width matches the row pill. */
|
|
79
|
+
export function placeNmDropdownRowPanel({
|
|
80
|
+
row,
|
|
81
|
+
panel,
|
|
82
|
+
viewport,
|
|
83
|
+
gap = NM_DROPDOWN_GAP_PX,
|
|
84
|
+
}: {
|
|
85
|
+
row: NmDropdownBox;
|
|
86
|
+
panel: Pick<NmDropdownBox, 'height'>;
|
|
87
|
+
viewport: NmDropdownViewport;
|
|
88
|
+
gap?: number;
|
|
89
|
+
}): NmDropdownPlacement & { width: number } {
|
|
90
|
+
const belowTop = row.bottom + gap;
|
|
91
|
+
const aboveTop = row.top - gap - panel.height;
|
|
92
|
+
const spaceBelow = viewport.height - belowTop;
|
|
93
|
+
const spaceAbove = row.top - gap;
|
|
94
|
+
const top =
|
|
95
|
+
spaceBelow >= panel.height || spaceBelow >= spaceAbove
|
|
96
|
+
? clamp(belowTop, 0, Math.max(0, viewport.height - panel.height))
|
|
97
|
+
: clamp(aboveTop, 0, Math.max(0, viewport.height - panel.height));
|
|
98
|
+
|
|
99
|
+
const width = row.width;
|
|
100
|
+
const left = clamp(row.left, 0, Math.max(0, viewport.width - width));
|
|
101
|
+
|
|
102
|
+
return { top, left, width };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Places a submenu beside its parent menu, with the same gap as the trigger. */
|
|
106
|
+
export function placeNmDropdownSubpanel({
|
|
107
|
+
rowTop,
|
|
108
|
+
rowBottom,
|
|
109
|
+
panelLeft,
|
|
110
|
+
panelRight,
|
|
111
|
+
submenuWidth,
|
|
112
|
+
submenuHeight,
|
|
113
|
+
viewportWidth,
|
|
114
|
+
viewportHeight,
|
|
115
|
+
gap = NM_DROPDOWN_GAP_PX,
|
|
116
|
+
}: {
|
|
117
|
+
rowTop: number;
|
|
118
|
+
rowBottom: number;
|
|
119
|
+
panelLeft: number;
|
|
120
|
+
panelRight: number;
|
|
121
|
+
submenuWidth: number;
|
|
122
|
+
submenuHeight: number;
|
|
123
|
+
viewportWidth: number;
|
|
124
|
+
viewportHeight: number;
|
|
125
|
+
gap?: number;
|
|
126
|
+
}): NmDropdownPlacement {
|
|
127
|
+
const onRight = panelRight + gap;
|
|
128
|
+
const fitsRight = onRight + submenuWidth <= viewportWidth;
|
|
129
|
+
const left = fitsRight ? onRight : Math.max(0, panelLeft - gap - submenuWidth);
|
|
130
|
+
const spaceBelowRow = viewportHeight - rowBottom - gap;
|
|
131
|
+
const openUpward = spaceBelowRow < submenuHeight;
|
|
132
|
+
const top = openUpward
|
|
133
|
+
? clamp(rowBottom - submenuHeight, gap, Math.max(gap, viewportHeight - submenuHeight - gap))
|
|
134
|
+
: clamp(rowTop, gap, Math.max(gap, viewportHeight - submenuHeight - gap));
|
|
135
|
+
const maxHeight = openUpward
|
|
136
|
+
? Math.max(0, rowBottom - gap - gap)
|
|
137
|
+
: Math.max(0, viewportHeight - top - gap);
|
|
138
|
+
return { top, left, maxHeight };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function clamp(value: number, min: number, max: number): number {
|
|
142
|
+
return Math.min(max, Math.max(min, value));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function dropdownPortalHost(
|
|
146
|
+
explicit: HTMLElement | null | undefined,
|
|
147
|
+
trigger: HTMLElement | null,
|
|
148
|
+
): HTMLElement {
|
|
149
|
+
if (explicit != null) {
|
|
150
|
+
return explicit;
|
|
151
|
+
}
|
|
152
|
+
const fullscreen = document.fullscreenElement;
|
|
153
|
+
if (fullscreen instanceof HTMLElement && trigger != null && fullscreen.contains(trigger)) {
|
|
154
|
+
return fullscreen;
|
|
155
|
+
}
|
|
156
|
+
return document.body;
|
|
157
|
+
}
|