@proj-airi/ui 0.8.0-beta.3 → 0.8.0-beta.5

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": "@proj-airi/ui",
3
3
  "type": "module",
4
- "version": "0.8.0-beta.3",
4
+ "version": "0.8.0-beta.5",
5
5
  "description": "A collection of UI components that used by Project AIRI",
6
6
  "author": {
7
7
  "name": "Moeru AI Project AIRI Team",
@@ -14,8 +14,7 @@ const hide = inject('hide') as () => void
14
14
  <template>
15
15
  <div
16
16
  v-bind="{ ...$attrs, class: null, style: null }"
17
- class="cursor-pointer rounded px-2 py-1 text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800"
18
- line-clamp-1 overflow-hidden text-ellipsis whitespace-pre-wrap text="xs sm:sm" transition-colors duration-150 ease-in-out will-change-background-color will-change-color
17
+ class="line-clamp-1 cursor-pointer overflow-hidden text-ellipsis whitespace-pre-wrap rounded px-2 py-1 text-xs text-neutral-700 transition-colors duration-150 ease-in-out will-change-background-color will-change-color hover:bg-neutral-100 sm:text-sm dark:text-neutral-200 dark:hover:bg-neutral-800"
19
18
  :class="{ 'bg-neutral-100 dark:bg-neutral-800': props.active }"
20
19
  @click="() => {
21
20
  selectOption(props.value)
@@ -0,0 +1,122 @@
1
+ <script setup lang="ts">
2
+ import { RadioGroupItem, RadioGroupRoot } from 'reka-ui'
3
+ import { computed } from 'vue'
4
+
5
+ interface SelectTabOption {
6
+ label: string
7
+ value: string | number
8
+ description?: string
9
+ icon?: string
10
+ }
11
+
12
+ const props = withDefaults(defineProps<{
13
+ options: SelectTabOption[]
14
+ disabled?: boolean
15
+ readonly?: boolean
16
+ size?: 'sm' | 'md'
17
+ }>(), {
18
+ disabled: false,
19
+ readonly: false,
20
+ size: 'md',
21
+ })
22
+
23
+ const modelValue = defineModel<string | number>({ required: true })
24
+
25
+ const activeIndex = computed(() => props.options.findIndex(option => option.value === modelValue.value))
26
+ const itemCount = computed(() => props.options.length || 1)
27
+ const isDisabled = computed(() => props.disabled || props.readonly)
28
+
29
+ const sizeClasses = computed(() =>
30
+ props.size === 'sm'
31
+ ? ['py-2', 'px-3', 'text-xs', 'rounded-md']
32
+ : ['py-2.5', 'px-3.5', 'text-sm', 'rounded-md'],
33
+ )
34
+
35
+ const rootStyle = computed(() => ({
36
+ '--select-tab-count': String(itemCount.value),
37
+ '--select-tab-active-index': String(Math.max(activeIndex.value, 0)),
38
+ '--select-tab-padding': props.size === 'sm' ? '0px' : '0px',
39
+ '--select-tab-gap': '0.25rem',
40
+ '--select-tab-indicator-opacity': activeIndex.value === -1 ? '0' : '1',
41
+ }))
42
+ </script>
43
+
44
+ <template>
45
+ <RadioGroupRoot
46
+ v-model="modelValue"
47
+ :disabled="isDisabled"
48
+ :aria-readonly="props.readonly"
49
+ :class="[
50
+ 'select-tab',
51
+ 'relative', 'flex', 'w-full', 'items-stretch', 'rounded-xl',
52
+ 'overflow-hidden',
53
+ 'bg-white-400/6', 'dark:bg-neutral-900/70',
54
+ 'transition-[border-color,box-shadow,opacity]', 'duration-200', 'ease-out', 'border-2',
55
+ 'border-neutral-100', 'dark:border-neutral-800',
56
+ isDisabled ? ['cursor-not-allowed', 'opacity-60'] : ['shadow-[0_14px_50px_-32px_rgba(0,0,0,0.55)]', 'backdrop-blur-sm'],
57
+ // before
58
+ 'before:bg-primary-300/50', 'dark:before:bg-primary-400/50',
59
+ 'before:rounded-md', 'sm:before:rounded-lg',
60
+ 'before:absolute', 'before:z-0', 'before:content-empty',
61
+ 'before:transition-[left,width,opacity,background-color]', 'before:duration-200', 'before:ease',
62
+ 'before:pointer-events-none',
63
+ 'before:opacity-$select-tab-indicator-opacity',
64
+ 'before:top-$select-tab-padding',
65
+ ]"
66
+ :style="[
67
+ rootStyle,
68
+ { padding: 'var(--select-tab-padding)', gap: 'var(--select-tab-gap)' },
69
+ ]"
70
+ >
71
+ <RadioGroupItem
72
+ v-for="option in props.options"
73
+ :key="option.value"
74
+ :value="option.value"
75
+ :disabled="isDisabled"
76
+ :aria-label="option.label"
77
+ :class="[
78
+ 'select-tab__item',
79
+ 'relative', 'z-1',
80
+ 'flex', 'flex-1', 'items-center', 'justify-center', 'gap-2',
81
+ 'text-center', 'text-neutral-700', 'dark:text-neutral-200', 'font-medium',
82
+ 'transition-[color,background-color,border-color,transform]', 'duration-200', 'ease-out',
83
+ 'focus-visible:border-none', 'focus-visible:outline-none',
84
+ sizeClasses,
85
+ isDisabled ? 'pointer-events-none' : 'cursor-pointer',
86
+ // checked
87
+ 'data-[state=checked]:text-primary-950', 'dark:data-[state=checked]:text-primary-50',
88
+ // unchecked
89
+ 'data-[state=unchecked]:hover:bg-primary-300/20', 'dark:data-[state=unchecked]:hover:bg-primary-400/20', 'data-[state=unchecked]:rounded-lg',
90
+ ]"
91
+ >
92
+ <span v-if="option.icon" :class="['size-4 shrink-0 text-current', option.icon]" />
93
+ <span :class="['truncate']">
94
+ {{ option.label }}
95
+ </span>
96
+ </RadioGroupItem>
97
+ </RadioGroupRoot>
98
+ </template>
99
+
100
+ <style scoped>
101
+ .select-tab {
102
+ position: relative;
103
+ isolation: isolate;
104
+ }
105
+
106
+ .select-tab::before {
107
+ left:
108
+ calc(
109
+ (100% + var(--select-tab-gap))
110
+ / var(--select-tab-count)
111
+ * var(--select-tab-active-index)
112
+ + var(--select-tab-padding)
113
+ );
114
+ width:
115
+ calc(
116
+ (100% + var(--select-tab-gap))
117
+ / var(--select-tab-count)
118
+ - var(--select-tab-gap)
119
+ );
120
+ height: calc(100% - var(--select-tab-padding) * 2);
121
+ }
122
+ </style>
@@ -0,0 +1 @@
1
+ export { default as SelectTab } from './SelectTab.vue'
@@ -5,4 +5,5 @@ export * from './Input'
5
5
  export * from './Radio'
