@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.
Files changed (44) hide show
  1. package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +3 -0
  2. package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +6 -0
  3. package/dist/components/Card/Card.vue.d.ts +3 -0
  4. package/dist/components/Card/CardStatusesContainer.vue.d.ts +3 -0
  5. package/dist/components/Card/SimpleCard.vue.d.ts +3 -0
  6. package/dist/components/Card/TitleCard.vue.d.ts +3 -0
  7. package/dist/components/CardInformation/CardInformation.vue.d.ts +3 -0
  8. package/dist/components/ChartBar/ChartBar.vue.d.ts +3 -0
  9. package/dist/components/ChartLine/ChartLine.vue.d.ts +3 -0
  10. package/dist/components/ChatText/ChatText.vue.d.ts +3 -0
  11. package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +3 -0
  12. package/dist/components/DataArea/DataArea.vue.d.ts +3 -0
  13. package/dist/components/DateFilter/DateFilter.vue.d.ts +3 -3
  14. package/dist/components/FormElement/FormElement.vue.d.ts +2 -2
  15. package/dist/components/Input/Input.vue.d.ts +3 -3
  16. package/dist/components/Label/Label.vue.d.ts +1 -1
  17. package/dist/components/Label/Label.vue.d.ts.map +1 -1
  18. package/dist/components/ModalNext/ModalNext.vue.d.ts +3 -3
  19. package/dist/components/MoodRating/MoodRating.vue.d.ts +3 -0
  20. package/dist/components/Slider/Slider.vue.d.ts +3 -0
  21. package/dist/components/Switch/Switch.vue.d.ts +1 -1
  22. package/dist/components/Tab/Tab.vue.d.ts +3 -0
  23. package/dist/components/TextArea/TextArea.vue.d.ts +3 -3
  24. package/dist/components/ToolTip/ToolTip.vue.d.ts +3 -0
  25. package/dist/components/ui/tooltip/TooltipContent.vue.d.ts +1 -0
  26. package/dist/components/ui/tooltip/TooltipContent.vue.d.ts.map +1 -1
  27. package/dist/{es-c09db281.mjs → es-29a7a594.mjs} +1 -1
  28. package/dist/{index-b84816f5.mjs → index-07b8dd4d.mjs} +2267 -2283
  29. package/dist/lib/layer-manager.d.ts +1 -11
  30. package/dist/lib/layer-manager.d.ts.map +1 -1
  31. package/dist/{pt-br-205e873a.mjs → pt-br-e37b537e.mjs} +1 -1
  32. package/dist/style.css +1 -1
  33. package/dist/unnnic.mjs +1 -1
  34. package/dist/unnnic.umd.js +30 -30
  35. package/package.json +1 -1
  36. package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
  37. package/src/components/Toast/Toast.vue +1 -1
  38. package/src/components/ui/dialog/DialogContent.vue +2 -2
  39. package/src/components/ui/drawer/DrawerContent.vue +1 -1
  40. package/src/components/ui/popover/PopoverContent.vue +1 -1
  41. package/src/components/ui/tooltip/TooltipContent.vue +2 -1
  42. package/src/lib/layer-manager.ts +24 -52
  43. package/src/stories/LayerManager.docs.mdx +9 -9
  44. package/src/stories/LayerManager.stories.js +54 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weni/unnnic-system",
3
- "version": "3.12.3-alpha-teleports.2",
3
+ "version": "3.12.3-alpha-teleports.3",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -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: 1405;">
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>
@@ -111,7 +111,7 @@ const typeConfig = computed(() => {
111
111
  };
112
112
  });
113
113
 
114
- const toastZIndex = useLayerZIndex('toast');
114
+ const toastZIndex = useLayerZIndex();
115
115
 
116
116
  const handleClose = () => {
117
117
  isVisible.value = false;
@@ -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('modal', { offset: -2 });
40
- const modalZIndex = useLayerZIndex('modal');
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('drawer');
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('popover');
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('tooltip');
31
+ const tooltipZIndex = useLayerZIndex();
31
32
  </script>
32
33
 
33
34
  <template>
@@ -1,62 +1,37 @@
1
1
  import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue';
2
2
 
3
- export const layerScale = {
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 activeValues: Record<LayerToken, number[]> = {
18
- hide: [],
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 Allocation {
9
+ interface LayerHandle {
28
10
  id: symbol;
29
- type: LayerToken;
30
11
  value: number;
31
12
  }
32
13
 
33
- const allocations = new Map<symbol, Allocation>();
34
-
35
- function acquire(type: LayerToken): Allocation {
14
+ function pushLayer(): LayerHandle {
36
15
  const id = Symbol('layer');
37
- const list = activeValues[type];
38
- const lastValue = list.length ? list[list.length - 1] : layerScale[type];
16
+ const lastValue = layerStack.length
17
+ ? layerStack[layerStack.length - 1]
18
+ : BASE_LAYER_Z_INDEX;
39
19
  const value = lastValue + DEFAULT_STEP;
40
- const allocation: Allocation = { id, type, value };
41
-
42
- list.push(value);
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 release(id: symbol) {
49
- const allocation = allocations.get(id);
50
- if (!allocation) {
25
+ function popLayer(id: symbol) {
26
+ const value = layerHandles.get(id);
27
+ if (value === undefined) {
51
28
  return;
52
29
  }
53
30
 
54
- allocations.delete(id);
55
- const list = activeValues[allocation.type];
56
- const index = list.indexOf(allocation.value);
57
-
31
+ layerHandles.delete(id);
32
+ const index = layerStack.indexOf(value);
58
33
  if (index !== -1) {
59
- list.splice(index, 1);
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
- type: LayerToken = 'base',
69
- options?: LayerZIndexOptions,
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 allocation = acquire(type);
78
- allocationId = allocation.id;
79
- zIndex.value = allocation.value + (options?.offset ?? 0);
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
- release(allocationId);
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. Defining semantic bands (drawer, modal, popover, tooltip, toast) and allocating values automatically whenever a component mounts. [Reference](https://v1.chakra-ui.com/docs/components/recipes/z-index)
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. **Tokens, not numbers** – components request a token such as `modal`, `popover`, or `tooltip`. The manager maps those tokens to a base band (e.g., modals start at 1200, popovers at 1400).
18
- 2. **Auto-increment** – every time a component mounts, it receives the next value in its band so nested dialogs or infinite toasts still stack correctly.
19
- 3. **Scoped offsets** – overlays that belong to the same surface (e.g., `DialogOverlay` vs `DialogContent`) simply call `useLayerZIndex` with a small negative offset so the overlay sits just beneath the content that opened it.
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('modal');
23
- const overlayZ = useLayerZIndex('modal', { offset: -2 });
22
+ const modalZ = useLayerZIndex();
23
+ const overlayZ = useLayerZIndex({ offset: -2 });
24
24
  ```
25
25
 
26
26
  ## Benefits
27
27
 
28
- - **Deterministic ordering** – open a drawer, then a popover, then a dialog, then a tooltip and the visual order will always follow the semantic bands.
29
- - **Safer refactors** – tokens can be remapped (e.g., raise the entire `tooltip` band) without touching every component.
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 new token in the layer manager if the surface fits the existing pattern (e.g., `tour`).
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 + Tooltip + Popover',
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 + Tooltip + Popover',
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 + Dialog',
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 + Toast',
349
+ name: 'Dialog > Toast',
307
350
  render: () => ({
308
351
  components: {
309
352
  Dialog,