@weni/unnnic-system 3.12.6 → 3.12.8-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.
Files changed (91) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{es-e7dc92a2.mjs → es-52edeb71.mjs} +1 -1
  3. package/dist/{index-84ade580.mjs → index-756fe685.mjs} +99873 -96635
  4. package/dist/index.d.ts +5714 -1674
  5. package/dist/{pt-br-51fd679a.mjs → pt-br-24583c8c.mjs} +1 -1
  6. package/dist/style.css +1 -1
  7. package/dist/unnnic.mjs +236 -204
  8. package/dist/unnnic.umd.js +48 -44
  9. package/package.json +3 -2
  10. package/src/assets/scss/scheme-colors.scss +223 -223
  11. package/src/assets/scss/tailwind.scss +8 -0
  12. package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
  13. package/src/components/Checkbox/Checkbox.vue +1 -1
  14. package/src/components/Drawer/Drawer.vue +190 -269
  15. package/src/components/Drawer/__tests__/Drawer.spec.js +37 -46
  16. package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +18 -19
  17. package/src/components/FormElement/FormElement.vue +1 -1
  18. package/src/components/Input/BaseInput.vue +25 -5
  19. package/src/components/Input/Input.scss +2 -3
  20. package/src/components/Input/Input.vue +24 -1
  21. package/src/components/Input/TextInput.vue +64 -25
  22. package/src/components/Input/__test__/TextInput.spec.js +1 -1
  23. package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +5 -1
  24. package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +7 -1
  25. package/src/components/ModalDialog/ModalDialog.vue +64 -148
  26. package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +11 -221
  27. package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +1 -22
  28. package/src/components/MultiSelect/MultSelectOption.vue +49 -0
  29. package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +557 -0
  30. package/src/components/MultiSelect/__tests__/MultiSelectOption.spec.js +229 -0
  31. package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +87 -0
  32. package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +51 -0
  33. package/src/components/MultiSelect/index.vue +265 -0
  34. package/src/components/Radio/Radio.vue +1 -1
  35. package/src/components/Select/__tests__/Select.spec.js +422 -0
  36. package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
  37. package/src/components/Select/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
  38. package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +71 -0
  39. package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
  40. package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
  41. package/src/components/Select/__tests__/__snapshots__/SelectPopover.spec.js.snap +8 -0
  42. package/src/components/Select/index.vue +308 -0
  43. package/src/components/Switch/Switch.vue +1 -1
  44. package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +3 -1
  45. package/src/components/TemplatePreview/TemplatePreview.vue +2 -2
  46. package/src/components/TemplatePreview/TemplatePreviewModal.vue +1 -1
  47. package/src/components/Toast/Toast.vue +16 -9
  48. package/src/components/ToolTip/ToolTip.vue +25 -177
  49. package/src/components/ToolTip/__tests__/ToolTip.spec.js +339 -61
  50. package/src/components/index.ts +66 -6
  51. package/src/components/ui/dialog/Dialog.vue +19 -0
  52. package/src/components/ui/dialog/DialogClose.vue +29 -0
  53. package/src/components/ui/dialog/DialogContent.vue +140 -0
  54. package/src/components/ui/dialog/DialogFooter.vue +50 -0
  55. package/src/components/ui/dialog/DialogHeader.vue +83 -0
  56. package/src/components/ui/dialog/DialogTitle.vue +38 -0
  57. package/src/components/ui/dialog/DialogTrigger.vue +16 -0
  58. package/src/components/ui/dialog/index.ts +7 -0
  59. package/src/components/ui/drawer/Drawer.vue +27 -0
  60. package/src/components/ui/drawer/DrawerClose.vue +31 -0
  61. package/src/components/ui/drawer/DrawerContent.vue +111 -0
  62. package/src/components/ui/drawer/DrawerDescription.vue +40 -0
  63. package/src/components/ui/drawer/DrawerFooter.vue +38 -0
  64. package/src/components/ui/drawer/DrawerHeader.vue +57 -0
  65. package/src/components/ui/drawer/DrawerOverlay.vue +33 -0
  66. package/src/components/ui/drawer/DrawerTitle.vue +37 -0
  67. package/src/components/ui/drawer/DrawerTrigger.vue +31 -0
  68. package/src/components/ui/drawer/index.ts +10 -0
  69. package/src/components/ui/popover/PopoverContent.vue +30 -10
  70. package/src/components/ui/popover/PopoverOption.vue +5 -1
  71. package/src/components/ui/popover/PopoverTrigger.vue +5 -1
  72. package/src/components/ui/tooltip/Tooltip.vue +21 -0
  73. package/src/components/ui/tooltip/TooltipContent.vue +74 -0
  74. package/src/components/ui/tooltip/TooltipTrigger.vue +26 -0
  75. package/src/components/ui/tooltip/index.ts +3 -0
  76. package/src/lib/layer-manager.ts +92 -0
  77. package/src/locales/en.json +3 -1
  78. package/src/locales/es.json +3 -1
  79. package/src/locales/pt_br.json +3 -1
  80. package/src/stories/Dialog.stories.js +832 -0
  81. package/src/stories/Drawer.stories.js +1 -1
  82. package/src/stories/DrawerNext.stories.js +611 -0
  83. package/src/stories/Input.mdx +3 -0
  84. package/src/stories/LayerManager.docs.mdx +40 -0
  85. package/src/stories/LayerManager.stories.js +364 -0
  86. package/src/stories/ModalDialog.mdx +3 -0
  87. package/src/stories/ModalDialog.stories.js +1 -1
  88. package/src/stories/MultiSelect.stories.js +143 -45
  89. package/src/stories/Popover.stories.js +5 -0
  90. package/src/stories/Select.stories.js +161 -0
  91. package/src/components/MultiSelect/MultiSelect.vue +0 -297
