@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
package/dist/index.js
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.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Solid file card primitives — the same shapes
|
|
3
|
+
* `@molecule/app-file-card-react` exports, with Solid's node type for the
|
|
4
|
+
* actions slot.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { JSX } from 'solid-js';
|
|
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?: JSX.Element;
|
|
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,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAClB,OAAO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,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-file-card-solid",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Solid file card primitives — icon, name, size, modified date, actions; grid + row layouts",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-file-card-solid",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"dev": "tsc --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"molecule",
|
|
27
|
+
"file-card",
|
|
28
|
+
"attachment",
|
|
29
|
+
"file-tile",
|
|
30
|
+
"solid"
|
|
31
|
+
],
|
|
32
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
37
|
+
"directory": "packages/app/features/file-card-solid"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20"
|
|
41
|
+
},
|
|
42
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@molecule/app-solid": "^3.5.0",
|
|
48
|
+
"@molecule/app-ui": "^1.0.1",
|
|
49
|
+
"@molecule/app-ui-solid": "^1.1.0",
|
|
50
|
+
"solid-js": "^1.8.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
54
|
+
"@molecule/app-i18n": "1.2.2",
|
|
55
|
+
"@molecule/app-icons": "1.0.4",
|
|
56
|
+
"@molecule/app-solid": "3.9.0",
|
|
57
|
+
"@molecule/app-ui": "1.5.0",
|
|
58
|
+
"@molecule/app-ui-solid": "1.2.1",
|
|
59
|
+
"@types/node": "26.6.5",
|
|
60
|
+
"jsdom": "30.1.3",
|
|
61
|
+
"solid-js": "1.9.17",
|
|
62
|
+
"typescript": "6.0.3",
|
|
63
|
+
"vite-plugin-solid": "2.11.15",
|
|
64
|
+
"vitest": "4.1.12"
|
|
65
|
+
}
|
|
66
|
+
}
|