@dosgato/dialog 0.0.36 → 0.0.38
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/chooser/Chooser.svelte +1 -1
- package/chooser/ChooserAPI.d.ts +1 -0
- package/chooser/Thumbnail.svelte +2 -1
- package/chooser/Thumbnail.svelte.d.ts +1 -0
- package/colorpicker/FieldColorPicker.svelte +1 -1
- package/cropper/FieldCropper.svelte +5 -5
- package/cropper/cropper.d.ts +6 -0
- package/cropper/cropper.js +11 -10
- package/package.json +1 -1
package/chooser/Chooser.svelte
CHANGED
|
@@ -100,7 +100,7 @@ onMount(async () => {
|
|
|
100
100
|
</section>
|
|
101
101
|
<section class="dialog-chooser-preview" tabindex="-1">
|
|
102
102
|
{#if $preview}
|
|
103
|
-
<Thumbnail item={$preview} />
|
|
103
|
+
<Thumbnail item={$preview} larger />
|
|
104
104
|
<Details item={$preview}>
|
|
105
105
|
{#if $preview.type === 'folder'}
|
|
106
106
|
<li>{$selected?.children?.length ?? 0} sub-items</li>
|
package/chooser/ChooserAPI.d.ts
CHANGED
package/chooser/Thumbnail.svelte
CHANGED
|
@@ -3,12 +3,13 @@ import fileLinkOutline from '@iconify-icons/mdi/file-link-outline.js';
|
|
|
3
3
|
import FileIcon from '../FileIcon.svelte';
|
|
4
4
|
import Icon from '../Icon.svelte';
|
|
5
5
|
export let item;
|
|
6
|
+
export let larger = false;
|
|
6
7
|
</script>
|
|
7
8
|
|
|
8
9
|
<div class="dialog-chooser-thumbnail">
|
|
9
10
|
{#if item.type === 'asset'}
|
|
10
11
|
{#if item.image}
|
|
11
|
-
<img src={item.image.thumbnailUrl} alt="" />
|
|
12
|
+
<img src={(larger ? item.image.thumbnailUrl : item.image.previewUrl) ?? item.image.thumbnailUrl ?? item.url} alt="" />
|
|
12
13
|
{:else}
|
|
13
14
|
<FileIcon mime={item.mime} width='5em' />
|
|
14
15
|
{/if}
|
|
@@ -12,7 +12,7 @@ export let required = false;
|
|
|
12
12
|
export let conditional = undefined;
|
|
13
13
|
export let helptext = undefined;
|
|
14
14
|
const store = new CropperStore({ width: 0, height: 0, minSelection, targetAspect: selectionAspectRatio });
|
|
15
|
-
const { output, selection } = store;
|
|
15
|
+
const { output, outputPct, selection } = store;
|
|
16
16
|
let setVal;
|
|
17
17
|
let value;
|
|
18
18
|
function init(spValue, spSetVal) {
|
|
@@ -39,7 +39,7 @@ let container;
|
|
|
39
39
|
function onMouseDown(e) {
|
|
40
40
|
if (!updateRect())
|
|
41
41
|
return;
|
|
42
|
-
if (e instanceof TouchEvent && e.touches.length > 1)
|
|
42
|
+
if (window.TouchEvent && TouchEvent && e instanceof TouchEvent && e.touches.length > 1)
|
|
43
43
|
return;
|
|
44
44
|
const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
45
45
|
const clientY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
@@ -51,7 +51,7 @@ function onMouseDown(e) {
|
|
|
51
51
|
function onMouseMove(e) {
|
|
52
52
|
if (!updateRect())
|
|
53
53
|
return;
|
|
54
|
-
if (e instanceof TouchEvent && e.touches.length > 1)
|
|
54
|
+
if (window.TouchEvent && e instanceof TouchEvent && e.touches.length > 1)
|
|
55
55
|
return;
|
|
56
56
|
const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
|
|
57
57
|
const clientY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
|
|
@@ -114,9 +114,9 @@ let focusWithin = false;
|
|
|
114
114
|
<div on:focusin={() => { focusWithin = true }} on:focusout={() => { focusWithin = false }}>
|
|
115
115
|
<div bind:this={container} use:resize on:resize={() => updateRect()} class="crop-image-container" on:mousedown={onMouseDown} on:touchstart={onMouseDown} on:touchmove={onMouseMove} style:cursor={$store.cursor}>
|
|
116
116
|
<img class="crop-image" src={imageSrc} alt="" />
|
|
117
|
-
{#if $selection && $
|
|
117
|
+
{#if $selection && $outputPct}
|
|
118
118
|
<div class='crop-bg'>
|
|
119
|
-
<img class='crop-image clipped' src={imageSrc} alt="" style:clip-path="polygon({$
|
|
119
|
+
<img class='crop-image clipped' src={imageSrc} alt="" style:clip-path="polygon({$outputPct.left}% {$outputPct.top}%, {100 - $outputPct.right}% {$outputPct.top}%, {100 - $outputPct.right}% {100 - $outputPct.bottom}%, {$outputPct.left}% {100 - $outputPct.bottom}%, {$outputPct.left}% {$outputPct.top}%)" />
|
|
120
120
|
</div>
|
|
121
121
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
122
122
|
<div class='selectionHilite' {id} tabindex="0" on:keydown={onKeyDown('move')}
|
package/cropper/cropper.d.ts
CHANGED
|
@@ -40,6 +40,12 @@ export declare class CropperStore extends Store<ICropperStore> {
|
|
|
40
40
|
bottom: number;
|
|
41
41
|
} | undefined, ICropperStore>;
|
|
42
42
|
output: import("@txstate-mws/svelte-store").DerivedStore<CropOutput | undefined, ICropperStore>;
|
|
43
|
+
outputPct: import("@txstate-mws/svelte-store").DerivedStore<{
|
|
44
|
+
left: number;
|
|
45
|
+
top: number;
|
|
46
|
+
right: number;
|
|
47
|
+
bottom: number;
|
|
48
|
+
} | undefined, ICropperStore>;
|
|
43
49
|
constructor(initialValue: Omit<ICropperStore, 'cursor'>);
|
|
44
50
|
setOutput(selection?: CropOutput): void;
|
|
45
51
|
updateDimensions(width: number, height: number): void;
|
package/cropper/cropper.js
CHANGED
|
@@ -8,6 +8,7 @@ export class CropperStore extends Store {
|
|
|
8
8
|
return this.convertToPx(v.selection, v.width, v.height);
|
|
9
9
|
});
|
|
10
10
|
output = derivedStore(this, 'selection');
|
|
11
|
+
outputPct = derivedStore(this, v => v.selection ? ({ left: v.selection.left * 100, top: v.selection.top * 100, right: v.selection.right * 100, bottom: v.selection.bottom * 100 }) : undefined);
|
|
11
12
|
constructor(initialValue) {
|
|
12
13
|
super({ ...initialValue, cursor: 'crosshair' });
|
|
13
14
|
}
|
|
@@ -57,7 +58,7 @@ export class CropperStore extends Store {
|
|
|
57
58
|
const ar = v.width / v.height;
|
|
58
59
|
const s = {};
|
|
59
60
|
if (ar > v.targetAspect) { // draw area is wider than aspect, fill height
|
|
60
|
-
s.left =
|
|
61
|
+
s.left = (ar - v.targetAspect) / (2 * ar);
|
|
61
62
|
s.right = s.left;
|
|
62
63
|
s.top = 0;
|
|
63
64
|
s.bottom = 0;
|
|
@@ -65,7 +66,7 @@ export class CropperStore extends Store {
|
|
|
65
66
|
else { // draw area is taller than aspect, fill width
|
|
66
67
|
s.left = 0;
|
|
67
68
|
s.right = 0;
|
|
68
|
-
s.top =
|
|
69
|
+
s.top = (v.targetAspect - ar) / (2 * v.targetAspect);
|
|
69
70
|
s.bottom = s.top;
|
|
70
71
|
}
|
|
71
72
|
return { ...v, selection: s };
|
|
@@ -75,20 +76,20 @@ export class CropperStore extends Store {
|
|
|
75
76
|
if (!sel)
|
|
76
77
|
return undefined;
|
|
77
78
|
return {
|
|
78
|
-
left:
|
|
79
|
-
right:
|
|
80
|
-
top:
|
|
81
|
-
bottom:
|
|
79
|
+
left: sel.left / width,
|
|
80
|
+
right: (width - sel.right) / width,
|
|
81
|
+
top: sel.top / height,
|
|
82
|
+
bottom: (height - sel.bottom) / height
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
85
|
convertToPx(output, width, height) {
|
|
85
86
|
if (!output)
|
|
86
87
|
return undefined;
|
|
87
88
|
return {
|
|
88
|
-
left: output.left * width
|
|
89
|
-
right: width - output.right * width
|
|
90
|
-
top: output.top * height
|
|
91
|
-
bottom: height - output.bottom * height
|
|
89
|
+
left: output.left * width,
|
|
90
|
+
right: width - output.right * width,
|
|
91
|
+
top: output.top * height,
|
|
92
|
+
bottom: height - output.bottom * height
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
determineSelection(startX, startY, x, y, v) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dosgato/dialog",
|
|
3
3
|
"description": "A component library for building forms that edit a JSON document.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.38",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@txstate-mws/svelte-components": "^1.3.7",
|
|
7
7
|
"@txstate-mws/svelte-forms": "^1.3.4",
|