wx-svelte-core 1.3.0 → 2.0.0-beta-1
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 +18 -3
- package/readme.md +68 -0
- 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 +21 -22
- 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 +16 -6
- 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 -30
- package/src/components/calendar/Year.svelte +17 -18
- package/src/components/calendar/helpers.js +3 -7
- 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/whatsnew.md +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wx-svelte-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta-1",
|
|
4
|
+
"description": "SVAR Svelte Core library, a collection of form controls and UI components",
|
|
4
5
|
"productTag": "core",
|
|
5
6
|
"productTrial": false,
|
|
6
7
|
"type": "module",
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
"build": "vite build",
|
|
9
10
|
"build:dist": "vite build --mode dist",
|
|
10
11
|
"build:tests": "vite build --mode test",
|
|
11
|
-
"lint": "yarn eslint ./demos ./src
|
|
12
|
+
"lint": "yarn eslint ./demos ./src",
|
|
12
13
|
"start": "vite --open",
|
|
13
14
|
"start:tests": "vite --open=/tests/ --host 0.0.0.0 --port 5100 --mode test",
|
|
14
15
|
"test": "true",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
},
|
|
24
25
|
"license": "MIT",
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"wx-core-locales": "
|
|
27
|
+
"wx-core-locales": "2.0.0-beta-1",
|
|
27
28
|
"wx-lib-dom": "0.6.0"
|
|
28
29
|
},
|
|
29
30
|
"files": [
|
|
@@ -31,5 +32,19 @@
|
|
|
31
32
|
"readme.md",
|
|
32
33
|
"whatsnew.md",
|
|
33
34
|
"license.txt"
|
|
35
|
+
],
|
|
36
|
+
"keywords": [
|
|
37
|
+
"svelte",
|
|
38
|
+
"svelte library",
|
|
39
|
+
"svelte ui components",
|
|
40
|
+
"svelte-ui-library",
|
|
41
|
+
"component-library",
|
|
42
|
+
"components library",
|
|
43
|
+
"ui library",
|
|
44
|
+
"ui-library",
|
|
45
|
+
"ui components",
|
|
46
|
+
"ui components",
|
|
47
|
+
"svelte ui library",
|
|
48
|
+
"svar widgets"
|
|
34
49
|
]
|
|
35
50
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# SVAR Svelte Core | UI Library
|
|
4
|
+
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
|
|
9
|
+
[Website](https://svar.dev/svelte/core/) • [Getting Started](https://docs.svar.dev/svelte/core/getting_started/) • [Demos](https://docs.svar.dev/svelte/core/samples/#/calendar/willow)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
|
|
15
|
+
[](https://www.npmjs.com/package/wx-svelte-core)
|
|
16
|
+
[](https://github.com/svar-widgets/core/blob/main/license.txt)
|
|
17
|
+
[](https://www.npmjs.com/package/wx-svelte-core)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
[SVAR Core library](https://svar.dev/svelte/core/) offers a set of 20+ ready-made Svelte UI components: form controls, popups, date and time picker, toast notifications, and more.
|
|
22
|
+
All components are lightweight, responsive, fast-performing, and available in light and dark skins.
|
|
23
|
+
|
|
24
|
+
<img src="https://cdn.svar.dev/public/core-ui-dark.jpg" alt="SVAR Core Library - Dark Skin" style="width: 600px;">
|
|
25
|
+
|
|
26
|
+
In addition to the Core library, you can use the following SVAR components to build unified app UIs:
|
|
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
|
+
# :hammer_and_wrench: How to Use
|
|
33
|
+
|
|
34
|
+
To use any of the Core components, simply import the package and include the desired component in your Svelte file:
|
|
35
|
+
|
|
36
|
+
```svelte
|
|
37
|
+
<script>
|
|
38
|
+
import { Button } from "wx-svelte-core";
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<Button>Click me</Button>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
See the [getting started guide](https://docs.svar.dev/svelte/core/getting_started/) to quickly set up and begin using SVAR Core components in your Svelte projects.
|
|
45
|
+
|
|
46
|
+
### :computer: How to Modify
|
|
47
|
+
|
|
48
|
+
Typically, you don't need to modify the code. However, if you wish to do so, follow these steps:
|
|
49
|
+
|
|
50
|
+
1. Run `yarn` to install dependencies. Note that this project is a monorepo using `yarn` workspaces, so npm will not work
|
|
51
|
+
2. Start the project in development mode with `yarn start`
|
|
52
|
+
|
|
53
|
+
### :white_check_mark: Run Tests
|
|
54
|
+
|
|
55
|
+
To run the test:
|
|
56
|
+
|
|
57
|
+
1. Start the test examples with:
|
|
58
|
+
```sh
|
|
59
|
+
yarn start:tests
|
|
60
|
+
```
|
|
61
|
+
2. In a separate console, run the end-to-end tests with:
|
|
62
|
+
```sh
|
|
63
|
+
yarn test:cypress
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### :speech_balloon: Need Help?
|
|
67
|
+
|
|
68
|
+
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,42 +1,41 @@
|
|
|
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
|
-
function fixCurrent() {
|
|
14
|
-
if (!current) current = value ? new Date(value) : new Date();
|
|
13
|
+
function fixCurrent(force) {
|
|
14
|
+
if (!current || force) current = value ? new Date(value) : new Date();
|
|
15
|
+
current.setDate(1);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
fixCurrent(value);
|
|
17
18
|
|
|
18
|
-
function
|
|
19
|
+
function onshift({ diff, type, month }) {
|
|
20
|
+
if (month || month === 0) {
|
|
21
|
+
current = new Date(current);
|
|
22
|
+
current.setMonth(month);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
19
25
|
const obj = configs[type];
|
|
20
26
|
current = diff > 0 ? obj.next(current) : obj.prev(current);
|
|
21
27
|
}
|
|
22
|
-
function
|
|
28
|
+
function onchange(v) {
|
|
23
29
|
const x = v.value;
|
|
24
30
|
if (x) {
|
|
25
|
-
current = new Date(x);
|
|
26
31
|
value = new Date(x);
|
|
32
|
+
fixCurrent(true);
|
|
27
33
|
} else {
|
|
28
34
|
value = null;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
change && change({ value });
|
|
32
38
|
}
|
|
33
39
|
</script>
|
|
34
40
|
|
|
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
|
-
/>
|
|
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>
|