@bagelink/vue 0.0.1104 → 0.0.1111

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/style.css CHANGED
@@ -1036,14 +1036,7 @@ pre code.hljs{
1036
1036
  }
1037
1037
  }
1038
1038
 
1039
- .img-web-kit[data-v-29509e85] {
1040
- max-width: 100%;
1041
- vertical-align: middle;
1042
- border: 0;
1043
- width: 100%;
1044
- }
1045
-
1046
- .fileUploadWrap[data-v-438b09e8] {
1039
+ .fileUploadWrap[data-v-133a8c7a] {
1047
1040
  outline: 1px solid var(--border-color);
1048
1041
  border-radius: var(--input-border-radius);
1049
1042
  text-align: center;
@@ -1055,7 +1048,7 @@ pre code.hljs{
1055
1048
  background: var(--input-bg);
1056
1049
  height: 215px;
1057
1050
  }
1058
- .bagel-input .fileUploadWrap.fileDropZone[data-v-438b09e8] {
1051
+ .bagel-input .fileUploadWrap.fileDropZone[data-v-133a8c7a] {
1059
1052
  background: var(--input-bg);
1060
1053
  display: flex;
1061
1054
  align-items: center;
@@ -1063,14 +1056,14 @@ pre code.hljs{
1063
1056
  color: var(--bgl-gray);
1064
1057
  flex-direction: column;
1065
1058
  }
1066
- .fileUploadWrap.dragover[data-v-438b09e8],
1067
- .fileUploadWrap[data-v-438b09e8]:hover {
1059
+ .fileUploadWrap.dragover[data-v-133a8c7a],
1060
+ .fileUploadWrap[data-v-133a8c7a]:hover {
1068
1061
  box-shadow: inset 0 0 10px #00000012;
1069
1062
  }
1070
- .fileUploadWrap[style*='height: auto;'][data-v-438b09e8] {
1063
+ .fileUploadWrap[style*='height: auto;'][data-v-133a8c7a] {
1071
1064
  min-height: 215px;
1072
1065
  }
1073
- .multi-image-item-preview[data-v-438b09e8] {
1066
+ .multi-image-item-preview[data-v-133a8c7a] {
1074
1067
  border: 1px solid var(--border-color) !important;
1075
1068
  border-radius: var(--input-border-radius);
1076
1069
  margin: 0.5rem !important;
@@ -1084,12 +1077,12 @@ pre code.hljs{
1084
1077
  gap: 1rem;
1085
1078
  align-items: center;
1086
1079
  }
1087
- .multi-image-item-preview p[data-v-438b09e8] {
1080
+ .multi-image-item-preview p[data-v-133a8c7a] {
1088
1081
  overflow: hidden;
1089
1082
  text-overflow: ellipsis;
1090
1083
  white-space: nowrap;
1091
1084
  }
1092
- .multi-preview[data-v-438b09e8] {
1085
+ .multi-preview[data-v-133a8c7a] {
1093
1086
  width: 40px;
1094
1087
  height: 40px;
1095
1088
  border-radius: var(--input-border-radius);
@@ -1100,17 +1093,17 @@ pre code.hljs{
1100
1093
  align-items: center;
1101
1094
  display: flex;
1102
1095
  }
1103
- .bgl-single-preview[data-v-438b09e8] {
1096
+ .bgl-single-preview[data-v-133a8c7a] {
1104
1097
  height: 100%;
1105
1098
  position: relative;
1106
1099
  }
1107
- .bgl-single-preview + .fileUploadPlaceHolder[data-v-438b09e8] {
1100
+ .bgl-single-preview + .fileUploadPlaceHolder[data-v-133a8c7a] {
1108
1101
  position: absolute;
1109
1102
  inset: 0;
1110
1103
  margin: auto;
1111
1104
  top: calc(50% - 2rem);
1112
1105
  }
1113
- .single-image-item-preview[data-v-438b09e8] {
1106
+ .single-image-item-preview[data-v-133a8c7a] {
1114
1107
  height: 100%;
1115
1108
  min-height: 100%;
1116
1109
  position: relative;
@@ -1118,13 +1111,13 @@ pre code.hljs{
1118
1111
  align-items: center;
1119
1112
  justify-content: center;
1120
1113
  }
1121
- .fileUploadWrap[style*='height: auto'] .single-image-item-preview[data-v-438b09e8] {
1114
+ .fileUploadWrap[style*='height: auto'] .single-image-item-preview[data-v-133a8c7a] {
1122
1115
  min-height: 215px;
1123
1116
  }
1124
- .fileUploadWrap[style*='height: auto'] .single-preview[data-v-438b09e8] {
1117
+ .fileUploadWrap[style*='height: auto'] .single-preview[data-v-133a8c7a] {
1125
1118
  margin: 0rem !important;
1126
1119
  }
1127
- .single-preview[data-v-438b09e8] {
1120
+ .single-preview[data-v-133a8c7a] {
1128
1121
  border-radius: var(--input-border-radius);
1129
1122
  margin: 1rem;
1130
1123
  padding: 0px;
@@ -1134,7 +1127,7 @@ pre code.hljs{
1134
1127
  background: var(--bgl-gray-light);
1135
1128
  width: 90%;
1136
1129
  }
1137
- .single-image-item-preview[data-v-438b09e8]:hover::after {
1130
+ .single-image-item-preview[data-v-133a8c7a]:hover::after {
1138
1131
  content: 'zoom_in';
1139
1132
  font-size: 32px;
1140
1133
  font-family: 'Material Symbols Outlined', serif;
@@ -1144,20 +1137,20 @@ pre code.hljs{
1144
1137
  z-index: 9;
1145
1138
  pointer-events: none;
1146
1139
  }
1147
- .single-image-item-preview:hover img[data-v-438b09e8] {
1140
+ .single-image-item-preview:hover img[data-v-133a8c7a] {
1148
1141
  filter: brightness(70%);
1149
1142
  }
1150
- .bgl_fill-image.single-image-item-preview[data-v-438b09e8] {
1143
+ .bgl_fill-image.single-image-item-preview[data-v-133a8c7a] {
1151
1144
  height: 100%;
1152
1145
  }
1153
- .bgl_fill-image.single-image-item-preview .single-preview[data-v-438b09e8] {
1146
+ .bgl_fill-image.single-image-item-preview .single-preview[data-v-133a8c7a] {
1154
1147
  border-radius: unset;
1155
1148
  object-fit: cover;
1156
1149
  box-shadow: unset;
1157
1150
  width: 100%;
1158
1151
  height: auto;
1159
1152
  }
1160
- .single-image-item-preview .pie[data-v-438b09e8] {
1153
+ .single-image-item-preview .pie[data-v-133a8c7a] {
1161
1154
  transform-origin: top;
1162
1155
  transform: scale(1.4);
1163
1156
  position: absolute;
@@ -1171,31 +1164,31 @@ pre code.hljs{
1171
1164
  border: none !important;
1172
1165
  padding: 0 !important;
1173
1166
  }
1174
- .bgl_oval-upload[data-v-438b09e8] {
1167
+ .bgl_oval-upload[data-v-133a8c7a] {
1175
1168
  border-radius: 100% !important;
1176
1169
  overflow: hidden;
1177
1170
  }
1178
- .bgl_oval-upload p[data-v-438b09e8] {
1171
+ .bgl_oval-upload p[data-v-133a8c7a] {
1179
1172
  padding: 0.75rem !important;
1180
1173
  font-size: 12px;
1181
1174
  }
1182
- .bgl_oval-upload .fileUploadPlaceHolder[data-v-438b09e8] {
1175
+ .bgl_oval-upload .fileUploadPlaceHolder[data-v-133a8c7a] {
1183
1176
  top: 0;
1184
1177
  }
1185
- .bgl_oval-upload .pie[data-v-438b09e8] {
1178
+ .bgl_oval-upload .pie[data-v-133a8c7a] {
1186
1179
  transform: scale(1);
1187
1180
  }
1188
- .bgl_oval-upload span.bgl_icon-font.color-primary[data-v-438b09e8] {
1181
+ .bgl_oval-upload span.bgl_icon-font.color-primary[data-v-133a8c7a] {
1189
1182
  transform: scale(0.4) !important;
1190
1183
  }
1191
- .bgl_oval-upload .single-image-item-preview[data-v-438b09e8] {
1184
+ .bgl_oval-upload .single-image-item-preview[data-v-133a8c7a] {
1192
1185
  height: 100%;
1193
1186
  }
1194
- .bgl_oval-upload .single-preview[data-v-438b09e8] {
1187
+ .bgl_oval-upload .single-preview[data-v-133a8c7a] {
1195
1188
  margin: 0;
1196
1189
  height: 100% !important;
1197
1190
  }
1198
- .pie[data-v-438b09e8] {
1191
+ .pie[data-v-133a8c7a] {
1199
1192
  width: 30px;
1200
1193
  height: 30px;
1201
1194
  position: relative;
@@ -1203,7 +1196,7 @@ pre code.hljs{
1203
1196
  align-items: center;
1204
1197
  justify-content: center;
1205
1198
  }
1206
- .pie[data-v-438b09e8]:before {
1199
+ .pie[data-v-133a8c7a]:before {
1207
1200
  content: '';
1208
1201
  position: absolute;
1209
1202
  border-radius: 50%;
@@ -1221,26 +1214,26 @@ pre code.hljs{
1221
1214
  #000 calc(100% - var(--b))
1222
1215
  );
1223
1216
  }
1224
- .pie .success[data-v-438b09e8] {
1217
+ .pie .success[data-v-133a8c7a] {
1225
1218
  transform: scale(0);
1226
1219
  opacity: 0;
1227
1220
  transition: all 0.3s ease-in-out;
1228
1221
  }
1229
- .pie .progress[data-v-438b09e8] {
1222
+ .pie .progress[data-v-133a8c7a] {
1230
1223
  position: absolute;
1231
1224
  font-size: 10px;
1232
1225
  }
1233
- .pie.complete .progress[data-v-438b09e8] {
1226
+ .pie.complete .progress[data-v-133a8c7a] {
1234
1227
  display: none;
1235
1228
  }
1236
- .pie.complete .success[data-v-438b09e8] {
1229
+ .pie.complete .success[data-v-133a8c7a] {
1237
1230
  transform: scale(1.3);
1238
1231
  opacity: 1;
1239
1232
  }
1240
- .pie.complete[data-v-438b09e8]:before {
1233
+ .pie.complete[data-v-133a8c7a]:before {
1241
1234
  background: conic-gradient(var(--bgl-green) calc(var(--p) * 1%), #0000 0);
1242
1235
  }
1243
- .pie.complete[data-v-438b09e8] {
1236
+ .pie.complete[data-v-133a8c7a] {
1244
1237
  color: var(--bgl-green);
1245
1238
  }
1246
1239
 
@@ -1251,14 +1244,14 @@ pre code.hljs{
1251
1244
  direction: ltr;
1252
1245
  }
1253
1246
 
1254
- .txtInputIconStart .iconStart[data-v-3a20cf4a] {
1247
+ .txtInputIconStart .iconStart[data-v-f265687e] {
1255
1248
  color: var(--input-color);
1256
1249
  position: absolute;
1257
1250
  inset-inline-start:calc(var(--input-height) / 3 - 0.25rem);
1258
1251
  margin-top: calc(var(--input-height) / 2 );
1259
1252
  line-height: 0;
1260
1253
  }
1261
- .textInputSpinnerWrap .spinner[data-v-3a20cf4a] {
1254
+ .textInputSpinnerWrap .spinner[data-v-f265687e] {
1262
1255
  color: var(--input-color);
1263
1256
  position: absolute;
1264
1257
  inset-inline-end: 0;
@@ -1268,18 +1261,18 @@ pre code.hljs{
1268
1261
  flex-direction: column;
1269
1262
  gap: 0;
1270
1263
  }
1271
- .top-bgl-ctrl-num-btn[data-v-3a20cf4a]{
1264
+ .top-bgl-ctrl-num-btn[data-v-f265687e]{
1272
1265
  margin-top: calc(var(--input-height) / 10) !important;
1273
1266
  }
1274
- .bgl-ctrl-num-btn[data-v-3a20cf4a]{
1267
+ .bgl-ctrl-num-btn[data-v-f265687e]{
1275
1268
  height: calc(var(--input-height) / 2.5) !important;
1276
1269
  isolation: isolate;
1277
1270
  }
1278
- .bgl-big-ctrl-num-btn[data-v-3a20cf4a]{
1271
+ .bgl-big-ctrl-num-btn[data-v-f265687e]{
1279
1272
  width: 100% !important;
1280
1273
  isolation: isolate;
1281
1274
  }
1282
- .bgl-number-input[data-v-3a20cf4a]{
1275
+ .bgl-number-input[data-v-f265687e]{
1283
1276
  padding-inline-end: 1.75rem !important;
1284
1277
  }
1285
1278
 
@@ -2130,6 +2123,13 @@ line-height: 1.65;
2130
2123
  color: var(--bgl-green);
2131
2124
  }
2132
2125
 
2126
+ .img-web-kit[data-v-29509e85] {
2127
+ max-width: 100%;
2128
+ vertical-align: middle;
2129
+ border: 0;
2130
+ width: 100%;
2131
+ }
2132
+
2133
2133
  .bgl_bottombar .bgl_btn-flex{
2134
2134
  flex-direction: column;
2135
2135
  height: 60px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.1104",
4
+ "version": "0.0.1111",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -13,10 +13,12 @@ import {
13
13
  classify,
14
14
  NumberInput,
15
15
  UploadInput,
16
+ type BagelFormState,
16
17
  BglForm
17
18
  } from '@bagelink/vue'
18
- import { useFormField } from '../../composables/useFormField'
19
+ import { inject } from 'vue'
19
20
  import TabsNav from '../layout/TabsNav.vue'
21
+ import { FORM_STATE_KEY, provideBagelFormState } from './useBagelFormState'
20
22
 
21
23
  const props = defineProps<{
22
24
  field: Field<T>
@@ -29,7 +31,7 @@ const emit = defineEmits<{
29
31
  'update:modelValue': [value: any]
30
32
  }>()
31
33
 
32
- const { fieldData } = useFormField(props)
34
+ const formState = inject<BagelFormState<T>>(FORM_STATE_KEY) ?? provideBagelFormState(props.modelValue)
33
35
 
34
36
  const customAttrs = $ref<{ [key: string]: any }>({})
35
37
 
@@ -53,17 +55,50 @@ const is = $computed(() => {
53
55
  return props.field.$el ?? 'div'
54
56
  })
55
57
 
58
+ const fieldData = $computed({
59
+ get: () => {
60
+ if (!props.fieldID) return props.field.defaultValue ?? (props.field.$el === 'form' ? {} : '')
61
+ const value = formState.getFieldData(props.fieldID)
62
+ if (props.field.$el === 'form' && !value) return {}
63
+ return value ?? ''
64
+ },
65
+ set: (val: any) => {
66
+ if (!props.fieldID) return
67
+ const currentValue = formState.getFieldData(props.fieldID)
68
+ if (JSON.stringify(val) === JSON.stringify(currentValue)) return
69
+
70
+ emit('update:modelValue', val)
71
+ if (props.field.onUpdate) {
72
+ props.field.onUpdate(val, currentValue)
73
+ }
74
+ formState.updateField(props.fieldID, val)
75
+ }
76
+ })
77
+
78
+ const vIf = $computed(() => {
79
+ if (props.field['v-if'] === undefined && props.field.vIf === undefined) return true
80
+ if (typeof props.field['v-if'] === 'boolean' || typeof props.field.vIf === 'boolean') return props.field['v-if']
81
+ if (typeof props.field['v-if'] === 'string' || typeof props.field.vIf === 'string') return true
82
+ if (typeof props.field['v-if'] === 'function') return props.field['v-if'](fieldData, formState.data.value as T)
83
+ if (typeof props.field.vIf === 'function') return props.field.vIf(fieldData, formState.data.value as T)
84
+ return true
85
+ })
86
+
87
+ // const computedFieldData = $computed(
88
+ // () => props.field.transform?.(fieldData, formState.data.value as T) ?? fieldData
89
+ // )
90
+
56
91
  const computedOptions = $computed(
57
- () => bindAttrs({ options: props.field.options }, fieldData, props.modelValue).options
92
+ () => bindAttrs({ options: props.field.options }, fieldData, formState.data.value).options
58
93
  )
59
94
 
60
95
  const computedAttrs = $computed(() => {
61
96
  const attrs = { ...customAttrs, ...props.field.attrs }
62
- return bindAttrs(attrs, fieldData, props.modelValue)
97
+ return bindAttrs(attrs, fieldData, formState.data.value)
63
98
  })
64
99
 
65
100
  const computedClass = $computed(
66
- () => classify(fieldData, props.modelValue, props.field.class, props.field.attrs?.class)
101
+ () => classify(fieldData, formState.data.value, props.field.class, props.field.attrs?.class)
67
102
  )
68
103
  </script>
69
104
 
@@ -71,7 +106,7 @@ const computedClass = $computed(
71
106
  <component
72
107
  v-bind="computedAttrs"
73
108
  :is="is"
74
- v-if="field.vIf === undefined || field.vIf"
109
+ v-if="vIf"
75
110
  v-model="fieldData"
76
111
  :fieldID="props.fieldID"
77
112
  :required="field.required"
@@ -6,14 +6,12 @@ import {
6
6
  type StorageFile,
7
7
  useBagel,
8
8
  Card,
9
+ Image,
9
10
  } from '@bagelink/vue'
10
11
  import { onMounted, watch } from 'vue'
11
- import Image from '../../Image.vue'
12
12
 
13
13
  type StrKey = keyof StorageFile
14
14
 
15
- type FSValue = string[] | string
16
-
17
15
  const {
18
16
  label,
19
17
  multiple,
@@ -34,7 +32,7 @@ const {
34
32
  multiple?: boolean
35
33
  files?: StorageFile | StorageFile[]
36
34
  bindkey?: StrKey
37
- modelValue?: FSValue
35
+ modelValue?: string[] | string
38
36
  width?: string
39
37
  height?: string | 'auto'
40
38
  topic?: string
@@ -62,8 +60,8 @@ interface QueueFile {
62
60
 
63
61
  const isImage = (str: string) => IMAGE_FORMATS_REGEXP.test(str)
64
62
 
65
- const file_bindkeys = defineModel('modelValue', {
66
- default: () => [] as FSValue,
63
+ const file_bindkeys = defineModel<string[] | string>('modelValue', {
64
+ default: () => [],
67
65
  })
68
66
  const storageFiles = $ref<StorageFile[]>([])
69
67
 
@@ -147,9 +145,9 @@ function compareLists(a: any, b: any) {
147
145
  }
148
146
 
149
147
  function updateModelValue() {
150
- let idValue: FSValue
148
+ let idValue: string | string[]
151
149
  if (multiple) {
152
- idValue = storageFiles.map(f => f[bindKey]) as FSValue
150
+ idValue = storageFiles.map(f => f[bindKey]) as string[]
153
151
  } else {
154
152
  idValue = (storageFiles[0][bindKey] as string) || ''
155
153
  }
@@ -104,7 +104,7 @@ watch(() => modelValue, (newVal) => {
104
104
  <label :for="id">
105
105
  {{ label }}
106
106
  <div class="gap-025" :class="{ 'column flex': layout === 'vertical', 'flex': layout === 'horizontal' }">
107
- <Btn v-if="layout && btnLayouts.includes(layout)" flat icon="add" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" @click="increment" />
107
+ <Btn v-if="layout && btnLayouts.includes(layout)" flat icon="add" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" tabindex="-1" @click="increment" />
108
108
 
109
109
  <input
110
110
  :id
@@ -138,10 +138,10 @@ watch(() => modelValue, (newVal) => {
138
138
  v-if="icon"
139
139
  :icon
140
140
  />
141
- <Btn v-if="layout && btnLayouts.includes(layout)" flat icon="remove" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" @click="decrement" />
141
+ <Btn v-if="layout && btnLayouts.includes(layout)" flat icon="remove" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" tabindex="-1" @click="decrement" />
142
142
  <div v-if="spinner && (!layout || !btnLayouts.includes(layout))" class="flex column spinner">
143
- <Btn icon="add" flat thin class="bgl-ctrl-num-btn ctrl-add color-gray top-bgl-ctrl-num-btn" :disabled="!canAdd" @click="increment" />
144
- <Btn icon="remove" flat thin class="bgl-ctrl-num-btn ctrl-remove color-gray" :disabled="!canDecrement" @click="decrement" />
143
+ <Btn icon="add" flat thin class="bgl-ctrl-num-btn ctrl-add color-gray top-bgl-ctrl-num-btn" :disabled="!canAdd" tabindex="-1" @click="increment" />
144
+ <Btn icon="remove" flat thin class="bgl-ctrl-num-btn ctrl-remove color-gray" :disabled="!canDecrement" tabindex="-1" @click="decrement" />
145
145
  </div>
146
146
  </div>
147
147
  </label>