@hanzo/ui 8.0.72 → 8.0.74

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.
@@ -21,11 +21,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
21
21
  * Radix's own defaults (700 / 300) are kept.
22
22
  * 2. `side` + `align` + `sideOffset` (Content) -> ONE `placement` and one
23
23
  * `offset` on the ROOT. Content still ACCEPTS all three and publishes them
24
- * up through a context — the same idiom `popover.tsx` uses for `sideOffset`
25
- * — so `<HoverCardContent side="left" align="start">` lands as
26
- * `placement="left-start"` instead of being silently dropped, which is what
27
- * `PopoverContent` does with `align` today. gui's popper and Radix agree on
28
- * the default here (`bottom`/`center`), so nothing has to be written out.
24
+ * up through a context — the same idiom `popover.tsx` uses so
25
+ * `<HoverCardContent side="left" align="start">` lands as
26
+ * `placement="left-start"`. The rejoining rule itself is `place()`, shared
27
+ * with `popover.tsx` rather than spelled here: it was written in both, and
28
+ * the two copies had already diverged. gui's popper and Radix agree on the
29
+ * default (`bottom`/`center`), so nothing has to be written out.
29
30
  *
30
31
  * One deliberate a11y deviation from Radix, in the safer direction. Radix's hover
31
32
  * card is sighted-user-only: its Content carries no role and its Trigger no aria
@@ -45,6 +46,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
45
46
  const gui_1 = require("@hanzo/gui");
46
47
  const react_1 = require("react");
47
48
  const ink_1 = require("./ink.cjs");
49
+ const place_1 = require("./place.cjs");
48
50
  const slot_1 = require("./slot.cjs");
49
51
  const portal_theme_1 = require("../../product/menu/portal-theme.cjs");
50
52
  /** Radix's defaults, kept so a migrated call site behaves identically. */
