@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,21 +2,33 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useState } from "react";
|
|
5
|
-
import
|
|
5
|
+
import { mergeRefs } from "react-merge-refs";
|
|
6
|
+
import s from "@plexui/styles/components/Image/Image.module.css";
|
|
6
7
|
const loadedSrcs = new Set();
|
|
7
|
-
export const Image = ({ src, className, draggable = false, onLoad, onError, forceRenderAfterLoadFail = false, ...restProps }) => {
|
|
8
|
-
|
|
9
|
-
const [
|
|
8
|
+
export const Image = ({ src, className, draggable = false, onLoad, onError, forceRenderAfterLoadFail = false, ref, ...restProps }) => {
|
|
9
|
+
// Track load/fail per src so a new src starts fresh after an error
|
|
10
|
+
const [loadedSrc, setLoadedSrc] = useState();
|
|
11
|
+
const [failedSrc, setFailedSrc] = useState();
|
|
12
|
+
const loaded = !!src && (loadedSrc === src || loadedSrcs.has(src));
|
|
13
|
+
const failed = !!src && failedSrc === src;
|
|
10
14
|
const considerLoaded = loaded || (failed && forceRenderAfterLoadFail);
|
|
15
|
+
// An image that loaded before hydration fired its load event before React
|
|
16
|
+
// listened for it, and React does not replay it: read the element instead
|
|
17
|
+
const markLoadedIfComplete = (img) => {
|
|
18
|
+
if (img && src && !loaded && img.complete && img.naturalWidth > 0) {
|
|
19
|
+
setLoadedSrc(src);
|
|
20
|
+
loadedSrcs.add(src);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
11
23
|
if (!src || (!forceRenderAfterLoadFail && failed)) {
|
|
12
24
|
return null;
|
|
13
25
|
}
|
|
14
|
-
return (_jsx("img", { ...restProps, src: src, className: clsx(s.Image, className), onLoad: (evt) => {
|
|
15
|
-
|
|
26
|
+
return (_jsx("img", { ...restProps, ref: mergeRefs([ref, markLoadedIfComplete]), src: src, className: clsx(s.Image, className), onLoad: (evt) => {
|
|
27
|
+
setLoadedSrc(src);
|
|
16
28
|
loadedSrcs.add(src);
|
|
17
29
|
onLoad?.(evt);
|
|
18
30
|
}, onError: (evt) => {
|
|
19
|
-
|
|
31
|
+
setFailedSrc(src);
|
|
20
32
|
onError?.(evt);
|
|
21
33
|
}, "data-loaded": considerLoaded ? "" : undefined, draggable: draggable }));
|
|
22
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/components/Image/Image.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAuB,QAAQ,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/components/Image/Image.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAuB,QAAQ,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAEhE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAA;AAEpC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,GAAG,EACH,SAAS,EACT,SAAS,GAAG,KAAK,EACjB,MAAM,EACN,OAAO,EACP,wBAAwB,GAAG,KAAK,EAChC,GAAG,EACH,GAAG,SAAS,EAIb,EAAE,EAAE;IACH,mEAAmE;IACnE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAU,CAAA;IACpD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAU,CAAA;IACpD,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,G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\n\nimport clsx from \"clsx\"\nimport { type ComponentProps, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport s from \"@plexui/styles/components/Image/Image.module.css\"\n\nconst loadedSrcs = new Set<string>()\n\nexport const Image = ({\n src,\n className,\n draggable = false,\n onLoad,\n onError,\n forceRenderAfterLoadFail = false,\n ref,\n ...restProps\n}: ComponentProps<\"img\"> & {\n /** Force the image tag to be placed in the DOM even if load failed (resulting in broken image display) */\n forceRenderAfterLoadFail?: boolean\n}) => {\n // Track load/fail per src so a new src starts fresh after an error\n const [loadedSrc, setLoadedSrc] = useState<string>()\n const [failedSrc, setFailedSrc] = useState<string>()\n const loaded = !!src && (loadedSrc === src || loadedSrcs.has(src))\n const failed = !!src && failedSrc === src\n const considerLoaded = loaded || (failed && forceRenderAfterLoadFail)\n\n // An image that loaded before hydration fired its load event before React\n // listened for it, and React does not replay it: read the element instead\n const markLoadedIfComplete = (img: HTMLImageElement | null) => {\n if (img && src && !loaded && img.complete && img.naturalWidth > 0) {\n setLoadedSrc(src)\n loadedSrcs.add(src)\n }\n }\n\n if (!src || (!forceRenderAfterLoadFail && failed)) {\n return null\n }\n\n return (\n <img\n {...restProps}\n ref={mergeRefs([ref, markLoadedIfComplete])}\n src={src}\n className={clsx(s.Image, className)}\n onLoad={(evt) => {\n setLoadedSrc(src)\n loadedSrcs.add(src)\n onLoad?.(evt)\n }}\n onError={(evt) => {\n setFailedSrc(src)\n onError?.(evt)\n }}\n data-loaded={considerLoaded ? \"\" : undefined}\n draggable={draggable}\n />\n )\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Image } from "./Image";
|
|
1
|
+
export { Image } from "./Image.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useState } from "react";
|
|
5
|
-
import { useSimulatedProgress } from "../../hooks/useSimulatedProgress";
|
|
6
|
-
import { toCssVariables } from "../../lib/helpers";
|
|
7
|
-
import s from "
|
|
5
|
+
import { useSimulatedProgress } from "../../hooks/useSimulatedProgress.js";
|
|
6
|
+
import { toCssVariables } from "../../lib/helpers.js";
|
|
7
|
+
import s from "@plexui/styles/components/Indicator/CircularProgress.module.css";
|
|
8
8
|
export const CircularProgress = ({ maxDuration = 15000, // 15 seconds
|
|
9
9
|
done = false, className, progress: propProgress, size, strokeWidth, trackActiveColor, trackColor, style, ...restProps }) => {
|
|
10
10
|
const [currentTime] = useState(new Date());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircularProgress.js","sourceRoot":"","sources":["../../../../src/components/Indicator/CircularProgress.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,CAAC,MAAM
|
|
1
|
+
{"version":3,"file":"CircularProgress.js","sourceRoot":"","sources":["../../../../src/components/Indicator/CircularProgress.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAgC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,WAAW,GAAG,KAAK,EAAE,aAAa;AAClC,IAAI,GAAG,KAAK,EACZ,SAAS,EACT,QAAQ,EAAE,YAAY,EACtB,IAAI,EACJ,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\"\n\nimport clsx from \"clsx\"\nimport { useState, type ComponentProps } from \"react\"\nimport { useSimulatedProgress } from \"../../hooks/useSimulatedProgress\"\n\nimport { toCssVariables } from \"../../lib/helpers\"\nimport s from \"@plexui/styles/components/Indicator/CircularProgress.module.css\"\n\nexport type CircularProgressProps = Omit<ComponentProps<\"div\">, \"children\"> & {\n /**\n * Maximum duration to use for simulated upload progress in ms\n * @default 15000\n */\n maxDuration?: number\n /**\n * Sets the progress to full and resolves the simulated timer\n * @default false\n */\n done?: boolean\n /**\n * Sets the progress to full and resolves the simulated timer\n * @default false\n */\n progress?: number\n /** Size of the indicator, in pixels\n * @default 28px\n */\n size?: number | string\n /** Stroke width of the indicator, in pixels, between 1 and 4\n * @default 2\n */\n strokeWidth?: number\n /** Color of the active progress track (stroke) */\n trackActiveColor?: string\n /** Color of the base track (background stroke) */\n trackColor?: string\n}\n\nexport const CircularProgress = ({\n maxDuration = 15000, // 15 seconds\n done = false,\n className,\n progress: propProgress,\n size,\n strokeWidth,\n trackActiveColor,\n trackColor,\n style,\n ...restProps\n}: CircularProgressProps) => {\n const [currentTime] = useState(new Date())\n const simulatedProgressDone = propProgress !== undefined || done\n const simulatedProgress = useSimulatedProgress(+currentTime, maxDuration, simulatedProgressDone)\n const progress = propProgress ?? simulatedProgress\n\n return (\n <div\n {...restProps}\n className={clsx(s.Container, className)}\n style={\n style ||\n toCssVariables({\n \"circular-progress-size\": size,\n \"circular-progress-stroke\": strokeWidth ? Math.min(4, strokeWidth) : undefined,\n \"circular-progress-track-active-color\": trackActiveColor,\n \"circular-progress-track-color\": trackColor,\n })\n }\n >\n <svg viewBox=\"0 0 20 20\" className={s.Track} data-no-autosize>\n <circle cx=\"10\" cy=\"10\" r=\"8\" fill=\"none\" />\n </svg>\n <svg\n viewBox=\"0 0 20 20\"\n className={s.TrackProgress}\n style={{\n strokeDashoffset: 50 - 50 * (progress / 100),\n }}\n data-no-autosize\n >\n <circle cx=\"10\" cy=\"10\" r=\"8\" fill=\"none\" />\n </svg>\n </div>\n )\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
-
import s from "
|
|
3
|
+
import s from "@plexui/styles/components/Indicator/LoadingDots.module.css";
|
|
4
4
|
export const LoadingDots = ({ className, ...restProps }) => {
|
|
5
5
|
return (_jsxs("div", { className: clsx(s.LoadingDots, className), ...restProps, children: [_jsx("div", { className: s.Dot }), _jsx("div", { className: s.Dot }), _jsx("div", { className: s.Dot })] }));
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingDots.js","sourceRoot":"","sources":["../../../../src/components/Indicator/LoadingDots.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"LoadingDots.js","sourceRoot":"","sources":["../../../../src/components/Indicator/LoadingDots.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,CAAC,MAAM,4DAA4D,CAAA;AAI1E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,EAAoB,EAAE,EAAE;IAC3E,OAAO,CACL,eAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,KAAM,SAAS,aAC3D,cAAK,SAAS,EAAE,CAAC,CAAC,GAAG,GAAI,EACzB,cAAK,SAAS,EAAE,CAAC,CAAC,GAAG,GAAI,EACzB,cAAK,SAAS,EAAE,CAAC,CAAC,GAAG,GAAI,IACrB,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport type { ComponentProps } from \"react\"\nimport s from \"@plexui/styles/components/Indicator/LoadingDots.module.css\"\n\nexport type LoadingDotsProps = Omit<ComponentProps<\"div\">, \"children\">\n\nexport const LoadingDots = ({ className, ...restProps }: LoadingDotsProps) => {\n return (\n <div className={clsx(s.LoadingDots, className)} {...restProps}>\n <div className={s.Dot} />\n <div className={s.Dot} />\n <div className={s.Dot} />\n </div>\n )\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
-
import { toCssVariables } from "../../lib/helpers";
|
|
4
|
-
import s from "
|
|
3
|
+
import { toCssVariables } from "../../lib/helpers.js";
|
|
4
|
+
import s from "@plexui/styles/components/Indicator/LoadingIndicator.module.css";
|
|
5
5
|
export const LoadingIndicator = ({ className, size, strokeWidth, style, ...restProps }) => {
|
|
6
6
|
return (_jsx("span", { ...restProps, className: clsx(s.LoadingIndicator, className), style: style ||
|
|
7
7
|
toCssVariables({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingIndicator.js","sourceRoot":"","sources":["../../../../src/components/Indicator/LoadingIndicator.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,CAAC,MAAM
|
|
1
|
+
{"version":3,"file":"LoadingIndicator.js","sourceRoot":"","sources":["../../../../src/components/Indicator/LoadingIndicator.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAe/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,SAAS,EACT,IAAI,EACJ,WAAW,EACX,KAAK,EACL,GAAG,SAAS,EACU,EAAE,EAAE;IAC1B,OAAO,CACL,kBACM,SAAS,EACb,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAC9C,KAAK,EACH,KAAK;YACL,cAAc,CAAC;gBACb,gBAAgB,EAAE,IAAI;gBACtB,kBAAkB,EAAE,WAAW;aAChC,CAAC,GAEJ,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport type { ComponentProps } from \"react\"\nimport { toCssVariables } from \"../../lib/helpers\"\nimport s from \"@plexui/styles/components/Indicator/LoadingIndicator.module.css\"\n\nexport type LoadingIndicatorProps = {\n /** Classname applied to the indicator */\n className?: string\n /** Size of the indicator, in pixels\n * @default 1em\n */\n size?: number | string\n /** Stroke width of the indicator, in pixels\n * @default 2\n */\n strokeWidth?: number\n} & Omit<ComponentProps<\"span\">, \"children\">\n\nexport const LoadingIndicator = ({\n className,\n size,\n strokeWidth,\n style,\n ...restProps\n}: LoadingIndicatorProps) => {\n return (\n <span\n {...restProps}\n className={clsx(s.LoadingIndicator, className)}\n style={\n style ||\n toCssVariables({\n \"indicator-size\": size,\n \"indicator-stroke\": strokeWidth,\n })\n }\n />\n )\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CircularProgress } from "./CircularProgress";
|
|
2
|
-
export { LoadingDots } from "./LoadingDots";
|
|
3
|
-
export { LoadingIndicator } from "./LoadingIndicator";
|
|
1
|
+
export { CircularProgress } from "./CircularProgress.js";
|
|
2
|
+
export { LoadingDots } from "./LoadingDots.js";
|
|
3
|
+
export { LoadingIndicator } from "./LoadingIndicator.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,9 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useEffect, useId, useRef, useState } from "react";
|
|
5
5
|
import { mergeRefs } from "react-merge-refs";
|
|
6
|
-
import {} from "../../types";
|
|
7
|
-
import { X } from "../Icon";
|
|
8
|
-
import s from "
|
|
6
|
+
import {} from "../../types.js";
|
|
7
|
+
import { X } from "../Icon/index.js";
|
|
8
|
+
import s from "@plexui/styles/components/Input/Input.module.css";
|
|
9
9
|
const InputRoot = (props) => {
|
|
10
10
|
const inputRef = useRef(null);
|
|
11
11
|
const inputIdSuffix = useId();
|
|
@@ -42,8 +42,12 @@ const InputRoot = (props) => {
|
|
|
42
42
|
const { clientX, clientY } = evt;
|
|
43
43
|
// "Before" the input: top/left
|
|
44
44
|
const isBefore = clientY < top || clientX < left;
|
|
45
|
+
// email, number and other types without the selection API throw on setSelectionRange
|
|
46
|
+
const hasSelection = input.selectionStart !== null;
|
|
45
47
|
// If this is the first click, clear the selection.
|
|
46
48
|
if (evt.detail === 1) {
|
|
49
|
+
if (!hasSelection)
|
|
50
|
+
return;
|
|
47
51
|
if (isBefore) {
|
|
48
52
|
input.setSelectionRange(0, 0);
|
|
49
53
|
}
|
|
@@ -54,6 +58,8 @@ const InputRoot = (props) => {
|
|
|
54
58
|
}
|
|
55
59
|
// If this is the second click, select the first or last word
|
|
56
60
|
else if (evt.detail === 2) {
|
|
61
|
+
if (!hasSelection)
|
|
62
|
+
return;
|
|
57
63
|
// Split the textarea value into words and non-word characters
|
|
58
64
|
const words = input.value.match(/\w+|[^\w\s]/g) || [];
|
|
59
65
|
const selectedWord = isBefore ? words.at(0) : words.at(-1);
|
|
@@ -75,19 +81,24 @@ const InputRoot = (props) => {
|
|
|
75
81
|
inputRef.current?.select();
|
|
76
82
|
}
|
|
77
83
|
}, [autoSelect]);
|
|
84
|
+
// The clear button unmounts once the value is gone, so keep focus in the input
|
|
85
|
+
const handleClear = (evt) => {
|
|
86
|
+
inputRef.current?.focus();
|
|
87
|
+
onClear?.(evt);
|
|
88
|
+
};
|
|
78
89
|
const handleAnimationStart = (evt) => {
|
|
79
90
|
onAnimationStart?.(evt);
|
|
80
91
|
if (evt.animationName === "native-autofill-in") {
|
|
81
92
|
onAutofill?.();
|
|
82
93
|
}
|
|
83
94
|
};
|
|
84
|
-
return (_jsxs("div", { className: clsx(s.Container, className), "data-slot": "input", "data-variant": variant, "data-size": size, "data-gutter-size": gutterSize, "data-focused": focused, "data-disabled": disabled ? "" : undefined, "data-readonly": readOnly ? "" : undefined, "data-invalid": invalid ? "" : undefined, "data-pill": pill ? "" : undefined, "data-optically-align": opticallyAlign, "data-has-start-adornment": StartAdornment ? "" : undefined, "data-has-end-adornment": EndAdornment || showClearButton ? "" : undefined, onMouseDown: handleMouseDown, children: [StartAdornment, _jsx("input", { ...restProps, ref: mergeRefs([ref, inputRef]), id: id || (allowAutofillExtensions ? undefined : onePasswordPreventionId), className: s.Input, type: type, name: name, value: value, defaultValue: defaultValue, readOnly: readOnly, disabled: disabled, onFocus: (evt) => {
|
|
95
|
+
return (_jsxs("div", { className: clsx(s.Container, className), "data-slot": "input", "data-variant": variant, "data-size": size, "data-gutter-size": gutterSize, "data-focused": focused, "data-disabled": disabled ? "" : undefined, "data-readonly": readOnly ? "" : undefined, "data-invalid": invalid ? "" : undefined, "data-pill": pill ? "" : undefined, "data-optically-align": opticallyAlign, "data-has-start-adornment": StartAdornment ? "" : undefined, "data-has-end-adornment": EndAdornment || showClearButton ? "" : undefined, onMouseDown: handleMouseDown, children: [StartAdornment, _jsx("input", { ...restProps, ref: mergeRefs([ref, inputRef]), id: id || (allowAutofillExtensions ? undefined : onePasswordPreventionId), className: s.Input, type: type, autoComplete: autoComplete, "aria-invalid": restProps["aria-invalid"] ?? (invalid || undefined), name: name, value: value, defaultValue: defaultValue, readOnly: readOnly, disabled: disabled, onFocus: (evt) => {
|
|
85
96
|
setFocused(true);
|
|
86
97
|
onFocus?.(evt);
|
|
87
98
|
}, onBlur: (evt) => {
|
|
88
99
|
setFocused(false);
|
|
89
100
|
onBlur?.(evt);
|
|
90
|
-
}, onAnimationStart: handleAnimationStart, "data-lpignore": allowAutofillExtensions ? undefined : true, "data-1p-ignore": allowAutofillExtensions ? undefined : true }), showClearButton && (_jsx("button", { type: "button", "aria-label": "Clear input", className: s.Clear, onClick:
|
|
101
|
+
}, onAnimationStart: handleAnimationStart, "data-lpignore": allowAutofillExtensions ? undefined : true, "data-1p-ignore": allowAutofillExtensions ? undefined : true }), showClearButton && (_jsx("button", { type: "button", "aria-label": "Clear input", className: s.Clear, onClick: handleClear, children: _jsx(X, {}) })), EndAdornment] }));
|
|
91
102
|
};
|
|
92
103
|
const InputAdornmentButton = ({ className, type = "button", color, ref, ...restProps }) => (_jsx("button", { ref: ref, type: type, className: clsx(s.AdornmentButton, className), "data-color": color, ...restProps }));
|
|
93
104
|
export const Input = InputRoot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAmE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AAC3B,OAAO,CAAC,MAAM,oBAAoB,CAAA;AAuElC,MAAM,SAAS,GAAG,CAAC,KAAiB,EAAE,EAAE;IACtC,MAAM,QAAQ,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAA;IACtD,MAAM,aAAa,GAAG,KAAK,EAAE,CAAA;IAC7B,qGAAqG;IACrG,wDAAwD;IACxD,MAAM,uBAAuB,GAAG,mBAAmB,aAAa,EAAE,CAAA;IAClE,MAAM,EACJ,EAAE,EACF,IAAI,EACJ,IAAI,GAAG,MAAM,EACb,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,KAAK;IACf,+DAA+D;IAC/D,uBAAuB,GAAG,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,IAAI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IAAI,EACV,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBACf,UAAU,CAAC,IAAI,CAAC,CAAA;oBAChB,OAAO,EAAE,CAAC,GAAG,CAAC,CAAA;gBAChB,CAAC,EACD,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;oBACd,UAAU,CAAC,KAAK,CAAC,CAAA;oBACjB,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;gBACf,CAAC,EACD,gBAAgB,EAAE,oBAAoB,mBAEvB,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,oBACzC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,GAC1D,EACD,eAAe,IAAI,CAClB,iBAAQ,IAAI,EAAC,QAAQ,gBAAY,aAAa,EAAC,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,YACjF,KAAC,CAAC,KAAG,GACE,CACV,EACA,YAAY,IACT,CACP,CAAA;AACH,CAAC,CAAA;AAsBD,MAAM,oBAAoB,GAAG,CAAC,EAC5B,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,KAAK,EACL,GAAG,EACH,GAAG,SAAS,EACc,EAAE,EAAE,CAAC,CAC/B,iBACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,gBACjC,KAAK,KACb,SAAS,GACb,CACH,CAAA;AAMD,MAAM,CAAC,MAAM,KAAK,GAAG,SAA2B,CAAA;AAChD,KAAK,CAAC,eAAe,GAAG,oBAAoB,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useId, useRef, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { type ControlSize, type SemanticColor, type Sizes, type Variants } from \"../../types\"\nimport { X } from \"../Icon\"\nimport s from \"./Input.module.css\"\n\nexport type InputProps = {\n /**\n * Visual style of the input\n * @default outline\n */\n variant?: Variants<\"outline\" | \"soft\">\n /**\n * Controls the size of the input\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 input, 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 /**\n * Disables the select visually and from interactions\n * @default false\n */\n disabled?: boolean\n /**\n * Mark the input as invalid\n * @default false\n */\n invalid?: boolean\n /**\n * Allow autofill extensions to appear in the input\n * @default false\n */\n allowAutofillExtensions?: boolean\n /**\n * Select all contents of the input when mounted.\n * @default false\n */\n autoSelect?: boolean\n /** Callback invoked when the input is autofilled by the browser */\n onAutofill?: () => void\n /** Content rendered at the start of the input */\n startAdornment?: React.ReactNode\n /** Content rendered at the end of the input */\n endAdornment?: React.ReactNode\n /**\n * Callback invoked when the clear button is clicked.\n * When provided, displays a clear button that appears when the input has a value.\n */\n onClear?: () => void\n /**\n * Determines if the button should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Applies a negative margin using the current gutter to optically align the input\n * with surrounding content.\n */\n opticallyAlign?: \"start\" | \"end\"\n /** Ref for the input */\n ref?: React.Ref<HTMLInputElement | null>\n} & Omit<React.InputHTMLAttributes<HTMLInputElement>, \"disabled\" | \"size\">\n\nconst InputRoot = (props: InputProps) => {\n const inputRef = useRef<HTMLInputElement | null>(null)\n const inputIdSuffix = useId()\n // Prevent 1Password from appearing: 1Password won't display if it thinks this field is for searching\n // Allow user to override this for connecting to labels.\n const onePasswordPreventionId = `search-ui-input-${inputIdSuffix}`\n const {\n id,\n name,\n type = \"text\",\n variant = \"outline\",\n size = \"md\",\n gutterSize,\n className,\n autoComplete,\n disabled = false,\n readOnly = false,\n invalid = false,\n // Default to `true` when type=\"password\" or presence of `name`\n allowAutofillExtensions = type === \"password\" || !!name,\n onFocus,\n onBlur,\n onAnimationStart,\n onAutofill,\n autoSelect,\n startAdornment: StartAdornment,\n endAdornment: EndAdornment,\n onClear,\n pill,\n opticallyAlign,\n ref,\n value,\n defaultValue,\n ...restProps\n } = props\n\n // Determine if clear button should be shown\n const hasValue = value !== undefined ? !!value : !!defaultValue\n const showClearButton = !!onClear && hasValue && !disabled && !readOnly\n // Redirect clicks on the container and adornments\n const handleMouseDown = (evt: React.MouseEvent<HTMLDivElement>) => {\n const input = inputRef.current\n // Bail out if the target is not an element or the textarea is not found\n if (!evt.target || !(evt.target instanceof Element) || !input) {\n return\n }\n // Bail out if the target is inside the textarea\n if (input.contains(evt.target)) {\n return\n }\n // Bail out if the target is a button\n if (evt.target.closest(\"button, [type='button'], [role='button'], [role='menuitem']\")) {\n return\n }\n\n evt.preventDefault()\n // If the textarea is not focused, focus it\n if (document.activeElement !== input) {\n input.focus()\n }\n\n const { left, top } = input.getBoundingClientRect()\n const { clientX, clientY } = evt\n // \"Before\" the input: top/left\n const isBefore = clientY < top || clientX < left\n\n // If this is the first click, clear the selection.\n if (evt.detail === 1) {\n if (isBefore) {\n input.setSelectionRange(0, 0)\n } else {\n const length = input.value.length\n input.setSelectionRange(length, length)\n }\n }\n // If this is the second click, select the first or last word\n else if (evt.detail === 2) {\n // Split the textarea value into words and non-word characters\n const words = input.value.match(/\\w+|[^\\w\\s]/g) || []\n const selectedWord = isBefore ? words.at(0) : words.at(-1)\n if (selectedWord) {\n const wordIndex = isBefore\n ? input.value.indexOf(selectedWord)\n : input.value.lastIndexOf(selectedWord)\n input.setSelectionRange(wordIndex, wordIndex + selectedWord.length)\n }\n }\n // If this is the third click or greater, select the entire input\n else {\n input.select()\n }\n }\n\n const [focused, setFocused] = useState<boolean>(false)\n\n useEffect(() => {\n if (autoSelect) {\n inputRef.current?.select()\n }\n }, [autoSelect])\n\n const handleAnimationStart = (evt: React.AnimationEvent<HTMLInputElement>) => {\n onAnimationStart?.(evt)\n if (evt.animationName === \"native-autofill-in\") {\n onAutofill?.()\n }\n }\n\n return (\n <div\n className={clsx(s.Container, className)}\n data-slot=\"input\"\n data-variant={variant}\n data-size={size}\n data-gutter-size={gutterSize}\n data-focused={focused}\n data-disabled={disabled ? \"\" : undefined}\n data-readonly={readOnly ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n data-pill={pill ? \"\" : undefined}\n data-optically-align={opticallyAlign}\n data-has-start-adornment={StartAdornment ? \"\" : undefined}\n data-has-end-adornment={EndAdornment || showClearButton ? \"\" : undefined}\n onMouseDown={handleMouseDown}\n >\n {StartAdornment}\n <input\n {...restProps}\n ref={mergeRefs([ref, inputRef])}\n id={id || (allowAutofillExtensions ? undefined : onePasswordPreventionId)}\n className={s.Input}\n type={type}\n name={name}\n value={value}\n defaultValue={defaultValue}\n readOnly={readOnly}\n disabled={disabled}\n onFocus={(evt) => {\n setFocused(true)\n onFocus?.(evt)\n }}\n onBlur={(evt) => {\n setFocused(false)\n onBlur?.(evt)\n }}\n onAnimationStart={handleAnimationStart}\n // Prevent LastPass and 1Password from appearing\n data-lpignore={allowAutofillExtensions ? undefined : true}\n data-1p-ignore={allowAutofillExtensions ? undefined : true}\n />\n {showClearButton && (\n <button type=\"button\" aria-label=\"Clear input\" className={s.Clear} onClick={onClear}>\n <X />\n </button>\n )}\n {EndAdornment}\n </div>\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* AdornmentButton — canonical inline action button for Input slots */\n/* (mic toggle, visibility toggle, copy, etc.). Sizes itself off the */\n/* parent Input via --input-clear-size / --input-clear-pill-offset */\n/* so it stays visually consistent with the built-in clear button. */\n/* ------------------------------------------------------------------ */\n\nexport type InputAdornmentButtonProps = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n \"ref\" | \"color\"\n> & {\n ref?: React.Ref<HTMLButtonElement>\n /**\n * Applies a semantic color tint to the pressed (`aria-pressed=\"true\"`) state\n * — the same palette Button accepts. Default `aria-pressed` keeps the\n * neutral primary-soft tint.\n */\n color?: SemanticColor\n}\n\nconst InputAdornmentButton = ({\n className,\n type = \"button\",\n color,\n ref,\n ...restProps\n}: InputAdornmentButtonProps) => (\n <button\n ref={ref}\n type={type}\n className={clsx(s.AdornmentButton, className)}\n data-color={color}\n {...restProps}\n />\n)\n\ntype InputComponent = typeof InputRoot & {\n AdornmentButton: typeof InputAdornmentButton\n}\n\nexport const Input = InputRoot as InputComponent\nInput.AdornmentButton = InputAdornmentButton\n"]}
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAmE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AAC3B,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAuEhE,MAAM,SAAS,GAAG,CAAC,KAAiB,EAAE,EAAE;IACtC,MAAM,QAAQ,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAA;IACtD,MAAM,aAAa,GAAG,KAAK,EAAE,CAAA;IAC7B,qGAAqG;IACrG,wDAAwD;IACxD,MAAM,uBAAuB,GAAG,mBAAmB,aAAa,EAAE,CAAA;IAClE,MAAM,EACJ,EAAE,EACF,IAAI,EACJ,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,IAAI,EAAC,QAAQ,gBAAY,aAAa,EAAC,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,YACrF,KAAC,CAAC,KAAG,GACE,CACV,EACA,YAAY,IACT,CACP,CAAA;AACH,CAAC,CAAA;AAsBD,MAAM,oBAAoB,GAAG,CAAC,EAC5B,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,KAAK,EACL,GAAG,EACH,GAAG,SAAS,EACc,EAAE,EAAE,CAAC,CAC/B,iBACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,gBACjC,KAAK,KACb,SAAS,GACb,CACH,CAAA;AAMD,MAAM,CAAC,MAAM,KAAK,GAAG,SAA2B,CAAA;AAChD,KAAK,CAAC,eAAe,GAAG,oBAAoB,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useEffect, useId, useRef, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { type ControlSize, type SemanticColor, type Sizes, type Variants } from \"../../types\"\nimport { X } from \"../Icon\"\nimport s from \"@plexui/styles/components/Input/Input.module.css\"\n\nexport type InputProps = {\n /**\n * Visual style of the input\n * @default outline\n */\n variant?: Variants<\"outline\" | \"soft\" | \"ghost\">\n /**\n * Controls the size of the input\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 input, 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 /**\n * Disables the select visually and from interactions\n * @default false\n */\n disabled?: boolean\n /**\n * Mark the input as invalid\n * @default false\n */\n invalid?: boolean\n /**\n * Allow autofill extensions to appear in the input\n * @default false\n */\n allowAutofillExtensions?: boolean\n /**\n * Select all contents of the input when mounted.\n * @default false\n */\n autoSelect?: boolean\n /** Callback invoked when the input is autofilled by the browser */\n onAutofill?: () => void\n /** Content rendered at the start of the input */\n startAdornment?: React.ReactNode\n /** Content rendered at the end of the input */\n endAdornment?: React.ReactNode\n /**\n * Callback invoked when the clear button is clicked.\n * When provided, displays a clear button that appears when the input has a value.\n */\n onClear?: () => void\n /**\n * Determines if the button should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Applies a negative margin using the current gutter to optically align the input\n * with surrounding content.\n */\n opticallyAlign?: \"start\" | \"end\"\n /** Ref for the input */\n ref?: React.Ref<HTMLInputElement | null>\n} & Omit<React.InputHTMLAttributes<HTMLInputElement>, \"disabled\" | \"size\">\n\nconst InputRoot = (props: InputProps) => {\n const inputRef = useRef<HTMLInputElement | null>(null)\n const inputIdSuffix = useId()\n // Prevent 1Password from appearing: 1Password won't display if it thinks this field is for searching\n // Allow user to override this for connecting to labels.\n const onePasswordPreventionId = `search-ui-input-${inputIdSuffix}`\n const {\n id,\n name,\n type = \"text\",\n variant = \"outline\",\n size = \"md\",\n gutterSize,\n className,\n autoComplete,\n disabled = false,\n readOnly = false,\n invalid = false,\n // Default to `true` when type=\"password\" or presence of `name`\n allowAutofillExtensions = type === \"password\" || !!name,\n onFocus,\n onBlur,\n onAnimationStart,\n onAutofill,\n autoSelect,\n startAdornment: StartAdornment,\n endAdornment: EndAdornment,\n onClear,\n pill,\n opticallyAlign,\n ref,\n value,\n defaultValue,\n ...restProps\n } = props\n\n // Determine if clear button should be shown\n const hasValue = value !== undefined ? !!value : !!defaultValue\n const showClearButton = !!onClear && hasValue && !disabled && !readOnly\n // Redirect clicks on the container and adornments\n const handleMouseDown = (evt: React.MouseEvent<HTMLDivElement>) => {\n const input = inputRef.current\n // Bail out if the target is not an element or the textarea is not found\n if (!evt.target || !(evt.target instanceof Element) || !input) {\n return\n }\n // Bail out if the target is inside the textarea\n if (input.contains(evt.target)) {\n return\n }\n // Bail out if the target is a button\n if (evt.target.closest(\"button, [type='button'], [role='button'], [role='menuitem']\")) {\n return\n }\n\n evt.preventDefault()\n // If the textarea is not focused, focus it\n if (document.activeElement !== input) {\n input.focus()\n }\n\n const { left, top } = input.getBoundingClientRect()\n const { clientX, clientY } = evt\n // \"Before\" the input: top/left\n const isBefore = clientY < top || clientX < left\n // email, number and other types without the selection API throw on setSelectionRange\n const hasSelection = input.selectionStart !== null\n\n // If this is the first click, clear the selection.\n if (evt.detail === 1) {\n if (!hasSelection) return\n if (isBefore) {\n input.setSelectionRange(0, 0)\n } else {\n const length = input.value.length\n input.setSelectionRange(length, length)\n }\n }\n // If this is the second click, select the first or last word\n else if (evt.detail === 2) {\n if (!hasSelection) return\n // Split the textarea value into words and non-word characters\n const words = input.value.match(/\\w+|[^\\w\\s]/g) || []\n const selectedWord = isBefore ? words.at(0) : words.at(-1)\n if (selectedWord) {\n const wordIndex = isBefore\n ? input.value.indexOf(selectedWord)\n : input.value.lastIndexOf(selectedWord)\n input.setSelectionRange(wordIndex, wordIndex + selectedWord.length)\n }\n }\n // If this is the third click or greater, select the entire input\n else {\n input.select()\n }\n }\n\n const [focused, setFocused] = useState<boolean>(false)\n\n useEffect(() => {\n if (autoSelect) {\n inputRef.current?.select()\n }\n }, [autoSelect])\n\n // The clear button unmounts once the value is gone, so keep focus in the input\n const handleClear = (evt: React.MouseEvent<HTMLButtonElement>) => {\n inputRef.current?.focus()\n ;(onClear as React.MouseEventHandler<HTMLButtonElement> | undefined)?.(evt)\n }\n\n const handleAnimationStart = (evt: React.AnimationEvent<HTMLInputElement>) => {\n onAnimationStart?.(evt)\n if (evt.animationName === \"native-autofill-in\") {\n onAutofill?.()\n }\n }\n\n return (\n <div\n className={clsx(s.Container, className)}\n data-slot=\"input\"\n data-variant={variant}\n data-size={size}\n data-gutter-size={gutterSize}\n data-focused={focused}\n data-disabled={disabled ? \"\" : undefined}\n data-readonly={readOnly ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n data-pill={pill ? \"\" : undefined}\n data-optically-align={opticallyAlign}\n data-has-start-adornment={StartAdornment ? \"\" : undefined}\n data-has-end-adornment={EndAdornment || showClearButton ? \"\" : undefined}\n onMouseDown={handleMouseDown}\n >\n {StartAdornment}\n <input\n {...restProps}\n ref={mergeRefs([ref, inputRef])}\n id={id || (allowAutofillExtensions ? undefined : onePasswordPreventionId)}\n className={s.Input}\n type={type}\n autoComplete={autoComplete}\n // Expose the visual invalid state to assistive tech; an explicit aria-invalid wins\n aria-invalid={restProps[\"aria-invalid\"] ?? (invalid || undefined)}\n name={name}\n value={value}\n defaultValue={defaultValue}\n readOnly={readOnly}\n disabled={disabled}\n onFocus={(evt) => {\n setFocused(true)\n onFocus?.(evt)\n }}\n onBlur={(evt) => {\n setFocused(false)\n onBlur?.(evt)\n }}\n onAnimationStart={handleAnimationStart}\n // Prevent LastPass and 1Password from appearing\n data-lpignore={allowAutofillExtensions ? undefined : true}\n data-1p-ignore={allowAutofillExtensions ? undefined : true}\n />\n {showClearButton && (\n <button type=\"button\" aria-label=\"Clear input\" className={s.Clear} onClick={handleClear}>\n <X />\n </button>\n )}\n {EndAdornment}\n </div>\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* AdornmentButton — canonical inline action button for Input slots */\n/* (mic toggle, visibility toggle, copy, etc.). Sizes itself off the */\n/* parent Input via --input-clear-size / --input-clear-pill-offset */\n/* so it stays visually consistent with the built-in clear button. */\n/* ------------------------------------------------------------------ */\n\nexport type InputAdornmentButtonProps = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n \"ref\" | \"color\"\n> & {\n ref?: React.Ref<HTMLButtonElement>\n /**\n * Applies a semantic color tint to the pressed (`aria-pressed=\"true\"`) state\n * — the same palette Button accepts. Default `aria-pressed` keeps the\n * neutral primary-soft tint.\n */\n color?: SemanticColor\n}\n\nconst InputAdornmentButton = ({\n className,\n type = \"button\",\n color,\n ref,\n ...restProps\n}: InputAdornmentButtonProps) => (\n <button\n ref={ref}\n type={type}\n className={clsx(s.AdornmentButton, className)}\n data-color={color}\n {...restProps}\n />\n)\n\ntype InputComponent = typeof InputRoot & {\n AdornmentButton: typeof InputAdornmentButton\n}\n\nexport const Input = InputRoot as InputComponent\nInput.AdornmentButton = InputAdornmentButton\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Input } from "./Input";
|
|
1
|
+
export { Input } from "./Input.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { createContext, useContext, } from "react";
|
|
5
|
+
import {} from "../../types.js";
|
|
6
|
+
import { Button } from "../Button/index.js";
|
|
7
|
+
import s from "@plexui/styles/components/InputGroup/InputGroup.module.css";
|
|
8
|
+
const InputGroupContext = createContext(null);
|
|
9
|
+
const CONTROL_SELECTOR = "[data-slot='input-group-control']";
|
|
10
|
+
/** Button size for each group size: the closest Button that fits inside the control */
|
|
11
|
+
const BUTTON_SIZE = {
|
|
12
|
+
"3xs": "3xs",
|
|
13
|
+
"2xs": "3xs",
|
|
14
|
+
"xs": "3xs",
|
|
15
|
+
"sm": "3xs",
|
|
16
|
+
"md": "2xs",
|
|
17
|
+
"lg": "sm",
|
|
18
|
+
"xl": "md",
|
|
19
|
+
"2xl": "lg",
|
|
20
|
+
"3xl": "xl",
|
|
21
|
+
};
|
|
22
|
+
const InputGroupRoot = ({ variant = "outline", size = "md", pill = false, disabled = false, invalid = false, className, onMouseDown, ref, ...restProps }) => {
|
|
23
|
+
// Clicks on the frame, icons and text focus the control, as in Input
|
|
24
|
+
const handleMouseDown = (evt) => {
|
|
25
|
+
onMouseDown?.(evt);
|
|
26
|
+
const control = evt.currentTarget.querySelector(CONTROL_SELECTOR);
|
|
27
|
+
const { target } = evt;
|
|
28
|
+
if (evt.defaultPrevented || !control || !(target instanceof Element) || control.contains(target)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Buttons, links, menus and other controls in the addons take their own clicks
|
|
32
|
+
if (target.closest("button, a, input, textarea, select, [role='button'], [role='menuitem']")) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
evt.preventDefault();
|
|
36
|
+
control.focus();
|
|
37
|
+
};
|
|
38
|
+
return (_jsx(InputGroupContext.Provider, { value: { size, pill, disabled, invalid }, children: _jsx("div", { ref: ref, role: "group", "data-slot": "input-group", "data-variant": variant, "data-size": size, "data-pill": pill ? "" : undefined, "data-disabled": disabled ? "" : undefined, "data-invalid": invalid ? "" : undefined, className: clsx(s.InputGroup, className), onMouseDown: handleMouseDown, ...restProps }) }));
|
|
39
|
+
};
|
|
40
|
+
const InputGroupInput = ({ type = "text", disabled, className, ref, ...restProps }) => {
|
|
41
|
+
const group = useContext(InputGroupContext);
|
|
42
|
+
return (_jsx("input", { ref: ref, type: type, "data-slot": "input-group-control", className: clsx(s.Control, className), disabled: disabled ?? group?.disabled, "aria-invalid": restProps["aria-invalid"] ?? (group?.invalid || undefined), ...restProps }));
|
|
43
|
+
};
|
|
44
|
+
const InputGroupTextarea = ({ rows = 3, disabled, className, ref, ...restProps }) => {
|
|
45
|
+
const group = useContext(InputGroupContext);
|
|
46
|
+
return (_jsx("textarea", { ref: ref, rows: rows, "data-slot": "input-group-control", className: clsx(s.Control, className), disabled: disabled ?? group?.disabled, "aria-invalid": restProps["aria-invalid"] ?? (group?.invalid || undefined), ...restProps }));
|
|
47
|
+
};
|
|
48
|
+
const InputGroupAddon = ({ align = "inline-start", className, ref, ...restProps }) => (_jsx("div", { ref: ref, "data-slot": "input-group-addon", "data-align": align, className: clsx(s.Addon, className), ...restProps }));
|
|
49
|
+
const InputGroupButton = ({ color = "secondary", variant = "ghost", pill, disabled, className, ...restProps }) => {
|
|
50
|
+
const group = useContext(InputGroupContext);
|
|
51
|
+
return (_jsx(Button, { color: color, variant: variant, size: BUTTON_SIZE[group?.size ?? "md"], pill: pill ?? group?.pill, disabled: disabled ?? group?.disabled, className: clsx(s.Button, className), ...restProps }));
|
|
52
|
+
};
|
|
53
|
+
const InputGroupText = ({ className, ref, ...restProps }) => (_jsx("span", { ref: ref, "data-slot": "input-group-text", className: clsx(s.Text, className), ...restProps }));
|
|
54
|
+
export const InputGroup = InputGroupRoot;
|
|
55
|
+
InputGroup.Input = InputGroupInput;
|
|
56
|
+
InputGroup.Textarea = InputGroupTextarea;
|
|
57
|
+
InputGroup.Addon = InputGroupAddon;
|
|
58
|
+
InputGroup.Button = InputGroupButton;
|
|
59
|
+
InputGroup.Text = InputGroupText;
|
|
60
|
+
//# sourceMappingURL=InputGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputGroup.js","sourceRoot":"","sources":["../../../../src/components/InputGroup/InputGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,aAAa,EACb,UAAU,GAKX,MAAM,OAAO,CAAA;AACd,OAAO,EAAmC,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAoB,MAAM,WAAW,CAAA;AACpD,OAAO,CAAC,MAAM,4DAA4D,CAAA;AAS1E,MAAM,iBAAiB,GAAG,aAAa,CAAgC,IAAI,CAAC,CAAA;AAE5E,MAAM,gBAAgB,GAAG,mCAAmC,CAAA;AAE5D,uFAAuF;AACvF,MAAM,WAAW,GAAqC;IACpD,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,IAAI;IAC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;AAClC,UAAU,CAAC,MAAM,GAAG,gBAAgB,CAAA;AACpC,UAAU,CAAC,IAAI,GAAG,cAAc,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n createContext,\n useContext,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type Ref,\n type TextareaHTMLAttributes,\n} from \"react\"\nimport { type ControlSize, type Variants } from \"../../types\"\nimport { Button, type ButtonProps } from \"../Button\"\nimport s from \"@plexui/styles/components/InputGroup/InputGroup.module.css\"\n\ntype InputGroupContextValue = {\n size: ControlSize\n pill: boolean\n disabled: boolean\n invalid: boolean\n}\n\nconst InputGroupContext = createContext<InputGroupContextValue | null>(null)\n\nconst CONTROL_SELECTOR = \"[data-slot='input-group-control']\"\n\n/** Button size for each group size: the closest Button that fits inside the control */\nconst BUTTON_SIZE: Record<ControlSize, ControlSize> = {\n \"3xs\": \"3xs\",\n \"2xs\": \"3xs\",\n \"xs\": \"3xs\",\n \"sm\": \"3xs\",\n \"md\": \"2xs\",\n \"lg\": \"sm\",\n \"xl\": \"md\",\n \"2xl\": \"lg\",\n \"3xl\": \"xl\",\n}\n\n/* ------------------------------------------------------------------ */\n/* Root */\n/* ------------------------------------------------------------------ */\n\nexport type InputGroupProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Visual style of the group\n * @default outline\n */\n variant?: Variants<\"outline\" | \"soft\">\n /**\n * Controls the size of the group, on the same scale as Input\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 * Fully rounded group, with pill buttons inside\n * @default false\n */\n pill?: boolean\n /**\n * Disables the control and the buttons inside the group\n * @default false\n */\n disabled?: boolean\n /**\n * Mark the group as invalid\n * @default false\n */\n invalid?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nconst InputGroupRoot = ({\n variant = \"outline\",\n size = \"md\",\n pill = false,\n disabled = false,\n invalid = false,\n className,\n onMouseDown,\n ref,\n ...restProps\n}: InputGroupProps) => {\n // Clicks on the frame, icons and text focus the control, as in Input\n const handleMouseDown = (evt: React.MouseEvent<HTMLDivElement>) => {\n onMouseDown?.(evt)\n const control = evt.currentTarget.querySelector<HTMLElement>(CONTROL_SELECTOR)\n const { target } = evt\n if (evt.defaultPrevented || !control || !(target instanceof Element) || control.contains(target)) {\n return\n }\n // Buttons, links, menus and other controls in the addons take their own clicks\n if (target.closest(\"button, a, input, textarea, select, [role='button'], [role='menuitem']\")) {\n return\n }\n evt.preventDefault()\n control.focus()\n }\n\n return (\n <InputGroupContext.Provider value={{ size, pill, disabled, invalid }}>\n <div\n ref={ref}\n role=\"group\"\n data-slot=\"input-group\"\n data-variant={variant}\n data-size={size}\n data-pill={pill ? \"\" : undefined}\n data-disabled={disabled ? \"\" : undefined}\n data-invalid={invalid ? \"\" : undefined}\n className={clsx(s.InputGroup, className)}\n onMouseDown={handleMouseDown}\n {...restProps}\n />\n </InputGroupContext.Provider>\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* Input / Textarea: the native control, framed by the group */\n/* ------------------------------------------------------------------ */\n\nexport type InputGroupInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, \"size\"> & {\n ref?: Ref<HTMLInputElement>\n}\n\nconst InputGroupInput = ({ type = \"text\", disabled, className, ref, ...restProps }: InputGroupInputProps) => {\n const group = useContext(InputGroupContext)\n return (\n <input\n ref={ref}\n type={type}\n data-slot=\"input-group-control\"\n className={clsx(s.Control, className)}\n disabled={disabled ?? group?.disabled}\n // Expose the group's invalid state to assistive tech; an explicit aria-invalid wins\n aria-invalid={restProps[\"aria-invalid\"] ?? (group?.invalid || undefined)}\n {...restProps}\n />\n )\n}\n\nexport type InputGroupTextareaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & {\n ref?: Ref<HTMLTextAreaElement>\n}\n\nconst InputGroupTextarea = ({ rows = 3, disabled, className, ref, ...restProps }: InputGroupTextareaProps) => {\n const group = useContext(InputGroupContext)\n return (\n <textarea\n ref={ref}\n rows={rows}\n data-slot=\"input-group-control\"\n className={clsx(s.Control, className)}\n disabled={disabled ?? group?.disabled}\n aria-invalid={restProps[\"aria-invalid\"] ?? (group?.invalid || undefined)}\n {...restProps}\n />\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* Addon: icons, text and buttons beside, above or below the control */\n/* ------------------------------------------------------------------ */\n\nexport type InputGroupAddonAlign = \"inline-start\" | \"inline-end\" | \"block-start\" | \"block-end\"\n\nexport type InputGroupAddonProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Where the addon sits: before or after the control on its line, or as a\n * row above or below it. Inline addons suit `InputGroup.Input`, block\n * addons suit `InputGroup.Textarea` and labels.\n * @default \"inline-start\"\n */\n align?: InputGroupAddonAlign\n ref?: Ref<HTMLDivElement>\n}\n\nconst InputGroupAddon = ({ align = \"inline-start\", className, ref, ...restProps }: InputGroupAddonProps) => (\n <div\n ref={ref}\n data-slot=\"input-group-addon\"\n data-align={align}\n className={clsx(s.Addon, className)}\n {...restProps}\n />\n)\n\n/* ------------------------------------------------------------------ */\n/* Button: a ghost Button sized from the group */\n/* ------------------------------------------------------------------ */\n\nexport type InputGroupButtonProps = Omit<ButtonProps, \"color\" | \"size\"> & {\n /**\n * Color for the button\n * @default secondary\n */\n color?: ButtonProps[\"color\"]\n}\n\nconst InputGroupButton = ({\n color = \"secondary\",\n variant = \"ghost\",\n pill,\n disabled,\n className,\n ...restProps\n}: InputGroupButtonProps) => {\n const group = useContext(InputGroupContext)\n return (\n <Button\n color={color}\n variant={variant}\n size={BUTTON_SIZE[group?.size ?? \"md\"]}\n pill={pill ?? group?.pill}\n disabled={disabled ?? group?.disabled}\n className={clsx(s.Button, className)}\n {...restProps}\n />\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* Text: plain text inside an addon (prefixes, units, counters) */\n/* ------------------------------------------------------------------ */\n\nexport type InputGroupTextProps = HTMLAttributes<HTMLSpanElement> & {\n ref?: Ref<HTMLSpanElement>\n}\n\nconst InputGroupText = ({ className, ref, ...restProps }: InputGroupTextProps) => (\n <span ref={ref} data-slot=\"input-group-text\" className={clsx(s.Text, className)} {...restProps} />\n)\n\n/* ------------------------------------------------------------------ */\n/* Export: compound API */\n/* ------------------------------------------------------------------ */\n\ntype InputGroupComponent = typeof InputGroupRoot & {\n Input: typeof InputGroupInput\n Textarea: typeof InputGroupTextarea\n Addon: typeof InputGroupAddon\n Button: typeof InputGroupButton\n Text: typeof InputGroupText\n}\n\nexport const InputGroup = InputGroupRoot as InputGroupComponent\nInputGroup.Input = InputGroupInput\nInputGroup.Textarea = InputGroupTextarea\nInputGroup.Addon = InputGroupAddon\nInputGroup.Button = InputGroupButton\nInputGroup.Text = InputGroupText\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/InputGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAQX,MAAM,cAAc,CAAA","sourcesContent":["export {\n InputGroup,\n type InputGroupAddonAlign,\n type InputGroupAddonProps,\n type InputGroupButtonProps,\n type InputGroupInputProps,\n type InputGroupProps,\n type InputGroupTextareaProps,\n type InputGroupTextProps,\n} from \"./InputGroup\"\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import s from "@plexui/styles/components/Kbd/Kbd.module.css";
|
|
4
|
+
/** A key or a shortcut, such as ⌘K, in a tooltip, a menu item or a sentence. */
|
|
5
|
+
export const Kbd = ({ size = "sm", variant = "soft", className, ...restProps }) => {
|
|
6
|
+
return _jsx("kbd", { className: clsx(s.Kbd, className), "data-size": size, "data-variant": variant, ...restProps });
|
|
7
|
+
};
|
|
8
|
+
/** Keys pressed together: a row of `Kbd`. */
|
|
9
|
+
const Group = ({ className, ...restProps }) => {
|
|
10
|
+
return _jsx("span", { className: clsx(s.Group, className), ...restProps });
|
|
11
|
+
};
|
|
12
|
+
Kbd.Group = Group;
|
|
13
|
+
//# sourceMappingURL=Kbd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kbd.js","sourceRoot":"","sources":["../../../../src/components/Kbd/Kbd.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,CAAC,MAAM,8CAA8C,CAAA;AAgB5D,gFAAgF;AAChF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAY,EAAE,EAAE;IAC1F,OAAO,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,eAAa,IAAI,kBAAgB,OAAO,KAAM,SAAS,GAAI,CAAA;AAC1G,CAAC,CAAA;AAID,6CAA6C;AAC7C,MAAM,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,EAAiB,EAAE,EAAE;IAC3D,OAAO,eAAM,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,KAAM,SAAS,GAAI,CAAA;AACrE,CAAC,CAAA;AAED,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport type { ComponentProps } from \"react\"\nimport s from \"@plexui/styles/components/Kbd/Kbd.module.css\"\n\nexport type KbdProps = ComponentProps<\"kbd\"> & {\n /**\n * Height and text size: `xs` 16px, `sm` 20px, `md` 24px\n * @default sm\n */\n size?: \"xs\" | \"sm\" | \"md\"\n /**\n * `soft` fills the key, `outline` draws its edge. Both mix the text color,\n * so the key reads on any surface.\n * @default soft\n */\n variant?: \"soft\" | \"outline\"\n}\n\n/** A key or a shortcut, such as ⌘K, in a tooltip, a menu item or a sentence. */\nexport const Kbd = ({ size = \"sm\", variant = \"soft\", className, ...restProps }: KbdProps) => {\n return <kbd className={clsx(s.Kbd, className)} data-size={size} data-variant={variant} {...restProps} />\n}\n\nexport type KbdGroupProps = ComponentProps<\"span\">\n\n/** Keys pressed together: a row of `Kbd`. */\nconst Group = ({ className, ...restProps }: KbdGroupProps) => {\n return <span className={clsx(s.Group, className)} {...restProps} />\n}\n\nKbd.Group = Group\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Kbd/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqC,MAAM,OAAO,CAAA","sourcesContent":["export { Kbd, type KbdGroupProps, type KbdProps } from \"./Kbd\"\n"]}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import {} from "react";
|
|
5
5
|
import { Label as RadixLabel } from "radix-ui";
|
|
6
|
-
import s from "
|
|
6
|
+
import s from "@plexui/styles/components/Label/Label.module.css";
|
|
7
7
|
export const Label = ({ className, children, ...restProps }) => {
|
|
8
8
|
return (_jsx(RadixLabel.Root, { className: clsx(s.Label, className), ...restProps, children: children }));
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../src/components/Label/Label.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAuB,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../src/components/Label/Label.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAuB,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAMhE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAc,EAAE,EAAE;IACzE,OAAO,CACL,KAAC,UAAU,CAAC,IAAI,IAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,KAAM,SAAS,YAChE,QAAQ,GACO,CACnB,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ComponentProps } from \"react\"\nimport { Label as RadixLabel } from \"radix-ui\"\nimport s from \"@plexui/styles/components/Label/Label.module.css\"\n\nexport type LabelProps = ComponentProps<typeof RadixLabel.Root> & {\n className?: string\n}\n\nexport const Label = ({ className, children, ...restProps }: LabelProps) => {\n return (\n <RadixLabel.Root className={clsx(s.Label, className)} {...restProps}>\n {children}\n </RadixLabel.Root>\n )\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Label } from "./Label";
|
|
1
|
+
export { Label } from "./Label.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,14 +6,14 @@ import ReactMarkdown from "react-markdown";
|
|
|
6
6
|
import remarkBreaks from "remark-breaks";
|
|
7
7
|
import remarkDirective from "remark-directive";
|
|
8
8
|
import remarkGfm from "remark-gfm";
|
|
9
|
-
import { CodeBlock, CodeBlockBase } from "../CodeBlock/CodeBlock";
|
|
10
|
-
import { CollapsibleCodeBlock } from "../CodeBlock/CollapsibleCodeBlock";
|
|
11
|
-
import { TextLink } from "../TextLink/TextLink";
|
|
12
|
-
import { reactMarkdownRemarkDirective } from "./directives";
|
|
13
|
-
import s from "
|
|
14
|
-
import { defaultUrlTransform } from "./urlTransform";
|
|
15
|
-
import { useMathPlugins } from "./useMathPlugins";
|
|
16
|
-
import { useParseMarkdownPre } from "./useParseMarkdownPre";
|
|
9
|
+
import { CodeBlock, CodeBlockBase } from "../CodeBlock/CodeBlock.js";
|
|
10
|
+
import { CollapsibleCodeBlock } from "../CodeBlock/CollapsibleCodeBlock.js";
|
|
11
|
+
import { TextLink } from "../TextLink/TextLink.js";
|
|
12
|
+
import { reactMarkdownRemarkDirective } from "./directives.js";
|
|
13
|
+
import s from "@plexui/styles/components/Markdown/Markdown.module.css";
|
|
14
|
+
import { defaultUrlTransform } from "./urlTransform.js";
|
|
15
|
+
import { useMathPlugins } from "./useMathPlugins.js";
|
|
16
|
+
import { useParseMarkdownPre } from "./useParseMarkdownPre.js";
|
|
17
17
|
const supportsLookbehind = (() => {
|
|
18
18
|
try {
|
|
19
19
|
new RegExp("(?<=a)b");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../../../src/components/Markdown/Markdown.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAgD,MAAM,OAAO,CAAA;AACvF,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,4BAA4B,EAA0B,MAAM,cAAc,CAAA;AACnF,OAAO,CAAC,MAAM,uBAAuB,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,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AEV,MAAM,cAAc,GAAsB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;IACpE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IACxD,OAAO,CACL,KAAC,oBAAoB,IAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,YAC3D,IAAI,GACgB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,iCAAiC,GAAsC;IAC3E,GAAG,EAAE,cAAc;CACX,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Children, useMemo, type ComponentProps, type FC, type ReactNode } from \"react\"\nimport ReactMarkdown from \"react-markdown\"\nimport remarkBreaks from \"remark-breaks\"\nimport remarkDirective from \"remark-directive\"\nimport remarkGfm from \"remark-gfm\"\n\nimport { CodeBlock, CodeBlockBase } from \"../CodeBlock/CodeBlock\"\nimport { CollapsibleCodeBlock } from \"../CodeBlock/CollapsibleCodeBlock\"\nimport { TextLink } from \"../TextLink/TextLink\"\nimport { reactMarkdownRemarkDirective, type MarkdownDirective } from \"./directives\"\nimport s from \"./Markdown.module.css\"\nimport { defaultUrlTransform } from \"./urlTransform\"\nimport { useMathPlugins } from \"./useMathPlugins\"\nimport { useParseMarkdownPre } from \"./useParseMarkdownPre\"\n\nconst supportsLookbehind = (() => {\n try {\n new RegExp(\"(?<=a)b\")\n return true\n } catch {\n return false\n }\n})()\n\nexport type MarkdownComponent = FC<{\n children?: ReactNode\n className?: string\n node: Record<string, unknown>\n}>\n\nexport type MarkdownProps = {\n children: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n directives?: MarkdownDirective<any>[]\n /** Determines if remark-math plugins should be loaded for rendering LaTeX */\n includeMath?: boolean\n /** Determines whether single newlines should insert <br> tags */\n breakNewLines?: boolean\n components?: Record<string, MarkdownComponent>\n remarkPlugins?: ComponentProps<typeof ReactMarkdown>[\"remarkPlugins\"]\n rehypePlugins?: ComponentProps<typeof ReactMarkdown>[\"rehypePlugins\"]\n allowedElements?: ComponentProps<typeof ReactMarkdown>[\"allowedElements\"]\n disallowedElements?: ComponentProps<typeof ReactMarkdown>[\"disallowedElements\"]\n urlTransform?: ComponentProps<typeof ReactMarkdown>[\"urlTransform\"]\n skipHtml?: boolean\n className?: string\n copyableCodeBlocks?: boolean\n /** Determines if code blocks should use the collapsible view with \"View Code\" button */\n collapsibleCodeBlocks?: boolean\n}\n\nexport function Markdown({\n children,\n directives,\n includeMath = false,\n breakNewLines = false,\n components: propsComponents,\n remarkPlugins,\n rehypePlugins,\n allowedElements,\n disallowedElements,\n skipHtml,\n urlTransform = defaultUrlTransform,\n className,\n copyableCodeBlocks = true,\n collapsibleCodeBlocks = true,\n}: MarkdownProps) {\n const mathPlugins = useMathPlugins(includeMath)\n const baseComponents = {\n ...COMMON_COMPONENTS,\n ...(collapsibleCodeBlocks ? COLLAPSIBLE_CODE_BLOCK_COMPONENTS : null),\n ...(copyableCodeBlocks ? null : NON_COPYABLE_CODE_BLOCK_COMPONENTS),\n ...propsComponents,\n }\n const components =\n directives?.reduce((acc, directive) => {\n acc[directive.directiveName] = directive.render\n return acc\n }, baseComponents) ?? baseComponents\n\n const mergedRemarkPlugins = useMemo(() => {\n const baseRemarkPlugins = [\n remarkDirective,\n reactMarkdownRemarkDirective,\n ...mathPlugins.remarkPlugins,\n ]\n\n if (breakNewLines) {\n baseRemarkPlugins.push(remarkBreaks)\n }\n\n // remark-gfm requires lookbehind support, which will throw in <= Safari 16.4\n // with no easily available polyfill.\n if (supportsLookbehind) {\n // Do not treat single tilde as strikethrough to allow for more\n // conversational use cases such as \"~$20-$30\"\n baseRemarkPlugins.push([remarkGfm, { singleTilde: false }])\n }\n\n return [...baseRemarkPlugins, ...(remarkPlugins ?? [])]\n }, [mathPlugins.remarkPlugins, remarkPlugins, breakNewLines])\n\n return (\n <ReactMarkdown\n className={clsx(s.MarkdownContent, className)}\n remarkPlugins={mergedRemarkPlugins}\n rehypePlugins={[...(rehypePlugins ?? []), ...mathPlugins.rehypePlugins]}\n components={components}\n allowedElements={allowedElements}\n disallowedElements={disallowedElements}\n skipHtml={skipHtml}\n urlTransform={urlTransform}\n >\n {children}\n </ReactMarkdown>\n )\n}\n\nconst Pre: MarkdownComponent = ({ children, className }) => {\n const { code, language } = useParseMarkdownPre(children)\n return (\n <CodeBlock language={language} className={className}>\n {code}\n </CodeBlock>\n )\n}\n\nconst InlineCode: MarkdownComponent = ({ children, className }) => (\n <code className={clsx(s.InlineCode, className)}>{children}</code>\n)\n\nconst Anchor: MarkdownComponent = ({ children, node: _node, ...props }) => (\n <TextLink as=\"a\" {...props}>\n {children}\n </TextLink>\n)\n\n// Sourced from common markdown implementations\nconst TableCell: MarkdownComponent = ({ node: _node, children, ...rest }) => {\n return (\n <td {...rest}>\n {Children.map(children, (child, i) =>\n // ReactMarkdown does not support <br> tags in tables without using\n // remark-html (which may not be safe), so we need to manually handle them\n child === \"<br>\" ? <br key={i} /> : child,\n )}\n </td>\n )\n}\n\nconst COMMON_COMPONENTS: Record<string, MarkdownComponent> = {\n code: InlineCode,\n pre: Pre,\n a: Anchor,\n td: TableCell,\n}\n\nconst NonCopyableCodeBlock: MarkdownComponent = ({ children, className }) => {\n const { code, language } = useParseMarkdownPre(children)\n return (\n <CodeBlockBase className={className}>\n <CodeBlockBase.Code language={language}>{code}</CodeBlockBase.Code>\n </CodeBlockBase>\n )\n}\n\nconst NON_COPYABLE_CODE_BLOCK_COMPONENTS: Record<string, MarkdownComponent> = {\n pre: NonCopyableCodeBlock,\n} as const\n\nconst CollapsiblePre: MarkdownComponent = ({ children, className }) => {\n const { code, language } = useParseMarkdownPre(children)\n return (\n <CollapsibleCodeBlock language={language} className={className}>\n {code}\n </CollapsibleCodeBlock>\n )\n}\n\nconst COLLAPSIBLE_CODE_BLOCK_COMPONENTS: Record<string, MarkdownComponent> = {\n pre: CollapsiblePre,\n} as const\n"]}
|
|
1
|
+
{"version":3,"file":"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A0E;QAC1E,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,eAAS,CAAC,CAAI,CAAC,CAAC,CAAC,KAAK,CAC1C,GACE,CACN,CAAA;AACH,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAsC;IAC3D,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,GAAG;IACR,CAAC,EAAE,MAAM;IACT,EAAE,EAAE,SAAS;CACd,CAAA;AAED,MAAM,oBAAoB,GAAsB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;IAC1E,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IACxD,OAAO,CACL,KAAC,aAAa,IAAC,SAAS,EAAE,SAAS,YACjC,KAAC,aAAa,CAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,YAAG,IAAI,GAAsB,GACrD,CACjB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,kCAAkC,GAAsC;IAC5E,GAAG,EAAE,oBAAoB;CACjB,CAAA;AAEV,MAAM,cAAc,GAAsB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;IACpE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IACxD,OAAO,CACL,KAAC,oBAAoB,IAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,YAC3D,IAAI,GACgB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,iCAAiC,GAAsC;IAC3E,GAAG,EAAE,cAAc;CACX,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Children, useMemo, type ComponentProps, type FC, type ReactNode } from \"react\"\nimport ReactMarkdown from \"react-markdown\"\nimport remarkBreaks from \"remark-breaks\"\nimport remarkDirective from \"remark-directive\"\nimport remarkGfm from \"remark-gfm\"\n\nimport { CodeBlock, CodeBlockBase } from \"../CodeBlock/CodeBlock\"\nimport { CollapsibleCodeBlock } from \"../CodeBlock/CollapsibleCodeBlock\"\nimport { TextLink } from \"../TextLink/TextLink\"\nimport { reactMarkdownRemarkDirective, type MarkdownDirective } from \"./directives\"\nimport s from \"@plexui/styles/components/Markdown/Markdown.module.css\"\nimport { defaultUrlTransform } from \"./urlTransform\"\nimport { useMathPlugins } from \"./useMathPlugins\"\nimport { useParseMarkdownPre } from \"./useParseMarkdownPre\"\n\nconst supportsLookbehind = (() => {\n try {\n new RegExp(\"(?<=a)b\")\n return true\n } catch {\n return false\n }\n})()\n\nexport type MarkdownComponent = FC<{\n children?: ReactNode\n className?: string\n node: Record<string, unknown>\n}>\n\nexport type MarkdownProps = {\n children: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n directives?: MarkdownDirective<any>[]\n /** Determines if remark-math plugins should be loaded for rendering LaTeX */\n includeMath?: boolean\n /** Determines whether single newlines should insert <br> tags */\n breakNewLines?: boolean\n components?: Record<string, MarkdownComponent>\n remarkPlugins?: ComponentProps<typeof ReactMarkdown>[\"remarkPlugins\"]\n rehypePlugins?: ComponentProps<typeof ReactMarkdown>[\"rehypePlugins\"]\n allowedElements?: ComponentProps<typeof ReactMarkdown>[\"allowedElements\"]\n disallowedElements?: ComponentProps<typeof ReactMarkdown>[\"disallowedElements\"]\n urlTransform?: ComponentProps<typeof ReactMarkdown>[\"urlTransform\"]\n skipHtml?: boolean\n className?: string\n copyableCodeBlocks?: boolean\n /** Determines if code blocks should use the collapsible view with \"View Code\" button */\n collapsibleCodeBlocks?: boolean\n}\n\nexport function Markdown({\n children,\n directives,\n includeMath = false,\n breakNewLines = false,\n components: propsComponents,\n remarkPlugins,\n rehypePlugins,\n allowedElements,\n disallowedElements,\n skipHtml,\n urlTransform = defaultUrlTransform,\n className,\n copyableCodeBlocks = true,\n collapsibleCodeBlocks = true,\n}: MarkdownProps) {\n const mathPlugins = useMathPlugins(includeMath)\n const baseComponents = {\n ...COMMON_COMPONENTS,\n ...(collapsibleCodeBlocks ? COLLAPSIBLE_CODE_BLOCK_COMPONENTS : null),\n ...(copyableCodeBlocks ? null : NON_COPYABLE_CODE_BLOCK_COMPONENTS),\n ...propsComponents,\n }\n const components =\n directives?.reduce((acc, directive) => {\n acc[directive.directiveName] = directive.render\n return acc\n }, baseComponents) ?? baseComponents\n\n const mergedRemarkPlugins = useMemo(() => {\n const baseRemarkPlugins = [\n remarkDirective,\n reactMarkdownRemarkDirective,\n ...mathPlugins.remarkPlugins,\n ]\n\n if (breakNewLines) {\n baseRemarkPlugins.push(remarkBreaks)\n }\n\n // remark-gfm requires lookbehind support, which will throw in <= Safari 16.4\n // with no easily available polyfill.\n if (supportsLookbehind) {\n // Do not treat single tilde as strikethrough to allow for more\n // conversational use cases such as \"~$20-$30\"\n baseRemarkPlugins.push([remarkGfm, { singleTilde: false }])\n }\n\n return [...baseRemarkPlugins, ...(remarkPlugins ?? [])]\n }, [mathPlugins.remarkPlugins, remarkPlugins, breakNewLines])\n\n return (\n <ReactMarkdown\n className={clsx(s.MarkdownContent, className)}\n remarkPlugins={mergedRemarkPlugins}\n rehypePlugins={[...(rehypePlugins ?? []), ...mathPlugins.rehypePlugins]}\n components={components}\n allowedElements={allowedElements}\n disallowedElements={disallowedElements}\n skipHtml={skipHtml}\n urlTransform={urlTransform}\n >\n {children}\n </ReactMarkdown>\n )\n}\n\nconst Pre: MarkdownComponent = ({ children, className }) => {\n const { code, language } = useParseMarkdownPre(children)\n return (\n <CodeBlock language={language} className={className}>\n {code}\n </CodeBlock>\n )\n}\n\nconst InlineCode: MarkdownComponent = ({ children, className }) => (\n <code className={clsx(s.InlineCode, className)}>{children}</code>\n)\n\nconst Anchor: MarkdownComponent = ({ children, node: _node, ...props }) => (\n <TextLink as=\"a\" {...props}>\n {children}\n </TextLink>\n)\n\n// Sourced from common markdown implementations\nconst TableCell: MarkdownComponent = ({ node: _node, children, ...rest }) => {\n return (\n <td {...rest}>\n {Children.map(children, (child, i) =>\n // ReactMarkdown does not support <br> tags in tables without using\n // remark-html (which may not be safe), so we need to manually handle them\n child === \"<br>\" ? <br key={i} /> : child,\n )}\n </td>\n )\n}\n\nconst COMMON_COMPONENTS: Record<string, MarkdownComponent> = {\n code: InlineCode,\n pre: Pre,\n a: Anchor,\n td: TableCell,\n}\n\nconst NonCopyableCodeBlock: MarkdownComponent = ({ children, className }) => {\n const { code, language } = useParseMarkdownPre(children)\n return (\n <CodeBlockBase className={className}>\n <CodeBlockBase.Code language={language}>{code}</CodeBlockBase.Code>\n </CodeBlockBase>\n )\n}\n\nconst NON_COPYABLE_CODE_BLOCK_COMPONENTS: Record<string, MarkdownComponent> = {\n pre: NonCopyableCodeBlock,\n} as const\n\nconst CollapsiblePre: MarkdownComponent = ({ children, className }) => {\n const { code, language } = useParseMarkdownPre(children)\n return (\n <CollapsibleCodeBlock language={language} className={className}>\n {code}\n </CollapsibleCodeBlock>\n )\n}\n\nconst COLLAPSIBLE_CODE_BLOCK_COMPONENTS: Record<string, MarkdownComponent> = {\n pre: CollapsiblePre,\n} as const\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {} from "react";
|
|
2
2
|
import { visit } from "unist-util-visit";
|
|
3
|
-
import { createId } from "../../lib/ids";
|
|
4
|
-
import { decodeBase64, encodeBase64 } from "../../lib/safeBase64";
|
|
3
|
+
import { createId } from "../../lib/ids.js";
|
|
4
|
+
import { decodeBase64, encodeBase64 } from "../../lib/safeBase64.js";
|
|
5
5
|
export function createMarkdownDirective({ render, name, mode, }) {
|
|
6
6
|
const prefix = `OaiMdDirective_${name}`;
|
|
7
7
|
const uniqueName = createId(prefix, prefix.length + 6);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { useParseMarkdownPre } from "./useParseMarkdownPre";
|
|
1
|
+
export { createMarkdownDirective } from "./directives.js";
|
|
2
|
+
export { Markdown } from "./Markdown.js";
|
|
3
|
+
export { defaultUrlTransform } from "./urlTransform.js";
|
|
4
|
+
export { useParseMarkdownPre } from "./useParseMarkdownPre.js";
|
|
6
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Markdown/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Markdown/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,QAAQ,EAA8C,MAAM,YAAY,CAAA;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA","sourcesContent":["export { createMarkdownDirective } from \"./directives\"\nexport { Markdown, type MarkdownComponent, type MarkdownProps } from \"./Markdown\"\nexport { defaultUrlTransform } from \"./urlTransform\"\n\nexport { useParseMarkdownPre } from \"./useParseMarkdownPre\"\n"]}
|