design-system-next 2.26.1 → 2.26.3
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 +252 -134
- package/dist/design-system-next.es.js +4794 -4724
- 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/components/input/input-contact-number/input-contact-number.vue +5 -7
- package/src/components/input/input-currency/input-currency.ts +11 -15
- package/src/components/input/input-currency/input-currency.vue +4 -0
- package/src/components/input/input-currency/use-input-currency.ts +76 -107
- package/src/components/input/input-dropdown/input-dropdown.vue +4 -0
- package/src/components/input/input-search/input-search.vue +4 -0
- package/src/components/input/input.ts +1 -0
- package/src/components/input/input.vue +2 -1
- package/src/components/input/use-input.ts +5 -0
- package/src/components/list/list-item/list-item.ts +60 -60
- package/src/components/list/use-list.ts +6 -6
- package/src/components/{radio-grouped → radio/radio-grouped}/radio-grouped.ts +74 -65
- package/src/components/{radio-grouped → radio/radio-grouped}/radio-grouped.vue +4 -1
- package/src/components/{radio-grouped → radio/radio-grouped}/use-radio-grouped.ts +63 -62
- package/src/components/radio/radio.ts +4 -0
- package/src/components/radio/radio.vue +10 -4
- package/src/components/radio/use-radio.ts +16 -2
- package/src/components/table/table.vue +14 -11
|
@@ -1,65 +1,74 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const radioGroupedPropTypes = {
|
|
13
|
+
id: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: [String, Number, Boolean],
|
|
19
|
+
},
|
|
20
|
+
name: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
type: Array as PropType<RadioOption[]>,
|
|
26
|
+
required: true,
|
|
27
|
+
default: () => [],
|
|
28
|
+
},
|
|
29
|
+
disabled: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
description: {
|
|
34
|
+
type: String,
|
|
35
|
+
},
|
|
36
|
+
fullWidth: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
bordered: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false,
|
|
43
|
+
},
|
|
44
|
+
displayHelper: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
helperIcon: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
52
|
+
helperText: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '',
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
horizontalAlign: {
|
|
61
|
+
type: String as PropType<'left' | 'center' | 'right'>,
|
|
62
|
+
default: 'left',
|
|
63
|
+
},
|
|
64
|
+
choiceBox: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const radioGroupedEmitTypes = ['update:modelValue'];
|
|
71
|
+
|
|
72
|
+
export type RadioGroupedPropTypes = ExtractPropTypes<typeof radioGroupedPropTypes>;
|
|
73
|
+
|
|
74
|
+
export type RadioGroupedEmitTypes = typeof radioGroupedEmitTypes;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="['spr-relative']">
|
|
2
|
+
<div :class="['spr-relative', { 'spr-w-full': props.choiceBox || props.fullWidth }]">
|
|
3
3
|
<div :class="radioGroupedClasses.containerClasses">
|
|
4
4
|
<spr-radio
|
|
5
5
|
v-for="(option, index) in renderOptions()"
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
:name="props.name"
|
|
10
10
|
:value="option.value"
|
|
11
11
|
:disabled="isOptionDisabled(option)"
|
|
12
|
+
:choice-box="props.choiceBox"
|
|
13
|
+
:full-width="props.fullWidth || props.choiceBox"
|
|
14
|
+
:description="option.description"
|
|
12
15
|
>
|
|
13
16
|
{{ option.text }}
|
|
14
17
|
</spr-radio>
|
|
@@ -1,62 +1,63 @@
|
|
|
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
|
-
};
|
|
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, choiceBox } = 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
|
+
choiceBox,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
:class="radioClasses.baseClasses"
|
|
4
|
+
@click="radioRef?.click()"
|
|
5
|
+
@mouseenter="isHovered = true"
|
|
6
|
+
@mouseleave="isHovered = false"
|
|
7
|
+
>
|
|
3
8
|
<input
|
|
4
9
|
:id="props.id"
|
|
5
10
|
ref="radioRef"
|
|
@@ -8,7 +13,7 @@
|
|
|
8
13
|
:name="props.name"
|
|
9
14
|
:value="props.value"
|
|
10
15
|
:disabled="props.disabled"
|
|
11
|
-
:class="radioClasses.
|
|
16
|
+
:class="radioClasses.baseInputClasses"
|
|
12
17
|
/>
|
|
13
18
|
<label
|
|
14
19
|
ref="radioRef"
|
|
@@ -25,8 +30,9 @@
|
|
|
25
30
|
'spr-text-xs spr-font-normal spr-leading-4 spr-text-mushroom-600',
|
|
26
31
|
{ 'spr-text-color-disabled': props.disabled },
|
|
27
32
|
]"
|
|
28
|
-
>{{ props.description }}</span
|
|
29
33
|
>
|
|
34
|
+
{{ props.description }}
|
|
35
|
+
</span>
|
|
30
36
|
</div>
|
|
31
37
|
</label>
|
|
32
38
|
</div>
|
|
@@ -42,7 +48,7 @@ const props = defineProps(radioPropTypes);
|
|
|
42
48
|
const emit = defineEmits(radioEmitTypes);
|
|
43
49
|
const slots = useSlots();
|
|
44
50
|
|
|
45
|
-
const { proxyValue, radioRef, radioClasses } = useRadioButton(props, emit, slots);
|
|
51
|
+
const { proxyValue, radioRef, radioClasses, isHovered } = useRadioButton(props, emit, slots);
|
|
46
52
|
</script>
|
|
47
53
|
|
|
48
54
|
<style scoped>
|
|
@@ -8,6 +8,7 @@ import type { RadioPropTypes, RadioEmitTypes } from './radio';
|
|
|
8
8
|
|
|
9
9
|
interface RadioClasses {
|
|
10
10
|
baseClasses: string;
|
|
11
|
+
baseInputClasses: string;
|
|
11
12
|
baseIndicatorClasses: string;
|
|
12
13
|
labelClasses: string;
|
|
13
14
|
borderedClasses: string;
|
|
@@ -18,13 +19,24 @@ export const useRadioButton = (
|
|
|
18
19
|
emit: SetupContext<RadioEmitTypes>['emit'],
|
|
19
20
|
slots: Record<string, unknown>,
|
|
20
21
|
) => {
|
|
21
|
-
const { modelValue, disabled, description, bordered, fullWidth } = toRefs(props);
|
|
22
|
+
const { modelValue, disabled, description, bordered, fullWidth, choiceBox } = toRefs(props);
|
|
22
23
|
|
|
23
24
|
const radioRef = ref<HTMLInputElement | null>(null);
|
|
24
25
|
const isHovered = useElementHover(radioRef);
|
|
25
26
|
|
|
26
27
|
const radioClasses: ComputedRef<RadioClasses> = computed(() => {
|
|
27
|
-
const baseClasses = classNames('spr-
|
|
28
|
+
const baseClasses = classNames('spr-relative spr-m-0', {
|
|
29
|
+
'spr-inline-block': !choiceBox.value,
|
|
30
|
+
'spr-block': choiceBox.value,
|
|
31
|
+
'spr-w-full': fullWidth.value || choiceBox.value,
|
|
32
|
+
'spr-align-middle': !choiceBox.value,
|
|
33
|
+
'spr-border-color spr-border-color-weak spr-border spr-border-solid spr-p-2 spr-rounded-lg spr-transition spr-ease-in-out spr-duration-150 active:spr-scale-[0.98]':
|
|
34
|
+
choiceBox.value,
|
|
35
|
+
'spr-cursor-pointer': choiceBox.value && !disabled.value,
|
|
36
|
+
'spr-cursor-not-allowed': disabled.value && choiceBox.value,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const baseInputClasses = classNames('spr-sr-only spr-peer spr-inline-block', {
|
|
28
40
|
'spr-cursor-not-allowed': disabled.value,
|
|
29
41
|
});
|
|
30
42
|
|
|
@@ -121,6 +133,7 @@ export const useRadioButton = (
|
|
|
121
133
|
|
|
122
134
|
return {
|
|
123
135
|
baseClasses,
|
|
136
|
+
baseInputClasses,
|
|
124
137
|
baseIndicatorClasses,
|
|
125
138
|
labelClasses,
|
|
126
139
|
borderedClasses,
|
|
@@ -132,6 +145,7 @@ export const useRadioButton = (
|
|
|
132
145
|
return {
|
|
133
146
|
radioRef,
|
|
134
147
|
radioClasses,
|
|
148
|
+
isHovered,
|
|
135
149
|
proxyValue,
|
|
136
150
|
description,
|
|
137
151
|
bordered,
|
|
@@ -17,13 +17,7 @@
|
|
|
17
17
|
</spr-table-actions>
|
|
18
18
|
</div>
|
|
19
19
|
<div :class="getTableClasses.tableBackgroundClasses">
|
|
20
|
-
<table
|
|
21
|
-
:key="tableKey"
|
|
22
|
-
aria-describedby="describe"
|
|
23
|
-
class="spr-h-full spr-w-full"
|
|
24
|
-
cellspacing="0"
|
|
25
|
-
cellpadding="0"
|
|
26
|
-
>
|
|
20
|
+
<table :key="tableKey" aria-describedby="describe" class="spr-h-full spr-w-full" cellspacing="0" cellpadding="0">
|
|
27
21
|
<thead>
|
|
28
22
|
<tr v-if="!(props.removeHeaderOnEmpty && tableData.length <= 0)">
|
|
29
23
|
<th
|
|
@@ -45,12 +39,16 @@
|
|
|
45
39
|
:class="[getTableClasses.headerClasses(header)]"
|
|
46
40
|
:style="{ width: header?.width }"
|
|
47
41
|
>
|
|
48
|
-
<div
|
|
42
|
+
<div
|
|
43
|
+
v-if="props.showHeaderFilter"
|
|
44
|
+
class="hover:spr-background-color-hover active:spr-background-color-pressed spr-absolute spr-inset-0 spr-z-[2] spr-cursor-pointer"
|
|
45
|
+
@click="handleHeaderDropdownClick(keyHeader)"
|
|
46
|
+
></div>
|
|
49
47
|
<!-- Header with Dropdown Filter -->
|
|
50
48
|
<spr-table-header-dropdown
|
|
51
49
|
v-if="props.showHeaderFilter"
|
|
52
|
-
:ref="(el: unknown) => setHeaderDropdownRef(el, keyHeader)"
|
|
53
50
|
:id="`th-dropdown-${keyHeader}`"
|
|
51
|
+
:ref="(el: unknown) => setHeaderDropdownRef(el, keyHeader)"
|
|
54
52
|
:header="header"
|
|
55
53
|
:is-sortable="true"
|
|
56
54
|
:header-classes="getTableClasses.headerNameClass"
|
|
@@ -83,7 +81,12 @@
|
|
|
83
81
|
/>
|
|
84
82
|
</span>
|
|
85
83
|
<span v-if="props.showHeaderFilter">
|
|
86
|
-
<Icon
|
|
84
|
+
<Icon
|
|
85
|
+
icon="ph:funnel-simple"
|
|
86
|
+
height="20"
|
|
87
|
+
width="20"
|
|
88
|
+
class="spr-ml-size-spacing-5xs spr-text-[#4B685E]"
|
|
89
|
+
/>
|
|
87
90
|
</span>
|
|
88
91
|
</div>
|
|
89
92
|
</th>
|
|
@@ -242,7 +245,7 @@ const emit = defineEmits(tableEmitTypes);
|
|
|
242
245
|
const slots = useSlots();
|
|
243
246
|
const headerDropdownRefs = ref<Record<string, Element | null>>({});
|
|
244
247
|
|
|
245
|
-
const setHeaderDropdownRef = (el: unknown, key: string | number) => {
|
|
248
|
+
const setHeaderDropdownRef = (el: unknown, key: string | number) => {
|
|
246
249
|
if (el) {
|
|
247
250
|
headerDropdownRefs.value[String(key)] = el as Element;
|
|
248
251
|
}
|