design-system-next 1.7.2 → 1.8.2

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.
@@ -0,0 +1,39 @@
1
+ import { PropType, ExtractPropTypes } from 'vue';
2
+
3
+ const PROGRESS_BAR_SIZES = ['xs', 'sm', 'lg'] as const;
4
+
5
+ export const progressBarPropTypes = {
6
+ size: {
7
+ type: String as PropType<(typeof PROGRESS_BAR_SIZES)[number]>,
8
+ validator: (value: (typeof PROGRESS_BAR_SIZES)[number]) => PROGRESS_BAR_SIZES.includes(value),
9
+ default: 'lg',
10
+ },
11
+ label: {
12
+ type: Boolean,
13
+ default: true,
14
+ },
15
+ value: {
16
+ type: Number,
17
+ default: 0,
18
+ validator(value: number, props: { max: number }) {
19
+ if (value < 0 || value > props.max) {
20
+ console.error(`Invalid prop: "value" (${value}) must be between 0 and ${props.max}.`);
21
+ return false;
22
+ }
23
+ return true;
24
+ },
25
+ },
26
+ max: {
27
+ type: Number,
28
+ default: 100,
29
+ validator(value: number) {
30
+ if (value <= 0 || value > 100) {
31
+ console.error('Invalid prop: "max" must be between 1 and 100.');
32
+ return false;
33
+ }
34
+ return true;
35
+ },
36
+ },
37
+ };
38
+
39
+ export type ProgressBarPropTypes = ExtractPropTypes<typeof progressBarPropTypes>;
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <div
3
+ class="spr-flex spr-w-full spr-flex-col spr-gap-size-spacing-5xs"
4
+ :aria-valuemin="0"
5
+ :aria-valuemax="props.max || 100"
6
+ role="progressbar"
7
+ >
8
+ <div :class="[handleProgressBarSize, 'spr-overflow-hidden spr-rounded-lg spr-bg-white-100']">
9
+ <div
10
+ class="spr-background-color-success-base spr-transition-all spr-duration-300"
11
+ :style="handleProgressBarStyle"
12
+ ></div>
13
+ </div>
14
+ <span
15
+ v-if="props.label"
16
+ class="spr-text-color-base spr-font-weight-regular spr-font-size-100 spr-line-height-100 spr-font-main"
17
+ >{{ percentage }}%</span
18
+ >
19
+ </div>
20
+ </template>
21
+
22
+ <script lang="ts" setup>
23
+ import { progressBarPropTypes } from './progress-bar';
24
+ import { useProgressBar } from './use-progress-bar';
25
+
26
+ const props = defineProps(progressBarPropTypes);
27
+
28
+ const { handleProgressBarSize, percentage, handleProgressBarStyle } = useProgressBar(props);
29
+ </script>
@@ -0,0 +1,31 @@
1
+ import { computed } from 'vue';
2
+ import type { ProgressBarPropTypes } from './progress-bar';
3
+
4
+ export const useProgressBar = (props: ProgressBarPropTypes) => {
5
+ const handleProgressBarSize = computed<string>(() => {
6
+ switch (props.size) {
7
+ case 'xs':
8
+ return 'spr-h-1';
9
+ case 'sm':
10
+ return 'spr-h-2';
11
+ case 'lg':
12
+ return 'spr-h-3';
13
+ default:
14
+ return 'spr-h-3';
15
+ }
16
+ });
17
+ const percentage = computed<number>(() => Math.min((props.value / (props.max || 100)) * 100, 100));
18
+
19
+ const handleProgressBarStyle = computed<{ width: string; height: string }>(() => {
20
+ return {
21
+ width: percentage.value + '%',
22
+ height: '100%',
23
+ };
24
+ });
25
+
26
+ return {
27
+ handleProgressBarSize,
28
+ percentage,
29
+ handleProgressBarStyle,
30
+ };
31
+ };
@@ -3,8 +3,8 @@
3
3
  ref="sliderRef"
4
4
  :class="[
5
5
  handleSliderSize,
6
- 'spr-relative spr-w-full spr-cursor-pointer spr-rounded-lg spr-bg-white-100',
7
- { 'spr-pointer-events-none spr-opacity-50': props.disabled },
6
+ 'spr-relative spr-w-full spr-rounded-lg spr-bg-white-100',
7
+ props.disabled ? 'spr-cursor-not-allowed spr-opacity-50' : 'spr-cursor-pointer',
8
8
  ]"
9
9
  role="slider"
10
10
  :aria-valuenow="props.modelValue"
@@ -18,6 +18,7 @@
18
18
  :class="[
