@zazz-ui/core 0.14.3 → 0.15.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.
@@ -16,7 +16,8 @@
16
16
  * **The refresh registry** lets navigation.ts re-scan swapped content without
17
17
  * naming components: a module whose work is scoped to page content (reveal observer, class-form
18
18
  * carousel init) registers a refresh hook, and after a navigation swap the
19
- * navigation module calls `refreshAll(newMain)`.
19
+ * navigation module calls `refreshAll(newMain)`. Content another library swaps
20
+ * in reaches the same hooks through the public `Zazz.refresh(scope)`.
20
21
  * Custom elements do not need hooks: their lifecycle rides the swap natively.
21
22
  */
22
23
  /** Base class for Zazz HTML web components: lifecycle envelope only. */
@@ -46,5 +47,30 @@ type RefreshHook = (scope: Element) => void;
46
47
  declare function registerRefresh(hook: RefreshHook): void;
47
48
  /** @description Runs every registered refresh hook against a swapped-in scope. */
48
49
  declare function refreshAll(scope: Element): void;
49
- export { ZazzElement, defineZazzElement, registerRefresh, refreshAll };
50
+ /**
51
+ * @description Runs every refresh hook over `scope` and its descendants, or
52
+ * over the whole body without one. Hooks search below the scope they get, so
53
+ * they get the scope's parent: an element htmx swapped in whole (`outerHTML`)
54
+ * is itself found. Hooks are idempotent, so the siblings they also see are
55
+ * skipped.
56
+ *
57
+ * @param scope - The element whose markup changed.
58
+ */
59
+ declare function refresh(scope?: Element): void;
60
+ /**
61
+ * @namespace Zazz
62
+ * @description The runtime API for pages whose content changes without a Zazz
63
+ * navigation. After htmx, Turbo, or any script inserts markup, pass the new
64
+ * element to `refresh` so page-scoped behavior (reveal, attribute-form
65
+ * carousels, select-all checkboxes, sticky states, the drawer page indent)
66
+ * picks it up: `htmx.onLoad((el) => Zazz.refresh(el))`. A select-all group
67
+ * counts only the boxes it can see, so when rows change under a header box,
68
+ * pass the element that holds both.
69
+ *
70
+ * @property refresh - Runs every refresh hook over an element, or the body.
71
+ */
72
+ declare const Zazz: {
73
+ refresh: typeof refresh;
74
+ };
75
+ export { Zazz, ZazzElement, defineZazzElement, registerRefresh, refreshAll };
50
76
  //# sourceMappingURL=zazz-element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zazz-element.d.ts","sourceRoot":"","sources":["zazz-element.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,wEAAwE;AACxE,uBAAe,WAAY,SAAQ,WAAW;;IAG5C,iBAAiB,IAAI,IAAI,CAIxB;IAED;;;;OAIG;IACH,qBAAqB,IAAI,IAAI,CAAG;IAEhC,oBAAoB,IAAI,IAAI,CAI3B;IAED,6EAA6E;IAC7E,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAEpD,+EAA+E;IAC/E,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;CAC7B;AAED,uEAAuE;AACvE,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,wBAAwB,GAAG,IAAI,CAG3E;AAID,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAG5C;;;;GAIG;AACH,iBAAS,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAEhD;AAED,kFAAkF;AAClF,iBAAS,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAExC;AAED,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"zazz-element.d.ts","sourceRoot":"","sources":["zazz-element.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,wEAAwE;AACxE,uBAAe,WAAY,SAAQ,WAAW;;IAG5C,iBAAiB,IAAI,IAAI,CAIxB;IAED;;;;OAIG;IACH,qBAAqB,IAAI,IAAI,CAAG;IAEhC,oBAAoB,IAAI,IAAI,CAI3B;IAED,6EAA6E;IAC7E,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAEpD,+EAA+E;IAC/E,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;CAC7B;AAED,uEAAuE;AACvE,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,wBAAwB,GAAG,IAAI,CAG3E;AAID,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAG5C;;;;GAIG;AACH,iBAAS,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAEhD;AAED,kFAAkF;AAClF,iBAAS,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAExC;AAED;;;;;;;;GAQG;AACH,iBAAS,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAEtC;AAED;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,IAAI;;CAAc,CAAC;AAQzB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC"}
@@ -17,7 +17,8 @@
17
17
  * **The refresh registry** lets navigation.ts re-scan swapped content without
18
18
  * naming components: a module whose work is scoped to page content (reveal observer, class-form
19
19
  * carousel init) registers a refresh hook, and after a navigation swap the
