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
package/license.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 XB Software Sp. z o.o.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wx-svelte-core",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"productTag": "core",
|
|
5
|
+
"productTrial": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"build:dist": "vite build --mode dist",
|
|
10
|
+
"build:tests": "vite build --mode test",
|
|
11
|
+
"lint": "yarn eslint ./demos ./src --ext .svelte,.ts,.js",
|
|
12
|
+
"start": "vite --open",
|
|
13
|
+
"start:tests": "vite --open=/tests/ --host 0.0.0.0 --port 5100 --mode test",
|
|
14
|
+
"test": "true",
|
|
15
|
+
"test:cypress": "cypress run -P ./ --config \"baseUrl=http://localhost:5100/tests\""
|
|
16
|
+
},
|
|
17
|
+
"svelte": "src/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"svelte": "./src/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"wx-core-locales": "1.3.0",
|
|
27
|
+
"wx-lib-dom": "0.6.0"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"src",
|
|
31
|
+
"readme.md",
|
|
32
|
+
"whatsnew.md",
|
|
33
|
+
"license.txt"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getContext, setContext } from "svelte";
|
|
3
|
+
import { locale } from "wx-lib-dom";
|
|
4
|
+
import { en } from "wx-core-locales";
|
|
5
|
+
|
|
6
|
+
export let words = null;
|
|
7
|
+
export let optional = false;
|
|
8
|
+
|
|
9
|
+
let l = getContext("wx-i18n");
|
|
10
|
+
if (!l) {
|
|
11
|
+
l = locale(en);
|
|
12
|
+
}
|
|
13
|
+
l = l.extend(words, optional);
|
|
14
|
+
setContext("wx-i18n", l);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<slot />
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
import { uid } from "wx-lib-dom";
|
|
4
|
+
|
|
5
|
+
export let value = "";
|
|
6
|
+
export let id = uid();
|
|
7
|
+
export let placeholder = "";
|
|
8
|
+
export let title = "";
|
|
9
|
+
export let disabled = false;
|
|
10
|
+
export let error = false;
|
|
11
|
+
export let readonly = false;
|
|
12
|
+
|
|
13
|
+
const dispatch = createEventDispatcher();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<textarea
|
|
17
|
+
class="wx-textarea"
|
|
18
|
+
class:wx-error={error}
|
|
19
|
+
bind:value
|
|
20
|
+
{id}
|
|
21
|
+
{disabled}
|
|
22
|
+
{placeholder}
|
|
23
|
+
{readonly}
|
|
24
|
+
{title}
|
|
25
|
+
on:input={() => dispatch("change", { value, input: true })}
|
|
26
|
+
on:change={() => dispatch("change", { value })}
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
.wx-textarea {
|
|
31
|
+
display: block;
|
|
32
|
+
resize: vertical;
|
|
33
|
+
width: var(--wx-input-width);
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
padding: var(--wx-input-padding);
|
|
36
|
+
outline: none;
|
|
37
|
+
min-height: 100px;
|
|
38
|
+
font-family: var(--wx-input-font-family);
|
|
39
|
+
font-size: var(--wx-input-font-size);
|
|
40
|
+
line-height: var(--wx-input-line-height);
|
|
41
|
+
font-weight: var(--wx-input-font-weight);
|
|
42
|
+
text-align: var(--wx-input-text-align);
|
|
43
|
+
color: var(--wx-input-font-color);
|
|
44
|
+
border: var(--wx-input-border);
|
|
45
|
+
border-radius: var(--wx-input-border-radius);
|
|
46
|
+
background: var(--wx-input-background);
|
|
47
|
+
}
|
|
48
|
+
.wx-textarea:focus {
|
|
49
|
+
border: var(--wx-input-border-focus);
|
|
50
|
+
}
|
|
51
|
+
.wx-textarea::placeholder {
|
|
52
|
+
color: var(--wx-input-placeholder-color);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.wx-textarea[disabled] {
|
|
56
|
+
cursor: not-allowed;
|
|
57
|
+
border: var(--wx-input-border-disabled);
|
|
58
|
+
color: var(--wx-color-font-disabled);
|
|
59
|
+
background: var(--wx-input-background-disabled);
|
|
60
|
+
resize: none;
|
|
61
|
+
}
|
|
62
|
+
.wx-textarea[disabled]::placeholder {
|
|
63
|
+
color: var(--wx-color-font-disabled);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.wx-textarea.wx-error {
|
|
67
|
+
border-color: var(--wx-color-danger);
|
|
68
|
+
color: var(--wx-color-danger);
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
|
|
4
|
+
export let type = "";
|
|
5
|
+
export let css = "";
|
|
6
|
+
export let click;
|
|
7
|
+
export let icon = "";
|
|
8
|
+
export let disabled = false;
|
|
9
|
+
export let title = "";
|
|
10
|
+
export let text = "";
|
|
11
|
+
|
|
12
|
+
const SLOTS = $$props.$$slots;
|
|
13
|
+
|
|
14
|
+
let buttonCss;
|
|
15
|
+
$: {
|
|
16
|
+
let cssType = type
|
|
17
|
+
? type
|
|
18
|
+
.split(" ")
|
|
19
|
+
.filter(a => a !== "")
|
|
20
|
+
.map(x => "wx-" + x)
|
|
21
|
+
.join(" ")
|
|
22
|
+
: "";
|
|
23
|
+
buttonCss = css + (css ? " " : "") + cssType;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const dispatch = createEventDispatcher();
|
|
27
|
+
const handleClick = ev => {
|
|
28
|
+
if (disabled) return;
|
|
29
|
+
dispatch("click");
|
|
30
|
+
if (click) click(ev);
|
|
31
|
+
};
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<button
|
|
35
|
+
{title}
|
|
36
|
+
class={`wx-button ${buttonCss}`}
|
|
37
|
+
class:wx-icon={icon && (!SLOTS || !SLOTS.default)}
|
|
38
|
+
{disabled}
|
|
39
|
+
on:click={handleClick}
|
|
40
|
+
>
|
|
41
|
+
{#if icon}<i class={icon} />{/if}
|
|
42
|
+
{#if SLOTS}
|
|
43
|
+
<slot />
|
|
44
|
+
{:else}{text}{/if}
|
|
45
|
+
</button>
|
|
46
|
+
|
|
47
|
+
<style>
|
|
48
|
+
.wx-button {
|
|
49
|
+
display: inline-block;
|
|
50
|
+
vertical-align: top;
|
|
51
|
+
text-decoration: none;
|
|
52
|
+
text-align: center;
|
|
53
|
+
letter-spacing: normal;
|
|
54
|
+
text-transform: var(--wx-button-text-transform);
|
|
55
|
+
font-family: var(--wx-button-font-family);
|
|
56
|
+
font-size: var(--wx-button-font-size);
|
|
57
|
+
line-height: var(--wx-button-line-height);
|
|
58
|
+
font-weight: var(--wx-button-font-weight);
|
|
59
|
+
padding: var(--wx-button-padding);
|
|
60
|
+
border: var(--wx-button-border);
|
|
61
|
+
border-radius: var(--wx-button-border-radius);
|
|
62
|
+
background-color: var(--wx-button-background);
|
|
63
|
+
color: var(--wx-button-font-color);
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
box-shadow: none;
|
|
66
|
+
transition: none;
|
|
67
|
+
max-width: 100%;
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
user-select: none;
|
|
72
|
+
min-width: var(--wx-button-width);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.wx-button:hover {
|
|
76
|
+
background-image: linear-gradient(
|
|
77
|
+
rgba(0, 0, 0, 0.1) 0%,
|
|
78
|
+
rgba(0, 0, 0, 0.1) 100%
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.wx-button,
|
|
83
|
+
.wx-button:focus,
|
|
84
|
+
.wx-button:active {
|
|
85
|
+
outline: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.wx-button:active:not([disabled]) {
|
|
89
|
+
opacity: 0.8;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.wx-button[disabled] {
|
|
93
|
+
cursor: not-allowed;
|
|
94
|
+
background: var(--wx-color-disabled);
|
|
95
|
+
border-color: transparent;
|
|
96
|
+
color: var(--wx-color-font-disabled);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.wx-block {
|
|
100
|
+
display: block;
|
|
101
|
+
width: 100%;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.wx-square {
|
|
105
|
+
border-radius: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
i {
|
|
109
|
+
position: relative;
|
|
110
|
+
display: inline-block;
|
|
111
|
+
vertical-align: top;
|
|
112
|
+
font-size: var(--wx-button-icon-size);
|
|
113
|
+
line-height: 1;
|
|
114
|
+
height: var(--wx-button-line-height);
|
|
115
|
+
margin-right: 2px;
|
|
116
|
+
opacity: 0.7;
|
|
117
|
+
}
|
|
118
|
+
i:before {
|
|
119
|
+
display: block;
|
|
120
|
+
position: relative;
|
|
121
|
+
top: 50%;
|
|
122
|
+
transform: translateY(-50%);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.wx-icon {
|
|
126
|
+
padding-left: var(--wx-button-icon-indent);
|
|
127
|
+
padding-right: var(--wx-button-icon-indent);
|
|
128
|
+
min-width: auto;
|
|
129
|
+
}
|
|
130
|
+
.wx-icon i {
|
|
131
|
+
margin: 0;
|
|
132
|
+
opacity: 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.wx-primary {
|
|
136
|
+
background-color: var(--wx-color-primary);
|
|
137
|
+
color: var(--wx-color-primary-font);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.wx-secondary {
|
|
141
|
+
background: var(--wx-color-secondary);
|
|
142
|
+
color: var(--wx-color-secondary-font);
|
|
143
|
+
border-color: var(--wx-color-secondary-border);
|
|
144
|
+
}
|
|
145
|
+
.wx-secondary:hover:not([disabled]),
|
|
146
|
+
.wx-secondary.wx-pressed:not([disabled]),
|
|
147
|
+
.wx-secondary.wx-pressed:hover:not([disabled]),
|
|
148
|
+
.wx-secondary.wx-pressed:active:not([disabled]) {
|
|
149
|
+
background: var(--wx-color-secondary-hover);
|
|
150
|
+
color: var(--wx-color-secondary-font-hover);
|
|
151
|
+
}
|
|
152
|
+
.wx-secondary[disabled] {
|
|
153
|
+
border-color: var(--wx-color-secondary-border-disabled);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.wx-danger {
|
|
157
|
+
background-color: var(--wx-color-danger);
|
|
158
|
+
color: var(--wx-button-danger-font-color);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.wx-link {
|
|
162
|
+
color: var(--wx-color-link);
|
|
163
|
+
padding: 0;
|
|
164
|
+
border: none;
|
|
165
|
+
vertical-align: baseline;
|
|
166
|
+
}
|
|
167
|
+
.wx-link,
|
|
168
|
+
.wx-link:hover,
|
|
169
|
+
.wx-link[disabled] {
|
|
170
|
+
background: transparent;
|
|
171
|
+
}
|
|
172
|
+
.wx-link[disabled] {
|
|
173
|
+
color: var(--wx-color-font-disabled);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.wx-pressed,
|
|
177
|
+
.wx-pressed:hover,
|
|
178
|
+
.wx-pressed:active,
|
|
179
|
+
.wx-pressed[disabled] {
|
|
180
|
+
opacity: 0.8;
|
|
181
|
+
background-image: linear-gradient(
|
|
182
|
+
rgba(0, 0, 0, 0.1) 0%,
|
|
183
|
+
rgba(0, 0, 0, 0.1) 100%
|
|
184
|
+
);
|
|
185
|
+
box-shadow: inset 0 2px 2px 1px rgba(0, 0, 0, 0.15);
|
|
186
|
+
}
|
|
187
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
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 value;
|
|
9
|
+
export let current;
|
|
10
|
+
export let markers = null;
|
|
11
|
+
export let buttons = true;
|
|
12
|
+
|
|
13
|
+
function fixCurrent() {
|
|
14
|
+
if (!current) current = value ? new Date(value) : new Date();
|
|
15
|
+
}
|
|
16
|
+
$: fixCurrent(value);
|
|
17
|
+
|
|
18
|
+
function doShift({ diff, type }) {
|
|
19
|
+
const obj = configs[type];
|
|
20
|
+
current = diff > 0 ? obj.next(current) : obj.prev(current);
|
|
21
|
+
}
|
|
22
|
+
function doChange(v) {
|
|
23
|
+
const x = v.value;
|
|
24
|
+
if (x) {
|
|
25
|
+
current = new Date(x);
|
|
26
|
+
value = new Date(x);
|
|
27
|
+
} else {
|
|
28
|
+
value = null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
dispatch("change", { value });
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<Panel
|
|
36
|
+
{value}
|
|
37
|
+
{current}
|
|
38
|
+
{markers}
|
|
39
|
+
{buttons}
|
|
40
|
+
on:shift={ev => doShift(ev.detail)}
|
|
41
|
+
on:change={ev => doChange(ev.detail)}
|
|
42
|
+
/>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
import { uid } from "wx-lib-dom";
|
|
4
|
+
|
|
5
|
+
const dispatch = createEventDispatcher();
|
|
6
|
+
|
|
7
|
+
export let id = uid();
|
|
8
|
+
export let label = "";
|
|
9
|
+
export let name = "";
|
|
10
|
+
export let value = false;
|
|
11
|
+
export let style = "";
|
|
12
|
+
export let disabled = false;
|
|
13
|
+
|
|
14
|
+
function handlerChange({ target }) {
|
|
15
|
+
value = target.checked;
|
|
16
|
+
dispatch("change", { value, name });
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<div {style} class="wx-checkbox">
|
|
21
|
+
<input
|
|
22
|
+
type="checkbox"
|
|
23
|
+
{id}
|
|
24
|
+
{disabled}
|
|
25
|
+
checked={value}
|
|
26
|
+
value={name}
|
|
27
|
+
on:change={handlerChange}
|
|
28
|
+
/>
|
|
29
|
+
<label for={id}>
|
|
30
|
+
<span />
|
|
31
|
+
{#if label}<span>{label}</span>{/if}
|
|
32
|
+
</label>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
.wx-checkbox {
|
|
37
|
+
position: relative;
|
|
38
|
+
display: inline-block;
|
|
39
|
+
vertical-align: top;
|
|
40
|
+
max-width: var(--wx-input-width);
|
|
41
|
+
}
|
|
42
|
+
input {
|
|
43
|
+
appearance: none;
|
|
44
|
+
width: 0;
|
|
45
|
+
height: 0;
|
|
46
|
+
opacity: 0;
|
|
47
|
+
position: absolute;
|
|
48
|
+
left: 0;
|
|
49
|
+
top: 0;
|
|
50
|
+
margin: 0;
|
|
51
|
+
padding: 0;
|
|
52
|
+
}
|
|
53
|
+
label {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-wrap: nowrap;
|
|
56
|
+
align-items: flex-start;
|
|
57
|
+
font-family: var(--wx-checkbox-font-family);
|
|
58
|
+
font-size: var(--wx-checkbox-font-size);
|
|
59
|
+
line-height: var(--wx-checkbox-line-height);
|
|
60
|
+
font-weight: var(--wx-checkbox-font-weight);
|
|
61
|
+
color: var(--wx-checkbox-font-color);
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
}
|
|
64
|
+
span {
|
|
65
|
+
display: block;
|
|
66
|
+
}
|
|
67
|
+
span + span {
|
|
68
|
+
margin-left: 8px;
|
|
69
|
+
padding-top: calc(
|
|
70
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-line-height)) / 2
|
|
71
|
+
);
|
|
72
|
+
padding-bottom: calc(
|
|
73
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-line-height)) / 2
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
span:first-child {
|
|
77
|
+
position: relative;
|
|
78
|
+
flex-shrink: 0;
|
|
79
|
+
padding-top: calc(
|
|
80
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-size)) / 2
|
|
81
|
+
);
|
|
82
|
+
padding-bottom: calc(
|
|
83
|
+
(var(--wx-checkbox-height) - var(--wx-checkbox-size)) / 2
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
span:first-child:before {
|
|
87
|
+
content: "";
|
|
88
|
+
display: block;
|
|
89
|
+
width: var(--wx-checkbox-size);
|
|
90
|
+
height: var(--wx-checkbox-size);
|
|
91
|
+
border: var(--wx-checkbox-border-width) solid
|
|
92
|
+
var(--wx-checkbox-border-color);
|
|
93
|
+
border-radius: var(--wx-checkbox-border-radius);
|
|
94
|
+
background: var(--wx-input-background);
|
|
95
|
+
}
|
|
96
|
+
span:first-child:after {
|
|
97
|
+
content: "";
|
|
98
|
+
position: absolute;
|
|
99
|
+
display: none;
|
|
100
|
+
left: 50%;
|
|
101
|
+
top: 50%;
|
|
102
|
+
width: calc(var(--wx-checkbox-size) * 0.56);
|
|
103
|
+
height: calc(var(--wx-checkbox-size) * 0.32);
|
|
104
|
+
border-style: solid;
|
|
105
|
+
border-color: var(--wx-color-primary-font);
|
|
106
|
+
border-width: 0 0 calc(var(--wx-checkbox-size) * 0.12)
|
|
107
|
+
calc(var(--wx-checkbox-size) * 0.12);
|
|
108
|
+
transform: rotate(-45deg);
|
|
109
|
+
margin-left: calc(var(--wx-checkbox-size) * -0.26);
|
|
110
|
+
margin-top: calc(var(--wx-checkbox-size) * -0.24);
|
|
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
|
+
input[disabled] ~ label span:first-child:after {
|
|
130
|
+
border-color: var(--wx-input-background);
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Checkbox from "./Checkbox.svelte";
|
|
3
|
+
|
|
4
|
+
export let options = [];
|
|
5
|
+
export let value = [];
|
|
6
|
+
export let type;
|
|
7
|
+
|
|
8
|
+
function handleChange(ev) {
|
|
9
|
+
const obj = ev.detail;
|
|
10
|
+
if (obj.value) value = [...value, obj.name];
|
|
11
|
+
else value = value.filter(a => a != obj.name);
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="wx-checkboxgroup wx-{type}">
|
|
16
|
+
{#each options as option}
|
|
17
|
+
<div class="wx-item">
|
|
18
|
+
<Checkbox
|
|
19
|
+
label={option.label}
|
|
20
|
+
name={option.value}
|
|
21
|
+
value={value.includes(option.value)}
|
|
22
|
+
on:change={handleChange}
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
{/each}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
.wx-checkboxgroup {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-wrap: wrap;
|
|
32
|
+
align-items: flex-start;
|
|
33
|
+
justify-content: flex-start;
|
|
34
|
+
margin-top: calc(var(--wx-field-gutter) * -1);
|
|
35
|
+
}
|
|
36
|
+
.wx-item {
|
|
37
|
+
flex: 0 0 100%;
|
|
38
|
+
max-width: 100%;
|
|
39
|
+
margin-top: var(--wx-field-gutter);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.wx-checkboxgroup.wx-inline .wx-item {
|
|
43
|
+
flex: none;
|
|
44
|
+
padding-right: var(--wx-field-gutter);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.wx-checkboxgroup.grid .wx-item {
|
|
48
|
+
flex: 0 0 50%;
|
|
49
|
+
max-width: 50%;
|
|
50
|
+
padding-right: var(--wx-field-gutter);
|
|
51
|
+
}
|
|
52
|
+
</style>
|