@dosgato/dialog 0.0.5 → 0.0.8

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 (48) hide show
  1. package/ButtonGroup.svelte +1 -1
  2. package/Checkbox.svelte +1 -1
  3. package/Container.svelte +5 -1
  4. package/FieldAutocomplete.svelte +62 -0
  5. package/FieldAutocomplete.svelte.d.ts +31 -0
  6. package/FieldCheckbox.svelte +1 -1
  7. package/FieldChoices.svelte +1 -1
  8. package/FieldChooserLink.svelte +2 -2
  9. package/FieldDate.svelte +1 -1
  10. package/FieldDateTime.svelte +1 -1
  11. package/FieldDualListbox.svelte +1 -1
  12. package/FieldMultiple.svelte +1 -1
  13. package/FieldMultiselect.svelte +1 -1
  14. package/FieldNumber.svelte +1 -1
  15. package/FieldRadio.svelte +1 -1
  16. package/FieldSelect.svelte +1 -1
  17. package/FieldSelect.svelte.d.ts +1 -1
  18. package/FieldStandard.svelte +1 -1
  19. package/FieldText.svelte +1 -1
  20. package/FileIcon.svelte +3 -47
  21. package/Form.svelte +1 -1
  22. package/Icon.svelte +1 -1
  23. package/InlineMessage.svelte +1 -1
  24. package/InlineMessages.svelte +1 -1
  25. package/Input.svelte +1 -1
  26. package/Listbox.svelte +1 -1
  27. package/Radio.svelte +1 -1
  28. package/Tab.svelte +1 -1
  29. package/TabStore.js +1 -0
  30. package/Tabs.svelte +1 -1
  31. package/chooser/Asset.svelte +1 -1
  32. package/chooser/AssetFolder.svelte +1 -1
  33. package/chooser/Chooser.svelte +1 -1
  34. package/chooser/ChooserStore.js +11 -9
  35. package/chooser/Details.svelte +2 -2
  36. package/chooser/Page.svelte +1 -1
  37. package/chooser/Thumbnail.svelte +1 -1
  38. package/fileIcons.d.ts +1 -0
  39. package/fileIcons.js +47 -0
  40. package/iconpicker/FieldIconPicker.svelte +256 -0
  41. package/iconpicker/FieldIconPicker.svelte.d.ts +24 -0
  42. package/iconpicker/iconpicker.d.ts +13 -0
  43. package/iconpicker/iconpicker.js +24784 -0
  44. package/iconpicker/index.d.ts +1 -0
  45. package/iconpicker/index.js +1 -0
  46. package/index.d.ts +3 -0
  47. package/index.js +3 -0
  48. package/package.json +12 -6
@@ -1,4 +1,4 @@
1
- <script >import { modifierKey } from '@txstate-mws/svelte-components';
1
+ <script>import { modifierKey } from '@txstate-mws/svelte-components';
2
2
  import { createEventDispatcher } from 'svelte';
3
3
  export let name = undefined;
4
4
  export let choices;
package/Checkbox.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { isNotBlank } from 'txstate-utils';
1
+ <script>import { isNotBlank } from 'txstate-utils';
2
2
  export let id = undefined;
3
3
  export let name;
4
4
  export let value;
package/Container.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { eq } from '@txstate-mws/svelte-components';
1
+ <script>import { eq } from '@txstate-mws/svelte-components';
2
2
  import InlineMessages from './InlineMessages.svelte';
3
3
  export let id = undefined;
4
4
  export let descid = undefined;
@@ -83,4 +83,8 @@ let messagesid;
83
83
  background-color: var(--dialog-field-bg2, #ffffff);
84
84
  color: var(--dialog-field-text2, inherit);
85
85
  }
86
+ .dialog-field-container :global(.field-help-text) {
87
+ font-size: 0.9em;
88
+ color: #595959;
89
+ }
86
90
  </style>
