@byyuurin/ui 0.0.1 → 0.0.3
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/README.md +75 -5
- package/dist/index.cjs +38 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/nuxt.d.mts +13 -0
- package/dist/nuxt.d.ts +6 -3
- package/dist/nuxt.mjs +6 -3
- package/dist/resolver.d.mts +13 -0
- package/dist/resolver.d.ts +6 -3
- package/dist/resolver.mjs +5 -2
- package/dist/{components → runtime/components}/Accordion.vue +19 -3
- package/dist/{components → runtime/components}/Button.vue +93 -94
- package/dist/{components → runtime/components}/Checkbox.vue +104 -104
- package/dist/{components → runtime/components}/RadioGroup.vue +180 -180
- package/dist/{components → runtime/components}/Select.vue +262 -258
- package/dist/{components → runtime/components}/Switch.vue +99 -99
- package/dist/{components → runtime/components}/Tabs.vue +117 -117
- package/dist/{components → runtime/components}/Toaster.vue +35 -1
- package/dist/runtime/components/index.cjs +132 -0
- package/dist/runtime/composables/index.cjs +33 -0
- package/dist/runtime/composables/useComponentIcons.cjs +30 -0
- package/dist/runtime/composables/useModal.cjs +55 -0
- package/dist/runtime/composables/useTheme.cjs +30 -0
- package/dist/{composables → runtime/composables}/useTheme.d.ts +0 -1
- package/dist/{composables → runtime/composables}/useTheme.mjs +3 -3
- package/dist/runtime/composables/useToast.cjs +51 -0
- package/dist/{composables → runtime/composables}/useToast.d.ts +1 -1
- package/dist/runtime/theme/accordion.cjs +27 -0
- package/dist/runtime/theme/app.cjs +15 -0
- package/dist/runtime/theme/button.cjs +127 -0
- package/dist/runtime/theme/card.cjs +17 -0
- package/dist/runtime/theme/checkbox.cjs +56 -0
- package/dist/runtime/theme/drawer.cjs +73 -0
- package/dist/runtime/theme/index.cjs +125 -0
- package/dist/runtime/theme/input.cjs +115 -0
- package/dist/runtime/theme/link.cjs +23 -0
- package/dist/runtime/theme/modal.cjs +55 -0
- package/dist/runtime/theme/popover.cjs +13 -0
- package/dist/runtime/theme/radioGroup.cjs +73 -0
- package/dist/runtime/theme/select.cjs +128 -0
- package/dist/runtime/theme/switch.cjs +73 -0
- package/dist/runtime/theme/tabs.cjs +105 -0
- package/dist/runtime/theme/toast.cjs +33 -0
- package/dist/runtime/theme/toaster.cjs +72 -0
- package/dist/runtime/theme/tooltip.cjs +14 -0
- package/dist/runtime/types/components.cjs +1 -0
- package/dist/runtime/types/index.cjs +27 -0
- package/dist/{types → runtime/types}/index.d.ts +1 -1
- package/dist/runtime/types/utils.cjs +1 -0
- package/dist/runtime/utils/extend-theme.cjs +24 -0
- package/dist/runtime/utils/index.cjs +119 -0
- package/dist/{utils → runtime/utils}/index.d.ts +3 -1
- package/dist/{utils → runtime/utils}/index.mjs +3 -1
- package/dist/runtime/utils/link.cjs +10 -0
- package/dist/runtime/utils/styler.cjs +18 -0
- package/dist/{internal → runtime/utils}/styler.d.ts +0 -1
- package/dist/runtime/utils/styler.mjs +10 -0
- package/dist/{internal/constants.mjs → shared/ui.CPXA9QoM.mjs} +4 -2
- package/dist/unocss-preset.d.mts +49 -0
- package/dist/unocss-preset.d.ts +20 -8
- package/dist/unocss-preset.mjs +428 -78
- package/package.json +16 -10
- package/dist/internal/constants.d.ts +0 -3
- package/dist/internal/extend-theme.test.d.ts +0 -1
- package/dist/internal/extend-theme.test.mjs +0 -45
- package/dist/internal/index.d.ts +0 -4
- package/dist/internal/index.mjs +0 -4
- package/dist/internal/styler.mjs +0 -235
- package/dist/internal/styler.test.d.ts +0 -1
- package/dist/internal/styler.test.mjs +0 -10
- package/dist/utils/unocss.d.ts +0 -3
- package/dist/utils/unocss.mjs +0 -50
- /package/dist/{components → runtime/components}/App.vue +0 -0
- /package/dist/{components → runtime/components}/Card.vue +0 -0
- /package/dist/{components → runtime/components}/Drawer.vue +0 -0
- /package/dist/{components → runtime/components}/Input.vue +0 -0
- /package/dist/{components → runtime/components}/Link.vue +0 -0
- /package/dist/{components → runtime/components}/Modal.vue +0 -0
- /package/dist/{components → runtime/components}/ModalProvider.vue +0 -0
- /package/dist/{components → runtime/components}/Popover.vue +0 -0
- /package/dist/{components → runtime/components}/Toast.vue +0 -0
- /package/dist/{components → runtime/components}/Tooltip.vue +0 -0
- /package/dist/{components → runtime/components}/index.d.ts +0 -0
- /package/dist/{components → runtime/components}/index.mjs +0 -0
- /package/dist/{composables → runtime/composables}/index.d.ts +0 -0
- /package/dist/{composables → runtime/composables}/index.mjs +0 -0
- /package/dist/{composables → runtime/composables}/useComponentIcons.d.ts +0 -0
- /package/dist/{composables → runtime/composables}/useComponentIcons.mjs +0 -0
- /package/dist/{composables → runtime/composables}/useModal.d.ts +0 -0
- /package/dist/{composables → runtime/composables}/useModal.mjs +0 -0
- /package/dist/{composables → runtime/composables}/useToast.mjs +0 -0
- /package/dist/{theme → runtime/theme}/accordion.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/accordion.mjs +0 -0
- /package/dist/{theme → runtime/theme}/app.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/app.mjs +0 -0
- /package/dist/{theme → runtime/theme}/button.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/button.mjs +0 -0
- /package/dist/{theme → runtime/theme}/card.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/card.mjs +0 -0
- /package/dist/{theme → runtime/theme}/checkbox.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/checkbox.mjs +0 -0
- /package/dist/{theme → runtime/theme}/drawer.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/drawer.mjs +0 -0
- /package/dist/{theme → runtime/theme}/index.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/index.mjs +0 -0
- /package/dist/{theme → runtime/theme}/input.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/input.mjs +0 -0
- /package/dist/{theme → runtime/theme}/link.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/link.mjs +0 -0
- /package/dist/{theme → runtime/theme}/modal.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/modal.mjs +0 -0
- /package/dist/{theme → runtime/theme}/popover.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/popover.mjs +0 -0
- /package/dist/{theme → runtime/theme}/radioGroup.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/radioGroup.mjs +0 -0
- /package/dist/{theme → runtime/theme}/select.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/select.mjs +0 -0
- /package/dist/{theme → runtime/theme}/switch.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/switch.mjs +0 -0
- /package/dist/{theme → runtime/theme}/tabs.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/tabs.mjs +0 -0
- /package/dist/{theme → runtime/theme}/toast.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/toast.mjs +0 -0
- /package/dist/{theme → runtime/theme}/toaster.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/toaster.mjs +0 -0
- /package/dist/{theme → runtime/theme}/tooltip.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/tooltip.mjs +0 -0
- /package/dist/{types → runtime/types}/components.d.ts +0 -0
- /package/dist/{types → runtime/types}/components.mjs +0 -0
- /package/dist/{types → runtime/types}/index.mjs +0 -0
- /package/dist/{types → runtime/types}/utils.d.ts +0 -0
- /package/dist/{types → runtime/types}/utils.mjs +0 -0
- /package/dist/{internal → runtime/utils}/extend-theme.d.ts +0 -0
- /package/dist/{internal → runtime/utils}/extend-theme.mjs +0 -0
- /package/dist/{internal → runtime/utils}/link.d.ts +0 -0
- /package/dist/{internal → runtime/utils}/link.mjs +0 -0
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type { PrimitiveProps, SwitchRootProps } from 'reka-ui'
|
|
4
|
-
import type { switch as _switch } from '../theme'
|
|
5
|
-
import type { ComponentAttrs } from '../types'
|
|
6
|
-
|
|
7
|
-
type SwitchVariants = VariantProps<typeof _switch>
|
|
8
|
-
|
|
9
|
-
export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<SwitchRootProps, 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
|
|
10
|
-
as?: PrimitiveProps['as']
|
|
11
|
-
size?: SwitchVariants['size']
|
|
12
|
-
/** When `true`, the loading icon will be displayed. */
|
|
13
|
-
loading?: boolean
|
|
14
|
-
/**
|
|
15
|
-
* The icon when the `loading` prop is `true`.
|
|
16
|
-
* @default app.icons.loading
|
|
17
|
-
*/
|
|
18
|
-
loadingIcon?: string
|
|
19
|
-
/** Display an icon when the switch is checked. */
|
|
20
|
-
checkedIcon?: string
|
|
21
|
-
/** Display an icon when the switch is unchecked. */
|
|
22
|
-
uncheckedIcon?: string
|
|
23
|
-
label?: string
|
|
24
|
-
description?: string
|
|
25
|
-
round?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface SwitchEmits {
|
|
29
|
-
(event: 'change', payload: Event): void
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface SwitchSlots {
|
|
33
|
-
label?: (props: { label?: string }) => any
|
|
34
|
-
description?: (props: { description?: string }) => any
|
|
35
|
-
}
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
<script lang="ts" setup>
|
|
39
|
-
import { reactivePick } from '@vueuse/core'
|
|
40
|
-
import { Label, Primitive, SwitchRoot, SwitchThumb, useForwardProps } from 'reka-ui'
|
|
41
|
-
import { computed, useId } from 'vue'
|
|
42
|
-
import { useTheme } from '../composables'
|
|
43
|
-
|
|
44
|
-
const props = withDefaults(defineProps<SwitchProps>(), {
|
|
45
|
-
size: 'md',
|
|
46
|
-
})
|
|
47
|
-
const emit = defineEmits<SwitchEmits>()
|
|
48
|
-
const slots = defineSlots<SwitchSlots>()
|
|
49
|
-
const modelValue = defineModel<boolean>({ default: undefined })
|
|
50
|
-
|
|
51
|
-
const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
|
|
52
|
-
const id = useId()
|
|
53
|
-
|
|
54
|
-
const { theme, createStyler } = useTheme()
|
|
55
|
-
const style = computed(() => {
|
|
56
|
-
const styler = createStyler(theme.value.switch)
|
|
57
|
-
return styler({ ...props, checked: false, unchecked: false })
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
function onUpdate(value: any) {
|
|
61
|
-
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
|
62
|
-
const event = new Event('change', { target: { value } })
|
|
63
|
-
emit('change', event)
|
|
64
|
-
}
|
|
65
|
-
</script>
|
|
66
|
-
|
|
67
|
-
<template>
|
|
68
|
-
<Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
69
|
-
<div :class="style.container({ class: props.ui?.container })">
|
|
70
|
-
<SwitchRoot
|
|
71
|
-
:id="id"
|
|
72
|
-
v-bind="rootProps"
|
|
73
|
-
v-model="modelValue"
|
|
74
|
-
:name="props.name"
|
|
75
|
-
:disabled="props.disabled || props.loading"
|
|
76
|
-
:class="style.base({ class: props.ui?.base })"
|
|
77
|
-
@update:model-value="onUpdate"
|
|
78
|
-
>
|
|
79
|
-
<SwitchThumb :class="style.thumb({ class: props.ui?.thumb })">
|
|
80
|
-
<i v-if="props.loading" :class="style.icon({ class: [theme.app.icons.loading, props.ui?.icon], checked: true, unchecked: true })"></i>
|
|
81
|
-
<template v-else>
|
|
82
|
-
<i v-if="props.checkedIcon" :class="style.icon({ class: [props.checkedIcon, props.ui?.icon], checked: true })"></i>
|
|
83
|
-
<i v-if="props.uncheckedIcon" :class="style.icon({ class: [props.uncheckedIcon, props.ui?.icon], unchecked: true })"></i>
|
|
84
|
-
</template>
|
|
85
|
-
</SwitchThumb>
|
|
86
|
-
</SwitchRoot>
|
|
87
|
-
</div>
|
|
88
|
-
<div v-if="props.label || slots.label || props.description || slots.description" :class="style.wrapper({ class: props.ui?.wrapper })">
|
|
89
|
-
<Label v-if="props.label || slots.label" :for="id" :class="style.label({ class: props.ui?.label })">
|
|
90
|
-
<slot name="label" :label="props.label">{{ props.label }}</slot>
|
|
91
|
-
</Label>
|
|
92
|
-
<p v-if="props.description || slots.description" :class="style.description({ class: props.ui?.description })">
|
|
93
|
-
<slot name="description" :description="props.description">
|
|
94
|
-
{{ props.description }}
|
|
95
|
-
</slot>
|
|
96
|
-
</p>
|
|
97
|
-
</div>
|
|
98
|
-
</Primitive>
|
|
99
|
-
</template>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
+
import type { PrimitiveProps, SwitchRootProps } from 'reka-ui'
|
|
4
|
+
import type { switch as _switch } from '../theme'
|
|
5
|
+
import type { ComponentAttrs } from '../types'
|
|
6
|
+
|
|
7
|
+
type SwitchVariants = VariantProps<typeof _switch>
|
|
8
|
+
|
|
9
|
+
export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<SwitchRootProps, 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
|
|
10
|
+
as?: PrimitiveProps['as']
|
|
11
|
+
size?: SwitchVariants['size']
|
|
12
|
+
/** When `true`, the loading icon will be displayed. */
|
|
13
|
+
loading?: boolean
|
|
14
|
+
/**
|
|
15
|
+
* The icon when the `loading` prop is `true`.
|
|
16
|
+
* @default app.icons.loading
|
|
17
|
+
*/
|
|
18
|
+
loadingIcon?: string
|
|
19
|
+
/** Display an icon when the switch is checked. */
|
|
20
|
+
checkedIcon?: string
|
|
21
|
+
/** Display an icon when the switch is unchecked. */
|
|
22
|
+
uncheckedIcon?: string
|
|
23
|
+
label?: string
|
|
24
|
+
description?: string
|
|
25
|
+
round?: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SwitchEmits {
|
|
29
|
+
(event: 'change', payload: Event): void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SwitchSlots {
|
|
33
|
+
label?: (props: { label?: string }) => any
|
|
34
|
+
description?: (props: { description?: string }) => any
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<script lang="ts" setup>
|
|
39
|
+
import { reactivePick } from '@vueuse/core'
|
|
40
|
+
import { Label, Primitive, SwitchRoot, SwitchThumb, useForwardProps } from 'reka-ui'
|
|
41
|
+
import { computed, useId } from 'vue'
|
|
42
|
+
import { useTheme } from '../composables'
|
|
43
|
+
|
|
44
|
+
const props = withDefaults(defineProps<SwitchProps>(), {
|
|
45
|
+
size: 'md',
|
|
46
|
+
})
|
|
47
|
+
const emit = defineEmits<SwitchEmits>()
|
|
48
|
+
const slots = defineSlots<SwitchSlots>()
|
|
49
|
+
const modelValue = defineModel<boolean>({ default: undefined })
|
|
50
|
+
|
|
51
|
+
const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
|
|
52
|
+
const id = useId()
|
|
53
|
+
|
|
54
|
+
const { theme, createStyler } = useTheme()
|
|
55
|
+
const style = computed(() => {
|
|
56
|
+
const styler = createStyler(theme.value.switch)
|
|
57
|
+
return styler({ ...props, checked: false, unchecked: false })
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
function onUpdate(value: any) {
|
|
61
|
+
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
|
62
|
+
const event = new Event('change', { target: { value } })
|
|
63
|
+
emit('change', event)
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<template>
|
|
68
|
+
<Primitive :as="props.as" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
69
|
+
<div :class="style.container({ class: props.ui?.container })">
|
|
70
|
+
<SwitchRoot
|
|
71
|
+
:id="id"
|
|
72
|
+
v-bind="rootProps"
|
|
73
|
+
v-model="modelValue"
|
|
74
|
+
:name="props.name"
|
|
75
|
+
:disabled="props.disabled || props.loading"
|
|
76
|
+
:class="style.base({ class: props.ui?.base })"
|
|
77
|
+
@update:model-value="onUpdate"
|
|
78
|
+
>
|
|
79
|
+
<SwitchThumb :class="style.thumb({ class: props.ui?.thumb })">
|
|
80
|
+
<i v-if="props.loading" :class="style.icon({ class: [theme.app.icons.loading, props.ui?.icon], checked: true, unchecked: true })"></i>
|
|
81
|
+
<template v-else>
|
|
82
|
+
<i v-if="props.checkedIcon" :class="style.icon({ class: [props.checkedIcon, props.ui?.icon], checked: true })"></i>
|
|
83
|
+
<i v-if="props.uncheckedIcon" :class="style.icon({ class: [props.uncheckedIcon, props.ui?.icon], unchecked: true })"></i>
|
|
84
|
+
</template>
|
|
85
|
+
</SwitchThumb>
|
|
86
|
+
</SwitchRoot>
|
|
87
|
+
</div>
|
|
88
|
+
<div v-if="props.label || slots.label || props.description || slots.description" :class="style.wrapper({ class: props.ui?.wrapper })">
|
|
89
|
+
<Label v-if="props.label || slots.label" :for="id" :class="style.label({ class: props.ui?.label })">
|
|
90
|
+
<slot name="label" :label="props.label">{{ props.label }}</slot>
|
|
91
|
+
</Label>
|
|
92
|
+
<p v-if="props.description || slots.description" :class="style.description({ class: props.ui?.description })">
|
|
93
|
+
<slot name="description" :description="props.description">
|
|
94
|
+
{{ props.description }}
|
|
95
|
+
</slot>
|
|
96
|
+
</p>
|
|
97
|
+
</div>
|
|
98
|
+
</Primitive>
|
|
99
|
+
</template>
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type { PrimitiveProps, TabsRootEmits, TabsRootProps } from 'reka-ui'
|
|
4
|
-
import type { tabs } from '../theme'
|
|
5
|
-
import type { ComponentAttrs, DynamicSlots } from '../types'
|
|
6
|
-
|
|
7
|
-
export interface TabsItem {
|
|
8
|
-
label?: string
|
|
9
|
-
icon?: string
|
|
10
|
-
slot?: string
|
|
11
|
-
content?: string
|
|
12
|
-
/** A unique value for the tab item. Defaults to the index. */
|
|
13
|
-
value?: string | number
|
|
14
|
-
disabled?: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type TabsVariants = VariantProps<typeof tabs>
|
|
18
|
-
|
|
19
|
-
export interface TabsProps<T> extends ComponentAttrs<typeof tabs>, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
|
|
20
|
-
as?: PrimitiveProps['as']
|
|
21
|
-
items?: T[]
|
|
22
|
-
variant?: TabsVariants['variant']
|
|
23
|
-
orientation?: TabsVariants['orientation']
|
|
24
|
-
size?: TabsVariants['size']
|
|
25
|
-
/** @default true */
|
|
26
|
-
full?: boolean
|
|
27
|
-
/**
|
|
28
|
-
* The content of the tabs, can be disabled to prevent rendering the content.
|
|
29
|
-
* @default true
|
|
30
|
-
*/
|
|
31
|
-
content?: boolean
|
|
32
|
-
/**
|
|
33
|
-
* The key used to get the label from the item.
|
|
34
|
-
* @default 'label'
|
|
35
|
-
*/
|
|
36
|
-
labelKey?: string
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface TabsEmits extends TabsRootEmits<string | number> {}
|
|
40
|
-
|
|
41
|
-
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
42
|
-
|
|
43
|
-
export type TabsSlots<T extends { slot?: string }> = {
|
|
44
|
-
leading?: SlotProps<T>
|
|
45
|
-
default?: SlotProps<T>
|
|
46
|
-
trailing?: SlotProps<T>
|
|
47
|
-
content?: SlotProps<T>
|
|
48
|
-
} & DynamicSlots<T, SlotProps<T>>
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<script lang="ts" setup generic="T extends TabsItem">
|
|
52
|
-
import { reactivePick } from '@vueuse/core'
|
|
53
|
-
import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from 'reka-ui'
|
|
54
|
-
import { computed } from 'vue'
|
|
55
|
-
import { useTheme } from '../composables'
|
|
56
|
-
import { get } from '../utils'
|
|
57
|
-
|
|
58
|
-
const props = withDefaults(defineProps<TabsProps<T>>(), {
|
|
59
|
-
defaultValue: '0',
|
|
60
|
-
variant: 'solid',
|
|
61
|
-
orientation: 'horizontal',
|
|
62
|
-
size: 'md',
|
|
63
|
-
full: true,
|
|
64
|
-
content: true,
|
|
65
|
-
labelKey: 'label',
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
const emits = defineEmits<TabsEmits>()
|
|
69
|
-
const slots = defineSlots<TabsSlots<T>>()
|
|
70
|
-
|
|
71
|
-
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emits)
|
|
72
|
-
|
|
73
|
-
const { theme, createStyler } = useTheme()
|
|
74
|
-
const style = computed(() => {
|
|
75
|
-
const styler = createStyler(theme.value.tabs)
|
|
76
|
-
return styler(props)
|
|
77
|
-
})
|
|
78
|
-
</script>
|
|
79
|
-
|
|
80
|
-
<template>
|
|
81
|
-
<TabsRoot v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
82
|
-
<TabsList :class="style.list({ class: props.ui?.list })">
|
|
83
|
-
<TabsIndicator :class="style.indicator({ class: props.ui?.indicator })" />
|
|
84
|
-
|
|
85
|
-
<TabsTrigger
|
|
86
|
-
v-for="(item, index) of items"
|
|
87
|
-
:key="index"
|
|
88
|
-
:value="item.value || String(index)"
|
|
89
|
-
:disabled="item.disabled"
|
|
90
|
-
:class="style.trigger({ class: props.ui?.trigger })"
|
|
91
|
-
>
|
|
92
|
-
<slot name="leading" :item="item" :index="index">
|
|
93
|
-
<i v-if="item.icon" :class="style.leadingIcon({ class: [item.icon, props.ui?.leadingIcon] })"></i>
|
|
94
|
-
</slot>
|
|
95
|
-
|
|
96
|
-
<span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })">
|
|
97
|
-
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
98
|
-
</span>
|
|
99
|
-
|
|
100
|
-
<slot name="trailing" :item="item" :index="index"></slot>
|
|
101
|
-
</TabsTrigger>
|
|
102
|
-
</TabsList>
|
|
103
|
-
|
|
104
|
-
<template v-if="props.content">
|
|
105
|
-
<TabsContent
|
|
106
|
-
v-for="(item, index) of items"
|
|
107
|
-
:key="index"
|
|
108
|
-
:value="item.value || String(index)"
|
|
109
|
-
:class="style.content({ class: props.ui?.content })"
|
|
110
|
-
>
|
|
111
|
-
<slot :name="item.slot || 'content'" :item="item" :index="index">
|
|
112
|
-
{{ item.content }}
|
|
113
|
-
</slot>
|
|
114
|
-
</TabsContent>
|
|
115
|
-
</template>
|
|
116
|
-
</TabsRoot>
|
|
117
|
-
</template>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
+
import type { PrimitiveProps, TabsRootEmits, TabsRootProps } from 'reka-ui'
|
|
4
|
+
import type { tabs } from '../theme'
|
|
5
|
+
import type { ComponentAttrs, DynamicSlots } from '../types'
|
|
6
|
+
|
|
7
|
+
export interface TabsItem {
|
|
8
|
+
label?: string
|
|
9
|
+
icon?: string
|
|
10
|
+
slot?: string
|
|
11
|
+
content?: string
|
|
12
|
+
/** A unique value for the tab item. Defaults to the index. */
|
|
13
|
+
value?: string | number
|
|
14
|
+
disabled?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type TabsVariants = VariantProps<typeof tabs>
|
|
18
|
+
|
|
19
|
+
export interface TabsProps<T> extends ComponentAttrs<typeof tabs>, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
|
|
20
|
+
as?: PrimitiveProps['as']
|
|
21
|
+
items?: T[]
|
|
22
|
+
variant?: TabsVariants['variant']
|
|
23
|
+
orientation?: TabsVariants['orientation']
|
|
24
|
+
size?: TabsVariants['size']
|
|
25
|
+
/** @default true */
|
|
26
|
+
full?: boolean
|
|
27
|
+
/**
|
|
28
|
+
* The content of the tabs, can be disabled to prevent rendering the content.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
content?: boolean
|
|
32
|
+
/**
|
|
33
|
+
* The key used to get the label from the item.
|
|
34
|
+
* @default 'label'
|
|
35
|
+
*/
|
|
36
|
+
labelKey?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TabsEmits extends TabsRootEmits<string | number> {}
|
|
40
|
+
|
|
41
|
+
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
42
|
+
|
|
43
|
+
export type TabsSlots<T extends { slot?: string }> = {
|
|
44
|
+
leading?: SlotProps<T>
|
|
45
|
+
default?: SlotProps<T>
|
|
46
|
+
trailing?: SlotProps<T>
|
|
47
|
+
content?: SlotProps<T>
|
|
48
|
+
} & DynamicSlots<T, SlotProps<T>>
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<script lang="ts" setup generic="T extends TabsItem">
|
|
52
|
+
import { reactivePick } from '@vueuse/core'
|
|
53
|
+
import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from 'reka-ui'
|
|
54
|
+
import { computed } from 'vue'
|
|
55
|
+
import { useTheme } from '../composables'
|
|
56
|
+
import { get } from '../utils'
|
|
57
|
+
|
|
58
|
+
const props = withDefaults(defineProps<TabsProps<T>>(), {
|
|
59
|
+
defaultValue: '0',
|
|
60
|
+
variant: 'solid',
|
|
61
|
+
orientation: 'horizontal',
|
|
62
|
+
size: 'md',
|
|
63
|
+
full: true,
|
|
64
|
+
content: true,
|
|
65
|
+
labelKey: 'label',
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const emits = defineEmits<TabsEmits>()
|
|
69
|
+
const slots = defineSlots<TabsSlots<T>>()
|
|
70
|
+
|
|
71
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emits)
|
|
72
|
+
|
|
73
|
+
const { theme, createStyler } = useTheme()
|
|
74
|
+
const style = computed(() => {
|
|
75
|
+
const styler = createStyler(theme.value.tabs)
|
|
76
|
+
return styler(props)
|
|
77
|
+
})
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<template>
|
|
81
|
+
<TabsRoot v-bind="rootProps" :class="style.root({ class: [props.class, props.ui?.root] })">
|
|
82
|
+
<TabsList :class="style.list({ class: props.ui?.list })">
|
|
83
|
+
<TabsIndicator :class="style.indicator({ class: props.ui?.indicator })" />
|
|
84
|
+
|
|
85
|
+
<TabsTrigger
|
|
86
|
+
v-for="(item, index) of items"
|
|
87
|
+
:key="index"
|
|
88
|
+
:value="item.value || String(index)"
|
|
89
|
+
:disabled="item.disabled"
|
|
90
|
+
:class="style.trigger({ class: props.ui?.trigger })"
|
|
91
|
+
>
|
|
92
|
+
<slot name="leading" :item="item" :index="index">
|
|
93
|
+
<i v-if="item.icon" :class="style.leadingIcon({ class: [item.icon, props.ui?.leadingIcon] })"></i>
|
|
94
|
+
</slot>
|
|
95
|
+
|
|
96
|
+
<span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })">
|
|
97
|
+
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
98
|
+
</span>
|
|
99
|
+
|
|
100
|
+
<slot name="trailing" :item="item" :index="index"></slot>
|
|
101
|
+
</TabsTrigger>
|
|
102
|
+
</TabsList>
|
|
103
|
+
|
|
104
|
+
<template v-if="props.content">
|
|
105
|
+
<TabsContent
|
|
106
|
+
v-for="(item, index) of items"
|
|
107
|
+
:key="index"
|
|
108
|
+
:value="item.value || String(index)"
|
|
109
|
+
:class="style.content({ class: props.ui?.content })"
|
|
110
|
+
>
|
|
111
|
+
<slot :name="item.slot || 'content'" :item="item" :index="index">
|
|
112
|
+
{{ item.content }}
|
|
113
|
+
</slot>
|
|
114
|
+
</TabsContent>
|
|
115
|
+
</template>
|
|
116
|
+
</TabsRoot>
|
|
117
|
+
</template>
|
|
@@ -139,5 +139,39 @@ function getOffset(index: number) {
|
|
|
139
139
|
</template>
|
|
140
140
|
|
|
141
141
|
<style>
|
|
142
|
-
@keyframes toast-collapsed-closed
|
|
142
|
+
@keyframes toast-collapsed-closed {
|
|
143
|
+
from {
|
|
144
|
+
transform: var(--transform);
|
|
145
|
+
}
|
|
146
|
+
to {
|
|
147
|
+
transform: translateY(calc((var(--before) - var(--height)) * var(--gap)))
|
|
148
|
+
scale(var(--scale));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
@keyframes toast-closed {
|
|
152
|
+
from {
|
|
153
|
+
transform: var(--transform);
|
|
154
|
+
}
|
|
155
|
+
to {
|
|
156
|
+
transform: translateY(
|
|
157
|
+
calc((var(--offset) - var(--height)) * var(--translate-factor))
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
@keyframes toast-slide-left {
|
|
162
|
+
from {
|
|
163
|
+
transform: translateX(0) translateY(var(--translate));
|
|
164
|
+
}
|
|
165
|
+
to {
|
|
166
|
+
transform: translateX(-100%) translateY(var(--translate));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
@keyframes toast-slide-right {
|
|
170
|
+
from {
|
|
171
|
+
transform: translateX(0) translateY(var(--translate));
|
|
172
|
+
}
|
|
173
|
+
to {
|
|
174
|
+
transform: translateX(100%) translateY(var(--translate));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
143
177
|
</style>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Accordion", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Accordion.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "App", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _App.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Button", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Button.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "Card", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _Card.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "Checkbox", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _Checkbox.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "Drawer", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _Drawer.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "Input", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _Input.default;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "Link", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _Link.default;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "Modal", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _Modal.default;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "ModalProvider", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _ModalProvider.default;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "Popover", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _Popover.default;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "RadioGroup", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _RadioGroup.default;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "Select", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _Select.default;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "Switch", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _Switch.default;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "Tabs", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _Tabs.default;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "Toast", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _Toast.default;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "Toaster", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _Toaster.default;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "Tooltip", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _Tooltip.default;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
var _Accordion = _interopRequireDefault(require("./Accordion.vue"));
|
|
115
|
+
var _App = _interopRequireDefault(require("./App.vue"));
|
|
116
|
+
var _Button = _interopRequireDefault(require("./Button.vue"));
|
|
117
|
+
var _Card = _interopRequireDefault(require("./Card.vue"));
|
|
118
|
+
var _Checkbox = _interopRequireDefault(require("./Checkbox.vue"));
|
|
119
|
+
var _Drawer = _interopRequireDefault(require("./Drawer.vue"));
|
|
120
|
+
var _Input = _interopRequireDefault(require("./Input.vue"));
|
|
121
|
+
var _Link = _interopRequireDefault(require("./Link.vue"));
|
|
122
|
+
var _Modal = _interopRequireDefault(require("./Modal.vue"));
|
|
123
|
+
var _ModalProvider = _interopRequireDefault(require("./ModalProvider.vue"));
|
|
124
|
+
var _Popover = _interopRequireDefault(require("./Popover.vue"));
|
|
125
|
+
var _RadioGroup = _interopRequireDefault(require("./RadioGroup.vue"));
|
|
126
|
+
var _Select = _interopRequireDefault(require("./Select.vue"));
|
|
127
|
+
var _Switch = _interopRequireDefault(require("./Switch.vue"));
|
|
128
|
+
var _Tabs = _interopRequireDefault(require("./Tabs.vue"));
|
|
129
|
+
var _Toast = _interopRequireDefault(require("./Toast.vue"));
|
|
130
|
+
var _Toaster = _interopRequireDefault(require("./Toaster.vue"));
|
|
131
|
+
var _Tooltip = _interopRequireDefault(require("./Tooltip.vue"));
|
|
132
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useComponentIcons", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useComponentIcons.useComponentIcons;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useModal", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _useModal.useModal;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "useTheme", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _useTheme.useTheme;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useToast", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _useToast.useToast;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _useComponentIcons = require("./useComponentIcons.cjs");
|
|
31
|
+
var _useModal = require("./useModal.cjs");
|
|
32
|
+
var _useTheme = require("./useTheme.cjs");
|
|
33
|
+
var _useToast = require("./useToast.cjs");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useComponentIcons = useComponentIcons;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
var _useTheme = require("./useTheme.cjs");
|
|
9
|
+
function useComponentIcons(componentProps) {
|
|
10
|
+
const {
|
|
11
|
+
theme
|
|
12
|
+
} = (0, _useTheme.useTheme)();
|
|
13
|
+
const props = (0, _vue.computed)(() => (0, _vue.toValue)(componentProps));
|
|
14
|
+
const isPrefix = (0, _vue.computed)(() => props.value.icon && props.value.prefix || props.value.icon && !props.value.suffix || props.value.loading && !props.value.suffix || !!props.value.prefixIcon);
|
|
15
|
+
const isSuffix = (0, _vue.computed)(() => props.value.icon && props.value.suffix || props.value.loading && props.value.suffix || !!props.value.suffixIcon);
|
|
16
|
+
const prefixIconName = (0, _vue.computed)(() => {
|
|
17
|
+
if (props.value.loading) return props.value.loadingIcon || theme.value.app.icons.loading;
|
|
18
|
+
return props.value.prefixIcon || props.value.icon;
|
|
19
|
+
});
|
|
20
|
+
const suffixIconName = (0, _vue.computed)(() => {
|
|
21
|
+
if (props.value.loading && !isPrefix.value) return props.value.loadingIcon || theme.value.app.icons.loading;
|
|
22
|
+
return props.value.suffixIcon || props.value.icon;
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
isPrefix,
|
|
26
|
+
isSuffix,
|
|
27
|
+
prefixIconName,
|
|
28
|
+
suffixIconName
|
|
29
|
+
};
|
|
30
|
+
}
|