@bagelink/vue 1.15.71 → 1.15.73

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.15.71",
4
+ "version": "1.15.73",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -1,7 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  import type { IconType, ThemeType } from '@bagelink/vue'
3
3
  import { Avatar, Icon } from '@bagelink/vue'
4
- import { computed } from 'vue'
4
+ import { computed, useAttrs } from 'vue'
5
+
6
+ defineOptions({ inheritAttrs: false })
5
7
 
6
8
  const props = withDefaults(
7
9
  defineProps<{
@@ -31,9 +33,8 @@ const props = withDefaults(
31
33
  /** Visually mark as selected (for non-router selection lists). */
32
34
  active?: boolean
33
35
  /** Render as an interactive row (cursor + hover) without needing a handler.
34
- Implied when `to`, `href`, or `onClick` is set. */
36
+ Implied when `to`, `href`, or a `@click` listener is set. */
35
37
  clickable?: boolean
36
- onClick?: () => void
37
38
  }>(),
38
39
  {
39
40
  ellipsis: true,
@@ -41,9 +42,34 @@ const props = withDefaults(
41
42
  }
42
43
  )
43
44
 
45
+ const attrs = useAttrs()
46
+
47
+ // Split inherited attrs: event listeners (onClick, onClickStop, …) belong on the
48
+ // clickable element so handlers + modifiers like `.stop` fire on the actual
49
+ // button/link row; everything else (class, style, data-*, …) stays on the root
50
+ // wrapper to preserve existing behavior.
51
+ const listenerAttrs = computed(() => {
52
+ const out: Record<string, any> = {}
53
+ for (const k of Object.keys(attrs)) {
54
+ if (/^on[A-Z]/.test(k)) { out[k] = (attrs as any)[k] }
55
+ }
56
+ return out
57
+ })
58
+ const rootAttrs = computed(() => {
59
+ const out: Record<string, any> = {}
60
+ for (const k of Object.keys(attrs)) {
61
+ if (!/^on[A-Z]/.test(k)) { out[k] = (attrs as any)[k] }
62
+ }
63
+ return out
64
+ })
65
+
44
66
  const hasTo = computed(() => props.to !== undefined && props.to !== '')
45
67
  const hasHref = computed(() => props.href !== undefined && props.href !== '')
46
- const isClickable = computed(() => hasTo.value || hasHref.value || props.onClick !== undefined || props.clickable === true)
68
+ // A `@click` listener (with or without modifiers like `.stop`) shows up in
69
+ // $attrs as `onClick` / `onClickStop` / etc — detect any of them so a clickable
70
+ // row is recognized even when the handler uses modifiers.
71
+ const hasClickListener = computed(() => Object.keys(attrs).some(k => /^onClick/i.test(k)))
72
+ const isClickable = computed(() => hasTo.value || hasHref.value || hasClickListener.value || props.clickable === true)
47
73
 
48
74
  const isComponent = computed(() => {
49
75
  if (hasTo.value) { return 'router-link' }
@@ -53,7 +79,10 @@ const isComponent = computed(() => {
53
79
  })
54
80
 
55
81
  const bind = computed(() => {
56
- const obj: { [key: string]: any } = {}
82
+ // Spread the inherited event listeners (including `@click`/`@click.stop`) onto
83
+ // the clickable element itself, so the handler fires on the actual button/link
84
+ // row — not the outer wrapper — and modifiers like `.stop` keep working.
85
+ const obj: { [key: string]: any } = { ...listenerAttrs.value }
57
86
  if (props.to !== undefined && props.to !== '') { obj.to = props.to }
58
87
  else if (props.href !== undefined && props.href !== '') { obj.href = props.href }
59
88
  if (props.target !== undefined && props.target !== undefined && ((props.to !== undefined && props.to !== '') || (props.href !== undefined && props.href !== ''))) { obj.target = props.target }
@@ -69,6 +98,7 @@ const bind = computed(() => {
69
98
 
70
99
  <template>
71
100
  <div
101
+ v-bind="rootAttrs"
72
102
  class="flex space-between list-item-row"
73
103
  :class="{ 'no-border-list': props.flat || rounded, 'list-item-flush': props.fullWidth, 'list-item-fullrow': isClickable, 'list-item-rounded': rounded, 'list-item-active': active }"
74
104
  :style="color ? { '--bgl-list-item-accent': `var(--bgl-${color})` } : undefined"
@@ -86,7 +116,7 @@ const bind = computed(() => {
86
116
  'py-05': props.thin,
87
117
  'px-1': !props.fullWidth,
88
118
  'px-0': props.fullWidth,
89
- }" @click="typeof onClick === 'function' && onClick()"
119
+ }"
90
120
  >
91
121
  <!-- Leading visual INSIDE the clickable area. Use #media for custom art
92
122
  (covers, thumbnails); `src`/`showAvatar` and `icon` are shortcuts. -->