Skip to content

Commit a9b2b49

Browse files
Merge pull request #276 from softnetics/supakorn/migrate/components
fix: `intent-ui` date component disabled and read-only state.
2 parents 40fc605 + e70d3bc commit a9b2b49

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

.changeset/wise-actors-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@genseki/react": patch
3+
---
4+
5+
fix: `intent-ui` date component disabled and read-only state.

packages/react/src/react/components/primitives/date-picker.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22

3+
import type React from 'react'
34
import {
45
DatePicker as DatePickerPrimitive,
56
type DatePickerProps as DatePickerPrimitiveProps,
@@ -24,6 +25,7 @@ import { composeTailwindRenderProps } from './primitive'
2425
import { RangeCalendar } from './range-calendar'
2526

2627
import { BaseIcon } from '../../components/primitives/base-icon'
28+
import { cn } from '../../utils/cn'
2729

2830
interface DatePickerOverlayProps
2931
extends Omit<DialogProps, 'children' | 'className' | 'style'>,
@@ -69,11 +71,18 @@ const DatePickerOverlay = ({
6971
)
7072
}
7173

72-
const DatePickerIcon = () => (
74+
const DatePickerIcon = ({
75+
className,
76+
...props
77+
}: Omit<React.ComponentPropsWithRef<typeof Button>, 'size' | 'variant'>) => (
7378
<Button
7479
size="md"
7580
variant="vanish"
76-
className="-translate-x-2 rounded-full outline-offset-0 hover:bg-transparent pressed:bg-transparent **:data-[slot=icon]:text-muted-fg"
81+
className={cn(
82+
'-translate-x-2 rounded-full outline-offset-0 hover:bg-transparent pressed:bg-transparent **:data-[slot=icon]:text-muted-fg',
83+
className
84+
)}
85+
{...props}
7786
>
7887
<BaseIcon icon={CalendarDotsIcon} weight="duotone" className="group-open:text-fg" aria-hidden />
7988
</Button>
@@ -107,7 +116,7 @@ const DatePicker = <T extends DateValue>({
107116
)}
108117
<FieldGroup className="min-w-40">
109118
<DateInput size="md" className="w-full pr-16" />
110-
<DatePickerIcon />
119+
<DatePickerIcon isDisabled={props.isDisabled || props.isReadOnly} />
111120
</FieldGroup>
112121
{description && <Description>{description}</Description>}
113122
<FieldError>{errorMessage}</FieldError>

0 commit comments

Comments
 (0)