@molecule/app-file-card-solid 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +307 -2
- package/dist/FileCard.d.ts +34 -0
- package/dist/FileCard.d.ts.map +1 -0
- package/dist/FileCard.jsx +259 -0
- package/dist/FileCard.jsx.map +1 -0
- package/dist/FileIcon.d.ts +19 -0
- package/dist/FileIcon.d.ts.map +1 -0
- package/dist/FileIcon.jsx +64 -0
- package/dist/FileIcon.jsx.map +1 -0
- package/dist/format.d.ts +80 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +88 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -4
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid file representation card — icon (or thumbnail), filename, formatted
|
|
3
|
+
* size, relative modified date, and an optional trailing actions slot, in
|
|
4
|
+
* `'grid'` (square tile) or `'row'` (horizontal line) layout.
|
|
5
|
+
*
|
|
6
|
+
* Solid counterpart of `@molecule/app-file-card-react`'s `FileCard` — the
|
|
7
|
+
* same props (React names) and the same DOM for the same input.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { Show } from 'solid-js';
|
|
12
|
+
import { useTranslation } from '@molecule/app-solid';
|
|
13
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
14
|
+
import { FileIcon } from './FileIcon.jsx';
|
|
15
|
+
import { relativeBucket, sizeParts } from './format.js';
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the relative-time text for a file via `t()`. Keeps the JSX clean
|
|
18
|
+
* and centralizes the bucket → key mapping.
|
|
19
|
+
*
|
|
20
|
+
* @param at - Modified-at timestamp.
|
|
21
|
+
* @param t - The `useTranslation()` `t` function.
|
|
22
|
+
* @param now - Reference "now".
|
|
23
|
+
* @returns The localized relative-time string.
|
|
24
|
+
*/
|
|
25
|
+
function relativeText(at, t, now) {
|
|
26
|
+
const bucket = relativeBucket(at, now);
|
|
27
|
+
switch (bucket.kind) {
|
|
28
|
+
case 'just-now':
|
|
29
|
+
return t('file-card.modified.just-now', {}, { defaultValue: 'just now' });
|
|
30
|
+
case 'minutes':
|
|
31
|
+
return t(bucket.n === 1 ? 'file-card.modified.minute-one' : 'file-card.modified.minute-other', { count: bucket.n }, { defaultValue: bucket.n === 1 ? '1 min ago' : `${bucket.n} min ago` });
|
|
32
|
+
case 'hours':
|
|
33
|
+
return t(bucket.n === 1 ? 'file-card.modified.hour-one' : 'file-card.modified.hour-other', { count: bucket.n }, { defaultValue: bucket.n === 1 ? '1 hr ago' : `${bucket.n} hr ago` });
|
|
34
|
+
case 'days':
|
|
35
|
+
return t(bucket.n === 1 ? 'file-card.modified.day-one' : 'file-card.modified.day-other', { count: bucket.n }, { defaultValue: bucket.n === 1 ? 'yesterday' : `${bucket.n} days ago` });
|
|
36
|
+
case 'weeks':
|
|
37
|
+
return t(bucket.n === 1 ? 'file-card.modified.week-one' : 'file-card.modified.week-other', { count: bucket.n }, { defaultValue: bucket.n === 1 ? '1 wk ago' : `${bucket.n} wk ago` });
|
|
38
|
+
case 'months':
|
|
39
|
+
return t(bucket.n === 1 ? 'file-card.modified.month-one' : 'file-card.modified.month-other', { count: bucket.n }, { defaultValue: bucket.n === 1 ? '1 mo ago' : `${bucket.n} mo ago` });
|
|
40
|
+
case 'absolute':
|
|
41
|
+
return bucket.iso;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the human-readable kind label via `t()`. One literal key per
|
|
46
|
+
* `FileKind` so the i18n gate can verify every key exists in the locale
|
|
47
|
+
* bond (a runtime-built `` `file-card.kind.${kind}` `` cannot be checked).
|
|
48
|
+
*
|
|
49
|
+
* @param kind - File kind.
|
|
50
|
+
* @param t - The `useTranslation()` `t` function.
|
|
51
|
+
* @returns The localized kind label.
|
|
52
|
+
*/
|
|
53
|
+
function kindText(kind, t) {
|
|
54
|
+
switch (kind) {
|
|
55
|
+
case 'image':
|
|
56
|
+
return t('file-card.kind.image', {}, { defaultValue: 'Image file' });
|
|
57
|
+
case 'video':
|
|
58
|
+
return t('file-card.kind.video', {}, { defaultValue: 'Video file' });
|
|
59
|
+
case 'audio':
|
|
60
|
+
return t('file-card.kind.audio', {}, { defaultValue: 'Audio file' });
|
|
61
|
+
case 'document':
|
|
62
|
+
return t('file-card.kind.document', {}, { defaultValue: 'Document' });
|
|
63
|
+
case 'archive':
|
|
64
|
+
return t('file-card.kind.archive', {}, { defaultValue: 'Archive' });
|
|
65
|
+
case 'code':
|
|
66
|
+
return t('file-card.kind.code', {}, { defaultValue: 'Code file' });
|
|
67
|
+
case 'folder':
|
|
68
|
+
return t('file-card.kind.folder', {}, { defaultValue: 'Folder' });
|
|
69
|
+
case 'other':
|
|
70
|
+
return t('file-card.kind.other', {}, { defaultValue: 'File' });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Resolve the size's unit word via `t()`, with the number {@link sizeParts}
|
|
75
|
+
* already displayed: one literal key per `SizeUnit` — the same pattern as
|
|
76
|
+
* {@link kindText} — so the i18n gate can verify every key exists in the
|
|
77
|
+
* locale bond, and the `{{n}}` placeholder lets a translation move the number
|
|
78
|
+
* or rename the token (French octets, Russian КБ).
|
|
79
|
+
*
|
|
80
|
+
* @param size - The size's displayed number and unit (`sizeParts(file.size)`).
|
|
81
|
+
* @param t - The `useTranslation()` `t` function.
|
|
82
|
+
* @returns The localized size text.
|
|
83
|
+
*/
|
|
84
|
+
function sizeUnitText(size, t) {
|
|
85
|
+
switch (size.unit) {
|
|
86
|
+
case 'B':
|
|
87
|
+
return t('file-card.size.b', { n: size.n }, { defaultValue: '{{n}} B' });
|
|
88
|
+
case 'KB':
|
|
89
|
+
return t('file-card.size.kb', { n: size.n }, { defaultValue: '{{n}} KB' });
|
|
90
|
+
case 'MB':
|
|
91
|
+
return t('file-card.size.mb', { n: size.n }, { defaultValue: '{{n}} MB' });
|
|
92
|
+
case 'GB':
|
|
93
|
+
return t('file-card.size.gb', { n: size.n }, { defaultValue: '{{n}} GB' });
|
|
94
|
+
case 'TB':
|
|
95
|
+
return t('file-card.size.tb', { n: size.n }, { defaultValue: '{{n}} TB' });
|
|
96
|
+
case 'PB':
|
|
97
|
+
return t('file-card.size.pb', { n: size.n }, { defaultValue: '{{n}} PB' });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* File representation card — icon (or thumbnail), filename, formatted size,
|
|
102
|
+
* relative modified date, and optional trailing actions slot. Used by
|
|
103
|
+
* cloud-file-manager grids/lists, social-media + email-client attachment
|
|
104
|
+
* previews, and document-collaboration sidebars.
|
|
105
|
+
*
|
|
106
|
+
* Two layouts:
|
|
107
|
+
* - `'grid'` (default) — square tile with the icon/thumbnail stacked above
|
|
108
|
+
* the metadata. Suitable for finder-style grids and attachment galleries.
|
|
109
|
+
* - `'row'` — horizontal line item with the icon on the left, metadata in
|
|
110
|
+
* the middle, and the actions slot on the right. Suitable for list views
|
|
111
|
+
* and chat/email attachment rows.
|
|
112
|
+
*
|
|
113
|
+
* All styling routes through `getClassMap()`. All user-visible text routes
|
|
114
|
+
* through `t()` so the card translates via the companion
|
|
115
|
+
* `@molecule/app-locales-file-card` locale bond.
|
|
116
|
+
*
|
|
117
|
+
* @param props - Component props (see {@link FileCardProps}).
|
|
118
|
+
* @returns The file card element.
|
|
119
|
+
*/
|
|
120
|
+
export const FileCard = (props) => {
|
|
121
|
+
const { t } = useTranslation();
|
|
122
|
+
const cm = getClassMap();
|
|
123
|
+
const kindLabel = () => kindText(props.file.kind, t);
|
|
124
|
+
const sizePartsOf = () => props.file.kind === 'folder' ? undefined : sizeParts(props.file.size);
|
|
125
|
+
const sizeText = () => {
|
|
126
|
+
const size = sizePartsOf();
|
|
127
|
+
return size ? sizeUnitText(size, t) : '';
|
|
128
|
+
};
|
|
129
|
+
const sizeLabel = () => sizeText()
|
|
130
|
+
? t('file-card.aria.size', { size: sizeText() }, { defaultValue: 'Size {{size}}' })
|
|
131
|
+
: '';
|
|
132
|
+
const modifiedText = () => props.file.modifiedAt ? relativeText(props.file.modifiedAt, t, props.now) : '';
|
|
133
|
+
const modifiedLabel = () => modifiedText()
|
|
134
|
+
? t('file-card.aria.modified', { when: modifiedText() }, { defaultValue: 'Modified {{when}}' })
|
|
135
|
+
: '';
|
|
136
|
+
const ariaLabel = () => t('file-card.aria.root', { name: props.file.name, kind: kindLabel() }, {
|
|
137
|
+
defaultValue: '{{name}}, {{kind}}',
|
|
138
|
+
});
|
|
139
|
+
const rootMolId = () => props.dataMolId ?? `file-card-${props.file.id}`;
|
|
140
|
+
/**
|
|
141
|
+
* Forward a body activation (a click on the select button, or Enter / Space
|
|
142
|
+
* on it) to the consumer.
|
|
143
|
+
*
|
|
144
|
+
* @param event - DOM mouse event.
|
|
145
|
+
*/
|
|
146
|
+
const handleClick = (event) => {
|
|
147
|
+
props.onClick?.(props.file, event);
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Forward right-click to the consumer.
|
|
151
|
+
*
|
|
152
|
+
* @param event - DOM mouse event.
|
|
153
|
+
*/
|
|
154
|
+
const handleContextMenu = (event) => {
|
|
155
|
+
if (props.onContextMenu)
|
|
156
|
+
props.onContextMenu(props.file, event);
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* The row icon: the thumbnail `<img>` at its 40px tile, else the glyph at 28.
|
|
160
|
+
*
|
|
161
|
+
* @returns The icon element.
|
|
162
|
+
*/
|
|
163
|
+
const rowIcon = () => props.file.thumbnail ? (<img src={props.file.thumbnail} alt="" style={{ width: '40px', height: '40px', 'object-fit': 'cover', 'border-radius': '4px' }}/>) : (<FileIcon kind={props.file.kind} size={28}/>);
|
|
164
|
+
/**
|
|
165
|
+
* The grid icon: the thumbnail `<img>` filling the square tile, else the
|
|
166
|
+
* glyph at 48.
|
|
167
|
+
*
|
|
168
|
+
* @returns The icon element.
|
|
169
|
+
*/
|
|
170
|
+
const gridIcon = () => props.file.thumbnail ? (<img src={props.file.thumbnail} alt="" style={{ width: '100%', height: '100%', 'object-fit': 'cover', 'border-radius': '4px' }}/>) : (<FileIcon kind={props.file.kind} size={48}/>);
|
|
171
|
+
/**
|
|
172
|
+
* The card's select control: a transparent native button covering the card
|
|
173
|
+
* (Enter / Space activate it natively), above the content and below the
|
|
174
|
+
* actions slot. A sibling of the actions, not their wrapper, so the action
|
|
175
|
+
* buttons stay reachable controls (a button's children are presentational).
|
|
176
|
+
*
|
|
177
|
+
* @returns The select button, or null without `onClick`.
|
|
178
|
+
*/
|
|
179
|
+
const selectButton = () => props.onClick ? (<button type="button" aria-label={ariaLabel()} aria-pressed={props.selected ? 'true' : 'false'} data-mol-id="file-card-select" onClick={handleClick}
|
|
180
|
+
/* mol-bespoke-button: the whole card is the hit area, not a CTA — an
|
|
181
|
+
empty, transparent button over the card; the inline background/
|
|
182
|
+
border/padding are native resets. */
|
|
183
|
+
class={cm.cn(cm.position('absolute'), cm.inset0, cm.cursorPointer)} style={{ background: 'transparent', border: 'medium', padding: '0px' }}/>) : null;
|
|
184
|
+
/**
|
|
185
|
+
* The size + modified meta line, with an `aria-hidden` separator between
|
|
186
|
+
* the two present.
|
|
187
|
+
*
|
|
188
|
+
* @returns The meta element, or null when neither is present.
|
|
189
|
+
*/
|
|
190
|
+
const meta = () => {
|
|
191
|
+
if (!sizeText() && !modifiedText())
|
|
192
|
+
return null;
|
|
193
|
+
return (<div class={cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.textSize('xs'))} data-mol-id="file-card-meta">
|
|
194
|
+
{sizeText() && (<span aria-label={sizeLabel()} data-mol-id="file-card-size">
|
|
195
|
+
{sizeText()}
|
|
196
|
+
</span>)}
|
|
197
|
+
{sizeText() && modifiedText() && <span aria-hidden="true">·</span>}
|
|
198
|
+
{modifiedText() && (<span aria-label={modifiedLabel()} data-mol-id="file-card-modified">
|
|
199
|
+
{modifiedText()}
|
|
200
|
+
</span>)}
|
|
201
|
+
</div>);
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* The trailing actions region, a sibling of the select button.
|
|
205
|
+
*
|
|
206
|
+
* @returns The actions element, or null without actions.
|
|
207
|
+
*/
|
|
208
|
+
const actions = () => {
|
|
209
|
+
if (!props.actions)
|
|
210
|
+
return null;
|
|
211
|
+
return (<div class={props.layout === 'row'
|
|
212
|
+
? cm.cn(cm.shrink0, cm.position('relative'))
|
|
213
|
+
: cm.cn(cm.flex({ align: 'center', justify: 'end', gap: 'sm' }), cm.position('relative'))} data-mol-id="file-card-actions">
|
|
214
|
+
{props.actions}
|
|
215
|
+
</div>);
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* The row layout: a horizontal line item — icon, name + meta, then the
|
|
219
|
+
* select button and the actions region.
|
|
220
|
+
*
|
|
221
|
+
* @returns The row card element.
|
|
222
|
+
*/
|
|
223
|
+
const rowLayout = () => (<div role="group" aria-label={ariaLabel()} data-mol-id={rootMolId()} data-selected={props.selected ? 'true' : undefined} class={cm.cn(cm.flex({ align: 'center', gap: 'md' }), cm.sp('p', 2), props.onClick ? cm.position('relative') : undefined, props.className)} oncontextmenu={handleContextMenu}>
|
|
224
|
+
<div class={cm.cn(cm.shrink0)} data-mol-id="file-card-icon">
|
|
225
|
+
{rowIcon()}
|
|
226
|
+
</div>
|
|
227
|
+
<div class={cm.cn(cm.stack(0))} style={{ flex: '1 1 0%', 'min-width': '0px' }}>
|
|
228
|
+
<div class={cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))} data-mol-id="file-card-name" style={{ overflow: 'hidden', 'text-overflow': 'ellipsis', 'white-space': 'nowrap' }}>
|
|
229
|
+
{props.file.name}
|
|
230
|
+
</div>
|
|
231
|
+
{meta()}
|
|
232
|
+
</div>
|
|
233
|
+
{selectButton()}
|
|
234
|
+
{actions()}
|
|
235
|
+
</div>);
|
|
236
|
+
/**
|
|
237
|
+
* The grid layout (default): a square tile — icon above name and meta,
|
|
238
|
+
* then the select button and the actions region.
|
|
239
|
+
*
|
|
240
|
+
* @returns The grid card element.
|
|
241
|
+
*/
|
|
242
|
+
const gridLayout = () => (<div role="group" aria-label={ariaLabel()} data-mol-id={rootMolId()} data-selected={props.selected ? 'true' : undefined} class={cm.cn(cm.stack(1), cm.sp('p', 3), props.onClick ? cm.position('relative') : undefined, props.className)} oncontextmenu={handleContextMenu}>
|
|
243
|
+
<div class={cm.cn(cm.flex({ align: 'center', justify: 'center' }))} data-mol-id="file-card-icon" style={{ 'aspect-ratio': '1 / 1', width: '100%' }}>
|
|
244
|
+
{gridIcon()}
|
|
245
|
+
</div>
|
|
246
|
+
<div class={cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))} data-mol-id="file-card-name" style={{ overflow: 'hidden', 'text-overflow': 'ellipsis', 'white-space': 'nowrap' }}>
|
|
247
|
+
{props.file.name}
|
|
248
|
+
</div>
|
|
249
|
+
{meta()}
|
|
250
|
+
{selectButton()}
|
|
251
|
+
{actions()}
|
|
252
|
+
</div>);
|
|
253
|
+
// The layout branch is reactive: a `layout` prop change swaps the trees
|
|
254
|
+
// the way React's re-render does.
|
|
255
|
+
return (<Show when={props.layout === 'row'} fallback={gridLayout()}>
|
|
256
|
+
{rowLayout()}
|
|
257
|
+
</Show>);
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=FileCard.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCard.jsx","sourceRoot":"","sources":["../src/FileCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAA4B,IAAI,EAAE,MAAM,UAAU,CAAA;AAEzD,OAAO,EAAE,cAAc,E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,CACP,CAAA;IAED,wEAAwE;IACxE,kCAAkC;IAClC,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC,CACzD;MAAA,CAAC,SAAS,EAAE,CACd;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid file-kind icon — a stroke-currentColor SVG glyph keyed by `FileKind`.
|
|
3
|
+
*
|
|
4
|
+
* Solid counterpart of `@molecule/app-file-card-react`'s `FileIcon` — the
|
|
5
|
+
* same props (React names) and the same DOM for the same input.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { Component } from 'solid-js';
|
|
10
|
+
import type { FileIconProps } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Icon glyph for a file kind. Stroke-currentColor SVG so it inherits the
|
|
13
|
+
* surrounding text color (no ClassMap colors needed).
|
|
14
|
+
*
|
|
15
|
+
* @param props - Component props (see {@link FileIconProps}).
|
|
16
|
+
* @returns The SVG icon element.
|
|
17
|
+
*/
|
|
18
|
+
export declare const FileIcon: Component<FileIconProps>;
|
|
19
|
+
//# sourceMappingURL=FileIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileIcon.d.ts","sourceRoot":"","sources":["../src/FileIcon.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAO,MAAM,UAAU,CAAA;AAE9C,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,YAAY,CAAA;AAgEzD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAAC,aAAa,CAkB7C,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid file-kind icon — a stroke-currentColor SVG glyph keyed by `FileKind`.
|
|
3
|
+
*
|
|
4
|
+
* Solid counterpart of `@molecule/app-file-card-react`'s `FileIcon` — the
|
|
5
|
+
* same props (React names) and the same DOM for the same input.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Single-element SVG path data for each `FileKind`. Stroke-only outlines
|
|
11
|
+
* keep the icon legible at small sizes and match common file-manager
|
|
12
|
+
* conventions (image = mountain, video = play, audio = note, document =
|
|
13
|
+
* page, archive = box, code = brackets, folder = tab, other = sheet).
|
|
14
|
+
*/
|
|
15
|
+
const PATHS = {
|
|
16
|
+
image: (<>
|
|
17
|
+
<rect x="3" y="5" width="18" height="14" rx="2"/>
|
|
18
|
+
<circle cx="8.5" cy="10.5" r="1.5"/>
|
|
19
|
+
<path d="m21 15-5-5L5 21"/>
|
|
20
|
+
</>),
|
|
21
|
+
video: (<>
|
|
22
|
+
<rect x="3" y="5" width="18" height="14" rx="2"/>
|
|
23
|
+
<path d="m10 9 5 3-5 3z" fill="currentColor"/>
|
|
24
|
+
</>),
|
|
25
|
+
audio: (<>
|
|
26
|
+
<path d="M9 18V5l12-2v13"/>
|
|
27
|
+
<circle cx="6" cy="18" r="3"/>
|
|
28
|
+
<circle cx="18" cy="16" r="3"/>
|
|
29
|
+
</>),
|
|
30
|
+
document: (<>
|
|
31
|
+
<path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
|
|
32
|
+
<path d="M14 3v6h6"/>
|
|
33
|
+
</>),
|
|
34
|
+
archive: (<>
|
|
35
|
+
<rect x="3" y="3" width="18" height="6" rx="1"/>
|
|
36
|
+
<path d="M3 9v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9"/>
|
|
37
|
+
<path d="M10 13h4"/>
|
|
38
|
+
</>),
|
|
39
|
+
code: (<>
|
|
40
|
+
<path d="m9 8-5 4 5 4"/>
|
|
41
|
+
<path d="m15 8 5 4-5 4"/>
|
|
42
|
+
<path d="m13 5-2 14"/>
|
|
43
|
+
</>),
|
|
44
|
+
folder: (<>
|
|
45
|
+
<path 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"/>
|
|
46
|
+
</>),
|
|
47
|
+
other: (<>
|
|
48
|
+
<path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/>
|
|
49
|
+
<path d="M14 3v6h6"/>
|
|
50
|
+
<path d="M9 14h6"/>
|
|
51
|
+
<path d="M9 17h4"/>
|
|
52
|
+
</>),
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Icon glyph for a file kind. Stroke-currentColor SVG so it inherits the
|
|
56
|
+
* surrounding text color (no ClassMap colors needed).
|
|
57
|
+
*
|
|
58
|
+
* @param props - Component props (see {@link FileIconProps}).
|
|
59
|
+
* @returns The SVG icon element.
|
|
60
|
+
*/
|
|
61
|
+
export const FileIcon = (props) => (<svg xmlns="http://www.w3.org/2000/svg" width={props.size ?? 24} height={props.size ?? 24} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width={1.75} stroke-linecap="round" stroke-linejoin="round" role={props.ariaLabel ? 'img' : undefined} aria-label={props.ariaLabel} aria-hidden={props.ariaLabel ? undefined : true} data-mol-id={`file-icon-${props.kind}`}>
|
|
62
|
+
{PATHS[props.kind]}
|
|
63
|
+
</svg>);
|
|
64
|
+
//# sourceMappingURL=FileIcon.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileIcon.jsx","sourceRoot":"","sources":["../src/FileIcon.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;;GAKG;AACH,MAAM,KAAK,GAAkC;IAC3C,KAAK,EAAE,CACL,EACE;MAAA,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,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,aAAa,KAAK,CAAC,IAAI,EAAE,CAAC,CAEvC;IAAA,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CACpB;EAAA,EAAE,GAAG,CAAC,CACP,CAAA"}
|
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,88 @@
|
|
|
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
|
+
}
|
|
88
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;IACtE,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;IACpE,MAAM,KAAK,GAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACxD,IAAI,CAAC,GAAG,KAAK,GAAG,IAAI,CAAA;IACpB,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,OAAO,CAAC,IAAI,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,CAAC,IAAI,IAAI,CAAA;QACT,SAAS,IAAI,CAAC,CAAA;IAChB,CAAC;IACD,yCAAyC;IACzC,MAAM,OAAO,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,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AG,GAAG,GAAG,CAAA;IACtB,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;IACrE,IAAI,EAAE,GAAG,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IAChE,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAA;IAC/D,IAAI,EAAE,GAAG,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IAClE,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAA;IACnE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAA;AACnE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid 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
|
+
* ```tsx
|
|
19
|
+
* import { FileCard, type FileSummary } from '@molecule/app-file-card-solid'
|
|
20
|
+
*
|
|
21
|
+
* const file: FileSummary = {
|
|
22
|
+
* id: 'f-1',
|
|
23
|
+
* name: 'Q3-report.pdf',
|
|
24
|
+
* size: 482_137,
|
|
25
|
+
* kind: 'document',
|
|
26
|
+
* modifiedAt: '2026-04-30T18:23:00Z',
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* <FileCard
|
|
30
|
+
* file={file}
|
|
31
|
+
* layout="grid"
|
|
32
|
+
* onClick={(f) => openFile(f.id)}
|
|
33
|
+
* actions={<KebabMenu fileId={file.id} />}
|
|
34
|
+
* />
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* All styling routes through `getClassMap()` from `@molecule/app-ui` —
|
|
39
|
+
* swap the ClassMap bond to restyle without touching this package.
|
|
40
|
+
*
|
|
41
|
+
* All user-visible text routes through `t()` (via `@molecule/app-solid`'s
|
|
42
|
+
* `useTranslation`) and translates via the companion
|
|
43
|
+
* `@molecule/app-locales-file-card` locale bond. English fallbacks are
|
|
44
|
+
* inlined so the card works without the locale bond present.
|
|
45
|
+
*
|
|
46
|
+
* @module
|
|
47
|
+
*/
|
|
48
|
+
export * from './FileCard.jsx';
|
|
49
|
+
export * from './FileIcon.jsx';
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|