0.5.4 • Published 1 month ago

vue-extended-multiselect v0.5.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

vue-extended-multiselect v0.5.4


Brief annotation

Vue extended multiselect is a component that was created for simplification of custom settings of built-in select element. This component allows developer to escape writing many excess css-rules by using built-in themes and to escape problems with different kinds of provided options. Various decoration of options list by some extra slots will help developer to make it more informative and obvious. More thorough filtering of raw options list given by developer excludes sudden errors if kind of option is not intended for extended multiselect. Switchable useful warnings will help to catch possible errors that may occur while working with options. Tools for working with selected options will allow user to control amount of displayed options and quickly deselect them. Such tools also can be customized by developer. Various slots can help developer to customize to his liking options list, elements with selected options in multiple select or some other interaction elements. You can use this component in your web-applications based on Vue 2 framework. If you are using next Vue versions, try "vue3-extended-multiselect". These packages are identical.

Page with live examples

https://vue3-extended-multiselect.surge.sh/

These examples are based on Vue3, but you can use the same props/slots/events in Vue2 version.

Installation with npm

npm install --save vue-extended-multiselect

Installation with yarn

yarn install --production vue-extended-multiselect

Importing

import VueExtendedMultiselect from "vue-extended-multiselect"

Importing types

import { UnionOptionType } from "vue-extended-multiselect"

Table of contents

Props list

Prop nameProp typeProp appointmentProp default valueProp values
autoSelectCreatedOptionBooleanDetermines whether to select just now created option automatically.false
autoSelectSearchValueBooleanDetermines whether to take search value from current selected option if "multiple" prop equals false.false
clearBySelectWhenMultipleBooleanDetermines whether to clear search field by option selection.false
createOnTheGoBooleanAllows user to create new options from search field.false
defaultExpandedBooleanDetermines whether options list should be expanded by default.false
disabledBooleanDisables extended multiselect.false
dropdownDisabledBooleanDisables dropdown toggle.false
highlightOptionsBooleanSwitches options highlighting while hovering.true
loadingBooleanSwitches loading state of extended multiselect.false
multipleBooleanAllows user to select multiple options.false
noResultsBlockShownBooleanDetermines whether to show special hint if no options were found.true
resetSearchByValueBooleanDetermines whether to clear search field by selection/deselection of options.true
searchFilterActiveBooleanAllows user to use internal search for options.true
simpleEventsBooleanSwitches full payload of extended multiselect events.true
selectedOptionsShownBooleanDetermines whether to show selected options in options list.false
showClearIconBooleanAllows user to deselect all options by special icon.false
showDeselectIconLoaderBooleanDetermines whether to show loader icon in multiple options block if "loading" prop equals truetrue
showInsertWarningsBooleanDetermines whether to show useful internal warnings in console.false
showMarkerBooleanDetermines whether to show slot with special marker beside option in options list.false
showSearchFieldBooleanDetermines whether to show search field which allows user to search for options with internal search.true
toggleMultipleBlocksLimitBooleanAllows user to increase limit of shown elements with selected options by special icon.false
toggleOptionsBySelectBooleanDetermines whether to roll up options list by selection of option.true
togglingSavesSearchValueBooleanDetermines whether to save current search value if display of options list was toggled.true
wrongCurrentValueBooleanDetermines whether to define special class for extended multiselect if value is wrong or if irregularity of value is defined by user.false
createOptionPlaceholderStringPlaceholder for the search field to be used if user is allowed to create new options."Select or create features"
createOptionTypeStringDefines kind for all options which will be created by user."primitive""primitive", "array", "object"
disableByFieldStringDetermines a field in options of type "object" which value will be used to disable such options."disabled"
emptyObjectsPlaceholderStringPlaceholder for options of type "object" or Array instances which length/keys length equals 0."Empty Object/Array"
errorBorderColorStringDefines "border-color" css-property for extended multiselect with wrong value."#FF0000"
iconFilterStringDefines svg-filter with color settings for all icons except loader."basic""basic", "black", "green"
iconSizeStringDefines sizes for all icons in pixels except loader."large""large", "medium", "small"
labelStringDefines field in options of type "object" that will be the label of option."label"
loaderIconFilterStringDefines svg-filter with color settings for loader icon."loader-default""loader-default", "basic", "slate-grey", "slate-blue", "teal", "strict"
placeholderStringPlaceholder for search field to be used if user is not allowed to create new options."Select features"
searchByFieldStringDetermines field in options of type "object" to use in internal search.""
themeTypeStringDefines overall color theme for extended multiselect."basic""basic", "slate-grey", "slate-blue", "teal", "strict"
toggleAppearanceSideStringDefines which side options list will be displayed on."auto""auto", "atop", "under"
toggleIconStringDefines kind of toggle icon from icons collection."base-arrow""base-arrow", "double-arrow", "wide-arrow", "circle-arrow", "inner-arrow", "triangle-arrow", "triangle-circle-arrow"
anyOptionWrapperBlockHeightNumberDefines "height" css-property for each option in options list.30
increaseDisplayByNumberDefines gap which increases limit of displayed elements with selected options.5
maxOptionsCountNumberMaximal limit of selected options.null
minOptionsCountNumberMinimal limit of selected options.null
multipleBlocksLimitNumberDefines limit of displayed elements with selected options.null
optionsCountRestrictionNumberDefines maximal limit of options list length.null
toggleMaxHeightNumberDefines maximal value in pixels of "max-height" css-property for options list.400
toggleMinHeightNumberDefines minimal value in pixels of "max-height" css-property for options list.null
createOptionFieldsArrayDefines a list of fields for options of type "object" created by user."label"
disabledPrimitiveOptionsArrayDefines a list of primitive options which will be disabled for selection.[]
optionsArrayRaw options list.[]
optionsPaddingArrayDefines a list with "padding-top", "padding-left", "padding-bottom" and "padding-right" css-properties for options in options list. Property "padding-top" matches index zero. Property "padding-right" matches index three.[]
preselectedOptionsArrayDefines a list of options that will be select by default.[]
specialKeysBlockArrayDefines a list of keys which in combination with mouse buttons or "enter" key will prevent selection of option.[]"alt", "ctrl", "shift"
createCustomOptionLabelFunctionDefines function that creates custom label for each option.(option) => null
multipleBlocksLimitMessageFunctionDefines function that creates notification when maximal limit of selected options has been reached.(number) => `and ${number} more items`
inputIdString, Number"id" attribute of search field.null
preselectedOptionUnionPropType (from types)Defines options that will be select by default.null
valueArrayDefines value of extended multiselect that can be used in "v-model".[]

