@molecule/app-file-dropzone-svelte 1.1.0 → 1.1.2

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 CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-16T12:54:36.705Z
6
+ Generated: 2026-11-24T08:57:53.913Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-file-dropzone-svelte
@@ -89,7 +89,7 @@ const FileDropzone: LegacyComponentType
89
89
 
90
90
  Peer dependencies:
91
91
 
92
- - `@molecule/app-svelte` ^3.5.0
92
+ - `@molecule/app-svelte` ^3.13.0
93
93
  - `@molecule/app-ui` ^1.0.1
94
94
  - `@molecule/app-ui-svelte` ^1.1.0
95
95
  - `svelte` ^5.0.0
@@ -6,7 +6,7 @@
6
6
  string goes through `t()` so a locale switch re-renders it.
7
7
  -->
8
8
  <script lang="ts">
9
- import { useTranslation } from '@molecule/app-svelte'
9
+ import { contentNodes, useTranslation } from '@molecule/app-svelte'
10
10
  import { getClassMap } from '@molecule/app-ui'
11
11
 
12
12
  import type { FileDropzoneProps } from './types.js'
@@ -26,7 +26,7 @@
26
26
  const { t } = useTranslation()
27
27
 
28
28
  let dragging = $state(false)
29
- let inputEl: HTMLInputElement | undefined
29
+ let inputEl = $state<HTMLInputElement | undefined>()
30
30
 
31
31
  // Every `t(…)` runs inside a `$derived`: it reads the i18n version under the
32
32
  // hood, so this re-runs on a locale switch the way React's render-time `t`
@@ -105,6 +105,30 @@
105
105
  /** The drag-over style: the border thickens and the fill tints. */
106
106
  const draggingStyle =
107
107
  'border: 2px dashed var(--mol-color-primary, #3366ff); border-radius: 12px; min-height: 140px; background: color-mix(in srgb, var(--mol-color-primary, #3366ff) 6%, transparent)'
108
+
109
+ // React's `children ?? default copy`: a children snippet that renders nothing (an empty list)
110
+ // falls back to the default copy, like an omitted one. A snippet's `{#each}` over no rows
111
+ // changes the DOM without changing the prop, so presence is read from the rendered DOM (the
112
+ // input and the default copy are this component's own nodes, not the children).
113
+ let rootEl = $state<HTMLDivElement | null>(null)
114
+ let dropHereEl = $state<HTMLParagraphElement | null>(null)
115
+ let acceptsEl = $state<HTMLParagraphElement | null>(null)
116
+ let childrenRenders = $state(false)
117
+ $effect(() => {
118
+ const element = rootEl
119
+ if (!element) return
120
+ const own = new Set<Node | null>([inputEl ?? null, dropHereEl, acceptsEl])
121
+ const sync = (): void => {
122
+ const present = contentNodes(element).some(
123
+ (node) => !own.has(node) && (node.nodeType === 1 || (node.textContent ?? '').trim() !== ''),
124
+ )
125
+ if (present !== childrenRenders) childrenRenders = present
126
+ }
127
+ sync()
128
+ const observer = new MutationObserver(sync)
129
+ observer.observe(element, { childList: true, characterData: true, subtree: true })
130
+ return () => observer.disconnect()
131
+ })
108
132
  </script>
109
133
 
110
134
  <div
@@ -139,6 +163,7 @@
139
163
  role="button"
140
164
  tabindex="0"
141
165
  aria-disabled={disabled}
166
+ bind:this={rootEl}
142
167
  class={cm.cn(
143
168
  cm.flex({ direction: 'col', align: 'center', justify: 'center' }),
144
169
  cm.sp('p', 6),
@@ -161,11 +186,14 @@
161
186
  style="display: none"
162
187
  />
163
188
  {#if children}
164
- {@render children()}
165
- {:else}
166
- <p class={cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))}>{dropHere}</p>
189
+ {@render children?.()}
190
+ {/if}
191
+ {#if !childrenRenders}
192
+ <p bind:this={dropHereEl} class={cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))}>
193
+ {dropHere}
194
+ </p>
167
195
  {#if accept}
168
- <p class={cm.cn(cm.textSize('xs'), cm.sp('mt', 1))}>{acceptsLabel}</p>
196
+ <p bind:this={acceptsEl} class={cm.cn(cm.textSize('xs'), cm.sp('mt', 1))}>{acceptsLabel}</p>
169
197
  {/if}
170
198
  {/if}
171
199
  </div>
@@ -1 +1 @@
1
- {"version":3,"file":"FileDropzone.svelte.d.ts","sourceRoot":"","sources":["../src/FileDropzone.svelte"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAsJpD,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"FileDropzone.svelte.d.ts","sourceRoot":"","sources":["../src/FileDropzone.svelte"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAiLpD,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-file-dropzone-svelte",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Drag-drop file upload area with click-to-browse, accept/size filtering, and a content slot",
5
5
  "homepage": "https://www.molecule.dev/packages/app-file-dropzone-svelte",
6
6
  "type": "module",
@@ -48,7 +48,7 @@
48
48
  "access": "public"
49
49
  },
50
50
  "peerDependencies": {
51
- "@molecule/app-svelte": "^3.5.0",
51
+ "@molecule/app-svelte": "^3.13.0",
52
52
  "@molecule/app-ui": "^1.0.1",
53
53
  "@molecule/app-ui-svelte": "^1.1.0",
54
54
  "svelte": "^5.0.0"
@@ -57,13 +57,13 @@
57
57
  "@molecule/app-framework-conformance": "0.0.0",
58
58
  "@molecule/app-i18n": "1.2.2",
59
59
  "@molecule/app-icons": "1.0.4",
60
- "@molecule/app-svelte": "3.7.1",
61
- "@molecule/app-ui": "1.4.0",
62
- "@molecule/app-ui-svelte": "1.1.5",
60
+ "@molecule/app-svelte": "3.14.1",
61
+ "@molecule/app-ui": "1.5.0",
62
+ "@molecule/app-ui-svelte": "1.4.2",
63
63
  "@sveltejs/package": "3.0.2",
64
64
  "@sveltejs/vite-plugin-svelte": "7.1.2",
65
65
  "@types/node": "26.6.5",
66
- "jsdom": "30.1.3",
66
+ "jsdom": "31.0.1",
67
67
  "svelte": "5.57.2",
68
68
  "svelte-check": "4.7.7",
69
69
  "typescript": "6.0.3",