19
19
  handleSliderSize,
20
20
  'spr-absolute spr-left-0 spr-top-1/2 spr--translate-y-1/2 spr-rounded-lg spr-bg-kangkong-600',
21
+ { 'spr-cursor-not-allowed': props.disabled },
21
22
  ]"
22
23
  :style="handleSliderStyle"
23
24
  ></div>
@@ -26,8 +27,8 @@
26
27
  icon="ph:circle-fill"
27
28
  :class="[
28
29
  handleSliderThumbSize,
29
- 'spr-absolute spr-top-1/2 spr--translate-x-1/2 spr--translate-y-1/2 spr-transform spr-rounded-full spr-text-kangkong-600 hover:spr-text-kangkong-700 active:spr-text-kangkong-800 active:spr-border-2 active:spr-border-solid',
30
- { 'spr-pointer-events-none': props.disabled },
30
+ 'spr-absolute spr-top-1/2 spr--translate-x-1/2 spr--translate-y-1/2 spr-transform spr-rounded-full spr-text-kangkong-600 hover:spr-text-kangkong-700 active:spr-border-2 active:spr-border-solid active:spr-text-kangkong-800',
31
+ { 'spr-pointer-events-none spr-cursor-not-allowed': props.disabled },
31
32
  ]"
32
33
  :style="handleThumbStyle"
33
34
  @pointerdown="startDrag"
@@ -35,7 +36,7 @@
35
36
  </div>
36
37
  </template>
37
38
 
38
- <script setup>
39
+ <script setup lang="ts">
39
40
  import { useSlider } from './use-slider';
40
41
  import { sliderPropTypes } from './slider';
41
42
  import { Icon } from '@iconify/vue';
@@ -1,27 +1,27 @@
1
1
  <template>
2
- <div :class="tablePaginationBaseClass">
2
+ <div :class="paginationClasses.baseClass">
3
3
  <spr-dropdown
4
4
  :menu="dropdownSelection"
5
5
  dropdown-type="single-select"
6
6
  placement="bottom"
7
7
  @get-selected-item="handleSelectedItem"
8
8
  >
9
- <spr-input :class="dropdownInputFieldClass" v-model="computeSelectedRowCount" :readonly="true">
9
+ <spr-input v-model="computeSelectedRowCount" :class="paginationClasses.dropdownInputFieldClass" :readonly="true">
10
10
  <template #icon>
11
- <Icon icon="ph:caret-down" />
11
+ <Icon icon="ph:caret-down-bold" :class="paginationClasses.inputFieldIconClass"/>
12
12
  </template>
13
13
  </spr-input>
14
14
  </spr-dropdown>
15
15
 
16
- <div :class="paginationRightSideClass">
17
- <div :class="computeRowRangeClass">
16
+ <div :class="paginationClasses.rightSideClass">
17
+ <div :class="paginationClasses.computeRowRangeClass">
18
18
  {{ computeRowRange }}
19
19
  </div>
20
- <div :class="navigationContainerClass">
21
- <spr-button hasIcon :class="navigationButtonClasses" @click="previous" :disabled="disabledNext">
20
+ <div :class="paginationClasses.navigationContainerClass">
21
+ <spr-button has-icon :class="paginationClasses.navigationButtonClass" :disabled="disabledNext" @click="previous" >
22
22
  <Icon icon="ph:caret-left"/>
23
23
  </spr-button>
24
- <spr-button hasIcon :class="navigationButtonClasses" @click="next" :disabled="disabledPrevious">
24
+ <spr-button has-icon :class="paginationClasses.navigationButtonClass" :disabled="disabledPrevious" @click="next" >
25
25
  <Icon icon="ph:caret-right"/>
26
26
  </spr-button>
27
27
  </div>
@@ -42,15 +42,10 @@ const emit = defineEmits(tablePaginationEmitTypes);
42
42
  const props = defineProps(tablePaginationPropTypes);
43
43
 
