@dosgato/dialog 1.1.19 → 1.1.20

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.
@@ -1,6 +1,6 @@
1
1
  <script>import { FORM_CONTEXT, FORM_INHERITED_PATH, Field } from '@txstate-mws/svelte-forms';
2
2
  import { getContext, onMount } from 'svelte';
3
- import { get, isNotBlank } from 'txstate-utils';
3
+ import { equal, get, isNotBlank } from 'txstate-utils';
4
4
  import Switcher from './Switcher.svelte';
5
5
  let className = '';
6
6
  export { className as class };
@@ -36,7 +36,7 @@ async function reactToChoices(..._) {
36
36
  return await store.setField(finalPath, finalDeserialize(''));
37
37
  }
38
38
  const val = get($store.data, finalPath);
39
- if (!choices.some(o => o.value === finalDeserialize(val)))
39
+ if (!choices.some(o => equal(o.value, val)))
40
40
  await store.setField(finalPath, notNull ? defaultValue : finalDeserialize(''));
41
41
  }
42
42
  $: reactToChoices(choices).catch(console.error);
@@ -1,5 +1,5 @@
1
1
  <script>import { resize, ScreenReaderOnly } from '@txstate-mws/svelte-components';
2
- import { onMount } from 'svelte';
2
+ import { onMount, tick } from 'svelte';
3
3
  import { isNotBlank, randomid } from 'txstate-utils';
4
4
  import FieldStandard from '../FieldStandard.svelte';
5
5
  import { CropperStore } from './cropper';
@@ -16,6 +16,7 @@ const store = new CropperStore({ width: 0, height: 0, minSelection, targetAspect
16
16
  const { output, outputPct, selection } = store;
17
17
  let setVal;
18
18
  let value;
19
+ const initialAspectRatio = selectionAspectRatio;
19
20
  function init(spValue, spSetVal) {
20
21
  setVal = spSetVal;
21
22
  value = spValue;
@@ -114,6 +115,18 @@ $: updateRect(container);
114
115
  const descid = randomid();
115
116
  const movedescid = randomid();
116
117
  let focusWithin = false;
118
+ let arChanged = false;
119
+ async function reactToAspectRatio(ar) {
120
+ if (!ar)
121
+ return;
122
+ store.updateTargetAspect(ar);
123
+ await tick();
124
+ if (ar !== initialAspectRatio || arChanged) {
125
+ store.reset();
126
+ arChanged = true;
127
+ }
128
+ }
129
+ $: void reactToAspectRatio(selectionAspectRatio);
117
130
  </script>
118
131
 
119
132
  <svelte:window on:mousemove={onMouseMove} on:mouseup={onMouseUp} on:touchend={onMouseUp} on:touchcancel={onMouseUp} />
@@ -49,6 +49,7 @@ export declare class CropperStore extends Store<ICropperStore> {
49
49
  constructor(initialValue: Omit<ICropperStore, 'cursor'>);
50
50
  setOutput(selection?: CropOutput): void;
51
51
  updateDimensions(width: number, height: number): void;
52
+ updateTargetAspect(ar: number): void;
52
53
  /**
53
54
  * The svelte component is responsible for making sure x and y are relative to the drawing area,
54
55
  * e.g. (0, 0) is the top left corner of the drawing area
@@ -18,6 +18,9 @@ export class CropperStore extends Store {
18
18
  updateDimensions(width, height) {
19
19
  this.update(v => ({ ...v, width, height }));
20
20
  }
21
+ updateTargetAspect(ar) {
22
+ this.update(v => ({ ...v, targetAspect: ar }));
23
+ }
21
24
  /**
22
25
  * The svelte component is responsible for making sure x and y are relative to the drawing area,
23
26
  * e.g. (0, 0) is the top left corner of the drawing area
@@ -221,7 +221,7 @@ function onKeyDown(e) {
221
221
  border-radius: 10px;
222
222
  border: 1px solid #999;
223
223
  height: 30px;
224
- padding: 0px 0px 0px 30px;
224
+ padding: 0.5em;
225
225
  font-family: 'Nunito Sans', sans-serif !important;
226
226
  }
227
227
 
@@ -250,7 +250,7 @@ function onKeyDown(e) {
250
250
  font-size: 28px;
251
251
  }
252
252
 
253
- .icon-picker-item[aria-checked=true] {
253
+ .icon-picker-item[aria-checked=true] :global(svg) {
254
254
  outline: 4px solid #93BBC4;
255
255
  background-color: #eee;
256
256
  }
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": "1.1.19",
4
+ "version": "1.1.20",
5
5
  "scripts": {
6
6
  "prepublishOnly": "svelte-package",
7
7
  "dev": "vite dev --force",