@mks2508/mks-ui 0.1.2 → 0.1.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.
Files changed (92) hide show
  1. package/README.md +96 -60
  2. package/dist/components/animate-ui/primitives/animate/slot.js +1 -1
  3. package/dist/components/animate-ui/primitives/base/accordion.js +132 -0
  4. package/dist/components/animate-ui/primitives/base/alert-dialog.js +132 -0
  5. package/dist/components/animate-ui/primitives/base/checkbox.js +101 -0
  6. package/dist/components/animate-ui/primitives/base/dialog.js +132 -0
  7. package/dist/components/animate-ui/primitives/base/menu.js +266 -0
  8. package/dist/components/animate-ui/primitives/base/popover.js +109 -0
  9. package/dist/components/animate-ui/primitives/base/progress.d.ts +14 -14
  10. package/dist/components/animate-ui/primitives/base/progress.js +63 -0
  11. package/dist/components/animate-ui/primitives/base/switch.js +1 -1
  12. package/dist/components/animate-ui/primitives/base/tabs.js +1 -1
  13. package/dist/components/animate-ui/primitives/base/tooltip.js +116 -0
  14. package/dist/components/animate-ui/primitives/effects/auto-height.js +1 -1
  15. package/dist/components/animate-ui/primitives/effects/highlight.js +2 -2
  16. package/dist/components/animate-ui/primitives/texts/counting-number.js +78 -0
  17. package/dist/components/ui/accordion.d.ts +9 -0
  18. package/dist/components/ui/accordion.d.ts.map +1 -0
  19. package/dist/components/ui/accordion.js +1 -0
  20. package/dist/components/ui/alert-dialog.d.ts +8 -20
  21. package/dist/components/ui/alert-dialog.d.ts.map +1 -1
  22. package/dist/components/ui/alert-dialog.js +1 -99
  23. package/dist/components/ui/auto-height.d.ts +9 -0
  24. package/dist/components/ui/auto-height.d.ts.map +1 -0
  25. package/dist/components/ui/auto-height.js +1 -0
  26. package/dist/components/ui/badge/badge.styles.d.ts +1 -1
  27. package/dist/components/ui/button/button.js +1 -1
  28. package/dist/components/ui/button/button.styles.d.ts +2 -2
  29. package/dist/components/ui/card.js +1 -1
  30. package/dist/components/ui/checkbox.d.ts +9 -0
  31. package/dist/components/ui/checkbox.d.ts.map +1 -0
  32. package/dist/components/ui/checkbox.js +1 -0
  33. package/dist/components/ui/corner-bracket.d.ts +34 -0
  34. package/dist/components/ui/corner-bracket.d.ts.map +1 -0
  35. package/dist/components/ui/{devenv-bracket.js → corner-bracket.js} +13 -9
  36. package/dist/components/ui/counting-number.d.ts +9 -0
  37. package/dist/components/ui/counting-number.d.ts.map +1 -0
  38. package/dist/components/ui/counting-number.js +1 -0
  39. package/dist/components/ui/dialog.d.ts +9 -0
  40. package/dist/components/ui/dialog.d.ts.map +1 -0
  41. package/dist/components/ui/dialog.js +1 -0
  42. package/dist/components/ui/field.js +1 -1
  43. package/dist/components/ui/highlight.d.ts +9 -0
  44. package/dist/components/ui/highlight.d.ts.map +1 -0
  45. package/dist/components/ui/highlight.js +1 -0
  46. package/dist/components/ui/index.d.ts +14 -3
  47. package/dist/components/ui/index.d.ts.map +1 -1
  48. package/dist/components/ui/index.js +32 -9
  49. package/dist/components/ui/input-group.js +1 -1
  50. package/dist/components/ui/menu.d.ts +9 -0
  51. package/dist/components/ui/menu.d.ts.map +1 -0
  52. package/dist/components/ui/menu.js +1 -0
  53. package/dist/components/ui/popover.d.ts +9 -0
  54. package/dist/components/ui/popover.d.ts.map +1 -0
  55. package/dist/components/ui/popover.js +1 -0
  56. package/dist/components/ui/progress.d.ts +9 -0
  57. package/dist/components/ui/progress.d.ts.map +1 -0
  58. package/dist/components/ui/progress.js +1 -0
  59. package/dist/components/ui/slot.d.ts +9 -0
  60. package/dist/components/ui/slot.d.ts.map +1 -0
  61. package/dist/components/ui/slot.js +1 -0
  62. package/dist/components/ui/tooltip.d.ts +9 -0
  63. package/dist/components/ui/tooltip.d.ts.map +1 -0
  64. package/dist/components/ui/tooltip.js +1 -0
  65. package/dist/hooks/index.d.ts +10 -0
  66. package/dist/hooks/index.d.ts.map +1 -0
  67. package/dist/hooks/index.js +4 -0
  68. package/dist/hooks/use-data-state.js +42 -0
  69. package/dist/hooks/use-is-in-view.js +20 -0
  70. package/dist/index.d.ts +4 -3
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +23 -7
  73. package/package.json +4 -8
  74. package/src/components/ui/accordion.tsx +9 -0
  75. package/src/components/ui/alert-dialog.tsx +9 -177
  76. package/src/components/ui/auto-height.tsx +9 -0
  77. package/src/components/ui/checkbox.tsx +9 -0
  78. package/src/components/ui/{devenv-bracket.tsx → corner-bracket.tsx} +12 -8
  79. package/src/components/ui/counting-number.tsx +9 -0
  80. package/src/components/ui/dialog.tsx +9 -0
  81. package/src/components/ui/highlight.tsx +9 -0
  82. package/src/components/ui/index.ts +20 -5
  83. package/src/components/ui/menu.tsx +9 -0
  84. package/src/components/ui/popover.tsx +9 -0
  85. package/src/components/ui/progress.tsx +9 -0
  86. package/src/components/ui/slot.tsx +9 -0
  87. package/src/components/ui/tooltip.tsx +9 -0
  88. package/src/hooks/index.ts +10 -0
  89. package/src/index.ts +6 -3
  90. package/dist/components/ui/devenv-bracket.d.ts +0 -30
  91. package/dist/components/ui/devenv-bracket.d.ts.map +0 -1
  92. /package/dist/components/ui/morphing-popover/{morphing-popover.module-yxDDcJHZ.css → morphing-popover.module-CE9GIgKo.css} +0 -0
