sveltacular 0.0.67 → 0.0.69
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/dist/forms/phone-box/phone-box.svelte +41 -19
- package/dist/generic/pill/pill.svelte +32 -3
- package/dist/generic/pill/pill.svelte.d.ts +2 -1
- package/dist/generic/section/section.svelte +9 -2
- package/dist/generic/section/section.svelte.d.ts +1 -0
- package/dist/helpers/date.d.ts +1 -0
- package/dist/helpers/date.js +6 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/modals/modal.svelte +6 -1
- package/dist/modals/modal.svelte.d.ts +1 -0
- package/dist/placeholders/skeleton-input.svelte +45 -0
- package/dist/placeholders/skeleton-input.svelte.d.ts +16 -0
- package/dist/placeholders/skeleton-text.svelte +21 -10
- package/dist/placeholders/skeleton-text.svelte.d.ts +1 -0
- package/dist/tables/data-grid.svelte +7 -2
- package/package.json +1 -1
|
@@ -6,14 +6,28 @@ export let value = "";
|
|
|
6
6
|
export let size = "md";
|
|
7
7
|
const id = uniqueId();
|
|
8
8
|
const dispatch = createEventDispatcher();
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
let
|
|
9
|
+
const fieldOrder = ["areaCode", "localExt", "lastFour"];
|
|
10
|
+
let areaCode = "";
|
|
11
|
+
let localExt = "";
|
|
12
|
+
let lastFour = "";
|
|
13
|
+
const getValueByField = (field) => {
|
|
14
|
+
if (field === "areaCode")
|
|
15
|
+
return areaCode;
|
|
16
|
+
if (field === "localExt")
|
|
17
|
+
return localExt;
|
|
18
|
+
if (field === "lastFour")
|
|
19
|
+
return lastFour;
|
|
20
|
+
return "";
|
|
21
|
+
};
|
|
22
|
+
const getValueByIndex = (index) => {
|
|
23
|
+
return getValueByField(fieldOrder[index]);
|
|
24
|
+
};
|
|
12
25
|
const getTargetProperties = (event) => {
|
|
13
26
|
const target = event.target;
|
|
14
27
|
const name = target.getAttribute("name");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
28
|
+
const currentIndex = fieldOrder.indexOf(name ?? "areaCode");
|
|
29
|
+
const nextId = currentIndex == 2 ? null : fieldOrder[currentIndex + 1];
|
|
30
|
+
const prevId = currentIndex == 0 ? null : fieldOrder[currentIndex - 1];
|
|
17
31
|
return {
|
|
18
32
|
target,
|
|
19
33
|
name,
|
|
@@ -26,9 +40,11 @@ const getTargetProperties = (event) => {
|
|
|
26
40
|
const cleanValue = (value2) => {
|
|
27
41
|
return value2.replace(/[^0-9]/g, "").slice(0, 10);
|
|
28
42
|
};
|
|
43
|
+
const getCombinedValue = () => {
|
|
44
|
+
return cleanValue(`${areaCode}${localExt}${lastFour}`);
|
|
45
|
+
};
|
|
29
46
|
const publishChange = () => {
|
|
30
|
-
value =
|
|
31
|
-
console.log("publishChange", value);
|
|
47
|
+
value = getCombinedValue();
|
|
32
48
|
dispatch("change", value);
|
|
33
49
|
return value;
|
|
34
50
|
};
|
|
@@ -53,16 +69,18 @@ const valueChanged = (event) => {
|
|
|
53
69
|
return setValue(`${areaCode}${newValue}`);
|
|
54
70
|
}
|
|
55
71
|
props.target.value = newValue.slice(0, props.maxLength);
|
|
56
|
-
if (newValue.length >= props.maxLength) {
|
|
57
|
-
|
|
72
|
+
if (newValue.length >= props.maxLength && props.nextInput) {
|
|
73
|
+
props.nextInput.focus();
|
|
58
74
|
}
|
|
59
75
|
};
|
|
60
|
-
const
|
|
76
|
+
const keyUp = (event) => {
|
|
61
77
|
const props = getTargetProperties(event);
|
|
62
|
-
const
|
|
78
|
+
const isBackspace = event.key === "Backspace";
|
|
79
|
+
const isDelete = event.key === "Delete";
|
|
80
|
+
const isBackspaceOrDelete = isBackspace || isDelete;
|
|
63
81
|
const isNumeric = !isNaN(Number(event.key));
|
|
64
82
|
const isCursorHighlighting = props.target.selectionStart !== props.target.selectionEnd;
|
|
65
|
-
const isAcceptable = isNumeric ||
|
|
83
|
+
const isAcceptable = isNumeric || isBackspaceOrDelete;
|
|
66
84
|
const isRightArrow = event.key === "ArrowRight" || event.key === "Tab";
|
|
67
85
|
const isLeftArrow = event.key === "ArrowLeft";
|
|
68
86
|
if (isRightArrow || isLeftArrow)
|
|
@@ -73,17 +91,21 @@ const keyDown = (event) => {
|
|
|
73
91
|
if (isCursorHighlighting) {
|
|
74
92
|
const start = props.target.selectionStart || 0;
|
|
75
93
|
const end = props.target.selectionEnd || 0;
|
|
76
|
-
return
|
|
94
|
+
return isBackspaceOrDelete ? props.value.slice(0, start) + props.value.slice(end) : props.value.slice(0, start) + event.key + props.value.slice(end);
|
|
77
95
|
}
|
|
78
|
-
return
|
|
96
|
+
return props.value;
|
|
79
97
|
})();
|
|
80
98
|
if (newValue.length >= props.maxLength) {
|
|
99
|
+
console.log(event.key);
|
|
81
100
|
props.target.value = newValue.slice(0, props.maxLength);
|
|
82
101
|
if (props.nextInput)
|
|
83
102
|
props.nextInput.focus();
|
|
84
103
|
}
|
|
85
|
-
if (
|
|
86
|
-
props.prevId
|
|
104
|
+
if (isBackspace) {
|
|
105
|
+
if (newValue.length === 0 && props.prevId) {
|
|
106
|
+
props.prevId.focus();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
87
109
|
};
|
|
88
110
|
setValue(value ?? "");
|
|
89
111
|
$:
|
|
@@ -101,8 +123,8 @@ $:
|
|
|
101
123
|
id="{id}-areaCode"
|
|
102
124
|
type="text"
|
|
103
125
|
on:input={valueChanged}
|
|
126
|
+
on:keyup={keyUp}
|
|
104
127
|
on:change={valueChanged}
|
|
105
|
-
on:keypress={keyDown}
|
|
106
128
|
bind:value={areaCode}
|
|
107
129
|
name="areaCode"
|
|
108
130
|
data-maxlength="3"
|
|
@@ -115,7 +137,7 @@ $:
|
|
|
115
137
|
type="text"
|
|
116
138
|
on:input={valueChanged}
|
|
117
139
|
on:change={valueChanged}
|
|
118
|
-
on:
|
|
140
|
+
on:keyup={keyUp}
|
|
119
141
|
bind:value={localExt}
|
|
120
142
|
name="localExt"
|
|
121
143
|
data-maxlength="3"
|
|
@@ -128,7 +150,7 @@ $:
|
|
|
128
150
|
type="text"
|
|
129
151
|
on:input={valueChanged}
|
|
130
152
|
on:change={valueChanged}
|
|
131
|
-
on:
|
|
153
|
+
on:keyup={keyUp}
|
|
132
154
|
bind:value={lastFour}
|
|
133
155
|
name="lastFour"
|
|
134
156
|
data-maxlength="4"
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
export let style = "standard";
|
|
3
3
|
export let shape = "rounded";
|
|
4
4
|
export let fill = "solid";
|
|
5
|
+
export let compact = false;
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
|
-
<
|
|
8
|
-
<slot
|
|
9
|
-
</
|
|
8
|
+
<div class="pill {size} {style} {shape} {fill}" class:compact>
|
|
9
|
+
<span><slot /></span>
|
|
10
|
+
</div>
|
|
10
11
|
|
|
11
12
|
<style>.pill {
|
|
12
13
|
display: inline-block;
|
|
@@ -18,6 +19,9 @@ export let fill = "solid";
|
|
|
18
19
|
color: #4a5568;
|
|
19
20
|
font-family: var(--base-font-family, sans-serif);
|
|
20
21
|
}
|
|
22
|
+
.pill.compact {
|
|
23
|
+
padding: 0.125rem;
|
|
24
|
+
}
|
|
21
25
|
.pill.sm {
|
|
22
26
|
font-size: 0.625rem;
|
|
23
27
|
padding: 0.125rem 0.25rem;
|
|
@@ -44,6 +48,31 @@ export let fill = "solid";
|
|
|
44
48
|
.pill.circular {
|
|
45
49
|
border-radius: 50%;
|
|
46
50
|
}
|
|
51
|
+
.pill.circle {
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
width: 1.75rem;
|
|
54
|
+
height: 1.75rem;
|
|
55
|
+
position: relative;
|
|
56
|
+
}
|
|
57
|
+
.pill.circle.sm {
|
|
58
|
+
width: 1.25rem;
|
|
59
|
+
height: 1.25rem;
|
|
60
|
+
}
|
|
61
|
+
.pill.circle.lg {
|
|
62
|
+
width: 2.25rem;
|
|
63
|
+
height: 2.25rem;
|
|
64
|
+
}
|
|
65
|
+
.pill.circle.xl {
|
|
66
|
+
width: 3rem;
|
|
67
|
+
height: 3rem;
|
|
68
|
+
}
|
|
69
|
+
.pill.circle span {
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
align-items: center;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
75
|
+
}
|
|
47
76
|
.pill.positive {
|
|
48
77
|
background-color: #0a5200;
|
|
49
78
|
color: #fff;
|
|
@@ -4,8 +4,9 @@ declare const __propDef: {
|
|
|
4
4
|
props: {
|
|
5
5
|
size?: FormFieldSizeOptions | undefined;
|
|
6
6
|
style?: "positive" | "negative" | "standard" | undefined;
|
|
7
|
-
shape?: "circular" | "square" | "rounded" | "badge" | undefined;
|
|
7
|
+
shape?: "circle" | "circular" | "square" | "rounded" | "badge" | undefined;
|
|
8
8
|
fill?: "outline" | "solid" | undefined;
|
|
9
|
+
compact?: boolean | undefined;
|
|
9
10
|
};
|
|
10
11
|
events: {
|
|
11
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -4,12 +4,13 @@ export let title = void 0;
|
|
|
4
4
|
export let level = 2;
|
|
5
5
|
export let size = "full";
|
|
6
6
|
export let hidden = false;
|
|
7
|
+
export let align = "left";
|
|
7
8
|
setContext("section", { level, title });
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
|
-
<section class="level-{level} {size}" class:hidden>
|
|
11
|
+
<section class="level-{level} {size} {align}" class:hidden>
|
|
11
12
|
{#if title}
|
|
12
|
-
<Header />
|
|
13
|
+
<Header {level} />
|
|
13
14
|
{/if}
|
|
14
15
|
<slot />
|
|
15
16
|
</section>
|
|
@@ -20,6 +21,12 @@ setContext("section", { level, title });
|
|
|
20
21
|
margin-bottom: 1rem;
|
|
21
22
|
font-family: var(--base-font-family, sans-serif);
|
|
22
23
|
}
|
|
24
|
+
section.center {
|
|
25
|
+
text-align: center;
|
|
26
|
+
}
|
|
27
|
+
section.right {
|
|
28
|
+
text-align: right;
|
|
29
|
+
}
|
|
23
30
|
section.hidden {
|
|
24
31
|
display: none;
|
|
25
32
|
}
|
package/dist/helpers/date.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export declare const dateTimeToInput: (dateTime?: Date) => string;
|
|
|
15
15
|
export declare const isDateString: (date: string) => date is string;
|
|
16
16
|
export declare const isDateTimeString: (dateTime: string) => dateTime is string;
|
|
17
17
|
export declare const isDateOrDateTimeString: (dateOrDateTime: unknown) => dateOrDateTime is string;
|
|
18
|
+
export declare const formatDateTime: (dateTime: string | Date) => string;
|
package/dist/helpers/date.js
CHANGED
|
@@ -113,3 +113,9 @@ export const isDateOrDateTimeString = (dateOrDateTime) => {
|
|
|
113
113
|
return false;
|
|
114
114
|
return isDateString(dateOrDateTime) || isDateTimeString(dateOrDateTime);
|
|
115
115
|
};
|
|
116
|
+
export const formatDateTime = (dateTime) => {
|
|
117
|
+
const date = new Date(dateTime);
|
|
118
|
+
const offset = date.getTimezoneOffset();
|
|
119
|
+
date.setMinutes(date.getMinutes() - offset);
|
|
120
|
+
return date.toISOString().split('.')[0].slice(0, -3);
|
|
121
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -48,14 +48,14 @@ export { default as ListItem } from './generic/list/list-item.svelte';
|
|
|
48
48
|
export { default as FlexCol } from './layout/flex-col.svelte';
|
|
49
49
|
export { default as FlexRow } from './layout/flex-row.svelte';
|
|
50
50
|
export { default as FlexItem } from './layout/flex-item.svelte';
|
|
51
|
-
export { default as
|
|
52
|
-
export { default as
|
|
53
|
-
export { default as
|
|
51
|
+
export { default as Alert } from './modals/alert.svelte';
|
|
52
|
+
export { default as Confirm } from './modals/confirm.svelte';
|
|
53
|
+
export { default as Modal } from './modals/modal.svelte';
|
|
54
|
+
export { default as Prompt } from './modals/prompt.svelte';
|
|
54
55
|
export { default as DialogBody } from './modals/dialog-body.svelte';
|
|
55
56
|
export { default as DialogFooter } from './modals/dialog-footer.svelte';
|
|
56
57
|
export { default as DialogHeader } from './modals/dialog-header.svelte';
|
|
57
58
|
export { default as DialogWindow } from './modals/dialog-window.svelte';
|
|
58
|
-
export { default as Modal } from './modals/modal.svelte';
|
|
59
59
|
export { default as Accordian } from './navigation/accordian/accordian.svelte';
|
|
60
60
|
export { default as AppBar } from './navigation/app-bar/app-bar.svelte';
|
|
61
61
|
export { default as Breadcrumbs } from './navigation/breadcrumbs/breadcrumbs.svelte';
|
package/dist/index.js
CHANGED
|
@@ -52,14 +52,14 @@ export { default as FlexCol } from './layout/flex-col.svelte';
|
|
|
52
52
|
export { default as FlexRow } from './layout/flex-row.svelte';
|
|
53
53
|
export { default as FlexItem } from './layout/flex-item.svelte';
|
|
54
54
|
// Modals
|
|
55
|
-
export { default as
|
|
56
|
-
export { default as
|
|
57
|
-
export { default as
|
|
55
|
+
export { default as Alert } from './modals/alert.svelte';
|
|
56
|
+
export { default as Confirm } from './modals/confirm.svelte';
|
|
57
|
+
export { default as Modal } from './modals/modal.svelte';
|
|
58
|
+
export { default as Prompt } from './modals/prompt.svelte';
|
|
58
59
|
export { default as DialogBody } from './modals/dialog-body.svelte';
|
|
59
60
|
export { default as DialogFooter } from './modals/dialog-footer.svelte';
|
|
60
61
|
export { default as DialogHeader } from './modals/dialog-header.svelte';
|
|
61
62
|
export { default as DialogWindow } from './modals/dialog-window.svelte';
|
|
62
|
-
export { default as Modal } from './modals/modal.svelte';
|
|
63
63
|
// Navigation
|
|
64
64
|
export { default as Accordian } from './navigation/accordian/accordian.svelte';
|
|
65
65
|
export { default as AppBar } from './navigation/app-bar/app-bar.svelte';
|
package/dist/modals/modal.svelte
CHANGED
|
@@ -7,16 +7,21 @@ const dispatch = createEventDispatcher();
|
|
|
7
7
|
export let open = false;
|
|
8
8
|
export let size = "md";
|
|
9
9
|
export let showCloseButton = true;
|
|
10
|
+
export let dismissable = true;
|
|
10
11
|
const close = () => {
|
|
12
|
+
if (!dismissable)
|
|
13
|
+
return;
|
|
11
14
|
dispatch("close");
|
|
12
15
|
open = false;
|
|
13
16
|
};
|
|
17
|
+
$:
|
|
18
|
+
_showCloseButton = dismissable && showCloseButton;
|
|
14
19
|
</script>
|
|
15
20
|
|
|
16
21
|
{#if open}
|
|
17
22
|
<Overlay on:click={close}>
|
|
18
23
|
<Dialog {size}>
|
|
19
|
-
<DialogCloseButton show={
|
|
24
|
+
<DialogCloseButton show={_showCloseButton} on:click={close} />
|
|
20
25
|
<DialogBody>
|
|
21
26
|
<slot />
|
|
22
27
|
</DialogBody>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>import FlexItem from "../layout/flex-item.svelte";
|
|
2
|
+
export let animation = "none";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<FlexItem>
|
|
6
|
+
<div class="box {animation}">
|
|
7
|
+
<div class="label"></div>
|
|
8
|
+
<div class="input"></div>
|
|
9
|
+
</div>
|
|
10
|
+
</FlexItem>
|
|
11
|
+
|
|
12
|
+
<style>
|
|
13
|
+
div.pulse {
|
|
14
|
+
animation: pulse 2s infinite;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
div.label {
|
|
18
|
+
height: 1rem;
|
|
19
|
+
background-color: var(--base-color-fg, #ccc);
|
|
20
|
+
opacity: 0.5;
|
|
21
|
+
border-radius: 1rem;
|
|
22
|
+
margin-bottom: 1rem;
|
|
23
|
+
width: 35%;
|
|
24
|
+
}
|
|
25
|
+
div.input {
|
|
26
|
+
height: 2rem;
|
|
27
|
+
width: 100%;
|
|
28
|
+
border: 1px solid var(--form-input-border, black);
|
|
29
|
+
background-color: var(--form-input-bg, white);
|
|
30
|
+
opacity: 0.7;
|
|
31
|
+
border-radius: 0.25rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@keyframes pulse {
|
|
35
|
+
0%,
|
|
36
|
+
100% {
|
|
37
|
+
opacity: 0.5;
|
|
38
|
+
scale: 0.99;
|
|
39
|
+
}
|
|
40
|
+
50% {
|
|
41
|
+
opacity: 1;
|
|
42
|
+
scale: 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
animation?: "none" | "pulse" | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type SkeletonInputProps = typeof __propDef.props;
|
|
12
|
+
export type SkeletonInputEvents = typeof __propDef.events;
|
|
13
|
+
export type SkeletonInputSlots = typeof __propDef.slots;
|
|
14
|
+
export default class SkeletonInput extends SvelteComponent<SkeletonInputProps, SkeletonInputEvents, SkeletonInputSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
<script>import { randomInt } from "../helpers/random.js";
|
|
2
2
|
export let min = 50;
|
|
3
3
|
export let max = 100;
|
|
4
|
+
export let animation = "none";
|
|
4
5
|
$:
|
|
5
6
|
width = randomInt(min, max);
|
|
6
7
|
</script>
|
|
7
8
|
|
|
8
|
-
<div style="width: {width}%" />
|
|
9
|
+
<div class="{animation}" style="width: {width}%" />
|
|
9
10
|
|
|
10
|
-
<style>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
<style>div {
|
|
12
|
+
height: 1rem;
|
|
13
|
+
background-color: var(--base-color-fg, #ccc);
|
|
14
|
+
opacity: 0.5;
|
|
15
|
+
border-radius: 1rem;
|
|
16
|
+
margin-bottom: 1rem;
|
|
17
|
+
}
|
|
18
|
+
div.pulse {
|
|
19
|
+
animation: pulse 2s infinite;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@keyframes pulse {
|
|
23
|
+
0%, 100% {
|
|
24
|
+
opacity: 0.5;
|
|
25
|
+
}
|
|
26
|
+
50% {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
}
|
|
29
|
+
}</style>
|
|
@@ -12,6 +12,7 @@ import Button from "../forms/button/button.svelte";
|
|
|
12
12
|
import Empty from "../generic/empty/empty.svelte";
|
|
13
13
|
import Pill from "../generic/pill/pill.svelte";
|
|
14
14
|
import FolderOpenIcon from "../icons/folder-open-icon.svelte";
|
|
15
|
+
import { formatDateTime } from "../index.js";
|
|
15
16
|
import Pagination from "../navigation/pagination/pagination.svelte";
|
|
16
17
|
import Loading from "../placeholders/loading.svelte";
|
|
17
18
|
import TableCaption from "./table-caption.svelte";
|
|
@@ -39,6 +40,10 @@ const format = (row, key) => {
|
|
|
39
40
|
return col.emptyText;
|
|
40
41
|
if (col.format)
|
|
41
42
|
return col.format(row, key);
|
|
43
|
+
if (col.type === "date")
|
|
44
|
+
return formatDateTime(String(row[key])).substring(0, 10);
|
|
45
|
+
if (col.type === "date-time")
|
|
46
|
+
return formatDateTime(String(row[key]));
|
|
42
47
|
return row[key];
|
|
43
48
|
};
|
|
44
49
|
const calculateTotalPages = () => {
|
|
@@ -113,11 +118,11 @@ $:
|
|
|
113
118
|
<TableCell type={col.type || typeof row[col.key]} width={col.width}>
|
|
114
119
|
{#if col.link}
|
|
115
120
|
<a href={col.link(row, col.key)}>{format(row, col.key)}</a>
|
|
116
|
-
|
|
121
|
+
{:else if col.type == 'email' && row[col.key]}
|
|
117
122
|
<a href={`mailto:${row[col.key]}`}>{format(row, col.key)}</a>
|
|
118
123
|
{:else if col.type == 'check'}
|
|
119
124
|
{#if row[col.key]}
|
|
120
|
-
<Pill shape="
|
|
125
|
+
<Pill shape="circle" style="positive" compact>✔</Pill>
|
|
121
126
|
{/if}
|
|
122
127
|
{:else}
|
|
123
128
|
{format(row, col.key)}
|