@iankibetsh/shframework 5.0.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/library.js CHANGED
@@ -2150,7 +2150,7 @@ const _hoisted_10$8 = {
2150
2150
 
2151
2151
  var script$z = {
2152
2152
  __name: 'ShSuggest',
2153
- props: ['data','allowMultiple','url','modelValue','optionTemplate'],
2153
+ props: ['data','allowMultiple','url','modelValue','optionTemplate','allowUserInput'],
2154
2154
  emits: ['update:modelValue'],
2155
2155
  setup(__props, { emit: __emit }) {
2156
2156
 
@@ -2190,7 +2190,12 @@ function addSuggestion(sgn){
2190
2190
  function updateModelValue(){
2191
2191
  let selectedItems = selectedSuggestions.value;
2192
2192
  if(selectedItems.length === 0) {
2193
- emit('update:modelValue', null);
2193
+ if(props.allowUserInput){
2194
+ emit('update:modelValue', searchText.value);
2195
+ console.log(searchText.value);
2196
+ } else {
2197
+ emit('update:modelValue', null);
2198
+ }
2194
2199
  } else if (!props.allowMultiple) {
2195
2200
  emit('update:modelValue', selectedItems[0].id);
2196
2201
  } else {
@@ -2216,12 +2221,14 @@ function filterData(e){
2216
2221
  searchText.value = filterValue;
2217
2222
  if (props.url) {
2218
2223
  fetchRemoteData();
2224
+ updateModelValue();
2219
2225
  } else if(props.data) {
2220
2226
  suggestions.value = props.data.filter(item=>{
2221
2227
  if(item.name.toLowerCase().includes(filterValue.toLowerCase())){
2222
2228
  return item
2223
2229
  }
2224
2230
  });
2231
+ updateModelValue();
2225
2232
  } else {
2226
2233
  console.log("Error: no data or url provided");
2227
2234
  }
@@ -2313,7 +2320,7 @@ return (_ctx, _cache) => {
2313
2320
  }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_6$a)
2314
2321
  ], 8 /* PROPS */, _hoisted_2$h),
2315
2322
  vue.createElementVNode("ul", {
2316
- class: "dropdown-menu w-100",
2323
+ class: vue.normalizeClass([(!vue.unref(suggestions) || vue.unref(suggestions).length === 0) ? 'no-sh-suggestions':'sh-found-suggestions', "dropdown-menu w-100"]),
2317
2324
  id: 'dropwdown_section' + vue.unref(id),
2318
2325
  "aria-labelledby": vue.unref(id)
2319
2326
  }, [
@@ -2345,7 +2352,7 @@ return (_ctx, _cache) => {
2345
2352
  : (vue.unref(searchText))
2346
2353
  ? (vue.openBlock(), vue.createElementBlock("li", _hoisted_9$8, " No results found "))
2347
2354
  : (vue.openBlock(), vue.createElementBlock("li", _hoisted_10$8, " Type to search... "))
2348
- ], 8 /* PROPS */, _hoisted_7$9)
2355
+ ], 10 /* CLASS, PROPS */, _hoisted_7$9)
2349
2356
  ]))
2350
2357
  : vue.createCommentVNode("v-if", true)
2351
2358
  }
package/dist/library.mjs CHANGED
@@ -3,7 +3,7 @@ import moment from 'moment';
3
3
  import Swal from 'sweetalert2';
4
4
  import { Modal, Offcanvas } from 'bootstrap';
5
5
  import NProgress from 'nprogress';
6
- import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, ref, onMounted, watch, unref, createBlock, resolveDynamicComponent, normalizeClass, resolveComponent, inject, mergeProps, renderSlot, normalizeStyle, computed, createVNode, withCtx, vModelCheckbox, shallowRef, normalizeProps, pushScopeId, popScopeId, markRaw, isRef } from 'vue';
6
+ import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, ref, onMounted, watch, unref, normalizeClass, createBlock, resolveDynamicComponent, resolveComponent, inject, mergeProps, renderSlot, normalizeStyle, computed, createVNode, withCtx, vModelCheckbox, shallowRef, normalizeProps, pushScopeId, popScopeId, markRaw, isRef } from 'vue';
7
7
  import _ from 'lodash';
8
8
  import { defineStore, storeToRefs } from 'pinia';
9
9
  import { useRoute, useRouter } from 'vue-router';
@@ -2138,7 +2138,7 @@ const _hoisted_10$8 = {
2138
2138
 
2139
2139
  var script$z = {
2140
2140
  __name: 'ShSuggest',
2141
- props: ['data','allowMultiple','url','modelValue','optionTemplate'],
2141
+ props: ['data','allowMultiple','url','modelValue','optionTemplate','allowUserInput'],
2142
2142
  emits: ['update:modelValue'],
2143
2143
  setup(__props, { emit: __emit }) {
2144
2144
 
@@ -2178,7 +2178,12 @@ function addSuggestion(sgn){
2178
2178
  function updateModelValue(){
2179
2179
  let selectedItems = selectedSuggestions.value;
2180
2180
  if(selectedItems.length === 0) {
2181
- emit('update:modelValue', null);
2181
+ if(props.allowUserInput){
2182
+ emit('update:modelValue', searchText.value);
2183
+ console.log(searchText.value);
2184
+ } else {
2185
+ emit('update:modelValue', null);
2186
+ }
2182
2187
  } else if (!props.allowMultiple) {
2183
2188
  emit('update:modelValue', selectedItems[0].id);
2184
2189
  } else {
@@ -2204,12 +2209,14 @@ function filterData(e){
2204
2209
  searchText.value = filterValue;
2205
2210
  if (props.url) {
2206
2211
  fetchRemoteData();
2212
+ updateModelValue();
2207
2213
  } else if(props.data) {
2208
2214
  suggestions.value = props.data.filter(item=>{
2209
2215
  if(item.name.toLowerCase().includes(filterValue.toLowerCase())){
2210
2216
  return item
2211
2217
  }
2212
2218
  });
2219
+ updateModelValue();
2213
2220
  } else {
2214
2221
  console.log("Error: no data or url provided");
2215
2222
  }
@@ -2301,7 +2308,7 @@ return (_ctx, _cache) => {
2301
2308
  }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_6$a)
2302
2309
  ], 8 /* PROPS */, _hoisted_2$h),
2303
2310
  createElementVNode("ul", {
2304
- class: "dropdown-menu w-100",
2311
+ class: normalizeClass([(!unref(suggestions) || unref(suggestions).length === 0) ? 'no-sh-suggestions':'sh-found-suggestions', "dropdown-menu w-100"]),
2305
2312
  id: 'dropwdown_section' + unref(id),
2306
2313
  "aria-labelledby": unref(id)
2307
2314
  }, [
@@ -2333,7 +2340,7 @@ return (_ctx, _cache) => {
2333
2340
  : (unref(searchText))
2334
2341
  ? (openBlock(), createElementBlock("li", _hoisted_9$8, " No results found "))
2335
2342
  : (openBlock(), createElementBlock("li", _hoisted_10$8, " Type to search... "))
2336
- ], 8 /* PROPS */, _hoisted_7$9)
2343
+ ], 10 /* CLASS, PROPS */, _hoisted_7$9)
2337
2344
  ]))
2338
2345
  : createCommentVNode("v-if", true)
2339
2346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",