wx-svelte-core 1.3.1 → 2.0.0-beta-2
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/package.json +3 -3
- package/readme.md +22 -4
- package/src/Locale.svelte +2 -3
- package/src/components/Area.svelte +13 -13
- package/src/components/Button.svelte +24 -31
- package/src/components/Calendar.svelte +12 -19
- package/src/components/Checkbox.svelte +13 -13
- package/src/components/CheckboxGroup.svelte +4 -7
- package/src/components/ColorBoard.svelte +25 -34
- package/src/components/ColorPicker.svelte +19 -15
- package/src/components/ColorSelect.svelte +41 -41
- package/src/components/Combo.svelte +75 -80
- package/src/components/Counter.svelte +23 -23
- package/src/components/DatePicker.svelte +28 -35
- package/src/components/DateRangePicker.svelte +37 -44
- package/src/components/Dropdown.svelte +10 -9
- package/src/components/Field.svelte +10 -7
- package/src/components/Globals.svelte +5 -3
- package/src/components/Icon.svelte +11 -10
- package/src/components/Modal.svelte +23 -15
- package/src/components/ModalArea.svelte +3 -1
- package/src/components/MultiCombo.svelte +66 -61
- package/src/components/Notice.svelte +4 -3
- package/src/components/Notices.svelte +1 -1
- package/src/components/Pager.svelte +34 -35
- package/src/components/Popup.svelte +20 -14
- package/src/components/Portal.svelte +4 -4
- package/src/components/RadioButton.svelte +12 -10
- package/src/components/RadioButtonGroup.svelte +2 -4
- package/src/components/RangeCalendar.svelte +36 -31
- package/src/components/RichSelect.svelte +28 -27
- package/src/components/Segmented.svelte +12 -11
- package/src/components/Select.svelte +11 -9
- package/src/components/SideArea.svelte +3 -5
- package/src/components/Slider.svelte +26 -27
- package/src/components/Switch.svelte +13 -5
- package/src/components/Tabs.svelte +10 -10
- package/src/components/Text.svelte +28 -39
- package/src/components/Timepicker.svelte +62 -57
- package/src/components/TwoState.svelte +25 -23
- package/src/components/calendar/Button.svelte +3 -3
- package/src/components/calendar/Duodecade.svelte +15 -15
- package/src/components/calendar/Header.svelte +23 -29
- package/src/components/calendar/Month.svelte +58 -57
- package/src/components/calendar/Panel.svelte +29 -31
- package/src/components/calendar/Year.svelte +18 -19
- package/src/components/helpers/SuggestDropdown.svelte +19 -12
- package/src/themes/FontOpenSans.svelte +1 -1
- package/src/themes/FonttRoboto.svelte +2 -1
- package/src/themes/Material.svelte +3 -4
- package/src/themes/Willow.svelte +3 -4
- package/src/themes/WillowDark.svelte +3 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wx-svelte-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta-2",
|
|
4
4
|
"description": "SVAR Svelte Core library, a collection of form controls and UI components",
|
|
5
5
|
"productTag": "core",
|
|
6
6
|
"productTrial": false,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"build": "vite build",
|
|
10
10
|
"build:dist": "vite build --mode dist",
|
|
11
11
|
"build:tests": "vite build --mode test",
|
|
12
|
-
"lint": "yarn eslint ./demos ./src
|
|
12
|
+
"lint": "yarn eslint ./demos ./src",
|
|
13
13
|
"start": "vite --open",
|
|
14
14
|
"start:tests": "vite --open=/tests/ --host 0.0.0.0 --port 5100 --mode test",
|
|
15
15
|
"test": "true",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"wx-core-locales": "
|
|
27
|
+
"wx-core-locales": "2.0.0-beta-2",
|
|
28
28
|
"wx-lib-dom": "0.6.0"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
package/readme.md
CHANGED
|
@@ -24,9 +24,26 @@ All components are lightweight, responsive, fast-performing, and available in li
|
|
|
24
24
|
<img src="https://cdn.svar.dev/public/core-ui-dark.jpg" alt="SVAR Core Library - Dark Skin" style="width: 600px;">
|
|
25
25
|
|
|
26
26
|
In addition to the Core library, you can use the following SVAR components to build unified app UIs:
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
27
|
+
|
|
28
|
+
- [Menu](https://www.npmjs.com/package/wx-svelte-menu)
|
|
29
|
+
- [Toolbar](https://www.npmjs.com/package/wx-svelte-toolbar)
|
|
30
|
+
- [File uploader](https://www.npmjs.com/package/wx-svelte-uploader)
|
|
31
|
+
|
|
32
|
+
### Svelte 4 and Svelte 5 versions
|
|
33
|
+
|
|
34
|
+
There are two versions of the library: the 1.x version, designed to work with Svelte 4, and the 2.x version, created for Svelte 5. Please note that the 2.x version is in beta and may contain some instabilities.
|
|
35
|
+
|
|
36
|
+
To use the SVAR Core beta for Svelte 5, install it as follows:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
npm install wx-svelte-core
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To use the SVAR Core for Svelte 4:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
npm install wx-svelte-core@1.3.0
|
|
46
|
+
```
|
|
30
47
|
|
|
31
48
|
# :hammer_and_wrench: How to Use
|
|
32
49
|
|
|
@@ -61,6 +78,7 @@ To run the test:
|
|
|
61
78
|
```sh
|
|
62
79
|
yarn test:cypress
|
|
63
80
|
```
|
|
81
|
+
|
|
64
82
|
### :speech_balloon: Need Help?
|
|
65
83
|
|
|
66
|
-
Join our [community forum](https://forum.svar.dev) to get help or submit feature requests.
|
|
84
|
+
Join our [community forum](https://forum.svar.dev) to get help or submit feature requests.
|
package/src/Locale.svelte
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import { locale } from "wx-lib-dom";
|
|
4
4
|
import { en } from "wx-core-locales";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
export let optional = false;
|
|
6
|
+
let { words = null, optional = false, children } = $props();
|
|
8
7
|
|
|
9
8
|
let l = getContext("wx-i18n");
|
|
10
9
|
if (!l) {
|
|
@@ -14,4 +13,4 @@
|
|
|
14
13
|
setContext("wx-i18n", l);
|
|
15
14
|
</script>
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
{@render children?.()}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { uid } from "wx-lib-dom";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
let {
|
|
5
|
+
value = $bindable(""),
|
|
6
|
+
id = uid(),
|
|
7
|
+
placeholder = "",
|
|
8
|
+
title = "",
|
|
9
|
+
disabled = false,
|
|
10
|
+
error = false,
|
|
11
|
+
readonly = false,
|
|
12
|
+
onchange,
|
|
13
|
+
} = $props();
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<textarea
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
{placeholder}
|
|
23
23
|
{readonly}
|
|
24
24
|
{title}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
oninput={() => onchange && onchange({ value, input: true })}
|
|
26
|
+
onchange={() => onchange && onchange({ value })}
|
|
27
|
+
></textarea>
|
|
28
28
|
|
|
29
29
|
<style>
|
|
30
30
|
.wx-textarea {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let buttonCss;
|
|
15
|
-
$: {
|
|
2
|
+
let {
|
|
3
|
+
type = "",
|
|
4
|
+
css = "",
|
|
5
|
+
icon = "",
|
|
6
|
+
disabled = false,
|
|
7
|
+
title = "",
|
|
8
|
+
text = "",
|
|
9
|
+
children,
|
|
10
|
+
onclick,
|
|
11
|
+
} = $props();
|
|
12
|
+
|
|
13
|
+
let buttonCss = $derived.by(() => {
|
|
16
14
|
let cssType = type
|
|
17
15
|
? type
|
|
18
16
|
.split(" ")
|
|
@@ -20,28 +18,23 @@
|
|
|
20
18
|
.map(x => "wx-" + x)
|
|
21
19
|
.join(" ")
|
|
22
20
|
: "";
|
|
23
|
-
|
|
24
|
-
}
|
|
21
|
+
return css + (css ? " " : "") + cssType;
|
|
22
|
+
});
|
|
25
23
|
|
|
26
|
-
const dispatch = createEventDispatcher();
|
|
27
24
|
const handleClick = ev => {
|
|
28
|
-
|
|
29
|
-
dispatch("click");
|
|
30
|
-
if (click) click(ev);
|
|
25
|
+
onclick && onclick(ev);
|
|
31
26
|
};
|
|
32
27
|
</script>
|
|
33
28
|
|
|
34
29
|
<button
|
|
35
30
|
{title}
|
|
36
31
|
class={`wx-button ${buttonCss}`}
|
|
37
|
-
class:wx-icon={icon &&
|
|
32
|
+
class:wx-icon={icon && !children}
|
|
38
33
|
{disabled}
|
|
39
|
-
|
|
34
|
+
onclick={handleClick}
|
|
40
35
|
>
|
|
41
|
-
{#if icon}<i class={icon}
|
|
42
|
-
{#if
|
|
43
|
-
<slot />
|
|
44
|
-
{:else}{text}{/if}
|
|
36
|
+
{#if icon}<i class={icon}></i>{/if}
|
|
37
|
+
{#if children}{@render children()}{:else}{text}{/if}
|
|
45
38
|
</button>
|
|
46
39
|
|
|
47
40
|
<style>
|
|
@@ -85,7 +78,7 @@
|
|
|
85
78
|
outline: none;
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
.wx-button:active:not([disabled]) {
|
|
81
|
+
.wx-button:active:not(:global([disabled])) {
|
|
89
82
|
opacity: 0.8;
|
|
90
83
|
}
|
|
91
84
|
|
|
@@ -142,10 +135,10 @@
|
|
|
142
135
|
color: var(--wx-color-secondary-font);
|
|
143
136
|
border-color: var(--wx-color-secondary-border);
|
|
144
137
|
}
|
|
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]) {
|
|
138
|
+
.wx-secondary:hover:not(:global([disabled])),
|
|
139
|
+
.wx-secondary.wx-pressed:not(:global([disabled])),
|
|
140
|
+
.wx-secondary.wx-pressed:hover:not(:global([disabled])),
|
|
141
|
+
.wx-secondary.wx-pressed:active:not(:global([disabled])) {
|
|
149
142
|
background: var(--wx-color-secondary-hover);
|
|
150
143
|
color: var(--wx-color-secondary-font-hover);
|
|
151
144
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
|
-
const dispatch = createEventDispatcher();
|
|
4
|
-
|
|
5
2
|
import Panel from "./calendar/Panel.svelte";
|
|
6
3
|
import { configs } from "./calendar/helpers";
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
let {
|
|
6
|
+
value = $bindable(),
|
|
7
|
+
current = $bindable(),
|
|
8
|
+
markers = null,
|
|
9
|
+
buttons = true,
|
|
10
|
+
onchange: change,
|
|
11
|
+
} = $props();
|
|
12
12
|
|
|
13
13
|
function fixCurrent(force) {
|
|
14
14
|
if (!current || force) current = value ? new Date(value) : new Date();
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
}
|
|
17
17
|
fixCurrent(value);
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function onshift({ diff, type, month }) {
|
|
20
20
|
if (month || month === 0) {
|
|
21
|
+
current = new Date(current);
|
|
21
22
|
current.setMonth(month);
|
|
22
|
-
current = current;
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
const obj = configs[type];
|
|
26
26
|
current = diff > 0 ? obj.next(current) : obj.prev(current);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function onchange(v) {
|
|
29
29
|
const x = v.value;
|
|
30
30
|
if (x) {
|
|
31
31
|
value = new Date(x);
|
|
@@ -34,15 +34,8 @@
|
|
|
34
34
|
value = null;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
change && change({ value });
|
|
38
38
|
}
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
|
-
<Panel
|
|
42
|
-
{value}
|
|
43
|
-
{current}
|
|
44
|
-
{markers}
|
|
45
|
-
{buttons}
|
|
46
|
-
on:shift={ev => doShift(ev.detail)}
|
|
47
|
-
on:change={ev => doChange(ev.detail)}
|
|
48
|
-
/>
|
|
41
|
+
<Panel {value} bind:current {markers} {buttons} {onshift} {onchange} />
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { uid } from "wx-lib-dom";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
let {
|
|
5
|
+
id = uid(),
|
|
6
|
+
label = "",
|
|
7
|
+
name = "",
|
|
8
|
+
value = $bindable(false),
|
|
9
|
+
style = "",
|
|
10
|
+
disabled = false,
|
|
11
|
+
onchange,
|
|
12
|
+
} = $props();
|
|
13
13
|
|
|
14
14
|
function handlerChange({ target }) {
|
|
15
15
|
value = target.checked;
|
|
16
|
-
|
|
16
|
+
onchange && onchange({ value, name });
|
|
17
17
|
}
|
|
18
18
|
</script>
|
|
19
19
|
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
{disabled}
|
|
25
25
|
checked={value}
|
|
26
26
|
value={name}
|
|
27
|
-
|
|
27
|
+
onchange={handlerChange}
|
|
28
28
|
/>
|
|
29
29
|
<label for={id}>
|
|
30
|
-
<span
|
|
30
|
+
<span></span>
|
|
31
31
|
{#if label}<span>{label}</span>{/if}
|
|
32
32
|
</label>
|
|
33
33
|
</div>
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
color: var(--wx-checkbox-border-color-disabled);
|
|
121
121
|
cursor: not-allowed;
|
|
122
122
|
}
|
|
123
|
-
input[disabled]:not(:checked) ~ label span:first-child:before {
|
|
123
|
+
input[disabled]:not(:global(:checked)) ~ label span:first-child:before {
|
|
124
124
|
border-color: var(--wx-checkbox-border-color-disabled);
|
|
125
125
|
}
|
|
126
126
|
input[disabled]:checked ~ label span:first-child:before {
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import Checkbox from "./Checkbox.svelte";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export let value = [];
|
|
6
|
-
export let type;
|
|
4
|
+
let { options = [], value = $bindable([]), type = "" } = $props();
|
|
7
5
|
|
|
8
|
-
function handleChange(
|
|
9
|
-
const obj = ev.detail;
|
|
6
|
+
function handleChange(obj) {
|
|
10
7
|
if (obj.value) value = [...value, obj.name];
|
|
11
8
|
else value = value.filter(a => a != obj.name);
|
|
12
9
|
}
|
|
13
10
|
</script>
|
|
14
11
|
|
|
15
|
-
<div class="wx-checkboxgroup wx
|
|
12
|
+
<div class="wx-checkboxgroup {type && `wx-${type}`}">
|
|
16
13
|
{#each options as option}
|
|
17
14
|
<div class="wx-item">
|
|
18
15
|
<Checkbox
|
|
19
16
|
label={option.label}
|
|
20
17
|
name={option.value}
|
|
21
18
|
value={value.includes(option.value)}
|
|
22
|
-
|
|
19
|
+
onchange={handleChange}
|
|
23
20
|
/>
|
|
24
21
|
</div>
|
|
25
22
|
{/each}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
3
|
import Button from "./Button.svelte";
|
|
4
4
|
|
|
5
5
|
//helpers
|
|
@@ -7,21 +7,21 @@
|
|
|
7
7
|
import colorTransformator from "./helpers/colorTransformator";
|
|
8
8
|
import { parseColor } from "./helpers/colorValidation.js";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
let { value = $bindable("#65D3B3"), button = false, onchange } = $props();
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
export let button = false;
|
|
12
|
+
let block;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const BLOCK = "Block";
|
|
15
|
+
const LINE = "Line";
|
|
17
16
|
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
let
|
|
21
|
-
let
|
|
17
|
+
let blockTop = $state();
|
|
18
|
+
let blockLeft = $state();
|
|
19
|
+
let hueColor = $state();
|
|
20
|
+
let colorLine = $state();
|
|
21
|
+
let lineLeft = $state();
|
|
22
22
|
|
|
23
|
-
let
|
|
24
|
-
let
|
|
23
|
+
let color = $derived(parseColor(value) || "#65D3B3");
|
|
24
|
+
let blockColor = $derived(colorTransformator.hvsToHex(hueColor, 1, 1));
|
|
25
25
|
|
|
26
26
|
function moveBlockSlider(dx, dy) {
|
|
27
27
|
const { width, height } = block.getBoundingClientRect();
|
|
@@ -56,9 +56,6 @@
|
|
|
56
56
|
value = colorTransformator.hvsToHex(hueColor, _sValue, _vValue);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
let hueColor;
|
|
60
|
-
$: blockColor = colorTransformator.hvsToHex(hueColor, 1, 1);
|
|
61
|
-
|
|
62
59
|
function moveLineSlider(dx) {
|
|
63
60
|
const width = colorLine.getBoundingClientRect().width;
|
|
64
61
|
|
|
@@ -94,7 +91,7 @@
|
|
|
94
91
|
function handleChange({ target }) {
|
|
95
92
|
const newColor = parseColor(target.value);
|
|
96
93
|
|
|
97
|
-
value =
|
|
94
|
+
value = newColor;
|
|
98
95
|
if (newColor) {
|
|
99
96
|
setSlidersPosition();
|
|
100
97
|
}
|
|
@@ -102,12 +99,9 @@
|
|
|
102
99
|
|
|
103
100
|
function handleSelect(ev) {
|
|
104
101
|
ev.stopPropagation();
|
|
105
|
-
|
|
102
|
+
onchange && onchange({ value: color });
|
|
106
103
|
}
|
|
107
104
|
|
|
108
|
-
const BLOCK = "Block";
|
|
109
|
-
const LINE = "Line";
|
|
110
|
-
|
|
111
105
|
function keydown(ev) {
|
|
112
106
|
const slider = ev.target;
|
|
113
107
|
const isSliderBlock = slider === BLOCK;
|
|
@@ -161,40 +155,37 @@
|
|
|
161
155
|
bind:this={block}
|
|
162
156
|
use:sliderMove={{ moveBlockSlider }}
|
|
163
157
|
>
|
|
164
|
-
<!-- svelte-ignore
|
|
158
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
159
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
165
160
|
<div
|
|
166
161
|
class="wx-color-block-slider wx-slider"
|
|
167
162
|
style="background: {color}; top: {blockTop}px; left:{blockLeft}px;"
|
|
168
163
|
tabindex="0"
|
|
169
164
|
data-slider={BLOCK}
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
onkeydown={keydown}
|
|
166
|
+
></div>
|
|
172
167
|
</div>
|
|
173
168
|
<div
|
|
174
169
|
class="wx-color-line"
|
|
175
170
|
bind:this={colorLine}
|
|
176
171
|
use:sliderMove={{ moveLineSlider }}
|
|
177
172
|
>
|
|
178
|
-
<!-- svelte-ignore
|
|
173
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
174
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
179
175
|
<div
|
|
180
176
|
class="wx-color-line-slider wx-slider"
|
|
181
177
|
style="background: {blockColor}; left: {lineLeft}px;"
|
|
182
178
|
tabindex="0"
|
|
183
179
|
data-slider={LINE}
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
onkeydown={keydown}
|
|
181
|
+
></div>
|
|
186
182
|
</div>
|
|
187
183
|
<div class="wx-color-controls">
|
|
188
|
-
<div class="wx-color" style="background: {color}"
|
|
189
|
-
<input
|
|
190
|
-
type="text"
|
|
191
|
-
class="wx-text"
|
|
192
|
-
bind:value
|
|
193
|
-
on:change={handleChange}
|
|
194
|
-
/>
|
|
184
|
+
<div class="wx-color" style="background: {color}"></div>
|
|
185
|
+
<input type="text" class="wx-text" bind:value onchange={handleChange} />
|
|
195
186
|
</div>
|
|
196
187
|
{#if button}
|
|
197
|
-
<Button
|
|
188
|
+
<Button onclick={handleSelect} type="secondary">Select</Button>
|
|
198
189
|
{/if}
|
|
199
190
|
</div>
|
|
200
191
|
|
|
@@ -3,28 +3,32 @@
|
|
|
3
3
|
import Dropdown from "./Dropdown.svelte";
|
|
4
4
|
import ColorBoard from "./ColorBoard.svelte";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
let {
|
|
7
|
+
value = $bindable(""),
|
|
8
|
+
id = uid(),
|
|
9
|
+
placeholder = "",
|
|
10
|
+
title = "",
|
|
11
|
+
disabled = false,
|
|
12
|
+
error = false,
|
|
13
|
+
onchange,
|
|
14
|
+
} = $props();
|
|
12
15
|
|
|
13
|
-
let popup;
|
|
16
|
+
let popup = $state(false);
|
|
14
17
|
|
|
15
18
|
function handlePopup() {
|
|
16
19
|
if (disabled) return false;
|
|
17
20
|
popup = true;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
function selectColor(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
function selectColor({ value }) {
|
|
24
|
+
popup = false;
|
|
25
|
+
onchange && onchange({ value });
|
|
23
26
|
}
|
|
24
27
|
</script>
|
|
25
28
|
|
|
26
|
-
<!-- svelte-ignore
|
|
27
|
-
|
|
29
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
30
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
31
|
+
<div class="wx-colorpicker" onclick={handlePopup}>
|
|
28
32
|
<input
|
|
29
33
|
{title}
|
|
30
34
|
{value}
|
|
@@ -35,11 +39,11 @@
|
|
|
35
39
|
class:wx-error={error}
|
|
36
40
|
class:wx-focus={popup}
|
|
37
41
|
/>
|
|
38
|
-
<div class="wx-color" style="background: {value}"
|
|
42
|
+
<div class="wx-color" style="background: {value}"></div>
|
|
39
43
|
|
|
40
44
|
{#if popup}
|
|
41
|
-
<Dropdown cancel={() => (popup =
|
|
42
|
-
<ColorBoard {value} button="true"
|
|
45
|
+
<Dropdown cancel={() => (popup = false)}>
|
|
46
|
+
<ColorBoard {value} button="true" onchange={selectColor} />
|
|
43
47
|
</Dropdown>
|
|
44
48
|
{/if}
|
|
45
49
|
</div>
|
|
@@ -2,38 +2,37 @@
|
|
|
2
2
|
import { uid } from "wx-lib-dom";
|
|
3
3
|
import Dropdown from "./Dropdown.svelte";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const defaultColors = [
|
|
6
6
|
"#00a037",
|
|
7
|
-
"#
|
|
8
|
-
"#
|
|
9
|
-
"#
|
|
10
|
-
"#
|
|
11
|
-
"#
|
|
12
|
-
"#
|
|
13
|
-
"#eb2f89",
|
|
14
|
-
"#ea77c0",
|
|
15
|
-
"#777676",
|
|
16
|
-
"#a9a8a8",
|
|
17
|
-
"#9bb402",
|
|
18
|
-
"#e7a90b",
|
|
19
|
-
"#0bbed7",
|
|
20
|
-
"#038cd9",
|
|
7
|
+
"#37a9ef",
|
|
8
|
+
"#f5a623",
|
|
9
|
+
"#ff4c3b",
|
|
10
|
+
"#a0a0a0",
|
|
11
|
+
"#000000",
|
|
12
|
+
"#ffffff",
|
|
21
13
|
];
|
|
22
|
-
export let value = "";
|
|
23
|
-
export let id = uid();
|
|
24
|
-
export let clear = true;
|
|
25
|
-
export let placeholder = "";
|
|
26
|
-
export let title;
|
|
27
|
-
export let disabled = false;
|
|
28
|
-
export let error = false;
|
|
29
14
|
|
|
30
|
-
let
|
|
15
|
+
let {
|
|
16
|
+
colors = defaultColors,
|
|
17
|
+
value = $bindable(""),
|
|
18
|
+
id = uid(),
|
|
19
|
+
clear = true,
|
|
20
|
+
placeholder = "",
|
|
21
|
+
title = "",
|
|
22
|
+
disabled = false,
|
|
23
|
+
error = false,
|
|
24
|
+
} = $props();
|
|
25
|
+
|
|
26
|
+
let popup = $state(false);
|
|
27
|
+
|
|
28
|
+
function selectColor(ev, color) {
|
|
29
|
+
ev.stopPropagation();
|
|
31
30
|
|
|
32
|
-
function selectColor(color) {
|
|
33
31
|
value = color;
|
|
34
|
-
popup =
|
|
32
|
+
popup = false;
|
|
35
33
|
}
|
|
36
|
-
function handleClear() {
|
|
34
|
+
function handleClear(ev) {
|
|
35
|
+
ev.stopPropagation();
|
|
37
36
|
value = null;
|
|
38
37
|
}
|
|
39
38
|
function handlePopup() {
|
|
@@ -42,8 +41,9 @@
|
|
|
42
41
|
}
|
|
43
42
|
</script>
|
|
44
43
|
|
|
45
|
-
<!-- svelte-ignore
|
|
46
|
-
|
|
44
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
45
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
46
|
+
<div class="wx-colorselect" onclick={handlePopup}>
|
|
47
47
|
<input
|
|
48
48
|
{title}
|
|
49
49
|
{value}
|
|
@@ -56,34 +56,34 @@
|
|
|
56
56
|
/>
|
|
57
57
|
|
|
58
58
|
{#if clear && value && !disabled}
|
|
59
|
-
<!-- svelte-ignore
|
|
60
|
-
|
|
59
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
60
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
61
|
+
<i class="wx-clear wxi-close" onclick={handleClear}></i>
|
|
61
62
|
{/if}
|
|
62
63
|
|
|
63
64
|
{#if value}
|
|
64
65
|
<div
|
|
65
66
|
class="wx-color wx-selected"
|
|
66
67
|
style="background-color: {value || '#00a037'}"
|
|
67
|
-
|
|
68
|
+
></div>
|
|
68
69
|
{:else}
|
|
69
|
-
<div class="wx-empty wx-selected"
|
|
70
|
+
<div class="wx-empty wx-selected"></div>
|
|
70
71
|
{/if}
|
|
71
72
|
|
|
72
73
|
{#if popup}
|
|
73
|
-
<Dropdown cancel={() => (popup =
|
|
74
|
+
<Dropdown cancel={() => (popup = false)}>
|
|
74
75
|
<div class="wx-colors">
|
|
75
|
-
<!-- svelte-ignore
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
on:click|stopPropagation={() => selectColor("")}
|
|
79
|
-
/>
|
|
76
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
77
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
78
|
+
<div class="wx-empty" onclick={ev => selectColor(ev, "")}></div>
|
|
80
79
|
{#each colors as color}
|
|
81
|
-
<!-- svelte-ignore
|
|
80
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
81
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
82
82
|
<div
|
|
83
83
|
class="wx-color"
|
|
84
84
|
style="background-color: {color}"
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
onclick={ev => selectColor(ev, color)}
|
|
86
|
+
></div>
|
|
87
87
|
{/each}
|
|
88
88
|
</div>
|
|
89
89
|
</Dropdown>
|