@hanzo/ui 4.5.3 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-MCP.md +3 -3
- package/README.md +229 -0
- package/assets/ai-icons.tsx +207 -0
- package/assets/crypto.tsx +33 -0
- package/assets/file-type-icon.tsx +66 -0
- package/assets/file.tsx +45 -0
- package/assets/general.tsx +2318 -0
- package/assets/hanzo-logo.svg +9 -0
- package/assets/hanzo-logo.tsx +15 -0
- package/assets/index.ts +8 -0
- package/assets/index.tsx +4 -0
- package/assets/llm-provider.tsx +1094 -0
- package/bin/create-registry.js +1 -1
- package/bin/test-mcp.sh +1 -1
- package/bin/update-registry.js +2 -2
- package/blocks/components/content.tsx +1 -1
- package/blocks/components/grid-block/index.tsx +1 -1
- package/blocks/components/screenful-block/content.tsx +1 -1
- package/blocks/components/screenful-block/poster-background.tsx +1 -1
- package/components/index.ts +56 -0
- package/dist/button.d.ts +1 -0
- package/dist/button.js +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/use-click-away.d.ts +2 -0
- package/dist/hooks/use-click-away.js +23 -0
- package/dist/hooks/use-combined-refs.d.ts +3 -0
- package/dist/hooks/use-combined-refs.js +18 -0
- package/dist/hooks/use-copy-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-clipboard.js +21 -0
- package/dist/hooks/use-debounce.d.ts +1 -0
- package/dist/hooks/use-debounce.js +13 -0
- package/dist/hooks/use-fill-ids.d.ts +8 -0
- package/dist/hooks/use-fill-ids.js +20 -0
- package/dist/hooks/use-map.d.ts +1 -0
- package/dist/hooks/use-map.js +20 -0
- package/dist/hooks/use-measure.d.ts +8 -0
- package/dist/hooks/use-measure.js +25 -0
- package/dist/hooks/use-reverse-video-playback.d.ts +1 -0
- package/dist/hooks/use-reverse-video-playback.js +41 -0
- package/dist/hooks/use-scroll-restoration.d.ts +8 -0
- package/dist/hooks/use-scroll-restoration.js +36 -0
- package/dist/mcp/enhanced-server.js +3 -3
- package/dist/mcp/index.js +1 -1
- package/dist/registry/api.d.ts +1 -1
- package/dist/registry/api.js +3 -4
- package/dist/registry/index.d.ts +348 -4
- package/dist/registry/index.js +3 -3
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/helpers/file.ts +33 -0
- package/helpers/memoization.ts +40 -0
- package/package.json +27 -6
- package/primitives/accordion.tsx +53 -45
- package/primitives/alert-dialog.tsx +185 -0
- package/primitives/alert.tsx +74 -0
- package/primitives/apply-typography.tsx +1 -1
- package/primitives/avatar.tsx +37 -29
- package/primitives/background-beams.tsx +142 -0
- package/primitives/badge.tsx +27 -19
- package/primitives/breadcrumb.tsx +77 -62
- package/primitives/button.tsx +69 -72
- package/primitives/card.tsx +73 -59
- package/primitives/chat/chat-input-area.tsx +87 -0
- package/primitives/chat/chat-input.tsx +71 -0
- package/primitives/chat/files-preview.tsx +330 -0
- package/primitives/chat/index.ts +6 -0
- package/primitives/chat/json-form.tsx +8 -0
- package/primitives/chat/message-list.tsx +307 -0
- package/primitives/chat/message.tsx +569 -0
- package/primitives/chat/sqlite-preview.tsx +215 -0
- package/primitives/checkbox.tsx +18 -19
- package/primitives/collapsible.tsx +9 -0
- package/primitives/command.tsx +75 -83
- package/primitives/context-menu.tsx +115 -109
- package/primitives/copy-to-clipboard-icon.tsx +60 -0
- package/primitives/dialog-video-controller.tsx +1 -1
- package/primitives/dialog.tsx +111 -145
- package/primitives/dot-pattern.tsx +57 -0
- package/primitives/dots-loader.tsx +13 -0
- package/primitives/drawer.tsx +59 -87
- package/primitives/dropdown-menu.tsx +199 -0
- package/primitives/error-message.tsx +19 -0
- package/primitives/file-uploader.tsx +200 -0
- package/primitives/form.tsx +92 -87
- package/primitives/hover-card.tsx +28 -0
- package/primitives/icons/github.tsx +1 -1
- package/primitives/icons/youtube-logo.tsx +1 -1
- package/primitives/index-common.ts +121 -42
- package/primitives/index-next.ts +3 -1
- package/primitives/input.tsx +115 -20
- package/primitives/label.tsx +15 -23
- package/primitives/loading-spinner.tsx +1 -1
- package/primitives/markdown-preview.tsx +609 -0
- package/primitives/mermaid.tsx +196 -0
- package/primitives/next/link-element.tsx +1 -1
- package/primitives/next/mdx-link.tsx +1 -1
- package/primitives/pagination.tsx +117 -0
- package/primitives/popover.tsx +20 -25
- package/primitives/pretty-json-print.tsx +28 -0
- package/primitives/progress.tsx +14 -15
- package/primitives/prompt-textarea.tsx +72 -0
- package/primitives/qr-code.tsx +112 -0
- package/primitives/radio-group.tsx +25 -39
- package/primitives/resizable.tsx +47 -0
- package/primitives/scroll-area.tsx +35 -25
- package/primitives/search-input.tsx +66 -0
- package/primitives/select.tsx +62 -109
- package/primitives/separator.tsx +22 -26
- package/primitives/sheet.tsx +78 -117
- package/primitives/skeleton.tsx +13 -16
- package/primitives/slider.tsx +50 -60
- package/primitives/stepper.tsx +272 -0
- package/primitives/switch.tsx +14 -23
- package/primitives/table.tsx +65 -77
- package/primitives/tabs.tsx +29 -39
- package/primitives/text-link.tsx +25 -0
- package/primitives/textarea.tsx +61 -0
- package/primitives/textfield.tsx +75 -0
- package/primitives/toast.tsx +30 -0
- package/primitives/toggle-group.tsx +33 -33
- package/primitives/toggle.tsx +22 -51
- package/primitives/tooltip.tsx +37 -38
- package/registry.json +1 -1
- package/src/button.ts +1 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/use-click-away.ts +31 -0
- package/src/hooks/use-combined-refs.ts +22 -0
- package/src/hooks/use-copy-clipboard.ts +30 -0
- package/src/hooks/use-debounce.ts +17 -0
- package/src/hooks/use-fill-ids.ts +25 -0
- package/src/hooks/use-map.ts +26 -0
- package/src/hooks/use-measure.ts +42 -0
- package/src/hooks/use-reverse-video-playback.ts +43 -0
- package/src/hooks/use-scroll-restoration.ts +50 -0
- package/{mcp → src/mcp}/README.md +1 -1
- package/{mcp → src/mcp}/enhanced-server.ts +2 -2
- package/{registry → src/registry}/api.ts +3 -3
- package/{registry → src/registry}/index.ts +3 -3
- package/src/utils.ts +1 -0
- package/style/theme-provider.tsx +1 -1
- package/test-imports.mjs +19 -0
- package/tsconfig.json +9 -4
- package/types/animation-def.ts +1 -1
- package/types/button-def.ts +1 -1
- package/types/index.ts +1 -1
- package/util/blob.ts +28 -0
- package/util/copy-to-clipboard.ts +17 -0
- package/util/create-shadow-root.ts +22 -0
- package/util/date.ts +83 -0
- package/util/debounce.ts +11 -0
- package/util/file.ts +15 -0
- package/util/format-and-abbreviate-as-currency.ts +1 -1
- package/util/format-text.ts +33 -0
- package/util/index.ts +9 -78
- package/util/timing.ts +3 -0
- package/util/toasts.tsx +17 -0
- package/utils.ts +9 -0
- package/dist/blocks/components/accordian-block.d.ts +0 -4
- package/dist/blocks/components/accordian-block.jsx +0 -25
- package/dist/blocks/components/block-component-props.d.ts +0 -7
- package/dist/blocks/components/block-component-props.js +0 -1
- package/dist/blocks/components/bullet-cards-block.d.ts +0 -4
- package/dist/blocks/components/bullet-cards-block.jsx +0 -25
- package/dist/blocks/components/card-block/index.d.ts +0 -6
- package/dist/blocks/components/card-block/index.jsx +0 -87
- package/dist/blocks/components/card-block/link-out-button.d.ts +0 -6
- package/dist/blocks/components/card-block/link-out-button.jsx +0 -4
- package/dist/blocks/components/card-block/util.d.ts +0 -4
- package/dist/blocks/components/card-block/util.js +0 -6
- package/dist/blocks/components/carte-blanche-block/index.d.ts +0 -4
- package/dist/blocks/components/carte-blanche-block/index.jsx +0 -82
- package/dist/blocks/components/carte-blanche-block/variant-content-left.d.ts +0 -10
- package/dist/blocks/components/carte-blanche-block/variant-content-left.jsx +0 -23
- package/dist/blocks/components/content.d.ts +0 -10
- package/dist/blocks/components/content.jsx +0 -47
- package/dist/blocks/components/cta-block.d.ts +0 -12
- package/dist/blocks/components/cta-block.jsx +0 -69
- package/dist/blocks/components/enh-heading-block.d.ts +0 -7
- package/dist/blocks/components/enh-heading-block.jsx +0 -142
- package/dist/blocks/components/grid-block/grid-block-mutator.d.ts +0 -5
- package/dist/blocks/components/grid-block/grid-block-mutator.js +0 -1
- package/dist/blocks/components/grid-block/index.d.ts +0 -9
- package/dist/blocks/components/grid-block/index.jsx +0 -56
- package/dist/blocks/components/grid-block/mutator-registry.d.ts +0 -3
- package/dist/blocks/components/grid-block/mutator-registry.js +0 -5
- package/dist/blocks/components/grid-block/table-borders.mutator.d.ts +0 -3
- package/dist/blocks/components/grid-block/table-borders.mutator.js +0 -36
- package/dist/blocks/components/group-block.d.ts +0 -7
- package/dist/blocks/components/group-block.jsx +0 -61
- package/dist/blocks/components/heading-block.d.ts +0 -4
- package/dist/blocks/components/heading-block.jsx +0 -99
- package/dist/blocks/components/image-block.d.ts +0 -7
- package/dist/blocks/components/image-block.jsx +0 -69
- package/dist/blocks/components/index.d.ts +0 -14
- package/dist/blocks/components/index.js +0 -13
- package/dist/blocks/components/screenful-block/content.d.ts +0 -8
- package/dist/blocks/components/screenful-block/content.jsx +0 -71
- package/dist/blocks/components/screenful-block/index.d.ts +0 -12
- package/dist/blocks/components/screenful-block/index.jsx +0 -57
- package/dist/blocks/components/screenful-block/poster-background.d.ts +0 -7
- package/dist/blocks/components/screenful-block/poster-background.jsx +0 -14
- package/dist/blocks/components/screenful-block/video-background.d.ts +0 -8
- package/dist/blocks/components/screenful-block/video-background.jsx +0 -20
- package/dist/blocks/components/space-block.d.ts +0 -4
- package/dist/blocks/components/space-block.jsx +0 -42
- package/dist/blocks/components/video-block.d.ts +0 -9
- package/dist/blocks/components/video-block.jsx +0 -83
- package/dist/blocks/def/accordian-block.d.ts +0 -10
- package/dist/blocks/def/accordian-block.js +0 -2
- package/dist/blocks/def/block.d.ts +0 -4
- package/dist/blocks/def/block.js +0 -1
- package/dist/blocks/def/bullet-cards-block.d.ts +0 -17
- package/dist/blocks/def/bullet-cards-block.js +0 -1
- package/dist/blocks/def/card-block.d.ts +0 -17
- package/dist/blocks/def/card-block.js +0 -2
- package/dist/blocks/def/carte-blanche-block.d.ts +0 -12
- package/dist/blocks/def/carte-blanche-block.js +0 -1
- package/dist/blocks/def/cta-block.d.ts +0 -8
- package/dist/blocks/def/cta-block.js +0 -1
- package/dist/blocks/def/element-block.d.ts +0 -7
- package/dist/blocks/def/element-block.js +0 -2
- package/dist/blocks/def/enh-heading-block.d.ts +0 -22
- package/dist/blocks/def/enh-heading-block.js +0 -1
- package/dist/blocks/def/grid-block.d.ts +0 -12
- package/dist/blocks/def/grid-block.js +0 -1
- package/dist/blocks/def/group-block.d.ts +0 -7
- package/dist/blocks/def/group-block.js +0 -1
- package/dist/blocks/def/heading-block.d.ts +0 -11
- package/dist/blocks/def/heading-block.js +0 -1
- package/dist/blocks/def/image-block.d.ts +0 -26
- package/dist/blocks/def/image-block.js +0 -1
- package/dist/blocks/def/index.d.ts +0 -17
- package/dist/blocks/def/index.js +0 -2
- package/dist/blocks/def/screenful-block.d.ts +0 -41
- package/dist/blocks/def/screenful-block.js +0 -1
- package/dist/blocks/def/space-block.d.ts +0 -47
- package/dist/blocks/def/space-block.js +0 -8
- package/dist/blocks/def/video-block.d.ts +0 -5
- package/dist/blocks/def/video-block.js +0 -1
- package/dist/blocks/index.d.ts +0 -2
- package/dist/blocks/index.js +0 -2
- package/dist/primitives/accordion.d.ts +0 -10
- package/dist/primitives/accordion.jsx +0 -21
- package/dist/primitives/action-button.d.ts +0 -9
- package/dist/primitives/action-button.jsx +0 -16
- package/dist/primitives/apply-typography.d.ts +0 -7
- package/dist/primitives/apply-typography.jsx +0 -38
- package/dist/primitives/aspect-ratio.d.ts +0 -3
- package/dist/primitives/aspect-ratio.jsx +0 -4
- package/dist/primitives/avatar.d.ts +0 -6
- package/dist/primitives/avatar.jsx +0 -11
- package/dist/primitives/badge.d.ts +0 -9
- package/dist/primitives/badge.jsx +0 -18
- package/dist/primitives/breadcrumb.d.ts +0 -19
- package/dist/primitives/breadcrumb.jsx +0 -27
- package/dist/primitives/breakpoint-indicator.d.ts +0 -3
- package/dist/primitives/breakpoint-indicator.jsx +0 -14
- package/dist/primitives/button.d.ts +0 -12
- package/dist/primitives/button.jsx +0 -55
- package/dist/primitives/calendar.d.ts +0 -8
- package/dist/primitives/calendar.jsx +0 -40
- package/dist/primitives/card.d.ts +0 -8
- package/dist/primitives/card.jsx +0 -18
- package/dist/primitives/carousel.d.ts +0 -18
- package/dist/primitives/carousel.jsx +0 -106
- package/dist/primitives/checkbox.d.ts +0 -4
- package/dist/primitives/checkbox.jsx +0 -15
- package/dist/primitives/combobox.d.ts +0 -41
- package/dist/primitives/combobox.jsx +0 -77
- package/dist/primitives/command.d.ts +0 -17
- package/dist/primitives/command.jsx +0 -38
- package/dist/primitives/context-menu.d.ts +0 -27
- package/dist/primitives/context-menu.jsx +0 -57
- package/dist/primitives/dialog-video-controller.d.ts +0 -3
- package/dist/primitives/dialog-video-controller.jsx +0 -24
- package/dist/primitives/dialog.d.ts +0 -28
- package/dist/primitives/dialog.jsx +0 -37
- package/dist/primitives/drawer.d.ts +0 -29
- package/dist/primitives/drawer.jsx +0 -34
- package/dist/primitives/form.d.ts +0 -12
- package/dist/primitives/form.jsx +0 -69
- package/dist/primitives/icons/github.d.ts +0 -4
- package/dist/primitives/icons/github.jsx +0 -6
- package/dist/primitives/icons/index.d.ts +0 -4
- package/dist/primitives/icons/index.js +0 -4
- package/dist/primitives/icons/youtube-logo.d.ts +0 -4
- package/dist/primitives/icons/youtube-logo.jsx +0 -39
- package/dist/primitives/index-common.d.ts +0 -47
- package/dist/primitives/index-common.js +0 -46
- package/dist/primitives/index-next.d.ts +0 -2
- package/dist/primitives/index-next.js +0 -2
- package/dist/primitives/input-otp.d.ts +0 -7
- package/dist/primitives/input-otp.jsx +0 -24
- package/dist/primitives/input.d.ts +0 -5
- package/dist/primitives/input.jsx +0 -11
- package/dist/primitives/label.d.ts +0 -5
- package/dist/primitives/label.jsx +0 -11
- package/dist/primitives/list-adaptor.d.ts +0 -9
- package/dist/primitives/list-adaptor.js +0 -1
- package/dist/primitives/list-box.d.ts +0 -10
- package/dist/primitives/list-box.jsx +0 -14
- package/dist/primitives/loading-spinner.d.ts +0 -5
- package/dist/primitives/loading-spinner.jsx +0 -8
- package/dist/primitives/navigation-menu.d.ts +0 -12
- package/dist/primitives/navigation-menu.jsx +0 -38
- package/dist/primitives/next/image.d.ts +0 -11
- package/dist/primitives/next/image.jsx +0 -42
- package/dist/primitives/next/index.d.ts +0 -7
- package/dist/primitives/next/index.js +0 -7
- package/dist/primitives/next/inline-icon.d.ts +0 -13
- package/dist/primitives/next/inline-icon.jsx +0 -15
- package/dist/primitives/next/link-element.d.ts +0 -23
- package/dist/primitives/next/link-element.jsx +0 -56
- package/dist/primitives/next/mdx-link.d.ts +0 -3
- package/dist/primitives/next/mdx-link.jsx +0 -12
- package/dist/primitives/next/media-stack.d.ts +0 -8
- package/dist/primitives/next/media-stack.jsx +0 -28
- package/dist/primitives/next/nav-items.d.ts +0 -10
- package/dist/primitives/next/nav-items.jsx +0 -24
- package/dist/primitives/next/youtube-embed.d.ts +0 -11
- package/dist/primitives/next/youtube-embed.jsx +0 -23
- package/dist/primitives/popover.d.ts +0 -9
- package/dist/primitives/popover.jsx +0 -18
- package/dist/primitives/progress.d.ts +0 -4
- package/dist/primitives/progress.jsx +0 -9
- package/dist/primitives/radio-group.d.ts +0 -7
- package/dist/primitives/radio-group.jsx +0 -18
- package/dist/primitives/scroll-area.d.ts +0 -5
- package/dist/primitives/scroll-area.jsx +0 -19
- package/dist/primitives/select.d.ts +0 -13
- package/dist/primitives/select.jsx +0 -62
- package/dist/primitives/separator.d.ts +0 -4
- package/dist/primitives/separator.jsx +0 -7
- package/dist/primitives/sheet.d.ts +0 -30
- package/dist/primitives/sheet.jsx +0 -56
- package/dist/primitives/skeleton.d.ts +0 -4
- package/dist/primitives/skeleton.jsx +0 -3
- package/dist/primitives/slider.d.ts +0 -9
- package/dist/primitives/slider.jsx +0 -30
- package/dist/primitives/sonner.d.ts +0 -5
- package/dist/primitives/sonner.jsx +0 -16
- package/dist/primitives/step-indicator.d.ts +0 -9
- package/dist/primitives/step-indicator.jsx +0 -23
- package/dist/primitives/switch.d.ts +0 -6
- package/dist/primitives/switch.jsx +0 -14
- package/dist/primitives/table.d.ts +0 -10
- package/dist/primitives/table.jsx +0 -21
- package/dist/primitives/tabs.d.ts +0 -7
- package/dist/primitives/tabs.jsx +0 -18
- package/dist/primitives/text-area.d.ts +0 -5
- package/dist/primitives/text-area.jsx +0 -9
- package/dist/primitives/toggle-group.d.ts +0 -14
- package/dist/primitives/toggle-group.jsx +0 -28
- package/dist/primitives/toggle.d.ts +0 -14
- package/dist/primitives/toggle.jsx +0 -52
- package/dist/primitives/tooltip.d.ts +0 -11
- package/dist/primitives/tooltip.jsx +0 -18
- package/dist/primitives/video-player.d.ts +0 -6
- package/dist/primitives/video-player.jsx +0 -8
- package/dist/style/theme-provider.d.ts +0 -4
- package/dist/style/theme-provider.jsx +0 -11
- package/dist/tailwind/fontFamily.tailwind.d.ts +0 -8
- package/dist/tailwind/fontFamily.tailwind.js +0 -7
- package/dist/tailwind/fontSize.tailwind.d.ts +0 -36
- package/dist/tailwind/fontSize.tailwind.js +0 -13
- package/dist/tailwind/index.d.ts +0 -3
- package/dist/tailwind/index.js +0 -2
- package/dist/tailwind/screens.tailwind.d.ts +0 -9
- package/dist/tailwind/screens.tailwind.js +0 -8
- package/dist/tailwind/tw-font-desc.d.ts +0 -6
- package/dist/tailwind/tw-font-desc.js +0 -6
- package/dist/types/animation-def.d.ts +0 -2
- package/dist/types/animation-def.js +0 -1
- package/dist/types/breakpoints.d.ts +0 -4
- package/dist/types/breakpoints.js +0 -4
- package/dist/types/bullet-item.d.ts +0 -6
- package/dist/types/bullet-item.js +0 -2
- package/dist/types/button-def.d.ts +0 -29
- package/dist/types/button-def.js +0 -2
- package/dist/types/dimensions.d.ts +0 -5
- package/dist/types/dimensions.js +0 -1
- package/dist/types/grid-def.d.ts +0 -36
- package/dist/types/grid-def.js +0 -33
- package/dist/types/image-def.d.ts +0 -27
- package/dist/types/image-def.js +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.js +0 -2
- package/dist/types/link-def.d.ts +0 -44
- package/dist/types/link-def.js +0 -1
- package/dist/types/media-stack-def.d.ts +0 -25
- package/dist/types/media-stack-def.js +0 -1
- package/dist/types/t-shirt-size.d.ts +0 -2
- package/dist/types/t-shirt-size.js +0 -1
- package/dist/types/tshirt-dimensions.d.ts +0 -12
- package/dist/types/tshirt-dimensions.js +0 -1
- package/dist/types/video-def.d.ts +0 -9
- package/dist/types/video-def.js +0 -1
- package/dist/util/format-and-abbreviate-as-currency.d.ts +0 -11
- package/dist/util/format-and-abbreviate-as-currency.js +0 -91
- package/dist/util/format-to-max-char.d.ts +0 -5
- package/dist/util/format-to-max-char.js +0 -57
- package/dist/util/index-client.d.ts +0 -2
- package/dist/util/index-client.js +0 -3
- package/dist/util/index.d.ts +0 -17
- package/dist/util/index.js +0 -41
- package/dist/util/number-abbreviate.d.ts +0 -9
- package/dist/util/number-abbreviate.js +0 -30
- package/dist/util/specifier.d.ts +0 -7
- package/dist/util/specifier.js +0 -31
- package/dist/util/spread-to-transform.d.ts +0 -7
- package/dist/util/spread-to-transform.js +0 -18
- package/dist/util/step-animation.d.ts +0 -5
- package/dist/util/step-animation.js +0 -60
- package/dist/util/two-way-map.d.ts +0 -8
- package/dist/util/two-way-map.js +0 -16
- /package/{mcp → src/mcp}/index.ts +0 -0
- /package/{mcp → src/mcp}/package.json +0 -0
- /package/{registry → src/registry}/package.json +0 -0
package/primitives/switch.tsx
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import * as SwitchPrimitives from '@radix-ui/react-switch'
|
|
1
|
+
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
2
|
+
import * as React from 'react';
|
|
4
3
|
|
|
5
|
-
import { cn } from '../
|
|
4
|
+
import { cn } from '../src/utils';
|
|
6
5
|
|
|
7
|
-
const Switch =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
>(({ className, thumbClx='', ...props }, ref) => (
|
|
6
|
+
const Switch = ({
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<typeof SwitchPrimitives.Root>) => (
|
|
12
10
|
<SwitchPrimitives.Root
|
|
13
11
|
className={cn(
|
|
14
|
-
'peer inline-flex h-
|
|
15
|
-
|
|
16
|
-
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ' +
|
|
17
|
-
'focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 ' +
|
|
18
|
-
'data-[state=checked]:bg-primary data-[state=unchecked]:bg-level-3',
|
|
19
|
-
className
|
|
12
|
+
'data-[state=checked]:bg-brand peer data-[state=unchecked]:bg-bg-secondary inline-flex h-[20px] w-[36px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 focus-visible:ring-offset-white focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
|
|
13
|
+
className,
|
|
20
14
|
)}
|
|
21
15
|
{...props}
|
|
22
|
-
ref={ref}
|
|
23
16
|
>
|
|
24
17
|
<SwitchPrimitives.Thumb
|
|
25
18
|
className={cn(
|
|
26
|
-
'pointer-events-none block h-4 w-4 rounded-full bg-
|
|
27
|
-
|
|
28
|
-
thumbClx
|
|
29
|
-
)}
|
|
19
|
+
'pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
|
|
20
|
+
)}
|
|
30
21
|
/>
|
|
31
22
|
</SwitchPrimitives.Root>
|
|
32
|
-
)
|
|
33
|
-
Switch.displayName = SwitchPrimitives.Root.displayName
|
|
23
|
+
);
|
|
24
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
34
25
|
|
|
35
|
-
export
|
|
26
|
+
export { Switch };
|
package/primitives/table.tsx
CHANGED
|
@@ -1,109 +1,97 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { cn } from '../
|
|
3
|
+
import { cn } from '../src/utils';
|
|
4
4
|
|
|
5
|
-
const Table =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
</div>
|
|
16
|
-
))
|
|
17
|
-
Table.displayName = 'Table'
|
|
18
|
-
|
|
19
|
-
const TableHeader = React.forwardRef<
|
|
20
|
-
HTMLTableSectionElement,
|
|
21
|
-
React.HTMLAttributes<HTMLTableSectionElement>
|
|
22
|
-
>(({ className, ...props }, ref) => (
|
|
23
|
-
<thead ref={ref} className={cn('[&_tr]:border-b', className)} {...props} />
|
|
24
|
-
))
|
|
25
|
-
TableHeader.displayName = 'TableHeader'
|
|
5
|
+
const Table = ({
|
|
6
|
+
className,
|
|
7
|
+
...props
|
|
8
|
+
}: React.HTMLAttributes<HTMLTableElement>) => (
|
|
9
|
+
<table
|
|
10
|
+
className={cn('w-full caption-bottom text-sm', className)}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
Table.displayName = 'Table';
|
|
26
15
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
className={cn('[&_tr:last-child]:border-0', className)}
|
|
16
|
+
const TableHeader = ({
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: React.HTMLAttributes<HTMLTableSectionElement>) => (
|
|
20
|
+
<thead
|
|
21
|
+
className={cn('[&_tr]:border-0 [&_tr]:border-b', className)}
|
|
34
22
|
{...props}
|
|
35
23
|
/>
|
|
36
|
-
)
|
|
37
|
-
|
|
24
|
+
);
|
|
25
|
+
TableHeader.displayName = 'TableHeader';
|
|
38
26
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
const TableBody = ({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}: React.HTMLAttributes<HTMLTableSectionElement>) => (
|
|
31
|
+
<tbody className={cn('[&_tr]:border-0', className)} {...props} />
|
|
32
|
+
);
|
|
33
|
+
TableBody.displayName = 'TableBody';
|
|
34
|
+
|
|
35
|
+
const TableFooter = ({
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: React.HTMLAttributes<HTMLTableSectionElement>) => (
|
|
43
39
|
<tfoot
|
|
44
|
-
|
|
45
|
-
className={cn(
|
|
46
|
-
'border-t bg-level-1 font-medium [&>tr]:last:border-b-0',
|
|
47
|
-
className
|
|
48
|
-
)}
|
|
40
|
+
className={cn('border-t font-medium [&>tr]:last:border-b-0', className)}
|
|
49
41
|
{...props}
|
|
50
42
|
/>
|
|
51
|
-
)
|
|
52
|
-
TableFooter.displayName = 'TableFooter'
|
|
43
|
+
);
|
|
44
|
+
TableFooter.displayName = 'TableFooter';
|
|
53
45
|
|
|
54
|
-
const TableRow =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
const TableRow = ({
|
|
47
|
+
className,
|
|
48
|
+
...props
|
|
49
|
+
}: React.HTMLAttributes<HTMLTableRowElement>) => (
|
|
58
50
|
<tr
|
|
59
|
-
ref={ref}
|
|
60
51
|
className={cn(
|
|
61
|
-
'
|
|
62
|
-
className
|
|
52
|
+
'data-[state=selected]:bg-muted transition-colors hover:bg-gray-300/50',
|
|
53
|
+
className,
|
|
63
54
|
)}
|
|
64
55
|
{...props}
|
|
65
56
|
/>
|
|
66
|
-
)
|
|
67
|
-
TableRow.displayName = 'TableRow'
|
|
57
|
+
);
|
|
58
|
+
TableRow.displayName = 'TableRow';
|
|
68
59
|
|
|
69
|
-
const TableHead =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
const TableHead = ({
|
|
61
|
+
className,
|
|
62
|
+
...props
|
|
63
|
+
}: React.HTMLAttributes<HTMLTableCellElement>) => (
|
|
73
64
|
<th
|
|
74
|
-
ref={ref}
|
|
75
65
|
className={cn(
|
|
76
|
-
'h-12 px-4 text-left align-middle font-medium
|
|
77
|
-
className
|
|
66
|
+
'text-text-secondary h-12 px-4 text-left align-middle font-medium uppercase [&:has([role=checkbox])]:pr-0',
|
|
67
|
+
className,
|
|
78
68
|
)}
|
|
79
69
|
{...props}
|
|
80
70
|
/>
|
|
81
|
-
)
|
|
82
|
-
TableHead.displayName = 'TableHead'
|
|
71
|
+
);
|
|
72
|
+
TableHead.displayName = 'TableHead';
|
|
83
73
|
|
|
84
|
-
const TableCell =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
const TableCell = ({
|
|
75
|
+
className,
|
|
76
|
+
...props
|
|
77
|
+
}: React.HTMLAttributes<HTMLTableCellElement>) => (
|
|
88
78
|
<td
|
|
89
|
-
ref={ref}
|
|
90
79
|
className={cn('p-4 align-middle [&:has([role=checkbox])]:pr-0', className)}
|
|
91
80
|
{...props}
|
|
92
81
|
/>
|
|
93
|
-
)
|
|
94
|
-
TableCell.displayName = 'TableCell'
|
|
82
|
+
);
|
|
83
|
+
TableCell.displayName = 'TableCell';
|
|
95
84
|
|
|
96
|
-
const TableCaption =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
const TableCaption = ({
|
|
86
|
+
className,
|
|
87
|
+
...props
|
|
88
|
+
}: React.HTMLAttributes<HTMLTableCaptionElement>) => (
|
|
100
89
|
<caption
|
|
101
|
-
|
|
102
|
-
className={cn('mt-4 text-sm text-muted', className)}
|
|
90
|
+
className={cn('text-text-secondary mt-4 text-sm', className)}
|
|
103
91
|
{...props}
|
|
104
92
|
/>
|
|
105
|
-
)
|
|
106
|
-
TableCaption.displayName = 'TableCaption'
|
|
93
|
+
);
|
|
94
|
+
TableCaption.displayName = 'TableCaption';
|
|
107
95
|
|
|
108
96
|
export {
|
|
109
97
|
Table,
|
|
@@ -114,4 +102,4 @@ export {
|
|
|
114
102
|
TableRow,
|
|
115
103
|
TableCell,
|
|
116
104
|
TableCaption,
|
|
117
|
-
}
|
|
105
|
+
};
|
package/primitives/tabs.tsx
CHANGED
|
@@ -1,60 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import * as TabsPrimitive from '@radix-ui/react-tabs'
|
|
1
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
2
|
+
import * as React from 'react';
|
|
4
3
|
|
|
5
|
-
import { cn } from '../
|
|
4
|
+
import { cn } from '../src/utils';
|
|
6
5
|
|
|
7
|
-
const Tabs = TabsPrimitive.Root
|
|
6
|
+
const Tabs = TabsPrimitive.Root;
|
|
8
7
|
|
|
9
|
-
const TabsList =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const TabsList = ({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof TabsPrimitive.List>) => (
|
|
13
12
|
<TabsPrimitive.List
|
|
14
|
-
ref={ref}
|
|
15
13
|
className={cn(
|
|
16
|
-
'inline-flex h-10 items-center justify-center rounded-md bg-
|
|
17
|
-
className
|
|
14
|
+
'text-text-tertiary inline-flex h-10 items-center justify-center rounded-md bg-[#27252B] p-1',
|
|
15
|
+
className,
|
|
18
16
|
)}
|
|
19
17
|
{...props}
|
|
20
18
|
/>
|
|
21
|
-
)
|
|
22
|
-
TabsList.displayName = TabsPrimitive.List.displayName
|
|
19
|
+
);
|
|
20
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
23
21
|
|
|
24
|
-
const TabsTrigger =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const TabsTrigger = ({
|
|
23
|
+
className,
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) => (
|
|
28
26
|
<TabsPrimitive.Trigger
|
|
29
|
-
ref={ref}
|
|
30
27
|
className={cn(
|
|
31
|
-
'inline-flex items-center justify-center whitespace-nowrap
|
|
32
|
-
|
|
33
|
-
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ' +
|
|
34
|
-
'focus-visible:ring-offset-2 disabled:pointer-events-none ' +
|
|
35
|
-
'disabled:opacity-50 data-[state=active]:bg-background ' +
|
|
36
|
-
'data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
37
|
-
className
|
|
28
|
+
'ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center rounded-md px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-[#2D3239] data-[state=active]:text-white data-[state=active]:shadow-xs',
|
|
29
|
+
className,
|
|
38
30
|
)}
|
|
39
31
|
{...props}
|
|
40
32
|
/>
|
|
41
|
-
)
|
|
42
|
-
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
33
|
+
);
|
|
34
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
43
35
|
|
|
44
|
-
const TabsContent =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
const TabsContent = ({
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}: React.ComponentProps<typeof TabsPrimitive.Content>) => (
|
|
48
40
|
<TabsPrimitive.Content
|
|
49
|
-
ref={ref}
|
|
50
41
|
className={cn(
|
|
51
|
-
'
|
|
52
|
-
|
|
53
|
-
className
|
|
42
|
+
'ring-offset-background focus-visible:ring-ring mt-3 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',
|
|
43
|
+
className,
|
|
54
44
|
)}
|
|
55
45
|
{...props}
|
|
56
46
|
/>
|
|
57
|
-
)
|
|
58
|
-
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
47
|
+
);
|
|
48
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
59
49
|
|
|
60
|
-
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
50
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '../src/utils';
|
|
4
|
+
|
|
5
|
+
export const TextLink = ({
|
|
6
|
+
label,
|
|
7
|
+
url,
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}: {
|
|
11
|
+
label: string;
|
|
12
|
+
url: string;
|
|
13
|
+
} & React.ButtonHTMLAttributes<HTMLSpanElement>) => (
|
|
14
|
+
<span
|
|
15
|
+
className={cn('cursor-pointer text-white underline', className)}
|
|
16
|
+
onClick={() => {
|
|
17
|
+
window.open(url);
|
|
18
|
+
}}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
<a href={url} rel="noreferrer" target="_blank">
|
|
22
|
+
{label}
|
|
23
|
+
</a>
|
|
24
|
+
</span>
|
|
25
|
+
);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { RefCallBack } from 'react-hook-form';
|
|
4
|
+
import { cn } from '../src/utils';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_MIN_TEXTAREA_HEIGHT = 32;
|
|
7
|
+
const DEFAULT_MAX_TEXTAREA_HEIGHT = 300;
|
|
8
|
+
|
|
9
|
+
export type TextareaProps =
|
|
10
|
+
React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
11
|
+
minHeight?: number;
|
|
12
|
+
maxHeight?: number;
|
|
13
|
+
resize?: 'none' | 'both' | 'horizontal' | 'vertical';
|
|
14
|
+
ref?: React.RefObject<HTMLTextAreaElement | null> | RefCallBack;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const Textarea = ({
|
|
18
|
+
className,
|
|
19
|
+
minHeight = DEFAULT_MIN_TEXTAREA_HEIGHT,
|
|
20
|
+
maxHeight = DEFAULT_MAX_TEXTAREA_HEIGHT,
|
|
21
|
+
resize = 'none',
|
|
22
|
+
ref,
|
|
23
|
+
...props
|
|
24
|
+
}: TextareaProps) => {
|
|
25
|
+
const textareaRef = React.useRef<HTMLTextAreaElement>(null);
|
|
26
|
+
|
|
27
|
+
React.useLayoutEffect(() => {
|
|
28
|
+
// Reset height - important to shrink on delete
|
|
29
|
+
if (!textareaRef.current) return;
|
|
30
|
+
textareaRef.current.style.height = 'inherit';
|
|
31
|
+
// Set height
|
|
32
|
+
textareaRef.current.style.height = `${Math.max(
|
|
33
|
+
textareaRef.current.scrollHeight + 2,
|
|
34
|
+
minHeight,
|
|
35
|
+
)}px`;
|
|
36
|
+
|
|
37
|
+
if (props.autoFocus !== undefined && props.autoFocus) {
|
|
38
|
+
textareaRef.current.focus();
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [props.value, minHeight, maxHeight]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<textarea
|
|
45
|
+
className={cn(
|
|
46
|
+
'bg-bg-secondary placeholder:!text-text-placeholder border-input focus-visible:ring-border-input-focus flex w-full rounded-md border px-4 py-2 pt-7 text-sm break-words focus-visible:ring-1 focus-visible:outline-hidden focus-visible:ring-inset disabled:cursor-not-allowed disabled:opacity-50',
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
ref={ref || textareaRef}
|
|
50
|
+
style={{
|
|
51
|
+
minHeight: `${minHeight}px`,
|
|
52
|
+
maxHeight: resize === 'vertical' ? undefined : `${maxHeight}px`,
|
|
53
|
+
resize: resize,
|
|
54
|
+
}}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
Textarea.displayName = 'Textarea';
|
|
60
|
+
|
|
61
|
+
export { Textarea };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { RefCallBack } from 'react-hook-form';
|
|
4
|
+
import { cn } from '../src/utils';
|
|
5
|
+
import {
|
|
6
|
+
FormControl,
|
|
7
|
+
FormDescription,
|
|
8
|
+
FormItem,
|
|
9
|
+
FormLabel,
|
|
10
|
+
FormMessage,
|
|
11
|
+
} from './form';
|
|
12
|
+
import { Input } from './input';
|
|
13
|
+
|
|
14
|
+
const TextField = ({
|
|
15
|
+
classes,
|
|
16
|
+
field,
|
|
17
|
+
label,
|
|
18
|
+
type = 'text',
|
|
19
|
+
helperMessage,
|
|
20
|
+
startAdornment,
|
|
21
|
+
endAdornment,
|
|
22
|
+
autoFocus,
|
|
23
|
+
min,
|
|
24
|
+
max,
|
|
25
|
+
}: {
|
|
26
|
+
classes?: {
|
|
27
|
+
formItem?: string;
|
|
28
|
+
label?: string;
|
|
29
|
+
input?: string;
|
|
30
|
+
helperMessage?: string;
|
|
31
|
+
};
|
|
32
|
+
field: {
|
|
33
|
+
onChange?: (...event: any[]) => void;
|
|
34
|
+
onFocus?: (...event: any[]) => void;
|
|
35
|
+
onKeyDown?: (...event: any[]) => void;
|
|
36
|
+
onBlur?: () => void;
|
|
37
|
+
value: any;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
name?: string;
|
|
40
|
+
ref?: React.RefObject<HTMLInputElement | null> | RefCallBack;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
readOnly?: boolean;
|
|
43
|
+
};
|
|
44
|
+
autoFocus?: boolean;
|
|
45
|
+
label: React.ReactNode;
|
|
46
|
+
helperMessage?: React.ReactNode;
|
|
47
|
+
type?: 'text' | 'password' | 'number';
|
|
48
|
+
startAdornment?: React.ReactNode;
|
|
49
|
+
endAdornment?: React.ReactNode;
|
|
50
|
+
min?: number;
|
|
51
|
+
max?: number;
|
|
52
|
+
}) => {
|
|
53
|
+
return (
|
|
54
|
+
<FormItem className={cn(classes?.formItem)}>
|
|
55
|
+
<FormControl>
|
|
56
|
+
<Input
|
|
57
|
+
autoFocus={autoFocus}
|
|
58
|
+
className={cn(classes?.input)}
|
|
59
|
+
endAdornment={endAdornment}
|
|
60
|
+
max={max}
|
|
61
|
+
min={min}
|
|
62
|
+
spellCheck={false}
|
|
63
|
+
startAdornment={startAdornment}
|
|
64
|
+
type={type}
|
|
65
|
+
{...field}
|
|
66
|
+
/>
|
|
67
|
+
</FormControl>
|
|
68
|
+
<FormLabel className={cn(classes?.label)}>{label}</FormLabel>
|
|
69
|
+
<FormDescription>{helperMessage}</FormDescription>
|
|
70
|
+
<FormMessage className={cn(classes?.helperMessage)} />
|
|
71
|
+
</FormItem>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { TextField };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Toaster as Sonner } from 'sonner';
|
|
3
|
+
|
|
4
|
+
type ToasterProps = React.ComponentProps<typeof Sonner>;
|
|
5
|
+
|
|
6
|
+
const Toaster = ({ ...props }: ToasterProps) => {
|
|
7
|
+
return (
|
|
8
|
+
<Sonner
|
|
9
|
+
className="toaster group"
|
|
10
|
+
closeButton
|
|
11
|
+
position="top-center"
|
|
12
|
+
richColors
|
|
13
|
+
theme={'dark' as ToasterProps['theme']}
|
|
14
|
+
toastOptions={{
|
|
15
|
+
classNames: {
|
|
16
|
+
toast:
|
|
17
|
+
'group toast group-[.toaster]:bg-background group-[.toaster]:text-text-default group-[.toaster]:border-border group-[.toaster]:shadow-lg',
|
|
18
|
+
description: 'group-[.toast]:text-text-secondary',
|
|
19
|
+
actionButton: 'group-[.toast]:bg-brand group-[.toast]:text-white',
|
|
20
|
+
cancelButton:
|
|
21
|
+
'group-[.toast]:bg-transparent group-[.toast]:text-gray=80',
|
|
22
|
+
},
|
|
23
|
+
}}
|
|
24
|
+
visibleToasts={5}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { Toaster };
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import * as React from 'react';
|
|
2
4
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import type { VariantProps } from 'class-variance-authority'
|
|
6
|
-
|
|
7
|
-
import { cn } from '../util'
|
|
8
|
-
import { toggleVariants } from './toggle'
|
|
5
|
+
import { cn } from '../src/utils';
|
|
6
|
+
import { toggleVariants } from './toggle';
|
|
9
7
|
|
|
10
8
|
const ToggleGroupContext = React.createContext<
|
|
11
9
|
VariantProps<typeof toggleVariants>
|
|
12
10
|
>({
|
|
13
11
|
size: 'default',
|
|
14
12
|
variant: 'default',
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const ToggleGroup = ({
|
|
16
|
+
className,
|
|
17
|
+
variant,
|
|
18
|
+
size,
|
|
19
|
+
children,
|
|
20
|
+
...props
|
|
21
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
22
|
+
VariantProps<typeof toggleVariants>) => (
|
|
23
23
|
<ToggleGroupPrimitive.Root
|
|
24
|
-
ref={ref}
|
|
25
24
|
className={cn('flex items-center justify-center gap-1', className)}
|
|
26
25
|
{...props}
|
|
27
26
|
>
|
|
28
|
-
<ToggleGroupContext.Provider value={{ variant, size
|
|
29
|
-
{children
|
|
27
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
28
|
+
{children}
|
|
30
29
|
</ToggleGroupContext.Provider>
|
|
31
30
|
</ToggleGroupPrimitive.Root>
|
|
32
|
-
)
|
|
31
|
+
);
|
|
33
32
|
|
|
34
|
-
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName
|
|
33
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
35
34
|
|
|
36
|
-
const ToggleGroupItem =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
const ToggleGroupItem = ({
|
|
36
|
+
className,
|
|
37
|
+
children,
|
|
38
|
+
variant,
|
|
39
|
+
size,
|
|
40
|
+
...props
|
|
41
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
|
42
|
+
VariantProps<typeof toggleVariants>) => {
|
|
43
|
+
const context = React.useContext(ToggleGroupContext);
|
|
42
44
|
|
|
43
45
|
return (
|
|
44
46
|
<ToggleGroupPrimitive.Item
|
|
45
|
-
ref={ref}
|
|
46
47
|
className={cn(
|
|
47
48
|
toggleVariants({
|
|
48
49
|
variant: context.variant || variant,
|
|
49
50
|
size: context.size || size,
|
|
50
|
-
rounded: context.rounded || rounded,
|
|
51
51
|
}),
|
|
52
|
-
className
|
|
52
|
+
className,
|
|
53
53
|
)}
|
|
54
54
|
{...props}
|
|
55
55
|
>
|
|
56
56
|
{children}
|
|
57
57
|
</ToggleGroupPrimitive.Item>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
60
|
|
|
61
|
-
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
|
|
61
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
62
62
|
|
|
63
|
-
export { ToggleGroup, ToggleGroupItem }
|
|
63
|
+
export { ToggleGroup, ToggleGroupItem };
|