bge-ui 1.2.4 → 1.2.6

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.
@@ -0,0 +1,37 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
+ disabled: BooleanConstructor;
3
+ placeholder: {
4
+ type: StringConstructor;
5
+ default: string;
6
+ };
7
+ modelValue: (StringConstructor | NumberConstructor)[];
8
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ input: (...args: any[]) => void;
10
+ change: (...args: any[]) => void;
11
+ "update:modelValue": (...args: any[]) => void;
12
+ clear: (...args: any[]) => void;
13
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
14
+ disabled: BooleanConstructor;
15
+ placeholder: {
16
+ type: StringConstructor;
17
+ default: string;
18
+ };
19
+ modelValue: (StringConstructor | NumberConstructor)[];
20
+ }>> & {
21
+ onChange?: ((...args: any[]) => any) | undefined;
22
+ onInput?: ((...args: any[]) => any) | undefined;
23
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
24
+ onClear?: ((...args: any[]) => any) | undefined;
25
+ }, {
26
+ disabled: boolean;
27
+ placeholder: string;
28
+ }, {}>, {
29
+ label?(_: {}): any;
30
+ default?(_: {}): any;
31
+ }>;
32
+ export default _default;
33
+ type __VLS_WithTemplateSlots<T, S> = T & {
34
+ new (): {
35
+ $slots: S;
36
+ };
37
+ };
@@ -0,0 +1,15 @@
1
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
+ label: StringConstructor;
3
+ value: (StringConstructor | NumberConstructor)[];
4
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
5
+ label: StringConstructor;
6
+ value: (StringConstructor | NumberConstructor)[];
7
+ }>>, {}, {}>, {
8
+ default?(_: {}): any;
9
+ }>;
10
+ export default _default;
11
+ type __VLS_WithTemplateSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };
package/dist/style.css CHANGED
@@ -738,7 +738,8 @@ to {
738
738
  vertical-align: middle;
739
739
  margin-right: 32px;
740
740
  }
