svelte-mobile-ui 1.0.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/LICENSE +21 -0
- package/README.md +173 -0
- package/components/ActionBar/ActionBar.svelte +31 -0
- package/components/ActionBar/ActionBarButton.svelte +105 -0
- package/components/ActionBar/ActionBarIcon.svelte +100 -0
- package/components/ActionBar/index.ts +3 -0
- package/components/ActionSheet/ActionSheet.svelte +134 -0
- package/components/ActionSheet/index.ts +1 -0
- package/components/AddressEdit/AddressEdit.svelte +23 -0
- package/components/AddressEdit/index.ts +1 -0
- package/components/AddressList/AddressList.svelte +23 -0
- package/components/AddressList/index.ts +1 -0
- package/components/Area/Area.svelte +23 -0
- package/components/Area/index.ts +1 -0
- package/components/BackTop/BackTop.svelte +23 -0
- package/components/BackTop/index.ts +1 -0
- package/components/Badge/Badge.svelte +90 -0
- package/components/Badge/index.ts +1 -0
- package/components/Barrage/Barrage.svelte +23 -0
- package/components/Barrage/index.ts +1 -0
- package/components/Button/Button.svelte +297 -0
- package/components/Button/index.ts +1 -0
- package/components/Calendar/Calendar.svelte +23 -0
- package/components/Calendar/index.ts +1 -0
- package/components/Card/Card.svelte +23 -0
- package/components/Card/index.ts +1 -0
- package/components/Cascader/Cascader.svelte +23 -0
- package/components/Cascader/index.ts +1 -0
- package/components/Cell/Cell.svelte +155 -0
- package/components/Cell/index.ts +1 -0
- package/components/CellGroup/CellGroup.svelte +47 -0
- package/components/CellGroup/index.ts +1 -0
- package/components/Checkbox/Checkbox.svelte +128 -0
- package/components/Checkbox/index.ts +1 -0
- package/components/CheckboxGroup/CheckboxGroup.svelte +36 -0
- package/components/CheckboxGroup/index.ts +1 -0
- package/components/Circle/Circle.svelte +23 -0
- package/components/Circle/index.ts +1 -0
- package/components/Col/Col.svelte +23 -0
- package/components/Col/index.ts +1 -0
- package/components/Collapse/Collapse.svelte +25 -0
- package/components/Collapse/CollapseItem.svelte +102 -0
- package/components/Collapse/index.ts +2 -0
- package/components/ConfigProvider/ConfigProvider.svelte +23 -0
- package/components/ConfigProvider/index.ts +1 -0
- package/components/ContactCard/ContactCard.svelte +23 -0
- package/components/ContactCard/index.ts +1 -0
- package/components/ContactEdit/ContactEdit.svelte +207 -0
- package/components/ContactEdit/index.ts +1 -0
- package/components/ContactList/ContactList.svelte +143 -0
- package/components/ContactList/index.ts +1 -0
- package/components/CountDown/CountDown.svelte +23 -0
- package/components/CountDown/index.ts +1 -0
- package/components/Coupon/Coupon.svelte +23 -0
- package/components/Coupon/CouponCell.svelte +130 -0
- package/components/Coupon/CouponList.svelte +225 -0
- package/components/Coupon/index.ts +3 -0
- package/components/DatePicker/DatePicker.svelte +23 -0
- package/components/DatePicker/index.ts +1 -0
- package/components/Dialog/Dialog.svelte +141 -0
- package/components/Dialog/index.ts +1 -0
- package/components/Divider/Divider.svelte +61 -0
- package/components/Divider/index.ts +1 -0
- package/components/DropdownMenu/DropdownItem.svelte +131 -0
- package/components/DropdownMenu/DropdownMenu.svelte +23 -0
- package/components/DropdownMenu/index.ts +2 -0
- package/components/Empty/Empty.svelte +73 -0
- package/components/Empty/index.ts +1 -0
- package/components/Field/Field.svelte +270 -0
- package/components/Field/index.ts +1 -0
- package/components/FloatingBubble/FloatingBubble.svelte +23 -0
- package/components/FloatingBubble/index.ts +1 -0
- package/components/FloatingPanel/FloatingPanel.svelte +139 -0
- package/components/FloatingPanel/index.ts +1 -0
- package/components/Form/Form.svelte +23 -0
- package/components/Form/index.ts +1 -0
- package/components/Grid/Grid.svelte +47 -0
- package/components/Grid/GridItem.svelte +150 -0
- package/components/Grid/index.ts +2 -0
- package/components/Highlight/Highlight.svelte +23 -0
- package/components/Highlight/index.ts +1 -0
- package/components/Icon/Icon.svelte +111 -0
- package/components/Icon/index.ts +1 -0
- package/components/ImageComp/ImageComp.svelte +104 -0
- package/components/ImageComp/index.ts +1 -0
- package/components/ImagePreview/ImagePreview.svelte +23 -0
- package/components/ImagePreview/index.ts +1 -0
- package/components/IndexBar/IndexAnchor.svelte +33 -0
- package/components/IndexBar/IndexBar.svelte +23 -0
- package/components/IndexBar/index.ts +2 -0
- package/components/List/List.svelte +23 -0
- package/components/List/index.ts +1 -0
- package/components/Loading/Loading.svelte +149 -0
- package/components/Loading/index.ts +1 -0
- package/components/NavBar/NavBar.svelte +109 -0
- package/components/NavBar/index.ts +1 -0
- package/components/NoticeBar/NoticeBar.svelte +120 -0
- package/components/NoticeBar/index.ts +1 -0
- package/components/Notify/Notify.svelte +23 -0
- package/components/Notify/index.ts +1 -0
- package/components/NumberKeyboard/NumberKeyboard.svelte +23 -0
- package/components/NumberKeyboard/index.ts +1 -0
- package/components/Overlay/Overlay.svelte +46 -0
- package/components/Overlay/index.ts +1 -0
- package/components/Pagination/Pagination.svelte +23 -0
- package/components/Pagination/index.ts +1 -0
- package/components/PasswordInput/PasswordInput.svelte +23 -0
- package/components/PasswordInput/index.ts +1 -0
- package/components/Picker/Picker.svelte +23 -0
- package/components/Picker/index.ts +1 -0
- package/components/PickerGroup/PickerGroup.svelte +99 -0
- package/components/PickerGroup/index.ts +1 -0
- package/components/Popover/Popover.svelte +23 -0
- package/components/Popover/index.ts +1 -0
- package/components/Popup/Popup.svelte +154 -0
- package/components/Popup/index.ts +1 -0
- package/components/Progress/Progress.svelte +89 -0
- package/components/Progress/index.ts +1 -0
- package/components/PullRefresh/PullRefresh.svelte +23 -0
- package/components/PullRefresh/index.ts +1 -0
- package/components/Radio/Radio.svelte +106 -0
- package/components/Radio/index.ts +1 -0
- package/components/RadioGroup/RadioGroup.svelte +34 -0
- package/components/RadioGroup/index.ts +1 -0
- package/components/Rate/Rate.svelte +87 -0
- package/components/Rate/index.ts +1 -0
- package/components/RollingText/RollingText.svelte +104 -0
- package/components/RollingText/index.ts +1 -0
- package/components/Row/Row.svelte +23 -0
- package/components/Row/index.ts +1 -0
- package/components/Search/Search.svelte +124 -0
- package/components/Search/index.ts +1 -0
- package/components/ShareSheet/ShareSheet.svelte +23 -0
- package/components/ShareSheet/index.ts +1 -0
- package/components/Sidebar/Sidebar.svelte +23 -0
- package/components/Sidebar/SidebarItem.svelte +110 -0
- package/components/Sidebar/index.ts +2 -0
- package/components/Signature/Signature.svelte +198 -0
- package/components/Signature/index.ts +1 -0
- package/components/Skeleton/Skeleton.svelte +23 -0
- package/components/Skeleton/SkeletonAvatar.svelte +26 -0
- package/components/Skeleton/SkeletonImage.svelte +44 -0
- package/components/Skeleton/SkeletonParagraph.svelte +60 -0
- package/components/Skeleton/SkeletonTitle.svelte +38 -0
- package/components/Skeleton/index.ts +5 -0
- package/components/Slider/Slider.svelte +112 -0
- package/components/Slider/index.ts +1 -0
- package/components/Space/Space.svelte +52 -0
- package/components/Space/index.ts +1 -0
- package/components/Stepper/Stepper.svelte +197 -0
- package/components/Stepper/index.ts +1 -0
- package/components/Steps/Step.svelte +126 -0
- package/components/Steps/Steps.svelte +23 -0
- package/components/Steps/index.ts +2 -0
- package/components/Sticky/Sticky.svelte +88 -0
- package/components/Sticky/index.ts +1 -0
- package/components/SubmitBar/SubmitBar.svelte +23 -0
- package/components/SubmitBar/index.ts +1 -0
- package/components/Swipe/Swipe.svelte +23 -0
- package/components/Swipe/SwipeItem.svelte +25 -0
- package/components/Swipe/index.ts +2 -0
- package/components/SwipeCell/SwipeCell.svelte +23 -0
- package/components/SwipeCell/index.ts +1 -0
- package/components/Switch/Switch.svelte +97 -0
- package/components/Switch/index.ts +1 -0
- package/components/Tabbar/Tabbar.svelte +62 -0
- package/components/Tabbar/index.ts +1 -0
- package/components/TabbarItem/TabbarItem.svelte +72 -0
- package/components/TabbarItem/index.ts +1 -0
- package/components/Tabs/Tab.svelte +37 -0
- package/components/Tabs/Tabs.svelte +161 -0
- package/components/Tabs/index.ts +2 -0
- package/components/Tag/Tag.svelte +144 -0
- package/components/Tag/index.ts +1 -0
- package/components/TextEllipsis/TextEllipsis.svelte +23 -0
- package/components/TextEllipsis/index.ts +1 -0
- package/components/TimePicker/TimePicker.svelte +23 -0
- package/components/TimePicker/index.ts +1 -0
- package/components/Toast/Toast.svelte +129 -0
- package/components/Toast/index.ts +1 -0
- package/components/TreeSelect/TreeSelect.svelte +23 -0
- package/components/TreeSelect/index.ts +1 -0
- package/components/Uploader/Uploader.svelte +23 -0
- package/components/Uploader/index.ts +1 -0
- package/components/Watermark/Watermark.svelte +23 -0
- package/components/Watermark/index.ts +1 -0
- package/components/index.ts +100 -0
- package/dist/styles.css +1 -0
- package/dist/svelte-mobile-ui.cjs +158 -0
- package/dist/svelte-mobile-ui.iife.js +209 -0
- package/dist/svelte-mobile-ui.mjs +158 -0
- package/dist/types/icons.ts +106 -0
- package/dist/types/index.ts +82 -0
- package/index.ts +8 -0
- package/package.json +63 -0
- package/styles/index.scss +153 -0
- package/styles/var.scss +83 -0
- package/utils/icons.ts +106 -0
- package/utils/index.ts +82 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
list = [],
|
|
6
|
+
addText = "新建联系人",
|
|
7
|
+
defaultTagText = "默认",
|
|
8
|
+
onAdd,
|
|
9
|
+
onEdit,
|
|
10
|
+
onSelect,
|
|
11
|
+
class: className = "",
|
|
12
|
+
}: {
|
|
13
|
+
list?: Array<{
|
|
14
|
+
id?: string | number;
|
|
15
|
+
name: string;
|
|
16
|
+
tel: string;
|
|
17
|
+
isDefault?: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
addText?: string;
|
|
20
|
+
defaultTagText?: string;
|
|
21
|
+
onAdd?: () => void;
|
|
22
|
+
onEdit?: (item: any, index: number) => void;
|
|
23
|
+
onSelect?: (item: any, index: number) => void;
|
|
24
|
+
class?: string;
|
|
25
|
+
} = $props();
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div class="smu-contact-list {className}">
|
|
29
|
+
{#if list.length > 0}
|
|
30
|
+
{#each list as item, i}
|
|
31
|
+
<div
|
|
32
|
+
class="smu-contact-list__item"
|
|
33
|
+
onclick={() => onSelect?.(item, i)}
|
|
34
|
+
>
|
|
35
|
+
<div class="smu-contact-list__info">
|
|
36
|
+
<div class="smu-contact-list__name">
|
|
37
|
+
{item.name}
|
|
38
|
+
{#if item.isDefault}
|
|
39
|
+
<span class="smu-contact-list__tag"
|
|
40
|
+
>{defaultTagText}</span
|
|
41
|
+
>
|
|
42
|
+
{/if}
|
|
43
|
+
</div>
|
|
44
|
+
<div class="smu-contact-list__tel">{item.tel}</div>
|
|
45
|
+
</div>
|
|
46
|
+
<div
|
|
47
|
+
class="smu-contact-list__edit"
|
|
48
|
+
onclick={(e) => {
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
onEdit?.(item, i);
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
编辑
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
{/each}
|
|
57
|
+
{:else}
|
|
58
|
+
<div class="smu-contact-list__empty">暂无联系人</div>
|
|
59
|
+
{/if}
|
|
60
|
+
|
|
61
|
+
<div class="smu-contact-list__add" onclick={() => onAdd?.()}>
|
|
62
|
+
{addText}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<style lang="scss">
|
|
67
|
+
.smu-contact-list {
|
|
68
|
+
&__item {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
padding: 12px var(--smu-padding-md);
|
|
72
|
+
background: var(--smu-background-2);
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
|
|
75
|
+
&:not(:last-child) {
|
|
76
|
+
border-bottom: 1px solid var(--smu-border-color);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&:active {
|
|
80
|
+
background: var(--smu-active-color);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__info {
|
|
85
|
+
flex: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&__name {
|
|
89
|
+
font-size: var(--smu-font-size-md);
|
|
90
|
+
font-weight: var(--smu-font-bold);
|
|
91
|
+
line-height: 24px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&__tag {
|
|
95
|
+
display: inline-block;
|
|
96
|
+
margin-left: 8px;
|
|
97
|
+
padding: 0 4px;
|
|
98
|
+
color: var(--smu-primary-color);
|
|
99
|
+
font-size: var(--smu-font-size-xs);
|
|
100
|
+
line-height: 18px;
|
|
101
|
+
border: 1px solid var(--smu-primary-color);
|
|
102
|
+
border-radius: var(--smu-radius-sm);
|
|
103
|
+
font-weight: normal;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&__tel {
|
|
107
|
+
margin-top: 4px;
|
|
108
|
+
color: var(--smu-gray-6);
|
|
109
|
+
font-size: var(--smu-font-size-sm);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&__edit {
|
|
113
|
+
padding: 4px 12px;
|
|
114
|
+
color: var(--smu-primary-color);
|
|
115
|
+
font-size: var(--smu-font-size-sm);
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&__empty {
|
|
120
|
+
padding: 40px 0;
|
|
121
|
+
text-align: center;
|
|
122
|
+
color: var(--smu-gray-6);
|
|
123
|
+
font-size: var(--smu-font-size-md);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&__add {
|
|
127
|
+
position: fixed;
|
|
128
|
+
bottom: 0;
|
|
129
|
+
left: 0;
|
|
130
|
+
right: 0;
|
|
131
|
+
padding: 12px 0;
|
|
132
|
+
text-align: center;
|
|
133
|
+
color: var(--smu-white);
|
|
134
|
+
font-size: var(--smu-font-size-lg);
|
|
135
|
+
background: var(--smu-primary-color);
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
|
|
138
|
+
&:active {
|
|
139
|
+
opacity: 0.8;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ContactList } from './ContactList.svelte'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
class: className = '',
|
|
7
|
+
...restProps
|
|
8
|
+
}: {
|
|
9
|
+
children?: Snippet
|
|
10
|
+
class?: string
|
|
11
|
+
[key: string]: any
|
|
12
|
+
} = $props()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="smu-countdown {className}">
|
|
16
|
+
{#if children}{@render children()}{/if}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.smu-countdown {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CountDown } from './CountDown.svelte'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
class: className = '',
|
|
7
|
+
...restProps
|
|
8
|
+
}: {
|
|
9
|
+
children?: Snippet
|
|
10
|
+
class?: string
|
|
11
|
+
[key: string]: any
|
|
12
|
+
} = $props()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="smu-coupon {className}">
|
|
16
|
+
{#if children}{@render children()}{/if}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.smu-coupon {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let {
|
|
3
|
+
title = "",
|
|
4
|
+
condition = "",
|
|
5
|
+
description = "",
|
|
6
|
+
startAt = 0,
|
|
7
|
+
endAt = 0,
|
|
8
|
+
valueDesc = 0,
|
|
9
|
+
unitDesc = "",
|
|
10
|
+
reason = "",
|
|
11
|
+
value = 0,
|
|
12
|
+
currency = "¥",
|
|
13
|
+
disabled = false,
|
|
14
|
+
chosen = false,
|
|
15
|
+
onclick,
|
|
16
|
+
class: className = "",
|
|
17
|
+
}: {
|
|
18
|
+
title?: string;
|
|
19
|
+
condition?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
startAt?: number;
|
|
22
|
+
endAt?: number;
|
|
23
|
+
valueDesc?: number | string;
|
|
24
|
+
unitDesc?: string;
|
|
25
|
+
reason?: string;
|
|
26
|
+
value?: number;
|
|
27
|
+
currency?: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
chosen?: boolean;
|
|
30
|
+
onclick?: () => void;
|
|
31
|
+
class?: string;
|
|
32
|
+
} = $props();
|
|
33
|
+
|
|
34
|
+
function formatDate(ts: number): string {
|
|
35
|
+
if (!ts) return "";
|
|
36
|
+
const d = new Date(ts * 1000);
|
|
37
|
+
return `${d.getFullYear()}.${String(d.getMonth() + 1).padStart(2, "0")}.${String(d.getDate()).padStart(2, "0")}`;
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<div
|
|
42
|
+
class="smu-coupon-cell {chosen ? 'smu-coupon-cell--chosen' : ''} {disabled
|
|
43
|
+
? 'smu-coupon-cell--disabled'
|
|
44
|
+
: ''} {className}"
|
|
45
|
+
onclick={() => !disabled && onclick?.()}
|
|
46
|
+
>
|
|
47
|
+
<div class="smu-coupon-cell__value">
|
|
48
|
+
<span class="smu-coupon-cell__currency">{currency}</span>
|
|
49
|
+
<span class="smu-coupon-cell__amount">{valueDesc || value}</span>
|
|
50
|
+
{#if unitDesc}<span class="smu-coupon-cell__unit">{unitDesc}</span>{/if}
|
|
51
|
+
</div>
|
|
52
|
+
<div class="smu-coupon-cell__info">
|
|
53
|
+
<div class="smu-coupon-cell__name">{title}</div>
|
|
54
|
+
{#if condition}<div class="smu-coupon-cell__condition">
|
|
55
|
+
{condition}
|
|
56
|
+
</div>{/if}
|
|
57
|
+
{#if startAt || endAt}
|
|
58
|
+
<div class="smu-coupon-cell__date">
|
|
59
|
+
{formatDate(startAt)} - {formatDate(endAt)}
|
|
60
|
+
</div>
|
|
61
|
+
{/if}
|
|
62
|
+
{#if description}<div class="smu-coupon-cell__desc">
|
|
63
|
+
{description}
|
|
64
|
+
</div>{/if}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<style lang="scss">
|
|
69
|
+
.smu-coupon-cell {
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
padding: 14px 0;
|
|
73
|
+
margin: 0 var(--smu-padding-md);
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
border-bottom: 1px solid var(--smu-border-color);
|
|
76
|
+
|
|
77
|
+
&--disabled {
|
|
78
|
+
opacity: 0.5;
|
|
79
|
+
cursor: not-allowed;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&--chosen {
|
|
83
|
+
.smu-coupon-cell__value {
|
|
84
|
+
color: var(--smu-danger-color);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&__value {
|
|
89
|
+
min-width: 80px;
|
|
90
|
+
text-align: center;
|
|
91
|
+
color: var(--smu-danger-color);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&__currency {
|
|
95
|
+
font-size: var(--smu-font-size-sm);
|
|
96
|
+
vertical-align: middle;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&__amount {
|
|
100
|
+
font-size: 24px;
|
|
101
|
+
font-weight: var(--smu-font-bold);
|
|
102
|
+
vertical-align: middle;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&__unit {
|
|
106
|
+
font-size: var(--smu-font-size-xs);
|
|
107
|
+
vertical-align: middle;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&__info {
|
|
111
|
+
flex: 1;
|
|
112
|
+
padding-left: 12px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&__name {
|
|
116
|
+
font-size: var(--smu-font-size-md);
|
|
117
|
+
font-weight: var(--smu-font-bold);
|
|
118
|
+
line-height: 20px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&__condition,
|
|
122
|
+
&__date,
|
|
123
|
+
&__desc {
|
|
124
|
+
margin-top: 4px;
|
|
125
|
+
color: var(--smu-gray-6);
|
|
126
|
+
font-size: var(--smu-font-size-sm);
|
|
127
|
+
line-height: 18px;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
</style>
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import CouponCell from "./CouponCell.svelte";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
code = $bindable(""),
|
|
7
|
+
coupons = [],
|
|
8
|
+
disabledCoupons = [],
|
|
9
|
+
chosenCoupon = $bindable(-1),
|
|
10
|
+
enabledTitle = "可用优惠券",
|
|
11
|
+
disabledTitle = "不可用优惠券",
|
|
12
|
+
exchangeButtonText = "兑换",
|
|
13
|
+
exchangeButtonLoading = false,
|
|
14
|
+
exchangeButtonDisabled = false,
|
|
15
|
+
showExchangeBar = true,
|
|
16
|
+
showCloseButton = true,
|
|
17
|
+
closeButtonText = "不使用优惠",
|
|
18
|
+
inputPlaceholder = "请输入优惠码",
|
|
19
|
+
showCount = true,
|
|
20
|
+
currency = "¥",
|
|
21
|
+
emptyImage = "",
|
|
22
|
+
onchange,
|
|
23
|
+
onexchange,
|
|
24
|
+
children,
|
|
25
|
+
class: className = "",
|
|
26
|
+
}: {
|
|
27
|
+
code?: string;
|
|
28
|
+
coupons?: any[];
|
|
29
|
+
disabledCoupons?: any[];
|
|
30
|
+
chosenCoupon?: number;
|
|
31
|
+
enabledTitle?: string;
|
|
32
|
+
disabledTitle?: string;
|
|
33
|
+
exchangeButtonText?: string;
|
|
34
|
+
exchangeButtonLoading?: boolean;
|
|
35
|
+
exchangeButtonDisabled?: boolean;
|
|
36
|
+
showExchangeBar?: boolean;
|
|
37
|
+
showCloseButton?: boolean;
|
|
38
|
+
closeButtonText?: string;
|
|
39
|
+
inputPlaceholder?: string;
|
|
40
|
+
showCount?: boolean;
|
|
41
|
+
currency?: string;
|
|
42
|
+
emptyImage?: string;
|
|
43
|
+
onchange?: (index: number) => void;
|
|
44
|
+
onexchange?: (code: string) => void;
|
|
45
|
+
children?: Snippet;
|
|
46
|
+
class?: string;
|
|
47
|
+
} = $props();
|
|
48
|
+
|
|
49
|
+
let activeTab = $state(0);
|
|
50
|
+
|
|
51
|
+
function handleSelect(index: number) {
|
|
52
|
+
chosenCoupon = index;
|
|
53
|
+
onchange?.(index);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function handleExchange() {
|
|
57
|
+
if (!code || exchangeButtonDisabled || exchangeButtonLoading) return;
|
|
58
|
+
onexchange?.(code);
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div class="smu-coupon-list {className}">
|
|
63
|
+
{#if showExchangeBar}
|
|
64
|
+
<div class="smu-coupon-list__exchange">
|
|
65
|
+
<input
|
|
66
|
+
class="smu-coupon-list__input"
|
|
67
|
+
type="text"
|
|
68
|
+
placeholder={inputPlaceholder}
|
|
69
|
+
bind:value={code}
|
|
70
|
+
/>
|
|
71
|
+
<button
|
|
72
|
+
class="smu-coupon-list__exchange-btn"
|
|
73
|
+
disabled={exchangeButtonDisabled ||
|
|
74
|
+
exchangeButtonLoading ||
|
|
75
|
+
!code}
|
|
76
|
+
onclick={handleExchange}
|
|
77
|
+
>
|
|
78
|
+
{exchangeButtonText}
|
|
79
|
+
</button>
|
|
80
|
+
</div>
|
|
81
|
+
{/if}
|
|
82
|
+
|
|
83
|
+
<div class="smu-coupon-list__tabs">
|
|
84
|
+
<div
|
|
85
|
+
class="smu-coupon-list__tab {activeTab === 0
|
|
86
|
+
? 'smu-coupon-list__tab--active'
|
|
87
|
+
: ''}"
|
|
88
|
+
onclick={() => (activeTab = 0)}
|
|
89
|
+
>
|
|
90
|
+
{enabledTitle}{#if showCount}
|
|
91
|
+
({coupons.length}){/if}
|
|
92
|
+
</div>
|
|
93
|
+
<div
|
|
94
|
+
class="smu-coupon-list__tab {activeTab === 1
|
|
95
|
+
? 'smu-coupon-list__tab--active'
|
|
96
|
+
: ''}"
|
|
97
|
+
onclick={() => (activeTab = 1)}
|
|
98
|
+
>
|
|
99
|
+
{disabledTitle}{#if showCount}
|
|
100
|
+
({disabledCoupons.length}){/if}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div class="smu-coupon-list__content">
|
|
105
|
+
{#if activeTab === 0}
|
|
106
|
+
{#if coupons.length > 0}
|
|
107
|
+
{#each coupons as coupon, i}
|
|
108
|
+
<CouponCell
|
|
109
|
+
{...coupon}
|
|
110
|
+
{currency}
|
|
111
|
+
chosen={chosenCoupon === i}
|
|
112
|
+
onclick={() => handleSelect(i)}
|
|
113
|
+
/>
|
|
114
|
+
{/each}
|
|
115
|
+
{:else}
|
|
116
|
+
<div class="smu-coupon-list__empty">暂无可用优惠券</div>
|
|
117
|
+
{/if}
|
|
118
|
+
{:else if disabledCoupons.length > 0}
|
|
119
|
+
{#each disabledCoupons as coupon}
|
|
120
|
+
<CouponCell {...coupon} {currency} disabled />
|
|
121
|
+
{/each}
|
|
122
|
+
{:else}
|
|
123
|
+
<div class="smu-coupon-list__empty">暂无不可用优惠券</div>
|
|
124
|
+
{/if}
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
{#if showCloseButton}
|
|
128
|
+
<div class="smu-coupon-list__close" onclick={() => onchange?.(-1)}>
|
|
129
|
+
{closeButtonText}
|
|
130
|
+
</div>
|
|
131
|
+
{/if}
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<style lang="scss">
|
|
135
|
+
.smu-coupon-list {
|
|
136
|
+
position: relative;
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
height: 100%;
|
|
140
|
+
background: var(--smu-background);
|
|
141
|
+
|
|
142
|
+
&__exchange {
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
padding: 8px var(--smu-padding-md);
|
|
146
|
+
background: var(--smu-background-2);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&__input {
|
|
150
|
+
flex: 1;
|
|
151
|
+
height: 32px;
|
|
152
|
+
padding: 0 8px;
|
|
153
|
+
border: 1px solid var(--smu-border-color);
|
|
154
|
+
border-radius: var(--smu-radius-sm);
|
|
155
|
+
font-size: var(--smu-font-size-md);
|
|
156
|
+
outline: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&__exchange-btn {
|
|
160
|
+
margin-left: 8px;
|
|
161
|
+
padding: 0 16px;
|
|
162
|
+
height: 32px;
|
|
163
|
+
color: var(--smu-white);
|
|
164
|
+
background: var(--smu-primary-color);
|
|
165
|
+
border: none;
|
|
166
|
+
border-radius: var(--smu-radius-sm);
|
|
167
|
+
font-size: var(--smu-font-size-sm);
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
|
|
170
|
+
&:disabled {
|
|
171
|
+
opacity: 0.5;
|
|
172
|
+
cursor: not-allowed;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&__tabs {
|
|
177
|
+
display: flex;
|
|
178
|
+
background: var(--smu-background-2);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&__tab {
|
|
182
|
+
flex: 1;
|
|
183
|
+
padding: 12px 0;
|
|
184
|
+
text-align: center;
|
|
185
|
+
font-size: var(--smu-font-size-md);
|
|
186
|
+
color: var(--smu-gray-6);
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
|
|
189
|
+
&--active {
|
|
190
|
+
color: var(--smu-text-color);
|
|
191
|
+
font-weight: var(--smu-font-bold);
|
|
192
|
+
border-bottom: 2px solid var(--smu-primary-color);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&__content {
|
|
197
|
+
flex: 1;
|
|
198
|
+
overflow-y: auto;
|
|
199
|
+
padding: var(--smu-padding-sm) 0;
|
|
200
|
+
background: var(--smu-background-2);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&__empty {
|
|
204
|
+
padding: 60px 0;
|
|
205
|
+
text-align: center;
|
|
206
|
+
color: var(--smu-gray-6);
|
|
207
|
+
font-size: var(--smu-font-size-md);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
&__close {
|
|
211
|
+
padding: 12px 0;
|
|
212
|
+
text-align: center;
|
|
213
|
+
color: var(--smu-text-color);
|
|
214
|
+
font-size: var(--smu-font-size-md);
|
|
215
|
+
font-weight: var(--smu-font-bold);
|
|
216
|
+
background: var(--smu-background-2);
|
|
217
|
+
cursor: pointer;
|
|
218
|
+
border-top: 1px solid var(--smu-border-color);
|
|
219
|
+
|
|
220
|
+
&:active {
|
|
221
|
+
background: var(--smu-active-color);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
class: className = '',
|
|
7
|
+
...restProps
|
|
8
|
+
}: {
|
|
9
|
+
children?: Snippet
|
|
10
|
+
class?: string
|
|
11
|
+
[key: string]: any
|
|
12
|
+
} = $props()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="smu-datepicker {className}">
|
|
16
|
+
{#if children}{@render children()}{/if}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.smu-datepicker {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DatePicker } from './DatePicker.svelte'
|