sprintify-ui 0.0.139 → 0.0.140
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
|
-
import { Option } from '@/types';
|
|
2
|
+
import { NormalizedOption, Option, OptionValue } from '@/types';
|
|
3
3
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
4
4
|
modelValue: {
|
|
5
5
|
default: undefined;
|
|
6
|
-
type: PropType<
|
|
6
|
+
type: PropType<OptionValue | undefined>;
|
|
7
7
|
};
|
|
8
8
|
name: {
|
|
9
9
|
default: undefined;
|
|
@@ -44,7 +44,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
44
44
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
45
45
|
modelValue: {
|
|
46
46
|
default: undefined;
|
|
47
|
-
type: PropType<
|
|
47
|
+
type: PropType<OptionValue | undefined>;
|
|
48
48
|
};
|
|
49
49
|
name: {
|
|
50
50
|
default: undefined;
|
|
@@ -88,13 +88,13 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
88
88
|
required: boolean;
|
|
89
89
|
name: string;
|
|
90
90
|
disabled: boolean;
|
|
91
|
-
modelValue:
|
|
91
|
+
modelValue: OptionValue | undefined;
|
|
92
92
|
hasError: boolean;
|
|
93
93
|
inputClass: string;
|
|
94
94
|
labelClass: string;
|
|
95
95
|
}>, {
|
|
96
96
|
option: (_: {
|
|
97
|
-
option:
|
|
97
|
+
option: NormalizedOption;
|
|
98
98
|
}) => any;
|
|
99
99
|
}>;
|
|
100
100
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { options } from '../../.storybook/utils';
|
|
2
2
|
import BaseRadioGroup from './BaseRadioGroup.vue';
|
|
3
3
|
import { createFieldStory } from '@/../.storybook/utils';
|
|
4
|
+
import ShowValue from '../../.storybook/components/ShowValue.vue';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
title: 'Form/BaseRadioGroup',
|
|
@@ -15,9 +16,9 @@ export default {
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const Template = (args) => ({
|
|
18
|
-
components: { BaseRadioGroup },
|
|
19
|
+
components: { BaseRadioGroup, ShowValue },
|
|
19
20
|
setup() {
|
|
20
|
-
const value = ref(
|
|
21
|
+
const value = ref(options[0].value);
|
|
21
22
|
function onSubmit() {
|
|
22
23
|
alert('submit');
|
|
23
24
|
}
|
|
@@ -27,7 +28,7 @@ const Template = (args) => ({
|
|
|
27
28
|
<form @submit.prevent="onSubmit">
|
|
28
29
|
<BaseRadioGroup v-model="value" v-bind="args"></BaseRadioGroup>
|
|
29
30
|
<button type="submit" class="btn btn-primary mt-4">Submit</button>
|
|
30
|
-
<
|
|
31
|
+
<ShowValue :value="value">{{ value }}</ShowValue>
|
|
31
32
|
</form>
|
|
32
33
|
`,
|
|
33
34
|
});
|
|
@@ -43,7 +44,6 @@ Required.args = {
|
|
|
43
44
|
export const Disabled = Template.bind({});
|
|
44
45
|
Disabled.args = {
|
|
45
46
|
disabled: true,
|
|
46
|
-
modelValue: { label: 'Dark Maul', value: 'darth_maul' },
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export const SlotOption = (args) => ({
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
:id="name + '-' + option.value"
|
|
15
15
|
type="radio"
|
|
16
16
|
:name="nameInternal"
|
|
17
|
-
:checked="
|
|
17
|
+
:checked="isChecked(option)"
|
|
18
18
|
:required="requiredInternal"
|
|
19
19
|
:disabled="disabled"
|
|
20
20
|
:value="option.value"
|
|
21
21
|
:class="inputClass"
|
|
22
|
-
@input="emitUpdate(option.
|
|
22
|
+
@input="emitUpdate(option.value)"
|
|
23
23
|
/>
|
|
24
24
|
|
|
25
25
|
<slot name="option" :option="option">
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
|
|
34
34
|
<script lang="ts" setup>
|
|
35
35
|
import { PropType } from 'vue';
|
|
36
|
-
import { Option } from '@/types';
|
|
37
|
-
import { useHasOptions } from '@/composables/hasOptions';
|
|
36
|
+
import { NormalizedOption, Option, OptionValue } from '@/types';
|
|
38
37
|
import { useField } from '@/composables/field';
|
|
39
38
|
import { uniqueId } from 'lodash';
|
|
40
39
|
|
|
41
40
|
const props = defineProps({
|
|
42
41
|
modelValue: {
|
|
43
42
|
default: undefined,
|
|
44
|
-
type: [
|
|
43
|
+
type: [String, Number, null, undefined] as PropType<
|
|
44
|
+
OptionValue | undefined
|
|
45
|
+
>,
|
|
45
46
|
},
|
|
46
47
|
name: {
|
|
47
48
|
default: undefined,
|
|
@@ -102,11 +103,20 @@ const { nameInternal, requiredInternal, emitUpdate } = useField({
|
|
|
102
103
|
labelClass: 'mb-3 font-medium',
|
|
103
104
|
});
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
function isChecked(option: NormalizedOption): boolean {
|
|
107
|
+
if (props.modelValue) {
|
|
108
|
+
return props.modelValue == option.value;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const normalizedOptions = computed((): NormalizedOption[] => {
|
|
114
|
+
return props.options.map((option) => {
|
|
115
|
+
return {
|
|
116
|
+
label: option[props.labelKey] as string,
|
|
117
|
+
value: option[props.valueKey] as string | number,
|
|
118
|
+
option: option,
|
|
119
|
+
} as NormalizedOption;
|
|
120
|
+
});
|
|
121
|
+
});
|
|
112
122
|
</script>
|