From ec9dd3bf608fbfd34a9b00df1e319a84a4a8efc9 Mon Sep 17 00:00:00 2001 From: oasis Date: Mon, 11 Nov 2024 14:50:59 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E7=BB=84=E4=BB=B6=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.json | 4 ++-- src/packages/checkbox/checkbox.taro.tsx | 20 ++++++-------------- src/packages/checkbox/checkbox.tsx | 6 ++---- src/packages/checkbox/demos/taro/demo2.tsx | 7 ++++--- src/packages/checkbox/demos/taro/demo3.tsx | 5 +++-- src/packages/checkbox/demos/taro/demo9.tsx | 5 +++-- src/packages/checkbox/index.taro.ts | 15 +++++++++++++-- src/packages/checkbox/index.ts | 15 +++++++++++++-- 8 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/config.json b/src/config.json index cd08dd2e36..b297504dac 100644 --- a/src/config.json +++ b/src/config.json @@ -459,7 +459,7 @@ "author": "ailululu" }, { - "version": "2.0.0", + "version": "3.0.0", "name": "Checkbox", "type": "component", "cName": "复选按钮", @@ -470,7 +470,7 @@ "author": "oasis" }, { - "version": "2.0.0", + "version": "3.0.0", "name": "CheckboxGroup", "type": "component", "cName": "多选按钮组", diff --git a/src/packages/checkbox/checkbox.taro.tsx b/src/packages/checkbox/checkbox.taro.tsx index acd6b2251a..9b5ce48e05 100644 --- a/src/packages/checkbox/checkbox.taro.tsx +++ b/src/packages/checkbox/checkbox.taro.tsx @@ -1,14 +1,7 @@ -import React, { - FunctionComponent, - ReactNode, - useContext, - useEffect, - useState, -} from 'react' -import { Checked, CheckDisabled, CheckNormal } from '@nutui/icons-react-taro' +import React, { ReactNode, useContext, useEffect, useState } from 'react' +import { CheckDisabled, Checked, CheckNormal } from '@nutui/icons-react-taro' import classNames from 'classnames' import { View } from '@tarojs/components' -import CheckboxGroup from '@/packages/checkboxgroup/index.taro' import { BasicComponent, ComponentDefaults } from '@/utils/typings' import Context from '../checkboxgroup/context' import { usePropsValue } from '@/utils/use-props-value' @@ -43,10 +36,10 @@ const defaultProps = { } as CheckboxProps const classPrefix = 'nut-checkbox' -export const Checkbox: FunctionComponent< +export const Checkbox: FC< Partial & Omit, 'onChange'> -> & { Group: typeof CheckboxGroup } = (props) => { +> = (props) => { const { children } = { ...defaultProps, ...props, @@ -152,13 +145,13 @@ export const Checkbox: FunctionComponent< } const renderLabel = () => { return ( - {children || label} - + ) } @@ -231,4 +224,3 @@ export const Checkbox: FunctionComponent< } Checkbox.displayName = 'NutCheckBox' -Checkbox.Group = CheckboxGroup diff --git a/src/packages/checkbox/checkbox.tsx b/src/packages/checkbox/checkbox.tsx index df7833a9a6..71c8dd4300 100644 --- a/src/packages/checkbox/checkbox.tsx +++ b/src/packages/checkbox/checkbox.tsx @@ -5,9 +5,8 @@ import React, { useEffect, useState, } from 'react' -import { Checked, CheckDisabled, CheckNormal } from '@nutui/icons-react' +import { CheckDisabled, Checked, CheckNormal } from '@nutui/icons-react' import classNames from 'classnames' -import CheckboxGroup from '@/packages/checkboxgroup' import { BasicComponent, ComponentDefaults } from '@/utils/typings' import Context from '../checkboxgroup/context' import { usePropsValue } from '@/utils/use-props-value' @@ -45,7 +44,7 @@ const classPrefix = 'nut-checkbox' export const Checkbox: FunctionComponent< Partial & Omit, 'onChange'> -> & { Group: typeof CheckboxGroup } = (props) => { +> = (props) => { const { children } = { ...defaultProps, ...props, @@ -230,4 +229,3 @@ export const Checkbox: FunctionComponent< } Checkbox.displayName = 'NutCheckBox' -Checkbox.Group = CheckboxGroup diff --git a/src/packages/checkbox/demos/taro/demo2.tsx b/src/packages/checkbox/demos/taro/demo2.tsx index c817562316..72d39189d4 100644 --- a/src/packages/checkbox/demos/taro/demo2.tsx +++ b/src/packages/checkbox/demos/taro/demo2.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react' -import { Checkbox, Cell } from '@nutui/nutui-react-taro' +import { Cell, Checkbox } from '@nutui/nutui-react-taro' import { Checklist } from '@nutui/icons-react-taro' +import { View } from '@tarojs/components' const Demo2 = () => { const [controlled, setControlled] = useState(false) @@ -36,9 +37,9 @@ const Demo2 = () => { value={controlledGroup} onChange={(value) => setControlledGroup(value)} > - + - + diff --git a/src/packages/checkbox/demos/taro/demo3.tsx b/src/packages/checkbox/demos/taro/demo3.tsx index b183c75c72..07a8c76649 100644 --- a/src/packages/checkbox/demos/taro/demo3.tsx +++ b/src/packages/checkbox/demos/taro/demo3.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react' import { Checkbox, Cell } from '@nutui/nutui-react-taro' +import { View } from '@tarojs/components' const Demo3 = () => { const [checked, setChecked] = useState(true) @@ -30,9 +31,9 @@ const Demo3 = () => { - + - + diff --git a/src/packages/checkbox/demos/taro/demo9.tsx b/src/packages/checkbox/demos/taro/demo9.tsx index 7340584870..c3bd308dba 100644 --- a/src/packages/checkbox/demos/taro/demo9.tsx +++ b/src/packages/checkbox/demos/taro/demo9.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react' -import { Checkbox, Toast, Cell } from '@nutui/nutui-react-taro' +import { Cell, Checkbox, Toast } from '@nutui/nutui-react-taro' +import { View } from '@tarojs/components' const Demo9 = () => { const [checkboxgroup1, setCheckboxgroup1] = useState(['1']) @@ -32,7 +33,7 @@ const Demo9 = () => { - 选中:{checkboxgroup1.toString()} + 选中:{checkboxgroup1.toString()} ) diff --git a/src/packages/checkbox/index.taro.ts b/src/packages/checkbox/index.taro.ts index a3c9db75c3..66d3ad13fe 100644 --- a/src/packages/checkbox/index.taro.ts +++ b/src/packages/checkbox/index.taro.ts @@ -1,4 +1,15 @@ -import { Checkbox } from './checkbox.taro' +import { Checkbox, CheckboxProps } from './checkbox.taro' +import { CheckboxGroup } from '../checkboxgroup/checkboxgroup.taro' export type { CheckboxProps, CheckboxShape } from './checkbox.taro' -export default Checkbox + +type CompoundedComponent = React.FC< + Partial & + Omit, 'onChange'> +> & { + Group: typeof CheckboxGroup +} +const InnerCheckbox = Checkbox as CompoundedComponent +InnerCheckbox.Group = CheckboxGroup + +export default InnerCheckbox diff --git a/src/packages/checkbox/index.ts b/src/packages/checkbox/index.ts index 15e1dc5684..b922963865 100644 --- a/src/packages/checkbox/index.ts +++ b/src/packages/checkbox/index.ts @@ -1,4 +1,15 @@ -import { Checkbox } from './checkbox' +import { Checkbox, CheckboxProps } from './checkbox' +import { CheckboxGroup } from '../checkboxgroup/checkboxgroup' export type { CheckboxProps, CheckboxShape } from './checkbox' -export default Checkbox + +type CompoundedComponent = React.FC< + Partial & + Omit, 'onChange'> +> & { + Group: typeof CheckboxGroup +} +const InnerCheckbox = Checkbox as CompoundedComponent +InnerCheckbox.Group = CheckboxGroup + +export default InnerCheckbox From 086d16187f6fb15cfc0dbc7b788fa810e339ab54 Mon Sep 17 00:00:00 2001 From: oasis Date: Mon, 11 Nov 2024 15:57:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=E9=B8=BF=E8=92=99=E4=B8=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20inline-flex=EF=BC=8C=E9=80=9A=E8=BF=87=20f?= =?UTF-8?q?lex=20=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/checkbox/demos/taro/demo1.tsx | 12 ++++++------ src/packages/checkbox/demos/taro/demo8.tsx | 6 ------ src/packages/checkboxgroup/checkboxgroup.scss | 7 +++++++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/packages/checkbox/demos/taro/demo1.tsx b/src/packages/checkbox/demos/taro/demo1.tsx index 7160ff6c1c..21ad980822 100644 --- a/src/packages/checkbox/demos/taro/demo1.tsx +++ b/src/packages/checkbox/demos/taro/demo1.tsx @@ -23,8 +23,8 @@ const Demo1 = () => { alignItems: 'center', }} > - 复选框 - 描述信息 + 复选框 + 描述信息 } defaultChecked={!checked} @@ -44,8 +44,8 @@ const Demo1 = () => { alignItems: 'center', }} > - 复选框 - 描述信息 + 复选框 + 描述信息 } defaultChecked={checked} @@ -62,8 +62,8 @@ const Demo1 = () => { alignItems: 'center', }} > - 复选框 - 描述信息 + 复选框 + 描述信息 } defaultChecked={checked} diff --git a/src/packages/checkbox/demos/taro/demo8.tsx b/src/packages/checkbox/demos/taro/demo8.tsx index 1abbbd160a..66802b194c 100644 --- a/src/packages/checkbox/demos/taro/demo8.tsx +++ b/src/packages/checkbox/demos/taro/demo8.tsx @@ -21,12 +21,6 @@ const Demo8 = () => { setShowToast(false) }} /> - handleChange(state)} - > - change复选框 - Date: Tue, 19 Nov 2024 14:28:16 +0800 Subject: [PATCH 3/5] fix: icon update --- src/packages/checkbox/demos/taro/demo1.tsx | 13 +++++++------ src/packages/checkbox/demos/taro/demo13.tsx | 17 +++++++++++++---- src/packages/checkboxgroup/checkboxgroup.scss | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/packages/checkbox/demos/taro/demo1.tsx b/src/packages/checkbox/demos/taro/demo1.tsx index 21ad980822..996512e8b4 100644 --- a/src/packages/checkbox/demos/taro/demo1.tsx +++ b/src/packages/checkbox/demos/taro/demo1.tsx @@ -5,6 +5,7 @@ import { Cell, Checkbox } from '@nutui/nutui-react-taro' const Demo1 = () => { const [checked] = useState(false) + const fontSize = { fontSize: 12 } return ( <> @@ -23,8 +24,8 @@ const Demo1 = () => { alignItems: 'center', }} > - 复选框 - 描述信息 + 复选框 + 描述信息 } defaultChecked={!checked} @@ -44,8 +45,8 @@ const Demo1 = () => { alignItems: 'center', }} > - 复选框 - 描述信息 + 复选框 + 描述信息 } defaultChecked={checked} @@ -62,8 +63,8 @@ const Demo1 = () => { alignItems: 'center', }} > - 复选框 - 描述信息 + 复选框 + 描述信息 } defaultChecked={checked} diff --git a/src/packages/checkbox/demos/taro/demo13.tsx b/src/packages/checkbox/demos/taro/demo13.tsx index 0f3ebc0288..3e8ae0225f 100644 --- a/src/packages/checkbox/demos/taro/demo13.tsx +++ b/src/packages/checkbox/demos/taro/demo13.tsx @@ -30,6 +30,7 @@ const Demo13 = () => { ref={checkboxgroup2Ref} direction="horizontal" defaultValue={checkboxgroup2} + style={{ width: '50%' }} onChange={(value) => { if (value.length === 4) { setIndeterminate(false) @@ -42,10 +43,18 @@ const Demo13 = () => { } }} > - 选项 - 选项 - 选项 - 选项 + + 选项 + + + 选项 + + + 选项 + + + 选项 + diff --git a/src/packages/checkboxgroup/checkboxgroup.scss b/src/packages/checkboxgroup/checkboxgroup.scss index 3aace487f0..47f6ceff8e 100644 --- a/src/packages/checkboxgroup/checkboxgroup.scss +++ b/src/packages/checkboxgroup/checkboxgroup.scss @@ -31,6 +31,7 @@ .nut-checkbox { display: inline-flex; + flex: 1; margin-right: 20px; &-button-active { From 5362a694d51b00d33872c163da3989277745d480 Mon Sep 17 00:00:00 2001 From: oasis Date: Tue, 19 Nov 2024 14:41:11 +0800 Subject: [PATCH 4/5] fix: build error --- src/packages/checkbox/checkbox.taro.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/checkbox/checkbox.taro.tsx b/src/packages/checkbox/checkbox.taro.tsx index 9b5ce48e05..41cdce02e0 100644 --- a/src/packages/checkbox/checkbox.taro.tsx +++ b/src/packages/checkbox/checkbox.taro.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode, useContext, useEffect, useState } from 'react' +import React, { ReactNode, useContext, useEffect, useState, FC } from 'react' import { CheckDisabled, Checked, CheckNormal } from '@nutui/icons-react-taro' import classNames from 'classnames' import { View } from '@tarojs/components' From a308ae7eaaec2db5636e3a7b38f330b16d121322 Mon Sep 17 00:00:00 2001 From: hanyuxinting Date: Wed, 20 Nov 2024 16:54:30 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=B8=8D=E8=A6=81=E4=B8=AD=E9=97=B4?= =?UTF-8?q?=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/checkbox/demos/h5/demo2.tsx | 4 +--- src/packages/checkbox/demos/h5/demo3.tsx | 4 +--- src/packages/checkbox/demos/taro/demo2.tsx | 5 +---- src/packages/checkbox/demos/taro/demo3.tsx | 5 +---- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/packages/checkbox/demos/h5/demo2.tsx b/src/packages/checkbox/demos/h5/demo2.tsx index ca7597509b..90e521053a 100644 --- a/src/packages/checkbox/demos/h5/demo2.tsx +++ b/src/packages/checkbox/demos/h5/demo2.tsx @@ -37,9 +37,7 @@ const Demo2 = () => { value={controlledGroup} onChange={(value) => setControlledGroup(value)} > - - - + diff --git a/src/packages/checkbox/demos/h5/demo3.tsx b/src/packages/checkbox/demos/h5/demo3.tsx index 4597f5dbdc..9424e70d38 100644 --- a/src/packages/checkbox/demos/h5/demo3.tsx +++ b/src/packages/checkbox/demos/h5/demo3.tsx @@ -30,9 +30,7 @@ const Demo3 = () => { - - - + diff --git a/src/packages/checkbox/demos/taro/demo2.tsx b/src/packages/checkbox/demos/taro/demo2.tsx index 72d39189d4..acc20b0e12 100644 --- a/src/packages/checkbox/demos/taro/demo2.tsx +++ b/src/packages/checkbox/demos/taro/demo2.tsx @@ -1,7 +1,6 @@ import React, { useState } from 'react' import { Cell, Checkbox } from '@nutui/nutui-react-taro' import { Checklist } from '@nutui/icons-react-taro' -import { View } from '@tarojs/components' const Demo2 = () => { const [controlled, setControlled] = useState(false) @@ -37,9 +36,7 @@ const Demo2 = () => { value={controlledGroup} onChange={(value) => setControlledGroup(value)} > - - - + diff --git a/src/packages/checkbox/demos/taro/demo3.tsx b/src/packages/checkbox/demos/taro/demo3.tsx index 07a8c76649..450d90fc94 100644 --- a/src/packages/checkbox/demos/taro/demo3.tsx +++ b/src/packages/checkbox/demos/taro/demo3.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react' import { Checkbox, Cell } from '@nutui/nutui-react-taro' -import { View } from '@tarojs/components' const Demo3 = () => { const [checked, setChecked] = useState(true) @@ -31,9 +30,7 @@ const Demo3 = () => { - - - +