design-system-next 1.2.5 → 1.2.7

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 (29) hide show
  1. package/dist/design-system-next.js +1959 -1870
  2. package/dist/design-system-next.js.gz +0 -0
  3. package/dist/main.css +1 -1
  4. package/dist/main.css.gz +0 -0
  5. package/package.json +1 -1
  6. package/src/App.vue +2 -5
  7. package/src/assets/images/sample-profile-image.jpg +0 -0
  8. package/src/assets/images/sprout-hr-logo.svg +33 -0
  9. package/src/assets/styles/tailwind.css +0 -66
  10. package/src/components/avatar/avatar.vue +2 -0
  11. package/src/components/badge/badge.vue +1 -0
  12. package/src/components/button/button.ts +1 -1
  13. package/src/components/button/button.vue +1 -9
  14. package/src/components/button/use-button.ts +27 -6
  15. package/src/components/{emptyState/emptyState.vue → empty-state/empty-state.vue} +3 -2
  16. package/src/components/{emptyState/use-emptyState.ts → empty-state/use-empty-state.ts} +1 -1
  17. package/src/components/input/input.vue +4 -2
  18. package/src/components/lozenge/lozenge.vue +5 -4
  19. package/src/components/lozenge/use-lozenge.ts +31 -7
  20. package/src/components/radio/radio.vue +3 -2
  21. package/src/components/sidenav/sidenav.vue +5 -5
  22. package/src/components/switch/switch.vue +6 -2
  23. package/src/components/tabs/tabs.vue +63 -26
  24. package/src/components/tabs/use-tabs.ts +41 -14
  25. package/src/components/timePicker/timePicker.vue +1 -1
  26. package/src/components/timePicker/use-timePicker.ts +1 -1
  27. /package/src/assets/scripts/{borderRadius.ts → border-radius.ts} +0 -0
  28. /package/src/assets/scripts/{maxWidth.ts → max-width.ts} +0 -0
  29. /package/src/components/{emptyState/emptyState.ts → empty-state/empty-state.ts} +0 -0
@@ -617,16 +617,16 @@
617
617
  </template>
618
618
 
619
619
  <script lang="ts" setup>
620
- import { sidenavPropTypes, sidenavEmitTypes } from './sidenav';
621
- import { useSidenav } from './use-sidenav';
622
-
623
620
  import { Menu, Tooltip } from 'floating-vue';
624
621
  import { Icon } from '@iconify/vue';
625
622
 
626
- import badge from '../badge/badge.vue';
627
-
628
623
  import 'floating-vue/dist/style.css';
629
624
 
625
+ import { sidenavPropTypes, sidenavEmitTypes } from './sidenav';
626
+ import { useSidenav } from './use-sidenav';
627
+
628
+ import badge from '../badge/badge.vue';
629
+
630
630
  const props = defineProps(sidenavPropTypes);
631
631
  const emit = defineEmits(sidenavEmitTypes);
632
632
 
@@ -7,7 +7,10 @@
7
7
  </label>
8
8
  <div
9
9
  ref="switchWrapperRef"
10
- :class="['relative flex items-center', 'transition duration-300 ease-in-out', 'active:scale-90']"
10
+ :class="{
11
+ 'relative flex items-center': true,
12
+ 'cursor-pointer transition duration-300 ease-in-out active:scale-90': !props.disabled,
13
+ }"
11
14
  >
12
15
  <input
13
16
  ref="switchRef"
@@ -28,9 +31,10 @@
28
31
  </template>
29
32
 
30
33
  <script lang="ts" setup>
34
+ import { useVModel } from '@vueuse/core';
35
+
31
36
  import { switchEmitTypes, switchPropTypes } from './switch';
32
37
  import { useSwitch } from './use-switch';
33
- import { useVModel } from '@vueuse/core';
34
38
 
35
39
  const props = defineProps(switchPropTypes);
36
40
  const emit = defineEmits(switchEmitTypes);
@@ -1,46 +1,52 @@
1
1
  <template>
2
- <div class="flex">
2
+ <div class="relative flex">
3
3
  <div
4
4
  v-for="(tab, index) in list"
5
5
  :key="index"
6
+ ref="tabElements"
6
7
  :class="[
7
8
  tabsClasses,
