@anmed/mui-selection 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/Selection.svelte +134 -0
- package/Selection.svelte.d.ts +19 -0
- package/SelectionField.svelte +70 -0
- package/SelectionField.svelte.d.ts +28 -0
- package/SelectionSpinner.svelte +54 -0
- package/SelectionSpinner.svelte.d.ts +23 -0
- package/SingleClickSelectionSpinner.svelte +46 -0
- package/SingleClickSelectionSpinner.svelte.d.ts +26 -0
- package/index.d.ts +6 -0
- package/index.js +6 -0
- package/mui-select-field.css +129 -0
- package/mui-select-field.scss +135 -0
- package/package.json +36 -0
package/Selection.svelte
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
<script>import './mui-select-field.scss';
|
2
|
+
import { onMount } from "svelte";
|
3
|
+
export let dataList = [];
|
4
|
+
export let value;
|
5
|
+
export let displayKey;
|
6
|
+
let pickerColumn;
|
7
|
+
let pickerContent;
|
8
|
+
let isPointerdown = false;
|
9
|
+
let itemHeight = 40;
|
10
|
+
let maxY = itemHeight * 2;
|
11
|
+
let minY = 0;
|
12
|
+
let lastY = 0;
|
13
|
+
let diffY = 0;
|
14
|
+
let translateY = 0;
|
15
|
+
let friction = 0.95; // 摩擦系数
|
16
|
+
let distanceY = 0;
|
17
|
+
let listHtml = "";
|
18
|
+
onMount(() => {
|
19
|
+
if (!value && dataList.length != 0) {
|
20
|
+
value = dataList[0];
|
21
|
+
}
|
22
|
+
});
|
23
|
+
function handlePointerdown(e) {
|
24
|
+
// 如果是鼠标点击,只响应左键
|
25
|
+
if (e.pointerType === 'mouse' && e.button !== 0) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
pickerColumn.setPointerCapture(e.pointerId);
|
29
|
+
isPointerdown = true;
|
30
|
+
lastY = e.clientY;
|
31
|
+
diffY = 0;
|
32
|
+
distanceY = 0;
|
33
|
+
getTransform();
|
34
|
+
pickerContent.style.transition = 'none';
|
35
|
+
}
|
36
|
+
function handlePointermove(e) {
|
37
|
+
if (isPointerdown) {
|
38
|
+
diffY = e.clientY - lastY;
|
39
|
+
translateY += diffY;
|
40
|
+
lastY = e.clientY;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
function handlePointerup(e) {
|
44
|
+
if (isPointerdown) {
|
45
|
+
isPointerdown = false;
|
46
|
+
getTranslateY();
|
47
|
+
// 滑动距离与时长成正比且最短时长为300ms
|
48
|
+
const duration = Math.max(Math.abs(distanceY) * 1.5, 300);
|
49
|
+
pickerContent.style.transition = 'transform ' + duration + 'ms ease';
|
50
|
+
}
|
51
|
+
}
|
52
|
+
function handlePointercancel(e) {
|
53
|
+
if (isPointerdown) {
|
54
|
+
isPointerdown = false;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
function getTransform() {
|
58
|
+
const transform = window.getComputedStyle(pickerContent).getPropertyValue('transform');
|
59
|
+
if (transform !== 'none') {
|
60
|
+
translateY = parseFloat(transform.split(',')[5]);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
function getTranslateY() {
|
64
|
+
let speed = diffY;
|
65
|
+
while (Math.abs(speed) > 1) {
|
66
|
+
speed *= friction;
|
67
|
+
distanceY += speed;
|
68
|
+
}
|
69
|
+
// 边界判断
|
70
|
+
let y = translateY + distanceY;
|
71
|
+
if (y > maxY) {
|
72
|
+
translateY = maxY;
|
73
|
+
distanceY = maxY - translateY;
|
74
|
+
}
|
75
|
+
else if (y < minY) {
|
76
|
+
translateY = minY;
|
77
|
+
distanceY = minY - translateY;
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
translateY = y;
|
81
|
+
}
|
82
|
+
// 计算停止位置使其为itemHeight的整数倍
|
83
|
+
let i = Math.round(translateY / itemHeight);
|
84
|
+
translateY = i * itemHeight;
|
85
|
+
value = dataList[2 - translateY / itemHeight];
|
86
|
+
}
|
87
|
+
function getHtmlList(list) {
|
88
|
+
let html = '';
|
89
|
+
for (const item of list) {
|
90
|
+
let displayText = '';
|
91
|
+
if ((displayKey?.length ?? 0) === 0) {
|
92
|
+
displayText = item.toString();
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
displayText = item[displayKey];
|
96
|
+
}
|
97
|
+
html += `<li style="line-height: 40px;text-align: center"> ${displayText} </li>`;
|
98
|
+
}
|
99
|
+
return html;
|
100
|
+
}
|
101
|
+
function getDefaultTranslateY(data) {
|
102
|
+
let dY;
|
103
|
+
let indexOf = data.indexOf(value);
|
104
|
+
if (indexOf == -1) {
|
105
|
+
dY = maxY;
|
106
|
+
}
|
107
|
+
else if (indexOf > 2) {
|
108
|
+
dY = -itemHeight * (indexOf - 2);
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
dY = itemHeight * (2 - indexOf);
|
112
|
+
}
|
113
|
+
return dY;
|
114
|
+
}
|
115
|
+
$: minY = itemHeight * (3 - dataList.length);
|
116
|
+
$: listHtml = getHtmlList(dataList);
|
117
|
+
$: translateY = getDefaultTranslateY(dataList);
|
118
|
+
</script>
|
119
|
+
|
120
|
+
<div class="mui-select-slide-box">
|
121
|
+
<div class="mui-select-group">
|
122
|
+
<div class="mui-select-column" bind:this={pickerColumn}
|
123
|
+
on:pointerdown={handlePointerdown}
|
124
|
+
on:pointermove={handlePointermove}
|
125
|
+
on:pointerup={handlePointerup}
|
126
|
+
on:pointercancel={handlePointercancel}>
|
127
|
+
<ul class="mui-select-content" bind:this={pickerContent}
|
128
|
+
style="transform: {'translate3d(0px, ' + translateY + 'px, 0px)'}"
|
129
|
+
>
|
130
|
+
{@html listHtml}
|
131
|
+
</ul>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
2
|
+
import './mui-select-field.scss';
|
3
|
+
declare const __propDef: {
|
4
|
+
props: {
|
5
|
+
dataList?: any[] | undefined;
|
6
|
+
value: any;
|
7
|
+
displayKey: string | null;
|
8
|
+
};
|
9
|
+
events: {
|
10
|
+
[evt: string]: CustomEvent<any>;
|
11
|
+
};
|
12
|
+
slots: {};
|
13
|
+
};
|
14
|
+
export type SelectionProps = typeof __propDef.props;
|
15
|
+
export type SelectionEvents = typeof __propDef.events;
|
16
|
+
export type SelectionSlots = typeof __propDef.slots;
|
17
|
+
export default class Selection extends SvelteComponentTyped<SelectionProps, SelectionEvents, SelectionSlots> {
|
18
|
+
}
|
19
|
+
export {};
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<script>import CommonField from "@anmed/mui-common-ui/common-field";
|
2
|
+
import { createEventDispatcher } from "svelte";
|
3
|
+
let dispatcher = createEventDispatcher();
|
4
|
+
export let list = [];
|
5
|
+
export let value;
|
6
|
+
export let keyCode = 'value';
|
7
|
+
export let keyText = 'text';
|
8
|
+
export let convertText;
|
9
|
+
export let label;
|
10
|
+
export let readOnly = false;
|
11
|
+
export let required = false;
|
12
|
+
export let error;
|
13
|
+
export let options;
|
14
|
+
export let isCardSelection = false;
|
15
|
+
let focused;
|
16
|
+
let above;
|
17
|
+
let displayText;
|
18
|
+
const getDisplayText = (item) => {
|
19
|
+
let text;
|
20
|
+
if (convertText) {
|
21
|
+
text = convertText(item);
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
text = item[keyText];
|
25
|
+
}
|
26
|
+
return text;
|
27
|
+
};
|
28
|
+
const onCardItemClick = (item) => {
|
29
|
+
if (!readOnly) {
|
30
|
+
value = item;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
$: {
|
34
|
+
let selectItem = list.find((item) => item[keyCode] == value);
|
35
|
+
if (selectItem) {
|
36
|
+
displayText = getDisplayText(selectItem);
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
displayText = '';
|
40
|
+
}
|
41
|
+
}
|
42
|
+
$: above = focused || displayText.toString().length != 0 || isCardSelection;
|
43
|
+
const handlerClick = () => {
|
44
|
+
if (!readOnly && !isCardSelection) {
|
45
|
+
dispatcher('action', value);
|
46
|
+
}
|
47
|
+
};
|
48
|
+
</script>
|
49
|
+
|
50
|
+
<div on:click={handlerClick}>
|
51
|
+
|
52
|
+
{#if isCardSelection}
|
53
|
+
<CommonField {label} {required} bind:focused {above} {error}>
|
54
|
+
<div class="card-select-box">
|
55
|
+
{#each list as item}
|
56
|
+
<span class="{item === value? 'card-select-item-selected' :'card-select-item-normal'}"
|
57
|
+
on:click={()=>onCardItemClick(item)}>{getDisplayText(item)}</span>
|
58
|
+
{/each}
|
59
|
+
</div>
|
60
|
+
</CommonField>
|
61
|
+
{:else }
|
62
|
+
<CommonField {label} {required} bind:focused {above} {error}>
|
63
|
+
<span class="mui-select-field-text">{displayText}</span>
|
64
|
+
<div slot="trailing-icon">
|
65
|
+
<span class="triangle-down"></span>
|
66
|
+
</div>
|
67
|
+
</CommonField>
|
68
|
+
{/if}
|
69
|
+
|
70
|
+
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
2
|
+
declare const __propDef: {
|
3
|
+
props: {
|
4
|
+
list?: any[] | undefined;
|
5
|
+
value: any;
|
6
|
+
keyCode?: string | undefined;
|
7
|
+
keyText?: string | undefined;
|
8
|
+
convertText: (item: any) => string;
|
9
|
+
label: string | null;
|
10
|
+
readOnly?: boolean | undefined;
|
11
|
+
required?: boolean | undefined;
|
12
|
+
error: any;
|
13
|
+
options: any;
|
14
|
+
isCardSelection?: boolean | undefined;
|
15
|
+
};
|
16
|
+
events: {
|
17
|
+
action: CustomEvent<any>;
|
18
|
+
} & {
|
19
|
+
[evt: string]: CustomEvent<any>;
|
20
|
+
};
|
21
|
+
slots: {};
|
22
|
+
};
|
23
|
+
export type SelectionFieldProps = typeof __propDef.props;
|
24
|
+
export type SelectionFieldEvents = typeof __propDef.events;
|
25
|
+
export type SelectionFieldSlots = typeof __propDef.slots;
|
26
|
+
export default class SelectionField extends SvelteComponentTyped<SelectionFieldProps, SelectionFieldEvents, SelectionFieldSlots> {
|
27
|
+
}
|
28
|
+
export {};
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
2
|
+
import Button from "@anmed/mui-buttons";
|
3
|
+
import SelectField from "./Selection.svelte";
|
4
|
+
export let visible;
|
5
|
+
export let title;
|
6
|
+
export let style;
|
7
|
+
export let dataList = [];
|
8
|
+
export let value;
|
9
|
+
export let displayKey;
|
10
|
+
const dispatch = createEventDispatcher();
|
11
|
+
const handleItemSelected = (item) => {
|
12
|
+
dispatch('select', value);
|
13
|
+
};
|
14
|
+
</script>
|
15
|
+
<div class="box" {style}>
|
16
|
+
<div>
|
17
|
+
{#if title}
|
18
|
+
<div class="title">
|
19
|
+
<span>{title}</span>
|
20
|
+
</div>
|
21
|
+
{/if}
|
22
|
+
<div>
|
23
|
+
<SelectField bind:value={value} bind:dataList={dataList} bind:displayKey={displayKey}/>
|
24
|
+
</div>
|
25
|
+
<div class="bottom_button_tab">
|
26
|
+
<Button round label="取消" on:click={()=>visible =false}/>
|
27
|
+
<Button round label="确认" on:click={handleItemSelected}/>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<style>
|
33
|
+
|
34
|
+
.box {
|
35
|
+
background-color: white;
|
36
|
+
border-top-right-radius: 15px;
|
37
|
+
border-top-left-radius: 15px;
|
38
|
+
}
|
39
|
+
|
40
|
+
.title {
|
41
|
+
padding: 15px;
|
42
|
+
text-align: center;
|
43
|
+
color: #333333;
|
44
|
+
font-size: 15px;
|
45
|
+
font-weight: bold;
|
46
|
+
}
|
47
|
+
|
48
|
+
.bottom_button_tab {
|
49
|
+
display: flex;
|
50
|
+
flex-direction: row;
|
51
|
+
justify-content: space-around;
|
52
|
+
align-items: center;
|
53
|
+
}
|
54
|
+
</style>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
2
|
+
declare const __propDef: {
|
3
|
+
props: {
|
4
|
+
visible: boolean;
|
5
|
+
title: string | null;
|
6
|
+
style: any;
|
7
|
+
dataList?: any[] | undefined;
|
8
|
+
value: any;
|
9
|
+
displayKey: string | null;
|
10
|
+
};
|
11
|
+
events: {
|
12
|
+
select: CustomEvent<any>;
|
13
|
+
} & {
|
14
|
+
[evt: string]: CustomEvent<any>;
|
15
|
+
};
|
16
|
+
slots: {};
|
17
|
+
};
|
18
|
+
export type SelectionSpinnerProps = typeof __propDef.props;
|
19
|
+
export type SelectionSpinnerEvents = typeof __propDef.events;
|
20
|
+
export type SelectionSpinnerSlots = typeof __propDef.slots;
|
21
|
+
export default class SelectionSpinner extends SvelteComponentTyped<SelectionSpinnerProps, SelectionSpinnerEvents, SelectionSpinnerSlots> {
|
22
|
+
}
|
23
|
+
export {};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
2
|
+
export let visible;
|
3
|
+
export let title;
|
4
|
+
export let style;
|
5
|
+
export let list = [];
|
6
|
+
export let value;
|
7
|
+
export let keyField = 'value';
|
8
|
+
export let textField = 'text';
|
9
|
+
export let convertText;
|
10
|
+
export let itemSelect;
|
11
|
+
const dispatch = createEventDispatcher();
|
12
|
+
const handleItemSelected = (item) => {
|
13
|
+
dispatch('select', item);
|
14
|
+
if (itemSelect) {
|
15
|
+
itemSelect(item);
|
16
|
+
}
|
17
|
+
value = item[keyField];
|
18
|
+
};
|
19
|
+
const getDisplayText = (item) => {
|
20
|
+
let displayText = '';
|
21
|
+
if (item) {
|
22
|
+
if (convertText) {
|
23
|
+
displayText = convertText(item);
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
displayText = item[textField];
|
27
|
+
}
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
displayText = '';
|
31
|
+
}
|
32
|
+
return displayText;
|
33
|
+
};
|
34
|
+
</script>
|
35
|
+
|
36
|
+
<div class="single-click-selection-box" {style}>
|
37
|
+
{#if title}
|
38
|
+
<span class="single-click-selection-title">{title}</span>
|
39
|
+
{/if}
|
40
|
+
<ul class="single-click-selection-ul">
|
41
|
+
{#each list as data}
|
42
|
+
<li on:click={()=>handleItemSelected(data)}
|
43
|
+
class={value === data[keyField] ? 'single-click-selection-li-selected':'single-click-selection-li-normal'}> {getDisplayText(data)}</li>
|
44
|
+
{/each}
|
45
|
+
</ul>
|
46
|
+
</div>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
2
|
+
declare const __propDef: {
|
3
|
+
props: {
|
4
|
+
visible: boolean;
|
5
|
+
title: string | null;
|
6
|
+
style: any;
|
7
|
+
list?: any[] | undefined;
|
8
|
+
value: any;
|
9
|
+
keyField?: string | undefined;
|
10
|
+
textField?: string | undefined;
|
11
|
+
convertText: (item: any) => string;
|
12
|
+
itemSelect: (item: any) => void;
|
13
|
+
};
|
14
|
+
events: {
|
15
|
+
select: CustomEvent<any>;
|
16
|
+
} & {
|
17
|
+
[evt: string]: CustomEvent<any>;
|
18
|
+
};
|
19
|
+
slots: {};
|
20
|
+
};
|
21
|
+
export type SingleClickSelectionSpinnerProps = typeof __propDef.props;
|
22
|
+
export type SingleClickSelectionSpinnerEvents = typeof __propDef.events;
|
23
|
+
export type SingleClickSelectionSpinnerSlots = typeof __propDef.slots;
|
24
|
+
export default class SingleClickSelectionSpinner extends SvelteComponentTyped<SingleClickSelectionSpinnerProps, SingleClickSelectionSpinnerEvents, SingleClickSelectionSpinnerSlots> {
|
25
|
+
}
|
26
|
+
export {};
|
package/index.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
import SelectField from "./Selection.svelte";
|
2
|
+
import SelectFieldSpinner from "./SelectionSpinner.svelte";
|
3
|
+
import SingleClickSelectionSpinner from "./lib/SingleClickSelectionSpinner.svelte";
|
4
|
+
import Selection from "./lib/Selection.svelte";
|
5
|
+
export default SelectField;
|
6
|
+
export { SingleClickSelectionSpinner, SelectFieldSpinner, Selection };
|
package/index.js
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
import SelectField from "./Selection.svelte";
|
2
|
+
import SelectFieldSpinner from "./SelectionSpinner.svelte";
|
3
|
+
import SingleClickSelectionSpinner from "./lib/SingleClickSelectionSpinner.svelte";
|
4
|
+
import Selection from "./lib/Selection.svelte";
|
5
|
+
export default SelectField;
|
6
|
+
export { SingleClickSelectionSpinner, SelectFieldSpinner, Selection };
|
@@ -0,0 +1,129 @@
|
|
1
|
+
@charset "UTF-8";
|
2
|
+
* {
|
3
|
+
margin: 0;
|
4
|
+
padding: 0;
|
5
|
+
}
|
6
|
+
|
7
|
+
.mui-select-slide-box {
|
8
|
+
flex: 1;
|
9
|
+
left: 0;
|
10
|
+
right: 0;
|
11
|
+
bottom: 0;
|
12
|
+
background: white;
|
13
|
+
user-select: none;
|
14
|
+
}
|
15
|
+
|
16
|
+
.mui-select-group {
|
17
|
+
display: flex;
|
18
|
+
}
|
19
|
+
|
20
|
+
.mui-select-column {
|
21
|
+
position: relative;
|
22
|
+
flex: 1;
|
23
|
+
height: 200px;
|
24
|
+
margin: 0 auto;
|
25
|
+
overflow: hidden;
|
26
|
+
touch-action: none;
|
27
|
+
}
|
28
|
+
|
29
|
+
.mui-select-column::before {
|
30
|
+
content: "";
|
31
|
+
position: absolute;
|
32
|
+
top: 0;
|
33
|
+
left: 0;
|
34
|
+
right: 0;
|
35
|
+
z-index: 1;
|
36
|
+
height: 79px;
|
37
|
+
border-bottom: 1px solid #ebebeb;
|
38
|
+
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6));
|
39
|
+
}
|
40
|
+
|
41
|
+
.mui-select-column::after {
|
42
|
+
content: "";
|
43
|
+
position: absolute;
|
44
|
+
bottom: 0;
|
45
|
+
left: 0;
|
46
|
+
right: 0;
|
47
|
+
z-index: 1;
|
48
|
+
height: 79px;
|
49
|
+
border-top: 1px solid #ebebeb;
|
50
|
+
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.9));
|
51
|
+
}
|
52
|
+
|
53
|
+
li {
|
54
|
+
list-style: none;
|
55
|
+
font-size: 14px;
|
56
|
+
line-height: 40px;
|
57
|
+
text-align: center;
|
58
|
+
}
|
59
|
+
|
60
|
+
/*CSS小三角*/
|
61
|
+
span.triangle-down {
|
62
|
+
display: inline-block;
|
63
|
+
width: 0;
|
64
|
+
height: 0;
|
65
|
+
margin: auto;
|
66
|
+
border-left: 5px solid transparent;
|
67
|
+
border-right: 5px solid transparent;
|
68
|
+
border-top: 5px solid #666;
|
69
|
+
}
|
70
|
+
|
71
|
+
.mui-select-field-text {
|
72
|
+
color: var(mui-select-field-text-color, #999);
|
73
|
+
font-size: var(mui-select-field-text-font-size, 16px);
|
74
|
+
}
|
75
|
+
|
76
|
+
.single-click-selection-box {
|
77
|
+
width: 100%;
|
78
|
+
background-color: white;
|
79
|
+
border-top-right-radius: 15px;
|
80
|
+
border-top-left-radius: 15px;
|
81
|
+
}
|
82
|
+
|
83
|
+
.single-click-selection-title {
|
84
|
+
display: flex;
|
85
|
+
padding: 15px;
|
86
|
+
justify-content: center;
|
87
|
+
color: #333333;
|
88
|
+
font-size: 15px;
|
89
|
+
font-weight: bold;
|
90
|
+
}
|
91
|
+
|
92
|
+
.single-click-selection-ul {
|
93
|
+
height: 200px;
|
94
|
+
overflow: auto;
|
95
|
+
}
|
96
|
+
|
97
|
+
.single-click-selection-li-normal {
|
98
|
+
height: 40px;
|
99
|
+
color: var(single-click-selection-normal-text-color, #666);
|
100
|
+
}
|
101
|
+
|
102
|
+
.single-click-selection-li-selected {
|
103
|
+
height: 40px;
|
104
|
+
color: var(--single-click-selection-selected-text-color, #0912ff);
|
105
|
+
}
|
106
|
+
|
107
|
+
.card-select-box {
|
108
|
+
display: flex;
|
109
|
+
justify-content: space-around;
|
110
|
+
}
|
111
|
+
.card-select-box .select-item-base, .card-select-box .card-select-item-selected, .card-select-box .card-select-item-normal {
|
112
|
+
width: 100%;
|
113
|
+
line-height: 24px;
|
114
|
+
border-radius: 5px;
|
115
|
+
margin-right: 10px;
|
116
|
+
font-size: 12px;
|
117
|
+
text-align: center;
|
118
|
+
}
|
119
|
+
.card-select-box .select-item-base:last-child, .card-select-box .card-select-item-selected:last-child, .card-select-box .card-select-item-normal:last-child {
|
120
|
+
margin-right: 0;
|
121
|
+
}
|
122
|
+
.card-select-box .card-select-item-normal {
|
123
|
+
background-color: var(--card-select-item-normal-bg-color, #F8F8F8);
|
124
|
+
color: var(--card-select-item-normal-text-color, #333333);
|
125
|
+
}
|
126
|
+
.card-select-box .card-select-item-selected {
|
127
|
+
background-color: var(--card-select-item-selected-bg-color, #E5F3FF);
|
128
|
+
color: var(--card-select-item-selected-text-color, #377EE1);
|
129
|
+
}
|
@@ -0,0 +1,135 @@
|
|
1
|
+
* {
|
2
|
+
margin: 0;
|
3
|
+
padding: 0;
|
4
|
+
}
|
5
|
+
|
6
|
+
.mui-select-slide-box {
|
7
|
+
flex: 1;
|
8
|
+
left: 0;
|
9
|
+
right: 0;
|
10
|
+
bottom: 0;
|
11
|
+
background: white;
|
12
|
+
user-select: none;
|
13
|
+
}
|
14
|
+
|
15
|
+
.mui-select-group {
|
16
|
+
display: flex;
|
17
|
+
}
|
18
|
+
|
19
|
+
.mui-select-column {
|
20
|
+
position: relative;
|
21
|
+
flex: 1;
|
22
|
+
height: 200px;
|
23
|
+
margin: 0 auto;
|
24
|
+
overflow: hidden;
|
25
|
+
touch-action: none;
|
26
|
+
}
|
27
|
+
|
28
|
+
.mui-select-column::before {
|
29
|
+
content: '';
|
30
|
+
position: absolute;
|
31
|
+
top: 0;
|
32
|
+
left: 0;
|
33
|
+
right: 0;
|
34
|
+
z-index: 1;
|
35
|
+
height: 79px;
|
36
|
+
border-bottom: 1px solid #ebebeb;
|
37
|
+
background: linear-gradient(to bottom, rgba(255, 255, 255, .9), rgba(255, 255, 255, .6));
|
38
|
+
}
|
39
|
+
|
40
|
+
.mui-select-column::after {
|
41
|
+
content: '';
|
42
|
+
position: absolute;
|
43
|
+
bottom: 0;
|
44
|
+
left: 0;
|
45
|
+
right: 0;
|
46
|
+
z-index: 1;
|
47
|
+
height: 79px;
|
48
|
+
border-top: 1px solid #ebebeb;
|
49
|
+
background: linear-gradient(to bottom, rgba(255, 255, 255, .6), rgba(255, 255, 255, .9));
|
50
|
+
}
|
51
|
+
|
52
|
+
li {
|
53
|
+
list-style: none;
|
54
|
+
font-size: 14px;
|
55
|
+
line-height: 40px;
|
56
|
+
text-align: center;
|
57
|
+
}
|
58
|
+
|
59
|
+
/*CSS小三角*/
|
60
|
+
span.triangle-down {
|
61
|
+
display: inline-block;
|
62
|
+
width: 0;
|
63
|
+
height: 0;
|
64
|
+
margin: auto;
|
65
|
+
border-left: 5px solid transparent;
|
66
|
+
border-right: 5px solid transparent;
|
67
|
+
border-top: 5px solid #666;
|
68
|
+
}
|
69
|
+
|
70
|
+
.mui-select-field-text {
|
71
|
+
color: var(mui-select-field-text-color, #999);
|
72
|
+
font-size: var(mui-select-field-text-font-size, 16px);;
|
73
|
+
}
|
74
|
+
|
75
|
+
.single-click-selection-box {
|
76
|
+
width: 100%;
|
77
|
+
background-color: white;
|
78
|
+
border-top-right-radius: 15px;
|
79
|
+
border-top-left-radius: 15px;
|
80
|
+
}
|
81
|
+
|
82
|
+
.single-click-selection-title {
|
83
|
+
display: flex;
|
84
|
+
padding: 15px;
|
85
|
+
justify-content: center;
|
86
|
+
color: #333333;
|
87
|
+
font-size: 15px;
|
88
|
+
font-weight: bold;
|
89
|
+
}
|
90
|
+
|
91
|
+
.single-click-selection-ul {
|
92
|
+
height: 200px;
|
93
|
+
overflow: auto;
|
94
|
+
}
|
95
|
+
|
96
|
+
.single-click-selection-li-normal {
|
97
|
+
height: 40px;
|
98
|
+
color: var(single-click-selection-normal-text-color, #666);
|
99
|
+
}
|
100
|
+
|
101
|
+
.single-click-selection-li-selected {
|
102
|
+
height: 40px;
|
103
|
+
color: var(--single-click-selection-selected-text-color, #0912ff);
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
.card-select-box {
|
108
|
+
display: flex;
|
109
|
+
justify-content: space-around;
|
110
|
+
|
111
|
+
.select-item-base {
|
112
|
+
width: 100%;
|
113
|
+
line-height: 24px;
|
114
|
+
border-radius: 5px;
|
115
|
+
margin-right: 10px;
|
116
|
+
font-size: 12px;
|
117
|
+
text-align: center;
|
118
|
+
|
119
|
+
&:last-child {
|
120
|
+
margin-right: 0;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
.card-select-item-normal {
|
125
|
+
@extend .select-item-base;
|
126
|
+
background-color: var(--card-select-item-normal-bg-color, #F8F8F8);
|
127
|
+
color: var(--card-select-item-normal-text-color, #333333);
|
128
|
+
}
|
129
|
+
|
130
|
+
.card-select-item-selected {
|
131
|
+
@extend .select-item-base;
|
132
|
+
background-color: var(--card-select-item-selected-bg-color, #E5F3FF);
|
133
|
+
color: var(--card-select-item-selected-text-color, #377EE1);
|
134
|
+
}
|
135
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"name": "@anmed/mui-selection",
|
3
|
+
"version": "0.0.2",
|
4
|
+
"description": "",
|
5
|
+
"type": "module",
|
6
|
+
"main": "index.js",
|
7
|
+
"types": "index.d.ts",
|
8
|
+
"devDependencies": {
|
9
|
+
"@sveltejs/adapter-auto": "next",
|
10
|
+
"@sveltejs/kit": "next",
|
11
|
+
"@sveltejs/package": "next",
|
12
|
+
"node-sass": "^8.0.0",
|
13
|
+
"sass": "^1.57.1",
|
14
|
+
"svelte": "^3.44.0",
|
15
|
+
"svelte-check": "^2.7.1",
|
16
|
+
"svelte-preprocess": "^4.10.6",
|
17
|
+
"tslib": "^2.3.1",
|
18
|
+
"typescript": "^4.7.4",
|
19
|
+
"vite": "4.0.4",
|
20
|
+
"@anmed/mui-buttons": "^0.0.1",
|
21
|
+
"@anmed/mui-common-ui": "file:/Users/mac/Work/Project/almd/code/jjld_3/mobile-components/mui-common-ui/package"
|
22
|
+
},
|
23
|
+
"author": "Xiang Feng",
|
24
|
+
"license": "MIT",
|
25
|
+
"exports": {
|
26
|
+
"./package.json": "./package.json",
|
27
|
+
"./Selection.svelte": "./Selection.svelte",
|
28
|
+
"./SelectionField.svelte": "./SelectionField.svelte",
|
29
|
+
"./SelectionSpinner.svelte": "./SelectionSpinner.svelte",
|
30
|
+
"./SingleClickSelectionSpinner.svelte": "./SingleClickSelectionSpinner.svelte",
|
31
|
+
".": "./index.js",
|
32
|
+
"./mui-select-field.css": "./mui-select-field.css",
|
33
|
+
"./mui-select-field.scss": "./mui-select-field.scss"
|
34
|
+
},
|
35
|
+
"svelte": "./index.js"
|
36
|
+
}
|