looseleaf-uni 0.1.0 → 0.2.0
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/attributes.json +4 -0
- package/lib/CHANGELOG.md +12 -0
- package/lib/common/theme.ts +3 -3
- package/lib/components/ll-attachment/ll-attachment.vue +6 -2
- package/lib/components/ll-avatar/ll-avatar.vue +8 -1
- package/lib/components/ll-badge/ll-badge.vue +6 -1
- package/lib/components/ll-button/button.ts +43 -42
- package/lib/components/ll-button/ll-button.vue +99 -91
- package/lib/components/ll-checkbox/ll-checkbox.vue +70 -54
- package/lib/components/ll-dialog/ll-dialog.vue +160 -159
- package/lib/components/ll-icon/ll-icon.vue +41 -37
- package/lib/components/ll-input/ll-input.vue +73 -73
- package/lib/components/ll-input-otp/ll-input-otp.vue +73 -60
- package/lib/components/ll-progress/ll-progress.vue +12 -2
- package/lib/components/ll-radio-group/ll-radio-group.vue +25 -0
- package/lib/components/ll-ribbon/ll-ribbon.vue +10 -3
- package/lib/components/ll-slider/ll-slider.vue +25 -1
- package/lib/components/ll-switch/ll-switch.vue +40 -0
- package/lib/components/ll-textarea/ll-textarea.vue +31 -26
- package/package.json +1 -1
- package/tags.json +1 -0
- package/web-types.json +10 -1
|
@@ -1,60 +1,73 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, ref } from 'vue'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
|
+
import { useLooseleafTheme } from '../../common/theme'
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(defineProps<{ modelValue: string; maxLength?: number; separatorAfter?: number[]; disabled?: boolean; invalid?: boolean; label?: string }>(), { maxLength: 6, separatorAfter: () => [] })
|
|
6
|
+
const emit = defineEmits<{ 'update:modelValue': [value: string]; complete: [value: string] }>()
|
|
7
|
+
const theme = useLooseleafTheme()
|
|
8
|
+
const focused = ref(false)
|
|
9
|
+
const positions = computed(() => Array.from({ length: props.maxLength }, (_, index) => index))
|
|
10
|
+
function update(event: unknown) {
|
|
11
|
+
// 微信事件不实现 DOM Event,统一读取原生输入的 detail.value。
|
|
12
|
+
const raw = (event as { detail: { value: string } }).detail.value
|
|
13
|
+
const value = raw.replace(/[\s‐-―-]+/g, '').slice(0, props.maxLength)
|
|
14
|
+
emit('update:modelValue', value)
|
|
15
|
+
if (value.length === props.maxLength && props.modelValue.length !== props.maxLength) emit('complete', value)
|
|
16
|
+
return value
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<view
|
|
22
|
+
class="ll-otp"
|
|
23
|
+
:style="{
|
|
24
|
+
color: theme.ink,
|
|
25
|
+
'--ll-otp-paper': theme.slip,
|
|
26
|
+
'--ll-otp-edge': theme.muted,
|
|
27
|
+
'--ll-otp-focus': theme.primary,
|
|
28
|
+
'--ll-otp-error': theme.destructive,
|
|
29
|
+
}"
|
|
30
|
+
>
|
|
31
|
+
<view
|
|
32
|
+
v-for="position in positions"
|
|
33
|
+
:key="position"
|
|
34
|
+
class="ll-otp__unit"
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
>
|
|
37
|
+
<text
|
|
38
|
+
class="ll-otp__slot"
|
|
39
|
+
:class="{ 'll-otp__slot--focus': focused && position === modelValue.length, 'll-otp__slot--invalid': invalid }"
|
|
40
|
+
>
|
|
41
|
+
{{ modelValue[position] }}
|
|
42
|
+
</text>
|
|
43
|
+
<text
|
|
44
|
+
v-if="separatorAfter.includes(position)"
|
|
45
|
+
class="ll-otp__separator"
|
|
46
|
+
>
|
|
47
|
+
−
|
|
48
|
+
</text>
|
|
49
|
+
</view>
|
|
50
|
+
<input
|
|
51
|
+
class="ll-otp__input"
|
|
52
|
+
:aria-label="label"
|
|
53
|
+
:aria-invalid="invalid"
|
|
54
|
+
:disabled="disabled"
|
|
55
|
+
:value="modelValue"
|
|
56
|
+
:maxlength="-1"
|
|
57
|
+
@input="update"
|
|
58
|
+
@focus="focused = true"
|
|
59
|
+
@blur="focused = false"
|
|
60
|
+
>
|
|
61
|
+
</view>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<style scoped>
|
|
65
|
+
.ll-otp { display: inline-flex; position: relative; gap: 4px; }
|
|
66
|
+
.ll-otp__unit { display: inline-flex; align-items: center; }
|
|
67
|
+
.ll-otp__slot { display: inline-flex; width: 29px; height: 34px; align-items: center; justify-content: center; border: 1px dashed var(--ll-otp-edge); border-radius: 3px 5px 3px 4px; background: var(--ll-otp-paper); }
|
|
68
|
+
/* 焦点继承主色,错误仍由危险色边框标记。 */
|
|
69
|
+
.ll-otp__slot--focus { outline: 2px solid var(--ll-otp-focus); outline-offset: 1px; }
|
|
70
|
+
.ll-otp__slot--invalid { border-color: var(--ll-otp-error); }
|
|
71
|
+
.ll-otp__separator { margin: 0 3px; }
|
|
72
|
+
.ll-otp__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .01; color: transparent; font-size: 16px; }
|
|
73
|
+
</style>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
+
import { useLooseleafTheme } from '../../common/theme'
|
|
4
|
+
|
|
3
5
|
const props = withDefaults(defineProps<{ value?: number; max?: number; size?: 'sm' | 'default' | 'lg'; ariaLabel?: string }>(), { max: 100, size: 'default' })
|
|
6
|
+
const theme = useLooseleafTheme()
|
|
4
7
|
// 进度的比例会限制在轨道内,零值仍显示已确定的空轨道。
|
|
5
8
|
const percent = computed(() => props.value === undefined ? undefined : Math.min(props.max, Math.max(0, props.value)) / props.max * 100)
|
|
6
9
|
</script>
|
|
@@ -9,6 +12,7 @@ const percent = computed(() => props.value === undefined ? undefined : Math.min(
|
|
|
9
12
|
<view
|
|
10
13
|
class="ll-progress"
|
|
11
14
|
:class="'ll-progress--' + size"
|
|
15
|
+
:style="{ '--ll-progress-paper': theme.slip, '--ll-progress-edge': theme.muted, '--ll-progress-fill': theme.primary }"
|
|
12
16
|
role="progressbar"
|
|
13
17
|
:aria-label="ariaLabel"
|
|
14
18
|
:aria-valuemin="0"
|
|
@@ -28,10 +32,16 @@ const percent = computed(() => props.value === undefined ? undefined : Math.min(
|
|
|
28
32
|
</template>
|
|
29
33
|
|
|
30
34
|
<style scoped>
|
|
31
|
-
|
|
35
|
+
/* 已知进度和加载动画共用同一层记号笔填色。 */
|
|
36
|
+
.ll-progress { position: relative; overflow: hidden; height: 9px; border: 1px solid var(--ll-progress-edge); border-radius: 5px 4px 5px 3px; background: var(--ll-progress-paper); }
|
|
32
37
|
.ll-progress--sm { height: 5px; }
|
|
33
38
|
.ll-progress--lg { height: 16px; }
|
|
34
|
-
.ll-progress__ink {
|
|
39
|
+
.ll-progress__ink {
|
|
40
|
+
height: 100%;
|
|
41
|
+
background-color: var(--ll-progress-fill);
|
|
42
|
+
background-image: repeating-linear-gradient(101deg, transparent 0 6px, rgb(255 255 255 / 14%) 7px 8px);
|
|
43
|
+
border-radius: 4px 6px 3px 4px;
|
|
44
|
+
}
|
|
35
45
|
.ll-progress__ink--moving { width: 33%; animation: ll-progress-slip 1.35s ease-in-out infinite alternate; }
|
|
36
46
|
@keyframes ll-progress-slip { to { transform: translateX(200%); } }
|
|
37
47
|
@media (prefers-reduced-motion: reduce) { .ll-progress__ink--moving { animation: none; } }
|
|
@@ -16,6 +16,7 @@ function update(event: unknown) {
|
|
|
16
16
|
<radio-group
|
|
17
17
|
class="ll-radio-group"
|
|
18
18
|
:class="'ll-radio-group--' + orientation"
|
|
19
|
+
:style="{ '--ll-radio-paper': theme.slip, '--ll-radio-ink': theme.ink, '--ll-radio-fill': theme.primary, '--ll-radio-muted': theme.muted }"
|
|
19
20
|
:aria-label="label"
|
|
20
21
|
@change="update"
|
|
21
22
|
>
|
|
@@ -41,4 +42,28 @@ function update(event: unknown) {
|
|
|
41
42
|
.ll-radio-group--vertical { flex-direction: column; align-items: flex-start; }
|
|
42
43
|
.ll-radio-group--horizontal { flex-wrap: wrap; }
|
|
43
44
|
.ll-radio-group__entry { display: inline-flex; align-items: center; gap: 6px; }
|
|
45
|
+
|
|
46
|
+
/* #ifdef H5 */
|
|
47
|
+
/* 原生单选仅在选中时插入图标,用它的位置绘制橙色墨点,保持分组和重置行为。 */
|
|
48
|
+
.ll-radio-group :deep(.uni-radio-input) {
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
width: 20px;
|
|
51
|
+
height: 20px;
|
|
52
|
+
margin-right: 0;
|
|
53
|
+
border: 0;
|
|
54
|
+
border-radius: 49% 52% 47% 51%;
|
|
55
|
+
background-color: var(--ll-radio-paper) !important;
|
|
56
|
+
box-shadow: inset 0 0 0 1.5px var(--ll-radio-ink);
|
|
57
|
+
}
|
|
58
|
+
.ll-radio-group :deep(.uni-radio-input > svg) {
|
|
59
|
+
width: 12px;
|
|
60
|
+
height: 11px;
|
|
61
|
+
transform: translate(-50%, -50%) rotate(-8deg);
|
|
62
|
+
border-radius: 53% 47% 51% 49%;
|
|
63
|
+
background-color: var(--ll-radio-fill);
|
|
64
|
+
}
|
|
65
|
+
.ll-radio-group :deep(.uni-radio-input > svg path) { opacity: 0; }
|
|
66
|
+
.ll-radio-group :deep(.uni-radio-input-disabled) { opacity: .55; }
|
|
67
|
+
.ll-radio-group :deep(.uni-radio-input-disabled > svg) { background-color: var(--ll-radio-muted); }
|
|
68
|
+
/* #endif */
|
|
44
69
|
</style>
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
3
|
+
import { useLooseleafTheme } from '../../common/theme'
|
|
4
|
+
|
|
5
|
+
const tones = { tangerine: '#edaa76', lemon: '#f1db75', grass: '#aec881', teal: '#93c8bf', sky: '#9cc7dd', bubblegum: '#e6adc3' }
|
|
6
|
+
const props = withDefaults(defineProps<{ variant?: 'banner' | 'swallow' | 'flag'; tone?: keyof typeof tones | 'marker' | 'hi' | 'paper'; size?: 'sm' | 'default' | 'lg' }>(), { variant: 'banner', tone: 'marker', size: 'default' })
|
|
7
|
+
const theme = useLooseleafTheme()
|
|
8
|
+
// 默认记号笔、荧光笔和纸色沿用主题,具名颜料仍有各自的色样。
|
|
9
|
+
const style = computed(() => ({
|
|
10
|
+
color: props.tone === 'marker' ? theme.value.onPrimary : theme.value.ink,
|
|
11
|
+
backgroundColor: { ...tones, marker: theme.value.primary, hi: theme.value.highlight, paper: theme.value.paper }[props.tone],
|
|
12
|
+
}))
|
|
6
13
|
</script>
|
|
7
14
|
|
|
8
15
|
<template>
|
|
@@ -12,6 +12,9 @@ function valueFrom(event: unknown) {
|
|
|
12
12
|
|
|
13
13
|
<template>
|
|
14
14
|
<slider
|
|
15
|
+
class="ll-slider"
|
|
16
|
+
:class="{ 'll-slider--disabled': disabled }"
|
|
17
|
+
:style="{ '--ll-slider-ink': theme.ink }"
|
|
15
18
|
:aria-label="label"
|
|
16
19
|
:value="modelValue"
|
|
17
20
|
:min="min"
|
|
@@ -20,9 +23,30 @@ function valueFrom(event: unknown) {
|
|
|
20
23
|
:disabled="disabled"
|
|
21
24
|
:show-value="showValue"
|
|
22
25
|
:active-color="theme.primary"
|
|
23
|
-
:background-color="theme.
|
|
26
|
+
:background-color="theme.slip"
|
|
27
|
+
:block-color="theme.slip"
|
|
24
28
|
:block-size="18"
|
|
25
29
|
@changing="emit('changing', valueFrom($event))"
|
|
26
30
|
@change="emit('update:modelValue', valueFrom($event))"
|
|
27
31
|
/>
|
|
28
32
|
</template>
|
|
33
|
+
|
|
34
|
+
<style scoped>
|
|
35
|
+
/* #ifdef H5 */
|
|
36
|
+
/* 只绘制纸底、墨线和滑块外观,拖拽热区和数值换算交给端侧组件。 */
|
|
37
|
+
.ll-slider :deep(.uni-slider-handle-wrapper) {
|
|
38
|
+
height: 5px;
|
|
39
|
+
border-radius: 4px 2px 4px 3px;
|
|
40
|
+
box-shadow: 0 0 0 1px var(--ll-slider-ink);
|
|
41
|
+
}
|
|
42
|
+
.ll-slider :deep(.uni-slider-track) {
|
|
43
|
+
border-radius: 4px 3px 2px 4px;
|
|
44
|
+
background-image: repeating-linear-gradient(101deg, transparent 0 5px, rgb(255 255 255 / 14%) 6px 7px);
|
|
45
|
+
}
|
|
46
|
+
.ll-slider :deep(.uni-slider-thumb) {
|
|
47
|
+
border-radius: 49% 52% 47% 51%;
|
|
48
|
+
box-shadow: inset 0 0 0 1.5px var(--ll-slider-ink);
|
|
49
|
+
}
|
|
50
|
+
.ll-slider--disabled { opacity: .55; }
|
|
51
|
+
/* #endif */
|
|
52
|
+
</style>
|
|
@@ -11,11 +11,51 @@ function change(event: unknown) {
|
|
|
11
11
|
|
|
12
12
|
<template>
|
|
13
13
|
<switch
|
|
14
|
+
class="ll-switch"
|
|
14
15
|
:checked="modelValue"
|
|
15
16
|
:disabled="disabled"
|
|
16
17
|
:aria-label="ariaLabel"
|
|
17
18
|
:name="name"
|
|
18
19
|
:color="theme.primary"
|
|
20
|
+
:style="{ '--ll-switch-ink': theme.ink, '--ll-switch-paper': theme.slip }"
|
|
19
21
|
@change="change"
|
|
20
22
|
/>
|
|
21
23
|
</template>
|
|
24
|
+
|
|
25
|
+
<style scoped>
|
|
26
|
+
/* #ifdef H5 */
|
|
27
|
+
/* 只改 H5 原生开关的绘制,沿用组件自己的勾选类以同步表单重置。 */
|
|
28
|
+
.ll-switch {
|
|
29
|
+
padding: 4px;
|
|
30
|
+
vertical-align: middle;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ll-switch :deep(.uni-switch-input) {
|
|
34
|
+
width: 44px;
|
|
35
|
+
height: 24px;
|
|
36
|
+
margin-right: 0;
|
|
37
|
+
border: 0;
|
|
38
|
+
border-radius: 12px 13px 12px 11px / 11px 11px 12px 12px;
|
|
39
|
+
background-color: var(--ll-switch-paper);
|
|
40
|
+
background-image: radial-gradient(rgb(42 36 32 / 12%) .4px, transparent .75px);
|
|
41
|
+
background-size: 3px 3px;
|
|
42
|
+
box-shadow: inset 0 0 0 1.5px var(--ll-switch-ink);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ll-switch :deep(.uni-switch-input::before) {
|
|
46
|
+
content: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ll-switch :deep(.uni-switch-input::after) {
|
|
50
|
+
top: 4px;
|
|
51
|
+
left: 4px;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
width: 16px;
|
|
54
|
+
height: 16px;
|
|
55
|
+
border: 1.5px solid var(--ll-switch-ink);
|
|
56
|
+
border-radius: 49% 52% 47% 51%;
|
|
57
|
+
background-color: var(--ll-switch-paper);
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
}
|
|
60
|
+
/* #endif */
|
|
61
|
+
</style>
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useLooseleafTheme } from '../../common/theme'
|
|
3
|
+
|
|
4
|
+
withDefaults(defineProps<{ modelValue: string; placeholder?: string; maxlength?: number; autoHeight?: boolean; disabled?: boolean; ariaLabel?: string }>(), { maxlength: 140 })
|
|
5
|
+
const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
|
6
|
+
const theme = useLooseleafTheme()
|
|
7
|
+
function update(event: unknown) {
|
|
8
|
+
// 微信事件不实现 DOM Event,多行输入仍通过 detail.value 读值。
|
|
9
|
+
emit('update:modelValue', (event as { detail: { value: string } }).detail.value)
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<textarea
|
|
15
|
+
class="ll-textarea"
|
|
16
|
+
:style="{ color: theme.ink, backgroundColor: theme.slip, '--ll-textarea-edge': theme.muted, '--ll-textarea-focus': theme.primary }"
|
|
17
|
+
:value="modelValue"
|
|
18
|
+
:placeholder="placeholder"
|
|
19
|
+
:auto-height="autoHeight"
|
|
20
|
+
:maxlength="maxlength"
|
|
21
|
+
:disabled="disabled"
|
|
22
|
+
:aria-label="ariaLabel"
|
|
23
|
+
@input="update"
|
|
24
|
+
/>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style scoped>
|
|
28
|
+
/* 多行输入和单行输入使用相同的纸底与焦点墨色。 */
|
|
29
|
+
.ll-textarea { box-sizing: border-box; display: block; width: 100%; min-height: 80px; padding: 10px 12px; border: 1px solid var(--ll-textarea-edge); border-radius: 5px 3px 5px 3px; font: inherit; }
|
|
30
|
+
.ll-textarea:focus-within { outline: 2px dashed var(--ll-textarea-focus); outline-offset: 2px; }
|
|
31
|
+
</style>
|
package/package.json
CHANGED
package/tags.json
CHANGED
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
|
|
3
3
|
"name": "looseleaf-uni",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"elements": [
|
|
@@ -27,6 +27,15 @@
|
|
|
27
27
|
"default": "default"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
+
{
|
|
31
|
+
"name": "block",
|
|
32
|
+
"description": "铺满容器宽度",
|
|
33
|
+
"value": {
|
|
34
|
+
"kind": "expression",
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"default": "false"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
30
39
|
{
|
|
31
40
|
"name": "disabled",
|
|
32
41
|
"description": "禁止激活",
|