ain-ui 0.2.0 → 0.2.1
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/dist/ainui.js +3 -1
- package/dist/react.js +3 -3
- package/package.json +1 -1
package/dist/ainui.js
CHANGED
|
@@ -130,10 +130,11 @@ export function ainuiFolder(opts) {
|
|
|
130
130
|
if (env.canWrite)
|
|
131
131
|
toolbar.push("new_btn", "upload");
|
|
132
132
|
const body = opts.items.length ? (view === "grid" ? "grid" : "list") : "empty";
|
|
133
|
-
const rootChildren = ["crumbs", "toolbar", body, ...(opts.note ? ["note"] : [])];
|
|
133
|
+
const rootChildren = ["crumbs", "toolbar", "inventory", body, ...(opts.note ? ["note"] : [])];
|
|
134
134
|
const comps = [
|
|
135
135
|
column("root", rootChildren),
|
|
136
136
|
breadcrumbs(),
|
|
137
|
+
text("inventory", { path: "/inventory" }, "caption"),
|
|
137
138
|
row("toolbar", toolbar, { align: "center" }),
|
|
138
139
|
{ id: "search_field", component: "TextField", label: "Search file names", value: { path: "/query" }, weight: 1 },
|
|
139
140
|
button("search_btn", "search_label", "aindrive.search", { drive_id: DRIVE, query: { path: "/query" }, path: { path: "/path" } }, { variant: "primary" }),
|
|
@@ -175,6 +176,7 @@ export function ainuiFolder(opts) {
|
|
|
175
176
|
query: opts.query ?? "",
|
|
176
177
|
new_name: "",
|
|
177
178
|
items: opts.items,
|
|
179
|
+
inventory: `${opts.items.filter(i => !i.is_dir).length} files · ${opts.items.filter(i => i.is_dir).length} folders · ${opts.items.filter(i => !i.is_dir && i.mime.startsWith("image/")).length} photos (${opts.query ? "search results" : "this folder only"})`,
|
|
178
180
|
});
|
|
179
181
|
}
|
|
180
182
|
export function ainuiFile(opts) {
|
package/dist/react.js
CHANGED
|
@@ -42,7 +42,7 @@ const Grid = createBinderlessComponentImplementation(api("Grid", { children: Com
|
|
|
42
42
|
const p = context.componentModel.properties;
|
|
43
43
|
const spec = p.children;
|
|
44
44
|
const rows = useValue(context, !Array.isArray(spec) && spec ? { path: spec.path } : []);
|
|
45
|
-
return _jsx("div", { style: { display: "grid", gridTemplateColumns: `repeat(auto-
|
|
45
|
+
return _jsx("div", { className: "ainui-grid", style: { display: "grid", width: "100%", minWidth: 0, gridTemplateColumns: `repeat(auto-fill,minmax(min(100%,${Math.max(64, Number(p.minItemWidth) || 128)}px),1fr))`, gap: Number(p.gap) || 8 }, children: Array.isArray(spec) ? spec.map((id) => _jsx(React.Fragment, { children: buildChild(id) }, id)) :
|
|
46
46
|
(Array.isArray(rows) ? rows : []).map((_, i) => _jsx(React.Fragment, { children: buildChild(spec.componentId, `${spec.path}/${i}`) }, i)) });
|
|
47
47
|
});
|
|
48
48
|
const Tile = createBinderlessComponentImplementation(api("Tile", { media: dynamic, label: dynamic, caption: dynamic, kind: dynamic, action: CommonSchemas.Action.optional() }), ({ context }) => {
|
|
@@ -55,8 +55,8 @@ const Tile = createBinderlessComponentImplementation(api("Tile", { media: dynami
|
|
|
55
55
|
const src = urlOf(media, resolver);
|
|
56
56
|
const [failed, setFailed] = useState(false);
|
|
57
57
|
useEffect(() => setFailed(false), [src]);
|
|
58
|
-
return _jsxs("button", { style: { ...box, ...button, textAlign: "left" }, onClick: () => void fire(context), children: [src && !failed ? _jsx("img", { src: src, alt: "", loading: "lazy", onError: () => setFailed(true), style: { width: "100%",
|
|
59
|
-
|
|
58
|
+
return _jsxs("button", { className: "ainui-tile", style: { ...box, ...button, width: "100%", height: "100%", textAlign: "left", overflow: "hidden" }, onClick: () => void fire(context), children: [_jsx("span", { className: "ainui-tile-media", style: { display: "flex", flex: "0 0 auto", alignItems: "center", justifyContent: "center", width: "100%", aspectRatio: "1", overflow: "hidden", borderRadius: 8, background: "#8882" }, children: src && !failed ? _jsx("img", { src: src, alt: "", loading: "lazy", onError: () => setFailed(true), style: { width: "100%", height: "100%", objectFit: "cover" } }) :
|
|
59
|
+
_jsx("span", { style: { fontSize: 40 }, children: kind === "folder" ? "📁" : "📄" }) }), _jsx("span", { className: "ainui-tile-name", title: label, style: { display: "-webkit-box", WebkitBoxOrient: "vertical", WebkitLineClamp: 2, overflow: "hidden", overflowWrap: "anywhere", lineHeight: "1.35em", height: "2.7em" }, children: label }), _jsx("small", { style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: "100%" }, children: caption })] });
|
|
60
60
|
});
|
|
61
61
|
const FileView = createBinderlessComponentImplementation(api("FileView", { src: dynamic, name: dynamic, mime: dynamic, size: dynamic }), ({ context }) => {
|
|
62
62
|
const p = context.componentModel.properties;
|