Slots list

Slot nameSlot appointmentSlot scope
cancelButton that deselects all options.cancel — function that deselects all options
labelBlockElement with single selected option that is shown if search field display is disabled.labelBlockValue — option label
lessThanLimitMessage displayed if minimal limit of selected options has not been reached.
listHeaderElement at the top of options list for information content.
listFooterElement at the bottom of options list for information content.
markerMarker that indicates state of option selection.selected — flag to determine markers for selected options
maxElementsMessage displayed if maximal limit of elements with selected options has been shown.
moreThanLimitMessage displayed if maximal limit of selected options has been reached.
multipleBlocksBlock with selected options and other multiple select slotsselectedOptions — list of selected options,deselectBlock — function that deselects option and removes element that contained it
noResultsMessage displayed if no options have been found by internal search.
noOptionsMessage displayed if given options list is empty.
optionOption in options list with its label.option — option from options list,createCustomOptionLabel — function that creates custom label for each option
optionBlockElement with selected option and its label.label — option label,deselectBlock — function that deselects option and removes element that contained it,index — option index
showMoreButton that increases limit of displayed elements with selected options.showMoreOptions — function that increases limit of displayed elements with selected options
toggleButton that toggles options list display.toggleOptionsList — function that toggles options list display

Events list

Event nameEvent appointmentListener methodSimplified event payloadFields of object with full event payload
pattern-changedChange value of search field.@pattern-changedvalue — pattern of inner search for available optionsvalue — pattern of inner search for available options,inputId — id of search field set by "id" prop
selectSelection of option.@selectoption — just now selected optionoption — just now selected option,inputId — id of search field set by "id" prop
cleanRemoval of all options or singe option.@cleanoption/options — just now deselected option or array with just now deselected optionsoption/options — just now deselected option or array with just now deselected options,inputId — id of search field set by "id" prop
option-createdCreation of new option by user.@option-createdoption — option created by useroption/options — option created by user,inputId — id of search field set by "id" prop
activeDropdown options list expanding.@activeinputId — id of search field set by "id" prop
closeRolling up dropdown options list.@closeoptions — array of selected optionsoptions — array of selected options,inputId — id of search field set by "id" prop
increaseIncreasing current limit of displayed elements with selected options.@increaselimit — current limit of options to be shown nextlimit — current limit of options to be shown next,inputId — id of search field set by "id" prop

