@indielayer/ui 1.0.0-alpha.0 → 1.0.0-alpha.2
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 +26 -10
- package/lib/components/avatar/Avatar.vue.d.ts +2 -2
- package/lib/components/badge/Badge.vue.d.ts +2 -2
- package/lib/components/button/Button.vue.d.ts +2 -2
- package/lib/components/button/ButtonGroup.vue.d.ts +2 -2
- package/lib/components/checkbox/Checkbox.vue.d.ts +5 -4
- package/lib/components/drawer/Drawer.vue.d.ts +1 -1
- package/lib/components/icon/Icon.vue.d.ts +2 -2
- package/lib/components/index.d.ts +2 -2
- package/lib/components/input/Input.vue.d.ts +4 -3
- package/lib/components/menu/Menu.vue.d.ts +2 -2
- package/lib/components/menu/MenuItem.vue.d.ts +3 -3
- package/lib/components/notifications/Notifications.vue.d.ts +2 -2
- package/lib/components/pagination/Pagination.vue.d.ts +3 -2
- package/lib/components/pagination/PaginationItem.vue.d.ts +2 -2
- package/lib/components/radio/Radio.vue.d.ts +3 -3
- package/lib/components/select/Select.vue.d.ts +4 -3
- package/lib/components/slider/Slider.vue.d.ts +3 -3
- package/lib/components/spacer/Spacer.vue.d.ts +1 -1
- package/lib/components/spinner/Spinner.vue.d.ts +2 -2
- package/lib/components/{tabs → tab}/Tab.vue.d.ts +2 -2
- package/lib/components/{tabs/Tabs.vue.d.ts → tab/TabGroup.vue.d.ts} +0 -0
- package/lib/components/table/TableBody.vue.d.ts +1 -1
- package/lib/components/table/TableHead.vue.d.ts +1 -1
- package/lib/components/tag/Tag.vue.d.ts +2 -2
- package/lib/components/textarea/Textarea.vue.d.ts +4 -12
- package/lib/components/toggle/Toggle.vue.d.ts +3 -3
- package/lib/composables/colors.d.ts +1 -1
- package/lib/composables/css.d.ts +4 -4
- package/lib/composables/keys.d.ts +1 -0
- package/lib/create.d.ts +11 -0
- package/lib/index.cjs.js +2 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.es.js +183 -107
- package/lib/install.d.ts +4 -6
- package/lib/nuxt.js +15 -16
- package/lib/nuxt.plugin.js +8 -0
- package/lib/style.css +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +19 -15
- package/src/components/alert/Alert.vue +164 -0
- package/src/components/avatar/Avatar.vue +137 -0
- package/src/components/badge/Badge.vue +107 -0
- package/src/components/breadcrumbs/Breadcrumbs.vue +60 -0
- package/src/components/button/Button.vue +433 -0
- package/src/components/button/ButtonGroup.vue +73 -0
- package/src/components/card/Card.vue +25 -0
- package/src/components/checkbox/Checkbox.vue +205 -0
- package/src/components/collapse/Collapse.vue +181 -0
- package/src/components/container/Container.vue +23 -0
- package/src/components/divider/Divider.vue +52 -0
- package/src/components/drawer/Drawer.vue +244 -0
- package/src/components/form/Form.vue +111 -0
- package/src/components/icon/Icon.vue +56 -0
- package/src/components/image/Image.vue +36 -0
- package/src/components/index.ts +45 -0
- package/src/components/input/Input.vue +198 -0
- package/src/components/link/Link.vue +110 -0
- package/src/components/menu/Menu.vue +118 -0
- package/src/components/menu/MenuItem.vue +277 -0
- package/src/components/modal/Modal.vue +175 -0
- package/src/components/notifications/Notifications.vue +318 -0
- package/src/components/pagination/Pagination.vue +181 -0
- package/src/components/pagination/PaginationItem.vue +58 -0
- package/src/components/popover/Popover.vue +194 -0
- package/src/components/popover/PopoverContainer.vue +23 -0
- package/src/components/progress/Progress.vue +86 -0
- package/src/components/radio/Radio.vue +220 -0
- package/src/components/scroll/Scroll.vue +143 -0
- package/src/components/select/Select.vue +408 -0
- package/src/components/skeleton/Skeleton.vue +23 -0
- package/src/components/slider/Slider.vue +240 -0
- package/src/components/spacer/Spacer.vue +11 -0
- package/src/components/spinner/Spinner.vue +45 -0
- package/src/components/tab/Tab.vue +100 -0
- package/src/components/tab/TabGroup.vue +151 -0
- package/src/components/table/Table.vue +172 -0
- package/src/components/table/TableBody.vue +13 -0
- package/src/components/table/TableCell.vue +78 -0
- package/src/components/table/TableHead.vue +15 -0
- package/src/components/table/TableHeader.vue +94 -0
- package/src/components/table/TableRow.vue +43 -0
- package/src/components/tag/Tag.vue +98 -0
- package/src/components/textarea/Textarea.vue +156 -0
- package/src/components/toggle/Toggle.vue +144 -0
- package/src/components/tooltip/Tooltip.vue +26 -0
- package/src/composables/colors-utils.ts +378 -0
- package/src/composables/colors.ts +82 -0
- package/src/composables/common.ts +20 -0
- package/src/composables/css.ts +45 -0
- package/src/composables/index.ts +7 -0
- package/src/composables/inputtable.ts +128 -0
- package/src/composables/interactive.ts +16 -0
- package/src/composables/keys.ts +8 -0
- package/src/composables/notification.ts +10 -0
- package/src/create.ts +36 -0
- package/src/exports/nuxt.js +32 -0
- package/src/exports/nuxt.plugin.js +8 -0
- package/src/exports/tailwind.preset.js +55 -0
- package/src/index.ts +8 -0
- package/src/install.ts +8 -0
- package/src/shims-vue.d.ts +6 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, type PropType } from 'vue'
|
|
3
|
+
|
|
4
|
+
const validators = {
|
|
5
|
+
verticalAlign: ['baseline','bottom','middle','text-bottom','text-top','top'],
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default defineComponent({
|
|
9
|
+
name: 'XTableRow',
|
|
10
|
+
|
|
11
|
+
validators,
|
|
12
|
+
|
|
13
|
+
props: {
|
|
14
|
+
pointer: Boolean,
|
|
15
|
+
striped: Boolean,
|
|
16
|
+
verticalAlign: {
|
|
17
|
+
type: String as PropType<'baseline' | 'bottom' | 'middle' | 'text-bottom' | 'text-top' | 'top'>,
|
|
18
|
+
default: 'top',
|
|
19
|
+
validator: (value: string) => validators.verticalAlign.includes(value),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<tr
|
|
27
|
+
:class="[
|
|
28
|
+
striped ? 'odd:bg-gray-50 dark:odd:bg-gray-800' : 'border-b border-gray-200 dark:border-gray-700',
|
|
29
|
+
{
|
|
30
|
+
'hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer': pointer,
|
|
31
|
+
// vertical-align
|
|
32
|
+
'align-baseline': verticalAlign === 'baseline',
|
|
33
|
+
'align-bottom': verticalAlign === 'bottom',
|
|
34
|
+
'align-middle': verticalAlign === 'middle',
|
|
35
|
+
'align-text-bottom': verticalAlign === 'text-bottom',
|
|
36
|
+
'align-text-top': verticalAlign === 'text-top',
|
|
37
|
+
'align-top': verticalAlign === 'top',
|
|
38
|
+
},
|
|
39
|
+
]"
|
|
40
|
+
>
|
|
41
|
+
<slot></slot>
|
|
42
|
+
</tr>
|
|
43
|
+
</template>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, defineComponent } from 'vue'
|
|
3
|
+
import { useCSS } from '../../composables/css'
|
|
4
|
+
import { useColors } from '../../composables/colors'
|
|
5
|
+
import { useCommon } from '../../composables/common'
|
|
6
|
+
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
name: 'XTag',
|
|
9
|
+
|
|
10
|
+
props: {
|
|
11
|
+
...useCommon.props(),
|
|
12
|
+
...useColors.props('gray'),
|
|
13
|
+
tag: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: 'span',
|
|
16
|
+
},
|
|
17
|
+
rounded: Boolean,
|
|
18
|
+
removable: Boolean,
|
|
19
|
+
outlined: Boolean,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
emits: ['remove'],
|
|
23
|
+
|
|
24
|
+
setup(props) {
|
|
25
|
+
const css = useCSS()
|
|
26
|
+
const colors = useColors()
|
|
27
|
+
const styles = computed(() => {
|
|
28
|
+
const color = colors.getPalette(props.color)
|
|
29
|
+
|
|
30
|
+
return css.variables({
|
|
31
|
+
bg: color[100],
|
|
32
|
+
text: color[800],
|
|
33
|
+
border: color[800],
|
|
34
|
+
dark: {
|
|
35
|
+
text: props.outlined ? color[200] : color[800],
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const sizeClasses = computed(() => {
|
|
41
|
+
if (props.size === 'xs') return 'px-2 py-1 text-xs'
|
|
42
|
+
else if (props.size === 'sm') return 'px-2 py-1 text-sm'
|
|
43
|
+
else if (props.size === 'lg') return 'px-4 py-3 text-lg'
|
|
44
|
+
else if (props.size === 'xl') return 'px-6 py-6 text-xl'
|
|
45
|
+
|
|
46
|
+
return 'px-3 py-2'
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
styles,
|
|
51
|
+
sizeClasses,
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<component
|
|
59
|
+
:is="tag"
|
|
60
|
+
class="inline-flex items-center leading-none whitespace-nowrap
|
|
61
|
+
text-[color:var(--x-text)]
|
|
62
|
+
dark:text-[color:var(--x-dark-text)]
|
|
63
|
+
border-[color:var(--x-border)
|
|
64
|
+
"
|
|
65
|
+
:style="styles"
|
|
66
|
+
:class="
|
|
67
|
+
[
|
|
68
|
+
sizeClasses,
|
|
69
|
+
outlined ? 'border' : 'bg-[color:var(--x-bg)]',
|
|
70
|
+
rounded ? 'rounded-full' : 'rounded'
|
|
71
|
+
]"
|
|
72
|
+
>
|
|
73
|
+
<span
|
|
74
|
+
v-if="removable"
|
|
75
|
+
class="flex items-center"
|
|
76
|
+
>
|
|
77
|
+
<slot></slot>
|
|
78
|
+
<svg
|
|
79
|
+
width="24"
|
|
80
|
+
height="24"
|
|
81
|
+
viewBox="0 0 24 24"
|
|
82
|
+
stroke="currentColor"
|
|
83
|
+
stroke-linejoin="round"
|
|
84
|
+
stroke-linecap="round"
|
|
85
|
+
fill="none"
|
|
86
|
+
role="presentation"
|
|
87
|
+
class="stroke-2 w-4 h-4 ml-1 cursor-pointer hover:text-gray-700 transition-colors duration-150 ease-in-out flex-shrink-0"
|
|
88
|
+
@click="(e) => $emit('remove', e)"
|
|
89
|
+
>
|
|
90
|
+
<path d="M6 18L18 6M6 6l12 12" />
|
|
91
|
+
</svg>
|
|
92
|
+
</span>
|
|
93
|
+
|
|
94
|
+
<template v-else>
|
|
95
|
+
<slot></slot>
|
|
96
|
+
</template>
|
|
97
|
+
</component>
|
|
98
|
+
</template>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, ref, watch, onMounted, onBeforeUnmount } from 'vue'
|
|
3
|
+
import { useCSS } from '../../composables/css'
|
|
4
|
+
import { useCommon } from '../../composables/common'
|
|
5
|
+
import { useColors } from '../../composables/colors'
|
|
6
|
+
import { useInputtable } from '../../composables/inputtable'
|
|
7
|
+
import { useInteractive } from '../../composables/interactive'
|
|
8
|
+
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
name: 'XTextarea',
|
|
11
|
+
|
|
12
|
+
validators: {
|
|
13
|
+
...useCommon.validators(),
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
...useCommon.props(),
|
|
18
|
+
...useInteractive.props(),
|
|
19
|
+
...useInputtable.props(),
|
|
20
|
+
helper: String,
|
|
21
|
+
label: String,
|
|
22
|
+
dir: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: 'ltr',
|
|
25
|
+
},
|
|
26
|
+
max: Number,
|
|
27
|
+
maxlength: Number,
|
|
28
|
+
min: Number,
|
|
29
|
+
minlength: Number,
|
|
30
|
+
placeholder: String,
|
|
31
|
+
adjustToText: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: true,
|
|
34
|
+
},
|
|
35
|
+
preventEnter: Boolean,
|
|
36
|
+
inputClass: String,
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
emits: useInputtable.emits(),
|
|
40
|
+
|
|
41
|
+
setup(props, { emit }) {
|
|
42
|
+
const elRef = ref<HTMLTextAreaElement>()
|
|
43
|
+
let observer: ResizeObserver | null = null
|
|
44
|
+
|
|
45
|
+
onMounted(() => {
|
|
46
|
+
if (elRef.value) {
|
|
47
|
+
observer = new ResizeObserver(resize)
|
|
48
|
+
observer.observe(elRef.value)
|
|
49
|
+
window.addEventListener('resize', resize)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
onBeforeUnmount(() => {
|
|
54
|
+
if (observer) observer.disconnect()
|
|
55
|
+
window.removeEventListener('resize', resize)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
watch([() => props.modelValue, () => props.size], () => {
|
|
59
|
+
setTimeout(resize)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const css = useCSS('textarea')
|
|
63
|
+
const colors = useColors()
|
|
64
|
+
const color = colors.getPalette('primary')
|
|
65
|
+
const style = css.get('border', color[500])
|
|
66
|
+
|
|
67
|
+
function onInput() {
|
|
68
|
+
resize()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function onEnter(e: KeyboardEvent) {
|
|
72
|
+
if (props.preventEnter) e.preventDefault()
|
|
73
|
+
e.stopPropagation()
|
|
74
|
+
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function resize() {
|
|
79
|
+
if (props.adjustToText && elRef.value) {
|
|
80
|
+
elRef.value.style.height = '1px'
|
|
81
|
+
elRef.value.style.height = (2 + elRef.value.scrollHeight) + 'px'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const interactive = useInteractive(elRef)
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
...interactive,
|
|
89
|
+
...useInputtable(props, { focus: interactive.focus, emit }),
|
|
90
|
+
elRef,
|
|
91
|
+
style,
|
|
92
|
+
onInput,
|
|
93
|
+
onEnter,
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<template>
|
|
100
|
+
<label
|
|
101
|
+
class="inline-block relative align-bottom text-left"
|
|
102
|
+
:class="{ 'mb-3': isInsideForm }"
|
|
103
|
+
>
|
|
104
|
+
<p
|
|
105
|
+
v-if="label"
|
|
106
|
+
class="font-medium text-gray-800 dark:text-gray-200 mb-1"
|
|
107
|
+
:class="{
|
|
108
|
+
'text-xs': size === 'xs',
|
|
109
|
+
'text-sm': size === 'sm',
|
|
110
|
+
'text-lg': size === 'lg',
|
|
111
|
+
'text-xl': size === 'xl',
|
|
112
|
+
}"
|
|
113
|
+
v-text="label"
|
|
114
|
+
></p>
|
|
115
|
+
|
|
116
|
+
<textarea
|
|
117
|
+
ref="elRef"
|
|
118
|
+
class="appearance-none block w-full placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none transition-colors duration-150 ease-in-out border-gray-300 dark:border-gray-700 resize-none overflow-hidden border shadow-sm rounded-md
|
|
119
|
+
focus:border-[color:var(--x-textarea-border)]
|
|
120
|
+
"
|
|
121
|
+
:style="style"
|
|
122
|
+
:class="[
|
|
123
|
+
disabled ? 'bg-gray-100 dark:bg-gray-700 text-gray-500 cursor-not-allowed' : 'bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200',
|
|
124
|
+
{
|
|
125
|
+
// size
|
|
126
|
+
'px-2 py-1 text-xs': size === 'xs',
|
|
127
|
+
'px-2 py-2 text-sm': size === 'sm',
|
|
128
|
+
'px-3 py-2': !size || !['auto', 'xs', 'sm', 'lg', 'xl'].includes(size),
|
|
129
|
+
'px-4 py-3 text-lg': size === 'lg',
|
|
130
|
+
'px-5 py-4 text-xl': size === 'xl',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
// error
|
|
134
|
+
'border-red-500 focus:border-red-500 dark:focus:border-red-500': errorInternal,
|
|
135
|
+
},
|
|
136
|
+
inputClass,
|
|
137
|
+
]"
|
|
138
|
+
:disabled="disabled"
|
|
139
|
+
:max="max"
|
|
140
|
+
:maxlength="maxlength"
|
|
141
|
+
:min="min"
|
|
142
|
+
:dir="dir"
|
|
143
|
+
:minlength="minlength"
|
|
144
|
+
:name="name"
|
|
145
|
+
:placeholder="placeholder"
|
|
146
|
+
:readonly="readonly"
|
|
147
|
+
:value="modelValue?.toString()"
|
|
148
|
+
v-on="inputListeners"
|
|
149
|
+
@keydown.enter="onEnter"
|
|
150
|
+
@input="onInput"
|
|
151
|
+
></textarea>
|
|
152
|
+
|
|
153
|
+
<p v-if="errorInternal" class="text-sm text-red-500 mt-1" v-text="errorInternal"></p>
|
|
154
|
+
<p v-else-if="helper" class="text-sm text-gray-500 mt-1" v-text="helper"></p>
|
|
155
|
+
</label>
|
|
156
|
+
</template>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, defineComponent, ref } from 'vue'
|
|
3
|
+
import { useCSS } from '../../composables/css'
|
|
4
|
+
import { useCommon } from '../../composables/common'
|
|
5
|
+
import { useColors } from '../../composables/colors'
|
|
6
|
+
import { useInputtable } from '../../composables/inputtable'
|
|
7
|
+
import { useInteractive } from '../../composables/interactive'
|
|
8
|
+
|
|
9
|
+
import XSpinner from '../../components/spinner/Spinner.vue'
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: 'XToggle',
|
|
13
|
+
|
|
14
|
+
components: {
|
|
15
|
+
XSpinner,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
validators: {
|
|
19
|
+
...useCommon.validators(),
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
props: {
|
|
23
|
+
...useCommon.props(),
|
|
24
|
+
...useColors.props('primary'),
|
|
25
|
+
...useInteractive.props(),
|
|
26
|
+
...useInputtable.props(),
|
|
27
|
+
id: String,
|
|
28
|
+
label: String,
|
|
29
|
+
glow: Boolean,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
emits: useInputtable.emits(false),
|
|
33
|
+
|
|
34
|
+
setup(props, { emit }) {
|
|
35
|
+
const elRef = ref<HTMLElement>()
|
|
36
|
+
const checked = computed({
|
|
37
|
+
get(): boolean {
|
|
38
|
+
return !!props.modelValue
|
|
39
|
+
},
|
|
40
|
+
set(val: boolean) {
|
|
41
|
+
emit('update:modelValue', val)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const css = useCSS()
|
|
46
|
+
const colors = useColors()
|
|
47
|
+
|
|
48
|
+
const styles = computed(() => {
|
|
49
|
+
const color = colors.getPalette(props.color)
|
|
50
|
+
|
|
51
|
+
return css.variables({
|
|
52
|
+
bg: color[500],
|
|
53
|
+
dark: {
|
|
54
|
+
bg: color[600],
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const interactive = useInteractive(elRef)
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
...interactive,
|
|
63
|
+
...useInputtable(props, { focus: interactive.focus, emit, withListeners: false }),
|
|
64
|
+
elRef,
|
|
65
|
+
checked,
|
|
66
|
+
styles,
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<label
|
|
74
|
+
class="inline-block mb-1 pb-2"
|
|
75
|
+
:class="[!disabled ? 'cursor-pointer' : 'cursor-not-allowed']"
|
|
76
|
+
>
|
|
77
|
+
<div class="flex items-center">
|
|
78
|
+
<div
|
|
79
|
+
class="flex items-center rounded-full transition-colors duration-300 border-[3px] shrink-0 border-transparent"
|
|
80
|
+
:style="styles"
|
|
81
|
+
:class="{
|
|
82
|
+
[`shadow-lg shadow-${color}-500/50`]: glow && modelValue,
|
|
83
|
+
'bg-gray-300 dark:bg-gray-500': !disabled && !checked && !loading,
|
|
84
|
+
'bg-gray-100 dark:bg-gray-700': disabled || loading,
|
|
85
|
+
'bg-[color:var(--x-bg)]': !disabled && checked,
|
|
86
|
+
}"
|
|
87
|
+
>
|
|
88
|
+
<div
|
|
89
|
+
class="relative shrink-0"
|
|
90
|
+
:class="[
|
|
91
|
+
{
|
|
92
|
+
'w-6': size === 'sm' || size === 'xs',
|
|
93
|
+
'w-8': !size || !['xs', 'sm', 'lg', 'xl'].includes(size),
|
|
94
|
+
'w-10': size === 'lg',
|
|
95
|
+
'w-12': size === 'xl',
|
|
96
|
+
}
|
|
97
|
+
]"
|
|
98
|
+
>
|
|
99
|
+
<input
|
|
100
|
+
:id="id"
|
|
101
|
+
ref="elRef"
|
|
102
|
+
v-model="checked"
|
|
103
|
+
:aria-checked="checked ? 'true' : 'false'"
|
|
104
|
+
:aria-disabled="disabled ? 'true' : undefined"
|
|
105
|
+
type="checkbox"
|
|
106
|
+
class="hidden"
|
|
107
|
+
:disabled="disabled || loading"
|
|
108
|
+
:name="name"
|
|
109
|
+
:required="required"
|
|
110
|
+
:value="modelValue"
|
|
111
|
+
/>
|
|
112
|
+
<div
|
|
113
|
+
class="rounded-full shadow transform transition duration-300 flex-shrink-0"
|
|
114
|
+
:class="[
|
|
115
|
+
{
|
|
116
|
+
'h-3 w-3': size === 'sm' || size === 'xs',
|
|
117
|
+
'h-4 w-4': !size || !['xs', 'sm', 'lg', 'xl'].includes(size),
|
|
118
|
+
'h-5 w-5': size === 'lg',
|
|
119
|
+
'h-6 w-6': size === 'xl',
|
|
120
|
+
'translate-x-full': checked,
|
|
121
|
+
'bg-gray-shadow-md': !disabled
|
|
122
|
+
},
|
|
123
|
+
[disabled ? 'bg-gray-50 dark:bg-gray-800' : 'bg-white dark:bg-gray-800']
|
|
124
|
+
]"
|
|
125
|
+
></div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
<span
|
|
129
|
+
v-if="label"
|
|
130
|
+
class="pl-2 font-medium text-gray-800 dark:text-gray-200"
|
|
131
|
+
:class="{
|
|
132
|
+
'text-xs': size === 'xs',
|
|
133
|
+
'text-sm': size === 'sm',
|
|
134
|
+
'text-lg': size === 'lg',
|
|
135
|
+
'text-xl': size === 'xl',
|
|
136
|
+
}"
|
|
137
|
+
v-text="label"
|
|
138
|
+
>
|
|
139
|
+
</span>
|
|
140
|
+
<x-spinner v-if="loading" :size="size" class="ml-1" />
|
|
141
|
+
</div>
|
|
142
|
+
<p v-if="errorInternal" class="text-sm text-red-500 mt-1" v-text="errorInternal"></p>
|
|
143
|
+
</label>
|
|
144
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
import XPopover from '../../components/popover/Popover.vue'
|
|
5
|
+
import XPopoverContainer from '../../components/popover/PopoverContainer.vue'
|
|
6
|
+
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
name: 'XTooltip',
|
|
9
|
+
|
|
10
|
+
components: {
|
|
11
|
+
XPopover,
|
|
12
|
+
XPopoverContainer,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<x-popover hover class="dark">
|
|
19
|
+
<slot></slot>
|
|
20
|
+
<template #content>
|
|
21
|
+
<x-popover-container class="p-2 text-white text-sm">
|
|
22
|
+
<slot name="tooltip"></slot>
|
|
23
|
+
</x-popover-container>
|
|
24
|
+
</template>
|
|
25
|
+
</x-popover>
|
|
26
|
+
</template>
|