hy-app 0.2.4 → 0.2.5

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.
@@ -24,6 +24,22 @@
24
24
  background-color: $hy-icon-color;
25
25
  }
26
26
 
27
+ /* 无边框 */
28
+ &__not {
29
+ background-color: $hy-background--track;
30
+ border-radius: $hy-border-radius-sm;
31
+ &__active {
32
+ &:before {
33
+ content: "";
34
+ background-color: $hy-text-color;
35
+ width: 1.5px;
36
+ border-radius: 2px;
37
+ height: 50%;
38
+ animation: 1s hy-cursor-flicker--2 infinite;
39
+ }
40
+ }
41
+ }
42
+
27
43
  /* 方块模式 */
28
44
  &__box {
29
45
  border-color: $hy-border-color--2;
@@ -93,6 +109,20 @@
93
109
  }
94
110
  }
95
111
 
112
+ /* #ifndef APP-NVUE */
113
+ @keyframes hy-cursor-flicker--2 {
114
+ 0% {
115
+ opacity: 0;
116
+ }
117
+ 50% {
118
+ opacity: 1;
119
+ }
120
+ 100% {
121
+ opacity: 0;
122
+ }
123
+ }
124
+ /* #endif */
125
+
96
126
  /* #ifndef APP-NVUE */
97
127
  @keyframes hy-cursor-flicker {
98
128
  0% {
@@ -105,4 +135,4 @@
105
135
  opacity: 0.2;
106
136
  }
107
137
  }
108
- /* #endif */
138
+ /* #endif */
@@ -1,21 +1,22 @@
1
- import type IProps from "./typing";
1
+ import type IProps from './typing'
2
2
 
3
3
  const defaultProps: IProps = {
4
- modelValue: "",
4
+ modelValue: '',
5
5
  adjustPosition: true,
6
6
  maxlength: 6,
7
+ border: true,
7
8
  dot: false,
8
- mode: "box",
9
+ mode: 'box',
9
10
  hairline: false,
10
11
  space: 10,
11
12
  focus: false,
12
13
  bold: false,
13
- color: "",
14
+ color: '',
14
15
  fontSize: 18,
15
16
  size: 35,
16
17
  disabledKeyboard: false,
17
- borderColor: "",
18
+ borderColor: '',
18
19
  disabledDot: true,
19
- };
20
+ }
20
21
 
21
- export default defaultProps;
22
+ export default defaultProps
@@ -1,65 +1,69 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
3
  export default interface HyCodeInputProps {
4
- modelValue: string | number;
4
+ modelValue: string | number
5
5
  /**
6
6
  * @description 键盘弹起时,是否自动上推页面(默认 true )
7
7
  * */
8
- adjustPosition?: boolean;
8
+ adjustPosition?: boolean
9
9
  /**
10
10
  * @description 最大输入长度(默认 6 )
11
11
  * */
12
- maxlength?: number;
12
+ maxlength?: number
13
+ /**
14
+ * @description 显示border
15
+ * */
16
+ border?: boolean
13
17
  /**
14
18
  * @description 是否用圆点填充(默认 false )
15
19
  * */
16
- dot?: boolean;
20
+ dot?: boolean
17
21
  /**
18
22
  * @description 显示模式,box-盒子模式,line-底部横线模式 (默认 'box' )
19
23
  * */
20
- mode?: "box" | string;
24
+ mode?: 'box' | string
21
25
  /**
22
26
  * @description 是否细边框 (默认 false )
23
27
  * */
24
- hairline?: boolean;
28
+ hairline?: boolean
25
29
  /**
26
30
  * @description 字符间的距离 (默认 10 )
27
31
  * */
28
- space?: number;
32
+ space?: number
29
33
  /**
30
34
  * @description 是否自动获取焦点 (默认 false )
31
35
  * */
32
- focus?: boolean;
36
+ focus?: boolean
33
37
  /**
34
38
  * @description 字体是否加粗 (默认 false )
35
39
  * */
36
- bold?: boolean;
40
+ bold?: boolean
37
41
  /**
38
42
  * @description 字体颜色 (默认 '#606266' )
39
43
  * */
40
- color?: string;
44
+ color?: string
41
45
  /**
42
46
  * @description 字体大小,单位px (默认 18 )
43
47
  * */
44
- fontSize?: number;
48
+ fontSize?: number
45
49
  /**
46
50
  * @description 输入框的大小,宽等于高 (默认 35 )
47
51
  * */
48
- size?: number | string;
52
+ size?: number | string
49
53
  /**
50
54
  * @description 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true (默认 false )
51
55
  * */
52
- disabledKeyboard?: boolean;
56
+ disabledKeyboard?: boolean
53
57
  /**
54
58
  * @description 边框和线条颜色 (默认 '#c9cacc' )
55
59
  * */
56
- borderColor?: string;
60
+ borderColor?: string
57
61
  /**
58
62
  * @description 是否禁止输入"."符号 (默认 true )
59
63
  * */
60
- disabledDot?: boolean;
64
+ disabledDot?: boolean
61
65
  /**
62
66
  * @description 定义需要用到的外部样式
63
67
  * */
64
- customStyle?: CSSProperties;
68
+ customStyle?: CSSProperties
65
69
  }
