@plexui/ui 0.19.0 → 0.20.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 +1 -3
- package/dist/es/components/Accordion/Accordion.js +2 -2
- package/dist/es/components/Accordion/Accordion.js.map +1 -1
- package/dist/es/components/Accordion/index.js +1 -1
- package/dist/es/components/Alert/Alert.js +6 -6
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/Alert/index.js +1 -1
- package/dist/es/components/Avatar/Avatar.js +12 -5
- package/dist/es/components/Avatar/Avatar.js.map +1 -1
- package/dist/es/components/Avatar/AvatarGroup.js +2 -2
- package/dist/es/components/Avatar/AvatarGroup.js.map +1 -1
- package/dist/es/components/Avatar/index.js +2 -2
- package/dist/es/components/Badge/index.js +3 -3
- package/dist/es/components/Badge/index.js.map +1 -1
- package/dist/es/components/Breadcrumb/Breadcrumb.js +34 -0
- package/dist/es/components/Breadcrumb/Breadcrumb.js.map +1 -0
- package/dist/es/components/Breadcrumb/index.js +2 -0
- package/dist/es/components/Breadcrumb/index.js.map +1 -0
- package/dist/es/components/Button/Button.js +7 -7
- package/dist/es/components/Button/Button.js.map +1 -1
- package/dist/es/components/Button/CopyButton.js +25 -13
- package/dist/es/components/Button/CopyButton.js.map +1 -1
- package/dist/es/components/Button/index.js +2 -2
- package/dist/es/components/ButtonGroup/ButtonGroup.js +2 -2
- package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist/es/components/ButtonGroup/index.js +1 -1
- package/dist/es/components/Card/Card.js +4 -3
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/index.js +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +12 -6
- package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/Checkbox/index.js +1 -1
- package/dist/es/components/CodeBlock/CodeBlock.js +25 -25
- package/dist/es/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/es/components/CodeBlock/CollapsibleCodeBlock.js +6 -4
- package/dist/es/components/CodeBlock/CollapsibleCodeBlock.js.map +1 -1
- package/dist/es/components/CodeBlock/index.js +2 -2
- package/dist/es/components/DataTable/DataTable.js +108 -27
- package/dist/es/components/DataTable/DataTable.js.map +1 -1
- package/dist/es/components/DataTable/DataTableColumnHeader.js +2 -2
- package/dist/es/components/DataTable/DataTableColumnHeader.js.map +1 -1
- package/dist/es/components/DataTable/DataTablePagination.js +8 -4
- package/dist/es/components/DataTable/DataTablePagination.js.map +1 -1
- package/dist/es/components/DataTable/columnHelpers.js +3 -3
- package/dist/es/components/DataTable/index.js +4 -4
- package/dist/es/components/DateInput/DateInput.js +21 -13
- package/dist/es/components/DateInput/DateInput.js.map +1 -1
- package/dist/es/components/DateInput/index.js +1 -1
- package/dist/es/components/DatePicker/Calendar.js +136 -32
- package/dist/es/components/DatePicker/Calendar.js.map +1 -1
- package/dist/es/components/DatePicker/DatePicker.js +15 -11
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DatePicker/index.js +1 -1
- package/dist/es/components/DateRangePicker/Calendar.js +125 -22
- package/dist/es/components/DateRangePicker/Calendar.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js +10 -9
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/Trigger.js +12 -9
- package/dist/es/components/DateRangePicker/Trigger.js.map +1 -1
- package/dist/es/components/DateRangePicker/index.js +2 -2
- package/dist/es/components/Dialog/Dialog.js +11 -6
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/index.js +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/EmptyMessage/EmptyMessage.js +4 -4
- package/dist/es/components/EmptyMessage/EmptyMessage.js.map +1 -1
- package/dist/es/components/EmptyMessage/index.js +1 -1
- package/dist/es/components/Field/Field.js +22 -7
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/Field/index.js +1 -1
- package/dist/es/components/FieldError/FieldError.js +4 -4
- package/dist/es/components/FieldError/FieldError.js.map +1 -1
- package/dist/es/components/FieldError/index.js +1 -1
- package/dist/es/components/FileUpload/FileUpload.js +12 -9
- package/dist/es/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/es/components/FileUpload/index.js +1 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +31 -4
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
- package/dist/es/components/FloatingLabelInput/index.js +1 -1
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js +28 -8
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js.map +1 -1
- package/dist/es/components/FloatingLabelSelect/index.js +1 -1
- package/dist/es/components/Icon/aliases.js +20 -20
- package/dist/es/components/Icon/index.js +653 -653
- package/dist/es/components/Image/Image.js +19 -7
- package/dist/es/components/Image/Image.js.map +1 -1
- package/dist/es/components/Image/index.js +1 -1
- package/dist/es/components/Indicator/CircularProgress.js +3 -3
- package/dist/es/components/Indicator/CircularProgress.js.map +1 -1
- package/dist/es/components/Indicator/LoadingDots.js +1 -1
- package/dist/es/components/Indicator/LoadingDots.js.map +1 -1
- package/dist/es/components/Indicator/LoadingIndicator.js +2 -2
- package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
- package/dist/es/components/Indicator/index.js +3 -3
- package/dist/es/components/Input/Input.js +16 -5
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/Input/index.js +1 -1
- package/dist/es/components/InputGroup/InputGroup.js +60 -0
- package/dist/es/components/InputGroup/InputGroup.js.map +1 -0
- package/dist/es/components/InputGroup/index.js +2 -0
- package/dist/es/components/InputGroup/index.js.map +1 -0
- package/dist/es/components/Kbd/Kbd.js +13 -0
- package/dist/es/components/Kbd/Kbd.js.map +1 -0
- package/dist/es/components/Kbd/index.js +2 -0
- package/dist/es/components/Kbd/index.js.map +1 -0
- package/dist/es/components/Label/Label.js +1 -1
- package/dist/es/components/Label/Label.js.map +1 -1
- package/dist/es/components/Label/index.js +1 -1
- package/dist/es/components/Markdown/Markdown.js +8 -8
- package/dist/es/components/Markdown/Markdown.js.map +1 -1
- package/dist/es/components/Markdown/directives.js +2 -2
- package/dist/es/components/Markdown/index.js +4 -5
- package/dist/es/components/Markdown/index.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +35 -11
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/MarkdownEditor/index.js +1 -1
- package/dist/es/components/Menu/Menu.js +26 -18
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Menu/index.js +1 -1
- package/dist/es/components/OTPInput/OTPInput.js +51 -34
- package/dist/es/components/OTPInput/OTPInput.js.map +1 -1
- package/dist/es/components/OTPInput/index.js +1 -1
- package/dist/es/components/PlexUIProvider/PlexUIProvider.js +3 -1
- package/dist/es/components/PlexUIProvider/PlexUIProvider.js.map +1 -1
- package/dist/es/components/PlexUIProvider/index.js +1 -1
- package/dist/es/components/PlexUIProvider/internal.js +1 -1
- package/dist/es/components/Popover/Popover.js +7 -7
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Popover/index.js +2 -3
- package/dist/es/components/Popover/index.js.map +1 -1
- package/dist/es/components/Popover/usePopoverController.js +2 -2
- package/dist/es/components/Progress/Progress.js +1 -1
- package/dist/es/components/Progress/Progress.js.map +1 -1
- package/dist/es/components/Progress/index.js +1 -1
- package/dist/es/components/ProgressSteps/ProgressSteps.js +6 -4
- package/dist/es/components/ProgressSteps/ProgressSteps.js.map +1 -1
- package/dist/es/components/ProgressSteps/index.js +1 -1
- package/dist/es/components/RadioGroup/RadioGroup.js +10 -6
- package/dist/es/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/es/components/RadioGroup/index.js +1 -1
- package/dist/es/components/SegmentedControl/index.js +1 -1
- package/dist/es/components/Select/Select.js +104 -67
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/Select/index.js +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +10 -5
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/SelectControl/index.js +1 -1
- package/dist/es/components/Separator/Separator.js +1 -1
- package/dist/es/components/Separator/Separator.js.map +1 -1
- package/dist/es/components/Separator/index.js +1 -1
- package/dist/es/components/ShimmerText/ShimmerText.js +1 -1
- package/dist/es/components/ShimmerText/ShimmerText.js.map +1 -1
- package/dist/es/components/ShimmerText/index.js +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +37 -29
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/components/Sidebar/index.js +2 -2
- package/dist/es/components/Sidebar/useSidebarContext.js +17 -19
- package/dist/es/components/Sidebar/useSidebarContext.js.map +1 -1
- package/dist/es/components/Skeleton/index.js +1 -1
- package/dist/es/components/Skeleton/index.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +48 -19
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Slider/index.js +1 -1
- package/dist/es/components/StatCard/StatCard.js +5 -5
- package/dist/es/components/StatCard/StatCard.js.map +1 -1
- package/dist/es/components/StatCard/index.js +1 -1
- package/dist/es/components/Switch/Switch.js +7 -3
- package/dist/es/components/Switch/Switch.js.map +1 -1
- package/dist/es/components/Switch/index.js +1 -1
- package/dist/es/components/Table/Table.js +1 -1
- package/dist/es/components/Table/Table.js.map +1 -1
- package/dist/es/components/Table/index.js +1 -1
- package/dist/es/components/Tabs/Tabs.js +154 -6
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/Tabs/index.js +1 -1
- package/dist/es/components/Tabs/overflow.js +44 -0
- package/dist/es/components/Tabs/overflow.js.map +1 -0
- package/dist/es/components/TagInput/TagInput.js +47 -23
- package/dist/es/components/TagInput/TagInput.js.map +1 -1
- package/dist/es/components/TagInput/index.js +1 -1
- package/dist/es/components/TextLink/TextLink.js +16 -5
- package/dist/es/components/TextLink/TextLink.js.map +1 -1
- package/dist/es/components/TextLink/index.js +1 -1
- package/dist/es/components/Textarea/Textarea.js +4 -4
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Textarea/index.js +1 -1
- package/dist/es/components/Toast/Toaster.js +2 -2
- package/dist/es/components/Toast/Toaster.js.map +1 -1
- package/dist/es/components/Toast/index.js +1 -1
- package/dist/es/components/Tooltip/CopyTooltip.js +30 -9
- package/dist/es/components/Tooltip/CopyTooltip.js.map +1 -1
- package/dist/es/components/Tooltip/Tooltip.js +3 -3
- package/dist/es/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/es/components/Tooltip/index.js +2 -2
- package/dist/es/components/Transition/Animate.js +4 -4
- package/dist/es/components/Transition/Animate.js.map +1 -1
- package/dist/es/components/Transition/AnimateLayout.js +4 -4
- package/dist/es/components/Transition/AnimateLayout.js.map +1 -1
- package/dist/es/components/Transition/AnimateLayoutGroup.js +12 -8
- package/dist/es/components/Transition/AnimateLayoutGroup.js.map +1 -1
- package/dist/es/components/Transition/SlotTransitionGroup.js +4 -4
- package/dist/es/components/Transition/TransitionGroup.js +5 -5
- package/dist/es/components/Transition/TransitionGroup.js.map +1 -1
- package/dist/es/components/Transition/getDisableAnimations.js +1 -1
- package/dist/es/components/Transition/index.js +5 -5
- package/dist/es/components/Transition/shared.js +7 -5
- package/dist/es/components/Transition/shared.js.map +1 -1
- package/dist/es/components/UIProvider/UIProvider.js +1 -1
- package/dist/es/components/UIProvider/index.js +1 -1
- package/dist/es/components/UIProvider/internal.js +1 -1
- package/dist/es/hooks/useAnimatedScrollTo.js +1 -1
- package/dist/es/hooks/useBreakpoints.js +8 -2
- package/dist/es/hooks/useBreakpoints.js.map +1 -1
- package/dist/es/hooks/useEscCloseStack.js +1 -1
- package/dist/es/hooks/usePrevious.js +7 -5
- package/dist/es/hooks/usePrevious.js.map +1 -1
- package/dist/es/hooks/useTextSelection.js +2 -2
- package/dist/es/hooks/useTrailingValue.js +1 -1
- package/dist/es/lib/constants.js +1 -1
- package/dist/es/lib/helpers.js +1 -1
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/es/lib/renderHelpers.js +15 -6
- package/dist/es/lib/renderHelpers.js.map +1 -1
- package/dist/es/lib/theme.js +16 -16
- package/dist/es/lib/theme.js.map +1 -1
- package/dist/es/lib/userAgent.js +3 -2
- package/dist/es/lib/userAgent.js.map +1 -1
- package/dist/es/styles/base.css +1 -102
- package/dist/es/styles/globals.css +1 -50
- package/dist/es/styles/index.css +1 -25
- package/dist/es/styles/katex.min.css +1 -1296
- package/dist/es/styles/tailwind-utilities.css +1 -1316
- package/dist/es/styles/variables-components.css +1 -626
- package/dist/es/styles/variables-primitive.css +1 -327
- package/dist/es/styles/variables-semantic.css +1 -609
- package/dist/es/styles/variables-tailwind-theme.css +1 -34
- package/dist/es/styles/variables-tokens-root.css +1 -41
- package/dist/es/types.js +1 -1
- package/dist/es/types.js.map +1 -1
- package/dist/es/vite/index.js +3 -53
- package/dist/es/vite/index.js.map +1 -1
- package/dist/types/components/Accordion/index.d.ts +1 -1
- package/dist/types/components/Alert/Alert.d.ts +8 -2
- package/dist/types/components/Alert/index.d.ts +1 -1
- package/dist/types/components/Avatar/Avatar.d.ts +1 -1
- package/dist/types/components/Avatar/index.d.ts +2 -2
- package/dist/types/components/Badge/index.d.ts +1 -1
- package/dist/types/components/Breadcrumb/Breadcrumb.d.ts +34 -0
- package/dist/types/components/Breadcrumb/index.d.ts +1 -0
- package/dist/types/components/Button/Button.d.ts +3 -3
- package/dist/types/components/Button/CopyButton.d.ts +9 -4
- package/dist/types/components/Button/index.d.ts +2 -2
- package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +4 -3
- package/dist/types/components/ButtonGroup/index.d.ts +1 -1
- package/dist/types/components/Card/index.d.ts +1 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +3 -1
- package/dist/types/components/Checkbox/index.d.ts +1 -1
- package/dist/types/components/CodeBlock/index.d.ts +2 -2
- package/dist/types/components/DataTable/DataTable.d.ts +3 -2
- package/dist/types/components/DataTable/index.d.ts +4 -4
- package/dist/types/components/DateInput/DateInput.d.ts +1 -1
- package/dist/types/components/DateInput/index.d.ts +1 -1
- package/dist/types/components/DatePicker/DatePicker.d.ts +7 -6
- package/dist/types/components/DatePicker/context.d.ts +1 -1
- package/dist/types/components/DatePicker/index.d.ts +2 -2
- package/dist/types/components/DateRangePicker/Calendar.d.ts +1 -1
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +5 -5
- package/dist/types/components/DateRangePicker/context.d.ts +2 -2
- package/dist/types/components/DateRangePicker/index.d.ts +2 -2
- package/dist/types/components/Dialog/Dialog.d.ts +19 -1
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/EmptyMessage/EmptyMessage.d.ts +15 -3
- package/dist/types/components/EmptyMessage/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts +14 -4
- package/dist/types/components/Field/index.d.ts +1 -1
- package/dist/types/components/FieldError/FieldError.d.ts +7 -1
- package/dist/types/components/FieldError/index.d.ts +1 -1
- package/dist/types/components/FileUpload/index.d.ts +1 -1
- package/dist/types/components/FloatingLabelInput/index.d.ts +1 -1
- package/dist/types/components/FloatingLabelSelect/index.d.ts +1 -1
- package/dist/types/components/Icon/aliases.d.ts +20 -20
- package/dist/types/components/Icon/index.d.ts +653 -653
- package/dist/types/components/Image/Image.d.ts +1 -1
- package/dist/types/components/Image/index.d.ts +1 -1
- package/dist/types/components/Indicator/index.d.ts +3 -3
- package/dist/types/components/Input/Input.d.ts +2 -2
- package/dist/types/components/Input/index.d.ts +1 -1
- package/dist/types/components/InputGroup/InputGroup.d.ts +78 -0
- package/dist/types/components/InputGroup/index.d.ts +1 -0
- package/dist/types/components/Kbd/Kbd.d.ts +20 -0
- package/dist/types/components/Kbd/index.d.ts +1 -0
- package/dist/types/components/Label/index.d.ts +1 -1
- package/dist/types/components/Markdown/Markdown.d.ts +1 -1
- package/dist/types/components/Markdown/index.d.ts +4 -4
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +6 -2
- package/dist/types/components/MarkdownEditor/index.d.ts +1 -1
- package/dist/types/components/Menu/Menu.d.ts +11 -3
- package/dist/types/components/Menu/index.d.ts +1 -1
- package/dist/types/components/OTPInput/index.d.ts +1 -1
- package/dist/types/components/PlexUIProvider/PlexUIProvider.d.ts +0 -11
- package/dist/types/components/PlexUIProvider/index.d.ts +1 -1
- package/dist/types/components/Popover/index.d.ts +2 -2
- package/dist/types/components/Progress/index.d.ts +1 -1
- package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +1 -1
- package/dist/types/components/ProgressSteps/index.d.ts +1 -1
- package/dist/types/components/RadioGroup/RadioGroup.d.ts +3 -1
- package/dist/types/components/RadioGroup/index.d.ts +1 -1
- package/dist/types/components/SegmentedControl/index.d.ts +2 -2
- package/dist/types/components/Select/Select.d.ts +8 -1
- package/dist/types/components/Select/index.d.ts +1 -1
- package/dist/types/components/SelectControl/SelectControl.d.ts +1 -1
- package/dist/types/components/SelectControl/index.d.ts +1 -1
- package/dist/types/components/Separator/index.d.ts +1 -1
- package/dist/types/components/ShimmerText/index.d.ts +1 -1
- package/dist/types/components/Sidebar/Sidebar.d.ts +4 -8
- package/dist/types/components/Sidebar/index.d.ts +4 -4
- package/dist/types/components/Slider/Slider.d.ts +8 -0
- package/dist/types/components/Slider/index.d.ts +2 -2
- package/dist/types/components/StatCard/index.d.ts +1 -1
- package/dist/types/components/Switch/index.d.ts +1 -1
- package/dist/types/components/Table/index.d.ts +1 -1
- package/dist/types/components/Tabs/Tabs.d.ts +15 -2
- package/dist/types/components/Tabs/index.d.ts +2 -2
- package/dist/types/components/Tabs/overflow.d.ts +17 -0
- package/dist/types/components/TagInput/TagInput.d.ts +1 -1
- package/dist/types/components/TagInput/index.d.ts +1 -1
- package/dist/types/components/TextLink/index.d.ts +1 -1
- package/dist/types/components/Textarea/Textarea.d.ts +1 -1
- package/dist/types/components/Textarea/index.d.ts +1 -1
- package/dist/types/components/Toast/index.d.ts +1 -1
- package/dist/types/components/Tooltip/CopyTooltip.d.ts +6 -1
- package/dist/types/components/Tooltip/index.d.ts +2 -2
- package/dist/types/components/Transition/Animate.d.ts +2 -2
- package/dist/types/components/Transition/AnimateLayout.d.ts +2 -2
- package/dist/types/components/Transition/AnimateLayoutGroup.d.ts +2 -2
- package/dist/types/components/Transition/SlotTransitionGroup.d.ts +1 -1
- package/dist/types/components/Transition/TransitionGroup.d.ts +1 -1
- package/dist/types/components/Transition/index.d.ts +5 -5
- package/dist/types/components/UIProvider/index.d.ts +1 -1
- package/dist/types/global.d.ts +5 -1
- package/dist/types/lib/constants.d.ts +1 -1
- package/dist/types/lib/helpers.d.ts +4 -4
- package/dist/types/lib/theme.d.ts +1 -1
- package/dist/types/types.d.ts +2 -15
- package/dist/types/vite/index.d.ts +2 -55
- package/package.json +10 -18
- package/dist/es/components/Accordion/Accordion.module.css +0 -89
- package/dist/es/components/Alert/Alert.module.css +0 -187
- package/dist/es/components/Avatar/Avatar.module.css +0 -168
- package/dist/es/components/Avatar/AvatarGroup.module.css +0 -26
- package/dist/es/components/Badge/Badge.module.css +0 -196
- package/dist/es/components/Button/Button.module.css +0 -859
- package/dist/es/components/ButtonGroup/ButtonGroup.module.css +0 -159
- package/dist/es/components/Card/Card.module.css +0 -125
- package/dist/es/components/Checkbox/Checkbox.module.css +0 -198
- package/dist/es/components/CodeBlock/CodeBlock.module.css +0 -137
- package/dist/es/components/DataTable/DataTable.module.css +0 -108
- package/dist/es/components/DatePicker/Calendar.module.css +0 -271
- package/dist/es/components/DateRangePicker/Calendar.module.css +0 -295
- package/dist/es/components/DateRangePicker/Trigger.module.css +0 -25
- package/dist/es/components/Dialog/Dialog.module.css +0 -133
- package/dist/es/components/EmptyMessage/EmptyMessage.module.css +0 -82
- package/dist/es/components/Field/Field.module.css +0 -137
- package/dist/es/components/FieldError/FieldError.module.css +0 -22
- package/dist/es/components/FileUpload/FileUpload.module.css +0 -133
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.module.css +0 -220
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.module.css +0 -146
- package/dist/es/components/Image/Image.module.css +0 -9
- package/dist/es/components/Indicator/CircularProgress.module.css +0 -28
- package/dist/es/components/Indicator/LoadingDots.module.css +0 -35
- package/dist/es/components/Indicator/LoadingIndicator.module.css +0 -41
- package/dist/es/components/Input/Input.module.css +0 -507
- package/dist/es/components/Label/Label.module.css +0 -16
- package/dist/es/components/Markdown/Markdown.module.css +0 -233
- package/dist/es/components/MarkdownEditor/MarkdownEditor.module.css +0 -297
- package/dist/es/components/Menu/Menu.module.css +0 -377
- package/dist/es/components/OTPInput/OTPInput.module.css +0 -66
- package/dist/es/components/Popover/Popover.module.css +0 -82
- package/dist/es/components/Progress/Progress.module.css +0 -34
- package/dist/es/components/ProgressSteps/ProgressSteps.module.css +0 -246
- package/dist/es/components/RadioGroup/RadioGroup.module.css +0 -137
- package/dist/es/components/Select/Select.module.css +0 -310
- package/dist/es/components/SelectControl/SelectControl.module.css +0 -558
- package/dist/es/components/Separator/Separator.module.css +0 -16
- package/dist/es/components/ShimmerText/ShimmerText.module.css +0 -43
- package/dist/es/components/Sidebar/Sidebar.module.css +0 -909
- package/dist/es/components/Skeleton/Skeleton.module.css +0 -17
- package/dist/es/components/Slider/Slider.module.css +0 -203
- package/dist/es/components/StatCard/StatCard.module.css +0 -234
- package/dist/es/components/Switch/Switch.module.css +0 -121
- package/dist/es/components/Table/Table.module.css +0 -56
- package/dist/es/components/Tabs/Tabs.module.css +0 -672
- package/dist/es/components/TagInput/TagInput.module.css +0 -320
- package/dist/es/components/TextLink/TextLink.module.css +0 -50
- package/dist/es/components/Textarea/Textarea.module.css +0 -272
- package/dist/es/components/Toast/Toast.module.css +0 -84
- package/dist/es/components/Tooltip/Tooltip.module.css +0 -91
- package/dist/es/components/Transition/Animate.module.css +0 -54
- package/dist/es/components/Transition/AnimateLayout.module.css +0 -101
- package/dist/es/components/Transition/AnimateLayoutGroup.module.css +0 -72
- package/dist/es/components/Transition/TransitionGroup.module.css +0 -4
|
@@ -2,13 +2,22 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { ToggleGroup } from "radix-ui";
|
|
5
|
-
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
5
|
+
import { Children, cloneElement, Fragment, isValidElement, useCallback, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
6
6
|
import { useResizeObserver } from "usehooks-ts";
|
|
7
|
-
import { handlePressableMouseEnter, waitForAnimationFrame } from "../../lib/helpers";
|
|
8
|
-
import {} from "../../types";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
7
|
+
import { handlePressableMouseEnter, waitForAnimationFrame } from "../../lib/helpers.js";
|
|
8
|
+
import {} from "../../types.js";
|
|
9
|
+
import { ChevronDownMd } from "../Icon/index.js";
|
|
10
|
+
import { LoadingIndicator } from "../Indicator/index.js";
|
|
11
|
+
import { Menu } from "../Menu/index.js";
|
|
12
|
+
import { fitCount, visibleTabCount } from "./overflow.js";
|
|
13
|
+
import s from "@plexui/styles/components/Tabs/Tabs.module.css";
|
|
14
|
+
export const Tabs = ({ overflow = "scroll", overflowLabel = "More", ...props }) => {
|
|
15
|
+
if (overflow === "menu" && !props.block && props.orientation !== "vertical") {
|
|
16
|
+
return _jsx(OverflowTabs, { ...props, overflowLabel: overflowLabel });
|
|
17
|
+
}
|
|
18
|
+
return _jsx(TabsRoot, { ...props });
|
|
19
|
+
};
|
|
20
|
+
const TabsRoot = ({ value, onChange, children, variant = "segmented", orientation = "horizontal", block, pill = true, flush, size = "md", gutterSize, className, onClick, ...restProps }) => {
|
|
12
21
|
const rootRef = useRef(null);
|
|
13
22
|
const thumbRef = useRef(null);
|
|
14
23
|
const prevSizeRef = useRef(size);
|
|
@@ -92,6 +101,24 @@ export const Tabs = ({ value, onChange, children, variant = "segmented", orienta
|
|
|
92
101
|
thumb.style.transition = currentTransition;
|
|
93
102
|
},
|
|
94
103
|
});
|
|
104
|
+
// Tabs added, removed, reordered or relabelled move the active tab without
|
|
105
|
+
// resizing the group: measure again, instantly, like a resize
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const root = rootRef.current;
|
|
108
|
+
if (!root || typeof MutationObserver === "undefined")
|
|
109
|
+
return;
|
|
110
|
+
const observer = new MutationObserver(() => {
|
|
111
|
+
const thumb = thumbRef.current;
|
|
112
|
+
if (!thumb)
|
|
113
|
+
return;
|
|
114
|
+
const currentTransition = thumb.style.transition;
|
|
115
|
+
thumb.style.transition = "";
|
|
116
|
+
applyThumbSizing(false);
|
|
117
|
+
thumb.style.transition = currentTransition;
|
|
118
|
+
});
|
|
119
|
+
observer.observe(root, { childList: true, characterData: true, subtree: true });
|
|
120
|
+
return () => observer.disconnect();
|
|
121
|
+
}, [applyThumbSizing]);
|
|
95
122
|
const transitionProperty = isVertical
|
|
96
123
|
? "height 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)"
|
|
97
124
|
: "width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)";
|
|
@@ -148,6 +175,127 @@ const Tab = ({ children, icon, badge, ...restProps }) => {
|
|
|
148
175
|
const badgeProps = badge != null ? (isBadgeObject(badge) ? badge : { content: badge }) : null;
|
|
149
176
|
return (_jsx(ToggleGroup.Item, { className: s.Tab, ...restProps, onPointerEnter: handlePressableMouseEnter, children: _jsxs("span", { className: s.TabContent, children: [icon, children && _jsx("span", { children: children }), badgeProps && (_jsx("span", { className: s.TabBadge, "data-color": badgeProps.color ?? "secondary", "data-variant": badgeProps.variant ?? "soft", "data-pill": badgeProps.pill ? "" : undefined, children: badgeProps.loading ? _jsx(LoadingIndicator, {}) : badgeProps.content }))] }) }));
|
|
150
177
|
};
|
|
178
|
+
// =============================================
|
|
179
|
+
// overflow="menu"
|
|
180
|
+
// =============================================
|
|
181
|
+
/** Value of the menu button; no real tab has it */
|
|
182
|
+
const MORE_VALUE = "__plexui_tabs_more__";
|
|
183
|
+
/** The tabs among the children, through fragments */
|
|
184
|
+
const tabElements = (children) => Children.toArray(children).flatMap((child) => {
|
|
185
|
+
if (!isValidElement(child))
|
|
186
|
+
return [];
|
|
187
|
+
return child.type === Fragment ? tabElements(child.props.children) : [child];
|
|
188
|
+
});
|
|
189
|
+
const plainText = (node) => {
|
|
190
|
+
if (typeof node === "string" || typeof node === "number")
|
|
191
|
+
return String(node);
|
|
192
|
+
if (Array.isArray(node))
|
|
193
|
+
return node.map(plainText).join("");
|
|
194
|
+
if (isValidElement(node))
|
|
195
|
+
return plainText(node.props.children);
|
|
196
|
+
return "";
|
|
197
|
+
};
|
|
198
|
+
const badgeText = (badge) => badge != null && isBadgeObject(badge) ? plainText(badge.content) : plainText(badge);
|
|
199
|
+
/** A tab's name: its text, else its accessible name, else its value */
|
|
200
|
+
const tabLabel = (item) => plainText(item.props.children) || item.props["aria-label"] || item.props.value;
|
|
201
|
+
/** What a tab's width depends on: the strip measures again when it changes */
|
|
202
|
+
const tabsSignature = (items) => items
|
|
203
|
+
.map((item) => [item.props.value, plainText(item.props.children), badgeText(item.props.badge), item.props.icon != null].join("\u0000"))
|
|
204
|
+
.join("\u0001");
|
|
205
|
+
/**
|
|
206
|
+
* `Menu.Trigger` sets `data-state` (open or closed) on its child, while a tab
|
|
207
|
+
* keeps `on` or `off` in the same attribute and the thumb finds the active tab
|
|
208
|
+
* by it. The menu's value does not reach the tab; its handlers and
|
|
209
|
+
* `aria-haspopup` / `aria-expanded` do.
|
|
210
|
+
*/
|
|
211
|
+
const MoreTab = ({ "data-state": _menuState, ...restProps }) => (_jsx(Tab, { ...restProps }));
|
|
212
|
+
const OverflowTabs = ({ children, value, onChange, overflowLabel, ...restProps }) => {
|
|
213
|
+
const items = tabElements(children);
|
|
214
|
+
// The strip's own props size the tabs and the menu button too
|
|
215
|
+
const { size, variant, gutterSize, pill, flush } = restProps;
|
|
216
|
+
const signature = [overflowLabel, size, variant, gutterSize, pill, flush, tabsSignature(items)].join("\u0002");
|
|
217
|
+
const activeIndex = items.findIndex((item) => item.props.value === value);
|
|
218
|
+
// null while the measuring pass renders every tab and the menu button
|
|
219
|
+
const [visibleCount, setVisibleCount] = useState(null);
|
|
220
|
+
const [known, setKnown] = useState({ signature, activeIndex });
|
|
221
|
+
const hostRef = useRef(null);
|
|
222
|
+
const measuringRef = useRef(true);
|
|
223
|
+
const boxWidthRef = useRef(-1);
|
|
224
|
+
// New tabs measure again. A new active tab measures again when it moves
|
|
225
|
+
// under the menu button or back out: the button carries the hidden one's name
|
|
226
|
+
if (known.signature !== signature || known.activeIndex !== activeIndex) {
|
|
227
|
+
const crossed = visibleCount !== null && (known.activeIndex >= visibleCount || activeIndex >= visibleCount);
|
|
228
|
+
setKnown({ signature, activeIndex });
|
|
229
|
+
if (visibleCount !== null && (known.signature !== signature || crossed))
|
|
230
|
+
setVisibleCount(null);
|
|
231
|
+
}
|
|
232
|
+
useLayoutEffect(() => {
|
|
233
|
+
measuringRef.current = visibleCount === null;
|
|
234
|
+
}, [visibleCount]);
|
|
235
|
+
useLayoutEffect(() => {
|
|
236
|
+
if (visibleCount !== null)
|
|
237
|
+
return;
|
|
238
|
+
const root = hostRef.current?.firstElementChild;
|
|
239
|
+
if (!(root instanceof HTMLElement))
|
|
240
|
+
return;
|
|
241
|
+
// The measuring pass renders every tab, then the menu button
|
|
242
|
+
const buttons = Array.from(root.querySelectorAll(":scope > button"));
|
|
243
|
+
if (buttons.length !== items.length + 1)
|
|
244
|
+
return;
|
|
245
|
+
const widths = buttons.map((button) => button.getBoundingClientRect().width);
|
|
246
|
+
const moreButton = buttons[buttons.length - 1];
|
|
247
|
+
const moreWidth = widths.pop() ?? 0;
|
|
248
|
+
const style = getComputedStyle(root);
|
|
249
|
+
const available = root.getBoundingClientRect().width -
|
|
250
|
+
(Number.parseFloat(style.paddingLeft) || 0) -
|
|
251
|
+
(Number.parseFloat(style.paddingRight) || 0);
|
|
252
|
+
const gap = Number.parseFloat(style.columnGap) || 0;
|
|
253
|
+
boxWidthRef.current = hostRef.current?.parentElement?.clientWidth ?? -1;
|
|
254
|
+
// A hidden strip has no width to decide by: show every tab, and measure
|
|
255
|
+
// when it appears (the observer sees the width change)
|
|
256
|
+
if (available <= 0) {
|
|
257
|
+
setVisibleCount(items.length);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
// The button with the active tab's name: that tab's width plus the chevron
|
|
261
|
+
const chevron = moreButton?.querySelector("svg");
|
|
262
|
+
const chevronWidth = chevron?.getBoundingClientRect().width ?? 0;
|
|
263
|
+
const labelGap = chevron?.parentElement ? Number.parseFloat(getComputedStyle(chevron.parentElement).columnGap) || 0 : 0;
|
|
264
|
+
const activeWidth = activeIndex < 0 ? 0 : (widths[activeIndex] ?? 0) + chevronWidth + labelGap;
|
|
265
|
+
setVisibleCount(visibleTabCount(widths, moreWidth, activeWidth, activeIndex, gap, available));
|
|
266
|
+
}, [visibleCount, items.length, activeIndex]);
|
|
267
|
+
// The width to fit is the container's, not the strip's: the strip shrinks
|
|
268
|
+
// to its content. Reports during a measuring pass are skipped, since the
|
|
269
|
+
// full strip may be pushing its container wider
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
const box = hostRef.current?.parentElement;
|
|
272
|
+
if (!box || typeof ResizeObserver === "undefined")
|
|
273
|
+
return;
|
|
274
|
+
const observer = new ResizeObserver(() => {
|
|
275
|
+
if (measuringRef.current)
|
|
276
|
+
return;
|
|
277
|
+
const width = box.clientWidth;
|
|
278
|
+
if (width === boxWidthRef.current)
|
|
279
|
+
return;
|
|
280
|
+
boxWidthRef.current = width;
|
|
281
|
+
setVisibleCount(null);
|
|
282
|
+
});
|
|
283
|
+
observer.observe(box);
|
|
284
|
+
return () => observer.disconnect();
|
|
285
|
+
}, []);
|
|
286
|
+
const measuring = visibleCount === null;
|
|
287
|
+
const shown = measuring ? items : items.slice(0, visibleCount);
|
|
288
|
+
const hidden = measuring ? [] : items.slice(visibleCount);
|
|
289
|
+
const hiddenActive = hidden.find((item) => item.props.value === value) ?? null;
|
|
290
|
+
return (_jsx("div", { ref: hostRef, className: s.OverflowHost, children: _jsxs(Menu, { children: [_jsxs(TabsRoot, { ...restProps, "data-overflow": "menu", value: hiddenActive ? MORE_VALUE : value, onChange: (next) => {
|
|
291
|
+
// Pressing the menu button opens the menu; it is not a tab
|
|
292
|
+
if (next !== MORE_VALUE)
|
|
293
|
+
onChange?.(next);
|
|
294
|
+
}, children: [shown.map((item) => cloneElement(item, { key: item.props.value })), (measuring || hidden.length > 0) && (_jsx(Menu.Trigger, { children: _jsx(MoreTab, { value: MORE_VALUE, children: _jsxs("span", { className: s.OverflowLabel, children: [hiddenActive ? tabLabel(hiddenActive) : overflowLabel, _jsx(ChevronDownMd, {})] }) }) }))] }), _jsx(Menu.Content, { align: "end", minWidth: "auto", children: _jsx(Menu.RadioGroup, { value: value, onChange: (next) => onChange?.(next), children: hidden.map((item) => {
|
|
295
|
+
const count = badgeText(item.props.badge);
|
|
296
|
+
return (_jsxs(Menu.RadioItem, { value: item.props.value, disabled: restProps.disabled || item.props.disabled, children: [item.props.icon, item.props.children ?? item.props["aria-label"] ?? item.props.value, count !== "" && _jsx("span", { className: s.OverflowBadge, children: count })] }, item.props.value));
|
|
297
|
+
}) }) })] }) }));
|
|
298
|
+
};
|
|
151
299
|
// Attach sub-components
|
|
152
300
|
Tabs.Tab = Tab;
|
|
153
301
|
// Backward-compat alias
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,i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{ useCallback, useLayoutEffect, useRef } from \"react\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { handlePressableMouseEnter, waitForAnimationFrame } from \"../../lib/helpers\"\nimport { type ControlSize, type SemanticColors, type Sizes, type Variants } from \"../../types\"\nimport { LoadingIndicator } from \"../Indicator\"\nimport s from \"./Tabs.module.css\"\n\nexport type SizeVariant = \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nexport type TabsVariant = \"segmented\" | \"underline\"\nexport type TabsOrientation = \"horizontal\" | \"vertical\"\n\nexport type TabsProps<T extends string> = {\n /**\n * Controlled value for the group\n */\n \"value\": T\n /** Callback for when a new value is selected */\n \"onChange\"?: (nextValue: T) => void\n /** Callback any time the control is clicked (even if a new value was not selected) */\n \"onClick\"?: () => void\n /**\n * Text read aloud to screen readers when the control is focused\n */\n \"aria-label\": string\n /**\n * Visual variant of the tab group\n * - `\"segmented\"` — background container with sliding highlight (default)\n * - `\"underline\"` — no background, animated line indicator under active tab\n * @default \"segmented\"\n */\n \"variant\"?: TabsVariant\n /**\n * Orientation of the tab layout\n * @default \"horizontal\"\n */\n \"orientation\"?: TabsOrientation\n /**\n * Controls the size of the tabs\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n *\n * @default md\n */\n \"size\"?: ControlSize\n /**\n * Controls gutter on the edges of the button, defaults to value from `size`.\n *\n * | 2xs | xs | sm | md | lg | xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `6px` | `8px` | `10px` | `12px` | `14px` | `16px` |\n */\n \"gutterSize\"?: Sizes<\"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">\n /** Disable the entire group */\n \"disabled\"?: boolean\n /**\n * Display the control as a block element with equal width segments\n * @default false\n */\n \"block\"?: boolean\n /**\n * Determines if the tabs should be a fully rounded pill shape.\n * Only applies to the `\"segmented\"` variant.\n * @default true\n */\n \"pill\"?: boolean\n /**\n * Flush underline style — removes tab padding so the indicator\n * matches the text width exactly, uses gap for spacing, and\n * removes the bottom border.\n * Only applies to the `\"underline\"` variant.\n * @default false\n */\n \"flush\"?: boolean\n \"className\"?: string\n \"children\": React.ReactNode\n}\n\nexport const Tabs = <T extends string>({\n value,\n onChange,\n children,\n variant = \"segmented\",\n orientation = \"horizontal\",\n block,\n pill = true,\n flush,\n size = \"md\",\n gutterSize,\n className,\n onClick,\n ...restProps\n}: TabsProps<T>) => {\n const rootRef = useRef<HTMLDivElement>(null)\n const thumbRef = useRef<HTMLDivElement>(null)\n const prevSizeRef = useRef(size)\n const isVertical = orientation === \"vertical\"\n\n const applyThumbSizing = useCallback(\n (attemptScroll: boolean) => {\n const root = rootRef.current\n const thumb = thumbRef.current\n\n if (!root || !thumb) {\n return\n }\n\n // Get selected node\n const activeNode = root?.querySelector<HTMLDivElement>('[data-state=\"on\"]')\n\n // Impossible\n if (!activeNode) {\n return\n }\n\n if (isVertical) {\n const rootHeight = root.clientHeight\n let targetHeight = Math.floor(activeNode.clientHeight)\n const targetOffset = activeNode.offsetTop\n\n // Detect subpixel edge case\n if (rootHeight - (targetHeight + targetOffset) < 2) {\n targetHeight = targetHeight - 1\n }\n\n thumb.style.height = `${Math.floor(targetHeight)}px`\n thumb.style.width = \"\"\n thumb.style.transform = `translateY(${targetOffset}px)`\n\n // Scroll into view if needed\n if (root.scrollHeight > rootHeight) {\n const buffer = rootHeight * 0.15\n const scrollTop = root.scrollTop\n const top = activeNode.offsetTop\n const bottom = top + targetHeight\n if (top < scrollTop + buffer || bottom > scrollTop + rootHeight - buffer) {\n if (attemptScroll) {\n activeNode.scrollIntoView({ block: \"center\", inline: \"nearest\", behavior: \"smooth\" })\n }\n }\n }\n } else {\n const rootWidth = root.clientWidth\n let targetWidth = Math.floor(activeNode.clientWidth)\n const targetOffset = activeNode.offsetLeft\n\n // Detect if the thumb is moving too far to the edge of the container.\n // This would most commonly be due to subpixel widths adding up to excessive distance.\n if (rootWidth - (targetWidth + targetOffset) < 2) {\n targetWidth = targetWidth - 1\n }\n\n thumb.style.width = `${Math.floor(targetWidth)}px`\n thumb.style.height = \"\"\n thumb.style.transform = `translateX(${targetOffset}px)`\n\n // If the control is scrollable, ensure the active option is visible\n if (root.scrollWidth > rootWidth) {\n // Only scroll items near the edge, but not the inner 2/3.\n const buffer = rootWidth * 0.15\n const scrollLeft = root.scrollLeft\n const left = activeNode.offsetLeft\n const right = left + targetWidth\n if (left < scrollLeft + buffer || right > scrollLeft + rootWidth - buffer) {\n // Cheap trick to avoid unintentional scroll on mount - transition is set after mounting\n if (attemptScroll) {\n activeNode.scrollIntoView({ block: \"nearest\", inline: \"center\", behavior: \"smooth\" })\n }\n }\n }\n }\n },\n [isVertical],\n )\n\n useResizeObserver({\n // @ts-expect-error(2322) -- bug in types: https://github.com/juliencrn/usehooks-ts/issues/663\n ref: rootRef,\n onResize: () => {\n const thumb = thumbRef.current\n\n if (!thumb) {\n return\n }\n\n // Perform the size update instantly\n const currentTransition = thumb.style.transition\n thumb.style.transition = \"\"\n applyThumbSizing(false)\n thumb.style.transition = currentTransition\n },\n })\n\n const transitionProperty = isVertical\n ? \"height 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)\"\n : \"width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)\"\n\n useLayoutEffect(() => {\n const root = rootRef.current\n const thumb = thumbRef.current\n\n if (!root || !thumb) {\n return\n }\n\n const sizeChanged = prevSizeRef.current !== size\n prevSizeRef.current = size\n\n if (sizeChanged) {\n // Size changed - disable transition, wait for CSS, then apply sizing\n const currentTransition = thumb.style.transition\n thumb.style.transition = \"\"\n\n waitForAnimationFrame(() => {\n applyThumbSizing(false)\n waitForAnimationFrame(() => {\n thumb.style.transition = currentTransition\n })\n })\n } else {\n // Normal update (value change, etc.)\n waitForAnimationFrame(() => {\n applyThumbSizing(!!thumb.style.transition)\n\n // Apply transition after initial calculation is set\n if (!thumb.style.transition) {\n waitForAnimationFrame(() => {\n thumb.style.transition = transitionProperty\n })\n }\n })\n }\n }, [applyThumbSizing, value, size, gutterSize, pill, flush, transitionProperty])\n\n const handleValueChange = (nextValue: T) => {\n // Only trigger onChange when a value exists\n // Disallow toggling off enabled items\n if (nextValue && onChange) onChange(nextValue)\n }\n\n // Only apply pill for segmented variant\n const isPill = variant === \"segmented\" && pill\n // Only apply flush for underline variant\n const isFlush = variant === \"underline\" && flush\n\n return (\n <ToggleGroup.Root\n ref={rootRef}\n className={clsx(s.Tabs, className)}\n type=\"single\"\n value={value}\n loop={false}\n onValueChange={handleValueChange}\n onClick={onClick}\n data-variant={variant}\n data-orientation={orientation}\n data-block={block ? \"\" : undefined}\n data-pill={isPill ? \"\" : undefined}\n data-flush={isFlush ? \"\" : undefined}\n data-size={size}\n data-gutter-size={gutterSize}\n {...restProps}\n >\n <div className={s.TabsThumb} ref={thumbRef} />\n {children}\n </ToggleGroup.Root>\n )\n}\n\n/**\n * Badge configuration for Tabs.Tab\n */\nexport type TabsBadgeProp =\n | React.ReactNode\n | {\n content: React.ReactNode\n color?: SemanticColors<\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n >\n variant?: Variants<\"soft\" | \"solid\">\n pill?: boolean\n loading?: boolean\n }\n\nexport type TabProps = {\n /**\n * Tab value\n */\n \"value\": string\n /**\n * Text read aloud to screen readers when the tab is focused\n */\n \"aria-label\"?: string\n /**\n * Text content to render in the tab\n */\n \"children\"?: React.ReactNode\n /**\n * Icon to render before the text content\n */\n \"icon\"?: React.ReactNode\n /**\n * Badge to render after the text content.\n * Can be a simple value or an object with content, color, variant, and loading options.\n * @example badge={5}\n * @example badge={{ content: 5, color: \"danger\" }}\n */\n \"badge\"?: TabsBadgeProp\n /**\n * Disable the individual tab\n */\n \"disabled\"?: boolean\n}\n\n// Type guard for badge object form\nconst isBadgeObject = (\n badge: TabsBadgeProp,\n): badge is Exclude<TabsBadgeProp, React.ReactNode> & { content: React.ReactNode } => {\n return badge != null && typeof badge === \"object\" && \"content\" in badge\n}\n\nconst Tab = ({ children, icon, badge, ...restProps }: TabProps) => {\n // Normalize badge prop\n const badgeProps = badge != null ? (isBadgeObject(badge) ? badge : { content: badge }) : null\n\n return (\n <ToggleGroup.Item\n className={s.Tab}\n {...restProps}\n onPointerEnter={handlePressableMouseEnter}\n >\n <span className={s.TabContent}>\n {icon}\n {children && <span>{children}</span>}\n {badgeProps && (\n <span\n className={s.TabBadge}\n data-color={badgeProps.color ?? \"secondary\"}\n data-variant={badgeProps.variant ?? \"soft\"}\n data-pill={badgeProps.pill ? \"\" : undefined}\n >\n {badgeProps.loading ? <LoadingIndicator /> : badgeProps.content}\n </span>\n )}\n </span>\n </ToggleGroup.Item>\n )\n}\n\n// Attach sub-components\nTabs.Tab = Tab\n// Backward-compat alias\nTabs.Option = Tab\n"]}
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACpF,OAAO,EAAoE,MAAM,aAAa,CAAA;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CA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AEb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,aAElD,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAEnE,KAAK,KAAK,EAAE,IAAI,eAAM,SAAS,EAAE,CAAC,CAAC,aAAa,YAAG,KAAK,GAAQ,KAP5D,IAAI,CAAC,KAAK,CAAC,KAAK,CAQN,CAClB,CAAA;wBACH,CAAC,CAAC,GACc,GACL,IACV,GACH,CACP,CAAA;AACH,CAAC,CAAA;AAED,wBAAwB;AACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;AACd,wBAAwB;AACxB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { ToggleGroup } from \"radix-ui\"\nimport {\n Children,\n cloneElement,\n Fragment,\n isValidElement,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ReactElement,\n type ReactNode,\n} from \"react\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { handlePressableMouseEnter, waitForAnimationFrame } from \"../../lib/helpers\"\nimport { type ControlSize, type SemanticColors, type Sizes, type Variants } from \"../../types\"\nimport { ChevronDownMd } from \"../Icon\"\nimport { LoadingIndicator } from \"../Indicator\"\nimport { Menu } from \"../Menu\"\nimport { fitCount, visibleTabCount } from \"./overflow\"\nimport s from \"@plexui/styles/components/Tabs/Tabs.module.css\"\n\nexport type SizeVariant = \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nexport type TabsVariant = \"segmented\" | \"underline\"\nexport type TabsOrientation = \"horizontal\" | \"vertical\"\n\nexport type TabsProps<T extends string> = {\n /**\n * Controlled value for the group\n */\n \"value\": T\n /** Callback for when a new value is selected */\n \"onChange\"?: (nextValue: T) => void\n /** Callback any time the control is clicked (even if a new value was not selected) */\n \"onClick\"?: () => void\n /**\n * Text read aloud to screen readers when the control is focused\n */\n \"aria-label\": string\n /**\n * Visual variant of the tab group\n * - `\"segmented\"` — background container with sliding highlight (default)\n * - `\"underline\"` — no background, animated line indicator under active tab\n * @default \"segmented\"\n */\n \"variant\"?: TabsVariant\n /**\n * Orientation of the tab layout\n * @default \"horizontal\"\n */\n \"orientation\"?: TabsOrientation\n /**\n * Controls the size of the tabs\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n *\n * @default md\n */\n \"size\"?: ControlSize\n /**\n * Controls gutter on the edges of the button, defaults to value from `size`.\n *\n * | 2xs | xs | sm | md | lg | xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `6px` | `8px` | `10px` | `12px` | `14px` | `16px` |\n */\n \"gutterSize\"?: Sizes<\"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">\n /** Disable the entire group */\n \"disabled\"?: boolean\n /**\n * Display the control as a block element with equal width segments\n * @default false\n */\n \"block\"?: boolean\n /**\n * Determines if the tabs should be a fully rounded pill shape.\n * Only applies to the `\"segmented\"` variant.\n * @default true\n */\n \"pill\"?: boolean\n /**\n * Flush underline style — removes tab padding so the indicator\n * matches the text width exactly, uses gap for spacing, and\n * removes the bottom border.\n * Only applies to the `\"underline\"` variant.\n * @default false\n */\n \"flush\"?: boolean\n /**\n * What happens to tabs that do not fit in one row: the strip scrolls\n * sideways (`scroll`), or the tabs that do not fit move into a menu at the\n * end of the strip (`menu`). The menu button shows the active tab's name\n * when it is one of the hidden ones. Horizontal tabs without `block` only.\n * @default \"scroll\"\n */\n \"overflow\"?: \"scroll\" | \"menu\"\n /**\n * Text of the menu button with `overflow=\"menu\"`\n * @default \"More\"\n */\n \"overflowLabel\"?: string\n \"className\"?: string\n \"children\": React.ReactNode\n}\n\nexport const Tabs = <T extends string>({ overflow = \"scroll\", overflowLabel = \"More\", ...props }: TabsProps<T>) => {\n if (overflow === \"menu\" && !props.block && props.orientation !== \"vertical\") {\n return <OverflowTabs {...props} overflowLabel={overflowLabel} />\n }\n return <TabsRoot {...props} />\n}\n\nconst TabsRoot = <T extends string>({\n value,\n onChange,\n children,\n variant = \"segmented\",\n orientation = \"horizontal\",\n block,\n pill = true,\n flush,\n size = \"md\",\n gutterSize,\n className,\n onClick,\n ...restProps\n}: Omit<TabsProps<T>, \"overflow\" | \"overflowLabel\">) => {\n const rootRef = useRef<HTMLDivElement>(null)\n const thumbRef = useRef<HTMLDivElement>(null)\n const prevSizeRef = useRef(size)\n const isVertical = orientation === \"vertical\"\n\n const applyThumbSizing = useCallback(\n (attemptScroll: boolean) => {\n const root = rootRef.current\n const thumb = thumbRef.current\n\n if (!root || !thumb) {\n return\n }\n\n // Get selected node\n const activeNode = root?.querySelector<HTMLDivElement>('[data-state=\"on\"]')\n\n // Impossible\n if (!activeNode) {\n return\n }\n\n if (isVertical) {\n const rootHeight = root.clientHeight\n let targetHeight = Math.floor(activeNode.clientHeight)\n const targetOffset = activeNode.offsetTop\n\n // Detect subpixel edge case\n if (rootHeight - (targetHeight + targetOffset) < 2) {\n targetHeight = targetHeight - 1\n }\n\n thumb.style.height = `${Math.floor(targetHeight)}px`\n thumb.style.width = \"\"\n thumb.style.transform = `translateY(${targetOffset}px)`\n\n // Scroll into view if needed\n if (root.scrollHeight > rootHeight) {\n const buffer = rootHeight * 0.15\n const scrollTop = root.scrollTop\n const top = activeNode.offsetTop\n const bottom = top + targetHeight\n if (top < scrollTop + buffer || bottom > scrollTop + rootHeight - buffer) {\n if (attemptScroll) {\n activeNode.scrollIntoView({ block: \"center\", inline: \"nearest\", behavior: \"smooth\" })\n }\n }\n }\n } else {\n const rootWidth = root.clientWidth\n let targetWidth = Math.floor(activeNode.clientWidth)\n const targetOffset = activeNode.offsetLeft\n\n // Detect if the thumb is moving too far to the edge of the container.\n // This would most commonly be due to subpixel widths adding up to excessive distance.\n if (rootWidth - (targetWidth + targetOffset) < 2) {\n targetWidth = targetWidth - 1\n }\n\n thumb.style.width = `${Math.floor(targetWidth)}px`\n thumb.style.height = \"\"\n thumb.style.transform = `translateX(${targetOffset}px)`\n\n // If the control is scrollable, ensure the active option is visible\n if (root.scrollWidth > rootWidth) {\n // Only scroll items near the edge, but not the inner 2/3.\n const buffer = rootWidth * 0.15\n const scrollLeft = root.scrollLeft\n const left = activeNode.offsetLeft\n const right = left + targetWidth\n if (left < scrollLeft + buffer || right > scrollLeft + rootWidth - buffer) {\n // Cheap trick to avoid unintentional scroll on mount - transition is set after mounting\n if (attemptScroll) {\n activeNode.scrollIntoView({ block: \"nearest\", inline: \"center\", behavior: \"smooth\" })\n }\n }\n }\n }\n },\n [isVertical],\n )\n\n useResizeObserver({\n // @ts-expect-error(2322) -- bug in types: https://github.com/juliencrn/usehooks-ts/issues/663\n ref: rootRef,\n onResize: () => {\n const thumb = thumbRef.current\n\n if (!thumb) {\n return\n }\n\n // Perform the size update instantly\n const currentTransition = thumb.style.transition\n thumb.style.transition = \"\"\n applyThumbSizing(false)\n thumb.style.transition = currentTransition\n },\n })\n\n // Tabs added, removed, reordered or relabelled move the active tab without\n // resizing the group: measure again, instantly, like a resize\n useEffect(() => {\n const root = rootRef.current\n if (!root || typeof MutationObserver === \"undefined\") return\n const observer = new MutationObserver(() => {\n const thumb = thumbRef.current\n if (!thumb) return\n const currentTransition = thumb.style.transition\n thumb.style.transition = \"\"\n applyThumbSizing(false)\n thumb.style.transition = currentTransition\n })\n observer.observe(root, { childList: true, characterData: true, subtree: true })\n return () => observer.disconnect()\n }, [applyThumbSizing])\n\n const transitionProperty = isVertical\n ? \"height 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)\"\n : \"width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)\"\n\n useLayoutEffect(() => {\n const root = rootRef.current\n const thumb = thumbRef.current\n\n if (!root || !thumb) {\n return\n }\n\n const sizeChanged = prevSizeRef.current !== size\n prevSizeRef.current = size\n\n if (sizeChanged) {\n // Size changed - disable transition, wait for CSS, then apply sizing\n const currentTransition = thumb.style.transition\n thumb.style.transition = \"\"\n\n waitForAnimationFrame(() => {\n applyThumbSizing(false)\n waitForAnimationFrame(() => {\n thumb.style.transition = currentTransition\n })\n })\n } else {\n // Normal update (value change, etc.)\n waitForAnimationFrame(() => {\n applyThumbSizing(!!thumb.style.transition)\n\n // Apply transition after initial calculation is set\n if (!thumb.style.transition) {\n waitForAnimationFrame(() => {\n thumb.style.transition = transitionProperty\n })\n }\n })\n }\n }, [applyThumbSizing, value, size, gutterSize, pill, flush, transitionProperty])\n\n const handleValueChange = (nextValue: T) => {\n // Only trigger onChange when a value exists\n // Disallow toggling off enabled items\n if (nextValue && onChange) onChange(nextValue)\n }\n\n // Only apply pill for segmented variant\n const isPill = variant === \"segmented\" && pill\n // Only apply flush for underline variant\n const isFlush = variant === \"underline\" && flush\n\n return (\n <ToggleGroup.Root\n ref={rootRef}\n className={clsx(s.Tabs, className)}\n type=\"single\"\n value={value}\n loop={false}\n onValueChange={handleValueChange}\n onClick={onClick}\n data-variant={variant}\n data-orientation={orientation}\n data-block={block ? \"\" : undefined}\n data-pill={isPill ? \"\" : undefined}\n data-flush={isFlush ? \"\" : undefined}\n data-size={size}\n data-gutter-size={gutterSize}\n {...restProps}\n >\n <div className={s.TabsThumb} ref={thumbRef} />\n {children}\n </ToggleGroup.Root>\n )\n}\n\n/**\n * Badge configuration for Tabs.Tab\n */\nexport type TabsBadgeProp =\n | React.ReactNode\n | {\n content: React.ReactNode\n color?: SemanticColors<\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n >\n variant?: Variants<\"soft\" | \"solid\">\n pill?: boolean\n loading?: boolean\n }\n\nexport type TabProps = {\n /**\n * Tab value\n */\n \"value\": string\n /**\n * Text read aloud to screen readers when the tab is focused\n */\n \"aria-label\"?: string\n /**\n * Text content to render in the tab\n */\n \"children\"?: React.ReactNode\n /**\n * Icon to render before the text content\n */\n \"icon\"?: React.ReactNode\n /**\n * Badge to render after the text content.\n * Can be a simple value or an object with content, color, variant, and loading options.\n * @example badge={5}\n * @example badge={{ content: 5, color: \"danger\" }}\n */\n \"badge\"?: TabsBadgeProp\n /**\n * Disable the individual tab\n */\n \"disabled\"?: boolean\n}\n\n// Type guard for badge object form\nconst isBadgeObject = (\n badge: TabsBadgeProp,\n): badge is Exclude<TabsBadgeProp, React.ReactNode> & { content: React.ReactNode } => {\n return badge != null && typeof badge === \"object\" && \"content\" in badge\n}\n\nconst Tab = ({ children, icon, badge, ...restProps }: TabProps) => {\n // Normalize badge prop\n const badgeProps = badge != null ? (isBadgeObject(badge) ? badge : { content: badge }) : null\n\n return (\n <ToggleGroup.Item\n className={s.Tab}\n {...restProps}\n onPointerEnter={handlePressableMouseEnter}\n >\n <span className={s.TabContent}>\n {icon}\n {children && <span>{children}</span>}\n {badgeProps && (\n <span\n className={s.TabBadge}\n data-color={badgeProps.color ?? \"secondary\"}\n data-variant={badgeProps.variant ?? \"soft\"}\n data-pill={badgeProps.pill ? \"\" : undefined}\n >\n {badgeProps.loading ? <LoadingIndicator /> : badgeProps.content}\n </span>\n )}\n </span>\n </ToggleGroup.Item>\n )\n}\n\n// =============================================\n// overflow=\"menu\"\n// =============================================\n\n/** Value of the menu button; no real tab has it */\nconst MORE_VALUE = \"__plexui_tabs_more__\"\n\ntype TabElement = ReactElement<TabProps>\n\n/** The tabs among the children, through fragments */\nconst tabElements = (children: ReactNode): TabElement[] =>\n Children.toArray(children).flatMap((child) => {\n if (!isValidElement<{ children?: ReactNode }>(child)) return []\n return child.type === Fragment ? tabElements(child.props.children) : [child as TabElement]\n })\n\nconst plainText = (node: unknown): string => {\n if (typeof node === \"string\" || typeof node === \"number\") return String(node)\n if (Array.isArray(node)) return node.map(plainText).join(\"\")\n if (isValidElement<{ children?: ReactNode }>(node)) return plainText(node.props.children)\n return \"\"\n}\n\nconst badgeText = (badge: TabsBadgeProp | undefined) =>\n badge != null && isBadgeObject(badge) ? plainText(badge.content) : plainText(badge)\n\n/** A tab's name: its text, else its accessible name, else its value */\nconst tabLabel = (item: TabElement) => plainText(item.props.children) || item.props[\"aria-label\"] || item.props.value\n\n/** What a tab's width depends on: the strip measures again when it changes */\nconst tabsSignature = (items: TabElement[]) =>\n items\n .map((item) =>\n [item.props.value, plainText(item.props.children), badgeText(item.props.badge), item.props.icon != null].join(\"\\u0000\"),\n )\n .join(\"\\u0001\")\n\n/**\n * `Menu.Trigger` sets `data-state` (open or closed) on its child, while a tab\n * keeps `on` or `off` in the same attribute and the thumb finds the active tab\n * by it. The menu's value does not reach the tab; its handlers and\n * `aria-haspopup` / `aria-expanded` do.\n */\nconst MoreTab = ({ \"data-state\": _menuState, ...restProps }: TabProps & { \"data-state\"?: string }) => (\n <Tab {...restProps} />\n)\n\nconst OverflowTabs = <T extends string>({\n children,\n value,\n onChange,\n overflowLabel,\n ...restProps\n}: Omit<TabsProps<T>, \"overflow\"> & { overflowLabel: string }) => {\n const items = tabElements(children)\n // The strip's own props size the tabs and the menu button too\n const { size, variant, gutterSize, pill, flush } = restProps\n const signature = [overflowLabel, size, variant, gutterSize, pill, flush, tabsSignature(items)].join(\"\\u0002\")\n const activeIndex = items.findIndex((item) => item.props.value === value)\n\n // null while the measuring pass renders every tab and the menu button\n const [visibleCount, setVisibleCount] = useState<number | null>(null)\n const [known, setKnown] = useState({ signature, activeIndex })\n const hostRef = useRef<HTMLDivElement>(null)\n const measuringRef = useRef(true)\n const boxWidthRef = useRef(-1)\n\n // New tabs measure again. A new active tab measures again when it moves\n // under the menu button or back out: the button carries the hidden one's name\n if (known.signature !== signature || known.activeIndex !== activeIndex) {\n const crossed =\n visibleCount !== null && (known.activeIndex >= visibleCount || activeIndex >= visibleCount)\n setKnown({ signature, activeIndex })\n if (visibleCount !== null && (known.signature !== signature || crossed)) setVisibleCount(null)\n }\n\n useLayoutEffect(() => {\n measuringRef.current = visibleCount === null\n }, [visibleCount])\n\n useLayoutEffect(() => {\n if (visibleCount !== null) return\n const root = hostRef.current?.firstElementChild\n if (!(root instanceof HTMLElement)) return\n\n // The measuring pass renders every tab, then the menu button\n const buttons = Array.from(root.querySelectorAll<HTMLElement>(\":scope > button\"))\n if (buttons.length !== items.length + 1) return\n\n const widths = buttons.map((button) => button.getBoundingClientRect().width)\n const moreButton = buttons[buttons.length - 1]\n const moreWidth = widths.pop() ?? 0\n const style = getComputedStyle(root)\n const available =\n root.getBoundingClientRect().width -\n (Number.parseFloat(style.paddingLeft) || 0) -\n (Number.parseFloat(style.paddingRight) || 0)\n const gap = Number.parseFloat(style.columnGap) || 0\n boxWidthRef.current = hostRef.current?.parentElement?.clientWidth ?? -1\n\n // A hidden strip has no width to decide by: show every tab, and measure\n // when it appears (the observer sees the width change)\n if (available <= 0) {\n setVisibleCount(items.length)\n return\n }\n\n // The button with the active tab's name: that tab's width plus the chevron\n const chevron = moreButton?.querySelector(\"svg\")\n const chevronWidth = chevron?.getBoundingClientRect().width ?? 0\n const labelGap = chevron?.parentElement ? Number.parseFloat(getComputedStyle(chevron.parentElement).columnGap) || 0 : 0\n const activeWidth = activeIndex < 0 ? 0 : (widths[activeIndex] ?? 0) + chevronWidth + labelGap\n\n setVisibleCount(visibleTabCount(widths, moreWidth, activeWidth, activeIndex, gap, available))\n }, [visibleCount, items.length, activeIndex])\n\n // The width to fit is the container's, not the strip's: the strip shrinks\n // to its content. Reports during a measuring pass are skipped, since the\n // full strip may be pushing its container wider\n useEffect(() => {\n const box = hostRef.current?.parentElement\n if (!box || typeof ResizeObserver === \"undefined\") return\n const observer = new ResizeObserver(() => {\n if (measuringRef.current) return\n const width = box.clientWidth\n if (width === boxWidthRef.current) return\n boxWidthRef.current = width\n setVisibleCount(null)\n })\n observer.observe(box)\n return () => observer.disconnect()\n }, [])\n\n const measuring = visibleCount === null\n const shown = measuring ? items : items.slice(0, visibleCount)\n const hidden = measuring ? [] : items.slice(visibleCount)\n const hiddenActive = hidden.find((item) => item.props.value === value) ?? null\n\n return (\n <div ref={hostRef} className={s.OverflowHost}>\n <Menu>\n <TabsRoot<string>\n {...restProps}\n data-overflow=\"menu\"\n value={hiddenActive ? MORE_VALUE : value}\n onChange={(next) => {\n // Pressing the menu button opens the menu; it is not a tab\n if (next !== MORE_VALUE) onChange?.(next as T)\n }}\n >\n {/* Keyed by value: tabs from different fragments may share a key */}\n {shown.map((item) => cloneElement(item, { key: item.props.value }))}\n {(measuring || hidden.length > 0) && (\n <Menu.Trigger>\n <MoreTab value={MORE_VALUE}>\n <span className={s.OverflowLabel}>\n {hiddenActive ? tabLabel(hiddenActive) : overflowLabel}\n <ChevronDownMd />\n </span>\n </MoreTab>\n </Menu.Trigger>\n )}\n </TabsRoot>\n <Menu.Content align=\"end\" minWidth=\"auto\">\n <Menu.RadioGroup<string> value={value} onChange={(next) => onChange?.(next as T)}>\n {hidden.map((item) => {\n const count = badgeText(item.props.badge)\n return (\n <Menu.RadioItem<string>\n key={item.props.value}\n value={item.props.value}\n disabled={restProps.disabled || item.props.disabled}\n >\n {item.props.icon}\n {item.props.children ?? item.props[\"aria-label\"] ?? item.props.value}\n {/* A tab's count moves into the menu with it */}\n {count !== \"\" && <span className={s.OverflowBadge}>{count}</span>}\n </Menu.RadioItem>\n )\n })}\n </Menu.RadioGroup>\n </Menu.Content>\n </Menu>\n </div>\n )\n}\n\n// Attach sub-components\nTabs.Tab = Tab\n// Backward-compat alias\nTabs.Option = Tab\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Tabs } from "./Tabs";
|
|
1
|
+
export { Tabs } from "./Tabs.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Width math for `Tabs overflow="menu"`: how many tabs fit before the menu
|
|
3
|
+
* button. Shared by the React and Vue packages (the Vue copy must match).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Slack for subpixels. Widths are fractional (`getBoundingClientRect`), and a
|
|
7
|
+
* tab that fits exactly is sometimes off by the last digit; without the
|
|
8
|
+
* tolerance the strip would flicker between two counts.
|
|
9
|
+
*/
|
|
10
|
+
const FIT_TOLERANCE_PX = 0.5;
|
|
11
|
+
/**
|
|
12
|
+
* How many tabs fit. When all of them do, the count is their number and no
|
|
13
|
+
* menu button is needed; otherwise room for the button is taken first.
|
|
14
|
+
*/
|
|
15
|
+
export function fitCount(widths, moreWidth, gap, available) {
|
|
16
|
+
const total = widths.reduce((sum, width, index) => sum + width + (index > 0 ? gap : 0), 0);
|
|
17
|
+
if (total <= available + FIT_TOLERANCE_PX)
|
|
18
|
+
return widths.length;
|
|
19
|
+
const budget = available - moreWidth - gap;
|
|
20
|
+
let used = 0;
|
|
21
|
+
let count = 0;
|
|
22
|
+
for (const width of widths) {
|
|
23
|
+
const next = used + width + (count > 0 ? gap : 0);
|
|
24
|
+
if (next > budget + FIT_TOLERANCE_PX)
|
|
25
|
+
break;
|
|
26
|
+
used = next;
|
|
27
|
+
count += 1;
|
|
28
|
+
}
|
|
29
|
+
return count;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* How many tabs stay in the strip when the hidden active tab lends its name
|
|
33
|
+
* to the menu button, which then grows wider than "More". Counted twice: with
|
|
34
|
+
* the narrow button first, and with the wide one if the active tab did not
|
|
35
|
+
* fit. The reserve only grows, so the second count cannot bring the active
|
|
36
|
+
* tab back into the strip.
|
|
37
|
+
*/
|
|
38
|
+
export function visibleTabCount(widths, moreWidth, activeWidth, activeIndex, gap, available) {
|
|
39
|
+
const count = fitCount(widths, moreWidth, gap, available);
|
|
40
|
+
if (activeIndex < 0 || activeIndex < count)
|
|
41
|
+
return count;
|
|
42
|
+
return fitCount(widths, Math.max(moreWidth, activeWidth), gap, available);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=overflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow.js","sourceRoot":"","sources":["../../../../src/components/Tabs/overflow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAgB,EAAE,SAAiB,EAAE,GAAW,EAAE,SAAiB;IAC1F,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1F,IAAI,KAAK,IAAI,SAAS,GAAG,gBAAgB;QAAE,OAAO,MAAM,CAAC,MAAM,CAAA;IAE/D,MAAM,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,GAAG,CAAA;IAC1C,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACjD,IAAI,IAAI,GAAG,MAAM,GAAG,gBAAgB;YAAE,MAAK;QAC3C,IAAI,GAAG,IAAI,CAAA;QACX,KAAK,IAAI,CAAC,CAAA;IACZ,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAgB,EAChB,SAAiB,EACjB,WAAmB,EACnB,WAAmB,EACnB,GAAW,EACX,SAAiB;IAEjB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;IACzD,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,GAAG,KAAK;QAAE,OAAO,KAAK,CAAA;IACxD,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;AAC3E,CAAC","sourcesContent":["/**\n * Width math for `Tabs overflow=\"menu\"`: how many tabs fit before the menu\n * button. Shared by the React and Vue packages (the Vue copy must match).\n */\n\n/**\n * Slack for subpixels. Widths are fractional (`getBoundingClientRect`), and a\n * tab that fits exactly is sometimes off by the last digit; without the\n * tolerance the strip would flicker between two counts.\n */\nconst FIT_TOLERANCE_PX = 0.5\n\n/**\n * How many tabs fit. When all of them do, the count is their number and no\n * menu button is needed; otherwise room for the button is taken first.\n */\nexport function fitCount(widths: number[], moreWidth: number, gap: number, available: number): number {\n const total = widths.reduce((sum, width, index) => sum + width + (index > 0 ? gap : 0), 0)\n if (total <= available + FIT_TOLERANCE_PX) return widths.length\n\n const budget = available - moreWidth - gap\n let used = 0\n let count = 0\n for (const width of widths) {\n const next = used + width + (count > 0 ? gap : 0)\n if (next > budget + FIT_TOLERANCE_PX) break\n used = next\n count += 1\n }\n return count\n}\n\n/**\n * How many tabs stay in the strip when the hidden active tab lends its name\n * to the menu button, which then grows wider than \"More\". Counted twice: with\n * the narrow button first, and with the wide one if the active tab did not\n * fit. The reserve only grows, so the second count cannot bring the active\n * tab back into the strip.\n */\nexport function visibleTabCount(\n widths: number[],\n moreWidth: number,\n activeWidth: number,\n activeIndex: number,\n gap: number,\n available: number,\n): number {\n const count = fitCount(widths, moreWidth, gap, available)\n if (activeIndex < 0 || activeIndex < count) return count\n return fitCount(widths, Math.max(moreWidth, activeWidth), gap, available)\n}\n"]}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useOnClickOutside } from "usehooks-ts";
|
|
5
|
-
import { useLatestValue } from "../../hooks/useLatestValue";
|
|
6
|
-
import { toCssVariables } from "../../lib/helpers";
|
|
7
|
-
import { X } from "../Icon";
|
|
8
|
-
import s from "
|
|
5
|
+
import { useLatestValue } from "../../hooks/useLatestValue.js";
|
|
6
|
+
import { toCssVariables } from "../../lib/helpers.js";
|
|
7
|
+
import { X } from "../Icon/index.js";
|
|
8
|
+
import s from "@plexui/styles/components/TagInput/TagInput.module.css";
|
|
9
9
|
// How many pixels to reserve on the right of the input as a buffer before wrapping to the next line
|
|
10
10
|
const INPUT_CURSOR_TOLERANCE_PX = 10;
|
|
11
11
|
// The total space reserved on either side of the input for padding
|
|
@@ -38,7 +38,7 @@ export const TagInput = (props) => {
|
|
|
38
38
|
defaultFocusEl.focus();
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
const selectedTagElement = containerRef.current.querySelector(`[data-tag="${selectedTag}"]`);
|
|
41
|
+
const selectedTagElement = containerRef.current.querySelector(`[data-tag="${CSS.escape(selectedTag)}"]`);
|
|
42
42
|
if (selectedTagElement) {
|
|
43
43
|
selectedTagElement.focus();
|
|
44
44
|
}
|
|
@@ -108,30 +108,46 @@ export const TagInput = (props) => {
|
|
|
108
108
|
// ============================================
|
|
109
109
|
// Tag lifecycle functions
|
|
110
110
|
// ============================================
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
// Adds every value in one update: a paste of "a,b" must not compute
|
|
112
|
+
// each addition from the same stale `tags` snapshot.
|
|
113
|
+
const addTags = (tagValues) => {
|
|
114
|
+
const newSet = new Map(tags);
|
|
115
|
+
let changed = false;
|
|
116
|
+
for (const tagValue of tagValues) {
|
|
117
|
+
if (maxTags && newSet.size >= maxTags) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
const trimmed = tagValue.trim();
|
|
121
|
+
if (!trimmed) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (newSet.has(trimmed)) {
|
|
125
|
+
setDuplicateTags((prevTags) => new Set(prevTags).add(trimmed));
|
|
126
|
+
setTimeout(() => setDuplicateTags((prevTags) => {
|
|
127
|
+
const newTags = new Set(prevTags);
|
|
128
|
+
newTags.delete(trimmed);
|
|
129
|
+
return newTags;
|
|
130
|
+
}), SHAKE_ANIMATION_DURATION_MS);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const validTag = validatorLatest.current?.(trimmed) ?? true;
|
|
134
|
+
newSet.set(trimmed, { value: trimmed, valid: validTag });
|
|
135
|
+
changed = true;
|
|
115
136
|
}
|
|
116
|
-
if (
|
|
117
|
-
setDuplicateTags((prevTags) => new Set(prevTags).add(trimmed));
|
|
118
|
-
setTimeout(() => setDuplicateTags((prevTags) => {
|
|
119
|
-
const newTags = new Set(prevTags);
|
|
120
|
-
newTags.delete(trimmed);
|
|
121
|
-
return newTags;
|
|
122
|
-
}), SHAKE_ANIMATION_DURATION_MS);
|
|
137
|
+
if (!changed) {
|
|
123
138
|
return;
|
|
124
139
|
}
|
|
125
|
-
const validTag = validatorLatest.current?.(trimmed) ?? true;
|
|
126
|
-
const newSet = new Map(tags);
|
|
127
|
-
newSet.set(trimmed, { value: trimmed, valid: validTag });
|
|
128
140
|
const newTags = Array.from(newSet.values());
|
|
129
141
|
onChangeLatest.current?.(newTags);
|
|
130
142
|
if (!isControlled) {
|
|
131
143
|
setInternalTags(newTags);
|
|
132
144
|
}
|
|
133
145
|
};
|
|
146
|
+
const addTag = (tagValue) => addTags([tagValue]);
|
|
134
147
|
const removeTag = (tag) => {
|
|
148
|
+
if (disabled) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
135
151
|
const newSet = new Map(tags);
|
|
136
152
|
newSet.delete(tag);
|
|
137
153
|
const newTags = Array.from(newSet.values());
|
|
@@ -184,7 +200,8 @@ export const TagInput = (props) => {
|
|
|
184
200
|
const handleContainerBlur = () => {
|
|
185
201
|
setFocused(false);
|
|
186
202
|
setSelectedTag(null);
|
|
187
|
-
|
|
203
|
+
// A disabled tag input keeps the pending text instead of committing it
|
|
204
|
+
if (currentInput && !disabled) {
|
|
188
205
|
addTag(currentInput);
|
|
189
206
|
setCurrentInput("");
|
|
190
207
|
}
|
|
@@ -193,6 +210,10 @@ export const TagInput = (props) => {
|
|
|
193
210
|
// Event handlers
|
|
194
211
|
// ============================================
|
|
195
212
|
const handleContainerKeyDown = (e) => {
|
|
213
|
+
// A tag can keep focus while the input turns disabled: no selecting or removing then
|
|
214
|
+
if (disabled) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
196
217
|
if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
197
218
|
if (isEmptyStartingSelection()) {
|
|
198
219
|
e.preventDefault();
|
|
@@ -245,7 +266,7 @@ export const TagInput = (props) => {
|
|
|
245
266
|
parts = parts.filter(Boolean);
|
|
246
267
|
if (parts.length > 1) {
|
|
247
268
|
e.preventDefault();
|
|
248
|
-
parts
|
|
269
|
+
addTags(parts);
|
|
249
270
|
}
|
|
250
271
|
};
|
|
251
272
|
const handleContainerMouseDown = (e) => {
|
|
@@ -310,8 +331,11 @@ export const TagInput = (props) => {
|
|
|
310
331
|
};
|
|
311
332
|
// @ts-expect-error - Fix once usehooks-ts is updated https://github.com/juliencrn/usehooks-ts/pull/675
|
|
312
333
|
useOnClickOutside(containerRef, handleContainerBlur);
|
|
313
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className: s.Container, ref: containerRef, onKeyDown: handleContainerKeyDown, onMouseDown: handleContainerMouseDown, onFocus: handleFocus, onBlur: handleBlur, "data-size": size, "data-focused": focused ? "" : undefined, "data-empty": tags.size === 0 ? "" : undefined, "data-pill": pill ? "" : undefined,
|
|
334
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: s.Container, ref: containerRef, onKeyDown: handleContainerKeyDown, onMouseDown: handleContainerMouseDown, onFocus: handleFocus, onBlur: handleBlur, "data-size": size, "data-focused": focused ? "" : undefined, "data-empty": tags.size === 0 ? "" : undefined, "data-pill": pill ? "" : undefined,
|
|
335
|
+
// At maxTags the input is gone, so the container becomes the tab stop;
|
|
336
|
+
// arrow keys and Backspace then select and remove tags from here
|
|
337
|
+
tabIndex: showInput || disabled ? -1 : 0, style: toCssVariables({ "min-rows": String(rows) }), "data-disabled": disabled ? "" : undefined, children: _jsxs("div", { className: s.TagInput, children: [Array.from(tags.values()).map((tag) => (_jsxs("div", { className: s.Tag, tabIndex: -1, onClick: () => setSelectedTag(tag.value), "data-tag": tag.value, "data-invalid": !tag.valid ? "" : undefined, "data-duplicate": duplicateTags.has(tag.value) ? "" : undefined, children: [_jsx("span", { className: "overflow-hidden text-ellipsis", title: tag.value, children: _jsx("span", { className: s.TagValue, children: tag.value }) }), _jsx("div", { className: s.TagRemove, onClick: () => removeTag(tag.value), role: "button", "aria-label": "Remove item", children: _jsx(X, {}) })] }, tag.value))), showInput && (_jsxs("div", { className: s.InputContainer, children: [_jsx("span", { ref: measureRef, className: s.InputMeasure }), _jsx("div", { className: s.InputWrapper, children: _jsx("input", { id: id, className: s.Input, ref: inputRef, value: currentInput, onChange: (e) => {
|
|
314
338
|
setCurrentInput(e.target.value);
|
|
315
|
-
}, onPaste: handlePaste, onKeyDown: handleInputKeyDown, placeholder: placeholderText, style: { width: inputWidth }, disabled: disabled }) })] }))] }) }), maxTags
|
|
339
|
+
}, onPaste: handlePaste, onKeyDown: handleInputKeyDown, placeholder: placeholderText, style: { width: inputWidth }, disabled: disabled }) })] }))] }) }), maxTags ? (_jsxs("div", { className: s.Limit, children: [tags.size, _jsx("span", { className: "mx-px", children: "/" }), maxTags] })) : null] }));
|
|
316
340
|
};
|
|
317
341
|
//# sourceMappingURL=TagInput.js.map
|