Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Nov 8, 2024
2 parents ed63ae5 + e667fa9 commit e1503a5
Show file tree
Hide file tree
Showing 15 changed files with 368 additions and 305 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/doc-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ jobs:
run: |
pnpm run build-doc
- name: Deploy to Surge
uses: dswistowski/surge-sh-action@v1
with:
domain: 'antd-mobile.surge.sh'
project: './dist'
login: ${{ secrets.SURGE_LOGIN }}
token: ${{ secrets.SURGE_TOKEN }}
# Note: We miss the url permission for surge.sh, so we can't use it now.
# - name: Deploy to Surge
# uses: dswistowski/surge-sh-action@v1
# with:
# domain: 'antd-mobile.surge.sh'
# project: './dist'
# login: ${{ secrets.SURGE_LOGIN }}
# token: ${{ secrets.SURGE_TOKEN }}

- name: Deploy to Surge (with SHA)
uses: dswistowski/surge-sh-action@v1
Expand Down
13 changes: 11 additions & 2 deletions docs/components/components/Main/MainSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button } from 'antd-mobile'
import React, { useEffect, useState } from 'react'
import Lottie from 'react-lottie'
import { useTrans } from '../../../../hooks/useTrans'
import { openUrl } from '../../../../utils'
import styles from './index.local.less'