@@ -1,28 +1,28 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
3
  export default interface HyConfigProviderProps {
4
4
  /**
5
5
  * @description dark-暗色、light-亮色
6
6
  * */
7
- theme?: HyApp.DarkModeType;
7
+ theme?: HyApp.DarkModeType
8
8
  /**
9
9
  * @description 主题色(默认 #3c9cff )
10
10
  * */
11
- themeColor?: string;
11
+ themeColor?: string
12
12
  /**
13
13
  * @description 主题色(默认 #ecf5ff )
14
14
  * */
15
- themeLightColor?: string;
15
+ themeLightColor?: string
16
16
  /**
17
17
  * @description 内边距(默认 10px )
18
18
  * */
19
- padding?: string;
19
+ padding?: string
20
20
  /**
21
21
  * @description 定义需要用到的主题类名
22
22
  * */
23
- customClass?: string | string[];
23
+ customClass?: string | string[]
24
24
  /**
25
25
  * @description 定义需要用到的外部样式
26
26
  * */
27
- customStyle?: CSSProperties;
27
+ customStyle?: CSSProperties | CSSProperties[]
28
28
  }
@@ -1,14 +1,12 @@
1
1
  <template>
2
2
  <!-- 标题栏 -->
3
- <view
4
- :class="['hy-dropdown-item__header', isOpen && 'is-active']"
5
- @click="handleClick"
6
- >
3
+ <view :class="['hy-dropdown-item__header', isOpen && 'is-active']" @click="handleClick">
7
4
  <text
8
5
  class="hy-dropdown-item__header--title"
9
6
  :style="{ color: currentColor, fontSize: addUnit(titleSize) }"
10
- >{{ title }}</text
11
7
  >
8
+ {{ title }}
9
+ </text>
12
10
  <HyIcon
13
11
  :custom-style="{
14
12
  transform: isOpen ? 'rotate(-180deg)' : 'rotate(0deg)',
@@ -19,11 +17,7 @@
19
17
  ></HyIcon>
20
18
  </view>
21
19
  <!-- 下拉弹窗 -->
22
- <HyOverlay
23
- :show="isOpen"
24
- :custom-style="{ top: addUnit(dropPopupTop) }"
25
- @click="closePopupFn"
26
- >
20
+ <HyOverlay :show="isOpen" :custom-style="{ top: addUnit(dropPopupTop) }" @click="closePopupFn">
27
21
  <view
28
22
  class="hy-dropdown-item__main"
29
23
  :style="{ top: addUnit(dropPopupTop), height: addUnit(dropHeight) }"
@@ -47,8 +41,9 @@
47
41
  :style="{
48
42
  color: currentIndex === index ? currentColor : inactiveColor,
49
43
  }"
50
- >{{ item.label }}</view
51
44
  >
45
+ {{ item.label }}
46
+ </view>
52
47
  <!-- 勾选图标 -->
53
48
  <HyIcon
54
49
  v-if="currentIndex === index"
@@ -62,91 +57,90 @@
62
57
  </HyOverlay>
63
58
  </template>
64
59
 
