@iankibetsh/shframework 0.4.6 → 0.5.2

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.
@@ -51,3 +51,18 @@
51
51
  width: 100% !important;
52
52
  }
53
53
  }
54
+
55
+ .sh-selected-item{
56
+ line-height: unset!important;
57
+ }
58
+ .sh-suggestion-input{
59
+ padding: 0.375rem 0.75rem;
60
+ }
61
+ .sh-suggest{
62
+ margin-bottom: 1rem;
63
+ }
64
+ .sh-suggest-control::after{
65
+ margin-top: auto;
66
+ margin-bottom: auto;
67
+ margin-right: 0.255em;
68
+ }
package/dist/library.js CHANGED
@@ -38,9 +38,10 @@ var shstorage = {
38
38
  removeItem
39
39
  };
40
40
 
41
- let apiUrl = window.VITE_APP_API_URL;
41
+ let apiUrl = undefined.VITE_APP_API_URL;
42
+ // eslint-disable-next-line no-undef
42
43
  if (process.env.NODE_ENV === 'production') {
43
- apiUrl = window.VITE_APP_API_PRODUCTION_URL;
44
+ apiUrl = undefined.VITE_APP_API_PRODUCTION_URL;
44
45
  }
45
46
  const axios = Axios__default["default"].create({
46
47
  baseURL: apiUrl
@@ -1544,7 +1545,7 @@ const countries = [
1544
1545
  }
1545
1546
  ];
1546
1547
 
1547
- var script$7 = {
1548
+ var script$8 = {
1548
1549
  name: 'ShPhone',
1549
1550
  props: ['modelValue', 'country_code'],
1550
1551
  data () {
@@ -1606,19 +1607,19 @@ var script$7 = {
1606
1607
  }
1607
1608
  };
1608
1609
 
1609
- const _hoisted_1$7 = { class: "sh-phone mb-3" };
1610
- const _hoisted_2$6 = {
1610
+ const _hoisted_1$8 = { class: "sh-phone mb-3" };
1611
+ const _hoisted_2$7 = {
1611
1612
  key: 0,
1612
1613
  style: {"display":"contents"}
1613
1614
  };
1614
- const _hoisted_3$6 = ["src"];
1615
- const _hoisted_4$6 = ["value"];
1615
+ const _hoisted_3$7 = ["src"];
1616
+ const _hoisted_4$7 = ["value"];
1616
1617
 
1617
1618
  function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1618
- return (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
1619
+ return (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
1619
1620
  ($data.selectedCountry)
1620
- ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$6, [
1621
- vue.createElementVNode("img", { src: $data.flag }, null, 8 /* PROPS */, _hoisted_3$6),
1621
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$7, [
1622
+ vue.createElementVNode("img", { src: $data.flag }, null, 8 /* PROPS */, _hoisted_3$7),
1622
1623
  vue.createTextVNode(" " + vue.toDisplayString($data.selectedCountry.dialCode), 1 /* TEXT */)
1623
1624
  ]))
1624
1625
  : vue.createCommentVNode("v-if", true),
@@ -1631,7 +1632,7 @@ function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1631
1632
  return (vue.openBlock(), vue.createElementBlock("option", {
1632
1633
  value: country,
1633
1634
  key: country.dialCode
1634
- }, vue.toDisplayString(country.name + '(' + country.dialCode + ')'), 9 /* TEXT, PROPS */, _hoisted_4$6))
1635
+ }, vue.toDisplayString(country.name + '(' + country.dialCode + ')'), 9 /* TEXT, PROPS */, _hoisted_4$7))
1635
1636
  }), 128 /* KEYED_FRAGMENT */))
1636
1637
  ], 544 /* HYDRATE_EVENTS, NEED_PATCH */), [
1637
1638
  [vue.vModelSelect, $data.selectedCountry]
@@ -1649,10 +1650,10 @@ function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1649
1650
  ]))
1650
1651
  }
1651
1652
 
1652
- script$7.render = render$7;
1653
- script$7.__file = "src/views/ShPhone.vue";
1653
+ script$8.render = render$7;
1654
+ script$8.__file = "src/views/ShPhone.vue";
1654
1655
 
