2022-06-05 17:10:44 +03:00
|
|
|
import Select from 'src/components/select/select.vue'
|
2023-03-12 14:32:13 +02:00
|
|
|
import Setting from './setting.js'
|
2022-06-05 17:10:44 +03:00
|
|
|
|
|
|
|
|
export const allCssUnits = ['cm', 'mm', 'in', 'px', 'pt', 'pc', 'em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vmax', '%']
|
|
|
|
|
export const defaultHorizontalUnits = ['px', 'rem', 'vw']
|
|
|
|
|
export const defaultVerticalUnits = ['px', 'rem', 'vh']
|
|
|
|
|
|
|
|
|
|
export default {
|
2023-03-16 23:18:55 +02:00
|
|
|
...Setting,
|
2022-06-05 17:10:44 +03:00
|
|
|
components: {
|
2023-03-16 23:18:55 +02:00
|
|
|
...Setting.components,
|
2022-06-05 17:10:44 +03:00
|
|
|
Select
|
|
|
|
|
},
|
|
|
|
|
props: {
|
2023-03-12 14:32:13 +02:00
|
|
|
...Setting.props,
|
2022-06-05 17:10:44 +03:00
|
|
|
min: Number,
|
|
|
|
|
units: {
|
2023-03-12 14:32:13 +02:00
|
|
|
type: Array,
|
2022-06-05 17:10:44 +03:00
|
|
|
default: () => allCssUnits
|
2024-04-24 15:58:26 +03:00
|
|
|
},
|
|
|
|
|
unitSet: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'none'
|
2023-03-12 14:32:13 +02:00
|
|
|
}
|
2022-06-05 17:10:44 +03:00
|
|
|
},
|
|
|
|
|
computed: {
|
2023-03-12 14:32:13 +02:00
|
|
|
...Setting.computed,
|
2022-06-05 17:10:44 +03:00
|
|
|
stateUnit () {
|
2023-03-12 14:32:13 +02:00
|
|
|
return this.state.replace(/\d+/, '')
|
2022-06-05 17:10:44 +03:00
|
|
|
},
|
|
|
|
|
stateValue () {
|
2023-03-12 14:32:13 +02:00
|
|
|
return this.state.replace(/\D+/, '')
|
2022-06-05 17:10:44 +03:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-03-12 14:32:13 +02:00
|
|
|
...Setting.methods,
|
2024-04-24 15:58:26 +03:00
|
|
|
getUnitString (value) {
|
|
|
|
|
if (this.unitSet === 'none') return value
|
|
|
|
|
return this.$t(['settings', 'units', this.unitSet, value].join('.'))
|
|
|
|
|
},
|
2022-06-05 17:10:44 +03:00
|
|
|
updateValue (e) {
|
2023-03-12 14:32:13 +02:00
|
|
|
this.configSink(this.path, parseInt(e.target.value) + this.stateUnit)
|
2022-06-05 17:10:44 +03:00
|
|
|
},
|
|
|
|
|
updateUnit (e) {
|
2023-03-12 14:32:13 +02:00
|
|
|
this.configSink(this.path, this.stateValue + e.target.value)
|
2022-06-05 17:10:44 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|