@@ -0,0 +1,37 @@
1
+ <script lang="ts" setup>
2
+ import type { DrawerTitleProps } from 'vaul-vue';
3
+ import { type HTMLAttributes } from 'vue';
4
+ import { reactiveOmit } from '@vueuse/core';
5
+ import { DrawerTitle } from 'vaul-vue';
6
+ import { cn } from '@/lib/utils';
7
+
8
+ defineOptions({
9
+ name: 'UnnnicDrawerTitle',
10
+ });
11
+
12
+ const props = defineProps<
13
+ DrawerTitleProps & { class?: HTMLAttributes['class'] }
14
+ >();
15
+
16
+ const delegatedProps = reactiveOmit(props, 'class');
17
+ </script>
18
+
19
+ <template>
20
+ <DrawerTitle
21
+ v-bind="delegatedProps"
22
+ :class="cn('unnnic-drawer__title', props.class)"
23
+ >
24
+ <slot />
25
+ </DrawerTitle>
26
+ </template>
27
+
28
+ <style lang="scss" scoped>
29
+ @use '@/assets/scss/unnnic' as *;
30
+
31
+ .unnnic-drawer__title {
32
+ margin: 0;
33
+
34
+ color: $unnnic-color-fg-emphasized;
35
+ font: $unnnic-font-display-2;
36
+ }
37
+ </style>
@@ -0,0 +1,31 @@
1
+ <script setup lang="ts">
2
+ import type { DrawerTriggerProps } from 'vaul-vue';
3
+ import { DrawerTrigger } from 'vaul-vue';
4
+
5
+ defineOptions({
6
+ name: 'UnnnicDrawerTrigger',
7
+ });
8
+
9
+ const props = defineProps<DrawerTriggerProps>();
10
+ </script>
11
+
12
+ <template>
13
+ <DrawerTrigger
14
+ v-bind="props"
15
+ class="unnnic-drawer__trigger"
16
+ >
17
+ <slot />
18
+ </DrawerTrigger>
19
+ </template>
20
+
21
+ <style lang="scss" scoped>
22
+ @use '@/assets/scss/unnnic' as *;
23
+
24
+ .unnnic-drawer__trigger {
25
+ border: none;
26
+ background: none;
27
+ padding: 0;
28
+ margin: 0;
29
+ cursor: pointer;
30
+ }
31
+ </style>
@@ -0,0 +1,10 @@
1
+ export { default as Drawer } from './Drawer.vue';
2
+ export { default as DrawerContent } from './DrawerContent.vue';
3
+ export { default as DrawerDescription } from './DrawerDescription.vue';
4
+ export { default as DrawerFooter } from './DrawerFooter.vue';
5
+ export { default as DrawerHeader } from './DrawerHeader.vue';
6
+ export { default as DrawerOverlay } from './DrawerOverlay.vue';
7
+ export { default as DrawerTitle } from './DrawerTitle.vue';
8
+ export { default as DrawerTrigger } from './DrawerTrigger.vue';
9
+ export { default as DrawerClose } from './DrawerClose.vue';
10
+ export { DrawerPortal } from 'vaul-vue';
@@ -2,10 +2,10 @@
2
2
  <PopoverPortal>