20
- * navigation module calls `refreshAll(newMain)`.
20
+ * navigation module calls `refreshAll(newMain)`. Content another library swaps
21
+ * in reaches the same hooks through the public `Zazz.refresh(scope)`.
21
22
  * Custom elements do not need hooks: their lifecycle rides the swap natively.
22
23
  */
23
24
  /** Base class for Zazz HTML web components: lifecycle envelope only. */
@@ -62,4 +63,34 @@ function refreshAll(scope) {
62
63
  for (const hook of refreshHooks)
63
64
  hook(scope);
64
65
  }
65
- export { ZazzElement, defineZazzElement, registerRefresh, refreshAll };
66
+ /**
67
+ * @description Runs every refresh hook over `scope` and its descendants, or
68
+ * over the whole body without one. Hooks search below the scope they get, so
69
+ * they get the scope's parent: an element htmx swapped in whole (`outerHTML`)
70
+ * is itself found. Hooks are idempotent, so the siblings they also see are
71
+ * skipped.
72
+ *
73
+ * @param scope - The element whose markup changed.
74
+ */
75
+ function refresh(scope) {
76
+ refreshAll(scope ? (scope.parentElement ?? scope) : document.body);
77
+ }
78
+ /**
79
+ * @namespace Zazz
80
+ * @description The runtime API for pages whose content changes without a Zazz
81
+ * navigation. After htmx, Turbo, or any script inserts markup, pass the new
82
+ * element to `refresh` so page-scoped behavior (reveal, attribute-form
83
+ * carousels, select-all checkboxes, sticky states, the drawer page indent)
84
+ * picks it up: `htmx.onLoad((el) => Zazz.refresh(el))`. A select-all group
85
+ * counts only the boxes it can see, so when rows change under a header box,
86
+ * pass the element that holds both.
87
+ *
88
+ * @property refresh - Runs every refresh hook over an element, or the body.
89
+ */
90
+ const Zazz = { refresh };
91
+ // Attach to window for the documented public API (`window.Zazz`), and export
92
+ // for module consumers (`index.ts` re-exports it).
93
+ if (typeof window !== "undefined") {
94
+ window.Zazz = Zazz;
95
+ }
96
+ export { Zazz, ZazzElement, defineZazzElement, registerRefresh, refreshAll };
@@ -18,7 +18,8 @@
18
18
  * **The refresh registry** lets navigation.ts re-scan swapped content without
19
19
  * naming components: a module whose work is scoped to page content (reveal observer, class-form
20
20
  * carousel init) registers a refresh hook, and after a navigation swap the
21
- * navigation module calls `refreshAll(newMain)`.
21
+ * navigation module calls `refreshAll(newMain)`. Content another library swaps
22
+ * in reaches the same hooks through the public `Zazz.refresh(scope)`.
22
23
  * Custom elements do not need hooks: their lifecycle rides the swap natively.
23
24
  */
24
25
 
@@ -77,4 +78,37 @@ function refreshAll(scope: Element): void {
77
78
  for (const hook of refreshHooks) hook(scope);
78
79
  }
79
80
 
80
- export { ZazzElement, defineZazzElement, registerRefresh, refreshAll };
81
+ /**
82
+ * @description Runs every refresh hook over `scope` and its descendants, or
83
+ * over the whole body without one. Hooks search below the scope they get, so
84
+ * they get the scope's parent: an element htmx swapped in whole (`outerHTML`)
85
+ * is itself found. Hooks are idempotent, so the siblings they also see are
86
+ * skipped.
87
+ *
88
+ * @param scope - The element whose markup changed.
89
+ */
90
+ function refresh(scope?: Element): void {
91
+ refreshAll(scope ? (scope.parentElement ?? scope) : document.body);
92
+ }
93
+
94
+ /**
95
+ * @namespace Zazz
96
+ * @description The runtime API for pages whose content changes without a Zazz
97
+ * navigation. After htmx, Turbo, or any script inserts markup, pass the new
98
+ * element to `refresh` so page-scoped behavior (reveal, attribute-form
99
+ * carousels, select-all checkboxes, sticky states, the drawer page indent)
100
+ * picks it up: `htmx.onLoad((el) => Zazz.refresh(el))`. A select-all group
101
+ * counts only the boxes it can see, so when rows change under a header box,
102
+ * pass the element that holds both.
103
+ *
104
+ * @property refresh - Runs every refresh hook over an element, or the body.
105
+ */
106
+ const Zazz = { refresh };
107
+
108
+ // Attach to window for the documented public API (`window.Zazz`), and export
109
+ // for module consumers (`index.ts` re-exports it).
110
+ if (typeof window !== "undefined") {
111
+ window.Zazz = Zazz;
112
+ }
113
+
114
+ export { Zazz, ZazzElement, defineZazzElement, registerRefresh, refreshAll };
package/src/globals.d.ts CHANGED
@@ -16,25 +16,6 @@ interface Element {
16
16
  _carouselController?: AbortController;
17
17
  }