1655
- var script$6 = {
1656
+ var script$7 = {
1656
1657
  name: 'ShEditor',
1657
1658
  props: ['modelValue'],
1658
1659
  components: {
@@ -1691,7 +1692,7 @@ var script$6 = {
1691
1692
  }
1692
1693
  };
1693
1694
 
1694
- const _hoisted_1$6 = /*#__PURE__*/vue.createElementVNode("textarea", {
1695
+ const _hoisted_1$7 = /*#__PURE__*/vue.createElementVNode("textarea", {
1695
1696
  id: "tiny",
1696
1697
  style: {"display":"none"},
1697
1698
  "data-cy": "tinymce_editor"
@@ -1701,7 +1702,7 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
1701
1702
  const _component_editor = vue.resolveComponent("editor");
1702
1703
 
1703
1704
  return (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
1704
- _hoisted_1$6,
1705
+ _hoisted_1$7,
1705
1706
  vue.createElementVNode("div", {
1706
1707
  onFocusin: _cache[1] || (_cache[1] = vue.withModifiers(() => {}, ["stop"])),
1707
1708
  class: "sh-editor w-100"
@@ -1726,14 +1727,174 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
1726
1727
  ], 64 /* STABLE_FRAGMENT */))
1727
1728
  }
1728
1729
 
1729
- script$6.render = render$6;
1730
- script$6.__file = "src/views/FormComponent/ShEditor.vue";
1730
+ script$7.render = render$6;
1731
+ script$7.__file = "src/views/FormComponent/ShEditor.vue";
1732
+
1733
+ const _hoisted_1$6 = {
1734
+ key: 0,
1735
+ class: "dropdown sh-suggest"
1736
+ };
1737
+ const _hoisted_2$6 = ["id"];
1738
+ const _hoisted_3$6 = { class: "badge bg-secondary m-1 sh-selected-item" };
1739
+ const _hoisted_4$6 = ["onClick"];
1740
+ const _hoisted_5$5 = ["id"];
1741
+ const _hoisted_6$3 = ["aria-labelledby"];
1742
+ const _hoisted_7$3 = { key: 0 };
1743
+ const _hoisted_8$2 = ["onClick"];
1744
+ const _hoisted_9$2 = {
1745
+ key: 1,
1746
+ class: "dropdown-item sh-suggest-no-results"
1747
+ };
1748
+ const _hoisted_10$3 = {
1749
+ key: 2,
1750
+ class: "dropdown-item sh-suggest-no-input"
1751
+ };
1752
+
1753
+
1754
+ var script$6 = {
1755
+ __name: 'ShSuggest',
1756
+ props: ['fillSelects','modelValue'],
1757
+ emits: ['update:modelValue'],
1758
+ setup(__props, { emit }) {
1759
+
1760
+ const props = __props;
1761
+
1762
+
1763
+
1764
+ let id = vue.ref(null);
1765
+ vue.ref(null);
1766
+ let suggestions = vue.ref(null);
1767
+ let selectedSuggestions = vue.ref([]);
1768
+ vue.onMounted(() => {
1769
+ id.value = 'sid' + (Math.random() + 1).toString(36).substring(7);
1770
+ resetData();
1771
+ });
1772
+ function resetData(){
1773
+ if(props.fillSelects.data) {
1774
+ suggestions.value = props.fillSelects.data;
1775
+ }
1776
+ }
1777
+ function addSuggestion(sgn){
1778
+ let selected = selectedSuggestions.value;
1779
+ if(selected.length > 0 && !props.fillSelects.allow_multiple){
1780
+ selected = [];
1781
+ }
1782
+ if(!selected.includes(sgn)){
1783
+ selected.push(sgn);
1784
+ selectedSuggestions.value = selected;
1785
+ }
1786
+ updateModelValue();
1787
+ document.getElementById('input_' + id.value).innerHTML = '';
1788
+ }
1789
+ function updateModelValue(){
1790
+ let selectedItems = selectedSuggestions.value;
1791
+ if(selectedItems.length === 0) {
1792
+ emit('update:modelValue', null);
1793
+ } else if (!props.fillSelects.allow_multiple) {
1794
+ emit('update:modelValue', selectedItems[0].id);
1795
+ } else {
1796
+ const ids = selectedItems.map(item => {
1797
+ return item.id
1798
+ });
1799
+ emit('update:modelValue', ids);
1800
+ }
1801
+ }
1802
+ function removeSuggestion(sgt){
1803
+ selectedSuggestions.value = selectedSuggestions.value.filter(selectedSgt=>{
1804
+ if(selectedSgt.id !== sgt) {
1805
+ return selectedSgt
1806
+ }
1807
+ });
1808
+ updateModelValue();
1809
+ }
1810
+ let searchText = vue.ref(null);
1811
+ function filterData(e){
1812
+ let filterValue = e.target.innerText;
1813
+ searchText.value = filterValue;
1814
+ if(props.fillSelects.data) {
1815
+ suggestions.value = props.fillSelects.data.filter(item=>{
1816
+ if(item.name.toLowerCase().includes(filterValue.toLowerCase())){
1817
+ return item
1818
+ }
1819
+ });
1820
+ } else {
1821
+ apis.doGet(props.fillSelects.url, { all: 1,filter_value: filterValue }).then(res => {
1822
+ suggestions.value = res.data.data;
1823
+ }).catch(res => {
1824
+ console.log(res);
1825
+ });
1826
+ }
1827
+ }
1828
+
1829
+ return (_ctx, _cache) => {
1830
+ return (vue.unref(id))
1831
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
1832
+ vue.createElementVNode("div", {
1833
+ id: vue.unref(id),
1834
+ "data-bs-toggle": "dropdown",
1835
+ class: "form-control p-0 d-flex sh-suggest-control dropdown-toggle",
1836
+ "aria-expanded": "false"
1837
+ }, [
1838
+ vue.createElementVNode("div", null, [
1839
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(selectedSuggestions), (sgt) => {
1840
+ return (vue.openBlock(), vue.createElementBlock("h5", _hoisted_3$6, [
1841
+ vue.createTextVNode(vue.toDisplayString(sgt.name) + " ", 1 /* TEXT */),
1842
+ vue.createElementVNode("button", {
1843
+ onClick: $event => (removeSuggestion(sgt.id)),
1844
+ type: "button",
1845
+ class: "btn-close border-start border-1 ms-1",
1846
+ "aria-label": "Close"
1847
+ }, null, 8 /* PROPS */, _hoisted_4$6)
1848
+ ]))
1849
+ }), 256 /* UNKEYED_FRAGMENT */))
1850
+ ]),
1851
+ vue.createElementVNode("div", {
1852
+ id: 'input_' + vue.unref(id),
1853
+ contenteditable: "true",
1854
+ onInput: filterData,
1855
+ class: "flex-fill h-100 sh-suggestion-input"
1856
+ }, null, 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_5$5)
1857
+ ], 8 /* PROPS */, _hoisted_2$6),
1858
+ vue.createElementVNode("ul", {
1859
+ class: "dropdown-menu w-100",
1860
+ "aria-labelledby": vue.unref(id)
1861
+ }, [
1862
+ (vue.unref(suggestions) && vue.unref(suggestions).length > 0)
1863
+ ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(vue.unref(suggestions), (suggestion) => {
1864
+ return (vue.openBlock(), vue.createElementBlock(vue.Fragment, {
1865
+ key: suggestion.id
1866
+ }, [
1867
+ (suggestion.name)
1868
+ ? (vue.openBlock(), vue.createElementBlock("li", _hoisted_7$3, [
1869
+ vue.createElementVNode("a", {
1870
+ onClick: $event => (addSuggestion(suggestion)),
1871
+ class: vue.normalizeClass(["dropdown-item", vue.unref(selectedSuggestions).includes(suggestion) ? 'active':'']),
1872
+ href: "#"
1873
+ }, vue.toDisplayString(suggestion.name ?? suggestion.text), 11 /* TEXT, CLASS, PROPS */, _hoisted_8$2)
1874
+ ]))
1875
+ : vue.createCommentVNode("v-if", true)
1876
+ ], 64 /* STABLE_FRAGMENT */))
1877
+ }), 128 /* KEYED_FRAGMENT */))
1878
+ : (vue.unref(searchText))
1879
+ ? (vue.openBlock(), vue.createElementBlock("li", _hoisted_9$2, " No results found "))
1880
+ : (vue.openBlock(), vue.createElementBlock("li", _hoisted_10$3, " Type to search... "))
1881
+ ], 8 /* PROPS */, _hoisted_6$3)
1882
+ ]))
1883
+ : vue.createCommentVNode("v-if", true)
1884
+ }
1885
+ }
1886
+
1887
+ };
1888
+
1889
+ script$6.__scopeId = "data-v-043a2b8f";
1890
+ script$6.__file = "src/views/FormComponent/ShSuggest.vue";
1731
1891
 
