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,197 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let {
|
|
3
|
+
value = $bindable(1),
|
|
4
|
+
min = 1,
|
|
5
|
+
max = Infinity,
|
|
6
|
+
step = 1,
|
|
7
|
+
theme = '',
|
|
8
|
+
integer = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
disablePlus = false,
|
|
11
|
+
disableMinus = false,
|
|
12
|
+
disableInput = false,
|
|
13
|
+
showPlus = true,
|
|
14
|
+
showMinus = true,
|
|
15
|
+
showInput = true,
|
|
16
|
+
inputWidth = '32px',
|
|
17
|
+
buttonSize = '28px',
|
|
18
|
+
longPress = true,
|
|
19
|
+
placeholder = '',
|
|
20
|
+
decimalLength,
|
|
21
|
+
onChange,
|
|
22
|
+
class: className = '',
|
|
23
|
+
}: {
|
|
24
|
+
value?: number
|
|
25
|
+
min?: number
|
|
26
|
+
max?: number
|
|
27
|
+
step?: number
|
|
28
|
+
theme?: '' | 'round'
|
|
29
|
+
integer?: boolean
|
|
30
|
+
disabled?: boolean
|
|
31
|
+
disablePlus?: boolean
|
|
32
|
+
disableMinus?: boolean
|
|
33
|
+
disableInput?: boolean
|
|
34
|
+
showPlus?: boolean
|
|
35
|
+
showMinus?: boolean
|
|
36
|
+
showInput?: boolean
|
|
37
|
+
inputWidth?: string
|
|
38
|
+
buttonSize?: string
|
|
39
|
+
longPress?: boolean
|
|
40
|
+
placeholder?: string
|
|
41
|
+
decimalLength?: number
|
|
42
|
+
onChange?: (value: number) => void
|
|
43
|
+
class?: string
|
|
44
|
+
} = $props()
|
|
45
|
+
|
|
46
|
+
const minusDisabled = $derived(disabled || disableMinus || value <= min)
|
|
47
|
+
const plusDisabled = $derived(disabled || disablePlus || value >= max)
|
|
48
|
+
|
|
49
|
+
function format(val: number) {
|
|
50
|
+
val = Math.max(Math.min(val, max), min)
|
|
51
|
+
if (integer) val = Math.round(val)
|
|
52
|
+
if (decimalLength !== undefined) val = Number(val.toFixed(decimalLength))
|
|
53
|
+
return val
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function onMinus() {
|
|
57
|
+
if (minusDisabled) return
|
|
58
|
+
value = format(value - step)
|
|
59
|
+
onChange?.(value)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function onPlus() {
|
|
63
|
+
if (plusDisabled) return
|
|
64
|
+
value = format(value + step)
|
|
65
|
+
onChange?.(value)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function onInput(e: Event) {
|
|
69
|
+
const v = (e.target as HTMLInputElement).value
|
|
70
|
+
const num = Number(v)
|
|
71
|
+
if (!isNaN(num)) {
|
|
72
|
+
value = format(num)
|
|
73
|
+
onChange?.(value)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<div class="smu-stepper {theme ? `smu-stepper--${theme}` : ''} {className}">
|
|
79
|
+
{#if showMinus}
|
|
80
|
+
<button
|
|
81
|
+
class="smu-stepper__minus {minusDisabled ? 'smu-stepper__minus--disabled' : ''}"
|
|
82
|
+
style="width: {buttonSize}; height: {buttonSize}"
|
|
83
|
+
onclick={onMinus}
|
|
84
|
+
disabled={minusDisabled}
|
|
85
|
+
type="button"
|
|
86
|
+
></button>
|
|
87
|
+
{/if}
|
|
88
|
+
{#if showInput}
|
|
89
|
+
<input
|
|
90
|
+
class="smu-stepper__input"
|
|
91
|
+
type={integer ? 'tel' : 'text'}
|
|
92
|
+
role="spinbutton"
|
|
93
|
+
value={value}
|
|
94
|
+
disabled={disabled || disableInput}
|
|
95
|
+
readonly={disableInput}
|
|
96
|
+
inputmode={integer ? 'numeric' : 'decimal'}
|
|
97
|
+
{placeholder}
|
|
98
|
+
style="width: {inputWidth}; height: {buttonSize}"
|
|
99
|
+
oninput={onInput}
|
|
100
|
+
/>
|
|
101
|
+
{/if}
|
|
102
|
+
{#if showPlus}
|
|
103
|
+
<button
|
|
104
|
+
class="smu-stepper__plus {plusDisabled ? 'smu-stepper__plus--disabled' : ''}"
|
|
105
|
+
style="width: {buttonSize}; height: {buttonSize}"
|
|
106
|
+
onclick={onPlus}
|
|
107
|
+
disabled={plusDisabled}
|
|
108
|
+
type="button"
|
|
109
|
+
></button>
|
|
110
|
+
{/if}
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<style lang="scss">
|
|
114
|
+
.smu-stepper {
|
|
115
|
+
display: inline-flex;
|
|
116
|
+
user-select: none;
|
|
117
|
+
|
|
118
|
+
&__minus,
|
|
119
|
+
&__plus {
|
|
120
|
+
position: relative;
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
margin: 0;
|
|
123
|
+
padding: 0;
|
|
124
|
+
color: var(--smu-text-color);
|
|
125
|
+
vertical-align: middle;
|
|
126
|
+
background: var(--smu-active-color);
|
|
127
|
+
border: 0;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
|
|
130
|
+
&::before,
|
|
131
|
+
&::after {
|
|
132
|
+
position: absolute;
|
|
133
|
+
top: 50%;
|
|
134
|
+
left: 50%;
|
|
135
|
+
background: var(--smu-text-color);
|
|
136
|
+
transform: translate(-50%, -50%);
|
|
137
|
+
content: '';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&::before {
|
|
141
|
+
width: 50%;
|
|
142
|
+
height: 1px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&--disabled {
|
|
146
|
+
cursor: not-allowed;
|
|
147
|
+
opacity: var(--smu-disabled-opacity);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&__plus::after {
|
|
152
|
+
width: 1px;
|
|
153
|
+
height: 50%;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&__minus {
|
|
157
|
+
border-radius: var(--smu-radius-md) 0 0 var(--smu-radius-md);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&__plus {
|
|
161
|
+
border-radius: 0 var(--smu-radius-md) var(--smu-radius-md) 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&__input {
|
|
165
|
+
box-sizing: border-box;
|
|
166
|
+
width: 32px;
|
|
167
|
+
height: 28px;
|
|
168
|
+
margin: 0 2px;
|
|
169
|
+
padding: 0;
|
|
170
|
+
color: var(--smu-text-color);
|
|
171
|
+
font-size: var(--smu-font-size-md);
|
|
172
|
+
text-align: center;
|
|
173
|
+
vertical-align: middle;
|
|
174
|
+
background: var(--smu-active-color);
|
|
175
|
+
border: 0;
|
|
176
|
+
border-radius: 0;
|
|
177
|
+
-webkit-appearance: none;
|
|
178
|
+
|
|
179
|
+
&:focus { outline: none; }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&--round {
|
|
183
|
+
.smu-stepper__minus,
|
|
184
|
+
.smu-stepper__plus {
|
|
185
|
+
border-radius: 50%;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.smu-stepper__minus { border: 1px solid var(--smu-danger-color); background: var(--smu-white); color: var(--smu-danger-color);
|
|
189
|
+
&::before, &::after { background: var(--smu-danger-color); }
|
|
190
|
+
}
|
|
191
|
+
.smu-stepper__plus { border: 1px solid var(--smu-primary-color); background: var(--smu-primary-color); color: var(--smu-white);
|
|
192
|
+
&::before, &::after { background: var(--smu-white); }
|
|
193
|
+
}
|
|
194
|
+
.smu-stepper__input { background: transparent; }
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Stepper } from './Stepper.svelte'
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
activeIndex = 0,
|
|
6
|
+
status = "waiting",
|
|
7
|
+
title = "",
|
|
8
|
+
description = "",
|
|
9
|
+
icon = "",
|
|
10
|
+
iconPrefix = "",
|
|
11
|
+
children,
|
|
12
|
+
titleSlot,
|
|
13
|
+
descriptionSlot,
|
|
14
|
+
iconSlot,
|
|
15
|
+
class: className = "",
|
|
16
|
+
}: {
|
|
17
|
+
activeIndex?: number;
|
|
18
|
+
status?: "waiting" | "process" | "finish";
|
|
19
|
+
title?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
iconPrefix?: string;
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
titleSlot?: Snippet;
|
|
25
|
+
descriptionSlot?: Snippet;
|
|
26
|
+
iconSlot?: Snippet;
|
|
27
|
+
class?: string;
|
|
28
|
+
} = $props();
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<div class="smu-step smu-step--{status} {className}">
|
|
32
|
+
<div class="smu-step__circle-container">
|
|
33
|
+
{#if iconSlot}
|
|
34
|
+
{@render iconSlot()}
|
|
35
|
+
{:else}
|
|
36
|
+
<div class="smu-step__circle"></div>
|
|
37
|
+
{/if}
|
|
38
|
+
<div class="smu-step__line"></div>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="smu-step__info">
|
|
41
|
+
<div class="smu-step__title">
|
|
42
|
+
{#if titleSlot}{@render titleSlot()}{:else}{title}{/if}
|
|
43
|
+
</div>
|
|
44
|
+
{#if description || descriptionSlot}
|
|
45
|
+
<div class="smu-step__description">
|
|
46
|
+
{#if descriptionSlot}{@render descriptionSlot()}{:else}{description}{/if}
|
|
47
|
+
</div>
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<style lang="scss">
|
|
53
|
+
.smu-step {
|
|
54
|
+
position: relative;
|
|
55
|
+
display: flex;
|
|
56
|
+
flex: 1;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
align-items: center;
|
|
59
|
+
color: var(--smu-gray-6);
|
|
60
|
+
font-size: var(--smu-font-size-sm);
|
|
61
|
+
|
|
62
|
+
&--process {
|
|
63
|
+
color: var(--smu-text-color);
|
|
64
|
+
.smu-step__circle {
|
|
65
|
+
background: var(--smu-primary-color);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&--finish {
|
|
70
|
+
color: var(--smu-primary-color);
|
|
71
|
+
.smu-step__circle {
|
|
72
|
+
background: var(--smu-primary-color);
|
|
73
|
+
}
|
|
74
|
+
.smu-step__line {
|
|
75
|
+
background: var(--smu-primary-color);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&__circle-container {
|
|
80
|
+
position: relative;
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
width: 100%;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&__circle {
|
|
88
|
+
width: 12px;
|
|
89
|
+
height: 12px;
|
|
90
|
+
background: var(--smu-gray-5);
|
|
91
|
+
border-radius: 50%;
|
|
92
|
+
flex-shrink: 0;
|
|
93
|
+
z-index: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&__line {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 50%;
|
|
99
|
+
left: 50%;
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 1px;
|
|
102
|
+
background: var(--smu-gray-5);
|
|
103
|
+
transform: translateY(-50%);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&:last-child .smu-step__line {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&__info {
|
|
111
|
+
margin-top: 8px;
|
|
112
|
+
text-align: center;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&__title {
|
|
116
|
+
font-size: var(--smu-font-size-sm);
|
|
117
|
+
line-height: 1.4;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&__description {
|
|
121
|
+
margin-top: 4px;
|
|
122
|
+
color: var(--smu-gray-6);
|
|
123
|
+
font-size: var(--smu-font-size-xs);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
</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-steps {className}">
|
|
16
|
+
{#if children}{@render children()}{/if}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.smu-steps {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { onMount, onDestroy } from "svelte";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
offsetTop = 0,
|
|
7
|
+
offsetBottom,
|
|
8
|
+
zIndex = 99,
|
|
9
|
+
container,
|
|
10
|
+
position = "top",
|
|
11
|
+
onChange,
|
|
12
|
+
onScroll,
|
|
13
|
+
children,
|
|
14
|
+
class: className = "",
|
|
15
|
+
}: {
|
|
16
|
+
offsetTop?: number | string;
|
|
17
|
+
offsetBottom?: number | string;
|
|
18
|
+
zIndex?: number | string;
|
|
19
|
+
container?: HTMLElement;
|
|
20
|
+
position?: "top" | "bottom";
|
|
21
|
+
onChange?: (isFixed: boolean) => void;
|
|
22
|
+
onScroll?: (params: { scrollTop: number; isFixed: boolean }) => void;
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
class?: string;
|
|
25
|
+
} = $props();
|
|
26
|
+
|
|
27
|
+
let rootEl: HTMLDivElement;
|
|
28
|
+
let isFixed = $state(false);
|
|
29
|
+
let fixedStyle = $state("");
|
|
30
|
+
|
|
31
|
+
function handleScroll() {
|
|
32
|
+
if (!rootEl) return;
|
|
33
|
+
const scrollTop =
|
|
34
|
+
(container || document.documentElement).scrollTop ||
|
|
35
|
+
window.pageYOffset;
|
|
36
|
+
const rect = rootEl.getBoundingClientRect();
|
|
37
|
+
const offset =
|
|
38
|
+
Number(position === "bottom" ? (offsetBottom ?? 0) : offsetTop) ||
|
|
39
|
+
0;
|
|
40
|
+
|
|
41
|
+
let newFixed = false;
|
|
42
|
+
if (position === "top") {
|
|
43
|
+
newFixed = rect.top < offset;
|
|
44
|
+
} else {
|
|
45
|
+
newFixed = rect.bottom > window.innerHeight - offset;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (newFixed !== isFixed) {
|
|
49
|
+
isFixed = newFixed;
|
|
50
|
+
onChange?.(isFixed);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (isFixed) {
|
|
54
|
+
if (position === "top") {
|
|
55
|
+
fixedStyle = `position: fixed; top: ${offset}px; left: ${rect.left}px; width: ${rect.width}px; z-index: ${zIndex};`;
|
|
56
|
+
} else {
|
|
57
|
+
fixedStyle = `position: fixed; bottom: ${offset}px; left: ${rect.left}px; width: ${rect.width}px; z-index: ${zIndex};`;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
fixedStyle = "";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
onScroll?.({ scrollTop, isFixed });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onMount(() => {
|
|
67
|
+
const target = container || window;
|
|
68
|
+
target.addEventListener("scroll", handleScroll, { passive: true });
|
|
69
|
+
handleScroll();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
onDestroy(() => {
|
|
73
|
+
const target = container || window;
|
|
74
|
+
target.removeEventListener("scroll", handleScroll);
|
|
75
|
+
});
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<div class="smu-sticky {className}" bind:this={rootEl}>
|
|
79
|
+
<div style={fixedStyle}>
|
|
80
|
+
{#if children}{@render children()}{/if}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<style lang="scss">
|
|
85
|
+
.smu-sticky {
|
|
86
|
+
position: relative;
|
|
87
|
+
}
|
|
88
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Sticky } from './Sticky.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-submitbar {className}">
|
|
16
|
+
{#if children}{@render children()}{/if}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.smu-submitbar {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SubmitBar } from './SubmitBar.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-swipe {className}">
|
|
16
|
+
{#if children}{@render children()}{/if}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.smu-swipe {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
class: className = "",
|
|
7
|
+
}: {
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
class?: string;
|
|
10
|
+
} = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class="smu-swipe-item {className}">
|
|
14
|
+
{#if children}{@render children()}{/if}
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<style lang="scss">
|
|
18
|
+
.smu-swipe-item {
|
|
19
|
+
position: relative;
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
</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-swipecell {className}">
|
|
16
|
+
{#if children}{@render children()}{/if}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.smu-swipecell {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SwipeCell } from './SwipeCell.svelte'
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Loading from '../Loading/Loading.svelte'
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
checked = $bindable(false),
|
|
6
|
+
loading = false,
|
|
7
|
+
disabled = false,
|
|
8
|
+
size = '26px',
|
|
9
|
+
activeColor = '',
|
|
10
|
+
inactiveColor = '',
|
|
11
|
+
activeValue = true,
|
|
12
|
+
inactiveValue = false,
|
|
13
|
+
onChange,
|
|
14
|
+
class: className = '',
|
|
15
|
+
}: {
|
|
16
|
+
checked?: boolean | any
|
|
17
|
+
loading?: boolean
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
size?: string | number
|
|
20
|
+
activeColor?: string
|
|
21
|
+
inactiveColor?: string
|
|
22
|
+
activeValue?: any
|
|
23
|
+
inactiveValue?: any
|
|
24
|
+
onChange?: (val: any) => void
|
|
25
|
+
class?: string
|
|
26
|
+
} = $props()
|
|
27
|
+
|
|
28
|
+
const isChecked = $derived(checked === activeValue)
|
|
29
|
+
const sizeStr = $derived(typeof size === 'number' ? size + 'px' : size)
|
|
30
|
+
|
|
31
|
+
function toggle() {
|
|
32
|
+
if (disabled || loading) return
|
|
33
|
+
const newVal = isChecked ? inactiveValue : activeValue
|
|
34
|
+
checked = newVal
|
|
35
|
+
onChange?.(newVal)
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<div
|
|
40
|
+
class="smu-switch {isChecked ? 'smu-switch--on' : ''} {disabled ? 'smu-switch--disabled' : ''} {loading ? 'smu-switch--loading' : ''} {className}"
|
|
41
|
+
style="font-size: {sizeStr}; {isChecked && activeColor ? `background: ${activeColor}` : ''} {!isChecked && inactiveColor ? `background: ${inactiveColor}` : ''}"
|
|
42
|
+
role="switch"
|
|
43
|
+
aria-checked={isChecked}
|
|
44
|
+
tabindex="0"
|
|
45
|
+
onclick={toggle}
|
|
46
|
+
>
|
|
47
|
+
<div class="smu-switch__node">
|
|
48
|
+
{#if loading}
|
|
49
|
+
<Loading size="65%" class="smu-switch__loading" color={isChecked ? (activeColor || 'var(--smu-primary-color)') : (inactiveColor || 'var(--smu-gray-5)')} />
|
|
50
|
+
{/if}
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<style lang="scss">
|
|
55
|
+
.smu-switch {
|
|
56
|
+
position: relative;
|
|
57
|
+
display: inline-block;
|
|
58
|
+
box-sizing: content-box;
|
|
59
|
+
width: 2em;
|
|
60
|
+
height: 1em;
|
|
61
|
+
background: rgba(120, 120, 128, 0.16);
|
|
62
|
+
border-radius: 1em;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
transition: background var(--smu-duration-base);
|
|
65
|
+
|
|
66
|
+
&--on {
|
|
67
|
+
background: var(--smu-primary-color);
|
|
68
|
+
|
|
69
|
+
.smu-switch__node {
|
|
70
|
+
transform: translateX(1em);
|
|
71
|
+
background: var(--smu-white);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&--disabled {
|
|
76
|
+
cursor: not-allowed;
|
|
77
|
+
opacity: var(--smu-disabled-opacity);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&__node {
|
|
81
|
+
position: absolute;
|
|
82
|
+
top: 0;
|
|
83
|
+
left: 0;
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
width: 1em;
|
|
88
|
+
height: 1em;
|
|
89
|
+
background: var(--smu-white);
|
|
90
|
+
border-radius: 50%;
|
|
91
|
+
box-shadow: 0 3px 1px 0 rgba(0, 0, 0, 0.05), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 3px 3px 0 rgba(0, 0, 0, 0.05);
|
|
92
|
+
transition: transform var(--smu-duration-base) cubic-bezier(0.3, 1.05, 0.4, 1.05);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&__loading { display: flex; }
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Switch } from './Switch.svelte'
|