@bagelink/vue 0.0.518 → 0.0.524

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.
@@ -2,70 +2,78 @@
2
2
  import { onMounted, onUnmounted, watch } from 'vue'
3
3
 
4
4
  const props = defineProps({
5
- autoHeight: { type: Boolean, default: false },
6
- allowScroll: { type: Boolean, default: true },
7
- freeDrag: { type: Boolean, default: true },
8
- items: { type: Number, default: 4 },
9
- index: { type: Number, default: 0 },
10
- autoplay: { type: Boolean, default: false },
11
- autoplaySpeed: { type: Number, default: 3000 },
12
- loop: { type: Boolean, default: false },
5
+ autoHeight: {
6
+ type: Boolean,
7
+ default: false,
8
+ },
9
+ allowScroll: {
10
+ type: Boolean,
11
+ default: true,
12
+ },
13
+ freeDrag: {
14
+ type: Boolean,
15
+ default: true,
16
+ },
17
+ items: {
18
+ type: Number,
19
+ default: 4,
20
+ },
21
+ index: {
22
+ type: Number,
23
+ default: 0,
24
+ },
13
25
  })
14
-
15
26
  const emit = defineEmits(['update:index'])
16
-
17
- const bglSlider = $ref<HTMLElement | null>(null)
27
+ const bglSlider = $ref<HTMLElement>()
18
28
  let activeSlideIndex = $ref(0)
19
29
  let isDragging = $ref(false)
20
30
  let startX = $ref(0)
21
31
  let scrollLeft = $ref(0)
22
32
  let isPressed = $ref(false)
23
- let yHeight = $ref('auto')
24
- let autoplayInterval = $ref<ReturnType<typeof setInterval> | null>(null)
25
- let originalSlideCount = $ref(0)
26
33
 
27
34
  function disableDrag() {
28
- bglSlider?.querySelectorAll('img').forEach((e) => { e.setAttribute('draggable', 'false') })
35
+ bglSlider
36
+ ?.querySelectorAll('img')
37
+ .forEach((e) => { e.setAttribute('draggable', 'false') })
38
+
29
39
  for (const e of (bglSlider?.children as any[] | undefined) || []) {
30
40
  e.setAttribute('draggable', 'false')
31
- e.addEventListener('click', (el: any) => el.preventDefault())
41
+ e.addEventListener('click', (e: any) => e.preventDefault())
32
42
  }
33
43
  }
34
44
 
45
+ let yHeight = $ref('auto')
35
46
  function evalHeight() {
36
47
  if (!props.autoHeight || !bglSlider) return
37
- const height = Array.from(bglSlider.children[activeSlideIndex].children)
48
+ const slidChildren = bglSlider.children[activeSlideIndex].children
49
+ const height = Array.from(slidChildren)
38
50
  .map(el => el.clientHeight)
39
51
  .reduce((a, b) => a + b, 0)
52
+
40
53
  yHeight = `${height}px`
41
54
  }
42
55
 
