@dosgato/dialog 1.4.5 → 1.5.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.
Files changed (61) hide show
  1. package/dist/Dialog.svelte +3 -3
  2. package/dist/FieldAutocomplete.svelte +19 -15
  3. package/dist/FieldCheckbox.svelte +4 -4
  4. package/dist/FieldChoices.svelte +11 -7
  5. package/dist/FieldChooserLink.svelte +30 -32
  6. package/dist/FieldDate.svelte +3 -3
  7. package/dist/FieldDateTime.svelte +3 -4
  8. package/dist/FieldDualListbox.svelte +9 -11
  9. package/dist/FieldIdentifier.svelte +2 -2
  10. package/dist/FieldMultiple.svelte +6 -5
  11. package/dist/FieldMultiselect.svelte +5 -5
  12. package/dist/FieldNumber.svelte +3 -3
  13. package/dist/FieldRadio.svelte +3 -7
  14. package/dist/FieldSelect.svelte +4 -8
  15. package/dist/FieldStandard.svelte +5 -3
  16. package/dist/FieldStandard.svelte.d.ts +4 -2
  17. package/dist/FieldText.svelte +6 -5
  18. package/dist/FieldText.svelte.d.ts +2 -1
  19. package/dist/FieldTextArea.svelte +3 -4
  20. package/dist/FileIcon.svelte +1 -1
  21. package/dist/Form.svelte +4 -4
  22. package/dist/FormDialog.svelte +2 -2
  23. package/dist/Icon.svelte +10 -6
  24. package/dist/InlineMessage.svelte +3 -3
  25. package/dist/InlineMessages.svelte +1 -1
  26. package/dist/Input.svelte +3 -3
  27. package/dist/Input.svelte.d.ts +2 -1
  28. package/dist/Listbox.svelte +3 -4
  29. package/dist/Radio.svelte +0 -1
  30. package/dist/Switcher.svelte +1 -1
  31. package/dist/Tabs.svelte +3 -4
  32. package/dist/Tooltip.svelte +6 -5
  33. package/dist/chooser/AssetTabs.svelte +19 -17
  34. package/dist/chooser/AssetTabs.svelte.d.ts +1 -1
  35. package/dist/chooser/Chooser.svelte +3 -3
  36. package/dist/chooser/Chooser.svelte.d.ts +5 -5
  37. package/dist/chooser/ChooserStore.js +2 -2
  38. package/dist/chooser/UploadUI.svelte +4 -4
  39. package/dist/code/FieldCodeEditor.svelte +3 -3
  40. package/dist/code/FieldGraphQLEditor.svelte +28 -0
  41. package/dist/code/FieldGraphQLEditor.svelte.d.ts +36 -0
  42. package/dist/code/FieldTypeScriptEditor.svelte +27 -0
  43. package/dist/code/FieldTypeScriptEditor.svelte.d.ts +34 -0
  44. package/dist/code/GraphQLEditor.svelte +145 -0
  45. package/dist/code/GraphQLEditor.svelte.d.ts +35 -0
  46. package/dist/code/TypeScriptEditor.svelte +186 -0
  47. package/dist/code/TypeScriptEditor.svelte.d.ts +33 -0
  48. package/dist/code/index.d.ts +2 -0
  49. package/dist/code/index.js +2 -0
  50. package/dist/colorpicker/FieldColorPicker.svelte +2 -2
  51. package/dist/cropper/FieldCropper.svelte +8 -10
  52. package/dist/cropper/cropper.js +9 -11
  53. package/dist/iconpicker/FieldIconPicker.svelte +7 -11
  54. package/dist/imageposition/FieldImagePosition.svelte +4 -5
  55. package/dist/imageposition/index.d.ts +1 -1
  56. package/dist/imageposition/index.js +0 -1
  57. package/dist/tagpicker/FieldTagPicker.svelte +1 -2
  58. package/dist/tree/Tree.svelte +2 -3
  59. package/dist/tree/TreeCell.svelte +2 -2
  60. package/dist/tree/TreeNode.svelte +16 -17
  61. package/package.json +14 -7
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { HTMLActionEntry } from '@txstate-mws/svelte-components'
3
3
  import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms'
4
+ import type { FullAutoFill } from 'svelte/elements'
4
5
  import FieldStandard from './FieldStandard.svelte'
5
6
  import Input from './Input.svelte'
6
7
  import MaxLength from './MaxLength.svelte'
@@ -10,11 +11,11 @@
10
11
  export { className as class }
11
12
  export let id: string | undefined = undefined
12
13
  export let path: string
13
- export let label: string = ''
14
+ export let label = ''
14
15
  export let placeholder: string | undefined = undefined
