@saasmakers/ui 2.1.3 → 2.1.4

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.
@@ -46,6 +46,7 @@ const id = useId()
46
46
  const modelValue = defineModel<FieldInput['modelValue']>({ default: '' })
47
47
  const input = ref<HTMLInputElement>()
48
48
  const showPassword = ref(false)
49
+ const focused = ref(false)
49
50
  const { isDesktopBrowser, isIos } = useDevice()
50
51
 
51
52
  const iosUppercaseTyping = computed(() => {
@@ -54,6 +55,10 @@ const iosUppercaseTyping = computed(() => {
54
55
  return props.uppercase && isIos.value && isProseField && !props.lowercaseOnly && !props.slugOnly
55
56
  })
56
57
 
58
+ const hideCssUppercase = computed(() => {
59
+ return iosUppercaseTyping.value && focused.value
60
+ })
61
+
57
62
  onMounted(() => {
58
63
  if (props.autofocus && input.value && isDesktopBrowser.value) {
59
64
  input.value.focus()
@@ -73,6 +78,8 @@ function focus() {
73
78
  }
74
79
 
75
80
  function onFieldBlur(event: FocusEvent) {
81
+ focused.value = false
82
+
76
83
  syncModelValueFromTarget(event.target)
77
84
 
78
85
  if (props.trim) {
@@ -91,6 +98,8 @@ function onFieldFocus(event: FocusEvent) {
91
98
  }
92
99
  }
93
100
 
101
+ focused.value = true
102
+
94
103
  emit('focus', event)
95
104
  }
96
105
 
@@ -211,8 +220,8 @@ defineExpose({
211
220
  v-bind="autofocus ? { 'data-autofocus': '' } : {}"
212
221
  class="h-full w-full appearance-none items-center rounded-lg font-medium tracking-tight outline-none placeholder-gray-600 dark:placeholder-gray-400"
213
222
  :class="{
214
- 'uppercase': uppercase && !iosUppercaseTyping,
215
- 'placeholder:uppercase': iosUppercaseTyping,
223
+ 'uppercase': uppercase && !hideCssUppercase,
224
+ 'placeholder:uppercase': hideCssUppercase,
216
225
  'field-disabled': disabled,
217
226
  'focus:placeholder-gray-900 hover:placeholder-gray-900 dark:focus:placeholder-gray-100 dark:hover:placeholder-gray-100': !disabled,
218
227
  'text-gray-900 dark:text-gray-100': !lineThrough,
@@ -30,12 +30,17 @@ const emit = defineEmits<{
30
30
  const id = useId()
31
31
  const modelValue = defineModel<FieldTextarea['modelValue']>({ default: '' })
32
32
  const textarea = ref<HTMLTextAreaElement>()
33
+ const focused = ref(false)
33
34
  const { isDesktopBrowser, isIos } = useDevice()
34
35
 
35
36
  const iosUppercaseTyping = computed(() => {
36
37
  return props.uppercase && isIos.value
37
38
  })
38
39
 
40
+ const hideCssUppercase = computed(() => {
41
+ return iosUppercaseTyping.value && focused.value
42
+ })
43
+
39
44
  onMounted(() => {
40
45
  if (props.autofocus && textarea.value && isDesktopBrowser.value) {
41
46
  textarea.value.focus()
@@ -43,6 +48,8 @@ onMounted(() => {
43
48
  })
44
49
 
45
50
  function onFieldBlur(event: FocusEvent) {
51
+ focused.value = false
52
+
46
53
  syncModelValueFromTarget(event.target)
47
54
  emit('blur', event, modelValue.value || '')
48
55
  }
@@ -52,15 +59,15 @@ function onFieldClick(event: MouseEvent) {
52
59
  }
53
60
 
54
61
  function onFieldFocus() {
55
- if (!iosUppercaseTyping.value) {
56
- return
57
- }
58
-
59
- const uppercased = modelValue.value.toString().toUpperCase()
62
+ if (iosUppercaseTyping.value) {
63
+ const uppercased = modelValue.value.toString().toUpperCase()
60
64
 
61
- if (uppercased !== modelValue.value) {
62
- modelValue.value = uppercased
65
+ if (uppercased !== modelValue.value) {
66
+ modelValue.value = uppercased
67
+ }
63
68
  }
69
+
70
+ focused.value = true
64
71
  }
65
72
 
66
73
  function syncModelValueFromTarget(target: EventTarget | null) {
@@ -96,8 +103,8 @@ function syncModelValueFromTarget(target: EventTarget | null) {
96
103
  :autocapitalize="iosUppercaseTyping ? 'characters' : undefined"
97
104
  class="w-full flex-1 appearance-none rounded-lg text-gray-900 font-medium tracking-tight outline-none dark:text-gray-100 placeholder-gray-600 dark:placeholder-gray-400"
98
105
  :class="{
99
- 'uppercase': uppercase && !iosUppercaseTyping,
100
- 'placeholder:uppercase': iosUppercaseTyping,
106
+ 'uppercase': uppercase && !hideCssUppercase,
107
+ 'placeholder:uppercase': hideCssUppercase,
101
108
  'field-disabled': disabled,
102
109
  'focus:placeholder-gray-900 hover:placeholder-gray-900 dark:focus:placeholder-gray-100 dark:hover:placeholder-gray-100': !disabled,
103
110
  'px-sm py-2.5': padding && size === 'sm',
@@ -1,6 +1,5 @@
1
1
  export default function useDevice() {
2
2
  const { isIOS, isNative } = useCapacitor()
3
-
4
3
  const isIos = ref(false)
5
4
 
6
5
  const isDesktopBrowser = computed(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "private": false,
5
5
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
6
6
  "license": "MIT",