PluginProbe
The Innovative Form Builder – IvyForms / 0.6
The Innovative Form Builder – IvyForms v0.6
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / views / _components / input / IvyNumberInput.vue

IvyNumberInput.vue in The Innovative Form Builder – IvyForms 0.6, at frontend/src/views/_components/input/IvyNumberInput.vue

212 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <template>
2 <ElInputNumber
3 ref="elInputNumberRef"
4 v-bind="{ ...$attrs, ...$props }"
5 v-model="localModelValue"
6 value-on-clear="min"
7 :placeholder="''"
8 class="ivyforms-input-number"
9 :class="[
10 {
11 'ivyforms-full-width': fullWidth,
12 'is-filled': props.filled,
13 'is-secondary': props.secondary,
14 },
15 ]"
16 >
17 <template #decrease-icon>
18 <IvyIcon
19 priority="tertiary"
20 name="minus"
21 size="s"
22 type="outline"
23 color="var(--map-base-dusk-symbol-2)"
24 />
25 </template>
26 <template #increase-icon>
27 <IvyIcon
28 priority="tertiary"
29 name="plus"
30 size="s"
31 type="outline"
32 color="var(--map-base-dusk-symbol-2)"
33 />
34 </template>
35 </ElInputNumber>
36 </template>
37
38 <script setup lang="ts">
39 import { computed, ref } from 'vue'
40
41 interface Props {
42 modelValue: number | undefined | null
43 min?: number
44 max?: number
45 fullWidth?: boolean
46 filled?: boolean
47 secondary?: boolean
48 }
49
50 const props = withDefaults(defineProps<Props>(), {
51 fullWidth: true,
52 min: Number.MIN_SAFE_INTEGER,
53 max: Number.MAX_SAFE_INTEGER,
54 })
55
56 const emit = defineEmits(['update:modelValue', 'input'])
57
58 const elInputNumberRef = ref()
59
60 const localModelValue = computed({
61 get() {
62 return props.modelValue === null ? undefined : props.modelValue
63 },
64 set(value) {
65 emit('update:modelValue', value === undefined || value === null ? null : value)
66 },
67 })
68
69 const focus = () => {
70 elInputNumberRef.value?.focus()
71 }
72
73 defineExpose({
74 focus,
75 })
76 </script>
77
78 <style lang="scss">
79 // Error and warning states (for use in form item context)
80 .el-form-item {
81 &.is-error {
82 .ivyforms-input-number {
83 &.el-input-number {
84 .el-input__wrapper {
85 border: 1px solid var(--map-status-error-symbol-0);
86 }
87 }
88 }
89 }
90
91 &.is-warning {
92 .ivyforms-input-number {
93 &.el-input-number {
94 .el-input__wrapper {
95 border: 1px solid var(--map-status-warning-stroke-0);
96 }
97 }
98 }
99 }
100
101 // Secondary
102 &.is-secondary {
103 .ivyforms-input-number {
104 &.el-input-number {
105 .el-input__wrapper {
106 &:active,
107 &:focus,
108 &.is-focus,
109 &.is-active {
110 border: 1px solid var(--map-base-purple-stroke-0);
111 }
112 }
113 }
114 }
115 }
116 }
117
118 .ivyforms-input-number {
119 display: flex;
120 height: 40px;
121 min-height: 40px;
122 background: var(--map-base-dusk-o05);
123
124 // Element Input Number
125 &.el-input-number {
126 // Decrease and Increase Buttons
127 .el-input-number__decrease,
128 .el-input-number__increase {
129 border: 0;
130 background: transparent;
131
132 // Icon
133 svg path {
134 @include transition(fill);
135 }
136
137 // Hover
138 &:hover {
139 // Wrapper
140 ~ .el-input:not(.is-disabled) .el-input__wrapper {
141 border-color: var(--map-base-dusk-stroke-0);
142 }
143 }
144
145 // Disabled
146 &.is-disabled {
147 opacity: 0.5;
148
149 // Button
150 button {
151 cursor: not-allowed;
152
153 // Transition
154 .ivyforms-button-action__transition {
155 display: none;
156 }
157 }
158 }
159 }
160
161 // Input Wrapper
162 .el-input__wrapper {
163 height: 40px;
164 min-height: 40px;
165 border-radius: 8px;
166 padding: 0 40px;
167 box-shadow: none !important;
168 border: 1px solid var(--map-base-dusk-stroke--2);
169 background-color: transparent;
170
171 // Hover
172 &:hover {
173 border-color: var(--map-base-dusk-stroke-0);
174 }
175
176 // Active
177 &:active,
178 &:focus,
179 &.is-focus,
180 &.is-active {
181 border-color: var(--map-base-brand-fill-0);
182 }
183
184 // Native Input
185 .el-input__inner {
186 box-shadow: none !important;
187 border: 0;
188 padding: 0;
189 font-size: 16px;
190 color: var(--map-base-text-0);
191 background-color: transparent;
192 }
193 }
194
195 // Decrease Button
196 .el-input-number__decrease {
197 @include flipProperty(left, right, 12px);
198 }
199
200 // Increase Button
201 .el-input-number__increase {
202 @include flipProperty(right, left, 12px);
203 }
204 }
205
206 // Full Width
207 &.ivyforms-full-width {
208 width: 100%;
209 }
210 }
211 </style>
212