@xanui/ui 1.2.6 → 1.2.8
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/Accordion/index.cjs +5 -5
- package/Accordion/index.cjs.map +1 -1
- package/Accordion/index.d.ts +3 -3
- package/Accordion/index.js +5 -5
- package/Accordion/index.js.map +1 -1
- package/Alert/index.cjs +19 -17
- package/Alert/index.cjs.map +1 -1
- package/Alert/index.d.ts +2 -2
- package/Alert/index.js +19 -17
- package/Alert/index.js.map +1 -1
- package/Autocomplete/index.cjs +2 -2
- package/Autocomplete/index.cjs.map +1 -1
- package/Autocomplete/index.d.ts +7 -7
- package/Autocomplete/index.js +2 -2
- package/Autocomplete/index.js.map +1 -1
- package/Avatar/index.cjs +2 -2
- package/Avatar/index.cjs.map +1 -1
- package/Avatar/index.d.ts +2 -2
- package/Avatar/index.js +2 -2
- package/Avatar/index.js.map +1 -1
- package/AvatarBox/index.cjs +19 -0
- package/AvatarBox/index.cjs.map +1 -0
- package/AvatarBox/index.d.ts +19 -0
- package/AvatarBox/index.js +17 -0
- package/AvatarBox/index.js.map +1 -0
- package/AvatarPicker/index.cjs +80 -0
- package/AvatarPicker/index.cjs.map +1 -0
- package/AvatarPicker/index.d.ts +27 -0
- package/AvatarPicker/index.js +78 -0
- package/AvatarPicker/index.js.map +1 -0
- package/Badge/index.cjs +1 -1
- package/Badge/index.cjs.map +1 -1
- package/Badge/index.d.ts +4 -4
- package/Badge/index.js +1 -1
- package/Badge/index.js.map +1 -1
- package/Box/index.d.ts +2 -2
- package/Button/index.cjs +5 -3
- package/Button/index.cjs.map +1 -1
- package/Button/index.d.ts +2 -2
- package/Button/index.js +5 -3
- package/Button/index.js.map +1 -1
- package/ButtonGroup/index.cjs +3 -2
- package/ButtonGroup/index.cjs.map +1 -1
- package/ButtonGroup/index.d.ts +2 -2
- package/ButtonGroup/index.js +3 -2
- package/ButtonGroup/index.js.map +1 -1
- package/Calendar/index.cjs +10 -10
- package/Calendar/index.cjs.map +1 -1
- package/Calendar/index.js +10 -10
- package/Calendar/index.js.map +1 -1
- package/CalendarInput/index.cjs +1 -1
- package/CalendarInput/index.cjs.map +1 -1
- package/CalendarInput/index.js +1 -1
- package/CalendarInput/index.js.map +1 -1
- package/Card/index.cjs +34 -0
- package/Card/index.cjs.map +1 -0
- package/Card/index.d.ts +10 -0
- package/Card/index.js +32 -0
- package/Card/index.js.map +1 -0
- package/Carousel/index.cjs +231 -0
- package/Carousel/index.cjs.map +1 -0
- package/Carousel/index.d.ts +28 -0
- package/Carousel/index.js +229 -0
- package/Carousel/index.js.map +1 -0
- package/Checkbox/index.cjs +2 -2
- package/Checkbox/index.cjs.map +1 -1
- package/Checkbox/index.d.ts +2 -2
- package/Checkbox/index.js +2 -2
- package/Checkbox/index.js.map +1 -1
- package/Chip/index.cjs +3 -3
- package/Chip/index.cjs.map +1 -1
- package/Chip/index.d.ts +2 -2
- package/Chip/index.js +3 -3
- package/Chip/index.js.map +1 -1
- package/CircleProgress/index.cjs +10 -10
- package/CircleProgress/index.cjs.map +1 -1
- package/CircleProgress/index.d.ts +2 -2
- package/CircleProgress/index.js +10 -10
- package/CircleProgress/index.js.map +1 -1
- package/ClickOutside/index.cjs +3 -12
- package/ClickOutside/index.cjs.map +1 -1
- package/ClickOutside/index.d.ts +3 -3
- package/ClickOutside/index.js +4 -13
- package/ClickOutside/index.js.map +1 -1
- package/Collaps/index.cjs +5 -5
- package/Collaps/index.cjs.map +1 -1
- package/Collaps/index.d.ts +2 -2
- package/Collaps/index.js +5 -5
- package/Collaps/index.js.map +1 -1
- package/Container/index.d.ts +2 -2
- package/DataFilter/index.d.ts +2 -2
- package/DataFilter/options/DateFilter.cjs +3 -3
- package/DataFilter/options/DateFilter.cjs.map +1 -1
- package/DataFilter/options/DateFilter.js +3 -3
- package/DataFilter/options/DateFilter.js.map +1 -1
- package/DataFilter/options/DateRangeFilter.cjs +2 -2
- package/DataFilter/options/DateRangeFilter.cjs.map +1 -1
- package/DataFilter/options/DateRangeFilter.js +2 -2
- package/DataFilter/options/DateRangeFilter.js.map +1 -1
- package/DataFilter/options/MultiSelectFilter.cjs +3 -3
- package/DataFilter/options/MultiSelectFilter.cjs.map +1 -1
- package/DataFilter/options/MultiSelectFilter.js +3 -3
- package/DataFilter/options/MultiSelectFilter.js.map +1 -1
- package/DataFilter/options/NumberFilter.cjs +2 -2
- package/DataFilter/options/NumberFilter.cjs.map +1 -1
- package/DataFilter/options/NumberFilter.js +2 -2
- package/DataFilter/options/NumberFilter.js.map +1 -1
- package/DataFilter/options/NumberRangeFilter.cjs +2 -2
- package/DataFilter/options/NumberRangeFilter.cjs.map +1 -1
- package/DataFilter/options/NumberRangeFilter.js +2 -2
- package/DataFilter/options/NumberRangeFilter.js.map +1 -1
- package/DataFilter/options/SelectFilter.cjs +3 -3
- package/DataFilter/options/SelectFilter.cjs.map +1 -1
- package/DataFilter/options/SelectFilter.js +3 -3
- package/DataFilter/options/SelectFilter.js.map +1 -1
- package/DataFilter/options/TextFilter.cjs +2 -2
- package/DataFilter/options/TextFilter.cjs.map +1 -1
- package/DataFilter/options/TextFilter.js +2 -2
- package/DataFilter/options/TextFilter.js.map +1 -1
- package/Datatable/FilterBox.cjs +2 -2
- package/Datatable/FilterBox.cjs.map +1 -1
- package/Datatable/FilterBox.js +2 -2
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/Row.cjs +2 -2
- package/Datatable/Row.cjs.map +1 -1
- package/Datatable/Row.js +2 -2
- package/Datatable/Row.js.map +1 -1
- package/Datatable/SelectedBox.cjs +2 -2
- package/Datatable/SelectedBox.cjs.map +1 -1
- package/Datatable/SelectedBox.js +2 -2
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/Table.cjs +1 -1
- package/Datatable/Table.cjs.map +1 -1
- package/Datatable/Table.js +1 -1
- package/Datatable/Table.js.map +1 -1
- package/Datatable/TableHead.cjs +3 -3
- package/Datatable/TableHead.cjs.map +1 -1
- package/Datatable/TableHead.js +3 -3
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/index.cjs +1 -1
- package/Datatable/index.cjs.map +1 -1
- package/Datatable/index.d.ts +2 -2
- package/Datatable/index.js +1 -1
- package/Datatable/index.js.map +1 -1
- package/Divider/index.cjs +3 -3
- package/Divider/index.cjs.map +1 -1
- package/Divider/index.d.ts +2 -2
- package/Divider/index.js +3 -3
- package/Divider/index.js.map +1 -1
- package/Drawer/index.cjs +2 -2
- package/Drawer/index.cjs.map +1 -1
- package/Drawer/index.js +2 -2
- package/Drawer/index.js.map +1 -1
- package/FilePicker/index.cjs +115 -0
- package/FilePicker/index.cjs.map +1 -0
- package/FilePicker/index.d.ts +23 -0
- package/FilePicker/index.js +113 -0
- package/FilePicker/index.js.map +1 -0
- package/Form/index.cjs +1 -1
- package/Form/index.cjs.map +1 -1
- package/Form/index.d.ts +2 -2
- package/Form/index.js +1 -1
- package/Form/index.js.map +1 -1
- package/GalleryPicker/index.cjs +88 -0
- package/GalleryPicker/index.cjs.map +1 -0
- package/GalleryPicker/index.d.ts +26 -0
- package/GalleryPicker/index.js +86 -0
- package/GalleryPicker/index.js.map +1 -0
- package/GridContainer/index.d.ts +2 -2
- package/GridItem/index.d.ts +2 -2
- package/IconButton/index.cjs +6 -3
- package/IconButton/index.cjs.map +1 -1
- package/IconButton/index.d.ts +2 -2
- package/IconButton/index.js +6 -3
- package/IconButton/index.js.map +1 -1
- package/Image/index.cjs +2 -14
- package/Image/index.cjs.map +1 -1
- package/Image/index.d.ts +3 -5
- package/Image/index.js +3 -15
- package/Image/index.js.map +1 -1
- package/Input/index.cjs +10 -10
- package/Input/index.cjs.map +1 -1
- package/Input/index.d.ts +14 -14
- package/Input/index.js +10 -10
- package/Input/index.js.map +1 -1
- package/InputNumber/index.d.ts +2 -2
- package/Label/index.cjs +1 -1
- package/Label/index.cjs.map +1 -1
- package/Label/index.d.ts +2 -2
- package/Label/index.js +1 -1
- package/Label/index.js.map +1 -1
- package/Layer/index.cjs +12 -13
- package/Layer/index.cjs.map +1 -1
- package/Layer/index.d.ts +5 -5
- package/Layer/index.js +13 -14
- package/Layer/index.js.map +1 -1
- package/LineProgress/index.cjs +6 -6
- package/LineProgress/index.cjs.map +1 -1
- package/LineProgress/index.d.ts +2 -2
- package/LineProgress/index.js +6 -6
- package/LineProgress/index.js.map +1 -1
- package/Link/index.cjs +41 -0
- package/Link/index.cjs.map +1 -0
- package/Link/index.d.ts +17 -0
- package/Link/index.js +39 -0
- package/Link/index.js.map +1 -0
- package/List/index.cjs +1 -1
- package/List/index.cjs.map +1 -1
- package/List/index.d.ts +2 -2
- package/List/index.js +1 -1
- package/List/index.js.map +1 -1
- package/ListItem/index.cjs +8 -8
- package/ListItem/index.cjs.map +1 -1
- package/ListItem/index.d.ts +2 -2
- package/ListItem/index.js +8 -8
- package/ListItem/index.js.map +1 -1
- package/LoadingBox/index.cjs +2 -2
- package/LoadingBox/index.cjs.map +1 -1
- package/LoadingBox/index.d.ts +2 -2
- package/LoadingBox/index.js +2 -2
- package/LoadingBox/index.js.map +1 -1
- package/Menu/index.cjs +6 -21
- package/Menu/index.cjs.map +1 -1
- package/Menu/index.d.ts +6 -4
- package/Menu/index.js +6 -21
- package/Menu/index.js.map +1 -1
- package/Modal/index.cjs +5 -5
- package/Modal/index.cjs.map +1 -1
- package/Modal/index.js +5 -5
- package/Modal/index.js.map +1 -1
- package/Option/index.d.ts +2 -2
- package/PasswordInput/index.cjs +21 -0
- package/PasswordInput/index.cjs.map +1 -0
- package/PasswordInput/index.d.ts +11 -0
- package/PasswordInput/index.js +19 -0
- package/PasswordInput/index.js.map +1 -0
- package/Portal/index.d.ts +3 -3
- package/Radio/index.d.ts +2 -2
- package/RangeSlider/index.cjs +158 -0
- package/RangeSlider/index.cjs.map +1 -0
- package/RangeSlider/index.d.ts +24 -0
- package/RangeSlider/index.js +156 -0
- package/RangeSlider/index.js.map +1 -0
- package/Scrollbar/index.cjs +6 -6
- package/Scrollbar/index.cjs.map +1 -1
- package/Scrollbar/index.d.ts +3 -3
- package/Scrollbar/index.js +6 -6
- package/Scrollbar/index.js.map +1 -1
- package/Select/index.cjs +2 -2
- package/Select/index.cjs.map +1 -1
- package/Select/index.d.ts +5 -5
- package/Select/index.js +2 -2
- package/Select/index.js.map +1 -1
- package/Skeleton/index.cjs +7 -5
- package/Skeleton/index.cjs.map +1 -1
- package/Skeleton/index.js +7 -5
- package/Skeleton/index.js.map +1 -1
- package/Stack/index.d.ts +2 -2
- package/Switch/index.cjs +2 -2
- package/Switch/index.cjs.map +1 -1
- package/Switch/index.d.ts +3 -3
- package/Switch/index.js +2 -2
- package/Switch/index.js.map +1 -1
- package/Tab/index.cjs +23 -2
- package/Tab/index.cjs.map +1 -1
- package/Tab/index.d.ts +2 -2
- package/Tab/index.js +25 -4
- package/Tab/index.js.map +1 -1
- package/Table/index.cjs +9 -9
- package/Table/index.cjs.map +1 -1
- package/Table/index.d.ts +2 -2
- package/Table/index.js +9 -9
- package/Table/index.js.map +1 -1
- package/TableBody/index.d.ts +2 -2
- package/TableCell/index.cjs +1 -1
- package/TableCell/index.cjs.map +1 -1
- package/TableCell/index.d.ts +2 -2
- package/TableCell/index.js +1 -1
- package/TableCell/index.js.map +1 -1
- package/TableFooter/index.d.ts +2 -2
- package/TableHead/index.d.ts +2 -2
- package/TablePagination/index.cjs +2 -2
- package/TablePagination/index.cjs.map +1 -1
- package/TablePagination/index.d.ts +2 -2
- package/TablePagination/index.js +2 -2
- package/TablePagination/index.js.map +1 -1
- package/TableRow/index.d.ts +2 -2
- package/Tabs/context.cjs +11 -0
- package/Tabs/context.cjs.map +1 -0
- package/Tabs/context.js +8 -0
- package/Tabs/context.js.map +1 -0
- package/Tabs/index.cjs +83 -168
- package/Tabs/index.cjs.map +1 -1
- package/Tabs/index.d.ts +4 -22
- package/Tabs/index.js +86 -171
- package/Tabs/index.js.map +1 -1
- package/Tabs/types.d.ts +16 -0
- package/Text/index.cjs +1 -1
- package/Text/index.cjs.map +1 -1
- package/Text/index.d.ts +2 -2
- package/Text/index.js +1 -1
- package/Text/index.js.map +1 -1
- package/Toast/index.cjs +15 -16
- package/Toast/index.cjs.map +1 -1
- package/Toast/index.js +16 -17
- package/Toast/index.js.map +1 -1
- package/Tooltip/index.cjs +2 -2
- package/Tooltip/index.cjs.map +1 -1
- package/Tooltip/index.js +2 -2
- package/Tooltip/index.js.map +1 -1
- package/ViewBox/index.d.ts +2 -2
- package/index.cjs +126 -110
- package/index.cjs.map +1 -1
- package/index.d.ts +9 -1
- package/index.js +9 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
- package/useBlurCss/index.cjs +1 -2
- package/useBlurCss/index.cjs.map +1 -1
- package/useBlurCss/index.js +1 -2
- package/useBlurCss/index.js.map +1 -1
- package/useContextMenu/index.cjs +2 -2
- package/useContextMenu/index.cjs.map +1 -1
- package/useContextMenu/index.d.ts +1 -1
- package/useContextMenu/index.js +2 -2
- package/useContextMenu/index.js.map +1 -1
- package/Paper/index.cjs +0 -16
- package/Paper/index.cjs.map +0 -1
- package/Paper/index.d.ts +0 -8
- package/Paper/index.js +0 -14
- package/Paper/index.js.map +0 -1
package/Menu/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Menu/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactNode, useEffect, useState, useRef } from \"react\";\nimport { Tag, TagProps, useBreakpointProps, useBreakpointPropsType, useInterface, TransitionProps, Transition } from \"@xanui/core\";\nimport Portal, { PortalProps } from \"../Portal\";\nimport ClickOutside from \"../ClickOutside\";\n\nexport type PlacementTypes =\n | \"top\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"right\"\n | \"right-top\"\n | \"right-bottom\"\n | \"left\"\n | \"left-top\"\n | \"left-bottom\";\n\nexport type MenuProps = {\n children?: ReactNode;\n target?: HTMLElement;\n placement?: useBreakpointPropsType<PlacementTypes>;\n zIndex?: number;\n\n variant?: TransitionProps['variant'];\n duration?: TransitionProps['duration'];\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Menu/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactNode, useEffect, useState, useRef } from \"react\";\nimport { Tag, TagProps, useBreakpointProps, useBreakpointPropsType, useInterface, TransitionProps, Transition } from \"@xanui/core\";\nimport Portal, { PortalProps } from \"../Portal\";\nimport ClickOutside, { ClickOutsideProps } from \"../ClickOutside\";\n\nexport type PlacementTypes =\n | \"top\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"right\"\n | \"right-top\"\n | \"right-bottom\"\n | \"left\"\n | \"left-top\"\n | \"left-bottom\";\n\nexport type MenuProps = {\n children?: ReactNode;\n target?: HTMLElement;\n placement?: useBreakpointPropsType<PlacementTypes>;\n zIndex?: number;\n\n variant?: TransitionProps['variant'];\n duration?: TransitionProps['duration'];\n onEnter?: TransitionProps['onEnter'];\n onEntered?: TransitionProps['onEntered'];\n onExit?: TransitionProps['onExit'];\n onExited?: TransitionProps['onExited'];\n\n onClickOutside?: (e: MouseEvent) => void;\n\n slotProps?: {\n transition?: Omit<TransitionProps, \"open\">;\n portal?: Omit<PortalProps, \"children\">;\n content?: Omit<TagProps<\"div\">, \"children\">;\n clickOutSide?: Omit<ClickOutsideProps, \"children\">\n };\n};\n\nconst placements: PlacementTypes[] = [\n \"top\",\n \"top-left\",\n \"top-right\",\n \"bottom\",\n \"bottom-left\",\n \"bottom-right\",\n \"right\",\n \"right-top\",\n \"right-bottom\",\n \"left\",\n \"left-top\",\n \"left-bottom\",\n];\n\nconst getTransformOrigin = (placement: PlacementTypes) => {\n switch (placement) {\n case \"top\":\n return \"bottom\";\n case \"top-left\":\n return \"bottom left\";\n case \"top-right\":\n return \"bottom right\";\n case \"bottom\":\n return \"top\";\n case \"bottom-left\":\n return \"top left\";\n case \"bottom-right\":\n return \"top right\";\n case \"left\":\n return \"right\";\n case \"left-top\":\n return \"top right\";\n case \"left-bottom\":\n return \"bottom right\";\n case \"right\":\n return \"left\";\n case \"right-top\":\n return \"top left\";\n case \"right-bottom\":\n return \"bottom left\";\n default:\n return \"top\";\n }\n};\n\nconst clampToViewport = (menu: HTMLElement, top: number, left: number) => {\n const { width, height } = menu.getBoundingClientRect();\n\n const clampedTop = Math.max(0, Math.min(top, window.innerHeight - height));\n const clampedLeft = Math.max(0, Math.min(left, window.innerWidth - width));\n\n return { top: clampedTop, left: clampedLeft };\n};\n\n// Compute coordinates for each placement\nconst computePosition = (\n placement: PlacementTypes,\n menu: HTMLElement,\n target: HTMLElement\n) => {\n const { width: mw, height: mh } = menu.getBoundingClientRect();\n const {\n top: tt,\n left: tl,\n bottom: tb,\n right: tr,\n width: tw,\n height: th,\n } = target.getBoundingClientRect();\n\n const positions: Record<PlacementTypes, { top: number; left: number }> = {\n \"bottom-left\": { top: tb, left: tl },\n \"bottom-right\": { top: tb, left: tr - mw },\n bottom: { top: tb, left: tl + (tw - mw) / 2 },\n\n \"top-left\": { top: tt - mh, left: tl },\n \"top-right\": { top: tt - mh, left: tr - mw },\n top: { top: tt - mh, left: tl + (tw - mw) / 2 },\n\n left: { top: tt + (th - mh) / 2, left: tl - mw },\n \"left-top\": { top: tt, left: tl - mw },\n \"left-bottom\": { top: tb - mh, left: tl - mw },\n\n right: { top: tt + (th - mh) / 2, left: tr },\n \"right-top\": { top: tt, left: tr },\n \"right-bottom\": { top: tb - mh, left: tr },\n };\n\n return positions[placement];\n};\n\n\n// Check if menu is off-screen\nconst isOffScreen = (menu: HTMLElement) => {\n const { x, y, width, height } = menu.getBoundingClientRect();\n return x < 0 || y < 0 || x + width > window.innerWidth || y + height > window.innerHeight;\n};\n\nconst placeMenu = (\n placement: PlacementTypes,\n menu: HTMLElement,\n target: HTMLElement\n) => {\n let finalPlacement = placement;\n\n let pos = computePosition(placement, menu, target);\n let clamped = clampToViewport(menu, pos.top, pos.left);\n\n menu.style.top = clamped.top + \"px\";\n menu.style.left = clamped.left + \"px\";\n\n // Try better placements\n if (isOffScreen(menu)) {\n for (const p of placements) {\n const fallbackPos = computePosition(p, menu, target);\n const fallbackClamped = clampToViewport(menu, fallbackPos.top, fallbackPos.left);\n\n menu.style.top = fallbackClamped.top + \"px\";\n menu.style.left = fallbackClamped.left + \"px\";\n\n if (!isOffScreen(menu)) {\n finalPlacement = p;\n break;\n }\n }\n }\n\n return finalPlacement;\n};\n\n\n\nconst Menu = ({ children, target, ...props }: MenuProps) => {\n let [{ onClickOutside, variant, duration, onEnter, onEntered, onExit, onExited, placement, zIndex, slotProps }] = useInterface<any>(\"Menu\", props, {});\n const _p: any = {};\n if (placement) _p.placement = placement;\n const p: any = useBreakpointProps(_p);\n placement = p.placement || \"bottom-left\";\n\n const isOpen = Boolean(target);\n const [closed, setClosed] = useState(!isOpen);\n const [placed, setPlaced] = useState<PlacementTypes>(placement);\n const menuRef = useRef<HTMLDivElement>(null);\n\n // Open/close effect\n useEffect(() => {\n if (closed && isOpen) setClosed(false);\n }, [isOpen]);\n\n\n useEffect(() => {\n if (!closed && target && menuRef.current) {\n const updatePosition = () => {\n if (menuRef.current && target) {\n requestAnimationFrame(() => {\n const p = placeMenu(placement!, menuRef.current as any, target);\n setPlaced(p);\n });\n }\n };\n\n updatePosition();\n window.addEventListener(\"resize\", updatePosition);\n window.addEventListener(\"scroll\", updatePosition, true);\n\n return () => {\n window.removeEventListener(\"resize\", updatePosition);\n window.removeEventListener(\"scroll\", updatePosition, true);\n };\n }\n return\n }, [closed, target, placement]);\n\n if (closed) return null;\n\n return (\n <Portal {...slotProps?.portal}>\n <ClickOutside\n {...slotProps?.clickOutSide}\n onClickOutside={(e: MouseEvent) => {\n if (target?.contains(e.target as any)) return;\n if (e.target !== target) {\n onClickOutside && onClickOutside(e);\n }\n }}\n ref={menuRef}\n sx={{\n position: \"fixed\",\n zIndex: 1500 + (zIndex || 0),\n ...slotProps?.clickOutSide?.sx\n }}\n >\n <Transition\n duration={duration ?? 200}\n easing=\"fast\"\n variant={variant ?? \"grow\"}\n {...slotProps?.transition}\n open={isOpen}\n onEnter={onEnter}\n onEntered={onEntered}\n onExit={onExit}\n onExited={() => {\n setClosed(true);\n onExited && onExited()\n }}\n >\n <Tag\n baseClass=\"menu-content\"\n {...slotProps?.content}\n sxr={{\n overflow: \"hidden\",\n bgcolor: \"surface.main\",\n shadow: 2,\n radius: 1,\n transformOrigin: getTransformOrigin(placed),\n ...slotProps?.content?.sx,\n }}\n >\n {children}\n </Tag>\n </Transition>\n </ClickOutside>\n </Portal>\n );\n};\n\nexport default Menu;\n"],"names":[],"mappings":";;;;;;;;AA2CA;;;;;;;;;;;;;;AAeA;;AAEQ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;AACJ;AACI;;AAEZ;AAEA;;;;;AAOA;AAEA;AACA;AAKI;AACA;AASA;;;AAGI;;AAGA;AACA;AAEA;;AAEA;AAEA;;;;AAKJ;AACJ;AAGA;AACA;AACI;;AAEJ;AAEA;;;AAQI;;;;AAMA;AACI;;AAEI;;;AAKA;;;;;;AAOR;AACJ;AAIA;;;AACI;;AAEA;AAAe;AACf;AACA;AAEA;;;AAGA;;;;;AAKA;;;;AAMY;;AAEQ;;AAEJ;;AAER;AAEA;AACA;;AAGA;AACI;;AAEJ;;;;AAKR;AAAY;AAEZ;;;AAMgB;AACI;;AAER;;;;AAwChB;;"}
|
package/Modal/index.cjs
CHANGED
|
@@ -16,11 +16,11 @@ const Modal = (props) => {
|
|
|
16
16
|
xl: 1300,
|
|
17
17
|
full: "100%"
|
|
18
18
|
};
|
|
19
|
-
let _c = props || {}, { children,
|
|
19
|
+
let _c = props || {}, { children, onEnter, size, slotProps } = _c, layerProps = tslib.__rest(_c, ["children", "onEnter", "size", "slotProps"]);
|
|
20
20
|
size = size !== null && size !== void 0 ? size : "xs";
|
|
21
21
|
slotProps = slotProps || {};
|
|
22
22
|
const root = (slotProps === null || slotProps === void 0 ? void 0 : slotProps.root) || {};
|
|
23
|
-
return (jsxRuntime.jsx(index, Object.assign({}, layerProps, { slotProps: Object.assign(Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer), { clickOutside: Object.assign({ maxWidth: sizes[size] || size, width: "100%" }, (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _a === void 0 ? void 0 : _a.clickOutside), root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _b === void 0 ? void 0 : _b.root) }), children: jsxRuntime.jsx(core.Tag, Object.assign({}, root, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "
|
|
23
|
+
return (jsxRuntime.jsx(index, Object.assign({}, layerProps, { slotProps: Object.assign(Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer), { clickOutside: Object.assign({ maxWidth: sizes[size] || size, width: "100%" }, (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _a === void 0 ? void 0 : _a.clickOutside), root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _b === void 0 ? void 0 : _b.root) }), children: jsxRuntime.jsx(core.Tag, Object.assign({}, root, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "surface.main", shadow: 15 }, root === null || root === void 0 ? void 0 : root.sx), baseClass: 'modal', children: children })) })));
|
|
24
24
|
};
|
|
25
25
|
Modal.open = (Children, props) => {
|
|
26
26
|
const InstanceModal = (_a) => {
|
|
@@ -34,10 +34,10 @@ Modal.open = (Children, props) => {
|
|
|
34
34
|
else {
|
|
35
35
|
m.updateProps({ open: false });
|
|
36
36
|
}
|
|
37
|
-
},
|
|
37
|
+
}, onExited: () => {
|
|
38
38
|
m.unrender();
|
|
39
|
-
if (props === null || props === void 0 ? void 0 : props.
|
|
40
|
-
props.
|
|
39
|
+
if (props === null || props === void 0 ? void 0 : props.onExited) {
|
|
40
|
+
props.onExited();
|
|
41
41
|
}
|
|
42
42
|
} }));
|
|
43
43
|
return {
|
package/Modal/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Modal/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactNode } from \"react\";\n// import useModal, { UseModalProps } from \"../useModal\";\nimport { Renderar, Tag, TagProps } from \"@xanui/core\";\nimport Layer, { ActionLayerChildren, LayerProps } from \"../Layer\";\n\nexport type ModalProps = Omit<LayerProps, \"slotProps\"> & {\n children: ReactNode;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\n slotProps?: {\n layer?: LayerProps['slotProps'];\n root?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\n\nconst Modal = (props: ModalProps) => {\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n full: \"100%\"\n }\n let { children,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Modal/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactNode } from \"react\";\n// import useModal, { UseModalProps } from \"../useModal\";\nimport { Renderar, Tag, TagProps } from \"@xanui/core\";\nimport Layer, { ActionLayerChildren, LayerProps } from \"../Layer\";\n\nexport type ModalProps = Omit<LayerProps, \"slotProps\"> & {\n children: ReactNode;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\n slotProps?: {\n layer?: LayerProps['slotProps'];\n root?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\n\nconst Modal = (props: ModalProps) => {\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n full: \"100%\"\n }\n let { children, onEnter, size, slotProps, ...layerProps } = props || {}\n size = size ?? \"xs\"\n slotProps = slotProps || {} as any\n const root: any = slotProps?.root || {}\n\n return (\n <Layer\n {...layerProps}\n slotProps={{\n ...slotProps?.layer,\n clickOutside: {\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n ...slotProps?.layer?.clickOutside,\n },\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ...slotProps?.layer?.root,\n }\n }}\n >\n <Tag\n {...root}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"surface.main\",\n shadow: 15,\n ...root?.sx\n }}\n baseClass='modal'\n >\n {children}\n </Tag>\n </Layer>\n )\n}\n\nModal.open = (Children: ActionLayerChildren, props?: Omit<ModalProps, 'children' | \"open\">) => {\n const InstanceModal = ({ children, ...props }: ModalProps) => <Modal {...props} >{children}</Modal>;\n const m = Renderar.render(InstanceModal as any, {\n open: true,\n children: typeof Children === \"function\" ? <Children\n open={() => m.updateProps({ open: true })}\n close={() => m.updateProps({ open: false })}\n /> : Children,\n ...props,\n onClickOutside: () => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n m.updateProps({ open: false })\n }\n },\n onExited: () => {\n m.unrender()\n if (props?.onExited) {\n props.onExited()\n }\n }\n })\n\n return {\n open: () => {\n m.updateProps({ open: true })\n },\n close: () => {\n m.updateProps({ open: false })\n },\n }\n};\n\n\nexport default Modal;"],"names":[],"mappings":";;;;;;;;AAgBA;;AACG;AACG;AACA;AACA;AACA;AACA;AACA;;AAEH;;AAEA;AACA;;AAoCH;AAEA;AACG;AAAuB;AAAuC;;AAC9D;;;;;;;AAaG;;;;;AAMA;;;;;;;;;AAWN;;"}
|
package/Modal/index.js
CHANGED
|
@@ -14,11 +14,11 @@ const Modal = (props) => {
|
|
|
14
14
|
xl: 1300,
|
|
15
15
|
full: "100%"
|
|
16
16
|
};
|
|
17
|
-
let _c = props || {}, { children,
|
|
17
|
+
let _c = props || {}, { children, onEnter, size, slotProps } = _c, layerProps = __rest(_c, ["children", "onEnter", "size", "slotProps"]);
|
|
18
18
|
size = size !== null && size !== void 0 ? size : "xs";
|
|
19
19
|
slotProps = slotProps || {};
|
|
20
20
|
const root = (slotProps === null || slotProps === void 0 ? void 0 : slotProps.root) || {};
|
|
21
|
-
return (jsx(Layer, Object.assign({}, layerProps, { slotProps: Object.assign(Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer), { clickOutside: Object.assign({ maxWidth: sizes[size] || size, width: "100%" }, (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _a === void 0 ? void 0 : _a.clickOutside), root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _b === void 0 ? void 0 : _b.root) }), children: jsx(Tag, Object.assign({}, root, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "
|
|
21
|
+
return (jsx(Layer, Object.assign({}, layerProps, { slotProps: Object.assign(Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer), { clickOutside: Object.assign({ maxWidth: sizes[size] || size, width: "100%" }, (_a = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _a === void 0 ? void 0 : _a.clickOutside), root: Object.assign({ display: "flex", alignItems: 'center', justifyContent: "center" }, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.layer) === null || _b === void 0 ? void 0 : _b.root) }), children: jsx(Tag, Object.assign({}, root, { sxr: Object.assign({ maxWidth: sizes[size] || size, width: "100%", radius: 2, bgcolor: "surface.main", shadow: 15 }, root === null || root === void 0 ? void 0 : root.sx), baseClass: 'modal', children: children })) })));
|
|
22
22
|
};
|
|
23
23
|
Modal.open = (Children, props) => {
|
|
24
24
|
const InstanceModal = (_a) => {
|
|
@@ -32,10 +32,10 @@ Modal.open = (Children, props) => {
|
|
|
32
32
|
else {
|
|
33
33
|
m.updateProps({ open: false });
|
|
34
34
|
}
|
|
35
|
-
},
|
|
35
|
+
}, onExited: () => {
|
|
36
36
|
m.unrender();
|
|
37
|
-
if (props === null || props === void 0 ? void 0 : props.
|
|
38
|
-
props.
|
|
37
|
+
if (props === null || props === void 0 ? void 0 : props.onExited) {
|
|
38
|
+
props.onExited();
|
|
39
39
|
}
|
|
40
40
|
} }));
|
|
41
41
|
return {
|
package/Modal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Modal/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactNode } from \"react\";\n// import useModal, { UseModalProps } from \"../useModal\";\nimport { Renderar, Tag, TagProps } from \"@xanui/core\";\nimport Layer, { ActionLayerChildren, LayerProps } from \"../Layer\";\n\nexport type ModalProps = Omit<LayerProps, \"slotProps\"> & {\n children: ReactNode;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\n slotProps?: {\n layer?: LayerProps['slotProps'];\n root?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\n\nconst Modal = (props: ModalProps) => {\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n full: \"100%\"\n }\n let { children,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Modal/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactNode } from \"react\";\n// import useModal, { UseModalProps } from \"../useModal\";\nimport { Renderar, Tag, TagProps } from \"@xanui/core\";\nimport Layer, { ActionLayerChildren, LayerProps } from \"../Layer\";\n\nexport type ModalProps = Omit<LayerProps, \"slotProps\"> & {\n children: ReactNode;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\n slotProps?: {\n layer?: LayerProps['slotProps'];\n root?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\n\nconst Modal = (props: ModalProps) => {\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n full: \"100%\"\n }\n let { children, onEnter, size, slotProps, ...layerProps } = props || {}\n size = size ?? \"xs\"\n slotProps = slotProps || {} as any\n const root: any = slotProps?.root || {}\n\n return (\n <Layer\n {...layerProps}\n slotProps={{\n ...slotProps?.layer,\n clickOutside: {\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n ...slotProps?.layer?.clickOutside,\n },\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ...slotProps?.layer?.root,\n }\n }}\n >\n <Tag\n {...root}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"surface.main\",\n shadow: 15,\n ...root?.sx\n }}\n baseClass='modal'\n >\n {children}\n </Tag>\n </Layer>\n )\n}\n\nModal.open = (Children: ActionLayerChildren, props?: Omit<ModalProps, 'children' | \"open\">) => {\n const InstanceModal = ({ children, ...props }: ModalProps) => <Modal {...props} >{children}</Modal>;\n const m = Renderar.render(InstanceModal as any, {\n open: true,\n children: typeof Children === \"function\" ? <Children\n open={() => m.updateProps({ open: true })}\n close={() => m.updateProps({ open: false })}\n /> : Children,\n ...props,\n onClickOutside: () => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n m.updateProps({ open: false })\n }\n },\n onExited: () => {\n m.unrender()\n if (props?.onExited) {\n props.onExited()\n }\n }\n })\n\n return {\n open: () => {\n m.updateProps({ open: true })\n },\n close: () => {\n m.updateProps({ open: false })\n },\n }\n};\n\n\nexport default Modal;"],"names":[],"mappings":";;;;;;AAgBA;;AACG;AACG;AACA;AACA;AACA;AACA;AACA;;AAEH;;AAEA;AACA;;AAoCH;AAEA;AACG;AAAuB;AAAuC;;AAC9D;;;;;;;AAaG;;;;;AAMA;;;;;;;;;AAWN;;"}
|
package/Option/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { ListItemProps } from '../ListItem/index.js';
|
|
3
3
|
|
|
4
4
|
type OptionProps = ListItemProps & {
|
|
5
5
|
value: string | number;
|
|
6
6
|
};
|
|
7
|
-
declare const Option:
|
|
7
|
+
declare const Option: React__default.ForwardRefExoticComponent<Omit<OptionProps, "ref"> & React__default.RefAttributes<any>>;
|
|
8
8
|
|
|
9
9
|
export { Option as default };
|
|
10
10
|
export type { OptionProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var tslib = require('tslib');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var Visibility = require('@xanui/icons/Visibility');
|
|
7
|
+
var VisibilityOff = require('@xanui/icons/VisibilityOff');
|
|
8
|
+
var index$1 = require('../IconButton/index.cjs');
|
|
9
|
+
var index = require('../Input/index.cjs');
|
|
10
|
+
var React = require('react');
|
|
11
|
+
|
|
12
|
+
const PasswordInput = React.forwardRef((_a, ref) => {
|
|
13
|
+
var { defaultShow } = _a, props = tslib.__rest(_a, ["defaultShow"]);
|
|
14
|
+
const [show, setShow] = React.useState(defaultShow !== null && defaultShow !== void 0 ? defaultShow : false);
|
|
15
|
+
return (jsxRuntime.jsx(index, Object.assign({ ref: ref, variant: "outline", placeholder: "Password" }, props, { type: show ? "text" : "password", endIcon: jsxRuntime.jsx(index$1, { variant: "text", color: "surface", size: "small", onClick: () => {
|
|
16
|
+
setShow(p => !p);
|
|
17
|
+
}, children: show ? jsxRuntime.jsx(Visibility, {}) : jsxRuntime.jsx(VisibilityOff, {}) }) })));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
module.exports = PasswordInput;
|
|
21
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/PasswordInput/index.tsx"],"sourcesContent":["\"use client\"\nimport Visibility from \"@xanui/icons/Visibility\"\nimport VisibilityOff from \"@xanui/icons/VisibilityOff\"\nimport IconButton from \"../IconButton\"\nimport Input from \"../Input\"\nimport { InputProps } from '../Input';\nimport React, { forwardRef } from 'react'\n\nexport type PasswordInputProps = InputProps & {\n placeholder?: string;\n defaultShow?: boolean\n}\n\nconst PasswordInput = forwardRef(({ defaultShow, ...props }: PasswordInputProps, ref: React.Ref<\"input\">) => {\n const [show, setShow] = React.useState(defaultShow ?? false)\n\n return (\n <Input\n ref={ref}\n variant=\"outline\"\n placeholder=\"Password\"\n {...props}\n type={show ? \"text\" : \"password\"}\n endIcon={\n <IconButton\n variant=\"text\"\n color=\"surface\"\n size=\"small\"\n onClick={() => {\n setShow(p => !p);\n }}\n >\n {show ? <Visibility /> : <VisibilityOff />}\n </IconButton>\n }\n />\n )\n})\n\nexport default PasswordInput"],"names":[],"mappings":";;;;;;;;;;;AAaA;AAAkC;AAC/B;;;AAgBY;AAOf;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InputProps } from '../Input/index.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
type PasswordInputProps = InputProps & {
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
defaultShow?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const PasswordInput: React__default.ForwardRefExoticComponent<Omit<PasswordInputProps, "ref"> & React__default.RefAttributes<"input">>;
|
|
9
|
+
|
|
10
|
+
export { PasswordInput as default };
|
|
11
|
+
export type { PasswordInputProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import Visibility from '@xanui/icons/Visibility';
|
|
5
|
+
import VisibilityOff from '@xanui/icons/VisibilityOff';
|
|
6
|
+
import IconButton from '../IconButton/index.js';
|
|
7
|
+
import Input from '../Input/index.js';
|
|
8
|
+
import React, { forwardRef } from 'react';
|
|
9
|
+
|
|
10
|
+
const PasswordInput = forwardRef((_a, ref) => {
|
|
11
|
+
var { defaultShow } = _a, props = __rest(_a, ["defaultShow"]);
|
|
12
|
+
const [show, setShow] = React.useState(defaultShow !== null && defaultShow !== void 0 ? defaultShow : false);
|
|
13
|
+
return (jsx(Input, Object.assign({ ref: ref, variant: "outline", placeholder: "Password" }, props, { type: show ? "text" : "password", endIcon: jsx(IconButton, { variant: "text", color: "surface", size: "small", onClick: () => {
|
|
14
|
+
setShow(p => !p);
|
|
15
|
+
}, children: show ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) }) })));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { PasswordInput as default };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/PasswordInput/index.tsx"],"sourcesContent":["\"use client\"\nimport Visibility from \"@xanui/icons/Visibility\"\nimport VisibilityOff from \"@xanui/icons/VisibilityOff\"\nimport IconButton from \"../IconButton\"\nimport Input from \"../Input\"\nimport { InputProps } from '../Input';\nimport React, { forwardRef } from 'react'\n\nexport type PasswordInputProps = InputProps & {\n placeholder?: string;\n defaultShow?: boolean\n}\n\nconst PasswordInput = forwardRef(({ defaultShow, ...props }: PasswordInputProps, ref: React.Ref<\"input\">) => {\n const [show, setShow] = React.useState(defaultShow ?? false)\n\n return (\n <Input\n ref={ref}\n variant=\"outline\"\n placeholder=\"Password\"\n {...props}\n type={show ? \"text\" : \"password\"}\n endIcon={\n <IconButton\n variant=\"text\"\n color=\"surface\"\n size=\"small\"\n onClick={() => {\n setShow(p => !p);\n }}\n >\n {show ? <Visibility /> : <VisibilityOff />}\n </IconButton>\n }\n />\n )\n})\n\nexport default PasswordInput"],"names":[],"mappings":";;;;;;;;;AAaA;AAAkC;AAC/B;;;AAgBY;AAOf;;"}
|
package/Portal/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
|
|
3
3
|
type PortalProps = {
|
|
4
|
-
children?:
|
|
4
|
+
children?: React__default.ReactNode;
|
|
5
5
|
appendTo?: HTMLElement;
|
|
6
6
|
container?: HTMLElement;
|
|
7
7
|
};
|
|
8
|
-
declare const Portal: ({ children, appendTo, container }: PortalProps) =>
|
|
8
|
+
declare const Portal: ({ children, appendTo, container }: PortalProps) => React__default.ReactPortal;
|
|
9
9
|
|
|
10
10
|
export { Portal as default };
|
|
11
11
|
export type { PortalProps };
|
package/Radio/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { CheckboxProps } from '../Checkbox/index.js';
|
|
3
3
|
|
|
4
|
-
declare const Radio:
|
|
4
|
+
declare const Radio: React__default.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React__default.RefAttributes<any>>;
|
|
5
5
|
|
|
6
6
|
export { Radio as default };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var tslib = require('tslib');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var core = require('@xanui/core');
|
|
8
|
+
|
|
9
|
+
const RangeSlider = (props) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { value, defaultValue, onChange, disabled } = props, rest = tslib.__rest(props, ["value", "defaultValue", "onChange", "disabled"]);
|
|
12
|
+
// interface system
|
|
13
|
+
let [{ color, min = 0, max = 100, step = 1, thumbContent, thumbSize = 16, size = "sm" }] = core.useInterface("RangeSlider", rest, {});
|
|
14
|
+
const bp = core.useBreakpointProps({
|
|
15
|
+
color,
|
|
16
|
+
size
|
|
17
|
+
});
|
|
18
|
+
color = (_a = bp.color) !== null && _a !== void 0 ? _a : "primary";
|
|
19
|
+
size = bp.size;
|
|
20
|
+
const sizesSX = {
|
|
21
|
+
xs: {
|
|
22
|
+
track: 2,
|
|
23
|
+
thumb: 8
|
|
24
|
+
},
|
|
25
|
+
sm: {
|
|
26
|
+
track: 4,
|
|
27
|
+
thumb: 14
|
|
28
|
+
},
|
|
29
|
+
md: {
|
|
30
|
+
track: 8,
|
|
31
|
+
thumb: 18
|
|
32
|
+
},
|
|
33
|
+
lg: {
|
|
34
|
+
track: 12,
|
|
35
|
+
thumb: 24
|
|
36
|
+
},
|
|
37
|
+
xl: {
|
|
38
|
+
track: 16,
|
|
39
|
+
thumb: 32
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const _size = sizesSX[size];
|
|
43
|
+
if (thumbSize) {
|
|
44
|
+
_size.thumb = thumbSize;
|
|
45
|
+
}
|
|
46
|
+
if (disabled) {
|
|
47
|
+
color = 'surface.divider';
|
|
48
|
+
}
|
|
49
|
+
const isControlled = value !== undefined;
|
|
50
|
+
const [internalValue, setInternalValue] = React.useState(() => {
|
|
51
|
+
if (value !== undefined)
|
|
52
|
+
return Array.isArray(value) ? value : [value];
|
|
53
|
+
if (defaultValue !== undefined)
|
|
54
|
+
return Array.isArray(defaultValue)
|
|
55
|
+
? defaultValue
|
|
56
|
+
: [defaultValue];
|
|
57
|
+
return [min];
|
|
58
|
+
});
|
|
59
|
+
// sync controlled
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (isControlled) {
|
|
62
|
+
setInternalValue(Array.isArray(value) ? value : [value]);
|
|
63
|
+
}
|
|
64
|
+
}, [value, isControlled]);
|
|
65
|
+
const containerRef = React.useRef(null);
|
|
66
|
+
const isDownRef = React.useRef(false);
|
|
67
|
+
const activeHandleRef = React.useRef(null);
|
|
68
|
+
const updateValue = (index, clientX) => {
|
|
69
|
+
if (!containerRef.current)
|
|
70
|
+
return;
|
|
71
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
72
|
+
let p = (clientX - rect.left) / rect.width;
|
|
73
|
+
p = Math.max(0, Math.min(1, p));
|
|
74
|
+
const raw = min + p * (max - min);
|
|
75
|
+
const stepped = Math.round((raw - min) / step) * step + min;
|
|
76
|
+
const next = [...internalValue];
|
|
77
|
+
next[index] = Math.min(max, Math.max(min, stepped));
|
|
78
|
+
if (!isControlled) {
|
|
79
|
+
setInternalValue(next);
|
|
80
|
+
}
|
|
81
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next.length === 1 ? next[0] : next);
|
|
82
|
+
};
|
|
83
|
+
// global drag system
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
const handleMove = (e) => {
|
|
86
|
+
if (!isDownRef.current || activeHandleRef.current === null)
|
|
87
|
+
return;
|
|
88
|
+
updateValue(activeHandleRef.current, e.clientX);
|
|
89
|
+
};
|
|
90
|
+
const handleUp = () => {
|
|
91
|
+
isDownRef.current = false;
|
|
92
|
+
activeHandleRef.current = null;
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener("mousemove", handleMove);
|
|
95
|
+
window.addEventListener("mouseup", handleUp);
|
|
96
|
+
return () => {
|
|
97
|
+
window.removeEventListener("mousemove", handleMove);
|
|
98
|
+
window.removeEventListener("mouseup", handleUp);
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
const sorted = [...internalValue].sort((a, b) => a - b);
|
|
102
|
+
const startValue = sorted.length === 1 ? min : sorted[0];
|
|
103
|
+
const endValue = sorted[sorted.length - 1];
|
|
104
|
+
const startPercent = ((startValue - min) / (max - min)) * 100;
|
|
105
|
+
const endPercent = ((endValue - min) / (max - min)) * 100;
|
|
106
|
+
return (jsxRuntime.jsxs(core.Tag, { ref: containerRef, onClick: (e) => {
|
|
107
|
+
if (disabled)
|
|
108
|
+
return;
|
|
109
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
110
|
+
const p = (e.clientX - rect.left) / rect.width;
|
|
111
|
+
const raw = min + p * (max - min);
|
|
112
|
+
const stepped = Math.round((raw - min) / step) * step + min;
|
|
113
|
+
let closestIndex = 0;
|
|
114
|
+
let minDist = Math.abs(internalValue[0] - stepped);
|
|
115
|
+
for (let i = 1; i < internalValue.length; i++) {
|
|
116
|
+
const d = Math.abs(internalValue[i] - stepped);
|
|
117
|
+
if (d < minDist) {
|
|
118
|
+
minDist = d;
|
|
119
|
+
closestIndex = i;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
updateValue(closestIndex, e.clientX);
|
|
123
|
+
}, sxr: Object.assign({ position: "relative", width: "100%", display: "flex", alignItems: "center" }, (disabled ? { cursor: "not-allowed" } : {})), children: [jsxRuntime.jsx(core.Tag, { sxr: {
|
|
124
|
+
position: "absolute",
|
|
125
|
+
width: "100%",
|
|
126
|
+
height: _size.track,
|
|
127
|
+
bgcolor: 'surface.divider',
|
|
128
|
+
radius: `${_size.track}px`,
|
|
129
|
+
} }), jsxRuntime.jsx(core.Tag, { sxr: {
|
|
130
|
+
position: "absolute",
|
|
131
|
+
height: _size.track,
|
|
132
|
+
bgcolor: color,
|
|
133
|
+
radius: `${_size.track}px`,
|
|
134
|
+
left: `${startPercent}%`,
|
|
135
|
+
width: `${endPercent - startPercent}%`,
|
|
136
|
+
} }), internalValue.map((v, i) => {
|
|
137
|
+
const percent = ((v - min) / (max - min)) * 100;
|
|
138
|
+
return (jsxRuntime.jsx(core.Tag, { sxr: {
|
|
139
|
+
position: "absolute",
|
|
140
|
+
width: _size.thumb,
|
|
141
|
+
height: _size.thumb,
|
|
142
|
+
radius: `${_size.thumb}px`,
|
|
143
|
+
bgcolor: color,
|
|
144
|
+
left: `${percent}%`,
|
|
145
|
+
transform: "translateX(-50%)",
|
|
146
|
+
cursor: disabled ? "not-allowed" : "initial",
|
|
147
|
+
}, onMouseDown: (e) => {
|
|
148
|
+
if (disabled)
|
|
149
|
+
return;
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
isDownRef.current = true;
|
|
152
|
+
activeHandleRef.current = i;
|
|
153
|
+
}, children: thumbContent ? thumbContent({ value: percent }) : "" }, i));
|
|
154
|
+
})] }));
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
module.exports = RangeSlider;
|
|
158
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/RangeSlider/index.tsx"],"sourcesContent":["\"use client\";\nimport { ReactElement, useEffect, useRef, useState } from \"react\";\nimport {\n Tag,\n useBreakpointProps,\n useBreakpointPropsType,\n UseColorTemplateColor,\n useInterface,\n} from \"@xanui/core\";\n\nexport type RangeSliderValue = number | number[];\n\nexport type RangeSliderProps = {\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n min?: number;\n max?: number;\n step?: number;\n value?: RangeSliderValue;\n defaultValue?: RangeSliderValue;\n onChange?: (value: RangeSliderValue) => void;\n disabled?: boolean;\n thumbContent?: (props: { value: number }) => ReactElement\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n thumbSize?: number;\n};\n\nconst RangeSlider = (props: RangeSliderProps) => {\n const { value, defaultValue, onChange, disabled, ...rest } = props;\n\n // interface system\n let [{ color, min = 0, max = 100, step = 1, thumbContent, thumbSize = 16, size = \"sm\" }] = useInterface<any>(\n \"RangeSlider\",\n rest,\n {}\n );\n\n const bp: any = useBreakpointProps({\n color,\n size\n });\n color = bp.color ?? \"primary\"\n size = bp.size;\n\n const sizesSX: any = {\n xs: {\n track: 2,\n thumb: 8\n },\n sm: {\n track: 4,\n thumb: 14\n },\n md: {\n track: 8,\n thumb: 18\n },\n lg: {\n track: 12,\n thumb: 24\n },\n xl: {\n track: 16,\n thumb: 32\n }\n }\n\n const _size = sizesSX[size]\n\n\n if (thumbSize) {\n _size.thumb = thumbSize\n }\n\n if (disabled) {\n color = 'surface.divider'\n }\n\n const isControlled = value !== undefined;\n\n const [internalValue, setInternalValue] = useState<number[]>(() => {\n if (value !== undefined) return Array.isArray(value) ? value : [value];\n if (defaultValue !== undefined)\n return Array.isArray(defaultValue)\n ? defaultValue\n : [defaultValue];\n return [min];\n });\n\n // sync controlled\n useEffect(() => {\n if (isControlled) {\n setInternalValue(Array.isArray(value) ? value : [value!]);\n }\n }, [value, isControlled]);\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const isDownRef = useRef(false);\n const activeHandleRef = useRef<number | null>(null);\n\n const updateValue = (index: number, clientX: number) => {\n if (!containerRef.current) return;\n\n const rect = containerRef.current.getBoundingClientRect();\n let p = (clientX - rect.left) / rect.width;\n p = Math.max(0, Math.min(1, p));\n\n const raw = min + p * (max - min);\n const stepped = Math.round((raw - min) / step) * step + min;\n\n const next = [...internalValue];\n next[index] = Math.min(max, Math.max(min, stepped));\n\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onChange?.(next.length === 1 ? next[0] : next);\n };\n\n // global drag system\n useEffect(() => {\n const handleMove = (e: MouseEvent) => {\n if (!isDownRef.current || activeHandleRef.current === null) return;\n updateValue(activeHandleRef.current, e.clientX);\n };\n\n const handleUp = () => {\n isDownRef.current = false;\n activeHandleRef.current = null;\n };\n\n window.addEventListener(\"mousemove\", handleMove);\n window.addEventListener(\"mouseup\", handleUp);\n\n return () => {\n window.removeEventListener(\"mousemove\", handleMove);\n window.removeEventListener(\"mouseup\", handleUp);\n };\n });\n\n const sorted = [...internalValue].sort((a, b) => a - b);\n\n const startValue = sorted.length === 1 ? min : sorted[0];\n const endValue = sorted[sorted.length - 1];\n\n const startPercent = ((startValue - min) / (max - min)) * 100;\n const endPercent = ((endValue - min) / (max - min)) * 100;\n\n\n\n return (\n <Tag\n ref={containerRef}\n onClick={(e: any) => {\n if (disabled) return;\n\n const rect = e.currentTarget.getBoundingClientRect();\n const p = (e.clientX - rect.left) / rect.width;\n const raw = min + p * (max - min);\n const stepped = Math.round((raw - min) / step) * step + min;\n\n let closestIndex = 0;\n let minDist = Math.abs(internalValue[0] - stepped);\n\n for (let i = 1; i < internalValue.length; i++) {\n const d = Math.abs(internalValue[i] - stepped);\n if (d < minDist) {\n minDist = d;\n closestIndex = i;\n }\n }\n\n updateValue(closestIndex, e.clientX);\n }}\n sxr={{\n position: \"relative\",\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n ...(disabled ? { cursor: \"not-allowed\" } : {}),\n }}\n >\n {/* Track */}\n <Tag\n sxr={{\n position: \"absolute\",\n width: \"100%\",\n height: _size.track,\n bgcolor: 'surface.divider',\n radius: `${_size.track}px`,\n }}\n />\n\n <Tag\n sxr={{\n position: \"absolute\",\n height: _size.track,\n bgcolor: color,\n radius: `${_size.track}px`,\n left: `${startPercent}%`,\n width: `${endPercent - startPercent}%`,\n }}\n />\n\n {internalValue.map((v, i) => {\n const percent = ((v - min) / (max - min)) * 100;\n return (\n <Tag\n key={i}\n sxr={{\n position: \"absolute\",\n width: _size.thumb,\n height: _size.thumb,\n radius: `${_size.thumb}px`,\n bgcolor: color,\n left: `${percent}%`,\n transform: \"translateX(-50%)\",\n cursor: disabled ? \"not-allowed\" : \"initial\",\n }}\n onMouseDown={(e) => {\n if (disabled) return;\n e.preventDefault();\n isDownRef.current = true;\n activeHandleRef.current = i;\n }}\n >\n {thumbContent ? thumbContent({ value: percent }) : \"\"}\n </Tag>\n );\n })}\n </Tag>\n );\n};\n\nexport default RangeSlider;"],"names":[],"mappings":";;;;;;;;AA0BA;;AACG;;AAGA;;;;AASC;AACD;AACA;AAEA;AACG;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;;AAGJ;;AAIG;;;;;AAOH;;;AAG4B;;AAEtB;AACG;AACA;;AAET;;;;AAKM;;AAEN;AAEA;AACA;AACA;AAEA;;;;AAIG;AACA;;AAGA;AAEA;AACA;;;;;AAOH;;;AAIG;;;;AAGA;;AAGG;AACA;AACH;AAEA;AACA;AAEA;AACG;AACA;AACH;AACH;;AAIA;;AAGA;AACA;AAIA;AAIS;;;AAGA;;AAEA;;AAGA;AAEA;AACG;AACA;;;;;AAMH;AACH;AAYM;AACA;;AAEA;AACA;AACF;AAKE;;AAEA;AACA;;AAEA;;AAKH;AACA;AAIS;;;AAGA;AACA;;AAEA;;AAEF;AAEE;;;AAEA;AACA;;;AASrB;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { useBreakpointPropsType, UseColorTemplateColor } from '@xanui/core';
|
|
4
|
+
|
|
5
|
+
type RangeSliderValue = number | number[];
|
|
6
|
+
type RangeSliderProps = {
|
|
7
|
+
color?: useBreakpointPropsType<UseColorTemplateColor>;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
step?: number;
|
|
11
|
+
value?: RangeSliderValue;
|
|
12
|
+
defaultValue?: RangeSliderValue;
|
|
13
|
+
onChange?: (value: RangeSliderValue) => void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
thumbContent?: (props: {
|
|
16
|
+
value: number;
|
|
17
|
+
}) => ReactElement;
|
|
18
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
19
|
+
thumbSize?: number;
|
|
20
|
+
};
|
|
21
|
+
declare const RangeSlider: (props: RangeSliderProps) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { RangeSlider as default };
|
|
24
|
+
export type { RangeSliderProps, RangeSliderValue };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useState, useEffect, useRef } from 'react';
|
|
5
|
+
import { useInterface, useBreakpointProps, Tag } from '@xanui/core';
|
|
6
|
+
|
|
7
|
+
const RangeSlider = (props) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const { value, defaultValue, onChange, disabled } = props, rest = __rest(props, ["value", "defaultValue", "onChange", "disabled"]);
|
|
10
|
+
// interface system
|
|
11
|
+
let [{ color, min = 0, max = 100, step = 1, thumbContent, thumbSize = 16, size = "sm" }] = useInterface("RangeSlider", rest, {});
|
|
12
|
+
const bp = useBreakpointProps({
|
|
13
|
+
color,
|
|
14
|
+
size
|
|
15
|
+
});
|
|
16
|
+
color = (_a = bp.color) !== null && _a !== void 0 ? _a : "primary";
|
|
17
|
+
size = bp.size;
|
|
18
|
+
const sizesSX = {
|
|
19
|
+
xs: {
|
|
20
|
+
track: 2,
|
|
21
|
+
thumb: 8
|
|
22
|
+
},
|
|
23
|
+
sm: {
|
|
24
|
+
track: 4,
|
|
25
|
+
thumb: 14
|
|
26
|
+
},
|
|
27
|
+
md: {
|
|
28
|
+
track: 8,
|
|
29
|
+
thumb: 18
|
|
30
|
+
},
|
|
31
|
+
lg: {
|
|
32
|
+
track: 12,
|
|
33
|
+
thumb: 24
|
|
34
|
+
},
|
|
35
|
+
xl: {
|
|
36
|
+
track: 16,
|
|
37
|
+
thumb: 32
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const _size = sizesSX[size];
|
|
41
|
+
if (thumbSize) {
|
|
42
|
+
_size.thumb = thumbSize;
|
|
43
|
+
}
|
|
44
|
+
if (disabled) {
|
|
45
|
+
color = 'surface.divider';
|
|
46
|
+
}
|
|
47
|
+
const isControlled = value !== undefined;
|
|
48
|
+
const [internalValue, setInternalValue] = useState(() => {
|
|
49
|
+
if (value !== undefined)
|
|
50
|
+
return Array.isArray(value) ? value : [value];
|
|
51
|
+
if (defaultValue !== undefined)
|
|
52
|
+
return Array.isArray(defaultValue)
|
|
53
|
+
? defaultValue
|
|
54
|
+
: [defaultValue];
|
|
55
|
+
return [min];
|
|
56
|
+
});
|
|
57
|
+
// sync controlled
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (isControlled) {
|
|
60
|
+
setInternalValue(Array.isArray(value) ? value : [value]);
|
|
61
|
+
}
|
|
62
|
+
}, [value, isControlled]);
|
|
63
|
+
const containerRef = useRef(null);
|
|
64
|
+
const isDownRef = useRef(false);
|
|
65
|
+
const activeHandleRef = useRef(null);
|
|
66
|
+
const updateValue = (index, clientX) => {
|
|
67
|
+
if (!containerRef.current)
|
|
68
|
+
return;
|
|
69
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
70
|
+
let p = (clientX - rect.left) / rect.width;
|
|
71
|
+
p = Math.max(0, Math.min(1, p));
|
|
72
|
+
const raw = min + p * (max - min);
|
|
73
|
+
const stepped = Math.round((raw - min) / step) * step + min;
|
|
74
|
+
const next = [...internalValue];
|
|
75
|
+
next[index] = Math.min(max, Math.max(min, stepped));
|
|
76
|
+
if (!isControlled) {
|
|
77
|
+
setInternalValue(next);
|
|
78
|
+
}
|
|
79
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next.length === 1 ? next[0] : next);
|
|
80
|
+
};
|
|
81
|
+
// global drag system
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const handleMove = (e) => {
|
|
84
|
+
if (!isDownRef.current || activeHandleRef.current === null)
|
|
85
|
+
return;
|
|
86
|
+
updateValue(activeHandleRef.current, e.clientX);
|
|
87
|
+
};
|
|
88
|
+
const handleUp = () => {
|
|
89
|
+
isDownRef.current = false;
|
|
90
|
+
activeHandleRef.current = null;
|
|
91
|
+
};
|
|
92
|
+
window.addEventListener("mousemove", handleMove);
|
|
93
|
+
window.addEventListener("mouseup", handleUp);
|
|
94
|
+
return () => {
|
|
95
|
+
window.removeEventListener("mousemove", handleMove);
|
|
96
|
+
window.removeEventListener("mouseup", handleUp);
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
const sorted = [...internalValue].sort((a, b) => a - b);
|
|
100
|
+
const startValue = sorted.length === 1 ? min : sorted[0];
|
|
101
|
+
const endValue = sorted[sorted.length - 1];
|
|
102
|
+
const startPercent = ((startValue - min) / (max - min)) * 100;
|
|
103
|
+
const endPercent = ((endValue - min) / (max - min)) * 100;
|
|
104
|
+
return (jsxs(Tag, { ref: containerRef, onClick: (e) => {
|
|
105
|
+
if (disabled)
|
|
106
|
+
return;
|
|
107
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
108
|
+
const p = (e.clientX - rect.left) / rect.width;
|
|
109
|
+
const raw = min + p * (max - min);
|
|
110
|
+
const stepped = Math.round((raw - min) / step) * step + min;
|
|
111
|
+
let closestIndex = 0;
|
|
112
|
+
let minDist = Math.abs(internalValue[0] - stepped);
|
|
113
|
+
for (let i = 1; i < internalValue.length; i++) {
|
|
114
|
+
const d = Math.abs(internalValue[i] - stepped);
|
|
115
|
+
if (d < minDist) {
|
|
116
|
+
minDist = d;
|
|
117
|
+
closestIndex = i;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
updateValue(closestIndex, e.clientX);
|
|
121
|
+
}, sxr: Object.assign({ position: "relative", width: "100%", display: "flex", alignItems: "center" }, (disabled ? { cursor: "not-allowed" } : {})), children: [jsx(Tag, { sxr: {
|
|
122
|
+
position: "absolute",
|
|
123
|
+
width: "100%",
|
|
124
|
+
height: _size.track,
|
|
125
|
+
bgcolor: 'surface.divider',
|
|
126
|
+
radius: `${_size.track}px`,
|
|
127
|
+
} }), jsx(Tag, { sxr: {
|
|
128
|
+
position: "absolute",
|
|
129
|
+
height: _size.track,
|
|
130
|
+
bgcolor: color,
|
|
131
|
+
radius: `${_size.track}px`,
|
|
132
|
+
left: `${startPercent}%`,
|
|
133
|
+
width: `${endPercent - startPercent}%`,
|
|
134
|
+
} }), internalValue.map((v, i) => {
|
|
135
|
+
const percent = ((v - min) / (max - min)) * 100;
|
|
136
|
+
return (jsx(Tag, { sxr: {
|
|
137
|
+
position: "absolute",
|
|
138
|
+
width: _size.thumb,
|
|
139
|
+
height: _size.thumb,
|
|
140
|
+
radius: `${_size.thumb}px`,
|
|
141
|
+
bgcolor: color,
|
|
142
|
+
left: `${percent}%`,
|
|
143
|
+
transform: "translateX(-50%)",
|
|
144
|
+
cursor: disabled ? "not-allowed" : "initial",
|
|
145
|
+
}, onMouseDown: (e) => {
|
|
146
|
+
if (disabled)
|
|
147
|
+
return;
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
isDownRef.current = true;
|
|
150
|
+
activeHandleRef.current = i;
|
|
151
|
+
}, children: thumbContent ? thumbContent({ value: percent }) : "" }, i));
|
|
152
|
+
})] }));
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export { RangeSlider as default };
|
|
156
|
+
//# sourceMappingURL=index.js.map
|