@iankibetsh/shframework 4.6.7 → 4.6.9

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
@@ -3613,7 +3613,7 @@ return (_ctx, _cache) => {
3613
3613
  : vue.createCommentVNode("v-if", true)
3614
3614
  ], 2 /* CLASS */))
3615
3615
  : vue.createCommentVNode("v-if", true),
3616
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(getFieldComponent(field)), vue.mergeProps(getComponentProps(field), {
3616
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(getFieldComponent(field)), vue.mergeProps({ ref_for: true }, getComponentProps(field), {
3617
3617
  isInvalid: typeof validationErrors.value[field.field] !== 'undefined',
3618
3618
  onClick: $event => (fieldChanged(field.field)),
3619
3619
  "onUpdate:modelValue": [$event => (fieldChanged(field.field)), $event => ((formFields.value[index].value) = $event)],
@@ -5742,7 +5742,8 @@ return (_ctx, _cache) => {
5742
5742
  (_ctx.selectedRecord)
5743
5743
  ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(action.canvasComponent), vue.mergeProps({
5744
5744
  key: 0,
5745
- onRecordUpdated: _ctx.reloadData
5745
+ onRecordUpdated: _ctx.reloadData,
5746
+ ref_for: true
5746
5747
  }, _ctx.cleanCanvasProps(action), { record: _ctx.selectedRecord }), null, 16 /* FULL_PROPS */, ["onRecordUpdated", "record"]))
5747
5748
  : vue.createCommentVNode("v-if", true)
5748
5749
  ]),
@@ -7193,10 +7194,43 @@ script.__file = "src/lib/components/core/auth/ShAuth.vue";
7193
7194
 
7194
7195
  var isAllowedTo = {
7195
7196
  mounted(el, binding) {
7196
- const {user} = pinia.storeToRefs(useUserStore());
7197
- if(!user.value.isAllowedTo(binding.value)){
7198
- // delete element
7199
- el.remove();
7197
+ const { user } = pinia.storeToRefs(useUserStore());
7198
+ el.permission = binding.value;
7199
+ if (!user.value.isAllowedTo(binding.value)) {
7200
+ // store a reference to the parent node and next sibling
7201
+ el.parentNodeRef = el.parentNode;
7202
+ el.nextSiblingRef = el.nextSibling;
7203
+ // create a comment node
7204
+ el.commentNode = document.createComment(`v-if-user-can`);
7205
+ // replace element with comment node
7206
+ el.parentNode.replaceChild(el.commentNode, el);
7207
+ }
7208
+ },
7209
+ updated(el, binding) {
7210
+ const { user } = pinia.storeToRefs(useUserStore());
7211
+ if (!user.value.isAllowedTo(binding.value)) {
7212
+ // if the element is not already replaced, replace it with comment node
7213
+ if (el.parentNode) {
7214
+ el.parentNodeRef = el.parentNode;
7215
+ el.nextSiblingRef = el.nextSibling;
7216
+ if (!el.commentNode) {
7217
+ el.commentNode = document.createComment(`v-if-user-can`);
7218
+ }
7219
+ el.parentNode.replaceChild(el.commentNode, el);
7220
+ }
7221
+ } else {
7222
+ // if the comment node is present, replace it with the original element
7223
+ if (el.commentNode && el.parentNodeRef) {
7224
+ if (el.nextSiblingRef) {
7225
+ el.parentNodeRef.insertBefore(el, el.nextSiblingRef);
7226
+ } else {
7227
+ el.parentNodeRef.appendChild(el);
7228
+ }
7229
+ // remove the comment node from the parent node
7230
+ el.parentNodeRef.removeChild(el.commentNode);
7231
+ // remove the reference to the comment node
7232
+ el.commentNode = null;
7233
+ }
7200
7234
  }
7201
7235
  }
7202
7236
  };
@@ -7320,32 +7354,29 @@ const useShFetch = (url, path, cacheKey) => {
7320
7354
  status.value = 'loading';
7321
7355
  if (cacheKey && shStorage.getItem(cacheKey)) {
7322
7356
  data.value = shStorage.getItem(cacheKey);
7357
+ }
7358
+ shApis.doGet(dataUrl ?? url).then(response => {
7323
7359
  status.value = 'success';
7324
- loading.value = false;
7325
- } else {
7326
- shApis.doGet(dataUrl ?? url).then(response => {
7327
- status.value = 'success';
7328
- let res = response.data;
7329
- if (path) {
7330
- let pathArr = path.split('.');
7331
- for (let i = 0; i < pathArr.length; i++) {
7332
- res = res[pathArr[i]];
7333
- }
7334
- }
7335
- data.value = res;
7336
- if (cacheKey) {
7337
- shStorage.setItem(cacheKey, res);
7360
+ let res = response.data;
7361
+ if (path) {
7362
+ let pathArr = path.split('.');
7363
+ for (let i = 0; i < pathArr.length; i++) {
7364
+ res = res[pathArr[i]];
7338
7365
  }
7366
+ }
7367
+ data.value = res;
7368
+ if (cacheKey) {
7369
+ shStorage.setItem(cacheKey, res);
7370
+ }
7371
+ })
7372
+ .catch(res => {
7373
+ status.value = 'error';
7374
+ error.value = res.message ? res.message : (res.error ? res.error : 'An unexpected error occurred');
7375
+ shRepo.showToast(error.value, 'error');
7339
7376
  })
7340
- .catch(res => {
7341
- status.value = 'error';
7342
- error.value = res.message ? res.message : (res.error ? res.error : 'An unexpected error occurred');
7343
- shRepo.showToast(error.value, 'error');
7344
- })
7345
- .finally(() => {
7346
- loading.value = false;
7347
- });
7348
- }
7377
+ .finally(() => {
7378
+ loading.value = false;
7379
+ });
7349
7380
  };
7350
7381
 
7351
7382
  return {
package/dist/library.mjs CHANGED
@@ -3601,7 +3601,7 @@ return (_ctx, _cache) => {
3601
3601
  : createCommentVNode("v-if", true)
3602
3602
  ], 2 /* CLASS */))
3603
3603
  : createCommentVNode("v-if", true),
3604
- (openBlock(), createBlock(resolveDynamicComponent(getFieldComponent(field)), mergeProps(getComponentProps(field), {
3604
+ (openBlock(), createBlock(resolveDynamicComponent(getFieldComponent(field)), mergeProps({ ref_for: true }, getComponentProps(field), {
3605
3605
  isInvalid: typeof validationErrors.value[field.field] !== 'undefined',
3606
3606
  onClick: $event => (fieldChanged(field.field)),
3607
3607
  "onUpdate:modelValue": [$event => (fieldChanged(field.field)), $event => ((formFields.value[index].value) = $event)],
@@ -5730,7 +5730,8 @@ return (_ctx, _cache) => {
5730
5730
  (_ctx.selectedRecord)
5731
5731
  ? (openBlock(), createBlock(resolveDynamicComponent(action.canvasComponent), mergeProps({
5732
5732
  key: 0,
5733
- onRecordUpdated: _ctx.reloadData
5733
+ onRecordUpdated: _ctx.reloadData,
5734
+ ref_for: true
5734
5735
  }, _ctx.cleanCanvasProps(action), { record: _ctx.selectedRecord }), null, 16 /* FULL_PROPS */, ["onRecordUpdated", "record"]))
5735
5736
  : createCommentVNode("v-if", true)
5736
5737
  ]),
@@ -7181,10 +7182,43 @@ script.__file = "src/lib/components/core/auth/ShAuth.vue";
7181
7182
 
7182
7183
  var isAllowedTo = {
7183
7184
  mounted(el, binding) {
7184
- const {user} = storeToRefs(useUserStore());
7185
- if(!user.value.isAllowedTo(binding.value)){
7186
- // delete element
7187
- el.remove();
7185
+ const { user } = storeToRefs(useUserStore());
7186
+ el.permission = binding.value;
7187
+ if (!user.value.isAllowedTo(binding.value)) {
7188
+ // store a reference to the parent node and next sibling
7189
+ el.parentNodeRef = el.parentNode;
7190
+ el.nextSiblingRef = el.nextSibling;
7191
+ // create a comment node
7192
+ el.commentNode = document.createComment(`v-if-user-can`);
7193
+ // replace element with comment node
7194
+ el.parentNode.replaceChild(el.commentNode, el);
7195
+ }
7196
+ },
7197
+ updated(el, binding) {
7198
+ const { user } = storeToRefs(useUserStore());
7199
+ if (!user.value.isAllowedTo(binding.value)) {
7200
+ // if the element is not already replaced, replace it with comment node
7201
+ if (el.parentNode) {
7202
+ el.parentNodeRef = el.parentNode;
7203
+ el.nextSiblingRef = el.nextSibling;
7204
+ if (!el.commentNode) {
7205
+ el.commentNode = document.createComment(`v-if-user-can`);
7206
+ }
7207
+ el.parentNode.replaceChild(el.commentNode, el);
7208
+ }
7209
+ } else {
7210
+ // if the comment node is present, replace it with the original element
7211
+ if (el.commentNode && el.parentNodeRef) {
7212
+ if (el.nextSiblingRef) {
7213
+ el.parentNodeRef.insertBefore(el, el.nextSiblingRef);
7214
+ } else {
7215
+ el.parentNodeRef.appendChild(el);
7216
+ }
7217
+ // remove the comment node from the parent node
7218
+ el.parentNodeRef.removeChild(el.commentNode);
7219
+ // remove the reference to the comment node
7220
+ el.commentNode = null;
7221
+ }
7188
7222
  }
7189
7223
  }
7190
7224
  };
@@ -7308,32 +7342,29 @@ const useShFetch = (url, path, cacheKey) => {
7308
7342
  status.value = 'loading';
7309
7343
  if (cacheKey && shStorage.getItem(cacheKey)) {
7310
7344
  data.value = shStorage.getItem(cacheKey);
7345
+ }
7346
+ shApis.doGet(dataUrl ?? url).then(response => {
7311
7347
  status.value = 'success';
7312
- loading.value = false;
7313
- } else {
7314
- shApis.doGet(dataUrl ?? url).then(response => {
7315
- status.value = 'success';
7316
- let res = response.data;
7317
- if (path) {
7318
- let pathArr = path.split('.');
7319
- for (let i = 0; i < pathArr.length; i++) {
7320
- res = res[pathArr[i]];
7321
- }
7322
- }
7323
- data.value = res;
7324
- if (cacheKey) {
7325
- shStorage.setItem(cacheKey, res);
7348
+ let res = response.data;
7349
+ if (path) {
7350
+ let pathArr = path.split('.');
7351
+ for (let i = 0; i < pathArr.length; i++) {
7352
+ res = res[pathArr[i]];
7326
7353
  }
7354
+ }
7355
+ data.value = res;
7356
+ if (cacheKey) {
7357
+ shStorage.setItem(cacheKey, res);
7358
+ }
7359
+ })
7360
+ .catch(res => {
7361
+ status.value = 'error';
7362
+ error.value = res.message ? res.message : (res.error ? res.error : 'An unexpected error occurred');
7363
+ shRepo.showToast(error.value, 'error');
7327
7364
  })
7328
- .catch(res => {
7329
- status.value = 'error';
7330
- error.value = res.message ? res.message : (res.error ? res.error : 'An unexpected error occurred');
7331
- shRepo.showToast(error.value, 'error');
7332
- })
7333
- .finally(() => {
7334
- loading.value = false;
7335
- });
7336
- }
7365
+ .finally(() => {
7366
+ loading.value = false;
7367
+ });
7337
7368
  };
7338
7369
 
7339
7370
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "4.6.7",
3
+ "version": "4.6.9",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",
@@ -30,7 +30,7 @@
30
30
  "nprogress": "^0.2.0",
31
31
  "pinia": "^2.0.22",
32
32
  "sweetalert2": "^11.10.5",
33
- "vue": "^3.2.37"
33
+ "vue": "^3.4.27"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@vitejs/plugin-vue": "^3.2.0",