@nutui/nutui-react-taro 2.0.0-alpha.3 → 2.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/esm/CircleProgress.js +2 -3
- package/dist/esm/Input.js +4 -1
- package/dist/esm/Tabbar.js +6 -3
- package/dist/esm/TabbarItem.js +3 -4
- package/dist/esm/{circleprogress.taro-d8973ae9.js → circleprogress.taro-d4943109.js} +21 -27
- package/dist/esm/input.taro-1aca4a45.js +167 -0
- package/dist/esm/nutui-react.es.js +5 -5
- package/dist/esm/tabbar.taro-48413fb8.js +51 -0
- package/dist/esm/tabbaritem.taro-5afa3562.js +37 -0
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +642 -851
- package/dist/nutui.react.umd.js +640 -849
- package/dist/packages/badge/badge.scss +0 -1
- package/dist/packages/circleprogress/circleprogress.scss +0 -9
- package/dist/packages/input/input.scss +13 -180
- package/dist/packages/tabbar/tabbar.scss +16 -23
- package/dist/packages/tabbaritem/tabbaritem.scss +9 -70
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +12 -16
- package/dist/styles/variables.scss +12 -16
- package/dist/types/index.d.ts +48 -84
- package/package.json +1 -1
- package/dist/esm/input.taro-f4e067f7.js +0 -237
- package/dist/esm/tabbar.taro-eefd0f8e.js +0 -59
- package/dist/esm/tabbaritem.taro-7a97e645.js +0 -55
package/dist/style.mjs
CHANGED
|
@@ -470,11 +470,11 @@ $picker-mask-bg-img: var(
|
|
|
470
470
|
) !default;
|
|
471
471
|
//input(✅)
|
|
472
472
|
$input-border-bottom: var(--nutui-input-border-bottom, #eaf0fb) !default;
|
|
473
|
-
$input-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
$required-color
|
|
473
|
+
$input-border-bottom-width: var(
|
|
474
|
+
--nutui-input-border-bottom-width,
|
|
475
|
+
0px
|
|
477
476
|
) !default;
|
|
477
|
+
$input-disabled-color: var(--nutui-input-disabled-color, #c8c9cc) !default;
|
|
478
478
|
$input-font-size: var(--nutui-input-font-size, $font-size-2) !default;
|
|
479
479
|
$input-padding: var(--nutui-input-padding, 10px 25px) !default;
|
|
480
480
|
|
|
@@ -871,28 +871,24 @@ $rate-icon-void-color: var(
|
|
|
871
871
|
// tabbar(✅)
|
|
872
872
|
$tabbar-height: var(--nutui-tabbar-height, 50px) !default;
|
|
873
873
|
$tabbar-active-color: var(--nutui-tabbar-active-color, $primary-color) !default;
|
|
874
|
-
$tabbar-
|
|
875
|
-
--nutui-tabbar-unactive-color,
|
|
876
|
-
$primary-color
|
|
877
|
-
) !default;
|
|
874
|
+
$tabbar-inactive-color: var(--nutui-tabbar-inactive-color, $gray1) !default;
|
|
878
875
|
$tabbar-border-top: var(--nutui-tabbar-border-top, 1px solid #eee) !default;
|
|
879
876
|
$tabbar-border-bottom: var(
|
|
880
877
|
--nutui-tabbar-border-bottom,
|
|
881
878
|
1px solid #eee
|
|
882
879
|
) !default;
|
|
883
880
|
$tabbar-box-shadow: var(--nutui-tabbar-box-shadow, none) !default;
|
|
884
|
-
$tabbar-
|
|
885
|
-
--nutui-tabbar-
|
|
881
|
+
$tabbar-text-font-size: var(
|
|
882
|
+
--nutui-tabbar-text-font-size,
|
|
886
883
|
$font-size-0
|
|
887
884
|
) !default;
|
|
888
|
-
$tabbar-
|
|
889
|
-
--nutui-tabbar-
|
|
890
|
-
|
|
885
|
+
$tabbar-text-large-font-size: var(
|
|
886
|
+
--nutui-tabbar-text-large-font-size,
|
|
887
|
+
$font-size-large
|
|
891
888
|
) !default;
|
|
889
|
+
$tabbar-text-line-height: var(--nutui-tabbar-text-line-height, 20px) !default;
|
|
892
890
|
$tabbar-height: var(--nutui-tabbar-height, 50px) !default;
|
|
893
|
-
$tabbar-
|
|
894
|
-
$tabbar-dot-right: var(--nutui-tabbar-dot-right, 12px) !default;
|
|
895
|
-
$tabbar-dot-top: var(--nutui-tabbar-dot-top, 0) !default;
|
|
891
|
+
$tabbar-text-margin-top: var(--nutui-tabbar-text-margin-top, 3px) !default;
|
|
896
892
|
|
|
897
893
|
//infiniteloading(✅)
|
|
898
894
|
$infiniteloading-bottom-color: var(
|
|
@@ -454,11 +454,11 @@ $picker-mask-bg-img: var(
|
|
|
454
454
|
|
|
455
455
|
//input(✅)
|
|
456
456
|
$input-border-bottom: var(--nutui-input-border-bottom, #eaf0fb) !default;
|
|
457
|
-
$input-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
$required-color
|
|
457
|
+
$input-border-bottom-width: var(
|
|
458
|
+
--nutui-input-border-bottom-width,
|
|
459
|
+
0px
|
|
461
460
|
) !default;
|
|
461
|
+
$input-disabled-color: var(--nutui-input-disabled-color, #c8c9cc) !default;
|
|
462
462
|
$input-font-size: var(--nutui-input-font-size, $font-size-2) !default;
|
|
463
463
|
$input-padding: var(--nutui-input-padding, 10px 25px) !default;
|
|
464
464
|
|
|
@@ -858,28 +858,24 @@ $rate-icon-void-color: var(
|
|
|
858
858
|
// tabbar(✅)
|
|
859
859
|
$tabbar-height: var(--nutui-tabbar-height, 50px) !default;
|
|
860
860
|
$tabbar-active-color: var(--nutui-tabbar-active-color, $primary-color) !default;
|
|
861
|
-
$tabbar-
|
|
862
|
-
--nutui-tabbar-unactive-color,
|
|
863
|
-
$primary-color
|
|
864
|
-
) !default;
|
|
861
|
+
$tabbar-inactive-color: var(--nutui-tabbar-inactive-color, $gray1) !default;
|
|
865
862
|
$tabbar-border-top: var(--nutui-tabbar-border-top, 1px solid #eee) !default;
|
|
866
863
|
$tabbar-border-bottom: var(
|
|
867
864
|
--nutui-tabbar-border-bottom,
|
|
868
865
|
1px solid #eee
|
|
869
866
|
) !default;
|
|
870
867
|
$tabbar-box-shadow: var(--nutui-tabbar-box-shadow, none) !default;
|
|
871
|
-
$tabbar-
|
|
872
|
-
--nutui-tabbar-
|
|
868
|
+
$tabbar-text-font-size: var(
|
|
869
|
+
--nutui-tabbar-text-font-size,
|
|
873
870
|
$font-size-0
|
|
874
871
|
) !default;
|
|
875
|
-
$tabbar-
|
|
876
|
-
--nutui-tabbar-
|
|
877
|
-
|
|
872
|
+
$tabbar-text-large-font-size: var(
|
|
873
|
+
--nutui-tabbar-text-large-font-size,
|
|
874
|
+
$font-size-large
|
|
878
875
|
) !default;
|
|
876
|
+
$tabbar-text-line-height: var(--nutui-tabbar-text-line-height, 20px) !default;
|
|
879
877
|
$tabbar-height: var(--nutui-tabbar-height, 50px) !default;
|
|
880
|
-
$tabbar-
|
|
881
|
-
$tabbar-dot-right: var(--nutui-tabbar-dot-right, 12px) !default;
|
|
882
|
-
$tabbar-dot-top: var(--nutui-tabbar-dot-top, 0) !default;
|
|
878
|
+
$tabbar-text-margin-top: var(--nutui-tabbar-text-margin-top, 3px) !default;
|
|
883
879
|
|
|
884
880
|
//infiniteloading(✅)
|
|
885
881
|
$infiniteloading-bottom-color: var(
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { CSSProperties, ReactNode, FunctionComponent, MouseEvent as MouseEvent$1, MouseEventHandler, HTMLInputTypeAttribute, ChangeEvent, FocusEvent, RefObject, Component } from 'react';
|
|
3
|
-
import { ButtonProps as ButtonProps$1, ITouchEvent } from '@tarojs/components';
|
|
3
|
+
import { ButtonProps as ButtonProps$1, ITouchEvent, InputProps as InputProps$1 } from '@tarojs/components';
|
|
4
4
|
import Taro, { InnerAudioContext } from '@tarojs/taro';
|
|
5
5
|
|
|
6
6
|
interface BasicComponent {
|
|
@@ -387,37 +387,40 @@ type SubSideNavBarProps = {
|
|
|
387
387
|
};
|
|
388
388
|
declare const SubSideNavBar: FunctionComponent<SubSideNavBarProps>;
|
|
389
389
|
|
|
390
|
-
interface
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
safeAreaInsetBottom: boolean;
|
|
398
|
-
className: string;
|
|
399
|
-
style: React__default.CSSProperties;
|
|
400
|
-
onSwitch: (child: React__default.ReactElement<any>, active: number) => void;
|
|
401
|
-
children?: React__default.ReactNode;
|
|
390
|
+
interface BadgeProps extends BasicComponent {
|
|
391
|
+
value: ReactNode;
|
|
392
|
+
dot: boolean;
|
|
393
|
+
max: number;
|
|
394
|
+
top: string;
|
|
395
|
+
right: string;
|
|
396
|
+
color: string;
|
|
402
397
|
}
|
|
403
|
-
declare const
|
|
398
|
+
declare const Badge: FunctionComponent<Partial<BadgeProps>>;
|
|
404
399
|
|
|
405
|
-
interface TabbarItemProps extends
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
tabTitle: string;
|
|
409
|
-
icon: React__default.ReactNode;
|
|
410
|
-
href: string;
|
|
411
|
-
to: any;
|
|
412
|
-
num: string | number;
|
|
400
|
+
interface TabbarItemProps extends BadgeProps {
|
|
401
|
+
title: ReactNode;
|
|
402
|
+
icon: ReactNode;
|
|
413
403
|
active: boolean;
|
|
414
404
|
activeColor: string;
|
|
415
|
-
|
|
405
|
+
inactiveColor: string;
|
|
416
406
|
index: number;
|
|
417
407
|
handleClick: (idx: number) => void;
|
|
418
408
|
}
|
|
419
409
|
declare const TabbarItem: FunctionComponent<Partial<TabbarItemProps>>;
|
|
420
410
|
|
|
411
|
+
interface TabbarProps extends BasicComponent {
|
|
412
|
+
defaultValue: number;
|
|
413
|
+
value?: number;
|
|
414
|
+
fixed: boolean;
|
|
415
|
+
inactiveColor: string;
|
|
416
|
+
activeColor: string;
|
|
417
|
+
safeArea: boolean;
|
|
418
|
+
onSwitch: (value: number) => void;
|
|
419
|
+
}
|
|
420
|
+
declare const Tabbar: FunctionComponent<Partial<TabbarProps>> & {
|
|
421
|
+
Item: typeof TabbarItem;
|
|
422
|
+
};
|
|
423
|
+
|
|
421
424
|
interface TabPanelInnerProps {
|
|
422
425
|
autoHeightClassName: string;
|
|
423
426
|
}
|
|
@@ -783,58 +786,30 @@ declare const Form: FunctionComponent<Partial<FormProps> & React__default.HTMLAt
|
|
|
783
786
|
|
|
784
787
|
type InputAlignType = 'left' | 'center' | 'right';
|
|
785
788
|
type InputFormatTrigger = 'onChange' | 'onBlur';
|
|
786
|
-
type
|
|
787
|
-
type InputRule = {
|
|
788
|
-
pattern?: RegExp;
|
|
789
|
-
message?: string;
|
|
790
|
-
required?: boolean;
|
|
791
|
-
};
|
|
789
|
+
type ConfirmTextType = 'send' | 'search' | 'next' | 'go' | 'done';
|
|
792
790
|
interface InputProps extends BasicComponent {
|
|
793
|
-
type:
|
|
791
|
+
type: keyof InputProps$1.Type | HTMLInputTypeAttribute;
|
|
794
792
|
name: string;
|
|
795
|
-
defaultValue
|
|
793
|
+
defaultValue?: string;
|
|
794
|
+
value?: string;
|
|
796
795
|
placeholder: string;
|
|
797
|
-
|
|
798
|
-
labelClass: string;
|
|
799
|
-
labelWidth: string | number;
|
|
800
|
-
labelAlign: InputAlignType;
|
|
801
|
-
colon: boolean;
|
|
802
|
-
inputAlign: InputAlignType;
|
|
803
|
-
center: boolean;
|
|
804
|
-
required: boolean;
|
|
796
|
+
align: InputAlignType;
|
|
805
797
|
disabled: boolean;
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
maxlength: any;
|
|
809
|
-
leftIcon: React__default.ReactNode;
|
|
810
|
-
rightIcon: React__default.ReactNode;
|
|
798
|
+
readOnly: boolean;
|
|
799
|
+
maxLength: number;
|
|
811
800
|
clearable: boolean;
|
|
812
801
|
clearIcon: React__default.ReactNode;
|
|
813
|
-
clearSize: string | number;
|
|
814
|
-
border: boolean;
|
|
815
802
|
formatTrigger: InputFormatTrigger;
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
slotButton?: React__default.ReactNode;
|
|
825
|
-
slotInput?: React__default.ReactNode;
|
|
826
|
-
formatter: (value: string) => void;
|
|
827
|
-
onChange?: (value: any, event: Event) => void;
|
|
828
|
-
onBlur?: (value: any, event: Event) => void;
|
|
829
|
-
onFocus?: (value: any, event: Event) => void;
|
|
830
|
-
onClear?: (value: any, event: Event) => void;
|
|
831
|
-
keypress?: (value: any, event: Event) => void;
|
|
832
|
-
onClickInput?: (value: any) => void;
|
|
833
|
-
onClickLeftIcon?: (value: any) => void;
|
|
834
|
-
onClickRightIcon?: (value: any) => void;
|
|
835
|
-
onClick?: (value: any) => void;
|
|
803
|
+
autoFocus: boolean;
|
|
804
|
+
confirmType: ConfirmTextType;
|
|
805
|
+
formatter?: (value: string) => void;
|
|
806
|
+
onChange?: (value: string) => void;
|
|
807
|
+
onBlur?: (value: string) => void;
|
|
808
|
+
onFocus?: (value: string) => void;
|
|
809
|
+
onClear?: (value: string) => void;
|
|
810
|
+
onClick?: (e: ITouchEvent) => void;
|
|
836
811
|
}
|
|
837
|
-
declare const Input:
|
|
812
|
+
declare const Input: React__default.ForwardRefExoticComponent<Partial<InputProps> & Partial<Omit<InputProps$1, "type" | "ref" | "onFocus" | "onBlur">> & React__default.RefAttributes<unknown>>;
|
|
838
813
|
|
|
839
814
|
interface InputNumberProps extends BasicComponent {
|
|
840
815
|
disabled: boolean;
|
|
@@ -1272,16 +1247,6 @@ interface ActionSheetProps {
|
|
|
1272
1247
|
}
|
|
1273
1248
|
declare const ActionSheet: FunctionComponent<Partial<ActionSheetProps> & React__default.HTMLAttributes<HTMLDivElement>>;
|
|
1274
1249
|
|
|
1275
|
-
interface BadgeProps extends BasicComponent {
|
|
1276
|
-
value: ReactNode;
|
|
1277
|
-
dot: boolean;
|
|
1278
|
-
max: number;
|
|
1279
|
-
top: string;
|
|
1280
|
-
right: string;
|
|
1281
|
-
color: string;
|
|
1282
|
-
}
|
|
1283
|
-
declare const Badge: FunctionComponent<Partial<BadgeProps>>;
|
|
1284
|
-
|
|
1285
1250
|
interface BasicDialogProps {
|
|
1286
1251
|
visible?: boolean;
|
|
1287
1252
|
title?: ReactNode;
|
|
@@ -1611,17 +1576,16 @@ interface AvatarGroupProps {
|
|
|
1611
1576
|
}
|
|
1612
1577
|
declare const AvatarGroup: FunctionComponent<Partial<AvatarGroupProps> & React__default.HTMLAttributes<HTMLDivElement>>;
|
|
1613
1578
|
|
|
1614
|
-
interface CircleProgressProps {
|
|
1615
|
-
|
|
1579
|
+
interface CircleProgressProps extends BasicComponent {
|
|
1580
|
+
percent: string | number;
|
|
1616
1581
|
strokeWidth?: string | number;
|
|
1617
1582
|
radius?: number | string;
|
|
1618
|
-
strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit'
|
|
1619
|
-
|
|
1620
|
-
|
|
1583
|
+
strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit';
|
|
1584
|
+
color?: object | string;
|
|
1585
|
+
background?: string;
|
|
1621
1586
|
clockwise?: boolean;
|
|
1622
|
-
className?: string;
|
|
1623
1587
|
}
|
|
1624
|
-
declare const CircleProgress: FunctionComponent<CircleProgressProps & React__default.HTMLAttributes<HTMLDivElement>>;
|
|
1588
|
+
declare const CircleProgress: FunctionComponent<CircleProgressProps & Omit<React__default.HTMLAttributes<HTMLDivElement>, 'color'>>;
|
|
1625
1589
|
|
|
1626
1590
|
interface CollapseProps {
|
|
1627
1591
|
className: string;
|
package/package.json
CHANGED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useRef, useEffect, useImperativeHandle, useCallback } from 'react';
|
|
2
|
-
import { MaskClose } from '@nutui/icons-react-taro';
|
|
3
|
-
import { u as useConfig } from './configprovider.taro-43a3c646.js';
|
|
4
|
-
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
5
|
-
|
|
6
|
-
function trimExtraChar(value, char, regExp) {
|
|
7
|
-
const index = value.indexOf(char);
|
|
8
|
-
if (index === -1) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
if (char === '-' && index !== 0) {
|
|
12
|
-
return value.slice(0, index);
|
|
13
|
-
}
|
|
14
|
-
return value.slice(0, index + 1) + value.slice(index).replace(regExp, '');
|
|
15
|
-
}
|
|
16
|
-
function formatNumber(value, allowDot = true, allowMinus = true) {
|
|
17
|
-
if (allowDot) {
|
|
18
|
-
value = trimExtraChar(value, '.', /\./g);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
value = value.split('.')[0];
|
|
22
|
-
}
|
|
23
|
-
if (allowMinus) {
|
|
24
|
-
value = trimExtraChar(value, '-', /-/g);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
value = value.replace(/-/, '');
|
|
28
|
-
}
|
|
29
|
-
const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
|
|
30
|
-
return value.replace(regExp, '');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const defaultProps = {
|
|
34
|
-
...ComponentDefaults,
|
|
35
|
-
type: 'text',
|
|
36
|
-
name: '',
|
|
37
|
-
defaultValue: '',
|
|
38
|
-
placeholder: '',
|
|
39
|
-
label: '',
|
|
40
|
-
labelClass: '',
|
|
41
|
-
labelWidth: '80',
|
|
42
|
-
labelAlign: 'left',
|
|
43
|
-
colon: false,
|
|
44
|
-
inputAlign: 'left',
|
|
45
|
-
center: false,
|
|
46
|
-
required: false,
|
|
47
|
-
disabled: false,
|
|
48
|
-
readonly: false,
|
|
49
|
-
error: false,
|
|
50
|
-
maxlength: '9999',
|
|
51
|
-
leftIcon: null,
|
|
52
|
-
rightIcon: null,
|
|
53
|
-
clearable: false,
|
|
54
|
-
clearIcon: null,
|
|
55
|
-
clearSize: '14',
|
|
56
|
-
border: true,
|
|
57
|
-
formatTrigger: 'onChange',
|
|
58
|
-
rules: [],
|
|
59
|
-
rows: null,
|
|
60
|
-
errorMessage: '',
|
|
61
|
-
errorMessageAlign: '',
|
|
62
|
-
showWordLimit: false,
|
|
63
|
-
autofocus: false,
|
|
64
|
-
slotButton: null,
|
|
65
|
-
slotInput: null,
|
|
66
|
-
};
|
|
67
|
-
const Input = forwardRef((props, ref) => {
|
|
68
|
-
const { locale } = useConfig();
|
|
69
|
-
const { children, type, name, defaultValue, placeholder, label, labelClass, labelWidth, labelAlign, colon, inputAlign, center, required, disabled, readonly, error, maxlength, leftIcon, rightIcon, clearable, clearIcon, clearSize, border, formatTrigger, rules, errorMessage, errorMessageAlign, showWordLimit, autofocus, style, className, rows, slotButton, slotInput, onChange, onBlur, onFocus, onClear, formatter, keypress, onClickInput, onClickLeftIcon, onClickRightIcon, onClick, ...rest } = {
|
|
70
|
-
...defaultProps,
|
|
71
|
-
...props,
|
|
72
|
-
};
|
|
73
|
-
const inputPlaceholder = placeholder || locale.placeholder;
|
|
74
|
-
const [inputValue, SetInputValue] = useState('');
|
|
75
|
-
const [active, SetActive] = useState(false);
|
|
76
|
-
const [classes, setClasses] = useState('');
|
|
77
|
-
const getModelValue = () => String(inputValue ?? '');
|
|
78
|
-
const inputRef = useRef(null);
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
setClasses(inputClass);
|
|
81
|
-
SetInputValue(defaultValue);
|
|
82
|
-
}, [defaultValue]);
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (inputValue) {
|
|
85
|
-
updateValue(getModelValue());
|
|
86
|
-
resetValidation();
|
|
87
|
-
}
|
|
88
|
-
}, [inputValue]);
|
|
89
|
-
useImperativeHandle(ref, () => {
|
|
90
|
-
return inputRef.current;
|
|
91
|
-
});
|
|
92
|
-
const inputClass = useCallback(() => {
|
|
93
|
-
const prefixCls = 'nut-input';
|
|
94
|
-
return [
|
|
95
|
-
prefixCls,
|
|
96
|
-
`${center ? 'center' : ''}`,
|
|
97
|
-
`${disabled ? `${prefixCls}-disabled` : ''}`,
|
|
98
|
-
`${required ? `${prefixCls}-required` : ''}`,
|
|
99
|
-
`${error ? `${prefixCls}-error` : ''}`,
|
|
100
|
-
`${border ? `${prefixCls}-border` : ''}`,
|
|
101
|
-
`${slotButton || rightIcon ? `${prefixCls}-right-mark` : ''}`,
|
|
102
|
-
]
|
|
103
|
-
.filter(Boolean)
|
|
104
|
-
.join(' ');
|
|
105
|
-
}, [disabled, required, error, border, slotButton, rightIcon, center]);
|
|
106
|
-
// 样式状态重置
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
setClasses(inputClass);
|
|
109
|
-
}, [disabled, required, error, border, slotButton, rightIcon, center]);
|
|
110
|
-
const updateValue = (value, trigger = 'onChange') => {
|
|
111
|
-
let val = value;
|
|
112
|
-
if (type === 'digit' || type === 'tel') {
|
|
113
|
-
val = formatNumber(val, false, false);
|
|
114
|
-
}
|
|
115
|
-
if (type === 'number') {
|
|
116
|
-
val = formatNumber(val, true, true);
|
|
117
|
-
}
|
|
118
|
-
if (type === 'tel' && !formatter) {
|
|
119
|
-
const regTel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
|
|
120
|
-
const regNumber = /[^-0-9]/g;
|
|
121
|
-
val =
|
|
122
|
-
!regTel.test(val) && val.length > 11
|
|
123
|
-
? val.substring(0, 11)
|
|
124
|
-
: val.replace(regNumber, '');
|
|
125
|
-
}
|
|
126
|
-
if (formatter && trigger === formatTrigger) {
|
|
127
|
-
val = formatter(val);
|
|
128
|
-
}
|
|
129
|
-
if (inputRef?.current?.value !== val) {
|
|
130
|
-
inputRef.current.value = val;
|
|
131
|
-
}
|
|
132
|
-
SetInputValue(val);
|
|
133
|
-
};
|
|
134
|
-
const handleFocus = (event) => {
|
|
135
|
-
const val = event.target.value;
|
|
136
|
-
SetActive(true);
|
|
137
|
-
onFocus && onFocus(val, event);
|
|
138
|
-
};
|
|
139
|
-
const handleInput = (event) => {
|
|
140
|
-
let val = event.target.value;
|
|
141
|
-
if (maxlength && val.length > Number(maxlength)) {
|
|
142
|
-
val = val.slice(0, Number(maxlength));
|
|
143
|
-
}
|
|
144
|
-
updateValue(val, 'onChange');
|
|
145
|
-
onChange && onChange(val, event);
|
|
146
|
-
};
|
|
147
|
-
const handleBlur = (event) => {
|
|
148
|
-
setTimeout(() => {
|
|
149
|
-
SetActive(false);
|
|
150
|
-
}, 200);
|
|
151
|
-
let val = event.target.value;
|
|
152
|
-
if (maxlength && val.length > Number(maxlength)) {
|
|
153
|
-
val = val.slice(0, Number(maxlength));
|
|
154
|
-
}
|
|
155
|
-
updateValue(val, 'onBlur');
|
|
156
|
-
onBlur && onBlur(val, event);
|
|
157
|
-
};
|
|
158
|
-
const handleClickInput = (event) => {
|
|
159
|
-
onClickInput && onClickInput(event);
|
|
160
|
-
};
|
|
161
|
-
const handleClickLeftIcon = (event) => {
|
|
162
|
-
onClickLeftIcon && onClickLeftIcon(event);
|
|
163
|
-
};
|
|
164
|
-
const handleClickRightIcon = (event) => {
|
|
165
|
-
onClickRightIcon && onClickRightIcon(event);
|
|
166
|
-
};
|
|
167
|
-
const resetValidation = () => {
|
|
168
|
-
};
|
|
169
|
-
const inputType = (type) => {
|
|
170
|
-
if (type === 'number') {
|
|
171
|
-
return 'text';
|
|
172
|
-
}
|
|
173
|
-
if (type === 'digit') {
|
|
174
|
-
return 'tel';
|
|
175
|
-
}
|
|
176
|
-
return type;
|
|
177
|
-
};
|
|
178
|
-
const handleClear = (event) => {
|
|
179
|
-
updateValue('');
|
|
180
|
-
onClear && onClear('', event);
|
|
181
|
-
};
|
|
182
|
-
return (React.createElement("div", { className: `${classes} ${className || ''}`, style: style, onClick: (e) => {
|
|
183
|
-
onClick && onClick(e);
|
|
184
|
-
} }, slotInput ? (React.createElement(React.Fragment, null,
|
|
185
|
-
label ? (React.createElement("div", { className: `nut-input-label ${labelClass}`, style: { width: `${labelWidth}px`, textAlign: labelAlign } },
|
|
186
|
-
React.createElement("div", { className: "label-string" },
|
|
187
|
-
label,
|
|
188
|
-
colon ? ':' : ''))) : null,
|
|
189
|
-
React.createElement("div", { className: "nut-input-value" },
|
|
190
|
-
React.createElement("div", { className: "nut-input-inner", onClick: (e) => {
|
|
191
|
-
handleClickInput(e);
|
|
192
|
-
} }, slotInput)))) : (React.createElement(React.Fragment, null,
|
|
193
|
-
React.isValidElement(leftIcon) ? (React.createElement("div", { className: "nut-input-left-icon", onClick: (e) => {
|
|
194
|
-
handleClickLeftIcon(e);
|
|
195
|
-
} }, leftIcon)) : null,
|
|
196
|
-
label ? (React.createElement("div", { className: `nut-input-label ${labelClass}`, style: { width: `${labelWidth}px`, textAlign: labelAlign } },
|
|
197
|
-
React.createElement("div", { className: "label-string" },
|
|
198
|
-
label,
|
|
199
|
-
colon ? ':' : ''))) : null,
|
|
200
|
-
React.createElement("div", { className: "nut-input-value" },
|
|
201
|
-
React.createElement("div", { className: "nut-input-main-con" },
|
|
202
|
-
React.createElement("div", { className: "nut-input-inner", onClick: (e) => {
|
|
203
|
-
handleClickInput(e);
|
|
204
|
-
} },
|
|
205
|
-
type === 'textarea' ? (React.createElement("textarea", { name: name, className: "input-text", ref: inputRef, style: {
|
|
206
|
-
textAlign: inputAlign,
|
|
207
|
-
height: `${Number(rows) * 24}px`,
|
|
208
|
-
}, maxLength: maxlength, placeholder: inputPlaceholder, disabled: disabled, readOnly: readonly, value: inputValue, autoFocus: autofocus, onBlur: (e) => {
|
|
209
|
-
handleBlur(e);
|
|
210
|
-
}, onFocus: (e) => {
|
|
211
|
-
handleFocus(e);
|
|
212
|
-
}, onInput: (e) => {
|
|
213
|
-
handleInput(e);
|
|
214
|
-
} })) : (React.createElement("input", { ...rest, name: name, className: "input-text", ref: inputRef, style: { textAlign: inputAlign }, type: inputType(type), maxLength: maxlength, placeholder: inputPlaceholder, disabled: disabled, readOnly: readonly, value: inputValue, autoFocus: autofocus, onBlur: (e) => {
|
|
215
|
-
handleBlur(e);
|
|
216
|
-
}, onFocus: (e) => {
|
|
217
|
-
handleFocus(e);
|
|
218
|
-
}, onInput: (e) => {
|
|
219
|
-
handleInput(e);
|
|
220
|
-
} })),
|
|
221
|
-
clearable && !readonly && active && inputValue.length > 0 ? (React.createElement("span", { className: "nut-input-clear-wrap", onClick: (e) => handleClear(e) }, clearIcon || React.createElement(MaskClose, { className: "nut-input-clear" }))) : null),
|
|
222
|
-
React.isValidElement(rightIcon) ? (React.createElement("div", { className: "nut-input-right-icon", onClick: (e) => {
|
|
223
|
-
handleClickRightIcon(e);
|
|
224
|
-
} }, rightIcon)) : null,
|
|
225
|
-
slotButton ? (React.createElement("div", { className: "nut-input-button" }, slotButton)) : null,
|
|
226
|
-
showWordLimit && maxlength ? (React.createElement("div", { className: "nut-input-word-limit" },
|
|
227
|
-
React.createElement("span", { className: "nut-input-word-num" }, inputValue ? inputValue.length : 0),
|
|
228
|
-
"/",
|
|
229
|
-
maxlength)) : null),
|
|
230
|
-
errorMessage ? (React.createElement("div", { className: "nut-input-error-message", style: {
|
|
231
|
-
textAlign: errorMessageAlign,
|
|
232
|
-
} }, errorMessage)) : (React.createElement("div", null)))))));
|
|
233
|
-
});
|
|
234
|
-
Input.defaultProps = defaultProps;
|
|
235
|
-
Input.displayName = 'NutInput';
|
|
236
|
-
|
|
237
|
-
export { Input as I };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { c as cn } from './bem-350c1702.js';
|
|
3
|
-
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
visible: 0,
|
|
6
|
-
bottom: false,
|
|
7
|
-
size: 20,
|
|
8
|
-
unactiveColor: '',
|
|
9
|
-
activeColor: '',
|
|
10
|
-
safeAreaInsetBottom: false,
|
|
11
|
-
className: '',
|
|
12
|
-
style: {},
|
|
13
|
-
onSwitch: (child, activeVisible) => { },
|
|
14
|
-
};
|
|
15
|
-
const Tabbar = (props) => {
|
|
16
|
-
const { children, visible, activeVisible, bottom, size, activeColor, unactiveColor, safeAreaInsetBottom, className, style, onSwitch, } = {
|
|
17
|
-
...defaultProps,
|
|
18
|
-
...props,
|
|
19
|
-
};
|
|
20
|
-
const b = cn('tabbar');
|
|
21
|
-
const [selectIndex, setSelectIndex] = useState(activeVisible || visible);
|
|
22
|
-
const handleClick = (idx) => {
|
|
23
|
-
if (!('activeVisible' in props)) {
|
|
24
|
-
setSelectIndex(idx);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (activeVisible !== undefined) {
|
|
29
|
-
setSelectIndex(activeVisible);
|
|
30
|
-
}
|
|
31
|
-
}, [activeVisible]);
|
|
32
|
-
return (React.createElement("div", { className: [
|
|
33
|
-
`${b()}`,
|
|
34
|
-
bottom ? `${b('bottom')}` : '',
|
|
35
|
-
safeAreaInsetBottom ? `${b('bottom')} ${b('safebottom')}` : '',
|
|
36
|
-
className,
|
|
37
|
-
].join(' '), style: style }, React.Children.map(children, (child, idx) => {
|
|
38
|
-
if (!React.isValidElement(child)) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
const childProps = {
|
|
42
|
-
...child.props,
|
|
43
|
-
active: idx === selectIndex,
|
|
44
|
-
index: idx,
|
|
45
|
-
unactiveColor,
|
|
46
|
-
activeColor,
|
|
47
|
-
size,
|
|
48
|
-
handleClick: () => {
|
|
49
|
-
handleClick(idx);
|
|
50
|
-
onSwitch(child, idx);
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
return React.cloneElement(child, childProps);
|
|
54
|
-
})));
|
|
55
|
-
};
|
|
56
|
-
Tabbar.defaultProps = defaultProps;
|
|
57
|
-
Tabbar.displayName = 'NutTabbar';
|
|
58
|
-
|
|
59
|
-
export { Tabbar as T };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import Taro from '@tarojs/taro';
|
|
3
|
-
import { c as cn } from './bem-350c1702.js';
|
|
4
|
-
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
5
|
-
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
...ComponentDefaults,
|
|
8
|
-
dot: false,
|
|
9
|
-
className: '',
|
|
10
|
-
tabTitle: '',
|
|
11
|
-
icon: null,
|
|
12
|
-
href: '',
|
|
13
|
-
to: '',
|
|
14
|
-
num: '',
|
|
15
|
-
active: false,
|
|
16
|
-
activeColor: '',
|
|
17
|
-
unactiveColor: '',
|
|
18
|
-
index: 0,
|
|
19
|
-
handleClick: (idx) => { },
|
|
20
|
-
};
|
|
21
|
-
const TabbarItem = (props) => {
|
|
22
|
-
const { dot, className, style, tabTitle, icon, href, to, num, active, activeColor, unactiveColor, index, handleClick, } = {
|
|
23
|
-
...defaultProps,
|
|
24
|
-
...props,
|
|
25
|
-
};
|
|
26
|
-
const b = cn('tabbar-item');
|
|
27
|
-
const bIcon = cn('tabbar-item__icon-box');
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (active && href) {
|
|
30
|
-
window.location.href = href;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (active && to) {
|
|
34
|
-
Taro.navigateTo({
|
|
35
|
-
url: to,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}, [active, href, to]);
|
|
39
|
-
return (React.createElement("div", { className: `${b({ active })} ${className}`, style: {
|
|
40
|
-
...style,
|
|
41
|
-
color: active ? activeColor : unactiveColor,
|
|
42
|
-
}, onClick: () => {
|
|
43
|
-
handleClick(index);
|
|
44
|
-
} },
|
|
45
|
-
React.createElement("div", { className: `${bIcon()}` },
|
|
46
|
-
!dot ? (React.createElement(React.Fragment, null,
|
|
47
|
-
num && num <= 99 && (React.createElement("div", { className: `${bIcon('tips', [bIcon('num')])}` }, num)),
|
|
48
|
-
num && num >= 100 && (React.createElement("div", { className: `${bIcon('tips', [bIcon('nums')])}` }, "99+")))) : (React.createElement("div", { className: `${bIcon('tips', [bIcon('dot')])}` })),
|
|
49
|
-
icon || null),
|
|
50
|
-
tabTitle && (React.createElement("div", { className: bIcon({ 'nav-word': true }, [
|
|
51
|
-
bIcon({ 'big-word': !icon }),
|
|
52
|
-
]) }, tabTitle))));
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { TabbarItem as T };
|