@yunlefun/vue 0.4.2 → 0.7.0

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.
Files changed (81) hide show
  1. package/README.md +6 -0
  2. package/components/YlfAccordion.vue +12 -7
  3. package/components/YlfAgentCard.vue +108 -0
  4. package/components/YlfAgentStatus.vue +69 -0
  5. package/components/YlfAgentTask.vue +85 -0
  6. package/components/YlfButton.vue +145 -28
  7. package/components/YlfCard.vue +10 -4
  8. package/components/YlfCheckbox.vue +70 -7
  9. package/components/YlfCloud.vue +193 -0
  10. package/components/YlfDialog.vue +53 -21
  11. package/components/YlfDropdownMenu.vue +41 -5
  12. package/components/YlfInput.vue +67 -0
  13. package/components/YlfLogo.vue +7 -5
  14. package/components/YlfNavigation.vue +84 -0
  15. package/components/YlfNavigationLink.vue +59 -0
  16. package/components/YlfNavigationTrigger.vue +53 -0
  17. package/components/YlfPopover.vue +43 -7
  18. package/components/YlfRadioGroup.vue +41 -6
  19. package/components/YlfScrollFade.vue +66 -0
  20. package/components/YlfSegmentedControl.vue +80 -10
  21. package/components/YlfSelect.vue +72 -34
  22. package/components/YlfSlider.vue +16 -5
  23. package/components/YlfSwitch.vue +30 -4
  24. package/components/YlfTabs.vue +12 -4
  25. package/components/YlfTooltip.vue +29 -4
  26. package/components/_navigation.scss +38 -0
  27. package/components/accordion/demo.vue +1 -1
  28. package/components/agent-card/demo.vue +17 -0
  29. package/components/agent-card/index.md +25 -0
  30. package/components/agent-status/demo.vue +38 -0
  31. package/components/agent-status/index.md +20 -0
  32. package/components/agent-task/demo.vue +15 -0
  33. package/components/agent-task/index.md +25 -0
  34. package/components/agent.ts +2 -0
  35. package/components/button/demo.vue +21 -0
  36. package/components/button/index.md +20 -11
  37. package/components/cloud/demo.vue +92 -0
  38. package/components/cloud/index.md +66 -0
  39. package/components/cloud.ts +4 -0
  40. package/components/input/demo.vue +22 -0
  41. package/components/input/index.md +19 -0
  42. package/components/navigation/demo.vue +104 -0
  43. package/components/navigation/index.md +90 -0
  44. package/components/navigation-indicator.ts +114 -0
  45. package/components/scroll-fade/demo.vue +49 -0
  46. package/components/scroll-fade/index.md +40 -0
  47. package/components/scroll-fade.ts +52 -0
  48. package/dist/ag-ui.cjs +132 -0
  49. package/dist/ag-ui.d.cts +25 -0
  50. package/dist/ag-ui.d.mts +25 -0
  51. package/dist/ag-ui.d.ts +25 -0
  52. package/dist/ag-ui.mjs +130 -0
  53. package/dist/components/YlfAgentCard.vue.d.ts +24 -0
  54. package/dist/components/YlfAgentStatus.vue.d.ts +13 -0
  55. package/dist/components/YlfAgentTask.vue.d.ts +23 -0
  56. package/dist/components/YlfAvatar.vue.d.ts +1 -1
  57. package/dist/components/YlfButton.vue.d.ts +8 -5
  58. package/dist/components/YlfCloud.vue.d.ts +15 -0
  59. package/dist/components/YlfDialog.vue.d.ts +5 -5
  60. package/dist/components/YlfDropdownMenu.vue.d.ts +2 -2
  61. package/dist/components/YlfInput.vue.d.ts +18 -0
  62. package/dist/components/YlfNavigation.vue.d.ts +23 -0
  63. package/dist/components/YlfNavigationLink.vue.d.ts +21 -0
  64. package/dist/components/YlfNavigationTrigger.vue.d.ts +18 -0
  65. package/dist/components/YlfPopover.vue.d.ts +3 -3
  66. package/dist/components/YlfProgress.vue.d.ts +1 -1
  67. package/dist/components/YlfScrollFade.vue.d.ts +24 -0
  68. package/dist/components/YlfSeparator.vue.d.ts +2 -2
  69. package/dist/components/YlfSwitch.vue.d.ts +1 -1
  70. package/dist/components/YlfTabs.vue.d.ts +3 -3
  71. package/dist/components/YlfTooltip.vue.d.ts +3 -3
  72. package/dist/components/agent.d.ts +2 -0
  73. package/dist/components/cloud.d.ts +3 -0
  74. package/dist/components/navigation-indicator.d.ts +14 -0
  75. package/dist/components/scroll-fade.d.ts +3 -0
  76. package/dist/index.cjs +3 -0
  77. package/dist/index.d.cts +9 -2
  78. package/dist/index.d.mts +9 -2
  79. package/dist/index.d.ts +9 -2
  80. package/dist/index.mjs +3 -1
  81. package/package.json +20 -6
