Skip to content

Commit

Permalink
feat: ✨ add readOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
AruSeito committed Oct 27, 2023
1 parent 373bc69 commit af65348
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/date-picker/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface PublicDatePickerProps extends BoxProps {
utcOffset?: number
timezone?: string
inputSuffix?: ReactNode
readonly?: boolean
}

export interface SinglePickerProps extends PublicDatePickerProps {
Expand Down
5 changes: 3 additions & 2 deletions packages/date-picker/src/range-date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const RangeDatePicker = forwardRef<HTMLDivElement, RangeDatePickerProps>(
size = "medium",
colorScheme = "blue",
extra,
readonly = false,
} = props

const weekStart = 0
Expand Down Expand Up @@ -764,7 +765,7 @@ export const RangeDatePicker = forwardRef<HTMLDivElement, RangeDatePickerProps>(
}
trigger="click"
position={position}
disabled={triggerDisabled}
disabled={triggerDisabled || readonly}
onVisibleChange={visibleChange}
popupVisible={mergedPopupVisible}
colorScheme="white"
Expand Down Expand Up @@ -793,7 +794,7 @@ export const RangeDatePicker = forwardRef<HTMLDivElement, RangeDatePickerProps>(
onPressEnter={onPressEnter}
onClear={onClear}
allowClear={allowClear}
editable={editable}
editable={editable || !readonly}
suffixIcon={suffixIcon}
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/date-picker/src/signle-date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const SingleDatePicker = forwardRef<
showTime,
showNowBtn = true,
onOk,
readonly = false,
} = props

const refInput = useRef<HTMLInputElement>(null)
Expand Down Expand Up @@ -438,7 +439,7 @@ export const SingleDatePicker = forwardRef<
}
trigger="click"
position={position}
disabled={disabled}
disabled={disabled || readonly}
onVisibleChange={visibleChange}
popupVisible={mergedPopupVisible}
colorScheme="white"
Expand All @@ -463,7 +464,7 @@ export const SingleDatePicker = forwardRef<
onPressEnter={onPressEnter}
onClear={onClear}
allowClear={allowClear}
editable={editable}
editable={editable || !readonly}
suffixIcon={suffixIcon}
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/date-picker/src/signle-year-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const SingleYearPicker = forwardRef<
size = "medium",
colorScheme = "blue",
inputSuffix,
readonly = false,
} = props

const refInput = useRef<HTMLInputElement>(null)
Expand Down Expand Up @@ -295,7 +296,7 @@ export const SingleYearPicker = forwardRef<
}
trigger="click"
position={position}
disabled={disabled}
disabled={disabled || readonly}
onVisibleChange={visibleChange}
popupVisible={mergedPopupVisible}
colorScheme="white"
Expand All @@ -320,7 +321,7 @@ export const SingleYearPicker = forwardRef<
onPressEnter={onPressEnter}
onClear={onClear}
allowClear={allowClear}
editable={editable}
editable={editable || !readonly}
suffixIcon={suffixIcon}
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/date-picker/src/single-month-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const SingleMonthPicker = forwardRef<
colorScheme = "blue",
inputSuffix,
onOk,
readonly = false,
} = props

const refInput = useRef<HTMLInputElement>(null)
Expand Down Expand Up @@ -345,7 +346,7 @@ export const SingleMonthPicker = forwardRef<
}
trigger="click"
position={position}
disabled={disabled}
disabled={disabled || readonly}
onVisibleChange={visibleChange}
popupVisible={mergedPopupVisible}
colorScheme="white"
Expand All @@ -370,7 +371,7 @@ export const SingleMonthPicker = forwardRef<
onPressEnter={onPressEnter}
onClear={onClear}
allowClear={allowClear}
editable={editable}
editable={editable || !readonly}
suffixIcon={suffixIcon}
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/date-picker/src/single-quarter-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const SingleQuarterPicker = forwardRef<
colorScheme = "blue",
inputSuffix,
onOk,
readonly = false,
} = props

const refInput = useRef<HTMLInputElement>(null)
Expand Down Expand Up @@ -345,7 +346,7 @@ export const SingleQuarterPicker = forwardRef<
}
trigger="click"
position={position}
disabled={disabled}
disabled={disabled || readonly}
onVisibleChange={visibleChange}
popupVisible={mergedPopupVisible}
colorScheme="white"
Expand All @@ -370,7 +371,7 @@ export const SingleQuarterPicker = forwardRef<
onPressEnter={onPressEnter}
onClear={onClear}
allowClear={allowClear}
editable={editable}
editable={editable || !readonly}
suffixIcon={suffixIcon}
/>
</div>
Expand Down
5 changes: 3 additions & 2 deletions packages/date-picker/src/single-week-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const SingleWeekPicker = forwardRef<
colorScheme = "blue",
inputSuffix,
onOk,
readonly = false,
} = props

const refInput = useRef<HTMLInputElement>(null)
Expand Down Expand Up @@ -343,7 +344,7 @@ export const SingleWeekPicker = forwardRef<
}
trigger="click"
position={position}
disabled={disabled}
disabled={disabled || readonly}
onVisibleChange={visibleChange}
popupVisible={mergedPopupVisible}
colorScheme="white"
Expand All @@ -368,7 +369,7 @@ export const SingleWeekPicker = forwardRef<
onPressEnter={onPressEnter}
onClear={onClear}
allowClear={allowClear}
editable={editable}
editable={editable || !readonly}
suffixIcon={suffixIcon}
/>
</div>
Expand Down

0 comments on commit af65348

Please sign in to comment.