@mattermost/compass-ui 0.1.0-alpha.27 → 0.1.0-alpha.28
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/compass-ui.css +16 -0
- package/dist/components/admin-console-footer/AdminConsoleFooter.css +1 -1
- package/dist/components/admin-console-footer/AdminConsoleFooter.module.scss.cjs +1 -1
- package/dist/components/admin-console-footer/AdminConsoleFooter.module.scss.js +7 -7
- package/dist/components/admin-console-header/AdminConsoleHeader.css +1 -1
- package/dist/components/admin-console-header/AdminConsoleHeader.module.scss.cjs +1 -1
- package/dist/components/admin-console-header/AdminConsoleHeader.module.scss.js +8 -8
- package/dist/components/admin-panel/AdminPanel.css +1 -1
- package/dist/components/admin-panel/AdminPanel.module.scss.cjs +1 -1
- package/dist/components/admin-panel/AdminPanel.module.scss.js +5 -5
- package/dist/components/admin-panel-footer/AdminPanelFooter.css +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.module.scss.cjs +1 -1
- package/dist/components/admin-panel-footer/AdminPanelFooter.module.scss.js +5 -5
- package/dist/components/admin-panel-header/AdminPanelHeader.cjs +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.cjs.map +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.css +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.d.ts +6 -0
- package/dist/components/admin-panel-header/AdminPanelHeader.d.ts.map +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.js +145 -109
- package/dist/components/admin-panel-header/AdminPanelHeader.js.map +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.module.scss.cjs +1 -1
- package/dist/components/admin-panel-header/AdminPanelHeader.module.scss.js +11 -10
- package/dist/components/admin-panel-header/AdminPanelHeader.module.scss.js.map +1 -1
- package/dist/components/attachment-card/AttachmentCard.css +1 -1
- package/dist/components/attachment-card/AttachmentCard.module.scss.cjs +1 -1
- package/dist/components/attachment-card/AttachmentCard.module.scss.js +22 -19
- package/dist/components/attachment-card/AttachmentCard.module.scss.js.map +1 -1
- package/dist/components/button/Button.css +1 -1
- package/dist/components/button/Button.module.scss.cjs +1 -1
- package/dist/components/button/Button.module.scss.js +20 -19
- package/dist/components/button/Button.module.scss.js.map +1 -1
- package/dist/components/card-button/CardButton.css +1 -1
- package/dist/components/card-button/CardButton.module.scss.cjs +1 -1
- package/dist/components/card-button/CardButton.module.scss.js +7 -7
- package/dist/components/card-button/CardButtonGroup.css +1 -1
- package/dist/components/card-button/CardButtonGroup.module.scss.cjs +1 -1
- package/dist/components/card-button/CardButtonGroup.module.scss.js +1 -1
- package/dist/components/channel-info-msg-header/ChannelInfoMsgHeader.css +1 -1
- package/dist/components/channel-info-msg-header/ChannelInfoMsgHeader.module.scss.cjs +1 -1
- package/dist/components/channel-info-msg-header/ChannelInfoMsgHeader.module.scss.js +8 -8
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.cjs +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.cjs.map +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.css +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.d.ts +66 -7
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.d.ts.map +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.js +163 -93
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.js.map +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.module.scss.cjs +1 -1
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.module.scss.js +35 -22
- package/dist/components/channel-sidebar-item/ChannelSidebarItem.module.scss.js.map +1 -1
- package/dist/components/checkbox/Checkbox.css +1 -1
- package/dist/components/checkbox/Checkbox.module.scss.cjs +1 -1
- package/dist/components/checkbox/Checkbox.module.scss.js +7 -7
- package/dist/components/chip/Chip.cjs +1 -1
- package/dist/components/chip/Chip.cjs.map +1 -1
- package/dist/components/chip/Chip.css +1 -1
- package/dist/components/chip/Chip.d.ts.map +1 -1
- package/dist/components/chip/Chip.js +8 -8
- package/dist/components/chip/Chip.js.map +1 -1
- package/dist/components/chip/Chip.module.scss.cjs +1 -1
- package/dist/components/chip/Chip.module.scss.js +13 -10
- package/dist/components/chip/Chip.module.scss.js.map +1 -1
- package/dist/components/chip/ChipGroup.cjs +1 -1
- package/dist/components/chip/ChipGroup.cjs.map +1 -1
- package/dist/components/chip/ChipGroup.css +1 -1
- package/dist/components/chip/ChipGroup.d.ts +1 -1
- package/dist/components/chip/ChipGroup.d.ts.map +1 -1
- package/dist/components/chip/ChipGroup.js +30 -30
- package/dist/components/chip/ChipGroup.js.map +1 -1
- package/dist/components/chip/ChipGroup.module.scss.cjs +1 -1
- package/dist/components/chip/ChipGroup.module.scss.js +1 -1
- package/dist/components/combobox/Combobox.cjs +1 -1
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.css +1 -1
- package/dist/components/combobox/Combobox.d.ts +10 -0
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.js +269 -252
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/combobox/Combobox.module.scss.cjs +1 -1
- package/dist/components/combobox/Combobox.module.scss.js +34 -31
- package/dist/components/combobox/Combobox.module.scss.js.map +1 -1
- package/dist/components/date-range-picker/DateRangePicker.cjs +1 -1
- package/dist/components/date-range-picker/DateRangePicker.cjs.map +1 -1
- package/dist/components/date-range-picker/DateRangePicker.css +1 -1
- package/dist/components/date-range-picker/DateRangePicker.d.ts +14 -1
- package/dist/components/date-range-picker/DateRangePicker.d.ts.map +1 -1
- package/dist/components/date-range-picker/DateRangePicker.js +217 -195
- package/dist/components/date-range-picker/DateRangePicker.js.map +1 -1
- package/dist/components/date-range-picker/DateRangePicker.module.scss.cjs +1 -1
- package/dist/components/date-range-picker/DateRangePicker.module.scss.js +29 -26
- package/dist/components/date-range-picker/DateRangePicker.module.scss.js.map +1 -1
- package/dist/components/divider/Divider.css +1 -1
- package/dist/components/divider/Divider.module.scss.cjs +1 -1
- package/dist/components/divider/Divider.module.scss.js +1 -1
- package/dist/components/dropdown/Dropdown.css +1 -1
- package/dist/components/dropdown/Dropdown.module.scss.cjs +1 -1
- package/dist/components/dropdown/Dropdown.module.scss.js +23 -22
- package/dist/components/dropdown/Dropdown.module.scss.js.map +1 -1
- package/dist/components/emoji/Emoji.css +1 -1
- package/dist/components/emoji/Emoji.module.scss.cjs +1 -1
- package/dist/components/emoji/Emoji.module.scss.js +12 -12
- package/dist/components/emoji-button/EmojiButton.css +1 -1
- package/dist/components/emoji-button/EmojiButton.module.scss.cjs +1 -1
- package/dist/components/emoji-button/EmojiButton.module.scss.js +12 -9
- package/dist/components/emoji-button/EmojiButton.module.scss.js.map +1 -1
- package/dist/components/emoji-popover/EmojiPopover.css +1 -1
- package/dist/components/emoji-popover/EmojiPopover.module.scss.cjs +1 -1
- package/dist/components/emoji-popover/EmojiPopover.module.scss.js +21 -21
- package/dist/components/empty-state/EmptyState.css +1 -1
- package/dist/components/empty-state/EmptyState.module.scss.cjs +1 -1
- package/dist/components/empty-state/EmptyState.module.scss.js +7 -7
- package/dist/components/feature-discovery-panel/FeatureDiscoveryPanel.css +1 -1
- package/dist/components/feature-discovery-panel/FeatureDiscoveryPanel.module.scss.cjs +1 -1
- package/dist/components/feature-discovery-panel/FeatureDiscoveryPanel.module.scss.js +9 -9
- package/dist/components/field/FieldClearButton.css +1 -1
- package/dist/components/field/FieldClearButton.module.scss.cjs +1 -1
- package/dist/components/field/FieldClearButton.module.scss.js +3 -3
- package/dist/components/field-message/FieldMessage.css +1 -1
- package/dist/components/field-message/FieldMessage.module.scss.cjs +1 -1
- package/dist/components/field-message/FieldMessage.module.scss.js +7 -7
- package/dist/components/global-banner/GlobalBanner.css +1 -1
- package/dist/components/global-banner/GlobalBanner.module.scss.cjs +1 -1
- package/dist/components/global-banner/GlobalBanner.module.scss.js +10 -10
- package/dist/components/icon/Icon.css +1 -1
- package/dist/components/icon/Icon.module.scss.cjs +1 -1
- package/dist/components/icon/Icon.module.scss.js +13 -13
- package/dist/components/icon-button/IconButton.css +1 -1
- package/dist/components/icon-button/IconButton.module.scss.cjs +1 -1
- package/dist/components/icon-button/IconButton.module.scss.js +19 -16
- package/dist/components/icon-button/IconButton.module.scss.js.map +1 -1
- package/dist/components/illustration/Illustration.css +1 -1
- package/dist/components/illustration/Illustration.module.scss.cjs +1 -1
- package/dist/components/illustration/Illustration.module.scss.js +1 -1
- package/dist/components/image-preview/ImagePreview.css +1 -1
- package/dist/components/image-preview/ImagePreview.module.scss.cjs +1 -1
- package/dist/components/image-preview/ImagePreview.module.scss.js +15 -15
- package/dist/components/link-preview/LinkPreview.css +1 -1
- package/dist/components/link-preview/LinkPreview.module.scss.cjs +1 -1
- package/dist/components/link-preview/LinkPreview.module.scss.js +14 -14
- package/dist/components/mention-badge/MentionBadge.css +1 -1
- package/dist/components/mention-badge/MentionBadge.module.scss.cjs +1 -1
- package/dist/components/mention-badge/MentionBadge.module.scss.js +9 -9
- package/dist/components/menu-group-heading/MenuGroupHeading.css +1 -1
- package/dist/components/menu-group-heading/MenuGroupHeading.module.scss.cjs +1 -1
- package/dist/components/menu-group-heading/MenuGroupHeading.module.scss.js +2 -2
- package/dist/components/menu-item/MenuItem.css +1 -1
- package/dist/components/menu-item/MenuItem.module.scss.cjs +1 -1
- package/dist/components/menu-item/MenuItem.module.scss.js +18 -18
- package/dist/components/message-actions/MessageActions.css +1 -1
- package/dist/components/message-actions/MessageActions.module.scss.cjs +1 -1
- package/dist/components/message-actions/MessageActions.module.scss.js +2 -2
- package/dist/components/message-header/MessageHeader.css +1 -1
- package/dist/components/message-header/MessageHeader.module.scss.cjs +1 -1
- package/dist/components/message-header/MessageHeader.module.scss.js +3 -3
- package/dist/components/message-separator/MessageSeparator.css +1 -1
- package/dist/components/message-separator/MessageSeparator.module.scss.cjs +1 -1
- package/dist/components/message-separator/MessageSeparator.module.scss.js +11 -11
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.cjs.map +1 -1
- package/dist/components/modal/Modal.css +1 -1
- package/dist/components/modal/Modal.d.ts +11 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +38 -36
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/modal/Modal.module.scss.cjs +1 -1
- package/dist/components/modal/Modal.module.scss.js +11 -11
- package/dist/components/modal/ModalOverlay.css +1 -1
- package/dist/components/modal/ModalOverlay.module.scss.cjs +1 -1
- package/dist/components/modal/ModalOverlay.module.scss.js +5 -5
- package/dist/components/modal-footer/ModalFooter.css +1 -1
- package/dist/components/modal-footer/ModalFooter.module.scss.cjs +1 -1
- package/dist/components/modal-footer/ModalFooter.module.scss.js +11 -11
- package/dist/components/modal-header/ModalHeader.cjs +1 -1
- package/dist/components/modal-header/ModalHeader.cjs.map +1 -1
- package/dist/components/modal-header/ModalHeader.css +1 -1
- package/dist/components/modal-header/ModalHeader.d.ts +13 -3
- package/dist/components/modal-header/ModalHeader.d.ts.map +1 -1
- package/dist/components/modal-header/ModalHeader.js +61 -55
- package/dist/components/modal-header/ModalHeader.js.map +1 -1
- package/dist/components/modal-header/ModalHeader.module.scss.cjs +1 -1
- package/dist/components/modal-header/ModalHeader.module.scss.js +18 -16
- package/dist/components/modal-header/ModalHeader.module.scss.js.map +1 -1
- package/dist/components/more-unreads-banner/MoreUnreadsBanner.css +1 -1
- package/dist/components/more-unreads-banner/MoreUnreadsBanner.module.scss.cjs +1 -1
- package/dist/components/more-unreads-banner/MoreUnreadsBanner.module.scss.js +8 -5
- package/dist/components/more-unreads-banner/MoreUnreadsBanner.module.scss.js.map +1 -1
- package/dist/components/new-message-banner/NewMessageBanner.css +1 -1
- package/dist/components/new-message-banner/NewMessageBanner.module.scss.cjs +1 -1
- package/dist/components/new-message-banner/NewMessageBanner.module.scss.js +9 -9
- package/dist/components/pagination-dots/PaginationDots.css +1 -1
- package/dist/components/pagination-dots/PaginationDots.module.scss.cjs +1 -1
- package/dist/components/pagination-dots/PaginationDots.module.scss.js +10 -10
- package/dist/components/password-input/PasswordInput.css +1 -1
- package/dist/components/password-input/PasswordInput.module.scss.cjs +1 -1
- package/dist/components/password-input/PasswordInput.module.scss.js +15 -14
- package/dist/components/password-input/PasswordInput.module.scss.js.map +1 -1
- package/dist/components/permalink-preview/PermalinkPreview.css +1 -1
- package/dist/components/permalink-preview/PermalinkPreview.module.scss.cjs +1 -1
- package/dist/components/permalink-preview/PermalinkPreview.module.scss.js +13 -13
- package/dist/components/pinned-saved-indicators/PinnedSavedIndicators.css +1 -1
- package/dist/components/pinned-saved-indicators/PinnedSavedIndicators.module.scss.cjs +1 -1
- package/dist/components/pinned-saved-indicators/PinnedSavedIndicators.module.scss.js +7 -7
- package/dist/components/popover-menu/PopoverMenu.css +1 -1
- package/dist/components/popover-menu/PopoverMenu.module.scss.cjs +1 -1
- package/dist/components/popover-menu/PopoverMenu.module.scss.js +13 -13
- package/dist/components/popover-notice/PopoverNotice.css +1 -1
- package/dist/components/popover-notice/PopoverNotice.module.scss.cjs +1 -1
- package/dist/components/popover-notice/PopoverNotice.module.scss.js +14 -14
- package/dist/components/profile-popover/ProfilePopover.css +1 -1
- package/dist/components/profile-popover/ProfilePopover.module.scss.cjs +1 -1
- package/dist/components/profile-popover/ProfilePopover.module.scss.js +33 -33
- package/dist/components/progress-bar/ProgressBar.css +1 -1
- package/dist/components/progress-bar/ProgressBar.module.scss.cjs +1 -1
- package/dist/components/progress-bar/ProgressBar.module.scss.js +9 -9
- package/dist/components/radio/Radio.css +1 -1
- package/dist/components/radio/Radio.module.scss.cjs +1 -1
- package/dist/components/radio/Radio.module.scss.js +12 -12
- package/dist/components/reaction-button/ReactionButton.css +1 -1
- package/dist/components/reaction-button/ReactionButton.module.scss.cjs +1 -1
- package/dist/components/reaction-button/ReactionButton.module.scss.js +8 -8
- package/dist/components/reactions-row/ReactionsRow.css +1 -1
- package/dist/components/reactions-row/ReactionsRow.module.scss.cjs +1 -1
- package/dist/components/reactions-row/ReactionsRow.module.scss.js +8 -8
- package/dist/components/right-sidebar-header/RightSidebarHeader.cjs +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.cjs.map +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.css +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.d.ts.map +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.js +39 -36
- package/dist/components/right-sidebar-header/RightSidebarHeader.js.map +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.module.scss.cjs +1 -1
- package/dist/components/right-sidebar-header/RightSidebarHeader.module.scss.js +12 -13
- package/dist/components/right-sidebar-header/RightSidebarHeader.module.scss.js.map +1 -1
- package/dist/components/scrollbar/Scrollbar.css +1 -1
- package/dist/components/scrollbar/Scrollbar.module.scss.cjs +1 -1
- package/dist/components/scrollbar/Scrollbar.module.scss.js +5 -5
- package/dist/components/search-input/SearchInput.css +1 -1
- package/dist/components/search-input/SearchInput.module.scss.cjs +1 -1
- package/dist/components/search-input/SearchInput.module.scss.js +15 -15
- package/dist/components/search-tip-banner/SearchTipBanner.css +1 -1
- package/dist/components/search-tip-banner/SearchTipBanner.module.scss.cjs +1 -1
- package/dist/components/search-tip-banner/SearchTipBanner.module.scss.js +3 -3
- package/dist/components/section-notice/SectionNotice.css +1 -1
- package/dist/components/section-notice/SectionNotice.module.scss.cjs +1 -1
- package/dist/components/section-notice/SectionNotice.module.scss.js +12 -12
- package/dist/components/segmented-control/SegmentedControl.cjs +2 -0
- package/dist/components/segmented-control/SegmentedControl.cjs.map +1 -0
- package/dist/components/segmented-control/SegmentedControl.css +1 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts +71 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts.map +1 -0
- package/dist/components/segmented-control/SegmentedControl.js +173 -0
- package/dist/components/segmented-control/SegmentedControl.js.map +1 -0
- package/dist/components/segmented-control/SegmentedControl.module.scss.cjs +2 -0
- package/dist/components/segmented-control/SegmentedControl.module.scss.cjs.map +1 -0
- package/dist/components/segmented-control/SegmentedControl.module.scss.js +20 -0
- package/dist/components/segmented-control/SegmentedControl.module.scss.js.map +1 -0
- package/dist/components/segmented-control/index.cjs +2 -0
- package/dist/components/segmented-control/index.cjs.map +1 -0
- package/dist/components/segmented-control/index.d.ts +3 -0
- package/dist/components/segmented-control/index.d.ts.map +1 -0
- package/dist/components/segmented-control/index.js +5 -0
- package/dist/components/segmented-control/index.js.map +1 -0
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.cjs.map +1 -1
- package/dist/components/select/Select.css +1 -1
- package/dist/components/select/Select.d.ts +14 -0
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/select/Select.js +151 -130
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/select/Select.module.scss.cjs +1 -1
- package/dist/components/select/Select.module.scss.js +28 -26
- package/dist/components/select/Select.module.scss.js.map +1 -1
- package/dist/components/shortcut-tag/ShortcutTag.css +1 -1
- package/dist/components/shortcut-tag/ShortcutTag.module.scss.cjs +1 -1
- package/dist/components/shortcut-tag/ShortcutTag.module.scss.js +7 -7
- package/dist/components/spinner/Spinner.css +1 -1
- package/dist/components/spinner/Spinner.module.scss.cjs +1 -1
- package/dist/components/spinner/Spinner.module.scss.js +2 -2
- package/dist/components/status-badge/StatusBadge.cjs +1 -1
- package/dist/components/status-badge/StatusBadge.cjs.map +1 -1
- package/dist/components/status-badge/StatusBadge.css +1 -1
- package/dist/components/status-badge/StatusBadge.d.ts +3 -1
- package/dist/components/status-badge/StatusBadge.d.ts.map +1 -1
- package/dist/components/status-badge/StatusBadge.js +16 -15
- package/dist/components/status-badge/StatusBadge.js.map +1 -1
- package/dist/components/status-badge/StatusBadge.module.scss.cjs +1 -1
- package/dist/components/status-badge/StatusBadge.module.scss.js +11 -11
- package/dist/components/switch/Switch.css +1 -1
- package/dist/components/switch/Switch.module.scss.cjs +1 -1
- package/dist/components/switch/Switch.module.scss.js +8 -8
- package/dist/components/tabs/Tabs.css +1 -1
- package/dist/components/tabs/Tabs.module.scss.cjs +1 -1
- package/dist/components/tabs/Tabs.module.scss.js +16 -13
- package/dist/components/tabs/Tabs.module.scss.js.map +1 -1
- package/dist/components/tag/Tag.css +1 -1
- package/dist/components/tag/Tag.module.scss.cjs +1 -1
- package/dist/components/tag/Tag.module.scss.js +11 -11
- package/dist/components/team-avatar/TeamAvatar.css +1 -1
- package/dist/components/team-avatar/TeamAvatar.module.scss.cjs +1 -1
- package/dist/components/team-avatar/TeamAvatar.module.scss.js +17 -17
- package/dist/components/text-area/TextArea.css +1 -1
- package/dist/components/text-area/TextArea.module.scss.cjs +1 -1
- package/dist/components/text-area/TextArea.module.scss.js +12 -12
- package/dist/components/text-input/TextInput.css +1 -1
- package/dist/components/text-input/TextInput.module.scss.cjs +1 -1
- package/dist/components/text-input/TextInput.module.scss.js +19 -19
- package/dist/components/thread-footer/ThreadFooter.cjs +1 -1
- package/dist/components/thread-footer/ThreadFooter.cjs.map +1 -1
- package/dist/components/thread-footer/ThreadFooter.css +1 -1
- package/dist/components/thread-footer/ThreadFooter.d.ts.map +1 -1
- package/dist/components/thread-footer/ThreadFooter.js +14 -14
- package/dist/components/thread-footer/ThreadFooter.js.map +1 -1
- package/dist/components/thread-footer/ThreadFooter.module.scss.cjs +1 -1
- package/dist/components/thread-footer/ThreadFooter.module.scss.js +19 -20
- package/dist/components/thread-footer/ThreadFooter.module.scss.js.map +1 -1
- package/dist/components/thread-list-item/ThreadListItem.css +1 -1
- package/dist/components/thread-list-item/ThreadListItem.module.scss.cjs +1 -1
- package/dist/components/thread-list-item/ThreadListItem.module.scss.js +26 -26
- package/dist/components/tile-button/TileButton.css +1 -1
- package/dist/components/tile-button/TileButton.module.scss.cjs +1 -1
- package/dist/components/tile-button/TileButton.module.scss.js +6 -6
- package/dist/components/toast/Toast.css +1 -1
- package/dist/components/toast/Toast.module.scss.cjs +1 -1
- package/dist/components/toast/Toast.module.scss.js +11 -11
- package/dist/components/tooltip/Tooltip.cjs +1 -1
- package/dist/components/tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/tooltip/Tooltip.css +1 -1
- package/dist/components/tooltip/Tooltip.d.ts +10 -1
- package/dist/components/tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/tooltip/Tooltip.js +29 -17
- package/dist/components/tooltip/Tooltip.js.map +1 -1
- package/dist/components/tooltip/Tooltip.module.scss.cjs +1 -1
- package/dist/components/tooltip/Tooltip.module.scss.js +7 -6
- package/dist/components/tooltip/Tooltip.module.scss.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/index.d.ts.map +1 -1
- package/dist/components/tour-point/TourPoint.css +1 -1
- package/dist/components/tour-point/TourPoint.module.scss.cjs +1 -1
- package/dist/components/tour-point/TourPoint.module.scss.js +28 -28
- package/dist/components/unread-badge/UnreadBadge.css +1 -1
- package/dist/components/unread-badge/UnreadBadge.module.scss.cjs +1 -1
- package/dist/components/unread-badge/UnreadBadge.module.scss.js +5 -5
- package/dist/components/user-avatar/UserAvatar.cjs +1 -1
- package/dist/components/user-avatar/UserAvatar.cjs.map +1 -1
- package/dist/components/user-avatar/UserAvatar.css +1 -1
- package/dist/components/user-avatar/UserAvatar.d.ts +18 -8
- package/dist/components/user-avatar/UserAvatar.d.ts.map +1 -1
- package/dist/components/user-avatar/UserAvatar.js +84 -52
- package/dist/components/user-avatar/UserAvatar.js.map +1 -1
- package/dist/components/user-avatar/UserAvatar.module.scss.cjs +1 -1
- package/dist/components/user-avatar/UserAvatar.module.scss.js +33 -26
- package/dist/components/user-avatar/UserAvatar.module.scss.js.map +1 -1
- package/dist/components/user-avatar-group/UserAvatarGroup.css +1 -1
- package/dist/components/user-avatar-group/UserAvatarGroup.module.scss.cjs +1 -1
- package/dist/components/user-avatar-group/UserAvatarGroup.module.scss.js +14 -14
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -55
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./SearchInput.css');const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./SearchInput.css');const a={"search-input":"_search-input_1wqam_13","search-input__wrapper":"_search-input__wrapper_1wqam_19","search-input__input":"_search-input__input_1wqam_29","search-input__label":"_search-input__label_1wqam_39","search-input--label-floated":"_search-input--label-floated_1wqam_59","search-input__inner":"_search-input__inner_1wqam_66","search-input__leading-icon":"_search-input__leading-icon_1wqam_97","search-input__trailing-icon":"_search-input__trailing-icon_1wqam_97","search-input--size-small":"_search-input--size-small_1wqam_111","search-input--size-medium":"_search-input--size-medium_1wqam_127","search-input--size-large":"_search-input--size-large_1wqam_147","search-input--has-leading-icon":"_search-input--has-leading-icon_1wqam_168","search-input--invalid":"_search-input--invalid_1wqam_192"};exports.default=a;
|
|
2
2
|
//# sourceMappingURL=SearchInput.module.scss.cjs.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import './SearchInput.css';const
|
|
2
|
-
"search-input": "_search-
|
|
3
|
-
"search-input__wrapper": "_search-
|
|
4
|
-
"search-input__input": "_search-
|
|
5
|
-
"search-input__label": "_search-
|
|
6
|
-
"search-input--label-floated": "_search-input--label-
|
|
7
|
-
"search-input__inner": "_search-
|
|
8
|
-
"search-input__leading-icon": "_search-input__leading-
|
|
9
|
-
"search-input__trailing-icon": "_search-input__trailing-
|
|
10
|
-
"search-input--size-small": "_search-input--size-
|
|
11
|
-
"search-input--size-medium": "_search-input--size-
|
|
12
|
-
"search-input--size-large": "_search-input--size-
|
|
13
|
-
"search-input--has-leading-icon": "_search-input--has-leading-
|
|
14
|
-
"search-input--invalid": "_search-input--
|
|
1
|
+
import './SearchInput.css';const a = {
|
|
2
|
+
"search-input": "_search-input_1wqam_13",
|
|
3
|
+
"search-input__wrapper": "_search-input__wrapper_1wqam_19",
|
|
4
|
+
"search-input__input": "_search-input__input_1wqam_29",
|
|
5
|
+
"search-input__label": "_search-input__label_1wqam_39",
|
|
6
|
+
"search-input--label-floated": "_search-input--label-floated_1wqam_59",
|
|
7
|
+
"search-input__inner": "_search-input__inner_1wqam_66",
|
|
8
|
+
"search-input__leading-icon": "_search-input__leading-icon_1wqam_97",
|
|
9
|
+
"search-input__trailing-icon": "_search-input__trailing-icon_1wqam_97",
|
|
10
|
+
"search-input--size-small": "_search-input--size-small_1wqam_111",
|
|
11
|
+
"search-input--size-medium": "_search-input--size-medium_1wqam_127",
|
|
12
|
+
"search-input--size-large": "_search-input--size-large_1wqam_147",
|
|
13
|
+
"search-input--has-leading-icon": "_search-input--has-leading-icon_1wqam_168",
|
|
14
|
+
"search-input--invalid": "_search-input--invalid_1wqam_192"
|
|
15
15
|
};
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
a as default
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=SearchInput.module.scss.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
._search-tip-
|
|
1
|
+
._search-tip-banner_1yblp_13{display:inline-flex;align-items:center;justify-content:flex-start;width:fit-content;max-width:100%;gap:var(--spacing-l);padding:var(--spacing-xxxs) var(--spacing-xxxs) var(--spacing-xxxs) var(--spacing-m);background-color:var(--center-channel-bg);border:1px solid rgba(var(--center-channel-color-rgb),.16);border-radius:var(--radius-s);box-shadow:var(--elevation-2)}._search-tip-banner__content_1yblp_26{display:inline-flex;align-items:center;gap:var(--spacing-s);height:24px;overflow:hidden}._search-tip-banner__text_1yblp_33{font-size:var(--font-size-100);font-weight:var(--font-weight-semibold);line-height:var(--line-height-100);color:var(--center-channel-color);white-space:nowrap}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./SearchTipBanner.css');const e={"search-tip-banner":"_search-tip-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./SearchTipBanner.css');const e={"search-tip-banner":"_search-tip-banner_1yblp_13","search-tip-banner__content":"_search-tip-banner__content_1yblp_26","search-tip-banner__text":"_search-tip-banner__text_1yblp_33"};exports.default=e;
|
|
2
2
|
//# sourceMappingURL=SearchTipBanner.module.scss.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './SearchTipBanner.css';const e = {
|
|
2
|
-
"search-tip-banner": "_search-tip-
|
|
3
|
-
"search-tip-banner__content": "_search-tip-
|
|
4
|
-
"search-tip-banner__text": "_search-tip-
|
|
2
|
+
"search-tip-banner": "_search-tip-banner_1yblp_13",
|
|
3
|
+
"search-tip-banner__content": "_search-tip-banner__content_1yblp_26",
|
|
4
|
+
"search-tip-banner__text": "_search-tip-banner__text_1yblp_33"
|
|
5
5
|
};
|
|
6
6
|
export {
|
|
7
7
|
e as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
._section-
|
|
1
|
+
._section-notice_kwgux_13{display:flex;flex-direction:column;align-items:flex-end;position:relative;border-radius:var(--radius-s);border:1px solid rgba(var(--color-info-rgb),.16);background-color:rgba(var(--color-info-rgb),.04)}._section-notice__content_kwgux_22{display:flex;align-items:flex-start;gap:var(--spacing-m);padding:var(--spacing-m);width:100%}._section-notice__icon_kwgux_29{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;color:var(--color-info)}._section-notice__body_kwgux_36{display:flex;flex:1 0 0;flex-direction:column;gap:var(--spacing-xs);min-width:0;overflow:hidden;padding-right:var(--spacing-xl)}._section-notice__title_kwgux_45._section-notice__title_kwgux_45{margin:0;font-weight:var(--font-weight-semibold)}._section-notice__title_kwgux_45{padding:0;font-family:var(--font-family-body);font-size:var(--font-size-100);line-height:var(--line-height-100);letter-spacing:var(--letter-spacing-normal);text-transform:none;color:var(--center-channel-color)}._section-notice__description_kwgux_58{font-size:var(--font-size-100);font-weight:var(--font-weight-regular);line-height:var(--line-height-100);color:var(--center-channel-color)}._section-notice__actions_kwgux_64{display:flex;align-items:center;gap:var(--spacing-s);padding:var(--spacing-xxs) 0}._section-notice__dismiss_kwgux_70{position:absolute;top:var(--spacing-xxs);right:var(--spacing-xxs)}._section-notice--type-warning_kwgux_75{background-color:rgba(var(--color-warning-rgb),.04);border-color:rgba(var(--color-warning-rgb),.16)}._section-notice--type-warning_kwgux_75 ._section-notice__icon_kwgux_29{color:var(--color-warning)}._section-notice--type-danger_kwgux_82{background-color:rgba(var(--error-text-color-rgb, var(--color-danger-rgb)),.04);border-color:rgba(var(--error-text-color-rgb, var(--color-danger-rgb)),.16)}._section-notice--type-danger_kwgux_82 ._section-notice__icon_kwgux_29{color:var(--error-text, var(--color-danger))}._section-notice--type-success_kwgux_89{background-color:rgba(var(--color-success-rgb),.04);border-color:rgba(var(--color-success-rgb),.16)}._section-notice--type-success_kwgux_89 ._section-notice__icon_kwgux_29{color:var(--color-success)}._section-notice--type-hint_kwgux_96{background-color:rgba(var(--center-channel-color-rgb),.04);border-color:rgba(var(--center-channel-color-rgb),.16)}._section-notice--type-hint_kwgux_96 ._section-notice__icon_kwgux_29{color:rgba(var(--center-channel-color-rgb),.64)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./SectionNotice.css');const e={"section-notice":"_section-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./SectionNotice.css');const e={"section-notice":"_section-notice_kwgux_13","section-notice__content":"_section-notice__content_kwgux_22","section-notice__icon":"_section-notice__icon_kwgux_29","section-notice__body":"_section-notice__body_kwgux_36","section-notice__title":"_section-notice__title_kwgux_45","section-notice__description":"_section-notice__description_kwgux_58","section-notice__actions":"_section-notice__actions_kwgux_64","section-notice__dismiss":"_section-notice__dismiss_kwgux_70","section-notice--type-warning":"_section-notice--type-warning_kwgux_75","section-notice--type-danger":"_section-notice--type-danger_kwgux_82","section-notice--type-success":"_section-notice--type-success_kwgux_89","section-notice--type-hint":"_section-notice--type-hint_kwgux_96"};exports.default=e;
|
|
2
2
|
//# sourceMappingURL=SectionNotice.module.scss.cjs.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import './SectionNotice.css';const t = {
|
|
2
|
-
"section-notice": "_section-
|
|
3
|
-
"section-notice__content": "_section-
|
|
4
|
-
"section-notice__icon": "_section-
|
|
5
|
-
"section-notice__body": "_section-
|
|
6
|
-
"section-notice__title": "_section-
|
|
7
|
-
"section-notice__description": "_section-
|
|
8
|
-
"section-notice__actions": "_section-
|
|
9
|
-
"section-notice__dismiss": "_section-
|
|
10
|
-
"section-notice--type-warning": "_section-notice--type-
|
|
11
|
-
"section-notice--type-danger": "_section-notice--type-
|
|
12
|
-
"section-notice--type-success": "_section-notice--type-
|
|
13
|
-
"section-notice--type-hint": "_section-notice--type-
|
|
2
|
+
"section-notice": "_section-notice_kwgux_13",
|
|
3
|
+
"section-notice__content": "_section-notice__content_kwgux_22",
|
|
4
|
+
"section-notice__icon": "_section-notice__icon_kwgux_29",
|
|
5
|
+
"section-notice__body": "_section-notice__body_kwgux_36",
|
|
6
|
+
"section-notice__title": "_section-notice__title_kwgux_45",
|
|
7
|
+
"section-notice__description": "_section-notice__description_kwgux_58",
|
|
8
|
+
"section-notice__actions": "_section-notice__actions_kwgux_64",
|
|
9
|
+
"section-notice__dismiss": "_section-notice__dismiss_kwgux_70",
|
|
10
|
+
"section-notice--type-warning": "_section-notice--type-warning_kwgux_75",
|
|
11
|
+
"section-notice--type-danger": "_section-notice--type-danger_kwgux_82",
|
|
12
|
+
"section-notice--type-success": "_section-notice--type-success_kwgux_89",
|
|
13
|
+
"section-notice--type-hint": "_section-notice--type-hint_kwgux_96"
|
|
14
14
|
};
|
|
15
15
|
export {
|
|
16
16
|
t as default
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("react/jsx-runtime"),u=require("react"),$=require("../icon/Icon.cjs"),R=require("../../utils/props.cjs"),F=require("../../utils/string.cjs"),l=require("./SegmentedControl.module.scss.cjs"),V={small:"12",medium:"16"};function W(r,t,a){return r<0?t<0?a-1:0:(r+t+a)%a}function U(r,t,a){const k=a?"ArrowLeft":"ArrowRight",h=a?"ArrowRight":"ArrowLeft";return r===k||t&&r==="ArrowDown"?1:r===h||t&&r==="ArrowUp"?-1:0}function Z(r){return!r||r.offsetWidth===0?null:{x:r.offsetLeft,y:r.offsetTop,width:r.offsetWidth,height:r.offsetHeight}}function v(r,t){return r===t||r!=null&&t!=null&&r.x===t.x&&r.y===t.y&&r.width===t.width&&r.height===t.height}function B({options:r,value:t,onChange:a,role:k="tablist",size:h="small",className:N,onBlur:S,...I}){const P=u.useRef(null),b=u.useRef(new Map),[p,w]=u.useState(t),[g,C]=u.useState(null),[j,q]=u.useState(!1),f=k==="radiogroup",A=f?"radio":"tab",E=r.map(e=>e.key).join("\0");u.useLayoutEffect(()=>{const e=()=>{const i=Z(b.current.get(t));C(y=>v(y,i)?y:i)};e();const s=P.current;if(typeof ResizeObserver>"u"||!s)return;const n=new ResizeObserver(e);n.observe(s);for(const i of b.current.values())n.observe(i);return()=>n.disconnect()},[t,E,h]);const D=g!==null;u.useEffect(()=>{D&&q(!0)},[D]);const[M,O]=u.useState(t);M!==t&&(O(t),w(t));const z=V[h],d=r.filter(e=>!e.disabled).map(e=>e.key),L=d.includes(p)?p:d.includes(t)?t:d[0],K=(e,s)=>{var n;w(e),(n=b.current.get(e))==null||n.focus(),s&&a(e)},H=e=>{if(S==null||S(e),e.defaultPrevented||f)return;const s=e.currentTarget;queueMicrotask(()=>{if(!s.isConnected)return;const n=document.activeElement;if(n instanceof Node&&s.contains(n))return;const i=d.includes(t)?t:d[0];i&&w(i)})},T=(e,s)=>{if(e.altKey||e.ctrlKey||e.metaKey)return;const n=d.length;if(n===0)return;const i=d.indexOf(s),y=P.current!=null&&getComputedStyle(P.current).direction==="rtl",_=U(e.key,f,y);if(_!==0){e.preventDefault();const o=d[W(i,_,n)];K(o,f&&o!==s);return}if(e.key==="Home"||e.key==="End"){e.preventDefault();const o=e.key==="Home"?d[0]:d[n-1];K(o,f&&o!==s);return}(e.key==="Enter"||e.key===" ")&&i>=0&&(e.preventDefault(),w(s),s!==t&&a(s))};return x.jsxs("div",{...I,ref:P,role:k,"aria-orientation":"horizontal",onBlur:H,className:R.mergeClassNames(l.default["segmented-control"],l.default[`segmented-control--size-${F.toKebab(h)}`],N),children:[x.jsx("span",{className:R.mergeClassNames(l.default["segmented-control__indicator"],j&&l.default["segmented-control__indicator--ready"],!g&&l.default["segmented-control__indicator--unpositioned"]),style:g?{transform:`translate(${g.x}px, ${g.y}px)`,width:g.width,height:g.height}:void 0,"aria-hidden":!0}),r.map(e=>{var i,y,_;const s=e.key===t,n=e.disabled===!0;return u.createElement("button",{...e.buttonProps,key:e.key,ref:o=>{o?b.current.set(e.key,o):b.current.delete(e.key)},id:e.id??((i=e.buttonProps)==null?void 0:i.id),type:"button",role:A,tabIndex:L===e.key?0:-1,"aria-selected":f?void 0:s,"aria-checked":f?s:void 0,"aria-controls":!f&&e.panelId?e.panelId:void 0,"aria-disabled":n||void 0,disabled:void 0,title:e.title??((y=e.buttonProps)==null?void 0:y.title),className:R.mergeClassNames(l.default["segmented-control__segment"],s&&l.default["segmented-control__segment--active"],n&&l.default["segmented-control__segment--disabled"],(_=e.buttonProps)==null?void 0:_.className),onMouseDown:o=>{var c,m;(m=(c=e.buttonProps)==null?void 0:c.onMouseDown)==null||m.call(c,o),n&&o.preventDefault()},onClick:o=>{var c,m;(m=(c=e.buttonProps)==null?void 0:c.onClick)==null||m.call(c,o),!(o.defaultPrevented||n)&&(w(e.key),e.key!==t&&a(e.key))},onKeyDown:o=>{var c,m;(m=(c=e.buttonProps)==null?void 0:c.onKeyDown)==null||m.call(c,o),!o.defaultPrevented&&T(o,e.key)}},e.icon!=null&&x.jsx("span",{className:l.default["segmented-control__icon"],children:x.jsx($.IconSlotContext.Provider,{value:{size:z},children:e.icon})}),x.jsx("span",{className:l.default["segmented-control__label"],children:e.label}))})]})}exports.default=B;
|
|
2
|
+
//# sourceMappingURL=SegmentedControl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.cjs","sources":["../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type FocusEvent,\n type HTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport type { IconSize } from '@/components/icon/Icon';\nimport { IconSlotContext } from '@/components/icon/Icon';\nimport { mergeClassNames, type BuiltInButtonProps } from '@/utils/props';\nimport { toKebab } from '@/utils/string';\nimport styles from './SegmentedControl.module.scss';\n\n/** `tablist` switches views. `radiogroup` is a short exclusive form choice. */\nexport type SegmentedControlRole = 'tablist' | 'radiogroup';\n\n/**\n * `small` matches a small Button (12px label, 12px icon). `medium` matches a\n * medium Button (14px label, 16px icon).\n */\nexport type SegmentedControlSize = 'small' | 'medium';\n\nconst SIZE_ICON_MAP: Record<SegmentedControlSize, IconSize> = {\n small: '12',\n medium: '16',\n};\n\nexport interface SegmentedControlOption {\n /**\n * Stable id for this segment. Used as the React key and the `onChange`\n * argument, so it is a string rather than translated text.\n */\n key: string;\n /** Segment label. Accepts translated nodes (e.g. `<FormattedMessage/>`). */\n label: ReactNode;\n /**\n * Optional leading icon. Pass `<Icon glyph={<SomeIcon />} />`;\n * SegmentedControl provides the size via context (12px at `small`, 16px at\n * `medium`), matching Button. No `size` prop is needed on the Icon.\n */\n icon?: ReactNode;\n /** Optional id for this segment (pair with `panelId` for `aria-controls`). */\n id?: string;\n /**\n * Optional id of the host panel this segment controls. Applied as\n * `aria-controls` when `role` is `tablist`. The host owns the panel.\n */\n panelId?: string;\n /** When true, the segment can't be selected and arrow keys skip it. */\n disabled?: boolean;\n /** Native tooltip text, e.g. to explain why the segment is disabled. */\n title?: string;\n /**\n * Extra attributes for this segment's `<button>` (e.g. `data-testid`).\n * Segment semantics (`role`, `aria-selected` / `aria-checked`, `tabIndex`,\n * `type`) take precedence. `className` is merged. `onClick`, `onKeyDown`,\n * and `onMouseDown` run first; `preventDefault()` skips selection.\n */\n buttonProps?: BuiltInButtonProps;\n}\n\nexport interface SegmentedControlProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'role'\n> {\n /** Segments, in order. One is selected. */\n options: SegmentedControlOption[];\n /** Key of the selected segment. */\n value: string;\n /** Called with the segment key when the selection changes. */\n onChange: (key: string) => void;\n /**\n * Semantics. `tablist` (default) switches views: arrow keys move focus, and\n * Enter, Space, or a click selects. The host owns the panel. `radiogroup`\n * is a short exclusive form choice: arrow keys move the selection. Pass\n * `aria-label` or `aria-labelledby` so the group has a name.\n */\n role?: SegmentedControlRole;\n /**\n * Size of the label and leading icon, matching Button. `small` (default)\n * is 12px text with a 12px icon. `medium` is 14px text with a 16px icon.\n */\n size?: SegmentedControlSize;\n /** Optional CSS class name. */\n className?: string;\n}\n\nfunction stepIndex(index: number, delta: number, count: number) {\n if (index < 0) return delta < 0 ? count - 1 : 0;\n return (index + delta + count) % count;\n}\n\nfunction arrowDelta(key: string, isRadio: boolean, isRtl: boolean) {\n const forward = isRtl ? 'ArrowLeft' : 'ArrowRight';\n const backward = isRtl ? 'ArrowRight' : 'ArrowLeft';\n if (key === forward || (isRadio && key === 'ArrowDown')) return 1;\n if (key === backward || (isRadio && key === 'ArrowUp')) return -1;\n return 0;\n}\n\ninterface IndicatorBox {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nfunction readBox(node: HTMLElement | null | undefined): IndicatorBox | null {\n if (!node || node.offsetWidth === 0) return null;\n return {\n x: node.offsetLeft,\n y: node.offsetTop,\n width: node.offsetWidth,\n height: node.offsetHeight,\n };\n}\n\nfunction sameBox(a: IndicatorBox | null, b: IndicatorBox | null) {\n return (\n a === b ||\n (a != null &&\n b != null &&\n a.x === b.x &&\n a.y === b.y &&\n a.width === b.width &&\n a.height === b.height)\n );\n}\n\n/**\n * Segmented controls let people pick one option from a short, exclusive set shown as one\n * compact control — search modes in a header, a filter on a list, or a form choice that\n * doesn't need a radio mark. One segment is selected; choosing another replaces it.\n */\nexport default function SegmentedControl({\n options,\n value,\n onChange,\n role = 'tablist',\n size = 'small',\n className,\n onBlur,\n ...rest\n}: SegmentedControlProps) {\n const trackRef = useRef<HTMLDivElement>(null);\n const segmentRefs = useRef(new Map<string, HTMLButtonElement>());\n const [focusedKey, setFocusedKey] = useState(value);\n const [indicator, setIndicator] = useState<IndicatorBox | null>(null);\n // The first placement is instant. Motion turns on after paint so the\n // surface doesn't slide in from the corner on mount.\n const [indicatorReady, setIndicatorReady] = useState(false);\n const isRadio = role === 'radiogroup';\n const itemRole = isRadio ? 'radio' : 'tab';\n\n // A string dependency: `options` is usually a fresh array each render, and\n // only added or removed segments need new observers (the observers already\n // cover label-driven size changes).\n const optionKeys = options.map((option) => option.key).join('\\u0000');\n\n useLayoutEffect(() => {\n const publish = () => {\n const next = readBox(segmentRefs.current.get(value));\n setIndicator((current) => (sameBox(current, next) ? current : next));\n };\n publish();\n\n const track = trackRef.current;\n if (typeof ResizeObserver === 'undefined' || !track) return;\n const observer = new ResizeObserver(publish);\n observer.observe(track);\n for (const node of segmentRefs.current.values()) {\n observer.observe(node);\n }\n return () => observer.disconnect();\n }, [value, optionKeys, size]);\n\n // Enable motion only after the first real placement has painted, so a first\n // measurement that is empty (hidden container) doesn't animate in later.\n const isPlaced = indicator !== null;\n useEffect(() => {\n if (isPlaced) setIndicatorReady(true);\n }, [isPlaced]);\n\n // Re-sync the roving focus to the selection while rendering, so there is no\n // render with a stale `focusedKey`.\n const [prevValue, setPrevValue] = useState(value);\n if (prevValue !== value) {\n setPrevValue(value);\n setFocusedKey(value);\n }\n\n const iconSize = SIZE_ICON_MAP[size];\n const enabledKeys = options\n .filter((option) => !option.disabled)\n .map((option) => option.key);\n const focusKey = enabledKeys.includes(focusedKey)\n ? focusedKey\n : enabledKeys.includes(value)\n ? value\n : enabledKeys[0];\n\n const moveFocus = (key: string, select: boolean) => {\n setFocusedKey(key);\n segmentRefs.current.get(key)?.focus();\n if (select) onChange(key);\n };\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n onBlur?.(event);\n // Manual tabs keep the last focused segment as the tab stop. Once focus\n // leaves the group, put it back on the selected segment so the next visit\n // lands on the choice, not a segment the user only passed through.\n if (event.defaultPrevented || isRadio) return;\n const track = event.currentTarget;\n queueMicrotask(() => {\n if (!track.isConnected) return;\n const active = document.activeElement;\n if (active instanceof Node && track.contains(active)) return;\n const tabStop = enabledKeys.includes(value) ? value : enabledKeys[0];\n if (tabStop) setFocusedKey(tabStop);\n });\n };\n\n const handleKeyDown = (\n event: KeyboardEvent<HTMLButtonElement>,\n key: string,\n ) => {\n // Alt, Ctrl, and Meta belong to the browser (Back, scroll-to-ends).\n // Shift still moves within the group.\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const count = enabledKeys.length;\n if (count === 0) return;\n const index = enabledKeys.indexOf(key);\n const isRtl =\n trackRef.current != null &&\n getComputedStyle(trackRef.current).direction === 'rtl';\n const delta = arrowDelta(event.key, isRadio, isRtl);\n\n if (delta !== 0) {\n event.preventDefault();\n const next = enabledKeys[stepIndex(index, delta, count)];\n moveFocus(next, isRadio && next !== key);\n return;\n }\n\n if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault();\n const next =\n event.key === 'Home' ? enabledKeys[0] : enabledKeys[count - 1];\n moveFocus(next, isRadio && next !== key);\n return;\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && index >= 0) {\n event.preventDefault();\n setFocusedKey(key);\n if (key !== value) onChange(key);\n }\n };\n\n return (\n <div\n {...rest}\n ref={trackRef}\n role={role}\n aria-orientation=\"horizontal\"\n onBlur={handleBlur}\n className={mergeClassNames(\n styles['segmented-control'],\n styles[`segmented-control--size-${toKebab(size)}`],\n className,\n )}\n >\n <span\n className={mergeClassNames(\n styles['segmented-control__indicator'],\n indicatorReady && styles['segmented-control__indicator--ready'],\n !indicator && styles['segmented-control__indicator--unpositioned'],\n )}\n style={\n indicator\n ? {\n transform: `translate(${indicator.x}px, ${indicator.y}px)`,\n width: indicator.width,\n height: indicator.height,\n }\n : undefined\n }\n aria-hidden\n />\n {options.map((option) => {\n const isSelected = option.key === value;\n const isDisabled = option.disabled === true;\n\n return (\n <button\n {...option.buttonProps}\n key={option.key}\n ref={(node) => {\n if (node) segmentRefs.current.set(option.key, node);\n else segmentRefs.current.delete(option.key);\n }}\n id={option.id ?? option.buttonProps?.id}\n type=\"button\"\n role={itemRole}\n tabIndex={focusKey === option.key ? 0 : -1}\n aria-selected={isRadio ? undefined : isSelected}\n aria-checked={isRadio ? isSelected : undefined}\n aria-controls={\n !isRadio && option.panelId ? option.panelId : undefined\n }\n aria-disabled={isDisabled || undefined}\n disabled={undefined}\n title={option.title ?? option.buttonProps?.title}\n className={mergeClassNames(\n styles['segmented-control__segment'],\n isSelected && styles['segmented-control__segment--active'],\n isDisabled && styles['segmented-control__segment--disabled'],\n option.buttonProps?.className,\n )}\n onMouseDown={(event) => {\n option.buttonProps?.onMouseDown?.(event);\n if (isDisabled) event.preventDefault();\n }}\n onClick={(event) => {\n option.buttonProps?.onClick?.(event);\n if (event.defaultPrevented || isDisabled) return;\n setFocusedKey(option.key);\n if (option.key !== value) onChange(option.key);\n }}\n onKeyDown={(event) => {\n option.buttonProps?.onKeyDown?.(event);\n if (event.defaultPrevented) return;\n handleKeyDown(event, option.key);\n }}\n >\n {option.icon != null && (\n <span className={styles['segmented-control__icon']}>\n <IconSlotContext.Provider value={{ size: iconSize }}>\n {option.icon}\n </IconSlotContext.Provider>\n </span>\n )}\n <span className={styles['segmented-control__label']}>\n {option.label}\n </span>\n </button>\n );\n })}\n </div>\n );\n}\n"],"names":["SIZE_ICON_MAP","stepIndex","index","delta","count","arrowDelta","key","isRadio","isRtl","forward","backward","readBox","node","sameBox","a","b","SegmentedControl","options","value","onChange","role","size","className","onBlur","rest","trackRef","useRef","segmentRefs","focusedKey","setFocusedKey","useState","indicator","setIndicator","indicatorReady","setIndicatorReady","itemRole","optionKeys","option","useLayoutEffect","publish","next","current","track","observer","isPlaced","useEffect","prevValue","setPrevValue","iconSize","enabledKeys","focusKey","moveFocus","select","_a","handleBlur","event","active","tabStop","handleKeyDown","jsxs","mergeClassNames","styles","toKebab","jsx","isSelected","isDisabled","createElement","_b","_c","IconSlotContext"],"mappings":"yTAyBMA,EAAwD,CAC5D,MAAO,KACP,OAAQ,IACV,EA8DA,SAASC,EAAUC,EAAeC,EAAeC,EAAe,CAC9D,OAAIF,EAAQ,EAAUC,EAAQ,EAAIC,EAAQ,EAAI,GACtCF,EAAQC,EAAQC,GAASA,CACnC,CAEA,SAASC,EAAWC,EAAaC,EAAkBC,EAAgB,CACjE,MAAMC,EAAUD,EAAQ,YAAc,aAChCE,EAAWF,EAAQ,aAAe,YACxC,OAAIF,IAAQG,GAAYF,GAAWD,IAAQ,YAAqB,EAC5DA,IAAQI,GAAaH,GAAWD,IAAQ,UAAmB,GACxD,CACT,CASA,SAASK,EAAQC,EAA2D,CAC1E,MAAI,CAACA,GAAQA,EAAK,cAAgB,EAAU,KACrC,CACL,EAAGA,EAAK,WACR,EAAGA,EAAK,UACR,MAAOA,EAAK,YACZ,OAAQA,EAAK,YAAA,CAEjB,CAEA,SAASC,EAAQC,EAAwBC,EAAwB,CAC/D,OACED,IAAMC,GACLD,GAAK,MACJC,GAAK,MACLD,EAAE,IAAMC,EAAE,GACVD,EAAE,IAAMC,EAAE,GACVD,EAAE,QAAUC,EAAE,OACdD,EAAE,SAAWC,EAAE,MAErB,CAOA,SAAwBC,EAAiB,CACvC,QAAAC,EACA,MAAAC,EACA,SAAAC,EACA,KAAAC,EAAO,UACP,K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line-flex;width:fit-content;align-items:center;gap:var(--spacing-xxxxs);padding:var(--spacing-xxxs);border:0;border-radius:var(--radius-m);background-color:rgba(var(--center-channel-color-rgb),var(--opacity-8))}._segmented-control__indicator_1azc0_24{position:absolute;z-index:0;top:0;left:0;border-radius:var(--radius-s);background-color:var(--center-channel-bg);box-shadow:var(--elevation-1);pointer-events:none}@media(forced-colors:active){._segmented-control__indicator_1azc0_24{outline:1px solid Highlight;outline-offset:-1px}}._segmented-control__indicator--ready_1azc0_40{transition:transform var(--duration-quick) var(--ease-transition),width var(--duration-quick) var(--ease-transition),height var(--duration-quick) var(--ease-transition)}@media(prefers-reduced-motion:reduce){._segmented-control__indicator--ready_1azc0_40{transition:none}}._segmented-control__indicator--unpositioned_1azc0_48{visibility:hidden}._segmented-control__segment_1azc0_51{position:relative;z-index:1;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;gap:var(--spacing-xxs);margin:0;border:0;padding-block:var(--spacing-xxxs);padding-inline:calc(var(--spacing-xs) + var(--spacing-xxxxs));border-radius:var(--radius-s);background-color:transparent;cursor:pointer;font-family:var(--font-family-body);font-weight:var(--font-weight-semibold);color:rgba(var(--center-channel-color-rgb),var(--opacity-72));white-space:nowrap;outline:none}._segmented-control__segment_1azc0_51:focus-visible{outline:2px solid var(--focus-ring-color);outline-offset:3px;animation:_focus-ring-in_1azc0_1 var(--duration-quick) var(--ease-transition)}@media(prefers-reduced-motion:reduce){._segmented-control__segment_1azc0_51:focus-visible{animation:none}}._segmented-control__segment_1azc0_51:not(._-host-shadow-a_1azc0_82):not(._-host-shadow-b_1azc0_82){box-shadow:none;border-radius:var(--radius-s)}@keyframes _focus-ring-in_1azc0_1{0%{outline-color:transparent;outline-offset:0}}._segmented-control__segment_1azc0_51:is(:hover,:focus-visible):not(._segmented-control__segment--active_1azc0_92):not(._segmented-control__segment--disabled_1azc0_92){background-color:rgba(var(--center-channel-color-rgb),var(--opacity-4));color:rgba(var(--center-channel-color-rgb),var(--opacity-88))}._segmented-control__segment--active_1azc0_92{color:var(--center-channel-color)}._segmented-control__segment--disabled_1azc0_92:not(._-host-shadow-a_1azc0_82):not(._-host-shadow-b_1azc0_82){cursor:not-allowed;color:rgba(var(--center-channel-color-rgb),var(--opacity-40))}._segmented-control__icon_1azc0_103{display:inline-flex;flex-shrink:0;align-items:center}._segmented-control__label_1azc0_108{display:inline-flex;align-items:center}._segmented-control--size-small_1azc0_112 ._segmented-control__segment_1azc0_51{font-size:var(--font-size-75);line-height:var(--line-height-75)}._segmented-control--size-medium_1azc0_116 ._segmented-control__segment_1azc0_51{font-size:var(--font-size-100);line-height:var(--line-height-100)}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { BuiltInButtonProps } from '../../utils/props';
|
|
3
|
+
/** `tablist` switches views. `radiogroup` is a short exclusive form choice. */
|
|
4
|
+
export type SegmentedControlRole = 'tablist' | 'radiogroup';
|
|
5
|
+
/**
|
|
6
|
+
* `small` matches a small Button (12px label, 12px icon). `medium` matches a
|
|
7
|
+
* medium Button (14px label, 16px icon).
|
|
8
|
+
*/
|
|
9
|
+
export type SegmentedControlSize = 'small' | 'medium';
|
|
10
|
+
export interface SegmentedControlOption {
|
|
11
|
+
/**
|
|
12
|
+
* Stable id for this segment. Used as the React key and the `onChange`
|
|
13
|
+
* argument, so it is a string rather than translated text.
|
|
14
|
+
*/
|
|
15
|
+
key: string;
|
|
16
|
+
/** Segment label. Accepts translated nodes (e.g. `<FormattedMessage/>`). */
|
|
17
|
+
label: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Optional leading icon. Pass `<Icon glyph={<SomeIcon />} />`;
|
|
20
|
+
* SegmentedControl provides the size via context (12px at `small`, 16px at
|
|
21
|
+
* `medium`), matching Button. No `size` prop is needed on the Icon.
|
|
22
|
+
*/
|
|
23
|
+
icon?: ReactNode;
|
|
24
|
+
/** Optional id for this segment (pair with `panelId` for `aria-controls`). */
|
|
25
|
+
id?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Optional id of the host panel this segment controls. Applied as
|
|
28
|
+
* `aria-controls` when `role` is `tablist`. The host owns the panel.
|
|
29
|
+
*/
|
|
30
|
+
panelId?: string;
|
|
31
|
+
/** When true, the segment can't be selected and arrow keys skip it. */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** Native tooltip text, e.g. to explain why the segment is disabled. */
|
|
34
|
+
title?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Extra attributes for this segment's `<button>` (e.g. `data-testid`).
|
|
37
|
+
* Segment semantics (`role`, `aria-selected` / `aria-checked`, `tabIndex`,
|
|
38
|
+
* `type`) take precedence. `className` is merged. `onClick`, `onKeyDown`,
|
|
39
|
+
* and `onMouseDown` run first; `preventDefault()` skips selection.
|
|
40
|
+
*/
|
|
41
|
+
buttonProps?: BuiltInButtonProps;
|
|
42
|
+
}
|
|
43
|
+
export interface SegmentedControlProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'role'> {
|
|
44
|
+
/** Segments, in order. One is selected. */
|
|
45
|
+
options: SegmentedControlOption[];
|
|
46
|
+
/** Key of the selected segment. */
|
|
47
|
+
value: string;
|
|
48
|
+
/** Called with the segment key when the selection changes. */
|
|
49
|
+
onChange: (key: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Semantics. `tablist` (default) switches views: arrow keys move focus, and
|
|
52
|
+
* Enter, Space, or a click selects. The host owns the panel. `radiogroup`
|
|
53
|
+
* is a short exclusive form choice: arrow keys move the selection. Pass
|
|
54
|
+
* `aria-label` or `aria-labelledby` so the group has a name.
|
|
55
|
+
*/
|
|
56
|
+
role?: SegmentedControlRole;
|
|
57
|
+
/**
|
|
58
|
+
* Size of the label and leading icon, matching Button. `small` (default)
|
|
59
|
+
* is 12px text with a 12px icon. `medium` is 14px text with a 16px icon.
|
|
60
|
+
*/
|
|
61
|
+
size?: SegmentedControlSize;
|
|
62
|
+
/** Optional CSS class name. */
|
|
63
|
+
className?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Segmented controls let people pick one option from a short, exclusive set shown as one
|
|
67
|
+
* compact control — search modes in a header, a filter on a list, or a form choice that
|
|
68
|
+
* doesn't need a radio mark. One segment is selected; choosing another replaces it.
|
|
69
|
+
*/
|
|
70
|
+
export default function SegmentedControl({ options, value, onChange, role, size, className, onBlur, ...rest }: SegmentedControlProps): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
//# sourceMappingURL=SegmentedControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/SegmentedControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EAEnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAIzE,+EAA+E;AAC/E,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,YAAY,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAOtD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,8EAA8E;IAC9E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,GAAG,MAAM,CACpB;IACC,2CAA2C;IAC3C,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAClC,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA4CD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAgB,EAChB,IAAc,EACd,SAAS,EACT,MAAM,EACN,GAAG,IAAI,EACR,EAAE,qBAAqB,2CAgNvB"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { jsxs as V, jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as N, useState as p, useLayoutEffect as W, useEffect as q, createElement as U } from "react";
|
|
3
|
+
import { IconSlotContext as Z } from "../icon/Icon.js";
|
|
4
|
+
import { mergeClassNames as D } from "../../utils/props.js";
|
|
5
|
+
import { toKebab as B } from "../../utils/string.js";
|
|
6
|
+
import l from "./SegmentedControl.module.scss.js";
|
|
7
|
+
const G = {
|
|
8
|
+
small: "12",
|
|
9
|
+
medium: "16"
|
|
10
|
+
};
|
|
11
|
+
function J(r, t, d) {
|
|
12
|
+
return r < 0 ? t < 0 ? d - 1 : 0 : (r + t + d) % d;
|
|
13
|
+
}
|
|
14
|
+
function Q(r, t, d) {
|
|
15
|
+
const x = d ? "ArrowLeft" : "ArrowRight", h = d ? "ArrowRight" : "ArrowLeft";
|
|
16
|
+
return r === x || t && r === "ArrowDown" ? 1 : r === h || t && r === "ArrowUp" ? -1 : 0;
|
|
17
|
+
}
|
|
18
|
+
function X(r) {
|
|
19
|
+
return !r || r.offsetWidth === 0 ? null : {
|
|
20
|
+
x: r.offsetLeft,
|
|
21
|
+
y: r.offsetTop,
|
|
22
|
+
width: r.offsetWidth,
|
|
23
|
+
height: r.offsetHeight
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function Y(r, t) {
|
|
27
|
+
return r === t || r != null && t != null && r.x === t.x && r.y === t.y && r.width === t.width && r.height === t.height;
|
|
28
|
+
}
|
|
29
|
+
function oe({
|
|
30
|
+
options: r,
|
|
31
|
+
value: t,
|
|
32
|
+
onChange: d,
|
|
33
|
+
role: x = "tablist",
|
|
34
|
+
size: h = "small",
|
|
35
|
+
className: S,
|
|
36
|
+
onBlur: P,
|
|
37
|
+
...A
|
|
38
|
+
}) {
|
|
39
|
+
const _ = N(null), g = N(/* @__PURE__ */ new Map()), [K, b] = p(t), [m, E] = p(null), [C, M] = p(!1), f = x === "radiogroup", z = f ? "radio" : "tab", L = r.map((e) => e.key).join("\0");
|
|
40
|
+
W(() => {
|
|
41
|
+
const e = () => {
|
|
42
|
+
const i = X(g.current.get(t));
|
|
43
|
+
E((y) => Y(y, i) ? y : i);
|
|
44
|
+
};
|
|
45
|
+
e();
|
|
46
|
+
const n = _.current;
|
|
47
|
+
if (typeof ResizeObserver > "u" || !n) return;
|
|
48
|
+
const s = new ResizeObserver(e);
|
|
49
|
+
s.observe(n);
|
|
50
|
+
for (const i of g.current.values())
|
|
51
|
+
s.observe(i);
|
|
52
|
+
return () => s.disconnect();
|
|
53
|
+
}, [t, L, h]);
|
|
54
|
+
const R = m !== null;
|
|
55
|
+
q(() => {
|
|
56
|
+
R && M(!0);
|
|
57
|
+
}, [R]);
|
|
58
|
+
const [O, j] = p(t);
|
|
59
|
+
O !== t && (j(t), b(t));
|
|
60
|
+
const H = G[h], a = r.filter((e) => !e.disabled).map((e) => e.key), $ = a.includes(K) ? K : a.includes(t) ? t : a[0], I = (e, n) => {
|
|
61
|
+
var s;
|
|
62
|
+
b(e), (s = g.current.get(e)) == null || s.focus(), n && d(e);
|
|
63
|
+
}, F = (e) => {
|
|
64
|
+
if (P == null || P(e), e.defaultPrevented || f) return;
|
|
65
|
+
const n = e.currentTarget;
|
|
66
|
+
queueMicrotask(() => {
|
|
67
|
+
if (!n.isConnected) return;
|
|
68
|
+
const s = document.activeElement;
|
|
69
|
+
if (s instanceof Node && n.contains(s)) return;
|
|
70
|
+
const i = a.includes(t) ? t : a[0];
|
|
71
|
+
i && b(i);
|
|
72
|
+
});
|
|
73
|
+
}, T = (e, n) => {
|
|
74
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
75
|
+
const s = a.length;
|
|
76
|
+
if (s === 0) return;
|
|
77
|
+
const i = a.indexOf(n), y = _.current != null && getComputedStyle(_.current).direction === "rtl", w = Q(e.key, f, y);
|
|
78
|
+
if (w !== 0) {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
const o = a[J(i, w, s)];
|
|
81
|
+
I(o, f && o !== n);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (e.key === "Home" || e.key === "End") {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
const o = e.key === "Home" ? a[0] : a[s - 1];
|
|
87
|
+
I(o, f && o !== n);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
(e.key === "Enter" || e.key === " ") && i >= 0 && (e.preventDefault(), b(n), n !== t && d(n));
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ V(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
...A,
|
|
96
|
+
ref: _,
|
|
97
|
+
role: x,
|
|
98
|
+
"aria-orientation": "horizontal",
|
|
99
|
+
onBlur: F,
|
|
100
|
+
className: D(
|
|
101
|
+
l["segmented-control"],
|
|
102
|
+
l[`segmented-control--size-${B(h)}`],
|
|
103
|
+
S
|
|
104
|
+
),
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ k(
|
|
107
|
+
"span",
|
|
108
|
+
{
|
|
109
|
+
className: D(
|
|
110
|
+
l["segmented-control__indicator"],
|
|
111
|
+
C && l["segmented-control__indicator--ready"],
|
|
112
|
+
!m && l["segmented-control__indicator--unpositioned"]
|
|
113
|
+
),
|
|
114
|
+
style: m ? {
|
|
115
|
+
transform: `translate(${m.x}px, ${m.y}px)`,
|
|
116
|
+
width: m.width,
|
|
117
|
+
height: m.height
|
|
118
|
+
} : void 0,
|
|
119
|
+
"aria-hidden": !0
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
r.map((e) => {
|
|
123
|
+
var i, y, w;
|
|
124
|
+
const n = e.key === t, s = e.disabled === !0;
|
|
125
|
+
return /* @__PURE__ */ U(
|
|
126
|
+
"button",
|
|
127
|
+
{
|
|
128
|
+
...e.buttonProps,
|
|
129
|
+
key: e.key,
|
|
130
|
+
ref: (o) => {
|
|
131
|
+
o ? g.current.set(e.key, o) : g.current.delete(e.key);
|
|
132
|
+
},
|
|
133
|
+
id: e.id ?? ((i = e.buttonProps) == null ? void 0 : i.id),
|
|
134
|
+
type: "button",
|
|
135
|
+
role: z,
|
|
136
|
+
tabIndex: $ === e.key ? 0 : -1,
|
|
137
|
+
"aria-selected": f ? void 0 : n,
|
|
138
|
+
"aria-checked": f ? n : void 0,
|
|
139
|
+
"aria-controls": !f && e.panelId ? e.panelId : void 0,
|
|
140
|
+
"aria-disabled": s || void 0,
|
|
141
|
+
disabled: void 0,
|
|
142
|
+
title: e.title ?? ((y = e.buttonProps) == null ? void 0 : y.title),
|
|
143
|
+
className: D(
|
|
144
|
+
l["segmented-control__segment"],
|
|
145
|
+
n && l["segmented-control__segment--active"],
|
|
146
|
+
s && l["segmented-control__segment--disabled"],
|
|
147
|
+
(w = e.buttonProps) == null ? void 0 : w.className
|
|
148
|
+
),
|
|
149
|
+
onMouseDown: (o) => {
|
|
150
|
+
var c, u;
|
|
151
|
+
(u = (c = e.buttonProps) == null ? void 0 : c.onMouseDown) == null || u.call(c, o), s && o.preventDefault();
|
|
152
|
+
},
|
|
153
|
+
onClick: (o) => {
|
|
154
|
+
var c, u;
|
|
155
|
+
(u = (c = e.buttonProps) == null ? void 0 : c.onClick) == null || u.call(c, o), !(o.defaultPrevented || s) && (b(e.key), e.key !== t && d(e.key));
|
|
156
|
+
},
|
|
157
|
+
onKeyDown: (o) => {
|
|
158
|
+
var c, u;
|
|
159
|
+
(u = (c = e.buttonProps) == null ? void 0 : c.onKeyDown) == null || u.call(c, o), !o.defaultPrevented && T(o, e.key);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
e.icon != null && /* @__PURE__ */ k("span", { className: l["segmented-control__icon"], children: /* @__PURE__ */ k(Z.Provider, { value: { size: H }, children: e.icon }) }),
|
|
163
|
+
/* @__PURE__ */ k("span", { className: l["segmented-control__label"], children: e.label })
|
|
164
|
+
);
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
export {
|
|
171
|
+
oe as default
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=SegmentedControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","sources":["../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type FocusEvent,\n type HTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport type { IconSize } from '@/components/icon/Icon';\nimport { IconSlotContext } from '@/components/icon/Icon';\nimport { mergeClassNames, type BuiltInButtonProps } from '@/utils/props';\nimport { toKebab } from '@/utils/string';\nimport styles from './SegmentedControl.module.scss';\n\n/** `tablist` switches views. `radiogroup` is a short exclusive form choice. */\nexport type SegmentedControlRole = 'tablist' | 'radiogroup';\n\n/**\n * `small` matches a small Button (12px label, 12px icon). `medium` matches a\n * medium Button (14px label, 16px icon).\n */\nexport type SegmentedControlSize = 'small' | 'medium';\n\nconst SIZE_ICON_MAP: Record<SegmentedControlSize, IconSize> = {\n small: '12',\n medium: '16',\n};\n\nexport interface SegmentedControlOption {\n /**\n * Stable id for this segment. Used as the React key and the `onChange`\n * argument, so it is a string rather than translated text.\n */\n key: string;\n /** Segment label. Accepts translated nodes (e.g. `<FormattedMessage/>`). */\n label: ReactNode;\n /**\n * Optional leading icon. Pass `<Icon glyph={<SomeIcon />} />`;\n * SegmentedControl provides the size via context (12px at `small`, 16px at\n * `medium`), matching Button. No `size` prop is needed on the Icon.\n */\n icon?: ReactNode;\n /** Optional id for this segment (pair with `panelId` for `aria-controls`). */\n id?: string;\n /**\n * Optional id of the host panel this segment controls. Applied as\n * `aria-controls` when `role` is `tablist`. The host owns the panel.\n */\n panelId?: string;\n /** When true, the segment can't be selected and arrow keys skip it. */\n disabled?: boolean;\n /** Native tooltip text, e.g. to explain why the segment is disabled. */\n title?: string;\n /**\n * Extra attributes for this segment's `<button>` (e.g. `data-testid`).\n * Segment semantics (`role`, `aria-selected` / `aria-checked`, `tabIndex`,\n * `type`) take precedence. `className` is merged. `onClick`, `onKeyDown`,\n * and `onMouseDown` run first; `preventDefault()` skips selection.\n */\n buttonProps?: BuiltInButtonProps;\n}\n\nexport interface SegmentedControlProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'role'\n> {\n /** Segments, in order. One is selected. */\n options: SegmentedControlOption[];\n /** Key of the selected segment. */\n value: string;\n /** Called with the segment key when the selection changes. */\n onChange: (key: string) => void;\n /**\n * Semantics. `tablist` (default) switches views: arrow keys move focus, and\n * Enter, Space, or a click selects. The host owns the panel. `radiogroup`\n * is a short exclusive form choice: arrow keys move the selection. Pass\n * `aria-label` or `aria-labelledby` so the group has a name.\n */\n role?: SegmentedControlRole;\n /**\n * Size of the label and leading icon, matching Button. `small` (default)\n * is 12px text with a 12px icon. `medium` is 14px text with a 16px icon.\n */\n size?: SegmentedControlSize;\n /** Optional CSS class name. */\n className?: string;\n}\n\nfunction stepIndex(index: number, delta: number, count: number) {\n if (index < 0) return delta < 0 ? count - 1 : 0;\n return (index + delta + count) % count;\n}\n\nfunction arrowDelta(key: string, isRadio: boolean, isRtl: boolean) {\n const forward = isRtl ? 'ArrowLeft' : 'ArrowRight';\n const backward = isRtl ? 'ArrowRight' : 'ArrowLeft';\n if (key === forward || (isRadio && key === 'ArrowDown')) return 1;\n if (key === backward || (isRadio && key === 'ArrowUp')) return -1;\n return 0;\n}\n\ninterface IndicatorBox {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nfunction readBox(node: HTMLElement | null | undefined): IndicatorBox | null {\n if (!node || node.offsetWidth === 0) return null;\n return {\n x: node.offsetLeft,\n y: node.offsetTop,\n width: node.offsetWidth,\n height: node.offsetHeight,\n };\n}\n\nfunction sameBox(a: IndicatorBox | null, b: IndicatorBox | null) {\n return (\n a === b ||\n (a != null &&\n b != null &&\n a.x === b.x &&\n a.y === b.y &&\n a.width === b.width &&\n a.height === b.height)\n );\n}\n\n/**\n * Segmented controls let people pick one option from a short, exclusive set shown as one\n * compact control — search modes in a header, a filter on a list, or a form choice that\n * doesn't need a radio mark. One segment is selected; choosing another replaces it.\n */\nexport default function SegmentedControl({\n options,\n value,\n onChange,\n role = 'tablist',\n size = 'small',\n className,\n onBlur,\n ...rest\n}: SegmentedControlProps) {\n const trackRef = useRef<HTMLDivElement>(null);\n const segmentRefs = useRef(new Map<string, HTMLButtonElement>());\n const [focusedKey, setFocusedKey] = useState(value);\n const [indicator, setIndicator] = useState<IndicatorBox | null>(null);\n // The first placement is instant. Motion turns on after paint so the\n // surface doesn't slide in from the corner on mount.\n const [indicatorReady, setIndicatorReady] = useState(false);\n const isRadio = role === 'radiogroup';\n const itemRole = isRadio ? 'radio' : 'tab';\n\n // A string dependency: `options` is usually a fresh array each render, and\n // only added or removed segments need new observers (the observers already\n // cover label-driven size changes).\n const optionKeys = options.map((option) => option.key).join('\\u0000');\n\n useLayoutEffect(() => {\n const publish = () => {\n const next = readBox(segmentRefs.current.get(value));\n setIndicator((current) => (sameBox(current, next) ? current : next));\n };\n publish();\n\n const track = trackRef.current;\n if (typeof ResizeObserver === 'undefined' || !track) return;\n const observer = new ResizeObserver(publish);\n observer.observe(track);\n for (const node of segmentRefs.current.values()) {\n observer.observe(node);\n }\n return () => observer.disconnect();\n }, [value, optionKeys, size]);\n\n // Enable motion only after the first real placement has painted, so a first\n // measurement that is empty (hidden container) doesn't animate in later.\n const isPlaced = indicator !== null;\n useEffect(() => {\n if (isPlaced) setIndicatorReady(true);\n }, [isPlaced]);\n\n // Re-sync the roving focus to the selection while rendering, so there is no\n // render with a stale `focusedKey`.\n const [prevValue, setPrevValue] = useState(value);\n if (prevValue !== value) {\n setPrevValue(value);\n setFocusedKey(value);\n }\n\n const iconSize = SIZE_ICON_MAP[size];\n const enabledKeys = options\n .filter((option) => !option.disabled)\n .map((option) => option.key);\n const focusKey = enabledKeys.includes(focusedKey)\n ? focusedKey\n : enabledKeys.includes(value)\n ? value\n : enabledKeys[0];\n\n const moveFocus = (key: string, select: boolean) => {\n setFocusedKey(key);\n segmentRefs.current.get(key)?.focus();\n if (select) onChange(key);\n };\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n onBlur?.(event);\n // Manual tabs keep the last focused segment as the tab stop. Once focus\n // leaves the group, put it back on the selected segment so the next visit\n // lands on the choice, not a segment the user only passed through.\n if (event.defaultPrevented || isRadio) return;\n const track = event.currentTarget;\n queueMicrotask(() => {\n if (!track.isConnected) return;\n const active = document.activeElement;\n if (active instanceof Node && track.contains(active)) return;\n const tabStop = enabledKeys.includes(value) ? value : enabledKeys[0];\n if (tabStop) setFocusedKey(tabStop);\n });\n };\n\n const handleKeyDown = (\n event: KeyboardEvent<HTMLButtonElement>,\n key: string,\n ) => {\n // Alt, Ctrl, and Meta belong to the browser (Back, scroll-to-ends).\n // Shift still moves within the group.\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const count = enabledKeys.length;\n if (count === 0) return;\n const index = enabledKeys.indexOf(key);\n const isRtl =\n trackRef.current != null &&\n getComputedStyle(trackRef.current).direction === 'rtl';\n const delta = arrowDelta(event.key, isRadio, isRtl);\n\n if (delta !== 0) {\n event.preventDefault();\n const next = enabledKeys[stepIndex(index, delta, count)];\n moveFocus(next, isRadio && next !== key);\n return;\n }\n\n if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault();\n const next =\n event.key === 'Home' ? enabledKeys[0] : enabledKeys[count - 1];\n moveFocus(next, isRadio && next !== key);\n return;\n }\n\n if ((event.key === 'Enter' || event.key === ' ') && index >= 0) {\n event.preventDefault();\n setFocusedKey(key);\n if (key !== value) onChange(key);\n }\n };\n\n return (\n <div\n {...rest}\n ref={trackRef}\n role={role}\n aria-orientation=\"horizontal\"\n onBlur={handleBlur}\n className={mergeClassNames(\n styles['segmented-control'],\n styles[`segmented-control--size-${toKebab(size)}`],\n className,\n )}\n >\n <span\n className={mergeClassNames(\n styles['segmented-control__indicator'],\n indicatorReady && styles['segmented-control__indicator--ready'],\n !indicator && styles['segmented-control__indicator--unpositioned'],\n )}\n style={\n indicator\n ? {\n transform: `translate(${indicator.x}px, ${indicator.y}px)`,\n width: indicator.width,\n height: indicator.height,\n }\n : undefined\n }\n aria-hidden\n />\n {options.map((option) => {\n const isSelected = option.key === value;\n const isDisabled = option.disabled === true;\n\n return (\n <button\n {...option.buttonProps}\n key={option.key}\n ref={(node) => {\n if (node) segmentRefs.current.set(option.key, node);\n else segmentRefs.current.delete(option.key);\n }}\n id={option.id ?? option.buttonProps?.id}\n type=\"button\"\n role={itemRole}\n tabIndex={focusKey === option.key ? 0 : -1}\n aria-selected={isRadio ? undefined : isSelected}\n aria-checked={isRadio ? isSelected : undefined}\n aria-controls={\n !isRadio && option.panelId ? option.panelId : undefined\n }\n aria-disabled={isDisabled || undefined}\n disabled={undefined}\n title={option.title ?? option.buttonProps?.title}\n className={mergeClassNames(\n styles['segmented-control__segment'],\n isSelected && styles['segmented-control__segment--active'],\n isDisabled && styles['segmented-control__segment--disabled'],\n option.buttonProps?.className,\n )}\n onMouseDown={(event) => {\n option.buttonProps?.onMouseDown?.(event);\n if (isDisabled) event.preventDefault();\n }}\n onClick={(event) => {\n option.buttonProps?.onClick?.(event);\n if (event.defaultPrevented || isDisabled) return;\n setFocusedKey(option.key);\n if (option.key !== value) onChange(option.key);\n }}\n onKeyDown={(event) => {\n option.buttonProps?.onKeyDown?.(event);\n if (event.defaultPrevented) return;\n handleKeyDown(event, option.key);\n }}\n >\n {option.icon != null && (\n <span className={styles['segmented-control__icon']}>\n <IconSlotContext.Provider value={{ size: iconSize }}>\n {option.icon}\n </IconSlotContext.Provider>\n </span>\n )}\n <span className={styles['segmented-control__label']}>\n {option.label}\n </span>\n </button>\n );\n })}\n </div>\n );\n}\n"],"names":["SIZE_ICON_MAP","stepIndex","index","delta","count","arrowDelta","key","isRadio","isRtl","forward","backward","readBox","node","sameBox","a","b","SegmentedControl","options","value","onChange","role","size","className","onBlur","rest","trackRef","useRef","segmentRefs","focusedKey","setFocusedKey","useState","indicator","setIndicator","indicatorReady","setIndicatorReady","itemRole","optionKeys","option","useLayoutEffect","publish","next","current","track","observer","isPlaced","useEffect","prevValue","setPrevValue","iconSize","enabledKeys","focusKey","moveFocus","select","_a","handleBlur","event","active","tabStop","handleKeyDown","jsxs","mergeClassNames","styles","toKebab","jsx","isSelected","isDisabled","createElement","_b","_c","IconSlotContext"],"mappings":";;;;;;AAyBA,MAAMA,IAAwD;AAAA,EAC5D,OAAO;AAAA,EACP,QAAQ;AACV;AA8DA,SAASC,EAAUC,GAAeC,GAAeC,GAAe;AAC9D,SAAIF,IAAQ,IAAUC,IAAQ,IAAIC,IAAQ,IAAI,KACtCF,IAAQC,IAAQC,KAASA;AACnC;AAEA,SAASC,EAAWC,GAAaC,GAAkBC,GAAgB;AACjE,QAAMC,IAAUD,IAAQ,cAAc,cAChCE,IAAWF,IAAQ,eAAe;AACxC,SAAIF,MAAQG,KAAYF,KAAWD,MAAQ,cAAqB,IAC5DA,MAAQI,KAAaH,KAAWD,MAAQ,YAAmB,KACxD;AACT;AASA,SAASK,EAAQC,G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CAACb,MAAU;;AACtB,iBAAAY,KAAAd,IAAAhB,EAAO,gBAAP,gBAAAgB,EAAoB,gBAApB,QAAAc,EAAA,KAAAd,GAAkCE,IAC9BU,OAAkB,eAAA;AAAA,cACxB;AAAA,cACA,SAAS,CAACV,MAAU;;AAElB,iBADAY,KAAAd,IAAAhB,EAAO,gBAAP,gBAAAgB,EAAoB,YAApB,QAAAc,EAAA,KAAAd,GAA8BE,IAC1B,EAAAA,EAAM,oBAAoBU,OAC9BpC,EAAcQ,EAAO,GAAG,GACpBA,EAAO,QAAQnB,KAAOC,EAASkB,EAAO,GAAG;AAAA,cAC/C;AAAA,cACA,WAAW,CAACkB,MAAU;;AAEpB,iBADAY,KAAAd,IAAAhB,EAAO,gBAAP,gBAAAgB,EAAoB,cAApB,QAAAc,EAAA,KAAAd,GAAgCE,IAC5B,CAAAA,EAAM,oBACVG,EAAcH,GAAOlB,EAAO,GAAG;AAAA,cACjC;AAAA,YAAA;AAAA,YAECA,EAAO,QAAQ,QACd,gBAAA0B,EAAC,UAAK,WAAWF,EAAO,yBAAyB,GAC/C,UAAA,gBAAAE,EAACM,EAAgB,UAAhB,EAAyB,OAAO,EAAE,MAAMrB,KACtC,UAAAX,EAAO,MACV,GACF;AAAA,8BAED,QAAA,EAAK,WAAWwB,EAAO,0BAA0B,GAC/C,YAAO,MAAA,CACV;AAAA,UAAA;AAAA,QAGN,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./SegmentedControl.css');const e={"segmented-control":"_segmented-control_1azc0_13","segmented-control__indicator":"_segmented-control__indicator_1azc0_24","segmented-control__indicator--ready":"_segmented-control__indicator--ready_1azc0_40","segmented-control__indicator--unpositioned":"_segmented-control__indicator--unpositioned_1azc0_48","segmented-control__segment":"_segmented-control__segment_1azc0_51","focus-ring-in":"_focus-ring-in_1azc0_1","-host-shadow-a":"_-host-shadow-a_1azc0_82","-host-shadow-b":"_-host-shadow-b_1azc0_82","segmented-control__segment--active":"_segmented-control__segment--active_1azc0_92","segmented-control__segment--disabled":"_segmented-control__segment--disabled_1azc0_92","segmented-control__icon":"_segmented-control__icon_1azc0_103","segmented-control__label":"_segmented-control__label_1azc0_108","segmented-control--size-small":"_segmented-control--size-small_1azc0_112","segmented-control--size-medium":"_segmented-control--size-medium_1azc0_116"};exports.default=e;
|
|
2
|
+
//# sourceMappingURL=SegmentedControl.module.scss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.module.scss.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import './SegmentedControl.css';const e = {
|
|
2
|
+
"segmented-control": "_segmented-control_1azc0_13",
|
|
3
|
+
"segmented-control__indicator": "_segmented-control__indicator_1azc0_24",
|
|
4
|
+
"segmented-control__indicator--ready": "_segmented-control__indicator--ready_1azc0_40",
|
|
5
|
+
"segmented-control__indicator--unpositioned": "_segmented-control__indicator--unpositioned_1azc0_48",
|
|
6
|
+
"segmented-control__segment": "_segmented-control__segment_1azc0_51",
|
|
7
|
+
"focus-ring-in": "_focus-ring-in_1azc0_1",
|
|
8
|
+
"-host-shadow-a": "_-host-shadow-a_1azc0_82",
|
|
9
|
+
"-host-shadow-b": "_-host-shadow-b_1azc0_82",
|
|
10
|
+
"segmented-control__segment--active": "_segmented-control__segment--active_1azc0_92",
|
|
11
|
+
"segmented-control__segment--disabled": "_segmented-control__segment--disabled_1azc0_92",
|
|
12
|
+
"segmented-control__icon": "_segmented-control__icon_1azc0_103",
|
|
13
|
+
"segmented-control__label": "_segmented-control__label_1azc0_108",
|
|
14
|
+
"segmented-control--size-small": "_segmented-control--size-small_1azc0_112",
|
|
15
|
+
"segmented-control--size-medium": "_segmented-control--size-medium_1azc0_116"
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
e as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=SegmentedControl.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),l=require("react"),__qe=require("@mattermost/compass-icons/components/chevron-down.js"),qe=__qe?.default??__qe,Y=require("../icon/Icon.cjs"),R=require("../field/fieldDescribedBy.cjs"),Se=require("../field-message/FieldMessage.cjs"),Re=require("../menu-item/MenuItem.cjs"),C=require("../popover-menu/PopoverMenu.cjs"),Ce=require("../../hooks/use-anchored-popup-portal.cjs"),Ne=require("../../hooks/use-outside-close.cjs"),Ee=require("../../hooks/use-popover-transition.cjs"),Fe=require("../../utils/menuItemProps.cjs"),Oe=require("../../utils/string.cjs"),n=require("./Select.module.scss.cjs"),Z=280;function Ae({option:c,menuItemProps:v,listboxId:k,selected:_,active:w,onSelect:b,onHover:D,dividerAfter:d=!1}){return s.jsxs(s.Fragment,{children:[s.jsx("li",{className:n.default.select__option,role:"presentation",children:s.jsx(Re.default,{...Fe.mergeMenuItemProps(v,c.menuItemProps),id:`${k}-option-${c.value}`,role:"option",label:c.label,secondaryLabel:c.secondaryLabel,leadingElement:c.leadingVisual!=null,leadingVisual:c.leadingVisual,trailingElement:_,active:w,disabled:c.disabled,"aria-selected":_,onMouseDown:j=>j.preventDefault(),onMouseEnter:D,onPointerUp:()=>{c.disabled||b(c)}})}),d?s.jsx("li",{role:"presentation",children:s.jsx(C.PopoverMenuDivider,{"aria-hidden":"true"})}):null]})}const Be=l.forwardRef(function({options:v,menuItemProps:k,value:_,defaultValue:w="",onChange:b,placeholder:D,label:d,leadingIcon:j,size:ee="medium",invalid:te=!1,message:M,messageTone:N,required:se=!1,disabled:h=!1,id:le,name:E,className:ne="","aria-label":F,"aria-describedby":ae,listboxLabel:re="Options",portalContainer:oe=null,zIndex:ie},g){const ce=l.useId(),I=le??ce,m=`${I}-listbox`,O=l.useRef(null),A=l.useRef(null),B=l.useRef(null),ue=l.useCallback(e=>{B.current=e,typeof g=="function"?g(e):g&&(g.current=e)},[g]),q=_!==void 0,[de,fe]=l.useState(w),f=q?_:de,[r,V]=l.useState(!1),[pe,$]=l.useState(!1),[i,p]=l.useState(-1),P=l.useRef(!1),ve=l.useCallback(e=>{e!==i&&(P.current=!0,p(e))},[i]),S=l.useMemo(()=>v.find(e=>e.value===f),[v,f]),o=l.useMemo(()=>v.filter(e=>e.value!==""),[v]),H=f!=="",{mounted:z,visible:be}=Ee.usePopoverTransition(r),{placement:he,maxHeight:me,style:xe,portalRef:T,renderPortal:_e}=Ce.useAnchoredPopupPortal(A,z,{preferredHeight:Z,maxHeightCap:Z,portalContainer:oe,zIndex:ie}),x=l.useCallback(()=>{V(!1),p(-1)},[]),y=l.useCallback(()=>{h||V(!0)},[h]);Ne.useOutsideClose(O,r,x,T),l.useEffect(()=>{r&&p(e=>{if(o.length===0)return-1;if(e>=0&&e<o.length)return e;const t=o.findIndex(u=>u.value===f);if(t>=0)return t;const a=o.findIndex(u=>!u.disabled);return a>=0?a:0})},[r,o,f]);const U=l.useCallback(e=>{q||fe(e),b==null||b(e)},[q,b]),K=l.useCallback(e=>{var t;e.disabled||(U(e.value),x(),(t=B.current)==null||t.focus())},[U,x]),L=l.useCallback(e=>{P.current=!1;const t=o.map((a,u)=>({o:a,i:u})).filter(({o:a})=>!a.disabled);if(t.length===0){p(-1);return}p(a=>{const u=t.findIndex(({i:Me})=>Me===a),De=u<0?e>0?0:t.length-1:(u+e+t.length)%t.length;return t[De].i})},[o]);l.useEffect(()=>{var a;if(!r||i<0)return;if(P.current){P.current=!1;return}const e=o[i];if(!e)return;const t=document.getElementById(`${m}-option-${e.value}`);(a=t==null?void 0:t.scrollIntoView)==null||a.call(t,{block:"nearest"})},[r,i,o,m]);const je=e=>{var t;if(!h)switch(e.key){case"ArrowDown":e.preventDefault(),r?L(1):y();break;case"ArrowUp":e.preventDefault(),r?L(-1):y();break;case"Home":if(r&&o.length>0){e.preventDefault();const a=o.findIndex(u=>!u.disabled);p(a>=0?a:0)}break;case"End":if(r&&o.length>0){e.preventDefault();for(let a=o.length-1;a>=0;a--)if(!((t=o[a])!=null&&t.disabled)){p(a);break}}break;case"Enter":case" ":e.preventDefault(),r&&i>=0&&o[i]?K(o[i]):r||y();break;case"Escape":r&&(e.preventDefault(),x());break;case"Tab":x();break}},ge=pe||r||H,G=(S==null?void 0:S.label)??D??"",Ie=!H&&G!=="",X=i>=0?o[i]:void 0,Pe=r&&X!=null?`${m}-option-${X.value}`:void 0,J=R.isFieldInvalid(te,M,N),Q=R.hasFieldMessage(M),W=Q?`${I}-message`:void 0,ye=n.default[`select--size-${Oe.toKebab(ee)}`],ke=[n.default.select,ye,J?n.default["select--invalid"]:"",d!=null&&ge?n.default["select--label-floated"]:"",j!=null?n.default["select--has-leading-icon"]:"",r?n.default["select--open"]:"",h?n.default["select--disabled"]:"",ne].filter(Boolean).join(" "),we=[n.default.select__control,Ie?n.default["select__control--placeholder"]:""].filter(Boolean).join(" ");return s.jsxs("div",{className:ke,ref:O,children:[s.jsxs("div",{className:n.default.select__wrapper,ref:A,children:[d!=null&&s.jsx("label",{className:n.default.select__label,htmlFor:I,children:d}),s.jsxs("button",{ref:ue,id:I,type:"button",role:"combobox",className:we,disabled:h,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":m,"aria-activedescendant":Pe,"aria-invalid":J?!0:void 0,"aria-required":se?!0:void 0,"aria-describedby":R.mergeFieldDescribedBy(ae,W,void 0),"aria-label":F,onClick:()=>r?x():y(),onFocus:()=>$(!0),onBlur:()=>$(!1),onKeyDown:je,children:[j!=null&&s.jsx("span",{className:n.default["select__leading-icon"],"aria-hidden":!0,children:s.jsx(Y.IconSlotContext.Provider,{value:{size:"16"},children:j})}),s.jsx("span",{className:n.default.select__value,children:G}),s.jsx("span",{className:n.default["select__trailing-icon"],"aria-hidden":!0,children:s.jsx(Y.default,{size:"12",glyph:s.jsx(qe,{})})})]})]}),Q&&s.jsx(Se.default,{id:W,className:n.default.select__message,message:M,tone:N??"error"}),E!=null&&!h&&s.jsx("input",{type:"hidden",name:E,value:f}),z&&_e(s.jsx("div",{ref:T,className:[n.default.select__popup,he==="above"?n.default["select__popup--above"]:"",be?n.default["select__popup--visible"]:""].filter(Boolean).join(" "),style:xe,children:s.jsx(C.default,{className:n.default.select__menu,children:s.jsx(C.PopoverMenuScroll,{maxHeight:me,children:s.jsx("ul",{id:m,className:n.default.select__list,role:"listbox","aria-label":typeof d=="string"?d:F??re,children:o.map((e,t)=>s.jsx(Ae,{option:e,menuItemProps:k,listboxId:m,selected:e.value===f,active:t===i,onSelect:K,onHover:()=>ve(t),dividerAfter:e.dividerAfter},e.value))})})})}))]})});exports.default=Be;
|
|
2
2
|
//# sourceMappingURL=Select.cjs.map
|