sheerly 0.0.1 → 0.0.3
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/lib/accordion.d.ts +13 -4
- package/lib/alert.d.ts +22 -7
- package/lib/avatar.css +1 -1
- package/lib/avatar.d.ts +21 -8
- package/lib/badge.d.ts +14 -4
- package/lib/breadcrumb.d.ts +49 -8
- package/lib/button.css +1 -1
- package/lib/button.d.ts +13 -4
- package/lib/card.d.ts +32 -12
- package/lib/carousel.d.ts +13 -7
- package/lib/checkbox.d.ts +6 -0
- package/lib/dialog.d.ts +20 -8
- package/lib/dropdown-menu.d.ts +39 -17
- package/lib/hover-card.d.ts +15 -6
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +308 -300
- package/lib/input.css +1 -1
- package/lib/input.d.ts +6 -0
- package/lib/kbd.d.ts +10 -3
- package/lib/label.css +1 -1
- package/lib/label.d.ts +6 -0
- package/lib/pagination.d.ts +52 -13
- package/lib/popover.d.ts +15 -6
- package/lib/progress.d.ts +6 -0
- package/lib/radio.d.ts +13 -3
- package/lib/scrollbar.css +1 -0
- package/lib/scrollbar.d.ts +17 -0
- package/lib/select.css +1 -1
- package/lib/select.d.ts +6 -0
- package/lib/separator.d.ts +14 -4
- package/lib/sheet.d.ts +19 -6
- package/lib/skeleton.d.ts +12 -3
- package/lib/slider.d.ts +6 -0
- package/lib/spinner.d.ts +10 -4
- package/lib/switch.d.ts +6 -0
- package/lib/table.css +1 -1
- package/lib/table.d.ts +14 -3
- package/lib/tabs.d.ts +37 -11
- package/lib/textarea.d.ts +6 -0
- package/lib/toggle.d.ts +7 -0
- package/lib/tooltip.d.ts +15 -6
- package/lib/typography.d.ts +12 -4
- package/lib/utils/polymorphic.d.ts +14 -0
- package/package.json +34 -33
- package/src/accordion.tsx +20 -6
- package/src/alert.tsx +52 -14
- package/src/avatar.css +0 -1
- package/src/avatar.tsx +44 -15
- package/src/badge.tsx +34 -16
- package/src/breadcrumb.tsx +97 -26
- package/src/button.css +1 -0
- package/src/button.tsx +44 -27
- package/src/card.tsx +82 -23
- package/src/carousel.tsx +28 -11
- package/src/checkbox.tsx +7 -1
- package/src/dialog.tsx +55 -16
- package/src/dropdown-menu.tsx +115 -33
- package/src/hover-card.tsx +28 -9
- package/src/index.css +1 -0
- package/src/index.ts +1 -1
- package/src/input.css +1 -0
- package/src/input.tsx +7 -1
- package/src/kbd.tsx +17 -5
- package/src/label.css +1 -0
- package/src/label.tsx +7 -1
- package/src/pagination.tsx +107 -35
- package/src/popover.tsx +28 -9
- package/src/progress.tsx +7 -1
- package/src/radio.tsx +20 -5
- package/src/scrollbar.css +56 -0
- package/src/scrollbar.tsx +28 -0
- package/src/select.css +24 -0
- package/src/select.tsx +7 -1
- package/src/separator.tsx +23 -7
- package/src/sheet.tsx +53 -13
- package/src/skeleton.tsx +19 -5
- package/src/slider.tsx +7 -1
- package/src/spinner.tsx +21 -8
- package/src/switch.tsx +7 -1
- package/src/table.css +0 -1
- package/src/table.tsx +21 -5
- package/src/tabs.tsx +65 -25
- package/src/textarea.tsx +7 -1
- package/src/toggle.tsx +8 -1
- package/src/tooltip.tsx +28 -9
- package/src/typography.tsx +19 -5
- package/src/utils/polymorphic.ts +19 -0
- /package/lib/{cn.d.ts → utils/cn.d.ts} +0 -0
- /package/src/{cn.ts → utils/cn.ts} +0 -0
package/src/switch.tsx
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { InputHTMLAttributes } from 'react'
|
|
2
|
-
import { cn } from './cn'
|
|
2
|
+
import { cn } from './utils/cn'
|
|
3
3
|
|
|
4
4
|
export interface SwitchProps
|
|
5
5
|
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'role'> {
|
|
6
6
|
'data-size'?: 'default' | 'sm'
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A toggle switch (checkbox with `role="switch"`).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <Switch defaultChecked />
|
|
14
|
+
*/
|
|
9
15
|
export function Switch({ className, ...props }: SwitchProps) {
|
|
10
16
|
return (
|
|
11
17
|
<input
|
package/src/table.css
CHANGED
package/src/table.tsx
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { cn } from './cn'
|
|
1
|
+
import type { ElementType, TableHTMLAttributes } from 'react'
|
|
2
|
+
import { cn } from './utils/cn'
|
|
3
|
+
import type { PolymorphicProps } from './utils/polymorphic'
|
|
3
4
|
|
|
4
|
-
export type TableContainerProps =
|
|
5
|
+
export type TableContainerProps<T extends ElementType = 'div'> = PolymorphicProps<T>
|
|
5
6
|
|
|
6
|
-
export function TableContainer
|
|
7
|
-
|
|
7
|
+
export function TableContainer<T extends ElementType = 'div'>({
|
|
8
|
+
as,
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: TableContainerProps<T>) {
|
|
12
|
+
const Tag = as ?? 'div'
|
|
13
|
+
return <Tag className={cn('sheerly-table-container', className)} {...props} />
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
export type TableProps = TableHTMLAttributes<HTMLTableElement>
|
|
11
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A data table. Use semantic HTML inside (no classes on inner elements); wrap
|
|
20
|
+
* in a <TableContainer> for horizontal overflow scroll.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <Table>
|
|
24
|
+
* <thead><tr><th>Name</th></tr></thead>
|
|
25
|
+
* <tbody><tr><td>Ada</td></tr></tbody>
|
|
26
|
+
* </Table>
|
|
27
|
+
*/
|
|
12
28
|
export function Table({ className, ...props }: TableProps) {
|
|
13
29
|
return <table className={cn('sheerly-table', className)} {...props} />
|
|
14
30
|
}
|
package/src/tabs.tsx
CHANGED
|
@@ -1,38 +1,78 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { cn } from './cn'
|
|
1
|
+
import type { ElementType } from 'react'
|
|
2
|
+
import { cn } from './utils/cn'
|
|
3
|
+
import type { PolymorphicProps } from './utils/polymorphic'
|
|
3
4
|
|
|
4
|
-
export type TabsProps =
|
|
5
|
+
export type TabsProps<T extends ElementType = 'div'> = PolymorphicProps<T>
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A tabbed interface. Compose a <TabsList> of <TabsTrigger>s with matching
|
|
9
|
+
* <TabsContent> panels (hide inactive panels with `hidden`).
|
|
10
|
+
*
|
|
11
|
+
* Polymorphic: pass `as` to change the rendered tag (defaults to `div`).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Tabs>
|
|
15
|
+
* <TabsList>
|
|
16
|
+
* <TabsTrigger aria-selected>Account</TabsTrigger>
|
|
17
|
+
* <TabsTrigger>Password</TabsTrigger>
|
|
18
|
+
* </TabsList>
|
|
19
|
+
* <TabsContent>…</TabsContent>
|
|
20
|
+
* <TabsContent hidden>…</TabsContent>
|
|
21
|
+
* </Tabs>
|
|
22
|
+
*/
|
|
23
|
+
export function Tabs<T extends ElementType = 'div'>({
|
|
24
|
+
as,
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}: TabsProps<T>) {
|
|
28
|
+
const Tag = as ?? 'div'
|
|
29
|
+
return <Tag className={cn('sheerly-tabs', className)} {...props} />
|
|
8
30
|
}
|
|
9
31
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
}
|
|
32
|
+
export type TabsListProps<T extends ElementType = 'div'> = PolymorphicProps<
|
|
33
|
+
T,
|
|
34
|
+
{ 'data-variant'?: 'line' }
|
|
35
|
+
>
|
|
13
36
|
|
|
14
|
-
|
|
15
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Polymorphic: pass `as` to change the rendered tag (defaults to `div`).
|
|
39
|
+
*/
|
|
40
|
+
export function TabsList<T extends ElementType = 'div'>({
|
|
41
|
+
as,
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}: TabsListProps<T>) {
|
|
45
|
+
const Tag = as ?? 'div'
|
|
46
|
+
return <Tag role="tablist" className={cn('sheerly-tabs-list', className)} {...props} />
|
|
16
47
|
}
|
|
17
48
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
}
|
|
49
|
+
export type TabsTriggerProps<T extends ElementType = 'button'> = PolymorphicProps<
|
|
50
|
+
T,
|
|
51
|
+
{ 'data-state'?: 'active' }
|
|
52
|
+
>
|
|
21
53
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Polymorphic: pass `as` to change the rendered tag (defaults to `button`).
|
|
56
|
+
*/
|
|
57
|
+
export function TabsTrigger<T extends ElementType = 'button'>({
|
|
58
|
+
as,
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
}: TabsTriggerProps<T>) {
|
|
62
|
+
const Tag = as ?? 'button'
|
|
63
|
+
return <Tag role="tab" className={cn('sheerly-tabs-trigger', className)} {...props} />
|
|
26
64
|
}
|
|
27
65
|
|
|
28
|
-
export type TabsContentProps =
|
|
66
|
+
export type TabsContentProps<T extends ElementType = 'div'> = PolymorphicProps<T>
|
|
29
67
|
|
|
30
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Polymorphic: pass `as` to change the rendered tag (defaults to `div`).
|
|
70
|
+
*/
|
|
71
|
+
export function TabsContent<T extends ElementType = 'div'>({
|
|
72
|
+
as,
|
|
31
73
|
className,
|
|
32
|
-
role = 'tabpanel',
|
|
33
74
|
...props
|
|
34
|
-
}: TabsContentProps) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
75
|
+
}: TabsContentProps<T>) {
|
|
76
|
+
const Tag = as ?? 'div'
|
|
77
|
+
return <Tag role="tabpanel" className={cn('sheerly-tabs-content', className)} {...props} />
|
|
78
|
+
}
|
package/src/textarea.tsx
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { TextareaHTMLAttributes } from 'react'
|
|
2
|
-
import { cn } from './cn'
|
|
2
|
+
import { cn } from './utils/cn'
|
|
3
3
|
|
|
4
4
|
export type TextareaProps = TextareaHTMLAttributes<HTMLTextAreaElement>
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* A multiline text field. Auto-grows with content (`field-sizing: content`).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Textarea placeholder="Type your message…" />
|
|
11
|
+
*/
|
|
6
12
|
export function Textarea({ className, ...props }: TextareaProps) {
|
|
7
13
|
return <textarea className={cn('sheerly-textarea', className)} {...props} />
|
|
8
14
|
}
|
package/src/toggle.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChangeEventHandler, LabelHTMLAttributes, ReactNode } from 'react'
|
|
2
|
-
import { cn } from './cn'
|
|
2
|
+
import { cn } from './utils/cn'
|
|
3
3
|
|
|
4
4
|
export interface ToggleProps
|
|
5
5
|
extends Omit<LabelHTMLAttributes<HTMLLabelElement>, 'onChange'> {
|
|
@@ -17,6 +17,13 @@ export interface ToggleProps
|
|
|
17
17
|
children?: ReactNode
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* A two-state toggle button. Works uncontrolled (no JS) or controlled via
|
|
22
|
+
* `pressed` / `onPressedChange`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <Toggle defaultPressed data-variant="outline">Bold</Toggle>
|
|
26
|
+
*/
|
|
20
27
|
export function Toggle({
|
|
21
28
|
className,
|
|
22
29
|
pressed,
|
package/src/tooltip.tsx
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { cn } from './cn'
|
|
1
|
+
import type { ElementType } from 'react'
|
|
2
|
+
import { cn } from './utils/cn'
|
|
3
|
+
import type { PolymorphicProps } from './utils/polymorphic'
|
|
3
4
|
|
|
4
|
-
export type TooltipProps =
|
|
5
|
+
export type TooltipProps<T extends ElementType = 'span'> = PolymorphicProps<T>
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper carrying the anchor. Nest the trigger + content inside.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Tooltip>
|
|
12
|
+
* <Button interestfor="tt">Hover me</Button>
|
|
13
|
+
* <TooltipContent id="tt" popover="hint">More info</TooltipContent>
|
|
14
|
+
* </Tooltip>
|
|
15
|
+
*/
|
|
16
|
+
export function Tooltip<T extends ElementType = 'span'>({
|
|
17
|
+
as,
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
}: TooltipProps<T>) {
|
|
21
|
+
const Tag = as ?? 'span'
|
|
22
|
+
return <Tag className={cn('sheerly-tooltip', className)} {...props} />
|
|
9
23
|
}
|
|
10
24
|
|
|
11
|
-
export type TooltipContentProps =
|
|
25
|
+
export type TooltipContentProps<T extends ElementType = 'span'> = PolymorphicProps<T>
|
|
12
26
|
|
|
13
27
|
/** The floating label. Give it `popover="hint"` and an `id` matched by the trigger's `interestfor`. */
|
|
14
|
-
export function TooltipContent
|
|
15
|
-
|
|
28
|
+
export function TooltipContent<T extends ElementType = 'span'>({
|
|
29
|
+
as,
|
|
30
|
+
className,
|
|
31
|
+
...props
|
|
32
|
+
}: TooltipContentProps<T>) {
|
|
33
|
+
const Tag = as ?? 'span'
|
|
34
|
+
return <Tag className={cn('sheerly-tooltip-content', className)} {...props} />
|
|
16
35
|
}
|
package/src/typography.tsx
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { cn } from './cn'
|
|
1
|
+
import type { ElementType } from 'react'
|
|
2
|
+
import { cn } from './utils/cn'
|
|
3
|
+
import type { PolymorphicProps } from './utils/polymorphic'
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export type TypographyProps<T extends ElementType = 'div'> = PolymorphicProps<T>
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* A prose wrapper. Unlike shadcn (per-element utility classes), Sheerly styles
|
|
8
9
|
* every child element (h1–h4, p, a, blockquote, ul/ol, li, code, table, …) via
|
|
9
10
|
* one `.sheerly-typography` class — just render semantic HTML inside it.
|
|
11
|
+
*
|
|
12
|
+
* Polymorphic: pass `as` to change the rendered tag (defaults to `div`).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <Typography as="article">
|
|
16
|
+
* <h1>Title</h1>
|
|
17
|
+
* <p>Some <a href="#">prose</a> with a <code>token</code>.</p>
|
|
18
|
+
* </Typography>
|
|
10
19
|
*/
|
|
11
|
-
export function Typography
|
|
12
|
-
|
|
20
|
+
export function Typography<T extends ElementType = 'div'>({
|
|
21
|
+
as,
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: TypographyProps<T>) {
|
|
25
|
+
const Tag = as ?? 'div'
|
|
26
|
+
return <Tag className={cn('sheerly-typography', className)} {...props} />
|
|
13
27
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ElementType } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for a polymorphic component: an optional `as` that swaps the rendered
|
|
5
|
+
* element, with the remaining props inferred from that element (so `href` is
|
|
6
|
+
* valid & checked when `as="a"`, etc.).
|
|
7
|
+
*
|
|
8
|
+
* `Extra` merges component-specific props (e.g. typed `data-*` unions) on top.
|
|
9
|
+
*
|
|
10
|
+
* No hooks, no `forwardRef` — matches Sheerly's thin, hookless wrapper style.
|
|
11
|
+
*/
|
|
12
|
+
export type PolymorphicProps<
|
|
13
|
+
T extends ElementType,
|
|
14
|
+
Extra = object,
|
|
15
|
+
> = {
|
|
16
|
+
/** The element or component to render. */
|
|
17
|
+
as?: T
|
|
18
|
+
} & Extra &
|
|
19
|
+
Omit<ComponentPropsWithoutRef<T>, 'as' | keyof Extra>
|
|
File without changes
|
|
File without changes
|