@iankibetsh/shframework 1.5.4 → 1.5.6

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
@@ -3107,6 +3107,7 @@ var script$e = {
3107
3107
  'helperTexts','labels','data',
3108
3108
  'actionLabel',
3109
3109
  'textAreas',
3110
+ 'currentData',
3110
3111
  'emails',
3111
3112
  'phones','numbers','selects','dates'
3112
3113
  ],
@@ -3119,6 +3120,9 @@ const props = __props;
3119
3120
 
3120
3121
  const formFields = vue.ref([]);
3121
3122
  const getFieldComponent = (fieldObj)=>{
3123
+ if(fieldObj.component){
3124
+ return fieldObj.component
3125
+ }
3122
3126
  const field = fieldObj.field;
3123
3127
  const defaultTextareas = ['message', 'meta_description', 'comment', 'call_response', 'comments', 'description'];
3124
3128
  const defaultNumbers = ['age'];
@@ -3226,14 +3230,28 @@ const submitForm = e => {
3226
3230
  return false
3227
3231
  };
3228
3232
  const submitBtnWidth = vue.ref(null);
3233
+ const setExistingData = ()=>{
3234
+ console.log(props.currentData, formFields.value);
3235
+ const existingData = props.currentData;
3236
+ if (props.currentData) {
3237
+ formFields.value.map(field=>{
3238
+ existingData[field.field] && (field.value = existingData[field.field]);
3239
+ });
3240
+ }
3241
+ };
3242
+ vue.watch(()=>props.currentData,()=>{
3243
+ setExistingData();
3244
+ });
3229
3245
  vue.onMounted((ev)=>{
3230
3246
  props.fields && props.fields.map(field=>{
3231
3247
  if(typeof field === 'object') {
3232
3248
  const fieldObj = {...field};
3233
- fieldObj.label && getLabel(fieldObj.field);
3234
- !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field);
3235
- fieldObj.helperText === undefined && (fieldObj.label = getLabel(fieldObj.field));
3236
- fieldObj.placeholder && fieldObj.placeHolder && getPlaceholder(fieldObj.field);
3249
+ // fieldObj.label && getLabel(fieldObj.field)
3250
+ fieldObj.helper = fieldObj.helperText ?? fieldObj.helper;
3251
+ // !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field)
3252
+ // fieldObj.helperText === undefined && ()
3253
+ fieldObj.label = fieldObj.label ?? getLabel(fieldObj.field);
3254
+ // fieldObj.placeholder && fieldObj.placeHolder && getPlaceholder(fieldObj.field)
3237
3255
  fieldObj.value = null;
3238
3256
  formFields.value.push(fieldObj);
3239
3257
  } else {
@@ -3245,6 +3263,7 @@ vue.onMounted((ev)=>{
3245
3263
  });
3246
3264
  }
3247
3265
  });
3266
+ setExistingData();
3248
3267
  });
3249
3268
 
3250
3269
 
@@ -3274,9 +3293,8 @@ return (_ctx, _cache) => {
3274
3293
  onClick: $event => (removeValidationError(field.field)),
3275
3294
  "onUpdate:modelValue": [$event => (removeValidationError(field.field)), $event => ((formFields.value[index].value) = $event)],
3276
3295
  modelValue: formFields.value[index].value,
3277
- placeholder: vue.unref(isFloating) ? field.label:field.placeholder,
3278
3296
  class: getComponentClass(field.field)
3279
- }), null, 16 /* FULL_PROPS */, ["isInvalid", "onClick", "onUpdate:modelValue", "modelValue", "placeholder", "class"])),
3297
+ }), null, 16 /* FULL_PROPS */, ["isInvalid", "onClick", "onUpdate:modelValue", "modelValue", "class"])),
3280
3298
  (vue.unref(isFloating) && field.label)
3281
3299
  ? (vue.openBlock(), vue.createElementBlock("label", {
3282
3300
  key: 1,
@@ -3296,7 +3314,9 @@ return (_ctx, _cache) => {
3296
3314
  key: 3,
3297
3315
  class: vue.normalizeClass(getElementClass('invalidFeedback'))
3298
3316
  }, vue.toDisplayString(validationErrors.value[field.field]), 3 /* TEXT, CLASS */))
3299
- : vue.createCommentVNode("v-if", true)
3317
+ : vue.createCommentVNode("v-if", true),
3318
+ vue.createCommentVNode(" <h5>{{ getFieldComponent(field) }}</h5>"),
3319
+ vue.createCommentVNode(" <h5>{{ getComponentProps(field) }}</h5>")
3300
3320
  ], 2 /* CLASS */))
3301
3321
  }), 128 /* KEYED_FRAGMENT */)),
