0.0.11 • Published 4 months ago

@sulzanoks/select42 v0.0.11

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

Select42 Vue Component

Select42 is a Vue.js component that replicates the functionality of Select2 without the need for jQuery. It provides a customizable and user-friendly dropdown for selecting options. The component is built with Vue.js and does not have any external dependencies other than Vue itself.

DISCLAIMER: This is my first NPM package. developed for my specific needs. Use at your own risk. No support. May require bootstrap 5.

Installation

You can install the Select42 component using npm:

npm install @sulzanoks/select42

Usage

To use the Select42 component, you can import it into your Vue project and register it as a local component:

<template>
  <div>
    <h2>Select42 Example</h2>
    <select42
      :options="options"
      :placeholder="placeholder"
      :ajaxUrl="ajaxUrl"
      :showSearch="showSearch"
      @update="handleOptionSelected"
    ></select42>
  </div>
</template>

<script>
import Select42 from "@sulzanoks/select42";
import '@sulzanoks/select42/dist/style.css';

export default {
  components: {
    select42,
  },
  data() {
    return {
      options: [
                { value: '1', text: 'One' },
                { value: '2', text: 'Two' },
                { value: '3', text: 'Three' },
      ],
      placeholder: "Select an option",
      ajaxUrl: "", // Your AJAX endpoint URL here, if applicable
      showSearch: true,
    };
  },
  methods: {
    handleOptionSelected(option) {
      console.log("Selected option:", option);
    },
  },
};
</script>

Props

PropertyTypeDefaultDescription
optionsArray[]An array of objects representing the available options for the dropdown. Each object should have the properties value and text.
placeholderString"Select an option"The text to display when no option is selected.
themeString"primary"NOT IMPLEMENTED! The CSS class name for customizing the appearance of the component.
dropdownPositionString"bottom"NOT IMPLEMENTED! The position of the dropdown relative to the select box. Possible values are "bottom" (default) or "top".
ajaxUrlStringnullThe URL to fetch options asynchronously when searching. If provided, the component will perform a search using this URL.
showSearchBooleantrueA boolean indicating whether to display the search input within the dropdown. Default is true.

For convenience

value: you can access selected value anytime with this.$refs.mySelect42Ref.value (where mySelect42Ref is ref name of your choice).

selectedOption: In case you've passed some extra data to options, you can access the whole selected option object with this.$refs.mySelect42Ref.selectedOption (where mySelect42Ref is ref name of your choice).

Events

@update:modelValue: This event is emitted when an option is selected. The selected option value is passed as the event payload.

@update:object: This event is emitted when an option is selected. The selected option object is passed as the event payload.

Methods

toggleDropdown: Toggles the visibility of the dropdown.

Slots

None.

License

Select42 is released under the MIT License. Feel free to use and modify it according to your needs.

0.0.11

4 months ago

0.0.10

6 months ago

0.0.9

7 months ago

0.0.8

9 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago

0.0.0

10 months ago