@molecule/app-file-card-solid 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 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
- # Temporary Holding Version
1
+ # @molecule/app-file-card-solid
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Solid file card primitives — icon, name, size, modified date, actions; grid + row layouts
4
+
5
+ ```
6
+ npm install @molecule/app-file-card-solid
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,34 @@
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 { type Component } from 'solid-js';
12
+ import type { FileCardProps } from './types.js';
13
+ /**
14
+ * File representation card — icon (or thumbnail), filename, formatted size,
15
+ * relative modified date, and optional trailing actions slot. Used by
16
+ * cloud-file-manager grids/lists, social-media + email-client attachment
17
+ * previews, and document-collaboration sidebars.
18
+ *
19
+ * Two layouts:
20
+ * - `'grid'` (default) — square tile with the icon/thumbnail stacked above
21
+ * the metadata. Suitable for finder-style grids and attachment galleries.
22
+ * - `'row'` — horizontal line item with the icon on the left, metadata in
23
+ * the middle, and the actions slot on the right. Suitable for list views
24
+ * and chat/email attachment rows.
25
+ *
26
+ * All styling routes through `getClassMap()`. All user-visible text routes
27
+ * through `t()` so the card translates via the companion
28
+ * `@molecule/app-locales-file-card` locale bond.
29
+ *
30
+ * @param props - Component props (see {@link FileCardProps}).
31
+ * @returns The file card element.
32
+ */
33
+ export declare const FileCard: Component<FileCardProps>;
34
+ //# sourceMappingURL=FileCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileCard.d.ts","sourceRoot":"","sources":["../src/FileCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,UAAU,CAAA;AAOzD,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,YAAY,CAAA;AAoHzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAAC,aAAa,CAwP7C,CAAA"}
@@ -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,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAA;AAUvE;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,EAA0B,EAAE,CAAM,EAAE,GAAqB;IAC7E,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;IACtC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,UAAU;YACb,OAAO,CAAC,CAAC,6BAA6B,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAA;QAC3E,KAAK,SAAS;YACZ,OAAO,CAAC,CACN,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,iCAAiC,EACpF,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,EACnB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,UAAU,EAAE,CACvE,CAAA;QACH,KAAK,OAAO;YACV,O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,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAC3D,WAAW,CAAC,gBAAgB,CAC5B,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAEpF;QAAA,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAClB;MAAA,EAAE,GAAG,CACL;MAAA,CAAC,IAAI,EAAE,CACP;MAAA,CAAC,YAAY,EAAE,CACf;MAAA,CAAC,OAAO,EAAE,CACZ;IAAA,EAAE,GAAG,CAAC,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,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAC/C;MAAA,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAClC;MAAA,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,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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,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACtF,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAa,EAAE,CAAA;AAC3D,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAA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AE,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"}
@@ -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"}
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"}
@@ -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,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,GAAG,CAAC,OAAO,CAAA;IACrB,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
@@ -0,0 +1,9 @@
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
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -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": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1-stage",
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.7.2",
57
+ "@molecule/app-ui": "1.4.0",
58
+ "@molecule/app-ui-solid": "1.1.5",
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
+ }