@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weni/unnnic-system",
3
- "version": "3.27.2",
3
+ "version": "3.28.2-alpha.0",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -140,4 +140,4 @@
140
140
  "vue-eslint-parser": "^10.4.0",
141
141
  "vue-tsc": "^3.0.5"
142
142
  }
143
- }
143
+ }
@@ -73,20 +73,34 @@ const getComponentName = (vnode: VNode): string | undefined => {
73
73
  return componentType?.name || componentType?.__name;
74
74
  };
75
75
 
76
- const contentChildren = computed(() => {
77
- const defaultSlot = slots.default?.() || [];
78
- return defaultSlot.filter(
79
- (vnode: VNode) => getComponentName(vnode) !== 'UnnnicPopoverFooter',
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
- const footerChildren = computed(() => {
84
- const defaultSlot = slots.default?.() || [];
85
- return defaultSlot.filter(
86
- (vnode: VNode) => getComponentName(vnode) === 'UnnnicPopoverFooter',
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
 
@@ -21,12 +21,8 @@ $popover-space: $unnnic-space-4;
21
21
  padding: $popover-space;
22
22
 
23
23
  display: flex;
24
- justify-content: center;
24
+ justify-content: flex-end;
25
25
  align-items: center;
26
26
  gap: $unnnic-space-2;
27
-
28
- > * {
29
- width: 100%;
30
- }
31
27
  }
32
28
  </style>
@@ -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
+ };