Skip to content

Commit c7ac80d

Browse files
authored
Merge pull request #1691 from DevCloudFE/dev
update main from dev
2 parents 02a3e1c + f0b5361 commit c7ac80d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+182
-143
lines changed

.eslintrc.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,12 @@ module.exports = {
109109
'max-depth': 'off',
110110
'@typescript-eslint/member-ordering': 'off',
111111
'array-callback-return': 'off',
112+
'import/no-unresolved': 'off',
112113
},
113-
"overrides": [
114+
overrides: [
114115
{
115-
"files": [
116-
"*.ts",
117-
"*.tsx"
118-
],
119-
"parser": "@typescript-eslint/parser"
120-
}
121-
]
116+
files: ['*.ts', '*.tsx'],
117+
parser: '@typescript-eslint/parser',
118+
},
119+
],
122120
};

packages/devui-vue/devui/checkbox/__tests__/checkbox-button.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mount } from '@vue/test-utils';
22
import { ref, nextTick } from 'vue';
33
import DCheckboxButton from '../src/checkbox-button';
4-
import { useNamespace } from '../../shared/hooks/use-namespace';
4+
import { useNamespace } from '@devui/shared/utils';
55

66
const ns = useNamespace('checkbox-button', true);
77
const baseClass = ns.b();

packages/devui-vue/devui/checkbox/__tests__/checkbox-group.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { reactive, ref, nextTick } from 'vue';
33
import DCheckboxGroup from '../src/checkbox-group';
44
import DCheckbox from '../src/checkbox';
55
import DCheckboxButton from '../src/checkbox-button';
6-
import { useNamespace } from '../../shared/hooks/use-namespace';
6+
import { useNamespace } from '@devui/shared/utils';
77

88
const ns = useNamespace('checkbox', true);
99
const baseClass = ns.b();

packages/devui-vue/devui/checkbox/__tests__/checkbox.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mount } from '@vue/test-utils';
22
import { ref, nextTick } from 'vue';
33
import DCheckbox from '../src/checkbox';
4-
import { useNamespace } from '../../shared/hooks/use-namespace';
4+
import { useNamespace } from '@devui/shared/utils';
55

66
const ns = useNamespace('checkbox', true);
77
const baseClass = ns.b();

packages/devui-vue/devui/checkbox/src/checkbox-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineComponent, SetupContext } from 'vue';
22
import { checkboxProps, CheckboxProps } from './checkbox-types';
3-
import { useNamespace } from '../../shared/hooks/use-namespace';
3+
import { useNamespace } from '@devui/shared/utils';
44
import { useCheckbox, useCheckboxButton } from './use-checkbox';
55
import './checkbox-button.scss';
66

packages/devui-vue/devui/checkbox/src/checkbox-group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineComponent, SetupContext } from 'vue';
22
import { checkboxGroupProps, CheckboxGroupProps } from './checkbox-types';
33
import DCheckbox from './checkbox';
44
import './checkbox-group.scss';
5-
import { useNamespace } from '../../shared/hooks/use-namespace';
5+
import { useNamespace } from '@devui/shared/utils';
66
import { useCheckboxGroup } from './use-checkbox';
77