60
+ <script lang="ts">
61
+ export default {
62
+ name: 'hy-dropdown-item',
63
+ options: {
64
+ styleIsolation: 'shared',
65
+ },
66
+ }
67
+ </script>
68
+
65
69
  <script setup lang="ts">
66
- import {
67
- computed,
68
- inject,
69
- ref,
70
- onMounted,
71
- watch,
72
- useSlots,
73
- toRefs,
74
- getCurrentInstance,
75
- } from "vue";
76
- import defaultProps from "./props";
77
- import type IProps from "./typing";
78
- import type FatherIProps from "../hy-dropdown/typing";
79
- import type { DropdownMenuItem } from "./typing";
80
- import { addUnit, getRect, throttle } from "../../utils";
81
- import { IconConfig } from "../../config";
70
+ import { computed, inject, ref, onMounted, watch, useSlots, toRefs, getCurrentInstance } from 'vue'
71
+ import defaultProps from './props'
72
+ import type IProps from './typing'
73
+ import type FatherIProps from '../hy-dropdown/typing'
74
+ import type { DropdownMenuItem } from './typing'
75
+ import { addUnit, getRect, throttle } from '../../utils'
76
+ import { IconConfig } from '../../config'
82
77
 
83
- import HyOverlay from "../hy-overlay/hy-overlay.vue";
84
- import HyIcon from "../hy-icon/hy-icon.vue";
78
+ import HyOverlay from '../hy-overlay/hy-overlay.vue'
79
+ import HyIcon from '../hy-icon/hy-icon.vue'
85
80
 
86
- const props = withDefaults(defineProps<IProps>(), defaultProps);
87
- const { modelValue, menus } = toRefs(props);
88
- const emits = defineEmits(["update:modelValue", "change"]);
81
+ const props = withDefaults(defineProps<IProps>(), defaultProps)
82
+ const { modelValue, menus } = toRefs(props)
83
+ const emits = defineEmits(['update:modelValue', 'change'])
89
84
 
90
- const slots = useSlots();
85
+ const slots = useSlots()
91
86
  //是否有插槽
92
87
  const hasSlot = computed(() => {
93
- return Object.keys(slots).length > 0;
94
- });
95
- const instance = getCurrentInstance();
88
+ return Object.keys(slots).length > 0
89
+ })
90
+ const instance = getCurrentInstance()
96
91
  //父的props值
97
- const dropdownProps: FatherIProps | undefined = inject("dropdownProps");
98
- const { titleSize, menuIcon, menuIconSize, inactiveColor } =
99
- dropdownProps as FatherIProps;
92
+ const dropdownProps: FatherIProps | undefined = inject('dropdownProps')
93
+ const { titleSize, menuIcon, menuIconSize, inactiveColor } = dropdownProps as FatherIProps
100
94
  //当前打开的dropItem项(标签名)
101
- const currentDropItem: any = inject("currentDropItem");
95
+ const currentDropItem: any = inject('currentDropItem')
102
96
  //当前文字/箭头颜色
103
97
  const currentColor = computed(() => {
104
- return isOpen.value ? dropdownProps?.activeColor : inactiveColor;
105
- });
98
+ return isOpen.value ? dropdownProps?.activeColor : inactiveColor
99
+ })
106
100
  //是否打开
107
- const isOpen = ref<boolean>(false);
101
+ const isOpen = ref<boolean>(false)
108
102
  //下拉弹窗距离页面顶部距离
109
- const dropPopupTop = ref(0);
103
+ const dropPopupTop = ref(0)
110
104
  //下拉弹窗高度
111
- const dropHeight = ref<string | number>(0);
105
+ const dropHeight = ref<string | number>(0)
112
106
  //下拉选项当前选中的索引
113
- const currentIndex = ref(-1);
107
+ const currentIndex = ref(-1)
114
108
 
115
109
  //动态class
116
- const customClass = computed(() => (isOpen.value ? "visible" : "hidden"));
110
+ const customClass = computed(() => (isOpen.value ? 'visible' : 'hidden'))
117
111
 
118
112
  onMounted(() => {
119
- getDropPopupTop();
120
- });
113
+ getDropPopupTop()
114
+ })
121
115
 
122
116
  /**
123
117
  * @description 计算下拉弹窗区域距离页面顶部距离
124
118
  * */
