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

feat(Select): valueDisplay and collapsibleItems params expanded options #4788

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions src/select-input/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ export interface SelectInputCommonProperties {
onMouseenter?: TdSelectInputProps['onMouseenter'];
onMouseleave?: TdSelectInputProps['onMouseleave'];
}

export interface SelectInputProps extends TdSelectInputProps {
/**
* 不对外暴露,参数穿透options, 给SelectInput/SelectInput 自定义选中项呈现的内容和多选状态下设置折叠项内容
*/
options: any[];
}
11 changes: 9 additions & 2 deletions src/select-input/select-input.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { computed, defineComponent, onBeforeUnmount, onMounted, PropType, ref, SetupContext, toRefs, watch } from 'vue';
import Popup, { PopupInstanceFunctions, PopupProps, PopupVisibleChangeContext } from '../popup';
import props from './props';
import { TdSelectInputProps } from './type';
import type { TdSelectInputProps } from './type';
import useSingle, { SelectInputValueDisplayOptions } from './useSingle';
import useMultiple from './useMultiple';
import useOverlayInnerStyle from './useOverlayInnerStyle';
import { usePrefixClass } from '../hooks/useConfig';
import { useTNodeJSX } from '../hooks';
import type { SelectInputProps } from './interface';

const useComponentClassName = () => {
return {
Expand All @@ -32,9 +33,15 @@ export default defineComponent({
valueDisplayOptions: {
type: Object as PropType<SelectInputValueDisplayOptions>,
},
/**
* 不对外暴露,参数穿透options, 给SelectInput/SelectInput 自定义选中项呈现的内容和多选状态下设置折叠项内容
*/
options: {
type: Array as PropType<any[]>,
},
},

setup(props: TdSelectInputProps & { valueDisplayOptions: SelectInputValueDisplayOptions }, context: SetupContext) {
setup(props: SelectInputProps & { valueDisplayOptions: SelectInputValueDisplayOptions }, context: SetupContext) {
const { NAME_CLASS, BASE_CLASS_BORDERLESS, BASE_CLASS_MULTIPLE, BASE_CLASS_POPUP_VISIBLE, BASE_CLASS_EMPTY } =
useComponentClassName();
const classPrefix = usePrefixClass();
Expand Down
7 changes: 4 additions & 3 deletions src/select-input/useMultiple.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SetupContext, computed, ref, toRefs, Ref } from 'vue';
import isObject from 'lodash/isObject';
import { TdSelectInputProps, SelectInputChangeContext, SelectInputKeys } from './type';
import { SelectInputCommonProperties } from './interface';
import type { SelectInputChangeContext, SelectInputKeys } from './type';
import type { SelectInputCommonProperties, SelectInputProps } from './interface';
import TagInput, { TagInputValue, TagInputProps } from '../tag-input';
import Loading from '../loading';
import useDefault from '../hooks/useDefaultValue';
Expand All @@ -24,7 +24,7 @@ const DEFAULT_KEYS = {
};

export default function useMultiple(
props: TdSelectInputProps,
props: SelectInputProps,
context: SetupContext,
popupRef: Ref<PopupInstanceFunctions>,
) {
Expand Down Expand Up @@ -101,6 +101,7 @@ export default function useMultiple(
collapsedItems: props.collapsedItems,
tag: props.tag,
value: tags.value,
options: props.options,
valueDisplay: props.valueDisplay,
inputValue: p.popupVisible && p.allowInput ? tInputValue.value : '',
inputProps: {
Expand Down
289 changes: 289 additions & 0 deletions src/select/__tests__/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,71 @@ exports[`Select > :props > :clearable 1`] = `
</div>
`;

exports[`Select > :props > :collapsedItems 1`] = `
<div
class="t-select__wrap"
>
<div
class="t-select-input t-select-input--multiple t-select-input--empty t-select"
>

<div
class="t-input__wrap t-tag-input t-tag-input--break-line t-is-empty t-tag-input__with-suffix-icon"
>
<div
class="t-input t-is-readonly t-input--prefix t-input--suffix"
>
<!---->
<div
class="t-input__prefix"
>


</div>
<input
class="t-input__inner"
placeholder="请选择"
readonly=""
spellcheck="false"
type="text"
unselectable="on"
/>
<span
class="t-input__input-pre"
>
请选择
</span>
<!---->
<!---->
<span
class="t-input__suffix t-input__suffix-icon"
>
<svg
class="t-fake-arrow t-select__right-icon"
fill="none"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921"
stroke="black"
stroke-opacity="0.9"
stroke-width="1.3"
/>
</svg>
</span>
</div>
<!---->
</div>
<!---->

<!---->
</div>
</div>
`;

exports[`Select > :props > :creatable 1`] = `
<div
class="t-select__wrap"
Expand Down Expand Up @@ -638,6 +703,230 @@ exports[`Select > :props > :size 1`] = `
</div>
`;

exports[`Select > Select Option > :props > :disabled 1`] = `
<div
class="t-select__wrap"
>
<div
class="t-select-input t-select"
>

<div
class="t-input__wrap"
>
<div
class="t-input t-is-readonly t-input--suffix"
>
<!---->
<!---->
<input
class="t-input__inner"
placeholder="请选择"
readonly=""
spellcheck="false"
type="text"
unselectable="on"
/>
<!---->
<!---->
<!---->
<span
class="t-input__suffix t-input__suffix-icon"
>
<svg
class="t-fake-arrow t-select__right-icon"
fill="none"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921"
stroke="black"
stroke-opacity="0.9"
stroke-width="1.3"
/>
</svg>
</span>
</div>
<!---->
</div>
<!---->

<!---->
</div>
</div>
`;

exports[`Select > Select Option > :props > :label 1`] = `
<div
class="t-select__wrap"
>
<div
class="t-select-input t-select"
>

<div
class="t-input__wrap"
>
<div
class="t-input t-is-readonly t-input--suffix"
>
<!---->
<!---->
<input
class="t-input__inner"
placeholder="请选择"
readonly=""
spellcheck="false"
type="text"
unselectable="on"
/>
<!---->
<!---->
<!---->
<span
class="t-input__suffix t-input__suffix-icon"
>
<svg
class="t-fake-arrow t-select__right-icon"
fill="none"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921"
stroke="black"
stroke-opacity="0.9"
stroke-width="1.3"
/>
</svg>
</span>
</div>
<!---->
</div>
<!---->

<!---->
</div>
</div>
`;

exports[`Select > Select Option > :props > :value 1`] = `
<div
class="t-select__wrap"
>
<div
class="t-select-input t-select"
>

<div
class="t-input__wrap"
>
<div
class="t-input t-is-readonly t-input--suffix"
>
<!---->
<!---->
<input
class="t-input__inner"
placeholder="请选择"
readonly=""
spellcheck="false"
type="text"
unselectable="on"
/>
<!---->
<!---->
<!---->
<span
class="t-input__suffix t-input__suffix-icon"
>
<svg
class="t-fake-arrow t-select__right-icon"
fill="none"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921"
stroke="black"
stroke-opacity="0.9"
stroke-width="1.3"
/>
</svg>
</span>
</div>
<!---->
</div>
<!---->

<!---->
</div>
</div>
`;

exports[`Select > Select OptionGroup > :props > :value 1`] = `
<div
class="t-select__wrap"
>
<div
class="t-select-input t-select"
>

<div
class="t-input__wrap"
>
<div
class="t-input t-is-readonly t-input--suffix"
>
<!---->
<!---->
<input
class="t-input__inner"
placeholder="请选择"
readonly=""
spellcheck="false"
type="text"
unselectable="on"
/>
<!---->
<!---->
<!---->
<span
class="t-input__suffix t-input__suffix-icon"
>
<svg
class="t-fake-arrow t-select__right-icon"
fill="none"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3.75 5.7998L7.99274 10.0425L12.2361 5.79921"
stroke="black"
stroke-opacity="0.9"
stroke-width="1.3"
/>
</svg>
</span>
</div>
<!---->
</div>
<!---->

<!---->
</div>
</div>
`;

exports[`Select Option > :props > :disabled 1`] = `
<div
class="t-select__wrap"
Expand Down
Loading