88
export default defineComponent({

packages/devui-vue/devui/checkbox/src/checkbox-types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const commonProps = {
3636
default: undefined,
3737
},
3838
size: {
39-
type: String as PropType<Size>
39+
type: String as PropType<Size>,
40+
default: 'md'
4041
},
4142
} as const;
4243

@@ -142,8 +143,8 @@ export type UseCheckboxFn = {
142143
mergedIsShowTitle: ComputedRef<boolean | undefined>;
143144
mergedShowAnimation: ComputedRef<boolean>;
144145
mergedColor: ComputedRef<string | undefined>;
145-
itemWidth: number | undefined;
146-
direction: string | undefined;
146+
itemWidth: Ref<number | undefined> | undefined;
147+
direction: Ref<string | undefined> | undefined;
147148
size: ComputedRef<string>;
148149
border: ComputedRef<boolean>;
149150
handleClick: (event: Event) => void;

packages/devui-vue/devui/checkbox/src/checkbox.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineComponent, SetupContext } from 'vue';
1+
import { defineComponent, computed, SetupContext } from 'vue';
22
import { checkboxProps, CheckboxProps } from './checkbox-types';
3-
import { useNamespace } from '../../shared/hooks/use-namespace';
3+
import { useNamespace } from '@devui/shared/utils';
44
import { useCheckbox } from './use-checkbox';
55
import './checkbox.scss';
66

@@ -24,11 +24,11 @@ export default defineComponent({
2424
} = useCheckbox(props, ctx);
2525

2626
return () => {
27-
const wrapperCls = {
28-
[ns.e('column-margin')]: direction === 'column',
29-
[ns.e('wrap')]: typeof itemWidth !== 'undefined',
30-
};
31-
const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
27+
const wrapperCls = computed(() => ({
28+
[ns.e('column-margin')]: direction?.value === 'column',
29+
[ns.e('wrap')]: typeof itemWidth?.value !== 'undefined',
30+
}));
31+
const wrapperStyle = computed(() => (itemWidth?.value ? [`width: ${itemWidth.value}px`] : []));
3232
const checkboxCls = {
3333
[ns.b()]: true,
3434
active: mergedChecked.value,
@@ -66,9 +66,9 @@ export default defineComponent({
6666
};
6767

6868
return (
69-
<div class={wrapperCls} style={wrapperStyle}>
69+
<div class={wrapperCls.value} style={wrapperStyle.value}>
7070
<div class={checkboxCls}>
71-
<label title={labelTitle} onClick={handleClick} class={labelCls} style={{ width: itemWidth ? '100%' : 'auto' }}>
71+
<label title={labelTitle} onClick={handleClick} class={labelCls} style={{ width: itemWidth?.value ? '100%' : 'auto' }}>
7272
<input
7373
name={(props.name || props.value) as string}
7474
class={ns.e('input')}

packages/devui-vue/devui/checkbox/src/use-checkbox.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export function useCheckbox(props: CheckboxProps, ctx: SetupContext): UseCheckbo
3535
const mergedColor = computed(() => {
3636
return checkboxGroupConf?.color.value ?? props.color;
3737
});
38-
const itemWidth = checkboxGroupConf?.itemWidth.value;
39-
const direction = checkboxGroupConf?.direction.value;
38+
const itemWidth = checkboxGroupConf?.itemWidth;
39+
const direction = checkboxGroupConf?.direction;
4040

4141
const canChange = (checked: boolean, val: string | undefined) => {
4242
if (mergedDisabled.value) {
@@ -54,15 +54,14 @@ export function useCheckbox(props: CheckboxProps, ctx: SetupContext): UseCheckbo
5454
return Promise.resolve(true);
5555
};
5656
const toggle = () => {
57-
const current = !isChecked.value;
57+
const current = !mergedChecked.value;
5858
checkboxGroupConf?.toggleGroupVal(props.value);
5959
ctx.emit('update:checked', current);
6060
ctx.emit('update:modelValue', current);
6161
ctx.emit('change', current);
6262
};
63-
const handleClick = ($event: Event) => {
64-
$event.stopPropagation();
65-
canChange(!isChecked.value, props.label).then((res) => res && toggle());
63+
const handleClick = () => {
64+
canChange(!mergedChecked.value, props.label).then((res) => res && toggle());
6665
};
6766

6867
const size = computed(() => props.size || checkboxGroupConf?.size.value || formContext?.size || 'md');
@@ -72,7 +71,7 @@ export function useCheckbox(props: CheckboxProps, ctx: SetupContext): UseCheckbo
7271
watch(
7372
() => props.modelValue,
7473
() => {
75-
formItemContext?.validate('change').catch((err) => console.warn(err));
74+
formItemContext?.validate('change').catch(() => {});
7675
}
7776
);
7877
return {
@@ -138,7 +137,7 @@ export function useCheckboxGroup(props: CheckboxGroupProps, ctx: SetupContext):
138137
watch(
139138
() => props.modelValue,
140139
() => {
141-
formItemContext?.validate('change').catch((err) => console.warn(err));
140+
formItemContext?.validate('change').catch(() => {});
142141
},
143142
{ deep: true }
144143
);

packages/devui-vue/devui/editor-md/src/composables/use-editor-md.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ export function useEditorMd(props: EditorMdProps, ctx: SetupContext) {
259259

260260
if (imageUploadToServer.value) {
261261
const callback = ({ name, imgUrl, title }: any) => {
262-
editorRef.value.focus();
263-
editorRef.value.replaceSelection(`![${name}](${imgUrl} '${title}')`);
262+
editorIns.focus();
263+
editorIns.replaceSelection(`![${name}](${imgUrl} '${title}')`);
264264
};
265265
ctx.emit('imageUpload', { file, callback });
266266
}
@@ -286,16 +286,20 @@ export function useEditorMd(props: EditorMdProps, ctx: SetupContext) {
286286
}
287287
});
288288

289-
watch(imageUploadToServer, (val: boolean) => {
290-
if (toolbars['image'].params) {
291-
toolbars['image'].params.imageUploadToServer = val;
292-
}
293-
if (toolbars['image'].params && !toolbars['image'].params.imageUpload) {
294-
toolbars['image'].params.imageUpload = (data: any) => {
295-
ctx.emit('imageUpload', data);
289+
watch(
290+
imageUploadToServer,
291+
(val: boolean) => {
292+
if (toolbars['image'].params) {
293+
toolbars['image'].params.imageUploadToServer = val;
296294
}
297-
}
298-
}, { immediate: true });
295+
if (toolbars['image'].params && !toolbars['image'].params.imageUpload) {
296+
toolbars['image'].params.imageUpload = (data: any) => {
297+
ctx.emit('imageUpload', data);
298+
};
299+
}
300+
},
301+
{ immediate: true }
302+
);
299303

300304
watch(hidePreviewView, () => {
301305
refreshEditorCursor();

0 commit comments

Comments
 (0)