@gentleduck/registry-ui 0.2.11 → 0.2.12
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/.turbo/turbo-test.log +24 -6
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/carousel/__test__/carousel.test.tsx +27 -0
- package/src/carousel/carousel.tsx +4 -4
- package/src/pagination/__test__/pagination.test.tsx +35 -0
- package/src/pagination/pagination.tsx +16 -16
- package/src/sidebar/__test__/sidebar.test.tsx +39 -0
- package/src/sidebar/sidebar.tsx +2 -2
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
$ bun test
|
|
2
2
|
bun test v1.3.5 (1e86cebd)
|
|
3
3
|
|
|
4
|
+
::group::src/pagination/__test__/pagination.test.tsx:
|
|
5
|
+
(pass) registry-ui pagination > PaginationWrapper prefers provided button icons over the default chevrons [18.00ms]
|
|
6
|
+
(pass) registry-ui pagination > PaginationWrapper still renders default chevrons when icons are not provided [4.00ms]
|
|
7
|
+
|
|
8
|
+
::endgroup::
|
|
9
|
+
|
|
10
|
+
::group::src/sidebar/__test__/sidebar.test.tsx:
|
|
11
|
+
(pass) registry-ui sidebar > SidebarTrigger prefers a provided icon over the default panel icon [1.00ms]
|
|
12
|
+
(pass) registry-ui sidebar > SidebarTrigger still renders the default panel icon when no icon is provided
|
|
13
|
+
|
|
14
|
+
::endgroup::
|
|
15
|
+
|
|
4
16
|
::group::src/chart/__test__/chart.test.tsx:
|
|
5
|
-
(pass) registry-ui chart > ChartContainer server render does not emit invalid size warnings [
|
|
17
|
+
(pass) registry-ui chart > ChartContainer server render does not emit invalid size warnings [11.00ms]
|
|
18
|
+
|
|
19
|
+
::endgroup::
|
|
20
|
+
|
|
21
|
+
::group::src/carousel/__test__/carousel.test.tsx:
|
|
22
|
+
(pass) registry-ui carousel > CarouselPrevious prefers a provided icon over the default arrow icon [2.00ms]
|
|
23
|
+
(pass) registry-ui carousel > CarouselNext still renders the default arrow icon when no icon is provided [1.00ms]
|
|
6
24
|
|
|
7
25
|
::endgroup::
|
|
8
26
|
|
|
9
27
|
::group::src/button/__test__/button.test.tsx:
|
|
10
|
-
(pass) registry-ui button > buttonVariants returns the shared base styles and defaults
|
|
28
|
+
(pass) registry-ui button > buttonVariants returns the shared base styles and defaults
|
|
11
29
|
(pass) registry-ui button > buttonVariants applies explicit variant and size overrides
|
|
12
30
|
(pass) registry-ui button > button exports keep stable display names
|
|
13
|
-
(pass) registry-ui button > Button renders loading state as a busy disabled native button [
|
|
31
|
+
(pass) registry-ui button > Button renders loading state as a busy disabled native button [1.00ms]
|
|
14
32
|
(pass) registry-ui button > Button preserves explicit disabled state even when loading is false
|
|
15
33
|
(pass) registry-ui button > Button collapses into icon-only mode and hides secondary content [1.00ms]
|
|
16
34
|
(pass) registry-ui button > AnimationIcon renders left and right placements around children
|
|
17
35
|
|
|
18
36
|
::endgroup::
|
|
19
37
|
|
|
20
|
-
|
|
38
|
+
14 pass
|
|
21
39
|
0 fail
|
|
22
|
-
|
|
23
|
-
Ran
|
|
40
|
+
43 expect() calls
|
|
41
|
+
Ran 14 tests across 5 files. [439.00ms]
|
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
4
|
+
import { Carousel, CarouselNext, CarouselPrevious } from '../carousel'
|
|
5
|
+
|
|
6
|
+
describe('registry-ui carousel', () => {
|
|
7
|
+
test('CarouselPrevious prefers a provided icon over the default arrow icon', () => {
|
|
8
|
+
const html = renderToStaticMarkup(
|
|
9
|
+
<Carousel>
|
|
10
|
+
<CarouselPrevious icon={<span data-icon="custom-prev">P</span>} />
|
|
11
|
+
</Carousel>,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
expect(html).toContain('data-icon="custom-prev"')
|
|
15
|
+
expect(html).not.toContain('lucide-arrow-left')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('CarouselNext still renders the default arrow icon when no icon is provided', () => {
|
|
19
|
+
const html = renderToStaticMarkup(
|
|
20
|
+
<Carousel>
|
|
21
|
+
<CarouselNext />
|
|
22
|
+
</Carousel>,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
expect(html).toContain('lucide-arrow-right')
|
|
26
|
+
})
|
|
27
|
+
})
|
|
@@ -154,7 +154,7 @@ CarouselItem.displayName = 'CarouselItem'
|
|
|
154
154
|
const CarouselPrevious = React.forwardRef<
|
|
155
155
|
React.ComponentRef<typeof Button>,
|
|
156
156
|
React.ComponentPropsWithoutRef<typeof Button> & { text?: string }
|
|
157
|
-
>(({ className, variant = 'outline', size = 'icon', text = 'Previous slide', ...props }, ref) => {
|
|
157
|
+
>(({ className, icon, variant = 'outline', size = 'icon', text = 'Previous slide', ...props }, ref) => {
|
|
158
158
|
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
159
159
|
|
|
160
160
|
return (
|
|
@@ -172,8 +172,8 @@ const CarouselPrevious = React.forwardRef<
|
|
|
172
172
|
ref={ref}
|
|
173
173
|
size={size}
|
|
174
174
|
variant={variant}
|
|
175
|
+
icon={icon === undefined ? <ArrowLeft aria-hidden="true" className="h-4 w-4 rtl:rotate-180" /> : icon}
|
|
175
176
|
{...props}>
|
|
176
|
-
<ArrowLeft aria-hidden="true" className="h-4 w-4 rtl:rotate-180" />
|
|
177
177
|
<span className="sr-only">{text}</span>
|
|
178
178
|
</Button>
|
|
179
179
|
)
|
|
@@ -183,7 +183,7 @@ CarouselPrevious.displayName = 'CarouselPrevious'
|
|
|
183
183
|
const CarouselNext = React.forwardRef<
|
|
184
184
|
React.ComponentRef<typeof Button>,
|
|
185
185
|
React.ComponentPropsWithoutRef<typeof Button> & { text?: string }
|
|
186
|
-
>(({ className, variant = 'outline', size = 'icon', text = 'Next slide', ...props }, ref) => {
|
|
186
|
+
>(({ className, icon, variant = 'outline', size = 'icon', text = 'Next slide', ...props }, ref) => {
|
|
187
187
|
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
188
188
|
|
|
189
189
|
return (
|
|
@@ -201,8 +201,8 @@ const CarouselNext = React.forwardRef<
|
|
|
201
201
|
ref={ref}
|
|
202
202
|
size={size}
|
|
203
203
|
variant={variant}
|
|
204
|
+
icon={icon === undefined ? <ArrowRight aria-hidden="true" className="h-4 w-4 rtl:rotate-180" /> : icon}
|
|
204
205
|
{...props}>
|
|
205
|
-
<ArrowRight aria-hidden="true" className="h-4 w-4 rtl:rotate-180" />
|
|
206
206
|
<span className="sr-only">{text}</span>
|
|
207
207
|
</Button>
|
|
208
208
|
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
4
|
+
import { PaginationWrapper } from '../pagination'
|
|
5
|
+
|
|
6
|
+
describe('registry-ui pagination', () => {
|
|
7
|
+
test('PaginationWrapper prefers provided button icons over the default chevrons', () => {
|
|
8
|
+
const html = renderToStaticMarkup(
|
|
9
|
+
<PaginationWrapper
|
|
10
|
+
left={{ icon: <span data-icon="left">L</span> }}
|
|
11
|
+
maxLeft={{ icon: <span data-icon="max-left">ML</span> }}
|
|
12
|
+
right={{ icon: <span data-icon="right">R</span> }}
|
|
13
|
+
maxRight={{ icon: <span data-icon="max-right">MR</span> }}
|
|
14
|
+
/>,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
expect(html).toContain('data-icon="left"')
|
|
18
|
+
expect(html).toContain('data-icon="max-left"')
|
|
19
|
+
expect(html).toContain('data-icon="right"')
|
|
20
|
+
expect(html).toContain('data-icon="max-right"')
|
|
21
|
+
expect(html).not.toContain('lucide-chevron-left')
|
|
22
|
+
expect(html).not.toContain('lucide-chevron-right')
|
|
23
|
+
expect(html).not.toContain('lucide-chevrons-left')
|
|
24
|
+
expect(html).not.toContain('lucide-chevrons-right')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('PaginationWrapper still renders default chevrons when icons are not provided', () => {
|
|
28
|
+
const html = renderToStaticMarkup(<PaginationWrapper />)
|
|
29
|
+
|
|
30
|
+
expect(html).toContain('lucide-chevron-left')
|
|
31
|
+
expect(html).toContain('lucide-chevron-right')
|
|
32
|
+
expect(html).toContain('lucide-chevrons-left')
|
|
33
|
+
expect(html).toContain('lucide-chevrons-right')
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -121,10 +121,10 @@ const PaginationWrapper = (props: DuckPaginationProps) => {
|
|
|
121
121
|
const { className: wrapperClassName, dir, ...wrapperProps } = props.wrapper ?? {}
|
|
122
122
|
const { className: contentClassName, ...contentProps } = props.content ?? {}
|
|
123
123
|
const { className: itemClassName, ...itemProps } = props.item ?? {}
|
|
124
|
-
const { className: rightClassName, ...rightProps } = props.right ?? {}
|
|
125
|
-
const { className: maxRightClassName, ...maxRightProps } = props.maxRight ?? {}
|
|
126
|
-
const { className: leftClassName, ...leftProps } = props.left ?? {}
|
|
127
|
-
const { className: maxLeftClassName, ...maxLeftProps } = props.maxLeft ?? {}
|
|
124
|
+
const { className: rightClassName, icon: rightIcon, ...rightProps } = props.right ?? {}
|
|
125
|
+
const { className: maxRightClassName, icon: maxRightIcon, ...maxRightProps } = props.maxRight ?? {}
|
|
126
|
+
const { className: leftClassName, icon: leftIcon, ...leftProps } = props.left ?? {}
|
|
127
|
+
const { className: maxLeftClassName, icon: maxLeftIcon, ...maxLeftProps } = props.maxLeft ?? {}
|
|
128
128
|
const direction = useDirection(dir as Direction)
|
|
129
129
|
const StartIcon = direction === 'rtl' ? ChevronRightIcon : ChevronLeftIcon
|
|
130
130
|
const EndIcon = direction === 'rtl' ? ChevronLeftIcon : ChevronRightIcon
|
|
@@ -138,41 +138,41 @@ const PaginationWrapper = (props: DuckPaginationProps) => {
|
|
|
138
138
|
<Button
|
|
139
139
|
aria-label="Go to first page"
|
|
140
140
|
className={cn('w-[32px] p-0', maxLeftClassName)}
|
|
141
|
+
icon={maxLeftIcon === undefined ? <StartDoubleIcon aria-hidden="true" /> : maxLeftIcon}
|
|
141
142
|
size="sm"
|
|
142
143
|
variant="outline"
|
|
143
|
-
{...maxLeftProps}
|
|
144
|
-
|
|
145
|
-
</Button>
|
|
144
|
+
{...maxLeftProps}
|
|
145
|
+
/>
|
|
146
146
|
</PaginationItem>
|
|
147
147
|
<PaginationItem className={cn(itemClassName)} {...itemProps}>
|
|
148
148
|
<Button
|
|
149
149
|
aria-label="Go to previous page"
|
|
150
150
|
className={cn('w-[32px] p-0', leftClassName)}
|
|
151
|
+
icon={leftIcon === undefined ? <StartIcon aria-hidden="true" /> : leftIcon}
|
|
151
152
|
size="sm"
|
|
152
153
|
variant="outline"
|
|
153
|
-
{...leftProps}
|
|
154
|
-
|
|
155
|
-
</Button>
|
|
154
|
+
{...leftProps}
|
|
155
|
+
/>
|
|
156
156
|
</PaginationItem>
|
|
157
157
|
<PaginationItem className={cn(itemClassName)} {...itemProps}>
|
|
158
158
|
<Button
|
|
159
159
|
aria-label="Go to next page"
|
|
160
160
|
className={cn('w-[32px] p-0', rightClassName)}
|
|
161
|
+
icon={rightIcon === undefined ? <EndIcon aria-hidden="true" /> : rightIcon}
|
|
161
162
|
size="sm"
|
|
162
163
|
variant="outline"
|
|
163
|
-
{...rightProps}
|
|
164
|
-
|
|
165
|
-
</Button>
|
|
164
|
+
{...rightProps}
|
|
165
|
+
/>
|
|
166
166
|
</PaginationItem>
|
|
167
167
|
<PaginationItem className={cn(itemClassName)} {...itemProps}>
|
|
168
168
|
<Button
|
|
169
169
|
aria-label="Go to last page"
|
|
170
170
|
className={cn('w-[32px] p-0', maxRightClassName)}
|
|
171
|
+
icon={maxRightIcon === undefined ? <EndDoubleIcon aria-hidden="true" /> : maxRightIcon}
|
|
171
172
|
size="sm"
|
|
172
173
|
variant="outline"
|
|
173
|
-
{...maxRightProps}
|
|
174
|
-
|
|
175
|
-
</Button>
|
|
174
|
+
{...maxRightProps}
|
|
175
|
+
/>
|
|
176
176
|
</PaginationItem>
|
|
177
177
|
</PaginationContent>
|
|
178
178
|
</Pagination>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
4
|
+
import { SidebarTrigger } from '../sidebar'
|
|
5
|
+
import { SidebarContext } from '../sidebar.hooks'
|
|
6
|
+
|
|
7
|
+
const sidebarContextValue = {
|
|
8
|
+
state: 'expanded' as const,
|
|
9
|
+
open: true,
|
|
10
|
+
setOpen: () => {},
|
|
11
|
+
openMobile: false,
|
|
12
|
+
setOpenMobile: () => {},
|
|
13
|
+
isMobile: false,
|
|
14
|
+
toggleSidebar: () => {},
|
|
15
|
+
dir: 'ltr' as const,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('registry-ui sidebar', () => {
|
|
19
|
+
test('SidebarTrigger prefers a provided icon over the default panel icon', () => {
|
|
20
|
+
const html = renderToStaticMarkup(
|
|
21
|
+
<SidebarContext.Provider value={sidebarContextValue}>
|
|
22
|
+
<SidebarTrigger icon={<span data-icon="custom">C</span>} />
|
|
23
|
+
</SidebarContext.Provider>,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
expect(html).toContain('data-icon="custom"')
|
|
27
|
+
expect(html).not.toContain('lucide-panel-left')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('SidebarTrigger still renders the default panel icon when no icon is provided', () => {
|
|
31
|
+
const html = renderToStaticMarkup(
|
|
32
|
+
<SidebarContext.Provider value={sidebarContextValue}>
|
|
33
|
+
<SidebarTrigger />
|
|
34
|
+
</SidebarContext.Provider>,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
expect(html).toContain('lucide-panel-left')
|
|
38
|
+
})
|
|
39
|
+
})
|
package/src/sidebar/sidebar.tsx
CHANGED
|
@@ -220,7 +220,7 @@ Sidebar.displayName = 'Sidebar'
|
|
|
220
220
|
const SidebarTrigger = React.forwardRef<
|
|
221
221
|
React.ComponentRef<typeof Button>,
|
|
222
222
|
React.ComponentPropsWithoutRef<typeof Button> & { text?: string }
|
|
223
|
-
>(({ className, onClick, text = 'Toggle Sidebar', ...props }, ref) => {
|
|
223
|
+
>(({ className, icon, onClick, text = 'Toggle Sidebar', ...props }, ref) => {
|
|
224
224
|
const { toggleSidebar } = useSidebar()
|
|
225
225
|
const direction = useDirection()
|
|
226
226
|
|
|
@@ -232,13 +232,13 @@ const SidebarTrigger = React.forwardRef<
|
|
|
232
232
|
variant="ghost"
|
|
233
233
|
size="icon-sm"
|
|
234
234
|
dir={direction}
|
|
235
|
+
icon={icon === undefined ? <PanelLeftIcon aria-hidden="true" className="rtl:-scale-x-100" /> : icon}
|
|
235
236
|
className={cn(className)}
|
|
236
237
|
onClick={(event) => {
|
|
237
238
|
onClick?.(event)
|
|
238
239
|
toggleSidebar()
|
|
239
240
|
}}
|
|
240
241
|
{...props}>
|
|
241
|
-
<PanelLeftIcon aria-hidden="true" className="rtl:-scale-x-100" />
|
|
242
242
|
<span className="sr-only">{text}</span>
|
|
243
243
|
</Button>
|
|
244
244
|
)
|