@solar-taro/ui-sun 0.0.0 → 1.0.1
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/accordion/index.vue.d.ts +25 -0
- package/chip/index.vue.d.ts +45 -0
- package/fab/fab-group.vue.d.ts +23 -0
- package/fab/fab.vue.d.ts +11 -0
- package/index.js +485 -0
- package/lazy-render/index.vue.d.ts +43 -0
- package/navbar/index.vue.d.ts +12 -0
- package/package.json +1 -1
- package/popover/index.vue.d.ts +92 -0
- package/segment/injection.d.ts +8 -0
- package/segment/segment-btn.vue.d.ts +24 -0
- package/segment/segment.vue.d.ts +36 -0
- package/spinner/index.vue.d.ts +26 -0
- package/sudoku/sudoku-item.vue.d.ts +11 -0
- package/sudoku/sudoku.vue.d.ts +25 -0
- package/table/table-cell.vue.d.ts +36 -0
- package/table/table-row.vue.d.ts +26 -0
- package/table/table.vue.d.ts +53 -0
- package/virtual-scroll/index.vue.d.ts +70 -0
- package/CHANGELOG.md +0 -3
- package/eslint.config.cjs +0 -22
- package/project.json +0 -28
- package/shims-vue.d.ts +0 -5
- package/src/accordion/index.vue +0 -27
- package/src/chip/index.vue +0 -27
- package/src/fab/fab-group.vue +0 -17
- package/src/fab/fab.vue +0 -5
- package/src/lazy-render/index.vue +0 -38
- package/src/navbar/index.vue +0 -26
- package/src/popover/index.vue +0 -56
- package/src/segment/injection.ts +0 -8
- package/src/segment/segment-btn.vue +0 -28
- package/src/segment/segment.vue +0 -86
- package/src/spinner/index.vue +0 -26
- package/src/sudoku/sudoku-item.vue +0 -5
- package/src/sudoku/sudoku.vue +0 -23
- package/src/table/table-cell.vue +0 -26
- package/src/table/table-row.vue +0 -12
- package/src/table/table.vue +0 -39
- package/src/virtual-scroll/index.vue +0 -138
- package/tsconfig.json +0 -21
- package/tsconfig.lib.json +0 -26
- package/tsconfig.spec.json +0 -28
- package/vite.config.ts +0 -130
- /package/{src/_color.scss → _color.scss} +0 -0
- /package/{src/_sun.scss → _sun.scss} +0 -0
- /package/{src/_wx.scss → _wx.scss} +0 -0
- /package/{src/accordion/index.ts → accordion/index.d.ts} +0 -0
- /package/{src/accordion → accordion}/index.scss +0 -0
- /package/{src/chip/index.ts → chip/index.d.ts} +0 -0
- /package/{src/chip → chip}/index.scss +0 -0
- /package/{src/fab/index.ts → fab/index.d.ts} +0 -0
- /package/{src/fab → fab}/index.scss +0 -0
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/index.scss → index.scss} +0 -0
- /package/{src/lazy-render/index.ts → lazy-render/index.d.ts} +0 -0
- /package/{src/navbar/index.ts → navbar/index.d.ts} +0 -0
- /package/{src/navbar → navbar}/index.scss +0 -0
- /package/{src/popover/index.ts → popover/index.d.ts} +0 -0
- /package/{src/popover → popover}/index.scss +0 -0
- /package/{src/segment/index.ts → segment/index.d.ts} +0 -0
- /package/{src/segment → segment}/index.scss +0 -0
- /package/{src/spinner/index.ts → spinner/index.d.ts} +0 -0
- /package/{src/spinner → spinner}/index.scss +0 -0
- /package/{src/sudoku/index.ts → sudoku/index.d.ts} +0 -0
- /package/{src/sudoku → sudoku}/index.scss +0 -0
- /package/{src/table → table}/_table-cell.scss +0 -0
- /package/{src/table → table}/_table-row.scss +0 -0
- /package/{src/table → table}/_table.scss +0 -0
- /package/{src/table/index.ts → table/index.d.ts} +0 -0
- /package/{src/table → table}/index.scss +0 -0
- /package/{src/virtual-scroll/index.ts → virtual-scroll/index.d.ts} +0 -0
- /package/{src/virtual-scroll → virtual-scroll}/index.scss +0 -0
package/src/popover/index.vue
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
class="sun-popover"
|
|
4
|
-
:class="[{ 'sun-popover-show': show }, `sun-popover-x-${x}`, `sun-popover-y-${y}`]"
|
|
5
|
-
:style="{ '--popover-x-offset': offsetX, '--popover-y-offset': offsetY, '--popover-background': bg } as any"
|
|
6
|
-
@tap.stop="false">
|
|
7
|
-
<view class="sun-popover-trigger">
|
|
8
|
-
<slot></slot>
|
|
9
|
-
</view>
|
|
10
|
-
|
|
11
|
-
<view v-bind="$attrs" class="sun-popover-container" :style="{ color: color }">
|
|
12
|
-
<view class="sun-popover-arrow"></view>
|
|
13
|
-
<slot name="content"></slot>
|
|
14
|
-
</view>
|
|
15
|
-
</view>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script lang="ts" setup>
|
|
19
|
-
defineProps({
|
|
20
|
-
/** 是否显示 */
|
|
21
|
-
show: {
|
|
22
|
-
type: Boolean,
|
|
23
|
-
default: undefined,
|
|
24
|
-
},
|
|
25
|
-
/** popover的横轴位置:left,right,start,end,center */
|
|
26
|
-
x: {
|
|
27
|
-
type: String,
|
|
28
|
-
default: 'left'
|
|
29
|
-
},
|
|
30
|
-
/** popover的纵轴位置:top,bottom,start,end,center */
|
|
31
|
-
y: {
|
|
32
|
-
type: String,
|
|
33
|
-
default: 'center'
|
|
34
|
-
},
|
|
35
|
-
/** 横轴偏移度 */
|
|
36
|
-
offsetX: {
|
|
37
|
-
type: String,
|
|
38
|
-
default: '7.5rpx'
|
|
39
|
-
},
|
|
40
|
-
/** 纵轴偏移度 */
|
|
41
|
-
offsetY: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: '7.5rpx'
|
|
44
|
-
},
|
|
45
|
-
/** popover背景 */
|
|
46
|
-
bg: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: '#fff'
|
|
49
|
-
},
|
|
50
|
-
/** popover文字颜色 */
|
|
51
|
-
color: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: '#000'
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
</script>
|
package/src/segment/injection.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ComponentInternalInstance, InjectionKey, Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
export const ACTIVE_CHILD = Symbol() as InjectionKey<Ref<ComponentInternalInstance>>;
|
|
4
|
-
export const PARENT = Symbol() as InjectionKey<{
|
|
5
|
-
link(child: ComponentInternalInstance): void;
|
|
6
|
-
unlink(child: ComponentInternalInstance): void;
|
|
7
|
-
active(child: ComponentInternalInstance): void;
|
|
8
|
-
}>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
v-bind="$attrs"
|
|
4
|
-
class="sun-segment-btn"
|
|
5
|
-
:class="{ 'sun-segment-btn-active': activeChild?.props['value'] === value }"
|
|
6
|
-
@tap="parent.active(instance)">
|
|
7
|
-
<slot></slot>
|
|
8
|
-
</view>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script lang="ts" setup>
|
|
12
|
-
import { getCurrentInstance, inject, onUnmounted } from 'vue';
|
|
13
|
-
import { ACTIVE_CHILD, PARENT } from './injection';
|
|
14
|
-
|
|
15
|
-
defineProps<{
|
|
16
|
-
value: unknown
|
|
17
|
-
}>();
|
|
18
|
-
|
|
19
|
-
const activeChild = inject(ACTIVE_CHILD)!;
|
|
20
|
-
const parent = inject(PARENT)!;
|
|
21
|
-
const instance = getCurrentInstance()!;
|
|
22
|
-
|
|
23
|
-
onUnmounted(() => {
|
|
24
|
-
parent.unlink(instance);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
parent.link(instance);
|
|
28
|
-
</script>
|
package/src/segment/segment.vue
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view v-bind="$attrs" class="sun-segment" :style="style">
|
|
3
|
-
<view class="sun-segment-inner">
|
|
4
|
-
<slot></slot>
|
|
5
|
-
</view>
|
|
6
|
-
</view>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script lang="ts" setup>
|
|
10
|
-
import { ComponentInternalInstance, computed, getCurrentInstance, onMounted, provide, shallowReactive, shallowRef, VNode, watch } from 'vue';
|
|
11
|
-
import { ACTIVE_CHILD, PARENT } from './injection';
|
|
12
|
-
|
|
13
|
-
const emit = defineEmits<{
|
|
14
|
-
(e: 'update:modelValue', v: unknown): void;
|
|
15
|
-
(e: 'change', v: { value: unknown, index: number }): void;
|
|
16
|
-
}>();
|
|
17
|
-
|
|
18
|
-
const props = defineProps<{
|
|
19
|
-
modelValue: unknown
|
|
20
|
-
}>();
|
|
21
|
-
|
|
22
|
-
const instance = getCurrentInstance()!;
|
|
23
|
-
|
|
24
|
-
const activeChild = shallowRef(null as unknown as ComponentInternalInstance);
|
|
25
|
-
const children = shallowReactive<ComponentInternalInstance[]>([]);
|
|
26
|
-
|
|
27
|
-
const activeIndex = computed(() => children.indexOf(activeChild.value));
|
|
28
|
-
const childrenLength = computed(() => children.length);
|
|
29
|
-
const style = computed(() => ({
|
|
30
|
-
'--segment-length': childrenLength.value,
|
|
31
|
-
'--segment-active-index': activeIndex.value
|
|
32
|
-
}))
|
|
33
|
-
|
|
34
|
-
provide(ACTIVE_CHILD, activeChild);
|
|
35
|
-
provide(PARENT, {
|
|
36
|
-
link: (child: ComponentInternalInstance) => {
|
|
37
|
-
const vnodes = getChildVnodes();
|
|
38
|
-
|
|
39
|
-
children.push(child);
|
|
40
|
-
children.sort((a, b) => {
|
|
41
|
-
const indexA = vnodes.indexOf(a.vnode);
|
|
42
|
-
const indexB = vnodes.indexOf(b.vnode);
|
|
43
|
-
return indexA - indexB;
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
unlink: (child: ComponentInternalInstance) => {
|
|
47
|
-
children.slice(children.indexOf(child), 1);
|
|
48
|
-
},
|
|
49
|
-
active: (child: ComponentInternalInstance) => {
|
|
50
|
-
emit('change', {
|
|
51
|
-
value: child.props['value'],
|
|
52
|
-
index: activeIndex.value
|
|
53
|
-
});
|
|
54
|
-
emit('update:modelValue', child.props['value']);
|
|
55
|
-
activeChild.value = child;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
watch(() => props.modelValue, value => {
|
|
60
|
-
activeChild.value = children.find(o => o.props['value'] === value)!;
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
function getChildVnodes(): VNode[] {
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
return instance
|
|
66
|
-
.subTree
|
|
67
|
-
.children[0]
|
|
68
|
-
.children[0]
|
|
69
|
-
.children
|
|
70
|
-
.filter((vnode: VNode) => typeof vnode.type !== 'symbol');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
onMounted(() => {
|
|
74
|
-
const vnodes = getChildVnodes();
|
|
75
|
-
|
|
76
|
-
children.forEach(child => {
|
|
77
|
-
const index = vnodes.findIndex(o => o === child.vnode);
|
|
78
|
-
|
|
79
|
-
child.props['value'] ??= index;
|
|
80
|
-
|
|
81
|
-
if (child.props['value'] === props.modelValue) {
|
|
82
|
-
activeChild.value = child;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
</script>
|
package/src/spinner/index.vue
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="sun-spinner" :class="className">
|
|
3
|
-
<view class="sun-spinner-dot">
|
|
4
|
-
<view v-for="o of 4" :key="o" class="sun-spinner-dot-item"></view>
|
|
5
|
-
</view>
|
|
6
|
-
<view v-if="$slots['default']" class="sun-spinner-desc">
|
|
7
|
-
<slot></slot>
|
|
8
|
-
</view>
|
|
9
|
-
</view>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script lang="ts" setup>
|
|
13
|
-
import { computed } from 'vue';
|
|
14
|
-
|
|
15
|
-
const props = defineProps<{
|
|
16
|
-
size?: 'small' | 'middle' | 'default' | 'large';
|
|
17
|
-
spinning?: boolean;
|
|
18
|
-
}>();
|
|
19
|
-
|
|
20
|
-
const className = computed(() => [
|
|
21
|
-
{
|
|
22
|
-
'sun-spinner-spinning': props.spinning,
|
|
23
|
-
},
|
|
24
|
-
`sun-spinner-${props.size}`
|
|
25
|
-
]);
|
|
26
|
-
</script>
|
package/src/sudoku/sudoku.vue
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view v-bind="$attrs" class="sun-sudoku" :class="classes" :style="{ '--sudoku-width': size }">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { computed } from 'vue';
|
|
9
|
-
|
|
10
|
-
const props = defineProps({
|
|
11
|
-
size: String,
|
|
12
|
-
count: {
|
|
13
|
-
type: Number,
|
|
14
|
-
default: 9
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const classes = computed(() => ({
|
|
19
|
-
'sun-sudoku-sm': props.count === 1,
|
|
20
|
-
'sun-sudoku-md': props.count === 2 || props.count === 4,
|
|
21
|
-
'sun-sudoku-lg': props.count === 3 || props.count > 4,
|
|
22
|
-
}))
|
|
23
|
-
</script>
|
package/src/table/table-cell.vue
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view v-bind="$attrs" class="sun-tb-cell" :class="cls" :style="{ width: width, 'min-width': width, 'max-width': maxWidth }">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { computed } from 'vue';
|
|
9
|
-
|
|
10
|
-
const props = defineProps<{
|
|
11
|
-
sticky?: 'left' | 'right',
|
|
12
|
-
width?: string,
|
|
13
|
-
maxWidth?: string,
|
|
14
|
-
/** 溢出省略 */
|
|
15
|
-
ellipsis?: boolean,
|
|
16
|
-
/** 文本换行 */
|
|
17
|
-
breakWord?: boolean
|
|
18
|
-
}>();
|
|
19
|
-
|
|
20
|
-
const cls = computed(() => ({
|
|
21
|
-
'sun-tb-cell-sticky-left': props.sticky === 'left',
|
|
22
|
-
'sun-tb-cell-sticky-right': props.sticky === 'right',
|
|
23
|
-
'sun-tb-cell-ellipsis': props.ellipsis,
|
|
24
|
-
'sun-tb-cell-break-word': props.breakWord,
|
|
25
|
-
}));
|
|
26
|
-
</script>
|
package/src/table/table-row.vue
DELETED
package/src/table/table.vue
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view v-bind="$attrs" class="sun-tb" :class="tableClass">
|
|
3
|
-
<view class="sun-tb-inner" :class="tableInnerClass">
|
|
4
|
-
<slot></slot>
|
|
5
|
-
</view>
|
|
6
|
-
</view>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script lang="ts" setup>
|
|
10
|
-
import { computed } from 'vue';
|
|
11
|
-
|
|
12
|
-
const props = withDefaults(
|
|
13
|
-
defineProps<{
|
|
14
|
-
rounded?: boolean,
|
|
15
|
-
bordered?: boolean,
|
|
16
|
-
outerBordered?: boolean,
|
|
17
|
-
/** 斑马风格 */
|
|
18
|
-
zebra?: boolean
|
|
19
|
-
size?: 'small' | 'medium' | 'default',
|
|
20
|
-
layout?: 'auto' | 'fixed'
|
|
21
|
-
}>(),
|
|
22
|
-
{
|
|
23
|
-
rounded: true,
|
|
24
|
-
outerBordered: true
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const tableClass = computed(() => ({
|
|
29
|
-
'sun-tb-rounded': props.rounded,
|
|
30
|
-
'sun-tb-bordered': props.bordered,
|
|
31
|
-
'sun-tb-outer-bordered': props.outerBordered,
|
|
32
|
-
[`sun-tb-size-${props.size}`]: props.size,
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
const tableInnerClass = computed(() => ({
|
|
36
|
-
'sun-tb-zebra': props.zebra,
|
|
37
|
-
[`sun-tb-layout-${props.layout}`]: props.layout
|
|
38
|
-
}));
|
|
39
|
-
</script>
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<scroll-view
|
|
3
|
-
v-bind="$attrs"
|
|
4
|
-
:id="id"
|
|
5
|
-
class="sun-virtual-scroll"
|
|
6
|
-
:refresher-enabled="refresher"
|
|
7
|
-
:refresher-triggered="refreshing"
|
|
8
|
-
:refresher-background="refresherBg"
|
|
9
|
-
:scroll-x="!isVertical"
|
|
10
|
-
:scroll-y="isVertical"
|
|
11
|
-
:enhanced="true"
|
|
12
|
-
:enable-passive="true"
|
|
13
|
-
:lower-threshold="300"
|
|
14
|
-
@scroll.passive="onScroll($event)"
|
|
15
|
-
@refresherrefresh="vibrator.short('light'); emit('refresh')"
|
|
16
|
-
@scrolltolower="emit('lower')">
|
|
17
|
-
<view class="sun-virtual-scroll-content-container" :style="contentContainerStyle">
|
|
18
|
-
<view
|
|
19
|
-
v-for="(item, index) in visibleItems"
|
|
20
|
-
:key="(item as any)[itemKey!] ?? index"
|
|
21
|
-
class="sun-virtual-scroll-item"
|
|
22
|
-
:style="itemStyle">
|
|
23
|
-
<slot :item="item" :index="index"></slot>
|
|
24
|
-
</view>
|
|
25
|
-
</view>
|
|
26
|
-
|
|
27
|
-
<view class="sun-virtual-scroll-spacer" :style="spacerStyle"></view>
|
|
28
|
-
</scroll-view>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script lang="ts">
|
|
32
|
-
let nextId = 1;
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<script lang="ts" setup>
|
|
36
|
-
import { withPixel } from '@solar-kit/core';
|
|
37
|
-
import { rpxToPx, vibrator } from '@solar-taro/core';
|
|
38
|
-
import { createSelectorQuery, NodesRef } from '@tarojs/taro';
|
|
39
|
-
import { computed, CSSProperties, onMounted, ref } from 'vue';
|
|
40
|
-
|
|
41
|
-
const emit = defineEmits<{
|
|
42
|
-
(e: 'refresh'): void;
|
|
43
|
-
(e: 'lower'): void;
|
|
44
|
-
}>();
|
|
45
|
-
|
|
46
|
-
const props = withDefaults(
|
|
47
|
-
defineProps<{
|
|
48
|
-
refreshing?: boolean;
|
|
49
|
-
refresher?: boolean;
|
|
50
|
-
refresherBg?: string;
|
|
51
|
-
direction?: 'vertical' | 'horizontal';
|
|
52
|
-
items: Record<string, any>[];
|
|
53
|
-
itemSize: number | string;
|
|
54
|
-
itemKey?: string;
|
|
55
|
-
id?: string;
|
|
56
|
-
bottomSpace?: number;
|
|
57
|
-
}>(),
|
|
58
|
-
{
|
|
59
|
-
refresherBg: 'transparent',
|
|
60
|
-
direction: 'vertical',
|
|
61
|
-
id: () => `sun-virtual-scroll-${nextId++}`,
|
|
62
|
-
bottomSpace: 0
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
let rafId: number;
|
|
67
|
-
|
|
68
|
-
const visibleItemCount = ref(0);
|
|
69
|
-
const startIndex = ref(0);
|
|
70
|
-
const startOffset = ref(0);
|
|
71
|
-
|
|
72
|
-
const isVertical = computed(() => props.direction === 'vertical');
|
|
73
|
-
const contentContainerStyle = computed<CSSProperties>(() => ({
|
|
74
|
-
right: isVertical.value ? '0' : 'auto',
|
|
75
|
-
transform: `translate${isVertical.value ? 'Y' : 'X'}(${startOffset.value}px)`,
|
|
76
|
-
'white-space': isVertical.value ? 'normal' : 'nowrap'
|
|
77
|
-
}));
|
|
78
|
-
const itemSizePx = computed(() => {
|
|
79
|
-
if (typeof props.itemSize === 'number') {
|
|
80
|
-
return props.itemSize;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (props.itemSize.endsWith('rpx')) {
|
|
84
|
-
return rpxToPx(parseFloat(props.itemSize));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return parseFloat(props.itemSize)
|
|
88
|
-
})
|
|
89
|
-
const spacerSize = computed(() => itemSizePx.value * props.items!.length);
|
|
90
|
-
const spacerStyle = computed(() => ({
|
|
91
|
-
[isVertical.value ? 'height' : 'width']: withPixel(spacerSize.value + props.bottomSpace)
|
|
92
|
-
}));
|
|
93
|
-
const itemStyle = computed(() => ({
|
|
94
|
-
display: isVertical.value ? 'block' : 'inline-block',
|
|
95
|
-
[isVertical.value ? 'height' : 'width']: withPixel(itemSizePx.value)
|
|
96
|
-
}))
|
|
97
|
-
const visibleItems = computed(() =>
|
|
98
|
-
props.items!.slice(
|
|
99
|
-
Math.max(startIndex.value - visibleItemCount.value, 0),
|
|
100
|
-
startIndex.value + visibleItemCount.value * 2
|
|
101
|
-
)
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
function onScroll({ detail }: any) {
|
|
105
|
-
rafId && cancelAnimationFrame(rafId);
|
|
106
|
-
rafId = requestAnimationFrame(() => {
|
|
107
|
-
const scrollDistance = isVertical.value ? detail.scrollTop : detail.scrollLeft;
|
|
108
|
-
startIndex.value = ~~(scrollDistance / itemSizePx.value);
|
|
109
|
-
|
|
110
|
-
if (startIndex.value > visibleItemCount.value - 1) {
|
|
111
|
-
startOffset.value = scrollDistance - (itemSizePx.value * visibleItemCount.value) - (scrollDistance % itemSizePx.value);
|
|
112
|
-
} else {
|
|
113
|
-
startOffset.value = scrollDistance - (scrollDistance % (itemSizePx.value * visibleItemCount.value));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
rafId = 0;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function initViewport() {
|
|
121
|
-
setTimeout(() => {
|
|
122
|
-
createSelectorQuery().select(`#${props.id}`).boundingClientRect(result => {
|
|
123
|
-
// 如果获取不到节点信息,重新初始化
|
|
124
|
-
if (!result) {
|
|
125
|
-
return initViewport()
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const { height, width } = result as NodesRef.BoundingClientRectCallbackResult;
|
|
129
|
-
const viewportSize = isVertical.value ? height : width;
|
|
130
|
-
visibleItemCount.value = Math.ceil(viewportSize / itemSizePx.value);
|
|
131
|
-
}).exec();
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
onMounted(() => {
|
|
136
|
-
initViewport();
|
|
137
|
-
});
|
|
138
|
-
</script>
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"forceConsistentCasingInFileNames": true,
|
|
5
|
-
"strict": true,
|
|
6
|
-
"noImplicitOverride": true,
|
|
7
|
-
"noImplicitReturns": true,
|
|
8
|
-
"noFallthroughCasesInSwitch": true,
|
|
9
|
-
"noPropertyAccessFromIndexSignature": true
|
|
10
|
-
},
|
|
11
|
-
"files": [],
|
|
12
|
-
"include": [],
|
|
13
|
-
"references": [
|
|
14
|
-
{
|
|
15
|
-
"path": "./tsconfig.lib.json"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"path": "./tsconfig.spec.json"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"declaration": true
|
|
6
|
-
},
|
|
7
|
-
"include": [
|
|
8
|
-
"src/**/*.ts",
|
|
9
|
-
"index.ts",
|
|
10
|
-
"index.ts"
|
|
11
|
-
],
|
|
12
|
-
"exclude": [
|
|
13
|
-
"vite.config.ts",
|
|
14
|
-
"vite.config.mts",
|
|
15
|
-
"vitest.config.ts",
|
|
16
|
-
"vitest.config.mts",
|
|
17
|
-
"src/**/*.test.ts",
|
|
18
|
-
"src/**/*.spec.ts",
|
|
19
|
-
"src/**/*.test.tsx",
|
|
20
|
-
"src/**/*.spec.tsx",
|
|
21
|
-
"src/**/*.test.js",
|
|
22
|
-
"src/**/*.spec.js",
|
|
23
|
-
"src/**/*.test.jsx",
|
|
24
|
-
"src/**/*.spec.jsx"
|
|
25
|
-
]
|
|
26
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"types": [
|
|
6
|
-
"vitest/globals",
|
|
7
|
-
"vitest/importMeta",
|
|
8
|
-
"vite/client",
|
|
9
|
-
"node",
|
|
10
|
-
"vitest"
|
|
11
|
-
]
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"vite.config.ts",
|
|
15
|
-
"vite.config.mts",
|
|
16
|
-
"vitest.config.ts",
|
|
17
|
-
"vitest.config.mts",
|
|
18
|
-
"src/**/*.test.ts",
|
|
19
|
-
"src/**/*.spec.ts",
|
|
20
|
-
"src/**/*.test.tsx",
|
|
21
|
-
"src/**/*.spec.tsx",
|
|
22
|
-
"src/**/*.test.js",
|
|
23
|
-
"src/**/*.spec.js",
|
|
24
|
-
"src/**/*.test.jsx",
|
|
25
|
-
"src/**/*.spec.jsx",
|
|
26
|
-
"src/**/*.d.ts"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/// <reference types='vitest' />
|
|
2
|
-
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
|
|
3
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
4
|
-
import vue from '@vitejs/plugin-vue';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { defineConfig } from 'vite';
|
|
7
|
-
import dts from 'vite-plugin-dts';
|
|
8
|
-
|
|
9
|
-
export default defineConfig({
|
|
10
|
-
root: __dirname,
|
|
11
|
-
cacheDir: '../../node_modules/.vite/ui-sun',
|
|
12
|
-
plugins: [
|
|
13
|
-
nxViteTsPaths(),
|
|
14
|
-
nxCopyAssetsPlugin(['*.md']),
|
|
15
|
-
dts({
|
|
16
|
-
entryRoot: 'src',
|
|
17
|
-
include: ['src'],
|
|
18
|
-
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
19
|
-
copyDtsFiles: true,
|
|
20
|
-
}),
|
|
21
|
-
vue({
|
|
22
|
-
template: {
|
|
23
|
-
transformAssetUrls: {
|
|
24
|
-
video: ['src', 'poster'],
|
|
25
|
-
'live-player': ['src'],
|
|
26
|
-
audio: ['src'],
|
|
27
|
-
source: ['src'],
|
|
28
|
-
image: ['src'],
|
|
29
|
-
'cover-image': ['src']
|
|
30
|
-
},
|
|
31
|
-
compilerOptions: {
|
|
32
|
-
mode: 'module',
|
|
33
|
-
optimizeImports: true,
|
|
34
|
-
isNativeTag: tag => {
|
|
35
|
-
return [
|
|
36
|
-
'slot-view',
|
|
37
|
-
'view',
|
|
38
|
-
'scroll-view',
|
|
39
|
-
'swiper',
|
|
40
|
-
'cover-view',
|
|
41
|
-
'cover-image',
|
|
42
|
-
'icon',
|
|
43
|
-
'text',
|
|
44
|
-
'rich-text',
|
|
45
|
-
'progress',
|
|
46
|
-
'button',
|
|
47
|
-
'checkbox',
|
|
48
|
-
'form',
|
|
49
|
-
'input',
|
|
50
|
-
'label',
|
|
51
|
-
'picker',
|
|
52
|
-
'picker-view',
|
|
53
|
-
'picker-view-column',
|
|
54
|
-
'radio',
|
|
55
|
-
'radio-group',
|
|
56
|
-
'checkbox-group',
|
|
57
|
-
'slider',
|
|
58
|
-
'switch',
|
|
59
|
-
'textarea',
|
|
60
|
-
'navigator',
|
|
61
|
-
'audio',
|
|
62
|
-
'image',
|
|
63
|
-
'video',
|
|
64
|
-
'camera',
|
|
65
|
-
'live-player',
|
|
66
|
-
'live-pusher',
|
|
67
|
-
'map',
|
|
68
|
-
'canvas',
|
|
69
|
-
'open-data',
|
|
70
|
-
'web-view',
|
|
71
|
-
'swiper-item',
|
|
72
|
-
'movable-area',
|
|
73
|
-
'movable-view',
|
|
74
|
-
'functional-page-navigator',
|
|
75
|
-
'ad',
|
|
76
|
-
'block',
|
|
77
|
-
'import',
|
|
78
|
-
'official-account',
|
|
79
|
-
'editor'
|
|
80
|
-
].some(o => o === tag) || tag.startsWith('van-')
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
],
|
|
86
|
-
// Uncomment this if you are using workers.
|
|
87
|
-
// worker: {
|
|
88
|
-
// plugins: [ nxViteTsPaths() ],
|
|
89
|
-
// },
|
|
90
|
-
// Configuration for building your library.
|
|
91
|
-
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
92
|
-
build: {
|
|
93
|
-
target: 'es2019',
|
|
94
|
-
outDir: '../../dist/ui-sun',
|
|
95
|
-
emptyOutDir: true,
|
|
96
|
-
reportCompressedSize: true,
|
|
97
|
-
lib: {
|
|
98
|
-
// Could also be a dictionary or array of multiple entry points.
|
|
99
|
-
entry: 'src/index.ts',
|
|
100
|
-
name: 'ui-sun',
|
|
101
|
-
fileName: 'index',
|
|
102
|
-
// Change this to the formats you want to support.
|
|
103
|
-
// Don't forget to update your package.json as well.
|
|
104
|
-
formats: ['es'],
|
|
105
|
-
},
|
|
106
|
-
rollupOptions: {
|
|
107
|
-
// External packages that should not be bundled into your library.
|
|
108
|
-
external: [
|
|
109
|
-
'vue',
|
|
110
|
-
'rxjs',
|
|
111
|
-
/@tarojs.+/,
|
|
112
|
-
/@ngify.+/,
|
|
113
|
-
/@opper.+/,
|
|
114
|
-
/@solar-kit.+/,
|
|
115
|
-
/@solar-taro.+/,
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
test: {
|
|
120
|
-
watch: false,
|
|
121
|
-
globals: true,
|
|
122
|
-
environment: 'node',
|
|
123
|
-
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
124
|
-
reporters: ['default'],
|
|
125
|
-
coverage: {
|
|
126
|
-
reportsDirectory: '../../coverage/ui-sun',
|
|
127
|
-
provider: 'v8',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|