Styling with css

Vue extended multiselect provides following css-variables:

  --basic-color: #708090;
  --basic-transparent: rgba(112, 128, 144, 0.6);
  --cancel: #B22222;
  --cancel-backgound-color: rgba(179, 33, 33, 0.1);
  --dark-slate-blue: #483D8B;
  --dark-slate-blue-transparent: rgba(72, 61, 139, 0.6);
  --dark-slate-grey: #2F4F4F;
  --dark-slate-grey-transparent: rgba(47, 79, 79, 0.6);
  --disabled: rgba(176, 176, 176, 0.6);
  --hover-color: #FFFFFF;
  --loader-color: #00BFFF;
  --strict: #000000;
  --strict-transparent: rgba(0, 0, 0, 0.6);
  --teal: #008080;
  --teal-transparent: rgba(0, 128, 128, 0.6);
  
  --block-border-radius: 4px;
  --block-cancel-padding: 4px;
  --block-gap: 6px;
  --block-padding: 1px 3px 1px 7px;
  --border-radius: 6px;
  --border-radius-small: 3px;
  --cancel-padding: 3px 8px;
  --grid-columns: 1fr 36px 36px;
  --grid-rows: 1fr 36px;
  --half-size: 50%;
  --icon-size-block: 14px;
  --icon-size-large: 18px;
  --icon-size-medium: 15px;
  --icon-size-small: 12px;
  --increaser-padding: 3px 7px;
  --max-size: 100%;
  --min-block-height: 25px;
  --options-padding: 6px 0;
  --outer-gap: 10px;
  --root-padding: 6px 10px;
  --toggle-icon-gap: 1px;
  --wide-text: 700;
  --wrapper-padding: 5px 10px;
  --z-index-options: 10;

  --border: 1px solid;
  --default-cursor: default;
  --icons-align-self: start;
  --icons-justify-self: center;
  --pointer-cursor: pointer;
  --wrapper-transition: border-top-left-radius 250ms ease 0s, border-top-right-radius 250ms ease 0s,
                        border-bottom-left-radius 250ms ease-out, border-bottom-right-radius 250ms ease-out;

You can override it globally or by particular instance class name.

  <vue-extended-multiselect class="instance-class" />
.instance-class {
  --basic-color: purple;
  --outer-gap: 2rem;
  --border: 1px dotted;
}

Styling with props

Vue extended multiselect provides following props for customizing:

  • errorBorderColor
  • iconFilter
  • iconSize
  • loaderIconFilter
  • themeType
  • toggleIcon
  • anyOptionWrapperBlockHeight
  • toggleMaxHeight
  • toggleMinHeight

Customizing examples

Changing border color when extended multiselect value is invalid.

  <vue-extended-multiselect error-border-color="#8B0000" />

Changing svg color filter for icons.

  <vue-extended-multiselect icon-filter="green" />

Resizing icons.

  <vue-extended-multiselect icon-size="small" />

Changing svg color filter for loader icon.

  <vue-extended-multiselect icon-size="small" />

Changing general color theme of extended multiselect.

  <vue-extended-multiselect theme-type="slate-blue" />

Changing toggle icon form.

  <vue-extended-multiselect toggle-icon="triangle-arrow" />

Resizing option blocks in options list.

  <vue-extended-multiselect :any-option-wrapper-block-height="60" />

Changing "max-height" css-property of options list.

  <vue-extended-multiselect :toggle-max-height="500" />

Changing "min-height" css-property of options list.

  <vue-extended-multiselect :toggle-min-height="500" />

License

MIT

0.5.4

1 month ago

0.5.0

1 month ago

0.5.2

1 month ago

0.5.1

1 month ago

0.4.1

1 month ago

0.4.3

1 month ago

0.4.2

1 month ago

0.4.0

3 months ago

0.3.0

4 months ago

0.3.2

4 months ago

0.3.1

4 months ago

0.2.1

8 months ago

0.2.0

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago