@skewedaspect/sleekspace-ui 0.9.0 → 0.9.1

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.
@@ -0,0 +1,75 @@
1
+ //----------------------------------------------------------------------------------------------------------------------
2
+ // Slot Utilities
3
+ //
4
+ // Helpers for inspecting Vue slot content. The common case: a component renders a wrapper div (or gates a
5
+ // fallback) based on whether a slot was passed. Checking `slots.foo` truthy only tells you a slot *function*
6
+ // exists; it doesn't tell you whether calling it produces anything. A slot whose content resolves to only
7
+ // comments, whitespace text, or a falsy `v-if` still evaluates truthy but renders nothing, which leaves
8
+ // behind empty wrappers that pick up gap/padding and distort layout.
9
+ //----------------------------------------------------------------------------------------------------------------------
10
+
11
+ import { Comment, Fragment, Text, type VNode } from 'vue';
12
+
13
+ //----------------------------------------------------------------------------------------------------------------------
14
+
15
+ // Accepts any slot-shaped callable. Covers both `Slot` (from useSlots) and the narrower
16
+ // `(props) => unknown` signatures that `defineSlots<...>()` produces for typed slots.
17
+ type SlotLike = (...args : any[]) => unknown;
18
+
19
+ //----------------------------------------------------------------------------------------------------------------------
20
+
21
+ export function hasRenderableContent(vnodes : VNode[]) : boolean
22
+ {
23
+ return vnodes.some((vnode) =>
24
+ {
25
+ if(vnode.type === Comment) { return false; }
26
+
27
+ if(vnode.type === Text)
28
+ {
29
+ return typeof vnode.children === 'string' && vnode.children.trim().length > 0;
30
+ }
31
+
32
+ if(vnode.type === Fragment && Array.isArray(vnode.children))
33
+ {
34
+ return hasRenderableContent(vnode.children as VNode[]);
35
+ }
36
+
37
+ return true;
38
+ });
39
+ }
40
+
41
+ //----------------------------------------------------------------------------------------------------------------------
42
+
43
+ export function hasSlotContent(slot : SlotLike | undefined, props ?: Record<string, unknown>) : boolean
44
+ {
45
+ if(!slot) { return false; }
46
+ return hasRenderableContent(slot(props) as VNode[]);
47
+ }
48
+
49
+ //----------------------------------------------------------------------------------------------------------------------
50
+
51
+ export function filterRenderableVNodes(vnodes : VNode[]) : VNode[]
52
+ {
53
+ return vnodes.flatMap((vnode) =>
54
+ {
55
+ if(vnode.type === Comment) { return []; }
56
+
57
+ if(vnode.type === Text)
58
+ {
59
+ if(typeof vnode.children === 'string' && vnode.children.trim().length > 0)
60
+ {
61
+ return [ vnode ];
62
+ }
63
+ return [];
64
+ }
65
+
66
+ if(vnode.type === Fragment && Array.isArray(vnode.children))
67
+ {
68
+ return filterRenderableVNodes(vnode.children as VNode[]);
69
+ }
70
+
71
+ return [ vnode ];
72
+ });
73
+ }
74
+
75
+ //----------------------------------------------------------------------------------------------------------------------
package/web-types.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json.schemastore.org/web-types",
3
3
  "framework": "vue",
4
4
  "name": "@skewedaspect/sleekspace-ui",
5
- "version": "0.9.0",
5
+ "version": "0.9.1",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "description-markup": "markdown",
@@ -2414,6 +2414,16 @@
2414
2414
  "type": "number"
2415
2415
  },
2416
2416
  "default": "1"
2417
+ },
2418
+ {
2419
+ "name": "showSteppers",
2420
+ "required": false,
2421
+ "description": "When true, renders the increment/decrement stepper buttons on the right side of the\ninput. Set to false for a plain numeric text field (users can still use arrow keys\nand type values directly).",
2422
+ "value": {
2423
+ "kind": "expression",
2424
+ "type": "boolean"
2425
+ },
2426
+ "default": "true"
2417
2427
  }
2418
2428
  ],
2419
2429
  "source": {