wx-svelte-core 1.3.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.txt +21 -0
- package/package.json +35 -0
- package/src/Locale.svelte +17 -0
- package/src/components/Area.svelte +70 -0
- package/src/components/Button.svelte +187 -0
- package/src/components/Calendar.svelte +42 -0
- package/src/components/Checkbox.svelte +132 -0
- package/src/components/CheckboxGroup.svelte +52 -0
- package/src/components/ColorBoard.svelte +311 -0
- package/src/components/ColorPicker.svelte +110 -0
- package/src/components/ColorSelect.svelte +204 -0
- package/src/components/Combo.svelte +228 -0
- package/src/components/Counter.svelte +178 -0
- package/src/components/DatePicker.svelte +115 -0
- package/src/components/DateRangePicker.svelte +138 -0
- package/src/components/Dropdown.svelte +125 -0
- package/src/components/Field.svelte +91 -0
- package/src/components/Globals.svelte +53 -0
- package/src/components/Icon.svelte +31 -0
- package/src/components/Modal.svelte +115 -0
- package/src/components/ModalArea.svelte +32 -0
- package/src/components/MultiCombo.svelte +279 -0
- package/src/components/Notice.svelte +145 -0
- package/src/components/Notices.svelte +20 -0
- package/src/components/Pager.svelte +131 -0
- package/src/components/Popup.svelte +53 -0
- package/src/components/Portal.svelte +42 -0
- package/src/components/RadioButton.svelte +129 -0
- package/src/components/RadioButtonGroup.svelte +50 -0
- package/src/components/RangeCalendar.svelte +134 -0
- package/src/components/RichSelect.svelte +149 -0
- package/src/components/Segmented.svelte +115 -0
- package/src/components/Select.svelte +124 -0
- package/src/components/SideArea.svelte +33 -0
- package/src/components/Slider.svelte +242 -0
- package/src/components/Switch.svelte +88 -0
- package/src/components/Tabs.svelte +163 -0
- package/src/components/Text.svelte +185 -0
- package/src/components/Timepicker.svelte +217 -0
- package/src/components/TwoState.svelte +60 -0
- package/src/components/calendar/Button.svelte +40 -0
- package/src/components/calendar/Duodecade.svelte +97 -0
- package/src/components/calendar/Header.svelte +105 -0
- package/src/components/calendar/Month.svelte +189 -0
- package/src/components/calendar/Panel.svelte +119 -0
- package/src/components/calendar/Year.svelte +89 -0
- package/src/components/calendar/helpers.js +56 -0
- package/src/components/helpers/SuggestDropdown.svelte +79 -0
- package/src/components/helpers/colorTransformator.js +146 -0
- package/src/components/helpers/colorValidation.js +21 -0
- package/src/components/helpers/listnav.js +85 -0
- package/src/components/helpers/sliderMove.js +42 -0
- package/src/components/helpers.js +6 -0
- package/src/index.js +50 -0
- package/src/themes/FontOpenSans.svelte +36 -0
- package/src/themes/FonttRoboto.svelte +19 -0
- package/src/themes/Material.svelte +321 -0
- package/src/themes/Willow.svelte +323 -0
- package/src/themes/WillowDark.svelte +320 -0
- package/whatsnew.md +97 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { uid } from "wx-lib-dom";
|
|
3
|
+
|
|
4
|
+
export let id = uid();
|
|
5
|
+
export let label = "";
|
|
6
|
+
export let value = "";
|
|
7
|
+
export let groupValue;
|
|
8
|
+
export let name;
|
|
9
|
+
export let disabled = false;
|
|
10
|
+
export let checked = false;
|
|
11
|
+
|
|
12
|
+
function handlerChange(ev) {
|
|
13
|
+
if (ev.target.checked) groupValue = value;
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div class="wx-radio">
|
|
18
|
+
<input
|
|
19
|
+
type="radio"
|
|
20
|
+
{id}
|
|
21
|
+
{value}
|
|
22
|
+
{disabled}
|
|
23
|
+
{name}
|
|
24
|
+
{checked}
|
|
25
|
+
on:change={handlerChange}
|
|
26
|
+
/>
|
|
27
|
+
<label for={id}>
|
|
28
|
+
<span />
|
|
29
|
+
{#if label}<span>{label}</span>{/if}
|
|
30
|
+
</label>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
.wx-radio {
|
|
35
|
+
position: relative;
|
|
36
|
+
display: inline-block;
|
|
37
|
+
vertical-align: top;
|
|
38
|
+
max-width: var(--wx-input-width);
|
|
39
|
+
}
|
|
40
|
+
input {
|
|
41
|
+
appearance: none;
|
|
42
|
+
width: 0;
|
|
43
|
+
height: 0;
|
|
44
|
+
opacity: 0;
|
|
45
|
+
position: absolute;
|
|
46
|
+
left: 0;
|
|
47
|
+
top: 0;
|
|
48
|
+
margin: 0;
|
|
49
|
+
padding: 0;
|
|
50
|
+
}
|
|
51
|
+
label {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-wrap: nowrap;
|
|
54
|
+
align-items: flex-start;
|
|
55
|
+
font-family: var(--wx-checkbox-font-family);
|
|
56
|
+
font-size: var(--wx-checkbox-font-size);
|
|
57
|
+
line-height: var(--wx-checkbox-line-height);
|
|
58
|
+
font-weight: var(--wx-checkbox-font-weight);
|
|
59
|
+
color: var(--wx-checkbox-font-color);
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
span {
|
|
63
|
+
display: block;
|
|
64
|
+
}
|
|
65
|
+
span + span {
|
|
66
|
+
margin-left: 8px;
|
|
67
|
+
padding-top: calc(
|
|
68
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-line-height)) / 2
|
|
69
|
+
);
|
|
70
|
+
padding-bottom: calc(
|
|
71
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-line-height)) / 2
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
span:first-child {
|
|
75
|
+
position: relative;
|
|
76
|
+
flex-shrink: 0;
|
|
77
|
+
padding-top: calc(
|
|
78
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-size)) / 2
|
|
79
|
+
);
|
|
80
|
+
padding-bottom: calc(
|
|
81
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-size)) / 2
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
span:first-child:before {
|
|
85
|
+
content: "";
|
|
86
|
+
display: block;
|
|
87
|
+
width: var(--wx-checkbox-size);
|
|
88
|
+
height: var(--wx-checkbox-size);
|
|
89
|
+
border: var(--wx-checkbox-border-width) solid
|
|
90
|
+
var(--wx-checkbox-border-color);
|
|
91
|
+
border-radius: 50%;
|
|
92
|
+
background: var(--wx-input-background);
|
|
93
|
+
}
|
|
94
|
+
span:first-child:after {
|
|
95
|
+
content: "";
|
|
96
|
+
position: absolute;
|
|
97
|
+
display: none;
|
|
98
|
+
left: 50%;
|
|
99
|
+
top: 50%;
|
|
100
|
+
transform: translate(-50%, -50%);
|
|
101
|
+
width: calc(
|
|
102
|
+
var(--wx-checkbox-size) - var(--wx-checkbox-border-width) * 2
|
|
103
|
+
);
|
|
104
|
+
height: calc(
|
|
105
|
+
var(--wx-checkbox-size) - var(--wx-checkbox-border-width) * 2
|
|
106
|
+
);
|
|
107
|
+
border-style: solid;
|
|
108
|
+
border-color: var(--wx-input-background);
|
|
109
|
+
border-width: calc(var(--wx-checkbox-size) * 0.2);
|
|
110
|
+
border-radius: 50%;
|
|
111
|
+
}
|
|
112
|
+
input:checked ~ label span:first-child:before {
|
|
113
|
+
background: var(--wx-color-primary);
|
|
114
|
+
border-color: transparent;
|
|
115
|
+
}
|
|
116
|
+
input:checked ~ label span:first-child:after {
|
|
117
|
+
display: block;
|
|
118
|
+
}
|
|
119
|
+
input[disabled] ~ label {
|
|
120
|
+
color: var(--wx-checkbox-border-color-disabled);
|
|
121
|
+
cursor: not-allowed;
|
|
122
|
+
}
|
|
123
|
+
input[disabled]:not(:checked) ~ label span:first-child:before {
|
|
124
|
+
border-color: var(--wx-checkbox-border-color-disabled);
|
|
125
|
+
}
|
|
126
|
+
input[disabled]:checked ~ label span:first-child:before {
|
|
127
|
+
background: var(--wx-checkbox-border-color-disabled);
|
|
128
|
+
}
|
|
129
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { uid } from "wx-lib-dom";
|
|
3
|
+
import RadioButton from "./RadioButton.svelte";
|
|
4
|
+
|
|
5
|
+
export let options = [{}];
|
|
6
|
+
export let value;
|
|
7
|
+
export let type;
|
|
8
|
+
|
|
9
|
+
const name = uid();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<div class="wx-radiogroup wx-{type}">
|
|
13
|
+
{#each options as option}
|
|
14
|
+
<div class="wx-item">
|
|
15
|
+
<RadioButton
|
|
16
|
+
label={option.label}
|
|
17
|
+
value={option.value}
|
|
18
|
+
checked={value === option.value}
|
|
19
|
+
bind:groupValue={value}
|
|
20
|
+
{name}
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
{/each}
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<style>
|
|
27
|
+
.wx-radiogroup {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
align-items: flex-start;
|
|
31
|
+
justify-content: flex-start;
|
|
32
|
+
margin-top: calc(var(--wx-field-gutter) * -1);
|
|
33
|
+
}
|
|
34
|
+
.wx-item {
|
|
35
|
+
flex: 0 0 100%;
|
|
36
|
+
max-width: 100%;
|
|
37
|
+
margin-top: var(--wx-field-gutter);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.wx-radiogroup.wx-inline .wx-item {
|
|
41
|
+
flex: none;
|
|
42
|
+
padding-right: var(--wx-field-gutter);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.wx-radiogroup.wx-grid .wx-item {
|
|
46
|
+
flex: 0 0 50%;
|
|
47
|
+
max-width: 50%;
|
|
48
|
+
padding-right: var(--wx-field-gutter);
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
const dispatch = createEventDispatcher();
|
|
4
|
+
|
|
5
|
+
import Panel from "./calendar/Panel.svelte";
|
|
6
|
+
import { configs } from "./calendar/helpers";
|
|
7
|
+
|
|
8
|
+
export let start;
|
|
9
|
+
export let end;
|
|
10
|
+
export let done;
|
|
11
|
+
export let current;
|
|
12
|
+
export let months = 2;
|
|
13
|
+
export let markers = null;
|
|
14
|
+
export let buttons = true;
|
|
15
|
+
|
|
16
|
+
function addMonth(l, diff, rPrev) {
|
|
17
|
+
const r = new Date(l);
|
|
18
|
+
r.setMonth(r.getMonth() + diff);
|
|
19
|
+
if (rPrev && r.valueOf() == rPrev.valueOf()) return rPrev;
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let leftCurrent, rightCurrent;
|
|
24
|
+
function setInitCurrents(s) {
|
|
25
|
+
leftCurrent = s ? new Date(s) : current || new Date();
|
|
26
|
+
}
|
|
27
|
+
$: setInitCurrents(start);
|
|
28
|
+
|
|
29
|
+
function onLeft() {
|
|
30
|
+
if (leftCurrent) rightCurrent = addMonth(leftCurrent, 1);
|
|
31
|
+
}
|
|
32
|
+
function onRight() {
|
|
33
|
+
if (rightCurrent) leftCurrent = addMonth(rightCurrent, -1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
$: onLeft(leftCurrent);
|
|
37
|
+
$: onRight(rightCurrent);
|
|
38
|
+
|
|
39
|
+
function doShift({ diff, type }) {
|
|
40
|
+
const obj = configs[type];
|
|
41
|
+
if (diff > 0) {
|
|
42
|
+
rightCurrent = obj.next(rightCurrent);
|
|
43
|
+
} else if (diff < 0) {
|
|
44
|
+
leftCurrent = obj.prev(leftCurrent);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function doChangeStart(v) {
|
|
49
|
+
selectChange(v);
|
|
50
|
+
if (start) leftCurrent = new Date(start);
|
|
51
|
+
}
|
|
52
|
+
function doChangeEnd(v) {
|
|
53
|
+
selectChange(v);
|
|
54
|
+
if (end) rightCurrent = new Date(end);
|
|
55
|
+
}
|
|
56
|
+
function selectChange(ev) {
|
|
57
|
+
const v = ev.value;
|
|
58
|
+
const final = v === -1;
|
|
59
|
+
if (!final) {
|
|
60
|
+
if (ev.select) {
|
|
61
|
+
if (!start || end) {
|
|
62
|
+
start = v;
|
|
63
|
+
end = null;
|
|
64
|
+
} else {
|
|
65
|
+
if (start > v) {
|
|
66
|
+
end = start;
|
|
67
|
+
start = v;
|
|
68
|
+
} else {
|
|
69
|
+
end = v;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
if (!v) {
|
|
74
|
+
start = end = null;
|
|
75
|
+
} else {
|
|
76
|
+
start = new Date(v);
|
|
77
|
+
end = new Date(v);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (final || !done) dispatch("change", { start, end });
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
{#if months == 1}
|
|
87
|
+
<Panel
|
|
88
|
+
value={{ start: start, end: end }}
|
|
89
|
+
current={leftCurrent}
|
|
90
|
+
{markers}
|
|
91
|
+
{done}
|
|
92
|
+
{buttons}
|
|
93
|
+
part="both"
|
|
94
|
+
on:shift={ev => doShift(ev.detail)}
|
|
95
|
+
on:change={ev => doChangeStart(ev.detail)}
|
|
96
|
+
/>
|
|
97
|
+
{:else}
|
|
98
|
+
<div class="wx-rangecalendar">
|
|
99
|
+
<div class="wx-half">
|
|
100
|
+
<Panel
|
|
101
|
+
value={{ start: start, end: end }}
|
|
102
|
+
current={leftCurrent}
|
|
103
|
+
{markers}
|
|
104
|
+
buttons={false}
|
|
105
|
+
part="left"
|
|
106
|
+
on:shift={ev => doShift(ev.detail)}
|
|
107
|
+
on:change={ev => doChangeStart(ev.detail)}
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
<div class="wx-half">
|
|
111
|
+
<Panel
|
|
112
|
+
value={{ start: start, end: end }}
|
|
113
|
+
current={rightCurrent}
|
|
114
|
+
{markers}
|
|
115
|
+
{done}
|
|
116
|
+
{buttons}
|
|
117
|
+
part="right"
|
|
118
|
+
on:shift={ev => doShift(ev.detail)}
|
|
119
|
+
on:change={ev => doChangeEnd(ev.detail)}
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
{/if}
|
|
124
|
+
|
|
125
|
+
<style>
|
|
126
|
+
.wx-rangecalendar {
|
|
127
|
+
display: flex;
|
|
128
|
+
padding-bottom: var(--wx-calendar-padding);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.wx-half {
|
|
132
|
+
flex: 1;
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
import List from "./helpers/SuggestDropdown.svelte";
|
|
4
|
+
|
|
5
|
+
export let value = "";
|
|
6
|
+
export let options = [];
|
|
7
|
+
export let placeholder = "Click to select";
|
|
8
|
+
export let disabled = false;
|
|
9
|
+
export let error = false;
|
|
10
|
+
export let title = "";
|
|
11
|
+
|
|
12
|
+
const dispatch = createEventDispatcher();
|
|
13
|
+
const SLOTS = $$props.$$slots;
|
|
14
|
+
|
|
15
|
+
let selected = null;
|
|
16
|
+
let navigate;
|
|
17
|
+
let keydown;
|
|
18
|
+
function ready(ev) {
|
|
19
|
+
navigate = ev.detail.navigate;
|
|
20
|
+
keydown = ev.detail.keydown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
$: selected =
|
|
24
|
+
value || value === 0 ? options.find(a => a.id === value) : null;
|
|
25
|
+
|
|
26
|
+
function select(ev) {
|
|
27
|
+
const { id } = ev.detail;
|
|
28
|
+
|
|
29
|
+
if (id || id === 0) {
|
|
30
|
+
value = id;
|
|
31
|
+
const obj = options.find(a => a.id === id);
|
|
32
|
+
|
|
33
|
+
navigate(null);
|
|
34
|
+
dispatch("select", { selected: obj });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const index = () => options.findIndex(a => a.id === value);
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
42
|
+
<div
|
|
43
|
+
class="wx-richselect"
|
|
44
|
+
{title}
|
|
45
|
+
class:wx-error={error}
|
|
46
|
+
class:wx-disabled={disabled}
|
|
47
|
+
class:wx-nowrap={!SLOTS}
|
|
48
|
+
on:click={() => navigate(index())}
|
|
49
|
+
on:keydown={ev => keydown(ev, index())}
|
|
50
|
+
tabindex="0"
|
|
51
|
+
>
|
|
52
|
+
<div class="wx-label">
|
|
53
|
+
{#if selected}
|
|
54
|
+
<slot option={selected}>{selected.name || ""}</slot>
|
|
55
|
+
{:else if placeholder}
|
|
56
|
+
<span class="wx-placeholder">{placeholder}</span>
|
|
57
|
+
{:else} {/if}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<i class="wx-icon wxi-angle-down" />
|
|
61
|
+
|
|
62
|
+
{#if !disabled}
|
|
63
|
+
<List let:option items={options} on:ready={ready} on:select={select}>
|
|
64
|
+
<slot {option}>{option.name}</slot>
|
|
65
|
+
</List>
|
|
66
|
+
{/if}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.wx-richselect {
|
|
71
|
+
position: relative;
|
|
72
|
+
outline: none;
|
|
73
|
+
width: var(--wx-input-width);
|
|
74
|
+
min-height: var(--wx-input-height);
|
|
75
|
+
border: var(--wx-input-border);
|
|
76
|
+
border-radius: var(--wx-input-border-radius);
|
|
77
|
+
background: var(--wx-input-background);
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
}
|
|
80
|
+
.wx-richselect:focus {
|
|
81
|
+
border: var(--wx-input-border-focus);
|
|
82
|
+
}
|
|
83
|
+
.wx-richselect.wx-disabled {
|
|
84
|
+
cursor: not-allowed;
|
|
85
|
+
border: var(--wx-input-border-disabled);
|
|
86
|
+
background: var(--wx-input-background-disabled);
|
|
87
|
+
}
|
|
88
|
+
.wx-richselect.wx-disabled .wx-label {
|
|
89
|
+
color: var(--wx-color-font-disabled);
|
|
90
|
+
}
|
|
91
|
+
.wx-richselect.wx-disabled .wx-icon {
|
|
92
|
+
color: var(--wx-color-font-disabled);
|
|
93
|
+
}
|
|
94
|
+
.wx-richselect.wx-error {
|
|
95
|
+
border-color: var(--wx-color-danger);
|
|
96
|
+
}
|
|
97
|
+
.wx-richselect.wx-error .wx-label {
|
|
98
|
+
color: var(--wx-color-danger);
|
|
99
|
+
}
|
|
100
|
+
.wx-richselect.wx-error .wx-icon {
|
|
101
|
+
color: var(--wx-color-danger);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.wx-label {
|
|
105
|
+
display: block;
|
|
106
|
+
width: 100%;
|
|
107
|
+
font-family: var(--wx-input-font-family);
|
|
108
|
+
font-size: var(--wx-input-font-size);
|
|
109
|
+
line-height: var(--wx-input-line-height);
|
|
110
|
+
font-weight: var(--wx-input-font-weight);
|
|
111
|
+
text-align: var(--wx-input-text-align);
|
|
112
|
+
color: var(--wx-input-font-color);
|
|
113
|
+
padding: var(--wx-input-padding);
|
|
114
|
+
padding-right: calc(
|
|
115
|
+
var(--wx-input-icon-size) + var(--wx-input-icon-indent) * 2
|
|
116
|
+
);
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.wx-placeholder {
|
|
121
|
+
color: var(--wx-input-placeholder-color);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.wx-icon {
|
|
125
|
+
position: absolute;
|
|
126
|
+
right: var(--wx-input-icon-indent);
|
|
127
|
+
top: 50%;
|
|
128
|
+
transform: translateY(-50%);
|
|
129
|
+
font-size: var(--wx-input-icon-size);
|
|
130
|
+
line-height: 1;
|
|
131
|
+
width: var(--wx-input-icon-size);
|
|
132
|
+
height: var(--wx-input-icon-size);
|
|
133
|
+
display: flex;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
align-items: center;
|
|
136
|
+
pointer-events: none;
|
|
137
|
+
user-select: none;
|
|
138
|
+
color: var(--wx-input-icon-color);
|
|
139
|
+
}
|
|
140
|
+
.wx-icon:before {
|
|
141
|
+
display: block;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.wx-nowrap .wx-label {
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
overflow: hidden;
|
|
147
|
+
text-overflow: ellipsis;
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
const dispatch = createEventDispatcher();
|
|
4
|
+
|
|
5
|
+
export let options;
|
|
6
|
+
export let value;
|
|
7
|
+
export let css;
|
|
8
|
+
|
|
9
|
+
function handleClick(id) {
|
|
10
|
+
value = id;
|
|
11
|
+
dispatch("select", { id });
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class={`wx-segmented ${css}`}>
|
|
16
|
+
{#each options as option (option.id)}
|
|
17
|
+
<button
|
|
18
|
+
css={option.css}
|
|
19
|
+
title={option.title || option.name}
|
|
20
|
+
class:wx-selected={option.id == value}
|
|
21
|
+
on:click={handleClick(option.id)}
|
|
22
|
+
>
|
|
23
|
+
<slot {option}>
|
|
24
|
+
{#if option.icon}
|
|
25
|
+
<i
|
|
26
|
+
class="wx-icon {option.icon} {!option.name
|
|
27
|
+
? 'wx-only'
|
|
28
|
+
: ''}"
|
|
29
|
+
/>
|
|
30
|
+
{/if}
|
|
31
|
+
{#if option.name}<span class="wx-label">{option.name}</span
|
|
32
|
+
>{/if}
|
|
33
|
+
</slot>
|
|
34
|
+
</button>
|
|
35
|
+
{/each}
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<style>
|
|
39
|
+
.wx-segmented {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
flex-wrap: nowrap;
|
|
42
|
+
background: var(--wx-segmented-background);
|
|
43
|
+
border: var(--wx-segmented-border);
|
|
44
|
+
border-radius: var(--wx-segmented-border-radius);
|
|
45
|
+
padding: var(--wx-segmented-padding);
|
|
46
|
+
max-width: 100%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
button {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-wrap: nowrap;
|
|
52
|
+
align-items: center;
|
|
53
|
+
text-decoration: none;
|
|
54
|
+
text-align: center;
|
|
55
|
+
letter-spacing: normal;
|
|
56
|
+
text-transform: var(--wx-button-text-transform);
|
|
57
|
+
font-family: var(--wx-button-font-family);
|
|
58
|
+
font-size: var(--wx-button-font-size);
|
|
59
|
+
line-height: var(--wx-button-line-height);
|
|
60
|
+
font-weight: var(--wx-button-font-weight);
|
|
61
|
+
padding: var(--wx-button-padding);
|
|
62
|
+
border: var(--wx-button-border);
|
|
63
|
+
border-radius: var(--wx-segmented-border-radius);
|
|
64
|
+
background: transparent;
|
|
65
|
+
color: var(--wx-button-font-color);
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
box-shadow: none;
|
|
68
|
+
transition: none;
|
|
69
|
+
max-width: 100%;
|
|
70
|
+
user-select: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
button,
|
|
74
|
+
button:focus,
|
|
75
|
+
button:active {
|
|
76
|
+
outline: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
button + button {
|
|
80
|
+
margin-left: var(--wx-segmented-padding);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
button:hover {
|
|
84
|
+
background: var(--wx-segmented-background-hover);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
button.wx-selected,
|
|
88
|
+
button.wx-selected:hover,
|
|
89
|
+
button.wx-selected:focus {
|
|
90
|
+
background: var(--wx-color-primary);
|
|
91
|
+
color: var(--wx-color-primary-font);
|
|
92
|
+
cursor: default;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.wx-icon {
|
|
96
|
+
position: relative;
|
|
97
|
+
font-size: var(--wx-button-icon-size);
|
|
98
|
+
line-height: 1;
|
|
99
|
+
height: var(--wx-button-line-height);
|
|
100
|
+
opacity: 0.7;
|
|
101
|
+
}
|
|
102
|
+
.wx-icon:before {
|
|
103
|
+
display: block;
|
|
104
|
+
position: relative;
|
|
105
|
+
top: 50%;
|
|
106
|
+
transform: translateY(-50%);
|
|
107
|
+
}
|
|
108
|
+
.wx-icon.wx-only {
|
|
109
|
+
opacity: 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.wx-icon + .wx-label {
|
|
113
|
+
margin-left: 4px;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { uid } from "wx-lib-dom";
|
|
3
|
+
export let label = "label";
|
|
4
|
+
export let value = "";
|
|
5
|
+
export let options = [];
|
|
6
|
+
export let placeholder = "";
|
|
7
|
+
export let title;
|
|
8
|
+
export let disabled = false;
|
|
9
|
+
export let error = false;
|
|
10
|
+
|
|
11
|
+
export let id = uid();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div class="wx-select">
|
|
15
|
+
<select {id} bind:value {disabled} class:wx-error={error} {title}>
|
|
16
|
+
{#each options as option (option.id)}
|
|
17
|
+
<option value={option.id}>{option[label]}</option>
|
|
18
|
+
{/each}
|
|
19
|
+
</select>
|
|
20
|
+
{#if !value && value !== 0}
|
|
21
|
+
<div class="wx-placeholder">{placeholder}</div>
|
|
22
|
+
{/if}
|
|
23
|
+
<i class="wx-icon wxi-angle-down" />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<style>
|
|
27
|
+
.wx-select {
|
|
28
|
+
position: relative;
|
|
29
|
+
width: var(--wx-input-width);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
select {
|
|
33
|
+
appearance: none;
|
|
34
|
+
display: block;
|
|
35
|
+
width: 100%;
|
|
36
|
+
height: var(--wx-input-height);
|
|
37
|
+
outline: none;
|
|
38
|
+
background: var(--wx-input-background);
|
|
39
|
+
border: var(--wx-input-border);
|
|
40
|
+
border-radius: var(--wx-input-border-radius);
|
|
41
|
+
font-family: var(--wx-input-font-family);
|
|
42
|
+
font-size: var(--wx-input-font-size);
|
|
43
|
+
line-height: var(--wx-input-line-height);
|
|
44
|
+
font-weight: var(--wx-input-font-weight);
|
|
45
|
+
text-align: var(--wx-input-text-align);
|
|
46
|
+
color: var(--wx-input-font-color);
|
|
47
|
+
padding: var(--wx-input-padding);
|
|
48
|
+
padding-right: calc(
|
|
49
|
+
var(--wx-input-icon-size) + var(--wx-input-icon-indent) * 2
|
|
50
|
+
);
|
|
51
|
+
overflow: hidden !important;
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
}
|
|
55
|
+
select:focus {
|
|
56
|
+
border: var(--wx-input-border-focus);
|
|
57
|
+
}
|
|
58
|
+
select[disabled] {
|
|
59
|
+
cursor: not-allowed;
|
|
60
|
+
border: var(--wx-input-border-disabled);
|
|
61
|
+
color: var(--wx-color-font-disabled);
|
|
62
|
+
background: var(--wx-input-background-disabled);
|
|
63
|
+
}
|
|
64
|
+
select[disabled] ~ .wx-placeholder {
|
|
65
|
+
color: var(--wx-color-font-disabled);
|
|
66
|
+
}
|
|
67
|
+
select[disabled] ~ .wx-icon {
|
|
68
|
+
color: var(--wx-color-font-disabled);
|
|
69
|
+
}
|
|
70
|
+
select.wx-error {
|
|
71
|
+
border-color: var(--wx-color-danger);
|
|
72
|
+
color: var(--wx-color-danger);
|
|
73
|
+
}
|
|
74
|
+
select.wx-error option {
|
|
75
|
+
color: var(--wx-input-font-color);
|
|
76
|
+
}
|
|
77
|
+
select.wx-error ~ .wx-icon {
|
|
78
|
+
color: var(--wx-color-danger);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.wx-placeholder {
|
|
82
|
+
position: absolute;
|
|
83
|
+
left: 0;
|
|
84
|
+
top: 0;
|
|
85
|
+
width: 100%;
|
|
86
|
+
border: var(--wx-input-border);
|
|
87
|
+
border-color: transparent;
|
|
88
|
+
font-family: var(--wx-input-font-family);
|
|
89
|
+
font-size: var(--wx-input-font-size);
|
|
90
|
+
line-height: var(--wx-input-line-height);
|
|
91
|
+
font-weight: var(--wx-input-font-weight);
|
|
92
|
+
text-align: var(--wx-input-text-align);
|
|
93
|
+
color: var(--wx-input-placeholder-color);
|
|
94
|
+
padding: var(--wx-input-padding);
|
|
95
|
+
padding-right: calc(
|
|
96
|
+
var(--wx-input-icon-size) + var(--wx-input-icon-indent) * 2
|
|
97
|
+
);
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
overflow: hidden !important;
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
pointer-events: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.wx-icon {
|
|
106
|
+
position: absolute;
|
|
107
|
+
right: var(--wx-input-icon-indent);
|
|
108
|
+
top: 50%;
|
|
109
|
+
transform: translateY(-50%);
|
|
110
|
+
font-size: var(--wx-input-icon-size);
|
|
111
|
+
line-height: 1;
|
|
112
|
+
width: var(--wx-input-icon-size);
|
|
113
|
+
height: var(--wx-input-icon-size);
|
|
114
|
+
display: flex;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
align-items: center;
|
|
117
|
+
pointer-events: none;
|
|
118
|
+
user-select: none;
|
|
119
|
+
color: var(--wx-input-icon-color);
|
|
120
|
+
}
|
|
121
|
+
.wx-icon:before {
|
|
122
|
+
display: block;
|
|
123
|
+
}
|
|
124
|
+
</style>
|