1732
1892
  var script$5 = {
1733
1893
  name: 'ShForm',
1734
1894
  components: {
1735
- ShEditor: script$6,
1736
- ShPhone: script$7
1895
+ ShSuggest: script$6,
1896
+ ShEditor: script$7,
1897
+ ShPhone: script$8
1737
1898
  },
1738
1899
  props: [
1739
1900
  'action',
@@ -1763,7 +1924,8 @@ var script$5 = {
1763
1924
  users: [],
1764
1925
  allPlaceHolders: {},
1765
1926
  user: null,
1766
- allLabels: {}
1927
+ allLabels: {},
1928
+ suggests: []
1767
1929
  }
1768
1930
  },
1769
1931
  methods: {
@@ -1788,6 +1950,9 @@ var script$5 = {
1788
1950
  }
1789
1951
  },
1790
1952
  getFieldType: function (field) {
1953
+ if(this.suggests && this.suggests.includes(field)){
1954
+ return 'suggest'
1955
+ }
1791
1956
  if(this.editors && this.editors.includes(field)){
1792
1957
  return 'editor'
1793
1958
  }
@@ -1811,7 +1976,7 @@ var script$5 = {
1811
1976
  const mapLocations = ['building_location'];
1812
1977
  const files = ['file', 'logo'];
1813
1978
  const phones = ['phone'];
1814
- if (field.includes('_id') || this.selectData[field]) {
1979
+ if (this.selectData[field]) {
1815
1980
  return 'select'
1816
1981
  }
1817
1982
  if (field === 'email') {
@@ -1993,7 +2158,12 @@ var script$5 = {
1993
2158
  const selectData = {};
1994
2159
  if (this.fillSelects) {
1995
2160
  Object.keys(this.fillSelects).forEach(key => {
1996
- if (this.fillSelects[key].data) {
2161
+ if(this.fillSelects[key].suggest || this.fillSelects[key].suggests) {
2162
+ if (!this.suggests) {
2163
+ this.suggests = [];
2164
+ }
2165
+ this.suggests.push(key);
2166
+ } else if (this.fillSelects[key].data) {
1997
2167
  selectData[key] = this.fillSelects[key].data;
1998
2168
  this.selectData = selectData;
1999
2169
  console.log(this.selectData);
@@ -2051,7 +2221,7 @@ const _hoisted_15$2 = ["name", "onFocus", "onUpdate:modelValue"];
2051
2221
  const _hoisted_16$2 = ["name", "onFocus", "onUpdate:modelValue"];
2052
2222
  const _hoisted_17$2 = ["value"];
2053
2223
  const _hoisted_18$2 = {
2054
- key: 10,
2224
+ key: 11,
2055
2225
  class: "invalid-feedback"
2056
2226
  };
2057
2227
  const _hoisted_19$2 = {
@@ -2084,6 +2254,7 @@ const _hoisted_23$2 = {
2084
2254
 
2085
2255
  function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2086
2256
  const _component_ShPhone = vue.resolveComponent("ShPhone");
2257
+ const _component_ShSuggest = vue.resolveComponent("ShSuggest");
2087
2258
  const _component_ShEditor = vue.resolveComponent("ShEditor");
2088
2259
 
2089
2260
  return (vue.openBlock(), vue.createElementBlock("form", _hoisted_1$5, [
@@ -2189,9 +2360,19 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2189
2360
  required: ""
2190
2361
  }, null, 8 /* PROPS */, ["country_code", "placeholder", "name", "onFocus", "class", "modelValue", "onUpdate:modelValue"]))
2191
2362
  : vue.createCommentVNode("v-if", true),
2363
+ ($options.getFieldType(field) === 'suggest')
2364
+ ? (vue.openBlock(), vue.createBlock(_component_ShSuggest, {
2365
+ key: 6,
2366
+ "select-data": _ctx.selectData[field],
2367
+ "fill-selects": $props.fillSelects[field],
2368
+ class: vue.normalizeClass(_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field),
2369
+ modelValue: _ctx.form_elements[field],
2370
+ "onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event)
2371
+ }, null, 8 /* PROPS */, ["select-data", "fill-selects", "class", "modelValue", "onUpdate:modelValue"]))
2372
+ : vue.createCommentVNode("v-if", true),
2192
2373
  ($options.getFieldType(field) === 'editor')
2193
2374
  ? (vue.openBlock(), vue.createBlock(_component_ShEditor, {
2194
- key: 6,
2375
+ key: 7,
2195
2376
  placeholder: _ctx.allPlaceHolders[field] ? _ctx.allPlaceHolders[field] : '',
2196
2377
  name: field,
2197
2378
  onFocus: $event => ($options.removeErrors(field)),
@@ -2202,7 +2383,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2202
2383
  : vue.createCommentVNode("v-if", true),
2203
2384
  ($options.getFieldType(field) === 'text')
2204
2385
  ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("input", {
2205
- key: 7,
2386
+ key: 8,
2206
2387
  disabled: $options.isDisabled(field),
2207
2388
  placeholder: field === 'phone_number' ? 'e.g 0712 345 678':'',
2208
2389
  name: field,
@@ -2216,7 +2397,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2216
2397
  : vue.createCommentVNode("v-if", true),
2217
2398
  ($options.getFieldType(field) === 'textarea')
2218
2399
  ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("textarea", {
2219
- key: 8,
2400
+ key: 9,
2220
2401
  name: field,
2221
2402
  onFocus: $event => ($options.removeErrors(field)),
2222
2403
  class: vue.normalizeClass([_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field, "form-control"]),
@@ -2227,7 +2408,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2227
2408
  : vue.createCommentVNode("v-if", true),
2228
2409
  ($options.getFieldType(field) === 'select' && _ctx.selectData[field] != null)
2229
2410
  ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("select", {
2230
- key: 9,
2411
+ key: 10,
2231
2412
  name: field,
2232
2413
  onFocus: $event => ($options.removeErrors(field)),
2233
2414
  class: vue.normalizeClass([_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field, "form-control"]),
@@ -2953,7 +3134,7 @@ var script$1 = {
2953
3134
  }
2954
3135
  };
2955
3136
 
2956
- const _hoisted_1$1 = { class: "auto-table mt-2" };
3137
+ const _hoisted_1$1 = { class: "auto-table" };
2957
3138
  const _hoisted_2$1 = {
2958
3139
  key: 0,
2959
3140
  class: "col-md-4 mb-2"
@@ -3681,7 +3862,7 @@ const useUserStore = pinia.defineStore('user-store', {
3681
3862
  exports.ShCanvas = script$4;
3682
3863
  exports.ShForm = script$5;
3683
3864
  exports.ShModal = script$3;
3684
- exports.ShPhone = script$7;
3865
+ exports.ShPhone = script$8;
3685
3866
  exports.ShTable = script$1;
3686
3867
  exports.ShTabs = script;
3687
3868
  exports.shApis = apis;
package/dist/library.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import Axios from 'axios';
2
2
  import NProgress from 'nprogress';
3
- import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, resolveComponent, withModifiers, createVNode, normalizeClass, createBlock, renderSlot, createStaticVNode, withCtx } from 'vue';
3
+ import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, resolveComponent, withModifiers, createVNode, ref, onMounted, unref, normalizeClass, createBlock, renderSlot, createStaticVNode, withCtx } from 'vue';
4
4
  import Editor from '@tinymce/tinymce-vue';
5
5
  import moment from 'moment';
6
6
  import Swal from 'sweetalert2';
@@ -26,9 +26,10 @@ var shstorage = {
26
26
  removeItem
27
27
  };
28
28
 
29
- let apiUrl = window.VITE_APP_API_URL;
29
+ let apiUrl = import.meta.env.VITE_APP_API_URL;
30
+ // eslint-disable-next-line no-undef
30
31
  if (process.env.NODE_ENV === 'production') {
31
- apiUrl = window.VITE_APP_API_PRODUCTION_URL;
32
+ apiUrl = import.meta.env.VITE_APP_API_PRODUCTION_URL;
32
33
  }
33
34
  const axios = Axios.create({
34
35
  baseURL: apiUrl
@@ -1532,7 +1533,7 @@ const countries = [
1532
1533
  }
1533
1534
  ];
1534
1535
 
1535
- var script$7 = {
1536
+ var script$8 = {
1536
1537
  name: 'ShPhone',
1537
1538
  props: ['modelValue', 'country_code'],
1538
1539
  data () {
@@ -1594,19 +1595,19 @@ var script$7 = {
1594
1595
  }
1595
1596
  };
1596
1597
 
1597
- const _hoisted_1$7 = { class: "sh-phone mb-3" };
1598
- const _hoisted_2$6 = {
1598
+ const _hoisted_1$8 = { class: "sh-phone mb-3" };
1599
+ const _hoisted_2$7 = {
1599
1600
  key: 0,
1600
1601
  style: {"display":"contents"}
1601
1602
  };
1602
- const _hoisted_3$6 = ["src"];
1603
- const _hoisted_4$6 = ["value"];
1603
+ const _hoisted_3$7 = ["src"];
1604
+ const _hoisted_4$7 = ["value"];
1604
1605
 
1605
1606
  function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1606
- return (openBlock(), createElementBlock("div", _hoisted_1$7, [
1607
+ return (openBlock(), createElementBlock("div", _hoisted_1$8, [
1607
1608
  ($data.selectedCountry)
1608
- ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
1609
- createElementVNode("img", { src: $data.flag }, null, 8 /* PROPS */, _hoisted_3$6),
1609
+ ? (openBlock(), createElementBlock("div", _hoisted_2$7, [
1610
+ createElementVNode("img", { src: $data.flag }, null, 8 /* PROPS */, _hoisted_3$7),
1610
1611
  createTextVNode(" " + toDisplayString($data.selectedCountry.dialCode), 1 /* TEXT */)
1611
1612
  ]))
1612
1613
  : createCommentVNode("v-if", true),
@@ -1619,7 +1620,7 @@ function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1619
1620
  return (openBlock(), createElementBlock("option", {
1620
1621
  value: country,
1621
1622
  key: country.dialCode
1622
- }, toDisplayString(country.name + '(' + country.dialCode + ')'), 9 /* TEXT, PROPS */, _hoisted_4$6))
1623
+ }, toDisplayString(country.name + '(' + country.dialCode + ')'), 9 /* TEXT, PROPS */, _hoisted_4$7))
1623
1624
  }), 128 /* KEYED_FRAGMENT */))
1624
1625
  ], 544 /* HYDRATE_EVENTS, NEED_PATCH */), [
1625
1626
  [vModelSelect, $data.selectedCountry]
@@ -1637,10 +1638,10 @@ function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1637
1638
  ]))
1638
1639
  }
1639
1640
 
1640
- script$7.render = render$7;
1641
- script$7.__file = "src/views/ShPhone.vue";
1641
+ script$8.render = render$7;
1642
+ script$8.__file = "src/views/ShPhone.vue";
1642
1643
 
1643
- var script$6 = {
1644
+ var script$7 = {
1644
1645
  name: 'ShEditor',
1645
1646
  props: ['modelValue'],
1646
1647
  components: {
@@ -1679,7 +1680,7 @@ var script$6 = {
1679
1680
  }
1680
1681
  };
1681
1682
 
1682
- const _hoisted_1$6 = /*#__PURE__*/createElementVNode("textarea", {
1683
+ const _hoisted_1$7 = /*#__PURE__*/createElementVNode("textarea", {
1683
1684
  id: "tiny",
1684
1685
  style: {"display":"none"},
1685
1686
  "data-cy": "tinymce_editor"
@@ -1689,7 +1690,7 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
1689
1690
  const _component_editor = resolveComponent("editor");
1690
1691
 
1691
1692
  return (openBlock(), createElementBlock(Fragment, null, [
1692
- _hoisted_1$6,
1693
+ _hoisted_1$7,
1693
1694
  createElementVNode("div", {
1694
1695
  onFocusin: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"])),
1695
1696
  class: "sh-editor w-100"
@@ -1714,14 +1715,174 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
1714
1715
  ], 64 /* STABLE_FRAGMENT */))
1715
1716
  }
1716
1717
 
1717
- script$6.render = render$6;
1718
- script$6.__file = "src/views/FormComponent/ShEditor.vue";
1718
+ script$7.render = render$6;
1719
+ script$7.__file = "src/views/FormComponent/ShEditor.vue";
1720
+
1721
+ const _hoisted_1$6 = {
1722
+ key: 0,
1723
+ class: "dropdown sh-suggest"
1724
+ };
1725
+ const _hoisted_2$6 = ["id"];
1726
+ const _hoisted_3$6 = { class: "badge bg-secondary m-1 sh-selected-item" };
1727
+ const _hoisted_4$6 = ["onClick"];
1728
+ const _hoisted_5$5 = ["id"];
1729
+ const _hoisted_6$3 = ["aria-labelledby"];
1730
+ const _hoisted_7$3 = { key: 0 };
1731
+ const _hoisted_8$2 = ["onClick"];
1732
+ const _hoisted_9$2 = {
1733
+ key: 1,
1734
+ class: "dropdown-item sh-suggest-no-results"
1735
+ };
1736
+ const _hoisted_10$3 = {
1737
+ key: 2,
1738
+ class: "dropdown-item sh-suggest-no-input"
1739
+ };
1740
+
1741
+
1742
+ var script$6 = {
1743
+ __name: 'ShSuggest',
1744
+ props: ['fillSelects','modelValue'],
1745
+ emits: ['update:modelValue'],
1746
+ setup(__props, { emit }) {
1747
+
1748
+ const props = __props;
1749
+
1750
+
1751
+
1752
+ let id = ref(null);
1753
+ ref(null);
1754
+ let suggestions = ref(null);
1755
+ let selectedSuggestions = ref([]);
1756
+ onMounted(() => {
1757
+ id.value = 'sid' + (Math.random() + 1).toString(36).substring(7);
1758
+ resetData();
1759
+ });
1760
+ function resetData(){
1761
+ if(props.fillSelects.data) {
1762
+ suggestions.value = props.fillSelects.data;
1763
+ }
1764
+ }
1765
+ function addSuggestion(sgn){
1766
+ let selected = selectedSuggestions.value;
1767
+ if(selected.length > 0 && !props.fillSelects.allow_multiple){
1768
+ selected = [];
1769
+ }
1770
+ if(!selected.includes(sgn)){
1771
+ selected.push(sgn);
1772
+ selectedSuggestions.value = selected;
1773
+ }
1774
+ updateModelValue();
1775
+ document.getElementById('input_' + id.value).innerHTML = '';
1776
+ }
1777
+ function updateModelValue(){
1778
+ let selectedItems = selectedSuggestions.value;
1779
+ if(selectedItems.length === 0) {
1780
+ emit('update:modelValue', null);
1781
+ } else if (!props.fillSelects.allow_multiple) {
1782
+ emit('update:modelValue', selectedItems[0].id);
1783
+ } else {
1784
+ const ids = selectedItems.map(item => {
1785
+ return item.id
1786
+ });
1787
+ emit('update:modelValue', ids);
1788
+ }
1789
+ }
1790
+ function removeSuggestion(sgt){
1791
+ selectedSuggestions.value = selectedSuggestions.value.filter(selectedSgt=>{
1792
+ if(selectedSgt.id !== sgt) {
1793
+ return selectedSgt
1794
+ }
1795
+ });
1796
+ updateModelValue();
1797
+ }
1798
+ let searchText = ref(null);
1799
+ function filterData(e){
1800
+ let filterValue = e.target.innerText;
1801
+ searchText.value = filterValue;
1802
+ if(props.fillSelects.data) {
1803
+ suggestions.value = props.fillSelects.data.filter(item=>{
1804
+ if(item.name.toLowerCase().includes(filterValue.toLowerCase())){
1805
+ return item
1806
+ }
1807
+ });
1808
+ } else {
1809
+ apis.doGet(props.fillSelects.url, { all: 1,filter_value: filterValue }).then(res => {
1810
+ suggestions.value = res.data.data;
1811
+ }).catch(res => {
1812
+ console.log(res);
1813
+ });
1814
+ }
1815
+ }
1816
+
1817
+ return (_ctx, _cache) => {
1818
+ return (unref(id))
1819
+ ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
1820
+ createElementVNode("div", {
1821
+ id: unref(id),
1822
+ "data-bs-toggle": "dropdown",
1823
+ class: "form-control p-0 d-flex sh-suggest-control dropdown-toggle",
1824
+ "aria-expanded": "false"
1825
+ }, [
1826
+ createElementVNode("div", null, [
1827
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(selectedSuggestions), (sgt) => {
1828
+ return (openBlock(), createElementBlock("h5", _hoisted_3$6, [
1829
+ createTextVNode(toDisplayString(sgt.name) + " ", 1 /* TEXT */),
1830
+ createElementVNode("button", {
1831
+ onClick: $event => (removeSuggestion(sgt.id)),
1832
+ type: "button",
1833
+ class: "btn-close border-start border-1 ms-1",
1834
+ "aria-label": "Close"
1835
+ }, null, 8 /* PROPS */, _hoisted_4$6)
1836
+ ]))
1837
+ }), 256 /* UNKEYED_FRAGMENT */))
1838
+ ]),
1839
+ createElementVNode("div", {
1840
+ id: 'input_' + unref(id),
1841
+ contenteditable: "true",
1842
+ onInput: filterData,
1843
+ class: "flex-fill h-100 sh-suggestion-input"
1844
+ }, null, 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_5$5)
1845
+ ], 8 /* PROPS */, _hoisted_2$6),
1846
+ createElementVNode("ul", {
1847
+ class: "dropdown-menu w-100",
1848
+ "aria-labelledby": unref(id)
1849
+ }, [
1850
+ (unref(suggestions) && unref(suggestions).length > 0)
1851
+ ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(suggestions), (suggestion) => {
1852
+ return (openBlock(), createElementBlock(Fragment, {
1853
+ key: suggestion.id
1854
+ }, [
1855
+ (suggestion.name)
1856
+ ? (openBlock(), createElementBlock("li", _hoisted_7$3, [
1857
+ createElementVNode("a", {
1858
+ onClick: $event => (addSuggestion(suggestion)),
1859
+ class: normalizeClass(["dropdown-item", unref(selectedSuggestions).includes(suggestion) ? 'active':'']),
1860
+ href: "#"
1861
+ }, toDisplayString(suggestion.name ?? suggestion.text), 11 /* TEXT, CLASS, PROPS */, _hoisted_8$2)
1862
+ ]))
1863
+ : createCommentVNode("v-if", true)
1864
+ ], 64 /* STABLE_FRAGMENT */))
1865
+ }), 128 /* KEYED_FRAGMENT */))
1866
+ : (unref(searchText))
1867
+ ? (openBlock(), createElementBlock("li", _hoisted_9$2, " No results found "))
1868
+ : (openBlock(), createElementBlock("li", _hoisted_10$3, " Type to search... "))
1869
+ ], 8 /* PROPS */, _hoisted_6$3)
1870
+ ]))
1871
+ : createCommentVNode("v-if", true)
1872
+ }
1873
+ }
1874
+
1875
+ };
1876
+
1877
+ script$6.__scopeId = "data-v-043a2b8f";
1878
+ script$6.__file = "src/views/FormComponent/ShSuggest.vue";
1719
1879
 
1720
1880
  var script$5 = {
1721
1881
  name: 'ShForm',
1722
1882
  components: {
1723
- ShEditor: script$6,
1724
- ShPhone: script$7
1883
+ ShSuggest: script$6,
1884
+ ShEditor: script$7,
1885
+ ShPhone: script$8
1725
1886
  },
1726
1887
  props: [
1727
1888
  'action',
@@ -1751,7 +1912,8 @@ var script$5 = {
1751
1912
  users: [],
1752
1913
  allPlaceHolders: {},
1753
1914
  user: null,
1754
- allLabels: {}
1915
+ allLabels: {},
1916
+ suggests: []
1755
1917
  }
1756
1918
  },
1757
1919
  methods: {
@@ -1776,6 +1938,9 @@ var script$5 = {
1776
1938
  }
1777
1939
  },
1778
1940
  getFieldType: function (field) {
1941
+ if(this.suggests && this.suggests.includes(field)){
1942
+ return 'suggest'
1943
+ }
1779
1944
  if(this.editors && this.editors.includes(field)){
1780
1945
  return 'editor'
1781
1946
  }
@@ -1799,7 +1964,7 @@ var script$5 = {
1799
1964
  const mapLocations = ['building_location'];
1800
1965
  const files = ['file', 'logo'];
1801
1966
  const phones = ['phone'];
1802
- if (field.includes('_id') || this.selectData[field]) {
1967
+ if (this.selectData[field]) {
1803
1968
  return 'select'
1804
1969
  }
1805
1970
  if (field === 'email') {
@@ -1981,7 +2146,12 @@ var script$5 = {
1981
2146
  const selectData = {};
1982
2147
  if (this.fillSelects) {
1983
2148
  Object.keys(this.fillSelects).forEach(key => {
1984
- if (this.fillSelects[key].data) {
2149
+ if(this.fillSelects[key].suggest || this.fillSelects[key].suggests) {
2150
+ if (!this.suggests) {
2151
+ this.suggests = [];
2152
+ }
2153
+ this.suggests.push(key);
2154
+ } else if (this.fillSelects[key].data) {
1985
2155
  selectData[key] = this.fillSelects[key].data;
1986
2156
  this.selectData = selectData;
1987
2157
  console.log(this.selectData);
@@ -2039,7 +2209,7 @@ const _hoisted_15$2 = ["name", "onFocus", "onUpdate:modelValue"];
2039
2209
  const _hoisted_16$2 = ["name", "onFocus", "onUpdate:modelValue"];
2040
2210
  const _hoisted_17$2 = ["value"];
2041
2211
  const _hoisted_18$2 = {
2042
- key: 10,
2212
+ key: 11,
2043
2213
  class: "invalid-feedback"
2044
2214
  };
2045
2215
  const _hoisted_19$2 = {
@@ -2072,6 +2242,7 @@ const _hoisted_23$2 = {
2072
2242
 
2073
2243
  function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2074
2244
  const _component_ShPhone = resolveComponent("ShPhone");
2245
+ const _component_ShSuggest = resolveComponent("ShSuggest");
2075
2246
  const _component_ShEditor = resolveComponent("ShEditor");
2076
2247
 
2077
2248
  return (openBlock(), createElementBlock("form", _hoisted_1$5, [
@@ -2177,9 +2348,19 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2177
2348
  required: ""
2178
2349
  }, null, 8 /* PROPS */, ["country_code", "placeholder", "name", "onFocus", "class", "modelValue", "onUpdate:modelValue"]))
2179
2350
  : createCommentVNode("v-if", true),
2351
+ ($options.getFieldType(field) === 'suggest')
2352
+ ? (openBlock(), createBlock(_component_ShSuggest, {
2353
+ key: 6,
2354
+ "select-data": _ctx.selectData[field],
2355
+ "fill-selects": $props.fillSelects[field],
2356
+ class: normalizeClass(_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field),
2357
+ modelValue: _ctx.form_elements[field],
2358
+ "onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event)
2359
+ }, null, 8 /* PROPS */, ["select-data", "fill-selects", "class", "modelValue", "onUpdate:modelValue"]))
2360
+ : createCommentVNode("v-if", true),
2180
2361
  ($options.getFieldType(field) === 'editor')
2181
2362
  ? (openBlock(), createBlock(_component_ShEditor, {
2182
- key: 6,
2363
+ key: 7,
2183
2364
  placeholder: _ctx.allPlaceHolders[field] ? _ctx.allPlaceHolders[field] : '',
2184
2365
  name: field,
2185
2366
  onFocus: $event => ($options.removeErrors(field)),
@@ -2190,7 +2371,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2190
2371
  : createCommentVNode("v-if", true),
2191
2372
  ($options.getFieldType(field) === 'text')
2192
2373
  ? withDirectives((openBlock(), createElementBlock("input", {
2193
- key: 7,
2374
+ key: 8,
2194
2375
  disabled: $options.isDisabled(field),
2195
2376
  placeholder: field === 'phone_number' ? 'e.g 0712 345 678':'',
2196
2377
  name: field,
@@ -2204,7 +2385,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2204
2385
  : createCommentVNode("v-if", true),
2205
2386
  ($options.getFieldType(field) === 'textarea')
2206
2387
  ? withDirectives((openBlock(), createElementBlock("textarea", {
2207
- key: 8,
2388
+ key: 9,
2208
2389
  name: field,
2209
2390
  onFocus: $event => ($options.removeErrors(field)),
2210
2391
  class: normalizeClass([_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field, "form-control"]),
@@ -2215,7 +2396,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2215
2396
  : createCommentVNode("v-if", true),
2216
2397
  ($options.getFieldType(field) === 'select' && _ctx.selectData[field] != null)
2217
2398
  ? withDirectives((openBlock(), createElementBlock("select", {
2218
- key: 9,
2399
+ key: 10,
2219
2400
  name: field,
2220
2401
  onFocus: $event => ($options.removeErrors(field)),
2221
2402
  class: normalizeClass([_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field, "form-control"]),
@@ -2941,7 +3122,7 @@ var script$1 = {
2941
3122
  }
2942
3123
  };
2943
3124
 
2944
- const _hoisted_1$1 = { class: "auto-table mt-2" };
3125
+ const _hoisted_1$1 = { class: "auto-table" };
2945
3126
  const _hoisted_2$1 = {
2946
3127
  key: 0,
2947
3128
  class: "col-md-4 mb-2"
@@ -3666,4 +3847,4 @@ const useUserStore = defineStore('user-store', {
3666
3847
  }
3667
3848
  });
3668
3849
 
3669
- export { script$4 as ShCanvas, script$5 as ShForm, script$3 as ShModal, script$7 as ShPhone, script$1 as ShTable, script as ShTabs, apis as shApis, helpers as shRepo, shstorage as shStorage, useUserStore };
3850
+ export { script$4 as ShCanvas, script$5 as ShForm, script$3 as ShModal, script$8 as ShPhone, script$1 as ShTable, script as ShTabs, apis as shApis, helpers as shRepo, shstorage as shStorage, useUserStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "0.4.6",
3
+ "version": "0.5.2",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",
@@ -11,25 +11,35 @@
11
11
  "test": "echo \"Error: no test specifieds\" && exit 1",
12
12
  "build": "rollup -c",
13
13
  "docs:dev": "vuepress dev docs",
14
- "docs:build": "vuepress build docs"
14
+ "docs:build": "vuepress build docs",
15
+ "dev": "vite",
16
+ "serve": "vite"
15
17
  },
16
18
  "keywords": [],
17
19
  "author": "",
18
20
  "license": "ISC",
19
21
  "peerDependencies": {
22
+ "@tinymce/tinymce-vue": "^4.0.7",
20
23
  "axios": "^0.27.2",
21
24
  "moment": "^2.29.3",
22
25
  "nprogress": "^0.2.0",
23
26
  "pinia": "^2.0.13",
24
27
  "sweetalert2": "^11.4.14",
25
- "vue": "^3.2.37",
26
- "@tinymce/tinymce-vue": "^4.0.7"
28
+ "vue": "^3.2.37"
27
29
  },
28
30
  "devDependencies": {
31
+ "@vitejs/plugin-vue": "^3.0.3",
32
+ "bootstrap": "^5.2.0",
33
+ "bootstrap-icons": "^1.9.1",
29
34
  "rollup": "^2.75.7",
30
35
  "rollup-plugin-css-only": "^3.1.0",
31
36
  "rollup-plugin-peer-deps-external": "^2.2.4",
32
37
  "rollup-plugin-vue": "^6.0.0",
33
- "vuepress": "^2.0.0-beta.48"
38
+ "vite": "^3.0.7",
39
+ "vuepress": "^2.0.0-beta.48",
40
+ "rollup-plugin-dotenv": "^0.3.0"
41
+ },
42
+ "dependencies": {
43
+ "vue-router": "^4.1.4"
34
44
  }
35
45
  }