bge-ui 1.4.0 → 1.4.2

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.
package/dist/style.css CHANGED
@@ -1741,6 +1741,32 @@ to {
1741
1741
  }
1742
1742
  .bge-datepicker .bge-datepicker__input.inputed:hover .bge-datepicker__icon[data-v-a163f1fb] {
1743
1743
  display: none;
1744
+ }.bge-switch[data-v-e973c7de] {
1745
+ width: 38px;
1746
+ height: 20px;
1747
+ border-radius: 999px;
1748
+ background-color: var(--separator-separator);
1749
+ transition: background-color 0.3s;
1750
+ position: relative;
1751
+ cursor: pointer;
1752
+ }
1753
+ .bge-switch[data-v-e973c7de]::after {
1754
+ content: "";
1755
+ position: absolute;
1756
+ top: 2px;
1757
+ left: 2px;
1758
+ border-radius: 100%;
1759
+ transition: all 0.3s;
1760
+ width: 16px;
1761
+ height: 16px;
1762
+ background-color: var(--tc-secondary);
1763
+ }
1764
+ .bge-switch.checked[data-v-e973c7de] {
1765
+ background: var(--tc-theme);
1766
+ }
1767
+ .bge-switch.checked[data-v-e973c7de]::after {
1768
+ left: 20px;
1769
+ background-color: var(--tc-icon-opposite);
1744
1770
  }.dp__input_wrap {
1745
1771
  position: relative;
1746
1772
  width: 100%;
@@ -0,0 +1,47 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ size: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ };
6
+ modelValue: {
7
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
8
+ default: () => never[];
9
+ };
10
+ trueValue: {
11
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
12
+ default: boolean;
13
+ };
14
+ falseValue: {
15
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
16
+ default: boolean;
17
+ };
18
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ change: (...args: any[]) => void;
20
+ "update:modelValue": (...args: any[]) => void;
21
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
22
+ size: {
23
+ type: StringConstructor;
24
+ default: string;
25
+ };
26
+ modelValue: {
27
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
28
+ default: () => never[];
29
+ };
30
+ trueValue: {
31
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
32
+ default: boolean;
33
+ };
34
+ falseValue: {
35
+ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
36
+ default: boolean;
37
+ };
38
+ }>> & {
39
+ onChange?: ((...args: any[]) => any) | undefined;
40
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
41
+ }, {
42
+ size: string;
43
+ modelValue: string | number | boolean;
44
+ trueValue: string | number | boolean;
45
+ falseValue: string | number | boolean;
46
+ }, {}>;
47
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bge-ui",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  </label>
26
26
  </template>
27
27
  <script lang="ts" setup>
28
- import { ref, watch, inject } from 'vue'
28
+ import { ref, watch, inject, onMounted } from 'vue'
29
29
  defineOptions({
30
30
  name: 'CheckBox',
31
31
  })
@@ -92,8 +92,23 @@ watch(() => props.modelValue, (val) => {
92
92
  }
93
93
  }
94
94
  formItemContext && formItemContext.validate && formItemContext.validate().catch((err: any) => (err))
95
- }, {
96
- immediate: true
95
+ })
96
+
97
+ onMounted(() => {
98
+ if (typeof val === 'number' || typeof val === 'string' || typeof val === 'boolean') {
99
+ input.value = true
100
+ if (val === props.trueValue) {
101
+ input.value = true
102
+ } else {
103
+ input.value = false
104
+ }
105
+ } else {
106
+ if (val.includes(props.trueValue)) {
107
+ input.value = true
108
+ } else {
109
+ input.value = false
110
+ }
111
+ }
97
112
  })
98
113
 
