@classic-homes/theme-react 0.3.2 → 0.4.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/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +14 -4
- package/dist/index.mjs +14 -4
- package/package.json +1 -4
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();
|
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();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classic-homes/theme-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "React components for the Classic theme system",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -47,8 +47,6 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@classic-homes/data-panel-core": "*",
|
|
49
49
|
"@classic-homes/theme-tokens": "*",
|
|
50
|
-
"@radix-ui/react-accordion": "^1.2.0",
|
|
51
|
-
"@radix-ui/react-alert-dialog": "^1.1.0",
|
|
52
50
|
"@radix-ui/react-avatar": "^1.1.0",
|
|
53
51
|
"@radix-ui/react-dialog": "^1.1.0",
|
|
54
52
|
"@radix-ui/react-dropdown-menu": "^2.1.0",
|
|
@@ -57,7 +55,6 @@
|
|
|
57
55
|
"@radix-ui/react-separator": "^1.1.0",
|
|
58
56
|
"@radix-ui/react-slot": "^1.1.0",
|
|
59
57
|
"@radix-ui/react-switch": "^1.1.0",
|
|
60
|
-
"@radix-ui/react-tabs": "^1.1.0",
|
|
61
58
|
"class-variance-authority": "^0.7.0",
|
|
62
59
|
"clsx": "^2.1.0",
|
|
63
60
|
"tailwind-merge": "^2.2.0"
|