125
119
  const getDropPopupTop = () => {
126
- getRect(".hy-dropdown-item__header", false, instance).then((rect) => {
127
- const { bottom } = rect as UniApp.NodeInfo;
120
+ getRect('.hy-dropdown-item__header', false, instance).then((rect) => {
121
+ const { bottom } = rect as UniApp.NodeInfo
128
122
  // #ifdef H5
129
123
  //H5需要加上导航栏高度,固定44px
130
- dropPopupTop.value = (bottom || 0) + 44;
124
+ dropPopupTop.value = (bottom || 0) + 44
131
125
  // #endif
132
126
  // #ifndef H5
133
- dropPopupTop.value = bottom || 0;
127
+ dropPopupTop.value = bottom || 0
134
128
  // #endif
135
- });
136
- };
129
+ })
130
+ }
137
131
 
138
132
  watch(isOpen, (v) => {
139
133
  //打开状态显示父容器
140
134
  if (v) {
141
- dropHeight.value = "auto";
135
+ dropHeight.value = 'auto'
142
136
  } else {
143
137
  //关闭状态隐藏父容器
144
138
  //延迟改变使得关闭动画能完整呈现
145
139
  setTimeout(() => {
146
- dropHeight.value = 0;
147
- }, 200);
140
+ dropHeight.value = 0
141
+ }, 200)
148
142
  }
149
- });
143
+ })
150
144
  /**
151
145
  * @description 动态控制开关,
152
146
  * @desc 防止点击展开后在点击下一个,导致上一个没有关闭bug
@@ -156,29 +150,29 @@ watch(
156
150
  (newVal) => {
157
151
  //关闭其他条件的下拉弹窗
158
152
  if (newVal !== props.title) {
159
- isOpen.value = false;
153
+ isOpen.value = false
160
154
  }
161
155
  },
162
- );
156
+ )
163
157
 
164
158
  //根据双向绑定值动态设置下拉选中项索引
165
159
  watch(
166
160
  () => modelValue.value,
167
161
  (newVal) => {
168
- currentIndex.value = menus.value.findIndex((item) => item.value === newVal);
162
+ currentIndex.value = menus.value.findIndex((item) => item.value === newVal)
169
163
  },
170
164
  { immediate: true },
171
- );
165
+ )
172
166
 
173
167
  //选中监听
174
168
  const onSelect = (item: DropdownMenuItem, index: number) => {
175
- isOpen.value = false;
169
+ isOpen.value = false
176
170
  if (index !== currentIndex.value) {
177
- currentIndex.value = index;
178
- emits("update:modelValue", item.value);
179
- emits("change", item.value);
171
+ currentIndex.value = index
172
+ emits('update:modelValue', item.value)
173
+ emits('change', item.value)
180
174
  }
181
- };
175
+ }
182
176
 
183
177
  /**
184
178
  * @description 打开或关闭
@@ -186,24 +180,24 @@ const onSelect = (item: DropdownMenuItem, index: number) => {
186
180
  const handleClick = () =>
187
181
  throttle(() => {
188
182
  //节流处理,防止点击过快动画未结束又切换导致显示bug
189
- isOpen.value = !isOpen.value;
183
+ isOpen.value = !isOpen.value
190
184
  if (isOpen.value) {
191
185
  // 防止点击展开后在点击下一个,导致上一个没有关闭bug
192
- currentDropItem.value = props.title;
193
- getDropPopupTop();
186
+ currentDropItem.value = props.title
187
+ getDropPopupTop()
194
188
  }
195
- });
189
+ })
196
190
 
197
191
  /**
198
192
  * @description 点击遮罩框关闭弹窗
199
193
  * */
200
194
  const closePopupFn = () => {
201
195
  if (dropdownProps?.closeOnClickMask) {
202
- isOpen.value = false;
196
+ isOpen.value = false
203
197
  }
204
- };
198
+ }
205
199
  </script>
206
200
 
207
201
  <style lang="scss" scoped>
208
- @import "./index.scss";
202
+ @import './index.scss';
209
203
  </style>
@@ -109,4 +109,4 @@
109
109
  100% {
110
110
  top: -100%;
111
111
  }
112
- }
112
+ }