@nous-research/ui 0.16.0 → 0.17.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/CHANGELOG.md +39 -0
- package/dist/hooks/use-below-breakpoint.d.ts +2 -0
- package/dist/hooks/use-below-breakpoint.js +17 -0
- package/dist/hooks/use-confirm-delete.d.ts +10 -0
- package/dist/hooks/use-confirm-delete.js +35 -0
- package/dist/hooks/use-toast.d.ts +7 -0
- package/dist/hooks/use-toast.js +21 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +23 -2
- package/dist/ui/components/bottom-sheet.d.ts +15 -0
- package/dist/ui/components/bottom-sheet.js +192 -0
- package/dist/ui/components/card.d.ts +5 -0
- package/dist/ui/components/card.js +74 -0
- package/dist/ui/components/checkbox.d.ts +1 -1
- package/dist/ui/components/checkbox.js +2 -2
- package/dist/ui/components/confirm-dialog.d.ts +13 -0
- package/dist/ui/components/confirm-dialog.js +113 -0
- package/dist/ui/components/dialog.d.ts +15 -0
- package/dist/ui/components/dialog.js +171 -0
- package/dist/ui/components/input.d.ts +1 -0
- package/dist/ui/components/input.js +21 -0
- package/dist/ui/components/label.d.ts +1 -0
- package/dist/ui/components/label.js +18 -0
- package/dist/ui/components/separator.d.ts +5 -0
- package/dist/ui/components/separator.js +22 -0
- package/dist/ui/components/toast.d.ts +8 -0
- package/dist/ui/components/toast.js +39 -0
- package/dist/ui/globals.css +14 -2
- package/package.json +2 -2
- package/src/hooks/use-below-breakpoint.ts +21 -0
- package/src/hooks/use-confirm-delete.ts +43 -0
- package/src/hooks/use-toast.ts +29 -0
- package/src/index.ts +22 -1
- package/src/ui/components/animated-count.stories.tsx +1 -1
- package/src/ui/components/ascii.stories.tsx +1 -1
- package/src/ui/components/badge.stories.tsx +1 -1
- package/src/ui/components/blend-mode.stories.tsx +1 -1
- package/src/ui/components/blink.stories.tsx +1 -1
- package/src/ui/components/bottom-sheet.stories.tsx +43 -0
- package/src/ui/components/bottom-sheet.tsx +227 -0
- package/src/ui/components/button.stories.tsx +1 -1
- package/src/ui/components/card.stories.tsx +63 -0
- package/src/ui/components/card.tsx +85 -0
- package/src/ui/components/checkbox.stories.tsx +1 -1
- package/src/ui/components/checkbox.tsx +1 -1
- package/src/ui/components/command-block.stories.tsx +1 -1
- package/src/ui/components/confirm-dialog.stories.tsx +91 -0
- package/src/ui/components/confirm-dialog.tsx +130 -0
- package/src/ui/components/dialog.stories.tsx +169 -0
- package/src/ui/components/dialog.tsx +177 -0
- package/src/ui/components/dropdown-menu.stories.tsx +1 -1
- package/src/ui/components/fit-text/index.stories.tsx +1 -1
- package/src/ui/components/forms.stories.tsx +173 -0
- package/src/ui/components/graphs/index.stories.tsx +1 -1
- package/src/ui/components/hover-bg.stories.tsx +1 -1
- package/src/ui/components/image-distortion.stories.tsx +1 -1
- package/src/ui/components/input.stories.tsx +39 -0
- package/src/ui/components/input.tsx +20 -0
- package/src/ui/components/label.stories.tsx +26 -0
- package/src/ui/components/label.tsx +16 -0
- package/src/ui/components/list-item.stories.tsx +1 -1
- package/src/ui/components/poster.stories.tsx +1 -1
- package/src/ui/components/progress.stories.tsx +1 -1
- package/src/ui/components/scramble.stories.tsx +1 -1
- package/src/ui/components/segmented.stories.tsx +1 -1
- package/src/ui/components/select.stories.tsx +1 -1
- package/src/ui/components/separator.stories.tsx +33 -0
- package/src/ui/components/separator.tsx +24 -0
- package/src/ui/components/spinner.stories.tsx +1 -1
- package/src/ui/components/stats.stories.tsx +1 -1
- package/src/ui/components/switch.stories.tsx +1 -1
- package/src/ui/components/tabs.stories.tsx +1 -1
- package/src/ui/components/terminal-demo.stories.tsx +1 -1
- package/src/ui/components/theme-toggle.stories.tsx +1 -1
- package/src/ui/components/tier-card.stories.tsx +1 -1
- package/src/ui/components/toast.stories.tsx +55 -0
- package/src/ui/components/toast.tsx +49 -0
- package/src/ui/components/tv.stories.tsx +1 -1
- package/src/ui/components/watchlist.stories.tsx +1 -1
- package/src/ui/globals.css +14 -2
- package/dist/ui/components/modal/index.d.ts +0 -8
- package/dist/ui/components/modal/index.js +0 -35
- package/dist/ui/components/modal/modal.css +0 -36
- package/src/ui/components/modal/index.stories.tsx +0 -46
- package/src/ui/components/modal/index.tsx +0 -48
- package/src/ui/components/modal/modal.css +0 -36
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
-
import { createPortal } from "react-dom";
|
|
5
|
-
import { cn } from "../../../utils/index.js";
|
|
6
|
-
export function Modal({
|
|
7
|
-
children,
|
|
8
|
-
className,
|
|
9
|
-
id,
|
|
10
|
-
trigger,
|
|
11
|
-
...props
|
|
12
|
-
}) {
|
|
13
|
-
const ref = useRef(null);
|
|
14
|
-
const [mounted, setMounted] = useState(false);
|
|
15
|
-
useEffect(() => setMounted(true), []);
|
|
16
|
-
const open = useCallback(() => ref.current?.showModal(), []);
|
|
17
|
-
const close = useCallback(() => ref.current?.close(), []);
|
|
18
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
-
trigger({ close, open }),
|
|
20
|
-
mounted && createPortal(
|
|
21
|
-
/* @__PURE__ */ jsx(
|
|
22
|
-
"dialog",
|
|
23
|
-
{
|
|
24
|
-
className: cn("modal", className),
|
|
25
|
-
onClick: (e) => e.target === e.currentTarget && close(),
|
|
26
|
-
...{ id, ref },
|
|
27
|
-
...props,
|
|
28
|
-
children: /* @__PURE__ */ jsx("div", { className: "modal-body post", children })
|
|
29
|
-
}
|
|
30
|
-
),
|
|
31
|
-
document.body
|
|
32
|
-
)
|
|
33
|
-
] });
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiPHN0ZGluPiJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiJ3VzZSBjbGllbnQnXG5cbmltcG9ydCB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BQUM7QUFBQTtBQUFBLFVBQ0MsV0FBVyxHQUFHLFNBQVMsU0FBUztBQUFBLFVBQ2hDLFNBQVMsT0FBSyxFQUFFLFdBQVcsRUFBRSxpQkFBaUIsTUFBTTtBQUFBLFVBQ25ELEdBQUcsRUFBRSxJQUFJLElBQUk7QUFBQSxVQUNiLEdBQUc7QUFBQSxVQUVKLDhCQUFDLFNBQUksV0FBVSxtQkFBbUIsVUFBUztBQUFBO0FBQUEsTUFDN0M7QUFBQSxNQUNBLFNBQVM7QUFBQSxJQUNYO0FBQUEsS0FDSjtBQUVKOyIsCiAgIm5hbWVzIjogW10KfQo=
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
.modal {
|
|
2
|
-
@apply bg-foreground-base text-background-base z-50 m-auto max-h-[85dvh] max-w-[90dvw] p-0 opacity-0 outline-none;
|
|
3
|
-
|
|
4
|
-
transition:
|
|
5
|
-
opacity 0.25s ease-out,
|
|
6
|
-
overlay 0.25s ease-out allow-discrete,
|
|
7
|
-
display 0.25s ease-out allow-discrete;
|
|
8
|
-
|
|
9
|
-
&::backdrop {
|
|
10
|
-
@apply bg-foreground-base/2 backdrop-blur-xs;
|
|
11
|
-
|
|
12
|
-
transition:
|
|
13
|
-
opacity 0.25s ease-out,
|
|
14
|
-
overlay 0.25s ease-out allow-discrete,
|
|
15
|
-
display 0.25s ease-out allow-discrete;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&[open] {
|
|
19
|
-
@apply opacity-100;
|
|
20
|
-
|
|
21
|
-
&::backdrop {
|
|
22
|
-
@apply opacity-100;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@starting-style {
|
|
27
|
-
&[open],
|
|
28
|
-
&[open]::backdrop {
|
|
29
|
-
@apply opacity-0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.modal-body {
|
|
35
|
-
@apply overflow-y-auto p-8 font-mono;
|
|
36
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
|
|
3
|
-
import { Button } from '../button'
|
|
4
|
-
import { EyeIcon } from '../icons'
|
|
5
|
-
import { Modal } from '../modal'
|
|
6
|
-
|
|
7
|
-
const meta: Meta<typeof Modal> = {
|
|
8
|
-
component: Modal,
|
|
9
|
-
title: 'Components/Modal'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default meta
|
|
13
|
-
|
|
14
|
-
type Story = StoryObj<typeof Modal>
|
|
15
|
-
|
|
16
|
-
export const Default: Story = {
|
|
17
|
-
render: () => (
|
|
18
|
-
<Modal
|
|
19
|
-
trigger={({ open }) => (
|
|
20
|
-
<Button onClick={open} prefix={<EyeIcon />}>
|
|
21
|
-
Open Modal
|
|
22
|
-
</Button>
|
|
23
|
-
)}
|
|
24
|
-
>
|
|
25
|
-
<h2>Modal Content</h2>
|
|
26
|
-
<p>Click outside or press Escape to close.</p>
|
|
27
|
-
</Modal>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const WithBody: Story = {
|
|
32
|
-
render: () => (
|
|
33
|
-
<Modal
|
|
34
|
-
trigger={({ open }) => <Button onClick={open}>Open with body</Button>}
|
|
35
|
-
>
|
|
36
|
-
<h2>A bigger modal</h2>
|
|
37
|
-
|
|
38
|
-
<p>
|
|
39
|
-
Native <code><dialog></code> under the hood. It portals into{' '}
|
|
40
|
-
<code>document.body</code>, so stacking context isn't a concern.
|
|
41
|
-
</p>
|
|
42
|
-
|
|
43
|
-
<p>Press Escape or click the backdrop to dismiss.</p>
|
|
44
|
-
</Modal>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
4
|
-
import { createPortal } from 'react-dom'
|
|
5
|
-
|
|
6
|
-
import { cn } from '../../../utils'
|
|
7
|
-
|
|
8
|
-
export function Modal({
|
|
9
|
-
children,
|
|
10
|
-
className,
|
|
11
|
-
id,
|
|
12
|
-
trigger,
|
|
13
|
-
...props
|
|
14
|
-
}: ModalProps) {
|
|
15
|
-
const ref = useRef<HTMLDialogElement>(null)
|
|
16
|
-
const [mounted, setMounted] = useState(false)
|
|
17
|
-
|
|
18
|
-
useEffect(() => setMounted(true), [])
|
|
19
|
-
|
|
20
|
-
const open = useCallback(() => ref.current?.showModal(), [])
|
|
21
|
-
const close = useCallback(() => ref.current?.close(), [])
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<>
|
|
25
|
-
{trigger({ close, open })}
|
|
26
|
-
|
|
27
|
-
{mounted &&
|
|
28
|
-
createPortal(
|
|
29
|
-
<dialog
|
|
30
|
-
className={cn('modal', className)}
|
|
31
|
-
onClick={e => e.target === e.currentTarget && close()}
|
|
32
|
-
{...{ id, ref }}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
<div className="modal-body post">{children}</div>
|
|
36
|
-
</dialog>,
|
|
37
|
-
document.body
|
|
38
|
-
)}
|
|
39
|
-
</>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface ModalProps extends Omit<React.ComponentProps<'dialog'>, 'open'> {
|
|
44
|
-
trigger: (controls: {
|
|
45
|
-
close: () => void
|
|
46
|
-
open: () => void
|
|
47
|
-
}) => React.ReactNode
|
|
48
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
.modal {
|
|
2
|
-
@apply bg-foreground-base text-background-base z-50 m-auto max-h-[85dvh] max-w-[90dvw] p-0 opacity-0 outline-none;
|
|
3
|
-
|
|
4
|
-
transition:
|
|
5
|
-
opacity 0.25s ease-out,
|
|
6
|
-
overlay 0.25s ease-out allow-discrete,
|
|
7
|
-
display 0.25s ease-out allow-discrete;
|
|
8
|
-
|
|
9
|
-
&::backdrop {
|
|
10
|
-
@apply bg-foreground-base/2 backdrop-blur-xs;
|
|
11
|
-
|
|
12
|
-
transition:
|
|
13
|
-
opacity 0.25s ease-out,
|
|
14
|
-
overlay 0.25s ease-out allow-discrete,
|
|
15
|
-
display 0.25s ease-out allow-discrete;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&[open] {
|
|
19
|
-
@apply opacity-100;
|
|
20
|
-
|
|
21
|
-
&::backdrop {
|
|
22
|
-
@apply opacity-100;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@starting-style {
|
|
27
|
-
&[open],
|
|
28
|
-
&[open]::backdrop {
|
|
29
|
-
@apply opacity-0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.modal-body {
|
|
35
|
-
@apply overflow-y-auto p-8 font-mono;
|
|
36
|
-
}
|