@jbpark/ui-kit 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +0 -1
- package/README.md +0 -1
- package/dist/Menu.d.mts +62 -2
- package/dist/Menu.d.mts.map +1 -0
- package/dist/Menu.mjs +66 -5
- package/dist/Menu.mjs.map +1 -0
- package/dist/Reveals.d.mts +43 -2
- package/dist/Reveals.d.mts.map +1 -0
- package/dist/Reveals.mjs +28 -3
- package/dist/Reveals.mjs.map +1 -0
- package/dist/Typography.d.mts +40 -2
- package/dist/Typography.d.mts.map +1 -0
- package/dist/Typography.mjs +20 -3
- package/dist/Typography.mjs.map +1 -0
- package/dist/{chunk-BWyCjowX.mjs → _virtual/_rolldown/runtime.mjs} +4 -4
- package/dist/components/atoms/Button/index.d.mts +36 -0
- package/dist/components/atoms/Button/index.d.mts.map +1 -0
- package/dist/components/atoms/Button/index.mjs +56 -0
- package/dist/components/atoms/Button/index.mjs.map +1 -0
- package/dist/components/atoms/Checkbox/Group/index.d.mts +21 -0
- package/dist/components/atoms/Checkbox/Group/index.d.mts.map +1 -0
- package/dist/components/atoms/Checkbox/Group/index.mjs +41 -0
- package/dist/components/atoms/Checkbox/Group/index.mjs.map +1 -0
- package/dist/components/atoms/Checkbox/index.d.mts +45 -0
- package/dist/components/atoms/Checkbox/index.d.mts.map +1 -0
- package/dist/components/atoms/Checkbox/index.mjs +70 -0
- package/dist/components/atoms/Checkbox/index.mjs.map +1 -0
- package/dist/components/atoms/ColorPicker/index.d.mts +18 -0
- package/dist/components/atoms/ColorPicker/index.d.mts.map +1 -0
- package/dist/components/atoms/ColorPicker/index.mjs +39 -0
- package/dist/components/atoms/ColorPicker/index.mjs.map +1 -0
- package/dist/components/atoms/FloatButton/BackTop/index.d.mts +12 -0
- package/dist/components/atoms/FloatButton/BackTop/index.d.mts.map +1 -0
- package/dist/components/atoms/FloatButton/BackTop/index.mjs +27 -0
- package/dist/components/atoms/FloatButton/BackTop/index.mjs.map +1 -0
- package/dist/components/atoms/FloatButton/index.d.mts +22 -0
- package/dist/components/atoms/FloatButton/index.d.mts.map +1 -0
- package/dist/components/atoms/FloatButton/index.mjs +19 -0
- package/dist/components/atoms/FloatButton/index.mjs.map +1 -0
- package/dist/components/atoms/Input/Search/index.d.mts +15 -0
- package/dist/components/atoms/Input/Search/index.d.mts.map +1 -0
- package/dist/components/atoms/Input/Search/index.mjs +57 -0
- package/dist/components/atoms/Input/Search/index.mjs.map +1 -0
- package/dist/components/atoms/Input/TextArea/index.d.mts +1 -0
- package/dist/components/atoms/Input/TextArea/index.mjs +18 -0
- package/dist/components/atoms/Input/TextArea/index.mjs.map +1 -0
- package/dist/components/atoms/Input/index.d.mts +31 -0
- package/dist/components/atoms/Input/index.d.mts.map +1 -0
- package/dist/components/atoms/Input/index.mjs +17 -0
- package/dist/components/atoms/Input/index.mjs.map +1 -0
- package/dist/components/atoms/Popover/index.d.mts +19 -0
- package/dist/components/atoms/Popover/index.d.mts.map +1 -0
- package/dist/components/atoms/Popover/index.mjs +229 -0
- package/dist/components/atoms/Popover/index.mjs.map +1 -0
- package/dist/components/atoms/Progress/index.d.mts +20 -0
- package/dist/components/atoms/Progress/index.d.mts.map +1 -0
- package/dist/components/atoms/Progress/index.mjs +25 -0
- package/dist/components/atoms/Progress/index.mjs.map +1 -0
- package/dist/components/atoms/Radio/Group/index.d.mts +21 -0
- package/dist/components/atoms/Radio/Group/index.d.mts.map +1 -0
- package/dist/components/atoms/Radio/Group/index.mjs +41 -0
- package/dist/components/atoms/Radio/Group/index.mjs.map +1 -0
- package/dist/components/atoms/Radio/index.d.mts +47 -0
- package/dist/components/atoms/Radio/index.d.mts.map +1 -0
- package/dist/components/atoms/Radio/index.mjs +77 -0
- package/dist/components/atoms/Radio/index.mjs.map +1 -0
- package/dist/components/atoms/Select/index.d.mts +31 -0
- package/dist/components/atoms/Select/index.d.mts.map +1 -0
- package/dist/components/atoms/Select/index.mjs +31 -0
- package/dist/components/atoms/Select/index.mjs.map +1 -0
- package/dist/components/atoms/Skeleton/Button/index.d.mts +2 -0
- package/dist/components/atoms/Skeleton/Button/index.mjs +15 -0
- package/dist/components/atoms/Skeleton/Button/index.mjs.map +1 -0
- package/dist/components/atoms/Skeleton/Node/index.d.mts +2 -0
- package/dist/components/atoms/Skeleton/Node/index.mjs +16 -0
- package/dist/components/atoms/Skeleton/Node/index.mjs.map +1 -0
- package/dist/components/atoms/Skeleton/index.d.mts +51 -0
- package/dist/components/atoms/Skeleton/index.d.mts.map +1 -0
- package/dist/components/atoms/Skeleton/index.mjs +46 -0
- package/dist/components/atoms/Skeleton/index.mjs.map +1 -0
- package/dist/components/atoms/Spin/index.d.mts +14 -0
- package/dist/components/atoms/Spin/index.d.mts.map +1 -0
- package/dist/components/atoms/Spin/index.mjs +17 -0
- package/dist/components/atoms/Spin/index.mjs.map +1 -0
- package/dist/components/atoms/Switch/index.d.mts +24 -0
- package/dist/components/atoms/Switch/index.d.mts.map +1 -0
- package/dist/components/atoms/Switch/index.mjs +32 -0
- package/dist/components/atoms/Switch/index.mjs.map +1 -0
- package/dist/components/atoms/Typography/Link/index.d.mts +12 -0
- package/dist/components/atoms/Typography/Link/index.d.mts.map +1 -0
- package/dist/components/atoms/Typography/Link/index.mjs +15 -0
- package/dist/components/atoms/Typography/Link/index.mjs.map +1 -0
- package/dist/components/atoms/Typography/Paragraph/index.d.mts +12 -0
- package/dist/components/atoms/Typography/Paragraph/index.d.mts.map +1 -0
- package/dist/components/atoms/Typography/Paragraph/index.mjs +15 -0
- package/dist/components/atoms/Typography/Paragraph/index.mjs.map +1 -0
- package/dist/components/atoms/Typography/Text/index.d.mts +17 -0
- package/dist/components/atoms/Typography/Text/index.d.mts.map +1 -0
- package/dist/components/atoms/Typography/Text/index.mjs +15 -0
- package/dist/components/atoms/Typography/Text/index.mjs.map +1 -0
- package/dist/components/atoms/Typography/Title/index.d.mts +15 -0
- package/dist/components/atoms/Typography/Title/index.d.mts.map +1 -0
- package/dist/components/atoms/Typography/Title/index.mjs +24 -0
- package/dist/components/atoms/Typography/Title/index.mjs.map +1 -0
- package/dist/components/atoms/index.d.mts +13 -0
- package/dist/components/atoms/index.mjs +15 -0
- package/dist/components/molecules/Card/index.d.mts +22 -0
- package/dist/components/molecules/Card/index.d.mts.map +1 -0
- package/dist/components/molecules/Card/index.mjs +21 -0
- package/dist/components/molecules/Card/index.mjs.map +1 -0
- package/dist/components/molecules/Collapse/index.d.mts +36 -0
- package/dist/components/molecules/Collapse/index.d.mts.map +1 -0
- package/dist/components/molecules/Collapse/index.mjs +53 -0
- package/dist/components/molecules/Collapse/index.mjs.map +1 -0
- package/dist/components/molecules/Dropdown/index.d.mts +23 -0
- package/dist/components/molecules/Dropdown/index.d.mts.map +1 -0
- package/dist/components/molecules/Dropdown/index.mjs +66 -0
- package/dist/components/molecules/Dropdown/index.mjs.map +1 -0
- package/dist/components/molecules/Marquees/Item/index.d.mts +17 -0
- package/dist/components/molecules/Marquees/Item/index.d.mts.map +1 -0
- package/dist/components/molecules/Marquees/Item/index.mjs +103 -0
- package/dist/components/molecules/Marquees/Item/index.mjs.map +1 -0
- package/dist/components/molecules/Marquees/index.d.mts +31 -0
- package/dist/components/molecules/Marquees/index.d.mts.map +1 -0
- package/dist/components/molecules/Marquees/index.mjs +63 -0
- package/dist/components/molecules/Marquees/index.mjs.map +1 -0
- package/dist/components/molecules/Menu/Item/Label/index.mjs +18 -0
- package/dist/components/molecules/Menu/Item/Label/index.mjs.map +1 -0
- package/dist/components/molecules/Menu/Item/index.mjs +122 -0
- package/dist/components/molecules/Menu/Item/index.mjs.map +1 -0
- package/dist/{index-BcxCfsJl.d.mts → components/molecules/Reveals/Item/index.d.mts} +4 -41
- package/dist/components/molecules/Reveals/Item/index.d.mts.map +1 -0
- package/dist/{Reveals-Cqo3i2hh.mjs → components/molecules/Reveals/Item/index.mjs} +5 -27
- package/dist/components/molecules/Reveals/Item/index.mjs.map +1 -0
- package/dist/components/molecules/Space/index.d.mts +34 -0
- package/dist/components/molecules/Space/index.d.mts.map +1 -0
- package/dist/components/molecules/Space/index.mjs +41 -0
- package/dist/components/molecules/Space/index.mjs.map +1 -0
- package/dist/components/molecules/index.d.mts +7 -0
- package/dist/components/molecules/index.mjs +9 -0
- package/dist/components/organisms/Drawer/index.d.mts +54 -0
- package/dist/components/organisms/Drawer/index.d.mts.map +1 -0
- package/dist/components/organisms/Drawer/index.mjs +72 -0
- package/dist/components/organisms/Drawer/index.mjs.map +1 -0
- package/dist/components/organisms/List/Item/index.mjs +15 -0
- package/dist/components/organisms/List/Item/index.mjs.map +1 -0
- package/dist/components/organisms/List/index.d.mts +52 -0
- package/dist/components/organisms/List/index.d.mts.map +1 -0
- package/dist/components/organisms/List/index.mjs +77 -0
- package/dist/components/organisms/List/index.mjs.map +1 -0
- package/dist/components/organisms/Modal/index.d.mts +66 -0
- package/dist/components/organisms/Modal/index.d.mts.map +1 -0
- package/dist/components/organisms/Modal/index.mjs +197 -0
- package/dist/components/organisms/Modal/index.mjs.map +1 -0
- package/dist/components/organisms/Swiper/Slide/index.mjs +17 -0
- package/dist/components/organisms/Swiper/Slide/index.mjs.map +1 -0
- package/dist/components/organisms/Swiper/index.d.mts +42 -0
- package/dist/components/organisms/Swiper/index.d.mts.map +1 -0
- package/dist/components/organisms/Swiper/index.mjs +58 -0
- package/dist/components/organisms/Swiper/index.mjs.map +1 -0
- package/dist/components/organisms/index.d.mts +4 -0
- package/dist/components/organisms/index.mjs +6 -0
- package/dist/components/templates/Layout/Content/index.d.mts +1 -0
- package/dist/components/templates/Layout/Content/index.mjs +15 -0
- package/dist/components/templates/Layout/Content/index.mjs.map +1 -0
- package/dist/components/templates/Layout/Footer/index.d.mts +1 -0
- package/dist/components/templates/Layout/Footer/index.mjs +15 -0
- package/dist/components/templates/Layout/Footer/index.mjs.map +1 -0
- package/dist/components/templates/Layout/Header/index.d.mts +7 -0
- package/dist/components/templates/Layout/Header/index.d.mts.map +1 -0
- package/dist/components/templates/Layout/Header/index.mjs +15 -0
- package/dist/components/templates/Layout/Header/index.mjs.map +1 -0
- package/dist/components/templates/Layout/Sider/index.d.mts +1 -0
- package/dist/components/templates/Layout/Sider/index.mjs +15 -0
- package/dist/components/templates/Layout/Sider/index.mjs.map +1 -0
- package/dist/components/templates/Layout/index.d.mts +38 -0
- package/dist/components/templates/Layout/index.d.mts.map +1 -0
- package/dist/components/templates/Layout/index.mjs +23 -0
- package/dist/components/templates/Layout/index.mjs.map +1 -0
- package/dist/components/templates/index.d.mts +1 -0
- package/dist/components/templates/index.mjs +3 -0
- package/dist/core/accordion.d.mts +32 -0
- package/dist/core/accordion.d.mts.map +1 -0
- package/dist/core/accordion.mjs +59 -0
- package/dist/core/accordion.mjs.map +1 -0
- package/dist/core/button.d.mts +26 -0
- package/dist/core/button.d.mts.map +1 -0
- package/dist/core/button.mjs +55 -0
- package/dist/core/button.mjs.map +1 -0
- package/dist/core/checkbox.d.mts +15 -0
- package/dist/core/checkbox.d.mts.map +1 -0
- package/dist/core/checkbox.mjs +34 -0
- package/dist/core/checkbox.mjs.map +1 -0
- package/dist/core/dialog.d.mts +68 -0
- package/dist/core/dialog.d.mts.map +1 -0
- package/dist/core/dialog.mjs +124 -0
- package/dist/core/dialog.mjs.map +1 -0
- package/dist/core/drawer.d.mts +60 -0
- package/dist/core/drawer.d.mts.map +1 -0
- package/dist/core/drawer.mjs +120 -0
- package/dist/core/drawer.mjs.map +1 -0
- package/dist/core/field.d.mts +68 -0
- package/dist/core/field.d.mts.map +1 -0
- package/dist/core/field.mjs +145 -0
- package/dist/core/field.mjs.map +1 -0
- package/dist/core/input.d.mts +15 -0
- package/dist/core/input.d.mts.map +1 -0
- package/dist/core/input.mjs +27 -0
- package/dist/core/input.mjs.map +1 -0
- package/dist/core/label.d.mts +15 -0
- package/dist/core/label.d.mts.map +1 -0
- package/dist/core/label.mjs +24 -0
- package/dist/core/label.mjs.map +1 -0
- package/dist/core/popover.d.mts +38 -0
- package/dist/core/popover.d.mts.map +1 -0
- package/dist/core/popover.mjs +78 -0
- package/dist/core/popover.mjs.map +1 -0
- package/dist/core/progress.d.mts +22 -0
- package/dist/core/progress.d.mts.map +1 -0
- package/dist/core/progress.mjs +29 -0
- package/dist/core/progress.mjs.map +1 -0
- package/dist/core/radio-group.d.mts +19 -0
- package/dist/core/radio-group.d.mts.map +1 -0
- package/dist/core/radio-group.mjs +43 -0
- package/dist/core/radio-group.mjs.map +1 -0
- package/dist/core/select.d.mts +56 -0
- package/dist/core/select.d.mts.map +1 -0
- package/dist/core/select.mjs +144 -0
- package/dist/core/select.mjs.map +1 -0
- package/dist/core/separator.d.mts +17 -0
- package/dist/core/separator.d.mts.map +1 -0
- package/dist/core/separator.mjs +25 -0
- package/dist/core/separator.mjs.map +1 -0
- package/dist/core/skeleton.d.mts +13 -0
- package/dist/core/skeleton.d.mts.map +1 -0
- package/dist/core/skeleton.mjs +17 -0
- package/dist/core/skeleton.mjs.map +1 -0
- package/dist/core/switch.d.mts +22 -0
- package/dist/core/switch.d.mts.map +1 -0
- package/dist/core/switch.mjs +39 -0
- package/dist/core/switch.mjs.map +1 -0
- package/dist/core/textarea.d.mts +14 -0
- package/dist/core/textarea.d.mts.map +1 -0
- package/dist/core/textarea.mjs +25 -0
- package/dist/core/textarea.mjs.map +1 -0
- package/dist/core.d.mts +17 -2
- package/dist/core.mjs +17 -5
- package/dist/enums.d.mts +2 -1
- package/dist/enums.d.mts.map +1 -0
- package/dist/enums.mjs +2 -1
- package/dist/enums.mjs.map +1 -0
- package/dist/index.d.mts +29 -714
- package/dist/index.mjs +31 -5
- package/dist/node_modules/gsap/CSSPlugin.mjs +920 -0
- package/dist/node_modules/gsap/CSSPlugin.mjs.map +1 -0
- package/dist/node_modules/gsap/gsap-core.mjs +2723 -0
- package/dist/node_modules/gsap/gsap-core.mjs.map +1 -0
- package/dist/node_modules/gsap/index.mjs +9 -0
- package/dist/node_modules/gsap/index.mjs.map +1 -0
- package/dist/{output.css → style.css} +3 -196
- package/dist/style.css.map +1 -0
- package/dist/style.mjs +1 -0
- package/dist/utils.d.mts +2 -1
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +16 -2
- package/dist/utils.mjs.map +1 -0
- package/package.json +10 -11
- package/dist/Typography-Dznhj8uL.mjs +0 -71
- package/dist/index-BC23qXS8.d.mts +0 -391
- package/dist/index-tclrN3ts.d.mts +0 -61
- package/dist/index-vBhS7Nno.d.mts +0 -75
- package/dist/src-BzCZ9O6j.css +0 -211
- package/dist/src-CS2dhz2p.mjs +0 -6160
- package/dist/utils-1s_37TSX.mjs +0 -16
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../../utils.mjs";
|
|
4
|
+
import Menu from "../../../Menu.mjs";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
8
|
+
|
|
9
|
+
//#region src/components/molecules/Dropdown/index.tsx
|
|
10
|
+
const Dropdown = ({ children, menu, trigger = "hover", open: _open, onOpenChange: _onOpenChange = () => {}, ...props }) => {
|
|
11
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
12
|
+
const controlled = _open !== void 0;
|
|
13
|
+
const open = controlled ? _open : uncontrolledOpen;
|
|
14
|
+
const isClickTrigger = trigger === "click";
|
|
15
|
+
const onOpenChange = (nextOpen) => {
|
|
16
|
+
if (!controlled) setUncontrolledOpen(nextOpen);
|
|
17
|
+
_onOpenChange(nextOpen);
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
...props,
|
|
21
|
+
className: cn("relative z-0", "inline-block cursor-pointer"),
|
|
22
|
+
onMouseEnter: () => {
|
|
23
|
+
if (isClickTrigger) return;
|
|
24
|
+
onOpenChange(true);
|
|
25
|
+
},
|
|
26
|
+
onMouseLeave: () => {
|
|
27
|
+
if (isClickTrigger) return;
|
|
28
|
+
onOpenChange(false);
|
|
29
|
+
},
|
|
30
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
31
|
+
onClick: () => {
|
|
32
|
+
if (!isClickTrigger) return;
|
|
33
|
+
onOpenChange(!open);
|
|
34
|
+
},
|
|
35
|
+
onBlur: () => {
|
|
36
|
+
onOpenChange(false);
|
|
37
|
+
},
|
|
38
|
+
children
|
|
39
|
+
}), /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(motion.div, {
|
|
40
|
+
className: cn("absolute top-full pt-2"),
|
|
41
|
+
initial: {
|
|
42
|
+
opacity: 0,
|
|
43
|
+
y: -10
|
|
44
|
+
},
|
|
45
|
+
animate: {
|
|
46
|
+
opacity: 1,
|
|
47
|
+
y: 0
|
|
48
|
+
},
|
|
49
|
+
exit: {
|
|
50
|
+
opacity: 0,
|
|
51
|
+
y: -10
|
|
52
|
+
},
|
|
53
|
+
transition: { duration: .1 },
|
|
54
|
+
children: /* @__PURE__ */ jsx(Menu, {
|
|
55
|
+
...menu,
|
|
56
|
+
onMouseDown: (e) => {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}) })]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { Dropdown as default };
|
|
66
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { cn } from '@repo/ui/utils';\n\nimport Menu, { MenuProps } from '../Menu';\n\ntype ChangeEventHandler = (open: boolean) => void;\n\ninterface Props extends React.ComponentPropsWithoutRef<'div'> {\n open?: boolean;\n trigger?: string;\n menu?: MenuProps;\n placement?: string;\n onOpenChange?: ChangeEventHandler;\n}\n\nconst Dropdown = ({\n children,\n menu,\n trigger = 'hover',\n open: _open,\n onOpenChange: _onOpenChange = () => {},\n ...props\n}: Props) => {\n const [uncontrolledOpen, setUncontrolledOpen] = useState<boolean>(false);\n\n const controlled = _open !== undefined;\n const open = controlled ? _open : uncontrolledOpen;\n\n const isClickTrigger = trigger === 'click';\n\n const onOpenChange = (nextOpen: boolean) => {\n if (!controlled) {\n setUncontrolledOpen(nextOpen);\n }\n _onOpenChange(nextOpen);\n };\n\n return (\n <div\n {...props}\n className={cn('relative z-0', 'inline-block cursor-pointer')}\n onMouseEnter={() => {\n if (isClickTrigger) {\n return;\n }\n onOpenChange(true);\n }}\n onMouseLeave={() => {\n if (isClickTrigger) {\n return;\n }\n onOpenChange(false);\n }}\n >\n <div\n onClick={() => {\n if (!isClickTrigger) {\n return;\n }\n onOpenChange(!open);\n }}\n onBlur={() => {\n onOpenChange(false);\n }}\n >\n {children}\n </div>\n <AnimatePresence>\n {open && (\n <motion.div\n className={cn(\n 'absolute top-full pt-2',\n //\n )}\n initial={{ opacity: 0, y: -10 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: -10 }}\n transition={{ duration: 0.1 }}\n >\n <Menu\n {...menu}\n onMouseDown={e => {\n e.preventDefault();\n }}\n />\n </motion.div>\n )}\n </AnimatePresence>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"mappings":";;;;;;;;;AAoBA,MAAM,YAAY,EAChB,UACA,MACA,UAAU,SACV,MAAM,OACN,cAAc,sBAAsB,IACpC,GAAG,YACQ;CACX,MAAM,CAAC,kBAAkB,uBAAuB,SAAkB,MAAM;CAExE,MAAM,aAAa,UAAU;CAC7B,MAAM,OAAO,aAAa,QAAQ;CAElC,MAAM,iBAAiB,YAAY;CAEnC,MAAM,gBAAgB,aAAsB;AAC1C,MAAI,CAAC,WACH,qBAAoB,SAAS;AAE/B,gBAAc,SAAS;;AAGzB,QACE,qBAAC;EACC,GAAI;EACJ,WAAW,GAAG,gBAAgB,8BAA8B;EAC5D,oBAAoB;AAClB,OAAI,eACF;AAEF,gBAAa,KAAK;;EAEpB,oBAAoB;AAClB,OAAI,eACF;AAEF,gBAAa,MAAM;;aAGrB,oBAAC;GACC,eAAe;AACb,QAAI,CAAC,eACH;AAEF,iBAAa,CAAC,KAAK;;GAErB,cAAc;AACZ,iBAAa,MAAM;;GAGpB;IACG,EACN,oBAAC,6BACE,QACC,oBAAC,OAAO;GACN,WAAW,GACT,yBAED;GACD,SAAS;IAAE,SAAS;IAAG,GAAG;IAAK;GAC/B,SAAS;IAAE,SAAS;IAAG,GAAG;IAAG;GAC7B,MAAM;IAAE,SAAS;IAAG,GAAG;IAAK;GAC5B,YAAY,EAAE,UAAU,IAAK;aAE7B,oBAAC;IACC,GAAI;IACJ,cAAa,MAAK;AAChB,OAAE,gBAAgB;;KAEpB;IACS,GAEC;GACd"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/components/molecules/Marquees/Item/index.d.ts
|
|
4
|
+
interface ItemProps {
|
|
5
|
+
key?: React.Key;
|
|
6
|
+
speed?: number;
|
|
7
|
+
autoFill?: boolean | number;
|
|
8
|
+
pause?: boolean;
|
|
9
|
+
pauseOnHover?: boolean;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
interface Props extends Omit<React.ComponentPropsWithoutRef<'div'>, 'key'>, ItemProps {
|
|
13
|
+
width: string | number;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ItemProps, Props };
|
|
17
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../src/components/molecules/Marquees/Item/index.tsx"],"mappings":";;;UAKiB,SAAA;EACf,GAAA,GAAM,KAAA,CAAM,GAAA;EACZ,KAAA;EACA,QAAA;EACA,KAAA;EACA,YAAA;EACA,QAAA,GAAW,KAAA,CAAM,SAAA;AAAA;AAAA,UAGF,KAAA,SACP,IAAA,CAAK,KAAA,CAAM,wBAAA,iBAAyC,SAAA;EAC5D,KAAA;AAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { gsapWithCSS } from "../../../../node_modules/gsap/index.mjs";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useGSAP } from "@gsap/react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/molecules/Marquees/Item/index.tsx
|
|
7
|
+
const Item = ({ width: _width, speed = 100, autoFill = false, pause: _pause = false, pauseOnHover = false, children }) => {
|
|
8
|
+
const itemRefs = useRef([]);
|
|
9
|
+
const containerRef = useRef(null);
|
|
10
|
+
const tweenRef = useRef(null);
|
|
11
|
+
const [width, setWidth] = useState(_width);
|
|
12
|
+
const [pause, setPause] = useState(false);
|
|
13
|
+
const [repeatCount, setRepeatCount] = useState(autoFill ? typeof autoFill === "boolean" ? 100 : autoFill : 0);
|
|
14
|
+
const isPaused = _pause || pause;
|
|
15
|
+
const hoverEvents = pauseOnHover ? {
|
|
16
|
+
onMouseEnter: () => {
|
|
17
|
+
setPause(true);
|
|
18
|
+
},
|
|
19
|
+
onMouseLeave: () => {
|
|
20
|
+
setPause(false);
|
|
21
|
+
}
|
|
22
|
+
} : {};
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!autoFill || !children || !itemRefs.current[0] || typeof width === "string") return;
|
|
25
|
+
const itemWidth = itemRefs.current[0].offsetWidth;
|
|
26
|
+
if (itemWidth >= width) {
|
|
27
|
+
setWidth(itemWidth);
|
|
28
|
+
setRepeatCount(0);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let totalWidth = 0;
|
|
32
|
+
let repeatCount = 0;
|
|
33
|
+
while (totalWidth < width) {
|
|
34
|
+
totalWidth += itemWidth;
|
|
35
|
+
repeatCount += 1;
|
|
36
|
+
}
|
|
37
|
+
setWidth(totalWidth);
|
|
38
|
+
setRepeatCount(repeatCount - 1);
|
|
39
|
+
}, [
|
|
40
|
+
autoFill,
|
|
41
|
+
width,
|
|
42
|
+
children
|
|
43
|
+
]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setWidth(_width);
|
|
46
|
+
}, [_width]);
|
|
47
|
+
useGSAP(() => {
|
|
48
|
+
if (!containerRef.current || typeof width === "string") return;
|
|
49
|
+
if (tweenRef.current) tweenRef.current.kill();
|
|
50
|
+
tweenRef.current = gsapWithCSS.fromTo(containerRef.current, { x: 0 }, {
|
|
51
|
+
x: -width,
|
|
52
|
+
duration: width / speed,
|
|
53
|
+
repeat: -1,
|
|
54
|
+
ease: "linear"
|
|
55
|
+
});
|
|
56
|
+
return () => {
|
|
57
|
+
tweenRef.current?.kill();
|
|
58
|
+
};
|
|
59
|
+
}, {
|
|
60
|
+
scope: containerRef,
|
|
61
|
+
dependencies: [width, speed]
|
|
62
|
+
});
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!tweenRef.current) return;
|
|
65
|
+
if (isPaused) tweenRef.current.pause();
|
|
66
|
+
else tweenRef.current.play();
|
|
67
|
+
}, [isPaused]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
setRepeatCount(autoFill ? typeof autoFill === "boolean" ? 100 : autoFill : 0);
|
|
70
|
+
}, [autoFill]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const onResize = () => {
|
|
73
|
+
if (!tweenRef.current || !containerRef.current) return;
|
|
74
|
+
tweenRef.current.pause();
|
|
75
|
+
};
|
|
76
|
+
window.addEventListener("resize", onResize);
|
|
77
|
+
return () => {
|
|
78
|
+
window.removeEventListener("resize", onResize);
|
|
79
|
+
};
|
|
80
|
+
}, []);
|
|
81
|
+
return /* @__PURE__ */ jsx("div", {
|
|
82
|
+
className: "flex overflow-hidden",
|
|
83
|
+
...hoverEvents,
|
|
84
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
85
|
+
ref: containerRef,
|
|
86
|
+
className: "flex flex-nowrap",
|
|
87
|
+
children: [...Array(2)].map((_, index) => /* @__PURE__ */ jsxs("div", {
|
|
88
|
+
style: { minWidth: width },
|
|
89
|
+
className: "flex flex-nowrap",
|
|
90
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
91
|
+
ref: (el) => {
|
|
92
|
+
if (el) itemRefs.current[index] = el;
|
|
93
|
+
},
|
|
94
|
+
children
|
|
95
|
+
}), [...Array(typeof autoFill === "number" ? autoFill : repeatCount)].map((_, i) => /* @__PURE__ */ jsx("div", { children }, i))]
|
|
96
|
+
}, index))
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { Item as default };
|
|
103
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["gsap"],"sources":["../../../../../src/components/molecules/Marquees/Item/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { useGSAP } from '@gsap/react';\nimport { gsap } from 'gsap';\n\nexport interface ItemProps {\n key?: React.Key;\n speed?: number;\n autoFill?: boolean | number;\n pause?: boolean;\n pauseOnHover?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface Props\n extends Omit<React.ComponentPropsWithoutRef<'div'>, 'key'>, ItemProps {\n width: string | number;\n}\n\nconst Item = ({\n width: _width,\n speed = 100,\n autoFill = false,\n pause: _pause = false,\n pauseOnHover = false,\n children,\n}: Props) => {\n const itemRefs = useRef<HTMLDivElement[]>([]);\n const containerRef = useRef<HTMLDivElement>(null);\n const tweenRef = useRef<gsap.core.Tween | null>(null);\n\n const [width, setWidth] = useState<string | number>(_width);\n const [pause, setPause] = useState(false);\n const [repeatCount, setRepeatCount] = useState(\n autoFill ? (typeof autoFill === 'boolean' ? 100 : autoFill) : 0,\n );\n\n const isPaused = _pause || pause;\n\n const hoverEvents = pauseOnHover\n ? {\n onMouseEnter: () => {\n setPause(true);\n },\n onMouseLeave: () => {\n setPause(false);\n },\n }\n : {};\n\n useEffect(() => {\n if (\n !autoFill ||\n !children ||\n !itemRefs.current[0] ||\n typeof width === 'string'\n ) {\n return;\n }\n\n const itemWidth = itemRefs.current[0].offsetWidth;\n\n if (itemWidth >= width) {\n setWidth(itemWidth);\n setRepeatCount(0);\n return;\n }\n\n let totalWidth = 0;\n let repeatCount = 0;\n\n while (totalWidth < width) {\n totalWidth += itemWidth;\n repeatCount += 1;\n }\n\n setWidth(totalWidth);\n setRepeatCount(repeatCount - 1);\n }, [autoFill, width, children]);\n\n useEffect(() => {\n setWidth(_width);\n }, [_width]);\n\n useGSAP(\n () => {\n if (!containerRef.current || typeof width === 'string') {\n return;\n }\n\n if (tweenRef.current) {\n tweenRef.current.kill();\n }\n\n tweenRef.current = gsap.fromTo(\n containerRef.current,\n { x: 0 },\n {\n x: -width,\n duration: width / speed,\n repeat: -1,\n ease: 'linear',\n },\n );\n\n return () => {\n tweenRef.current?.kill();\n };\n },\n {\n scope: containerRef,\n dependencies: [width, speed],\n },\n );\n\n useEffect(() => {\n if (!tweenRef.current) {\n return;\n }\n\n if (isPaused) {\n tweenRef.current.pause();\n } else {\n tweenRef.current.play();\n }\n }, [isPaused]);\n\n useEffect(() => {\n setRepeatCount(\n autoFill ? (typeof autoFill === 'boolean' ? 100 : autoFill) : 0,\n );\n }, [autoFill]);\n\n useEffect(() => {\n const onResize = () => {\n if (!tweenRef.current || !containerRef.current) {\n return;\n }\n tweenRef.current.pause();\n };\n\n window.addEventListener('resize', onResize);\n\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, []);\n\n return (\n <div\n className=\"flex overflow-hidden\"\n {...hoverEvents}\n //\n >\n <div ref={containerRef} className=\"flex flex-nowrap\">\n {[...Array(2)].map((_, index) => (\n <div\n key={index}\n style={{ minWidth: width }}\n className=\"flex flex-nowrap\"\n >\n <div\n ref={el => {\n if (el) {\n itemRefs.current[index] = el;\n }\n }}\n >\n {children}\n </div>\n {[\n ...Array(typeof autoFill === 'number' ? autoFill : repeatCount),\n ].map((_, i) => (\n <div key={i}>{children}</div>\n ))}\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nexport default Item;\n"],"mappings":";;;;;;AAmBA,MAAM,QAAQ,EACZ,OAAO,QACP,QAAQ,KACR,WAAW,OACX,OAAO,SAAS,OAChB,eAAe,OACf,eACW;CACX,MAAM,WAAW,OAAyB,EAAE,CAAC;CAC7C,MAAM,eAAe,OAAuB,KAAK;CACjD,MAAM,WAAW,OAA+B,KAAK;CAErD,MAAM,CAAC,OAAO,YAAY,SAA0B,OAAO;CAC3D,MAAM,CAAC,OAAO,YAAY,SAAS,MAAM;CACzC,MAAM,CAAC,aAAa,kBAAkB,SACpC,WAAY,OAAO,aAAa,YAAY,MAAM,WAAY,EAC/D;CAED,MAAM,WAAW,UAAU;CAE3B,MAAM,cAAc,eAChB;EACE,oBAAoB;AAClB,YAAS,KAAK;;EAEhB,oBAAoB;AAClB,YAAS,MAAM;;EAElB,GACD,EAAE;AAEN,iBAAgB;AACd,MACE,CAAC,YACD,CAAC,YACD,CAAC,SAAS,QAAQ,MAClB,OAAO,UAAU,SAEjB;EAGF,MAAM,YAAY,SAAS,QAAQ,GAAG;AAEtC,MAAI,aAAa,OAAO;AACtB,YAAS,UAAU;AACnB,kBAAe,EAAE;AACjB;;EAGF,IAAI,aAAa;EACjB,IAAI,cAAc;AAElB,SAAO,aAAa,OAAO;AACzB,iBAAc;AACd,kBAAe;;AAGjB,WAAS,WAAW;AACpB,iBAAe,cAAc,EAAE;IAC9B;EAAC;EAAU;EAAO;EAAS,CAAC;AAE/B,iBAAgB;AACd,WAAS,OAAO;IACf,CAAC,OAAO,CAAC;AAEZ,eACQ;AACJ,MAAI,CAAC,aAAa,WAAW,OAAO,UAAU,SAC5C;AAGF,MAAI,SAAS,QACX,UAAS,QAAQ,MAAM;AAGzB,WAAS,UAAUA,YAAK,OACtB,aAAa,SACb,EAAE,GAAG,GAAG,EACR;GACE,GAAG,CAAC;GACJ,UAAU,QAAQ;GAClB,QAAQ;GACR,MAAM;GACP,CACF;AAED,eAAa;AACX,YAAS,SAAS,MAAM;;IAG5B;EACE,OAAO;EACP,cAAc,CAAC,OAAO,MAAM;EAC7B,CACF;AAED,iBAAgB;AACd,MAAI,CAAC,SAAS,QACZ;AAGF,MAAI,SACF,UAAS,QAAQ,OAAO;MAExB,UAAS,QAAQ,MAAM;IAExB,CAAC,SAAS,CAAC;AAEd,iBAAgB;AACd,iBACE,WAAY,OAAO,aAAa,YAAY,MAAM,WAAY,EAC/D;IACA,CAAC,SAAS,CAAC;AAEd,iBAAgB;EACd,MAAM,iBAAiB;AACrB,OAAI,CAAC,SAAS,WAAW,CAAC,aAAa,QACrC;AAEF,YAAS,QAAQ,OAAO;;AAG1B,SAAO,iBAAiB,UAAU,SAAS;AAE3C,eAAa;AACX,UAAO,oBAAoB,UAAU,SAAS;;IAE/C,EAAE,CAAC;AAEN,QACE,oBAAC;EACC,WAAU;EACV,GAAI;YAGJ,oBAAC;GAAI,KAAK;GAAc,WAAU;aAC/B,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,KAAK,GAAG,UACrB,qBAAC;IAEC,OAAO,EAAE,UAAU,OAAO;IAC1B,WAAU;eAEV,oBAAC;KACC,MAAK,OAAM;AACT,UAAI,GACF,UAAS,QAAQ,SAAS;;KAI7B;MACG,EACL,CACC,GAAG,MAAM,OAAO,aAAa,WAAW,WAAW,YAAY,CAChE,CAAC,KAAK,GAAG,MACR,oBAAC,SAAa,YAAJ,EAAmB,CAC7B;MAjBG,MAkBD,CACN;IACE;GACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ItemProps, Props as Props$1 } from "./Item/index.mjs";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/molecules/Marquees/index.d.ts
|
|
5
|
+
interface Props extends React.ComponentPropsWithoutRef<'div'> {
|
|
6
|
+
speed?: number;
|
|
7
|
+
autoFill?: boolean | number;
|
|
8
|
+
pauseOnHover?: boolean;
|
|
9
|
+
items?: ItemProps[];
|
|
10
|
+
}
|
|
11
|
+
declare const Marquees: {
|
|
12
|
+
({
|
|
13
|
+
className,
|
|
14
|
+
items,
|
|
15
|
+
speed,
|
|
16
|
+
pauseOnHover,
|
|
17
|
+
autoFill,
|
|
18
|
+
...props
|
|
19
|
+
}: Props): react_jsx_runtime0.JSX.Element;
|
|
20
|
+
Item: ({
|
|
21
|
+
width: _width,
|
|
22
|
+
speed,
|
|
23
|
+
autoFill,
|
|
24
|
+
pause: _pause,
|
|
25
|
+
pauseOnHover,
|
|
26
|
+
children
|
|
27
|
+
}: Props$1) => react_jsx_runtime0.JSX.Element;
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Marquees };
|
|
31
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/components/molecules/Marquees/index.tsx"],"mappings":";;;;UAUiB,KAAA,SAAc,KAAA,CAAM,wBAAA;EACnC,KAAA;EACA,QAAA;EACA,YAAA;EACA,KAAA,GAAQ,SAAA;AAAA;AAAA,cAGJ,QAAA;EAAA;;;;;;;KAOH,KAAA,GAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../../utils.mjs";
|
|
4
|
+
import Item from "./Item/index.mjs";
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useResponsiveSize, useThrottle } from "@jbpark/use-hooks";
|
|
8
|
+
|
|
9
|
+
//#region src/components/molecules/Marquees/index.tsx
|
|
10
|
+
const Marquees = ({ className, items, speed, pauseOnHover = true, autoFill = true, ...props }) => {
|
|
11
|
+
const [width, setWidth] = useState("100vw");
|
|
12
|
+
const [padding, setPadding] = useState(0);
|
|
13
|
+
const [pause, setPause] = useState(false);
|
|
14
|
+
const throttledWidth = useThrottle(width, 200);
|
|
15
|
+
const { size } = useResponsiveSize();
|
|
16
|
+
const containerRef = useRef(null);
|
|
17
|
+
const hoverEvents = pauseOnHover ? {
|
|
18
|
+
onMouseEnter: () => {
|
|
19
|
+
setPause(true);
|
|
20
|
+
},
|
|
21
|
+
onMouseLeave: () => {
|
|
22
|
+
setPause(false);
|
|
23
|
+
}
|
|
24
|
+
} : {};
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!size.width || !containerRef.current) return;
|
|
27
|
+
const computedStyle = getComputedStyle(containerRef.current);
|
|
28
|
+
setPadding((parseFloat(computedStyle.paddingLeft) || 0) + (parseFloat(computedStyle.paddingRight) || 0));
|
|
29
|
+
setWidth(size.width);
|
|
30
|
+
}, [size]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const onScroll = () => {
|
|
33
|
+
setWidth(document.body.scrollWidth);
|
|
34
|
+
};
|
|
35
|
+
window.addEventListener("scroll", onScroll);
|
|
36
|
+
return () => {
|
|
37
|
+
window.removeEventListener("scroll", onScroll);
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
return /* @__PURE__ */ jsx("div", {
|
|
41
|
+
ref: containerRef,
|
|
42
|
+
className: cn(className),
|
|
43
|
+
...hoverEvents,
|
|
44
|
+
...props,
|
|
45
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
46
|
+
className: cn("flex flex-col gap-y-5", "overflow-hidden", "whitespace-nowrap", "bg-inherit"),
|
|
47
|
+
style: { width: typeof throttledWidth === "number" ? throttledWidth - padding : throttledWidth },
|
|
48
|
+
children: items?.map(({ children, key: itemKey, ...item }, key) => /* @__PURE__ */ jsx(Item, {
|
|
49
|
+
width: throttledWidth,
|
|
50
|
+
pause,
|
|
51
|
+
speed,
|
|
52
|
+
autoFill,
|
|
53
|
+
...item,
|
|
54
|
+
children
|
|
55
|
+
}, itemKey || key))
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
Marquees.Item = Item;
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { Marquees as default };
|
|
63
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/components/molecules/Marquees/index.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { useResponsiveSize, useThrottle } from '@jbpark/use-hooks';\n\nimport { cn } from '@repo/ui/utils';\n\nimport Item, { type ItemProps } from './Item';\n\nexport interface Props extends React.ComponentPropsWithoutRef<'div'> {\n speed?: number;\n autoFill?: boolean | number;\n pauseOnHover?: boolean;\n items?: ItemProps[];\n}\n\nconst Marquees = ({\n className,\n items,\n speed,\n pauseOnHover = true,\n autoFill = true,\n ...props\n}: Props) => {\n const [width, setWidth] = useState<string | number>(\n '100vw',\n //\n );\n const [padding, setPadding] = useState(0);\n const [pause, setPause] = useState(false);\n\n const throttledWidth = useThrottle(width, 200);\n\n const { size } = useResponsiveSize<HTMLDivElement>();\n const containerRef = useRef<HTMLDivElement | null>(null);\n const hoverEvents = pauseOnHover\n ? {\n onMouseEnter: () => {\n setPause(true);\n },\n onMouseLeave: () => {\n setPause(false);\n },\n }\n : {};\n\n useEffect(() => {\n if (!size.width || !containerRef.current) {\n return;\n }\n\n const computedStyle = getComputedStyle(containerRef.current);\n const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;\n const paddingRight = parseFloat(computedStyle.paddingRight) || 0;\n\n setPadding(paddingLeft + paddingRight);\n\n setWidth(size.width);\n }, [size]);\n\n useEffect(() => {\n const onScroll = () => {\n setWidth(document.body.scrollWidth);\n };\n\n window.addEventListener('scroll', onScroll);\n\n return () => {\n window.removeEventListener('scroll', onScroll);\n };\n }, []);\n\n return (\n <div\n ref={containerRef}\n className={cn(\n className,\n //\n )}\n {...hoverEvents}\n {...props}\n >\n <div\n className={cn(\n 'flex flex-col gap-y-5',\n 'overflow-hidden',\n 'whitespace-nowrap',\n 'bg-inherit',\n //\n )}\n style={{\n width:\n typeof throttledWidth === 'number'\n ? throttledWidth - padding\n : throttledWidth,\n }}\n >\n {items?.map(({ children, key: itemKey, ...item }: ItemProps, key) => (\n <Item\n key={itemKey || key}\n width={throttledWidth}\n pause={pause}\n speed={speed}\n autoFill={autoFill}\n {...item}\n >\n {children}\n </Item>\n ))}\n </div>\n </div>\n );\n};\n\nMarquees.Item = Item;\n\nexport { Item, type ItemProps, type Props as MarqueesProps };\n\nexport default Marquees;\n"],"mappings":";;;;;;;;;AAiBA,MAAM,YAAY,EAChB,WACA,OACA,OACA,eAAe,MACf,WAAW,MACX,GAAG,YACQ;CACX,MAAM,CAAC,OAAO,YAAY,SACxB,QAED;CACD,MAAM,CAAC,SAAS,cAAc,SAAS,EAAE;CACzC,MAAM,CAAC,OAAO,YAAY,SAAS,MAAM;CAEzC,MAAM,iBAAiB,YAAY,OAAO,IAAI;CAE9C,MAAM,EAAE,SAAS,mBAAmC;CACpD,MAAM,eAAe,OAA8B,KAAK;CACxD,MAAM,cAAc,eAChB;EACE,oBAAoB;AAClB,YAAS,KAAK;;EAEhB,oBAAoB;AAClB,YAAS,MAAM;;EAElB,GACD,EAAE;AAEN,iBAAgB;AACd,MAAI,CAAC,KAAK,SAAS,CAAC,aAAa,QAC/B;EAGF,MAAM,gBAAgB,iBAAiB,aAAa,QAAQ;AAI5D,cAHoB,WAAW,cAAc,YAAY,IAAI,MACxC,WAAW,cAAc,aAAa,IAAI,GAEzB;AAEtC,WAAS,KAAK,MAAM;IACnB,CAAC,KAAK,CAAC;AAEV,iBAAgB;EACd,MAAM,iBAAiB;AACrB,YAAS,SAAS,KAAK,YAAY;;AAGrC,SAAO,iBAAiB,UAAU,SAAS;AAE3C,eAAa;AACX,UAAO,oBAAoB,UAAU,SAAS;;IAE/C,EAAE,CAAC;AAEN,QACE,oBAAC;EACC,KAAK;EACL,WAAW,GACT,UAED;EACD,GAAI;EACJ,GAAI;YAEJ,oBAAC;GACC,WAAW,GACT,yBACA,mBACA,qBACA,aAED;GACD,OAAO,EACL,OACE,OAAO,mBAAmB,WACtB,iBAAiB,UACjB,gBACP;aAEA,OAAO,KAAK,EAAE,UAAU,KAAK,SAAS,GAAG,QAAmB,QAC3D,oBAAC;IAEC,OAAO;IACA;IACA;IACG;IACV,GAAI;IAEH;MAPI,WAAW,IAQX,CACP;IACE;GACF;;AAIV,SAAS,OAAO"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cn } from "../../../../../utils.mjs";
|
|
2
|
+
import Typography from "../../../../../Typography.mjs";
|
|
3
|
+
import "../../../../../index.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/molecules/Menu/Item/Label/index.tsx
|
|
7
|
+
const Label = ({ children, className, ...props }) => {
|
|
8
|
+
if (typeof children === "string") return /* @__PURE__ */ jsx(Typography.Text, {
|
|
9
|
+
className: cn(className),
|
|
10
|
+
...props,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
return children;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Label as default };
|
|
18
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../src/components/molecules/Menu/Item/Label/index.tsx"],"sourcesContent":["import { Typography } from '@repo/ui';\nimport { cn } from '@repo/ui/utils';\n\ninterface Props extends React.ComponentPropsWithoutRef<\n typeof Typography.Text\n> {}\n\nconst Label = ({ children, className, ...props }: Props) => {\n if (typeof children === 'string') {\n return (\n <Typography.Text className={cn(className)} {...props}>\n {children}\n </Typography.Text>\n );\n }\n\n return children;\n};\n\nexport default Label;\n"],"mappings":";;;;;;AAOA,MAAM,SAAS,EAAE,UAAU,WAAW,GAAG,YAAmB;AAC1D,KAAI,OAAO,aAAa,SACtB,QACE,oBAAC,WAAW;EAAK,WAAW,GAAG,UAAU;EAAE,GAAI;EAC5C;GACe;AAItB,QAAO"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { cn } from "../../../../utils.mjs";
|
|
2
|
+
import Label from "./Label/index.mjs";
|
|
3
|
+
import { MENU_CLASSNAMES } from "../../../../Menu.mjs";
|
|
4
|
+
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { createElement, useRef, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
8
|
+
|
|
9
|
+
//#region src/components/molecules/Menu/Item/index.tsx
|
|
10
|
+
const OFFSET = [8, 8];
|
|
11
|
+
const INLINE_OFFSET = 16;
|
|
12
|
+
const STYLES = {
|
|
13
|
+
hover: { classes: ["hover:underline", "hover:underline-offset-8"] },
|
|
14
|
+
open: { classes: ["underline", "underline-offset-8"] }
|
|
15
|
+
};
|
|
16
|
+
const getItemClasses = (root, isHorizontal, isInline, hasChildren, customClasses) => cn("px-4 py-2", "cursor-pointer", "whitespace-nowrap", root && isHorizontal ? "inline-flex" : "flex", ...root ? [
|
|
17
|
+
"h-full",
|
|
18
|
+
"rounded-none border-transparent",
|
|
19
|
+
hasChildren && "hover:border-current",
|
|
20
|
+
isHorizontal ? "border-b-2" : "border-r-2",
|
|
21
|
+
isInline && "border-none"
|
|
22
|
+
] : ["rounded-md", ...STYLES.hover.classes], customClasses);
|
|
23
|
+
const Item = ({ itemKey, keyPath, root = false, mode, label, children, selectedKeys = [], selectionMap, classNames, styles, offset = OFFSET, inlineOffset = INLINE_OFFSET, onClick, onSelect, ...props }) => {
|
|
24
|
+
const [open, setOpen] = useState(false);
|
|
25
|
+
const itemRef = useRef(null);
|
|
26
|
+
const isHorizontal = mode === "horizontal";
|
|
27
|
+
const isInline = mode === "inline";
|
|
28
|
+
const [left, top] = offset;
|
|
29
|
+
const selected = selectionMap?.get(itemKey) ?? false;
|
|
30
|
+
const item = {
|
|
31
|
+
...props,
|
|
32
|
+
label,
|
|
33
|
+
key: itemKey,
|
|
34
|
+
children
|
|
35
|
+
};
|
|
36
|
+
const itemClassNames = getItemClasses(root, isHorizontal, isInline, !!children?.length, root ? classNames?.rootItem : classNames?.item);
|
|
37
|
+
const childrenContainerClassNames = cn(isInline ? "relative overflow-hidden" : "absolute min-w-[200px]", !isInline && root && isHorizontal ? "left-0 top-full pt-2 pl-0" : !isInline ? "left-full top-0 pl-2 pt-0" : "pl-4");
|
|
38
|
+
const childrenContainerStyle = isInline ? { paddingLeft: inlineOffset } : root && isHorizontal ? { paddingTop: top } : { paddingLeft: left };
|
|
39
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
40
|
+
ref: itemRef,
|
|
41
|
+
className: cn("group", "relative", root && isHorizontal ? "inline-block" : "block"),
|
|
42
|
+
onMouseEnter: () => {
|
|
43
|
+
if (isInline) return;
|
|
44
|
+
setOpen(true);
|
|
45
|
+
},
|
|
46
|
+
onMouseLeave: () => {
|
|
47
|
+
if (isInline) return;
|
|
48
|
+
setOpen(false);
|
|
49
|
+
},
|
|
50
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
51
|
+
role: "menuitem",
|
|
52
|
+
"aria-expanded": children?.length ? open : void 0,
|
|
53
|
+
"aria-haspopup": children?.length ? "menu" : void 0,
|
|
54
|
+
"aria-selected": selected,
|
|
55
|
+
className: cn(itemClassNames, ...selected ? root ? ["border-current"] : [...STYLES.open.classes, ...STYLES.hover.classes] : root && !!children?.length ? ["group-hover:border-current"] : []),
|
|
56
|
+
style: root ? styles?.rootItem : styles?.item,
|
|
57
|
+
onClick: (e) => {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
if (isInline) setOpen(!open);
|
|
60
|
+
const params = {
|
|
61
|
+
domEvent: e,
|
|
62
|
+
key: itemKey,
|
|
63
|
+
keyPath,
|
|
64
|
+
item
|
|
65
|
+
};
|
|
66
|
+
onClick?.(params);
|
|
67
|
+
if (!selected) onSelect?.(params);
|
|
68
|
+
},
|
|
69
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
70
|
+
className: cn("w-full", "inline-flex items-center justify-between"),
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx(Label, {
|
|
73
|
+
className: cn(classNames?.label),
|
|
74
|
+
style: styles?.label,
|
|
75
|
+
children: label
|
|
76
|
+
}),
|
|
77
|
+
!root && !isInline && !!children?.length && /* @__PURE__ */ jsx(ChevronDown, { className: cn("-rotate-90") }),
|
|
78
|
+
isInline && !!children?.length && /* @__PURE__ */ jsx(ChevronDown, { className: cn("transition-all", open ? "-rotate-180" : "rotate-0") })
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
}), /* @__PURE__ */ jsx(AnimatePresence, { children: !!children?.length && open && /* @__PURE__ */ jsx(motion.div, {
|
|
82
|
+
className: cn(childrenContainerClassNames),
|
|
83
|
+
style: childrenContainerStyle,
|
|
84
|
+
initial: isInline ? {
|
|
85
|
+
height: 0,
|
|
86
|
+
opacity: 0
|
|
87
|
+
} : { opacity: 0 },
|
|
88
|
+
animate: isInline ? {
|
|
89
|
+
height: "auto",
|
|
90
|
+
opacity: 1
|
|
91
|
+
} : { opacity: 1 },
|
|
92
|
+
exit: isInline ? {
|
|
93
|
+
height: 0,
|
|
94
|
+
opacity: 0
|
|
95
|
+
} : { opacity: 0 },
|
|
96
|
+
transition: { duration: .2 },
|
|
97
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
98
|
+
className: cn(MENU_CLASSNAMES, isInline && "shadow-none", classNames?.subMenu),
|
|
99
|
+
style: styles?.subMenu,
|
|
100
|
+
children: children.map((child) => /* @__PURE__ */ createElement(Item, {
|
|
101
|
+
...child,
|
|
102
|
+
key: child.key,
|
|
103
|
+
itemKey: child.key,
|
|
104
|
+
keyPath: [...keyPath, child.key],
|
|
105
|
+
selectionMap,
|
|
106
|
+
mode,
|
|
107
|
+
selectedKeys,
|
|
108
|
+
classNames,
|
|
109
|
+
styles,
|
|
110
|
+
offset,
|
|
111
|
+
inlineOffset,
|
|
112
|
+
onClick,
|
|
113
|
+
onSelect
|
|
114
|
+
}))
|
|
115
|
+
})
|
|
116
|
+
}) })]
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { Item as default };
|
|
122
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/components/molecules/Menu/Item/index.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\n\nimport { ChevronDown } from 'lucide-react';\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { cn } from '@repo/ui/utils';\n\nimport { MENU_CLASSNAMES, MenuItem, Props } from '..';\nimport Label from './Label';\n\ninterface ItemProps extends Props, MenuItem {\n itemKey: React.Key;\n keyPath: React.Key[];\n root?: boolean;\n}\nconst OFFSET: [number, number] = [8, 8];\nconst INLINE_OFFSET = 16;\n\nconst STYLES = {\n hover: {\n classes: ['hover:underline', 'hover:underline-offset-8'],\n },\n open: {\n classes: ['underline', 'underline-offset-8'],\n },\n} as const;\n\nconst getItemClasses = (\n root: boolean,\n isHorizontal: boolean,\n isInline: boolean,\n hasChildren: boolean,\n customClasses?: string,\n) =>\n cn(\n 'px-4 py-2',\n 'cursor-pointer',\n 'whitespace-nowrap',\n root && isHorizontal ? 'inline-flex' : 'flex',\n ...(root\n ? [\n 'h-full',\n 'rounded-none border-transparent',\n hasChildren && 'hover:border-current',\n isHorizontal ? 'border-b-2' : 'border-r-2',\n isInline && 'border-none',\n ]\n : ['rounded-md', ...STYLES.hover.classes]),\n customClasses,\n );\n\nconst Item = ({\n itemKey,\n keyPath,\n root = false,\n mode,\n label,\n children,\n selectedKeys = [],\n selectionMap,\n classNames,\n styles,\n offset = OFFSET,\n inlineOffset = INLINE_OFFSET,\n onClick,\n onSelect,\n ...props\n}: ItemProps) => {\n const [open, setOpen] = useState<boolean>(false);\n\n const itemRef = useRef<HTMLLIElement | null>(null);\n\n const isHorizontal = mode === 'horizontal';\n const isInline = mode === 'inline';\n\n const [left, top] = offset;\n\n const selected = selectionMap?.get(itemKey) ?? false;\n\n const item = {\n ...props,\n label,\n key: itemKey,\n children,\n };\n\n const itemClassNames = getItemClasses(\n root,\n isHorizontal,\n isInline,\n !!children?.length,\n root ? classNames?.rootItem : classNames?.item,\n );\n\n const childrenContainerClassNames = cn(\n isInline ? 'relative overflow-hidden' : 'absolute min-w-[200px]',\n !isInline && root && isHorizontal\n ? 'left-0 top-full pt-2 pl-0'\n : !isInline\n ? 'left-full top-0 pl-2 pt-0'\n : 'pl-4',\n );\n\n const childrenContainerStyle = isInline\n ? {\n paddingLeft: inlineOffset,\n }\n : root && isHorizontal\n ? {\n paddingTop: top,\n }\n : {\n paddingLeft: left,\n };\n\n return (\n <li\n ref={itemRef}\n className={cn(\n 'group',\n 'relative',\n root && isHorizontal ? 'inline-block' : 'block',\n )}\n onMouseEnter={() => {\n if (isInline) {\n return;\n }\n setOpen(true);\n }}\n onMouseLeave={() => {\n if (isInline) {\n return;\n }\n setOpen(false);\n }}\n >\n <div\n role=\"menuitem\"\n aria-expanded={children?.length ? open : undefined}\n aria-haspopup={children?.length ? 'menu' : undefined}\n aria-selected={selected}\n className={cn(\n itemClassNames,\n ...(selected\n ? root\n ? ['border-current']\n : [...STYLES.open.classes, ...STYLES.hover.classes]\n : root && !!children?.length\n ? ['group-hover:border-current']\n : []),\n //\n )}\n style={root ? styles?.rootItem : styles?.item}\n onClick={e => {\n e.stopPropagation();\n\n if (isInline) {\n setOpen(!open);\n }\n\n const params = {\n domEvent: e,\n key: itemKey,\n keyPath,\n item,\n };\n\n onClick?.(params);\n\n if (!selected) {\n onSelect?.(params);\n }\n }}\n >\n <div\n className={cn(\n 'w-full',\n 'inline-flex items-center justify-between',\n //\n )}\n >\n <Label className={cn(classNames?.label)} style={styles?.label}>\n {label}\n </Label>\n {!root && !isInline && !!children?.length && (\n <ChevronDown className={cn('-rotate-90')} />\n )}\n {isInline && !!children?.length && (\n <ChevronDown\n className={cn(\n 'transition-all',\n open ? '-rotate-180' : 'rotate-0',\n )}\n />\n )}\n </div>\n </div>\n <AnimatePresence>\n {!!children?.length && open && (\n <motion.div\n className={cn(\n childrenContainerClassNames,\n //\n )}\n style={childrenContainerStyle}\n initial={isInline ? { height: 0, opacity: 0 } : { opacity: 0 }}\n animate={isInline ? { height: 'auto', opacity: 1 } : { opacity: 1 }}\n exit={isInline ? { height: 0, opacity: 0 } : { opacity: 0 }}\n transition={{ duration: 0.2 }}\n >\n <ul\n className={cn(\n MENU_CLASSNAMES,\n isInline && 'shadow-none',\n classNames?.subMenu,\n //\n )}\n style={styles?.subMenu}\n >\n {children.map(child => (\n <Item\n {...child}\n key={child.key}\n itemKey={child.key}\n keyPath={[...keyPath, child.key]}\n selectionMap={selectionMap}\n mode={mode}\n selectedKeys={selectedKeys}\n classNames={classNames}\n styles={styles}\n offset={offset}\n inlineOffset={inlineOffset}\n onClick={onClick}\n onSelect={onSelect}\n />\n ))}\n </ul>\n </motion.div>\n )}\n </AnimatePresence>\n </li>\n );\n};\n\nexport default Item;\n"],"mappings":";;;;;;;;;AAeA,MAAM,SAA2B,CAAC,GAAG,EAAE;AACvC,MAAM,gBAAgB;AAEtB,MAAM,SAAS;CACb,OAAO,EACL,SAAS,CAAC,mBAAmB,2BAA2B,EACzD;CACD,MAAM,EACJ,SAAS,CAAC,aAAa,qBAAqB,EAC7C;CACF;AAED,MAAM,kBACJ,MACA,cACA,UACA,aACA,kBAEA,GACE,aACA,kBACA,qBACA,QAAQ,eAAe,gBAAgB,QACvC,GAAI,OACA;CACE;CACA;CACA,eAAe;CACf,eAAe,eAAe;CAC9B,YAAY;CACb,GACD,CAAC,cAAc,GAAG,OAAO,MAAM,QAAQ,EAC3C,cACD;AAEH,MAAM,QAAQ,EACZ,SACA,SACA,OAAO,OACP,MACA,OACA,UACA,eAAe,EAAE,EACjB,cACA,YACA,QACA,SAAS,QACT,eAAe,eACf,SACA,UACA,GAAG,YACY;CACf,MAAM,CAAC,MAAM,WAAW,SAAkB,MAAM;CAEhD,MAAM,UAAU,OAA6B,KAAK;CAElD,MAAM,eAAe,SAAS;CAC9B,MAAM,WAAW,SAAS;CAE1B,MAAM,CAAC,MAAM,OAAO;CAEpB,MAAM,WAAW,cAAc,IAAI,QAAQ,IAAI;CAE/C,MAAM,OAAO;EACX,GAAG;EACH;EACA,KAAK;EACL;EACD;CAED,MAAM,iBAAiB,eACrB,MACA,cACA,UACA,CAAC,CAAC,UAAU,QACZ,OAAO,YAAY,WAAW,YAAY,KAC3C;CAED,MAAM,8BAA8B,GAClC,WAAW,6BAA6B,0BACxC,CAAC,YAAY,QAAQ,eACjB,8BACA,CAAC,WACC,8BACA,OACP;CAED,MAAM,yBAAyB,WAC3B,EACE,aAAa,cACd,GACD,QAAQ,eACN,EACE,YAAY,KACb,GACD,EACE,aAAa,MACd;AAEP,QACE,qBAAC;EACC,KAAK;EACL,WAAW,GACT,SACA,YACA,QAAQ,eAAe,iBAAiB,QACzC;EACD,oBAAoB;AAClB,OAAI,SACF;AAEF,WAAQ,KAAK;;EAEf,oBAAoB;AAClB,OAAI,SACF;AAEF,WAAQ,MAAM;;aAGhB,oBAAC;GACC,MAAK;GACL,iBAAe,UAAU,SAAS,OAAO;GACzC,iBAAe,UAAU,SAAS,SAAS;GAC3C,iBAAe;GACf,WAAW,GACT,gBACA,GAAI,WACA,OACE,CAAC,iBAAiB,GAClB,CAAC,GAAG,OAAO,KAAK,SAAS,GAAG,OAAO,MAAM,QAAQ,GACnD,QAAQ,CAAC,CAAC,UAAU,SAClB,CAAC,6BAA6B,GAC9B,EAAE,CAET;GACD,OAAO,OAAO,QAAQ,WAAW,QAAQ;GACzC,UAAS,MAAK;AACZ,MAAE,iBAAiB;AAEnB,QAAI,SACF,SAAQ,CAAC,KAAK;IAGhB,MAAM,SAAS;KACb,UAAU;KACV,KAAK;KACL;KACA;KACD;AAED,cAAU,OAAO;AAEjB,QAAI,CAAC,SACH,YAAW,OAAO;;aAItB,qBAAC;IACC,WAAW,GACT,UACA,2CAED;;KAED,oBAAC;MAAM,WAAW,GAAG,YAAY,MAAM;MAAE,OAAO,QAAQ;gBACrD;OACK;KACP,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,UAAU,UACjC,oBAAC,eAAY,WAAW,GAAG,aAAa,GAAI;KAE7C,YAAY,CAAC,CAAC,UAAU,UACvB,oBAAC,eACC,WAAW,GACT,kBACA,OAAO,gBAAgB,WACxB,GACD;;KAEA;IACF,EACN,oBAAC,6BACE,CAAC,CAAC,UAAU,UAAU,QACrB,oBAAC,OAAO;GACN,WAAW,GACT,4BAED;GACD,OAAO;GACP,SAAS,WAAW;IAAE,QAAQ;IAAG,SAAS;IAAG,GAAG,EAAE,SAAS,GAAG;GAC9D,SAAS,WAAW;IAAE,QAAQ;IAAQ,SAAS;IAAG,GAAG,EAAE,SAAS,GAAG;GACnE,MAAM,WAAW;IAAE,QAAQ;IAAG,SAAS;IAAG,GAAG,EAAE,SAAS,GAAG;GAC3D,YAAY,EAAE,UAAU,IAAK;aAE7B,oBAAC;IACC,WAAW,GACT,iBACA,YAAY,eACZ,YAAY,QAEb;IACD,OAAO,QAAQ;cAEd,SAAS,KAAI,UACZ,8BAAC;KACC,GAAI;KACJ,KAAK,MAAM;KACX,SAAS,MAAM;KACf,SAAS,CAAC,GAAG,SAAS,MAAM,IAAI;KAClB;KACR;KACQ;KACF;KACJ;KACA;KACM;KACL;KACC;MACV,CACF;KACC;IACM,GAEC;GACf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
import { MotionProps } from "motion/react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/molecules/Reveals/Item/index.d.ts
|
|
@@ -54,44 +54,7 @@ declare const Item: ({
|
|
|
54
54
|
transition,
|
|
55
55
|
className,
|
|
56
56
|
...props
|
|
57
|
-
}: ItemProps) =>
|
|
57
|
+
}: ItemProps) => react_jsx_runtime0.JSX.Element;
|
|
58
58
|
//#endregion
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
cascade?: number;
|
|
62
|
-
classNames?: {
|
|
63
|
-
root?: string;
|
|
64
|
-
item?: string;
|
|
65
|
-
};
|
|
66
|
-
once?: boolean;
|
|
67
|
-
items?: ItemProps[];
|
|
68
|
-
}
|
|
69
|
-
declare const DURATION = 0.6;
|
|
70
|
-
declare const DELAY = 0;
|
|
71
|
-
declare const CASCADE = 0.1;
|
|
72
|
-
declare const Reveals: {
|
|
73
|
-
({
|
|
74
|
-
children,
|
|
75
|
-
className,
|
|
76
|
-
classNames,
|
|
77
|
-
items,
|
|
78
|
-
cascade,
|
|
79
|
-
duration,
|
|
80
|
-
delay,
|
|
81
|
-
...props
|
|
82
|
-
}: Props): react_jsx_runtime11.JSX.Element;
|
|
83
|
-
Item: ({
|
|
84
|
-
effect,
|
|
85
|
-
children,
|
|
86
|
-
once,
|
|
87
|
-
viewport,
|
|
88
|
-
variants,
|
|
89
|
-
duration,
|
|
90
|
-
delay,
|
|
91
|
-
transition,
|
|
92
|
-
className,
|
|
93
|
-
...props
|
|
94
|
-
}: ItemProps) => react_jsx_runtime11.JSX.Element;
|
|
95
|
-
};
|
|
96
|
-
//#endregion
|
|
97
|
-
export { Reveals as a, Props as i, DELAY as n, Item as o, DURATION as r, ItemProps as s, CASCADE as t };
|
|
59
|
+
export { Item, ItemProps };
|
|
60
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../src/components/molecules/Reveals/Item/index.tsx"],"mappings":";;;;cAMM,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAeW,SAAA;EACf,MAAA,gBAAsB,cAAA;EACtB,KAAA;EACA,IAAA;EACA,QAAA;EACA,SAAA;EACA,QAAA,GAAW,KAAA,CAAM,SAAA;EACjB,QAAA,GAAW,WAAA;EACX,QAAA,GAAW,WAAA;EACX,UAAA,GAAa,WAAA;AAAA;AAAA,cAGT,IAAA;EAAQ,MAAA;EAAA,QAAA;EAAA,IAAA;EAAA,QAAA;EAAA,QAAA;EAAA,QAAA;EAAA,KAAA;EAAA,UAAA;EAAA,SAAA;EAAA,GAAA;AAAA,GAWX,SAAA,KAAS,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../../../utils.mjs";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { motion } from "motion/react";
|
|
5
6
|
|
|
@@ -60,30 +61,7 @@ const Item = ({ effect = "fadeInUp", children, once, viewport, variants, duratio
|
|
|
60
61
|
children
|
|
61
62
|
});
|
|
62
63
|
};
|
|
63
|
-
var Item_default = Item;
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/components/molecules/Reveals/index.tsx
|
|
67
|
-
const DURATION = .6;
|
|
68
|
-
const DELAY = 0;
|
|
69
|
-
const CASCADE = .1;
|
|
70
|
-
const Reveals = ({ children, className, classNames, items = [], cascade = CASCADE, duration = DURATION, delay = DELAY, ...props }) => {
|
|
71
|
-
const renderItems = (items$1) => items$1.map((item, index) => /* @__PURE__ */ jsx(Item_default, {
|
|
72
|
-
duration,
|
|
73
|
-
delay: delay + cascade * index,
|
|
74
|
-
className: cn(item.className, classNames?.item),
|
|
75
|
-
...props,
|
|
76
|
-
...item,
|
|
77
|
-
children: item.children
|
|
78
|
-
}, index));
|
|
79
|
-
return /* @__PURE__ */ jsx("div", {
|
|
80
|
-
className: cn("flex gap-5", className, classNames?.root),
|
|
81
|
-
...props,
|
|
82
|
-
children: renderItems(children ? Children.toArray(children).map((child) => ({ children: child })) : items)
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
Reveals.Item = Item_default;
|
|
86
|
-
var Reveals_default = Reveals;
|
|
87
64
|
|
|
88
65
|
//#endregion
|
|
89
|
-
export {
|
|
66
|
+
export { Item as default };
|
|
67
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/components/molecules/Reveals/Item/index.tsx"],"sourcesContent":["'use client';\n\nimport { type MotionProps, motion } from 'motion/react';\n\nimport { cn } from '@repo/ui/utils';\n\nconst effectVariants = {\n fadeIn: {\n offscreen: { opacity: 0 },\n onscreen: { opacity: 1 },\n },\n fadeInUp: {\n offscreen: { opacity: 0, y: 50 },\n onscreen: { opacity: 1, y: 0 },\n },\n slideInUp: {\n offscreen: { opacity: 1, y: 50 },\n onscreen: { opacity: 1, y: 0 },\n },\n};\n\nexport interface ItemProps {\n effect?: keyof typeof effectVariants;\n delay?: number;\n once?: boolean;\n duration?: number;\n className?: string;\n children?: React.ReactNode;\n viewport?: MotionProps['viewport'];\n variants?: MotionProps['variants'];\n transition?: MotionProps['transition'];\n}\n\nconst Item = ({\n effect = 'fadeInUp',\n children,\n once,\n viewport,\n variants,\n duration,\n delay,\n transition,\n className,\n ...props\n}: ItemProps) => {\n return (\n <motion.div\n initial=\"offscreen\"\n whileInView=\"onscreen\"\n viewport={{ once, ...viewport }}\n variants={{\n offscreen: {\n ...effectVariants[effect].offscreen,\n ...variants?.offscreen,\n transition: {\n duration: 0,\n },\n },\n onscreen: {\n ...effectVariants[effect].onscreen,\n ...variants?.onscreen,\n transition: {\n duration,\n ease: 'easeOut',\n delay,\n ...transition,\n },\n },\n }}\n className={cn(\n 'flex h-full items-center justify-center',\n className,\n //\n )}\n {...props}\n >\n {children}\n </motion.div>\n );\n};\n\nexport default Item;\n"],"mappings":";;;;;;;AAMA,MAAM,iBAAiB;CACrB,QAAQ;EACN,WAAW,EAAE,SAAS,GAAG;EACzB,UAAU,EAAE,SAAS,GAAG;EACzB;CACD,UAAU;EACR,WAAW;GAAE,SAAS;GAAG,GAAG;GAAI;EAChC,UAAU;GAAE,SAAS;GAAG,GAAG;GAAG;EAC/B;CACD,WAAW;EACT,WAAW;GAAE,SAAS;GAAG,GAAG;GAAI;EAChC,UAAU;GAAE,SAAS;GAAG,GAAG;GAAG;EAC/B;CACF;AAcD,MAAM,QAAQ,EACZ,SAAS,YACT,UACA,MACA,UACA,UACA,UACA,OACA,YACA,WACA,GAAG,YACY;AACf,QACE,oBAAC,OAAO;EACN,SAAQ;EACR,aAAY;EACZ,UAAU;GAAE;GAAM,GAAG;GAAU;EAC/B,UAAU;GACR,WAAW;IACT,GAAG,eAAe,QAAQ;IAC1B,GAAG,UAAU;IACb,YAAY,EACV,UAAU,GACX;IACF;GACD,UAAU;IACR,GAAG,eAAe,QAAQ;IAC1B,GAAG,UAAU;IACb,YAAY;KACV;KACA,MAAM;KACN;KACA,GAAG;KACJ;IACF;GACF;EACD,WAAW,GACT,2CACA,UAED;EACD,GAAI;EAEH;GACU"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/components/molecules/Space/index.d.ts
|
|
4
|
+
interface Props extends React.ComponentPropsWithRef<'div'> {
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
loader?: React.ReactNode;
|
|
7
|
+
orientation?: 'horizontal' | 'vertical';
|
|
8
|
+
size?: 'small' | 'middle' | 'large' | number | number[];
|
|
9
|
+
align?: 'start' | 'end' | 'center' | 'baseline';
|
|
10
|
+
wrap?: boolean;
|
|
11
|
+
split?: React.ReactNode;
|
|
12
|
+
grid?: {
|
|
13
|
+
rows?: number;
|
|
14
|
+
cols?: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
declare const Space: ({
|
|
18
|
+
loading,
|
|
19
|
+
loader,
|
|
20
|
+
children,
|
|
21
|
+
size,
|
|
22
|
+
orientation,
|
|
23
|
+
align,
|
|
24
|
+
wrap,
|
|
25
|
+
split,
|
|
26
|
+
className,
|
|
27
|
+
grid,
|
|
28
|
+
hidden,
|
|
29
|
+
style,
|
|
30
|
+
...props
|
|
31
|
+
}: Props) => react_jsx_runtime0.JSX.Element;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Space };
|
|
34
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/components/molecules/Space/index.tsx"],"mappings":";;;UAMU,KAAA,SAAc,KAAA,CAAM,qBAAA;EAC5B,OAAA;EACA,MAAA,GAAS,KAAA,CAAM,SAAA;EACf,WAAA;EACA,IAAA;EACA,KAAA;EACA,IAAA;EACA,KAAA,GAAQ,KAAA,CAAM,SAAA;EACd,IAAA;IACE,IAAA;IACA,IAAA;EAAA;AAAA;AAAA,cAiBE,KAAA;EAAS,OAAA;EAAA,MAAA;EAAA,QAAA;EAAA,IAAA;EAAA,WAAA;EAAA,KAAA;EAAA,IAAA;EAAA,KAAA;EAAA,SAAA;EAAA,IAAA;EAAA,MAAA;EAAA,KAAA;EAAA,GAAA;AAAA,GAcZ,KAAA,KAAK,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|