Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for incoming ref to image-uploader #6316

Merged
merged 36 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7f85638
docs: update doc of SwipeAction ProgressBar ProgressCircle Popover S…
1587315093 Jul 4, 2023
1029d6f
test: fix failed test (#6227)
miracles1919 Jul 5, 2023
6337f96
doc: Improve doc descriptions of some components (#6233)
1587315093 Jul 5, 2023
374e13d
fix: virtual input value 0 (#6231)
wulisensen Jul 10, 2023
d12f5de
fix(TextArea): hidden textarea element is not positioned relative to …
1587315093 Jul 10, 2023
a765ced
chore: auto merge branches (#6244)
github-actions[bot] Jul 12, 2023
be422bc
chore: bump 5.32.0
zombieJ Jul 12, 2023
adf776f
enhance: useWheel dir change (#6240)
1587315093 Jul 14, 2023
5892da7
Merge branch 'master' of https://github.com/ant-design/ant-design-mobile
zombieJ Jul 14, 2023
be7369a
chore: prompt when repairing step cloneElement (#6259)
1587315093 Jul 19, 2023
7f3d91d
fix(TextArea): reset rows when rows exceed autoSize (#6256)
miracles1919 Jul 20, 2023
3e0c0cd
chore: side add type specification (#6258)
1587315093 Jul 28, 2023
ace65c1
chore: type enhance (#6262)
1587315093 Jul 28, 2023
e2f82a6
refactor: to simplify the judge (#6263)
1587315093 Jul 28, 2023
4cf67a3
chore: repair type warning (#6267)
1587315093 Jul 28, 2023
bed51d6
fix: classname use repeatedly (#6278)
1587315093 Aug 1, 2023
317c116
chore: form's code style optimization (#6279)
1587315093 Aug 2, 2023
bf44a5c
refactor(Calendar): change locale from method to string (#6276)
whwnow Aug 2, 2023
49a1ef5
chore: add `--inactive-color-half` type (#6281)
HydenLiu Aug 4, 2023
121468b
enhance: passive and preventDefault coexist repair (#6284)
1587315093 Aug 7, 2023
180f18d
chore: pick type to InputHTMLAttributes (#6290)
1587315093 Aug 7, 2023
edbd0e8
enhance(toast): compatible with rtl mode (#6287)
Fog3211 Aug 7, 2023
e4d9aed
test(useLockScroll): update test (#6292)
miracles1919 Aug 8, 2023
83b5947
fix: repir passive and preventDefault in components (#6296)
1587315093 Aug 9, 2023
d919096
chore: eventOptions type fix (#6298)
1587315093 Aug 10, 2023
1561d15
enhance: floating-panel add classPrefix (#6297)
1587315093 Aug 10, 2023
a76c9b0
chore: code simplify (#6295)
1587315093 Aug 10, 2023
46ffd90
fix: useLockScroll whether the element scroll is in the end #6253 (#6…
19Qingfeng Aug 10, 2023
e1fd659
fix: error-block Normal display 0 (#6309)
1587315093 Aug 11, 2023
35953dc
feat: support for incoming ref to image-uploader #6289
19Qingfeng Aug 14, 2023
2b71ba5
fix: remove imageUploaderRef openPhoto #6316
19Qingfeng Aug 15, 2023
38096e6
fix: remove log ref:#6316
19Qingfeng Aug 16, 2023
58c66ba
doc: update
miracles1919 Aug 16, 2023
10d97e9
feat: export image upload ref
miracles1919 Aug 16, 2023
53af4fe
doc: update demo
miracles1919 Aug 16, 2023
7b5718a
Merge remote-tracking branch 'feature' into feat/image-uploader
miracles1919 Aug 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antd-mobile",
"version": "5.31.1",
"version": "5.32.0",
"scripts": {
"start": "dumi dev",
"build": "gulp",
Expand Down
9 changes: 5 additions & 4 deletions src/components/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useConfig } from '../config-provider'
import isoWeek from 'dayjs/plugin/isoWeek'
import { useUpdateEffect } from 'ahooks'
import { usePropsValue } from '../../utils/use-props-value'
import { replaceMessage } from '../../utils/replace-message'
import {
convertValueToRange,
convertPageToDayjs,
Expand Down Expand Up @@ -171,10 +172,10 @@ export const Calendar = forwardRef<CalendarRef, CalendarProps>((p, ref) => {
{props.prevMonthButton}
</a>
<div className={`${classPrefix}-title`}>
{locale.Calendar.renderYearAndMonth(
current.year(),
current.month() + 1
)}
{replaceMessage(locale.Calendar.yearAndMonth, {
year: current.year().toString(),
month: (current.month() + 1).toString(),
})}
</div>
<a
className={classNames(
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type CheckboxValue = string | number
| block | Whether to render as a block-level element | `boolean` | `false` |
| checked | To specify whether selected or not currently | `boolean` | `false` |
| defaultChecked | Selected or not initially | `boolean` | `false` |
| disabled | Failure state | `boolean` | `false` |
| disabled | Disabled state | `boolean` | `false` |
| icon | The customized `icon` | `(checked: boolean, indeterminate: boolean) => React.ReactNode` | - |
| id | The id of the input element, often used in conjunction with the label | `string` | - |
| indeterminate | To set the `indeterminate` state, only responsible for style control | `boolean` | `false` |
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type CheckboxValue = string | number
| block | 是否渲染为块级元素 | `boolean` | `false` |
| checked | 指定当前是否选中 | `boolean` | `false` |
| defaultChecked | 初始是否选中 | `boolean` | `false` |
| disabled | 失效状态 | `boolean` | `false` |
| disabled | 禁用状态 | `boolean` | `false` |
| icon | 自定义 `icon` 图标 | `(checked: boolean, indeterminate: boolean) => React.ReactNode` | - |
| id | `input` 元素的 `id`,常用来配合 `label` 使用 | `string` | - |
| indeterminate | 设置 `indeterminate` 状态,只负责样式控制 | `boolean` | `false` |
Expand Down
62 changes: 38 additions & 24 deletions src/components/collapse/collapse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,30 +129,44 @@ export const Collapse: FC<CollapseProps> = props => {
panels.push(child)
})

const [activeKey, setActiveKey] = usePropsValue<string[]>(
props.accordion
? {
value:
props.activeKey === undefined
? undefined
: props.activeKey === null
? []
: [props.activeKey],
defaultValue:
props.defaultActiveKey === undefined ||
props.defaultActiveKey === null
? []
: [props.defaultActiveKey],
onChange: v => {
props.onChange?.(v[0] ?? null)
},
}
: {
value: props.activeKey,
defaultValue: props.defaultActiveKey ?? [],
onChange: props.onChange,
}
)
const handlePropsValue = () => {
if (!props.accordion) {
return {
value: props.activeKey,
defaultValue: props.defaultActiveKey ?? [],
onChange: props.onChange,
}
}

const initValue: {
value?: string[]
defaultValue: string[]
onChange: (v: string[]) => void
} = {
value: [],
defaultValue: [],
onChange: v => {
props.onChange?.(v[0] ?? null)
},
}

if (props.activeKey === undefined) {
initValue.value = undefined
} else if (props.activeKey !== null) {
initValue.value = [props.activeKey]
}

if (
![null, undefined].includes(props.defaultActiveKey as null | undefined)
) {
initValue.defaultValue = [props.defaultActiveKey as string]
}

return initValue
}

const [activeKey, setActiveKey] = usePropsValue<string[]>(handlePropsValue())

const activeKeyList =
activeKey === null ? [] : Array.isArray(activeKey) ? activeKey : [activeKey]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8618,7 +8618,7 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
<div
class="adm-calendar-title"
>
2022年3月
2022年3月
</div>
<a
class="adm-calendar-arrow-button adm-calendar-arrow-button-right adm-calendar-arrow-button-right-month"
Expand Down
50 changes: 24 additions & 26 deletions src/components/ellipsis/ellipsis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,34 +194,32 @@ export const Ellipsis: FC<EllipsisProps> = p => {
])

const expandActionElement =
exceeded && props.expandText
? withStopPropagation(
props.stopPropagationForActionButtons,
<a
ref={expandElRef}
onClick={() => {
setExpanded(true)
}}
>
{props.expandText}
</a>
)
: null
!!props.expandText &&
withStopPropagation(
props.stopPropagationForActionButtons,
<a
ref={expandElRef}
onClick={() => {
setExpanded(true)
}}
>
{props.expandText}
</a>
)

const collapseActionElement =
exceeded && props.collapseText
? withStopPropagation(
props.stopPropagationForActionButtons,
<a
ref={collapseElRef}
onClick={() => {
setExpanded(false)
}}
>
{props.collapseText}
</a>
)
: null
!!props.collapseText &&
withStopPropagation(
props.stopPropagationForActionButtons,
<a
ref={collapseElRef}
onClick={() => {
setExpanded(false)
}}
>
{props.collapseText}
</a>
)

const renderContent = () => {
if (!exceeded) return props.content
Expand Down
10 changes: 6 additions & 4 deletions src/components/error-block/create-error-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export function createErrorBlock(imageRecord: ImageRecord) {
const props = mergeProps(defaultProps, p)
const { locale } = useConfig()
const contentPack = locale.ErrorBlock[props.status]
const des =
const desc =
'description' in props ? props.description : contentPack.description
const title = 'title' in props ? props.title : contentPack.title

const image: ReactNode = props.image ?? imageRecord[props.status]
const imageNode =
typeof image === 'string' ? (
Expand All @@ -50,11 +51,12 @@ export function createErrorBlock(imageRecord: ImageRecord) {
>
<div className={`${classPrefix}-image`}>{imageNode}</div>
<div className={`${classPrefix}-description`}>
{title && (
{![undefined, null].includes(title as null) && (
<div className={`${classPrefix}-description-title`}>{title}</div>
)}
{des && (
<div className={`${classPrefix}-description-subtitle`}>{des}</div>

{![undefined, null].includes(desc as null) && (
<div className={`${classPrefix}-description-subtitle`}>{desc}</div>
)}
</div>

Expand Down
20 changes: 20 additions & 0 deletions src/components/error-block/tests/error-block.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,24 @@ describe('ErrorBlock', () => {

expect(container).toMatchSnapshot()
})
test('renders when description and title', async () => {
const title = 0
const description = 0

const { container } = render(
<ErrorBlock title={title} description={description} />
)

const titleElement = container.querySelector(
`.${classPrefix}-description-title`
)
expect(titleElement).toBeInTheDocument()
expect(titleElement?.textContent).toBe(title + '')

const descElement = container.querySelector(
`.${classPrefix}-description-subtitle`
)
expect(descElement).toBeInTheDocument()
expect(descElement?.textContent).toBe(description + '')
})
})
18 changes: 9 additions & 9 deletions src/components/floating-panel/floating-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { mergeProps } from '../../utils/with-default-props'
import { useLockScroll } from '../../utils/use-lock-scroll'
import { useMemoizedFn } from 'ahooks'

const classPrefix = 'adm-floating-panel'

export type FloatingPanelRef = {
setHeight: (
height: number,
Expand Down Expand Up @@ -88,7 +90,7 @@ export const FloatingPanel = forwardRef<FloatingPanelRef, FloatingPanelProps>(
setPulling(pullingRef.current)
if (!pullingRef.current) return
const { event } = state
if (event.cancelable) {
if (event.cancelable && supportsPassive) {
event.preventDefault()
}
event.stopPropagation()
Expand All @@ -109,9 +111,7 @@ export const FloatingPanel = forwardRef<FloatingPanelRef, FloatingPanelProps>(
from: () => [0, y.get()],
pointer: { touch: true },
target: elementRef,
eventOptions: supportsPassive
? { passive: false }
: (false as unknown as AddEventListenerOptions),
eventOptions: supportsPassive ? { passive: false } : undefined,
}
)

Expand Down Expand Up @@ -139,22 +139,22 @@ export const FloatingPanel = forwardRef<FloatingPanelRef, FloatingPanelProps>(
props,
<animated.div
ref={elementRef}
className='adm-floating-panel'
className={classPrefix}
style={{
height: Math.round(maxHeight),
translateY: y.to(y => `calc(100% + (${Math.round(y)}px))`),
}}
>
<div
className='adm-floating-panel-mask'
className={`${classPrefix}-mask`}
style={{
display: pulling ? 'block' : 'none',
}}
/>
<div className='adm-floating-panel-header' ref={headerRef}>
<div className='adm-floating-panel-bar' />
<div className={`${classPrefix}-header`} ref={headerRef}>
<div className={`${classPrefix}-bar`} />
</div>
<div className='adm-floating-panel-content' ref={contentRef}>
<div className={`${classPrefix}-content`} ref={contentRef}>
{props.children}
</div>
</animated.div>
Expand Down
30 changes: 14 additions & 16 deletions src/components/form/demos/demo-subscribe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ export default function () {
</Form.Item>

<Form.Subscribe to={['loginMethod']}>
{({ loginMethod }) => {
return (
<>
{loginMethod === 'mobile' && (
<Form.Item name='account' label='手机号'>
<Input placeholder='请输入手机号' />
</Form.Item>
)}
{loginMethod === 'email' && (
<Form.Item name='account' label='邮箱'>
<Input placeholder='请输入邮箱' />
</Form.Item>
)}
</>
)
}}
{({ loginMethod }) => (
<>
{loginMethod === 'mobile' && (
<Form.Item name='account' label='手机号'>
<Input placeholder='请输入手机号' />
</Form.Item>
)}
{loginMethod === 'email' && (
<Form.Item name='account' label='邮箱'>
<Input placeholder='请输入邮箱' />
</Form.Item>
)}
</>
)}
</Form.Subscribe>
</Form>
)
Expand Down
8 changes: 2 additions & 6 deletions src/components/form/demos/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,9 @@ export default () => {
</Form.Item>
<Form.Item
label='表单联动-字段B'
shouldUpdate={(prevValues, curValues) => {
return prevValues.b !== curValues.b
}}
shouldUpdate={(prevValues, curValues) => prevValues.b !== curValues.b}
>
{({ getFieldValue }) => {
return JSON.stringify(getFieldValue('b'))
}}
{({ getFieldValue }) => JSON.stringify(getFieldValue('b'))}
</Form.Item>
<DatePickerInputItem />
</Form>
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/demos/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PickerValue } from 'antd-mobile/es/components/picker'
import { DownOutline } from 'antd-mobile-icons'

interface MobileValue {
preValue: string
preValue: string | number
realValue: string
}

Expand Down
Loading
Loading