code:
import type { IOptionV2Props, ISelectV2Props } from './defaults';
import type { InjectionKey, Ref } from 'vue';
import type { Option } from './select.types';
import type { TooltipInstance } from 'element-plus/es/components/tooltip';
export interface SelectV2Context {
    props: ISelectV2Props;
    expanded: Ref<boolean>;
    tooltipRef: Ref<TooltipInstance | undefined>;
    onSelect: (option: Option) => void;
    onHover: (idx?: number) => void;
    onKeyboardNavigate: (direction: 'forward' | 'backward') => void;
    onKeyboardSelect: () => void;
}
export declare const selectV2InjectionKey: InjectionKey<SelectV2Context>;
export type { ISelectV2Props, IOptionV2Props };

license: mit


code:
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const selectV2InjectionKey = Symbol("ElSelectV2Injection");

exports.selectV2InjectionKey = selectV2InjectionKey;
//# sourceMappingURL=token.js.map


sourcesContent:
import type { IOptionV2Props, ISelectV2Props } from './defaults'
import type { InjectionKey, Ref } from 'vue'
import type { Option } from './select.types'
import type { TooltipInstance } from '@element-plus/components/tooltip'

export interface SelectV2Context {
  props: ISelectV2Props
  expanded: Ref<boolean>
  tooltipRef: Ref<TooltipInstance | undefined>
  onSelect: (option: Option) => void
  onHover: (idx?: number) => void
  onKeyboardNavigate: (direction: 'forward' | 'backward') => void
  onKeyboardSelect: () => void
}

export const selectV2InjectionKey: InjectionKey<SelectV2Context> = Symbol(
  'ElSelectV2Injection'
)
export type { ISelectV2Props, IOptionV2Props }


code:
import type { ISelectV2Props } from './token';
import type { Option, SelectStates } from './select.types';
export declare function useAllowCreate(props: ISelectV2Props, states: SelectStates): {
    createNewOption: (query: string) => void;
    removeNewOption: (option: Option) => void;
    selectNewOption: (option: Option) => void;
    clearAllNewOption: () => void;
};


code:
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var useProps = require('./useProps.js');

function useAllowCreate(props, states) {
  const { aliasProps, getLabel, getValue } = useProps.useProps(props);
  const createOptionCount = vue.ref(0);
  const cachedSelectedOption = vue.ref();
  const enableAllowCreateMode = vue.computed(() => {
    return props.allowCreate && props.filterable;
  });
  function hasExistingOption(query) {
    const hasOption = (option) => getLabel(option) === query;
    return props.options && props.options.some(hasOption) || states.createdOptions.some(hasOption);
  }
  function selectNewOption(option) {
    if (!enableAllowCreateMode.value) {
      return;
    }
    if (props.multiple && option.created) {
      createOptionCount.value++;
    } else {
      cachedSelectedOption.value = option;
    }
  }
  function createNewOption(query) {
    if (enableAllowCreateMode.value) {
      if (query && query.length > 0) {
        if (hasExistingOption(query)) {
          return;
        }
        const newOption = {
          [aliasProps.value.value]: query,
          [aliasProps.value.label]: query,
          created: true,
          [aliasProps.value.disabled]: false
        };
        if (states.createdOptions.length >= createOptionCount.value) {
          states.createdOptions[createOptionCount.value] = newOption;
        } else {
          states.createdOptions.push(newOption);
        }
      } else {
        if (props.multiple) {
          states.createdOptions.length = createOptionCount.value;
        } else {
          const selectedOption = cachedSelectedOption.value;
          states.createdOptions.length = 0;
          if (selectedOption && selectedOption.created) {
            states.createdOptions.push(selectedOption);
          }
        }
      }
    }
  }
  function removeNewOption(option) {
    if (!enableAllowCreateMode.value || !option || !option.created || option.created && props.reserveKeyword && states.inputValue === getLabel(option)) {
      return;
    }
    const idx = states.createdOptions.findIndex((it) => getValue(it) === getValue(option));
    if (~idx) {
      states.createdOptions.splice(idx, 1);
      createOptionCount.value--;
    }
  }
  function clearAllNewOption() {
    if (enableAllowCreateMode.value) {
      states.createdOptions.length = 0;
      createOptionCount.value = 0;
    }
  }
  return {
    createNewOption,
    removeNewOption,
    selectNewOption,
    clearAllNewOption
  };
}

exports.useAllowCreate = useAllowCreate;
//# sourceMappingURL=useAllowCreate.js.map


code:
import type { IOptionV2Props } from './token';
import type { OptionEmitFn } from './defaults';
export declare function useOption(props: IOptionV2Props, { emit }: {
    emit: OptionEmitFn;
}): {
    hoverItem: () => void;
    selectOptionClick: () => void;
};


code:
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function useOption(props, { emit }) {
  return {
    hoverItem: () => {
      if (!props.disabled) {
        emit("hover", props.index);
      }
    },
    selectOptionClick: () => {
      if (!props.disabled) {
        emit("select", props.item, props.index);
      }
    }
  };
}

exports.useOption = useOption;
//# sourceMappingURL=useOption.js.map


code:
import type { ISelectV2Props } from './token';
import type { Option } from './select.types';
export interface Props {
    label?: string;
    value?: string;
    disabled?: string;
    options?: string;
}
export declare const defaultProps: Required<Props>;
export declare function useProps(props: Pick<ISelectV2Props, 'props'>): {
    aliasProps: import("vue").ComputedRef<{
        label: string;
        value: string;
        disabled: string;
        options: string;
    }>;
    getLabel: (option: Option) => any;
    getValue: (option: Option) => any;
    getDisabled: (option: Option) => any;
    getOptions: (option: Option) => any;
};


code:
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var lodashUnified = require('lodash-unified');

const defaultProps = {
  label: "label",
  value: "value",
  disabled: "disabled",
  options: "options"
};
function useProps(props) {
  const aliasProps = vue.computed(() => ({ ...defaultProps, ...props.props }));
  const getLabel = (option) => lodashUnified.get(option, aliasProps.value.label);
  const getValue = (option) => lodashUnified.get(option, aliasProps.value.value);
  const getDisabled = (option) => lodashUnified.get(option, aliasProps.value.disabled);
  const getOptions = (option) => lodashUnified.get(option, aliasProps.value.options);
  return {
    aliasProps,
    getLabel,
    getValue,
    getDisabled,
    getOptions
  };
}

exports.defaultProps = defaultProps;
exports.useProps = useProps;
//# sourceMappingURL=useProps.js.map