8
- 'body-sm-regular text-color-strong cursor-pointer border-solid',
9
9
  {
10
- // Active tab without underline
11
- 'background-color-single-active border': !underlined && selectedTabIndex === index,
10
+ // Regular Tab
11
+ 'rounded-l-md': !underlined && index === 0,
12
+ 'rounded-r-md': !underlined && index === tabElements.length - 1,
12
13
 
13
- // Inactive tab without underline
14
- 'border-color-weak hover:background-color-hover border-x-[0.5px] border-y':
15
- !underlined && selectedTabIndex !== index,
14
+ // Regular Tab - Active
15
+ 'text-color-brand-base border-color-success-base cursor-pointer border border-solid':
16
+ !underlined && activeTab.index === index,
16
17
 
17
- // Underlined tab that is not selected
18
- 'border-color-base border-b': underlined && selectedTabIndex !== index,
18
+ // Regular Tab - Inactive
19
+ 'border-color-weak hover:background-color-hover cursor-pointer border-x-[0.5px] border-y border-solid':
20
+ !underlined && activeTab.index !== index,
19
21
 
20
- // Underlined and selected tab
21
- 'border-b-2': underlined && selectedTabIndex === index,
22
+ // Regular Tab - Disabled
23
+ 'background-color-base !cursor-not-allowed': !underlined && tab.disabled,
22
24
 
23
- // Disabled tab with underline
24
- 'border-color-disabled text-color-disabled !cursor-not-allowed border-b': underlined && tab.disabled,
25
-
26
- // Regular text for non-selected tabs
27
- 'body-sm-regular': selectedTabIndex !== index,
25
+ // Underlined Tab - Active
26
+ 'text-color-brand-base cursor-pointer': underlined && activeTab.index === index,
28
27
 
29
- // Active tab with custom text and border styles
30
- 'body-sm-regular text-color-brand-base border-color-success-base': selectedTabIndex === index,
28
+ // Underlined Tab - Inactive
29
+ 'border-color-base cursor-pointer border-b border-solid': underlined && activeTab.index !== index,
30
+ 'hover:background-color-hover cursor-pointer': underlined && activeTab.index !== index && !tab.disabled,
31
31
 
32
- // Border adjustments for previous and next tab
33
- 'border-l-0': selectedTabIndex - index === -1,
34
- 'border-r-0': selectedTabIndex - index === 1,
32
+ // Underlined Tab - Disabled
33
+ 'border-color-disabled text-color-disabled !cursor-not-allowed border-b': underlined && tab.disabled,
35
34
  },
36
35
  ]"
37
36
  @click="updateSelectedTabIndex(index, tab.disabled)"
38
37
  >
39
- <div class="flex items-center gap-size-spacing-5xs leading-none">
38
+ <div
39
+ :class="{
40
+ 'flex items-center gap-size-spacing-5xs leading-none': true,
41
+ 'transition duration-150 ease-in-out': true,
42
+ 'cursor-pointer group-active:scale-75': !tab.disabled,
43
+ 'cursor-not-allowed': tab.disabled,
44
+ }"
45
+ >
40
46
  <div v-if="!!tab.icon">
41
47
  <Icon
42
- :icon="selectedTabIndex === index && !!tab.iconFill ? tab.iconFill : tab.icon"
43
48
  class="body-sm-regular"
49
+ :icon="activeTab.index === index && typeof tab.iconFill === 'string' ? tab.iconFill : tab.icon"
44
50
  />
45
51
  </div>
46
52
  <div v-if="!!tab.label">
@@ -48,17 +54,48 @@
48
54
  </div>
49
55
  </div>
50
56
  </div>
57
+
58
+ <!-- Regular Tab Background Active Indicator -->
59
+ <div
60
+ v-if="!underlined"
61
+ :class="[
62
+ 'background-color-single-active absolute bottom-0 left-0 z-[5] block',
63
+ 'transition-left duration-150 ease-in-out',
64
+ {
65
+ 'rounded-l-md': activeTab.index === 0,
66
+ 'rounded-r-md': activeTab.index === tabElements.length - 1,
67
+ },
68
+ ]"
69
+ :style="{
70
+ height: `${activeTab.height}px`,
71
+ width: `${activeTab.width}px`,
72
+ left: `${activeTab.undelineLeftOffset}px`,
73
+ }"
74
+ />
75
+
76
+ <!-- Underlined Tab Active Indicator -->
77
+ <div
78
+ v-if="underlined"
79
+ :class="[
80
+ 'background-color-success-base absolute bottom-0 left-0 z-10 block h-0.5 rounded-full',
81
+ 'transition-left duration-150 ease-in-out',
82
+ ]"
83
+ :style="{
84
+ width: `${activeTab.width}px`,
85
+ left: `calc(${activeTab.undelineLeftOffset}px - 2.3px)`,
86
+ }"
87
+ />
51
88
  </div>
52
89
  </template>
53
90
 