@@ -0,0 +1,84 @@
1
+ <script setup lang="ts">
2
+ import { useTemplateRef } from 'vue'
3
+ import { useNavigationIndicator } from './navigation-indicator'
4
+
5
+ const props = withDefaults(defineProps<{
6
+ /** Accessible name; distinguish multiple navigation landmarks on one page. */
7
+ label: string
8
+ orientation?: 'horizontal' | 'vertical'
9
+ /** Move the shared underline between current links in horizontal navigation. */
10
+ animated?: boolean
11
+ }>(), {
12
+ orientation: 'horizontal',
13
+ animated: true,
14
+ })
15
+
16
+ const root = useTemplateRef<HTMLElement>('root')
17
+ const indicator = useNavigationIndicator(root, {
18
+ links: element => Array.from(element.querySelectorAll<HTMLElement>('.ylf-navigation-link'))
19
+ .filter(link => link.closest('.ylf-navigation') === element),
20
+ active: link => link.hasAttribute('data-active'),
21
+ attributes: ['data-active'],
22
+ enabled: () => props.animated && props.orientation === 'horizontal',
23
+ })
24
+ </script>
25
+
26
+ <template>
27
+ <nav ref="root" class="ylf-navigation" :aria-label="label" :data-orientation="orientation" :data-indicator="indicator ? '' : undefined">
28
+ <slot />
29
+ <span
30
+ v-if="indicator"
31
+ class="ylf-navigation__indicator"
32
+ aria-hidden="true"
33
+ :style="{ transform: `translate(${indicator.x}px, ${indicator.y}px)` }"
34
+ />
35
+ </nav>
36
+ </template>
37
+
38
+ <style lang="scss" scoped>
39
+ .ylf-navigation {
40
+ --_ylf-nav-justify: center;
41
+ --_ylf-nav-active-bg: transparent;
42
+ --_ylf-nav-indicator: block;
43
+
44
+ position: relative;
45
+ display: flex;
46
+ flex-wrap: wrap;
47
+ align-items: center;
48
+ gap: var(--ylf-space-2, 8px);
49
+ min-width: 0;
50
+
51
+ &[data-indicator] {
52
+ --_ylf-nav-indicator: none;
53
+ }
54
+
55
+ &__indicator {
56
+ position: absolute;
57
+ top: 0;
58
+ left: 0;
59
+ width: 16px;
60
+ height: 2px;
61
+ border-radius: var(--ylf-radius-pill, 999px);
62
+ background: var(--ylf-c-brand, #2563eb);
63
+ pointer-events: none;
64
+ transition: transform var(--ylf-duration-normal, 240ms) var(--ylf-ease-standard, ease);
65
+ }
66
+
67
+ &[data-orientation='vertical'] {
68
+ --_ylf-nav-justify: flex-start;
69
+ --_ylf-nav-active-bg: var(--ylf-c-brand-soft, #eff6ff);
70
+ --_ylf-nav-indicator: none;
71
+
72
+ flex-direction: column;
73
+ flex-wrap: nowrap;
74
+ align-items: stretch;
75
+ gap: var(--ylf-space-1, 4px);
76
+ }
77
+ }
78
+
79
+ @media (prefers-reduced-motion: reduce) {
80
+ .ylf-navigation__indicator {
81
+ transition: none;
82
+ }
83
+ }
84
+ </style>
@@ -0,0 +1,59 @@
1
+ <script setup lang="ts">
2
+ import { Primitive } from 'reka-ui'
3
+
4
+ withDefaults(defineProps<{
5
+ active?: boolean
6
+ /** Merge attributes onto one child anchor, e.g. NuxtLink or RouterLink. */
7
+ asChild?: boolean
8
+ }>(), {
9
+ active: false,
10
+ asChild: false,
11
+ })
12
+ </script>
13
+
14
+ <template>
15
+ <Primitive
16
+ as="a"
17
+ :as-child="asChild"
18
+ class="ylf-navigation-link"
19
+ :aria-current="active ? 'page' : undefined"
20
+ :data-active="active ? '' : undefined"
21
+ >
22
+ <slot />
23
+ </Primitive>
24
+ </template>
25
+
26
+ <style lang="scss" scoped>
27
+ @use './navigation' as navigation;
28
+
29
+ .ylf-navigation-link {
30
+ @include navigation.control;
31
+
32
+ position: relative;
33
+ justify-content: var(--_ylf-nav-justify, center);
34
+ min-width: 60px;
35
+ padding: var(--ylf-space-2, 8px) var(--ylf-space-4, 16px);
36
+
37
+ &[data-active] {
38
+ background: var(--_ylf-nav-active-bg, transparent);
39
+ color: var(--ylf-c-brand, #2563eb);
40
+
41
+ &::after {
42
+ position: absolute;
43
+ display: var(--_ylf-nav-indicator, block);
44
+ bottom: 4px;
45
+ inset-inline-start: calc(50% - 8px);
46
+ width: 16px;
47
+ height: 2px;
48
+ border-radius: var(--ylf-radius-pill, 999px);
49
+ background: currentColor;
50
+ content: '';
51
+ }
52
+
53
+ &:hover {
54
+ background: var(--ylf-c-bg-soft, #f1f5f9);
55
+ color: var(--ylf-c-brand, #2563eb);
56
+ }
57
+ }
58
+ }
59
+ </style>
@@ -0,0 +1,53 @@
1
+ <script setup lang="ts">
2
+ withDefaults(defineProps<{
3
+ disabled?: boolean
4
+ }>(), {
5
+ disabled: false,
6
+ })
7
+ </script>
8
+
9
+ <template>
10
+ <button type="button" class="ylf-navigation-trigger" :disabled="disabled">
11
+ <slot />
12
+ <svg class="ylf-navigation-trigger__chevron" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
13
+ <path d="m6 9 6 6 6-6" />
14
+ </svg>
15
+ </button>
16
+ </template>
17
+
18
+ <style lang="scss" scoped>
19
+ @use './navigation' as navigation;
20
+
21
+ .ylf-navigation-trigger {
22
+ @include navigation.control;
23
+
24
+ justify-content: center;
25
+ padding: var(--ylf-space-2, 8px) var(--ylf-space-3, 12px);
26
+
27
+ &[aria-expanded='true'] {
28
+ background: var(--ylf-c-bg-soft, #f1f5f9);
29
+ color: var(--ylf-c-text, #0f172a);
30
+ }
31
+
32
+ &:disabled {
33
+ opacity: 0.5;
34
+ cursor: not-allowed;
35
+ }
36
+
37
+ &__chevron {
38
+ flex: none;
39
+ color: var(--ylf-c-text-3, #5c6b80);
40
+ transition: transform var(--ylf-duration-fast, 160ms) var(--ylf-ease-standard, ease);
41
+ }
42
+
43
+ &[aria-expanded='true'] &__chevron {
44
+ transform: rotate(180deg);
45
+ }
46
+ }
47
+
48
+ @media (prefers-reduced-motion: reduce) {
49
+ .ylf-navigation-trigger__chevron {
50
+ transition: none;
51
+ }
52
+ }
53
+ </style>
@@ -21,8 +21,10 @@ const open = defineModel<boolean>('open', { default: false })
21
21
  <slot name="trigger" />
22
22
  </PopoverTrigger>
23
23
  <PopoverPortal :to="portalTo">
24
- <PopoverContent v-bind="$attrs" :side="side" :align="align" :side-offset="8" class="ylf-popover">
25
- <slot />
24
+ <PopoverContent v-bind="$attrs" :side="side" :align="align" :side-offset="8" :collision-padding="16" class="ylf-popover">
25
+ <div class="ylf-popover__body">
26
+ <slot />
27
+ </div>
26
28
  <PopoverArrow class="ylf-popover__arrow" :width="12" :height="6" />
27
29
  </PopoverContent>
28
30
  </PopoverPortal>
@@ -32,8 +34,12 @@ const open = defineModel<boolean>('open', { default: false })
32
34
  <style lang="scss">
33
35
  .ylf-popover {
34
36
  z-index: 105;
35
- min-width: 180px;
36
- max-width: 320px;
37
+ box-sizing: border-box;
38
+ min-width: min(180px, var(--reka-popover-content-available-width, 100vw));
39
+ max-width: min(320px, var(--reka-popover-content-available-width, calc(100vw - 32px)));
40
+ max-height: var(--reka-popover-content-available-height, calc(100dvh - 32px));
41
+ overflow-wrap: anywhere;
42
+ overscroll-behavior: contain;
37
43
  padding: 16px;
38
44
  color: var(--ylf-c-text, #0f172a);
39
45
  background: var(--ylf-c-panel, var(--ylf-c-surface, #fff));
@@ -44,7 +50,30 @@ const open = defineModel<boolean>('open', { default: false })
44
50
  transform-origin: var(--reka-popover-content-transform-origin);
45
51
 
46
52
  &[data-state='open'] {
47
- animation: ylf-popover-in 0.18s var(--ylf-ease-bounce, cubic-bezier(0.34, 1.56, 0.64, 1));
53
+ animation: ylf-popover-in var(--ylf-duration-enter, 240ms) var(--ylf-ease-standard, ease);
54
+ }
55
+
56
+ &[data-state='closed'] {
57
+ animation: ylf-popover-out var(--ylf-duration-exit, 160ms) var(--ylf-ease-standard, ease);
58
+ }
59
+
60
+ &[data-side='bottom'] {
61
+ --_enter-y: -4px;
62
+ }
63
+ &[data-side='top'] {
64
+ --_enter-y: 4px;
65
+ }
66
+ &[data-side='left'] {
67
+ --_enter-x: 4px;
68
+ }
69
+ &[data-side='right'] {
70
+ --_enter-x: -4px;
71
+ }
72
+
73
+ &__body {
74
+ max-height: calc(var(--reka-popover-content-available-height, calc(100dvh - 32px)) - 34px);
75
+ overflow: auto;
76
+ overscroll-behavior: contain;
48
77
  }
49
78
 
50
79
  &__arrow {
@@ -56,12 +85,19 @@ const open = defineModel<boolean>('open', { default: false })
56
85
  @keyframes ylf-popover-in {
57
86
  from {
58
87
  opacity: 0;
59
- transform: scale(0.96);
88
+ transform: translate(var(--_enter-x, 0), var(--_enter-y, 0)) scale(0.96);
89
+ }
90
+ }
91
+
92
+ @keyframes ylf-popover-out {
93
+ to {
94
+ opacity: 0;
95
+ transform: scale(0.97);
60
96
  }
61
97
  }
62
98
 
63
99
  @media (prefers-reduced-motion: reduce) {
64
- .ylf-popover[data-state='open'] {
100
+ .ylf-popover[data-state] {
65
101
  animation: none;
66
102
  }
67
103
  }
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  // 行为 / 可访问性由 reka-ui 提供(role=radiogroup、方向键 roving focus);皮肤走 token。
3
3
  import { RadioGroupIndicator, RadioGroupItem, RadioGroupRoot } from 'reka-ui'
4
- import { nextTick } from 'vue'
4
+ import { nextTick, shallowRef, watch } from 'vue'
5
5
 
6
6
  interface RadioOption {
7
7
  label: string
@@ -19,6 +19,11 @@ const props = withDefaults(defineProps<{
19
19
  })
20
20
 
21
21
  const model = defineModel<string>()
22
+ // 只在选择变化后让圆点弹出,首屏默认选项保持静止。
23
+ const animated = shallowRef(false)
24
+ watch(model, () => {
25
+ animated.value = true
26
+ })
22
27
 
23
28
  function selectFocusedRadio(event: KeyboardEvent) {
24
29
  if (props.disabled || !event.defaultPrevented || !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key))
@@ -43,7 +48,7 @@ function selectFocusedRadio(event: KeyboardEvent) {
43
48
  :disabled="disabled"
44
49
  :orientation="orientation"
45
50
  class="ylf-radio-group"
46
- :class="`ylf-radio-group--${orientation}`"
51
+ :class="[`ylf-radio-group--${orientation}`, { 'is-animated': animated }]"
47
52
  @keydown="selectFocusedRadio"
48
53
  >
49
54
  <RadioGroupItem
@@ -99,12 +104,15 @@ function selectFocusedRadio(event: KeyboardEvent) {
99
104
  background: var(--ylf-c-surface, #fff);
100
105
  box-shadow: var(--ylf-shadow-control);
101
106
  transition:
102
- border-color 0.18s ease,
103
- box-shadow 0.2s ease;
107
+ border-color var(--ylf-duration-fast, 160ms) var(--ylf-ease-standard, ease),
108
+ box-shadow var(--ylf-duration-fast, 160ms) var(--ylf-ease-standard, ease),
109
+ transform var(--ylf-duration-slow, 480ms) var(--ylf-ease-spring, var(--ylf-ease-standard, ease));
104
110
  }
105
111
 
106
- &:hover:not([data-disabled]) .ylf-radio__control {
107
- border-color: var(--ylf-c-brand, #2563eb);
112
+ @media (hover: hover) and (pointer: fine) {
113
+ &:hover:not([data-disabled]) .ylf-radio__control {
114
+ border-color: var(--ylf-c-brand, #2563eb);
115
+ }
108
116
  }
109
117
 
110
118
  &:focus-visible {
@@ -134,8 +142,35 @@ function selectFocusedRadio(event: KeyboardEvent) {
134
142
  background: var(--ylf-c-brand, #2563eb);
135
143
  }
136
144
 
145
+ &:active:not([data-disabled]) .ylf-radio__control {
146
+ transform: scale(0.9);
147
+ transition-duration: var(--ylf-duration-press, 100ms);
148
+ }
149
+
137
150
  &__label {
138
151
  font-size: 15px;
139
152
  }
140
153
  }
154
+ .ylf-radio-group.is-animated .ylf-radio__dot {
155
+ animation: ylf-radio-dot var(--ylf-duration-slow, 480ms) var(--ylf-ease-spring, var(--ylf-ease-standard, ease));
156
+ }
157
+ @keyframes ylf-radio-dot {
158
+ from {
159
+ transform: scale(0);
160
+ }
161
+ }
162
+ @media (prefers-reduced-motion: reduce) {
163
+ .ylf-radio-group.is-animated .ylf-radio__dot {
164
+ animation: none;
165
+ }
166
+ .ylf-radio__control {
167
+ transition: none;
168
+ }
169
+ }
170
+ @media (pointer: coarse) {
171
+ .ylf-radio {
172
+ min-width: var(--ylf-touch-target, 44px);
173
+ min-height: var(--ylf-touch-target, 44px);
174
+ }
175
+ }
141
176
  </style>
@@ -0,0 +1,66 @@
1
+ <script setup lang="ts">
2
+ import { toRef } from 'vue'
3
+ import { useScrollFade } from './scroll-fade'
4
+
5
+ const props = withDefaults(defineProps<{
6
+ /** The element inside the frame that owns vertical scrolling. */
7
+ viewport?: HTMLElement | null
8
+ /** CSS color of the surface behind the content. */
9
+ surface?: string
10
+ /** CSS length of the fade at each scroll edge. */
11
+ size?: string
12
+ }>(), {
13
+ surface: 'var(--ylf-c-surface, #fff)',
14
+ size: '24px',
15
+ })
16
+
17
+ const fadeStyle = useScrollFade(toRef(() => props.viewport))
18
+ </script>
19
+
20
+ <template>
21
+ <div
22
+ class="ylf-scroll-fade"
23
+ :style="[fadeStyle, { '--ylf-scroll-fade-surface': surface, '--ylf-scroll-fade-size': size }]"
24
+ >
25
+ <slot />
26
+ </div>
27
+ </template>
28
+
29
+ <style scoped>
30
+ .ylf-scroll-fade {
31
+ position: relative;
32
+ isolation: isolate;
33
+ min-width: 0;
34
+ min-height: 0;
35
+ overflow: hidden;
36
+ }
37
+
38
+ .ylf-scroll-fade::before,
39
+ .ylf-scroll-fade::after {
40
+ position: absolute;
41
+ z-index: 1;
42
+ inset-inline: 0;
43
+ height: min(var(--ylf-scroll-fade-size), 50%);
44
+ pointer-events: none;
45
+ content: '';
46
+ }
47
+
48
+ .ylf-scroll-fade::before {
49
+ top: 0;
50
+ opacity: var(--scroll-fade-top);
51
+ background: linear-gradient(to bottom, var(--ylf-scroll-fade-surface), transparent);
52
+ }
53
+
54
+ .ylf-scroll-fade::after {
55
+ bottom: 0;
56
+ opacity: var(--scroll-fade-bottom);
57
+ background: linear-gradient(to top, var(--ylf-scroll-fade-surface), transparent);
58
+ }
59
+
60
+ @media (prefers-reduced-transparency: reduce), (forced-colors: active) {
61
+ .ylf-scroll-fade::before,
62
+ .ylf-scroll-fade::after {
63
+ display: none;
64
+ }
65
+ }
66
+ </style>
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts" generic="T extends string = string">
2
2
  import type { YlfSegmentedOption } from './segmented-control'
3
3
  import { ToggleGroupItem, ToggleGroupRoot } from 'reka-ui'
4
+ import { nextTick, onBeforeUnmount, onMounted, shallowRef, useTemplateRef, watch } from 'vue'
4
5
  import YlfTooltip from './YlfTooltip.vue'
5
6
 
6
7
  const props = withDefaults(defineProps<{
@@ -26,11 +27,42 @@ function updateValue(value: unknown): void {
26
27
  if (!props.disabled && option && !option.disabled)
27
28
  model.value = option.value
28
29
  }
30
+
31
+ // 选中胶囊在选项间滑动;首次定位不带过渡,之后的切换才用弹簧。
32
+ const root = useTemplateRef<{ $el: HTMLElement }>('root')
33
+ const pill = shallowRef<{ x: number, y: number, width: number, height: number } | null>(null)
34
+ const pillAnimated = shallowRef(false)
35
+ let resizeObserver: ResizeObserver | undefined
36
+
37
+ function measurePill() {
38
+ const item = root.value?.$el?.querySelector<HTMLElement>('.ylf-segmented__item[aria-pressed="true"]')
39
+ pill.value = item?.offsetWidth
40
+ ? { x: item.offsetLeft, y: item.offsetTop, width: item.offsetWidth, height: item.offsetHeight }
41
+ : null
42
+ }
43
+
44
+ watch(model, async () => {
45
+ await nextTick()
46
+ measurePill()
47
+ })
48
+ onMounted(() => {
49
+ measurePill()
50
+ requestAnimationFrame(() => {
51
+ pillAnimated.value = true
52
+ })
53
+ if (typeof ResizeObserver !== 'undefined' && root.value?.$el) {
54
+ resizeObserver = new ResizeObserver(measurePill)
55
+ resizeObserver.observe(root.value.$el)
56
+ }
57
+ })
58
+ onBeforeUnmount(() => resizeObserver?.disconnect())
29
59
  </script>
30
60
 
31
61
  <template>
32
62
  <ToggleGroupRoot
63
+ ref="root"
33
64
  class="ylf-segmented"
65
+ :class="{ 'has-pill': pill, 'is-pill-animated': pillAnimated }"
34
66
  :data-size="size"
35
67
  :data-icon-only="iconOnly || undefined"
36
68
  type="single"
@@ -40,6 +72,12 @@ function updateValue(value: unknown): void {
40
72
  :model-value="model"
41
73
  @update:model-value="updateValue"
42
74
  >
75
+ <span
76
+ v-if="pill"
77
+ class="ylf-segmented__pill"
78
+ aria-hidden="true"
79
+ :style="{ width: `${pill.width}px`, height: `${pill.height}px`, transform: `translate(${pill.x}px, ${pill.y}px)` }"
80
+ />
43
81
  <YlfTooltip v-for="option in options" :key="option.value" :content="option.label" :disabled="!iconOnly || disabled || option.disabled">
44
82
  <ToggleGroupItem
45
83
  class="ylf-segmented__item"
@@ -60,6 +98,8 @@ function updateValue(value: unknown): void {
60
98
  <style>
61
99
  .ylf-segmented {
62
100
  --ylf-segmented-item-size: 36px;
101
+ position: relative;
102
+ isolation: isolate;
63
103
  display: inline-flex;
64
104
  align-items: center;
65
105
  flex: none;
@@ -82,10 +122,10 @@ function updateValue(value: unknown): void {
82
122
  display: inline-flex;
83
123
  align-items: center;
84
124
  justify-content: center;
85
- flex: 0 0 auto;
125
+ flex: 1 1 auto;
86
126
  box-sizing: border-box;
87
127
  min-width: var(--ylf-segmented-item-size);
88
- height: var(--ylf-segmented-item-size);
128
+ min-height: var(--ylf-segmented-item-size);
89
129
  gap: 6px;
90
130
  padding: 0 10px;
91
131
  border: 1px solid transparent;
@@ -95,8 +135,9 @@ function updateValue(value: unknown): void {
95
135
  font: inherit;
96
136
  font-size: var(--ylf-text-sm, 14px);
97
137
  font-weight: 500;
98
- line-height: 1;
99
- white-space: nowrap;
138
+ line-height: 1.4;
139
+ white-space: normal;
140
+ overflow-wrap: anywhere;
100
141
  cursor: pointer;
101
142
  transition:
102
143
  background var(--ylf-duration-fast, 160ms),
@@ -114,9 +155,11 @@ function updateValue(value: unknown): void {
114
155
  padding: 0;
115
156
  }
116
157
 
117
- .ylf-segmented__item:hover:not([data-disabled], [aria-pressed='true']) {
118
- color: var(--ylf-c-text, #0f172a);
119
- background: color-mix(in srgb, var(--ylf-c-surface, #fff) 60%, transparent);
158
+ @media (hover: hover) and (pointer: fine) {
159
+ .ylf-segmented__item:hover:not([data-disabled], [aria-pressed='true']) {
160
+ color: var(--ylf-c-text, #0f172a);
161
+ background: color-mix(in srgb, var(--ylf-c-surface, #fff) 60%, transparent);
162
+ }
120
163
  }
121
164
 
122
165
  .ylf-segmented__item[aria-pressed='true'] {
@@ -126,6 +169,32 @@ function updateValue(value: unknown): void {
126
169
  box-shadow: var(--ylf-shadow-control, var(--ylf-shadow-sm));
127
170
  }
128
171
 
172
+ .ylf-segmented__pill {
173
+ position: absolute;
174
+ top: 0;
175
+ left: 0;
176
+ z-index: -1;
177
+ box-sizing: border-box;
178
+ border: 1px solid var(--ylf-c-border, #e2e8f0);
179
+ border-radius: calc(var(--ylf-radius-sm, 10px) - 4px);
180
+ background: var(--ylf-c-surface, #fff);
181
+ box-shadow: var(--ylf-shadow-control, var(--ylf-shadow-sm));
182
+ pointer-events: none;
183
+ }
184
+
185
+ .ylf-segmented.is-pill-animated .ylf-segmented__pill {
186
+ transition:
187
+ transform var(--ylf-duration-slow, 480ms) var(--ylf-ease-spring, var(--ylf-ease-standard, ease)),
188
+ width var(--ylf-duration-normal, 240ms) var(--ylf-ease-standard, ease),
189
+ height var(--ylf-duration-normal, 240ms) var(--ylf-ease-standard, ease);
190
+ }
191
+
192
+ .ylf-segmented.has-pill .ylf-segmented__item[aria-pressed='true'] {
193
+ border-color: transparent;
194
+ background: transparent;
195
+ box-shadow: none;
196
+ }
197
+
129
198
  .ylf-segmented__item:focus-visible {
130
199
  position: relative;
131
200
  z-index: 1;
@@ -168,13 +237,14 @@ function updateValue(value: unknown): void {
168
237
 
169
238
  @media (pointer: coarse) {
170
239
  .ylf-segmented .ylf-segmented__item {
171
- min-width: 44px;
172
- min-height: 44px;
240
+ min-width: var(--ylf-touch-target, 44px);
241
+ min-height: var(--ylf-touch-target, 44px);
173
242
  }
174
243
  }
175
244
 
176
245
  @media (prefers-reduced-motion: reduce) {
177
- .ylf-segmented__item {
246
+ .ylf-segmented__item,
247
+ .ylf-segmented.is-pill-animated .ylf-segmented__pill {
178
248
  transition: none;
179
249
  }
180
250
  }