@iankibetsh/shframework 4.6.6 → 4.6.8

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.
@@ -1,36 +1,4 @@
1
1
 
2
- .sh-phone{
3
- display: flex;
4
- width: 100%;
5
- align-items: center;
6
- padding: 0 0.25rem;
7
- }
8
- .phone-country{
9
- width: 2rem;
10
- border: none;
11
- align-self: center;
12
- outline: none !important;
13
- padding: 0.4rem;
14
- border-right: 1px solid #0003;
15
- }
16
- .phone-number{
17
- width: calc(100% - 2.2rem);
18
- border: none;
19
- align-self: center;
20
- outline: none;
21
- margin-bottom: 0;
22
- padding: 0.4rem;
23
- }
24
- .sh-phone img{
25
- padding: 0.125rem;
26
- width: 2rem;
27
- height: 2rem;
28
- }
29
- .phone-number::placeholder{
30
- font-weight: 300;
31
- opacity: 0.5;
32
- }
33
-
34
2
  .colored-toast.swal2-icon-success {
35
3
  background-color: #a5dc86 !important;
36
4
  }
@@ -63,20 +31,36 @@
63
31
  color: white;
64
32
  }
65
33
 
66
- .sh-selected-item{
67
- line-height: unset!important;
34
+ .sh-phone{
35
+ display: flex;
36
+ width: 100%;
37
+ align-items: center;
38
+ padding: 0 0.25rem;
68
39
  }
69
- .sh-suggestion-input{
70
- padding: 0.375rem 0.75rem;
40
+ .phone-country{
41
+ width: 2rem;
42
+ border: none;
43
+ align-self: center;
44
+ outline: none !important;
45
+ padding: 0.4rem;
46
+ border-right: 1px solid #0003;
71
47
  }
72
- .sh-suggest{
73
- margin-bottom: 1rem;
74
- padding: 0rem 0rem;
48
+ .phone-number{
49
+ width: calc(100% - 2.2rem);
50
+ border: none;
51
+ align-self: center;
52
+ outline: none;
53
+ margin-bottom: 0;
54
+ padding: 0.4rem;
75
55
  }
76
- .sh-suggest-control::after{
77
- margin-top: auto;
78
- margin-bottom: auto;
79
- margin-right: 0.255em;
56
+ .sh-phone img{
57
+ padding: 0.125rem;
58
+ width: 2rem;
59
+ height: 2rem;
60
+ }
61
+ .phone-number::placeholder{
62
+ font-weight: 300;
63
+ opacity: 0.5;
80
64
  }
81
65
 
82
66
  .permissions-main {
@@ -111,6 +95,22 @@
111
95
  flex-grow: 1;
112
96
  }
113
97
 
98
+ .sh-selected-item{
99
+ line-height: unset!important;
100
+ }
101
+ .sh-suggestion-input{
102
+ padding: 0.375rem 0.75rem;
103
+ }
104
+ .sh-suggest{
105
+ margin-bottom: 1rem;
106
+ padding: 0rem 0rem;
107
+ }
108
+ .sh-suggest-control::after{
109
+ margin-top: auto;
110
+ margin-bottom: auto;
111
+ margin-right: 0.255em;
112
+ }
113
+
114
114
  .callout{
115
115
  --bs-link-color-rgb: 110,168,254;
116
116
  --bs-code-color: #e685b5;
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)],
@@ -4146,6 +4146,7 @@ const useUserStore = pinia.defineStore('user-store', {
4146
4146
  }
4147
4147
  return false
4148
4148
  };
4149
+ user.can = user.isAllowedTo;
4149
4150
  this.user = user;
4150
4151
  }).catch((reason) => {
4151
4152
  if (reason.response && reason.response.status) {
@@ -5741,7 +5742,8 @@ return (_ctx, _cache) => {
5741
5742
  (_ctx.selectedRecord)
5742
5743
  ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(action.canvasComponent), vue.mergeProps({
5743
5744
  key: 0,
5744
- onRecordUpdated: _ctx.reloadData
5745
+ onRecordUpdated: _ctx.reloadData,
5746
+ ref_for: true
5745
5747
  }, _ctx.cleanCanvasProps(action), { record: _ctx.selectedRecord }), null, 16 /* FULL_PROPS */, ["onRecordUpdated", "record"]))
5746
5748
  : vue.createCommentVNode("v-if", true)
5747
5749
  ]),
@@ -7190,8 +7192,55 @@ return (_ctx, _cache) => {
7190
7192
  script.__scopeId = "data-v-2911509a";
7191
7193
  script.__file = "src/lib/components/core/auth/ShAuth.vue";
7192
7194
 
7195
+ var isAllowedTo = {
7196
+ mounted(el, binding) {
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
+ }
7234
+ }
7235
+ }
7236
+ };
7237
+
7193
7238
  const ShFrontend = {
7194
7239
  install: (app, options) => {
7240
+
7241
+ // add user-can directive
7242
+ app.directive('if-user-can', isAllowedTo);
7243
+
7195
7244
  if(options.sessionTimeout){
7196
7245
  app.provide('sessionTimeout',options.sessionTimeout);
7197
7246
  shStorage.setItem('sessionTimeout',options.sessionTimeout);
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)],
@@ -4134,6 +4134,7 @@ const useUserStore = defineStore('user-store', {
4134
4134
  }
4135
4135
  return false
4136
4136
  };
4137
+ user.can = user.isAllowedTo;
4137
4138
  this.user = user;
4138
4139
  }).catch((reason) => {
4139
4140
  if (reason.response && reason.response.status) {
@@ -5729,7 +5730,8 @@ return (_ctx, _cache) => {
5729
5730
  (_ctx.selectedRecord)
5730
5731
  ? (openBlock(), createBlock(resolveDynamicComponent(action.canvasComponent), mergeProps({
5731
5732
  key: 0,
5732
- onRecordUpdated: _ctx.reloadData
5733
+ onRecordUpdated: _ctx.reloadData,
5734
+ ref_for: true
5733
5735
  }, _ctx.cleanCanvasProps(action), { record: _ctx.selectedRecord }), null, 16 /* FULL_PROPS */, ["onRecordUpdated", "record"]))
5734
5736
  : createCommentVNode("v-if", true)
5735
5737
  ]),
@@ -7178,8 +7180,55 @@ return (_ctx, _cache) => {
7178
7180
  script.__scopeId = "data-v-2911509a";
7179
7181
  script.__file = "src/lib/components/core/auth/ShAuth.vue";
7180
7182
 
7183
+ var isAllowedTo = {
7184
+ mounted(el, binding) {
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
+ }
7222
+ }
7223
+ }
7224
+ };
7225
+
7181
7226
  const ShFrontend = {
7182
7227
  install: (app, options) => {
7228
+
7229
+ // add user-can directive
7230
+ app.directive('if-user-can', isAllowedTo);
7231
+
7183
7232
  if(options.sessionTimeout){
7184
7233
  app.provide('sessionTimeout',options.sessionTimeout);
7185
7234
  shStorage.setItem('sessionTimeout',options.sessionTimeout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "4.6.6",
3
+ "version": "4.6.8",
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",