741
- .bge-form .bge-form-item__content.error .bge-input__wrapper {
741
+ .bge-form .bge-form-item__content.error .bge-input__wrapper,
742
+ .bge-form .bge-form-item__content.error .bge-select__wrapper {
742
743
  border: 1px solid var(--tc-red, #FF477E);
743
744
  background-color: var(--bg-red-08, rgba(255, 82, 133, 0.08));
744
745
  }.bge-form {
@@ -1435,7 +1436,7 @@ to {
1435
1436
  display: flex;
1436
1437
  align-items: center;
1437
1438
  cursor: pointer;
1438
- padding: 7px 16px;
1439
+ padding: 15px 2px;
1439
1440
  }
1440
1441
  .bge-slider.mark {
1441
1442
  margin-bottom: 32px;
@@ -1459,7 +1460,7 @@ to {
1459
1460
  height: 14px;
1460
1461
  width: 14px;
1461
1462
  position: absolute;
1462
- z-index: 100;
1463
+ z-index: 2;
1463
1464
  top: -6px;
1464
1465
  transform: translateX(-50%);
1465
1466
  background-color: transparent;
@@ -1553,4 +1554,83 @@ to {
1553
1554
  }
1554
1555
  .bge-slider .bge-slider__runway .bge-slider__stops.bge-slider__stop-10 .bge-slider__stop:nth-child(-n+11) {
1555
1556
  background: var(--bg-slider-selected, #4F5C71);
1557
+ }.bge-select {
1558
+ position: relative;
1559
+ vertical-align: middle;
1560
+ --bg-input: var(--bg-opacity);
1561
+ --bg-input-hover: var(--bg-opacity-hover);
1562
+ }
1563
+ .bge-select .bge-select__wrapper {
1564
+ height: 40px;
1565
+ padding: var(--layout-x-0, 0px) var(--layout-x-4, 16px);
1566
+ border-radius: var(--radius-small, 4px);
1567
+ border: 1px solid transparent;
1568
+ background: var(--bg-input, rgba(88, 126, 163, 0.08));
1569
+ display: flex;
1570
+ font-size: 14px;
1571
+ align-items: center;
1572
+ align-self: stretch;
1573
+ }
1574
+ .bge-select .bge-select__wrapper .bge-select__inner {
1575
+ display: flex;
1576
+ align-items: center;
1577
+ justify-content: space-between;
1578
+ width: 100%;
1579
+ }
1580
+ .bge-select .bge-select__wrapper .arrow-down {
1581
+ font-size: 20px;
1582
+ width: 20px;
1583
+ color: var(--tc-tertiary);
1584
+ }
1585
+ .bge-select .bge-select__wrapper:hover {
1586
+ border: 1px solid transparent;
1587
+ background: var(--bg-input-hover, rgba(88, 126, 163, 0.12));
1588
+ }
1589
+ .bge-select .bge-select__wrapper.disabled:hover {
1590
+ border: 1px solid transparent;
1591
+ background: var(--bg-input, rgba(88, 126, 163, 0.08));
1592
+ }
1593
+ .bge-select .bge-select__wrapper.disabled:hover .arrow-down {
1594
+ font-size: 20px;
1595
+ width: 20px;
1596
+ color: var(--tc-tertiary);
1597
+ }
1598
+ .bge-select .bge-select__wrapper .placeholder {
1599
+ color: var(--tc-quaternary);
1600
+ font-size: 14px;
1601
+ line-height: 24px;
1602
+ font-weight: 500;
1603
+ }
1604
+ .bge-select .bge-select__wrapper.focus {
1605
+ border: 1px solid var(--tc-theme, #292D33);
1606
+ background: transparent;
1607
+ }
1608
+ .bge-select .bge-select__wrapper.focus .arrow-down {
1609
+ font-size: 20px;
1610
+ width: 20px;
1611
+ color: var(--tc-title);
1612
+ }
1613
+ .bge-select .bge-select__wrapper:hover .bge-select__suffix .bge-select__suffix-inner .clear, .bge-select .bge-select__wrapper.focus .bge-select__suffix .bge-select__suffix-inner .clear {
1614
+ display: block;
1615
+ }
1616
+ .bge-select .bge-popper-wrapper {
1617
+ min-width: 120px;
1618
+ width: 100%;
1619
+ }
1620
+ .bge-select .bge-popper-wrapper .popper-content {
1621
+ max-width: unset;
1622
+ width: 100%;
1623
+ }.bge-option[data-v-8a6e1228] {
1624
+ padding: 8px 24px;
1625
+ color: var(--tc-secondary);
1626
+ font-size: 14px;
1627
+ font-weight: 500;
1628
+ line-height: 24px;
1629
+ }
1630
+ .bge-option[data-v-8a6e1228]:hover {
1631
+ background: var(--bg-opacity);
1632
+ color: var(--tc-title);
1633
+ }
1634
+ .bge-option.active[data-v-8a6e1228] {
1635
+ color: var(--tc-title);
1556
1636
  }
@@ -1,5 +1,5 @@
1
1
  import type { PropType } from 'vue';
2
- import type { PositioningStrategy, Placement, Modifier } from '@popperjs/core';
2
+ import type { PositioningStrategy, Placement } from '@popperjs/core';
3
3
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
4
4
  /**
5
5
  * title
@@ -87,13 +87,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
87
87
  type: PropType<Placement>;
88
88
  default: string;
89
89
  };
90
- /**
91
- * Set the modifiers of the popper
92
- */
93
- modifiers: {
94
- type: PropType<Modifier<any, any>[]>;
95
- default: () => never[];
96
- };
97
90
  /**
98
91
  * Set the type of animation
99
92
  *
@@ -206,13 +199,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
206
199
  type: PropType<Placement>;
207
200
  default: string;
208
201
  };
209
- /**
210
- * Set the modifiers of the popper
211
- */
212
- modifiers: {
213
- type: PropType<Modifier<any, any>[]>;
214
- default: () => never[];
215
- };
216
202
  /**
217
203
  * Set the type of animation
218
204
  *
@@ -239,7 +225,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
239
225
  type: string;
240
226
  title: string;
241
227
  teleported: boolean;
242
- modifiers: Modifier<any, any>[];
243
228
  animation: string;
244
229
  animationDuration: number | unknown[];
245
230
  placement: Placement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bge-ui",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -108,7 +108,8 @@ defineExpose({
108
108
 
109
109
  .bge-form-item__content {
110
110
  &.error {
111
- .bge-input__wrapper {
111
+ .bge-input__wrapper,
112
+ .bge-select__wrapper {
112
113
  border: 1px solid var(--tc-red, #FF477E);
113
114
  background-color: var(--bg-red-08, rgba(#ff5285, 0.08));
114
115
  }
package/src/index.ts CHANGED
@@ -13,7 +13,8 @@ import UiDialog from "./dialog/index.vue"
13
13
  import UiCheckbox from "./checkBox/index.vue"
14
14
  import UiRadio from "./radio/index.vue"
15
15
  import UiSlider from "./slider/index.vue"
16
-
16
+ import UiSelect from "./select/index.vue"
17
+ import UiOption from "./select/option.vue"
17
18
  const components: any = {
18
19
  UiButton,
19
20
  UiLink,
@@ -26,7 +27,9 @@ const components: any = {
26
27
  UiDialog,
27
28
  UiCheckbox,
28
29
  UiRadio,
29
- UiSlider
30
+ UiSlider,
31
+ UiSelect,
32
+ UiOption
30
33
  }
31
34
 
32
35
  export * from './icons/index.ts'
@@ -44,7 +47,9 @@ export {
44
47
  UiMessage,
45
48
  UiCheckbox,
46
49
  UiRadio,
47
- UiSlider
50
+ UiSlider,
51
+ UiSelect,
52
+ UiOption
48
53
  }
49
54
 
50
55
  export default {
@@ -81,8 +81,6 @@ function handleBlur() {
81
81
  watch(() => props.modelValue, (val) => {
82
82
  input.value = val
83
83
  formItemContext && formItemContext.validate && formItemContext.validate().catch((err: any) => (err))
84
- }, {
85
- immediate: true
86
84
  })
87
85
 
88
86
  function handleChange() {
@@ -1,3 +1,183 @@
1
1
  <template>
2
- <div></div>
3
- </template>
2
+ <div
3
+ ref="selectRef"
4
+ class="bge-select"
5
+ @click="isFocus = !isFocus"
6
+ >
7
+ <ui-tooltip
8
+ ref="tooltipRef"
9
+ placement="bottom"
10
+ class="bge-select-popper-wrapper"
11
+ :teleported="false"
12
+ :show-arrow="false"
13
+ type="dropdown"
14
+ :hover="false"
15
+ >
16
+ <div class="bge-select__wrapper" :class="{ focus: isFocus, disabled: disabled }">
17
+ <div class="bge-select__inner">
18
+ <div class="bge-select__current">
19
+ <slot v-if="labelSlot" name="label">
20
+ </slot>
21
+ <template v-else-if="!!modelValue">
22
+ {{ optionsMap[modelValue] }}
23
+ </template>
24
+ <span class="placeholder" v-else>{{ placeholder }}</span>
25
+ </div>
26
+ <MonoArrowDown class="arrow-down" />
27
+ </div>
28
+ </div>
29
+ <template #content>
30
+ <slot name="default"></slot>
31
+ </template>
32
+ </ui-tooltip>
33
+ </div>
34
+ </template>
35
+
36
+ <script lang="ts" setup>
37
+ import { useSlots, ref, provide, reactive, computed, toRef, inject } from 'vue'
38
+ import UiTooltip from '../tooltip/index.vue'
39
+ import MonoArrowDown from '../icons/MonoArrowDown.vue'
40
+ const isFocus = ref(false)
41
+ const tooltipRef = ref()
42
+ const labelSlot = useSlots().label
43
+ const props = defineProps({
44
+ disabled: Boolean,
45
+ placeholder: {
46
+ type: String,
47
+ default: '请选择'
48
+ },
49
+ modelValue: [String, Number]
50
+ })
51
+
52
+ const formItemContextKey = 'bge-form-item-context'
53
+
54
+ const formItemContext: any = inject(formItemContextKey, undefined)
55
+
56
+ function changeValue(value: string|number) {
57
+ emits('change', value)
58
+ emits('input', value)
59
+ emits('update:modelValue', value)
60
+ formItemContext && formItemContext.validate && formItemContext.validate().catch((err: any) => (err))
61
+ tooltipRef.value.toggleTooltip()
62
+ }
63
+
64
+ const options = ref<any>([])
65
+ const optionsMap: any = computed(() => {
66
+ const result: any = {}
67
+ options.value.forEach((v: any) => {
68
+ result[v.value] = v.label
69
+ })
70
+ return result
71
+ })
72
+ function addOption(option: any) {
73
+ options.value.push(option)
74
+ }
75
+
76
+
77
+ const context: any = reactive({
78
+ changeValue,
79
+ addOption,
80
+ modelValue: toRef(props, 'modelValue')
81
+ })
82
+
83
+ provide('bge-select-context', context)
84
+
85
+ const emits = defineEmits([
86
+ 'update:modelValue',
87
+ 'change',
88
+ 'input',
89
+ 'clear',
90
+ ])
91
+ </script>
92
+ <style lang="scss">
93
+ .bge-select {
94
+ position: relative;
95
+ vertical-align: middle;
96
+
97
+ --bg-input: var(--bg-opacity);
98
+ --bg-input-hover: var(--bg-opacity-hover);
99
+
100
+ .bge-select__wrapper {
101
+ height: 40px;
102
+ padding: var(--layout-x-0, 0px) var(--layout-x-4, 16px);
103
+ border-radius: var(--radius-small, 4px);
104
+ border: 1px solid transparent;
105
+ background: var(--bg-input, rgba(88, 126, 163, 0.08));
106
+ display: flex;
107
+ font-size: 14px;
108
+ align-items: center;
109
+ align-self: stretch;
110
+
111
+ .bge-select__inner {
112
+ display: flex;
113
+ align-items: center;
114
+ justify-content: space-between;
115
+ width: 100%;
116
+ }
117
+
118
+ .arrow-down {
119
+ font-size: 20px;
120
+ width: 20px;
121
+ color: var(--tc-tertiary);
122
+ }
123
+
124
+ &:hover {
125
+ border: 1px solid transparent;
126
+ background: var(--bg-input-hover, rgba(88, 126, 163, 0.12));
127
+ }
128
+
129
+ &.disabled {
130
+ &:hover {
131
+ border: 1px solid transparent;
132
+ background: var(--bg-input, rgba(88, 126, 163, 0.08));
133
+
134
+
135
+ .arrow-down {
136
+ font-size: 20px;
137
+ width: 20px;
138
+ color: var(--tc-tertiary);
139
+ }
140
+ }
141
+ }
142
+
143
+ .placeholder {
144
+ color: var(--tc-quaternary);
145
+ font-size: 14px;
146
+ line-height: 24px;
147
+ font-weight: 500;
148
+ }
149
+
150
+ &.focus {
151
+ border: 1px solid var(--tc-theme, #292D33);
152
+ background: transparent;
153
+
154
+
155
+ .arrow-down {
156
+ font-size: 20px;
157
+ width: 20px;
158
+ color: var(--tc-title);
159
+ }
160
+ }
161
+
162
+ &:hover,
163
+ &.focus {
164
+ .bge-select__suffix {
165
+ .bge-select__suffix-inner{
166
+ .clear {
167
+ display: block;
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ .bge-popper-wrapper {
175
+ min-width: 120px;
176
+ width: 100%;
177
+ .popper-content {
178
+ max-width: unset;
179
+ width: 100%;
180
+ }
181
+ }
182
+ }
183
+ </style>
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div class="bge-option" :class="{active: value === context.modelValue}" @click="context.changeValue(value)">
3
+ <slot v-if="defaultSlot" name="default"></slot>
4
+ <template v-else>{{ props.label }}</template>
5
+ </div>
6
+ </template>
7
+ <script lang="ts" setup>
8
+ import { useSlots, inject, onMounted } from 'vue'
9
+ const defaultSlot = useSlots().default
10
+
11
+ const props = defineProps({
12
+ label: String,
13
+ value: [Number, String]
14
+ })
15
+
16
+ const context: any = inject('bge-select-context', undefined)
17
+
18
+ onMounted(() => {
19
+ context.addOption({
20
+ ...props
21
+ })
22
+ })
23
+ </script>
24
+ <style lang="scss" scoped>
25
+ .bge-option {
26
+ padding: 8px 24px;
27
+ color: var(--tc-secondary);
28
+ font-size: 14px;
29
+ font-weight: 500;
30
+ line-height: 24px;
31
+ &:hover {
32
+ background: var(--bg-opacity);
33
+ color: var(--tc-title);
34
+ }
35
+
36
+ &.active {
37
+ color: var(--tc-title);
38
+ }
39
+ }
40
+ </style>
@@ -171,7 +171,7 @@ watch(() => props.modelValue, (val: number) => {
171
171
  display: flex;
172
172
  align-items: center;
173
173
  cursor: pointer;
174
- padding: 7px 16px;
174
+ padding: 15px 2px;
175
175
 
176
176
  &.mark {
177
177
  margin-bottom: 32px;
@@ -197,7 +197,7 @@ watch(() => props.modelValue, (val: number) => {
197
197
  height: 14px;
198
198
  width: 14px;
199
199
  position: absolute;
200
- z-index: 100;
200
+ z-index: 2;
201
201
  top: -6px;
202
202
  transform: translateX(-50%);
203
203
  background-color: transparent;
@@ -26,7 +26,7 @@
26
26
  import { OnlyChild as UiOnlyChild } from './only-child'
27
27
  import type { PropType } from 'vue'
28
28
  import { computed, ref, onMounted, onBeforeMount, nextTick } from 'vue';
29
- import type { PositioningStrategy, Placement, Modifier } from '@popperjs/core'
29
+ import type { PositioningStrategy, Placement } from '@popperjs/core'
30
30
  import UiDialog from '../dialog/index.vue'
31
31
  import UiButton from '../button/index.vue'
32
32
  import { usePopper } from './usePopper'
@@ -142,16 +142,6 @@ const props = defineProps({
142
142
  default: 'top',
143
143
  },
144
144
 
145
- /**
146
- * Set the modifiers of the popper
147
- */
148
- modifiers: {
149
- type: Array as PropType<Modifier<any, any>[]>,
150
- default: () => {
151
- return [];
152
- },
153
- },
154
-
155
145
  /**
156
146
  * Set the type of animation
157
147
  *
@@ -222,7 +212,6 @@ function initTooltip() {
222
212
  closeDelay: props.closeDelay,
223
213
  showArrow: props.showArrow,
224
214
  strategy: props.strategy,
225
- modifiers: props.modifiers,
226
215
  animation: props.animation,
227
216
  placement: props.placement,
228
217
  interactive: props.interactive,
@@ -170,9 +170,10 @@ const usePopper = function (triggerReference, suppliedOptions: Options = {}) {
170
170
  */
171
171
  const getPopperOptions = computed(() => {
172
172
  let { modifiers } = popperDefaultOptions;
173
- if (options.modifiers) {
174
- modifiers = [...modifiers, ...options.modifiers];
175
- }
173
+ if (options.showArrow === false) {
174
+ modifiers[0].options.offset = [0, 8]
175
+ }
176
+ modifiers = [...modifiers]
176
177
 
177
178
  return {
178
179
  ...popperDefaultOptions,