Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/xiamiao1121/hiui into hot…
Browse files Browse the repository at this point in the history
…fix/date-picker/XiaoMi#2825
  • Loading branch information
xiamiao committed May 15, 2024
2 parents 93e0da1 + c4f48c1 commit b883b03
Show file tree
Hide file tree
Showing 34 changed files with 347 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-mails-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/pop-confirm": patch
---

fix: 修复点击按钮会触发 onCancel 问题
5 changes: 5 additions & 0 deletions .changeset/fast-waves-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

fix(pop-confirm): 修复点击确定按钮会触发 onCancel 问题
5 changes: 5 additions & 0 deletions .changeset/large-glasses-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/preview": minor
---

feat: 支持配置图片水印以及禁止右键下载图片
5 changes: 5 additions & 0 deletions .changeset/real-keys-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/select": patch
---

fix: 修复搜索时在中文输入法下按回车键弹窗会关闭的问题
5 changes: 5 additions & 0 deletions .changeset/serious-penguins-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

feat(preview): 支持图片配置水印以及禁止右键下载图片
5 changes: 5 additions & 0 deletions .changeset/tough-kangaroos-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

fix(select): 修复搜索时在中文输入法下按回车键弹窗会关闭的问题
6 changes: 6 additions & 0 deletions packages/ui/descriptions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @hi-ui/descriptions

## 4.3.0

### Minor Changes

