@weni/unnnic-system 3.27.2 → 3.28.2-alpha.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.
package/package.json
CHANGED
|
@@ -73,20 +73,34 @@ const getComponentName = (vnode: VNode): string | undefined => {
|
|
|
73
73
|
return componentType?.name || componentType?.__name;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
const isFooter = (vnode: VNode) =>
|
|
77
|
+
getComponentName(vnode) === 'UnnnicPopoverFooter';
|
|
78
|
+
|
|
79
|
+
// This function recursively checks if there is a UnnnicPopoverFooter in the slot,
|
|
80
|
+
// and splits the content into content and footer
|
|
81
|
+
const splitSlot = computed(() => {
|
|
82
|
+
const footers: VNode[] = [];
|
|
83
|
+
|
|
84
|
+
const content = (function extract(vnodes: VNode[]): VNode[] {
|
|
85
|
+
return vnodes.filter((vnode: VNode) => {
|
|
86
|
+
if (!vnode || typeof vnode !== 'object') return true;
|
|
87
|
+
if (isFooter(vnode)) return footers.push(vnode) && false;
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
if (Array.isArray(vnode.children) && vnode.children.length) {
|
|
90
|
+
vnode.children = extract(vnode.children as VNode[]);
|
|
91
|
+
return (vnode.children as VNode[]).length > 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return true;
|
|
95
|
+
});
|
|
96
|
+
})(slots.default?.() || []);
|
|
97
|
+
|
|
98
|
+
return { content, footers };
|
|
88
99
|
});
|
|
89
100
|
|
|
101
|
+
const contentChildren = computed(() => splitSlot.value.content);
|
|
102
|
+
const footerChildren = computed(() => splitSlot.value.footers);
|
|
103
|
+
|
|
90
104
|
const contentWidth = computed(() => {
|
|
91
105
|
if (props.width) return props.width;
|
|
92
106
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PopoverOption } from '../components/ui/popover';
|
|
2
|
+
import UnnnicTag from '../components/Tag/Tag.vue';
|
|
2
3
|
import colorsList from '../utils/colorsList';
|
|
3
4
|
|
|
4
5
|
export default {
|
|
@@ -73,3 +74,55 @@ export const Default = {
|
|
|
73
74
|
`,
|
|
74
75
|
}),
|
|
75
76
|
};
|
|
77
|
+
|
|
78
|
+
export const WithTag = {
|
|
79
|
+
parameters: {
|
|
80
|
+
docs: {
|
|
81
|
+
description: {
|
|
82
|
+
story:
|
|
83
|
+
'Uses the default slot to render custom content, such as a label alongside a status tag. The option keeps the `space-between` layout, so the tag stays aligned to the end.',
|
|
84
|
+
},
|
|
85
|
+
source: {
|
|
86
|
+
code: `<UnnnicPopoverOption v-for="option in options" :key="option.value">
|
|
87
|
+
<span class="popover-option__label">{{ option.label }}</span>
|
|
88
|
+
<UnnnicTag
|
|
89
|
+
type="default"
|
|
90
|
+
size="small"
|
|
91
|
+
:scheme="statusConfig[option.status].scheme"
|
|
92
|
+
:text="statusConfig[option.status].text"
|
|
93
|
+
/>
|
|
94
|
+
</UnnnicPopoverOption>`,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
render: () => ({
|
|
99
|
+
components: { PopoverOption, UnnnicTag },
|
|
100
|
+
data() {
|
|
101
|
+
return {
|
|
102
|
+
options: [
|
|
103
|
+
{ label: 'John Doe', value: 'john-doe', status: 'online' },
|
|
104
|
+
{ label: 'Jane Doe', value: 'jane-doe', status: 'lunch' },
|
|
105
|
+
{ label: 'James Smith', value: 'james-smith', status: 'offline' },
|
|
106
|
+
],
|
|
107
|
+
statusConfig: {
|
|
108
|
+
online: { scheme: 'green', text: 'Online' },
|
|
109
|
+
lunch: { scheme: 'orange', text: 'Lunch' },
|
|
110
|
+
offline: { scheme: 'gray', text: 'Offline' },
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
template: `
|
|
115
|
+
<section style="display: flex; flex-direction: column; gap: 8px; width: 280px;">
|
|
116
|
+
<PopoverOption v-for="option in options" :key="option.value" :label="option.label">
|
|
117
|
+
<span style="flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{{ option.label }}</span>
|
|
118
|
+
<unnnic-tag
|
|
119
|
+
type="default"
|
|
120
|
+
size="small"
|
|
121
|
+
:scheme="statusConfig[option.status].scheme"
|
|
122
|
+
:text="statusConfig[option.status].text"
|
|
123
|
+
/>
|
|
124
|
+
</PopoverOption>
|
|
125
|
+
</section>
|
|
126
|
+
`,
|
|
127
|
+
}),
|
|
128
|
+
};
|