@molecule/app-file-card-svelte 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/FileCard.svelte +306 -0
- package/dist/FileCard.svelte.d.ts +5 -0
- package/dist/FileCard.svelte.d.ts.map +1 -0
- package/dist/FileIcon.svelte +60 -0
- package/dist/FileIcon.svelte.d.ts +5 -0
- package/dist/FileIcon.svelte.d.ts.map +1 -0
- package/dist/components.d.ts +9 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +8 -0
- package/dist/format.d.ts +80 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +87 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/style.d.ts +28 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +115 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/package.json +73 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @molecule/app-file-card-svelte
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Svelte file card primitives — icon, name, size, modified date, actions; grid + row layouts
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @molecule/app-file-card-svelte
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Part of the [Molecule](https://www.molecule.dev) package fleet. This page carries the manifest summary; the full generated documentation ships with the package's first committed version.
|
|
10
|
+
|
|
11
|
+
License: Apache-2.0
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
FileCard: the Svelte counterpart of `@molecule/app-file-card-react`'s
|
|
3
|
+
`FileCard` — file representation card (icon/thumbnail + name + size +
|
|
4
|
+
relative modified date + optional actions slot) in `'grid'` (square tile)
|
|
5
|
+
or `'row'` (horizontal line) layout. Same props, same DOM for the same
|
|
6
|
+
input.
|
|
7
|
+
|
|
8
|
+
Whitespace is deliberate: React's JSX strips whitespace-only text between
|
|
9
|
+
elements, so every element opens glued to the previous tag's close and no
|
|
10
|
+
stray whitespace text nodes render.
|
|
11
|
+
-->
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { useTranslation } from '@molecule/app-svelte'
|
|
14
|
+
import { getClassMap } from '@molecule/app-ui'
|
|
15
|
+
|
|
16
|
+
import FileIcon from './FileIcon.svelte'
|
|
17
|
+
import { relativeBucket, type SizeParts, sizeParts } from './format.js'
|
|
18
|
+
import { reactStyle } from './style.js'
|
|
19
|
+
import type { FileCardProps, FileKind } from './types.js'
|
|
20
|
+
|
|
21
|
+
/** The translation function shape we use here — matches `useTranslation().t`. */
|
|
22
|
+
type TFn = (
|
|
23
|
+
key: string,
|
|
24
|
+
values?: Record<string, string | number | boolean | Date>,
|
|
25
|
+
options?: { defaultValue?: string },
|
|
26
|
+
) => string
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the relative-time text for a file via `t()`. Keeps the template
|
|
30
|
+
* clean and centralizes the bucket → key mapping.
|
|
31
|
+
*
|
|
32
|
+
* @param at - Modified-at timestamp.
|
|
33
|
+
* @param t - The `useTranslation()` `t` function.
|
|
34
|
+
* @param now - Reference "now".
|
|
35
|
+
* @returns The localized relative-time string.
|
|
36
|
+
*/
|
|
37
|
+
function relativeText(at: string | number | Date, t: TFn, now: Date | undefined): string {
|
|
38
|
+
const bucket = relativeBucket(at, now)
|
|
39
|
+
switch (bucket.kind) {
|
|
40
|
+
case 'just-now':
|
|
41
|
+
return t('file-card.modified.just-now', {}, { defaultValue: 'just now' })
|
|
42
|
+
case 'minutes':
|
|
43
|
+
return t(
|
|
44
|
+
bucket.n === 1 ? 'file-card.modified.minute-one' : 'file-card.modified.minute-other',
|
|
45
|
+
{ count: bucket.n },
|
|
46
|
+
{ defaultValue: bucket.n === 1 ? '1 min ago' : `${bucket.n} min ago` },
|
|
47
|
+
)
|
|
48
|
+
case 'hours':
|
|
49
|
+
return t(
|
|
50
|
+
bucket.n === 1 ? 'file-card.modified.hour-one' : 'file-card.modified.hour-other',
|
|
51
|
+
{ count: bucket.n },
|
|
52
|
+
{ defaultValue: bucket.n === 1 ? '1 hr ago' : `${bucket.n} hr ago` },
|
|
53
|
+
)
|
|
54
|
+
case 'days':
|
|
55
|
+
return t(
|
|
56
|
+
bucket.n === 1 ? 'file-card.modified.day-one' : 'file-card.modified.day-other',
|
|
57
|
+
{ count: bucket.n },
|
|
58
|
+
{ defaultValue: bucket.n === 1 ? 'yesterday' : `${bucket.n} days ago` },
|
|
59
|
+
)
|
|
60
|
+
case 'weeks':
|
|
61
|
+
return t(
|
|
62
|
+
bucket.n === 1 ? 'file-card.modified.week-one' : 'file-card.modified.week-other',
|
|
63
|
+
{ count: bucket.n },
|
|
64
|
+
{ defaultValue: bucket.n === 1 ? '1 wk ago' : `${bucket.n} wk ago` },
|
|
65
|
+
)
|
|
66
|
+
case 'months':
|
|
67
|
+
return t(
|
|
68
|
+
bucket.n === 1 ? 'file-card.modified.month-one' : 'file-card.modified.month-other',
|
|
69
|
+
{ count: bucket.n },
|
|
70
|
+
{ defaultValue: bucket.n === 1 ? '1 mo ago' : `${bucket.n} mo ago` },
|
|
71
|
+
)
|
|
72
|
+
case 'absolute':
|
|
73
|
+
return bucket.iso
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Resolve the human-readable kind label via `t()`. One literal key per
|
|
79
|
+
* `FileKind` so the i18n gate can verify every key exists in the locale
|
|
80
|
+
* bond (a runtime-built `` `file-card.kind.${kind}` `` cannot be checked).
|
|
81
|
+
*
|
|
82
|
+
* @param kind - File kind.
|
|
83
|
+
* @param t - The `useTranslation()` `t` function.
|
|
84
|
+
* @returns The localized kind label.
|
|
85
|
+
*/
|
|
86
|
+
function kindText(kind: FileKind, t: TFn): string {
|
|
87
|
+
switch (kind) {
|
|
88
|
+
case 'image':
|
|
89
|
+
return t('file-card.kind.image', {}, { defaultValue: 'Image file' })
|
|
90
|
+
case 'video':
|
|
91
|
+
return t('file-card.kind.video', {}, { defaultValue: 'Video file' })
|
|
92
|
+
case 'audio':
|
|
93
|
+
return t('file-card.kind.audio', {}, { defaultValue: 'Audio file' })
|
|
94
|
+
case 'document':
|
|
95
|
+
return t('file-card.kind.document', {}, { defaultValue: 'Document' })
|
|
96
|
+
case 'archive':
|
|
97
|
+
return t('file-card.kind.archive', {}, { defaultValue: 'Archive' })
|
|
98
|
+
case 'code':
|
|
99
|
+
return t('file-card.kind.code', {}, { defaultValue: 'Code file' })
|
|
100
|
+
case 'folder':
|
|
101
|
+
return t('file-card.kind.folder', {}, { defaultValue: 'Folder' })
|
|
102
|
+
case 'other':
|
|
103
|
+
return t('file-card.kind.other', {}, { defaultValue: 'File' })
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Resolve the size's unit word via `t()`, with the number {@link sizeParts}
|
|
109
|
+
* already displayed: one literal key per `SizeUnit` — the same pattern as
|
|
110
|
+
* {@link kindText} — so the i18n gate can verify every key exists in the
|
|
111
|
+
* locale bond, and the `{{n}}` placeholder lets a translation move the number
|
|
112
|
+
* or rename the token (French octets, Russian КБ).
|
|
113
|
+
*
|
|
114
|
+
* @param size - The size's displayed number and unit (`sizeParts(file.size)`).
|
|
115
|
+
* @param t - The `useTranslation()` `t` function.
|
|
116
|
+
* @returns The localized size text.
|
|
117
|
+
*/
|
|
118
|
+
function sizeUnitText(size: SizeParts, t: TFn): string {
|
|
119
|
+
switch (size.unit) {
|
|
120
|
+
case 'B':
|
|
121
|
+
return t('file-card.size.b', { n: size.n }, { defaultValue: '{{n}} B' })
|
|
122
|
+
case 'KB':
|
|
123
|
+
return t('file-card.size.kb', { n: size.n }, { defaultValue: '{{n}} KB' })
|
|
124
|
+
case 'MB':
|
|
125
|
+
return t('file-card.size.mb', { n: size.n }, { defaultValue: '{{n}} MB' })
|
|
126
|
+
case 'GB':
|
|
127
|
+
return t('file-card.size.gb', { n: size.n }, { defaultValue: '{{n}} GB' })
|
|
128
|
+
case 'TB':
|
|
129
|
+
return t('file-card.size.tb', { n: size.n }, { defaultValue: '{{n}} TB' })
|
|
130
|
+
case 'PB':
|
|
131
|
+
return t('file-card.size.pb', { n: size.n }, { defaultValue: '{{n}} PB' })
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let {
|
|
136
|
+
file,
|
|
137
|
+
selected,
|
|
138
|
+
onClick,
|
|
139
|
+
onContextMenu,
|
|
140
|
+
layout = 'grid',
|
|
141
|
+
actions,
|
|
142
|
+
now,
|
|
143
|
+
className,
|
|
144
|
+
dataMolId,
|
|
145
|
+
}: FileCardProps = $props()
|
|
146
|
+
|
|
147
|
+
const { t } = useTranslation()
|
|
148
|
+
|
|
149
|
+
const cm = $derived(getClassMap())
|
|
150
|
+
const kindLabel = $derived(kindText(file.kind, t))
|
|
151
|
+
const size = $derived(file.kind === 'folder' ? undefined : sizeParts(file.size))
|
|
152
|
+
const sizeText = $derived(size ? sizeUnitText(size, t) : '')
|
|
153
|
+
const sizeLabel = $derived(
|
|
154
|
+
sizeText ? t('file-card.aria.size', { size: sizeText }, { defaultValue: 'Size {{size}}' }) : '',
|
|
155
|
+
)
|
|
156
|
+
const modifiedText = $derived(file.modifiedAt ? relativeText(file.modifiedAt, t, now) : '')
|
|
157
|
+
const modifiedLabel = $derived(
|
|
158
|
+
modifiedText
|
|
159
|
+
? t('file-card.aria.modified', { when: modifiedText }, { defaultValue: 'Modified {{when}}' })
|
|
160
|
+
: '',
|
|
161
|
+
)
|
|
162
|
+
const ariaLabel = $derived(
|
|
163
|
+
t(
|
|
164
|
+
'file-card.aria.root',
|
|
165
|
+
{ name: file.name, kind: kindLabel },
|
|
166
|
+
{
|
|
167
|
+
defaultValue: '{{name}}, {{kind}}',
|
|
168
|
+
},
|
|
169
|
+
),
|
|
170
|
+
)
|
|
171
|
+
const rootMolId = $derived(dataMolId ?? `file-card-${file.id}`)
|
|
172
|
+
const isRow = $derived(layout === 'row')
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Forward a body activation (a click on the select button, or Enter / Space
|
|
176
|
+
* on it) to the consumer.
|
|
177
|
+
*
|
|
178
|
+
* @param event - DOM mouse event.
|
|
179
|
+
*/
|
|
180
|
+
function handleClick(event: MouseEvent): void {
|
|
181
|
+
onClick?.(file, event)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Forward right-click to the consumer.
|
|
186
|
+
*
|
|
187
|
+
* @param event - DOM mouse event.
|
|
188
|
+
*/
|
|
189
|
+
function handleContextMenu(event: MouseEvent): void {
|
|
190
|
+
if (onContextMenu) onContextMenu(file, event)
|
|
191
|
+
}
|
|
192
|
+
</script>
|
|
193
|
+
|
|
194
|
+
{#if isRow}<div
|
|
195
|
+
role="group"
|
|
196
|
+
aria-label={ariaLabel}
|
|
197
|
+
data-mol-id={rootMolId}
|
|
198
|
+
data-selected={selected ? 'true' : undefined}
|
|
199
|
+
class={cm.cn(
|
|
200
|
+
cm.flex({ align: 'center', gap: 'md' }),
|
|
201
|
+
cm.sp('p', 2),
|
|
202
|
+
onClick ? cm.position('relative') : undefined,
|
|
203
|
+
className,
|
|
204
|
+
)}
|
|
205
|
+
oncontextmenu={handleContextMenu}
|
|
206
|
+
>
|
|
207
|
+
<div class={cm.cn(cm.shrink0)} data-mol-id="file-card-icon">
|
|
208
|
+
{#if file.thumbnail}<img
|
|
209
|
+
src={file.thumbnail}
|
|
210
|
+
alt=""
|
|
211
|
+
use:reactStyle={{ width: 40, height: 40, objectFit: 'cover', borderRadius: 4 }}
|
|
212
|
+
/>{:else}<FileIcon kind={file.kind} size={28} />{/if}
|
|
213
|
+
</div>
|
|
214
|
+
<div class={cm.cn(cm.stack(0))} use:reactStyle={{ flex: 1, minWidth: 0 }}>
|
|
215
|
+
<div
|
|
216
|
+
class={cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))}
|
|
217
|
+
data-mol-id="file-card-name"
|
|
218
|
+
use:reactStyle={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
|
219
|
+
>
|
|
220
|
+
{file.name}
|
|
221
|
+
</div>
|
|
222
|
+
{#if sizeText || modifiedText}<div
|
|
223
|
+
class={cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.textSize('xs'))}
|
|
224
|
+
data-mol-id="file-card-meta"
|
|
225
|
+
>
|
|
226
|
+
{#if sizeText}<span aria-label={sizeLabel} data-mol-id="file-card-size">{sizeText}</span
|
|
227
|
+
>{/if}{#if sizeText && modifiedText}<span aria-hidden="true">·</span
|
|
228
|
+
>{/if}{#if modifiedText}<span
|
|
229
|
+
aria-label={modifiedLabel}
|
|
230
|
+
data-mol-id="file-card-modified">{modifiedText}</span
|
|
231
|
+
>{/if}
|
|
232
|
+
</div>{/if}
|
|
233
|
+
</div>
|
|
234
|
+
{#if onClick}<button
|
|
235
|
+
type="button"
|
|
236
|
+
aria-label={ariaLabel}
|
|
237
|
+
aria-pressed={selected ? 'true' : 'false'}
|
|
238
|
+
data-mol-id="file-card-select"
|
|
239
|
+
onclick={handleClick}
|
|
240
|
+
class={cm.cn(cm.position('absolute'), cm.inset0, cm.cursorPointer)}
|
|
241
|
+
use:reactStyle={{ background: 'transparent', border: 'none', padding: 0 }}
|
|
242
|
+
></button>{/if}{#if actions}<div
|
|
243
|
+
class={cm.cn(cm.shrink0, cm.position('relative'))}
|
|
244
|
+
data-mol-id="file-card-actions"
|
|
245
|
+
>
|
|
246
|
+
{@render actions()}
|
|
247
|
+
</div>{/if}
|
|
248
|
+
</div>{:else}<div
|
|
249
|
+
role="group"
|
|
250
|
+
aria-label={ariaLabel}
|
|
251
|
+
data-mol-id={rootMolId}
|
|
252
|
+
data-selected={selected ? 'true' : undefined}
|
|
253
|
+
class={cm.cn(
|
|
254
|
+
cm.stack(1),
|
|
255
|
+
cm.sp('p', 3),
|
|
256
|
+
onClick ? cm.position('relative') : undefined,
|
|
257
|
+
className,
|
|
258
|
+
)}
|
|
259
|
+
oncontextmenu={handleContextMenu}
|
|
260
|
+
>
|
|
261
|
+
<div
|
|
262
|
+
class={cm.cn(cm.flex({ align: 'center', justify: 'center' }))}
|
|
263
|
+
data-mol-id="file-card-icon"
|
|
264
|
+
use:reactStyle={{ aspectRatio: '1 / 1', width: '100%' }}
|
|
265
|
+
>
|
|
266
|
+
{#if file.thumbnail}<img
|
|
267
|
+
src={file.thumbnail}
|
|
268
|
+
alt=""
|
|
269
|
+
use:reactStyle={{ width: '100%', height: '100%', objectFit: 'cover', borderRadius: 4 }}
|
|
270
|
+
/>{:else}<FileIcon kind={file.kind} size={48} />{/if}
|
|
271
|
+
</div>
|
|
272
|
+
<div
|
|
273
|
+
class={cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))}
|
|
274
|
+
data-mol-id="file-card-name"
|
|
275
|
+
use:reactStyle={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
|
276
|
+
>
|
|
277
|
+
{file.name}
|
|
278
|
+
</div>
|
|
279
|
+
{#if sizeText || modifiedText}<div
|
|
280
|
+
class={cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.textSize('xs'))}
|
|
281
|
+
data-mol-id="file-card-meta"
|
|
282
|
+
>
|
|
283
|
+
{#if sizeText}<span aria-label={sizeLabel} data-mol-id="file-card-size">{sizeText}</span
|
|
284
|
+
>{/if}{#if sizeText && modifiedText}<span aria-hidden="true">·</span
|
|
285
|
+
>{/if}{#if modifiedText}<span aria-label={modifiedLabel} data-mol-id="file-card-modified"
|
|
286
|
+
>{modifiedText}</span
|
|
287
|
+
>{/if}
|
|
288
|
+
</div>{/if}
|
|
289
|
+
{#if onClick}<button
|
|
290
|
+
type="button"
|
|
291
|
+
aria-label={ariaLabel}
|
|
292
|
+
aria-pressed={selected ? 'true' : 'false'}
|
|
293
|
+
data-mol-id="file-card-select"
|
|
294
|
+
onclick={handleClick}
|
|
295
|
+
class={cm.cn(cm.position('absolute'), cm.inset0, cm.cursorPointer)}
|
|
296
|
+
use:reactStyle={{ background: 'transparent', border: 'none', padding: 0 }}
|
|
297
|
+
></button>{/if}{#if actions}<div
|
|
298
|
+
class={cm.cn(
|
|
299
|
+
cm.flex({ align: 'center', justify: 'end', gap: 'sm' }),
|
|
300
|
+
cm.position('relative'),
|
|
301
|
+
)}
|
|
302
|
+
data-mol-id="file-card-actions"
|
|
303
|
+
>
|
|
304
|
+
{@render actions()}
|
|
305
|
+
</div>{/if}
|
|
306
|
+
</div>{/if}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCard.svelte.d.ts","sourceRoot":"","sources":["../src/FileCard.svelte"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,YAAY,CAAC;AAsO1D,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
FileIcon: the Svelte counterpart of `@molecule/app-file-card-react`'s
|
|
3
|
+
`FileIcon` — a stroke-currentColor SVG glyph keyed by `FileKind`. Same
|
|
4
|
+
props, same DOM for the same input.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import type { FileIconProps } from './types.js'
|
|
8
|
+
|
|
9
|
+
let { kind, size = 24, ariaLabel }: FileIconProps = $props()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<svg
|
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
+
width={size}
|
|
15
|
+
height={size}
|
|
16
|
+
viewBox="0 0 24 24"
|
|
17
|
+
fill="none"
|
|
18
|
+
stroke="currentColor"
|
|
19
|
+
stroke-width="1.75"
|
|
20
|
+
stroke-linecap="round"
|
|
21
|
+
stroke-linejoin="round"
|
|
22
|
+
role={ariaLabel ? 'img' : undefined}
|
|
23
|
+
aria-label={ariaLabel}
|
|
24
|
+
aria-hidden={ariaLabel ? undefined : true}
|
|
25
|
+
data-mol-id="file-icon-{kind}"
|
|
26
|
+
>
|
|
27
|
+
{#if kind === 'image'}<rect x="3" y="5" width="18" height="14" rx="2" /><circle
|
|
28
|
+
cx="8.5"
|
|
29
|
+
cy="10.5"
|
|
30
|
+
r="1.5"
|
|
31
|
+
/><path d="m21 15-5-5L5 21" />{:else if kind === 'video'}<rect
|
|
32
|
+
x="3"
|
|
33
|
+
y="5"
|
|
34
|
+
width="18"
|
|
35
|
+
height="14"
|
|
36
|
+
rx="2"
|
|
37
|
+
/><path d="m10 9 5 3-5 3z" fill="currentColor" />{:else if kind === 'audio'}<path
|
|
38
|
+
d="M9 18V5l12-2v13"
|
|
39
|
+
/><circle cx="6" cy="18" r="3" /><circle
|
|
40
|
+
cx="18"
|
|
41
|
+
cy="16"
|
|
42
|
+
r="3"
|
|
43
|
+
/>{:else if kind === 'document'}<path
|
|
44
|
+
d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"
|
|
45
|
+
/><path d="M14 3v6h6" />{:else if kind === 'archive'}<rect
|
|
46
|
+
x="3"
|
|
47
|
+
y="3"
|
|
48
|
+
width="18"
|
|
49
|
+
height="6"
|
|
50
|
+
rx="1"
|
|
51
|
+
/><path d="M3 9v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9" /><path
|
|
52
|
+
d="M10 13h4"
|
|
53
|
+
/>{:else if kind === 'code'}<path d="m9 8-5 4 5 4" /><path d="m15 8 5 4-5 4" /><path
|
|
54
|
+
d="m13 5-2 14"
|
|
55
|
+
/>{:else if kind === 'folder'}<path
|
|
56
|
+
d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"
|
|
57
|
+
/>{:else}<path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z" /><path
|
|
58
|
+
d="M14 3v6h6"
|
|
59
|
+
/><path d="M9 14h6" /><path d="M9 17h4" />{/if}
|
|
60
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileIcon.svelte.d.ts","sourceRoot":"","sources":["../src/FileIcon.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAehD,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package's components: one Svelte 5 component per React component in
|
|
3
|
+
* `@molecule/app-file-card-react`, under the same React name.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { default as FileCard } from './FileCard.svelte';
|
|
8
|
+
export { default as FileIcon } from './FileIcon.svelte';
|
|
9
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package's components: one Svelte 5 component per React component in
|
|
3
|
+
* `@molecule/app-file-card-react`, under the same React name.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { default as FileCard } from './FileCard.svelte';
|
|
8
|
+
export { default as FileIcon } from './FileIcon.svelte';
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format helpers for the file card. Pure functions — UI-agnostic so they can
|
|
3
|
+
* be unit-tested directly.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/** The unit token a formatted byte count ends in (`B` plus the binary steps). */
|
|
8
|
+
export type SizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB';
|
|
9
|
+
/** A formatted size's displayed number and its unit token, split for `t()`. */
|
|
10
|
+
export interface SizeParts {
|
|
11
|
+
/** The displayed number, rounded the way {@link bytes} displays it. */
|
|
12
|
+
n: string;
|
|
13
|
+
/** The unit token the number counts. */
|
|
14
|
+
unit: SizeUnit;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Split a non-negative byte count into its displayed number and unit token
|
|
18
|
+
* (e.g. `420` + `B`, `1.4` + `KB`, `471` + `MB`) — the two halves
|
|
19
|
+
* {@link bytes} joins, exposed so the card can translate the unit word via
|
|
20
|
+
* `t()` (one literal key per {@link SizeUnit}, as the kind labels do).
|
|
21
|
+
*
|
|
22
|
+
* Uses a 1024 base (binary) and 1 fractional digit for KB+. Returns the
|
|
23
|
+
* `0 B` parts for non-finite or negative inputs so callers do not need to
|
|
24
|
+
* pre-validate.
|
|
25
|
+
*
|
|
26
|
+
* @param value - Byte count (>= 0).
|
|
27
|
+
* @returns The displayed number and unit token.
|
|
28
|
+
*/
|
|
29
|
+
export declare function sizeParts(value: number): SizeParts;
|
|
30
|
+
/**
|
|
31
|
+
* Format a non-negative byte count as a short human-readable string
|
|
32
|
+
* (e.g. `420 B`, `1.4 KB`, `2.3 MB`, `4.7 GB`, `8.1 TB`).
|
|
33
|
+
*
|
|
34
|
+
* The unlocalized join of {@link sizeParts}'s two halves, for callers that
|
|
35
|
+
* want the raw SI shorthand. The card itself renders the unit through `t()`
|
|
36
|
+
* (`file-card.size.<unit>` keys in the locale bond) so a locale switch
|
|
37
|
+
* translates it; the unit token is universal SI shorthand — a language that
|
|
38
|
+
* names bytes differently (French octets, Russian КБ) changes only the token,
|
|
39
|
+
* never the magnitude.
|
|
40
|
+
*
|
|
41
|
+
* @param value - Byte count (>= 0).
|
|
42
|
+
* @returns Formatted size string.
|
|
43
|
+
*/
|
|
44
|
+
export declare function bytes(value: number): string;
|
|
45
|
+
/**
|
|
46
|
+
* A relative-time bucket used to pick a translation key. Higher granularity
|
|
47
|
+
* buckets first; falls through to absolute date when older than ~1 year.
|
|
48
|
+
*/
|
|
49
|
+
export type RelativeBucket = {
|
|
50
|
+
kind: 'just-now';
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'minutes';
|
|
53
|
+
n: number;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'hours';
|
|
56
|
+
n: number;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'days';
|
|
59
|
+
n: number;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'weeks';
|
|
62
|
+
n: number;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'months';
|
|
65
|
+
n: number;
|
|
66
|
+
} | {
|
|
67
|
+
kind: 'absolute';
|
|
68
|
+
iso: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Bucket a `Date` (or ISO string / ms timestamp) against `now` into a
|
|
72
|
+
* relative-time bucket. The bucket is purely structural — translation keys
|
|
73
|
+
* and pluralization are applied by the consumer.
|
|
74
|
+
*
|
|
75
|
+
* @param at - Modified-at timestamp (ISO string, ms epoch, or `Date`).
|
|
76
|
+
* @param now - Reference "now" (defaults to `new Date()`). Injected for tests.
|
|
77
|
+
* @returns A `RelativeBucket` describing the offset from `now`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function relativeBucket(at: string | number | Date, now?: Date): RelativeBucket;
|
|
80
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iFAAiF;AACjF,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE7D,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,CAAC,EAAE,MAAM,CAAA;IACT,wCAAwC;IACxC,IAAI,EAAE,QAAQ,CAAA;CACf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAalD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAErC;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,cAAc,CAiBjG"}
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format helpers for the file card. Pure functions — UI-agnostic so they can
|
|
3
|
+
* be unit-tested directly.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Split a non-negative byte count into its displayed number and unit token
|
|
9
|
+
* (e.g. `420` + `B`, `1.4` + `KB`, `471` + `MB`) — the two halves
|
|
10
|
+
* {@link bytes} joins, exposed so the card can translate the unit word via
|
|
11
|
+
* `t()` (one literal key per {@link SizeUnit}, as the kind labels do).
|
|
12
|
+
*
|
|
13
|
+
* Uses a 1024 base (binary) and 1 fractional digit for KB+. Returns the
|
|
14
|
+
* `0 B` parts for non-finite or negative inputs so callers do not need to
|
|
15
|
+
* pre-validate.
|
|
16
|
+
*
|
|
17
|
+
* @param value - Byte count (>= 0).
|
|
18
|
+
* @returns The displayed number and unit token.
|
|
19
|
+
*/
|
|
20
|
+
export function sizeParts(value) {
|
|
21
|
+
if (!Number.isFinite(value) || value < 0)
|
|
22
|
+
return { n: '0', unit: 'B' };
|
|
23
|
+
if (value < 1024)
|
|
24
|
+
return { n: String(Math.round(value)), unit: 'B' };
|
|
25
|
+
const units = ['KB', 'MB', 'GB', 'TB', 'PB'];
|
|
26
|
+
let n = value / 1024;
|
|
27
|
+
let unitIndex = 0;
|
|
28
|
+
while (n >= 1024 && unitIndex < units.length - 1) {
|
|
29
|
+
n /= 1024;
|
|
30
|
+
unitIndex += 1;
|
|
31
|
+
}
|
|
32
|
+
// 1 decimal place when < 100, else round
|
|
33
|
+
const display = n >= 100 ? Math.round(n).toString() : n.toFixed(1).replace(/\.0$/, '');
|
|
34
|
+
return { n: display, unit: units[unitIndex] };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Format a non-negative byte count as a short human-readable string
|
|
38
|
+
* (e.g. `420 B`, `1.4 KB`, `2.3 MB`, `4.7 GB`, `8.1 TB`).
|
|
39
|
+
*
|
|
40
|
+
* The unlocalized join of {@link sizeParts}'s two halves, for callers that
|
|
41
|
+
* want the raw SI shorthand. The card itself renders the unit through `t()`
|
|
42
|
+
* (`file-card.size.<unit>` keys in the locale bond) so a locale switch
|
|
43
|
+
* translates it; the unit token is universal SI shorthand — a language that
|
|
44
|
+
* names bytes differently (French octets, Russian КБ) changes only the token,
|
|
45
|
+
* never the magnitude.
|
|
46
|
+
*
|
|
47
|
+
* @param value - Byte count (>= 0).
|
|
48
|
+
* @returns Formatted size string.
|
|
49
|
+
*/
|
|
50
|
+
export function bytes(value) {
|
|
51
|
+
const { n, unit } = sizeParts(value);
|
|
52
|
+
return `${n} ${unit}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Bucket a `Date` (or ISO string / ms timestamp) against `now` into a
|
|
56
|
+
* relative-time bucket. The bucket is purely structural — translation keys
|
|
57
|
+
* and pluralization are applied by the consumer.
|
|
58
|
+
*
|
|
59
|
+
* @param at - Modified-at timestamp (ISO string, ms epoch, or `Date`).
|
|
60
|
+
* @param now - Reference "now" (defaults to `new Date()`). Injected for tests.
|
|
61
|
+
* @returns A `RelativeBucket` describing the offset from `now`.
|
|
62
|
+
*/
|
|
63
|
+
export function relativeBucket(at, now = new Date()) {
|
|
64
|
+
const then = at instanceof Date ? at : new Date(at);
|
|
65
|
+
const ms = now.getTime() - then.getTime();
|
|
66
|
+
if (!Number.isFinite(ms))
|
|
67
|
+
return { kind: 'absolute', iso: String(at) };
|
|
68
|
+
if (ms < 60_000)
|
|
69
|
+
return { kind: 'just-now' };
|
|
70
|
+
const minute = 60_000;
|
|
71
|
+
const hour = 60 * minute;
|
|
72
|
+
const day = 24 * hour;
|
|
73
|
+
const week = 7 * day;
|
|
74
|
+
const month = 30 * day;
|
|
75
|
+
const year = 365 * day;
|
|
76
|
+
if (ms < hour)
|
|
77
|
+
return { kind: 'minutes', n: Math.floor(ms / minute) };
|
|
78
|
+
if (ms < day)
|
|
79
|
+
return { kind: 'hours', n: Math.floor(ms / hour) };
|
|
80
|
+
if (ms < week)
|
|
81
|
+
return { kind: 'days', n: Math.floor(ms / day) };
|
|
82
|
+
if (ms < month)
|
|
83
|
+
return { kind: 'weeks', n: Math.floor(ms / week) };
|
|
84
|
+
if (ms < year)
|
|
85
|
+
return { kind: 'months', n: Math.floor(ms / month) };
|
|
86
|
+
return { kind: 'absolute', iso: then.toISOString().slice(0, 10) };
|
|
87
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte file card primitives.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - `<FileCard>` — file representation card (icon/thumbnail + name + size + modified date + optional actions).
|
|
6
|
+
* Two layouts: `'grid'` (square tile, default) and `'row'` (horizontal list line).
|
|
7
|
+
* - `<FileIcon>` — stroke-currentColor SVG glyph keyed by `FileKind`.
|
|
8
|
+
* - `bytes(value)` — pure helper that formats a byte count as `420 B` / `1.4 KB` / `2.3 MB` / etc.
|
|
9
|
+
* - `sizeParts(value)` — the same split as `{ n, unit }`, for rendering the unit through `t()`.
|
|
10
|
+
* - `relativeBucket(at, now?)` — pure helper that buckets a timestamp into `just-now` / `minutes` /
|
|
11
|
+
* `hours` / `days` / `weeks` / `months` / `absolute`.
|
|
12
|
+
* - `FileSummary` / `FileKind` / `SizeParts` types — stable shape for the consumer's domain model.
|
|
13
|
+
*
|
|
14
|
+
* Used by cloud-file-manager (grid + list views), social-media + email-client
|
|
15
|
+
* (attachment previews), and document-collaboration (sidebars).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```svelte
|
|
19
|
+
* <script lang="ts">
|
|
20
|
+
* import { FileCard, type FileSummary } from '@molecule/app-file-card-svelte'
|
|
21
|
+
*
|
|
22
|
+
* const file: FileSummary = {
|
|
23
|
+
* id: 'f-1',
|
|
24
|
+
* name: 'Q3-report.pdf',
|
|
25
|
+
* size: 482_137,
|
|
26
|
+
* kind: 'document',
|
|
27
|
+
* modifiedAt: '2026-04-30T18:23:00Z',
|
|
28
|
+
* }
|
|
29
|
+
* </script>
|
|
30
|
+
*
|
|
31
|
+
* <FileCard {file} layout="grid" onClick={(f) => openFile(f.id)}>
|
|
32
|
+
* {#snippet actions()}
|
|
33
|
+
* <KebabMenu fileId={file.id} />
|
|
34
|
+
* {/snippet}
|
|
35
|
+
* </FileCard>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* All styling routes through `getClassMap()` from `@molecule/app-ui` —
|
|
40
|
+
* swap the ClassMap bond to restyle without touching this package.
|
|
41
|
+
*
|
|
42
|
+
* All user-visible text routes through `t()` (via `@molecule/app-svelte`'s
|
|
43
|
+
* `useTranslation`) and translates via the companion
|
|
44
|
+
* `@molecule/app-locales-file-card` locale bond. English fallbacks are
|
|
45
|
+
* inlined so the card works without the locale bond present.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
export * from './components.js';
|
|
50
|
+
export * from './format.js';
|
|
51
|
+
export * from './types.js';
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte file card primitives.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - `<FileCard>` — file representation card (icon/thumbnail + name + size + modified date + optional actions).
|
|
6
|
+
* Two layouts: `'grid'` (square tile, default) and `'row'` (horizontal list line).
|
|
7
|
+
* - `<FileIcon>` — stroke-currentColor SVG glyph keyed by `FileKind`.
|
|
8
|
+
* - `bytes(value)` — pure helper that formats a byte count as `420 B` / `1.4 KB` / `2.3 MB` / etc.
|
|
9
|
+
* - `sizeParts(value)` — the same split as `{ n, unit }`, for rendering the unit through `t()`.
|
|
10
|
+
* - `relativeBucket(at, now?)` — pure helper that buckets a timestamp into `just-now` / `minutes` /
|
|
11
|
+
* `hours` / `days` / `weeks` / `months` / `absolute`.
|
|
12
|
+
* - `FileSummary` / `FileKind` / `SizeParts` types — stable shape for the consumer's domain model.
|
|
13
|
+
*
|
|
14
|
+
* Used by cloud-file-manager (grid + list views), social-media + email-client
|
|
15
|
+
* (attachment previews), and document-collaboration (sidebars).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```svelte
|
|
19
|
+
* <script lang="ts">
|
|
20
|
+
* import { FileCard, type FileSummary } from '@molecule/app-file-card-svelte'
|
|
21
|
+
*
|
|
22
|
+
* const file: FileSummary = {
|
|
23
|
+
* id: 'f-1',
|
|
24
|
+
* name: 'Q3-report.pdf',
|
|
25
|
+
* size: 482_137,
|
|
26
|
+
* kind: 'document',
|
|
27
|
+
* modifiedAt: '2026-04-30T18:23:00Z',
|
|
28
|
+
* }
|
|
29
|
+
* </script>
|
|
30
|
+
*
|
|
31
|
+
* <FileCard {file} layout="grid" onClick={(f) => openFile(f.id)}>
|
|
32
|
+
* {#snippet actions()}
|
|
33
|
+
* <KebabMenu fileId={file.id} />
|
|
34
|
+
* {/snippet}
|
|
35
|
+
* </FileCard>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* All styling routes through `getClassMap()` from `@molecule/app-ui` —
|
|
40
|
+
* swap the ClassMap bond to restyle without touching this package.
|
|
41
|
+
*
|
|
42
|
+
* All user-visible text routes through `t()` (via `@molecule/app-svelte`'s
|
|
43
|
+
* `useTranslation`) and translates via the companion
|
|
44
|
+
* `@molecule/app-locales-file-card` locale bond. English fallbacks are
|
|
45
|
+
* inlined so the card works without the locale bond present.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
export * from './components.js';
|
|
50
|
+
export * from './format.js';
|
|
51
|
+
export * from './types.js';
|
package/dist/style.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline styles shared by this package's components: a Svelte action that
|
|
3
|
+
* applies a React-shaped style object the way react-dom does, so both
|
|
4
|
+
* frameworks leave the same declarations on the element.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A React-shaped inline style object (camelCase properties, numbers allowed).
|
|
10
|
+
*/
|
|
11
|
+
export type CSSStyle = Record<string, string | number | undefined | null | false>;
|
|
12
|
+
/**
|
|
13
|
+
* Svelte action applying a React-shaped style object to an element the way
|
|
14
|
+
* React applies it: every entry is assigned through the CSSOM property setter
|
|
15
|
+
* (in object order, numbers gaining `px` unless unitless, falsy entries
|
|
16
|
+
* cleared), and keys removed by a re-render are cleared too. React never
|
|
17
|
+
* writes a literal `style` string, so shorthand/longhand pairs
|
|
18
|
+
* (`borderColor` + `borderTopColor`) merge in the CSSOM exactly as React's
|
|
19
|
+
* serialized attribute does.
|
|
20
|
+
*
|
|
21
|
+
* @param node - The element to style.
|
|
22
|
+
* @param style - The React-shaped style object (may be undefined).
|
|
23
|
+
* @returns The action with an update that re-applies on prop changes.
|
|
24
|
+
*/
|
|
25
|
+
export declare function reactStyle(node: HTMLElement, style: CSSStyle | undefined): {
|
|
26
|
+
update: (next: CSSStyle | undefined) => void;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC,CAAA;AA2EjF;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,QAAQ,GAAG,SAAS,GAC1B;IAAE,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAA;CAAE,CAqBlD"}
|
package/dist/style.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline styles shared by this package's components: a Svelte action that
|
|
3
|
+
* applies a React-shaped style object the way react-dom does, so both
|
|
4
|
+
* frameworks leave the same declarations on the element.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Properties whose numeric values take no unit (React's `isUnitlessNumber`).
|
|
10
|
+
*/
|
|
11
|
+
const UNITLESS = new Set([
|
|
12
|
+
'animationIterationCount',
|
|
13
|
+
'aspectRatio',
|
|
14
|
+
'borderImageOutset',
|
|
15
|
+
'borderImageSlice',
|
|
16
|
+
'borderImageWidth',
|
|
17
|
+
'boxFlex',
|
|
18
|
+
'boxFlexGroup',
|
|
19
|
+
'boxOrdinalGroup',
|
|
20
|
+
'columnCount',
|
|
21
|
+
'columns',
|
|
22
|
+
'flex',
|
|
23
|
+
'flexGrow',
|
|
24
|
+
'flexPositive',
|
|
25
|
+
'flexShrink',
|
|
26
|
+
'flexNegative',
|
|
27
|
+
'flexOrder',
|
|
28
|
+
'gridArea',
|
|
29
|
+
'gridRow',
|
|
30
|
+
'gridRowEnd',
|
|
31
|
+
'gridRowStart',
|
|
32
|
+
'gridColumn',
|
|
33
|
+
'gridColumnEnd',
|
|
34
|
+
'gridColumnStart',
|
|
35
|
+
'fontWeight',
|
|
36
|
+
'lineClamp',
|
|
37
|
+
'lineHeight',
|
|
38
|
+
'opacity',
|
|
39
|
+
'order',
|
|
40
|
+
'orphans',
|
|
41
|
+
'scale',
|
|
42
|
+
'tabSize',
|
|
43
|
+
'widows',
|
|
44
|
+
'zIndex',
|
|
45
|
+
'zoom',
|
|
46
|
+
'fillOpacity',
|
|
47
|
+
'floodOpacity',
|
|
48
|
+
'stopOpacity',
|
|
49
|
+
'strokeDasharray',
|
|
50
|
+
'strokeDashoffset',
|
|
51
|
+
'strokeOpacity',
|
|
52
|
+
'strokeWidth',
|
|
53
|
+
]);
|
|
54
|
+
/**
|
|
55
|
+
* Turns a camelCase CSS property name into its kebab-case DOM spelling.
|
|
56
|
+
*
|
|
57
|
+
* @param name - The camelCase property (`marginTop`, `zIndex`).
|
|
58
|
+
* @returns The kebab-case property (`margin-top`, `z-index`).
|
|
59
|
+
*/
|
|
60
|
+
const kebab = (name) => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
61
|
+
/**
|
|
62
|
+
* React's `dangerousStyleValue`: null/undefined/boolean/empty values clear the
|
|
63
|
+
* property, numbers other than 0 take `px` unless the property is unitless,
|
|
64
|
+
* and strings are trimmed.
|
|
65
|
+
*
|
|
66
|
+
* @param name - The camelCase property name.
|
|
67
|
+
* @param value - The style value.
|
|
68
|
+
* @returns The string React would assign, or `''` to clear.
|
|
69
|
+
*/
|
|
70
|
+
const reactStyleValue = (name, value) => {
|
|
71
|
+
if (value === undefined || value === null || value === false || value === '')
|
|
72
|
+
return '';
|
|
73
|
+
if (typeof value === 'number' && value !== 0 && !UNITLESS.has(name))
|
|
74
|
+
return `${value}px`;
|
|
75
|
+
return String(value).trim();
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Svelte action applying a React-shaped style object to an element the way
|
|
79
|
+
* React applies it: every entry is assigned through the CSSOM property setter
|
|
80
|
+
* (in object order, numbers gaining `px` unless unitless, falsy entries
|
|
81
|
+
* cleared), and keys removed by a re-render are cleared too. React never
|
|
82
|
+
* writes a literal `style` string, so shorthand/longhand pairs
|
|
83
|
+
* (`borderColor` + `borderTopColor`) merge in the CSSOM exactly as React's
|
|
84
|
+
* serialized attribute does.
|
|
85
|
+
*
|
|
86
|
+
* @param node - The element to style.
|
|
87
|
+
* @param style - The React-shaped style object (may be undefined).
|
|
88
|
+
* @returns The action with an update that re-applies on prop changes.
|
|
89
|
+
*/
|
|
90
|
+
export function reactStyle(node, style) {
|
|
91
|
+
const applied = new Set();
|
|
92
|
+
const apply = (next) => {
|
|
93
|
+
const removed = new Set(applied);
|
|
94
|
+
if (next) {
|
|
95
|
+
for (const key of Object.keys(next)) {
|
|
96
|
+
removed.delete(key);
|
|
97
|
+
const text = reactStyleValue(key, next[key]);
|
|
98
|
+
if (key.startsWith('--'))
|
|
99
|
+
node.style.setProperty(key, text);
|
|
100
|
+
else
|
|
101
|
+
node.style.setProperty(kebab(key), text);
|
|
102
|
+
if (text)
|
|
103
|
+
applied.add(key);
|
|
104
|
+
else
|
|
105
|
+
applied.delete(key);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
for (const key of removed) {
|
|
109
|
+
node.style.setProperty(kebab(key), '');
|
|
110
|
+
applied.delete(key);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
apply(style);
|
|
114
|
+
return { update: apply };
|
|
115
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Svelte file card primitives — the same shapes
|
|
3
|
+
* `@molecule/app-file-card-react` exports, with Svelte 5 snippets for the
|
|
4
|
+
* actions slot.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { Snippet } from 'svelte';
|
|
9
|
+
/**
|
|
10
|
+
* Supported file kinds. Drives icon selection and the "<kind>" portion of
|
|
11
|
+
* the aria label translation key (e.g. `file-card.kind.image`).
|
|
12
|
+
*/
|
|
13
|
+
export type FileKind = 'image' | 'video' | 'audio' | 'document' | 'archive' | 'code' | 'folder' | 'other';
|
|
14
|
+
/**
|
|
15
|
+
* Minimal description of a file shown in a `<FileCard>`. Apps map their own
|
|
16
|
+
* domain types onto this shape — there is no required mime field; pass
|
|
17
|
+
* `kind` instead so the icon matches even when only a filename is known.
|
|
18
|
+
*/
|
|
19
|
+
export interface FileSummary {
|
|
20
|
+
/** Stable identifier for the file (parent key + `data-mol-id` suffix). */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Display name (filename including extension). */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Size in bytes. Pass `0` for folders or unknown. */
|
|
25
|
+
size: number;
|
|
26
|
+
/** File kind — drives the icon and the "kind" aria token. */
|
|
27
|
+
kind: FileKind;
|
|
28
|
+
/** Last-modified timestamp (ISO string, ms epoch, or `Date`). Optional. */
|
|
29
|
+
modifiedAt?: string | number | Date;
|
|
30
|
+
/** Optional thumbnail URL. When set, replaces the icon in `'grid'` layout. */
|
|
31
|
+
thumbnail?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Props for `<FileCard>`. */
|
|
34
|
+
export interface FileCardProps {
|
|
35
|
+
/** The file to render. */
|
|
36
|
+
file: FileSummary;
|
|
37
|
+
/** Selected highlight state. */
|
|
38
|
+
selected?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Handler fired when the card body is activated: a click anywhere on it, or
|
|
41
|
+
* Enter / Space on its select button (a transparent button covering the card,
|
|
42
|
+
* with `aria-pressed` for `selected`). Not fired for the actions slot, which
|
|
43
|
+
* sits above that button.
|
|
44
|
+
*/
|
|
45
|
+
onClick?: (file: FileSummary, event: MouseEvent) => void;
|
|
46
|
+
/** Context-menu (right-click) handler. */
|
|
47
|
+
onContextMenu?: (file: FileSummary, event: MouseEvent) => void;
|
|
48
|
+
/** Layout — `'grid'` (default) is a square tile, `'row'` is a horizontal list line. */
|
|
49
|
+
layout?: 'grid' | 'row';
|
|
50
|
+
/** Optional trailing action slot (button row, kebab menu). Clicks here do not fire `onClick`. */
|
|
51
|
+
actions?: Snippet;
|
|
52
|
+
/** Reference "now" for relative-time formatting. Useful for testing/snapshots. */
|
|
53
|
+
now?: Date;
|
|
54
|
+
/** Extra classes merged onto the root element. */
|
|
55
|
+
className?: string;
|
|
56
|
+
/** Override the root `data-mol-id` (defaults to `file-card-${file.id}`). */
|
|
57
|
+
dataMolId?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Props for `<FileIcon>`. */
|
|
60
|
+
export interface FileIconProps {
|
|
61
|
+
/** File kind — picks the SVG glyph. */
|
|
62
|
+
kind: FileKind;
|
|
63
|
+
/** Pixel size of the rendered SVG (default 24). */
|
|
64
|
+
size?: number;
|
|
65
|
+
/** Optional aria-label. When omitted the icon is `aria-hidden`. */
|
|
66
|
+
ariaLabel?: string;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAClB,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEpF;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAA;IACV,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,IAAI,EAAE,QAAQ,CAAA;IACd,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,8BAA8B;AAC9B,MAAM,WAAW,aAAa;IAC5B,0BAA0B;IAC1B,IAAI,EAAE,WAAW,CAAA;IACjB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACxD,0CAA0C;IAC1C,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAC9D,uFAAuF;IACvF,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACvB,iGAAiG;IACjG,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kFAAkF;IAClF,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,8BAA8B;AAC9B,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,IAAI,EAAE,QAAQ,CAAA;IACd,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-file-card-svelte",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1-stage",
|
|
4
|
+
"description": "Svelte file card primitives — icon, name, size, modified date, actions; grid + row layouts",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-file-card-svelte",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"svelte": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"svelte": "./dist/index.js",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"!dist/**/__tests__",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/*.spec.*",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && svelte-package --input src --output dist --tsconfig ./tsconfig.json",
|
|
27
|
+
"dev": "svelte-package --input src --output dist --tsconfig ./tsconfig.json --watch",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"molecule",
|
|
33
|
+
"file-card",
|
|
34
|
+
"attachment",
|
|
35
|
+
"file-tile",
|
|
36
|
+
"svelte"
|
|
37
|
+
],
|
|
38
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
43
|
+
"directory": "packages/app/features/file-card-svelte"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
},
|
|
48
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@molecule/app-svelte": "^3.5.0",
|
|
54
|
+
"@molecule/app-ui": "^1.0.1",
|
|
55
|
+
"@molecule/app-ui-svelte": "^1.1.0",
|
|
56
|
+
"svelte": "^5.0.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
60
|
+
"@molecule/app-i18n": "1.2.2",
|
|
61
|
+
"@molecule/app-icons": "1.0.4",
|
|
62
|
+
"@molecule/app-svelte": "3.7.2",
|
|
63
|
+
"@molecule/app-ui": "1.4.0",
|
|
64
|
+
"@molecule/app-ui-svelte": "1.1.7",
|
|
65
|
+
"@sveltejs/package": "3.0.2",
|
|
66
|
+
"@sveltejs/vite-plugin-svelte": "7.1.2",
|
|
67
|
+
"@types/node": "26.6.5",
|
|
68
|
+
"jsdom": "30.1.3",
|
|
69
|
+
"svelte": "5.57.2",
|
|
70
|
+
"svelte-check": "4.7.7",
|
|
71
|
+
"typescript": "6.0.3",
|
|
72
|
+
"vite": "8.3.5",
|
|
73
|
+
"vitest": "4.1.12"
|
|
74
|
+
}
|
|
75
|
+
}
|