@@ -0,0 +1,62 @@
1
+ <script>import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
2
+ import FieldStandard from './FieldStandard.svelte';
3
+ import { randomid } from 'txstate-utils';
4
+ import { PopupMenu, ScreenReaderOnly } from '@txstate-mws/svelte-components';
5
+ export let id = undefined;
6
+ export let path;
7
+ export let label = '';
8
+ export let placeholder = 'Select' + (label ? ' ' + label : '');
9
+ let className = '';
10
+ export { className as class };
11
+ export let notNull = false;
12
+ export let disabled = false;
13
+ export let choices;
14
+ export let defaultValue = notNull ? choices[0].value : undefined;
15
+ export let conditional = undefined;
16
+ export let required = false;
17
+ export let helptext = '';
18
+ let inputelement;
19
+ let inputvalue = '';
20
+ let popupvalue = undefined;
21
+ let savedLabel = '';
22
+ let changed = false;
23
+ if (defaultValue) {
24
+ const selected = choices.find(c => c.value === defaultValue);
25
+ inputvalue = selected.label || selected.value;
26
+ savedLabel = inputvalue;
27
+ }
28
+ const listId = randomid();
29
+ const liveTextId = randomid();
30
+ const helpTextId = randomid();
31
+ $: filteredChoices = changed
32
+ ? choices.filter((item) => {
33
+ return item.label?.toLowerCase().includes(inputvalue.toLowerCase()) || item.value.toLowerCase().includes(inputvalue.toLowerCase());
34
+ })
35
+ : choices;
36
+ function onchangepopup(setVal) {
37
+ return (e) => {
38
+ inputvalue = e.detail.label || e.detail.value;
39
+ savedLabel = inputvalue;
40
+ popupvalue = undefined;
41
+ setVal(e.detail.value);
42
+ changed = false;
43
+ };
44
+ }
45
+ async function checkifchanged(e) {
46
+ await setTimeout(function () {
47
+ if (inputelement.value !== savedLabel)
48
+ changed = true;
49
+ }, 1);
50
+ }
51
+ </script>
52
+
53
+ <FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} serialize={!notNull && nullableSerialize} deserialize={!notNull && nullableDeserialize} let:setVal let:valid let:invalid let:id let:onBlur let:onChange>
54
+ <input bind:this={inputelement} bind:value={inputvalue} {id} {placeholder} class="dialog-input {className}" class:valid class:invalid aria-invalid={invalid} {onBlur} {onChange} aria-owns={listId} autocapitalize="none" type="text" autocomplete="off" aria-autocomplete="list" role="combobox" aria-expanded="false" {disabled} aria-describedby={helptext.length ? helpTextId : ''} on:keydown={checkifchanged}>
55
+ <PopupMenu align="bottomleft" items={filteredChoices} buttonelement={inputelement} bind:value={popupvalue} on:change={onchangepopup(setVal)} emptyText="No options available"/>
56
+ {#if helptext.length}
57
+ <span id={helpTextId} class="field-help-text">{helptext}</span>
58
+ {/if}
59
+ <ScreenReaderOnly arialive="polite" ariaatomic={true} id={liveTextId}>
60
+ {filteredChoices.length} {filteredChoices.length === 1 ? 'option' : 'options'} available.
61
+ </ScreenReaderOnly>
62
+ </FieldStandard>
@@ -0,0 +1,31 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ id?: string | undefined;
5
+ path: string;
6
+ label?: string;
7
+ placeholder?: string;
8
+ class?: string;
9
+ notNull?: boolean;
10
+ disabled?: boolean;
11
+ choices: {
12
+ label?: string;
13
+ value: string;
14
+ disabled?: boolean;
15
+ }[];
16
+ defaultValue?: any;
17
+ conditional?: boolean | undefined;
18
+ required?: boolean;
19
+ helptext?: string;
20
+ };
21
+ events: {
22
+ [evt: string]: CustomEvent<any>;
23
+ };
24
+ slots: {};
25
+ };
26
+ export declare type FieldAutocompleteProps = typeof __propDef.props;
27
+ export declare type FieldAutocompleteEvents = typeof __propDef.events;
28
+ export declare type FieldAutocompleteSlots = typeof __propDef.slots;
29
+ export default class FieldAutocomplete extends SvelteComponentTyped<FieldAutocompleteProps, FieldAutocompleteEvents, FieldAutocompleteSlots> {
30
+ }
31
+ export {};
@@ -1,4 +1,4 @@
1
- <script >import { randomid } from 'txstate-utils';
1
+ <script>import { randomid } from 'txstate-utils';
2
2
  import FieldStandard from './FieldStandard.svelte';
3
3
  import Checkbox from './Checkbox.svelte';
