@proj-airi/ui 0.8.0-beta.4 → 0.8.0-beta.6
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 +1 -1
- package/src/components/Form/Select/Option.vue +1 -2
- package/src/components/Form/SelectTab/SelectTab.vue +122 -0
- package/src/components/Form/SelectTab/index.ts +1 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/Misc/Button.vue +12 -12
- package/src/components/Misc/DoubleCheckButton.vue +137 -0
- package/src/components/Misc/index.ts +1 -0
package/package.json
CHANGED
|
@@ -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'
|
|
@@ -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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
import Button from './Button.vue'
|
|
5
|
+
|
|
6
|
+
type ButtonVariant = 'primary' | 'secondary' | 'secondary-muted' | 'danger' | 'caution'
|
|
7
|
+
type ButtonSize = 'sm' | 'md' | 'lg'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
variant?: ButtonVariant
|
|
11
|
+
cancelVariant?: ButtonVariant
|
|
12
|
+
size?: ButtonSize
|
|
13
|
+
block?: boolean
|
|
14
|
+
disabled?: boolean
|
|
15
|
+
loading?: boolean
|
|
16
|
+
}>(), {
|
|
17
|
+
variant: 'danger',
|
|
18
|
+
cancelVariant: 'secondary',
|
|
19
|
+
size: 'md',
|
|
20
|
+
block: false,
|
|
21
|
+
disabled: false,
|
|
22
|
+
loading: false,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits<{
|
|
26
|
+
(event: 'confirm'): void
|
|
27
|
+
(event: 'cancel'): void
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const slots = defineSlots<{
|
|
31
|
+
'default': (props: Record<string, unknown>) => unknown
|
|
32
|
+
'confirm': (props: Record<string, unknown>) => unknown
|
|
33
|
+
'cancel': (props: Record<string, unknown>) => unknown
|
|
34
|
+
'cancel-botton-icon': (props: Record<string, unknown>) => unknown
|
|
35
|
+
}>()
|
|
36
|
+
|
|
37
|
+
const confirming = ref(false)
|
|
38
|
+
|
|
39
|
+
const wrapperClasses = computed(() => [
|
|
40
|
+
'inline-flex flex-col gap-2',
|
|
41
|
+
props.block ? 'w-full' : '',
|
|
42
|
+
])
|
|
43
|
+
|
|
44
|
+
watch(() => props.disabled, (disabled) => {
|
|
45
|
+
if (disabled)
|
|
46
|
+
confirming.value = false
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
function handlePrimaryClick() {
|
|
50
|
+
if (!confirming.value) {
|
|
51
|
+
confirming.value = true
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
emit('confirm')
|
|
56
|
+
confirming.value = false
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function handleCancel() {
|
|
60
|
+
confirming.value = false
|
|
61
|
+
emit('cancel')
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<template>
|
|
66
|
+
<div :class="wrapperClasses">
|
|
67
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
68
|
+
<Transition name="double-check-slide">
|
|
69
|
+
<Button
|
|
70
|
+
v-if="confirming"
|
|
71
|
+
key="cancel"
|
|
72
|
+
:variant="cancelVariant"
|
|
73
|
+
:size="size"
|
|
74
|
+
:block="block"
|
|
75
|
+
class="whitespace-nowrap"
|
|
76
|
+
@click="handleCancel"
|
|
77
|
+
>
|
|
78
|
+
<div class="flex items-center gap-2">
|
|
79
|
+
<slot
|
|
80
|
+
v-if="slots['cancel-botton-icon']"
|
|
81
|
+
name="cancel-botton-icon"
|
|
82
|
+
/>
|
|
83
|
+
<span><slot name="cancel">Cancel</slot></span>
|
|
84
|
+
</div>
|
|
85
|
+
</Button>
|
|
86
|
+
</Transition>
|
|
87
|
+
|
|
88
|
+
<Button
|
|
89
|
+
:variant="variant"
|
|
90
|
+
:size="size"
|
|
91
|
+
:block="block"
|
|
92
|
+
:disabled="disabled"
|
|
93
|
+
:loading="loading"
|
|
94
|
+
:class="[
|
|
95
|
+
'double-check-primary whitespace-nowrap',
|
|
96
|
+
'transition-width duration-150 ease-in-out',
|
|
97
|
+
confirming ? 'double-check-primary--confirming' : 'double-check-primary--default',
|
|
98
|
+
]"
|
|
99
|
+
@click="handlePrimaryClick"
|
|
100
|
+
>
|
|
101
|
+
<span v-if="!confirming">
|
|
102
|
+
<slot />
|
|
103
|
+
</span>
|
|
104
|
+
<span v-else>
|
|
105
|
+
<slot name="confirm">
|
|
106
|
+
<slot />
|
|
107
|
+
</slot>
|
|
108
|
+
</span>
|
|
109
|
+
</Button>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</template>
|
|
113
|
+
|
|
114
|
+
<style scoped>
|
|
115
|
+
.double-check-slide-enter-active,
|
|
116
|
+
.double-check-slide-leave-active {
|
|
117
|
+
transition: opacity 160ms ease, transform 160ms ease;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.double-check-slide-enter-from,
|
|
121
|
+
.double-check-slide-leave-to {
|
|
122
|
+
opacity: 0;
|
|
123
|
+
transform: translateX(-10px);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.double-check-primary {
|
|
127
|
+
transition: min-width 180ms ease, padding 180ms ease;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.double-check-primary--default {
|
|
131
|
+
min-width: 7rem;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.double-check-primary--confirming {
|
|
135
|
+
min-width: 9rem;
|
|
136
|
+
}
|
|
137
|
+
</style>
|