99
114
  function getLabeledValue(isChecked: boolean) {
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ import UiSlider from "./slider/index.vue"
16
16
  import UiSelect from "./select/index.vue"
17
17
  import UiOption from "./select/option.vue"
18
18
  import UiDatePicker from "./datePicker/index.vue"
19
+ import UiSwitch from "./switch/index.vue"
19
20
  import "./datePicker/style/main.scss"
20
21
  const components: any = {
21
22
  UiButton,
@@ -32,7 +33,8 @@ const components: any = {
32
33
  UiSlider,
33
34
  UiSelect,
34
35
  UiOption,
35
- UiDatePicker
36
+ UiDatePicker,
37
+ UiSwitch
36
38
  }
37
39
 
38
40
  export * from './icons/index.ts'
@@ -53,7 +55,8 @@ export {
53
55
  UiSlider,
54
56
  UiSelect,
55
57
  UiOption,
56
- UiDatePicker
58
+ UiDatePicker,
59
+ UiSwitch
57
60
  }
58
61
 
59
62
  export default {
@@ -24,7 +24,7 @@
24
24
  </label>
25
25
  </template>
26
26
  <script lang="ts" setup>
27
- import { ref, watch, inject, nextTick } from 'vue'
27
+ import { ref, watch, inject, nextTick, onMounted } from 'vue'
28
28
  defineOptions({
29
29
  name: 'Radio',
30
30
  })
@@ -92,6 +92,14 @@ function getLabeledValue(isChecked: boolean) {
92
92
  }
93
93
  }
94
94
 
95
+ onMounted(() => {
96
+ if (props.modelValue === props.trueValue) {
97
+ input.value = true
98
+ } else {
99
+ input.value = false
100
+ }
101
+ })
102
+
95
103
  function handleChange (e: Event) {
96
104
  nextTick(() => {
97
105
  const target = e.target as HTMLInputElement
@@ -0,0 +1,80 @@
1
+ <template>
2
+ <div class="bge-switch" :class="{checked: isChecked}" @click="isChecked = !isChecked">
3
+ </div>
4
+ </template>
5
+ <script lang="ts" setup>
6
+ import {ref, watch} from 'vue'
7
+ const isChecked = ref(false)
8
+
9
+ const emit = defineEmits([
10
+ 'change',
11
+ 'update:modelValue'
12
+ ])
13
+
14
+ const props = defineProps({
15
+ size: {
16
+ type: String,
17
+ default: 'default'
18
+ },
19
+ modelValue: {
20
+ type: [String, Number, Boolean],
21
+ default: () => []
22
+ },
23
+ trueValue: {
24
+ type: [Boolean, String, Number],
25
+ default: true
26
+ },
27
+ falseValue: {
28
+ type: [Boolean, String, Number],
29
+ default: false
30
+ }
31
+ })
32
+
33
+ watch(() => props.modelValue, (val) => {
34
+ isChecked.value = val === props.trueValue
35
+ }, {
36
+ immediate: true
37
+ })
38
+
39
+ watch(isChecked, (val) => {
40
+ if (val) {
41
+ emit('update:modelValue', props.trueValue)
42
+ emit('change', props.trueValue)
43
+ } else {
44
+ emit('update:modelValue', props.falseValue)
45
+ emit('change', props.falseValue)
46
+ }
47
+ })
48
+ </script>
49
+ <style lang="scss" scoped>
50
+ .bge-switch {
51
+ width: 38px;
52
+ height: 20px;
53
+ border-radius: 999px;
54
+ background-color: var(--separator-separator);
55
+ transition: background-color .3s;
56
+ position: relative;
57
+ cursor: pointer;
58
+
59
+ &::after {
60
+ content: "";
61
+ position: absolute;
62
+ top: 2px;
63
+ left: 2px;
64
+ border-radius: 100%;
65
+ transition: all .3s;
66
+ width: 16px;
67
+ height: 16px;
68
+ background-color: var(--tc-secondary);
69
+ }
70
+
71
+ &.checked {
72
+ background: var(--tc-theme);
73
+
74
+ &::after {
75
+ left: 20px;
76
+ background-color: var(--tc-icon-opposite);
77
+ }
78
+ }
79
+ }
80
+ </style>