- [#2812](https://github.com/XiaoMi/hiui/pull/2812) [`fbaf242b0`](https://github.com/XiaoMi/hiui/commit/fbaf242b0e36729787ee576e7e3ab05ed4115cf4) Thanks [@xiamiao1121](https://github.com/xiamiao1121)! - feat: 新增自定义列间距功能

## 4.2.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/descriptions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hi-ui/descriptions",
"version": "4.2.5",
"version": "4.3.0",
"description": "A sub-package for @hi-ui/hiui.",
"keywords": [],
"author": "HiUI <[email protected]>",
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/descriptions/src/Cell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { cx } from '@hi-ui/classname'
import { cx, getPrefixStyleVar } from '@hi-ui/classname'
import { isNullish } from '@hi-ui/type-assertion'

export const Cell: React.FC<CellProps> = ({
Expand All @@ -13,6 +13,7 @@ export const Cell: React.FC<CellProps> = ({
label,
content,
labelWidth,
cellColumnGap,
}) => {
const Component: any = component

Expand Down Expand Up @@ -42,7 +43,13 @@ export const Cell: React.FC<CellProps> = ({

return (
<Component className={cx(`${itemPrefixCls}-item`, className)} style={style} colSpan={colSpan}>
<div className={`${itemPrefixCls}-item__container`}>
<div
className={`${itemPrefixCls}-item__container`}
style={{
[`${getPrefixStyleVar('container-padding-right')}`]:
typeof cellColumnGap === 'number' ? cellColumnGap + 'px' : cellColumnGap,
}}
>
{!isNullish(label) && (
<span className={cx(`${itemPrefixCls}-item__label`)} style={{ width: labelWidth }}>
{label}
Expand All @@ -67,4 +74,5 @@ export interface CellProps {
label?: React.ReactNode
content?: React.ReactNode
labelWidth?: React.ReactText
cellColumnGap?: React.ReactText
}
7 changes: 7 additions & 0 deletions packages/ui/descriptions/src/Descriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const Descriptions = forwardRef<HTMLDivElement | null, DescriptionsProps>
appearance = 'unset',
labelPlacement = 'left',
labelWidth,
columnGap,
size = 'md',
...rest
},
Expand Down Expand Up @@ -66,6 +67,7 @@ export const Descriptions = forwardRef<HTMLDivElement | null, DescriptionsProps>
noBackground={noBackground}
labelPlacement={labelPlacement}
rootLabelWidth={labelWidth}
cellColumnGap={columnGap}
/>
))}
</tbody>
Expand Down Expand Up @@ -100,6 +102,11 @@ export interface DescriptionsProps extends HiBaseHTMLProps<'div'> {
* label宽度
*/
labelWidth?: React.ReactText
/**
* 单元格列间距
* 注:在无边框场景下生效
*/
columnGap?: React.ReactText
/**
* 设置大小
*/
Expand Down
10 changes: 9 additions & 1 deletion packages/ui/descriptions/src/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface RowProps {
noBackground?: boolean
labelPlacement?: 'left' | 'center' | 'right'
rootLabelWidth?: React.ReactText
cellColumnGap?: React.ReactText
}

interface CellConfig {
Expand All @@ -60,7 +61,13 @@ interface CellConfig {

function renderCols(
items: React.ReactElement<DescriptionsItemProps>[],
{ prefixCls, bordered, labelPlacement: labelPlacementContext, rootLabelWidth }: RowProps,
{
prefixCls,
bordered,
labelPlacement: labelPlacementContext,
rootLabelWidth,
cellColumnGap,
}: RowProps,
{ component, type, showLabel, showContent }: CellConfig
) {
return items.map(
Expand Down Expand Up @@ -95,6 +102,7 @@ function renderCols(
label={showLabel ? label : null}
content={showContent ? children : null}
labelWidth={labelWidth ?? rootLabelWidth}
cellColumnGap={index === items.length - 1 ? 0 : cellColumnGap}
/>
)
}
Expand Down
1 change: 1 addition & 0 deletions packages/ui/descriptions/src/styles/descriptions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ $prefix: '#{$component-prefix}-descriptions' !default;
&__container {
box-sizing: border-box;
display: flex;
padding-right: var(--hi-v4-container-padding-right, 0);
}

&__label,
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/form/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @hi-ui/form

## 4.2.0

### Minor Changes

- [#2818](https://github.com/XiaoMi/hiui/pull/2818) [`39d555903`](https://github.com/XiaoMi/hiui/commit/39d555903c81207d5d2bf34a2a5d1942152dcee0) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: add showValidateMessage api

## 4.1.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hi-ui/form",
"version": "4.1.7",
"version": "4.2.0",
"description": "A sub-package for @hi-ui/hiui.",
"keywords": [],
"author": "HiUI <[email protected]>",
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/form/src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const Form = forwardRef<HTMLFormElement | null, FormProps>(
contentPosition = 'center',
showRequiredOnValidateRequired = false,
showColon = true,
showValidateMessage = true,
...rest
},
ref
Expand Down Expand Up @@ -61,17 +62,19 @@ export const Form = forwardRef<HTMLFormElement | null, FormProps>(
showColon,
contentPosition,
showRequiredOnValidateRequired,
showValidateMessage,
...formContext,
prefixCls,
}
}, [
labelWidth,
formContext,
labelPlacement,
showColon,
prefixCls,
contentPosition,
showRequiredOnValidateRequired,
showValidateMessage,
formContext,
prefixCls,
])

const cls = cx(prefixCls, className, placement && `${prefixCls}--placement-${placement}`)
Expand Down Expand Up @@ -118,6 +121,11 @@ export interface FormProps<Values = Record<string, any>>
* FormItem 开启 filed 的 required 校验时,展示红色星号
*/
showRequiredOnValidateRequired?: boolean
/**
* 是否显示校验提示
* @default true
*/
showValidateMessage?: boolean
}

if (__DEV__) {
Expand Down
10 changes: 9 additions & 1 deletion packages/ui/form/src/FormLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const FormLabel = forwardRef<HTMLDivElement | null, FormLabelProps>((prop
labelPlacement: labelPlacementContext,
showColon: showColonContext,
contentPosition: contentPositionContext,
showValidateMessage: showValidateMessageContext,
} = useFormContext()

const {
Expand All @@ -32,6 +33,7 @@ export const FormLabel = forwardRef<HTMLDivElement | null, FormLabelProps>((prop
contentPosition = contentPositionContext,
labelPlacement = labelPlacementContext,
formMessage,
showValidateMessage: showValidateMessageProp = showValidateMessageContext,
...rest
} = props

Expand Down Expand Up @@ -92,7 +94,9 @@ export const FormLabel = forwardRef<HTMLDivElement | null, FormLabelProps>((prop
{children}
</div>
</div>
<div style={{ paddingLeft: `calc(100% - ${controlWidth})` }}>{formMessage}</div>
{showValidateMessageProp && (
<div style={{ paddingLeft: `calc(100% - ${controlWidth})` }}>{formMessage}</div>
)}
</div>
)
})
Expand Down Expand Up @@ -126,6 +130,10 @@ export interface FormLabelProps extends HiBaseHTMLProps<'div'> {
* 提示信息
*/
formMessage?: ReactNode
/**
* 是否显示校验提示。优先级高于 Form 设置的 showValidateMessage
*/
showValidateMessage?: boolean
}

if (__DEV__) {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/form/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface FormContextProps extends UseFormReturn {
contentPosition: 'top' | 'center' | 'bottom'
showColon: boolean
showRequiredOnValidateRequired: boolean
showValidateMessage: boolean
prefixCls: string
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/form/stories/get-values.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const GetValues = () => {
<FormItem required={true} label="姓名" field="name" valueType="string">
<Input placeholder="请输入" style={{ width: 200 }} />
</FormItem>
<FormItem valueType={null} field={null}>
<FormItem valueType={null} field={null} showValidateMessage={false}>
<Button
type="primary"
onClick={() => {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/form/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './label-placement.stories'
export * from './placement.stories'
export * from './validate.stories'
export * from './validate-field.stories'
export * from './validate-message.stories'
export * from './set-values.stories'
export * from './get-values.stories'
export * from './render.stories'
Expand Down
34 changes: 34 additions & 0 deletions packages/ui/form/stories/validate-message.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import Form from '../src'
import Input from '@hi-ui/input'
import Button from '@hi-ui/button'
import Card from '@hi-ui/card'

/**
* @title 是否显示校验提示
* @desc 适用于无需展示校验提示的场景
*/
export const ValidateMessage = () => {
const FormItem = Form.Item

return (
<>
<h1>ValidateMessage</h1>
<div className="form-validate-message__wrap" style={{ width: 900 }}>
<Card>
<Form placement="horizontal" labelPlacement="right" showValidateMessage={false}>
<FormItem label="商品ID" labelWidth="100" valueType="string">
<Input placeholder={'请输入'} />
</FormItem>
<FormItem label="商品分类" labelWidth="100" valueType="string">
<Input placeholder={'请输入'} />
</FormItem>
<FormItem showValidateMessage={false}>
<Button>查询</Button>
</FormItem>
</Form>
</Card>
</div>
</>
)
}
15 changes: 15 additions & 0 deletions packages/ui/hiui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @hi-ui/hiui

## 4.5.9

### Patch Changes

- [#2817](https://github.com/XiaoMi/hiui/pull/2817) [`c32ae3dd9`](https://github.com/XiaoMi/hiui/commit/c32ae3dd9b5a89840270649fc397d474e9e1de4b) Thanks [@zyprepare](https://github.com/zyprepare)! - fix(table): 修复表头分组单元格边框显示问题

- [#2812](https://github.com/XiaoMi/hiui/pull/2812) [`fbaf242b0`](https://github.com/XiaoMi/hiui/commit/fbaf242b0e36729787ee576e7e3ab05ed4115cf4) Thanks [@xiamiao1121](https://github.com/xiamiao1121)! - feat(descriptions): 新增自定义列间距功能

- [#2818](https://github.com/XiaoMi/hiui/pull/2818) [`39d555903`](https://github.com/XiaoMi/hiui/commit/39d555903c81207d5d2bf34a2a5d1942152dcee0) Thanks [@zyprepare](https://github.com/zyprepare)! - feat(form): add showValidateMessage api

- Updated dependencies [[`fbaf242b0`](https://github.com/XiaoMi/hiui/commit/fbaf242b0e36729787ee576e7e3ab05ed4115cf4), [`c32ae3dd9`](https://github.com/XiaoMi/hiui/commit/c32ae3dd9b5a89840270649fc397d474e9e1de4b), [`39d555903`](https://github.com/XiaoMi/hiui/commit/39d555903c81207d5d2bf34a2a5d1942152dcee0)]:
- @hi-ui/descriptions@4.3.0
- @hi-ui/table@4.5.3
- @hi-ui/form@4.2.0

## 4.5.8

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/hiui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hi-ui/hiui",
"version": "4.5.8",
"version": "4.5.9",
"description": "The root-package for @hi-ui/hiui.",
"keywords": [],
"author": "HiUI <[email protected]>",
Expand Down Expand Up @@ -60,13 +60,13 @@
"@hi-ui/collapse": "^4.1.6",
"@hi-ui/counter": "^4.1.9",
"@hi-ui/date-picker": "^4.6.2",
"@hi-ui/descriptions": "^4.2.5",
"@hi-ui/descriptions": "^4.3.0",
"@hi-ui/drawer": "^4.1.4",
"@hi-ui/dropdown": "^4.1.5",
"@hi-ui/ellipsis-tooltip": "^4.1.8",
"@hi-ui/empty-state": "^4.1.1",
"@hi-ui/filter": "^4.1.5",
"@hi-ui/form": "^4.1.7",
"@hi-ui/form": "^4.2.0",
"@hi-ui/grid": "^4.0.9",
"@hi-ui/highlighter": "^4.0.9",
"@hi-ui/input": "^4.1.1",
Expand Down Expand Up @@ -97,7 +97,7 @@
"@hi-ui/stepper": "^4.0.8",
"@hi-ui/svg-icon": "^4.0.8",
"@hi-ui/switch": "^4.0.11",
"@hi-ui/table": "^4.5.2",
"@hi-ui/table": "^4.5.3",
"@hi-ui/tabs": "^4.1.5",
"@hi-ui/tag": "^4.2.1",
"@hi-ui/textarea": "^4.1.7",
Expand Down
10 changes: 5 additions & 5 deletions packages/ui/pop-confirm/src/use-pop-confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ export const usePopConfirm = ({
defaultVisible: false,
visible: visibleProp,
onOpen,
onClose: () => {
onClose?.()
onCancelProp?.()
},
onClose,
})

const onCancelLatest = useLatestCallback(onCancelProp)

const onCancel = useCallback(() => {
onCancelLatest()
if (closeOnCancel) {
visibleAction.off()
}
}, [closeOnCancel, visibleAction])
}, [closeOnCancel, visibleAction, onCancelLatest])

const onConfirmLatest = useLatestCallback(onConfirmProp)

Expand Down
Loading

0 comments on commit b883b03

Please sign in to comment.