@classic-homes/theme-react 0.3.1 → 0.4.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/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +22 -5
- package/dist/index.mjs +22 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -483,15 +483,19 @@ interface StudioCanvasItemProps {
|
|
|
483
483
|
insertLabel?: string;
|
|
484
484
|
/** Marks the item as having problems (dashed amber outline) */
|
|
485
485
|
invalid?: boolean;
|
|
486
|
+
/** Where the "+" sits: centred on the item's bottom edge, or in the left gutter beside it */
|
|
487
|
+
insertPlacement?: 'center' | 'gutter';
|
|
486
488
|
className?: string;
|
|
487
489
|
}
|
|
488
490
|
/**
|
|
489
491
|
* StudioCanvasItem - one selectable part of the canvas. Clicking anywhere in
|
|
490
492
|
* it, or tabbing into it, selects it; the content stays live. The selected
|
|
491
493
|
* item gets a ring and its `toolbar`; `onInsert` adds a "+" below it. On
|
|
492
|
-
* phones picking an item opens the inspector sheet.
|
|
494
|
+
* phones picking an item opens the inspector sheet. Picking it from elsewhere
|
|
495
|
+
* scrolls it into view; picking it on the canvas does not. `insertPlacement=
|
|
496
|
+
* "gutter"` puts the "+" in the left margin, clear of text edited in place.
|
|
493
497
|
*/
|
|
494
|
-
declare function StudioCanvasItem({ children, selected, onSelect, label, toolbar, onInsert, insertLabel, invalid, className, }: StudioCanvasItemProps): React$1.JSX.Element;
|
|
498
|
+
declare function StudioCanvasItem({ children, selected, onSelect, label, toolbar, onInsert, insertLabel, invalid, insertPlacement, className, }: StudioCanvasItemProps): React$1.JSX.Element;
|
|
495
499
|
|
|
496
500
|
interface StudioInspectorTab {
|
|
497
501
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -483,15 +483,19 @@ interface StudioCanvasItemProps {
|
|
|
483
483
|
insertLabel?: string;
|
|
484
484
|
/** Marks the item as having problems (dashed amber outline) */
|
|
485
485
|
invalid?: boolean;
|
|
486
|
+
/** Where the "+" sits: centred on the item's bottom edge, or in the left gutter beside it */
|
|
487
|
+
insertPlacement?: 'center' | 'gutter';
|
|
486
488
|
className?: string;
|
|
487
489
|
}
|
|
488
490
|
/**
|
|
489
491
|
* StudioCanvasItem - one selectable part of the canvas. Clicking anywhere in
|
|
490
492
|
* it, or tabbing into it, selects it; the content stays live. The selected
|
|
491
493
|
* item gets a ring and its `toolbar`; `onInsert` adds a "+" below it. On
|
|
492
|
-
* phones picking an item opens the inspector sheet.
|
|
494
|
+
* phones picking an item opens the inspector sheet. Picking it from elsewhere
|
|
495
|
+
* scrolls it into view; picking it on the canvas does not. `insertPlacement=
|
|
496
|
+
* "gutter"` puts the "+" in the left margin, clear of text edited in place.
|
|
493
497
|
*/
|
|
494
|
-
declare function StudioCanvasItem({ children, selected, onSelect, label, toolbar, onInsert, insertLabel, invalid, className, }: StudioCanvasItemProps): React$1.JSX.Element;
|
|
498
|
+
declare function StudioCanvasItem({ children, selected, onSelect, label, toolbar, onInsert, insertLabel, invalid, insertPlacement, className, }: StudioCanvasItemProps): React$1.JSX.Element;
|
|
495
499
|
|
|
496
500
|
interface StudioInspectorTab {
|
|
497
501
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -1718,10 +1718,12 @@ function StudioCanvasItem({
|
|
|
1718
1718
|
onInsert,
|
|
1719
1719
|
insertLabel,
|
|
1720
1720
|
invalid = false,
|
|
1721
|
+
insertPlacement = "center",
|
|
1721
1722
|
className
|
|
1722
1723
|
}) {
|
|
1723
1724
|
const studio = useStudio();
|
|
1724
1725
|
const ref = React19.useRef(null);
|
|
1726
|
+
const pickedHere = React19.useRef(false);
|
|
1725
1727
|
const inQuickAction = (target) => !!target?.closest?.("[data-studio-quick-action]");
|
|
1726
1728
|
const select = (reveal) => {
|
|
1727
1729
|
if (!selected) onSelect?.();
|
|
@@ -1729,7 +1731,9 @@ function StudioCanvasItem({
|
|
|
1729
1731
|
};
|
|
1730
1732
|
React19.useEffect(() => {
|
|
1731
1733
|
const el = ref.current;
|
|
1732
|
-
|
|
1734
|
+
const here = pickedHere.current;
|
|
1735
|
+
pickedHere.current = false;
|
|
1736
|
+
if (!selected || !el || here || el.contains(document.activeElement)) return;
|
|
1733
1737
|
const reduce = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
1734
1738
|
el.scrollIntoView?.({ block: "nearest", behavior: reduce ? "auto" : "smooth" });
|
|
1735
1739
|
}, [selected]);
|
|
@@ -1749,9 +1753,14 @@ function StudioCanvasItem({
|
|
|
1749
1753
|
invalid && "-outline-offset-2 outline-dashed outline-2 outline-warning/70",
|
|
1750
1754
|
className
|
|
1751
1755
|
),
|
|
1756
|
+
onPointerDownCapture: (e) => {
|
|
1757
|
+
if (!selected && !inQuickAction(e.target)) pickedHere.current = true;
|
|
1758
|
+
},
|
|
1752
1759
|
onClickCapture: (e) => select(!inQuickAction(e.target)),
|
|
1753
1760
|
onFocus: (e) => {
|
|
1754
|
-
if (
|
|
1761
|
+
if (inQuickAction(e.target)) return;
|
|
1762
|
+
if (!selected) pickedHere.current = true;
|
|
1763
|
+
select(false);
|
|
1755
1764
|
},
|
|
1756
1765
|
children: [
|
|
1757
1766
|
!selected && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
@@ -1782,8 +1791,9 @@ function StudioCanvasItem({
|
|
|
1782
1791
|
"aria-label": insertLabel ?? `Add below ${label}`,
|
|
1783
1792
|
title: insertLabel ?? "Add below",
|
|
1784
1793
|
className: cn(
|
|
1785
|
-
"absolute
|
|
1786
|
-
|
|
1794
|
+
"absolute top-0 z-10 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 shadow-sm hover:border-primary hover:text-primary focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/item:opacity-100 [@media(hover:none)]:opacity-100",
|
|
1795
|
+
insertPlacement === "gutter" ? "right-full mr-1.5 group-focus-within/item:opacity-100" : "left-1/2 -translate-x-1/2",
|
|
1796
|
+
selected && insertPlacement === "center" && "opacity-100"
|
|
1787
1797
|
),
|
|
1788
1798
|
onClick: (e) => {
|
|
1789
1799
|
e.stopPropagation();
|
|
@@ -2148,10 +2158,13 @@ function InsertPalette({
|
|
|
2148
2158
|
renderThumbnail
|
|
2149
2159
|
}) {
|
|
2150
2160
|
const [query, setQuery] = React22.useState("");
|
|
2161
|
+
const picked = React22.useRef(false);
|
|
2151
2162
|
const listRef = React22.useRef(null);
|
|
2152
2163
|
const searchRef = React22.useRef(null);
|
|
2153
2164
|
React22.useEffect(() => {
|
|
2154
|
-
if (open)
|
|
2165
|
+
if (!open) return;
|
|
2166
|
+
setQuery("");
|
|
2167
|
+
picked.current = false;
|
|
2155
2168
|
}, [open]);
|
|
2156
2169
|
const q = query.trim().toLowerCase();
|
|
2157
2170
|
const filtered = q ? groups.map((g) => ({
|
|
@@ -2165,6 +2178,7 @@ function InsertPalette({
|
|
|
2165
2178
|
const firstMatch = filtered.flatMap((g) => g.items).find((i) => !i.disabled);
|
|
2166
2179
|
const choose = (item) => {
|
|
2167
2180
|
if (item.disabled) return;
|
|
2181
|
+
picked.current = true;
|
|
2168
2182
|
onOpenChange(false);
|
|
2169
2183
|
onSelect(item.id);
|
|
2170
2184
|
};
|
|
@@ -2178,6 +2192,9 @@ function InsertPalette({
|
|
|
2178
2192
|
e.preventDefault();
|
|
2179
2193
|
searchRef.current?.focus();
|
|
2180
2194
|
},
|
|
2195
|
+
onCloseAutoFocus: (e) => {
|
|
2196
|
+
if (picked.current) e.preventDefault();
|
|
2197
|
+
},
|
|
2181
2198
|
...description ? {} : { "aria-describedby": void 0 },
|
|
2182
2199
|
children: [
|
|
2183
2200
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DialogTitle, { children: title }),
|
package/dist/index.mjs
CHANGED
|
@@ -1609,10 +1609,12 @@ function StudioCanvasItem({
|
|
|
1609
1609
|
onInsert,
|
|
1610
1610
|
insertLabel,
|
|
1611
1611
|
invalid = false,
|
|
1612
|
+
insertPlacement = "center",
|
|
1612
1613
|
className
|
|
1613
1614
|
}) {
|
|
1614
1615
|
const studio = useStudio();
|
|
1615
1616
|
const ref = React19.useRef(null);
|
|
1617
|
+
const pickedHere = React19.useRef(false);
|
|
1616
1618
|
const inQuickAction = (target) => !!target?.closest?.("[data-studio-quick-action]");
|
|
1617
1619
|
const select = (reveal) => {
|
|
1618
1620
|
if (!selected) onSelect?.();
|
|
@@ -1620,7 +1622,9 @@ function StudioCanvasItem({
|
|
|
1620
1622
|
};
|
|
1621
1623
|
React19.useEffect(() => {
|
|
1622
1624
|
const el = ref.current;
|
|
1623
|
-
|
|
1625
|
+
const here = pickedHere.current;
|
|
1626
|
+
pickedHere.current = false;
|
|
1627
|
+
if (!selected || !el || here || el.contains(document.activeElement)) return;
|
|
1624
1628
|
const reduce = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
1625
1629
|
el.scrollIntoView?.({ block: "nearest", behavior: reduce ? "auto" : "smooth" });
|
|
1626
1630
|
}, [selected]);
|
|
@@ -1640,9 +1644,14 @@ function StudioCanvasItem({
|
|
|
1640
1644
|
invalid && "-outline-offset-2 outline-dashed outline-2 outline-warning/70",
|
|
1641
1645
|
className
|
|
1642
1646
|
),
|
|
1647
|
+
onPointerDownCapture: (e) => {
|
|
1648
|
+
if (!selected && !inQuickAction(e.target)) pickedHere.current = true;
|
|
1649
|
+
},
|
|
1643
1650
|
onClickCapture: (e) => select(!inQuickAction(e.target)),
|
|
1644
1651
|
onFocus: (e) => {
|
|
1645
|
-
if (
|
|
1652
|
+
if (inQuickAction(e.target)) return;
|
|
1653
|
+
if (!selected) pickedHere.current = true;
|
|
1654
|
+
select(false);
|
|
1646
1655
|
},
|
|
1647
1656
|
children: [
|
|
1648
1657
|
!selected && /* @__PURE__ */ jsxs12(
|
|
@@ -1673,8 +1682,9 @@ function StudioCanvasItem({
|
|
|
1673
1682
|
"aria-label": insertLabel ?? `Add below ${label}`,
|
|
1674
1683
|
title: insertLabel ?? "Add below",
|
|
1675
1684
|
className: cn(
|
|
1676
|
-
"absolute
|
|
1677
|
-
|
|
1685
|
+
"absolute top-0 z-10 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 shadow-sm hover:border-primary hover:text-primary focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/item:opacity-100 [@media(hover:none)]:opacity-100",
|
|
1686
|
+
insertPlacement === "gutter" ? "right-full mr-1.5 group-focus-within/item:opacity-100" : "left-1/2 -translate-x-1/2",
|
|
1687
|
+
selected && insertPlacement === "center" && "opacity-100"
|
|
1678
1688
|
),
|
|
1679
1689
|
onClick: (e) => {
|
|
1680
1690
|
e.stopPropagation();
|
|
@@ -2039,10 +2049,13 @@ function InsertPalette({
|
|
|
2039
2049
|
renderThumbnail
|
|
2040
2050
|
}) {
|
|
2041
2051
|
const [query, setQuery] = React22.useState("");
|
|
2052
|
+
const picked = React22.useRef(false);
|
|
2042
2053
|
const listRef = React22.useRef(null);
|
|
2043
2054
|
const searchRef = React22.useRef(null);
|
|
2044
2055
|
React22.useEffect(() => {
|
|
2045
|
-
if (open)
|
|
2056
|
+
if (!open) return;
|
|
2057
|
+
setQuery("");
|
|
2058
|
+
picked.current = false;
|
|
2046
2059
|
}, [open]);
|
|
2047
2060
|
const q = query.trim().toLowerCase();
|
|
2048
2061
|
const filtered = q ? groups.map((g) => ({
|
|
@@ -2056,6 +2069,7 @@ function InsertPalette({
|
|
|
2056
2069
|
const firstMatch = filtered.flatMap((g) => g.items).find((i) => !i.disabled);
|
|
2057
2070
|
const choose = (item) => {
|
|
2058
2071
|
if (item.disabled) return;
|
|
2072
|
+
picked.current = true;
|
|
2059
2073
|
onOpenChange(false);
|
|
2060
2074
|
onSelect(item.id);
|
|
2061
2075
|
};
|
|
@@ -2069,6 +2083,9 @@ function InsertPalette({
|
|
|
2069
2083
|
e.preventDefault();
|
|
2070
2084
|
searchRef.current?.focus();
|
|
2071
2085
|
},
|
|
2086
|
+
onCloseAutoFocus: (e) => {
|
|
2087
|
+
if (picked.current) e.preventDefault();
|
|
2088
|
+
},
|
|
2072
2089
|
...description ? {} : { "aria-describedby": void 0 },
|
|
2073
2090
|
children: [
|
|
2074
2091
|
/* @__PURE__ */ jsx24(DialogTitle, { children: title }),
|