4
4
  let className = '';
@@ -1,4 +1,4 @@
1
- <script >import { getContext } from 'svelte';
1
+ <script>import { getContext } from 'svelte';
2
2
  import { Field, FORM_CONTEXT } from '@txstate-mws/svelte-forms';
3
3
  import { derivedStore } from '@txstate-mws/svelte-store';
4
4
  import { randomid } from 'txstate-utils';
@@ -1,6 +1,6 @@
1
- <script context="module">export {};
1
+ <script context="module">export {};
2
2
  </script>
3
- <script >import { FORM_CONTEXT } from '@txstate-mws/svelte-forms';
3
+ <script>import { FORM_CONTEXT } from '@txstate-mws/svelte-forms';
4
4
  import { getContext } from 'svelte';
5
5
  import { randomid } from 'txstate-utils';
6
6
  import { Chooser, ChooserStore, CHOOSER_API_CONTEXT } from './chooser';
package/FieldDate.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { dateSerialize, dateDeserialize } from '@txstate-mws/svelte-forms';
1
+ <script>import { dateSerialize, dateDeserialize } from '@txstate-mws/svelte-forms';
2
2
  import FieldStandard from './FieldStandard.svelte';
3
3
  import Input from './Input.svelte';
4
4
  let className = '';
@@ -1,4 +1,4 @@
1
- <script >import { datetimeSerialize, datetimeDeserialize } from '@txstate-mws/svelte-forms';
1
+ <script>import { datetimeSerialize, datetimeDeserialize } from '@txstate-mws/svelte-forms';
2
2
  import FieldStandard from './FieldStandard.svelte';
3
3
  import Input from './Input.svelte';
4
4
  let className = '';
@@ -1,4 +1,4 @@
1
- <script >import menuRight from '@iconify-icons/mdi/menu-right.js';
1
+ <script>import menuRight from '@iconify-icons/mdi/menu-right.js';
2
2
  import menuLeft from '@iconify-icons/mdi/menu-left.js';
3
3
  import FieldStandard from './FieldStandard.svelte';
4
4
  import { ScreenReaderOnly, modifierKey } from '@txstate-mws/svelte-components';
@@ -1,4 +1,4 @@
1
- <script >import { AddMore, FORM_CONTEXT, FORM_INHERITED_PATH } from '@txstate-mws/svelte-forms';
1
+ <script>import { AddMore, FORM_CONTEXT, FORM_INHERITED_PATH } from '@txstate-mws/svelte-forms';
2
2
  import { derivedStore } from '@txstate-mws/svelte-store';
3
3
  import { getContext } from 'svelte';
4
4
  import { isNotNull } from 'txstate-utils';
@@ -1,4 +1,4 @@
1
- <script >import { MultiSelect } from '@txstate-mws/svelte-components';
1
+ <script>import { MultiSelect } from '@txstate-mws/svelte-components';
2
2
  import FieldStandard from './FieldStandard.svelte';
3
3
  export let id = undefined;
4
4
  export let path;
@@ -1,4 +1,4 @@
1
- <script >import FieldStandard from './FieldStandard.svelte';
1
+ <script>import FieldStandard from './FieldStandard.svelte';
2
2
  import Input from './Input.svelte';
3
3
  import { numberDeserialize, numberNullableDeserialize, numberSerialize } from '@txstate-mws/svelte-forms';
4
4
  let className = '';
package/FieldRadio.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
1
+ <script>import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
2
2
  import { randomid } from 'txstate-utils';
3
3
  import FieldStandard from './FieldStandard.svelte';
4
4
  import Radio from './Radio.svelte';
@@ -1,4 +1,4 @@
1
- <script >import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
1
+ <script>import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
2
2
  import FieldStandard from './FieldStandard.svelte';
3
3
  let className = '';
4
4
  export { className as class };
