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

Xingyan/fix form #1840

Merged
merged 22 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8c98e3b
fix(Radio): 优化单选组中,单个radio的默认高度 (#1818) (#1819)
xingyan95 Apr 1, 2024
6959a4d
fix: merge dev
CoderTongxin Apr 9, 2024
5451f5c
fix(Tooltip): 修改构建报错 (#1821) (#1822)
xingyan95 Apr 9, 2024
8afdb42
fix(EditorMd): 解决页面上有md编辑器时,刷新页面,页面自动滚动到某个位置的问题 (#1825)
xingyan95 Apr 11, 2024
f154140
Merge branch dev into main
xingyan95 Apr 13, 2024
d28f856
Merge branch 'dev'
CoderTongxin Apr 16, 2024
78fa38c
feat(Card): 优化显示结构 (#1832) (#1833)
xingyan95 Apr 18, 2024
59be978
Merge branch 'dev' of github.com:DevCloudFE/vue-devui into dev
CoderTongxin Apr 18, 2024
bdbc24d
Merge branch 'dev' of github.com:DevCloudFE/vue-devui into dev
CoderTongxin Apr 18, 2024
06ff164
feat(Dropdown): 优化展开方向识别逻辑 (#1835) (#1836)
xingyan95 Apr 19, 2024
36c6fde
Merge branch 'dev' of github.com:DevCloudFE/vue-devui into dev
CoderTongxin Apr 22, 2024
251cb2b
Merge branch 'dev' of github.com:DevCloudFE/vue-devui into dev
CoderTongxin Apr 22, 2024
f1dd00d
Merge branch dev
CoderTongxin Apr 22, 2024
23b9656
fix(EditableSelect): 修复选项清空时不生效的问题 (#1838) (#1839)
xingyan95 Apr 28, 2024
804ae00
feat(Popover): 手动控制的时候,鼠标从内容区移出后不应该隐藏
CoderTongxin Apr 28, 2024
9aa5edc
fix(CateGorySearch): 修复某些选项没有冒号的问题
CoderTongxin Apr 28, 2024
c1a9e7e
feat: 弹出类组件默认支持四个方向展开
CoderTongxin Apr 29, 2024
c4cf9b7
feat: 弹出类组件默认支持四个方向展开
CoderTongxin Apr 29, 2024
b5df719
feat(Form): 支持设置必填星号的位置
CoderTongxin Apr 29, 2024
17e6421
feat: 修改版本号
CoderTongxin Apr 29, 2024
949ba80
Merge branch 'dev' of github.com:DevCloudFE/vue-devui into dev
CoderTongxin Apr 29, 2024
c88f6c7
Merge branch 'dev' into xingyan/fix-form
CoderTongxin Apr 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const autoCompleteProps = {
},
position: {
type: Array as PropType<Array<Placement>>,
default: ['bottom-end'],
default: () => ['bottom', 'top', 'left', 'right'],
},
disabled: {
type: Boolean,
Expand Down
2 changes: 0 additions & 2 deletions packages/devui-vue/devui/auto-complete/src/auto-complete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default defineComponent({
const inputNs = useNamespace('auto-complete-input');
const isDisabled = computed(() => formContext?.disabled || disabled.value);
const autoCompleteSize = computed(() => formContext?.size || props.size);
const align = computed(() => (position.value.some((item) => item.includes('start') || item.includes('end')) ? 'start' : null));

const { handleSearch, searchList, showNoResultItemTemplate, recentlyFocus } = useSearchFn(
ctx,
Expand Down Expand Up @@ -126,7 +125,6 @@ export default defineComponent({
<FlexibleOverlay
origin={origin.value}
position={position.value}
align={align.value}
v-model={visible.value}
onPositionChange={handlePositionChange}
style={overlayStyles.value}>
Expand Down
1 change: 0 additions & 1 deletion packages/devui-vue/devui/cascader/src/cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export default defineComponent({
ref={overlayRef}
v-model={menuShow.value}
position={position.value as Placement[]}
align="start"
style={styles.value}
onPositionChange={handlePositionChange}>
<div class={ns.e('drop-menu-animation')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineComponent({
rootCtx.slots[`${item.value.field}Tag`]!({ tag: item.value })
) : isJoinLabelType.value ? (
<>
<span>{item.value.label}</span>
<span>{item.value.label}: </span>
<span class='dp-category-search-multi-tag' style={{ maxWidth: tagMaxWidth?.value + 'px' }}>
{Array.isArray(item.value.value?.cache) &&
item.value.value?.cache?.map((tag: any, index: number) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ export default defineComponent({
transformOrigin: currentPosition.value === 'top' ? '0% 100%' : '0% 0%',
'z-index': 'var(--devui-z-index-dropdown, 1052)',
}));
const align = computed(() => {
if (position.value.some((item: string) => item.includes('start'))) {
return 'start';
}
if (position.value.some((item: string) => item.includes('end'))) {
return 'end';
}
return undefined;
});

return () => {
const vSlots = {
Expand Down Expand Up @@ -149,7 +140,6 @@ export default defineComponent({
v-model={isPanelShow.value}
ref={overlayRef}
origin={originRef.value}
align={align.value}
position={position.value}
style={styles.value}
onPositionChange={handlePositionChange}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const datePickerProCommonProps = {
},
position: {
type: Array as PropType<Placement[]>,
default: () => ['bottom-start', 'top-start'],
default: () => ['bottom-start', 'top-start', 'left-start', 'right-start'],
},
};

Expand Down
10 changes: 0 additions & 10 deletions packages/devui-vue/devui/date-picker-pro/src/date-picker-pro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ export default defineComponent({
transformOrigin: currentPosition.value === 'top' ? '0% 100%' : '0% 0%',
'z-index': 'var(--devui-z-index-dropdown, 1052)',
}));
const align = computed(() => {
if (position.value.some((item: string) => item.includes('start'))) {
return 'start';
}
if (position.value.some((item: string) => item.includes('end'))) {
return 'end';
}
return undefined;
});

return () => {
const vSlots = {
Expand Down Expand Up @@ -98,7 +89,6 @@ export default defineComponent({
v-model={isPanelShow.value}
ref={overlayRef}
origin={originRef.value}
align={align.value}
position={position.value}
style={styles.value}
onPositionChange={handlePositionChange}>
Expand Down
7 changes: 1 addition & 6 deletions packages/devui-vue/devui/dropdown/src/dropdown-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type Placement =
| 'bottom-end'
| 'left-start'
| 'left-end';
export type Alignment = 'start' | 'end';
export type OffsetOptions = { mainAxis?: number; crossAxis?: number };

export type EmitEvent = (event: 'toggle', result: boolean) => void;
Expand All @@ -35,11 +34,7 @@ export const dropdownProps = {
},
position: {
type: Array as PropType<Array<Placement>>,
default: ['bottom'],
},
align: {
type: String as PropType<Alignment> | null,
default: null,
default: () => ['bottom', 'top', 'left', 'right'],
},
offset: {
type: [Number, Object] as PropType<number | OffsetOptions>,
Expand Down
3 changes: 1 addition & 2 deletions packages/devui-vue/devui/dropdown/src/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineComponent({
props: dropdownProps,
emits: ['toggle'],
setup(props: DropdownProps, { slots, attrs, emit, expose }) {
const { visible, position, align, offset, destroyOnHide, shiftOffset, showAnimation, teleport } = toRefs(props);
const { visible, position, offset, destroyOnHide, shiftOffset, showAnimation, teleport } = toRefs(props);
const origin = ref<HTMLElement | undefined>();
const dropdownRef = ref<HTMLElement | undefined>();
const overlayRef = ref();
Expand Down Expand Up @@ -59,7 +59,6 @@ export default defineComponent({
ref={overlayRef}
origin={origin.value}
position={position.value}
align={align.value}
offset={offset.value}
shiftOffset={shiftOffset?.value}
onPositionChange={handlePositionChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const editableSelectProps = {
},
position: {
type: Array as PropType<Placement[]>,
default: ['bottom'],
default: () => ['bottom', 'top', 'left', 'right'],
},
options: {
type: Array as PropType<Options>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default defineComponent({
const states = useSelectStates();
// data refs
const { appendToBody, disabled, modelValue, position, placeholder, maxLength } = toRefs(props);
const align = computed(() => (position.value.some((item) => item.includes('start') || item.includes('end')) ? 'start' : null));

// input事件
const { onInput, onMouseenter, onMouseleave, setSoftFocus, handleBlur, handleFocus, handleClear } = useInputEvent(
Expand Down Expand Up @@ -101,7 +100,6 @@ export default defineComponent({
v-model={states.visible}
origin={originRef.value}
position={position.value}
align={align.value}
style={styles.value}
onPositionChange={handlePositionChange}>
<Dropdown options={filteredOptions.value} width={props.width} maxHeight={props.maxHeight} v-slots={ctx.slots}></Dropdown>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RuleItem, ValidateFieldsError } from 'async-validator';
import type { ComputedRef, ExtractPropTypes, PropType, InjectionKey, Ref, SetupContext } from 'vue';
import { LabelAlign, LabelSize, Layout } from '../../form-types';
import type { ComputedRef, ExtractPropTypes, PropType, Ref, SetupContext } from 'vue';
import { LabelAlign, LabelSize, Layout, RequirePosition } from '../../form-types';
import { FeedbackStatus } from '../form-control/form-control-types';

export type FormItemValidateState = '' | 'error' | 'pending' | 'success';
Expand Down Expand Up @@ -81,6 +81,7 @@ export type LabelData = ComputedRef<{
layout: Layout;
labelSize: LabelSize;
labelAlign: LabelAlign;
requiredPosition: RequirePosition;
helpTips: string | HelpTips;
formItemCtx: SetupContext;
}>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default defineComponent({
layout: formContext.layout,
labelSize: formContext.labelSize,
labelAlign: formContext.labelAlign,
requiredPosition: formContext.requirePosition,
helpTips: helpTips.value,
formItemCtx: ctx,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@
margin-right: 8px;
margin-left: -12px;
}
}

.#{$devui-prefix}-form__label--required-right {
&::after {
content: '*';
color: red;
display: inline-block;
margin-left: 8px;
}
}

&-hide {
&::before {
display: none;
}
.#{$devui-prefix}-form__label--required-hide {
&::before,
&::after {
display: none;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export function useFormLabel() {

const labelInnerClasses = computed(() => ({
[`${ns.e('label-span')}`]: true,
[`${ns.em('label', 'required')}`]: formItemContext.isRequired,
[`${ns.em('label', 'required')}`]: formItemContext.isRequired && labelData.value.requiredPosition === 'left',
[`${ns.em('label', 'required-right')}`]: formItemContext.isRequired && labelData.value.requiredPosition === 'right',
[`${ns.em('label', 'required-hide')}`]: formItemContext.isRequired && formContext.hideRequiredMark,
}));

Expand Down
5 changes: 5 additions & 0 deletions packages/devui-vue/devui/form/src/form-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type LabelAlign = 'start' | 'center' | 'end';
export type FormData = Record<string, unknown>;
export type StyleType = 'default' | 'gray';
export type AppendToBodyScrollStrategy = 'close' | 'reposition';
export type RequirePosition = 'left' | 'right';

export type FormRules = Partial<Record<string, Array<FormRuleItem>>>;
export interface ValidateFailure {
Expand Down Expand Up @@ -78,6 +79,10 @@ export const formProps = {
type: String as PropType<AppendToBodyScrollStrategy>,
default: 'reposition',
},
requirePosition: {
type: String as PropType<RequirePosition>,
default: 'left',
},
} as const;

export interface UseFieldCollection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const paginationProps = {
},
pageSizeDirection: {
type: Array as PropType<Array<PageSizeDirection>>,
default: () => ['bottom', 'top'],
default: () => ['bottom', 'top', 'left', 'bottom'],
},
pageIndex: {
type: Number,
Expand Down
7 changes: 1 addition & 6 deletions packages/devui-vue/devui/popover/src/popover-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type Placement =
| 'bottom-end'
| 'left-start'
| 'left-end';
export type Alignment = 'start' | 'end';
export type OffsetOptions = { mainAxis?: number; crossAxis?: number };

export const popoverProps = {
Expand All @@ -25,11 +24,7 @@ export const popoverProps = {
},
position: {
type: Array as PropType<Array<Placement>>,
default: ['bottom'],
},
align: {
type: String as PropType<Alignment> | null,
default: null,
default: () => ['top', 'right', 'bottom', 'left'],
},
offset: {
type: [Number, Object] as PropType<number | OffsetOptions>,
Expand Down
3 changes: 1 addition & 2 deletions packages/devui-vue/devui/popover/src/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineComponent({
props: popoverProps,
emits: ['show', 'hide'],
setup(props: PopoverProps, { slots, attrs, emit }) {
const { content, popType, position, align, offset, showAnimation } = toRefs(props);
const { content, popType, position, offset, showAnimation } = toRefs(props);
const origin = ref<HTMLElement>();
const popoverRef = ref<HTMLElement>();
const visible = ref(false);
Expand All @@ -40,7 +40,6 @@ export default defineComponent({
ref={popoverRef}
origin={origin.value}
position={position.value}
align={align.value}
offset={offset.value}
class={[ns.e('content'), popType.value !== 'default' ? 'is-icon' : '']}
show-arrow
Expand Down
5 changes: 3 additions & 2 deletions packages/devui-vue/devui/popover/src/use-popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function usePopover(
export function usePopoverEvent(props: PopoverProps, visible: Ref<boolean>, origin: Ref): UsePopoverEvent {
const { trigger, position, mouseEnterDelay, mouseLeaveDelay, disabled } = toRefs(props);
const isClick: ComputedRef<boolean> = computed(() => trigger.value === 'click');
const isHover: ComputedRef<boolean> = computed(() => trigger.value === 'hover');
const placement: Ref<string> = ref(position.value[0].split('-')[0]);
const isEnter: Ref<boolean> = ref(false);

Expand All @@ -69,13 +70,13 @@ export function usePopoverEvent(props: PopoverProps, visible: Ref<boolean>, orig
if (disabled.value) {
return;
}
if (!isClick.value) {
if (isHover.value) {
isEnter.value = true;
enter();
}
};
const onMouseleave = () => {
if (!isClick.value) {
if (isHover.value) {
isEnter.value = false;
leave();
}
Expand Down
17 changes: 17 additions & 0 deletions packages/devui-vue/devui/select/src/select-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ export type Options = Array<OptionItem>;
export type ModelValue = number | string | Array<number | string>;
export type filterValue = boolean | ((query: string) => void);
export type SelectSize = 'sm' | 'md' | 'lg';
export type Placement =
| 'top'
| 'right'
| 'bottom'
| 'left'
| 'top-start'
| 'top-end'
| 'right-start'
| 'right-end'
| 'bottom-start'
| 'bottom-end'
| 'left-start'
| 'left-end';
export const selectProps = {
modelValue: {
type: [String, Number, Array] as PropType<ModelValue>,
Expand All @@ -26,6 +39,10 @@ export const selectProps = {
type: Array as PropType<Options>,
default: () => [],
},
position: {
type: Array as PropType<Placement[]>,
default: () => ['bottom', 'top', 'left', 'right'],
},
size: {
type: String as PropType<SelectSize>,
default: '',
Expand Down
6 changes: 2 additions & 4 deletions packages/devui-vue/devui/select/src/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import SelectContent from './components/select-content';
import useSelectFunction from './composables/use-select-function';
import './select.scss';
import { createI18nTranslate } from '../../locale/create';
import { FlexibleOverlay, Placement } from '../../overlay';
import { FlexibleOverlay } from '../../overlay';
import LoadingDirective from '../../loading/src/loading-directive';

export default defineComponent({
Expand Down Expand Up @@ -77,7 +77,6 @@ export default defineComponent({
ctx.expose({ focus, blur, toggleChange });
const isRender = ref<boolean>(false);
const currentPosition = ref('bottom');
const position = ref<Placement[]>(['bottom-start', 'top-start']);

const handlePositionChange = (pos: string) => {
currentPosition.value = pos.split('-')[0] === 'top' ? 'top' : 'bottom';
Expand Down Expand Up @@ -141,10 +140,9 @@ export default defineComponent({
v-model={isRender.value}
ref={dropdownRef}
origin={originRef.value}
align="start"
offset={4}
fit-origin-width
position={position.value}
position={props.position}
onPositionChange={handlePositionChange}
style={styles.value}
class={props.menuClass}>
Expand Down
Loading
Loading