@intlayer/design-system 6.1.5 → 6.1.6-canary.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/dist/.vite/manifest.json +13 -9
- package/dist/Form-CriPBaZk.js.map +1 -1
- package/dist/Form-DJrUK3mm.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.cjs +51 -15
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.d.ts +44 -5
- package/dist/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion/Accordion.mjs +52 -16
- package/dist/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/components/Avatar/index.cjs +114 -31
- package/dist/components/Avatar/index.cjs.map +1 -1
- package/dist/components/Avatar/index.d.ts +46 -2
- package/dist/components/Avatar/index.d.ts.map +1 -1
- package/dist/components/Avatar/index.mjs +115 -32
- package/dist/components/Avatar/index.mjs.map +1 -1
- package/dist/components/Badge/index.cjs +88 -9
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.ts +80 -2
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.mjs +89 -10
- package/dist/components/Badge/index.mjs.map +1 -1
- package/dist/components/Breadcrumb/index.cjs +124 -59
- package/dist/components/Breadcrumb/index.cjs.map +1 -1
- package/dist/components/Breadcrumb/index.d.ts +89 -5
- package/dist/components/Breadcrumb/index.d.ts.map +1 -1
- package/dist/components/Breadcrumb/index.mjs +124 -59
- package/dist/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/components/Button/Button.cjs +44 -25
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.d.ts +95 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.mjs +44 -25
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/ClickOutsideDiv/index.cjs +38 -7
- package/dist/components/ClickOutsideDiv/index.cjs.map +1 -1
- package/dist/components/ClickOutsideDiv/index.d.ts +13 -0
- package/dist/components/ClickOutsideDiv/index.d.ts.map +1 -1
- package/dist/components/ClickOutsideDiv/index.mjs +39 -8
- package/dist/components/ClickOutsideDiv/index.mjs.map +1 -1
- package/dist/components/Container/index.cjs +2 -0
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.d.ts +42 -0
- package/dist/components/Container/index.d.ts.map +1 -1
- package/dist/components/Container/index.mjs +2 -0
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.cjs +80 -33
- package/dist/components/ContentEditor/ContentEditor.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.d.ts +29 -0
- package/dist/components/ContentEditor/ContentEditor.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.mjs +80 -33
- package/dist/components/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorInput.cjs +58 -31
- package/dist/components/ContentEditor/ContentEditorInput.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorInput.d.ts +33 -0
- package/dist/components/ContentEditor/ContentEditorInput.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditorInput.mjs +58 -31
- package/dist/components/ContentEditor/ContentEditorInput.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs +58 -30
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts +35 -0
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs +59 -31
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs.map +1 -1
- package/dist/components/ContentEditor/index.cjs +4 -0
- package/dist/components/ContentEditor/index.cjs.map +1 -1
- package/dist/components/ContentEditor/index.d.ts +2 -0
- package/dist/components/ContentEditor/index.d.ts.map +1 -1
- package/dist/components/ContentEditor/index.mjs +5 -1
- package/dist/components/ContentEditor/index.mjs.map +1 -1
- package/dist/components/ContentSelector/ContentSelector.cjs +9 -1
- package/dist/components/ContentSelector/ContentSelector.cjs.map +1 -1
- package/dist/components/ContentSelector/ContentSelector.d.ts +167 -0
- package/dist/components/ContentSelector/ContentSelector.d.ts.map +1 -1
- package/dist/components/ContentSelector/ContentSelector.mjs +9 -1
- package/dist/components/ContentSelector/ContentSelector.mjs.map +1 -1
- package/dist/components/CopyButton/index.cjs +23 -8
- package/dist/components/CopyButton/index.cjs.map +1 -1
- package/dist/components/CopyButton/index.d.ts +78 -0
- package/dist/components/CopyButton/index.d.ts.map +1 -1
- package/dist/components/CopyButton/index.mjs +23 -8
- package/dist/components/CopyButton/index.mjs.map +1 -1
- package/dist/components/CopyToClipboard/index.cjs +58 -22
- package/dist/components/CopyToClipboard/index.cjs.map +1 -1
- package/dist/components/CopyToClipboard/index.d.ts +68 -2
- package/dist/components/CopyToClipboard/index.d.ts.map +1 -1
- package/dist/components/CopyToClipboard/index.mjs +59 -23
- package/dist/components/CopyToClipboard/index.mjs.map +1 -1
- package/dist/components/DropDown/index.cjs +6 -4
- package/dist/components/DropDown/index.cjs.map +1 -1
- package/dist/components/DropDown/index.d.ts +92 -15
- package/dist/components/DropDown/index.d.ts.map +1 -1
- package/dist/components/DropDown/index.mjs +6 -4
- package/dist/components/DropDown/index.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.d.ts +38 -0
- package/dist/components/EditableField/EditableFieldInput.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.cjs +10 -2
- package/dist/components/EditableField/EditableFieldLayout.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.mjs +10 -2
- package/dist/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.d.ts +42 -0
- package/dist/components/EditableField/EditableFieldTextArea.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/components/ExpandCollapse/ExpandCollapse.cjs.map +1 -1
- package/dist/components/ExpandCollapse/ExpandCollapse.d.ts +58 -0
- package/dist/components/ExpandCollapse/ExpandCollapse.d.ts.map +1 -1
- package/dist/components/ExpandCollapse/ExpandCollapse.mjs.map +1 -1
- package/dist/components/Footer/index.cjs.map +1 -1
- package/dist/components/Footer/index.d.ts +101 -0
- package/dist/components/Footer/index.d.ts.map +1 -1
- package/dist/components/Footer/index.mjs.map +1 -1
- package/dist/components/Form/elements/MultiselectElement.d.ts.map +1 -1
- package/dist/components/Form/elements/SelectElement.d.ts.map +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.d.ts.map +1 -1
- package/dist/components/Headers/index.cjs.map +1 -1
- package/dist/components/Headers/index.d.ts +69 -2
- package/dist/components/Headers/index.d.ts.map +1 -1
- package/dist/components/Headers/index.mjs.map +1 -1
- package/dist/components/HeightResizer/index.cjs +10 -7
- package/dist/components/HeightResizer/index.cjs.map +1 -1
- package/dist/components/HeightResizer/index.d.ts +89 -0
- package/dist/components/HeightResizer/index.d.ts.map +1 -1
- package/dist/components/HeightResizer/index.mjs +10 -7
- package/dist/components/HeightResizer/index.mjs.map +1 -1
- package/dist/components/InformationTag/index.cjs.map +1 -1
- package/dist/components/InformationTag/index.d.ts +72 -0
- package/dist/components/InformationTag/index.d.ts.map +1 -1
- package/dist/components/InformationTag/index.mjs.map +1 -1
- package/dist/components/KeyboardScreenAdapter/index.cjs.map +1 -1
- package/dist/components/KeyboardScreenAdapter/index.d.ts +100 -0
- package/dist/components/KeyboardScreenAdapter/index.d.ts.map +1 -1
- package/dist/components/KeyboardScreenAdapter/index.mjs.map +1 -1
- package/dist/components/Label/index.cjs +25 -3
- package/dist/components/Label/index.cjs.map +1 -1
- package/dist/components/Label/index.d.ts +65 -1
- package/dist/components/Label/index.d.ts.map +1 -1
- package/dist/components/Label/index.mjs +26 -4
- package/dist/components/Label/index.mjs.map +1 -1
- package/dist/components/Link/Link.cjs.map +1 -1
- package/dist/components/Link/Link.d.ts +169 -0
- package/dist/components/Link/Link.d.ts.map +1 -1
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/Loader/index.cjs.map +1 -1
- package/dist/components/Loader/index.d.ts +82 -11
- package/dist/components/Loader/index.d.ts.map +1 -1
- package/dist/components/Loader/index.mjs.map +1 -1
- package/dist/components/Loader/spinner.cjs.map +1 -1
- package/dist/components/Loader/spinner.d.ts +56 -0
- package/dist/components/Loader/spinner.d.ts.map +1 -1
- package/dist/components/Loader/spinner.mjs.map +1 -1
- package/dist/components/MarkDownRender/MarkDownRender.cjs +0 -1
- package/dist/components/MarkDownRender/MarkDownRender.cjs.map +1 -1
- package/dist/components/MarkDownRender/MarkDownRender.d.ts +147 -0
- package/dist/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
- package/dist/components/MarkDownRender/MarkDownRender.mjs +0 -1
- package/dist/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
- package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
- package/dist/components/MaxHeightSmoother/index.d.ts +152 -0
- package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
- package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
- package/dist/components/Modal/Modal.cjs +5 -0
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +81 -3
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +5 -0
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/Navbar/Burger.cjs.map +1 -1
- package/dist/components/Navbar/Burger.d.ts +54 -0
- package/dist/components/Navbar/Burger.d.ts.map +1 -1
- package/dist/components/Navbar/Burger.mjs.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.cjs.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.d.ts +78 -0
- package/dist/components/Navbar/DesktopNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.mjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.d.ts +88 -0
- package/dist/components/Navbar/MobileNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/MobileNavbar.mjs.map +1 -1
- package/dist/components/Navbar/index.cjs.map +1 -1
- package/dist/components/Navbar/index.d.ts +69 -0
- package/dist/components/Navbar/index.d.ts.map +1 -1
- package/dist/components/Navbar/index.mjs.map +1 -1
- package/dist/components/Navbar/useNavigation.cjs +8 -1
- package/dist/components/Navbar/useNavigation.cjs.map +1 -1
- package/dist/components/Navbar/useNavigation.d.ts +83 -0
- package/dist/components/Navbar/useNavigation.d.ts.map +1 -1
- package/dist/components/Navbar/useNavigation.mjs +8 -1
- package/dist/components/Navbar/useNavigation.mjs.map +1 -1
- package/dist/components/Pattern/DotPattern.cjs.map +1 -1
- package/dist/components/Pattern/DotPattern.d.ts +101 -0
- package/dist/components/Pattern/DotPattern.d.ts.map +1 -1
- package/dist/components/Pattern/DotPattern.mjs.map +1 -1
- package/dist/components/Pattern/GridPattern.cjs.map +1 -1
- package/dist/components/Pattern/GridPattern.d.ts +114 -0
- package/dist/components/Pattern/GridPattern.d.ts.map +1 -1
- package/dist/components/Pattern/GridPattern.mjs.map +1 -1
- package/dist/components/Pattern/SpotLight.cjs.map +1 -1
- package/dist/components/Pattern/SpotLight.d.ts +125 -0
- package/dist/components/Pattern/SpotLight.d.ts.map +1 -1
- package/dist/components/Pattern/SpotLight.mjs.map +1 -1
- package/dist/components/Popover/index.cjs +10 -10
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.ts +110 -15
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.mjs +10 -10
- package/dist/components/Popover/index.mjs.map +1 -1
- package/dist/components/PressableSpan/PressableSpan.cjs +22 -5
- package/dist/components/PressableSpan/PressableSpan.cjs.map +1 -1
- package/dist/components/PressableSpan/PressableSpan.d.ts +105 -3
- package/dist/components/PressableSpan/PressableSpan.d.ts.map +1 -1
- package/dist/components/PressableSpan/PressableSpan.mjs +22 -5
- package/dist/components/PressableSpan/PressableSpan.mjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.d.ts +182 -0
- package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.cjs.map +1 -1
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.d.ts +44 -0
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.d.ts.map +1 -1
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.mjs.map +1 -1
- package/dist/components/RightDrawer/useRightDrawerStore.cjs.map +1 -1
- package/dist/components/RightDrawer/useRightDrawerStore.d.ts +102 -0
- package/dist/components/RightDrawer/useRightDrawerStore.d.ts.map +1 -1
- package/dist/components/RightDrawer/useRightDrawerStore.mjs.map +1 -1
- package/dist/components/Select/Multiselect.cjs.map +1 -1
- package/dist/components/Select/Multiselect.d.ts +125 -18
- package/dist/components/Select/Multiselect.d.ts.map +1 -1
- package/dist/components/Select/Multiselect.mjs.map +1 -1
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.d.ts +214 -7
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/SwitchSelector/index.cjs.map +1 -1
- package/dist/components/SwitchSelector/index.d.ts +157 -8
- package/dist/components/SwitchSelector/index.d.ts.map +1 -1
- package/dist/components/SwitchSelector/index.mjs.map +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.d.ts +184 -0
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.mjs.map +1 -1
- package/dist/components/Tag/index.cjs.map +1 -1
- package/dist/components/Tag/index.d.ts +223 -0
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.mjs.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.cjs.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.d.ts +91 -0
- package/dist/components/TextArea/AutoSizeTextArea.d.ts.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.mjs.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.cjs.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.d.ts +145 -0
- package/dist/components/TextArea/AutocompleteTextArea.d.ts.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.mjs.map +1 -1
- package/dist/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +74 -0
- package/dist/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/Toaster/Toast.cjs +4 -0
- package/dist/components/Toaster/Toast.cjs.map +1 -1
- package/dist/components/Toaster/Toast.d.ts +148 -2
- package/dist/components/Toaster/Toast.d.ts.map +1 -1
- package/dist/components/Toaster/Toast.mjs +4 -0
- package/dist/components/Toaster/Toast.mjs.map +1 -1
- package/dist/components/Toaster/Toaster.cjs.map +1 -1
- package/dist/components/Toaster/Toaster.d.ts +42 -0
- package/dist/components/Toaster/Toaster.d.ts.map +1 -1
- package/dist/components/Toaster/Toaster.mjs.map +1 -1
- package/dist/components/Toaster/useToast.cjs.map +1 -1
- package/dist/components/Toaster/useToast.d.ts +199 -2
- package/dist/components/Toaster/useToast.d.ts.map +1 -1
- package/dist/components/Toaster/useToast.mjs.map +1 -1
- package/dist/components/WithResizer/index.cjs.map +1 -1
- package/dist/components/WithResizer/index.d.ts +143 -0
- package/dist/components/WithResizer/index.d.ts.map +1 -1
- package/dist/components/WithResizer/index.mjs.map +1 -1
- package/dist/components/index.cjs +2 -2
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/components/index.mjs.map +1 -1
- package/dist/hooks/reactQuery.cjs +2 -1
- package/dist/hooks/reactQuery.cjs.map +1 -1
- package/dist/hooks/reactQuery.d.ts +1 -1
- package/dist/hooks/reactQuery.d.ts.map +1 -1
- package/dist/hooks/reactQuery.mjs +2 -1
- package/dist/hooks/reactQuery.mjs.map +1 -1
- package/dist/utils/image.cjs +30 -0
- package/dist/utils/image.cjs.map +1 -0
- package/dist/utils/image.d.ts +37 -0
- package/dist/utils/image.d.ts.map +1 -0
- package/dist/utils/image.mjs +30 -0
- package/dist/utils/image.mjs.map +1 -0
- package/package.json +20 -18
- package/dist/utils/capitalize.cjs +0 -10
- package/dist/utils/capitalize.cjs.map +0 -1
- package/dist/utils/capitalize.d.ts +0 -2
- package/dist/utils/capitalize.d.ts.map +0 -1
- package/dist/utils/capitalize.mjs +0 -10
- package/dist/utils/capitalize.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.mjs","sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { getLocalizedUrl } from '@intlayer/core';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { ExternalLink } from 'lucide-react';\nimport {\n type AnchorHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\nexport enum LinkVariant {\n DEFAULT = 'default',\n INVISIBLE_LINK = 'invisible-link',\n BUTTON = 'button',\n BUTTON_OUTLINED = 'button-outlined',\n HOVERABLE = 'hoverable',\n}\n\nexport enum LinkColor {\n PRIMARY = 'primary',\n SECONDARY = 'secondary',\n DESTRUCTIVE = 'destructive',\n NEUTRAL = 'neutral',\n LIGHT = 'light',\n DARK = 'dark',\n TEXT = 'text',\n TEXT_INVERSE = 'text-inverse',\n ERROR = 'error',\n SUCCESS = 'success',\n CUSTOM = 'custom',\n}\n\nexport enum LinkUnderlined {\n DEFAULT = 'default',\n TRUE = 'true',\n FALSE = 'false',\n}\n\nexport const linkVariants = cva(\n 'gap-3 transition focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n [`${LinkVariant.DEFAULT}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-4 hover:bg-current/0 hover:underline',\n [`${LinkVariant.INVISIBLE_LINK}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-4 hover:bg-current/0',\n [`${LinkVariant.BUTTON}`]:\n 'rounded-lg bg-current *:text-text-opposite min-h-8 px-6 max-md:py-2 text-sm flex items-center justify-center gap-2 whitespace-nowrap font-medium transition focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',\n [`${LinkVariant.BUTTON_OUTLINED}`]:\n 'rounded-lg border-[1.5px] hover:bg-current/30 min-h-8 px-6 max-md:py-2 text-sm flex items-center justify-center gap-2 whitespace-nowrap font-medium transition focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',\n [`${LinkVariant.HOVERABLE}`]:\n 'block rounded-lg border-none bg-current/0 transition hover:bg-current/20 aria-[current]:bg-current/5',\n },\n color: {\n [`${LinkColor.PRIMARY}`]: 'text-primary',\n [`${LinkColor.SECONDARY}`]: 'text-secondary',\n [`${LinkColor.DESTRUCTIVE}`]: 'text-destructive',\n [`${LinkColor.NEUTRAL}`]: 'text-neutral',\n [`${LinkColor.LIGHT}`]: 'text-white',\n [`${LinkColor.DARK}`]: 'text-neutral-800',\n [`${LinkColor.TEXT}`]: 'text-text',\n [`${LinkColor.TEXT_INVERSE}`]: 'text-text-opposite',\n [`${LinkColor.ERROR}`]: 'text-error',\n [`${LinkColor.SUCCESS}`]: 'text-success',\n [`${LinkColor.CUSTOM}`]: '',\n },\n underlined: {\n [LinkUnderlined.DEFAULT]: '',\n [LinkUnderlined.TRUE]: 'underline',\n [LinkUnderlined.FALSE]: 'no-underline',\n },\n },\n\n defaultVariants: {\n variant: LinkVariant.DEFAULT,\n color: LinkColor.PRIMARY,\n underlined: LinkUnderlined.DEFAULT,\n },\n }\n);\n\nexport type LinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> &\n VariantProps<typeof linkVariants> & {\n label: string;\n isExternalLink?: boolean;\n isActive?: boolean;\n locale?: LocalesValues;\n };\n\nexport const checkIsExternalLink = ({\n href,\n isExternalLink: isExternalLinkProp,\n}: LinkProps): boolean => {\n const isValidHref = typeof href === 'string' && href.trim() !== '';\n const isExternalLink =\n isExternalLinkProp === true ||\n (typeof isExternalLinkProp === 'undefined' &&\n isValidHref &&\n /^https?:\\/\\//.test(href));\n\n return isExternalLink;\n};\n\nexport const Link: FC<LinkProps> = (props) => {\n const {\n variant = LinkVariant.DEFAULT,\n color = LinkColor.PRIMARY,\n children,\n label,\n className,\n isActive,\n underlined,\n locale,\n isExternalLink: isExternalLinkProp,\n href: hrefProp,\n ...otherProps\n } = props;\n const { internationalization } = configuration;\n\n const isExternalLink = checkIsExternalLink(props);\n const isChildrenString = typeof children === 'string';\n\n const rel = isExternalLink ? 'noopener noreferrer nofollow' : undefined;\n\n const target = isExternalLink ? '_blank' : '_self';\n\n const hrefLang = locale\n ? locale === internationalization.defaultLocale\n ? 'x-default'\n : locale\n : undefined;\n\n const href =\n locale && hrefProp && !isExternalLink\n ? getLocalizedUrl(hrefProp, locale)\n : hrefProp;\n\n return (\n <a\n href={href}\n hrefLang={hrefLang}\n aria-label={label}\n rel={rel}\n target={target}\n aria-current={isActive ? 'page' : undefined}\n className={cn(\n linkVariants({\n variant,\n color,\n underlined,\n className,\n })\n )}\n {...otherProps}\n >\n {variant === 'button' ? <span>{children}</span> : children}\n {isExternalLink && isChildrenString && (\n <ExternalLink className=\"ml-2 inline-block size-4\" />\n )}\n </a>\n );\n};\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,gBAC9B,cACA,SACF;AAEJ,QAAM,OACJ,UAAU,YAAY,CAAC,iBACnB,gBAAgB,UAAU,MAAM,IAChC;AAEN,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,cAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,gBAAc,WAAW,SAAS;AAAA,MAClC,WAAW;AAAA,QACT,aAAa;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,MAEF,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA,YAAY,WAAW,oBAAC,QAAA,EAAM,SAAA,CAAS,IAAU;AAAA,QACjD,kBAAkB,oBACjB,oBAAC,cAAA,EAAa,WAAU,2BAAA,CAA2B;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAI3D;"}
|
|
1
|
+
{"version":3,"file":"Link.mjs","sources":["../../../src/components/Link/Link.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { getLocalizedUrl } from '@intlayer/core';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { ExternalLink } from 'lucide-react';\nimport {\n type AnchorHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\n/**\n * Visual style variants for Link component\n *\n * @enum {string}\n */\nexport enum LinkVariant {\n /** Default underlined link with hover effects */\n DEFAULT = 'default',\n /** Link without visible underline or hover effects */\n INVISIBLE_LINK = 'invisible-link',\n /** Button-styled link with solid background */\n BUTTON = 'button',\n /** Button-styled link with outlined border */\n BUTTON_OUTLINED = 'button-outlined',\n /** Link with subtle hover background effect */\n HOVERABLE = 'hoverable',\n}\n\n/**\n * Color theme variants for Link component\n *\n * @enum {string}\n */\nexport enum LinkColor {\n /** Primary brand color */\n PRIMARY = 'primary',\n /** Secondary brand color */\n SECONDARY = 'secondary',\n /** Destructive/danger color for critical actions */\n DESTRUCTIVE = 'destructive',\n /** Neutral/muted color for less prominent links */\n NEUTRAL = 'neutral',\n /** Light color for dark backgrounds */\n LIGHT = 'light',\n /** Dark color for light backgrounds */\n DARK = 'dark',\n /** Default text color */\n TEXT = 'text',\n /** Inverse text color for opposite backgrounds */\n TEXT_INVERSE = 'text-inverse',\n /** Error/red color for error states */\n ERROR = 'error',\n /** Success/green color for positive actions */\n SUCCESS = 'success',\n /** Custom color - no default styling applied */\n CUSTOM = 'custom',\n}\n\n/**\n * Underline style options for Link component\n *\n * @enum {string}\n */\nexport enum LinkUnderlined {\n /** Default underline behavior based on variant */\n DEFAULT = 'default',\n /** Always show underline */\n TRUE = 'true',\n /** Never show underline */\n FALSE = 'false',\n}\n\n/**\n * Class variance authority configuration for Link component styling\n * Defines the visual appearance based on variant, color, and underline options\n */\nexport const linkVariants = cva(\n 'gap-3 transition focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n [`${LinkVariant.DEFAULT}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-4 hover:bg-current/0 hover:underline',\n [`${LinkVariant.INVISIBLE_LINK}`]:\n 'h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-4 hover:bg-current/0',\n [`${LinkVariant.BUTTON}`]:\n 'rounded-lg bg-current *:text-text-opposite min-h-8 px-6 max-md:py-2 text-sm flex items-center justify-center gap-2 whitespace-nowrap font-medium transition focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',\n [`${LinkVariant.BUTTON_OUTLINED}`]:\n 'rounded-lg border-[1.5px] hover:bg-current/30 min-h-8 px-6 max-md:py-2 text-sm flex items-center justify-center gap-2 whitespace-nowrap font-medium transition focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',\n [`${LinkVariant.HOVERABLE}`]:\n 'block rounded-lg border-none bg-current/0 transition hover:bg-current/20 aria-[current]:bg-current/5',\n },\n color: {\n [`${LinkColor.PRIMARY}`]: 'text-primary',\n [`${LinkColor.SECONDARY}`]: 'text-secondary',\n [`${LinkColor.DESTRUCTIVE}`]: 'text-destructive',\n [`${LinkColor.NEUTRAL}`]: 'text-neutral',\n [`${LinkColor.LIGHT}`]: 'text-white',\n [`${LinkColor.DARK}`]: 'text-neutral-800',\n [`${LinkColor.TEXT}`]: 'text-text',\n [`${LinkColor.TEXT_INVERSE}`]: 'text-text-opposite',\n [`${LinkColor.ERROR}`]: 'text-error',\n [`${LinkColor.SUCCESS}`]: 'text-success',\n [`${LinkColor.CUSTOM}`]: '',\n },\n underlined: {\n [LinkUnderlined.DEFAULT]: '',\n [LinkUnderlined.TRUE]: 'underline',\n [LinkUnderlined.FALSE]: 'no-underline',\n },\n },\n\n defaultVariants: {\n variant: LinkVariant.DEFAULT,\n color: LinkColor.PRIMARY,\n underlined: LinkUnderlined.DEFAULT,\n },\n }\n);\n\n/**\n * Props interface for the Link component\n *\n * @interface LinkProps\n * @extends {DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>}\n * @extends {VariantProps<typeof linkVariants>}\n */\nexport type LinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> &\n VariantProps<typeof linkVariants> & {\n /**\n * Accessible label for screen readers (required)\n * Provides context about what the link does or where it leads\n * @example \"Navigate to home page\"\n */\n label: string;\n\n /**\n * Whether this link opens in a new tab/window\n * When true, adds target=\"_blank\" and security attributes\n * Auto-detected for URLs starting with http/https when undefined\n * @default undefined (auto-detect based on href)\n */\n isExternalLink?: boolean;\n\n /**\n * Whether this link represents the current page/active state\n * Adds aria-current=\"page\" for accessibility\n * @default false\n */\n isActive?: boolean;\n\n /**\n * Locale for internationalized URLs\n * When provided, URLs are automatically localized using Intlayer\n * @example 'fr', 'es', 'en'\n */\n locale?: LocalesValues;\n };\n\n/**\n * Utility function to determine if a link should be treated as external\n *\n * @param props - Link component props containing href and isExternalLink\n * @returns {boolean} True if the link should open externally\n *\n * @example\n * ```tsx\n * checkIsExternalLink({ href: 'https://example.com' }) // true\n * checkIsExternalLink({ href: '/internal-page' }) // false\n * checkIsExternalLink({ href: '/page', isExternalLink: true }) // true\n * ```\n */\nexport const checkIsExternalLink = ({\n href,\n isExternalLink: isExternalLinkProp,\n}: LinkProps): boolean => {\n const isValidHref = typeof href === 'string' && href.trim() !== '';\n const isExternalLink =\n isExternalLinkProp === true ||\n (typeof isExternalLinkProp === 'undefined' &&\n isValidHref &&\n /^https?:\\/\\//.test(href));\n\n return isExternalLink;\n};\n\n/**\n * Link Component\n *\n * A versatile link component that handles both internal and external navigation\n * with comprehensive internationalization support and multiple visual variants.\n *\n * ## Key Features\n * - **Multiple Variants**: Default, invisible, button, outlined button, and hoverable styles\n * - **Color Themes**: Comprehensive color palette for different contexts and meanings\n * - **External Link Detection**: Automatic detection and handling of external URLs\n * - **Internationalization**: Built-in support for localized URLs via Intlayer\n * - **Security**: Automatic security attributes for external links (noopener, noreferrer)\n * - **Accessibility**: Full ARIA support with proper labels and current page indication\n * - **Visual Feedback**: Hover effects, underline options, and active states\n *\n * ## Use Cases\n * - Navigation within applications (internal links)\n * - External links to other websites with security measures\n * - Button-styled links for call-to-action scenarios\n * - Subtle hoverable links for navigation menus\n * - Multi-language website navigation with automatic URL localization\n *\n * ## Security Features\n * External links automatically receive security attributes:\n * - `rel=\"noopener noreferrer nofollow\"` - Prevents security vulnerabilities\n * - `target=\"_blank\"` - Opens in new tab/window\n * - External link icon indication for user clarity\n *\n * ## Internationalization\n * When used with Intlayer, the component automatically:\n * - Localizes internal URLs based on the current or specified locale\n * - Sets appropriate `hrefLang` attributes for SEO\n * - Maintains proper URL structure for multi-language sites\n *\n * @component\n * @example\n * ```tsx\n * // Basic internal link\n * <Link href=\"/about\" label=\"Go to about page\">\n * About Us\n * </Link>\n *\n * // External link with auto-detection\n * <Link href=\"https://example.com\" label=\"Visit external site\">\n * External Site\n * </Link>\n *\n * // Button-styled link\n * <Link\n * href=\"/signup\"\n * variant={LinkVariant.BUTTON}\n * color={LinkColor.PRIMARY}\n * label=\"Sign up for account\"\n * >\n * Get Started\n * </Link>\n *\n * // Localized link\n * <Link\n * href=\"/products\"\n * locale=\"fr\"\n * label=\"Voir les produits\"\n * >\n * Produits\n * </Link>\n *\n * // Active navigation link\n * <Link\n * href=\"/dashboard\"\n * isActive={true}\n * variant={LinkVariant.HOVERABLE}\n * label=\"Current page: Dashboard\"\n * >\n * Dashboard\n * </Link>\n * ```\n *\n * @param props - Link component props\n * @param props.children - Content to display inside the link\n * @param props.href - URL or path to navigate to\n * @param props.label - Accessible label describing the link's purpose\n * @param props.variant - Visual style variant\n * @param props.color - Color theme for the link\n * @param props.underlined - Underline visibility option\n * @param props.isExternalLink - Override external link detection\n * @param props.isActive - Whether this link represents the current page\n * @param props.locale - Locale for URL internationalization\n * @param props.className - Additional CSS classes\n * @returns Accessible and internationalized link component\n */\nexport const Link: FC<LinkProps> = (props) => {\n const {\n variant = LinkVariant.DEFAULT,\n color = LinkColor.PRIMARY,\n children,\n label,\n className,\n isActive,\n underlined,\n locale,\n isExternalLink: isExternalLinkProp,\n href: hrefProp,\n ...otherProps\n } = props;\n const { internationalization } = configuration;\n\n const isExternalLink = checkIsExternalLink(props);\n const isChildrenString = typeof children === 'string';\n\n const rel = isExternalLink ? 'noopener noreferrer nofollow' : undefined;\n\n const target = isExternalLink ? '_blank' : '_self';\n\n const hrefLang = locale\n ? locale === internationalization.defaultLocale\n ? 'x-default'\n : locale\n : undefined;\n\n const href =\n locale && hrefProp && !isExternalLink\n ? getLocalizedUrl(hrefProp, locale)\n : hrefProp;\n\n return (\n <a\n href={href}\n hrefLang={hrefLang}\n aria-label={label}\n rel={rel}\n target={target}\n aria-current={isActive ? 'page' : undefined}\n className={cn(\n linkVariants({\n variant,\n color,\n underlined,\n className,\n })\n )}\n {...otherProps}\n >\n {variant === 'button' ? <span>{children}</span> : children}\n {isExternalLink && isChildrenString && (\n <ExternalLink className=\"ml-2 inline-block size-4\" />\n )}\n </a>\n );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AM,WAAW,SACb,WAAW,qBAAqB,gBAC9B,cACA,SACF;AAEJ,QAAM,OACJ,UAAU,YAAY,CAAC,iBACnB,gBAAgB,UAAU,MAAM,IAChC;AAEN,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,cAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,gBAAc,WAAW,SAAS;AAAA,MAClC,WAAW;AAAA,QACT,aAAa;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,MAEF,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA,YAAY,WAAW,oBAAC,QAAA,EAAM,SAAA,CAAS,IAAU;AAAA,QACjD,kBAAkB,oBACjB,oBAAC,cAAA,EAAa,WAAU,2BAAA,CAA2B;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAI3D;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Loader/index.tsx"],"sourcesContent":["import type { FC, HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Spinner } from './spinner';\n\nexport type LoaderProps = HTMLAttributes<HTMLDivElement> & {\n isLoading?: boolean;\n};\n\n/**\n *\n *
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Loader/index.tsx"],"sourcesContent":["import type { FC, HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Spinner } from './spinner';\n\n/**\n * Props for the Loader component\n */\nexport type LoaderProps = HTMLAttributes<HTMLDivElement> & {\n /** Controls whether the loading spinner is displayed. Defaults to true when undefined */\n isLoading?: boolean;\n};\n\n/**\n * Loader Component\n *\n * A versatile loading component that can function as both a standalone loader\n * and a wrapper for content. When loading is true, displays an animated spinner.\n * When loading is false, renders the wrapped content.\n *\n * @component\n * @example\n * Standalone usage:\n * ```tsx\n * <Loader isLoading={true} />\n * ```\n *\n * @example\n * As a content wrapper:\n * ```tsx\n * <Loader isLoading={isDataLoading}>\n * <div>Your content here</div>\n * </Loader>\n * ```\n *\n * @example\n * Default behavior (loading = true):\n * ```tsx\n * <Loader />\n * ```\n *\n * @example\n * With custom styling:\n * ```tsx\n * <Loader\n * isLoading={true}\n * className=\"min-h-[200px] bg-gray-50\"\n * aria-label=\"Loading user data\"\n * />\n * ```\n *\n * @example\n * Conditional content loading:\n * ```tsx\n * <Loader isLoading={!data}>\n * {data && (\n * <div>\n * <h2>{data.title}</h2>\n * <p>{data.content}</p>\n * </div>\n * )}\n * </Loader>\n * ```\n *\n * Features:\n * - Dual-mode operation: standalone spinner or content wrapper\n * - Responsive design with flexible sizing\n * - Accessible with proper ARIA attributes and role\n * - Smooth animated spinner using SVG\n * - Customizable styling through className prop\n * - Supports all standard HTML div attributes\n * - Screen constraints (max-height/width) to prevent overflow\n * - Internationalization ready with aria-label support\n *\n * Accessibility:\n * - Uses role=\"status\" for screen reader announcements\n * - Includes descriptive aria-label for the loading state\n * - Maintains focus management when transitioning between states\n * - Supports custom aria-label through props for specific contexts\n * - Compatible with keyboard navigation patterns\n *\n * Performance:\n * - Lightweight SVG spinner with CSS animations\n * - Conditional rendering prevents unnecessary DOM updates\n * - Optimized for frequent loading state changes\n * - No external dependencies beyond internal utilities\n *\n * @param props - Component props extending HTML div attributes\n * @param props.children - Content to display when not loading\n * @param props.isLoading - Loading state control (defaults to true)\n * @param props.className - Additional CSS classes for the loader container\n * @param props.role - ARIA role (defaults to \"status\")\n * @param props.aria-label - Custom accessibility label\n * @param props.id - Unique identifier for the loader\n * @param props.style - Inline styles object\n * @param props.data-* - Data attributes for testing or tracking\n * @param props...rest - All other standard HTML div attributes\n *\n * @returns A loading spinner when isLoading is true, otherwise renders children\n */\nexport const Loader: FC<LoaderProps> = ({\n children,\n isLoading = true,\n className,\n ...props\n}) => (\n <>\n {isLoading ? (\n <div\n className={cn(\n 'flex size-full max-h-screen max-w-[100vw] flex-1 items-center justify-center',\n className\n )}\n role=\"status\"\n aria-label=\"Animated icon, meaning that the website is processing\"\n {...props}\n >\n <Spinner className=\"size-10 max-h-full max-w-full\" />\n </div>\n ) : (\n (children ?? <></>)\n )}\n </>\n);\n"],"names":["jsx","cn","Spinner"],"mappings":";;;;;AAmGO,MAAM,SAA0B,CAAC;AAAA,EACtC;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,GAAG;AACL,4DAEK,UAAA,YACCA,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC,SAAAA;AAAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAEF,MAAK;AAAA,IACL,cAAW;AAAA,IACV,GAAG;AAAA,IAEJ,UAAAD,2BAAAA,IAACE,0BAAAA,SAAA,EAAQ,WAAU,gCAAA,CAAgC;AAAA,EAAA;AACrD,IAEC,kEAAc,EAAA,CAEnB;;"}
|
|
@@ -1,26 +1,97 @@
|
|
|
1
1
|
import { FC, HTMLAttributes } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the Loader component
|
|
4
|
+
*/
|
|
2
5
|
export type LoaderProps = HTMLAttributes<HTMLDivElement> & {
|
|
6
|
+
/** Controls whether the loading spinner is displayed. Defaults to true when undefined */
|
|
3
7
|
isLoading?: boolean;
|
|
4
8
|
};
|
|
5
9
|
/**
|
|
10
|
+
* Loader Component
|
|
6
11
|
*
|
|
7
|
-
*
|
|
12
|
+
* A versatile loading component that can function as both a standalone loader
|
|
13
|
+
* and a wrapper for content. When loading is true, displays an animated spinner.
|
|
14
|
+
* When loading is false, renders the wrapped content.
|
|
8
15
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
16
|
+
* @component
|
|
17
|
+
* @example
|
|
18
|
+
* Standalone usage:
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Loader isLoading={true} />
|
|
14
21
|
* ```
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* As a content wrapper:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Loader isLoading={isDataLoading}>
|
|
27
|
+
* <div>Your content here</div>
|
|
28
|
+
* </Loader>
|
|
18
29
|
* ```
|
|
19
30
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
31
|
+
* @example
|
|
32
|
+
* Default behavior (loading = true):
|
|
33
|
+
* ```tsx
|
|
22
34
|
* <Loader />
|
|
23
35
|
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* With custom styling:
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <Loader
|
|
41
|
+
* isLoading={true}
|
|
42
|
+
* className="min-h-[200px] bg-gray-50"
|
|
43
|
+
* aria-label="Loading user data"
|
|
44
|
+
* />
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* Conditional content loading:
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <Loader isLoading={!data}>
|
|
51
|
+
* {data && (
|
|
52
|
+
* <div>
|
|
53
|
+
* <h2>{data.title}</h2>
|
|
54
|
+
* <p>{data.content}</p>
|
|
55
|
+
* </div>
|
|
56
|
+
* )}
|
|
57
|
+
* </Loader>
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* Features:
|
|
61
|
+
* - Dual-mode operation: standalone spinner or content wrapper
|
|
62
|
+
* - Responsive design with flexible sizing
|
|
63
|
+
* - Accessible with proper ARIA attributes and role
|
|
64
|
+
* - Smooth animated spinner using SVG
|
|
65
|
+
* - Customizable styling through className prop
|
|
66
|
+
* - Supports all standard HTML div attributes
|
|
67
|
+
* - Screen constraints (max-height/width) to prevent overflow
|
|
68
|
+
* - Internationalization ready with aria-label support
|
|
69
|
+
*
|
|
70
|
+
* Accessibility:
|
|
71
|
+
* - Uses role="status" for screen reader announcements
|
|
72
|
+
* - Includes descriptive aria-label for the loading state
|
|
73
|
+
* - Maintains focus management when transitioning between states
|
|
74
|
+
* - Supports custom aria-label through props for specific contexts
|
|
75
|
+
* - Compatible with keyboard navigation patterns
|
|
76
|
+
*
|
|
77
|
+
* Performance:
|
|
78
|
+
* - Lightweight SVG spinner with CSS animations
|
|
79
|
+
* - Conditional rendering prevents unnecessary DOM updates
|
|
80
|
+
* - Optimized for frequent loading state changes
|
|
81
|
+
* - No external dependencies beyond internal utilities
|
|
82
|
+
*
|
|
83
|
+
* @param props - Component props extending HTML div attributes
|
|
84
|
+
* @param props.children - Content to display when not loading
|
|
85
|
+
* @param props.isLoading - Loading state control (defaults to true)
|
|
86
|
+
* @param props.className - Additional CSS classes for the loader container
|
|
87
|
+
* @param props.role - ARIA role (defaults to "status")
|
|
88
|
+
* @param props.aria-label - Custom accessibility label
|
|
89
|
+
* @param props.id - Unique identifier for the loader
|
|
90
|
+
* @param props.style - Inline styles object
|
|
91
|
+
* @param props.data-* - Data attributes for testing or tracking
|
|
92
|
+
* @param props...rest - All other standard HTML div attributes
|
|
93
|
+
*
|
|
94
|
+
* @returns A loading spinner when isLoading is true, otherwise renders children
|
|
24
95
|
*/
|
|
25
96
|
export declare const Loader: FC<LoaderProps>;
|
|
26
97
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Loader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIhD,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Loader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIhD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IACzD,yFAAyF;IACzF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AACH,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CAuBlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/components/Loader/index.tsx"],"sourcesContent":["import type { FC, HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Spinner } from './spinner';\n\nexport type LoaderProps = HTMLAttributes<HTMLDivElement> & {\n isLoading?: boolean;\n};\n\n/**\n *\n *
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/components/Loader/index.tsx"],"sourcesContent":["import type { FC, HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Spinner } from './spinner';\n\n/**\n * Props for the Loader component\n */\nexport type LoaderProps = HTMLAttributes<HTMLDivElement> & {\n /** Controls whether the loading spinner is displayed. Defaults to true when undefined */\n isLoading?: boolean;\n};\n\n/**\n * Loader Component\n *\n * A versatile loading component that can function as both a standalone loader\n * and a wrapper for content. When loading is true, displays an animated spinner.\n * When loading is false, renders the wrapped content.\n *\n * @component\n * @example\n * Standalone usage:\n * ```tsx\n * <Loader isLoading={true} />\n * ```\n *\n * @example\n * As a content wrapper:\n * ```tsx\n * <Loader isLoading={isDataLoading}>\n * <div>Your content here</div>\n * </Loader>\n * ```\n *\n * @example\n * Default behavior (loading = true):\n * ```tsx\n * <Loader />\n * ```\n *\n * @example\n * With custom styling:\n * ```tsx\n * <Loader\n * isLoading={true}\n * className=\"min-h-[200px] bg-gray-50\"\n * aria-label=\"Loading user data\"\n * />\n * ```\n *\n * @example\n * Conditional content loading:\n * ```tsx\n * <Loader isLoading={!data}>\n * {data && (\n * <div>\n * <h2>{data.title}</h2>\n * <p>{data.content}</p>\n * </div>\n * )}\n * </Loader>\n * ```\n *\n * Features:\n * - Dual-mode operation: standalone spinner or content wrapper\n * - Responsive design with flexible sizing\n * - Accessible with proper ARIA attributes and role\n * - Smooth animated spinner using SVG\n * - Customizable styling through className prop\n * - Supports all standard HTML div attributes\n * - Screen constraints (max-height/width) to prevent overflow\n * - Internationalization ready with aria-label support\n *\n * Accessibility:\n * - Uses role=\"status\" for screen reader announcements\n * - Includes descriptive aria-label for the loading state\n * - Maintains focus management when transitioning between states\n * - Supports custom aria-label through props for specific contexts\n * - Compatible with keyboard navigation patterns\n *\n * Performance:\n * - Lightweight SVG spinner with CSS animations\n * - Conditional rendering prevents unnecessary DOM updates\n * - Optimized for frequent loading state changes\n * - No external dependencies beyond internal utilities\n *\n * @param props - Component props extending HTML div attributes\n * @param props.children - Content to display when not loading\n * @param props.isLoading - Loading state control (defaults to true)\n * @param props.className - Additional CSS classes for the loader container\n * @param props.role - ARIA role (defaults to \"status\")\n * @param props.aria-label - Custom accessibility label\n * @param props.id - Unique identifier for the loader\n * @param props.style - Inline styles object\n * @param props.data-* - Data attributes for testing or tracking\n * @param props...rest - All other standard HTML div attributes\n *\n * @returns A loading spinner when isLoading is true, otherwise renders children\n */\nexport const Loader: FC<LoaderProps> = ({\n children,\n isLoading = true,\n className,\n ...props\n}) => (\n <>\n {isLoading ? (\n <div\n className={cn(\n 'flex size-full max-h-screen max-w-[100vw] flex-1 items-center justify-center',\n className\n )}\n role=\"status\"\n aria-label=\"Animated icon, meaning that the website is processing\"\n {...props}\n >\n <Spinner className=\"size-10 max-h-full max-w-full\" />\n </div>\n ) : (\n (children ?? <></>)\n )}\n </>\n);\n"],"names":[],"mappings":";;;AAmGO,MAAM,SAA0B,CAAC;AAAA,EACtC;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,GAAG;AACL,sCAEK,UAAA,YACC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAEF,MAAK;AAAA,IACL,cAAW;AAAA,IACV,GAAG;AAAA,IAEJ,UAAA,oBAAC,SAAA,EAAQ,WAAU,gCAAA,CAAgC;AAAA,EAAA;AACrD,IAEC,4CAAc,EAAA,CAEnB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.cjs","sources":["../../../src/components/Loader/spinner.tsx"],"sourcesContent":["import type { SVGProps } from 'react';\nimport { cn } from '../../utils/cn';\n\ntype SpinnerProps = SVGProps<SVGSVGElement> & {\n strokeWidth?: number;\n};\n\nexport const Spinner = ({ className, strokeWidth = 4 }: SpinnerProps) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"44\"\n height=\"44\"\n viewBox=\"0 0 44 44\"\n stroke=\"currentColor\"\n className={cn('size-full', className)}\n >\n <g fill=\"none\" fillRule=\"evenodd\" strokeWidth={strokeWidth}>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n </g>\n </svg>\n);\n"],"names":["jsx","cn","jsxs"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"spinner.cjs","sources":["../../../src/components/Loader/spinner.tsx"],"sourcesContent":["import type { SVGProps } from 'react';\nimport { cn } from '../../utils/cn';\n\n/**\n * Props for the Spinner component\n */\ntype SpinnerProps = SVGProps<SVGSVGElement> & {\n /** Stroke width for the spinner animation circles. Defaults to 4 */\n strokeWidth?: number;\n};\n\n/**\n * Spinner Component\n *\n * An animated SVG spinner that displays two expanding and fading circles\n * to indicate loading or processing states. Uses smooth CSS animations\n * with spline curves for natural motion.\n *\n * @component\n * @example\n * Basic usage:\n * ```tsx\n * <Spinner />\n * ```\n *\n * @example\n * Custom stroke width:\n * ```tsx\n * <Spinner strokeWidth={6} className=\"text-blue-500\" />\n * ```\n *\n * @example\n * Custom size:\n * ```tsx\n * <Spinner className=\"size-8 text-red-500\" strokeWidth={2} />\n * ```\n *\n * Features:\n * - Smooth expanding circle animation\n * - Customizable stroke width\n * - Inherits text color from parent (currentColor)\n * - Responsive sizing through className\n * - Infinite loop animation\n * - Two-phase animation with offset timing\n * - Optimized SVG with minimal DOM impact\n *\n * Animation Details:\n * - Duration: 1.8 seconds per cycle\n * - Two circles with 0.9s offset\n * - Radius expands from 1 to 20\n * - Opacity fades from 1 to 0\n * - Spline easing for natural motion\n *\n * @param props - SVG props with custom spinner options\n * @param props.className - CSS classes for styling and sizing\n * @param props.strokeWidth - Line thickness for the animated circles\n * @param props.color - SVG color (use className with text-color for easier styling)\n * @param props.width - SVG width (defaults to 44, use className for responsive sizing)\n * @param props.height - SVG height (defaults to 44, use className for responsive sizing)\n * @param props...rest - All other standard SVG element attributes\n *\n * @returns An animated SVG spinner element\n */\nexport const Spinner = ({ className, strokeWidth = 4 }: SpinnerProps) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"44\"\n height=\"44\"\n viewBox=\"0 0 44 44\"\n stroke=\"currentColor\"\n className={cn('size-full', className)}\n >\n <g fill=\"none\" fillRule=\"evenodd\" strokeWidth={strokeWidth}>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n </g>\n </svg>\n);\n"],"names":["jsx","cn","jsxs"],"mappings":";;;;AA+DO,MAAM,UAAU,CAAC,EAAE,WAAW,cAAc,QACjDA,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAM;AAAA,IACN,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,QAAO;AAAA,IACP,WAAWC,SAAAA,GAAG,aAAa,SAAS;AAAA,IAEpC,0CAAC,KAAA,EAAE,MAAK,QAAO,UAAS,WAAU,aAChC,UAAA;AAAA,MAAAC,gCAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KACxB,UAAA;AAAA,QAAAF,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,QAEdA,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,MACd,GACF;AAAA,sCACC,UAAA,EAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KACxB,UAAA;AAAA,QAAAA,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,QAEdA,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,MACd,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA;AACF;;"}
|
|
@@ -1,7 +1,63 @@
|
|
|
1
1
|
import { SVGProps } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the Spinner component
|
|
4
|
+
*/
|
|
2
5
|
type SpinnerProps = SVGProps<SVGSVGElement> & {
|
|
6
|
+
/** Stroke width for the spinner animation circles. Defaults to 4 */
|
|
3
7
|
strokeWidth?: number;
|
|
4
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Spinner Component
|
|
11
|
+
*
|
|
12
|
+
* An animated SVG spinner that displays two expanding and fading circles
|
|
13
|
+
* to indicate loading or processing states. Uses smooth CSS animations
|
|
14
|
+
* with spline curves for natural motion.
|
|
15
|
+
*
|
|
16
|
+
* @component
|
|
17
|
+
* @example
|
|
18
|
+
* Basic usage:
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Spinner />
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* Custom stroke width:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Spinner strokeWidth={6} className="text-blue-500" />
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* Custom size:
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <Spinner className="size-8 text-red-500" strokeWidth={2} />
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Features:
|
|
36
|
+
* - Smooth expanding circle animation
|
|
37
|
+
* - Customizable stroke width
|
|
38
|
+
* - Inherits text color from parent (currentColor)
|
|
39
|
+
* - Responsive sizing through className
|
|
40
|
+
* - Infinite loop animation
|
|
41
|
+
* - Two-phase animation with offset timing
|
|
42
|
+
* - Optimized SVG with minimal DOM impact
|
|
43
|
+
*
|
|
44
|
+
* Animation Details:
|
|
45
|
+
* - Duration: 1.8 seconds per cycle
|
|
46
|
+
* - Two circles with 0.9s offset
|
|
47
|
+
* - Radius expands from 1 to 20
|
|
48
|
+
* - Opacity fades from 1 to 0
|
|
49
|
+
* - Spline easing for natural motion
|
|
50
|
+
*
|
|
51
|
+
* @param props - SVG props with custom spinner options
|
|
52
|
+
* @param props.className - CSS classes for styling and sizing
|
|
53
|
+
* @param props.strokeWidth - Line thickness for the animated circles
|
|
54
|
+
* @param props.color - SVG color (use className with text-color for easier styling)
|
|
55
|
+
* @param props.width - SVG width (defaults to 44, use className for responsive sizing)
|
|
56
|
+
* @param props.height - SVG height (defaults to 44, use className for responsive sizing)
|
|
57
|
+
* @param props...rest - All other standard SVG element attributes
|
|
58
|
+
*
|
|
59
|
+
* @returns An animated SVG spinner element
|
|
60
|
+
*/
|
|
5
61
|
export declare const Spinner: ({ className, strokeWidth }: SpinnerProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
62
|
export {};
|
|
7
63
|
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/Loader/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,KAAK,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,4BAAgC,YAAY,4CAwDnE,CAAC"}
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/Loader/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC;;GAEG;AACH,KAAK,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG;IAC5C,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,OAAO,GAAI,4BAAgC,YAAY,4CAwDnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.mjs","sources":["../../../src/components/Loader/spinner.tsx"],"sourcesContent":["import type { SVGProps } from 'react';\nimport { cn } from '../../utils/cn';\n\ntype SpinnerProps = SVGProps<SVGSVGElement> & {\n strokeWidth?: number;\n};\n\nexport const Spinner = ({ className, strokeWidth = 4 }: SpinnerProps) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"44\"\n height=\"44\"\n viewBox=\"0 0 44 44\"\n stroke=\"currentColor\"\n className={cn('size-full', className)}\n >\n <g fill=\"none\" fillRule=\"evenodd\" strokeWidth={strokeWidth}>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n </g>\n </svg>\n);\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"spinner.mjs","sources":["../../../src/components/Loader/spinner.tsx"],"sourcesContent":["import type { SVGProps } from 'react';\nimport { cn } from '../../utils/cn';\n\n/**\n * Props for the Spinner component\n */\ntype SpinnerProps = SVGProps<SVGSVGElement> & {\n /** Stroke width for the spinner animation circles. Defaults to 4 */\n strokeWidth?: number;\n};\n\n/**\n * Spinner Component\n *\n * An animated SVG spinner that displays two expanding and fading circles\n * to indicate loading or processing states. Uses smooth CSS animations\n * with spline curves for natural motion.\n *\n * @component\n * @example\n * Basic usage:\n * ```tsx\n * <Spinner />\n * ```\n *\n * @example\n * Custom stroke width:\n * ```tsx\n * <Spinner strokeWidth={6} className=\"text-blue-500\" />\n * ```\n *\n * @example\n * Custom size:\n * ```tsx\n * <Spinner className=\"size-8 text-red-500\" strokeWidth={2} />\n * ```\n *\n * Features:\n * - Smooth expanding circle animation\n * - Customizable stroke width\n * - Inherits text color from parent (currentColor)\n * - Responsive sizing through className\n * - Infinite loop animation\n * - Two-phase animation with offset timing\n * - Optimized SVG with minimal DOM impact\n *\n * Animation Details:\n * - Duration: 1.8 seconds per cycle\n * - Two circles with 0.9s offset\n * - Radius expands from 1 to 20\n * - Opacity fades from 1 to 0\n * - Spline easing for natural motion\n *\n * @param props - SVG props with custom spinner options\n * @param props.className - CSS classes for styling and sizing\n * @param props.strokeWidth - Line thickness for the animated circles\n * @param props.color - SVG color (use className with text-color for easier styling)\n * @param props.width - SVG width (defaults to 44, use className for responsive sizing)\n * @param props.height - SVG height (defaults to 44, use className for responsive sizing)\n * @param props...rest - All other standard SVG element attributes\n *\n * @returns An animated SVG spinner element\n */\nexport const Spinner = ({ className, strokeWidth = 4 }: SpinnerProps) => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"44\"\n height=\"44\"\n viewBox=\"0 0 44 44\"\n stroke=\"currentColor\"\n className={cn('size-full', className)}\n >\n <g fill=\"none\" fillRule=\"evenodd\" strokeWidth={strokeWidth}>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"0s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n <circle cx=\"22\" cy=\"22\" r=\"1\">\n <animate\n attributeName=\"r\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 20\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.165, 0.84, 0.44, 1\"\n repeatCount=\"indefinite\"\n />\n <animate\n attributeName=\"stroke-opacity\"\n begin=\"-0.9s\"\n dur=\"1.8s\"\n values=\"1; 0\"\n calcMode=\"spline\"\n keyTimes=\"0; 1\"\n keySplines=\"0.3, 0.61, 0.355, 1\"\n repeatCount=\"indefinite\"\n />\n </circle>\n </g>\n </svg>\n);\n"],"names":[],"mappings":";;AA+DO,MAAM,UAAU,CAAC,EAAE,WAAW,cAAc,QACjD;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAM;AAAA,IACN,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,QAAO;AAAA,IACP,WAAW,GAAG,aAAa,SAAS;AAAA,IAEpC,+BAAC,KAAA,EAAE,MAAK,QAAO,UAAS,WAAU,aAChC,UAAA;AAAA,MAAA,qBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KACxB,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,QAEd;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,MACd,GACF;AAAA,2BACC,UAAA,EAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KACxB,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,QAEd;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAc;AAAA,YACd,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,QAAO;AAAA,YACP,UAAS;AAAA,YACT,UAAS;AAAA,YACT,YAAW;AAAA,YACX,aAAY;AAAA,UAAA;AAAA,QAAA;AAAA,MACd,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA;AACF;"}
|
|
@@ -47,7 +47,6 @@ const MarkdownRenderer = ({
|
|
|
47
47
|
components_MarkDownRender_processor.MarkdownProcessor,
|
|
48
48
|
{
|
|
49
49
|
options: {
|
|
50
|
-
disableParsingRawHTML: true,
|
|
51
50
|
overrides: {
|
|
52
51
|
h1: (props) => /* @__PURE__ */ jsxRuntime.jsx(components_Headers_index.H1, { isClickable: true, ...props }),
|
|
53
52
|
h2: (props) => /* @__PURE__ */ jsxRuntime.jsx(components_Headers_index.H2, { isClickable: true, ...props }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkDownRender.cjs","sources":["../../../src/components/MarkDownRender/MarkDownRender.tsx"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport type { ComponentProps, ComponentPropsWithoutRef, FC } from 'react';\nimport type { BundledLanguage } from 'shiki';\nimport { cn } from '../../utils/cn';\nimport { H1, H2, H3, H4, H5, H6 } from '../Headers';\nimport type { CodeCompAttributes } from '../IDE/Code';\nimport { Code } from '../IDE/Code';\nimport { CodeProvider } from '../IDE/CodeContext';\nimport { Link } from '../Link';\nimport { Tab } from '../Tab';\nimport { TabProvider } from '../Tab/TabContext';\nimport { Table } from '../Table';\nimport { MarkdownProcessor, type MarkdownProcessorOptions } from './processor';\n\ntype MarkdownRendererProps = {\n children: string;\n isDarkMode?: boolean;\n locale?: LocalesValues;\n options?: MarkdownProcessorOptions;\n};\n\n/**\n * Removes frontmatter from markdown content\n * Frontmatter is the YAML metadata block at the beginning of markdown files\n * delimited by --- at the start and end\n */\nconst stripFrontmatter = (markdown: string): string => {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== '---') {\n // No frontmatter, return original content\n return markdown;\n }\n\n let inMetadataBlock = false;\n let endOfMetadataIndex = -1;\n\n for (let i = 0; i < lines.length; i++) {\n const trimmedLine = lines[i].trim();\n\n // Toggle metadata block on encountering the delimiter\n if (trimmedLine === '---') {\n if (!inMetadataBlock) {\n // Begin metadata block\n inMetadataBlock = true;\n continue;\n } else {\n // End of metadata block\n endOfMetadataIndex = i;\n break;\n }\n }\n }\n\n if (endOfMetadataIndex > -1) {\n // Return content after the frontmatter\n return lines.slice(endOfMetadataIndex + 1).join('\\n');\n }\n\n // If we couldn't find the end delimiter, return original content\n return markdown;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n children,\n isDarkMode,\n locale,\n options,\n}) => {\n const { overrides, ...restOptions } = options ?? {};\n\n // Strip frontmatter from the markdown content before rendering\n const cleanMarkdown = stripFrontmatter(children);\n\n return (\n <CodeProvider>\n <TabProvider>\n <MarkdownProcessor\n options={{\n disableParsingRawHTML: true,\n overrides: {\n h1: (props: ComponentProps<typeof H1>) => (\n <H1 isClickable={true} {...props} />\n ),\n h2: (props: ComponentProps<typeof H2>) => (\n <H2 isClickable={true} {...props} />\n ),\n h3: (props: ComponentProps<typeof H3>) => (\n <H3 isClickable={true} {...props} />\n ),\n h4: (props: ComponentProps<typeof H4>) => (\n <H4 isClickable={true} {...props} />\n ),\n h5: (props: ComponentProps<typeof H5>) => (\n <H5 isClickable={true} {...props} />\n ),\n h6: (props: ComponentProps<typeof H6>) => (\n <H6 isClickable={true} {...props} />\n ),\n\n code: (\n props: Omit<ComponentPropsWithoutRef<'code'>, 'children'> &\n Partial<CodeCompAttributes> & { children: string }\n ) =>\n !props.className ? (\n <strong className=\"bg-card/60 rounded p-1 shadow-[0_0_10px_-15px_rgba(0,0,0,0.3)] backdrop-blur\">\n {props.children}\n </strong>\n ) : (\n <Code\n {...props}\n isDarkMode={isDarkMode}\n language={\n (props.className?.replace('lang-', '') ||\n 'plaintext') as BundledLanguage\n }\n fileName={props.fileName}\n showHeader={Boolean(props.fileName)}\n />\n ),\n\n blockquote: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'blockquote'>) => (\n <blockquote\n className={cn(\n 'border-card text-neutral mt-5 flex flex-col gap-3 border-l-4 pl-5',\n className\n )}\n {...props}\n />\n ),\n ul: ({ className, ...props }: ComponentPropsWithoutRef<'ul'>) => (\n <ul\n className={cn(\n 'mt-5 flex flex-col gap-3 pl-5 list-disc',\n className\n )}\n {...props}\n />\n ),\n ol: ({ className, ...props }: ComponentPropsWithoutRef<'ol'>) => (\n <ol\n className={cn(\n 'mt-5 flex flex-col gap-3 pl-5 list-decimal',\n className\n )}\n {...props}\n />\n ),\n img: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'img'>) => (\n <img\n {...props}\n loading=\"lazy\"\n className={cn(\n 'max-w-full max-h-[80vh] rounded-md',\n className\n )}\n src={`${props.src}?raw=true`}\n />\n ),\n a: (props: ComponentProps<typeof Link>) => (\n <Link\n color=\"neutral\"\n isExternalLink={props.href?.startsWith('http')}\n underlined={true}\n locale={locale}\n {...props}\n />\n ),\n pre: (props: ComponentPropsWithoutRef<'pre'>) => props.children,\n\n table: (props: ComponentProps<typeof Table>) => (\n <Table {...props} />\n ),\n th: ({ className, ...props }: ComponentPropsWithoutRef<'th'>) => (\n <th\n className={cn(\n 'border-neutral bg-neutral/10 border-b p-4',\n className\n )}\n {...props}\n />\n ),\n tr: ({ className, ...props }: ComponentPropsWithoutRef<'tr'>) => (\n <tr\n className={cn('hover:bg-neutral/10 hover:/10', className)}\n {...props}\n />\n ),\n td: ({ className, ...props }: ComponentPropsWithoutRef<'td'>) => (\n <td\n className={cn(\n 'border-b border-neutral-500/50 p-4',\n className\n )}\n {...props}\n />\n ),\n hr: ({ className, ...props }: ComponentPropsWithoutRef<'hr'>) => (\n <hr\n className={cn('mt-16 mx-6 text-neutral', className)}\n {...props}\n />\n ),\n // Support both <Tab> and <Tabs> in markdown\n Tabs: (props: ComponentProps<typeof Tab>) => <Tab {...props} />,\n Tab: (props: ComponentProps<typeof Tab>) => <Tab {...props} />,\n TabItem: (props: ComponentProps<typeof Tab.Item>) => (\n <Tab.Item {...props} />\n ),\n Columns: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'div'>) => (\n <div\n className={cn('flex max-md:flex-col gap-4', className)}\n {...props}\n />\n ),\n Column: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'div'>) => (\n <div className={cn('flex-1', className)} {...props} />\n ),\n ...overrides,\n },\n ...restOptions,\n }}\n >\n {cleanMarkdown ?? ''}\n </MarkdownProcessor>\n </TabProvider>\n </CodeProvider>\n );\n};\n"],"names":["jsx","CodeProvider","TabProvider","MarkdownProcessor","H1","H2","H3","H4","H5","H6","Code","cn","Link","Table","Tab"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,mBAAmB,CAAC,aAA6B;AACrD,QAAM,QAAQ,SAAS,MAAM,OAAO;AAGpC,QAAM,oBAAoB,MAAM,KAAK,CAAC,SAAS,KAAK,KAAA,MAAW,EAAE;AAEjE,MAAI,CAAC,qBAAqB,kBAAkB,KAAA,MAAW,OAAO;AAE5D,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB;AACtB,MAAI,qBAAqB;AAEzB,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,cAAc,MAAM,CAAC,EAAE,KAAA;AAG7B,QAAI,gBAAgB,OAAO;AACzB,UAA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YAAA;AAAA,UAAA;AAAA,UAGR,QAAQ,CAAC;AAAA,YACP;AAAA,YACA,GAAG;AAAA,UAAA,qCAEF,OAAA,EAAI,WAAWA,SAAAA,GAAG,UAAU,SAAS,GAAI,GAAG,OAAO;AAAA,UAEtD,GAAG;AAAA,QAAA;AAAA,QAEL,GAAG;AAAA,MAAA;AAAA,MAGJ,UAAA,iBAAiB;AAAA,IAAA;AAAA,EAAA,GAEtB,EAAA,CACF;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"MarkDownRender.cjs","sources":["../../../src/components/MarkDownRender/MarkDownRender.tsx"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport type { ComponentProps, ComponentPropsWithoutRef, FC } from 'react';\nimport type { BundledLanguage } from 'shiki';\nimport { cn } from '../../utils/cn';\nimport { H1, H2, H3, H4, H5, H6 } from '../Headers';\nimport type { CodeCompAttributes } from '../IDE/Code';\nimport { Code } from '../IDE/Code';\nimport { CodeProvider } from '../IDE/CodeContext';\nimport { Link } from '../Link';\nimport { Tab } from '../Tab';\nimport { TabProvider } from '../Tab/TabContext';\nimport { Table } from '../Table';\nimport { MarkdownProcessor, type MarkdownProcessorOptions } from './processor';\n\ntype MarkdownRendererProps = {\n children: string;\n isDarkMode?: boolean;\n locale?: LocalesValues;\n options?: MarkdownProcessorOptions;\n};\n\n/**\n * Removes frontmatter from markdown content\n * Frontmatter is the YAML metadata block at the beginning of markdown files\n * delimited by --- at the start and end\n */\nconst stripFrontmatter = (markdown: string): string => {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== '---') {\n // No frontmatter, return original content\n return markdown;\n }\n\n let inMetadataBlock = false;\n let endOfMetadataIndex = -1;\n\n for (let i = 0; i < lines.length; i++) {\n const trimmedLine = lines[i].trim();\n\n // Toggle metadata block on encountering the delimiter\n if (trimmedLine === '---') {\n if (!inMetadataBlock) {\n // Begin metadata block\n inMetadataBlock = true;\n continue;\n } else {\n // End of metadata block\n endOfMetadataIndex = i;\n break;\n }\n }\n }\n\n if (endOfMetadataIndex > -1) {\n // Return content after the frontmatter\n return lines.slice(endOfMetadataIndex + 1).join('\\n');\n }\n\n // If we couldn't find the end delimiter, return original content\n return markdown;\n};\n\n/**\n * MarkdownRenderer Component\n *\n * A comprehensive markdown renderer that transforms markdown text into rich,\n * interactive HTML with custom styling and Intlayer integration. Supports\n * code syntax highlighting, responsive tables, internationalized links,\n * and automatic frontmatter stripping.\n *\n * @component\n * @example\n * Basic usage:\n * ```tsx\n * const markdownContent = `\n * # Hello World\n * This is **bold** and *italic* text.\n * `;\n *\n * <MarkdownRenderer>{markdownContent}</MarkdownRenderer>\n * ```\n *\n * @example\n * With dark mode:\n * ```tsx\n * const codeExample = `\n * # API Documentation\n * \\`\\`\\`javascript\n * const response = await fetch('/api/data');\n * const data = await response.json();\n * \\`\\`\\`\n * `;\n *\n * <MarkdownRenderer isDarkMode={true}>\n * {codeExample}\n * </MarkdownRenderer>\n * ```\n *\n * @example\n * With internationalized links:\n * ```tsx\n * const content = `\n * Visit our [documentation](/docs) for more information.\n * External link: [Google](https://google.com)\n * `;\n *\n * <MarkdownRenderer locale=\"fr\">\n * {content}\n * </MarkdownRenderer>\n * ```\n *\n * @example\n * With custom overrides:\n * ```tsx\n * const customOptions = {\n * overrides: {\n * h1: ({ children }) => (\n * <h1 className=\"custom-title\">{children}</h1>\n * ),\n * },\n * };\n *\n * <MarkdownRenderer options={customOptions}>\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n *\n * @example\n * With frontmatter (automatically stripped):\n * ```tsx\n * const blogPost = `\n * ---\n * title: \"My Blog Post\"\n * date: \"2023-12-01\"\n * author: \"John Doe\"\n * ---\n * # My Blog Post\n * This content will be rendered without the frontmatter.\n * `;\n *\n * <MarkdownRenderer>{blogPost}</MarkdownRenderer>\n * ```\n *\n * Features:\n * - Automatic frontmatter detection and removal\n * - Syntax-highlighted code blocks with theme support\n * - Clickable headers with anchor links\n * - Internationalized link handling with locale awareness\n * - Responsive tables with hover effects\n * - Custom blockquote, list, and image styling\n * - External link detection and security attributes\n * - Inline code with distinctive styling\n * - Lazy-loaded images with GitHub raw URL support\n * - Horizontal rules with custom styling\n *\n * Supported Markdown Elements:\n * - Headers (h1-h4) with click-to-anchor functionality\n * - Code blocks with language-specific syntax highlighting\n * - Inline code with background styling\n * - Blockquotes with custom border and padding\n * - Ordered and unordered lists with custom spacing\n * - Links (internal and external) with security attributes\n * - Images with lazy loading and responsive sizing\n * - Tables with hover effects and proper styling\n * - Horizontal rules with custom appearance\n * - All standard markdown formatting (bold, italic, etc.)\n *\n * Code Block Support:\n * - Language detection from code fence info\n * - Syntax highlighting through Code component\n * - Dark/light mode theme switching\n * - Line numbers and copy functionality (via Code component)\n * - Support for popular languages (JS, TS, Python, etc.)\n *\n * Link Handling:\n * - Automatic external link detection (starts with 'http')\n * - Security attributes for external links (rel=\"noopener noreferrer\")\n * - Locale-aware internal link routing\n * - Custom Link component integration\n * - Underlined styling for better visibility\n *\n * Image Processing:\n * - Automatic lazy loading for performance\n * - GitHub raw URL transformation for repository images\n * - Responsive sizing with max-width constraints\n * - Rounded corners for visual appeal\n *\n * Accessibility:\n * - Semantic HTML structure with proper heading hierarchy\n * - ARIA attributes through component integration\n * - Screen reader friendly link descriptions\n * - Keyboard navigation support\n * - High contrast styling options\n *\n * Performance:\n * - Lazy loading for images\n * - Efficient re-rendering with React memo patterns\n * - Code syntax highlighting with minimal bundle impact\n * - Optimized markdown parsing with markdown-to-jsx\n *\n * @param props - Component props\n * @param props.children - Raw markdown content to render\n * @param props.isDarkMode - Enable dark mode styling for code blocks\n * @param props.locale - Current locale for link internationalization\n * @param props.options - Additional markdown-to-jsx options\n * @param props.options.overrides - Custom component overrides for markdown elements\n *\n * @returns Rendered markdown content with custom styling and functionality\n */\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n children,\n isDarkMode,\n locale,\n options,\n}) => {\n const { overrides, ...restOptions } = options ?? {};\n\n // Strip frontmatter from the markdown content before rendering\n const cleanMarkdown = stripFrontmatter(children);\n\n return (\n <CodeProvider>\n <TabProvider>\n <MarkdownProcessor\n options={{\n overrides: {\n h1: (props: ComponentProps<typeof H1>) => (\n <H1 isClickable={true} {...props} />\n ),\n h2: (props: ComponentProps<typeof H2>) => (\n <H2 isClickable={true} {...props} />\n ),\n h3: (props: ComponentProps<typeof H3>) => (\n <H3 isClickable={true} {...props} />\n ),\n h4: (props: ComponentProps<typeof H4>) => (\n <H4 isClickable={true} {...props} />\n ),\n h5: (props: ComponentProps<typeof H5>) => (\n <H5 isClickable={true} {...props} />\n ),\n h6: (props: ComponentProps<typeof H6>) => (\n <H6 isClickable={true} {...props} />\n ),\n\n code: (\n props: Omit<ComponentPropsWithoutRef<'code'>, 'children'> &\n Partial<CodeCompAttributes> & { children: string }\n ) =>\n !props.className ? (\n <strong className=\"bg-card/60 rounded p-1 shadow-[0_0_10px_-15px_rgba(0,0,0,0.3)] backdrop-blur\">\n {props.children}\n </strong>\n ) : (\n <Code\n {...props}\n isDarkMode={isDarkMode}\n language={\n (props.className?.replace('lang-', '') ||\n 'plaintext') as BundledLanguage\n }\n fileName={props.fileName}\n showHeader={Boolean(props.fileName)}\n />\n ),\n\n blockquote: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'blockquote'>) => (\n <blockquote\n className={cn(\n 'border-card text-neutral mt-5 flex flex-col gap-3 border-l-4 pl-5',\n className\n )}\n {...props}\n />\n ),\n ul: ({ className, ...props }: ComponentPropsWithoutRef<'ul'>) => (\n <ul\n className={cn(\n 'mt-5 flex flex-col gap-3 pl-5 list-disc',\n className\n )}\n {...props}\n />\n ),\n ol: ({ className, ...props }: ComponentPropsWithoutRef<'ol'>) => (\n <ol\n className={cn(\n 'mt-5 flex flex-col gap-3 pl-5 list-decimal',\n className\n )}\n {...props}\n />\n ),\n img: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'img'>) => (\n <img\n {...props}\n loading=\"lazy\"\n className={cn(\n 'max-w-full max-h-[80vh] rounded-md',\n className\n )}\n src={`${props.src}?raw=true`}\n />\n ),\n a: (props: ComponentProps<typeof Link>) => (\n <Link\n color=\"neutral\"\n isExternalLink={props.href?.startsWith('http')}\n underlined={true}\n locale={locale}\n {...props}\n />\n ),\n pre: (props: ComponentPropsWithoutRef<'pre'>) => props.children,\n\n table: (props: ComponentProps<typeof Table>) => (\n <Table {...props} />\n ),\n th: ({ className, ...props }: ComponentPropsWithoutRef<'th'>) => (\n <th\n className={cn(\n 'border-neutral bg-neutral/10 border-b p-4',\n className\n )}\n {...props}\n />\n ),\n tr: ({ className, ...props }: ComponentPropsWithoutRef<'tr'>) => (\n <tr\n className={cn('hover:bg-neutral/10 hover:/10', className)}\n {...props}\n />\n ),\n td: ({ className, ...props }: ComponentPropsWithoutRef<'td'>) => (\n <td\n className={cn(\n 'border-b border-neutral-500/50 p-4',\n className\n )}\n {...props}\n />\n ),\n hr: ({ className, ...props }: ComponentPropsWithoutRef<'hr'>) => (\n <hr\n className={cn('mt-16 mx-6 text-neutral', className)}\n {...props}\n />\n ),\n // Support both <Tab> and <Tabs> in markdown\n Tabs: (props: ComponentProps<typeof Tab>) => <Tab {...props} />,\n Tab: (props: ComponentProps<typeof Tab>) => <Tab {...props} />,\n TabItem: (props: ComponentProps<typeof Tab.Item>) => (\n <Tab.Item {...props} />\n ),\n Columns: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'div'>) => (\n <div\n className={cn('flex max-md:flex-col gap-4', className)}\n {...props}\n />\n ),\n Column: ({\n className,\n ...props\n }: ComponentPropsWithoutRef<'div'>) => (\n <div className={cn('flex-1', className)} {...props} />\n ),\n ...overrides,\n },\n ...restOptions,\n }}\n >\n {cleanMarkdown ?? ''}\n </MarkdownProcessor>\n </TabProvider>\n </CodeProvider>\n );\n};\n"],"names":["jsx","CodeProvider","TabProvider","MarkdownProcessor","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,UAAA;AAAA;AAAA,UAIR,MAAM,CAAC,UAAsCX,2BAAAA,IAACc,mBAAAA,KAAA,EAAK,GAAG,OAAO;AAAA,UAC7D,KAAK,CAAC,UAAsCd,2BAAAA,IAACc,mBAAAA,KAAA,EAAK,GAAG,OAAO;AAAA,UAC5D,SAAS,CAAC,UACRd,2BAAAA,IAACc,mBAAAA,IAAI,MAAJ,EAAU,GAAG,OAAO;AAAA,UAEvB,SAAS,CAAC;AAAA,YACR;AAAA,YACA,GAAG;AAAA,UAAA,MAEHd,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWW,SAAAA,GAAG,8BAA8B,SAAS;AAAA,cACpD,GAAG;AAAA,YAAA;AAAA,UAAA;AAAA,UAGR,QAAQ,CAAC;AAAA,YACP;AAAA,YACA,GAAG;AAAA,UAAA,qCAEF,OAAA,EAAI,WAAWA,SAAAA,GAAG,UAAU,SAAS,GAAI,GAAG,OAAO;AAAA,UAEtD,GAAG;AAAA,QAAA;AAAA,QAEL,GAAG;AAAA,MAAA;AAAA,MAGJ,UAAA,iBAAiB;AAAA,IAAA;AAAA,EAAA,GAEtB,EAAA,CACF;AAEJ;;"}
|
|
@@ -7,6 +7,153 @@ type MarkdownRendererProps = {
|
|
|
7
7
|
locale?: LocalesValues;
|
|
8
8
|
options?: MarkdownProcessorOptions;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* MarkdownRenderer Component
|
|
12
|
+
*
|
|
13
|
+
* A comprehensive markdown renderer that transforms markdown text into rich,
|
|
14
|
+
* interactive HTML with custom styling and Intlayer integration. Supports
|
|
15
|
+
* code syntax highlighting, responsive tables, internationalized links,
|
|
16
|
+
* and automatic frontmatter stripping.
|
|
17
|
+
*
|
|
18
|
+
* @component
|
|
19
|
+
* @example
|
|
20
|
+
* Basic usage:
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const markdownContent = `
|
|
23
|
+
* # Hello World
|
|
24
|
+
* This is **bold** and *italic* text.
|
|
25
|
+
* `;
|
|
26
|
+
*
|
|
27
|
+
* <MarkdownRenderer>{markdownContent}</MarkdownRenderer>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* With dark mode:
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const codeExample = `
|
|
34
|
+
* # API Documentation
|
|
35
|
+
* \`\`\`javascript
|
|
36
|
+
* const response = await fetch('/api/data');
|
|
37
|
+
* const data = await response.json();
|
|
38
|
+
* \`\`\`
|
|
39
|
+
* `;
|
|
40
|
+
*
|
|
41
|
+
* <MarkdownRenderer isDarkMode={true}>
|
|
42
|
+
* {codeExample}
|
|
43
|
+
* </MarkdownRenderer>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* With internationalized links:
|
|
48
|
+
* ```tsx
|
|
49
|
+
* const content = `
|
|
50
|
+
* Visit our [documentation](/docs) for more information.
|
|
51
|
+
* External link: [Google](https://google.com)
|
|
52
|
+
* `;
|
|
53
|
+
*
|
|
54
|
+
* <MarkdownRenderer locale="fr">
|
|
55
|
+
* {content}
|
|
56
|
+
* </MarkdownRenderer>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* With custom overrides:
|
|
61
|
+
* ```tsx
|
|
62
|
+
* const customOptions = {
|
|
63
|
+
* overrides: {
|
|
64
|
+
* h1: ({ children }) => (
|
|
65
|
+
* <h1 className="custom-title">{children}</h1>
|
|
66
|
+
* ),
|
|
67
|
+
* },
|
|
68
|
+
* };
|
|
69
|
+
*
|
|
70
|
+
* <MarkdownRenderer options={customOptions}>
|
|
71
|
+
* {markdownContent}
|
|
72
|
+
* </MarkdownRenderer>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* With frontmatter (automatically stripped):
|
|
77
|
+
* ```tsx
|
|
78
|
+
* const blogPost = `
|
|
79
|
+
* ---
|
|
80
|
+
* title: "My Blog Post"
|
|
81
|
+
* date: "2023-12-01"
|
|
82
|
+
* author: "John Doe"
|
|
83
|
+
* ---
|
|
84
|
+
* # My Blog Post
|
|
85
|
+
* This content will be rendered without the frontmatter.
|
|
86
|
+
* `;
|
|
87
|
+
*
|
|
88
|
+
* <MarkdownRenderer>{blogPost}</MarkdownRenderer>
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* Features:
|
|
92
|
+
* - Automatic frontmatter detection and removal
|
|
93
|
+
* - Syntax-highlighted code blocks with theme support
|
|
94
|
+
* - Clickable headers with anchor links
|
|
95
|
+
* - Internationalized link handling with locale awareness
|
|
96
|
+
* - Responsive tables with hover effects
|
|
97
|
+
* - Custom blockquote, list, and image styling
|
|
98
|
+
* - External link detection and security attributes
|
|
99
|
+
* - Inline code with distinctive styling
|
|
100
|
+
* - Lazy-loaded images with GitHub raw URL support
|
|
101
|
+
* - Horizontal rules with custom styling
|
|
102
|
+
*
|
|
103
|
+
* Supported Markdown Elements:
|
|
104
|
+
* - Headers (h1-h4) with click-to-anchor functionality
|
|
105
|
+
* - Code blocks with language-specific syntax highlighting
|
|
106
|
+
* - Inline code with background styling
|
|
107
|
+
* - Blockquotes with custom border and padding
|
|
108
|
+
* - Ordered and unordered lists with custom spacing
|
|
109
|
+
* - Links (internal and external) with security attributes
|
|
110
|
+
* - Images with lazy loading and responsive sizing
|
|
111
|
+
* - Tables with hover effects and proper styling
|
|
112
|
+
* - Horizontal rules with custom appearance
|
|
113
|
+
* - All standard markdown formatting (bold, italic, etc.)
|
|
114
|
+
*
|
|
115
|
+
* Code Block Support:
|
|
116
|
+
* - Language detection from code fence info
|
|
117
|
+
* - Syntax highlighting through Code component
|
|
118
|
+
* - Dark/light mode theme switching
|
|
119
|
+
* - Line numbers and copy functionality (via Code component)
|
|
120
|
+
* - Support for popular languages (JS, TS, Python, etc.)
|
|
121
|
+
*
|
|
122
|
+
* Link Handling:
|
|
123
|
+
* - Automatic external link detection (starts with 'http')
|
|
124
|
+
* - Security attributes for external links (rel="noopener noreferrer")
|
|
125
|
+
* - Locale-aware internal link routing
|
|
126
|
+
* - Custom Link component integration
|
|
127
|
+
* - Underlined styling for better visibility
|
|
128
|
+
*
|
|
129
|
+
* Image Processing:
|
|
130
|
+
* - Automatic lazy loading for performance
|
|
131
|
+
* - GitHub raw URL transformation for repository images
|
|
132
|
+
* - Responsive sizing with max-width constraints
|
|
133
|
+
* - Rounded corners for visual appeal
|
|
134
|
+
*
|
|
135
|
+
* Accessibility:
|
|
136
|
+
* - Semantic HTML structure with proper heading hierarchy
|
|
137
|
+
* - ARIA attributes through component integration
|
|
138
|
+
* - Screen reader friendly link descriptions
|
|
139
|
+
* - Keyboard navigation support
|
|
140
|
+
* - High contrast styling options
|
|
141
|
+
*
|
|
142
|
+
* Performance:
|
|
143
|
+
* - Lazy loading for images
|
|
144
|
+
* - Efficient re-rendering with React memo patterns
|
|
145
|
+
* - Code syntax highlighting with minimal bundle impact
|
|
146
|
+
* - Optimized markdown parsing with markdown-to-jsx
|
|
147
|
+
*
|
|
148
|
+
* @param props - Component props
|
|
149
|
+
* @param props.children - Raw markdown content to render
|
|
150
|
+
* @param props.isDarkMode - Enable dark mode styling for code blocks
|
|
151
|
+
* @param props.locale - Current locale for link internationalization
|
|
152
|
+
* @param props.options - Additional markdown-to-jsx options
|
|
153
|
+
* @param props.options.overrides - Custom component overrides for markdown elements
|
|
154
|
+
*
|
|
155
|
+
* @returns Rendered markdown content with custom styling and functionality
|
|
156
|
+
*/
|
|
10
157
|
export declare const MarkdownRenderer: FC<MarkdownRendererProps>;
|
|
11
158
|
export {};
|
|
12
159
|
//# sourceMappingURL=MarkDownRender.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkDownRender.d.ts","sourceRoot":"","sources":["../../../src/components/MarkDownRender/MarkDownRender.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAA4C,EAAE,EAAE,MAAM,OAAO,CAAC;AAW1E,OAAO,EAAqB,KAAK,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE/E,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC,CAAC;AA+CF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"MarkDownRender.d.ts","sourceRoot":"","sources":["../../../src/components/MarkDownRender/MarkDownRender.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAA4C,EAAE,EAAE,MAAM,OAAO,CAAC;AAW1E,OAAO,EAAqB,KAAK,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE/E,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC,CAAC;AA+CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkJG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAgLtD,CAAC"}
|
|
@@ -45,7 +45,6 @@ const MarkdownRenderer = ({
|
|
|
45
45
|
MarkdownProcessor,
|
|
46
46
|
{
|
|
47
47
|
options: {
|
|
48
|
-
disableParsingRawHTML: true,
|
|
49
48
|
overrides: {
|
|
50
49
|
h1: (props) => /* @__PURE__ */ jsx(H1, { isClickable: true, ...props }),
|
|
51
50
|
h2: (props) => /* @__PURE__ */ jsx(H2, { isClickable: true, ...props }),
|