design-system-next 2.22.2 → 2.23.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.es.d.ts +114 -74
- package/dist/design-system-next.es.js +2669 -2519
- package/dist/design-system-next.es.js.gz +0 -0
- package/dist/design-system-next.umd.js +12 -12
- package/dist/design-system-next.umd.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/package.json +1 -1
- package/src/assets/styles/tailwind.css +4 -0
- package/src/components/input/input-contact-number/input-contact-number.ts +16 -0
- package/src/components/input/input-contact-number/input-contact-number.vue +8 -0
- package/src/components/radio/radio.ts +1 -1
- package/src/components/radio/radio.vue +5 -2
- package/src/components/radio-grouped/radio-grouped.ts +65 -0
- package/src/components/radio-grouped/radio-grouped.vue +37 -0
- package/src/components/radio-grouped/use-radio-grouped.ts +62 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="['spr-relative', { 'spr-w-full'
|
|
2
|
+
<div :class="['spr-relative', { 'spr-w-full': props.fullWidth }]">
|
|
3
3
|
<input
|
|
4
4
|
:id="props.id"
|
|
5
5
|
ref="radioRef"
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
<slot />
|
|
22
22
|
<span
|
|
23
23
|
v-if="props.description && props.description !== ''"
|
|
24
|
-
:class="[
|
|
24
|
+
:class="[
|
|
25
|
+
'spr-text-xs spr-font-normal spr-leading-4 spr-text-mushroom-600',
|
|
26
|
+
{ 'spr-text-color-disabled': props.disabled },
|
|
27
|
+
]"
|
|
25
28
|
>{{ props.description }}</span
|
|
26
29
|
>
|
|
27
30
|
</div>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
|
|
4
|
+
|
|
5
|
+
export interface RadioOption {
|
|
6
|
+
text: string;
|
|
7
|
+
value: string | number | boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const radioGroupedPropTypes = {
|
|
12
|
+
id: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
modelValue: {
|
|
17
|
+
type: [String, Number, Boolean],
|
|
18
|
+
},
|
|
19
|
+
name: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
options: {
|
|
24
|
+
type: Array as PropType<RadioOption[]>,
|
|
25
|
+
required: true,
|
|
26
|
+
default: () => [],
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false,
|
|
31
|
+
},
|
|
32
|
+
description: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
bordered: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
displayHelper: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
43
|
+
helperIcon: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: null,
|
|
46
|
+
},
|
|
47
|
+
helperText: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: '',
|
|
50
|
+
},
|
|
51
|
+
error: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false,
|
|
54
|
+
},
|
|
55
|
+
horizontalAlign: {
|
|
56
|
+
type: String as PropType<'left' | 'center' | 'right'>,
|
|
57
|
+
default: 'left',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const radioGroupedEmitTypes = ['update:modelValue'];
|
|
62
|
+
|
|
63
|
+
export type RadioGroupedPropTypes = ExtractPropTypes<typeof radioGroupedPropTypes>;
|
|
64
|
+
|
|
65
|
+
export type RadioGroupedEmitTypes = typeof radioGroupedEmitTypes;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['spr-relative']">
|
|
3
|
+
<div :class="radioGroupedClasses.containerClasses">
|
|
4
|
+
<spr-radio
|
|
5
|
+
v-for="(option, index) in renderOptions()"
|
|
6
|
+
:id="`${props.id}-${index}`"
|
|
7
|
+
:key="`${props.id}-option-${index}`"
|
|
8
|
+
v-model="proxyValue"
|
|
9
|
+
:name="props.name"
|
|
10
|
+
:value="option.value"
|
|
11
|
+
:disabled="isOptionDisabled(option)"
|
|
12
|
+
>
|
|
13
|
+
{{ option.text }}
|
|
14
|
+
</spr-radio>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div v-if="props.displayHelper" :class="radioGroupedClasses.helperClasses">
|
|
18
|
+
<slot name="helperMessage">
|
|
19
|
+
<Icon v-if="props.helperIcon" class="spr-h-5 spr-min-h-5 spr-w-5 spr-min-w-5" :icon="props.helperIcon" />
|
|
20
|
+
<span>{{ props.helperText }}</span>
|
|
21
|
+
</slot>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { Icon } from '@iconify/vue';
|
|
28
|
+
import SprRadio from '@/components/radio/radio.vue';
|
|
29
|
+
|
|
30
|
+
import { radioGroupedPropTypes, radioGroupedEmitTypes } from './radio-grouped';
|
|
31
|
+
import { useRadioGrouped } from './use-radio-grouped';
|
|
32
|
+
|
|
33
|
+
const props = defineProps(radioGroupedPropTypes);
|
|
34
|
+
const emit = defineEmits(radioGroupedEmitTypes);
|
|
35
|
+
|
|
36
|
+
const { radioGroupedClasses, proxyValue, renderOptions, isOptionDisabled } = useRadioGrouped(props, emit);
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { toRefs, computed, ComputedRef } from 'vue';
|
|
2
|
+
import { useVModel } from '@vueuse/core';
|
|
3
|
+
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
|
|
6
|
+
import type { SetupContext } from 'vue';
|
|
7
|
+
import type { RadioGroupedPropTypes, RadioGroupedEmitTypes, RadioOption } from './radio-grouped';
|
|
8
|
+
|
|
9
|
+
interface RadioGroupedClasses {
|
|
10
|
+
containerClasses: string;
|
|
11
|
+
helperClasses: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useRadioGrouped = (props: RadioGroupedPropTypes, emit: SetupContext<RadioGroupedEmitTypes>['emit']) => {
|
|
15
|
+
const { disabled, horizontalAlign, displayHelper, error } = toRefs(props);
|
|
16
|
+
|
|
17
|
+
const radioGroupedClasses: ComputedRef<RadioGroupedClasses> = computed(() => {
|
|
18
|
+
const alignmentMap = {
|
|
19
|
+
left: 'spr-justify-start',
|
|
20
|
+
center: 'spr-justify-center',
|
|
21
|
+
right: 'spr-justify-end',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const containerClasses = classNames('spr-flex spr-flex-col spr-gap-2', {
|
|
25
|
+
[alignmentMap[horizontalAlign.value as keyof typeof alignmentMap]]: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const helperClasses = classNames(
|
|
29
|
+
'spr-flex spr-items-center spr-gap-1 spr-mt-size-spacing-2xs spr-body-sm-regular',
|
|
30
|
+
{
|
|
31
|
+
'spr-text-mushroom-600': !error.value,
|
|
32
|
+
'spr-text-color-danger-base': error.value,
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
containerClasses,
|
|
38
|
+
helperClasses,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const proxyValue = useVModel(props, 'modelValue', emit);
|
|
43
|
+
|
|
44
|
+
const renderOptions = (): RadioOption[] => {
|
|
45
|
+
return props.options || [];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const isOptionDisabled = (option: RadioOption): boolean => {
|
|
49
|
+
return disabled.value || (option.disabled ?? false);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
radioGroupedClasses,
|
|
54
|
+
proxyValue,
|
|
55
|
+
renderOptions,
|
|
56
|
+
isOptionDisabled,
|
|
57
|
+
disabled,
|
|
58
|
+
displayHelper,
|
|
59
|
+
horizontalAlign,
|
|
60
|
+
error,
|
|
61
|
+
};
|
|
62
|
+
};
|