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

fix: 修复 Checkbox.Group 在嵌套情况下影响内部选中状态的问题 #890

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
6176b43
fix: 修复 `Checkbox.Group` 在嵌套情况下影响内部选中状态的问题
Dec 26, 2024
1bcbdcf
Merge branch 'main' into fix-bug-checkbox-group-nested
Dec 26, 2024
0fb871e
chore: 3.5.6-beta.2
Dec 26, 2024
fa8ad42
fix: 修复 `Select` 多选模式下,开启 `onFilter` 后且使用 `open` 做面板受控打开时,自动聚焦失效的问题
Dec 26, 2024
2e82961
fix: 更新Button示例
Dec 26, 2024
b6ee5ff
fix: 修复`Radio.Group` 传data属性用法下,设置 `size` 属性不生效的问题
Dec 26, 2024
bb4e22c
fix: release 3.5.6-beta.3
Dec 26, 2024
f994229
chore: update test snap
Dec 26, 2024
2feff22
fix: 修复 `DatePicker` 组件在开启 `range` 和 `open` 属性后第一次点击无法选择日期的问题 (#897)
KMS-Bismarck Dec 30, 2024
7e07d8b
fix: 修复 `Spin` 的ring样式在微前端框架下颜色不继承的问题
Dec 30, 2024
786695b
fix: 修复 `Steps` 组件 `type='arrow'` 模式下小尺寸样式异常的问题 (#899)
KMS-Bismarck Dec 30, 2024
3dfd3f6
chore: 3.5.6-beta.6
Dec 30, 2024
bc181aa
fix: 修复 `Steps` 在 `size='large'` 情况下样式异常的问题 (#900)
KMS-Bismarck Dec 31, 2024
6e39f09
fix: 修复 `Form.Field` 下的Input使用onChange设置对象格式的值时,光标跳到末尾的问题(Regression:…
Dec 31, 2024
7645ca7
fix: 修复 `Cascader` 选择结果后箭头和关闭 icon 展示异常的问题 (#903)
KMS-Bismarck Jan 2, 2025
4b0fdce
fix: 修复 `Cascader` 在输入搜索过程中点击选项后 `onChange` 第二参数未返回的问题 (#904)
KMS-Bismarck Jan 2, 2025
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,7 +1,7 @@
{
"name": "sheinx",
"private": true,
"version": "3.5.6-beta.1",
"version": "3.5.6-beta.10",
"description": "A react library developed with sheinx",
"module": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
18 changes: 12 additions & 6 deletions packages/base/src/cascader/cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { FormFieldContext } from '../form/form-field-context';

import { useConfig, getLocale } from '../config';

const { devUseWarning} = util
const { devUseWarning } = util;

const Cascader = <DataItem, Value extends KeygenResult[]>(
props0: CascaderProps<DataItem, Value>,
Expand Down Expand Up @@ -423,12 +423,16 @@ const Cascader = <DataItem, Value extends KeygenResult[]>(
{defaultIcon}
</span>
);
const close = (
<span className={styles.clearIcon} onClick={handleClear}>
{Icons.cascader.Close}
</span>
);

return (
<>
<span className={styles.clearIcon} onClick={handleClear}>
{Icons.cascader.Close}
</span>
{!open && !isEmpty && arrow}
{close}
{!open && !isEmpty && !focused && arrow}
</>
);
};
Expand Down Expand Up @@ -693,7 +697,9 @@ const Cascader = <DataItem, Value extends KeygenResult[]>(
}

if (mode !== undefined && loader && [0, 1, 2].includes(mode)) {
devUseWarning.error(`The mode ${mode} is not supported when loader setted. Only 3 or 4 can be set.`);
devUseWarning.error(
`The mode ${mode} is not supported when loader setted. Only 3 or 4 can be set.`,
);
}
}, []);

Expand Down
8 changes: 4 additions & 4 deletions packages/base/src/cascader/filter-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ const FilterNode = <DataItem, Value extends KeygenResult[]>(

const styles = jssStyle?.cascader?.() as CascaderClasses;

const handleSelectItem = (index: number, e?: any) => {
const handleSelectItem = (index: number, d: DataItem, e?: any) => {
const isFinal = data && index === data.length - 1;
if (shouldFinal && !isFinal) return;
if (e) e.stopPropagation();
const item = data[index];
const isDisabled = datum.isDisabled(datum.getKey(item));
if (isDisabled) return;
const keys = data.slice(0, index + 1).map((i: DataItem) => datum.getKey(i)) as Value;
if (onChange) onChange(keys);
if (onChange) onChange(keys, d);
onPathChange(datum.getKey(item), item, keys.slice(0, keys.length - 1) as Value, true);
setInputText('');
setFilterText('');
};

const handleSelect = () => {
handleSelectItem(data.length - 1);
handleSelectItem(data.length - 1, data?.[data.length - 1]);
};

return (
<div className={classNames(styles.option, styles.filterOption)} onClick={handleSelect}>
<div className={classNames(styles.optionInner)}>
{data.map((item, index) => {
const handleClick = (e: any) => {
handleSelectItem(index, e);
handleSelectItem(index, item, e);
};
const isDisabled = datum.isDisabled(datum.getKey(item));
const content = (
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/cascader/filter-node.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface FilterNodeProps<DataItem, Value extends KeygenResult[]> {
renderItem: (data: DataItem, active?: boolean, id?: Value[0] | undefined) => React.ReactNode;
setInputText: (text: string) => void;
setFilterText: (text: string) => void;
onChange: (item: Value) => void;
onChange: (item: Value, selected?: DataItem) => void;
onPathChange: (
id: KeygenResult,
item: DataItem | null,
Expand Down
18 changes: 15 additions & 3 deletions packages/base/src/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import GroupContext from './group-context';
import useCheckboxInputable from './use-checkbox-inputable';
import Input from '../input';

const {devUseWarning} = util
const { devUseWarning } = util;

const Checkbox = <T,>(props: CheckboxProps<T>) => {
const {
Expand Down Expand Up @@ -55,9 +55,12 @@ const Checkbox = <T,>(props: CheckboxProps<T>) => {
}

// 兼容Checkbox在createPortal中使用时,无法改变勾选状态的问题
if ('value' in props && props.checked === undefined) {
if ('value' in props && props.checked === undefined) {
onInputableCheckboxChange(checked);
}
if (props.onRawChange) {
props.onRawChange(checked ? htmlValue : undefined, checked, htmlValue);
}
onChange?.(checked ? htmlValue : undefined, checked, htmlValue);
});

Expand Down Expand Up @@ -106,7 +109,16 @@ const Checkbox = <T,>(props: CheckboxProps<T>) => {

const CheckboxWithContext = <T,>(props: CheckboxProps<T>) => {
return (
<GroupContext.Consumer>{(value) => <Checkbox {...props} {...value} />}</GroupContext.Consumer>
<GroupContext.Consumer>
{(value) => (
<Checkbox
{...props}
{...value}
onRawChange={props.onChange}
checked={'checked' in props ? props.checked : value.checked}
/>
)}
</GroupContext.Consumer>
);
};

Expand Down
5 changes: 5 additions & 0 deletions packages/base/src/checkbox/checkbox.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export interface CheckboxProps<T>
* @cn 值改变回调函数
*/
onChange?: (value: T | undefined, checked: boolean, raw: T) => void;
/**
* @en Value chane callback
* @cn 值改变回调函数
*/
onRawChange?: (value: T | undefined, checked: boolean, raw: T) => void;
/**
* @en If not set, use (value === htmlValue)
* @cn checked 传入时为受控组件
Expand Down
13 changes: 12 additions & 1 deletion packages/base/src/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,25 @@ const DatePicker = <Value extends DatePickerValueType>(props0: DatePickerProps<V
}
} else {
func.finishEdit();

// 如果是通过 props.open 控制的,那么需要在关闭时,将组件再次进入编辑状态
if (props.open === true) {
func.startEdit();
}
}

setIsCloseFromConfirm(false);
}
props.onCollapse?.(isOpen);
});

// 如果一开始就打开了板子,那么需要初始化让组件进入编辑状态
useEffect(() => {
if (props.open) {
func.startEdit();
}
}, []);

const { open, position, targetRef, popupRef, openPop, closePop } = usePopup({
open: props.open,
onCollapse: onCollapse,
Expand Down Expand Up @@ -169,7 +181,6 @@ const DatePicker = <Value extends DatePickerValueType>(props0: DatePickerProps<V
const handleClose = (isFromConfirm?: boolean) => {
setIsCloseFromConfirm(isFromConfirm || false);
closePop();

if (isFromConfirm) {
func.finishEdit();
}
Expand Down
5 changes: 3 additions & 2 deletions packages/base/src/radio/radio-group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RadioGroupProps } from './radio-group.type';
import { useInputAble, useListSelectSingle, usePersistFn, util } from '@sheinx/hooks';
import groupContext from './group-context';
import GroupContext from './group-context';
import Radio from './radio';
import React, { useContext } from 'react';
import classNames from 'classnames';
Expand Down Expand Up @@ -106,7 +106,7 @@ const Group = <DataItem, Value>(props0: RadioGroupProps<DataItem, Value>) => {

const Radios =
props.data === undefined ? (
<groupContext.Provider value={providerValue}>{children}</groupContext.Provider>
<GroupContext.Provider value={providerValue}>{children}</GroupContext.Provider>
) : (
<>
{props.data.map((d, i) => (
Expand All @@ -116,6 +116,7 @@ const Group = <DataItem, Value>(props0: RadioGroupProps<DataItem, Value>) => {
disabled={datum.disabledCheck(d)}
key={util.getKey(keygen, d, i)}
htmlValue={i}
size={size}
onChange={handleIndexChange}
renderRadio={renderRadio}
>
Expand Down
7 changes: 7 additions & 0 deletions packages/base/src/select/result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ const Result = <DataItem, Value>(props: ResultProps<DataItem, Value>) => {
mounted.current = true;
}, [focus, placeholder, multiple]);

// Select多选模式下,且开启了onFilter,自动聚焦
useLayoutEffect(() => {
if (multiple && focus && inputRef?.current) {
inputRef.current.focus();
}
}, [focus, multiple]);

useLayoutEffect(() => {
handleResetMore();
}, [valueProp, data]);
Expand Down
15 changes: 12 additions & 3 deletions packages/hooks/src/components/use-form/use-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,18 @@ const useForm = <T extends ObjectType>(props: UseFormProps<T>) => {
} else {
const names = isArray(name) ? name : [name];
names.forEach((key) => {
context.updateMap[key]?.forEach((update) => {
update(context.value, context.errors, context.serverErrors);
});
// 外部直接设置user.name这种格式的,但是又没有显性的声明user.name绑定的表单元素;
// 这里需要手动触发,否则会导致Input输入过程中光标跳到末尾的异常
if (!context.updateMap[key]) {
const parentKey = key.split('.')[0];
context.updateMap[parentKey]?.forEach((update) => {
update(context.value, context.errors, context.serverErrors);
});
} else {
context.updateMap[key]?.forEach((update) => {
update(context.value, context.errors, context.serverErrors);
});
}
context.flowMap[key]?.forEach((update) => {
update();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/shineout-style/src/spin/ring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
boxSizing: 'border-box',
position: 'relative',
borderStyle: 'solid',
borderColor: Token.spinColor,
borderColor: `transparent ${Token.spinColor} ${Token.spinColor} ${Token.spinColor}`,
borderRadius: '50%',
animation: '$ring 1s linear infinite',
borderTopColor: 'transparent',
};

119 changes: 110 additions & 9 deletions packages/shineout-style/src/steps/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,70 @@ const stepsStyle: JsStyles<StepsClassType> = {
small: {
fontSize: Token.stepsIconFontSize,
'&$arrow': {
'& $step[dir=rtl]:after': {
left: -12,
},
'& $step:not(:last-child)': {
'&$widthDescription': {
'&:after': {
borderLeftWidth: 22,
borderTopWidth: 28,
borderBottomWidth: 28,
},
'&:before': {
borderLeftWidth: 22,
borderTopWidth: 28,
borderBottomWidth: 28,
},
'&[dir=ltr]:after': { right: -22 },
'&[dir=rtl]:after': { left: -22 },
},
'&[dir=rtl]:after': {
left: -12,
right: 'auto',
},
'&:after': {
top: `calc(100% - 28px)`,
width: 56,
height: 56,
top: 0,
right: -12,
width: 12,
height: 32,
borderLeftWidth: 12,
borderTopWidth: 16,
borderBottomWidth: 16,
},
'&:before': {
top: `calc(100% - 28px)`,
width: 56,
height: 56,
top: 0,
width: 12,
height: 32,
borderLeftWidth: 12,
borderTopWidth: 16,
borderBottomWidth: 16,
right: -12,
},
'&[dir=rtl]:before': {
right: 0,
},
},
'& $step:last-child': {
'&$widthDescription': {
'&:before': {
borderLeftWidth: 22,
borderTopWidth: 28,
borderBottomWidth: 28,
},
},
'&:before': {
borderLeftWidth: 12,
borderTopWidth: 16,
borderBottomWidth: 16,
},
},
'& $content': {
padding: `${Token.stepsSmallArrowPaddingY} ${Token.stepsSmallArrowPaddingX}`,
boxSizing: 'border-box',
},
},

'&$dot': {
'&$vertical': {
'& $tail': {},
Expand Down Expand Up @@ -135,9 +182,63 @@ const stepsStyle: JsStyles<StepsClassType> = {
},
large: {
'&$arrow': {
'& $step': {
'&:after': {},
'&:before': {},
'& $step:not(:last-child)': {
'&$widthDescription': {
'&:after': {
top: 0,
width: 30,
height: 72,
borderLeftWidth: 30,
borderTopWidth: 36,
borderBottomWidth: 36,
},
'&:before': {
borderLeftWidth: 30,
borderTopWidth: 36,
borderBottomWidth: 36,
},
'&[dir=ltr]:after': { right: -30 },
'&[dir=rtl]:after': { left: -30 },
},
'&[dir=rtl]:after': {
left: -20,
right: 'auto',
},
'&[dir=rtl]:before': {
right: 0,
},
'&:after': {
top: 0,
width: 20,
height: 48,
borderLeftWidth: 20,
borderTopWidth: 24,
borderBottomWidth: 24,
right: -20,
},
'&:before': {
top: 0,
width: 20,
height: 48,
borderLeftWidth: 20,
borderTopWidth: 24,
borderBottomWidth: 24,
right: -20,
},
},
'& $step:last-child': {
'&$widthDescription': {
'&:before': {
borderLeftWidth: 30,
borderTopWidth: 36,
borderBottomWidth: 36,
},
},
'&:before': {
borderLeftWidth: 20,
borderTopWidth: 24,
borderBottomWidth: 24,
},
},
'& $content': {
padding: `${Token.stepsLargeArrowPaddingY} ${Token.stepsLargeArrowPaddingX}`,
Expand Down
Loading
Loading