43
- function goToSlide(index: number, behavior: ScrollBehavior = 'smooth') {
44
- if (!bglSlider) return
45
- if (props.loop) {
46
- if (index >= originalSlideCount) {
47
- index = index % originalSlideCount
48
- behavior = 'auto'
49
- } else if (index < 0) {
50
- index = originalSlideCount - (-index % originalSlideCount)
51
- behavior = 'auto'
52
- }
53
- }
54
-
56
+ function goToSlide(index: number) {
57
+ if (!bglSlider || index < 0 || index > bglSlider.children.length - 1) return
58
+ const slider = bglSlider
55
59
  const isRTL = getComputedStyle(bglSlider).direction === 'rtl'
56
- const scrollX = bglSlider.offsetWidth * index * (isRTL ? -1 : 1)
57
- bglSlider.scrollTo({ left: scrollX, behavior })
60
+ const scrollX = slider.offsetWidth * index * (isRTL ? -1 : 1)
61
+ slider.scrollTo({ left: scrollX, behavior: 'smooth' })
58
62
  activeSlideIndex = index
59
63
  evalHeight()
60
64
  }
61
65
 
62
- watch(() => props.index, (index) => { goToSlide(index) })
66
+ watch(() => props.index, goToSlide)
63
67
 
64
- watch(() => activeSlideIndex, (index) => { emit('update:index', index) })
68
+ watch(
69
+ () => activeSlideIndex,
70
+ (index) => { emit('update:index', index) }
71
+ )
65
72
 
66
73
  function scrollEnd() {
67
- if (props.items !== 1 || !bglSlider) return
68
- const nextSlide = Math.round(bglSlider.scrollLeft / bglSlider.offsetWidth)
74
+ const slider = bglSlider
75
+ if (!slider || props.items !== 1) return
76
+ const nextSlide = Math.round(slider.scrollLeft / slider.offsetWidth)
69
77
  goToSlide(nextSlide)
70
78
  }
71
79
 
@@ -74,10 +82,11 @@ function stopDragging(e: MouseEvent) {
74
82
  const slider = bglSlider
75
83
  if (!slider) return
76
84
  const isDragForward = startX > e.pageX + slider.offsetLeft
77
- activeSlideIndex = isDragForward
78
- ? Math.ceil(slider.scrollLeft / slider.offsetWidth)
79
- : Math.floor(slider.scrollLeft / slider.offsetWidth)
85
+ if (isDragForward)
86
+ activeSlideIndex = Math.ceil(slider.scrollLeft / slider.offsetWidth)
87
+ else activeSlideIndex = Math.floor(slider.scrollLeft / slider.offsetWidth)
80
88
  if (props.items === 1) goToSlide(activeSlideIndex)
89
+ startX = 0
81
90
  document.removeEventListener('mousemove', move)
82
91
  document.removeEventListener('mouseup', stopDragging)
83
92
  document.removeEventListener('dragend', stopDragging)
@@ -87,9 +96,11 @@ function stopDragging(e: MouseEvent) {
87
96
  function move(e: MouseEvent) {
88
97
  if (!bglSlider) return
89
98
  const x = e.pageX - bglSlider.offsetLeft
90
- if (Math.abs(x - startX) > 20) isDragging = true
99
+ const walk = x - startX
100
+ if (walk > 20 || walk < -20) isDragging = true
91
101
  if (!isDragging) return
92
- bglSlider.scrollLeft = scrollLeft - (x - startX)
102
+ const scroll = x - startX
103
+ bglSlider.scrollLeft = scrollLeft - scroll
93
104
  }
94
105
 
95
106
  function startDragging(e: MouseEvent) {
@@ -103,85 +114,57 @@ function startDragging(e: MouseEvent) {
103
114
  }
104
115
 
105
116
  function next() {
106
- if (bglSlider) {
107
- goToSlide(activeSlideIndex + 1)
108
- }
117
+ if (!bglSlider) return
118
+ const slideCount = bglSlider.children.length
119
+ const isLastSlide = activeSlideIndex >= slideCount - 1
120
+ if (isLastSlide) goToSlide(0)
121
+ else goToSlide(activeSlideIndex + 1)
109
122
  }
110
123
 
111
124
  function prev() {
112
- if (bglSlider) {
113
- goToSlide(activeSlideIndex - 1)
114
- }
125
+ if (!bglSlider) return
126
+ const slideCount = bglSlider.children.length
127
+ if (activeSlideIndex === 0) goToSlide(slideCount - 1)
128
+ else goToSlide(activeSlideIndex - 1)
115
129
  }
116
130
 
117
131
  function evalWidth() {
118
- if (bglSlider) goToSlide(activeSlideIndex)
119
- }
120
-
121
- function startAutoplay() {
122
- if (props.autoplay) {
123
- autoplayInterval = setInterval(next, props.autoplaySpeed)
124
- }
125
- }
126
-
127
- function stopAutoplay() {
128
- if (autoplayInterval) {
129
- clearInterval(autoplayInterval)
130
- autoplayInterval = null
131
- }
132
- }
133
-
134
- function cloneSlides() {
135
- if (!bglSlider || !props.loop) return
136
- const slides = Array.from(bglSlider.children)
137
- originalSlideCount = slides.length
138
- slides.forEach((slide) => {
139
- const clone = slide.cloneNode(true) as HTMLElement
140
- bglSlider.appendChild(clone)
141
- })
142
- slides.forEach((slide) => {
143
- const clone = slide.cloneNode(true) as HTMLElement
144
- bglSlider.insertBefore(clone, bglSlider.firstChild)
145
- })
132
+ if (!bglSlider) return
133
+ goToSlide(activeSlideIndex)
146
134
  }
147
135
 
148
136
  onMounted(() => {
149
- cloneSlides()
150
137
  window.addEventListener('resize', evalWidth)
151
138
  evalHeight()
152
139
  disableDrag()
153
- startAutoplay()
154
140
  })
155
141
 
156
- onUnmounted(() => {
157
- window.removeEventListener('resize', evalWidth)
158
- stopAutoplay()
159
- })
142
+ onUnmounted(() => { window.removeEventListener('resize', evalWidth) })
160
143
  </script>
161
144
 
162
145
  <template>
163
- <div class="BglCarousel" :style="{ height: yHeight }" :class="{ autoHeight: props.autoHeight }">
146
+ <div class="BglCarousel" :style="{ height: yHeight }" :class="{ autoHeight }">
164
147
  <div
165
148
  ref="bglSlider"
166
- class="bgl-slider" :class="[
167
- { dragging: isDragging, clicking: isPressed, [`slides-${props.items}`]: true, allowScroll: props.allowScroll },
168
- ]"
149
+ :class="{
150
+ dragging: isDragging,
151
+ clicking: isPressed,
152
+ [`slides-${items}`]: true,
153
+ allowScroll,
154
+ }"
155
+ class="bgl-slider"
169
156
  @scrollend="scrollEnd"
170
157
  @mousedown="startDragging"
171
- @mouseenter="stopAutoplay"
172
- @mouseleave="startAutoplay"
173
- @focusin="stopAutoplay"
174
- @focusout="startAutoplay"
175
158
  >
176
159
  <div v-if="isDragging" class="blocker" />
177
160
  <slot />
178
161
  </div>
179
162
  <div class="Handlers">
180
163
  <span @click="prev">
181
- <slot name="prev" :index="activeSlideIndex" />
164
+ <slot :prev :index="activeSlideIndex" name="prev" />
182
165
  </span>
183
166
  <span @click="next">
184
- <slot name="next" :index="activeSlideIndex" />
167
+ <slot :next :index="activeSlideIndex" name="next" />
185
168
  </span>
186
169
  </div>
187
170
  </div>
@@ -189,99 +172,99 @@ onUnmounted(() => {
189
172
 
190
173
  <style scoped>
191
174
  .blocker {
192
- position: fixed;
193
- top: 0;
194
- left: 0;
195
- width: 100%;
196
- height: 100%;
197
- z-index: 100;
175
+ position: fixed;
176
+ top: 0;
177
+ left: 0;
178
+ width: 100%;
179
+ height: 100%;
180
+ z-index: 100;
198
181
  }
199
182
 
200
183
  .bgl-slider {
201
- display: grid;
202
- position: relative;
203
- scroll-behavior: smooth;
204
- grid-auto-flow: column;
205
- grid-auto-columns: 100%;
206
- scroll-snap-type: x mandatory;
207
- overflow-x: hidden;
184
+ display: grid;
185
+ position: relative;
186
+ scroll-behavior: smooth;
187
+ grid-auto-flow: column;
188
+ grid-auto-columns: 100%;
189
+ scroll-snap-type: x mandatory;
190
+ overflow-x: hidden;
208
191
  }
209
192
 
210
193
  .autoHeight {
211
- transition: height ease 0.7s;
194
+ transition: height ease 0.7s;
212
195
  }
213
196
 
214
197
  .bgl-slider.allowScroll {
215
- overflow-x: scroll;
198
+ overflow-x: scroll;
216
199
  }
217
200
 
218
201
  .bgl-slider.slides-6 {
219
- grid-auto-columns: 15.9%;
220
- gap: 1%;
202
+ grid-auto-columns: 15.9%;
203
+ gap: 1%;
221
204
  }
222
205
 
223
206
  .bgl-slider.slides-5 {
224
- grid-auto-columns: 19.3%;
225
- gap: 1%;
207
+ grid-auto-columns: 19.3%;
208
+ gap: 1%;
226
209
  }
227
210
 
228
211
  .bgl-slider.slides-4 {
229
- grid-auto-columns: 25%;
230
- gap: 1%;
231
- }
212
+ grid-auto-columns: 24.3%;
213
+ gap: 1%;
214
+ }
232
215
 
233
216
  .bgl-slider.slides-3 {
234
- grid-auto-columns: 33%;
235
- gap: 1%;
217
+ grid-auto-columns: 33%;
218
+ gap: 1%;
236
219
  }
237
220
 
238
221
  .bgl-slider.slides-2 {
239
- grid-auto-columns: 50%;
240
- gap: 1%;
222
+ grid-auto-columns: 50%;
223
+ gap: 1%;
241
224
  }
242
225
 
243
226
  .bgl-slider.slides-1 {
244
- grid-auto-columns: 100%;
227
+ grid-auto-columns: 100%;
245
228
  }
246
229
 
247
230
  .bgl-slider::-webkit-scrollbar {
248
- display: none;
231
+ display: none;
249
232
  }
250
233
 
251
234
  .bgl-slider * {
252
- scroll-snap-align: center;
235
+ scroll-snap-align: start;
253
236
  }
254
237
 
255
238
  .dragging.bgl-slider {
256
- cursor: grabbing;
257
- cursor: -webkit-grabbing;
258
- scroll-snap-type: unset;
239
+ cursor: grabbing;
240
+ cursor: -webkit-grabbing;
241
+ scroll-snap-type: unset;
259
242
  }
260
243
 
261
244
  .clicking.bgl-slider {
262
- scroll-behavior: unset;
245
+ scroll-behavior: unset;
263
246
  }
264
247
 
265
248
  .dragging.bgl-slider * {
266
- scroll-snap-align: unset;
267
- user-select: none;
249
+ scroll-snap-align: unset;
250
+ user-select: none;
268
251
  }
269
252
 
270
253
  @media screen and (max-width: 1280px) {
271
- .bgl-slider.slides-4 {
272
- grid-auto-columns: 33%;
273
- }
254
+ .bgl-slider.slides-4 {
255
+ grid-auto-columns: 33%;
256
+ }
274
257
  }
275
258
 
276
259
  @media screen and (max-width: 991px) {
277
- .bgl-slider.slides-4 {
278
- grid-auto-columns: 50%;
279
- }
260
+ .bgl-slider.slides-4 {
261
+ grid-auto-columns: 50%;
262
+ }
280
263
  }
281
264
 
282
265
  @media screen and (max-width: 600px) {
283
- .bgl-slider.slides-4 {
284
- grid-auto-columns: 100%;
285
- }
266
+ .bgl-slider.slides-4 {
267
+ grid-auto-columns: 100%;
268
+ }
286
269
  }
287
270
  </style>
@@ -14,7 +14,7 @@ defineProps<{
14
14
  <component :is="to ? 'RouterLink' : 'div'" :to="to" class="flex list-item gap-1">
15
15
  <Avatar v-if="src || showAvatar" style="flex-basis: 1;" :name="title" :src="src" :size="40" />
16
16
  <div>
17
- <p class="no-margin ellipsis line-height-14">
17
+ <p class="no-margin ellipsis line-height-14 pb-025">
18
18
  {{ title }}
19
19
  <slot />
20
20
  </p>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup></script>
2
2
 
3
3
  <template>
4
- <div class="list-wrap bgl_card thin grid overflow-hidden h-100 p-0">
4
+ <div class="list-wrap bgl_card thin grid overflow-hidden h-100 pt-0 pb-05 px-0">
5
5
  <div class="p-1">
6
6
  <slot name="header" />
7
7
  </div>
@@ -96,7 +96,7 @@ const computedData = $computed(() => {
96
96
  return dta
97
97
  })
98
98
 
99
- function selectAll(event: PointerEvent) {
99
+ function _unused_SelectAll(event: PointerEvent) {
100
100
  const value = (event.target as HTMLInputElement).checked
101
101
  if (!value) {
102
102
  selected = []
@@ -229,7 +229,7 @@ th {
229
229
  top: 0;
230
230
  z-index: 2;
231
231
  background: var(--bgl-white);
232
- height: 50px;
232
+ /* height: 50px; */
233
233
  vertical-align: bottom;
234
234
  }
235
235
  .row.first-row input[type=checkbox]{
@@ -252,7 +252,7 @@ th {
252
252
 
253
253
  .col {
254
254
  white-space: nowrap;
255
- padding: 0.75rem 0.5rem;
255
+ padding: 0.75rem 1rem;
256
256
  transition: var(--bgl-transition);
257
257
  line-height: 1;
258
258
  align-items: center;
@@ -431,6 +431,39 @@
431
431
  box-shadow: 0 1px 5px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1) !important;
432
432
  }
433
433
 
434
+ .border-bottom {
435
+ border-bottom: 1px solid var(--border-color)
436
+ }
437
+
438
+ .border-top {
439
+ border-top: 1px solid var(--border-color)
440
+ }
441
+
442
+ .border-start {
443
+ border-inline-start: 1px solid var(--border-color)
444
+ }
445
+
446
+ .border-end {
447
+ border-inline-end: 1px solid var(--border-color)
448
+ }
449
+
450
+ .border-inner-bottom>* {
451
+ border-bottom: 1px solid var(--border-color)
452
+ }
453
+
454
+ .border-inner-top>* {
455
+ border-top: 1px solid var(--border-color)
456
+ }
457
+
458
+ .border-inner-start>* {
459
+ border-inline-start: 1px solid var(--border-color)
460
+ }
461
+
462
+ .border-inner-end>* {
463
+ border-inline-end: 1px solid var(--border-color)
464
+ }
465
+
466
+
434
467
 
435
468
  @media screen and (max-width: 910px) {
436
469
  .m_opacity-0 {
@@ -862,4 +895,37 @@
862
895
  box-shadow: 0 1px 5px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1) !important;
863
896
  }
864
897
 
898
+ .m_border-bottom {
899
+ border-bottom: 1px solid var(--border-color)
900
+ }
901
+
902
+ .m_border-top {
903
+ border-top: 1px solid var(--border-color)
904
+ }
905
+
906
+ .m_border-start {
907
+ border-inline-start: 1px solid var(--border-color)
908
+ }
909
+
910
+ .m_border-end {
911
+ border-inline-end: 1px solid var(--border-color)
912
+ }
913
+
914
+ .m_border-inner-bottom>* {
915
+ border-bottom: 1px solid var(--border-color)
916
+ }
917
+
918
+ .m_border-inner-top>* {
919
+ border-top: 1px solid var(--border-color)
920
+ }
921
+
922
+ .m_border-inner-start>* {
923
+ border-inline-start: 1px solid var(--border-color)
924
+ }
925
+
926
+ .m_border-inner-end>* {
927
+ border-inline-end: 1px solid var(--border-color)
928
+ }
929
+
930
+
865
931
  }
@@ -7,7 +7,7 @@
7
7
 
8
8
  ::-webkit-scrollbar-thumb {
9
9
  background-color: var(--bgl-gray);
10
- border-radius: 12px;
10
+ border-radius: 1rem;
11
11
  }
12
12
 
13
13
  ::-webkit-scrollbar-corner {
@@ -15,6 +15,8 @@ interface InputOptions {
15
15
  helptext?: string
16
16
  }
17
17
 
18
+ type DateOptions = InputOptions
19
+
18
20
  interface TextInputOptions extends InputOptions {
19
21
  type?: 'text' | 'tel' | 'email'
20
22
  pattern?: string
@@ -61,6 +63,7 @@ export function txtField(
61
63
  required: options?.required,
62
64
  id,
63
65
  label,
66
+ disabled: options?.disabled,
64
67
  placeholder: options?.placeholder,
65
68
  defaultValue: options?.defaultValue,
66
69
  attrs: {
@@ -108,6 +111,25 @@ export function checkField(
108
111
  }
109
112
  }
110
113
 
114
+ export function dateField(
115
+ id: string,
116
+ label?: string,
117
+ options?: DateOptions,
118
+ ): Field {
119
+ return {
120
+ $el: 'date',
121
+ class: options?.class,
122
+ required: options?.required,
123
+ id,
124
+ disabled: options?.disabled,
125
+ label,
126
+ defaultValue: options?.defaultValue,
127
+ attrs: {
128
+ disabled: options?.disabled,
129
+ },
130
+ }
131
+ }
132
+
111
133
  export function numField(
112
134
  id: string,
113
135
  label?: string,
@@ -120,6 +142,7 @@ export function numField(
120
142
  defaultValue: options?.defaultValue,
121
143
  id,
122
144
  label,
145
+ disabled: options?.disabled,
123
146
  placeholder: options?.placeholder,
124
147
  helptext: options?.helptext,
125
148
  attrs: {