@raxium/vue 0.1.1 → 0.1.3

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,90 @@
1
+ import { computed, createBlock, createPropsRestProxy, createVNode, defineComponent, guardReactiveProps, normalizeClass, normalizeProps, openBlock, renderSlot, unref, withCtx } from "vue";
2
+ import { Accordion, useAccordion } from "@ark-ui/vue/accordion";
3
+ import { useForwardExpose, useForwardProps } from "@ark-ui/vue/utils";
4
+ import { clsx } from "@raxium/themes/utils";
5
+ import { useTheme } from "../../composables/useTheme.js";
6
+ import { ThemeProvider } from "../../providers/theme/index.js";
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
+ __name: "Accordion",
9
+ props: {
10
+ class: {
11
+ type: [
12
+ Boolean,
13
+ null,
14
+ String,
15
+ Object,
16
+ Array
17
+ ]
18
+ },
19
+ collapsible: {
20
+ type: Boolean
21
+ },
22
+ defaultValue: {},
23
+ disabled: {
24
+ type: Boolean
25
+ },
26
+ id: {},
27
+ ids: {},
28
+ modelValue: {},
29
+ multiple: {
30
+ type: Boolean
31
+ },
32
+ orientation: {},
33
+ lazyMount: {
34
+ type: Boolean
35
+ },
36
+ unmountOnExit: {
37
+ type: Boolean
38
+ },
39
+ asChild: {
40
+ type: Boolean
41
+ },
42
+ theme: {}
43
+ },
44
+ emits: [
45
+ "focusChange",
46
+ "valueChange",
47
+ "update:modelValue"
48
+ ],
49
+ setup (__props, { expose: __expose, emit: __emit }) {
50
+ const props = createPropsRestProxy(__props, [
51
+ "class",
52
+ "theme"
53
+ ]);
54
+ const emit = __emit;
55
+ const forwarded = useForwardProps(props);
56
+ const accordion = useAccordion(forwarded, emit);
57
+ const theme = useTheme(()=>__props.theme);
58
+ const crafts = computed(()=>theme.value.crafts.tvAccordion());
59
+ __expose({
60
+ $api: accordion
61
+ });
62
+ useForwardExpose();
63
+ return (_ctx, _cache)=>(openBlock(), createBlock(unref(Accordion).RootProvider, {
64
+ value: unref(accordion),
65
+ class: normalizeClass(crafts.value.root({
66
+ class: unref(clsx)(__props.class),
67
+ ...unref(theme)
68
+ }))
69
+ }, {
70
+ default: withCtx(()=>[
71
+ createVNode(unref(ThemeProvider), {
72
+ value: unref(theme)
73
+ }, {
74
+ default: withCtx(()=>[
75
+ renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(unref(accordion))))
76
+ ]),
77
+ _: 3
78
+ }, 8, [
79
+ "value"
80
+ ])
81
+ ]),
82
+ _: 3
83
+ }, 8, [
84
+ "value",
85
+ "class"
86
+ ]));
87
+ }
88
+ });
89
+ const accordion_Accordion = _sfc_main;
90
+ export default accordion_Accordion;
@@ -0,0 +1,47 @@
1
+ import { computed, createBlock, createPropsRestProxy, defineComponent, mergeProps, openBlock, renderSlot, unref, withCtx } from "vue";
2
+ import { useForwardProps } from "@ark-ui/vue";
3
+ import { Accordion } from "@ark-ui/vue/accordion";
4
+ import { clsx } from "@raxium/themes/utils";
5
+ import { useTheme } from "../../composables/useTheme.js";
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
7
+ __name: "AccordionContent",
8
+ props: {
9
+ class: {
10
+ type: [
11
+ Boolean,
12
+ null,
13
+ String,
14
+ Object,
15
+ Array
16
+ ]
17
+ },
18
+ asChild: {
19
+ type: Boolean
20
+ },
21
+ theme: {}
22
+ },
23
+ setup (__props) {
24
+ const props = createPropsRestProxy(__props, [
25
+ "class",
26
+ "theme"
27
+ ]);
28
+ const forwarded = useForwardProps(props);
29
+ const theme = useTheme(()=>__props.theme);
30
+ const crafts = computed(()=>theme.value.crafts.tvAccordion());
31
+ return (_ctx, _cache)=>(openBlock(), createBlock(unref(Accordion).ItemContent, mergeProps(unref(forwarded), {
32
+ class: crafts.value.content({
33
+ class: unref(clsx)(__props.class),
34
+ ...unref(theme)
35
+ })
36
+ }), {
37
+ default: withCtx(()=>[
38
+ renderSlot(_ctx.$slots, "default")
39
+ ]),
40
+ _: 3
41
+ }, 16, [
42
+ "class"
43
+ ]));
44
+ }
45
+ });
46
+ const AccordionContent = _sfc_main;
47
+ export default AccordionContent;
@@ -0,0 +1,14 @@
1
+ import type { AccordionContentProps } from '.';
2
+ declare var __VLS_8: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_8) => any;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<AccordionContentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionContentProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
10
+ type __VLS_WithSlots<T, S> = T & {
11
+ new (): {
12
+ $slots: S;
13
+ };
14
+ };
@@ -0,0 +1,51 @@
1
+ import { computed, createBlock, createPropsRestProxy, defineComponent, mergeProps, openBlock, renderSlot, unref, withCtx } from "vue";
2
+ import { useForwardProps } from "@ark-ui/vue";
3
+ import { Accordion } from "@ark-ui/vue/accordion";
4
+ import { clsx } from "@raxium/themes/utils";
5
+ import { useTheme } from "../../composables/useTheme.js";
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
7
+ __name: "AccordionItem",
8
+ props: {
9
+ class: {
10
+ type: [
11
+ Boolean,
12
+ null,
13
+ String,
14
+ Object,
15
+ Array
16
+ ]
17
+ },
18
+ value: {},
19
+ disabled: {
20
+ type: Boolean
21
+ },
22
+ asChild: {
23
+ type: Boolean
24
+ },
25
+ theme: {}
26
+ },
27
+ setup (__props) {
28
+ const props = createPropsRestProxy(__props, [
29
+ "class",
30
+ "theme"
31
+ ]);
32
+ const forwarded = useForwardProps(props);
33
+ const theme = useTheme(()=>__props.theme);
34
+ const crafts = computed(()=>theme.value.crafts.tvAccordion());
35
+ return (_ctx, _cache)=>(openBlock(), createBlock(unref(Accordion).Item, mergeProps(unref(forwarded), {
36
+ class: crafts.value.item({
37
+ class: unref(clsx)(__props.class),
38
+ ...unref(theme)
39
+ })
40
+ }), {
41
+ default: withCtx(()=>[
42
+ renderSlot(_ctx.$slots, "default")
43
+ ]),
44
+ _: 3
45
+ }, 16, [
46
+ "class"
47
+ ]));
48
+ }
49
+ });
50
+ const AccordionItem = _sfc_main;
51
+ export default AccordionItem;
@@ -0,0 +1,14 @@
1
+ import type { AccordionItemProps } from '.';
2
+ declare var __VLS_8: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_8) => any;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<AccordionItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
10
+ type __VLS_WithSlots<T, S> = T & {
11
+ new (): {
12
+ $slots: S;
13
+ };
14
+ };
@@ -0,0 +1,83 @@
1
+ import { computed, createBlock, createCommentVNode, createPropsRestProxy, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, openBlock, renderSlot, unref, withCtx } from "vue";
2
+ import { useForwardProps } from "@ark-ui/vue";
3
+ import { Accordion, useAccordionItemContext } from "@ark-ui/vue/accordion";
4
+ import { clsx } from "@raxium/themes/utils";
5
+ import { useTheme } from "../../composables/useTheme.js";
6
+ import { ChevronDown } from "lucide-vue-next";
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
+ __name: "AccordionTrigger",
9
+ props: {
10
+ class: {
11
+ type: [
12
+ Boolean,
13
+ null,
14
+ String,
15
+ Object,
16
+ Array
17
+ ]
18
+ },
19
+ indicator: {
20
+ type: Boolean,
21
+ default: true
22
+ },
23
+ ui: {},
24
+ asChild: {
25
+ type: Boolean
26
+ },
27
+ theme: {}
28
+ },
29
+ setup (__props) {
30
+ const props = createPropsRestProxy(__props, [
31
+ "class",
32
+ "theme",
33
+ "indicator",
34
+ "ui"
35
+ ]);
36
+ const forwarded = useForwardProps(props);
37
+ const itemContext = useAccordionItemContext();
38
+ const theme = useTheme(()=>__props.theme);
39
+ const crafts = computed(()=>theme.value.crafts.tvAccordion());
40
+ return (_ctx, _cache)=>(openBlock(), createBlock(unref(Accordion).ItemTrigger, mergeProps(unref(forwarded), {
41
+ class: crafts.value.trigger({
42
+ class: unref(clsx)(__props.ui?.root, __props.class),
43
+ ...unref(theme)
44
+ })
45
+ }), {
46
+ default: withCtx(()=>[
47
+ renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
48
+ open: unref(itemContext).expanded,
49
+ visible: unref(itemContext).expanded
50
+ }))),
51
+ renderSlot(_ctx.$slots, "indicator", normalizeProps(guardReactiveProps({
52
+ open: unref(itemContext).expanded,
53
+ visible: unref(itemContext).expanded
54
+ })), ()=>[
55
+ __props.indicator ? (openBlock(), createBlock(unref(Accordion).ItemIndicator, {
56
+ key: 0,
57
+ class: normalizeClass(crafts.value.indicator({
58
+ class: unref(clsx)(__props.ui?.indicator),
59
+ ...unref(theme)
60
+ }))
61
+ }, {
62
+ default: withCtx(()=>[
63
+ createVNode(unref(ChevronDown), {
64
+ style: {
65
+ width: "1lh",
66
+ height: "1lh"
67
+ }
68
+ })
69
+ ]),
70
+ _: 1
71
+ }, 8, [
72
+ "class"
73
+ ])) : createCommentVNode("", true)
74
+ ])
75
+ ]),
76
+ _: 3
77
+ }, 16, [
78
+ "class"
79
+ ]));
80
+ }
81
+ });
82
+ const AccordionTrigger = _sfc_main;
83
+ export default AccordionTrigger;
@@ -0,0 +1,22 @@
1
+ import type { AccordionTriggerProps } from '.';
2
+ declare var __VLS_8: {
3
+ open: boolean;
4
+ visible: boolean;
5
+ }, __VLS_10: {
6
+ open: boolean;
7
+ visible: boolean;
8
+ };
9
+ type __VLS_Slots = {} & {
10
+ default?: (props: typeof __VLS_8) => any;
11
+ } & {
12
+ indicator?: (props: typeof __VLS_10) => any;
13
+ };
14
+ declare const __VLS_base: import("vue").DefineComponent<AccordionTriggerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionTriggerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
16
+ declare const _default: typeof __VLS_export;
17
+ export default _default;
18
+ type __VLS_WithSlots<T, S> = T & {
19
+ new (): {
20
+ $slots: S;
21
+ };
22
+ };
@@ -0,0 +1,6 @@
1
+ export { default as Accordion } from './Accordion.vue';
2
+ export { default as AccordionContent } from './AccordionContent.vue';
3
+ export { default as AccordionItem } from './AccordionItem.vue';
4
+ export { default as AccordionPanel } from './AccordionItem.vue';
5
+ export { default as AccordionTrigger } from './AccordionTrigger.vue';
6
+ export * from './props';
@@ -0,0 +1,5 @@
1
+ export * from "./props.js";
2
+ export { default as Accordion } from "./Accordion.js";
3
+ export { default as AccordionContent } from "./AccordionContent.js";
4
+ export { default as AccordionItem, default as AccordionPanel } from "./AccordionItem.js";
5
+ export { default as AccordionTrigger } from "./AccordionTrigger.js";
@@ -0,0 +1,20 @@
1
+ import type { AccordionItemBaseProps, AccordionItemContentBaseProps, AccordionItemTriggerBaseProps, AccordionRootBaseProps } from '@ark-ui/vue/accordion';
2
+ import type { ThemeCrafts, ThemeNoCrafts } from '../../providers';
3
+ import type { HTMLAttributes } from 'vue';
4
+ export interface AccordionProps extends AccordionRootBaseProps, ThemeCrafts<'tvAccordion'> {
5
+ class?: HTMLAttributes['class'];
6
+ }
7
+ export interface AccordionItemProps extends AccordionItemBaseProps, ThemeNoCrafts {
8
+ class?: HTMLAttributes['class'];
9
+ }
10
+ export interface AccordionTriggerProps extends AccordionItemTriggerBaseProps, ThemeNoCrafts {
11
+ class?: HTMLAttributes['class'];
12
+ indicator?: boolean;
13
+ ui?: {
14
+ root?: HTMLAttributes['class'];
15
+ indicator?: HTMLAttributes['class'];
16
+ };
17
+ }
18
+ export interface AccordionContentProps extends AccordionItemContentBaseProps, ThemeNoCrafts {
19
+ class?: HTMLAttributes['class'];
20
+ }
File without changes
@@ -7,19 +7,19 @@ declare const __VLS_base: import("vue").DefineComponent<DatePickerProps, {
7
7
  $api: import("@ark-ui/vue").UseDatePickerReturn;
8
8
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
9
  openChange: (details: import("@zag-js/date-picker").OpenChangeDetails) => any;
10
+ focusChange: (details: import("@zag-js/date-picker").FocusChangeDetails) => any;
10
11
  valueChange: (details: import("@zag-js/date-picker").ValueChangeDetails) => any;
11
12
  "update:modelValue": (value: import("@zag-js/date-picker").DateValue[]) => any;
12
13
  "update:open": (open: boolean) => any;
13
- focusChange: (details: import("@zag-js/date-picker").FocusChangeDetails) => any;
14
14
  viewChange: (details: import("@zag-js/date-picker").ViewChangeDetails) => any;
15
15
  "update:view": (view: import("@zag-js/date-picker").DateView) => any;
16
16
  "update:focusedValue": (focusedValue: import("@zag-js/date-picker").DateValue) => any;
17
17
  }, string, import("vue").PublicProps, Readonly<DatePickerProps> & Readonly<{
18
18
  onOpenChange?: ((details: import("@zag-js/date-picker").OpenChangeDetails) => any) | undefined;
19
+ onFocusChange?: ((details: import("@zag-js/date-picker").FocusChangeDetails) => any) | undefined;
19
20
  onValueChange?: ((details: import("@zag-js/date-picker").ValueChangeDetails) => any) | undefined;
20
21
  "onUpdate:modelValue"?: ((value: import("@zag-js/date-picker").DateValue[]) => any) | undefined;
21
22
  "onUpdate:open"?: ((open: boolean) => any) | undefined;
22
- onFocusChange?: ((details: import("@zag-js/date-picker").FocusChangeDetails) => any) | undefined;
23
23
  onViewChange?: ((details: import("@zag-js/date-picker").ViewChangeDetails) => any) | undefined;
24
24
  "onUpdate:view"?: ((view: import("@zag-js/date-picker").DateView) => any) | undefined;
25
25
  "onUpdate:focusedValue"?: ((focusedValue: import("@zag-js/date-picker").DateValue) => any) | undefined;
@@ -1,3 +1,4 @@
1
+ export * from './accordion';
1
2
  export * from './badge';
2
3
  export * from './button';
3
4
  export * from './checkbox';
@@ -1,3 +1,4 @@
1
+ export * from "./accordion/index.js";
1
2
  export * from "./badge/index.js";
2
3
  export * from "./button/index.js";
3
4
  export * from "./checkbox/index.js";
@@ -11,16 +11,16 @@ declare const __VLS_base: import("vue").DefineComponent<NumberInputProps, {
11
11
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  blur: (event: FocusEvent) => any;
13
13
  focus: (event: FocusEvent) => any;
14
+ focusChange: (details: NumberInput.FocusChangeDetails) => any;
14
15
  valueChange: (details: NumberInput.ValueChangeDetails) => any;
15
16
  "update:modelValue": (value: string) => any;
16
- focusChange: (details: NumberInput.FocusChangeDetails) => any;
17
17
  valueInvalid: (details: NumberInput.ValueInvalidDetails) => any;
18
18
  }, string, import("vue").PublicProps, Readonly<NumberInputProps> & Readonly<{
19
19
  onBlur?: ((event: FocusEvent) => any) | undefined;
20
20
  onFocus?: ((event: FocusEvent) => any) | undefined;
21
+ onFocusChange?: ((details: NumberInput.FocusChangeDetails) => any) | undefined;
21
22
  onValueChange?: ((details: NumberInput.ValueChangeDetails) => any) | undefined;
22
23
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
23
- onFocusChange?: ((details: NumberInput.FocusChangeDetails) => any) | undefined;
24
24
  onValueInvalid?: ((details: NumberInput.ValueInvalidDetails) => any) | undefined;
25
25
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
26
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -11,14 +11,14 @@ type __VLS_Slots = {} & {
11
11
  declare const __VLS_base: import("vue").DefineComponent<SliderProps, {
12
12
  $api: import("@ark-ui/vue").UseSliderReturn;
13
13
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
+ focusChange: (details: Slider.FocusChangeDetails) => any;
14
15
  valueChange: (details: Slider.ValueChangeDetails) => any;
15
16
  "update:modelValue": (value: number[]) => any;
16
- focusChange: (details: Slider.FocusChangeDetails) => any;
17
17
  valueChangeEnd: (details: Slider.ValueChangeDetails) => any;
18
18
  }, string, import("vue").PublicProps, Readonly<SliderProps> & Readonly<{
19
+ onFocusChange?: ((details: Slider.FocusChangeDetails) => any) | undefined;
19
20
  onValueChange?: ((details: Slider.ValueChangeDetails) => any) | undefined;
20
21
  "onUpdate:modelValue"?: ((value: number[]) => any) | undefined;
21
- onFocusChange?: ((details: Slider.FocusChangeDetails) => any) | undefined;
22
22
  onValueChangeEnd?: ((details: Slider.ValueChangeDetails) => any) | undefined;
23
23
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
24
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,7 +1,7 @@
1
1
  import type { SlotsType, VNode } from 'vue';
2
2
  import type { SpinRenderProps } from '.';
3
3
  /**
4
- * TODO: rslib无法解析<script setup lang="tsx">的组件, 会解析为虚拟请求(?vue), 导致解析链断掉
4
+ * rslib无法解析<script setup lang="tsx">的组件, 会解析为虚拟请求(?vue), 导致解析链断掉
5
5
  * 继续使用bundle:false, 需要直接解析tsx文件
6
6
  */
7
7
  type Slots = {
@@ -1,6 +1,7 @@
1
1
  import { computed, createVNode, defineComponent, isVNode, provide } from "vue";
2
2
  import { ark } from "@ark-ui/vue/factory";
3
3
  import { clsx } from "@raxium/themes/utils";
4
+ import { isEmptyVNode } from "../../utils/index.js";
4
5
  import { LoaderCircle } from "lucide-vue-next";
5
6
  function _isSlot(s) {
6
7
  return 'function' == typeof s || '[object Object]' === Object.prototype.toString.call(s) && !isVNode(s);
@@ -12,7 +13,7 @@ const SpinProvider = defineComponent({
12
13
  function renderIcon(props) {
13
14
  const icon = slots?.icon?.(props);
14
15
  const crafts = computed(()=>props.theme?.crafts?.tvSpin?.());
15
- if (icon) return createVNode(ark.span, {
16
+ if (!isEmptyVNode(icon)) return createVNode(ark.span, {
16
17
  class: crafts.value?.icon({
17
18
  class: clsx(props.class),
18
19
  ...props.theme
@@ -7,13 +7,13 @@ type __VLS_Slots = {} & {
7
7
  declare const __VLS_base: import("vue").DefineComponent<TabsProps, {
8
8
  $api: import("@ark-ui/vue").UseTabsReturn;
9
9
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ focusChange: (details: Tabs.FocusChangeDetails) => any;
10
11
  valueChange: (details: Tabs.ValueChangeDetails) => any;
11
12
  "update:modelValue": (value: string) => any;
12
- focusChange: (details: Tabs.FocusChangeDetails) => any;
13
13
  }, string, import("vue").PublicProps, Readonly<TabsProps> & Readonly<{
14
+ onFocusChange?: ((details: Tabs.FocusChangeDetails) => any) | undefined;
14
15
  onValueChange?: ((details: Tabs.ValueChangeDetails) => any) | undefined;
15
16
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
16
- onFocusChange?: ((details: Tabs.FocusChangeDetails) => any) | undefined;
17
17
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
18
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
19
19
  declare const _default: typeof __VLS_export;
@@ -2,8 +2,8 @@ import type { TreeNode } from '@ark-ui/vue/tree-view';
2
2
  import type { TreeProps } from '.';
3
3
  declare const __VLS_export: <T = TreeNode>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
4
  props: import("vue").PublicProps & __VLS_PrettifyLocal<TreeProps<T> & {
5
- onCheckedChange?: ((details: import("@zag-js/tree-view").CheckedChangeDetails) => any) | undefined;
6
5
  onFocusChange?: ((details: import("@zag-js/tree-view").FocusChangeDetails<any>) => any) | undefined;
6
+ onCheckedChange?: ((details: import("@zag-js/tree-view").CheckedChangeDetails) => any) | undefined;
7
7
  "onUpdate:focusedValue"?: ((value: import("./props").TreeValueType) => any) | undefined;
8
8
  "onUpdate:expandedValue"?: ((value: import("./props").TreeValueType[]) => any) | undefined;
9
9
  "onUpdate:selectedValue"?: ((value: import("./props").TreeValueType[]) => any) | undefined;
@@ -27,7 +27,7 @@ declare const __VLS_export: <T = TreeNode>(__VLS_props: NonNullable<Awaited<type
27
27
  } & {
28
28
  suffix?: (props: {}) => any;
29
29
  };
30
- emit: ((evt: "checkedChange", details: import("@zag-js/tree-view").CheckedChangeDetails) => void) & ((evt: "focusChange", details: import("@zag-js/tree-view").FocusChangeDetails<any>) => void) & ((evt: "update:focusedValue", value: import("./props").TreeValueType) => void) & ((evt: "update:expandedValue", value: import("./props").TreeValueType[]) => void) & ((evt: "update:selectedValue", value: import("./props").TreeValueType[]) => void) & ((evt: "update:checkedValue", value: import("./props").TreeValueType[]) => void) & ((evt: "expandedChange", details: import("@zag-js/tree-view").ExpandedChangeDetails<any>) => void) & ((evt: "selectionChange", details: import("@zag-js/tree-view").SelectionChangeDetails<any>) => void) & ((evt: "loadChildrenComplete", details: import("@zag-js/tree-view").LoadChildrenCompleteDetails<T>) => void) & ((evt: "loadChildrenError", details: import("@zag-js/tree-view").LoadChildrenErrorDetails<T>) => void) & ((evt: "renameStart", details: import("@zag-js/tree-view").RenameStartDetails<T>) => void) & ((evt: "beforeRename", details: import("@zag-js/tree-view").RenameCompleteDetails) => void) & ((evt: "renameComplete", details: import("@zag-js/tree-view").RenameCompleteDetails) => void);
30
+ emit: ((evt: "focusChange", details: import("@zag-js/tree-view").FocusChangeDetails<any>) => void) & ((evt: "checkedChange", details: import("@zag-js/tree-view").CheckedChangeDetails) => void) & ((evt: "update:focusedValue", value: import("./props").TreeValueType) => void) & ((evt: "update:expandedValue", value: import("./props").TreeValueType[]) => void) & ((evt: "update:selectedValue", value: import("./props").TreeValueType[]) => void) & ((evt: "update:checkedValue", value: import("./props").TreeValueType[]) => void) & ((evt: "expandedChange", details: import("@zag-js/tree-view").ExpandedChangeDetails<any>) => void) & ((evt: "selectionChange", details: import("@zag-js/tree-view").SelectionChangeDetails<any>) => void) & ((evt: "loadChildrenComplete", details: import("@zag-js/tree-view").LoadChildrenCompleteDetails<T>) => void) & ((evt: "loadChildrenError", details: import("@zag-js/tree-view").LoadChildrenErrorDetails<T>) => void) & ((evt: "renameStart", details: import("@zag-js/tree-view").RenameStartDetails<T>) => void) & ((evt: "beforeRename", details: import("@zag-js/tree-view").RenameCompleteDetails) => void) & ((evt: "renameComplete", details: import("@zag-js/tree-view").RenameCompleteDetails) => void);
31
31
  }>) => import("vue").VNode & {
32
32
  __ctx?: Awaited<typeof __VLS_setup>;
33
33
  };
@@ -1,7 +1,7 @@
1
1
  import { Fragment, cloneVNode, computed, createVNode, defineComponent, isVNode, mergeProps, toRefs, unref } from "vue";
2
2
  import { TreeView, useTreeViewContext } from "@ark-ui/vue";
3
- import { useTheme } from "../../composables/useTheme.js";
4
3
  import { clsx } from "@raxium/themes/utils";
4
+ import { useTheme } from "../../composables/useTheme.js";
5
5
  import { Check, ChevronRight, Minus } from "lucide-vue-next";
6
6
  import { TreeCheckboxNode } from "./index.js";
7
7
  import { Icon } from "../icon/index.js";
@@ -1,8 +1,8 @@
1
1
  import { Fragment, cloneVNode, computed, createVNode, defineComponent, isVNode, mergeProps, toRefs, unref } from "vue";
2
2
  import { TreeView } from "@ark-ui/vue";
3
+ import { clsx } from "@raxium/themes/utils";
3
4
  import { Icon } from "../icon/index.js";
4
5
  import { useTheme } from "../../composables/useTheme.js";
5
- import { clsx } from "@raxium/themes/utils";
6
6
  import { ChevronRight } from "lucide-vue-next";
7
7
  import { TreeNode } from "./index.js";
8
8
  import { injectTreeContext } from "./tree-context.js";
@@ -0,0 +1,191 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { Comment, Fragment, Text, createCommentVNode, createTextVNode, defineComponent, h } from "vue";
3
+ import { checkContextVNodePosition, excludeVNodesByName, excludeVNodesByNames, findVNodeByName, findVNodesByName, hasChildVNodeByName, isEmptyVNode, someVNode } from "../vnode.js";
4
+ function cmp(name) {
5
+ return defineComponent({
6
+ name,
7
+ setup: ()=>()=>null
8
+ });
9
+ }
10
+ describe('someVNode', ()=>{
11
+ it('returns false for undefined / empty', ()=>{
12
+ expect(someVNode(void 0, ()=>true)).toBe(false);
13
+ expect(someVNode([], ()=>true)).toBe(false);
14
+ });
15
+ it('matches direct vnode', ()=>{
16
+ const n = h('div');
17
+ expect(someVNode(n, (v)=>'div' === v.type)).toBe(true);
18
+ expect(someVNode(n, (v)=>'span' === v.type)).toBe(false);
19
+ });
20
+ it('recurses into array children (e.g. Fragment)', ()=>{
21
+ const inner = h('span');
22
+ const frag = h(Fragment, null, [
23
+ inner
24
+ ]);
25
+ expect(someVNode(frag, (v)=>'span' === v.type)).toBe(true);
26
+ });
27
+ });
28
+ describe('findVNodeByName', ()=>{
29
+ it('finds component by name with camelCase normalization', ()=>{
30
+ const C = cmp('MyWidget');
31
+ const nodes = [
32
+ h('div'),
33
+ h(C)
34
+ ];
35
+ expect(findVNodeByName(nodes, 'my-widget')).toBeDefined();
36
+ expect(findVNodeByName(nodes, 'MyWidget')).toBeDefined();
37
+ expect(findVNodeByName(nodes, 'my-widget').type.name).toBe('MyWidget');
38
+ });
39
+ it('returns undefined when missing or nodes empty', ()=>{
40
+ expect(findVNodeByName(void 0, 'x')).toBeUndefined();
41
+ expect(findVNodeByName([], 'x')).toBeUndefined();
42
+ expect(findVNodeByName([
43
+ h('div')
44
+ ], 'Missing')).toBeUndefined();
45
+ });
46
+ it('walks Fragment children', ()=>{
47
+ const Inner = cmp('InnerNode');
48
+ const frag = h(Fragment, null, [
49
+ h(Inner)
50
+ ]);
51
+ expect(findVNodeByName([
52
+ frag
53
+ ], 'InnerNode')).toBeDefined();
54
+ });
55
+ });
56
+ describe('findVNodesByName', ()=>{
57
+ it('collects all matches', ()=>{
58
+ const A = cmp('Dup');
59
+ const nodes = [
60
+ h(A),
61
+ h('p'),
62
+ h(A)
63
+ ];
64
+ const found = findVNodesByName(nodes, 'Dup');
65
+ expect(found).toHaveLength(2);
66
+ });
67
+ });
68
+ describe('excludeVNodesByName / excludeVNodesByNames', ()=>{
69
+ it('excludes one name', ()=>{
70
+ const A = cmp('Keep');
71
+ const B = cmp('Drop');
72
+ const out = excludeVNodesByName([
73
+ h(A),
74
+ h(B),
75
+ h('i')
76
+ ], 'Drop');
77
+ expect(out).toHaveLength(2);
78
+ expect(out.some((v)=>v.type?.name === 'Drop')).toBe(false);
79
+ });
80
+ it('excludes multiple names', ()=>{
81
+ const A = cmp('A1');
82
+ const B = cmp('A2');
83
+ const out = excludeVNodesByNames([
84
+ h(A),
85
+ h(B),
86
+ h('span')
87
+ ], [
88
+ 'A1',
89
+ 'A2'
90
+ ]);
91
+ expect(out).toHaveLength(1);
92
+ expect(out[0].type).toBe('span');
93
+ });
94
+ it('returns [] for empty input', ()=>{
95
+ expect(excludeVNodesByName(void 0, 'x')).toEqual([]);
96
+ });
97
+ });
98
+ describe('hasChildVNodeByName', ()=>{
99
+ it('matches root component name', ()=>{
100
+ const C = cmp('RootX');
101
+ expect(hasChildVNodeByName(h(C), 'root-x')).toBe(true);
102
+ });
103
+ it('matches nested component in children array', ()=>{
104
+ const Inner = cmp('Nested');
105
+ const root = h('div', [
106
+ h(Inner)
107
+ ]);
108
+ expect(hasChildVNodeByName(root, 'Nested')).toBe(true);
109
+ });
110
+ it('returns false when absent', ()=>{
111
+ expect(hasChildVNodeByName(void 0, 'x')).toBe(false);
112
+ expect(hasChildVNodeByName(h('div'), 'None')).toBe(false);
113
+ });
114
+ it('handles vnode array at root', ()=>{
115
+ const Inner = cmp('InArray');
116
+ expect(hasChildVNodeByName([
117
+ h('div'),
118
+ h(Inner)
119
+ ], 'InArray')).toBe(true);
120
+ });
121
+ });
122
+ describe('checkContextVNodePosition', ()=>{
123
+ it('warns when single child name equals context', ()=>{
124
+ const warn = vi.spyOn(console, 'warn').mockImplementation(()=>{});
125
+ const C = cmp('ContextHost');
126
+ checkContextVNodePosition([
127
+ h(C)
128
+ ], 'ContextHost', 'Parent');
129
+ expect(warn).toHaveBeenCalledTimes(1);
130
+ warn.mockRestore();
131
+ });
132
+ it('does not warn when multiple nodes', ()=>{
133
+ const warn = vi.spyOn(console, 'warn').mockImplementation(()=>{});
134
+ const C = cmp('ContextHost');
135
+ checkContextVNodePosition([
136
+ h(C),
137
+ h('div')
138
+ ], 'ContextHost', 'Parent');
139
+ expect(warn).not.toHaveBeenCalled();
140
+ warn.mockRestore();
141
+ });
142
+ });
143
+ describe('isEmptyVNode', ()=>{
144
+ it('treats null / undefined as empty', ()=>{
145
+ expect(isEmptyVNode(null)).toBe(true);
146
+ expect(isEmptyVNode(void 0)).toBe(true);
147
+ });
148
+ it('treats Comment as empty', ()=>{
149
+ const v = createCommentVNode('x');
150
+ expect(v.type).toBe(Comment);
151
+ expect(isEmptyVNode(v)).toBe(true);
152
+ });
153
+ it('treats blank Text as empty', ()=>{
154
+ expect(isEmptyVNode(createTextVNode(''))).toBe(true);
155
+ expect(isEmptyVNode(createTextVNode(' '))).toBe(true);
156
+ });
157
+ it('treats non-blank Text as non-empty', ()=>{
158
+ expect(isEmptyVNode(createTextVNode('a'))).toBe(false);
159
+ });
160
+ it('treats empty Fragment as empty', ()=>{
161
+ expect(isEmptyVNode(h(Fragment, null, []))).toBe(true);
162
+ expect(isEmptyVNode(h(Fragment, null, null))).toBe(true);
163
+ });
164
+ it('treats Fragment with only empty children as empty', ()=>{
165
+ expect(isEmptyVNode(h(Fragment, null, [
166
+ createCommentVNode(),
167
+ createTextVNode('')
168
+ ]))).toBe(true);
169
+ });
170
+ it('treats element / component as non-empty', ()=>{
171
+ expect(isEmptyVNode(h('div'))).toBe(false);
172
+ expect(isEmptyVNode(h(cmp('X')))).toBe(false);
173
+ });
174
+ it('requires every item in array to be empty', ()=>{
175
+ expect(isEmptyVNode([
176
+ createCommentVNode(),
177
+ createTextVNode('')
178
+ ])).toBe(true);
179
+ expect(isEmptyVNode([
180
+ createCommentVNode(),
181
+ h('span')
182
+ ])).toBe(false);
183
+ });
184
+ it('treats non-VNode object as empty (compat)', ()=>{
185
+ expect(isEmptyVNode({})).toBe(true);
186
+ });
187
+ it('compares Text type symbol', ()=>{
188
+ const tv = createTextVNode('hi');
189
+ expect(tv.type).toBe(Text);
190
+ });
191
+ });
@@ -6,3 +6,4 @@ export declare function excludeVNodesByName(node: VNode | VNode[] | undefined, n
6
6
  export declare function excludeVNodesByNames(nodes: VNode[] | undefined, name: string[]): VNode[];
7
7
  export declare function hasChildVNodeByName(node: VNode | VNode[] | undefined, name: string): boolean;
8
8
  export declare function checkContextVNodePosition(nodes: VNode[] | undefined, contextName: string, componentName?: string): void;
9
+ export declare function isEmptyVNode(node: VNode | VNode[] | null | undefined): boolean;
@@ -1,5 +1,5 @@
1
1
  import { camelCase, isEmpty } from "es-toolkit/compat";
2
- import { isVNode } from "vue";
2
+ import { Comment, Fragment, Text, isVNode } from "vue";
3
3
  function someVNode(children, pred) {
4
4
  const arr = Array.isArray(children) ? children : null != children ? [
5
5
  children
@@ -83,4 +83,23 @@ function checkContextVNodePosition(nodes, contextName, componentName) {
83
83
  _srcName === _targetName && console.warn(`\<${contextName}\> can not be a direct child of \<${componentName}\>, it may cause unexpected style behavior, consider lift it up or use it closer to where you want to use it `);
84
84
  }
85
85
  }
86
- export { checkContextVNodePosition, excludeVNodesByName, excludeVNodesByNames, findVNodeByName, findVNodesByName, hasChildVNodeByName, someVNode };
86
+ function isEmptyVNode(node) {
87
+ if (!node) return true;
88
+ const nodes = Array.isArray(node) ? node : [
89
+ node
90
+ ];
91
+ if (0 === nodes.length) return true;
92
+ return nodes.every((n)=>{
93
+ if (!n) return true;
94
+ if (!isVNode(n)) return true;
95
+ if (n.type === Comment) return true;
96
+ if (n.type === Text) return '' === String(n.children ?? '').trim();
97
+ if (n.type === Fragment) {
98
+ const ch = n.children;
99
+ if (null == ch || '' === ch) return true;
100
+ if (Array.isArray(ch)) return ch.every((c)=>isEmptyVNode(c));
101
+ }
102
+ return false;
103
+ });
104
+ }
105
+ export { checkContextVNodePosition, excludeVNodesByName, excludeVNodesByNames, findVNodeByName, findVNodesByName, hasChildVNodeByName, isEmptyVNode, someVNode };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@raxium/vue",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "description": "Vue core components for Raxium, based on Ark UI",
6
6
  "author": {
7
7
  "name": "Hwacc",
@@ -67,8 +67,8 @@
67
67
  "es-toolkit": "^1.44.0",
68
68
  "lucide-vue-next": "^0.577.0",
69
69
  "vue-component-type-helpers": "^3.2.1",
70
- "@raxium/shared": "0.1.1",
71
- "@raxium/themes": "0.1.1"
70
+ "@raxium/themes": "0.1.3",
71
+ "@raxium/shared": "0.1.1"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@ark-ui/vue": "^5.34.1",
@@ -86,8 +86,9 @@
86
86
  "rsbuild-plugin-unplugin-vue": "^0.2.0",
87
87
  "tailwind-merge": "^3.5.0",
88
88
  "tsc-alias": "^1.8.16",
89
+ "vitest": "^4.1.1",
89
90
  "vue-tsc": "^3.2.4",
90
- "@raxium/themes": "0.1.1",
91
+ "@raxium/themes": "0.1.3",
91
92
  "@raxium/shared": "0.1.1"
92
93
  },
93
94
  "publishConfig": {
@@ -95,6 +96,6 @@
95
96
  },
96
97
  "scripts": {
97
98
  "build": "rslib build --tsconfig ./tsconfig.build.json && vue-tsc --project tsconfig.build.json && tsc-alias --project tsconfig.build.json",
98
- "test": "echo \"Error: no test specified\" && exit 1"
99
+ "test": "vitest run"
99
100
  }
100
101
  }