diff --git a/package.json b/package.json index 906280769c..ef1266f904 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nutui/nutui-react-taro", - "version": "3.0.19-cpp.22", + "version": "3.0.19-cpp.22-7", "style": "dist/style.css", "main": "dist/nutui.react.umd.js", "module": "dist/es/packages/nutui.react.build.js", diff --git a/src/packages/calendar/calendar.scss b/src/packages/calendar/calendar.scss index 7a394555d6..3ca26a783f 100644 --- a/src/packages/calendar/calendar.scss +++ b/src/packages/calendar/calendar.scss @@ -127,9 +127,20 @@ font-weight: $calendar-day-font-weight; margin-bottom: 4px; + // 部分 Taro 机型下子节点不会稳定继承父级 color,颜色直接落到最内层文案。 + &-day, + &-info-curr { + color: $color-title; + } + &:nth-child(7n + 0), &:nth-child(7n + 1) { color: $color-primary; + + .nut-calendar-day-day, + .nut-calendar-day-info-curr { + color: $color-primary; + } } &-info, @@ -170,7 +181,12 @@ border-bottom-right-radius: $calendar-day-active-border-radius; } - .nut-calendar-day-info { + &.nut-calendar-day-active .nut-calendar-day-info { + color: $color-primary-text; + } + + &.nut-calendar-day-active .nut-calendar-day-day, + &.nut-calendar-day-active .nut-calendar-day-info-curr { color: $color-primary-text; } } @@ -178,6 +194,11 @@ &-disabled { color: $calendar-disable-color !important; + &.nut-calendar-day-disabled .nut-calendar-day-day, + &.nut-calendar-day-disabled .nut-calendar-day-info-curr { + color: $calendar-disable-color; + } + .nut-calendar-day-info-curr { display: none; } @@ -187,10 +208,20 @@ background-color: $calendar-choose-background-color; color: $calendar-choose-color; + &.nut-calendar-day-choose .nut-calendar-day-day, + &.nut-calendar-day-choose .nut-calendar-day-info-curr { + color: $calendar-choose-color; + } + &-disabled { background-color: $calendar-choose-disable-background-color; color: $calendar-disable-color !important; + &.nut-calendar-day-choose-disabled .nut-calendar-day-day, + &.nut-calendar-day-choose-disabled .nut-calendar-day-info-curr { + color: $calendar-disable-color; + } + .nut-calendar-day-info-curr { display: none; } diff --git a/src/packages/calendarcard/calendarcard.scss b/src/packages/calendarcard/calendarcard.scss index 56042a0b92..d9f24c8830 100644 --- a/src/packages/calendarcard/calendarcard.scss +++ b/src/packages/calendarcard/calendarcard.scss @@ -30,6 +30,12 @@ } } + &-icon { + width: 18px; + height: 18px; + display: block; + } + &-days { display: flex; flex-direction: row; @@ -49,6 +55,13 @@ margin-bottom: 4px; text-align: center; + // 部分 Taro 机型下子节点不会稳定继承父级 color,颜色直接落到最内层文案。 + &-top, + &-inner, + &-bottom { + color: $color-title; + } + &.header { cursor: auto; } @@ -66,6 +79,12 @@ &.weekend { color: $calendar-choose-color; + + .nut-calendarcard-day-top, + .nut-calendarcard-day-inner, + .nut-calendarcard-day-bottom { + color: $calendar-choose-color; + } } &.active { diff --git a/src/packages/calendarcard/icon.taro.tsx b/src/packages/calendarcard/icon.taro.tsx index 1223f86495..f76c19c5cc 100644 --- a/src/packages/calendarcard/icon.taro.tsx +++ b/src/packages/calendarcard/icon.taro.tsx @@ -1,44 +1,32 @@ import React, { FC } from 'react' -import { Image, View } from '@tarojs/components' - -let left = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNNi42MDUgOS40OWEuNzcxLjc3MSAwIDAgMSAwLS45OGwzLjYtNC4zNzJhLjc3MS43NzEgMCAwIDEgMS4xOS45ODFMOC4yIDlsMy4xOTcgMy44ODFhLjc3MS43NzEgMCAxIDEtMS4xOTEuOThsLTMuNi00LjM3eiIvPjwvc3ZnPg==' - -let right = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNMTEuMzk2IDkuNDlhLjc3MS43NzEgMCAwIDAgMC0uOThsLTMuNi00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EuNzcxIDAgMCAxLS4xMi0xLjA4NUwxMi4zODMgOSA5LjI3MiA1LjExYS43NzEuNzcxIDAgMSAxIDEuMjA1LS45NjNsMy40OTcgNC4zNzFhLjc3MS43NzEgMCAwIDEgMCAuOTY0bC0zLjQ5NyA0LjM3MWEuNzcxLjc3MSAwIDAgMS0xLjA4NS4xMnoiLz48L3N2Zz4=' +import { Image } from '@tarojs/components' interface IconProps { url: string } -if (process.env.TARO_ENV === 'jdharmony_cpp') { - left = - 'https://img11.360buyimg.com/imagetools/jfs/t1/187031/35/51586/196/6731c464F9b9f8f00/5506e32bf15e29dc.png' - right = - 'https://img12.360buyimg.com/imagetools/jfs/t1/181006/25/51824/185/6731c452F9e252322/7493147dd6b4a88d.png' - doubleLeft = - 'https://img13.360buyimg.com/imagetools/jfs/t1/221244/29/45876/259/6731c6bdF515df0a2/624e8eee3c8494a2.png' - doubleRight = - 'https://img11.360buyimg.com/imagetools/jfs/t1/238382/25/24000/235/6731c6bdF0153286c/4a57e60b6e889af3.png' -} +const left = + 'https://storage.360buyimg.com/imgtools/6437a2b149-bb511b40-4942-11f1-b1e1-7158b9aae0a9.svg' +const right = + 'https://storage.360buyimg.com/imgtools/8aa060341d-baf78990-4942-11f1-9368-cd56fc5fadc6.svg' +const doubleLeft = + 'https://storage.360buyimg.com/imgtools/b5e798f4ed-bbe8c760-4942-11f1-b1e1-7158b9aae0a9.svg' +const doubleRight = + 'https://storage.360buyimg.com/imgtools/d6979fa16d-bbb4bf10-4942-11f1-9368-cd56fc5fadc6.svg' const Icon: FC = ({ url }) => { - const style = { - background: `url('${url}') no-repeat center`, - backgroundSize: '100% 100%', - width: 18, - height: 18, - } - if (process.env.TARO_ENV === 'jdharmony_cpp') { - return + const iconStyle = { + color: 'var(--nutui-color-text)', } - return + return ( + + ) } export const ArrowLeft: FC = () => diff --git a/src/packages/calendarcard/icons/doubleLeft.svg b/src/packages/calendarcard/icons/doubleLeft.svg new file mode 100644 index 0000000000..10561de0c6 --- /dev/null +++ b/src/packages/calendarcard/icons/doubleLeft.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/packages/calendarcard/icons/doubleRight.svg b/src/packages/calendarcard/icons/doubleRight.svg new file mode 100644 index 0000000000..ac60c24227 --- /dev/null +++ b/src/packages/calendarcard/icons/doubleRight.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/packages/calendarcard/icons/singleLeft.svg b/src/packages/calendarcard/icons/singleLeft.svg new file mode 100644 index 0000000000..9342023bc4 --- /dev/null +++ b/src/packages/calendarcard/icons/singleLeft.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/packages/calendarcard/icons/singleRight.svg b/src/packages/calendarcard/icons/singleRight.svg new file mode 100644 index 0000000000..2f9ac7a883 --- /dev/null +++ b/src/packages/calendarcard/icons/singleRight.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/packages/price/price.taro.tsx b/src/packages/price/price.taro.tsx index f491494e08..4484d15af5 100644 --- a/src/packages/price/price.taro.tsx +++ b/src/packages/price/price.taro.tsx @@ -5,6 +5,10 @@ import { ComponentDefaults } from '@/utils/typings' import { useRtl } from '@/packages/configprovider/index.taro' import { TaroPriceProps, PriceColorEnum } from '@/types' import { harmony } from '@/utils/taro/platform' +import { + shouldRenderPriceAsRaw, + hasNonPriceChars, +} from '@/utils/should-render-price-raw' const defaultProps = { ...ComponentDefaults, @@ -16,6 +20,7 @@ const defaultProps = { position: 'before', size: 'normal', line: false, + raw: false, } as TaroPriceProps export const Price: FunctionComponent> = (props) => { const { @@ -27,6 +32,7 @@ export const Price: FunctionComponent> = (props) => { position, size, line, + raw, className, style, } = { @@ -38,9 +44,20 @@ export const Price: FunctionComponent> = (props) => { const rtl = useRtl() + const isRenderPriceRaw = useMemo( + () => + (typeof originalPrice === 'string' && + shouldRenderPriceAsRaw(originalPrice)) || + (raw && + typeof originalPrice === 'string' && + hasNonPriceChars(originalPrice)), + [originalPrice, raw] + ) + const price = useMemo(() => { + if (isRenderPriceRaw) return '' return originalPrice.toString().replace(/[^\d.]/g, '') - }, [originalPrice]) + }, [originalPrice, isRenderPriceRaw]) const isCustomPriceColor = useMemo(() => { const specificPriceColor = Object.values(PriceColorEnum) @@ -86,7 +103,7 @@ export const Price: FunctionComponent> = (props) => { } const formatDecimal = (decimalNum: any) => { - if (Number(decimalNum) === 0) { + if (Number(decimalNum) === 0 && !checkPoint(decimalNum)) { decimalNum = 0 } @@ -164,6 +181,8 @@ export const Price: FunctionComponent> = (props) => { ) } + const renderRawContent = () => <>{originalPrice} + return ( <> {harmony() || process.env.TARO_ENV === 'dynamic' ? ( @@ -171,14 +190,14 @@ export const Price: FunctionComponent> = (props) => { className={`${classPrefix} ${classPrefix}-${color} ${className}`} style={style} > - {renderInner()} + {isRenderPriceRaw ? renderRawContent() : renderInner()} ) : ( - {renderInner()} + {isRenderPriceRaw ? renderRawContent() : renderInner()} )} diff --git a/src/types/spec/price/base.ts b/src/types/spec/price/base.ts index 82d67de4b3..74a21693e4 100644 --- a/src/types/spec/price/base.ts +++ b/src/types/spec/price/base.ts @@ -19,4 +19,5 @@ export interface BasePrice extends BaseProps { position: string size: PriceSize line: boolean + raw: boolean } diff --git a/src/utils/should-render-price-raw.ts b/src/utils/should-render-price-raw.ts new file mode 100644 index 0000000000..35fa961a80 --- /dev/null +++ b/src/utils/should-render-price-raw.ts @@ -0,0 +1,31 @@ +const RE_NUM = /\d+(?:\.\d+)?/g + +// 价格合法字符:数字、小数点、负号、大写货币代码(HK USD EUR 等)、常见货币符号 Unicode 区块(含全角 ¥) +const PRICE_CHARS = /^[\d.\-A-Z¥¥$€£₩₹₽₺₴₪฿\u20A0-\u20CF\uFE69\uFF04\uFFE5]*$/ + +function hasNoExtractablePrice(s: string) { + const t = s.trim() + if (!t) return true + if (!/\d/.test(t)) return true + if (t.replace(/[^\d.]/g, '') === '') return true + return false +} + +export function shouldRenderPriceAsRaw(s: string) { + if (hasNoExtractablePrice(s)) { + return true + } + const t = s.trim() + const matches = Array.from(t.matchAll(RE_NUM)) + if (matches.length < 2) return false + const a = matches[0] + const b = matches[1] + const i0 = a.index! + const i1 = b.index! + const between = t.slice(i0 + a[0].length, i1) + return !PRICE_CHARS.test(between) +} + +export function hasNonPriceChars(s: string): boolean { + return !PRICE_CHARS.test(s) +}