@molecule/app-image-gallery-editor-react 1.0.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 +115 -0
- package/dist/ImageGalleryEditor.d.ts +49 -0
- package/dist/ImageGalleryEditor.d.ts.map +1 -0
- package/dist/ImageGalleryEditor.js +89 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the
|
|
45
|
+
original version of the Work and any modifications or additions
|
|
46
|
+
to that Work, that is intentionally submitted to the Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or
|
|
48
|
+
Legal Entity authorized to submit on behalf of the copyright owner.
|
|
49
|
+
|
|
50
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
52
|
+
subsequently incorporated within the Work.
|
|
53
|
+
|
|
54
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
55
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
56
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
57
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
58
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
59
|
+
Work and such Derivative Works in Source or Object form.
|
|
60
|
+
|
|
61
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
63
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
+
patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
69
|
+
modifications, and in Source or Object form, provided that You
|
|
70
|
+
meet the following conditions:
|
|
71
|
+
|
|
72
|
+
(a) You must give any other recipients of the Work or
|
|
73
|
+
Derivative Works a copy of this License; and
|
|
74
|
+
|
|
75
|
+
(b) You must cause any modified files to carry prominent notices
|
|
76
|
+
stating that You changed the files; and
|
|
77
|
+
|
|
78
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
79
|
+
that You distribute, all copyright, patent, trademark, and
|
|
80
|
+
attribution notices from the Source form of the Work,
|
|
81
|
+
excluding those notices that do not pertain to any part of
|
|
82
|
+
the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
|
+
distribution, then any Derivative Works that You distribute must
|
|
86
|
+
include a readable copy of the attribution notices contained
|
|
87
|
+
within such NOTICE file.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
93
|
+
|
|
94
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
+
agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
96
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
97
|
+
|
|
98
|
+
8. Limitation of Liability. In no event and under no legal theory shall
|
|
99
|
+
any Contributor be liable to You for damages.
|
|
100
|
+
|
|
101
|
+
9. Accepting Warranty or Additional Liability.
|
|
102
|
+
|
|
103
|
+
Copyright 2026 Molecule Dev, Inc.
|
|
104
|
+
|
|
105
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
|
+
you may not use this file except in compliance with the License.
|
|
107
|
+
You may obtain a copy of the License at
|
|
108
|
+
|
|
109
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
|
|
111
|
+
Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
See the License for the specific language governing permissions and
|
|
115
|
+
limitations under the License.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editable image gallery — a hero drop zone with a side grid of
|
|
3
|
+
* thumbnail slots. Clicking an empty slot or the drop zone opens the
|
|
4
|
+
* native file picker; clicking a filled slot prompts to remove.
|
|
5
|
+
*
|
|
6
|
+
* Stateless about persistence: the consumer supplies the slot array
|
|
7
|
+
* and reacts to `onChange` (e.g. by uploading to S3 and replacing the
|
|
8
|
+
* preview URL with the persisted URL).
|
|
9
|
+
*
|
|
10
|
+
* Styling goes entirely through the ClassMap bond (`getClassMap()` / `cm.*`)
|
|
11
|
+
* so the editor renders out of the box under ANY styling library and needs
|
|
12
|
+
* no per-app Tailwind `@source` scan of this package. The handful of
|
|
13
|
+
* `style={...}` values (grid-column span, aspect ratio, corner radius, the
|
|
14
|
+
* dashed drop-zone affordance border, `object-fit`, the dimming opacity, and
|
|
15
|
+
* the hidden file input's `display:none`) are the documented
|
|
16
|
+
* ClassMap-can't-express cases (molecule Rule 5); each uses a real theme
|
|
17
|
+
* token (`var(--color-*)`) rather than a hardcoded color. Icons are real SVG
|
|
18
|
+
* glyphs from `@molecule/app-ui-react`'s `<Icon>` (no Material Symbols font).
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
import { type JSX, type ReactNode } from 'react';
|
|
23
|
+
import type { IconName } from '@molecule/app-icons';
|
|
24
|
+
/** Props for {@link ImageGalleryEditor}. */
|
|
25
|
+
export interface ImageGalleryEditorProps {
|
|
26
|
+
/** Ordered slots, `null` for empty. Length determines slot count. */
|
|
27
|
+
slots: (string | null)[];
|
|
28
|
+
onChange: (slots: (string | null)[]) => void;
|
|
29
|
+
/** Called when the user picks files; defaults to a local object URL. */
|
|
30
|
+
onPickFiles?: (files: FileList) => Promise<(string | null)[]> | (string | null)[];
|
|
31
|
+
maxImages?: number;
|
|
32
|
+
/** Header heading + subtitle slot (renders left of the photo counter). */
|
|
33
|
+
header?: ReactNode;
|
|
34
|
+
/** Photo-counter label (e.g. "3 / 24 Photos"). */
|
|
35
|
+
counter?: ReactNode;
|
|
36
|
+
dropZoneTitle?: ReactNode;
|
|
37
|
+
dropZoneHint?: ReactNode;
|
|
38
|
+
confirmRemoveMessage?: string;
|
|
39
|
+
statusMessage?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Glyph rendered in empty slots — a typed `IconName` from the bonded
|
|
42
|
+
* `@molecule/app-icons` set (an unknown name is a type error, not a blank).
|
|
43
|
+
*/
|
|
44
|
+
emptySlotIcon?: IconName;
|
|
45
|
+
}
|
|
46
|
+
/** Editable image gallery primitive. */
|
|
47
|
+
export declare function ImageGalleryEditor({ slots, onChange, onPickFiles, maxImages, header, counter, dropZoneTitle, dropZoneHint, confirmRemoveMessage, statusMessage, emptySlotIcon, }: ImageGalleryEditorProps): JSX.Element;
|
|
48
|
+
export default ImageGalleryEditor;
|
|
49
|
+
//# sourceMappingURL=ImageGalleryEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageGalleryEditor.d.ts","sourceRoot":"","sources":["../src/ImageGalleryEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAInD,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,KAAK,IAAI,CAAA;IAC5C,wEAAwE;IACxE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IACjF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,kDAAkD;IAClD,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,aAAa,CAAC,EAAE,SAAS,CAAA;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAA;CACzB;AAUD,wCAAwC;AACxC,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAc,EACd,MAAM,EACN,OAAO,EACP,aAA2C,EAC3C,YAA+C,EAC/C,oBAA2C,EAC3C,aAAa,EACb,aAAuB,GACxB,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CA0KvC;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Editable image gallery — a hero drop zone with a side grid of
|
|
4
|
+
* thumbnail slots. Clicking an empty slot or the drop zone opens the
|
|
5
|
+
* native file picker; clicking a filled slot prompts to remove.
|
|
6
|
+
*
|
|
7
|
+
* Stateless about persistence: the consumer supplies the slot array
|
|
8
|
+
* and reacts to `onChange` (e.g. by uploading to S3 and replacing the
|
|
9
|
+
* preview URL with the persisted URL).
|
|
10
|
+
*
|
|
11
|
+
* Styling goes entirely through the ClassMap bond (`getClassMap()` / `cm.*`)
|
|
12
|
+
* so the editor renders out of the box under ANY styling library and needs
|
|
13
|
+
* no per-app Tailwind `@source` scan of this package. The handful of
|
|
14
|
+
* `style={...}` values (grid-column span, aspect ratio, corner radius, the
|
|
15
|
+
* dashed drop-zone affordance border, `object-fit`, the dimming opacity, and
|
|
16
|
+
* the hidden file input's `display:none`) are the documented
|
|
17
|
+
* ClassMap-can't-express cases (molecule Rule 5); each uses a real theme
|
|
18
|
+
* token (`var(--color-*)`) rather than a hardcoded color. Icons are real SVG
|
|
19
|
+
* glyphs from `@molecule/app-ui-react`'s `<Icon>` (no Material Symbols font).
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import { useRef, useState } from 'react';
|
|
24
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
25
|
+
import { Icon } from '@molecule/app-ui-react';
|
|
26
|
+
/**
|
|
27
|
+
* Corner radius shared by the drop zone and thumbnail slots. The ClassMap
|
|
28
|
+
* contract exposes only `roundedFull` (a circle), so a specific radius amount
|
|
29
|
+
* is a documented inline-style exception (molecule Rule 5) — not a raw
|
|
30
|
+
* `rounded-xl` class, which no scaffold `@source`-scans from this package.
|
|
31
|
+
*/
|
|
32
|
+
const SLOT_RADIUS = '0.75rem';
|
|
33
|
+
/** Editable image gallery primitive. */
|
|
34
|
+
export function ImageGalleryEditor({ slots, onChange, onPickFiles, maxImages = 24, header, counter, dropZoneTitle = 'Drag and drop assets here', dropZoneHint = 'or click to browse local files', confirmRemoveMessage = 'Remove this image?', statusMessage, emptySlotIcon = 'image', }) {
|
|
35
|
+
const cm = getClassMap();
|
|
36
|
+
const fileInputRef = useRef(null);
|
|
37
|
+
const [uploadingSlot, setUploadingSlot] = useState(null);
|
|
38
|
+
const handleSlotClick = (index) => {
|
|
39
|
+
if (slots[index]) {
|
|
40
|
+
if (!window.confirm(confirmRemoveMessage))
|
|
41
|
+
return;
|
|
42
|
+
const next = [...slots];
|
|
43
|
+
next[index] = null;
|
|
44
|
+
onChange(next);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setUploadingSlot(index);
|
|
48
|
+
fileInputRef.current?.click();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const handleUploadAreaClick = () => {
|
|
52
|
+
setUploadingSlot(null);
|
|
53
|
+
fileInputRef.current?.click();
|
|
54
|
+
};
|
|
55
|
+
const handleFileChange = async (e) => {
|
|
56
|
+
const files = e.target.files;
|
|
57
|
+
if (!files?.length)
|
|
58
|
+
return;
|
|
59
|
+
const urls = onPickFiles
|
|
60
|
+
? await onPickFiles(files)
|
|
61
|
+
: Array.from(files).map((f) => URL.createObjectURL(f));
|
|
62
|
+
const next = [...slots];
|
|
63
|
+
if (uploadingSlot !== null) {
|
|
64
|
+
next[uploadingSlot] = urls[0] ?? null;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
let writeAt = next.findIndex((s) => s === null);
|
|
68
|
+
for (const url of urls) {
|
|
69
|
+
if (writeAt < 0 || writeAt >= maxImages)
|
|
70
|
+
break;
|
|
71
|
+
next[writeAt] = url ?? null;
|
|
72
|
+
writeAt = next.findIndex((s) => s === null);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
onChange(next.slice(0, maxImages));
|
|
76
|
+
setUploadingSlot(null);
|
|
77
|
+
e.target.value = '';
|
|
78
|
+
};
|
|
79
|
+
return (_jsxs("section", { children: [(header || counter) && (_jsxs("div", { className: cm.cn(cm.flex({ align: 'end', justify: 'between' }), cm.sp('mb', 6)), children: [header ?? _jsx("div", {}), counter ? (_jsx("span", { className: cm.cn(cm.textSize('xs'), cm.fontWeight('bold'), cm.textMuted, cm.uppercase, cm.trackingWide), children: counter })) : null] })), _jsxs("div", { className: cm.cn(cm.grid({ cols: 12, gap: 'md', responsive: false })), children: [_jsxs("div", { onClick: handleUploadAreaClick, className: cm.cn(cm.surfaceSecondary, cm.flex({ direction: 'col', align: 'center', justify: 'center' }), cm.cursorPointer), style: {
|
|
80
|
+
gridColumn: 'span 8 / span 8',
|
|
81
|
+
aspectRatio: '16 / 9',
|
|
82
|
+
borderRadius: SLOT_RADIUS,
|
|
83
|
+
border: '2px dashed var(--color-border)',
|
|
84
|
+
}, children: [_jsx("div", { className: cm.cn(cm.w(16), cm.h(16), cm.bgWhite, cm.roundedFull, cm.flex({ align: 'center', justify: 'center' }), cm.sp('mb', 4)), children: _jsx(Icon, { name: "upload", size: 28, className: cm.textPrimary }) }), _jsx("p", { className: cm.cn(cm.fontWeight('bold')), children: dropZoneTitle }), _jsx("p", { className: cm.cn(cm.textSize('sm'), cm.textMuted, cm.sp('mt', 1)), children: dropZoneHint })] }), _jsx("div", { className: cm.cn(cm.grid({ cols: 2, gap: 'md', responsive: false })), style: { gridColumn: 'span 4 / span 4' }, children: slots.map((url, i) => (_jsx("div", { onClick: () => handleSlotClick(i), className: cm.cn(cm.surfaceSecondary, cm.position('relative'), cm.cursorPointer), style: { aspectRatio: '1 / 1', borderRadius: SLOT_RADIUS, overflow: 'hidden' }, children: url ? (_jsxs(_Fragment, { children: [_jsx("img", { alt: "", src: url, className: cm.cn(cm.w('full'), cm.h('full')),
|
|
85
|
+
// object-fit + a steady dim are not in the ClassMap contract
|
|
86
|
+
// (Rule 5). The dim lets the always-visible delete glyph read.
|
|
87
|
+
style: { objectFit: 'cover', opacity: 0.6 } }), _jsx("div", { className: cm.cn(cm.position('absolute'), cm.inset0, cm.flex({ align: 'center', justify: 'center' })), children: _jsx(Icon, { name: "trash", size: 20 }) })] })) : (_jsx("div", { className: cm.cn(cm.w('full'), cm.h('full'), cm.flex({ align: 'center', justify: 'center' })), children: _jsx(Icon, { name: emptySlotIcon, size: 24, className: cm.textMuted }) })) }, i))) })] }), statusMessage ? (_jsx("p", { className: cm.cn(cm.sp('mt', 3), cm.textSize('xs'), cm.textMuted), "data-mol-id": "image-gallery-editor-status", children: statusMessage })) : null, _jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", style: { display: 'none' }, onChange: handleFileChange })] }));
|
|
88
|
+
}
|
|
89
|
+
export default ImageGalleryEditor;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@molecule/app-image-gallery-editor-react` — hero drop zone + side grid of
|
|
3
|
+
* thumbnail slots. Click an empty slot or the drop zone to upload; click a
|
|
4
|
+
* filled slot to remove (native `window.confirm`).
|
|
5
|
+
*
|
|
6
|
+
* Stateless about persistence — the consumer owns the slot array and handles
|
|
7
|
+
* uploads via `onPickFiles` (defaults to local object URLs for preview).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { useState } from 'react'
|
|
12
|
+
* import { ImageGalleryEditor } from '@molecule/app-image-gallery-editor-react'
|
|
13
|
+
*
|
|
14
|
+
* function GalleryEditor() {
|
|
15
|
+
* const [slots, setSlots] = useState<(string | null)[]>(Array(4).fill(null))
|
|
16
|
+
* return (
|
|
17
|
+
* <ImageGalleryEditor
|
|
18
|
+
* slots={slots}
|
|
19
|
+
* onChange={setSlots}
|
|
20
|
+
* onPickFiles={async (files) => {
|
|
21
|
+
* // upload each file, return persisted URLs (null keeps a slot empty)
|
|
22
|
+
* return Array.from(files).map((f) => URL.createObjectURL(f))
|
|
23
|
+
* }}
|
|
24
|
+
* header={<h3>Image Gallery</h3>}
|
|
25
|
+
* counter={`${slots.filter(Boolean).length} / 24 Photos`}
|
|
26
|
+
* />
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - Styling is 100% ClassMap (`getClassMap()` / `cm.*`) — the editor renders
|
|
33
|
+
* correctly out of the box under any bonded styling library and needs NO
|
|
34
|
+
* per-app Tailwind `@source` scan of this package. (It previously hardcoded
|
|
35
|
+
* raw Tailwind + Material-3 utility classes that no scaffold `@source`-scans,
|
|
36
|
+
* so even the `hidden` file input never generated a rule and rendered
|
|
37
|
+
* visible; the file input is now hidden with an inline `display:none`.) The
|
|
38
|
+
* few `style={...}` values (grid-column span, aspect ratio, corner radius,
|
|
39
|
+
* the dashed drop-zone border, `object-fit`, dim opacity, `display:none`)
|
|
40
|
+
* are the documented ClassMap-can't-express cases and use real theme tokens.
|
|
41
|
+
* - Icons are real SVG glyphs from `@molecule/app-ui-react`'s `<Icon>`
|
|
42
|
+
* (`upload`, `trash`, and the `emptySlotIcon` — a typed `IconName`) — NO
|
|
43
|
+
* Material Symbols font to load. Requires a bonded `@molecule/app-icons` set.
|
|
44
|
+
* - The filled-slot delete affordance is always visible (touch-friendly)
|
|
45
|
+
* rather than hover-revealed.
|
|
46
|
+
* - `dropZoneTitle` / `dropZoneHint` / `confirmRemoveMessage` default to
|
|
47
|
+
* English strings — pass translated values (`t('...')`) in localized apps.
|
|
48
|
+
* - `getClassMap()` requires a bonded ClassMap for the layout primitives.
|
|
49
|
+
*
|
|
50
|
+
* @module
|
|
51
|
+
*/
|
|
52
|
+
export * from './ImageGalleryEditor.js';
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,cAAc,yBAAyB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@molecule/app-image-gallery-editor-react` — hero drop zone + side grid of
|
|
3
|
+
* thumbnail slots. Click an empty slot or the drop zone to upload; click a
|
|
4
|
+
* filled slot to remove (native `window.confirm`).
|
|
5
|
+
*
|
|
6
|
+
* Stateless about persistence — the consumer owns the slot array and handles
|
|
7
|
+
* uploads via `onPickFiles` (defaults to local object URLs for preview).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { useState } from 'react'
|
|
12
|
+
* import { ImageGalleryEditor } from '@molecule/app-image-gallery-editor-react'
|
|
13
|
+
*
|
|
14
|
+
* function GalleryEditor() {
|
|
15
|
+
* const [slots, setSlots] = useState<(string | null)[]>(Array(4).fill(null))
|
|
16
|
+
* return (
|
|
17
|
+
* <ImageGalleryEditor
|
|
18
|
+
* slots={slots}
|
|
19
|
+
* onChange={setSlots}
|
|
20
|
+
* onPickFiles={async (files) => {
|
|
21
|
+
* // upload each file, return persisted URLs (null keeps a slot empty)
|
|
22
|
+
* return Array.from(files).map((f) => URL.createObjectURL(f))
|
|
23
|
+
* }}
|
|
24
|
+
* header={<h3>Image Gallery</h3>}
|
|
25
|
+
* counter={`${slots.filter(Boolean).length} / 24 Photos`}
|
|
26
|
+
* />
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - Styling is 100% ClassMap (`getClassMap()` / `cm.*`) — the editor renders
|
|
33
|
+
* correctly out of the box under any bonded styling library and needs NO
|
|
34
|
+
* per-app Tailwind `@source` scan of this package. (It previously hardcoded
|
|
35
|
+
* raw Tailwind + Material-3 utility classes that no scaffold `@source`-scans,
|
|
36
|
+
* so even the `hidden` file input never generated a rule and rendered
|
|
37
|
+
* visible; the file input is now hidden with an inline `display:none`.) The
|
|
38
|
+
* few `style={...}` values (grid-column span, aspect ratio, corner radius,
|
|
39
|
+
* the dashed drop-zone border, `object-fit`, dim opacity, `display:none`)
|
|
40
|
+
* are the documented ClassMap-can't-express cases and use real theme tokens.
|
|
41
|
+
* - Icons are real SVG glyphs from `@molecule/app-ui-react`'s `<Icon>`
|
|
42
|
+
* (`upload`, `trash`, and the `emptySlotIcon` — a typed `IconName`) — NO
|
|
43
|
+
* Material Symbols font to load. Requires a bonded `@molecule/app-icons` set.
|
|
44
|
+
* - The filled-slot delete affordance is always visible (touch-friendly)
|
|
45
|
+
* rather than hover-revealed.
|
|
46
|
+
* - `dropZoneTitle` / `dropZoneHint` / `confirmRemoveMessage` default to
|
|
47
|
+
* English strings — pass translated values (`t('...')`) in localized apps.
|
|
48
|
+
* - `getClassMap()` requires a bonded ClassMap for the layout primitives.
|
|
49
|
+
*
|
|
50
|
+
* @module
|
|
51
|
+
*/
|
|
52
|
+
export * from './ImageGalleryEditor.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/app-image-gallery-editor-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Editable image gallery: hero drop zone + grid of thumbnail slots with click-to-remove and progress label. Extracted from property-listing ListingEditorImageGallery.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"molecule",
|
|
24
|
+
"image-gallery",
|
|
25
|
+
"uploader",
|
|
26
|
+
"editor",
|
|
27
|
+
"react"
|
|
28
|
+
],
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@molecule/app-icons": "^1.0.0",
|
|
32
|
+
"@molecule/app-react": "^1.0.0",
|
|
33
|
+
"@molecule/app-ui": "^1.0.0",
|
|
34
|
+
"@molecule/app-ui-react": "^1.0.0",
|
|
35
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@molecule/app-icons": "1.0.0",
|
|
39
|
+
"@molecule/app-react": "1.0.0",
|
|
40
|
+
"@molecule/app-ui": "1.0.0",
|
|
41
|
+
"@molecule/app-ui-react": "1.0.0",
|
|
42
|
+
"@types/node": "26.1.2",
|
|
43
|
+
"@types/react": "19.2.17",
|
|
44
|
+
"@types/react-dom": "19.2.3",
|
|
45
|
+
"react": "19.2.8",
|
|
46
|
+
"react-dom": "19.2.8",
|
|
47
|
+
"typescript": "6.0.3",
|
|
48
|
+
"vitest": "4.1.10"
|
|
49
|
+
}
|
|
50
|
+
}
|