54
91
  <script lang="ts" setup>
92
+ import { Icon } from '@iconify/vue';
93
+
55
94
  import { tabsPropTypes, tabsEmitTypes } from './tabs';
56
95
  import { useTabs } from './use-tabs';
57
96
 
58
- import { Icon } from '@iconify/vue';
59
-
60
97
  const emit = defineEmits(tabsEmitTypes);
61
98
  const props = defineProps(tabsPropTypes);
62
99
 
63
- const { updateSelectedTabIndex, selectedTabIndex, tabsClasses } = useTabs(props, emit);
100
+ const { tabsClasses, activeTab, tabElements, updateSelectedTabIndex } = useTabs(props, emit);
64
101
  </script>
@@ -1,33 +1,60 @@
1
- import { ref, computed, SetupContext } from 'vue';
1
+ import { ref, computed, onMounted, SetupContext } from 'vue';
2
2
  import type { TabsPropTypes, TabsEmitTypes } from './tabs';
3
3
 
4
4
  import classNames from 'classnames';
5
5
 
6
6
  export const useTabs = (props: TabsPropTypes, emit: SetupContext<TabsEmitTypes>['emit']) => {
7
- const selectedTabIndex = ref(0);
8
- const { underlined } = props;
7
+ const tabsClasses = computed(() => {
8
+ return classNames({
9
+ 'relative z-[10] px-size-spacing-xs py-size-spacing-3xs body-sm text-color-strong group': true,
10
+ 'transition-left duration-150 ease-in-out': true,
11
+ capitalize: !props.underlined,
12
+ 'uppercase border-x-0 border-t-0': props.underlined,
13
+ });
14
+ });
15
+
16
+ const activeTab = ref({
17
+ index: 0,
18
+ previousIndex: -1,
19
+ height: 0,
20
+ width: 0,
21
+ undelineLeftOffset: 0,
22
+ });
23
+
24
+ const tabElements = ref<HTMLElement[]>([]);
9
25
 
10
- function updateSelectedTabIndex(index: number, disabled = false) {
26
+ const updateSelectedTabIndex = (index: number, disabled = false) => {
11
27
  if (disabled) return;
12
28
 
13
- if (selectedTabIndex.value === index) return;
29
+ activeTab.value.previousIndex = activeTab.value.index;
14
30
 
15
- selectedTabIndex.value = index;
31
+ if (activeTab.value.index === index) return;
32
+
33
+ activeTab.value.index = index;
34
+
35
+ // Update underline left offset based on previous index
36
+ const indexDifference = Math.abs(activeTab.value.index - activeTab.value.previousIndex);
37
+
38
+ if (activeTab.value.index > activeTab.value.previousIndex) {
39
+ // Moving right: increase the offset by the width of each tab
40
+ activeTab.value.undelineLeftOffset += indexDifference * activeTab.value.width;
41
+ } else {
42
+ // Moving left: decrease the offset by the width of each tab
43
+ activeTab.value.undelineLeftOffset -= indexDifference * activeTab.value.width;
44
+ }
16
45
 
17
46
  emit('tabIndex', index);
18
- }
47
+ };
19
48
 
20
- const tabsClasses = computed(() => {
21
- return classNames({
22
- 'px-size-spacing-xs py-size-spacing-3xs capitalize text-color-strong first:rounded-l-md first:border-l last:border-r last:rounded-r-md':
23
- !underlined,
24
- 'p-size-spacing-xs uppercase border-x-0 border-t-0': underlined,
25
- });
49
+ onMounted(() => {
50
+ activeTab.value.height = tabElements.value[activeTab.value.index].offsetHeight;
51
+ activeTab.value.width = tabElements.value[activeTab.value.index].offsetWidth;
26
52
  });
27
53
 
28
54
  return {
29
55
  tabsClasses,
30
- selectedTabIndex,
56
+ activeTab,
57
+ tabElements,
31
58
  updateSelectedTabIndex,
32
59
  };
33
60
  };
@@ -20,7 +20,7 @@
20
20
  @focusout="isOpen = false"
21
21
  />
22
22
 
23
- <div :class="iconClasses">
23
+ <div :class="iconClasses" @click="handleClick">
24
24
  <Icon icon="ph:clock" />
25
25
  </div>
26
26
  </div>
@@ -43,7 +43,7 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
43
43
  const optionClasses: ComputedRef<string> = computed(() => {
44
44
  return classNames(
45
45
  'absolute',
46
- 'z-50 ',
46
+ 'z-30 ',
47
47
  'mt-1',
48
48
  'max-h-[300px]',
49
49
  'w-[240px]',