@nubisco/ui 1.59.0 → 1.60.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.
@@ -0,0 +1,17 @@
1
+ import { type Slots, type VNode } from 'vue';
2
+ /**
3
+ * True when the vnodes would render something visible.
4
+ *
5
+ * Comments (Vue's `v-if` placeholders) and whitespace-only text do not count;
6
+ * fragments are searched recursively.
7
+ *
8
+ * Note the limit: a component vnode always counts, because whether it renders
9
+ * anything is only known after it renders. `<RouterView name="x" />` therefore
10
+ * reads as content even on routes registering no `x` view. Consumers that only
11
+ * need to *style* the empty case should prefer a CSS `:empty` guard, which is
12
+ * evaluated against the real DOM and re-evaluated on navigation.
13
+ */
14
+ export declare function hasRenderableContent(nodes: VNode[]): boolean;
15
+ /** True when the named slot has renderable content. */
16
+ export declare function hasSlotContent(slots: Slots, name: string): boolean;
17
+ //# sourceMappingURL=slotContent.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slotContent.helper.d.ts","sourceRoot":"","sources":["../../src/utils/slotContent.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,KAAK,CAAA;AAErE;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAe5D;AAED,uDAAuD;AACvD,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubisco/ui",
3
- "version": "1.59.0",
3
+ "version": "1.60.0",
4
4
  "description": "Vue 3 UI component library",
5
5
  "packageManager": "pnpm@11.0.8",
6
6
  "repository": {
@@ -0,0 +1,36 @@
1
+ import { Comment, Fragment, Text, type Slots, type VNode } from 'vue'
2
+
3
+ /**
4
+ * True when the vnodes would render something visible.
5
+ *
6
+ * Comments (Vue's `v-if` placeholders) and whitespace-only text do not count;
7
+ * fragments are searched recursively.
8
+ *
9
+ * Note the limit: a component vnode always counts, because whether it renders
10
+ * anything is only known after it renders. `<RouterView name="x" />` therefore
11
+ * reads as content even on routes registering no `x` view. Consumers that only
12
+ * need to *style* the empty case should prefer a CSS `:empty` guard, which is
13
+ * evaluated against the real DOM and re-evaluated on navigation.
14
+ */
15
+ export function hasRenderableContent(nodes: VNode[]): boolean {
16
+ return nodes.some((node) => {
17
+ if (node.type === Comment) return false
18
+ if (node.type === Text) {
19
+ return (
20
+ typeof node.children === 'string' && node.children.trim().length > 0
21
+ )
22
+ }
23
+ if (node.type === Fragment) {
24
+ return Array.isArray(node.children)
25
+ ? hasRenderableContent(node.children as VNode[])
26
+ : false
27
+ }
28
+ return true
29
+ })
30
+ }
31
+
32
+ /** True when the named slot has renderable content. */
33
+ export function hasSlotContent(slots: Slots, name: string): boolean {
34
+ const content = slots[name]?.()
35
+ return content ? hasRenderableContent(content) : false
36
+ }