3302
3322
  vue.createElementVNode("div", {
package/dist/library.mjs CHANGED
@@ -2,7 +2,7 @@ import Axios from 'axios';
2
2
  import moment from 'moment';
3
3
  import Swal from 'sweetalert2';
4
4
  import NProgress from 'nprogress';
5
- import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, resolveComponent, withModifiers, createVNode, ref, onMounted, unref, normalizeClass, createBlock, resolveDynamicComponent, inject, mergeProps, normalizeStyle, renderSlot, normalizeProps, guardReactiveProps, withCtx, createStaticVNode, shallowRef, vModelCheckbox, pushScopeId, popScopeId, computed, isRef, watch } from 'vue';
5
+ import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, resolveComponent, withModifiers, createVNode, ref, onMounted, unref, normalizeClass, createBlock, resolveDynamicComponent, inject, watch, mergeProps, normalizeStyle, renderSlot, normalizeProps, guardReactiveProps, withCtx, createStaticVNode, shallowRef, vModelCheckbox, pushScopeId, popScopeId, computed, isRef } from 'vue';
6
6
  import Editor from '@tinymce/tinymce-vue';
7
7
  import _ from 'lodash';
8
8
  import { useRoute, useRouter } from 'vue-router';
@@ -3094,6 +3094,7 @@ var script$e = {
3094
3094
  'helperTexts','labels','data',
3095
3095
  'actionLabel',
3096
3096
  'textAreas',
3097
+ 'currentData',
3097
3098
  'emails',
3098
3099
  'phones','numbers','selects','dates'
3099
3100
  ],
@@ -3106,6 +3107,9 @@ const props = __props;
3106
3107
 
3107
3108
  const formFields = ref([]);
3108
3109
  const getFieldComponent = (fieldObj)=>{
3110
+ if(fieldObj.component){
3111
+ return fieldObj.component
3112
+ }
3109
3113
  const field = fieldObj.field;
3110
3114
  const defaultTextareas = ['message', 'meta_description', 'comment', 'call_response', 'comments', 'description'];
3111
3115
  const defaultNumbers = ['age'];
@@ -3213,14 +3217,28 @@ const submitForm = e => {
3213
3217
  return false
3214
3218
  };
3215
3219
  const submitBtnWidth = ref(null);
3220
+ const setExistingData = ()=>{
3221
+ console.log(props.currentData, formFields.value);
3222
+ const existingData = props.currentData;
3223
+ if (props.currentData) {
3224
+ formFields.value.map(field=>{
3225
+ existingData[field.field] && (field.value = existingData[field.field]);
3226
+ });
3227
+ }
3228
+ };
3229
+ watch(()=>props.currentData,()=>{
3230
+ setExistingData();
3231
+ });
3216
3232
  onMounted((ev)=>{
3217
3233
  props.fields && props.fields.map(field=>{
3218
3234
  if(typeof field === 'object') {
3219
3235
  const fieldObj = {...field};
3220
- fieldObj.label && getLabel(fieldObj.field);
3221
- !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field);
3222
- fieldObj.helperText === undefined && (fieldObj.label = getLabel(fieldObj.field));
3223
- fieldObj.placeholder && fieldObj.placeHolder && getPlaceholder(fieldObj.field);
3236
+ // fieldObj.label && getLabel(fieldObj.field)
3237
+ fieldObj.helper = fieldObj.helperText ?? fieldObj.helper;
3238
+ // !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field)
3239
+ // fieldObj.helperText === undefined && ()
3240
+ fieldObj.label = fieldObj.label ?? getLabel(fieldObj.field);
3241
+ // fieldObj.placeholder && fieldObj.placeHolder && getPlaceholder(fieldObj.field)
3224
3242
  fieldObj.value = null;
3225
3243
  formFields.value.push(fieldObj);
3226
3244
  } else {
@@ -3232,6 +3250,7 @@ onMounted((ev)=>{
3232
3250
  });
3233
3251
  }
3234
3252
  });
3253
+ setExistingData();
3235
3254
  });
3236
3255
 
3237
3256
 
@@ -3261,9 +3280,8 @@ return (_ctx, _cache) => {
3261
3280
  onClick: $event => (removeValidationError(field.field)),
3262
3281
  "onUpdate:modelValue": [$event => (removeValidationError(field.field)), $event => ((formFields.value[index].value) = $event)],
3263
3282
  modelValue: formFields.value[index].value,
3264
- placeholder: unref(isFloating) ? field.label:field.placeholder,
3265
3283
  class: getComponentClass(field.field)
3266
- }), null, 16 /* FULL_PROPS */, ["isInvalid", "onClick", "onUpdate:modelValue", "modelValue", "placeholder", "class"])),
3284
+ }), null, 16 /* FULL_PROPS */, ["isInvalid", "onClick", "onUpdate:modelValue", "modelValue", "class"])),
3267
3285
  (unref(isFloating) && field.label)
3268
3286
  ? (openBlock(), createElementBlock("label", {
3269
3287
  key: 1,
@@ -3283,7 +3301,9 @@ return (_ctx, _cache) => {
3283
3301
  key: 3,
3284
3302
  class: normalizeClass(getElementClass('invalidFeedback'))
3285
3303
  }, toDisplayString(validationErrors.value[field.field]), 3 /* TEXT, CLASS */))
3286
- : createCommentVNode("v-if", true)
3304
+ : createCommentVNode("v-if", true),
3305
+ createCommentVNode(" <h5>{{ getFieldComponent(field) }}</h5>"),
3306
+ createCommentVNode(" <h5>{{ getComponentProps(field) }}</h5>")
3287
3307
  ], 2 /* CLASS */))
3288
3308
  }), 128 /* KEYED_FRAGMENT */)),
3289
3309
  createElementVNode("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",