@@ -10,7 +10,7 @@ declare const __propDef: {
10
10
  disabled?: boolean;
11
11
  choices: {
12
12
  label?: string;
13
- value: any;
13
+ value: string;
14
14
  disabled?: boolean;
15
15
  }[];
16
16
  defaultValue?: any;
@@ -1,4 +1,4 @@
1
- <script >import { Field } from '@txstate-mws/svelte-forms';
1
+ <script>import { Field } from '@txstate-mws/svelte-forms';
2
2
  import { randomid } from 'txstate-utils';
3
3
  import Container from './Container.svelte';
4
4
  export let id = randomid();
package/FieldText.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
1
+ <script>import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
2
2
  import FieldStandard from './FieldStandard.svelte';
3
3
  import Input from './Input.svelte';
4
4
  let className = '';
package/FileIcon.svelte CHANGED
@@ -1,56 +1,12 @@
1
- <script context="module">import archiveOutline from '@iconify-icons/mdi/archive-outline.js';
2
- import fileCodeOutline from '@iconify-icons/mdi/file-code-outline.js';
3
- import fileDocumentOutline from '@iconify-icons/mdi/file-document-outline.js';
4
- import fileMusicOutline from '@iconify-icons/mdi/file-music-outline.js';
5
- import fileOutline from '@iconify-icons/mdi/file-outline.js';
6
- import fileTableOutline from '@iconify-icons/mdi/file-table-outline.js';
7
- import fileVideoOutline from '@iconify-icons/mdi/file-video-outline.js';
8
- import fileImageOutline from '@iconify-icons/mdi/file-image-outline.js';
9
- import microsoftExcel from '@iconify-icons/mdi/microsoft-excel.js';
10
- import microsoftWord from '@iconify-icons/mdi/microsoft-word.js';
11
- import noteTextOutline from '@iconify-icons/mdi/note-text-outline.js';
12
- const icons = {
13
- 'application/vnd.ms-excel': microsoftExcel,
14
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': microsoftExcel,
15
- 'application/vnd.oasis.opendocument.spreadsheet': microsoftExcel,
16
- 'text/csv': fileTableOutline,
17
- 'application/msword': microsoftWord,
18
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': microsoftWord,
19
- 'application/vnd.oasis.opendocument.text': microsoftWord,
20
- 'application/rtf': microsoftWord,
21
- 'application/pdf': fileDocumentOutline,
22
- 'application/json': fileCodeOutline,
23
- 'application/x-httpd-php': fileCodeOutline,
24
- 'application/x-sh': fileCodeOutline,
25
- 'application/xml': fileCodeOutline,
26
- 'text/css': fileCodeOutline,
27
- 'text/html': fileCodeOutline,
28
- 'text/javascript': fileCodeOutline,
29
- 'application/gzip': archiveOutline,
30
- 'application/java-archive': archiveOutline,
31
- 'application/zip': archiveOutline,
32
- 'application/vnd.apple.installer+xml': archiveOutline,
33
- 'application/vnd.rar': archiveOutline,
34
- 'application/x-7z-compressed': archiveOutline,
35
- 'application/x-bzip': archiveOutline,
36
- 'application/x-bzip2': archiveOutline,
37
- 'application/x-tar': archiveOutline
38
- };
39
- const prefixes = {
40
- image: fileImageOutline,
41
- text: noteTextOutline,
42
- video: fileVideoOutline,
43
- audio: fileMusicOutline
44
- };
45
- </script>
46
- <script >import Icon from './Icon.svelte';
1
+ <script>import Icon from './Icon.svelte';
2
+ import { iconForMime } from './fileIcons';
47
3
  export let mime;
48
4
  export let hiddenLabel = undefined;
49
5
  export let inline = false;
50
6
  export let width = '1em';
51
7
  export let height = width;
52
8
  export let vAlign = 'middle';
53
- $: icon = icons[mime] ?? prefixes[mime.split('/', 2)[0]] ?? fileOutline;
9
+ $: icon = iconForMime(mime);
54
10
  </script>
55
11
 
56
12
  <Icon {icon} {hiddenLabel} {inline} {width} {height} {vAlign} />
package/Form.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { Form, FormStore } from '@txstate-mws/svelte-forms';
1
+ <script>import { Form, FormStore } from '@txstate-mws/svelte-forms';
2
2
  import { setContext } from 'svelte';
3
3
  import { CHOOSER_API_CONTEXT } from './chooser';
4
4
  let className = '';
package/Icon.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import Icon from '@iconify/svelte/dist/OfflineIcon.svelte';
1
+ <script>import Icon from '@iconify/svelte/dist/OfflineIcon.svelte';
2
2
  import { ScreenReaderOnly } from '@txstate-mws/svelte-components';
3
3
  export let icon;
4
4
  export let hiddenLabel = undefined;
@@ -1,4 +1,4 @@
1
- <script >import alertCircleOutline from '@iconify-icons/mdi/alert-circle-outline.js';
1
+ <script>import alertCircleOutline from '@iconify-icons/mdi/alert-circle-outline.js';
2
2
  import checkCircleOutline from '@iconify-icons/mdi/check-circle-outline.js';
3
3
  import informationOutline from '@iconify-icons/mdi/information-outline.js';
4
4
  import closeOctagonOutline from '@iconify-icons/mdi/close-octagon-outline.js';
@@ -1,4 +1,4 @@
1
- <script >import { randomid } from 'txstate-utils';
1
+ <script>import { randomid } from 'txstate-utils';
2
2
  import InlineMessage from './InlineMessage.svelte';
3
3
  export let id = randomid();
4
4
  export let messages;
package/Input.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { dateSerialize, datetimeSerialize } from '@txstate-mws/svelte-forms';
1
+ <script>import { dateSerialize, datetimeSerialize } from '@txstate-mws/svelte-forms';
2
2
  let className = '';
3
3
  export { className as class };
4
4
  export let name;
package/Listbox.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { createEventDispatcher } from 'svelte';
1
+ <script>import { createEventDispatcher } from 'svelte';
2
2
  import { modifierKey } from '@txstate-mws/svelte-components';
3
3
  import check from '@iconify-icons/mdi/check.js';
4
4
  import Icon from './Icon.svelte';
package/Radio.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >export let id = undefined;
1
+ <script>export let id = undefined;
2
2
  export let name;
3
3
  export let value;
4
4
  export let selected = false;
package/Tab.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { getContext } from 'svelte';
1
+ <script>import { getContext } from 'svelte';
2
2
  import Icon from './Icon.svelte';
3
3
  import { TabStore, TAB_CONTEXT } from './TabStore';
4
4
  export let title;
package/TabStore.js CHANGED
@@ -2,6 +2,7 @@ import { Store, derivedStore } from '@txstate-mws/svelte-store';
2
2
  import { findIndex, randomid } from 'txstate-utils';
3
3
  export const TAB_CONTEXT = {};
4
4
  export class TabStore extends Store {
5
+ initialTab;
5
6
  constructor(tabs, initialTab) {
6
7
  super({
7
8
  tabs,
package/Tabs.svelte CHANGED
@@ -1,4 +1,4 @@
1
- <script >import { modifierKey, resize } from '@txstate-mws/svelte-components';
1
+ <script>import { modifierKey, resize } from '@txstate-mws/svelte-components';
2
2
  import { setContext } from 'svelte';
3
3
  import { roundTo } from 'txstate-utils';
4
4
  import Icon from './Icon.svelte';
@@ -1,4 +1,4 @@
1
- <script >import { modifierKey } from '@txstate-mws/svelte-components';
1
+ <script>import { modifierKey } from '@txstate-mws/svelte-components';
2
2
  import { createEventDispatcher, getContext } from 'svelte';
3
3
  import { hashid } from 'txstate-utils';
4
4
  import { CHOOSER_STORE_CONTEXT } from './ChooserStore';
@@ -1,4 +1,4 @@
1
- <script >import folderOutline from '@iconify-icons/mdi/folder-outline.js';
1
+ <script>import folderOutline from '@iconify-icons/mdi/folder-outline.js';
2
2
  import folderOpenOutline from '@iconify-icons/mdi/folder-open-outline.js';
3
3
  import folderSyncOutline from '@iconify-icons/mdi/folder-sync-outline.js';
4
4
  import { modifierKey } from '@txstate-mws/svelte-components';
@@ -1,4 +1,4 @@
1
- <script >import fileTree from '@iconify-icons/mdi/file-tree.js';
1
+ <script>import fileTree from '@iconify-icons/mdi/file-tree.js';
2
2
  import viewGrid from '@iconify-icons/mdi/view-grid.js';
3
3
  import { Loading, Modal } from '@txstate-mws/svelte-components';
4
4
  import { derivedStore } from '@txstate-mws/svelte-store';
@@ -13,6 +13,8 @@ export function bytesToHuman(bytes) {
13
13
  return String(parseFloat((bytes / Math.pow(1024, scale)).toPrecision(3))) + scales[scale];
14
14
  }
15
15
  export class ChooserStore extends SafeStore {
16
+ client;
17
+ options;
16
18
  constructor(client) {
17
19
  super({ activetype: 'page', activesource: 0 });
18
20
  this.client = client;
@@ -56,7 +58,7 @@ export class ChooserStore extends SafeStore {
56
58
  });
57
59
  }
58
60
  if (this.value.preview)
59
- await this.openPathRecursive(combinePath(this.value.preview.path, this.value.preview.name));
61
+ await this.openPathRecursive(this.value.preview.path);
60
62
  else if (this.options.initialPath)
61
63
  await this.openPathRecursive(this.options.initialPath);
62
64
  else
@@ -75,7 +77,7 @@ export class ChooserStore extends SafeStore {
75
77
  return item;
76
78
  }
77
79
  async open(folder) {
78
- return await this.openPath(combinePath(folder.path, folder.name));
80
+ return await this.openPath(folder.path);
79
81
  }
80
82
  async openPath(path) {
81
83
  const folder = this.itemByPath(this.value, path);
@@ -116,7 +118,7 @@ export class ChooserStore extends SafeStore {
116
118
  if (!current || current.type === 'asset')
117
119
  break;
118
120
  if (!current.open) {
119
- current.children = await filterAsync(await this.client.getChildren(source.name, combinePath(current.path, current.name), this.options.passthruFilters), this.options.filter);
121
+ current.children = await filterAsync(await this.client.getChildren(source.name, current.path, this.options.passthruFilters), this.options.filter);
120
122
  current.loading = false;
121
123
  current.open = true;
122
124
  }
@@ -130,12 +132,12 @@ export class ChooserStore extends SafeStore {
130
132
  if (!current)
131
133
  return v;
132
134
  v.focus = current.id;
133
- v.focusPath = combinePath(current.path, current.name);
135
+ v.focusPath = current.path;
134
136
  return v;
135
137
  });
136
138
  }
137
139
  async close(folder) {
138
- return await this.closePath(combinePath(folder.path, folder.name));
140
+ return await this.closePath(folder.path);
139
141
  }
140
142
  async closePath(path) {
141
143
  this.update(v => {
@@ -156,7 +158,7 @@ export class ChooserStore extends SafeStore {
156
158
  return this.clearPreview();
157
159
  if (item.type === 'folder' && !this.options.chooseFolder)
158
160
  return;
159
- this.update(v => ({ ...v, preview: item, focus: item.id, focusPath: combinePath(item.path, item.name) }));
161
+ this.update(v => ({ ...v, preview: item, focus: item.id, focusPath: item.path }));
160
162
  }
161
163
  clearPreview() {
162
164
  this.update(v => ({ ...v, preview: undefined }));
@@ -170,7 +172,7 @@ export class ChooserStore extends SafeStore {
170
172
  if (source.children?.length) {
171
173
  const firstchild = source.children[0];
172
174
  v.focus = firstchild.id;
173
- v.focusPath = combinePath(firstchild.path, firstchild.name);
175
+ v.focusPath = firstchild.path;
174
176
  }
175
177
  return v;
176
178
  });
@@ -180,7 +182,7 @@ export class ChooserStore extends SafeStore {
180
182
  const source = this.getSource(v);
181
183
  source.children = children;
182
184
  v.focus = children[0]?.id;
183
- v.focusPath = children[0] ? combinePath(children[0]?.path, children[0].name) : undefined;
185
+ v.focusPath = children[0] ? children[0]?.path : undefined;
184
186
  return v;
185
187
  });
186
188
  }
@@ -193,7 +195,7 @@ export class ChooserStore extends SafeStore {
193
195
  return;
194
196
  this.update(v => {
195
197
  v.focus = itm.id;
196
- v.focusPath = combinePath(itm.path, itm.name);
198
+ v.focusPath = itm.path;
197
199
  return v;
198
200
  });
199
201
  }
@@ -1,4 +1,4 @@
1
- <script >import { bytesToHuman, combinePath } from './ChooserStore';
1
+ <script>import { bytesToHuman } from './ChooserStore';
2
2
  export let item;
3
3
  </script>
4
4
 
@@ -11,7 +11,7 @@ export let item;
11
11
  {:else if item.type === 'page'}
12
12
  <li>{item.title}</li>
13
13
  {:else if item.type === 'folder'}
14
- <li>{combinePath(item.path, item.name)}</li>
14
+ <li>{item.path}</li>
15
15
  {/if}
16
16
  {#if item.type === 'asset'}
17
17
  <li>{item.mime}</li>
@@ -1,4 +1,4 @@
1
- <script >import fileOutline from '@iconify-icons/mdi/file-outline.js';
1
+ <script>import fileOutline from '@iconify-icons/mdi/file-outline.js';
2
2
  import fileSyncOutline from '@iconify-icons/mdi/file-sync-outline.js';
3
3
  import { modifierKey } from '@txstate-mws/svelte-components';
4
4
  import { createEventDispatcher, getContext } from 'svelte';
@@ -1,4 +1,4 @@
1
- <script >import folderOutline from '@iconify-icons/mdi/folder-outline.js';
1
+ <script>import folderOutline from '@iconify-icons/mdi/folder-outline.js';
2
2
  import fileLinkOutline from '@iconify-icons/mdi/file-link-outline.js';
3
3
  import FileIcon from '../FileIcon.svelte';
4
4
  import Icon from '../Icon.svelte';
package/fileIcons.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function iconForMime(mime: string): import("@iconify/types").IconifyIcon;
package/fileIcons.js ADDED
@@ -0,0 +1,47 @@
1
+ import archiveOutline from '@iconify-icons/mdi/archive-outline.js';
2
+ import fileCodeOutline from '@iconify-icons/mdi/file-code-outline.js';
3
+ import fileDocumentOutline from '@iconify-icons/mdi/file-document-outline.js';
4
+ import fileMusicOutline from '@iconify-icons/mdi/file-music-outline.js';
5
+ import fileOutline from '@iconify-icons/mdi/file-outline.js';
6
+ import fileTableOutline from '@iconify-icons/mdi/file-table-outline.js';
7
+ import fileVideoOutline from '@iconify-icons/mdi/file-video-outline.js';
8
+ import fileImageOutline from '@iconify-icons/mdi/file-image-outline.js';
9
+ import microsoftExcel from '@iconify-icons/mdi/microsoft-excel.js';
10
+ import microsoftWord from '@iconify-icons/mdi/microsoft-word.js';
11
+ import noteTextOutline from '@iconify-icons/mdi/note-text-outline.js';
12
+ const fileIconsByMime = {
13
+ 'application/vnd.ms-excel': microsoftExcel,
14
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': microsoftExcel,
15
+ 'application/vnd.oasis.opendocument.spreadsheet': microsoftExcel,
16
+ 'text/csv': fileTableOutline,
17
+ 'application/msword': microsoftWord,
18
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': microsoftWord,
19
+ 'application/vnd.oasis.opendocument.text': microsoftWord,
20
+ 'application/rtf': microsoftWord,
21
+ 'application/pdf': fileDocumentOutline,
22
+ 'application/json': fileCodeOutline,
23
+ 'application/x-httpd-php': fileCodeOutline,
24
+ 'application/x-sh': fileCodeOutline,
25
+ 'application/xml': fileCodeOutline,
26
+ 'text/css': fileCodeOutline,
27
+ 'text/html': fileCodeOutline,
28
+ 'text/javascript': fileCodeOutline,
29
+ 'application/gzip': archiveOutline,
30
+ 'application/java-archive': archiveOutline,
31
+ 'application/zip': archiveOutline,
32
+ 'application/vnd.apple.installer+xml': archiveOutline,
33
+ 'application/vnd.rar': archiveOutline,
34
+ 'application/x-7z-compressed': archiveOutline,
35
+ 'application/x-bzip': archiveOutline,
36
+ 'application/x-bzip2': archiveOutline,
37
+ 'application/x-tar': archiveOutline
38
+ };
39
+ const prefixes = {
40
+ image: fileImageOutline,
41
+ text: noteTextOutline,
42
+ video: fileVideoOutline,
43
+ audio: fileMusicOutline
44
+ };
45
+ export function iconForMime(mime) {
46
+ return fileIconsByMime[mime] ?? prefixes[mime.split('/', 2)[0]] ?? fileOutline;
47
+ }