package/README.md CHANGED
@@ -1,73 +1,109 @@
1
- # React + TypeScript + Vite
1
+ # @mks2508/mks-ui
2
2
 
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3
+ UI component library built on Shadcn UI + Animate UI primitives with custom components, animated icons, and React hooks.
4
4
 
5
- Currently, two official plugins are available:
5
+ ## Install
6
6
 
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
7
+ ```bash
8
+ bun add @mks2508/mks-ui
9
+ ```
10
+
11
+ Peer dependencies: `react >= 19.2.0`, `react-dom >= 19.2.0`
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { Button, Card, Dialog, CornerBracket } from '@mks2508/mks-ui';
17
+ import { useAutoHeight } from '@mks2508/mks-ui';
18
+ import { cn } from '@mks2508/mks-ui';
19
+ ```
20
+
21
+ ## Components
22
+
23
+ ### Animate UI (animated)
24
+
25
+ | Component | Description |
26
+ |-----------|-------------|
27
+ | `Accordion` | Animated expand/collapse panels |
28
+ | `AlertDialog` | Animated alert dialog with backdrop |
29
+ | `Checkbox` | Animated checkbox with indicator |
30
+ | `Dialog` | Modal dialog with motion transitions |
31
+ | `Menu` | Context/trigger menu with highlight |
32
+ | `Popover` | Animated popover with arrow |
33
+ | `Progress` | Animated progress bar |
34
+ | `Switch` | Animated toggle switch |
35
+ | `Tabs` | Animated tabs with highlight |
36
+ | `Tooltip` | Animated tooltip with arrow |
37
+
38
+ ### Animate UI utilities
9
39
 
10
- ## React Compiler
40
+ | Component | Description |
41
+ |-----------|-------------|
42
+ | `AutoHeight` | Smooth height auto-resize animation |
43
+ | `CountingNumber` | Animated number interpolation |
44
+ | `Highlight` | Animated highlight effect |
45
+ | `Slot` | Motion-enhanced asChild composition |
11
46
 
12
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
47
+ ### Shadcn base
13
48
 
14
- ## Expanding the ESLint configuration
49
+ | Component | Description |
50
+ |-----------|-------------|
51
+ | `Badge` | Status/label badges |
52
+ | `Button` | Button with variants and sizes |
53
+ | `Card` | Container card |
54
+ | `Combobox` | Searchable select |
55
+ | `DropdownMenu` | Dropdown menu (Shadcn API) |
56
+ | `Field` | Form field wrapper |
57
+ | `Input` | Text input |
58
+ | `InputGroup` | Grouped input with addons |
59
+ | `Label` | Form label |
60
+ | `Select` | Select dropdown |
61
+ | `Separator` | Visual divider |
62
+ | `Textarea` | Multi-line text input |
15
63
 
16
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
64
+ ### Custom
17
65
 
18
- ```js
19
- export default defineConfig([
20
- globalIgnores(['dist']),
21
- {
22
- files: ['**/*.{ts,tsx}'],
23
- extends: [
24
- // Other configs...
66
+ | Component | Description |
67
+ |-----------|-------------|
68
+ | `CornerBracket` | Corner bracket decoration (tl/tr/bl/br) |
69
+ | `MorphingPopover` | Morphing transition popover |
25
70
 
26
- // Remove tseslint.configs.recommended and replace with this
27
- tseslint.configs.recommendedTypeChecked,
28
- // Alternatively, use this for stricter rules
29
- tseslint.configs.strictTypeChecked,
30
- // Optionally, add this for stylistic rules
31
- tseslint.configs.stylisticTypeChecked,
71
+ ## Icons
32
72
 
33
- // Other configs...
34
- ],
35
- languageOptions: {
36
- parserOptions: {
37
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
- tsconfigRootDir: import.meta.dirname,
39
- },
40
- // other options...
41
- },
42
- },
43
- ])
73
+ 32 animated Lucide icons + HugeIcons namespace.
74
+
75
+ ```tsx
76
+ import { Check, Search, Terminal } from '@mks2508/mks-ui';
77
+ import { HugeIcons } from '@mks2508/mks-ui';
44
78
  ```
