AmInputNumber.vue
255 lines
| 1 | <template> |
| 2 | <el-input-number |
| 3 | :id="id" |
| 4 | ref="amInputNumber" |
| 5 | v-model="model" |
| 6 | class="am-input-number" |
| 7 | :class="[`am-input-number__${size}`]" |
| 8 | :style="cssVars" |
| 9 | :min="min" |
| 10 | :max="max" |
| 11 | :step="step" |
| 12 | :step-strictly="stepStrictly" |
| 13 | :precision="precision" |
| 14 | :disabled="disabled" |
| 15 | :controls="controls" |
| 16 | :controls-position="controlsPosition" |
| 17 | :name="name" |
| 18 | :label="label" |
| 19 | :place-holder="placeHolder" |
| 20 | @blur="(e) => $emit('blur', e)" |
| 21 | @focus="(e) => $emit('focus', e)" |
| 22 | @change="(currentValue, oldValue) => $emit('change', currentValue, oldValue)" |
| 23 | /> |
| 24 | </template> |
| 25 | |
| 26 | <script setup> |
| 27 | import { ref, toRefs, inject, computed } from 'vue'; |
| 28 | import { useColorTransparency } from "../../../assets/js/common/colorManipulation"; |
| 29 | |
| 30 | /** |
| 31 | * Component Props |
| 32 | */ |
| 33 | const props = defineProps({ |
| 34 | id: { |
| 35 | type: String |
| 36 | }, |
| 37 | modelValue: { |
| 38 | type: Number, |
| 39 | }, |
| 40 | min: { |
| 41 | type: Number, |
| 42 | required: true |
| 43 | }, |
| 44 | max: { |
| 45 | type: Number, |
| 46 | default: Infinity |
| 47 | }, |
| 48 | step: { |
| 49 | type: Number, |
| 50 | default: 1 |
| 51 | }, |
| 52 | stepStrictly: { |
| 53 | type: Boolean, |
| 54 | default: false |
| 55 | }, |
| 56 | precision: { |
| 57 | type: Number |
| 58 | }, |
| 59 | size: { |
| 60 | type: String, |
| 61 | default: 'default', |
| 62 | validator(value) { |
| 63 | return ['default', 'medium', 'small'].includes(value) |
| 64 | } |
| 65 | }, |
| 66 | disabled: { |
| 67 | type: Boolean, |
| 68 | default: false |
| 69 | }, |
| 70 | controls: { |
| 71 | type: Boolean, |
| 72 | default: true |
| 73 | }, |
| 74 | controlsPosition: { |
| 75 | // right |
| 76 | type: String, |
| 77 | default: '' |
| 78 | }, |
| 79 | name: { |
| 80 | type: String, |
| 81 | default: '' |
| 82 | }, |
| 83 | label: { |
| 84 | type: String, |
| 85 | default: '' |
| 86 | }, |
| 87 | placeHolder: { |
| 88 | type: String, |
| 89 | default: '' |
| 90 | } |
| 91 | }) |
| 92 | |
| 93 | /** |
| 94 | * Component Emits |
| 95 | * */ |
| 96 | const emits = defineEmits(['change', 'visible-change', 'clear', 'blur', 'focus', 'update:modelValue']) |
| 97 | |
| 98 | /** |
| 99 | * Component model |
| 100 | */ |
| 101 | let { modelValue } = toRefs(props) |
| 102 | let model = computed({ |
| 103 | get: () => modelValue.value, |
| 104 | set: (val) => { |
| 105 | emits('update:modelValue', val) |
| 106 | } |
| 107 | }) |
| 108 | |
| 109 | /** |
| 110 | * Component reference |
| 111 | */ |
| 112 | const amInputNumber = ref(null) |
| 113 | |
| 114 | // * Colors |
| 115 | let amColors = inject('amColors', ref({ |
| 116 | colorPrimary: '#1246D6', |
| 117 | colorSuccess: '#019719', |
| 118 | colorError: '#B4190F', |
| 119 | colorWarning: '#CCA20C', |
| 120 | colorMainBgr: '#FFFFFF', |
| 121 | colorMainHeadingText: '#33434C', |
| 122 | colorMainText: '#1A2C37', |
| 123 | colorSbBgr: '#17295A', |
| 124 | colorSbText: '#FFFFFF', |
| 125 | colorInpBgr: '#FFFFFF', |
| 126 | colorInpBorder: '#D1D5D7', |
| 127 | colorInpText: '#1A2C37', |
| 128 | colorInpPlaceHolder: '#1A2C37', |
| 129 | colorDropBgr: '#FFFFFF', |
| 130 | colorDropBorder: '#D1D5D7', |
| 131 | colorDropText: '#0E1920', |
| 132 | colorBtnPrim: '#265CF2', |
| 133 | colorBtnPrimText: '#FFFFFF', |
| 134 | colorBtnSec: '#1A2C37', |
| 135 | colorBtnSecText: '#FFFFFF', |
| 136 | })) |
| 137 | let cssVars = computed(() => { |
| 138 | return { |
| 139 | '--am-c-inp-number-bgr': amColors.value.colorInpBgr, |
| 140 | '--am-c-inp-number-border': amColors.value.colorInpBorder, |
| 141 | '--am-c-inp-number-text': amColors.value.colorInpText, |
| 142 | '--am-c-inp-number-text-op10': useColorTransparency(amColors.value.colorInpText, 0.1), |
| 143 | '--am-c-inp-number-text-op03': useColorTransparency(amColors.value.colorInpText, 0.03), |
| 144 | '--am-c-inp-number-text-op40': useColorTransparency(amColors.value.colorInpText, 0.4), |
| 145 | '--am-c-inp-number-text-op60': useColorTransparency(amColors.value.colorInpText, 0.6), |
| 146 | '--am-c-inp-number-placeholder': amColors.value.colorInpPlaceHolder, |
| 147 | } |
| 148 | }) |
| 149 | </script> |
| 150 | |
| 151 | <style lang="scss"> |
| 152 | @mixin am-inp-number-block { |
| 153 | .am-input-number { |
| 154 | --am-c-inp-number-bgr: var(--am-c-inp-bgr); |
| 155 | --am-c-inp-number-border: var(--am-c-inp-border); |
| 156 | --am-c-inp-number-text: var(--am-c-inp-text); |
| 157 | --am-c-inp-number-placeholder: var(--am-c-inp-placeholder); |
| 158 | --am-rad-inp-number: var(--am-rad-input); |
| 159 | --am-fs-inp-number: var(--am-fs-input); |
| 160 | |
| 161 | &__default { |
| 162 | --am-input-number-height: 40px; |
| 163 | --am-input-number-padding: 8px 34px; |
| 164 | } |
| 165 | |
| 166 | &__medium { |
| 167 | --am-input-number-height: 36px; |
| 168 | --am-input-number-padding: 6px 34px; |
| 169 | } |
| 170 | |
| 171 | &__small { |
| 172 | --am-input-number-height: 32px; |
| 173 | --am-input-number-padding: 4px 34px; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | .el-input-number { |
| 178 | .el-input { |
| 179 | &__inner { |
| 180 | height: var(--am-input-number-height); |
| 181 | font-size: var(--am-fs-inp-number); |
| 182 | line-height: 1.6; |
| 183 | color: var(--am-c-inp-number-text); |
| 184 | border: 1px solid var(--am-c-inp-number-border); |
| 185 | border-radius: var(--am-rad-inp-number); |
| 186 | background-color: var(--am-c-inp-number-bgr); |
| 187 | padding: var(--am-input-number-padding) !important; |
| 188 | margin: 0; |
| 189 | max-width: 100%; |
| 190 | |
| 191 | &::-webkit-input-placeholder { /* Chrome/Opera/Safari */ |
| 192 | color: var(--am-c-inp-number-placeholder); |
| 193 | } |
| 194 | &::-moz-placeholder { /* Firefox 19+ */ |
| 195 | color: var(--am-c-inp-number-placeholder); |
| 196 | } |
| 197 | &:-ms-input-placeholder { /* IE 10+ */ |
| 198 | color: var(--am-c-inp-number-placeholder); |
| 199 | } |
| 200 | &:-moz-placeholder { /* Firefox 18- */ |
| 201 | color: var(--am-c-inp-number-placeholder); |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | &__decrease { |
| 207 | border-right-color: transparent; |
| 208 | } |
| 209 | |
| 210 | &__increase { |
| 211 | border-left-color: transparent; |
| 212 | } |
| 213 | |
| 214 | &__decrease, &__increase { |
| 215 | background-color: transparent; |
| 216 | |
| 217 | &:hover { |
| 218 | .el-icon { |
| 219 | color: var(--am-c-inp-number-text); |
| 220 | border-radius: 4px; |
| 221 | background-color: var(--am-c-inp-number-text-op10); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | .el-icon { |
| 226 | width: 22px; |
| 227 | height: 22px; |
| 228 | color: var(--am-c-inp-number-text); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | &.is-disabled { |
| 233 | .el-icon { |
| 234 | color: var(--am-c-inp-number-text-op40); |
| 235 | } |
| 236 | |
| 237 | .el-input__inner { |
| 238 | background-color: var(--am-c-inp-number-text-op03); |
| 239 | color: var(--am-c-inp-number-text-op60); |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | // public |
| 246 | .amelia-v2-booking #amelia-container { |
| 247 | @include am-inp-number-block; |
| 248 | } |
| 249 | |
| 250 | // admin |
| 251 | #amelia-app-backend-new { |
| 252 | @include am-inp-number-block; |
| 253 | } |
| 254 | </style> |
| 255 |