export default (props: { isWidthScreen: boolean }) => {
Expand Down Expand Up @@ -39,15 +40,23 @@ export default (props: { isWidthScreen: boolean }) => {
color='primary'
shape='rounded'
className={styles.buttonLeft}
href={trans('/guide/quick-start', '/zh/guide/quick-start')}
onClick={() =>
openUrl({
href: trans('/guide/quick-start', '/zh/guide/quick-start'),
})
}
>
{trans('Get Start', '开始使用')}
</Button>
<Button
color='primary'
shape='rounded'
className={styles.buttonRight}
href={trans('/components', '/zh/components')}
onClick={() =>
openUrl({
href: trans('/components', '/zh/components'),
})
}
>
{trans('Preview Online', '在线体验')}
</Button>
Expand Down
11 changes: 7 additions & 4 deletions docs/components/components/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button, Card } from 'antd-mobile'
import React, { useEffect, useRef, useState } from 'react'
import Lottie from 'react-lottie'
import { useTrans } from '../../../hooks/useTrans'
import { openUrl } from '../../../utils'
import MainSection from './MainSection'
import {
getGuides,
Expand Down Expand Up @@ -99,10 +100,12 @@ export default () => {
</div>
<Button
className={styles.productResourceCardButton}
type='primary'
shape='round'
target={resource.target}
href={resource.buttonLink}
onClick={() =>
openUrl({
href: resource.buttonLink,
target: resource.target,
})
}
>
{resource.buttonText}
</Button>
Expand Down
15 changes: 15 additions & 0 deletions docs/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const openUrl = ({
href,
target,
}: {
href: string
target?: string
}) => {
switch (target) {
case '_blank':
window.open(href, target)
break
default:
window.location.href = href
}
}
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.38.0",
"version": "5.38.1",
"homepage": "https://github.com/ant-design/ant-design-mobile#readme",
"bugs": {
"url": "https://github.com/ant-design/ant-design-mobile/issues"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Only the simplest content area is shown here, and other more usages can be consu
| max | Maximum value of a selectable range. | `Date` | - |
| min | Minimum value of a selectable range. | `Date` | - | - |
| onChange | Trigger when selected date changes. | `(val: Date \| null) => void` when selection mode is "single". `(val: [Date, Date] \| null) => void` when selection mode is "range". | - |
| renderTop | The top information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - |
| renderBottom | The bottom information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - |
| renderTop | The top information of date render function. | `((date: Date) => ReactNode \| null \| undefined) \| false` | - | `false`: 5.38.0 |
| renderBottom | The bottom information of date render function. | `((date: Date) => ReactNode \| null \| undefined) \| false` | - | `false`: 5.38.0 |
| selectionMode | The selection mode. Disable selection when this prop is not set. | `'single' \| 'range'` | - |
| shouldDisableDate | Set whether the date is disable selection. The min and max Settings are ignored | `(date: Date) => boolean` | - |
| title | The title of calendar | `React.ReactNode` | `Date selection` |
Expand Down
43 changes: 30 additions & 13 deletions src/components/calendar-picker-view/calendar-picker-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export type CalendarPickerViewRef = {
getDateRange: () => DateRange
}

export type CalendarPickerViewColumRender = (date: Date) => ReactNode

export type CalendarPickerViewProps = {
title?: React.ReactNode | false
confirmText?: string
weekStartsOn?: 'Monday' | 'Sunday'
renderTop?: (date: Date) => React.ReactNode
renderDate?: (date: Date) => React.ReactNode
renderBottom?: (date: Date) => React.ReactNode
renderTop?: CalendarPickerViewColumRender | false
renderDate?: CalendarPickerViewColumRender
renderBottom?: CalendarPickerViewColumRender | false
allowClear?: boolean
max?: Date
min?: Date
Expand Down Expand Up @@ -269,26 +271,45 @@ export const CalendarPickerView = forwardRef<
(minDay && d.isBefore(minDay, 'day'))

const renderTop = () => {
if (props.renderTop === false) return null

const contentWrapper = (content: ReactNode) => (
<div className={`${classPrefix}-cell-top`}>{content}</div>
)

const top = props.renderTop?.(d.toDate())

if (top) {
return top
return contentWrapper(top)
}

if (props.selectionMode === 'range') {
if (isBegin) {
return locale.Calendar.start
return contentWrapper(locale.Calendar.start)
}

if (isEnd) {
return locale.Calendar.end
return contentWrapper(locale.Calendar.end)
}
}

if (d.isSame(today, 'day') && !isSelect) {
return locale.Calendar.today
return contentWrapper(locale.Calendar.today)
}

return contentWrapper(null)
}

const renderBottom = () => {
if (props.renderBottom === false) return null

return (
<div className={`${classPrefix}-cell-bottom`}>
{props.renderBottom?.(d.toDate())}
</div>
)
}

return (
<div
key={d.valueOf()}
Expand Down Expand Up @@ -342,17 +363,13 @@ export const CalendarPickerView = forwardRef<
}
}}
>
<div className={`${classPrefix}-cell-top`}>
{renderTop()}
</div>
{renderTop()}
<div className={`${classPrefix}-cell-date`}>
{props.renderDate
? props.renderDate(d.toDate())
: d.date()}
</div>
<div className={`${classPrefix}-cell-bottom`}>
{props.renderBottom?.(d.toDate())}
</div>
{renderBottom()}
</div>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ CalendarPickerView 是 [CalendarPicker](/zh/components/calendar-picker) 的内
| max | 可选择范围的最大值 | `Date` | - |
| min | 可选择范围的最小值 | `Date` | - |
| onChange | 选择日期变化时触发 | 单选模式下为 `(val: Date \| null) => void`,多选模式下为 `(val: [Date, Date] \| null) => void` | - |
| renderTop | 日期顶部信息的渲染函数 | `(date: Date) => ReactNode \| null \| undefined` | - |
| renderBottom | 日期底部信息的渲染函数 | `(date: Date) => ReactNode \| null \| undefined` | - |
| renderTop | 日期顶部信息的渲染函数 | `((date: Date) => ReactNode \| null \| undefined) \| false` | - | `false`: 5.38.0 |
| renderBottom | 日期底部信息的渲染函数 | `((date: Date) => ReactNode \| null \| undefined) \| false` | - | `false`: 5.38.0 |
| selectionMode | 选择模式,不设置的话表示不支持选择 | `'single' \| 'range'` | - |
| shouldDisableDate | 判断日期是否可选,使用后会忽略 min 和 max 设置 | `(date: Date) => boolean` | - |
| title | 日期选择器的标题 | `React.ReactNode` | `日期选择` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@ describe('Calendar', () => {
expect(document.querySelector(`.${classPrefix}-header`)).toBeNull()
})

test('renderTop hidden', () => {
render(<CalendarPickerView renderTop={false} />)

expect(document.querySelector(`.${classPrefix}-cell-top`)).toBeNull()
})

test('renderBottom hidden', () => {
render(<CalendarPickerView renderBottom={false} />)

expect(document.querySelector(`.${classPrefix}-cell-bottom`)).toBeNull()
})

test('not fill empty cells if unnecessary', () => {
const { container } = render(
<CalendarPickerView
Expand Down
4 changes: 2 additions & 2 deletions src/components/ellipsis/demos/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Ellipsis, Space } from 'antd-mobile'
import { DemoBlock } from 'demos'
import { DownOutline, UpOutline } from 'antd-mobile-icons'
import { DemoBlock } from 'demos'
import React from 'react'

const content =
'蚂蚁的企业级产品是一个庞大且复杂的体系。这类产品不仅量级巨大且功能复杂,而且变动和并发频繁,常常需要设计与开发能够快速的做出响应。同时这类产品中有存在很多类似的页面以及组件,可以通过抽象得到一些稳定且高复用性的内容。'
Expand Down
1 change: 1 addition & 0 deletions src/components/ellipsis/ellipsis.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.@{class-prefix-ellipsis} {
overflow: hidden;
line-height: 1.5;
word-break: break-word;
}
Loading

0 comments on commit e1503a5

Please sign in to comment.