sprintify-ui 0.0.139 → 0.0.141
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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprintify-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.141",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rimraf dist && vue-tsc && vite build",
|
|
6
6
|
"build-fast": "rimraf dist && vite build",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"humanize-duration": "^3.0.0",
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"luxon": "^3.0.0",
|
|
25
|
-
"maska": "^2.1.
|
|
25
|
+
"maska": "^2.1.3",
|
|
26
26
|
"microtip": "^0.2.2",
|
|
27
27
|
"object-to-formdata": "^4.4.2",
|
|
28
28
|
"pikaday": "^1.8.2",
|
|
@@ -19,29 +19,8 @@
|
|
|
19
19
|
>
|
|
20
20
|
{{ prefix }}
|
|
21
21
|
</div>
|
|
22
|
-
<input
|
|
23
|
-
|
|
24
|
-
v-maska:[maskOptions]
|
|
25
|
-
:value="modelValue"
|
|
26
|
-
:type="type"
|
|
27
|
-
:name="nameInternal"
|
|
28
|
-
:step="step"
|
|
29
|
-
:min="min"
|
|
30
|
-
:max="max"
|
|
31
|
-
:disabled="disabled"
|
|
32
|
-
:placeholder="placeholder"
|
|
33
|
-
:required="requiredInternal"
|
|
34
|
-
class="w-full border-none bg-white outline-none focus:z-[1] focus:ring-2 focus:ring-primary-600 focus:ring-offset-1 disabled:cursor-not-allowed disabled:text-slate-300"
|
|
35
|
-
:class="{
|
|
36
|
-
'rounded-l': !iconLeft && !prefix,
|
|
37
|
-
'rounded-r': !iconRight && !suffix,
|
|
38
|
-
}"
|
|
39
|
-
:autocomplete="autocomplete ? 'on' : 'off'"
|
|
40
|
-
@keydown.enter="onEnter"
|
|
41
|
-
@input="emitUpdate(transformInputValue($event))"
|
|
42
|
-
@focus="$emit('focus', $event)"
|
|
43
|
-
@blur="$emit('blur', $event)"
|
|
44
|
-
/>
|
|
22
|
+
<input v-if="hasMask" ref="input" v-maska:[maskOptions] v-bind="bindings" />
|
|
23
|
+
<input v-else ref="input" v-bind="bindings" />
|
|
45
24
|
<div
|
|
46
25
|
v-if="suffix"
|
|
47
26
|
class="flex shrink-0 items-center justify-center border-l px-4 transition-colors"
|
|
@@ -65,7 +44,7 @@
|
|
|
65
44
|
</template>
|
|
66
45
|
|
|
67
46
|
<script lang="ts" setup>
|
|
68
|
-
import { get
|
|
47
|
+
import { get } from 'lodash';
|
|
69
48
|
import { PropType } from 'vue';
|
|
70
49
|
import { BaseIcon } from '@/index';
|
|
71
50
|
import { useField } from '@/composables/field';
|
|
@@ -156,6 +135,37 @@ const maskOptions = computed(() => {
|
|
|
156
135
|
return undefined;
|
|
157
136
|
});
|
|
158
137
|
|
|
138
|
+
const hasMask = computed(() => {
|
|
139
|
+
return !!props.mask;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const bindings = computed<any>(() => {
|
|
143
|
+
return {
|
|
144
|
+
value: props.modelValue,
|
|
145
|
+
type: props.type,
|
|
146
|
+
name: nameInternal.value,
|
|
147
|
+
step: props.step,
|
|
148
|
+
min: props.min,
|
|
149
|
+
max: props.max,
|
|
150
|
+
disabled: props.disabled,
|
|
151
|
+
placeholder: props.placeholder,
|
|
152
|
+
required: requiredInternal.value,
|
|
153
|
+
autocomplete: props.autocomplete ? 'on' : 'off',
|
|
154
|
+
class: {
|
|
155
|
+
'rounded-l': !props.iconLeft && !props.prefix,
|
|
156
|
+
'rounded-r': !props.iconRight && !props.suffix,
|
|
157
|
+
'w-full border-none bg-white outline-none focus:z-[1] focus:ring-2 focus:ring-primary-600 focus:ring-offset-1 disabled:cursor-not-allowed disabled:text-slate-300':
|
|
158
|
+
true,
|
|
159
|
+
},
|
|
160
|
+
onKeydown: {
|
|
161
|
+
enter: onEnter,
|
|
162
|
+
},
|
|
163
|
+
onInput: update,
|
|
164
|
+
onFocus: (e: Event) => emit('focus', e),
|
|
165
|
+
onBlur: (e: Event) => emit('blur', e),
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
|
|
159
169
|
const maskInternal = computed(() => {
|
|
160
170
|
if (props.mask === 'phone') {
|
|
161
171
|
return '(###) ###-####';
|
|
@@ -186,18 +196,12 @@ const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate } =
|
|
|
186
196
|
emit: emit,
|
|
187
197
|
});
|
|
188
198
|
|
|
189
|
-
function
|
|
199
|
+
function update(event: any | null) {
|
|
190
200
|
if (event === null) {
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const value = get(event, 'target.value', null);
|
|
195
|
-
|
|
196
|
-
if (isString(value)) {
|
|
197
|
-
return value;
|
|
201
|
+
emitUpdate(null);
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
return '';
|
|
204
|
+
return emitUpdate(get(event, 'target.value', ''));
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
function onEnter(e: Event) {
|
|
@@ -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>
|