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: 修复一些issue #910

Merged
merged 13 commits into from
May 31, 2022
2 changes: 1 addition & 1 deletion src/anchor/anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default defineComponent({
{renderCursor()}
</div>
</div>
{slots.default && slots.default(null)}
{renderTNodeJSX('default')}
</div>
);

Expand Down
3 changes: 2 additions & 1 deletion src/cascader/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const useCascaderContext = (props: TdCascaderProps) => {
watch(
() => props.options,
() => {
const { options, keys = {} } = props;
const { options, keys = {}, checkStrictly } = props;
const { treeStore } = statusContext;

if (!options.length && !treeStore) return;
Expand All @@ -131,6 +131,7 @@ export const useCascaderContext = (props: TdCascaderProps) => {
checkable: true,
expandMutex: true,
expandParent: true,
checkStrictly,
onLoad: () => {
nextTick(() => {
treeStore.refreshNodes();
Expand Down
6 changes: 4 additions & 2 deletions src/checkbox/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import { CheckboxGroupInjectionKey } from './constants';
// hooks
import useVModel from '../hooks/useVModel';
import { usePrefixClass } from '../hooks/useConfig';
import { useTNodeJSX } from '../hooks/tnode';

export default defineComponent({
name: 'TCheckboxGroup',
props,

setup(props, { slots }) {
setup(props) {
/** 样式 */
const COMPONENT_NAME = usePrefixClass('checkbox-group');
const renderTNodeJSX = useTNodeJSX();

const { isArray } = Array;
const { value, modelValue } = toRefs(props);
Expand Down Expand Up @@ -163,7 +165,7 @@ export default defineComponent({
</Checkbox>
));
} else {
const nodes = slots.default && slots.default(null);
const nodes = renderTNodeJSX('default');
optionList.value = getOptionListBySlots(nodes);
children = nodes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dropdown/dropdown-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default defineComponent({
if (!props.hasChildren && !props.disabled) {
const data = {
value: props.value,
path: props.path,
path: props.path || `/${props.value}`,
content: props.content,
};
props.onClick?.(data, { e });
Expand Down
6 changes: 3 additions & 3 deletions src/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineComponent({
name: 'TDropdown',
props,
setup(props: TdDropdownProps, { attrs, slots }) {
const renderTNode = useTNodeJSX();
const renderTNodeJSX = useTNodeJSX();
const COMPONENT_NAME = usePrefixClass('dropdown');
const popupElem = ref(null);

Expand All @@ -34,9 +34,9 @@ export default defineComponent({
);

return () => {
const trigger = slots.default ? slots.default(null) : '';
const trigger = renderTNodeJSX('default');

const contentSlot = renderTNode('dropdown');
const contentSlot = renderTNodeJSX('dropdown');

const popupProps = {
...attrs,
Expand Down
2 changes: 1 addition & 1 deletion src/form/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default defineComponent({
e?.stopPropagation();
}
children.value.filter((child: any) => isFunction(child.resetField)).forEach((child: any) => child.resetField());
props.onReset({ e });
props.onReset?.({ e });
};
const clearValidate = (fields?: Array<string>) => {
children.value.forEach((child) => {
Expand Down
4 changes: 2 additions & 2 deletions src/input-number/useComponentComputed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function useComponentComputed(COMPONENT_NAME: Ref<string>, props:
const handleStartInput = () => {
inputting.value = true;
if (innerValue.value === undefined) return;
filterValue.value = innerValue.value.toFixed(digitsNum.value);
filterValue.value = Number(innerValue.value).toFixed(digitsNum.value);
};

const handleEndInput = (e: FocusEvent) => {
Expand Down Expand Up @@ -117,7 +117,7 @@ export default function useComponentComputed(COMPONENT_NAME: Ref<string>, props:
// end input
return props.format && !inputting.value
? props.format(innerValue.value)
: innerValue.value.toFixed(digitsNum.value);
: Number(innerValue.value).toFixed(digitsNum.value);
});

watch(
Expand Down
5 changes: 5 additions & 0 deletions src/input-number/useInputNumberTools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Ref } from 'vue';
import isNumber from 'lodash/isNumber';
import { TdInputNumberProps } from './type';

export default function useInputNumberTools(props: TdInputNumberProps, digitsNum: Ref<number>, isError: Ref<boolean>) {
Expand Down Expand Up @@ -38,6 +39,10 @@ export default function useInputNumberTools(props: TdInputNumberProps, digitsNum
handleInputError(true);
return false;
}
if (!isNumber(v)) {
handleInputError(true);
return false;
}
handleInputError(false);
return true;
};
Expand Down
2 changes: 1 addition & 1 deletion src/radio/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default defineComponent({
const radioGroupName = usePrefixClass('radio-group');
const renderSlot = useTNodeDefault();
const renderBlock = (): VNode => {
if (props.variant.includes('filled'))
if (props.variant.includes('filled') && innerValue.value)
return <div style={barStyle.value} class={`${radioGroupName.value}__bg-block`} />;
};
const renderOptions = (): VNode[] => {
Expand Down
26 changes: 17 additions & 9 deletions src/steps/steps.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { computed, defineComponent, provide, reactive, ref, toRefs, VNode, watchEffect } from 'vue';
import isObject from 'lodash/isObject';
import props from './props';
import stepItemProps from './step-item-props';
import { TdStepItemProps } from './type';

import { usePrefixClass } from '../hooks/useConfig';
Expand Down Expand Up @@ -69,7 +71,15 @@ export default defineComponent({
const arr: Array<TdStepItemProps> = [];
nodes?.forEach((node) => {
const option = node?.props;
if (!option) return;
const children = node?.children;
if (!option && !children) return;
if (children && isObject(children)) {
for (const key in children) {
if (key in stepItemProps && !option[key]) {
option[key] = children[key];
}
}
}
props.sequence === 'reverse' ? arr.unshift(option as TdStepItemProps) : arr.push(option as TdStepItemProps);
});
return arr;
Expand Down Expand Up @@ -99,14 +109,12 @@ export default defineComponent({

if (nodes && nodes[index]) {
const vnode = nodes[index];
if (vnode.props) {
vnode.props = {
...item,
index: stepIndex,
status: handleStatus(item, index),
};
return vnode;
}
vnode.props = {
...item,
index: stepIndex,
status: handleStatus(item, index),
};
return vnode;
}
return stepItem;
});
Expand Down
5 changes: 1 addition & 4 deletions test/unit/radio/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,6 @@ exports[`Radio RadioGroup > :props > :variant 1`] = `
</span>
</label>

<div
class="t-radio-group__bg-block"
style="width: 0px; left: 0px;"
/>
<!---->
</div>
`;