18
18
 
19
- /** @see https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API */
20
- interface NavigationDestination {
21
- url: string;
22
- }
23
-
24
- interface NavigateEvent extends Event {
25
- canIntercept: boolean;
26
- hashChange: boolean;
27
- downloadRequest: unknown;
28
- formData: FormData | null;
29
- destination: NavigationDestination;
30
- intercept(options: { handler: () => Promise<void> }): void;
31
- scroll(): void;
32
- }
33
-
34
- interface Navigation extends EventTarget {
35
- addEventListener(type: "navigate", listener: (event: NavigateEvent) => void): void;
36
- }
37
-
38
19
  /**
39
20
  * Invoker Commands API (command/commandfor). Native in Chromium 135+; the
40
21
  * invokers polyfill dispatches a compatible event. Declared here (as interface
@@ -109,8 +90,14 @@ interface SignalsNamespace {
109
90
  effect(callback: () => void | (() => void), options?: { signal?: AbortSignal }): () => void;
110
91
  }
111
92
 
93
+ interface ZazzNamespace {
94
+ /** Runs every refresh hook over `scope` and its descendants (the body without one): markup inserted without a Zazz navigation. */
95
+ refresh(scope?: Element): void;
96
+ }
97
+
112
98
  interface Window {
113
- navigation: Navigation;
99
+ /** Set by zazz-element.js — the runtime API for content other libraries swap in. */
100
+ Zazz: ZazzNamespace;
114
101
  Utils: UtilsNamespace;
115
102
  /** Set by signals.js — the TC39 signals wrapper (state/computed/effect). */
116
103
  Signals: SignalsNamespace;
package/src/index.d.ts CHANGED
@@ -34,4 +34,5 @@ import "./primitives/select/multiselect.ts";
34
34
  import "./primitives/tabs/tabs.ts";
35
35
  import "./primitives/toaster/toaster.ts";
36
36
  import "./base/navigation.ts";
37
+ export { Zazz } from "./base/zazz-element.ts";
37
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,iBAAiB,CAAC;AACzB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,4BAA4B,CAAC;AACpC,OAAO,oBAAoB,CAAC;AAC5B,OAAO,2CAA2C,CAAC;AACnD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,iCAAiC,CAAC;AACzC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+CAA+C,CAAC;AACvD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,2BAA2B,CAAC;AACnC,OAAO,iCAAiC,CAAC;AACzC,OAAO,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,iBAAiB,CAAC;AACzB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,4BAA4B,CAAC;AACpC,OAAO,oBAAoB,CAAC;AAC5B,OAAO,2CAA2C,CAAC;AACnD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,iCAAiC,CAAC;AACzC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+CAA+C,CAAC;AACvD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,2BAA2B,CAAC;AACnC,OAAO,iCAAiC,CAAC;AACzC,OAAO,sBAAsB,CAAC;AAI9B,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC"}
package/src/index.js CHANGED
@@ -34,6 +34,9 @@ import "./primitives/select/multiselect.js";
34
34
  import "./primitives/tabs/tabs.js";
35
35
  import "./primitives/toaster/toaster.js";
36
36
  import "./base/navigation.js";
37
+ // The runtime API (also `window.Zazz`): `Zazz.refresh(scope)` after another
38
+ // library swaps content in.
39
+ export { Zazz } from "./base/zazz-element.js";
37
40
  // The experimental `stuck` utility state reads container scroll-state queries;
38
41
  // where they are unsupported (Safari, Firefox), load the polyfill. Chromium never fetches it.
39
42
  if (typeof CSS !== "undefined" && !CSS.supports("container-type", "scroll-state")) {
package/src/index.ts CHANGED
@@ -36,6 +36,10 @@ import "./primitives/tabs/tabs.ts";
36
36
  import "./primitives/toaster/toaster.ts";
37
37
  import "./base/navigation.ts";
38
38
 
39
+ // The runtime API (also `window.Zazz`): `Zazz.refresh(scope)` after another
40
+ // library swaps content in.
41
+ export { Zazz } from "./base/zazz-element.ts";
42
+
39
43
  // The experimental `stuck` utility state reads container scroll-state queries;
40
44
  // where they are unsupported (Safari, Firefox), load the polyfill. Chromium never fetches it.
41
45
  if (typeof CSS !== "undefined" && !CSS.supports("container-type", "scroll-state")) {
@@ -19,8 +19,9 @@
19
19
  * logical insets
20
20
  * @uses border-*: inherit — the arrow's two outer edges take the content's computed
21
21
  * border (utilities included), so it stays outlined over a matching background
22
- * @uses @media not (hover: hover) — hidden on touch screens (no hover to show it, and a
23
- * tap would cover the trigger's own action); keep essential text visible
22
+ * @uses @media not (hover: hover) — the content is hidden on touch screens (no hover to
23
+ * show it, and a tap would cover the trigger's own action); the trigger stays.
24
+ * Keep essential text visible
24
25
  * @tokens --ui-tooltip-* (@layer variables; read on the content slot)
25
26
  */
26
27
 
@@ -377,8 +378,9 @@
377
378
  --_tooltip-arrow-turn: -45deg;
378
379
  }
379
380
 
381
+ /* Only the content: the wrapper holds the trigger, which stays. */
380
382
  @media not (hover: hover) {
381
- :where(ui-tooltip, [data-ui~="tooltip"]) {
383
+ :where(ui-tooltip, [data-ui~="tooltip"]) [data-tooltip-slot~="content"] {
382
384
  display: none !important;
383
385
  }
384
386
  }
@@ -1 +0,0 @@
1
- import{t as e}from"./zazz.js";const t=`data-ui-stuck`,n={top:`bottom`,right:`left`,bottom:`top`,left:`right`};let r=[],i,a=0;function o(e){for(let t=e.parentElement;t&&t!==document.body;t=t.parentElement){let{overflowX:e,overflowY:n}=getComputedStyle(t);if(/auto|scroll|hidden/.test(e+n))return t}return null}function s(e,{writingMode:t,direction:r}){let i=!t.startsWith(`horizontal`),a=i?t.endsWith(`lr`)?`left`:`right`:`top`,o=i?r===`rtl`?`bottom`:`top`:r===`rtl`?`right`:`left`,s=[];return e===a&&s.push(`block-start`),e===n[a]&&s.push(`block-end`),e===o&&s.push(`inline-start`),e===n[o]&&s.push(`inline-end`),s}function c(e,t){if(t.position!==`sticky`)return[];let n=o(e),r=n??document.scrollingElement??document.documentElement,i=n?(()=>{let e=n.getBoundingClientRect(),t=e.top+n.clientTop,r=e.left+n.clientLeft;return{top:t,left:r,bottom:t+n.clientHeight,right:r+n.clientWidth}})():{top:0,left:0,bottom:innerHeight,right:innerWidth},a=e.getBoundingClientRect(),s=r.scrollHeight-r.clientHeight,c=r.scrollWidth-r.clientWidth,l=getComputedStyle(r).direction===`rtl`,u=r.scrollLeft,d={top:r.scrollTop>0,bottom:r.scrollTop<s-.5,left:l?u>-c+.5:u>0,right:l?u<0:u<c-.5},f={top:a.top-i.top,bottom:i.bottom-a.bottom,left:a.left-i.left,right:i.right-a.right};return Object.keys(f).filter(e=>{let n=t[e];return n!==`auto`&&d[e]&&Math.abs(f[e]-Number.parseFloat(n))<1})}function l(){a=0;for(let e of r){let n=getComputedStyle(e),r=c(e,n).flatMap(e=>[e,...s(e,n)]).join(` `);r?e.getAttribute(t)!==r&&e.setAttribute(t,r):e.removeAttribute(t)}}function u(){a||=requestAnimationFrame(l)}function d(){if(i){for(let e of r)e.isConnected||e.removeAttribute(t);r=[...document.querySelectorAll(`[style*=": sticky"], [style*="--stuck-state:"]`)].filter(e=>e.querySelector(`[style*="--stuck:"]`)),u()}}function f(){return typeof CSS<`u`&&CSS.supports(`container-type`,`scroll-state`)}function p({force:e=!1}={}){if(i||!e&&f())return;i=new AbortController;let t={passive:!0,capture:!0,signal:i.signal};document.addEventListener(`scroll`,u,t),window.addEventListener(`resize`,u,t),d()}typeof window<`u`&&typeof document<`u`&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>p(),{once:!0}):p(),e(d));export{};