miral 0.0.4 → 0.0.5
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/README.md +67 -34
- package/dist/Assets.js +4 -0
- package/dist/Controls.js +55 -0
- package/dist/Nav.js +17 -0
- package/dist/Spinner.js +7 -0
- package/dist/Toolbar.js +139 -0
- package/dist/Viewer.js +364 -0
- package/dist/cli.js +179 -0
- package/dist/icons.js +12 -0
- package/{src → dist}/theme.css +1 -1
- package/package.json +14 -9
- package/src/Assets.tsx +0 -41
- package/src/Controls.tsx +0 -147
- package/src/Nav.tsx +0 -99
- package/src/Spinner.tsx +0 -15
- package/src/Toolbar.tsx +0 -271
- package/src/Viewer.tsx +0 -643
- package/src/cli.js +0 -206
- package/src/icons.tsx +0 -31
package/README.md
CHANGED
|
@@ -1,55 +1,88 @@
|
|
|
1
1
|
# Miral
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Miral is a lightweight UI kit explorer for React and Preact.
|
|
4
|
+
It’s opinionated, TypeScript-first, and ESM-first.
|
|
5
|
+
Built on Vite, React, Preact, and Tailwind CSS.
|
|
6
|
+
|
|
7
|
+
TLDR: Like storybook, but simpler.
|
|
8
|
+
|
|
9
|
+
## Why Miral
|
|
10
|
+
|
|
11
|
+
Working on a component should be simpler than setting up the tools around it.
|
|
12
|
+
Miral grew out of frustration with Storybook’s complex toolchain, layers of configuration, tree of aging dependencies,
|
|
13
|
+
endless stream of warnings, bloated UI full of features rarely used, and addons to learn and configure.
|
|
14
|
+
As the ecosystem moved on, keeping Storybook working with newer TypeScript versions and evolving ESM support took more
|
|
15
|
+
effort than it should have.
|
|
16
|
+
Miral takes a simpler approach. TypeScript first, ESM first, and one opinionated setup built on Vite, React or Preact,
|
|
17
|
+
Zod, and Tailwind CSS.
|
|
18
|
+
Modern stack, minimal setup. Spend your time building components instead of maintaining configuration files and chasing
|
|
19
|
+
outdated dependencies.
|
|
5
20
|
|
|
6
21
|
## Usage
|
|
7
22
|
|
|
8
23
|
```sh
|
|
9
|
-
npx miral
|
|
10
|
-
npx miral build
|
|
24
|
+
npx miral dev --port 9000
|
|
25
|
+
npx miral build && npx -y fotone --port 9000 ./dist
|
|
11
26
|
```
|
|
12
27
|
|
|
13
|
-
Open `http://localhost:9000` for development. Serve the generated `dist/` directory with any static HTTP server.
|
|
14
|
-
URLs are relative, so the catalog can also run under a subdirectory.
|
|
15
|
-
`--
|
|
28
|
+
Open `http://localhost:9000` for development. Serve the generated `dist/` directory with any static HTTP server.
|
|
29
|
+
Asset URLs are relative, so the catalog can also run under a subdirectory.
|
|
30
|
+
Use `--port` for a different development port or `--outDir` for a different build directory.
|
|
31
|
+
Both commands accept an optional directory to scan.
|
|
16
32
|
|
|
17
|
-
##
|
|
33
|
+
## Add components
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
Miral reads the named export `PropsSchema` from the matching component file. Give the schema any local name and
|
|
36
|
+
export it under that name with `as PropsSchema`.
|
|
20
37
|
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
```tsx
|
|
39
|
+
// Button.tsx
|
|
40
|
+
import { z } from "zod";
|
|
41
|
+
|
|
42
|
+
export const PropsSchema = z.object({
|
|
43
|
+
label: z.string().default("Save"),
|
|
44
|
+
disabled: z.boolean().default(false),
|
|
45
|
+
});
|
|
46
|
+
export type Props = z.input<typeof PropsSchema>;
|
|
47
|
+
|
|
48
|
+
export const Button = (props: Props) => {
|
|
49
|
+
const { label, disabled } = PropsSchema.parse(props);
|
|
50
|
+
return <button type="button" disabled={disabled}>{label}</button>;
|
|
27
51
|
};
|
|
28
52
|
```
|
|
29
53
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
```tsx
|
|
55
|
+
// Button.mira.tsx
|
|
56
|
+
import { Button } from "./Button";
|
|
33
57
|
|
|
34
|
-
|
|
58
|
+
export const section = "Controls";
|
|
59
|
+
export default Button;
|
|
60
|
+
export const Preview = () => <Button/>;
|
|
61
|
+
export const Disabled = () => <Button disabled/>;
|
|
62
|
+
```
|
|
35
63
|
|
|
36
|
-
|
|
64
|
+
- The default export opens in `Playground` with the schema defaults. Use the generated controls to edit the props.
|
|
65
|
+
- `Preview` opens when you select **Button**. Other capitalized component exports, such as `Disabled`, appear as
|
|
66
|
+
examples.
|
|
67
|
+
- `section` must be a string literal. Omit it to use `Elements`.
|
|
37
68
|
|
|
38
|
-
|
|
69
|
+
## Configuration reference
|
|
39
70
|
|
|
40
|
-
|
|
41
|
-
import * as z from "zod/mini";
|
|
71
|
+
Place an optional `miral.config.ts` in the directory Miral scans. All options are optional.
|
|
42
72
|
|
|
43
|
-
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
```ts
|
|
74
|
+
export default {
|
|
75
|
+
title: "My UI kit",
|
|
76
|
+
assetsDir: "./assets",
|
|
77
|
+
order: ["Controls", "Components"],
|
|
78
|
+
componentOrder: ["Select", "Input"],
|
|
79
|
+
};
|
|
48
80
|
```
|
|
49
81
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
82
|
+
| Option | Type | Behavior |
|
|
83
|
+
|------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
84
|
+
| `title` | `string` | Sets the sidebar heading and browser tab title, for example `My UI kit \| Miral`. If empty or omitted, the sidebar has no heading and the tab shows `Miral`. |
|
|
85
|
+
| `assetsDir` | String literal | Path relative to `miral.config.ts`. Adds an Assets entry at the end of the sidebar. Files in this directory and its subdirectories appear by filename, with previews for images. |
|
|
86
|
+
| `order` | `string[]` | Lists sidebar sections in display order. Remaining sections follow alphabetically. |
|
|
87
|
+
| `componentOrder` | `string[]` | Lists components in display order within each section. Remaining components follow alphabetically. |
|
|
88
|
+
| `stylesheet` | `string` | Sets the preview iframe stylesheet. Import the CSS file with Vite’s `?url` suffix and pass the URL here. |
|
package/dist/Assets.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const Assets = ({ className, files }) => (_jsxs("section", { className: className, children: [_jsx("h1", { children: "Assets" }), !Object.keys(files).length && _jsx("p", { children: "No assets found." }), _jsx("div", { className: "miral:grid miral:grid-cols-[repeat(auto-fill,minmax(min(100%,12rem),1fr))] miral:gap-4", children: Object.entries(files)
|
|
3
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
4
|
+
.map(([path, url]) => (_jsxs("figure", { className: "miral:grid miral:content-start miral:gap-1.5 miral:m-0", children: [_jsx("figcaption", { className: "miral:text-left miral:wrap-anywhere", children: _jsx("a", { href: url, download: path.split("/").at(-1), children: path.split("/").at(-1) }) }), _jsx("div", { className: "miral:grid miral:place-items-center miral:min-h-32 miral:p-4 miral:border miral:border-solid miral:border-edge miral:rounded-lg", children: /\.(avif|bmp|gif|ico|jpe?g|png|svg|webp)$/i.test(path) ? (_jsx("img", { className: "miral:w-full miral:h-32 miral:object-contain", src: url, alt: "", loading: "lazy" })) : (_jsx("a", { href: url, download: path.split("/").at(-1), children: "Download" })) })] }, path))) })] }));
|
package/dist/Controls.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const Controls = ({ schema, values, onChange }) => {
|
|
3
|
+
return (_jsxs("section", { className: "miral:border-t miral:border-edge miral:text-sm/[1.5] miral:font-normal miral:group-data-isolated/shell:hidden", "aria-labelledby": "preview-props-heading", children: [_jsx("h2", { id: "preview-props-heading", className: "miral:m-0 miral:px-4 miral:py-2 miral:text-[length:inherit] miral:font-semibold", children: "Props" }), _jsx("form", { className: "miral:max-h-[30dvh] miral:overflow-auto miral:px-4 miral:pb-2", onSubmit: preventSubmit, children: Object.entries(schema.shape).map(([name, field]) => {
|
|
4
|
+
let inner = field._zod.def;
|
|
5
|
+
let optional = false;
|
|
6
|
+
while ((inner.type === "optional" || inner.type === "default") &&
|
|
7
|
+
"innerType" in inner) {
|
|
8
|
+
optional ||= inner.type === "optional";
|
|
9
|
+
inner = inner.innerType._zod.def;
|
|
10
|
+
}
|
|
11
|
+
let options = [];
|
|
12
|
+
if ("entries" in inner)
|
|
13
|
+
options = Object.values(inner.entries);
|
|
14
|
+
else if ("values" in inner)
|
|
15
|
+
options = inner.values;
|
|
16
|
+
const value = values[name];
|
|
17
|
+
const handleChange = (event) => {
|
|
18
|
+
const text = event.currentTarget.value;
|
|
19
|
+
const next = { ...values };
|
|
20
|
+
if (event.currentTarget instanceof HTMLInputElement &&
|
|
21
|
+
event.currentTarget.type === "checkbox")
|
|
22
|
+
next[name] = event.currentTarget.checked;
|
|
23
|
+
else if (inner.type === "boolean")
|
|
24
|
+
next[name] = text === "true";
|
|
25
|
+
else if (inner.type === "number")
|
|
26
|
+
next[name] = Number(text);
|
|
27
|
+
else
|
|
28
|
+
next[name] = text;
|
|
29
|
+
if (text === "" && optional)
|
|
30
|
+
delete next[name];
|
|
31
|
+
const parsed = schema.safeParse(next);
|
|
32
|
+
if (parsed.success)
|
|
33
|
+
onChange(parsed.data);
|
|
34
|
+
};
|
|
35
|
+
if (inner.type === "boolean" && optional) {
|
|
36
|
+
return (_jsxs("div", { className: "preview-prop-row", role: "radiogroup", "aria-label": name, children: [_jsx("span", { "aria-hidden": "true", children: name }), _jsx("div", { className: "miral:flex miral:w-fit miral:border miral:border-solid miral:border-edge miral:rounded-sm", children: [
|
|
37
|
+
["", "Default"],
|
|
38
|
+
["true", "On"],
|
|
39
|
+
["false", "Off"],
|
|
40
|
+
].map(([choice, label]) => (_jsxs("label", { className: "miral:relative miral:py-[0.2rem] miral:px-2 miral:cursor-pointer miral:has-checked:text-paper miral:has-checked:bg-ink miral:focus-within:outline-2 miral:focus-within:outline-solid miral:focus-within:outline-ink miral:focus-within:outline-offset-2", children: [_jsx("input", { className: "miral:absolute miral:inset-0 miral:m-0 miral:opacity-0 miral:cursor-pointer", type: "radio", name: name, value: choice, checked: String(value ?? "") === choice, onChange: handleChange }), label] }, choice))) })] }, name));
|
|
41
|
+
}
|
|
42
|
+
if (inner.type === "boolean") {
|
|
43
|
+
return (_jsxs("label", { className: "preview-prop-row", children: [name, _jsx("input", { className: "miral:justify-self-start miral:accent-ink", type: "checkbox", checked: value === true, onChange: handleChange })] }, name));
|
|
44
|
+
}
|
|
45
|
+
if (options.length) {
|
|
46
|
+
return (_jsxs("label", { className: "preview-prop-row", children: [name, _jsxs("select", { value: String(value ?? ""), onChange: handleChange, children: [optional && _jsx("option", { value: "", children: "Default" }), options.map((item) => (_jsx("option", { children: item }, item)))] })] }, name));
|
|
47
|
+
}
|
|
48
|
+
if (inner.type !== "string" && inner.type !== "number")
|
|
49
|
+
return null;
|
|
50
|
+
return (_jsxs("label", { className: "preview-prop-row", children: [name, _jsx("input", { type: inner.type === "number" ? "number" : "text", value: String(value ?? ""), onChange: handleChange })] }, name));
|
|
51
|
+
}) })] }));
|
|
52
|
+
};
|
|
53
|
+
function preventSubmit(event) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
}
|
package/dist/Nav.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const Nav = ({ title, className, entries, activePath, assetsPath, names, selected, theme, layout, isolated, link, onLinkClick, }) => (_jsxs("nav", { className: [
|
|
3
|
+
"miral:overflow-auto miral:wrap-anywhere miral:py-[1.375rem] miral:px-3 miral:border-e miral:border-divider miral:[font-family:Inter,system-ui,sans-serif] miral:transition-opacity miral:duration-200 miral:ease-out miral:group-data-isolated/shell:opacity-0 miral:motion-reduce:transition-none miral:[@media(max-width:600px)]:max-h-[25dvh]",
|
|
4
|
+
className,
|
|
5
|
+
]
|
|
6
|
+
.filter(Boolean)
|
|
7
|
+
.join(" "), inert: isolated, "aria-label": "Component catalog", children: [!!title && (_jsx("h1", { className: "miral:mx-2 miral:mt-0 miral:mb-[1.625rem] miral:text-2xl/[1.1] miral:font-bold miral:tracking-[-0.045em]", children: title })), Array.from(new Set(entries.map((item) => item.section))).map((section) => (_jsxs("section", { className: "miral:[section+&]:mt-[1.375rem]", children: [_jsx("h2", { className: "miral:mx-2 miral:mt-0 miral:mb-1.5 miral:text-muted miral:text-[0.71875rem]/[1.4] miral:font-[650] miral:tracking-[0.075em] miral:uppercase", children: section }), entries
|
|
8
|
+
.filter((item) => item.section === section)
|
|
9
|
+
.map((item) => (_jsxs("div", { children: [_jsx("a", { "aria-current": item.path === activePath && selected === "Preview"
|
|
10
|
+
? "page"
|
|
11
|
+
: undefined, href: link({ component: item.path, theme, layout }), onClick: onLinkClick, children: item.name }), item.path === activePath &&
|
|
12
|
+
names.map((name) => (_jsx("a", { className: "miral:ms-2 miral:ps-3.5 miral:rounded-l-none", onClick: onLinkClick, "aria-current": selected === name ? "page" : undefined, href: link({
|
|
13
|
+
component: item.path,
|
|
14
|
+
example: name,
|
|
15
|
+
theme,
|
|
16
|
+
layout,
|
|
17
|
+
}), children: name.replace(/([a-z])([A-Z])/g, "$1 $2") }, name)))] }, item.path)))] }, section))), !!assetsPath && (_jsx("a", { className: "miral:mt-4", href: link({ component: assetsPath, theme, layout }), "aria-current": activePath === assetsPath ? "page" : undefined, onClick: onLinkClick, children: "Assets" }))] }));
|
package/dist/Spinner.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const Spinner = ({ className }) => (_jsx("span", { className: [
|
|
3
|
+
"miral:fixed miral:inset-0 miral:z-2 miral:m-auto miral:inline-block miral:box-border miral:size-[1em] miral:pointer-events-none miral:rounded-full miral:border-2 miral:border-solid miral:border-current miral:border-r-transparent miral:text-ink miral:motion-safe:animate-spin miral:motion-safe:[animation-duration:700ms]",
|
|
4
|
+
className,
|
|
5
|
+
]
|
|
6
|
+
.filter(Boolean)
|
|
7
|
+
.join(" "), "data-miral-spinner": true, role: "status", "aria-label": "Loading" }));
|
package/dist/Toolbar.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Icon } from "./icons.js";
|
|
4
|
+
const storageKey = "miral.preview:" + location.pathname + ":toolbar";
|
|
5
|
+
const guideKey = storageKey + ":guide-seen";
|
|
6
|
+
function read(key) {
|
|
7
|
+
try {
|
|
8
|
+
const value = localStorage.getItem(key);
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function save(key, value) {
|
|
16
|
+
try {
|
|
17
|
+
localStorage.setItem(key, value);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
/* Storage can be disabled. */
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function readPosition() {
|
|
24
|
+
try {
|
|
25
|
+
const value = JSON.parse(read(storageKey) ?? "null");
|
|
26
|
+
if (value && Number.isFinite(value.x) && Number.isFinite(value.y)) {
|
|
27
|
+
const result = { x: value.x, y: value.y };
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
/* Ignore invalid saved coordinates. */
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function constrain(position, element) {
|
|
37
|
+
const x = Math.max(0, Math.min(position.x, document.documentElement.clientWidth - element.offsetWidth - 4));
|
|
38
|
+
const y = Math.max(0, Math.min(position.y, window.innerHeight - element.offsetHeight - 4));
|
|
39
|
+
return { x, y };
|
|
40
|
+
}
|
|
41
|
+
const shortcuts = [
|
|
42
|
+
["Cycle layout", "Shift + L"],
|
|
43
|
+
["Switch theme", "Shift + T"],
|
|
44
|
+
["Toggle full screen", "Shift + F"],
|
|
45
|
+
["Exit full screen", "Esc"],
|
|
46
|
+
["Show or hide toolbar", "Shift + C"],
|
|
47
|
+
];
|
|
48
|
+
export const Toolbar = ({ children, hidden, isolated, className, }) => {
|
|
49
|
+
const dock = React.useRef(null);
|
|
50
|
+
const drag = React.useRef(null);
|
|
51
|
+
const [position, setPosition] = React.useState(readPosition);
|
|
52
|
+
const [guide, setGuide] = React.useState(() => read(guideKey) !== "1");
|
|
53
|
+
const [dragging, setDragging] = React.useState(false);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
if (guide && !hidden && !isolated)
|
|
56
|
+
save(guideKey, "1");
|
|
57
|
+
}, [guide, hidden, isolated]);
|
|
58
|
+
React.useLayoutEffect(() => {
|
|
59
|
+
const element = dock.current;
|
|
60
|
+
if (!element)
|
|
61
|
+
return;
|
|
62
|
+
const fit = () => setPosition((current) => {
|
|
63
|
+
if (!current)
|
|
64
|
+
return current;
|
|
65
|
+
const next = constrain(current, element);
|
|
66
|
+
if (next.x === current.x && next.y === current.y)
|
|
67
|
+
return current;
|
|
68
|
+
return next;
|
|
69
|
+
});
|
|
70
|
+
fit();
|
|
71
|
+
const observer = new ResizeObserver(fit);
|
|
72
|
+
observer.observe(element);
|
|
73
|
+
window.addEventListener("resize", fit);
|
|
74
|
+
return () => {
|
|
75
|
+
observer.disconnect();
|
|
76
|
+
window.removeEventListener("resize", fit);
|
|
77
|
+
};
|
|
78
|
+
}, []);
|
|
79
|
+
const handlePointerDown = (event) => {
|
|
80
|
+
if (event.button !== 0 || !event.isPrimary || !dock.current)
|
|
81
|
+
return;
|
|
82
|
+
const rect = dock.current.getBoundingClientRect();
|
|
83
|
+
drag.current = {
|
|
84
|
+
x: event.clientX - rect.left,
|
|
85
|
+
y: event.clientY - rect.top,
|
|
86
|
+
};
|
|
87
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
88
|
+
setDragging(true);
|
|
89
|
+
};
|
|
90
|
+
const handlePointerMove = (event) => {
|
|
91
|
+
if (!drag.current ||
|
|
92
|
+
!dock.current ||
|
|
93
|
+
!event.currentTarget.hasPointerCapture(event.pointerId))
|
|
94
|
+
return;
|
|
95
|
+
const next = constrain({ x: event.clientX - drag.current.x, y: event.clientY - drag.current.y }, dock.current);
|
|
96
|
+
setPosition(next);
|
|
97
|
+
};
|
|
98
|
+
const handlePointerUp = (event) => {
|
|
99
|
+
if (!drag.current ||
|
|
100
|
+
!dock.current ||
|
|
101
|
+
!event.currentTarget.hasPointerCapture(event.pointerId))
|
|
102
|
+
return;
|
|
103
|
+
const next = constrain({ x: event.clientX - drag.current.x, y: event.clientY - drag.current.y }, dock.current);
|
|
104
|
+
setPosition(next);
|
|
105
|
+
save(storageKey, JSON.stringify(next));
|
|
106
|
+
};
|
|
107
|
+
const handleLostPointerCapture = () => {
|
|
108
|
+
drag.current = null;
|
|
109
|
+
setDragging(false);
|
|
110
|
+
};
|
|
111
|
+
const handleGripKeyDown = (event) => {
|
|
112
|
+
if (!dock.current ||
|
|
113
|
+
!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key))
|
|
114
|
+
return;
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
const rect = dock.current.getBoundingClientRect();
|
|
117
|
+
const next = constrain({
|
|
118
|
+
x: rect.left +
|
|
119
|
+
16 *
|
|
120
|
+
(Number(event.key === "ArrowRight") -
|
|
121
|
+
Number(event.key === "ArrowLeft")),
|
|
122
|
+
y: rect.top +
|
|
123
|
+
16 *
|
|
124
|
+
(Number(event.key === "ArrowDown") -
|
|
125
|
+
Number(event.key === "ArrowUp")),
|
|
126
|
+
}, dock.current);
|
|
127
|
+
setPosition(next);
|
|
128
|
+
save(storageKey, JSON.stringify(next));
|
|
129
|
+
};
|
|
130
|
+
const handleDismissClick = () => setGuide(false);
|
|
131
|
+
return (_jsxs("div", { ref: dock, className: [
|
|
132
|
+
"miral:group/dock miral:fixed miral:top-3 miral:right-3 miral:w-max miral:max-w-screen miral:text-ink miral:text-sm/[1.5] miral:font-normal miral:transition-[opacity,transform,translate,scale] miral:duration-[160ms] miral:ease-out miral:data-hidden:opacity-0 miral:data-hidden:-translate-y-1 miral:data-hidden:scale-[0.98] miral:data-hidden:pointer-events-none miral:motion-reduce:transition-none",
|
|
133
|
+
className,
|
|
134
|
+
]
|
|
135
|
+
.filter(Boolean)
|
|
136
|
+
.join(" "), "data-hidden": hidden || undefined, "data-dragging": dragging || undefined, inert: hidden, style: position
|
|
137
|
+
? { left: position.x, top: position.y, right: "auto" }
|
|
138
|
+
: undefined, children: [_jsxs("div", { className: "preview-toolbar miral:w-max miral:ms-auto miral:flex miral:items-center miral:p-[0.2rem] miral:border miral:border-solid miral:border-edge miral:rounded-[0.65rem] miral:bg-paper miral:text-ink", role: "group", "aria-label": "Preview settings", children: [_jsx("button", { type: "button", className: "miral:cursor-grab miral:touch-none miral:select-none miral:group-data-dragging/dock:cursor-grabbing", title: "Move toolbar \u00B7 Drag or use arrow keys", "aria-label": "Move toolbar", onKeyDown: handleGripKeyDown, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onLostPointerCapture: handleLostPointerCapture, children: _jsx(Icon, { name: "grip" }) }), children] }), guide && (_jsxs("aside", { className: "miral:mt-[0.35rem] miral:p-[0.65rem] miral:border miral:border-solid miral:border-edge miral:rounded-[0.65rem] miral:bg-paper miral:max-h-[calc(100dvh-3.5rem)] miral:overflow-auto", "aria-label": "Preview shortcuts", children: [_jsxs("div", { className: "miral:flex miral:gap-[0.35rem] miral:justify-between", children: [_jsx("strong", { className: "miral:font-[650]", children: "Preview shortcuts" }), _jsx("button", { type: "button", className: "miral:cursor-pointer", "aria-label": "Dismiss shortcut guide", onClick: handleDismissClick, children: _jsx(Icon, { name: "close" }) })] }), _jsx("p", { className: "miral:m-0 miral:mt-1", children: "Drag the handle to move the toolbar." }), _jsx("dl", { className: "miral:m-0 miral:mt-2 miral:flex miral:flex-col miral:gap-[0.35rem] miral:justify-between", children: shortcuts.map(([label, keys]) => (_jsxs("div", { className: "miral:flex miral:gap-[0.35rem] miral:justify-between", children: [_jsx("dt", { children: label }), _jsx("dd", { className: "miral:m-0", children: _jsx("kbd", { className: "miral:[font:inherit]", children: keys }) })] }, keys))) })] }))] }));
|
|
139
|
+
};
|