design-system-next 2.3.1 → 2.5.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.
- package/dist/design-system-next.js +4982 -4702
- package/dist/design-system-next.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/package.json +1 -1
- package/src/components/accordion/accordion.ts +39 -0
- package/src/components/accordion/accordion.vue +54 -0
- package/src/components/accordion/use-accordion.ts +31 -0
- package/src/components/snackbar/snack/snack.vue +1 -1
- package/src/components/snackbar/snackbar.vue +2 -2
- package/src/components/stepper/step/step.ts +39 -0
- package/src/components/stepper/step/step.vue +30 -0
- package/src/components/stepper/step/use-step.ts +70 -0
- package/src/components/stepper/stepper.ts +38 -0
- package/src/components/stepper/stepper.vue +33 -0
- package/src/components/stepper/use-stepper.ts +52 -0
- package/src/components/table/table.vue +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import type { SetupContext } from 'vue';
|
|
3
|
+
import { computed, ComputedRef } from 'vue';
|
|
4
|
+
import type { StepEmitTypes, StepPropTypes } from './step';
|
|
5
|
+
|
|
6
|
+
interface StepClasses {
|
|
7
|
+
baseClass: string;
|
|
8
|
+
badgeClass: string;
|
|
9
|
+
numberClass: string;
|
|
10
|
+
textContainerClass: string;
|
|
11
|
+
labelClass: string;
|
|
12
|
+
descriptionClass: string;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const useStep = (props: StepPropTypes, emit: SetupContext<StepEmitTypes>['emit']) => {
|
|
17
|
+
|
|
18
|
+
const stepClasses: ComputedRef<StepClasses> = computed(() => {
|
|
19
|
+
const baseClass = classNames('spr-flex spr-gap-2 spr-items-center');
|
|
20
|
+
|
|
21
|
+
// Usage of prop.status ensures reactivity instead of destructuring props
|
|
22
|
+
const badgeClass = classNames(
|
|
23
|
+
'spr-flex spr-items-center spr-justify-center spr-rounded-border-radius-full spr-h-6 spr-w-6 spr-border spr-border-solid spr-border-2',
|
|
24
|
+
{
|
|
25
|
+
'spr-bg-kangkong-700 spr-border-kangkong-700': props.status === 'active',
|
|
26
|
+
'spr-border-mushroom-300': props.status === 'pending',
|
|
27
|
+
'spr-border-kangkong-700': props.status === 'completed',
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const numberClass = classNames('spr-text-sm spr-font-medium',
|
|
32
|
+
{
|
|
33
|
+
'spr-text-white-50': props.status === 'active',
|
|
34
|
+
'spr-text-mushroom-600': props.status === 'pending',
|
|
35
|
+
'spr-text-kangkong-700': props.status === 'completed',
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const textContainerClass = classNames('spr-flex spr-flex-col spr-relative');
|
|
40
|
+
|
|
41
|
+
const labelClass = classNames('spr-text-sm spr-whitespace-nowrap',
|
|
42
|
+
{
|
|
43
|
+
'spr-text-kangkong-700 spr-font-semibold': props.status === 'active',
|
|
44
|
+
'spr-text-mushroom-600': props.status === 'pending',
|
|
45
|
+
'spr-text-mushroom-950': props.status === 'completed',
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Absolute since the sample in the figma is a hanging text for description
|
|
50
|
+
const descriptionClass = classNames('spr-text-xs spr-text-mushroom-400 spr-absolute spr-mt-size-spacing-sm spr-whitespace-nowrap');
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
baseClass,
|
|
54
|
+
badgeClass,
|
|
55
|
+
numberClass,
|
|
56
|
+
labelClass,
|
|
57
|
+
textContainerClass,
|
|
58
|
+
descriptionClass,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const handleClick = (evt: MouseEvent) => {
|
|
63
|
+
emit('click', evt);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
stepClasses,
|
|
68
|
+
handleClick,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { StepPropTypes } from '@/components/stepper/step/step';
|
|
2
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
3
|
+
|
|
4
|
+
export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
|
|
5
|
+
const STEPPER_VARIANTS = ['horizontal', 'vertical'] as const;
|
|
6
|
+
export const STEPPER_STATES = ['pending', 'active', 'completed'] as const;
|
|
7
|
+
|
|
8
|
+
export const stepperPropTypes = {
|
|
9
|
+
/**
|
|
10
|
+
* @description Variant of the stepper
|
|
11
|
+
*/
|
|
12
|
+
variant: {
|
|
13
|
+
type: String as PropType<(typeof STEPPER_VARIANTS)[number]>,
|
|
14
|
+
validator: (value: (typeof STEPPER_VARIANTS)[number]) => STEPPER_VARIANTS.includes(value),
|
|
15
|
+
default: 'vertical',
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* @description steps of the stepper
|
|
19
|
+
* @type {Array<Step>}
|
|
20
|
+
* @property {number} number - Step number
|
|
21
|
+
* @property {string} label - Text label shown in step
|
|
22
|
+
* @property {string} status - Step state either as 'pending', 'active', 'completed'
|
|
23
|
+
* @property {string} description - Description shown in step
|
|
24
|
+
*/
|
|
25
|
+
steps: {
|
|
26
|
+
type: Array as PropType<StepPropTypes[]>,
|
|
27
|
+
default: () => [],
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* @description has lines between steps
|
|
31
|
+
*/
|
|
32
|
+
hasLines: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false,
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type StepperPropTypes = ExtractPropTypes<typeof stepperPropTypes>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="stepperClasses.baseClass">
|
|
3
|
+
<div v-for="(step, index) in props.steps" :key="index" :class="stepperClasses.stepClass">
|
|
4
|
+
<!-- STEP NUMBER -->
|
|
5
|
+
<spr-step
|
|
6
|
+
:number="step.number"
|
|
7
|
+
:label="step.label"
|
|
8
|
+
:status="step.status"
|
|
9
|
+
:description="step.description"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<!-- LINES -->
|
|
13
|
+
<!-- Line container -->
|
|
14
|
+
<div
|
|
15
|
+
v-if="props.hasLines && index < props.steps.length - 1"
|
|
16
|
+
:class="stepperClasses.lineContainerClass"
|
|
17
|
+
>
|
|
18
|
+
<!-- Actual line -->
|
|
19
|
+
<div :class="[stepperClasses.linesClass, getLineColorClass(step)]"/>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import SprStep from '@/components/stepper/step/step.vue';
|
|
27
|
+
import { stepperPropTypes } from '@/components/stepper/stepper';
|
|
28
|
+
import { useStepper } from '@/components/stepper/use-stepper';
|
|
29
|
+
|
|
30
|
+
const props = defineProps(stepperPropTypes);
|
|
31
|
+
|
|
32
|
+
const { stepperClasses, getLineColorClass} = useStepper(props);
|
|
33
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { StepPropTypes } from '@/components/stepper/step/step';
|
|
2
|
+
import type { StepperPropTypes } from '@/components/stepper/stepper';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { computed, ComputedRef } from 'vue';
|
|
5
|
+
|
|
6
|
+
interface StepperClasses {
|
|
7
|
+
baseClass: string;
|
|
8
|
+
stepClass: string;
|
|
9
|
+
lineContainerClass: string;
|
|
10
|
+
linesClass: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useStepper = (props: StepperPropTypes) => {
|
|
14
|
+
const stepperClasses: ComputedRef<StepperClasses> = computed(() => {
|
|
15
|
+
const baseClass = classNames('spr-flex spr-gap-size-spacing-xs ', {
|
|
16
|
+
'spr-flex-col spr-mb-size-spacing-xs': props.variant === 'vertical',
|
|
17
|
+
'spr-flex-row spr-mr-size-spacing-xs': props.variant === 'horizontal',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const stepClass = classNames('spr-flex spr-flex-grow', {
|
|
21
|
+
'spr-flex-col': props.variant === 'vertical',
|
|
22
|
+
'spr-flex-rows': props.variant === 'horizontal',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const lineContainerClass = classNames('spr-flex spr-min-w-6 spr-min-h-6', {
|
|
26
|
+
'spr-ml-3.5 spr-pt-size-spacing-2xs': props.variant === 'vertical',
|
|
27
|
+
'spr-items-center spr-pl-size-spacing-xs spr-w-full': props.variant === 'horizontal',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const linesClass = classNames({
|
|
31
|
+
'spr-w-0.5 spr-rounded-full spr-h-12': props.variant === 'vertical',
|
|
32
|
+
'spr-h-0.5 spr-rounded-full spr-w-full': props.variant === 'horizontal',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
baseClass,
|
|
38
|
+
stepClass,
|
|
39
|
+
lineContainerClass,
|
|
40
|
+
linesClass,
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const getLineColorClass = (step: StepPropTypes) => {
|
|
45
|
+
return step.status === 'completed' ? 'spr-bg-kangkong-700' : 'spr-bg-mushroom-200';
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
stepperClasses,
|
|
50
|
+
getLineColorClass,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
>
|
|
64
64
|
<td v-if="props.isMultiSelect" :class="[getTableClasses.multiselectClass, getTableClasses.multiselectRowClass]">
|
|
65
65
|
<div class="spr-flex spr-justify-center spr-items-center">
|
|
66
|
-
<spr-checkbox label="" :checked="isRowSelected(item)" @update:
|
|
66
|
+
<spr-checkbox label="" :checked="isRowSelected(item)" @update:model-value="handleSelect(item)"/>
|
|
67
67
|
</div>
|
|
68
68
|
</td>
|
|
69
69
|
<td v-for="(column, headerKey) in headers" :key="headerKey" :class="getTableClasses.tableDataClasses">
|