wave-ui 4.0.2 → 4.1.0

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.
@@ -88,6 +88,8 @@
88
88
  }
89
89
 
90
90
  :root[data-theme="light"] {
91
+ color-scheme: light;
92
+
91
93
  --w-base-bg-color: #fff;
92
94
  --w-base-color: #000;
93
95
  --w-contrast-bg-color: #000;
@@ -97,6 +99,8 @@
97
99
  }
98
100
 
99
101
  :root[data-theme="dark"] {
102
+ color-scheme: dark;
103
+
100
104
  --w-base-bg-color: #222;
101
105
  --w-base-color: #fff;
102
106
  --w-contrast-bg-color: #fff;
@@ -0,0 +1,39 @@
1
+ import { nextTick } from 'vue'
2
+
3
+ export function focusElement (el) {
4
+ el?.focus?.()
5
+ }
6
+
7
+ export function guardFocusable (vm) {
8
+ if (vm.isDisabled || vm.isReadonly) return false
9
+ return true
10
+ }
11
+
12
+ /**
13
+ * Resolve focus() from a directive host. On components, `vnode` is the root element
14
+ * VNode (no `vnode.component`); the DOM owner is on `el.__vueParentComponent`.
15
+ * Walk up when the root is a wrapper (e.g. `w-form-element` around `w-input`).
16
+ */
17
+ export function resolveFocusFn (vnode, el) {
18
+ let instance = vnode?.component ?? el?.__vueParentComponent
19
+ while (instance) {
20
+ const focusFn = instance.exposed?.focus ?? instance.proxy?.focus
21
+ if (typeof focusFn === 'function') return focusFn
22
+ instance = instance.parent
23
+ }
24
+ return null
25
+ }
26
+
27
+ export function callFocus (vnode, el) {
28
+ const focusFn = resolveFocusFn(vnode, el)
29
+ if (typeof focusFn === 'function') {
30
+ focusFn()
31
+ return
32
+ }
33
+ focusElement(el)
34
+ }
35
+
36
+ /** Schedule focus after mount so template refs exist on the host component. */
37
+ export function scheduleFocus (vnode, el) {
38
+ nextTick(() => callFocus(vnode, el))
39
+ }