45
79
 
46
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
-
48
- ```js
49
- // eslint.config.js
50
- import reactX from 'eslint-plugin-react-x'
51
- import reactDom from 'eslint-plugin-react-dom'
52
-
53
- export default defineConfig([
54
- globalIgnores(['dist']),
55
- {
56
- files: ['**/*.{ts,tsx}'],
57
- extends: [
58
- // Other configs...
59
- // Enable lint rules for React
60
- reactX.configs['recommended-typescript'],
61
- // Enable lint rules for React DOM
62
- reactDom.configs.recommended,
63
- ],
64
- languageOptions: {
65
- parserOptions: {
66
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
- tsconfigRootDir: import.meta.dirname,
68
- },
69
- // other options...
70
- },
71
- },
72
- ])
80
+ ## Hooks
81
+
82
+ | Hook | Description |
83
+ |------|-------------|
84
+ | `useAutoHeight` | Auto-resizing height |
85
+ | `useControlledState` | Controlled/uncontrolled state |
86
+ | `useDataState` | Data loading state |
87
+ | `useIsInView` | Intersection Observer |
88
+
89
+ ## Sub-path imports
90
+
91
+ ```tsx
92
+ import { Button } from '@mks2508/mks-ui/components/ui/button';
93
+ import { Check } from '@mks2508/mks-ui/icons/lucide-animated/check';
94
+ import { cn } from '@mks2508/mks-ui/lib/utils';
73
95
  ```
96
+
97
+ ## Development
98
+
99
+ ```bash
100
+ bun run dev # Vite dev server
101
+ bun run build # Production build
102
+ bun run typecheck # Type check
103
+ bun run lint # ESLint
104
+ bun run format # Prettier
105
+ ```
106
+
107
+ ## License
108
+
109
+ MIT
@@ -2,8 +2,8 @@
2
2
 
3
3
  import { cn } from "../../../../lib/utils.js";
4
4
  import * as React from "react";
5
- import { jsx } from "react/jsx-runtime";
6
5
  import { isMotionComponent, motion } from "motion/react";
6
+ import { jsx } from "react/jsx-runtime";
7
7
 
8
8
  //#region src/components/animate-ui/primitives/animate/slot.tsx
9
9
  function mergeRefs(...refs) {
@@ -0,0 +1,132 @@
1
+ 'use client';
2
+
3
+ import { getStrictContext } from "../../../../lib/get-strict-context.js";
4
+ import { useControlledState } from "../../../../hooks/use-controlled-state.js";
5
+ import * as React from "react";
6
+ import { Accordion } from "@base-ui-components/react/accordion";
7
+ import { AnimatePresence, motion } from "motion/react";
8
+ import { jsx } from "react/jsx-runtime";
9
+
10
+ //#region src/components/animate-ui/primitives/base/accordion.tsx
11
+ const [AccordionProvider, useAccordion] = getStrictContext("AccordionContext");
12
+ const [AccordionItemProvider, useAccordionItem] = getStrictContext("AccordionItemContext");
13
+ function Accordion$1(props) {
14
+ const [value, setValue] = useControlledState({
15
+ value: props?.value,
16
+ defaultValue: props?.defaultValue,
17
+ onChange: props?.onValueChange
18
+ });
19
+ return /* @__PURE__ */ jsx(AccordionProvider, {
20
+ value: {
21
+ value,
22
+ setValue
23
+ },
24
+ children: /* @__PURE__ */ jsx(Accordion.Root, {
25
+ "data-slot": "accordion",
26
+ ...props,
27
+ onValueChange: setValue
28
+ })
29
+ });
30
+ }
31
+ function AccordionItem(props) {
32
+ const { value } = useAccordion();
33
+ const [isOpen, setIsOpen] = React.useState(value?.includes(props?.value) ?? false);
34
+ React.useEffect(() => {
35
+ setIsOpen(value?.includes(props?.value) ?? false);
36
+ }, [value, props?.value]);
37
+ return /* @__PURE__ */ jsx(AccordionItemProvider, {
38
+ value: {
39
+ isOpen,
40
+ setIsOpen
41
+ },
42
+ children: /* @__PURE__ */ jsx(Accordion.Item, {
43
+ "data-slot": "accordion-item",
44
+ ...props
45
+ })
46
+ });
47
+ }
48
+ function AccordionHeader(props) {
49
+ return /* @__PURE__ */ jsx(Accordion.Header, {
50
+ "data-slot": "accordion-header",
51
+ ...props
52
+ });
53
+ }
54
+ function AccordionTrigger(props) {
55
+ return /* @__PURE__ */ jsx(Accordion.Trigger, {
56
+ "data-slot": "accordion-trigger",
57
+ ...props
58
+ });
59
+ }
60
+ function AccordionPanel({ transition = {
61
+ duration: .35,
62
+ ease: "easeInOut"
63
+ }, hiddenUntilFound, keepRendered = false, ...props }) {
64
+ const { isOpen } = useAccordionItem();
65
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: keepRendered ? /* @__PURE__ */ jsx(Accordion.Panel, {
66
+ hidden: false,
67
+ hiddenUntilFound,
68
+ keepMounted: true,
69
+ render: /* @__PURE__ */ jsx(motion.div, {
70
+ "data-slot": "accordion-panel",
71
+ initial: {
72
+ height: 0,
73
+ opacity: 0,
74
+ "--mask-stop": "0%",
75
+ y: 20
76
+ },
77
+ animate: isOpen ? {
78
+ height: "auto",
79
+ opacity: 1,
80
+ "--mask-stop": "100%",
81
+ y: 0
82
+ } : {
83
+ height: 0,
84
+ opacity: 0,
85
+ "--mask-stop": "0%",
86
+ y: 20
87
+ },
88
+ transition,
89
+ style: {
90
+ maskImage: "linear-gradient(black var(--mask-stop), transparent var(--mask-stop))",
91
+ WebkitMaskImage: "linear-gradient(black var(--mask-stop), transparent var(--mask-stop))",
92
+ overflow: "hidden"
93
+ },
94
+ ...props
95
+ }, "accordion-panel")
96
+ }) : isOpen && /* @__PURE__ */ jsx(Accordion.Panel, {
97
+ hidden: false,
98
+ hiddenUntilFound,
99
+ keepMounted: true,
100
+ render: /* @__PURE__ */ jsx(motion.div, {
101
+ "data-slot": "accordion-panel",
102
+ initial: {
103
+ height: 0,
104
+ opacity: 0,
105
+ "--mask-stop": "0%",
106
+ y: 20
107
+ },
108
+ animate: {
109
+ height: "auto",
110
+ opacity: 1,
111
+ "--mask-stop": "100%",
112
+ y: 0
113
+ },
114
+ exit: {
115
+ height: 0,
116
+ opacity: 0,
117
+ "--mask-stop": "0%",
118
+ y: 20
119
+ },
120
+ transition,
121
+ style: {
122
+ maskImage: "linear-gradient(black var(--mask-stop), transparent var(--mask-stop))",
123
+ WebkitMaskImage: "linear-gradient(black var(--mask-stop), transparent var(--mask-stop))",
124
+ overflow: "hidden"
125
+ },
126
+ ...props
127
+ }, "accordion-panel")
128
+ }) });
129
+ }
130
+
131
+ //#endregion
132
+ export { Accordion$1 as Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger, useAccordionItem };
@@ -0,0 +1,132 @@
1
+ 'use client';
2
+
3
+ import { getStrictContext } from "../../../../lib/get-strict-context.js";
4
+ import { useControlledState } from "../../../../hooks/use-controlled-state.js";
5
+ import "react";
6
+ import { AnimatePresence, motion } from "motion/react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { AlertDialog } from "@base-ui-components/react/alert-dialog";
9
+
10
+ //#region src/components/animate-ui/primitives/base/alert-dialog.tsx
11
+ const [AlertDialogProvider, useAlertDialog] = getStrictContext("AlertDialogContext");
12
+ function AlertDialog$1(props) {
13
+ const [isOpen, setIsOpen] = useControlledState({
14
+ value: props?.open,
15
+ defaultValue: props?.defaultOpen,
16
+ onChange: props?.onOpenChange
17
+ });
18
+ return /* @__PURE__ */ jsx(AlertDialogProvider, {
19
+ value: {
20
+ isOpen,
21
+ setIsOpen
22
+ },
23
+ children: /* @__PURE__ */ jsx(AlertDialog.Root, {
24
+ "data-slot": "alert-dialog",
25
+ ...props,
26
+ onOpenChange: setIsOpen
27
+ })
28
+ });
29
+ }
30
+ function AlertDialogTrigger(props) {
31
+ return /* @__PURE__ */ jsx(AlertDialog.Trigger, {
32
+ "data-slot": "alert-dialog-trigger",
33
+ ...props
34
+ });
35
+ }
36
+ function AlertDialogPortal(props) {
37
+ const { isOpen } = useAlertDialog();
38
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(AlertDialog.Portal, {
39
+ "data-slot": "alert-dialog-portal",
40
+ keepMounted: true,
41
+ ...props
42
+ }) });
43
+ }
44
+ function AlertDialogBackdrop({ transition = {
45
+ duration: .2,
46
+ ease: "easeInOut"
47
+ }, ...props }) {
48
+ return /* @__PURE__ */ jsx(AlertDialog.Backdrop, {
49
+ "data-slot": "alert-dialog-backdrop",
50
+ render: /* @__PURE__ */ jsx(motion.div, {
51
+ initial: {
52
+ opacity: 0,
53
+ filter: "blur(4px)"
54
+ },
55
+ animate: {
56
+ opacity: 1,
57
+ filter: "blur(0px)"
58
+ },
59
+ exit: {
60
+ opacity: 0,
61
+ filter: "blur(4px)"
62
+ },
63
+ transition,
64
+ ...props
65
+ }, "alert-dialog-backdrop")
66
+ });
67
+ }
68
+ function AlertDialogPopup({ from = "top", initialFocus, finalFocus, transition = {
69
+ type: "spring",
70
+ stiffness: 150,
71
+ damping: 25
72
+ }, ...props }) {
73
+ const initialRotation = from === "bottom" || from === "left" ? "20deg" : "-20deg";
74
+ const rotateAxis = from === "top" || from === "bottom" ? "rotateX" : "rotateY";
75
+ return /* @__PURE__ */ jsx(AlertDialog.Popup, {
76
+ initialFocus,
77
+ finalFocus,
78
+ render: /* @__PURE__ */ jsx(motion.div, {
79
+ "data-slot": "alert-dialog-popup",
80
+ initial: {
81
+ opacity: 0,
82
+ filter: "blur(4px)",
83
+ transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`
84
+ },
85
+ animate: {
86
+ opacity: 1,
87
+ filter: "blur(0px)",
88
+ transform: `perspective(500px) ${rotateAxis}(0deg) scale(1)`
89
+ },
90
+ exit: {
91
+ opacity: 0,
92
+ filter: "blur(4px)",
93
+ transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`
94
+ },
95
+ transition,
96
+ ...props
97
+ }, "alert-dialog-popup")
98
+ });
99
+ }
100
+ function AlertDialogClose(props) {
101
+ return /* @__PURE__ */ jsx(AlertDialog.Close, {
102
+ "data-slot": "alert-dialog-close",
103
+ ...props
104
+ });
105
+ }
106
+ function AlertDialogHeader(props) {
107
+ return /* @__PURE__ */ jsx("div", {
108
+ "data-slot": "alert-dialog-header",
109
+ ...props
110
+ });
111
+ }
112
+ function AlertDialogFooter(props) {
113
+ return /* @__PURE__ */ jsx("div", {
114
+ "data-slot": "alert-dialog-footer",
115
+ ...props
116
+ });
117
+ }
118
+ function AlertDialogTitle(props) {
119
+ return /* @__PURE__ */ jsx(AlertDialog.Title, {
120
+ "data-slot": "alert-dialog-title",
121
+ ...props
122
+ });
123
+ }
124
+ function AlertDialogDescription(props) {
125
+ return /* @__PURE__ */ jsx(AlertDialog.Description, {
126
+ "data-slot": "alert-dialog-description",
127
+ ...props
128
+ });
129
+ }
130
+
131
+ //#endregion
132
+ export { AlertDialog$1 as AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, useAlertDialog };
@@ -0,0 +1,101 @@
1
+ 'use client';
2
+
3
+ import { getStrictContext } from "../../../../lib/get-strict-context.js";
4
+ import { useControlledState } from "../../../../hooks/use-controlled-state.js";
5
+ import "react";
6
+ import { motion } from "motion/react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { Checkbox } from "@base-ui-components/react/checkbox";
9
+
10
+ //#region src/components/animate-ui/primitives/base/checkbox.tsx
11
+ const [CheckboxProvider, useCheckbox] = getStrictContext("CheckboxContext");
12
+ function Checkbox$1({ name, checked, defaultChecked, onCheckedChange, indeterminate, value, nativeButton, parent, disabled, readOnly, required, inputRef, id, ...props }) {
13
+ const [isChecked, setIsChecked] = useControlledState({
14
+ value: checked,
15
+ defaultValue: defaultChecked,
16
+ onChange: onCheckedChange
17
+ });
18
+ return /* @__PURE__ */ jsx(CheckboxProvider, {
19
+ value: {
20
+ isChecked,
21
+ setIsChecked,
22
+ isIndeterminate: indeterminate
23
+ },
24
+ children: /* @__PURE__ */ jsx(Checkbox.Root, {
25
+ name,
26
+ defaultChecked,
27
+ checked,
28
+ onCheckedChange: setIsChecked,
29
+ indeterminate,
30
+ value,
31
+ nativeButton,
32
+ parent,
33
+ disabled,
34
+ readOnly,
35
+ required,
36
+ inputRef,
37
+ id,
38
+ render: /* @__PURE__ */ jsx(motion.button, {
39
+ "data-slot": "checkbox",
40
+ whileTap: { scale: .95 },
41
+ whileHover: { scale: 1.05 },
42
+ ...props
43
+ })
44
+ })
45
+ });
46
+ }
47
+ function CheckboxIndicator(props) {
48
+ const { isChecked, isIndeterminate } = useCheckbox();
49
+ return /* @__PURE__ */ jsx(Checkbox.Indicator, {
50
+ keepMounted: true,
51
+ render: /* @__PURE__ */ jsx(motion.svg, {
52
+ "data-slot": "checkbox-indicator",
53
+ xmlns: "http://www.w3.org/2000/svg",
54
+ fill: "none",
55
+ viewBox: "0 0 24 24",
56
+ strokeWidth: "3.5",
57
+ stroke: "currentColor",
58
+ initial: "unchecked",
59
+ animate: isChecked ? "checked" : "unchecked",
60
+ ...props,
61
+ children: isIndeterminate ? /* @__PURE__ */ jsx(motion.line, {
62
+ x1: "5",
63
+ y1: "12",
64
+ x2: "19",
65
+ y2: "12",
66
+ strokeLinecap: "round",
67
+ initial: {
68
+ pathLength: 0,
69
+ opacity: 0
70
+ },
71
+ animate: {
72
+ pathLength: 1,
73
+ opacity: 1,
74
+ transition: { duration: .2 }
75
+ }
76
+ }) : /* @__PURE__ */ jsx(motion.path, {
77
+ strokeLinecap: "round",
78
+ strokeLinejoin: "round",
79
+ d: "M4.5 12.75l6 6 9-13.5",
80
+ variants: {
81
+ checked: {
82
+ pathLength: 1,
83
+ opacity: 1,
84
+ transition: {
85
+ duration: .2,
86
+ delay: .2
87
+ }
88
+ },
89
+ unchecked: {
90
+ pathLength: 0,
91
+ opacity: 0,
92
+ transition: { duration: .2 }
93
+ }
94
+ }
95
+ })
96
+ })
97
+ });
98
+ }
99
+
100
+ //#endregion
101
+ export { Checkbox$1 as Checkbox, CheckboxIndicator, useCheckbox };
@@ -0,0 +1,132 @@
1
+ 'use client';
2
+
3
+ import { getStrictContext } from "../../../../lib/get-strict-context.js";
4
+ import { useControlledState } from "../../../../hooks/use-controlled-state.js";
5
+ import "react";
6
+ import { AnimatePresence, motion } from "motion/react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { Dialog } from "@base-ui-components/react/dialog";
9
+
10
+ //#region src/components/animate-ui/primitives/base/dialog.tsx
11
+ const [DialogProvider, useDialog] = getStrictContext("DialogContext");
12
+ function Dialog$1(props) {
13
+ const [isOpen, setIsOpen] = useControlledState({
14
+ value: props?.open,
15
+ defaultValue: props?.defaultOpen,
16
+ onChange: props?.onOpenChange
17
+ });
18
+ return /* @__PURE__ */ jsx(DialogProvider, {
19
+ value: {
20
+ isOpen,
21
+ setIsOpen
22
+ },
23
+ children: /* @__PURE__ */ jsx(Dialog.Root, {
24
+ "data-slot": "dialog",
25
+ ...props,
26
+ onOpenChange: setIsOpen
27
+ })
28
+ });
29
+ }
30
+ function DialogTrigger(props) {
31
+ return /* @__PURE__ */ jsx(Dialog.Trigger, {
32
+ "data-slot": "dialog-trigger",
33
+ ...props
34
+ });
35
+ }
36
+ function DialogPortal(props) {
37
+ const { isOpen } = useDialog();
38
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(Dialog.Portal, {
39
+ "data-slot": "dialog-portal",
40
+ keepMounted: true,
41
+ ...props
42
+ }) });
43
+ }
44
+ function DialogBackdrop({ transition = {
45
+ duration: .2,
46
+ ease: "easeInOut"
47
+ }, ...props }) {
48
+ return /* @__PURE__ */ jsx(Dialog.Backdrop, {
49
+ "data-slot": "dialog-backdrop",
50
+ render: /* @__PURE__ */ jsx(motion.div, {
51
+ initial: {
52
+ opacity: 0,
53
+ filter: "blur(4px)"
54
+ },
55
+ animate: {
56
+ opacity: 1,
57
+ filter: "blur(0px)"
58
+ },
59
+ exit: {
60
+ opacity: 0,
61
+ filter: "blur(4px)"
62
+ },
63
+ transition,
64
+ ...props
65
+ }, "dialog-backdrop")
66
+ });
67
+ }
68
+ function DialogPopup({ from = "top", initialFocus, finalFocus, transition = {
69
+ type: "spring",
70
+ stiffness: 150,
71
+ damping: 25
72
+ }, ...props }) {
73
+ const initialRotation = from === "bottom" || from === "left" ? "20deg" : "-20deg";
74
+ const rotateAxis = from === "top" || from === "bottom" ? "rotateX" : "rotateY";
75
+ return /* @__PURE__ */ jsx(Dialog.Popup, {
76
+ initialFocus,
77
+ finalFocus,
78
+ render: /* @__PURE__ */ jsx(motion.div, {
79
+ "data-slot": "dialog-popup",
80
+ initial: {
81
+ opacity: 0,
82
+ filter: "blur(4px)",
83
+ transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`
84
+ },
85
+ animate: {
86
+ opacity: 1,
87
+ filter: "blur(0px)",
88
+ transform: `perspective(500px) ${rotateAxis}(0deg) scale(1)`
89
+ },
90
+ exit: {
91
+ opacity: 0,
92
+ filter: "blur(4px)",
93
+ transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`
94
+ },
95
+ transition,
96
+ ...props
97
+ }, "dialog-popup")
98
+ });
99
+ }
100
+ function DialogClose(props) {
101
+ return /* @__PURE__ */ jsx(Dialog.Close, {
102
+ "data-slot": "dialog-close",
103
+ ...props
104
+ });
105
+ }
106
+ function DialogHeader(props) {
107
+ return /* @__PURE__ */ jsx("div", {
108
+ "data-slot": "dialog-header",
109
+ ...props
110
+ });
111
+ }
112
+ function DialogFooter(props) {
113
+ return /* @__PURE__ */ jsx("div", {
114
+ "data-slot": "dialog-footer",
115
+ ...props
116
+ });
117
+ }
118
+ function DialogTitle(props) {
119
+ return /* @__PURE__ */ jsx(Dialog.Title, {
120
+ "data-slot": "dialog-title",
121
+ ...props
122
+ });
123
+ }
124
+ function DialogDescription(props) {
125
+ return /* @__PURE__ */ jsx(Dialog.Description, {
126
+ "data-slot": "dialog-description",
127
+ ...props
128
+ });
129
+ }
130
+
131
+ //#endregion
132
+ export { Dialog$1 as Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogTitle, DialogTrigger, useDialog };