@saasmakers/ui 0.1.98 → 0.1.100
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/app/components/fields/FieldCheckbox.vue +2 -1
- package/app/components/fields/FieldEmojis.vue +10 -6
- package/app/components/fields/FieldInput.vue +4 -2
- package/app/components/fields/FieldLabel.vue +1 -1
- package/app/components/fields/FieldMessage.vue +1 -2
- package/app/components/fields/FieldSelect.vue +18 -15
- package/app/components/fields/FieldTabs.vue +1 -1
- package/app/components/fields/FieldTextarea.vue +4 -2
- package/app/components/fields/FieldTime.vue +2 -1
- package/package.json +1 -1
|
@@ -33,8 +33,9 @@ const uuid = ref(`${Math.floor((1 + Math.random()) * 0x100000)}`)
|
|
|
33
33
|
v-if="!loading"
|
|
34
34
|
:id="uuid"
|
|
35
35
|
v-model="modelValue"
|
|
36
|
-
class="
|
|
36
|
+
class="border border-gray-300 rounded-lg accent-indigo-700 transition-shadow flex-initial dark:border-gray-700"
|
|
37
37
|
:class="{
|
|
38
|
+
'cursor-pointer hover:border-gray-400 dark:hover:border-gray-600 focus:border-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-indigo-500/40 dark:focus:border-gray-500': !disabled,
|
|
38
39
|
'field-disabled': disabled,
|
|
39
40
|
'h-3.5 w-3.5': size === 'xs',
|
|
40
41
|
'h-4 w-4': size === 'sm',
|
|
@@ -3,7 +3,7 @@ import type { FieldEmojis } from '../../types/fields'
|
|
|
3
3
|
import { emojis } from '@saasmakers/shared'
|
|
4
4
|
import { refDebounced } from '@vueuse/core'
|
|
5
5
|
|
|
6
|
-
withDefaults(defineProps<Omit<FieldEmojis, 'modelValue'>>(), { disabled: false })
|
|
6
|
+
const props = withDefaults(defineProps<Omit<FieldEmojis, 'modelValue'>>(), { disabled: false })
|
|
7
7
|
|
|
8
8
|
const emit = defineEmits<{
|
|
9
9
|
click: [event: MouseEvent, emoji: string]
|
|
@@ -43,8 +43,11 @@ const emojisFiltered = computed(() => {
|
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
function onEmojiClick(event: MouseEvent, emoji?: string) {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (!props.disabled) {
|
|
47
|
+
emit('click', event, emoji || '')
|
|
48
|
+
|
|
49
|
+
modelValue.value = emoji || ''
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
</script>
|
|
50
53
|
|
|
@@ -55,7 +58,7 @@ function onEmojiClick(event: MouseEvent, emoji?: string) {
|
|
|
55
58
|
>
|
|
56
59
|
<FieldInput
|
|
57
60
|
v-model="searchRaw"
|
|
58
|
-
|
|
61
|
+
:disabled="disabled"
|
|
59
62
|
:placeholder="t('searchEmoji')"
|
|
60
63
|
size="sm"
|
|
61
64
|
/>
|
|
@@ -80,8 +83,9 @@ function onEmojiClick(event: MouseEvent, emoji?: string) {
|
|
|
80
83
|
<BaseEmoji
|
|
81
84
|
v-for="emoji in category.emojis"
|
|
82
85
|
:key="emoji.id"
|
|
83
|
-
class="rounded-lg p-1.5
|
|
84
|
-
|
|
86
|
+
class="rounded-lg p-1.5"
|
|
87
|
+
:class="{ 'hover:bg-gray-200 dark:hover:bg-gray-800': !disabled }"
|
|
88
|
+
:clickable="!disabled"
|
|
85
89
|
:emoji="emoji.id"
|
|
86
90
|
size="xl"
|
|
87
91
|
@click="onEmojiClick"
|
|
@@ -151,9 +151,10 @@ defineExpose({ focus })
|
|
|
151
151
|
:id="uuid"
|
|
152
152
|
ref="input"
|
|
153
153
|
:autocomplete="autocomplete ? 'on' : 'off'"
|
|
154
|
-
class="h-full w-full flex-1 appearance-none items-center rounded-lg outline-none placeholder-gray-600 dark:placeholder-gray-400
|
|
154
|
+
class="h-full w-full flex-1 appearance-none items-center rounded-lg outline-none placeholder-gray-600 dark:placeholder-gray-400"
|
|
155
155
|
:class="{
|
|
156
156
|
'field-disabled': disabled,
|
|
157
|
+
'focus:placeholder-gray-900 hover:placeholder-gray-900 dark:focus:placeholder-gray-100 dark:hover:placeholder-gray-100': !disabled,
|
|
157
158
|
'text-gray-900 dark:text-gray-100': !lineThrough,
|
|
158
159
|
'text-gray-500 dark:text-gray-500 line-through': lineThrough,
|
|
159
160
|
'font-medium tracking-tight uppercase': uppercase,
|
|
@@ -163,7 +164,8 @@ defineExpose({ focus })
|
|
|
163
164
|
'text-right': alignment === 'right',
|
|
164
165
|
'bg-gray-100 dark:bg-gray-900': background === 'gray',
|
|
165
166
|
'bg-white dark:bg-gray-900': background === 'white',
|
|
166
|
-
'border shadow-sm border-gray-200 dark:border-gray-800 px-3
|
|
167
|
+
'border shadow-sm border-gray-200 dark:border-gray-800 px-3': border === 'full',
|
|
168
|
+
'hover:border-gray-300 focus:border-gray-400 dark:hover:border-gray-700 dark:focus:border-gray-600': border === 'full' && !disabled,
|
|
167
169
|
'border-b border-gray-200 dark:border-gray-800 px-10': border === 'bottom',
|
|
168
170
|
'border-0 p-0': border === 'none',
|
|
169
171
|
'text-xs': size === 'xs',
|
|
@@ -33,7 +33,7 @@ function onClick(event: MouseEvent) {
|
|
|
33
33
|
'cursor-wait': loading,
|
|
34
34
|
'text-gray-900 dark:text-gray-100': !lineThrough,
|
|
35
35
|
'text-gray-500 dark:text-gray-500 line-through': lineThrough,
|
|
36
|
-
'hover:text-black dark:hover:text-white': !
|
|
36
|
+
'hover:text-black dark:hover:text-white': !disabled && !lineThrough && !loading,
|
|
37
37
|
'w-0 truncate': truncate,
|
|
38
38
|
'mb-1.5': size === 'xs' && hasMarginBottom,
|
|
39
39
|
'mb-2': size === 'sm' && hasMarginBottom,
|
|
@@ -134,13 +134,12 @@ const text = computed<BaseTextText>(() => {
|
|
|
134
134
|
v-if="text"
|
|
135
135
|
class="field-disabled text-left tracking-tighter"
|
|
136
136
|
:class="{
|
|
137
|
-
'text-red-700 dark:text-red-300': status === 'error',
|
|
138
|
-
'text-gray-700 dark:text-gray-300': status === 'default',
|
|
139
137
|
'mt-2': size === 'xs',
|
|
140
138
|
'mt-2.5': size === 'sm',
|
|
141
139
|
'mt-3': size === 'base',
|
|
142
140
|
'mt-3.5': size === 'lg',
|
|
143
141
|
}"
|
|
142
|
+
:color="status === 'error' ? 'red' : 'gray'"
|
|
144
143
|
size="sm"
|
|
145
144
|
:text="text"
|
|
146
145
|
/>
|
|
@@ -45,7 +45,7 @@ const computedColumns = computed(() => {
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
const computedOptions = computed(() => {
|
|
48
|
-
const options = []
|
|
48
|
+
const options: FieldSelectOption[] = []
|
|
49
49
|
|
|
50
50
|
// Add index to each option
|
|
51
51
|
if (props.columns.length) {
|
|
@@ -86,15 +86,17 @@ function onClose() {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function onContainerClick(event: MouseEvent) {
|
|
89
|
-
if (!props.disabled
|
|
89
|
+
if (!props.disabled) {
|
|
90
90
|
opened.value = !opened.value
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
if (selectedOption.value) {
|
|
93
|
+
emit('click', event, selectedOption.value.value)
|
|
94
|
+
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
function onContainerKeypress(event: KeyboardEvent) {
|
|
97
|
-
if (['Enter', 'Space'].includes(event.code)) {
|
|
99
|
+
if (['Enter', 'Space'].includes(event.code) && !props.disabled) {
|
|
98
100
|
(event.target as HTMLElement)?.click()
|
|
99
101
|
}
|
|
100
102
|
}
|
|
@@ -106,7 +108,7 @@ function onLabelClick() {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
function onMouseEnter() {
|
|
109
|
-
if (props.openOnHover) {
|
|
111
|
+
if (props.openOnHover && !props.disabled) {
|
|
110
112
|
opened.value = true
|
|
111
113
|
}
|
|
112
114
|
}
|
|
@@ -118,16 +120,17 @@ function onMouseLeave() {
|
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
function onOptionClick(event: MouseEvent, option: FieldSelectOption) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
if (!props.disabled) {
|
|
124
|
+
// Check that the option is not currently selected
|
|
125
|
+
if ((selectedOption.value || {}).value !== option.value) {
|
|
126
|
+
selectOption(event, option.value)
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
reset()
|
|
130
|
+
}
|
|
125
131
|
|
|
126
|
-
|
|
127
|
-
reset()
|
|
132
|
+
emit('optionClick', event, option.value)
|
|
128
133
|
}
|
|
129
|
-
|
|
130
|
-
emit('optionClick', event, option.value)
|
|
131
134
|
}
|
|
132
135
|
</script>
|
|
133
136
|
|
|
@@ -166,7 +169,7 @@ function onOptionClick(event: MouseEvent, option: FieldSelectOption) {
|
|
|
166
169
|
'border-b border-gray-200 dark:border-gray-800': border === 'bottom',
|
|
167
170
|
'border-0': border === 'none',
|
|
168
171
|
'border-gray-400 dark:border-gray-600': opened,
|
|
169
|
-
'hover:border-gray-300 dark:hover:border-gray-700': !opened,
|
|
172
|
+
'hover:border-gray-300 dark:hover:border-gray-700': !opened && !disabled,
|
|
170
173
|
'focus:border-gray-400 dark:focus:border-gray-600': !disabled,
|
|
171
174
|
'px-3': padding,
|
|
172
175
|
'text-2xs h-8': size === 'xs',
|
|
@@ -174,7 +177,7 @@ function onOptionClick(event: MouseEvent, option: FieldSelectOption) {
|
|
|
174
177
|
'text-sm h-12': size === 'base',
|
|
175
178
|
'text-base h-14': size === 'lg',
|
|
176
179
|
}"
|
|
177
|
-
tabindex="0"
|
|
180
|
+
:tabindex="disabled ? -1 : 0"
|
|
178
181
|
@click="onContainerClick"
|
|
179
182
|
@keypress.prevent="onContainerKeypress"
|
|
180
183
|
>
|
|
@@ -48,7 +48,7 @@ function onTabClick(event: MouseEvent, tabValue: string) {
|
|
|
48
48
|
class="flex cursor-pointer items-center justify-center text-xs"
|
|
49
49
|
:class="{
|
|
50
50
|
'text-gray-900 dark:text-gray-100': isTabActive(tab.value),
|
|
51
|
-
'text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100': !isTabActive(tab.value),
|
|
51
|
+
'text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100': !isTabActive(tab.value) && !disabled,
|
|
52
52
|
'flex-1': !minimizeOnMobile || !isTabActive(tab.value),
|
|
53
53
|
'flex-2 sm:flex-1': minimizeOnMobile && isTabActive(tab.value),
|
|
54
54
|
'py-1.5 px-2.5': size === 'xs' && theme === 'rounded',
|
|
@@ -69,15 +69,17 @@ function onFieldClick(event: MouseEvent) {
|
|
|
69
69
|
ref="textarea"
|
|
70
70
|
v-model="modelValue"
|
|
71
71
|
v-bind="{ 'data-enable-grammarly': 'false' }"
|
|
72
|
-
class="w-full flex-1 appearance-none rounded-lg text-gray-900 font-medium tracking-tight uppercase outline-none dark:text-gray-100 placeholder-gray-600 dark:placeholder-gray-400
|
|
72
|
+
class="w-full flex-1 appearance-none rounded-lg text-gray-900 font-medium tracking-tight uppercase outline-none dark:text-gray-100 placeholder-gray-600 dark:placeholder-gray-400"
|
|
73
73
|
:class="{
|
|
74
74
|
'field-disabled': disabled,
|
|
75
|
+
'focus:placeholder-gray-900 hover:placeholder-gray-900 dark:focus:placeholder-gray-100 dark:hover:placeholder-gray-100': !disabled,
|
|
75
76
|
'p-2.5': padding,
|
|
76
77
|
'p-0': !padding,
|
|
77
78
|
'resize-none': !resize,
|
|
78
79
|
'bg-gray-100 dark:bg-gray-900': background === 'gray',
|
|
79
80
|
'bg-white dark:bg-gray-900': background === 'white',
|
|
80
|
-
'border shadow-sm border-gray-200 dark:border-gray-800
|
|
81
|
+
'border shadow-sm border-gray-200 dark:border-gray-800': border,
|
|
82
|
+
'hover:border-gray-300 dark:hover:border-gray-700 focus:border-gray-400 dark:focus:border-gray-600': border && !disabled,
|
|
81
83
|
'border-0': !border,
|
|
82
84
|
'text-xs': size === 'xs',
|
|
83
85
|
'text-sm': size === 'sm',
|
|
@@ -45,9 +45,10 @@ function onFieldBlur(event: FocusEvent) {
|
|
|
45
45
|
/>
|
|
46
46
|
|
|
47
47
|
<div
|
|
48
|
-
class="flex cursor-pointer items-center gap-2 overflow-hidden border border-gray-200 rounded-lg px-3 font-normal dark:border-gray-800
|
|
48
|
+
class="flex cursor-pointer items-center gap-2 overflow-hidden border border-gray-200 rounded-lg px-3 font-normal dark:border-gray-800"
|
|
49
49
|
:class="{
|
|
50
50
|
'field-disabled': disabled,
|
|
51
|
+
'focus-within:border-gray-400 hover:border-gray-300 dark:focus-within:border-gray-600 dark:hover:border-gray-700': !disabled,
|
|
51
52
|
'bg-gray-100 dark:bg-gray-900': background === 'gray',
|
|
52
53
|
'bg-white dark:bg-gray-900': background === 'white',
|
|
53
54
|
'text-2xs h-8': size === 'xs',
|