spaper 1.3.0 → 1.4.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/README.md +1 -0
- package/components/Form/Form.svelte +11 -0
- package/components/Form/Input.svelte +1 -8
- package/components/Form/Input.svelte.d.ts +2 -2
- package/components/Form/NumberInput/DecrementButton.svelte +9 -0
- package/components/Form/NumberInput/DecrementButton.svelte.d.ts +19 -0
- package/components/Form/NumberInput/IncrementButton.svelte +9 -0
- package/components/Form/NumberInput/IncrementButton.svelte.d.ts +19 -0
- package/components/Form/NumberInput/NumberInput.svelte +129 -0
- package/components/Form/NumberInput/NumberInput.svelte.d.ts +36 -0
- package/components/Form/NumberInput/index.d.ts +3 -0
- package/components/Form/NumberInput/index.js +3 -0
- package/components/Form/index.d.ts +2 -1
- package/components/Form/index.js +2 -1
- package/components/Popover.svelte +10 -5
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -9,3 +9,14 @@
|
|
|
9
9
|
on:focus>
|
|
10
10
|
<slot />
|
|
11
11
|
</form>
|
|
12
|
+
|
|
13
|
+
<style >form {
|
|
14
|
+
/* NOTE: set back PaperCSS margins for our structure
|
|
15
|
+
<label> being parent of <input> instead of a sibling */
|
|
16
|
+
}
|
|
17
|
+
form :global(label) {
|
|
18
|
+
margin-block-end: 0;
|
|
19
|
+
}
|
|
20
|
+
form :global(input) {
|
|
21
|
+
margin-block-start: 0.5rem;
|
|
22
|
+
}</style>
|
|
@@ -35,18 +35,14 @@ import { computeClasses, getDomAttributes } from '../../utils';
|
|
|
35
35
|
;
|
|
36
36
|
;
|
|
37
37
|
export let label = '';
|
|
38
|
-
export let value =
|
|
38
|
+
export let value = '';
|
|
39
39
|
export let block = false;
|
|
40
40
|
export let type = 'text';
|
|
41
41
|
export let valid = null;
|
|
42
42
|
export let noResize = false;
|
|
43
43
|
const dispatch = createEventDispatcher();
|
|
44
|
-
// let value_ = value
|
|
45
44
|
function onInput({ target }) {
|
|
46
45
|
dispatch('input', target.value);
|
|
47
|
-
// console.log(type)
|
|
48
|
-
// const valueToDispatch = type === 'number' ? parseFloat(target.value) : target.value;
|
|
49
|
-
// dispatch('input', valueToDispatch);
|
|
50
46
|
}
|
|
51
47
|
let isValid = true;
|
|
52
48
|
$: if (valid) {
|
|
@@ -62,9 +58,6 @@ $: {
|
|
|
62
58
|
}
|
|
63
59
|
let classes;
|
|
64
60
|
$: classes = `${(_a = $$restProps.class) !== null && _a !== void 0 ? _a : ''} ${computeClasses('input', { block })}`;
|
|
65
|
-
// $: console.log('value in input', value, value === null)
|
|
66
|
-
// FIXME: change value twice... use other var? value_?
|
|
67
|
-
// $: if (type === 'number' && value !== null) value = Number(value)
|
|
68
61
|
</script>
|
|
69
62
|
|
|
70
63
|
<style>
|
|
@@ -4,10 +4,10 @@ declare const __propDef: {
|
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
label?: string;
|
|
7
|
-
value?: string
|
|
7
|
+
value?: string;
|
|
8
8
|
block?: boolean;
|
|
9
9
|
type?: InputType;
|
|
10
|
-
valid?: (val: string
|
|
10
|
+
valid?: (val: string) => boolean;
|
|
11
11
|
noResize?: boolean;
|
|
12
12
|
};
|
|
13
13
|
events: {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { PaperType } from '../../../types';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
clickHandler: (e: MouseEvent) => any;
|
|
7
|
+
type: PaperType;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export declare type DecrementButtonProps = typeof __propDef.props;
|
|
15
|
+
export declare type DecrementButtonEvents = typeof __propDef.events;
|
|
16
|
+
export declare type DecrementButtonSlots = typeof __propDef.slots;
|
|
17
|
+
export default class DecrementButton extends SvelteComponentTyped<DecrementButtonProps, DecrementButtonEvents, DecrementButtonSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { PaperType } from '../../../types';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
clickHandler: (e: MouseEvent) => any;
|
|
7
|
+
type: PaperType;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export declare type IncrementButtonProps = typeof __propDef.props;
|
|
15
|
+
export declare type IncrementButtonEvents = typeof __propDef.events;
|
|
16
|
+
export declare type IncrementButtonSlots = typeof __propDef.slots;
|
|
17
|
+
export default class IncrementButton extends SvelteComponentTyped<IncrementButtonProps, IncrementButtonEvents, IncrementButtonSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{#if label}
|
|
2
|
+
<div class="number-input-wrapper">
|
|
3
|
+
{#if controls}
|
|
4
|
+
<DecrementButton
|
|
5
|
+
clickHandler={() => value -= step}
|
|
6
|
+
type={controlsType}
|
|
7
|
+
disabled={!canDecrement}
|
|
8
|
+
/>
|
|
9
|
+
{/if}
|
|
10
|
+
<label>
|
|
11
|
+
{label}
|
|
12
|
+
<input {...attr}
|
|
13
|
+
inputmode="numeric"
|
|
14
|
+
bind:value={formattedValue}
|
|
15
|
+
class:border-danger={!isValid && value}
|
|
16
|
+
class:border-success={isValid && value && valid}
|
|
17
|
+
aria-valuemin={min}
|
|
18
|
+
aria-valuemax={max}
|
|
19
|
+
aria-valuenow={value}
|
|
20
|
+
on:input={onInput}
|
|
21
|
+
on:focus
|
|
22
|
+
on:blur
|
|
23
|
+
on:change />
|
|
24
|
+
</label>
|
|
25
|
+
{#if controls}
|
|
26
|
+
<IncrementButton
|
|
27
|
+
clickHandler={() => value += step}
|
|
28
|
+
type={controlsType}
|
|
29
|
+
disabled={!canIncrement}
|
|
30
|
+
/>
|
|
31
|
+
{/if}
|
|
32
|
+
</div>
|
|
33
|
+
{:else}
|
|
34
|
+
<div class="number-input-wrapper">
|
|
35
|
+
{#if controls}
|
|
36
|
+
<DecrementButton
|
|
37
|
+
clickHandler={() => value -= step}
|
|
38
|
+
type={controlsType}
|
|
39
|
+
disabled={!canDecrement}
|
|
40
|
+
/>
|
|
41
|
+
{/if}
|
|
42
|
+
<input {...attr}
|
|
43
|
+
inputmode="numeric"
|
|
44
|
+
bind:value={formattedValue}
|
|
45
|
+
class:border-danger={!isValid && value}
|
|
46
|
+
class:border-success={isValid && value && valid}
|
|
47
|
+
aria-valuemin={min}
|
|
48
|
+
aria-valuemax={max}
|
|
49
|
+
aria-valuenow={value}
|
|
50
|
+
on:input={onInput}
|
|
51
|
+
on:focus
|
|
52
|
+
on:blur
|
|
53
|
+
on:change />
|
|
54
|
+
{#if controls}
|
|
55
|
+
<IncrementButton
|
|
56
|
+
clickHandler={() => value += step}
|
|
57
|
+
type={controlsType}
|
|
58
|
+
disabled={!canIncrement}
|
|
59
|
+
/>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>
|
|
62
|
+
{/if}
|
|
63
|
+
|
|
64
|
+
<script >var _a;
|
|
65
|
+
import { createEventDispatcher } from 'svelte';
|
|
66
|
+
import { DecrementButton, IncrementButton } from './';
|
|
67
|
+
import { computeClasses, getDomAttributes } from '../../../utils';
|
|
68
|
+
;
|
|
69
|
+
export let label = '';
|
|
70
|
+
export let value = null;
|
|
71
|
+
export let step = 1;
|
|
72
|
+
export let min = null;
|
|
73
|
+
export let max = null;
|
|
74
|
+
export let disabled = false;
|
|
75
|
+
export let controls = true;
|
|
76
|
+
export let controlsType = 'secondary';
|
|
77
|
+
export let block = false;
|
|
78
|
+
export let valid = null;
|
|
79
|
+
export let prefix = '';
|
|
80
|
+
export let suffix = '';
|
|
81
|
+
export let format = null;
|
|
82
|
+
export let formatOptions = undefined;
|
|
83
|
+
const dispatch = createEventDispatcher();
|
|
84
|
+
function onInput({ target }) {
|
|
85
|
+
dispatch('input', target.value);
|
|
86
|
+
}
|
|
87
|
+
let isValid = true;
|
|
88
|
+
$: if (valid) {
|
|
89
|
+
isValid = valid(value);
|
|
90
|
+
}
|
|
91
|
+
let attr;
|
|
92
|
+
$: {
|
|
93
|
+
attr = getDomAttributes({
|
|
94
|
+
props: $$props,
|
|
95
|
+
classes,
|
|
96
|
+
toOmit: ['block', 'value', 'valid', 'noResize', 'min', 'max']
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
let classes;
|
|
100
|
+
$: classes = `${(_a = $$restProps.class) !== null && _a !== void 0 ? _a : ''} ${computeClasses('input', { block })}`;
|
|
101
|
+
$: canDecrement = !disabled && (min !== null ? value - step >= min : true);
|
|
102
|
+
$: canIncrement = !disabled && (max !== null ? value + step <= max : true);
|
|
103
|
+
let formattedValue = '';
|
|
104
|
+
$: if (value !== null) {
|
|
105
|
+
formattedValue = String(value);
|
|
106
|
+
if (format) {
|
|
107
|
+
if (typeof format === 'string') {
|
|
108
|
+
formattedValue = new Intl.NumberFormat(format === 'locale' ? undefined : format, formatOptions).format(value);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
formattedValue = format(value);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
formattedValue = [
|
|
115
|
+
prefix,
|
|
116
|
+
formattedValue,
|
|
117
|
+
suffix,
|
|
118
|
+
].join(' ').trim();
|
|
119
|
+
}
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<style >:global(.number-input-wrapper) {
|
|
123
|
+
display: flex;
|
|
124
|
+
gap: 0.25rem;
|
|
125
|
+
}
|
|
126
|
+
:global(.number-input-wrapper) :global(.paper-btn) {
|
|
127
|
+
align-self: flex-end;
|
|
128
|
+
padding: 0.5rem;
|
|
129
|
+
}</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { PaperType } from '../../../types';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
label?: string;
|
|
7
|
+
value?: number | null;
|
|
8
|
+
step?: number;
|
|
9
|
+
min?: number | null;
|
|
10
|
+
max?: number | null;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
controls?: boolean;
|
|
13
|
+
controlsType?: PaperType;
|
|
14
|
+
block?: boolean;
|
|
15
|
+
valid?: (val: number | null) => boolean;
|
|
16
|
+
prefix?: string;
|
|
17
|
+
suffix?: string;
|
|
18
|
+
format?: string | ((val: number | null) => string);
|
|
19
|
+
formatOptions?: Intl.NumberFormatOptions | undefined;
|
|
20
|
+
};
|
|
21
|
+
events: {
|
|
22
|
+
focus: FocusEvent;
|
|
23
|
+
blur: FocusEvent;
|
|
24
|
+
change: Event;
|
|
25
|
+
input: CustomEvent<any>;
|
|
26
|
+
} & {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
};
|
|
29
|
+
slots: {};
|
|
30
|
+
};
|
|
31
|
+
export declare type NumberInputProps = typeof __propDef.props;
|
|
32
|
+
export declare type NumberInputEvents = typeof __propDef.events;
|
|
33
|
+
export declare type NumberInputSlots = typeof __propDef.slots;
|
|
34
|
+
export default class NumberInput extends SvelteComponentTyped<NumberInputProps, NumberInputEvents, NumberInputSlots> {
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -5,5 +5,6 @@ import Checkbox from './Checkbox.svelte';
|
|
|
5
5
|
import Switch from './Switch.svelte';
|
|
6
6
|
import Slider from './Slider.svelte';
|
|
7
7
|
import Form from './Form.svelte';
|
|
8
|
+
import { NumberInput } from './NumberInput';
|
|
8
9
|
export declare type InputType = 'text' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'url' | 'time' | 'date' | 'month' | 'week' | 'datetime-local' | 'color' | 'textarea';
|
|
9
|
-
export { Input, Select, Radio, Checkbox, Switch, Slider, Form, };
|
|
10
|
+
export { Input, Select, Radio, Checkbox, Switch, Slider, Form, NumberInput, };
|
package/components/Form/index.js
CHANGED
|
@@ -5,4 +5,5 @@ import Checkbox from './Checkbox.svelte';
|
|
|
5
5
|
import Switch from './Switch.svelte';
|
|
6
6
|
import Slider from './Slider.svelte';
|
|
7
7
|
import Form from './Form.svelte';
|
|
8
|
-
|
|
8
|
+
import { NumberInput } from './NumberInput';
|
|
9
|
+
export { Input, Select, Radio, Checkbox, Switch, Slider, Form, NumberInput, };
|
|
@@ -24,27 +24,32 @@ function bgClass(color) {
|
|
|
24
24
|
|
|
25
25
|
[popover-top].popover-primary::after, [popover-right].popover-primary::after,
|
|
26
26
|
[popover-bottom].popover-primary::after, [popover-left].popover-primary::after {
|
|
27
|
-
background-color: var(--primary);
|
|
27
|
+
background-color: var(--primary-light);
|
|
28
|
+
color: var(--muted-dark);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
[popover-top].popover-secondary::after, [popover-right].popover-secondary::after,
|
|
31
32
|
[popover-bottom].popover-secondary::after, [popover-left].popover-secondary::after {
|
|
32
|
-
background-color: var(--secondary);
|
|
33
|
+
background-color: var(--secondary-light);
|
|
34
|
+
color: var(--muted-dark);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
[popover-top].popover-success::after, [popover-right].popover-success::after,
|
|
36
38
|
[popover-bottom].popover-success::after, [popover-left].popover-success::after {
|
|
37
|
-
background-color: var(--success);
|
|
39
|
+
background-color: var(--success-light);
|
|
40
|
+
color: var(--muted-dark);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
[popover-top].popover-warning::after, [popover-right].popover-warning::after,
|
|
41
44
|
[popover-bottom].popover-warning::after, [popover-left].popover-warning::after {
|
|
42
|
-
background-color: var(--warning);
|
|
45
|
+
background-color: var(--warning-light);
|
|
46
|
+
color: var(--muted-dark);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
[popover-top].popover-danger::after, [popover-right].popover-danger::after,
|
|
46
50
|
[popover-bottom].popover-danger::after, [popover-left].popover-danger::after {
|
|
47
|
-
background-color: var(--danger);
|
|
51
|
+
background-color: var(--danger-light);
|
|
52
|
+
color: var(--muted-dark);
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
[popover-top], [popover-right],
|
package/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import Breadcrumb from './components/Breadcrumb.svelte';
|
|
|
5
5
|
import Navbar from './components/Navbar.svelte';
|
|
6
6
|
import Modal from './components/Modal';
|
|
7
7
|
import { Tabs, Tab } from './components/Tabs';
|
|
8
|
-
import { Input, Select, Radio, Checkbox, Switch, Slider, Form } from './components/Form';
|
|
8
|
+
import { Input, Select, Radio, Checkbox, Switch, Slider, Form, NumberInput } from './components/Form';
|
|
9
9
|
import Article from './components/Article.svelte';
|
|
10
10
|
import Card from './components/Card.svelte';
|
|
11
11
|
import Collapsible from './components/Collapsible.svelte';
|
|
@@ -20,4 +20,4 @@ import Skeleton from './components/Skeleton.svelte';
|
|
|
20
20
|
import { Carousel, CarouselItem } from './components/Carousel';
|
|
21
21
|
import Hero from './components/Hero.svelte';
|
|
22
22
|
import { Col, Row } from './components/Layout';
|
|
23
|
-
export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, CloseButton, CopyButton, Skeleton, Carousel, CarouselItem, Hero, Col, Row, };
|
|
23
|
+
export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, CloseButton, CopyButton, Skeleton, Carousel, CarouselItem, Hero, Col, Row, NumberInput, };
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import Breadcrumb from './components/Breadcrumb.svelte';
|
|
|
5
5
|
import Navbar from './components/Navbar.svelte';
|
|
6
6
|
import Modal from './components/Modal';
|
|
7
7
|
import { Tabs, Tab } from './components/Tabs';
|
|
8
|
-
import { Input, Select, Radio, Checkbox, Switch, Slider, Form } from './components/Form';
|
|
8
|
+
import { Input, Select, Radio, Checkbox, Switch, Slider, Form, NumberInput, } from './components/Form';
|
|
9
9
|
import Article from './components/Article.svelte';
|
|
10
10
|
import Card from './components/Card.svelte';
|
|
11
11
|
import Collapsible from './components/Collapsible.svelte';
|
|
@@ -20,4 +20,4 @@ import Skeleton from './components/Skeleton.svelte';
|
|
|
20
20
|
import { Carousel, CarouselItem } from './components/Carousel';
|
|
21
21
|
import Hero from './components/Hero.svelte';
|
|
22
22
|
import { Col, Row } from './components/Layout';
|
|
23
|
-
export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, CloseButton, CopyButton, Skeleton, Carousel, CarouselItem, Hero, Col, Row, };
|
|
23
|
+
export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, CloseButton, CopyButton, Skeleton, Carousel, CarouselItem, Hero, Col, Row, NumberInput, };
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"papercss",
|
|
9
9
|
"components"
|
|
10
10
|
],
|
|
11
|
-
"version": "1.
|
|
11
|
+
"version": "1.4.0",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git+https://github.com/Oli8/spaper.git"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/Oli8/spaper#readme",
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"papercss": "^1.
|
|
21
|
+
"papercss": "^1.9.2"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"exports": {
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"./components/Form/Checkbox.svelte": "./components/Form/Checkbox.svelte",
|
|
40
40
|
"./components/Form/Form.svelte": "./components/Form/Form.svelte",
|
|
41
41
|
"./components/Form/Input.svelte": "./components/Form/Input.svelte",
|
|
42
|
+
"./components/Form/NumberInput/DecrementButton.svelte": "./components/Form/NumberInput/DecrementButton.svelte",
|
|
43
|
+
"./components/Form/NumberInput/IncrementButton.svelte": "./components/Form/NumberInput/IncrementButton.svelte",
|
|
44
|
+
"./components/Form/NumberInput/NumberInput.svelte": "./components/Form/NumberInput/NumberInput.svelte",
|
|
45
|
+
"./components/Form/NumberInput": "./components/Form/NumberInput/index.js",
|
|
42
46
|
"./components/Form/Radio.svelte": "./components/Form/Radio.svelte",
|
|
43
47
|
"./components/Form/Select.svelte": "./components/Form/Select.svelte",
|
|
44
48
|
"./components/Form/Slider.svelte": "./components/Form/Slider.svelte",
|