44
44
  const {
45
- tablePaginationBaseClass,
46
- dropdownInputFieldClass,
47
- paginationRightSideClass,
48
- computeRowRangeClass,
49
- navigationContainerClass,
45
+ paginationClasses,
50
46
  handleSelectedItem,
51
47
  computeRowRange,
52
48
  computeSelectedRowCount,
53
- navigationButtonClasses,
54
49
  next,
55
50
  previous,
56
51
  disabledNext,
@@ -1,19 +1,42 @@
1
1
  import { computed, ref, toRefs } from 'vue';
2
- import type { SetupContext } from 'vue';
2
+ import type { ComputedRef, SetupContext } from 'vue';
3
3
 
4
4
  import type { TablePaginationPropTypes, TablePaginationEmitTypes } from '@/components/table/table-pagination/table-pagination';
5
5
  import type { DropdownMenuType } from '@/components/dropdown/dropdown';
6
6
 
7
- export const useTablePagination = (props: TablePaginationPropTypes, emit:SetupContext<TablePaginationEmitTypes>['emit'] ) => {
7
+ interface TablePaginationClasses {
8
+ baseClass: string;
9
+ dropdownInputFieldClass: string;
10
+ rightSideClass: string;
11
+ computeRowRangeClass: string;
12
+ navigationContainerClass: string;
13
+ inputFieldIconClass: string;
14
+ navigationButtonClass: string;
15
+ }
16
+
17
+ export const useTablePagination = (props: TablePaginationPropTypes, emit: SetupContext<TablePaginationEmitTypes>['emit']) => {
8
18
  const { selectedRowCount, currentPage, totalItems } = toRefs(props);
9
19
 
10
- const tablePaginationBaseClass = 'spr-p-size-spacing-xs spr-flex spr-justify-between spr-bg-white-50 spr-h-max' as const
11
- const dropdownInputFieldClass = 'spr-w-[110px]' as const
12
- const paginationRightSideClass = 'spr-flex spr-justify-between spr-items-center spr-space-x-4' as const
13
- const computeRowRangeClass = 'spr-font-main spr-text-color-base' as const
20
+ const paginationClasses: ComputedRef<TablePaginationClasses> = computed(() => {
21
+ const baseClass = 'spr-p-size-spacing-xs spr-flex spr-justify-between spr-bg-white-50 spr-h-max' as const;
22
+ const dropdownInputFieldClass = 'spr-w-[100px] spr-font-bold spr-h-full spr-space-x-2' as const;
23
+ const inputFieldIconClass = 'spr-mt-0.5 spr-pl-1 spr-text-mushroom-950' as const;
24
+ const rightSideClass = 'spr-flex spr-justify-between spr-items-center spr-space-x-4' as const;
25
+ const computeRowRangeClass = 'spr-font-main spr-text-color-base' as const;
26
+ const navigationContainerClass = 'spr-flex spr-space-x-2' as const;
27
+ const navigationButtonClass = 'spr-rounded-border-radius-md' as const;
28
+ return {
29
+ baseClass,
30
+ dropdownInputFieldClass,
31
+ rightSideClass,
32
+ computeRowRangeClass,
33
+ inputFieldIconClass,
34
+ navigationContainerClass,
35
+ navigationButtonClass
36
+ };
37
+ });
38
+
14
39
  const dropdownSelection = ref(props.dropdownSelection);
15
- const navigationContainerClass = 'spr-flex spr-space-x-2' as const
16
- const navigationButtonClasses = 'spr-rounded-border-radius-md' as const
17
40
  const computeRowRange = computed(() => {
18
41
  const startRow = (currentPage.value - 1) * selectedRowCount.value + 1;
19
42
  const endRow = Math.min(currentPage.value * selectedRowCount.value, totalItems.value);
@@ -45,15 +68,10 @@ export const useTablePagination = (props: TablePaginationPropTypes, emit:SetupCo
45
68
  })
46
69
 
47
70
  return {
48
- tablePaginationBaseClass,
49
- dropdownInputFieldClass,
50
- paginationRightSideClass,
51
- computeRowRangeClass,
52
- navigationContainerClass,
71
+ paginationClasses,
53
72
  handleSelectedItem,
54
73
  computeRowRange,
55
74
  computeSelectedRowCount,
56
- navigationButtonClasses,
57
75
  next,
58
76
  previous,
59
77
  disabledNext,
@@ -20,7 +20,7 @@
20
20
  </spr-table-actions>
21
21
  </div>
22
22
 
23
- <div class="spr-h-[400px]">
23
+ <div class="spr-max-h-85vh">
24
24
  <table aria-describedby="describe" class="spr-w-full spr-table-fixed" cellspacing="0" cellpadding="0">
25
25
  <thead>
26
26
  <tr>
@@ -145,7 +145,7 @@
145
145
  </tbody>
146
146
  </table>
147
147
  </div>
148
- <div v-if="$slots.footer" class="spr-w-full spr-border spr-border-solid spr-border-color-weak spr-mt-10" >
148
+ <div v-if="$slots.footer" class="spr-w-full spr-border spr-border-solid spr-border-color-weak" >
149
149
  <slot name="footer"/>
150
150
  </div>
151
151
  </div>