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,125 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { clickOutside } from "wx-lib-dom";
|
|
3
|
+
import { afterUpdate } from "svelte";
|
|
4
|
+
|
|
5
|
+
export let position = "bottom";
|
|
6
|
+
export let align = "start";
|
|
7
|
+
export let autoFit = true;
|
|
8
|
+
export let cancel = null;
|
|
9
|
+
export let width = "100%";
|
|
10
|
+
|
|
11
|
+
let node;
|
|
12
|
+
|
|
13
|
+
afterUpdate(() => {
|
|
14
|
+
if (autoFit) {
|
|
15
|
+
const nodeCoords = node.getBoundingClientRect();
|
|
16
|
+
const bodyCoords = document.body.getBoundingClientRect();
|
|
17
|
+
|
|
18
|
+
if (nodeCoords.right >= bodyCoords.right) {
|
|
19
|
+
align = "end";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (nodeCoords.bottom >= bodyCoords.bottom) {
|
|
23
|
+
position = "top";
|
|
24
|
+
}
|
|
25
|
+
return `${position}-${align}`;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function down(e) {
|
|
30
|
+
if (cancel) cancel(e);
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<div
|
|
35
|
+
use:clickOutside={down}
|
|
36
|
+
bind:this={node}
|
|
37
|
+
class="wx-dropdown {`wx-${position}-${align}`}"
|
|
38
|
+
style="width:{width}"
|
|
39
|
+
>
|
|
40
|
+
<slot />
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
.wx-dropdown {
|
|
45
|
+
position: absolute;
|
|
46
|
+
z-index: 5;
|
|
47
|
+
background: var(--wx-popup-background);
|
|
48
|
+
box-shadow: var(--wx-popup-shadow);
|
|
49
|
+
border: var(--wx-popup-border);
|
|
50
|
+
border-radius: var(--wx-popup-border-radius);
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.wx-top-center {
|
|
55
|
+
top: 0;
|
|
56
|
+
left: 50%;
|
|
57
|
+
transform: translate(-50%, -100%) translateY(-2px);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.wx-top-start {
|
|
61
|
+
top: 0;
|
|
62
|
+
left: 0;
|
|
63
|
+
transform: translateY(-100%) translateY(-2px);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.wx-top-end {
|
|
67
|
+
top: 0;
|
|
68
|
+
right: 0;
|
|
69
|
+
transform: translateY(-100%) translateY(-2px);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.wx-bottom-center {
|
|
73
|
+
bottom: 0;
|
|
74
|
+
left: 50%;
|
|
75
|
+
transform: translate(-50%, 100%) translateY(2px);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.wx-bottom-start {
|
|
79
|
+
bottom: 0;
|
|
80
|
+
left: 0;
|
|
81
|
+
transform: translateY(100%) translateY(2px);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.wx-bottom-end {
|
|
85
|
+
bottom: 0;
|
|
86
|
+
right: 0;
|
|
87
|
+
transform: translateY(100%) translateY(2px);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.wx-left-center {
|
|
91
|
+
bottom: 50%;
|
|
92
|
+
left: 0;
|
|
93
|
+
transform: translate(-100%, 50%) translateX(-2px);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.wx-left-start {
|
|
97
|
+
top: 0;
|
|
98
|
+
left: 0;
|
|
99
|
+
transform: translateX(-100%) translateX(-2px);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.wx-left-end {
|
|
103
|
+
bottom: 0;
|
|
104
|
+
left: 0;
|
|
105
|
+
transform: translateX(-100%) translateX(-2px);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.wx-right-center {
|
|
109
|
+
bottom: 50%;
|
|
110
|
+
right: 0;
|
|
111
|
+
transform: translate(100%, 50%) translateX(2px);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.wx-right-start {
|
|
115
|
+
top: 0;
|
|
116
|
+
right: 0;
|
|
117
|
+
transform: translateX(100%) translateX(2px);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.wx-right-end {
|
|
121
|
+
bottom: 0;
|
|
122
|
+
right: 0;
|
|
123
|
+
transform: translateX(100%) translateX(2px);
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { uid } from "wx-lib-dom";
|
|
3
|
+
|
|
4
|
+
export let label = "";
|
|
5
|
+
export let position = "";
|
|
6
|
+
export let width = "";
|
|
7
|
+
export let error = false;
|
|
8
|
+
export let type = "";
|
|
9
|
+
|
|
10
|
+
let id = uid();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
class="wx-field wx-{position}"
|
|
15
|
+
class:wx-error={error}
|
|
16
|
+
style={width ? `width: ${width}` : ""}
|
|
17
|
+
>
|
|
18
|
+
{#if label}<label for={id}>{label}</label>{/if}
|
|
19
|
+
<div class="wx-field-control wx-{type}">
|
|
20
|
+
<slot {id} />
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.wx-field {
|
|
26
|
+
width: var(--wx-field-width);
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
margin-bottom: var(--wx-field-gutter);
|
|
29
|
+
}
|
|
30
|
+
.wx-field.wx-left {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: nowrap;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
}
|
|
35
|
+
.wx-field.wx-left > label {
|
|
36
|
+
width: var(--wx-label-width);
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
margin: 0 var(--wx-field-gutter) 0 0;
|
|
39
|
+
padding-top: calc(
|
|
40
|
+
(var(--wx-input-height) - var(--wx-label-line-height)) / 2
|
|
41
|
+
);
|
|
42
|
+
text-align: right;
|
|
43
|
+
}
|
|
44
|
+
.wx-field.wx-left > .wx-field-control {
|
|
45
|
+
max-width: calc(100% - var(--wx-label-width) - var(--wx-field-gutter));
|
|
46
|
+
}
|
|
47
|
+
.wx-field.wx-error label {
|
|
48
|
+
color: var(--wx-color-danger);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.wx-field.wx-left .wx-field-control.wx-checkbox {
|
|
52
|
+
padding-top: calc(
|
|
53
|
+
(var(--wx-input-height) - var(--wx-checkbox-height)) / 2
|
|
54
|
+
);
|
|
55
|
+
padding-bottom: calc(
|
|
56
|
+
(var(--wx-input-height) - var(--wx-checkbox-height)) / 2
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
.wx-field.wx-left .wx-field-control.wx-slider {
|
|
60
|
+
padding-top: calc(
|
|
61
|
+
(var(--wx-input-height) - var(--wx-slider-height)) / 2
|
|
62
|
+
);
|
|
63
|
+
padding-bottom: calc(
|
|
64
|
+
(var(--wx-input-height) - var(--wx-slider-height)) / 2
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
.wx-field.wx-left .wx-field-control.wx-switch {
|
|
68
|
+
padding-top: calc(
|
|
69
|
+
(var(--wx-input-height) - var(--wx-switch-height)) / 2
|
|
70
|
+
);
|
|
71
|
+
padding-bottom: calc(
|
|
72
|
+
(var(--wx-input-height) - var(--wx-switch-height)) / 2
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
label {
|
|
77
|
+
display: block;
|
|
78
|
+
margin: var(--wx-label-margin);
|
|
79
|
+
padding: var(--wx-label-padding);
|
|
80
|
+
font-family: var(--wx-label-font-family);
|
|
81
|
+
font-size: var(--wx-label-font-size);
|
|
82
|
+
line-height: var(--wx-label-line-height);
|
|
83
|
+
font-weight: var(--wx-label-font-weight);
|
|
84
|
+
color: var(--wx-label-font-color);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.wx-field-control {
|
|
88
|
+
position: relative;
|
|
89
|
+
width: 100%;
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { setContext } from "svelte";
|
|
3
|
+
|
|
4
|
+
import Notices from "./Notices.svelte";
|
|
5
|
+
import Modal from "./Modal.svelte";
|
|
6
|
+
|
|
7
|
+
import { uid } from "wx-lib-dom";
|
|
8
|
+
|
|
9
|
+
let modal = null;
|
|
10
|
+
function showModal(msg) {
|
|
11
|
+
modal = { ...msg };
|
|
12
|
+
return new Promise((res, rej) => {
|
|
13
|
+
modal.resolve = v => {
|
|
14
|
+
modal = null;
|
|
15
|
+
res(v);
|
|
16
|
+
};
|
|
17
|
+
modal.reject = v => {
|
|
18
|
+
modal = null;
|
|
19
|
+
rej(v);
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let notices = [];
|
|
25
|
+
function showNotice(msg) {
|
|
26
|
+
msg = { ...msg };
|
|
27
|
+
msg.id = msg.id || uid();
|
|
28
|
+
msg.remove = () => (notices = notices.filter(a => a.id !== msg.id));
|
|
29
|
+
|
|
30
|
+
if (msg.expire != -1) {
|
|
31
|
+
setTimeout(msg.remove, msg.expire || 5100);
|
|
32
|
+
}
|
|
33
|
+
notices = [...notices, msg];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setContext("wx-helpers", {
|
|
37
|
+
showNotice,
|
|
38
|
+
showModal,
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<slot />
|
|
43
|
+
{#if modal}
|
|
44
|
+
<Modal
|
|
45
|
+
title={modal.title}
|
|
46
|
+
buttons={modal.buttons}
|
|
47
|
+
ok={modal.resolve}
|
|
48
|
+
cancel={modal.reject}
|
|
49
|
+
>
|
|
50
|
+
{modal.message}
|
|
51
|
+
</Modal>
|
|
52
|
+
{/if}
|
|
53
|
+
<Notices data={notices} />
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let css = "";
|
|
3
|
+
export let title = "";
|
|
4
|
+
|
|
5
|
+
const SLOTS = $$props.$$slots;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
{#if SLOTS && SLOTS.default}
|
|
9
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
10
|
+
<i {title} role="icon" class="wx-icon {css}" on:click>
|
|
11
|
+
<slot />
|
|
12
|
+
</i>
|
|
13
|
+
{:else}
|
|
14
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
15
|
+
<i {title} class="wx-icon {css}" on:click />
|
|
16
|
+
{/if}
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
.wx-icon {
|
|
20
|
+
color: var(--wx-color-font-alt);
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
font-size: var(--wx-button-icon-size);
|
|
23
|
+
padding: var(--wx-button-icon-indent);
|
|
24
|
+
|
|
25
|
+
line-height: var(--wx-button-line-height);
|
|
26
|
+
display: inline-block;
|
|
27
|
+
}
|
|
28
|
+
.wx-icon:hover {
|
|
29
|
+
background-color: var(--wx-background-hover);
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount, getContext } from "svelte";
|
|
3
|
+
import { fade } from "svelte/transition";
|
|
4
|
+
import Button from "./Button.svelte";
|
|
5
|
+
|
|
6
|
+
const _ = getContext("wx-i18n").getGroup("core");
|
|
7
|
+
|
|
8
|
+
export let title = "";
|
|
9
|
+
export let ok;
|
|
10
|
+
export let cancel;
|
|
11
|
+
export let buttons = ["cancel", "ok"];
|
|
12
|
+
|
|
13
|
+
function keydown(e) {
|
|
14
|
+
switch (e.code) {
|
|
15
|
+
case "Enter": {
|
|
16
|
+
const from = e.target.tagName;
|
|
17
|
+
if (from === "TEXTAREA" || from === "BUTTON") return;
|
|
18
|
+
ok();
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
case "Escape":
|
|
22
|
+
cancel();
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let modal;
|
|
28
|
+
onMount(() => {
|
|
29
|
+
modal.focus();
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
34
|
+
<div
|
|
35
|
+
class="wx-modal"
|
|
36
|
+
bind:this={modal}
|
|
37
|
+
transition:fade={{ duration: 100 }}
|
|
38
|
+
tabindex="0"
|
|
39
|
+
on:keydown={keydown}
|
|
40
|
+
>
|
|
41
|
+
<div class="wx-window">
|
|
42
|
+
<slot name="title">
|
|
43
|
+
{#if title}
|
|
44
|
+
<div class="wx-header">{title}</div>
|
|
45
|
+
{/if}
|
|
46
|
+
</slot>
|
|
47
|
+
<div>
|
|
48
|
+
<slot />
|
|
49
|
+
</div>
|
|
50
|
+
<slot name="buttons">
|
|
51
|
+
<div class="wx-buttons">
|
|
52
|
+
{#each buttons as button}
|
|
53
|
+
<div class="wx-button">
|
|
54
|
+
<Button
|
|
55
|
+
type="block {button === 'ok'
|
|
56
|
+
? 'primary'
|
|
57
|
+
: 'secondary'}"
|
|
58
|
+
click={() => (button === "ok" ? ok() : cancel())}
|
|
59
|
+
>
|
|
60
|
+
{_(button)}
|
|
61
|
+
</Button>
|
|
62
|
+
</div>
|
|
63
|
+
{/each}
|
|
64
|
+
</div>
|
|
65
|
+
</slot>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.wx-modal {
|
|
71
|
+
position: fixed;
|
|
72
|
+
z-index: var(--wx-modal-z-index);
|
|
73
|
+
top: 0;
|
|
74
|
+
left: 0;
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: 100%;
|
|
80
|
+
background: var(--wx-modal-backdrop);
|
|
81
|
+
text-align: center;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.wx-window {
|
|
85
|
+
background: var(--wx-modal-background);
|
|
86
|
+
box-shadow: var(--wx-modal-shadow);
|
|
87
|
+
border: var(--wx-modal-border);
|
|
88
|
+
border-radius: var(--wx-modal-border-radius);
|
|
89
|
+
padding: var(--wx-modal-padding);
|
|
90
|
+
min-width: var(--wx-modal-width);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.wx-header {
|
|
94
|
+
font-family: var(--wx-modal-header-font-family);
|
|
95
|
+
font-size: var(--wx-modal-header-font-size);
|
|
96
|
+
line-height: var(--wx-modal-header-line-height);
|
|
97
|
+
font-weight: var(--wx-modal-header-font-weight);
|
|
98
|
+
color: var(--wx-modal-header-font-color);
|
|
99
|
+
margin-bottom: var(--wx-modal-gutter);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.wx-buttons {
|
|
103
|
+
margin-top: var(--wx-modal-gutter);
|
|
104
|
+
display: flex;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
margin-left: calc(var(--wx-modal-gutter) / -2);
|
|
107
|
+
margin-right: calc(var(--wx-modal-gutter) / -2);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.wx-button {
|
|
111
|
+
flex: 1;
|
|
112
|
+
max-width: 50%;
|
|
113
|
+
padding: 0 calc(var(--wx-modal-gutter) / 2);
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { fade } from "svelte/transition";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div class="wx-modal" transition:fade={{ duration: 100 }}>
|
|
6
|
+
<div class="wx-window">
|
|
7
|
+
<slot />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
.wx-modal {
|
|
13
|
+
position: absolute;
|
|
14
|
+
z-index: var(--wx-modal-z-index);
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
background: var(--wx-modal-backdrop);
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.wx-window {
|
|
26
|
+
background: var(--wx-modal-background);
|
|
27
|
+
box-shadow: var(--wx-modal-shadow);
|
|
28
|
+
border: var(--wx-modal-border);
|
|
29
|
+
border-radius: var(--wx-modal-border-radius);
|
|
30
|
+
min-width: var(--wx-modal-width);
|
|
31
|
+
}
|
|
32
|
+
</style>
|