6
6
  export * from './Range'
7
7
  export * from './Select'
8
+ export * from './SelectTab'
8
9
  export * from './Textarea'
@@ -3,12 +3,9 @@ import { BidirectionalTransition } from '@proj-airi/ui'
3
3
  import { computed } from 'vue'
4
4
 
5
5
  // Define button variants for better type safety and maintainability
6
- type ButtonVariant = 'primary' | 'secondary' | 'secondary-muted' | 'danger' | 'caution'
6
+ type ButtonVariant = 'primary' | 'secondary' | 'secondary-muted' | 'danger' | 'caution' | 'pure'
7
7
 
8
- type ButtonTheme
9
- = | 'default'
10
- // | 'dimmed'
11
- // | 'lightened'
8
+ type ButtonTheme = 'default'
12
9
 
13
10
  // Define size options for better flexibility
14
11
  type ButtonSize = 'sm' | 'md' | 'lg'
@@ -38,13 +35,11 @@ const props = withDefaults(defineProps<ButtonProps>(), {
38
35
  const isDisabled = computed(() => props.disabled || props.loading)
39
36
 
40
37
  // Extract variant styles for better organization
41
- const variantClasses: Record<ButtonVariant, {
42
- default: {
43
- default: string
44
- nonToggled?: string
45
- toggled?: string
46
- }
47
- }> = {
38
+ const variantClasses: Record<ButtonVariant, Record<ButtonTheme, {
39
+ default: string
40
+ nonToggled?: string
41
+ toggled?: string
42
+ }>> = {
48
43
  'primary': {
49
44
  default: {
50
45
  default: 'bg-primary-500/15 hover:bg-primary-500/20 active:bg-primary-500/30 dark:bg-primary-700/30 dark:hover:bg-primary-700/40 dark:active:bg-primary-700/30 focus:ring-primary-300/60 dark:focus:ring-primary-600/30 border-2 border-solid border-primary-500/5 dark:border-primary-900/40 text-primary-950 dark:text-primary-100',
@@ -72,6 +67,11 @@ const variantClasses: Record<ButtonVariant, {
72
67
  default: 'bg-amber-400/20 hover:bg-amber-400/25 active:bg-amber-400/35 dark:bg-amber-500/20 dark:hover:bg-amber-500/30 dark:active:bg-amber-500/35 focus:ring-amber-300/40 dark:focus:ring-amber-400/40 border-2 border-solid border-amber-300/40 dark:border-amber-500/40 text-amber-900 dark:text-amber-50',
73
68
  },
74
69
  },
70
+ 'pure': {
71
+ default: {
72
+ default: 'bg-white hover:bg-neutral-50 active:bg-neutral-100 dark:bg-neutral-900 dark:hover:bg-neutral-800 dark:active:bg-neutral-700 border-2 border-solid border-neutral-100 dark:border-neutral-800 focus:ring-neutral-200/40 dark:focus:ring-neutral-600/40 text-neutral-900 dark:text-neutral-50',
73
+ },
74
+ },
75
75
  }
76
76
 
77
77
  // Extract size styles for better organization