15
16
  export let notNull = false
16
17
  export let defaultValue: any = notNull ? '' : undefined
17
- export let type: string = 'text'
18
+ export let type = 'text'
18
19
  export let allowlastpass = false
19
20
  export let maxlength: number | undefined = undefined
20
21
  export let conditional: boolean | undefined = undefined
@@ -22,13 +23,13 @@
22
23
  export let use: HTMLActionEntry[] = []
23
24
  export let inputelement: HTMLInputElement = undefined as any
24
25
  export let related: true | number = 0
25
- export let autocomplete = 'off'
26
+ export let autocomplete: FullAutoFill = 'off'
26
27
  export let extradescid: string | undefined = undefined
27
28
  export let helptext: string | undefined = undefined
28
29
  </script>
29
30
 
30
- <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} serialize={!notNull ? nullableSerialize : undefined} deserialize={!notNull ? nullableDeserialize : undefined} let:value let:valid let:invalid let:id let:onBlur let:onChange let:messagesid let:helptextid>
31
- <Input bind:inputelement {type} {placeholder} {autocomplete} name={path} {value} {id} class="dialog-input {className}" {allowlastpass} {onChange} {onBlur} {valid} {invalid} {messagesid} {helptextid} {extradescid} {use}></Input>
31
+ <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} serialize={!notNull ? nullableSerialize : undefined} deserialize={!notNull ? nullableDeserialize : undefined} let:value let:valid let:invalid let:id={fieldid} let:onBlur let:onChange let:messagesid let:helptextid>
32
+ <Input bind:inputelement {type} {placeholder} {autocomplete} name={path} {value} id={fieldid} class="dialog-input {className}" {allowlastpass} {onChange} {onBlur} {valid} {invalid} {messagesid} {helptextid} {extradescid} {use}></Input>
32
33
  {#if isNotNull(maxlength)}
33
34
  <MaxLength {value} {maxlength}/>
34
35
  {/if}
@@ -1,5 +1,6 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { HTMLActionEntry } from '@txstate-mws/svelte-components';
3
+ import type { FullAutoFill } from 'svelte/elements';
3
4
  declare const __propDef: {
4
5
  props: {
5
6
  class?: string;
@@ -17,7 +18,7 @@ declare const __propDef: {
17
18
  use?: HTMLActionEntry[];
18
19
  inputelement?: HTMLInputElement;
19
20
  related?: true | number;
20
- autocomplete?: string;
21
+ autocomplete?: FullAutoFill;
21
22
  extradescid?: string | undefined;
22
23
  helptext?: string | undefined;
23
24
  };
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { getDescribedBy } from './'
3
3
  import { type HTMLActionEntry, passActions } from '@txstate-mws/svelte-components'
4
- import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms'
5
4
  import FieldStandard from './FieldStandard.svelte'
6
5
  import MaxLength from './MaxLength.svelte'
7
6
  import { isNotNull } from 'txstate-utils'
@@ -9,7 +8,7 @@
9
8
  export { className as class }
10
9
  export let id: string | undefined = undefined
11
10
  export let path: string
12
- export let label: string = ''
11
+ export let label = ''
13
12
  export let placeholder: string | undefined = undefined
14
13
  export let notNull = false
15
14
  export let defaultValue: any = notNull ? '' : undefined
@@ -24,8 +23,8 @@
24
23
  export let helptext: string | undefined = undefined
25
24
  </script>
26
25
 
27
- <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} serialize={!notNull ? nullableSerialize : undefined} deserialize={!notNull ? nullableDeserialize : undefined} let:value let:valid let:invalid let:id let:onBlur let:onChange let:messagesid let:helptextid>
28
- <textarea bind:this={inputelement} {placeholder} name={path} {value} {id} {rows} class="dialog-input dialog-textarea {className}" class:valid class:invalid aria-invalid={invalid} aria-describedby={getDescribedBy([messagesid, helptextid, extradescid])} on:change={onChange} on:blur={onBlur} on:keyup={onChange} on:paste use:passActions={use}></textarea>
26
+ <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} {notNull} let:value let:valid let:invalid let:id={fieldid} let:onBlur let:onChange let:messagesid let:helptextid>
27
+ <textarea bind:this={inputelement} {placeholder} name={path} {value} id={fieldid} {rows} class="dialog-input dialog-textarea {className}" class:valid class:invalid aria-invalid={invalid} aria-describedby={getDescribedBy([messagesid, helptextid, extradescid])} on:change={onChange} on:blur={onBlur} on:keyup={onChange} on:paste use:passActions={use}></textarea>
29
28
  {#if isNotNull(maxlength)}
30
29
  <MaxLength {value} {maxlength}/>
31
30
  {/if}
@@ -3,7 +3,7 @@
3
3
  import { iconForMime } from './fileIcons'
4
4
  export let mime: string
5
5
  export let hiddenLabel: string | undefined = undefined
6
- export let inline: boolean = false
6
+ export let inline = false
7
7
  export let width: string | number = '1em'
8
8
  export let height: string | number = width
9
9
 
package/dist/Form.svelte CHANGED
@@ -47,7 +47,7 @@
47
47
  {@const successMessages = messages.filter(m => m.type === 'success')}
48
48
  {#if errorMessages.length || showingInlineErrors}
49
49
  <ul class="form-errors" aria-live='assertive'>
50
- {#each errorMessages as message}
50
+ {#each errorMessages as message (message.path, message.message)}
51
51
  <li><Icon icon={messageIcons[message.type] ?? messageIcons.error} inline hiddenLabel="error"/> {message.message}</li>
52
52
  {/each}
53
53
  {#if showingInlineErrors}
@@ -57,21 +57,21 @@
57
57
  {/if}
58
58
  {#if warningMessages.length}
59
59
  <ul class="form-warnings" aria-live='assertive'>
60
- {#each warningMessages as message}
60
+ {#each warningMessages as message (message.message)}
61
61
  <li><Icon icon={messageIcons.warning} inline hiddenLabel="warning"/> {message.message}</li>
62
62
  {/each}
63
63
  </ul>
64
64
  {/if}
65
65
  {#if infoMessages.length}
66
66
  <ul class="form-info" aria-live='assertive'>
67
- {#each infoMessages as message}
67
+ {#each infoMessages as message (message.message)}
68
68
  <li><Icon icon={messageIcons.info} inline hiddenLabel="info"/> {message.message}</li>
69
69
  {/each}
70
70
  </ul>
71
71
  {/if}
72
72
  {#if successMessages.length}
73
73
  <ul class="form-successes" aria-live='assertive'>
74
- {#each successMessages as message}
74
+ {#each successMessages as message (message.message)}
75
75
  <li><Icon icon={messageIcons.success} inline hiddenLabel="success" /> {message.message}</li>
76
76
  {/each}
77
77
  </ul>
@@ -2,7 +2,7 @@
2
2
  import type { IconifyIcon } from '@iconify/svelte'
3
3
  import contentSave from '@iconify-icons/mdi/content-save'
4
4
  import type { Feedback, FormStore } from '@txstate-mws/svelte-forms'
5
- import { type ComponentProps } from 'svelte'
5
+ import type { ComponentProps } from 'svelte'
6
6
  import { Form } from './'
7
7
  import Dialog from './Dialog.svelte'
8
8
 
@@ -28,7 +28,7 @@
28
28
  }
29
29
 
30
30
  export let store: FormStore<T> | undefined = undefined
31
- export let title: string = ''
31
+ export let title = ''
32
32
  export let icon: IconifyIcon | undefined = undefined
33
33
  export let size: 'tiny' | 'small' | 'normal' | 'large' = 'normal'
34
34
  export let expandable = true
package/dist/Icon.svelte CHANGED
@@ -12,7 +12,7 @@
12
12
  export let icon: IconifyIcon | undefined
13
13
  /** Label used in a `<ScreenReaderOnly>`. */
14
14
  export let hiddenLabel: string | undefined = undefined
15
- export let inline: boolean = false
15
+ export let inline = false
16
16
  export let width: string | number | undefined = undefined
17
17
  export let height: string | number | undefined = undefined
18
18
  export let tooltip: string | undefined = undefined
@@ -21,24 +21,25 @@
21
21
  export { className as class }
22
22
 
23
23
  function replaceIDs (body: string): string {
24
- const matches = body.matchAll(/\sid="(\S+)"/g)
24
+ const matches = body.matchAll(/\sid="(\S+)"/gv)
25
25
  const ids = Array.from(matches).map(m => m[1])
26
26
  if (!ids.length) return body
27
27
 
28
28
  // Replace with unique ids
29
- ids.forEach((id) => {
30
- const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
29
+ ids.forEach(id => {
30
+ const escapedID = id.replace(/[.*+?^$\{\}\(\)\]\\]/gv, '\\$&')
31
31
 
32
32
  body = body.replace(
33
33
  // Allowed characters before id: [#;"]
34
34
  // Allowed characters after id: [)"], .[a-z]
35
- new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', 'g'),
35
+ new RegExp('([#;"])(' + escapedID + ')([\\)"]|\\.[a-z])', 'gv'),
36
36
  '$1' + randomid() + '$3'
37
37
  )
38
38
  })
39
39
  return body
40
40
  }
41
41
 
42
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity -- no need for reactivity
42
43
  const fixedSVG = new Map<IconifyIcon, string>()
43
44
  function svgBody (icon: IconifyIcon) {
44
45
  if (!fixedSVG.has(icon)) fixedSVG.set(icon, replaceIDs(icon.body))
@@ -46,7 +47,10 @@
46
47
  }
47
48
 
48
49
  // If neither is defined, set both to 1em
49
- if (!width && !height) width = height = '1em'
50
+ if (!width && !height) {
51
+ width = '1em'
52
+ height = '1em'
53
+ }
50
54
  height ??= width
51
55
  </script>
52
56
 
@@ -13,13 +13,13 @@
13
13
  $: iconLabel = messageLabels[message.type] ?? messageLabels.error
14
14
 
15
15
  function addMarkup (msg: string) {
16
- const lines = msg.split(/\r?\n/)
16
+ const lines = msg.split(/\r?\n/v)
17
17
  const output: string[] = []
18
18
  for (const line of lines) {
19
- const splitLinks = line.split(/((?:\[[^\]]+\])?\([^)]+\))/)
19
+ const splitLinks = line.split(/((?:\[[^\]]+\])?\([^\)]+\))/v)
20
20
  const replaced: string[] = []
21
21
  for (const segment of splitLinks) {
22
- const m = segment.match(/(?:\[([^\]]+)\])?\(([^)]+)\)/)
22
+ const m = segment.match(/(?:\[([^\]]+)\])?\(([^\)]+)\)/v)
23
23
  if (m) {
24
24
  try {
25
25
  const url = new URL(m[2])
@@ -15,7 +15,7 @@
15
15
 
16
16
  {#if id}
17
17
  <div {id}>
18
- {#each messages as message}
18
+ {#each messages as message (message.type, message.path, message.message)}
19
19
  <InlineMessage {message} />
20
20
  {/each}
21
21
  </div>
package/dist/Input.svelte CHANGED
@@ -1,13 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { passActions, type HTMLActionEntry } from '@txstate-mws/svelte-components'
3
3
  import { dateSerialize, datetimeSerialize } from '@txstate-mws/svelte-forms'
4
+ import type { FullAutoFill } from 'svelte/elements'
4
5
  import { isNotBlank } from 'txstate-utils'
5
6
 
6
7
  let className = ''
7
8
  export { className as class }
8
9
  export let name: string
9
10
  export let value: string
10
- export let type: string = 'text'
11
+ export let type = 'text'
11
12
  export let allowlastpass = false
12
13
  export let placeholder: string | undefined = undefined
13
14
  export let maxlength: number | undefined = undefined
@@ -16,7 +17,7 @@
16
17
  export let step: number | undefined = undefined
17
18
  export let id: string | undefined = undefined
18
19
  export let disabled = false
19
- export let autocomplete = 'off'
20
+ export let autocomplete: FullAutoFill = 'off'
20
21
  export let extradescid: string | undefined = undefined
21
22
  export let messagesid: string | undefined = undefined
22
23
  export let helptextid: string | undefined = undefined
@@ -40,5 +41,4 @@
40
41
  $: maxStr = resolveMinMax(max)
41
42
  </script>
42
43
 
43
- <!-- svelte-ignore a11y-autocomplete-valid -->
44
44
  <input bind:this={inputelement} {type} {id} {autocomplete} {placeholder} class={className} data-lpignore={!allowlastpass} {name} {value} {disabled} {maxlength} min={minStr} max={maxStr} {step} class:valid class:invalid aria-invalid={invalid} aria-describedby={isNotBlank(descby) ? descby : null} on:change={onChange} on:select={onSelect} on:blur={onBlur} on:keyup={onChange} use:passActions={use}>
@@ -1,5 +1,6 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import { type HTMLActionEntry } from '@txstate-mws/svelte-components';
3
+ import type { FullAutoFill } from 'svelte/elements';
3
4
  declare const __propDef: {
4
5
  props: {
5
6
  class?: string;
@@ -18,7 +19,7 @@ declare const __propDef: {
18
19
  step?: number | undefined;
19
20
  id?: string | undefined;
20
21
  disabled?: boolean;
21
- autocomplete?: string;
22
+ autocomplete?: FullAutoFill;
22
23
  extradescid?: string | undefined;
23
24
  messagesid?: string | undefined;
24
25
  helptextid?: string | undefined;
@@ -6,7 +6,7 @@
6
6
  const dispatch = createEventDispatcher()
7
7
  export let items: PopupMenuItem[] = []
8
8
  export let label: string
9
- export let multiselect: boolean = false
9
+ export let multiselect = false
10
10
  export let selected: { value: string, label?: string }[] = []
11
11
  export let descid: string | undefined = undefined
12
12
  export let valid = false
@@ -67,13 +67,13 @@
67
67
  e.preventDefault()
68
68
  if (items.length < 1) return
69
69
  let i = (hilited ?? firstactive - 1) + 1
70
- while (items[i]?.disabled) i++
70
+ while (items[i]?.disabled) i += 1
71
71
  move(i)
72
72
  } else if (e.key === 'ArrowUp') {
73
73
  e.preventDefault()
74
74
  if (items.length < 1) return
75
75
  let i = (hilited ?? lastactive + 1) - 1
76
- while (items[i]?.disabled) i--
76
+ while (items[i]?.disabled) i -= 1
77
77
  move(i)
78
78
  } else if (e.key === ' ') {
79
79
  e.preventDefault()
@@ -114,7 +114,6 @@
114
114
 
115
115
  <div class="listbox-container" class:valid class:invalid>
116
116
  <span id={labelId}>{label}</span>
117
- <!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
118
117
  <ul bind:this={listboxElement} role="listbox" id={listId} class="listbox-items" tabindex="0" aria-describedby={descid} aria-labelledby={labelId} aria-multiselectable={multiselect} on:keydown={onkeydown} on:focus={focusListbox}>
119
118
  {#each items as item, i (item.value)}
120
119
  <!-- svelte-ignore a11y-click-events-have-key-events -->
package/dist/Radio.svelte CHANGED
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { isNotBlank } from 'txstate-utils'
3
3
 
4
-
5
4
  export let id: string | undefined = undefined
6
5
  export let name: string
7
6
  export let value: string
@@ -9,7 +9,7 @@
9
9
  let className = ''
10
10
  export { className as class }
11
11
  export let id: string | undefined = randomid()
12
- export let path: string = ''
12
+ export let path = ''
13
13
  export let name = randomid()
14
14
  export let choices: { label?: string, value: string, disabled?: boolean }[]
15
15
  export let horizontal = false
package/dist/Tabs.svelte CHANGED
@@ -49,7 +49,7 @@
49
49
  return () => store.activate(idx)
50
50
  }
51
51
  function onKeyDown (idx: number) {
52
- return async (e) => {
52
+ return async e => {
53
53
  if (modifierKey(e)) return
54
54
  if (['Enter', ' ', 'ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(e.key)) {
55
55
  e.preventDefault()
@@ -98,13 +98,13 @@
98
98
  if (!activeelement) return
99
99
  const tabelement = tabelements[$currentIdx]
100
100
  if (!tabelement) return
101
- const span = tabelement.querySelector(':scope > span') as HTMLSpanElement
101
+ const span = tabelement.querySelector<HTMLElement>(':scope > span')!
102
102
  if (!span) return
103
103
  const left = span.offsetLeft - activeelement.offsetLeft - activeOversize
104
104
  const width = span.offsetWidth + (activeOversize * 2)
105
105
  activeelement.style.transform = `translateX(${left}px)`
106
106
  activeelement.style.width = `${width}px`
107
- hiddenTabs = $store.tabs.filter((tab, idx) => { return tabIsHidden(idx) })
107
+ hiddenTabs = $store.tabs.filter((tab, idx) => tabIsHidden(idx))
108
108
  }
109
109
 
110
110
  $: active = $currentName
@@ -115,7 +115,6 @@
115
115
 
116
116
  {#if $store.tabs.length > 1}
117
117
  {#if !$accordion}
118
- <!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
119
118
  <ul use:resize={{ store }} class="tabs-buttons" role="tablist">
120
119
  {#each $store.tabs as tab, idx (tab.name)}
121
120
  {@const active = isActive(idx, $store.current)}
@@ -4,12 +4,12 @@
4
4
  import { randomid } from 'txstate-utils'
5
5
 
6
6
  export let tip: string | undefined = undefined
7
- export let top: boolean = false
8
- export let right: boolean = false
9
- export let bottom: boolean = false
10
- export let left: boolean = false
7
+ export let top = false
8
+ export let right = false
9
+ export let bottom = false
10
+ export let left = false
11
11
  export let align: GlueAlignOpts | undefined = undefined
12
- export let active: boolean = false
12
+ export let active = false
13
13
 
14
14
  const tooltipId = randomid()
15
15
  const anchorName = `--tip-${tooltipId}`
@@ -56,6 +56,7 @@
56
56
  opacity: 0;
57
57
  z-index: 1;
58
58
  visibility: hidden;
59
+ white-space: pre-line;
59
60
  transition: opacity 150ms, visibility 150ms;
60
61
  }
61
62
  .default-tip {
@@ -1,19 +1,17 @@
1
1
  <script lang="ts">
2
2
  import { bytesToHuman } from 'txstate-utils'
3
- import type { Asset } from './ChooserAPI'
4
3
  import { Dialog, FieldTextArea } from '..'
5
4
  import Button from '../Button.svelte'
6
5
  import Icon from '../Icon.svelte'
7
6
  import outIcon from '@iconify-icons/ph/arrow-square-out-bold'
8
7
  import warningIcon from '@iconify-icons/ph/warning'
9
8
  import { getContext } from 'svelte'
10
- import type { Client } from './ChooserAPI'
11
- import { CHOOSER_API_CONTEXT } from './ChooserAPI'
9
+ import { CHOOSER_API_CONTEXT, type Asset, type Client } from './ChooserAPI'
12
10
 
13
11
  export let id: string
14
12
  export let selectedAsset: Asset
15
- export let showMetadata: boolean = false
16
- export let altTextRequired: boolean = false
13
+ export let showMetadata = false
14
+ export let altTextRequired = false
17
15
  // if they say it's required but don't provide a path, default to 'altText'
18
16
  export let altTextPath: string | undefined = altTextRequired ? 'altText' : undefined
19
17
  export let altTextHelp: string | undefined
@@ -31,26 +29,30 @@
31
29
  { id: `${id}-details`, label: 'Asset Details' },
32
30
  ...(showMetadata ? [{ id: `${id}-metadata`, label: 'Metadata' }] : [])
33
31
  ]
34
- $: activeTab = tabs ? tabs[0].id : 0
32
+ let activeTab: string | number = 0
33
+ function reactToTabs (..._: any[]) {
34
+ activeTab = tabs ? tabs[0].id : 0
35
+ }
36
+ $: reactToTabs(tabs)
35
37
  let focusedTabIdx = 0
36
38
 
37
- function selectTab(tabId: string) {
39
+ function selectTab (tabId: string) {
38
40
  activeTab = tabId
39
41
  focusedTabIdx = tabs.findIndex(t => t.id === tabId)
40
42
  // ensure the focused tab is visible
41
- const tabEls = tabListEl.querySelectorAll(`[role="tab"][data-tab-asset]`)
42
- tabEls[focusedTabIdx]?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center'})
43
+ const tabEls = tabListEl.querySelectorAll('[role="tab"][data-tab-asset]')
44
+ tabEls[focusedTabIdx]?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' })
43
45
  }
44
46
 
45
- function focusTab(idx: number) {
47
+ function focusTab (idx: number) {
46
48
  focusedTabIdx = idx
47
49
  activeTab = tabs[idx].id
48
- const tabEls = tabListEl.querySelectorAll(`[role="tab"][data-tab-asset]`)
50
+ const tabEls = tabListEl.querySelectorAll('[role="tab"][data-tab-asset]')
49
51
  if (tabEls[idx]) (tabEls[idx] as HTMLElement).focus()
50
- tabEls[idx]?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center'})
52
+ tabEls[idx]?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' })
51
53
  }
52
54
 
53
- function onTabKeydown(e: KeyboardEvent, idx: number) {
55
+ function onTabKeydown (e: KeyboardEvent, idx: number) {
54
56
  if (e.key === 'ArrowRight') {
55
57
  e.preventDefault()
56
58
  focusTab((idx + 1) % tabs.length)
@@ -63,7 +65,7 @@
63
65
  }
64
66
  }
65
67
 
66
- async function navigateToManageAsset() {
68
+ async function navigateToManageAsset () {
67
69
  manageAssetsModalOpen = false
68
70
  const url = chooserClient.idToEditingUrl ? await chooserClient.idToEditingUrl(selectedAsset.id) : undefined
69
71
  if (url) {
@@ -74,7 +76,7 @@
74
76
 
75
77
  {#if useTabs}
76
78
  <ul bind:this={tabListEl} class="tabs" role="tablist">
77
- {#each tabs as tab, idx}
79
+ {#each tabs as tab, idx (tab.id)}
78
80
  <li
79
81
  id="{tab.id}-tab"
80
82
  class="tab {activeTab === tab.id ? 'active' : ''}"
@@ -84,7 +86,7 @@
84
86
  tabindex={focusedTabIdx === idx ? 0 : -1}
85
87
  data-tab-asset
86
88
  on:click={() => selectTab(tab.id)}
87
- on:keydown={(e) => onTabKeydown(e, idx)}
89
+ on:keydown={e => onTabKeydown(e, idx)}
88
90
  on:focus={() => { focusedTabIdx = idx }}
89
91
  >
90
92
  <span>{tab.label}</span>
@@ -203,4 +205,4 @@
203
205
  justify-content: center;
204
206
  gap: 0.4em;
205
207
  }
206
- </style>
208
+ </style>
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { Asset } from './ChooserAPI';
2
+ import { type Asset } from './ChooserAPI';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  id: string;
@@ -1,4 +1,4 @@
1
- <script lang="ts" generics="F">
1
+ <script lang="ts" generics="F extends object">
2
2
  import browserIcon from '@iconify-icons/ph/browser'
3
3
  import folderIcon from '@iconify-icons/ph/folder'
4
4
  import folderNotchOpen from '@iconify-icons/ph/folder-notch-open'
@@ -41,7 +41,7 @@
41
41
  $: store.setPreview($selected)
42
42
 
43
43
  function onChoose () {
44
- dispatch('change', { preview: $store.preview, copyAltText: altTextCheckbox?.checked ?? false } )
44
+ dispatch('change', { preview: $store.preview, copyAltText: altTextCheckbox?.checked ?? false })
45
45
  }
46
46
 
47
47
  function onDeselect () {
@@ -54,7 +54,7 @@
54
54
  showuploader = false
55
55
  }
56
56
 
57
- async function selectPreview (preloadPath) {
57
+ async function selectPreview (preloadPath: string | undefined) {
58
58
  if (!$store.initialized) return
59
59
  if (preloadPath) {
60
60
  const currentSelection = await expandTreePath(treeStore, preloadPath.split('/').filter(isNotBlank))
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import { type AnyItem } from './ChooserAPI';
3
3
  import { ChooserStore } from './ChooserStore';
4
- declare class __sveltets_Render<F> {
4
+ declare class __sveltets_Render<F extends object> {
5
5
  props(): {
6
6
  label?: string | undefined;
7
7
  images?: boolean;
@@ -25,9 +25,9 @@ declare class __sveltets_Render<F> {
25
25
  };
26
26
  slots(): {};
27
27
  }
28
- export type ChooserProps<F> = ReturnType<__sveltets_Render<F>['props']>;
29
- export type ChooserEvents<F> = ReturnType<__sveltets_Render<F>['events']>;
30
- export type ChooserSlots<F> = ReturnType<__sveltets_Render<F>['slots']>;
31
- export default class Chooser<F> extends SvelteComponentTyped<ChooserProps<F>, ChooserEvents<F>, ChooserSlots<F>> {
28
+ export type ChooserProps<F extends object> = ReturnType<__sveltets_Render<F>['props']>;
29
+ export type ChooserEvents<F extends object> = ReturnType<__sveltets_Render<F>['events']>;
30
+ export type ChooserSlots<F extends object> = ReturnType<__sveltets_Render<F>['slots']>;
31
+ export default class Chooser<F extends object> extends SvelteComponentTyped<ChooserProps<F>, ChooserEvents<F>, ChooserSlots<F>> {
32
32
  }
33
33
  export {};
@@ -13,7 +13,7 @@ export function combinePath(path, name) {
13
13
  export function bytesToHuman(bytes) {
14
14
  const scales = [' bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
15
15
  const scale = Math.floor(Math.log(bytes) / Math.log(1024));
16
- return String(parseFloat((bytes / Math.pow(1024, scale)).toPrecision(3))) + scales[scale];
16
+ return String(parseFloat((bytes / 1024 ** scale).toPrecision(3))) + scales[scale];
17
17
  }
18
18
  export class ChooserStore extends Store {
19
19
  client;
@@ -85,7 +85,7 @@ export class ChooserStore extends Store {
85
85
  this.update(v => {
86
86
  if (!v.initialized && !init)
87
87
  return v;
88
- name ??= [...(v.sources?.page ?? []), ...(v.sources?.asset ?? [])].filter(s => this.options.activeSources ? this.options.activeSources.has(s.name) : true)[0].name;
88
+ name ??= [...(v.sources?.page ?? []), ...(v.sources?.asset ?? [])].find(s => this.options.activeSources ? this.options.activeSources.has(s.name) : true)?.name;
89
89
  const pageSource = v.sources?.page.findIndex(s => s.name === name);
90
90
  const assetSource = v.sources?.asset.findIndex(s => s.name === name);
91
91
  if ((pageSource ?? -1) >= 0)
@@ -6,7 +6,7 @@
6
6
 
7
7
  export let title: string
8
8
  export let folder: Folder
9
- export let maxFiles: number = 200
9
+ export let maxFiles = 200
10
10
  export let escapable = true
11
11
  export let mimeWhitelist: string[] = []
12
12
  export let mimeBlacklist: string[] = []
@@ -23,11 +23,11 @@
23
23
  let uploadError: string | undefined
24
24
 
25
25
  function onUploadEnter (e: DragEvent) {
26
- if (e.dataTransfer?.items.length) dragover++
26
+ if (e.dataTransfer?.items.length) dragover += 1
27
27
  }
28
28
 
29
29
  function onUploadLeave (e: DragEvent) {
30
- if (e.dataTransfer?.items.length) dragover--
30
+ if (e.dataTransfer?.items.length) dragover -= 1
31
31
  }
32
32
 
33
33
  function onUploadDrop (e: DragEvent) {
@@ -99,7 +99,7 @@
99
99
  <input type="file" id="uploader_input" multiple on:change={onUploadChange}>
100
100
  <label for="uploader_input">Choose or drag files</label>
101
101
  <ul>
102
- {#each uploadList as file}
102
+ {#each uploadList as file (file)}
103
103
  <li>
104
104
  <FileIcon width="1.5em" mime={file.type} inline />{file.name}<button type="button" on:click={onDeleteFile(file)}><Icon icon={trashLight} width="1.5em" hiddenLabel="Remove File" inline /></button>
105
105
  {#if (whitelist.size && !whitelist.has(file.type)) || (blacklist.size && blacklist.has(file.type))}
@@ -7,7 +7,7 @@
7
7
  export { className as class }
8
8
  export let id: string | undefined = undefined
9
9
  export let path: string
10
- export let label: string = ''
10
+ export let label = ''
11
11
  export let notNull = false
12
12
  export let defaultValue: any = notNull ? '' : undefined
13
13
  export let rows = 8
@@ -21,6 +21,6 @@
21
21
  export let language: 'js' | 'css' | 'html'
22
22
  </script>
23
23
 
24
- <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} serialize={!notNull ? nullableSerialize : undefined} deserialize={!notNull ? nullableDeserialize : undefined} let:value let:valid let:invalid let:id let:onBlur let:setVal let:messagesid let:helptextid>
25
- <CodeEditor {id} bind:inputelement {language} {rows} class={className} {value} {valid} {invalid} {helptextid} {messagesid} {extradescid} on:paste on:focusout={onBlur} {use} on:change={e => setVal(e.detail)}/>
24
+ <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} serialize={!notNull ? nullableSerialize : undefined} deserialize={!notNull ? nullableDeserialize : undefined} let:value let:valid let:invalid let:id={fieldid} let:onBlur let:setVal let:messagesid let:helptextid>
25
+ <CodeEditor id={fieldid} bind:inputelement {language} {rows} class={className} {value} {valid} {invalid} {helptextid} {messagesid} {extradescid} on:paste on:focusout={onBlur} {use} on:change={e => setVal(e.detail)}/>
26
26
  </FieldStandard>
@@ -0,0 +1,28 @@
1
+ <script lang="ts">
2
+ import type { HTMLActionEntry } from '@txstate-mws/svelte-components'
3
+ import type { GraphQLSchema } from 'graphql'
4
+ import { FieldStandard } from '..'
5
+ import GraphQLEditor from './GraphQLEditor.svelte'
6
+ let className = ''
7
+ export { className as class }
8
+ export let id: string | undefined = undefined
9
+ export let path: string
10
+ export let label = ''
11
+ export let notNull = false
12
+ export let defaultValue: any = notNull ? '' : undefined
13
+ export let rows = 8
14
+ export let conditional: boolean | undefined = undefined
15
+ export let required = false
16
+ export let use: HTMLActionEntry[] = []
17
+ export let inputelement: HTMLElement = undefined as any
18
+ export let related: true | number = 0
19
+ export let extradescid: string | undefined = undefined
20
+ export let helptext: string | undefined = undefined
21
+ export let schema: GraphQLSchema | undefined = undefined
22
+ export let noMutations = false
23
+ export let allowInvalid = false
24
+ </script>
25
+
26
+ <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} {notNull} let:value let:valid let:invalid let:id={fieldid} let:onBlur let:setVal let:messagesid let:helptextid let:deserialize>
27
+ <GraphQLEditor id={fieldid} bind:inputelement {schema} {noMutations} {allowInvalid} {rows} class={className} {value} {valid} {invalid} {helptextid} {messagesid} {extradescid} on:paste on:focusout={onBlur} {use} on:change={e => { console.log(e.detail); setVal(deserialize?.(e.detail)) }}/>
28
+ </FieldStandard>