@weni/unnnic-system 3.12.3-alpha-teleports.2 → 3.12.3-alpha-teleports.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.
- package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +3 -0
- package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +6 -0
- package/dist/components/Card/Card.vue.d.ts +3 -0
- package/dist/components/Card/CardStatusesContainer.vue.d.ts +3 -0
- package/dist/components/Card/SimpleCard.vue.d.ts +3 -0
- package/dist/components/Card/TitleCard.vue.d.ts +3 -0
- package/dist/components/CardInformation/CardInformation.vue.d.ts +3 -0
- package/dist/components/ChartBar/ChartBar.vue.d.ts +3 -0
- package/dist/components/ChartLine/ChartLine.vue.d.ts +3 -0
- package/dist/components/ChatText/ChatText.vue.d.ts +3 -0
- package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +3 -0
- package/dist/components/DataArea/DataArea.vue.d.ts +3 -0
- package/dist/components/DateFilter/DateFilter.vue.d.ts +3 -3
- package/dist/components/FormElement/FormElement.vue.d.ts +2 -2
- package/dist/components/Input/Input.vue.d.ts +3 -3
- package/dist/components/Label/Label.vue.d.ts +1 -1
- package/dist/components/Label/Label.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +3 -3
- package/dist/components/MoodRating/MoodRating.vue.d.ts +3 -0
- package/dist/components/Slider/Slider.vue.d.ts +3 -0
- package/dist/components/Switch/Switch.vue.d.ts +1 -1
- package/dist/components/Tab/Tab.vue.d.ts +3 -0
- package/dist/components/TextArea/TextArea.vue.d.ts +3 -3
- package/dist/components/ToolTip/ToolTip.vue.d.ts +3 -0
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts +1 -0
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts.map +1 -1
- package/dist/{es-c09db281.mjs → es-29a7a594.mjs} +1 -1
- package/dist/{index-b84816f5.mjs → index-07b8dd4d.mjs} +2267 -2283
- package/dist/lib/layer-manager.d.ts +1 -11
- package/dist/lib/layer-manager.d.ts.map +1 -1
- package/dist/{pt-br-205e873a.mjs → pt-br-e37b537e.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +1 -1
- package/dist/unnnic.umd.js +30 -30
- package/package.json +1 -1
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
- package/src/components/Toast/Toast.vue +1 -1
- package/src/components/ui/dialog/DialogContent.vue +2 -2
- package/src/components/ui/drawer/DrawerContent.vue +1 -1
- package/src/components/ui/popover/PopoverContent.vue +1 -1
- package/src/components/ui/tooltip/TooltipContent.vue +2 -1
- package/src/lib/layer-manager.ts +24 -52
- package/src/stories/LayerManager.docs.mdx +9 -9
- package/src/stories/LayerManager.stories.js +54 -11
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`UnnnicAlert.vue > matches the snapshot 1`] = `
|
|
4
4
|
"<transition-stub data-v-c3231c18="" name="toast-slide" appear="true" persisted="false" css="true" data-testid="toast-transition">
|
|
5
|
-
<aside data-v-c3231c18="" class="unnnic-toast unnnic-toast--success" role="status" aria-live="polite" data-testid="toast" style="z-index:
|
|
5
|
+
<aside data-v-c3231c18="" class="unnnic-toast unnnic-toast--success" role="status" aria-live="polite" data-testid="toast" style="z-index: 1005;">
|
|
6
6
|
<section data-v-c3231c18="" class="unnnic-toast__content" data-testid="toast-content">
|
|
7
7
|
<header data-v-c3231c18="" class="unnnic-toast__header" data-testid="toast-header"><span data-v-26446d8e="" data-v-c3231c18="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--green-500 unnnic-icon-size--ant unnnic-icon__size--ant" data-testid="toast-type-icon" translate="no">check_circle</span>
|
|
8
8
|
<h3 data-v-c3231c18="" class="unnnic-toast__title" data-testid="toast-title">Test Alert</h3><span data-v-26446d8e="" data-v-c3231c18="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-dark unnnic-icon-size--ant unnnic-icon__size--ant unnnic--clickable unnnic-toast__close" data-testid="toast-close-icon" translate="no">close</span>
|
|
@@ -36,8 +36,8 @@ const delegatedProps = reactiveOmit(props, 'class', 'parentClass');
|
|
|
36
36
|
|
|
37
37
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
38
38
|
|
|
39
|
-
const overlayZIndex = useLayerZIndex(
|
|
40
|
-
const modalZIndex = useLayerZIndex(
|
|
39
|
+
const overlayZIndex = useLayerZIndex({ offset: -2 });
|
|
40
|
+
const modalZIndex = useLayerZIndex();
|
|
41
41
|
|
|
42
42
|
const contentClasses = computed(() =>
|
|
43
43
|
cn(
|
|
@@ -31,7 +31,7 @@ const emits = defineEmits<DialogContentEmits>();
|
|
|
31
31
|
const delegatedProps = reactiveOmit(props, 'class');
|
|
32
32
|
const forwardedProps = useForwardPropsEmits(delegatedProps, emits);
|
|
33
33
|
|
|
34
|
-
const layerZIndex = useLayerZIndex(
|
|
34
|
+
const layerZIndex = useLayerZIndex();
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
37
|
<template>
|
|
@@ -63,7 +63,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
63
63
|
|
|
64
64
|
const slots = useSlots();
|
|
65
65
|
|
|
66
|
-
const popoverZIndex = useLayerZIndex(
|
|
66
|
+
const popoverZIndex = useLayerZIndex();
|
|
67
67
|
|
|
68
68
|
const getComponentName = (vnode: VNode): string | undefined => {
|
|
69
69
|
const componentType = vnode.type as { name?: string; __name?: string };
|
|
@@ -19,6 +19,7 @@ const props = withDefaults(
|
|
|
19
19
|
defineProps<TooltipContentProps & { class?: HTMLAttributes['class'] }>(),
|
|
20
20
|
{
|
|
21
21
|
sideOffset: 0,
|
|
22
|
+
class: undefined,
|
|
22
23
|
},
|
|
23
24
|
);
|
|
24
25
|
|
|
@@ -27,7 +28,7 @@ const emits = defineEmits<TooltipContentEmits>();
|
|
|
27
28
|
const delegatedProps = reactiveOmit(props, 'class');
|
|
28
29
|
|
|
29
30
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
30
|
-
const tooltipZIndex = useLayerZIndex(
|
|
31
|
+
const tooltipZIndex = useLayerZIndex();
|
|
31
32
|
</script>
|
|
32
33
|
|
|
33
34
|
<template>
|
package/src/lib/layer-manager.ts
CHANGED
|
@@ -1,62 +1,37 @@
|
|
|
1
1
|
import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
hide: -1,
|
|
5
|
-
base: 0,
|
|
6
|
-
drawer: 1000,
|
|
7
|
-
modal: 1100,
|
|
8
|
-
popover: 1200,
|
|
9
|
-
tooltip: 1300,
|
|
10
|
-
toast: 1400,
|
|
11
|
-
} as const;
|
|
12
|
-
|
|
13
|
-
export type LayerToken = keyof typeof layerScale;
|
|
14
|
-
|
|
3
|
+
const BASE_LAYER_Z_INDEX = 1000;
|
|
15
4
|
const DEFAULT_STEP = 5;
|
|
16
5
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
base: [],
|
|
20
|
-
drawer: [],
|
|
21
|
-
modal: [],
|
|
22
|
-
popover: [],
|
|
23
|
-
tooltip: [],
|
|
24
|
-
toast: [],
|
|
25
|
-
};
|
|
6
|
+
const layerStack: number[] = [];
|
|
7
|
+
const layerHandles = new Map<symbol, number>();
|
|
26
8
|
|
|
27
|
-
interface
|
|
9
|
+
interface LayerHandle {
|
|
28
10
|
id: symbol;
|
|
29
|
-
type: LayerToken;
|
|
30
11
|
value: number;
|
|
31
12
|
}
|
|
32
13
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function acquire(type: LayerToken): Allocation {
|
|
14
|
+
function pushLayer(): LayerHandle {
|
|
36
15
|
const id = Symbol('layer');
|
|
37
|
-
const
|
|
38
|
-
|
|
16
|
+
const lastValue = layerStack.length
|
|
17
|
+
? layerStack[layerStack.length - 1]
|
|
18
|
+
: BASE_LAYER_Z_INDEX;
|
|
39
19
|
const value = lastValue + DEFAULT_STEP;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
allocations.set(id, allocation);
|
|
44
|
-
|
|
45
|
-
return allocation;
|
|
20
|
+
layerStack.push(value);
|
|
21
|
+
layerHandles.set(id, value);
|
|
22
|
+
return { id, value };
|
|
46
23
|
}
|
|
47
24
|
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
25
|
+
function popLayer(id: symbol) {
|
|
26
|
+
const value = layerHandles.get(id);
|
|
27
|
+
if (value === undefined) {
|
|
51
28
|
return;
|
|
52
29
|
}
|
|
53
30
|
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
const index = list.indexOf(allocation.value);
|
|
57
|
-
|
|
31
|
+
layerHandles.delete(id);
|
|
32
|
+
const index = layerStack.indexOf(value);
|
|
58
33
|
if (index !== -1) {
|
|
59
|
-
|
|
34
|
+
layerStack.splice(index, 1);
|
|
60
35
|
}
|
|
61
36
|
}
|
|
62
37
|
|
|
@@ -64,26 +39,23 @@ export interface LayerZIndexOptions {
|
|
|
64
39
|
offset?: number;
|
|
65
40
|
}
|
|
66
41
|
|
|
67
|
-
export function useLayerZIndex(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
): Ref<number> {
|
|
71
|
-
const initialValue = layerScale[type] + (options?.offset ?? 0);
|
|
72
|
-
const zIndex = ref(initialValue);
|
|
42
|
+
export function useLayerZIndex(options?: LayerZIndexOptions): Ref<number> {
|
|
43
|
+
const offset = options?.offset ?? 0;
|
|
44
|
+
const zIndex = ref(BASE_LAYER_Z_INDEX + offset);
|
|
73
45
|
|
|
74
46
|
let allocationId: symbol | null = null;
|
|
75
47
|
|
|
76
48
|
const allocate = () => {
|
|
77
|
-
const
|
|
78
|
-
allocationId =
|
|
79
|
-
zIndex.value =
|
|
49
|
+
const handle = pushLayer();
|
|
50
|
+
allocationId = handle.id;
|
|
51
|
+
zIndex.value = handle.value + offset;
|
|
80
52
|
};
|
|
81
53
|
|
|
82
54
|
onMounted(allocate);
|
|
83
55
|
|
|
84
56
|
onBeforeUnmount(() => {
|
|
85
57
|
if (allocationId) {
|
|
86
|
-
|
|
58
|
+
popLayer(allocationId);
|
|
87
59
|
allocationId = null;
|
|
88
60
|
}
|
|
89
61
|
});
|
|
@@ -4,7 +4,7 @@ import { Meta } from '@storybook/blocks';
|
|
|
4
4
|
|
|
5
5
|
# Layer Manager Overview
|
|
6
6
|
|
|
7
|
-
The layer manager exists to keep every teleported component (dialogs, drawers, popovers, tooltips, toasts, etc.) in a predictable stacking order without sprinkling arbitrary `z-index: 9999` rules across the codebase.
|
|
7
|
+
The layer manager exists to keep every teleported component (dialogs, drawers, popovers, tooltips, toasts, etc.) in a predictable stacking order without sprinkling arbitrary `z-index: 9999` rules across the codebase. Instead of assigning fixed bands per component type, we keep a single global stack that increments as layers mount. [Reference](https://v1.chakra-ui.com/docs/components/recipes/z-index)
|
|
8
8
|
|
|
9
9
|
## Why avoid manual z-index values?
|
|
10
10
|
|
|
@@ -14,25 +14,25 @@ The layer manager exists to keep every teleported component (dialogs, drawers, p
|
|
|
14
14
|
|
|
15
15
|
## How it works here
|
|
16
16
|
|
|
17
|
-
1. **
|
|
18
|
-
2. **Auto-increment** – every time a component mounts, it receives the next value in
|
|
19
|
-
3. **Scoped offsets** – overlays that belong to the same surface (e.g., `DialogOverlay` vs `DialogContent`)
|
|
17
|
+
1. **Single base (1000)** – all teleported layers share the same starting point, which keeps the implementation simple and predictable.
|
|
18
|
+
2. **Auto-increment** – every time a component mounts, it receives the next value in the global stack so the newest element always sits on top, regardless of type.
|
|
19
|
+
3. **Scoped offsets** – overlays that belong to the same surface (e.g., `DialogOverlay` vs. `DialogContent`) call `useLayerZIndex({ offset: -2 })` so the overlay sits just beneath the content that spawned it.
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
const modalZ = useLayerZIndex(
|
|
23
|
-
const overlayZ = useLayerZIndex(
|
|
22
|
+
const modalZ = useLayerZIndex();
|
|
23
|
+
const overlayZ = useLayerZIndex({ offset: -2 });
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Benefits
|
|
27
27
|
|
|
28
|
-
- **Deterministic ordering** –
|
|
29
|
-
- **Safer refactors** –
|
|
28
|
+
- **Deterministic ordering** – the last overlay opened is always on top, no matter if it is a drawer, modal, popover, or toast.
|
|
29
|
+
- **Safer refactors** – no need to chase down hard-coded z-index constants across the codebase; everything flows through the same stack.
|
|
30
30
|
|
|
31
31
|
## When to override
|
|
32
32
|
|
|
33
33
|
In rare cases you might still need a custom `z-index`. Prefer to:
|
|
34
34
|
|
|
35
|
-
1. Add a
|
|
35
|
+
1. Add a dedicated offset (e.g., `useLayerZIndex({ offset: X })`) if the overlay needs to sit just above/below a sibling.
|
|
36
36
|
2. Only apply inline overrides for truly one-off cases, and document why the global manager does not work there.
|
|
37
37
|
|
|
38
38
|
|
|
@@ -48,7 +48,7 @@ export default {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export const DialogWithTooltipAndPopover = {
|
|
51
|
-
name: 'Dialog
|
|
51
|
+
name: 'Dialog > Tooltip + Popover',
|
|
52
52
|
render: () => ({
|
|
53
53
|
components: {
|
|
54
54
|
Dialog,
|
|
@@ -110,7 +110,7 @@ export const DialogWithTooltipAndPopover = {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
export const DrawerWithTooltipAndPopover = {
|
|
113
|
-
name: 'Drawer
|
|
113
|
+
name: 'Drawer > Tooltip + Popover',
|
|
114
114
|
render: () => ({
|
|
115
115
|
components: {
|
|
116
116
|
Drawer,
|
|
@@ -174,7 +174,7 @@ export const DrawerWithTooltipAndPopover = {
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
export const DrawerNextToDialog = {
|
|
177
|
-
name: 'Drawer
|
|
177
|
+
name: 'Drawer > Dialog',
|
|
178
178
|
render: () => ({
|
|
179
179
|
components: {
|
|
180
180
|
Drawer,
|
|
@@ -188,8 +188,6 @@ export const DrawerNextToDialog = {
|
|
|
188
188
|
DialogContent,
|
|
189
189
|
DialogHeader,
|
|
190
190
|
DialogTitle,
|
|
191
|
-
DialogFooter,
|
|
192
|
-
DialogClose,
|
|
193
191
|
UnnnicButton,
|
|
194
192
|
},
|
|
195
193
|
setup() {
|
|
@@ -224,11 +222,6 @@ export const DrawerNextToDialog = {
|
|
|
224
222
|
<div style="padding: 24px; color: #67738B;">
|
|
225
223
|
This dialog must appear above the drawer and its overlay.
|
|
226
224
|
</div>
|
|
227
|
-
<DialogFooter>
|
|
228
|
-
<DialogClose>
|
|
229
|
-
<UnnnicButton text="Close dialog" type="tertiary" />
|
|
230
|
-
</DialogClose>
|
|
231
|
-
</DialogFooter>
|
|
232
225
|
</DialogContent>
|
|
233
226
|
</Dialog>
|
|
234
227
|
</div>
|
|
@@ -236,6 +229,56 @@ export const DrawerNextToDialog = {
|
|
|
236
229
|
}),
|
|
237
230
|
};
|
|
238
231
|
|
|
232
|
+
export const DrawerOpenedFromDialog = {
|
|
233
|
+
name: 'Dialog > Drawer',
|
|
234
|
+
render: () => ({
|
|
235
|
+
components: {
|
|
236
|
+
UnnnicButton,
|
|
237
|
+
Dialog,
|
|
238
|
+
DialogContent,
|
|
239
|
+
DialogHeader,
|
|
240
|
+
DialogTitle,
|
|
241
|
+
Drawer,
|
|
242
|
+
DrawerContent,
|
|
243
|
+
DrawerHeader,
|
|
244
|
+
DrawerTitle,
|
|
245
|
+
DrawerDescription,
|
|
246
|
+
},
|
|
247
|
+
setup() {
|
|
248
|
+
const dialogOpen = ref(false);
|
|
249
|
+
const drawerOpen = ref(false);
|
|
250
|
+
return { dialogOpen, drawerOpen };
|
|
251
|
+
},
|
|
252
|
+
template: `
|
|
253
|
+
<div>
|
|
254
|
+
<div style="display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;">
|
|
255
|
+
<UnnnicButton text="Open dialog" type="primary" @click="dialogOpen = true" />
|
|
256
|
+
</div>
|
|
257
|
+
<Dialog v-model:open="dialogOpen">
|
|
258
|
+
<DialogContent>
|
|
259
|
+
<DialogHeader>
|
|
260
|
+
<DialogTitle>Dialog</DialogTitle>
|
|
261
|
+
</DialogHeader>
|
|
262
|
+
<div style="padding: 24px; color: #67738B;">
|
|
263
|
+
<UnnnicButton text="Open drawer" type="primary" @click="drawerOpen = true" />
|
|
264
|
+
</div>
|
|
265
|
+
</DialogContent>
|
|
266
|
+
</Dialog>
|
|
267
|
+
<Drawer v-model:open="drawerOpen">
|
|
268
|
+
<DrawerContent>
|
|
269
|
+
<DrawerHeader>
|
|
270
|
+
<DrawerTitle>Drawer</DrawerTitle>
|
|
271
|
+
</DrawerHeader>
|
|
272
|
+
<div style="padding: 24px; color: #67738B;">
|
|
273
|
+
Drawer should appear above the dialog.
|
|
274
|
+
</div>
|
|
275
|
+
</DrawerContent>
|
|
276
|
+
</Drawer>
|
|
277
|
+
</div>
|
|
278
|
+
`,
|
|
279
|
+
}),
|
|
280
|
+
};
|
|
281
|
+
|
|
239
282
|
export const NestedDialogs = {
|
|
240
283
|
name: 'Dialog nested',
|
|
241
284
|
render: () => ({
|
|
@@ -303,7 +346,7 @@ export const NestedDialogs = {
|
|
|
303
346
|
};
|
|
304
347
|
|
|
305
348
|
export const DialogWithToast = {
|
|
306
|
-
name: 'Dialog
|
|
349
|
+
name: 'Dialog > Toast',
|
|
307
350
|
render: () => ({
|
|
308
351
|
components: {
|
|
309
352
|
Dialog,
|