3
3
  <PopoverContent
4
4
  v-bind="{ ...forwarded, ...$attrs }"
5
+ :style="{ width: contentWidth, zIndex: popoverZIndex }"
5
6
  :class="
6
7
  cn(
7
8
  'unnnic-popover',
8
- `unnnic-popover--size-${props.size}`,
9
9
  'bg-popover text-popover-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
10
10
  )
11
11
  "
@@ -34,6 +34,7 @@ import { computed, useSlots } from 'vue';
34
34
  import { reactiveOmit } from '@vueuse/core';
35
35
  import { PopoverContent, PopoverPortal, useForwardPropsEmits } from 'reka-ui';
36
36
  import { cn } from '@/lib/utils';
37
+ import { useLayerZIndex } from '@/lib/layer-manager';
37
38
 
38
39
  defineOptions({
39
40
  inheritAttrs: false,
@@ -43,7 +44,8 @@ const props = withDefaults(
43
44
  defineProps<
44
45
  PopoverContentProps & {
45
46
  class?: HTMLAttributes['class'];
46
- size?: 'small' | 'medium' | 'large';
47
+ size?: string;
48
+ width?: string;
47
49
  }
48
50
  >(),
49
51
  {
@@ -51,6 +53,7 @@ const props = withDefaults(
51
53
  sideOffset: 4,
52
54
  size: 'medium',
53
55
  class: '',
56
+ width: '',
54
57
  },
55
58
  );
56
59
  const emits = defineEmits<PopoverContentEmits>();
@@ -61,6 +64,8 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
61
64
 
62
65
  const slots = useSlots() as Slots;
63
66
 
67
+ const popoverZIndex = useLayerZIndex('popover');
68
+
64
69
  const getComponentName = (vnode: VNode): string | undefined => {
65
70
  const componentType = vnode.type as { name?: string; __name?: string };
66
71
  return componentType?.name || componentType?.__name;
@@ -79,6 +84,18 @@ const footerChildren = computed(() => {
79
84
  (vnode: VNode) => getComponentName(vnode) === 'UnnnicPopoverFooter',
80
85
  );
81
86
  });
87
+
88
+ const contentWidth = computed(() => {
89
+ if (props.width) return props.width;
90
+
91
+ const sizes = {
92
+ small: '240px',
93
+ medium: '320px',
94
+ large: '400px',
95
+ };
96
+
97
+ return sizes[props.size as keyof typeof sizes];
98
+ });
82
99
  </script>
83
100
 
84
101
  <style lang="scss">
@@ -87,19 +104,22 @@ const footerChildren = computed(() => {
87
104
  $popover-space: $unnnic-space-4;
88
105
 
89
106
  .unnnic-popover {
90
- z-index: 10000;
91
-
92
107
  border-radius: $unnnic-radius-2;
93
108
  box-shadow: $unnnic-shadow-1;
109
+ border: 1px solid $unnnic-color-border-soft;
94
110
 
95
- &--size-small {
96
- width: 240px;
111
+ &::-webkit-scrollbar {
112
+ width: $unnnic-spacing-inline-nano;
97
113
  }
98
- &--size-medium {
99
- width: 320px;
114
+
115
+ &::-webkit-scrollbar-thumb {
116
+ background: $unnnic-color-neutral-cleanest;
117
+ border-radius: $unnnic-border-radius-pill;
100
118
  }
101
- &--size-large {
102
- width: 400px;
119
+
120
+ &::-webkit-scrollbar-track {
121
+ background: $unnnic-color-neutral-soft;
122
+ border-radius: $unnnic-border-radius-pill;
103
123
  }
104
124
 
105
125
  &__content {
@@ -76,7 +76,7 @@ const schemeColor = computed(() => {
76
76
  .unnnic-popover-option {
77
77
  cursor: pointer;
78
78
  border-radius: $unnnic-radius-2;
79
- padding: $unnnic-space-2;
79
+ padding: $unnnic-space-2 $unnnic-space-4;
80
80
  font: $unnnic-font-emphasis;
81
81
  display: flex;
82
82
  gap: $unnnic-space-2;
@@ -98,6 +98,10 @@ const schemeColor = computed(() => {
98
98
  }
99
99
 
100
100
  &__label {
101
+ overflow: hidden;
102
+ text-overflow: ellipsis;
103
+ white-space: nowrap;
104
+
101
105
  @each $name, $color in $unnnic-scheme-colors {
102
106
  &.unnnic-popover-option__label--#{$name} {
103
107
  color: $color;
@@ -14,10 +14,14 @@ const props = defineProps<PopoverTriggerProps>();
14
14
  </PopoverTrigger>
15
15
  </template>
16
16
 
17
- <style scoped>
17
+ <style lang="scss" scoped>
18
18
  .unnnic-popover-trigger {
19
19
  border: none;
20
20
  background: transparent;
21
21
  padding: 0;
22
+
23
+ & > * {
24
+ width: 100%;
25
+ }
22
26
  }
23
27
  </style>
@@ -0,0 +1,21 @@
1
+ <script setup lang="ts">
2
+ import type { TooltipRootEmits, TooltipRootProps } from 'reka-ui';
3
+ import { TooltipRoot, useForwardPropsEmits } from 'reka-ui';
4
+ import { TooltipProvider } from 'reka-ui';
5
+
6
+ const props = defineProps<TooltipRootProps>();
7
+ const emits = defineEmits<TooltipRootEmits>();
8
+
9
+ const forwarded = useForwardPropsEmits(props, emits);
10
+ </script>
11
+
12
+ <template>
13
+ <TooltipProvider
14
+ :delayDuration="100"
15
+ disableClosingTrigger
16
+ >
17
+ <TooltipRoot v-bind="forwarded">
18
+ <slot />
19
+ </TooltipRoot>
20
+ </TooltipProvider>
21
+ </template>
@@ -0,0 +1,74 @@
1
+ <script setup lang="ts">
2
+ import type { TooltipContentEmits, TooltipContentProps } from 'reka-ui';
3
+ import type { HTMLAttributes } from 'vue';
4
+ import { reactiveOmit } from '@vueuse/core';
5
+ import {
6
+ TooltipArrow,
7
+ TooltipContent,
8
+ TooltipPortal,
9
+ useForwardPropsEmits,
10
+ } from 'reka-ui';
11
+ import { cn } from '@/lib/utils';
12
+ import { useLayerZIndex } from '@/lib/layer-manager';
13
+
14
+ defineOptions({
15
+ inheritAttrs: false,
16
+ });
17
+
18
+ const props = withDefaults(
19
+ defineProps<TooltipContentProps & { class?: HTMLAttributes['class'] }>(),
20
+ {
21
+ sideOffset: 0,
22
+ },
23
+ );
24
+
25
+ const emits = defineEmits<TooltipContentEmits>();
26
+
27
+ const delegatedProps = reactiveOmit(props, 'class');
28
+
29
+ const forwarded = useForwardPropsEmits(delegatedProps, emits);
30
+ const tooltipZIndex = useLayerZIndex('tooltip');
31
+ </script>
32
+
33
+ <template>
34
+ <TooltipPortal>
35
+ <TooltipContent
36
+ v-bind="{ ...forwarded, ...$attrs }"
37
+ :class="
38
+ cn(
39
+ 'tooltip__content',
40
+ 'animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
41
+ props.class,
42
+ )
43
+ "
44
+ :style="{ zIndex: tooltipZIndex }"
45
+ >
46
+ <slot />
47
+
48
+ <TooltipArrow class="tooltip__arrow" />
49
+ </TooltipContent>
50
+ </TooltipPortal>
51
+ </template>
52
+
53
+ <style lang="scss">
54
+ @use '@/assets/scss/unnnic' as *;
55
+
56
+ .tooltip__content {
57
+ background-color: $unnnic-color-gray-900;
58
+ color: $unnnic-color-white;
59
+ border-radius: $unnnic-radius-1;
60
+ padding: $unnnic-space-2;
61
+ box-shadow: $unnnic-shadow-1;
62
+ font: $unnnic-font-caption-2;
63
+
64
+ overflow-wrap: break-word;
65
+ }
66
+
67
+ .tooltip__arrow {
68
+ width: 10px;
69
+ height: 10px;
70
+ background-color: $unnnic-color-gray-900;
71
+ fill: $unnnic-color-gray-900;
72
+ transform: rotate(45deg) translate(-50%, -50%);
73
+ }
74
+ </style>
@@ -0,0 +1,26 @@
1
+ <script setup lang="ts">
2
+ import type { TooltipTriggerProps } from 'reka-ui';
3
+ import { TooltipTrigger } from 'reka-ui';
4
+
5
+ const props = defineProps<TooltipTriggerProps>();
6
+ </script>
7
+
8
+ <template>
9
+ <TooltipTrigger
10
+ v-bind="props"
11
+ as="div"
12
+ class="unnnic-tooltip-trigger"
13
+ >
14
+ <slot />
15
+ </TooltipTrigger>
16
+ </template>
17
+
18
+ <style lang="scss" scoped>
19
+ .unnnic-tooltip-trigger {
20
+ display: inline-block;
21
+
22
+ & > * {
23
+ width: 100%;
24
+ }
25
+ }
26
+ </style>
@@ -0,0 +1,3 @@
1
+ export { default as Tooltip } from './Tooltip.vue';
2
+ export { default as TooltipContent } from './TooltipContent.vue';
3
+ export { default as TooltipTrigger } from './TooltipTrigger.vue';
@@ -0,0 +1,92 @@
1
+ import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue';
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
+
15
+ const DEFAULT_STEP = 5;
16
+
17
+ const activeValues: Record<LayerToken, number[]> = {
18
+ hide: [],
19
+ base: [],
20
+ drawer: [],
21
+ modal: [],
22
+ popover: [],
23
+ tooltip: [],
24
+ toast: [],
25
+ };
26
+
27
+ interface Allocation {
28
+ id: symbol;
29
+ type: LayerToken;
30
+ value: number;
31
+ }
32
+
33
+ const allocations = new Map<symbol, Allocation>();
34
+
35
+ function acquire(type: LayerToken): Allocation {
36
+ const id = Symbol('layer');
37
+ const list = activeValues[type];
38
+ const lastValue = list.length ? list[list.length - 1] : layerScale[type];
39
+ 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;
46
+ }
47
+
48
+ function release(id: symbol) {
49
+ const allocation = allocations.get(id);
50
+ if (!allocation) {
51
+ return;
52
+ }
53
+
54
+ allocations.delete(id);
55
+ const list = activeValues[allocation.type];
56
+ const index = list.indexOf(allocation.value);
57
+
58
+ if (index !== -1) {
59
+ list.splice(index, 1);
60
+ }
61
+ }
62
+
63
+ export interface LayerZIndexOptions {
64
+ offset?: number;
65
+ }
66
+
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);
73
+
74
+ let allocationId: symbol | null = null;
75
+
76
+ const allocate = () => {
77
+ const allocation = acquire(type);
78
+ allocationId = allocation.id;
79
+ zIndex.value = allocation.value + (options?.offset ?? 0);
80
+ };
81
+
82
+ onMounted(allocate);
83
+
84
+ onBeforeUnmount(() => {
85
+ if (allocationId) {
86
+ release(allocationId);
87
+ allocationId = null;
88
+ }
89
+ });
90
+
91
+ return zIndex;
92
+ }
@@ -44,5 +44,7 @@
44
44
  "flags": "Flags",
45
45
  "custom": "Custom"
46
46
  }
47
- }
47
+ },
48
+ "search": "Search",
49
+ "without_results": "No results found"
48
50
  }
@@ -44,5 +44,7 @@
44
44
  "flags": "Banderas",
45
45
  "custom": "Personalizados"
46
46
  }
47
- }
47
+ },
48
+ "search": "Buscar",
49
+ "without_results": "No se encontró ningún resultado"
48
50
  }
@@ -44,5 +44,7 @@
44
44
  "flags": "Bandeiras",
45
45
  "custom": "Personalizados"
46
46
  }
47
- }
47
+ },
48
+ "search": "Buscar",
49
+ "without_results": "Nenhum resultado encontrado"
48
50
  }