@@ -70,7 +72,7 @@ exports.HoverCardTrigger = HoverCardTrigger;
70
72
  const HoverCardContent = ({ side = 'bottom', align = 'center', sideOffset = DEFAULT_OFFSET, children, ...props }) => {
71
73
  const themeName = (0, portal_theme_1.useThemeName)();
72
74
  const publish = (0, react_1.useContext)(FloatContext);
73
- (0, react_1.useEffect)(() => publish?.(align === 'center' ? side : `${side}-${align}`, sideOffset), [publish, side, align, sideOffset]);
75
+ (0, react_1.useEffect)(() => publish?.((0, place_1.place)(side, align), sideOffset), [publish, side, align, sideOffset]);
74
76
  return ((0, jsx_runtime_1.jsx)(portal_theme_1.PortalTheme, { name: themeName, children: (0, jsx_runtime_1.jsx)(gui_1.Popover.Content, { ...(0, slot_1.slot)('hover-card-content'), bg: "$color2", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", p: "$4", width: WIDTH, ...props, children: (0, ink_1.ink)(children, undefined, { size: '$2' }) }) }));
75
77
  };
76
78
  exports.HoverCardContent = HoverCardContent;
@@ -15,11 +15,12 @@
15
15
  * Radix's own defaults (700 / 300) are kept.
16
16
  * 2. `side` + `align` + `sideOffset` (Content) -> ONE `placement` and one
17
17
  * `offset` on the ROOT. Content still ACCEPTS all three and publishes them
18
- * up through a context — the same idiom `popover.tsx` uses for `sideOffset`
19
- * — so `<HoverCardContent side="left" align="start">` lands as
20
- * `placement="left-start"` instead of being silently dropped, which is what
21
- * `PopoverContent` does with `align` today. gui's popper and Radix agree on
22
- * the default here (`bottom`/`center`), so nothing has to be written out.
18
+ * up through a context — the same idiom `popover.tsx` uses so
19
+ * `<HoverCardContent side="left" align="start">` lands as
20
+ * `placement="left-start"`. The rejoining rule itself is `place()`, shared
21
+ * with `popover.tsx` rather than spelled here: it was written in both, and
22
+ * the two copies had already diverged. gui's popper and Radix agree on the
23
+ * default (`bottom`/`center`), so nothing has to be written out.
23
24
  *
24
25
  * One deliberate a11y deviation from Radix, in the safer direction. Radix's hover
25
26
  * card is sighted-user-only: its Content carries no role and its Trigger no aria
@@ -38,8 +39,7 @@
38
39
  */
39
40
  import { Popover as GuiPopover } from '@hanzo/gui';
40
41
  import { type ComponentProps } from 'react';
41
- type Side = 'top' | 'right' | 'bottom' | 'left';
42
- type Align = 'start' | 'center' | 'end';
42
+ import { type Align, type Side } from './place.js';
43
43
  export type HoverCardProps = Omit<ComponentProps<typeof GuiPopover>, 'hoverable' | 'placement' | 'offset'> & {
44
44
  openDelay?: number;
45
45
  closeDelay?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"hover-card.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/hover-card.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,OAAO,CAAA;AAcd,KAAK,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAC/C,KAAK,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;AAOvC,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,cAAc,CAAC,OAAO,UAAU,CAAC,EACjC,WAAW,GAAG,WAAW,GAAG,QAAQ,CACrC,GAAG;IACF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,iBAAS,SAAS,CAAC,EACjB,SAAsB,EACtB,UAAwB,EACxB,GAAG,KAAK,EACT,EAAE,cAAc,2CAsBhB;AAED,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAA;AAE7E,QAAA,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,4CAErD,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG;IAC9E,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,QAAA,MAAM,gBAAgB,GAAI,iDAMvB,qBAAqB,4CAuBvB,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"hover-card.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/hover-card.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,OAAO,CAAA;AAGd,OAAO,EAAS,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS,CAAA;AAkBtD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,cAAc,CAAC,OAAO,UAAU,CAAC,EACjC,WAAW,GAAG,WAAW,GAAG,QAAQ,CACrC,GAAG;IACF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,iBAAS,SAAS,CAAC,EACjB,SAAsB,EACtB,UAAwB,EACxB,GAAG,KAAK,EACT,EAAE,cAAc,2CAsBhB;AAED,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAA;AAE7E,QAAA,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,4CAErD,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG;IAC9E,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,QAAA,MAAM,gBAAgB,GAAI,iDAMvB,qBAAqB,4CAuBvB,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA"}
@@ -17,11 +17,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
17
17
  * Radix's own defaults (700 / 300) are kept.
18
18
  * 2. `side` + `align` + `sideOffset` (Content) -> ONE `placement` and one
19
19
  * `offset` on the ROOT. Content still ACCEPTS all three and publishes them
20
- * up through a context — the same idiom `popover.tsx` uses for `sideOffset`
21
- * — so `<HoverCardContent side="left" align="start">` lands as
22
- * `placement="left-start"` instead of being silently dropped, which is what
23
- * `PopoverContent` does with `align` today. gui's popper and Radix agree on
24
- * the default here (`bottom`/`center`), so nothing has to be written out.
20
+ * up through a context — the same idiom `popover.tsx` uses so
21
+ * `<HoverCardContent side="left" align="start">` lands as
22
+ * `placement="left-start"`. The rejoining rule itself is `place()`, shared
23
+ * with `popover.tsx` rather than spelled here: it was written in both, and
24
+ * the two copies had already diverged. gui's popper and Radix agree on the
25
+ * default (`bottom`/`center`), so nothing has to be written out.
25
26
  *
26
27
  * One deliberate a11y deviation from Radix, in the safer direction. Radix's hover
27
28
  * card is sighted-user-only: its Content carries no role and its Trigger no aria
@@ -41,6 +42,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
41
42
  import { Popover as GuiPopover } from '@hanzo/gui';
42
43
  import { createContext, useCallback, useContext, useEffect, useState, } from 'react';
43
44
  import { ink } from './ink.js';
45
+ import { place } from './place.js';
44
46
  import { slot } from './slot.js';
45
47
  import { PortalTheme, useThemeName } from '../../product/menu/portal-theme.js';
46
48
  /** Radix's defaults, kept so a migrated call site behaves identically. */
@@ -65,7 +67,7 @@ const HoverCardTrigger = (props) => (_jsx(GuiPopover.Trigger, { ...slot('hover-c
65
67
  const HoverCardContent = ({ side = 'bottom', align = 'center', sideOffset = DEFAULT_OFFSET, children, ...props }) => {
66
68
  const themeName = useThemeName();
67
69
  const publish = useContext(FloatContext);
68
- useEffect(() => publish?.(align === 'center' ? side : `${side}-${align}`, sideOffset), [publish, side, align, sideOffset]);
70
+ useEffect(() => publish?.(place(side, align), sideOffset), [publish, side, align, sideOffset]);
69
71
  return (_jsx(PortalTheme, { name: themeName, children: _jsx(GuiPopover.Content, { ...slot('hover-card-content'), bg: "$color2", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", p: "$4", width: WIDTH, ...props, children: ink(children, undefined, { size: '$2' }) }) }));
70
72
  };
71
73
  export { HoverCard, HoverCardTrigger, HoverCardContent };
@@ -1 +1 @@
1
- {"version":3,"file":"hover-card.js","sourceRoot":"","sources":["../../../src/backends/gui/hover-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GAET,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAE3E,0EAA0E;AAC1E,MAAM,UAAU,GAAG,GAAG,CAAA;AACtB,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,cAAc,GAAG,CAAC,CAAA;AACxB,gCAAgC;AAChC,MAAM,KAAK,GAAG,GAAG,CAAA;AAMjB,mFAAmF;AACnF,MAAM,YAAY,GAAG,eAAe,CAAC,aAAa,CAEhD,IAAI,CAAC,CAAA;AAUP,SAAS,SAAS,CAAC,EACjB,SAAS,GAAG,UAAU,EACtB,UAAU,GAAG,WAAW,EACxB,GAAG,KAAK,EACO;IACf,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA2C;QAC3E,SAAS,EAAE,QAAQ;QACnB,MAAM,EAAE,cAAc;KACvB,CAAC,CAAA;IACF,8EAA8E;IAC9E,qCAAqC;IACrC,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,SAAoB,EAAE,MAAc,EAAE,EAAE,CACvC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,SA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U,CAAC,EAC5D,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CACnC,CAAA;IACD,OAAO,CACL,KAAC,WAAW,IAAC,IAAI,EAAE,SAAS,YAC1B,KAAC,UAAU,CAAC,OAAO,OACb,IAAI,CAAC,oBAAoB,CAAC,EAC9B,EAAE,EAAC,SAAS,EACZ,WAAW,EAAE,CAAC,EACd,WAAW,EAAC,cAAc,EAC1B,OAAO,EAAC,IAAI,EACZ,CAAC,EAAC,IAAI,EACN,KAAK,EAAE,KAAK,KACR,KAAK,YAER,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GACtB,GACT,CACf,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA"}
@@ -0,0 +1,34 @@
1
+ 'use client';"use strict";
2
+ /**
3
+ * PLACE — one floating panel, two vocabularies.
4
+ *
5
+ * gui speaks floating-ui's single placement string (`bottom`, `bottom-start`),
6
+ * and it keeps that string on the popper ROOT. The compound API every call site
7
+ * is written against splits the same fact in two and puts it on the CONTENT: a
8
+ * `side` and an `align`. Rejoining them is the whole of the translation, and it
9
+ * belongs in one place because two components need it — `popover` and
10
+ * `hover-card`, which is a popover in hover mode.
11
+ *
12
+ * It lives in its own leaf rather than in either component so that neither has
13
+ * to import the other for it. It was written twice before that was true, and the
14
+ * two copies had already diverged: one of them could not re-align a side that
15
+ * already carried a suffix.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.place = void 0;
19
+ /**
20
+ * The placement a side and an align name together.
21
+ *
22
+ * `center` is the ABSENCE of a suffix rather than a suffix of its own, and a
23
+ * side that already carries one is RE-aligned rather than appended to — so the
24
+ * result is always a legal placement and applying it twice changes nothing.
25
+ *
26
+ * place('bottom') === 'bottom'
27
+ * place('bottom', 'start') === 'bottom-start'
28
+ * place('bottom-end', 'start') === 'bottom-start'
29
+ */
30
+ const place = (side, align = 'center') => {
31
+ const base = side.split('-')[0];
32
+ return align === 'center' ? base : `${base}-${align}`;
33
+ };
34
+ exports.place = place;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * PLACE — one floating panel, two vocabularies.
3
+ *
4
+ * gui speaks floating-ui's single placement string (`bottom`, `bottom-start`),
5
+ * and it keeps that string on the popper ROOT. The compound API every call site
6
+ * is written against splits the same fact in two and puts it on the CONTENT: a
7
+ * `side` and an `align`. Rejoining them is the whole of the translation, and it
8
+ * belongs in one place because two components need it — `popover` and
9
+ * `hover-card`, which is a popover in hover mode.
10
+ *
11
+ * It lives in its own leaf rather than in either component so that neither has
12
+ * to import the other for it. It was written twice before that was true, and the
13
+ * two copies had already diverged: one of them could not re-align a side that
14
+ * already carried a suffix.
15
+ */
16
+ /** Where the panel sits relative to its trigger. */
17
+ export type Side = 'top' | 'right' | 'bottom' | 'left';
18
+ /** Where the panel lines up along that side. */
19
+ export type Align = 'start' | 'center' | 'end';
20
+ /**
21
+ * The placement a side and an align name together.
22
+ *
23
+ * `center` is the ABSENCE of a suffix rather than a suffix of its own, and a
24
+ * side that already carries one is RE-aligned rather than appended to — so the
25
+ * result is always a legal placement and applying it twice changes nothing.
26
+ *
27
+ * place('bottom') === 'bottom'
28
+ * place('bottom', 'start') === 'bottom-start'
29
+ * place('bottom-end', 'start') === 'bottom-start'
30
+ */
31
+ export declare const place: (side: string, align?: Align) => string;
32
+ //# sourceMappingURL=place.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"place.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/place.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oDAAoD;AACpD,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEtD,gDAAgD;AAChD,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;AAE9C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,QAAO,KAAgB,KAAG,MAG7D,CAAA"}
@@ -0,0 +1,31 @@
1
+ 'use client';/**
2
+ * PLACE — one floating panel, two vocabularies.
3
+ *
4
+ * gui speaks floating-ui's single placement string (`bottom`, `bottom-start`),
5
+ * and it keeps that string on the popper ROOT. The compound API every call site
6
+ * is written against splits the same fact in two and puts it on the CONTENT: a
7
+ * `side` and an `align`. Rejoining them is the whole of the translation, and it
8
+ * belongs in one place because two components need it — `popover` and
9
+ * `hover-card`, which is a popover in hover mode.
10
+ *
11
+ * It lives in its own leaf rather than in either component so that neither has
12
+ * to import the other for it. It was written twice before that was true, and the
13
+ * two copies had already diverged: one of them could not re-align a side that
14
+ * already carried a suffix.
15
+ */
16
+ /**
17
+ * The placement a side and an align name together.
18
+ *
19
+ * `center` is the ABSENCE of a suffix rather than a suffix of its own, and a
20
+ * side that already carries one is RE-aligned rather than appended to — so the
21
+ * result is always a legal placement and applying it twice changes nothing.
22
+ *
23
+ * place('bottom') === 'bottom'
24
+ * place('bottom', 'start') === 'bottom-start'
25
+ * place('bottom-end', 'start') === 'bottom-start'
26
+ */
27
+ export const place = (side, align = 'center') => {
28
+ const base = side.split('-')[0];
29
+ return align === 'center' ? base : `${base}-${align}`;
30
+ };
31
+ //# sourceMappingURL=place.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"place.js","sourceRoot":"","sources":["../../../src/backends/gui/place.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,QAAe,QAAQ,EAAU,EAAE;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/B,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAA;AACvD,CAAC,CAAA"}
@@ -9,20 +9,24 @@ const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  *
10
10
  * `PopoverContent` mounts its own portal and re-applies the trigger's resolved
11
11
  * theme inside it (gui portals re-root the subtree, so theme context does not
12
- * flow). `sideOffset` lands on the popper root, which is where gui keeps it.
12
+ * flow).
13
+ *
14
+ * gui keeps BOTH placement facts on the popper ROOT — `offset` and `placement`
15
+ * — while the compound API spells them on Content, as `sideOffset` and `align`.
16
+ * One value, one owner: the root holds them, Content publishes into it.
13
17
  */
14
18
  const gui_1 = require("@hanzo/gui");
15
19
  const react_1 = require("react");
16
20
  const portal_theme_1 = require("../../product/menu/portal-theme.cjs");
21
+ const place_1 = require("./place.cjs");
17
22
  const slot_1 = require("./slot.cjs");
18
23
  const DEFAULT_OFFSET = 4;
19
- /** gui puts `offset` on the popper ROOT; the compound API puts `sideOffset` on
20
- * Content. One value, one owner: the root holds it, Content publishes into it. */
21
- const OffsetContext = /* @__PURE__ */ (0, react_1.createContext)(null);
22
- function Popover({ offset = DEFAULT_OFFSET, ...props }) {
23
- const [current, setOffset] = (0, react_1.useState)(offset);
24
- (0, react_1.useEffect)(() => setOffset(offset), [offset]);
25
- return ((0, jsx_runtime_1.jsx)(OffsetContext.Provider, { value: setOffset, children: (0, jsx_runtime_1.jsx)(gui_1.Popover, { offset: current, ...props }) }));
24
+ const DEFAULT_SIDE = 'bottom';
25
+ const Publish = /* @__PURE__ */ (0, react_1.createContext)(null);
26
+ function Popover({ offset = DEFAULT_OFFSET, placement, ...props }) {
27
+ const [placed, setPlaced] = (0, react_1.useState)({});
28
+ const publish = (0, react_1.useCallback)((p) => setPlaced((prev) => ({ ...prev, ...p })), []);
29
+ return ((0, jsx_runtime_1.jsx)(Publish.Provider, { value: publish, children: (0, jsx_runtime_1.jsx)(gui_1.Popover, { offset: placed.offset ?? offset, placement: (0, place_1.place)(placement ?? DEFAULT_SIDE, placed.align), ...props }) }));
26
30
  }
27
31
  const PopoverTrigger = gui_1.Popover.Trigger;
28
32
  exports.PopoverTrigger = PopoverTrigger;
@@ -30,10 +34,10 @@ const PopoverAnchor = gui_1.Popover.Anchor;
30
34
  exports.PopoverAnchor = PopoverAnchor;
31
35
  const PopoverClose = gui_1.Popover.Close;
32
36
  exports.PopoverClose = PopoverClose;
33
- const PopoverContent = ({ sideOffset = DEFAULT_OFFSET, align: _align, ...props }) => {
37
+ const PopoverContent = ({ sideOffset = DEFAULT_OFFSET, align, ...props }) => {
34
38
  const themeName = (0, portal_theme_1.useThemeName)();
35
- const setOffset = (0, react_1.useContext)(OffsetContext);
36
- (0, react_1.useEffect)(() => setOffset?.(sideOffset), [setOffset, sideOffset]);
39
+ const publish = (0, react_1.useContext)(Publish);
40
+ (0, react_1.useEffect)(() => publish?.({ offset: sideOffset, align }), [publish, sideOffset, align]);
37
41
  return ((0, jsx_runtime_1.jsx)(portal_theme_1.PortalTheme, { name: themeName, children: (0, jsx_runtime_1.jsx)(gui_1.Popover.Content, { ...(0, slot_1.slot)('popover-content'), bg: "$color2", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", p: "$4", width: 288, ...props }) }));
38
42
  };
39
43
  exports.PopoverContent = PopoverContent;
@@ -3,21 +3,27 @@
3
3
  *
4
4
  * `PopoverContent` mounts its own portal and re-applies the trigger's resolved
5
5
  * theme inside it (gui portals re-root the subtree, so theme context does not
6
- * flow). `sideOffset` lands on the popper root, which is where gui keeps it.
6
+ * flow).
7
+ *
8
+ * gui keeps BOTH placement facts on the popper ROOT — `offset` and `placement`
9
+ * — while the compound API spells them on Content, as `sideOffset` and `align`.
10
+ * One value, one owner: the root holds them, Content publishes into it.
7
11
  */
8
12
  import { Popover as GuiPopover } from '@hanzo/gui';
9
13
  import { type ComponentProps } from 'react';
14
+ import { type Align } from './place.js';
15
+ export type { Align };
10
16
  export type PopoverProps = Omit<ComponentProps<typeof GuiPopover>, 'offset'> & {
11
17
  offset?: number;
12
18
  };
13
- declare function Popover({ offset, ...props }: PopoverProps): import("react/jsx-runtime").JSX.Element;
19
+ declare function Popover({ offset, placement, ...props }: PopoverProps): import("react/jsx-runtime").JSX.Element;
14
20
  declare const PopoverTrigger: typeof GuiPopover.Trigger;
15
21
  declare const PopoverAnchor: typeof GuiPopover.Anchor;
16
22
  declare const PopoverClose: typeof GuiPopover.Close;
17
23
  export type PopoverContentProps = ComponentProps<typeof GuiPopover.Content> & {
18
24
  sideOffset?: number;
19
- align?: 'start' | 'center' | 'end';
25
+ align?: Align;
20
26
  };
21
- declare const PopoverContent: ({ sideOffset, align: _align, ...props }: PopoverContentProps) => import("react/jsx-runtime").JSX.Element;
27
+ declare const PopoverContent: ({ sideOffset, align, ...props }: PopoverContentProps) => import("react/jsx-runtime").JSX.Element;
22
28
  export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverClose };
23
29
  //# sourceMappingURL=popover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/popover.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAkD,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA;AAU3F,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAElG,iBAAS,OAAO,CAAC,EAAE,MAAuB,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,2CAQnE;AAED,QAAA,MAAM,cAAc,EAAE,OAAO,UAAU,CAAC,OAA4B,CAAA;AACpE,QAAA,MAAM,aAAa,EAAE,OAAO,UAAU,CAAC,MAA0B,CAAA;AACjE,QAAA,MAAM,YAAY,EAAE,OAAO,UAAU,CAAC,KAAwB,CAAA;AAE9D,MAAM,MAAM,mBAAmB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AAI,iCAAkD,mBAAmB,4CAkB5F,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,CAAA"}
@@ -5,28 +5,32 @@ import { jsx as _jsx } from "react/jsx-runtime";
5
5
  *
6
6
  * `PopoverContent` mounts its own portal and re-applies the trigger's resolved
7
7
  * theme inside it (gui portals re-root the subtree, so theme context does not
8
- * flow). `sideOffset` lands on the popper root, which is where gui keeps it.
8
+ * flow).
9
+ *
10
+ * gui keeps BOTH placement facts on the popper ROOT — `offset` and `placement`
11
+ * — while the compound API spells them on Content, as `sideOffset` and `align`.
12
+ * One value, one owner: the root holds them, Content publishes into it.
9
13
  */
10
14
  import { Popover as GuiPopover } from '@hanzo/gui';
11
- import { createContext, useContext, useEffect, useState } from 'react';
15
+ import { createContext, useCallback, useContext, useEffect, useState, } from 'react';
12
16
  import { PortalTheme, useThemeName } from '../../product/menu/portal-theme.js';
17
+ import { place } from './place.js';
13
18
  import { slot } from './slot.js';
14
19
  const DEFAULT_OFFSET = 4;
15
- /** gui puts `offset` on the popper ROOT; the compound API puts `sideOffset` on
16
- * Content. One value, one owner: the root holds it, Content publishes into it. */
17
- const OffsetContext = /* @__PURE__ */ createContext(null);
18
- function Popover({ offset = DEFAULT_OFFSET, ...props }) {
19
- const [current, setOffset] = useState(offset);
20
- useEffect(() => setOffset(offset), [offset]);
21
- return (_jsx(OffsetContext.Provider, { value: setOffset, children: _jsx(GuiPopover, { offset: current, ...props }) }));
20
+ const DEFAULT_SIDE = 'bottom';
21
+ const Publish = /* @__PURE__ */ createContext(null);
22
+ function Popover({ offset = DEFAULT_OFFSET, placement, ...props }) {
23
+ const [placed, setPlaced] = useState({});
24
+ const publish = useCallback((p) => setPlaced((prev) => ({ ...prev, ...p })), []);
25
+ return (_jsx(Publish.Provider, { value: publish, children: _jsx(GuiPopover, { offset: placed.offset ?? offset, placement: place(placement ?? DEFAULT_SIDE, placed.align), ...props }) }));
22
26
  }
23
27
  const PopoverTrigger = GuiPopover.Trigger;
24
28
  const PopoverAnchor = GuiPopover.Anchor;
25
29
  const PopoverClose = GuiPopover.Close;
26
- const PopoverContent = ({ sideOffset = DEFAULT_OFFSET, align: _align, ...props }) => {
30
+ const PopoverContent = ({ sideOffset = DEFAULT_OFFSET, align, ...props }) => {
27
31
  const themeName = useThemeName();
28
- const setOffset = useContext(OffsetContext);
29
- useEffect(() => setOffset?.(sideOffset), [setOffset, sideOffset]);
32
+ const publish = useContext(Publish);
33
+ useEffect(() => publish?.({ offset: sideOffset, align }), [publish, sideOffset, align]);
30
34
  return (_jsx(PortalTheme, { name: themeName, children: _jsx(GuiPopover.Content, { ...slot('popover-content'), bg: "$color2", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", p: "$4", width: 288, ...props }) }));
31
35
  };
32
36
  export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverClose };
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","sourceRoot":"","sources":["../../../src/backends/gui/popover.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAA;AAC3F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,cAAc,GAAG,CAAC,CAAA;AAExB;mFACmF;AACnF,MAAM,aAAa,GAAG,eAAe,CAAC,aAAa,CAA+B,IAAI,CAAC,CAAA;AAIvF,SAAS,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,GAAG,KAAK,EAAgB;IAClE,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC7C,SA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AAc,GAAG,CAAC,EAAE,UAAU,GAAG,cAAc,EAAE,KAAK,EAAE,GAAG,KAAK,EAAuB,EAAE,EAAE;IAC/F,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACnC,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;IACvF,OAAO,CACL,KAAC,WAAW,IAAC,IAAI,EAAE,SAAS,YAC1B,KAAC,UAAU,CAAC,OAAO,OACb,IAAI,CAAC,iBAAiB,CAAC,EAC3B,EAAE,EAAC,SAAS,EACZ,WAAW,EAAE,CAAC,EACd,WAAW,EAAC,cAAc,EAC1B,OAAO,EAAC,IAAI,EACZ,CAAC,EAAC,IAAI,EACN,KAAK,EAAE,GAAG,KACN,KAAK,GACT,GACU,CACf,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,CAAA"}
@@ -1,7 +1,7 @@
1
1
  'use client';"use strict";
2
2
  'use client';
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Slider = void 0;
4
+ exports.Slider = exports.named = void 0;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  /** Slider — 6px track, 16px thumb, `touch()` to the 44px floor on every target. */
7
7
  const gui_1 = require("@hanzo/gui");
@@ -9,12 +9,36 @@ const slot_1 = require("./slot.cjs");
9
9
  const gesture_1 = require("./gesture.cjs");
10
10
  const TRACK = 6;
11
11
  const THUMB = 16;
12
- const Slider = (props) => ((0, jsx_runtime_1.jsxs)(gui_1.Slider, { ...(0, slot_1.slot)('slider'), width: "100%", ...props, children: [(0, jsx_runtime_1.jsx)(gui_1.Slider.Track, { ...(0, slot_1.slot)('slider-track'), height: TRACK, bg: "$color4", rounded: "$10", children: (0, jsx_runtime_1.jsx)(gui_1.Slider.TrackActive, { ...(0, slot_1.slot)('slider-range'), bg: "$color12" }) }), (0, jsx_runtime_1.jsx)(gui_1.Slider.Thumb, { ...(0, slot_1.slot)('slider-thumb'), index: 0, circular: true, size: THUMB,
13
- // A FILLED knob, no ring. It used to be a dark knob ringed in `$color12`,
14
- // which is #fff on dark the one border value the identity does not
15
- // allow. `$borderColor` is not the fix either: gui gives the thumb its own
16
- // `SliderThumb` sub-theme, where that token is white as well. A filled
17
- // knob needs no border, and `$color12` reads on both themes (white on
18
- // dark, near-black on light).
19
- bg: "$color12", borderWidth: 0, ...(0, gesture_1.touch)(THUMB) })] }));
12
+ /**
13
+ * The name belongs where the ROLE is. gui puts `role="slider"` on the Thumb,
14
+ * so a name spread onto the root lands on a plain container that no screen
15
+ * reader announces the control reads as an unlabelled slider. These are the
16
+ * naming and description properties an ARIA slider must carry; everything else
17
+ * (value, range, step, orientation, disabled) is the root's and stays there.
18
+ */
19
+ const NAMES = ['aria-label', 'aria-labelledby', 'aria-describedby', 'aria-valuetext'];
20
+ /** Splits a caller's props into what the thumb must carry and what the root keeps. */
21
+ const named = (props) => {
22
+ const name = {};
23
+ const rest = {};
24
+ for (const [k, v] of Object.entries(props)) {
25
+ if (NAMES.includes(k))
26
+ name[k] = v;
27
+ else
28
+ rest[k] = v;
29
+ }
30
+ return { name, rest };
31
+ };
32
+ exports.named = named;
33
+ const Slider = (props) => {
34
+ const { name, rest } = (0, exports.named)(props);
35
+ return ((0, jsx_runtime_1.jsxs)(gui_1.Slider, { ...(0, slot_1.slot)('slider'), width: "100%", ...rest, children: [(0, jsx_runtime_1.jsx)(gui_1.Slider.Track, { ...(0, slot_1.slot)('slider-track'), height: TRACK, bg: "$color4", rounded: "$10", children: (0, jsx_runtime_1.jsx)(gui_1.Slider.TrackActive, { ...(0, slot_1.slot)('slider-range'), bg: "$color12" }) }), (0, jsx_runtime_1.jsx)(gui_1.Slider.Thumb, { ...(0, slot_1.slot)('slider-thumb'), index: 0, circular: true, size: THUMB,
36
+ // A FILLED knob, no ring. It used to be a dark knob ringed in `$color12`,
37
+ // which is #fff on dark — the one border value the identity does not
38
+ // allow. `$borderColor` is not the fix either: gui gives the thumb its own
39
+ // `SliderThumb` sub-theme, where that token is white as well. A filled
40
+ // knob needs no border, and `$color12` reads on both themes (white on
41
+ // dark, near-black on light).
42
+ bg: "$color12", borderWidth: 0, ...(0, gesture_1.touch)(THUMB), ...name })] }));
43
+ };
20
44
  exports.Slider = Slider;
@@ -1,6 +1,22 @@
1
1
  /** Slider — 6px track, 16px thumb, `touch()` to the 44px floor on every target. */
2
2
  import { Slider as GuiSlider } from '@hanzo/gui';
3
3
  import type { ComponentProps } from 'react';
4
+ /**
5
+ * The name belongs where the ROLE is. gui puts `role="slider"` on the Thumb,
6
+ * so a name spread onto the root lands on a plain container that no screen
7
+ * reader announces — the control reads as an unlabelled slider. These are the
8
+ * naming and description properties an ARIA slider must carry; everything else
9
+ * (value, range, step, orientation, disabled) is the root's and stays there.
10
+ */
11
+ declare const NAMES: readonly ["aria-label", "aria-labelledby", "aria-describedby", "aria-valuetext"];
12
+ type Name = (typeof NAMES)[number];
13
+ /** An ARIA naming property is a string by contract, so the split says so. */
14
+ type Names = Partial<Record<Name, string>>;
15
+ /** Splits a caller's props into what the thumb must carry and what the root keeps. */
16
+ export declare const named: (props: Record<string, unknown>) => {
17
+ name: Names;
18
+ rest: Record<string, unknown>;
19
+ };
4
20
  export type SliderProps = ComponentProps<typeof GuiSlider>;
5
21
  declare const Slider: (props: SliderProps) => import("react/jsx-runtime").JSX.Element;
6
22
  export { Slider };
@@ -1 +1 @@
1
- {"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/slider.tsx"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAO3C,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,CAAA;AAE1D,QAAA,MAAM,MAAM,GAAI,OAAO,WAAW,4CAqBjC,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/slider.tsx"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAO3C;;;;;;GAMG;AACH,QAAA,MAAM,KAAK,kFAAmF,CAAA;AAE9F,KAAK,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAA;AAElC,6EAA6E;AAC7E,KAAK,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;AAE1C,sFAAsF;AACtF,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAQlG,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,CAAA;AAE1D,QAAA,MAAM,MAAM,GAAI,OAAO,WAAW,4CAyBjC,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -6,13 +6,36 @@ import { slot } from './slot.js';
6
6
  import { touch } from './gesture.js';
7
7
  const TRACK = 6;
8
8
  const THUMB = 16;
9
- const Slider = (props) => (_jsxs(GuiSlider, { ...slot('slider'), width: "100%", ...props, children: [_jsx(GuiSlider.Track, { ...slot('slider-track'), height: TRACK, bg: "$color4", rounded: "$10", children: _jsx(GuiSlider.TrackActive, { ...slot('slider-range'), bg: "$color12" }) }), _jsx(GuiSlider.Thumb, { ...slot('slider-thumb'), index: 0, circular: true, size: THUMB,
10
- // A FILLED knob, no ring. It used to be a dark knob ringed in `$color12`,
11
- // which is #fff on dark the one border value the identity does not
12
- // allow. `$borderColor` is not the fix either: gui gives the thumb its own
13
- // `SliderThumb` sub-theme, where that token is white as well. A filled
14
- // knob needs no border, and `$color12` reads on both themes (white on
15
- // dark, near-black on light).
16
- bg: "$color12", borderWidth: 0, ...touch(THUMB) })] }));
9
+ /**
10
+ * The name belongs where the ROLE is. gui puts `role="slider"` on the Thumb,
11
+ * so a name spread onto the root lands on a plain container that no screen
12
+ * reader announces the control reads as an unlabelled slider. These are the
13
+ * naming and description properties an ARIA slider must carry; everything else
14
+ * (value, range, step, orientation, disabled) is the root's and stays there.
15
+ */
16
+ const NAMES = ['aria-label', 'aria-labelledby', 'aria-describedby', 'aria-valuetext'];
17
+ /** Splits a caller's props into what the thumb must carry and what the root keeps. */
18
+ export const named = (props) => {
19
+ const name = {};
20
+ const rest = {};
21
+ for (const [k, v] of Object.entries(props)) {
22
+ if (NAMES.includes(k))
23
+ name[k] = v;
24
+ else
25
+ rest[k] = v;
26
+ }
27
+ return { name, rest };
28
+ };
29
+ const Slider = (props) => {
30
+ const { name, rest } = named(props);
31
+ return (_jsxs(GuiSlider, { ...slot('slider'), width: "100%", ...rest, children: [_jsx(GuiSlider.Track, { ...slot('slider-track'), height: TRACK, bg: "$color4", rounded: "$10", children: _jsx(GuiSlider.TrackActive, { ...slot('slider-range'), bg: "$color12" }) }), _jsx(GuiSlider.Thumb, { ...slot('slider-thumb'), index: 0, circular: true, size: THUMB,
32
+ // A FILLED knob, no ring. It used to be a dark knob ringed in `$color12`,
33
+ // which is #fff on dark — the one border value the identity does not
34
+ // allow. `$borderColor` is not the fix either: gui gives the thumb its own
35
+ // `SliderThumb` sub-theme, where that token is white as well. A filled
36
+ // knob needs no border, and `$color12` reads on both themes (white on
37
+ // dark, near-black on light).
38
+ bg: "$color12", borderWidth: 0, ...touch(THUMB), ...name })] }));
39
+ };
17
40
  export { Slider };
18
41
  //# sourceMappingURL=slider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/backends/gui/slider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,mFAAmF;AACnF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,MAAM,KAAK,GAAG,CAAC,CAAA;AACf,MAAM,KAAK,GAAG,EAAE,CAAA;AAIhB,MAAM,MAAM,GAAG,CAAC,KAAkB,EAAE,EAAE,CAAC,CACrC,MAAC,SAAS,OAAK,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAC,MAAM,KAAK,KAAK,aACnD,KAAC,SAAS,CAAC,KAAK,OAAK,IAAI,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAC,SAAS,EAAC,OAAO,EAAC,KAAK,YAClF,KAAC,SAAS,CAAC,WAAW,OAAK,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,EAAC,UAAU,GAAG,GACjD,EAClB,KAAC,SAAS,CAAC,KAAK,OACV,IAAI,CAAC,cAAc,CAAC,EACxB,KAAK,EAAE,CAAC,EACR,QAAQ,QACR,IAAI,EAAE,KAAK;YACX,0EAA0E;YAC1E,qEAAqE;YACrE,2EAA2E;YAC3E,uEAAuE;YACvE,sEAAsE;YACtE,8BAA8B;YAC9B,EAAE,EAAC,UAAU,EACb,WAAW,EAAE,CAAC,KACV,KAAK,CAAC,KAAK,CAAC,GAChB,IACQ,CACb,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/backends/gui/slider.tsx"],"names":[],"m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AAS,CAAC,WAAW,OAAK,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,EAAC,UAAU,GAAG,GACjD,EAClB,KAAC,SAAS,CAAC,KAAK,OACV,IAAI,CAAC,cAAc,CAAC,EACxB,KAAK,EAAE,CAAC,EACR,QAAQ,QACR,IAAI,EAAE,KAAK;gBACX,0EAA0E;gBAC1E,qEAAqE;gBACrE,2EAA2E;gBAC3E,uEAAuE;gBACvE,sEAAsE;gBACtE,8BAA8B;gBAC9B,EAAE,EAAC,UAAU,EACb,WAAW,EAAE,CAAC,KACV,KAAK,CAAC,KAAK,CAAC,KACZ,IAAI,GACR,IACQ,CACb,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/ui",
3
- "version": "8.0.72",
3
+ "version": "8.0.74",
4
4
  "type": "module",
5
5
  "description": "Hanzo UI — the one canonical Hanzo component library, on @hanzo/gui + @hanzo/design. ONE substrate: every component renders through @hanzo/gui primitives, so the same import works on web, native (expo) and desktop (Tauri). Self-contained (theme.css), presentational, host-agnostic, clean-room.",
6
6
  "exports": {