@hazem3500/palette 0.9.146 → 0.9.148

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/react.js CHANGED
@@ -1 +1 @@
1
- "use client";import{B as e,d as n,e as t,h as r}from"./chunk-EWC2YAAK.js";import{b as s}from"./chunk-WH4SUF66.js";import"./chunk-5MFM5GPR.js";import"./chunk-HHUTDVTM.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-5HZI7HRR.js";import"./chunk-2BS2OWWH.js";import"./chunk-XOMOONGK.js";import"./chunk-TFFPX3O4.js";import"./chunk-VX6XCU4E.js";import"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";import{useEffect as o,useRef as i}from"react";function c(e){let n=i(null);o(()=>{if(n.current&&function(e,n){return[...new Set([...Object.keys(e),...Object.keys(n)])].every(t=>{if("shortcuts"===t||"features"===t||"frame"===t||"pins"===t){let r=e[t]??{},s=n[t]??{};return Object.keys({...r,...s}).every(e=>Object.is(r[e],s[e]))}if("design"===t){let t=e.design,r=n.design;if(!t||!r)return t===r;let s=t.themes??[],o=r.themes??[];return t.tokens===r.tokens&&t.components===r.components&&s.length===o.length&&s.every((e,n)=>e===o[n])}if("persistentRegions"===t)return e[t]?.length===n[t]?.length&&(e[t]??[]).every((e,r)=>e===n[t]?.[r]);if("onboarding"!==t)return Object.is(e[t],n[t]);let r=e.onboarding,s=n.onboarding;return r&&s?Object.keys({...r,...s}).every(e=>"sites"===e?r.sites?.length===s.sites?.length&&(r.sites??[]).every((e,n)=>e===s.sites?.[n]):Object.is(r[e],s[e])):r===s})}(n.current.config,e)||(n.current?.controller.destroy(),n.current=null,!1===e.enabled))return;let t={...e,...e.persistentRegions?{persistentRegions:[...e.persistentRegions]}:{},...e.onboarding?{onboarding:{...e.onboarding,...e.onboarding.sites?{sites:[...e.onboarding.sites]}:{}}}:{}};n.current={config:t,controller:s(t)}}),o(()=>()=>{n.current?.controller.destroy(),n.current=null},[])}function u(e){let r=i(null),s=i(null);return s.current||(s.current=e=>{r.current=e}),o(()=>{if(!0===e.enabled&&r.current)return n(r.current,e.component,e.props,e.onChange)},[e.enabled,e.component]),o(()=>{!0===e.enabled&&t(r.current,e.component,e.props,e.onChange)},[e.enabled,e.component,e.props,e.onChange]),{ref:s.current,"data-palette-inspectable":e.component.id,"data-komo-inspectable":e.component.id}}function a(e){o(()=>{if(!0!==e.enabled)return;let n=e.root??document.documentElement;return r(n,e.tokens)},[e.root,e.tokens,e.enabled])}var l=c,p=u,m=a;export{e as cssVariableTokens,l as useKomo,m as useKomoDesignTokens,p as useKomoInspectable,c as usePalette,a as usePaletteDesignTokens,u as usePaletteInspectable};
1
+ "use client";import{B as e,d as n,e as t,h as r}from"./chunk-EWC2YAAK.js";import{b as s}from"./chunk-BKIUQ7QJ.js";import"./chunk-5MFM5GPR.js";import"./chunk-HHUTDVTM.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-5HZI7HRR.js";import"./chunk-2BS2OWWH.js";import"./chunk-XOMOONGK.js";import"./chunk-TFFPX3O4.js";import"./chunk-VX6XCU4E.js";import"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";import{useEffect as o,useRef as i}from"react";function c(e){let n=i(null);o(()=>{if(n.current&&function(e,n){return[...new Set([...Object.keys(e),...Object.keys(n)])].every(t=>{if("shortcuts"===t||"features"===t||"frame"===t||"pins"===t){let r=e[t]??{},s=n[t]??{};return Object.keys({...r,...s}).every(e=>Object.is(r[e],s[e]))}if("design"===t){let t=e.design,r=n.design;if(!t||!r)return t===r;let s=t.themes??[],o=r.themes??[];return t.tokens===r.tokens&&t.components===r.components&&s.length===o.length&&s.every((e,n)=>e===o[n])}if("persistentRegions"===t)return e[t]?.length===n[t]?.length&&(e[t]??[]).every((e,r)=>e===n[t]?.[r]);if("onboarding"!==t)return Object.is(e[t],n[t]);let r=e.onboarding,s=n.onboarding;return r&&s?Object.keys({...r,...s}).every(e=>"sites"===e?r.sites?.length===s.sites?.length&&(r.sites??[]).every((e,n)=>e===s.sites?.[n]):Object.is(r[e],s[e])):r===s})}(n.current.config,e)||(n.current?.controller.destroy(),n.current=null,!1===e.enabled))return;let t={...e,...e.persistentRegions?{persistentRegions:[...e.persistentRegions]}:{},...e.onboarding?{onboarding:{...e.onboarding,...e.onboarding.sites?{sites:[...e.onboarding.sites]}:{}}}:{}};n.current={config:t,controller:s(t)}}),o(()=>()=>{n.current?.controller.destroy(),n.current=null},[])}function u(e){let r=i(null),s=i(null);return s.current||(s.current=e=>{r.current=e}),o(()=>{if(!0===e.enabled&&r.current)return n(r.current,e.component,e.props,e.onChange)},[e.enabled,e.component]),o(()=>{!0===e.enabled&&t(r.current,e.component,e.props,e.onChange)},[e.enabled,e.component,e.props,e.onChange]),{ref:s.current,"data-palette-inspectable":e.component.id,"data-komo-inspectable":e.component.id}}function a(e){o(()=>{if(!0!==e.enabled)return;let n=e.root??document.documentElement;return r(n,e.tokens)},[e.root,e.tokens,e.enabled])}var l=c,p=u,m=a;export{e as cssVariableTokens,l as useKomo,m as useKomoDesignTokens,p as useKomoInspectable,c as usePalette,a as usePaletteDesignTokens,u as usePaletteInspectable};
@@ -40,7 +40,7 @@ export type FrameView = Box & {
40
40
  * never upscales; 100% keeps CSS pixels and pans when it is larger than the box.
41
41
  */
42
42
  export declare function frameView(box: Box, [width, height]: number[], actual: boolean): FrameView;
43
- type Edges = {
43
+ export type Edges = {
44
44
  left: number;
45
45
  top: number;
46
46
  right: number;
@@ -51,11 +51,23 @@ export declare const pinBox: ({ x, y }: {
51
51
  x: number;
52
52
  y: number;
53
53
  }) => Edges;
54
+ /** What the card should keep clear of, and the side an earlier decision chose. */
55
+ export type CardAvoid = {
56
+ /** The anchor element's box: never covered when any candidate can avoid it. */
57
+ anchor?: Edges;
58
+ /** Interactive host elements near the anchor. */
59
+ targets?: () => Edges[];
60
+ /** Candidate index chosen earlier; reused while it still fits, so scrolling never flips sides. */
61
+ choice?: {
62
+ side?: number;
63
+ };
64
+ };
54
65
  /**
55
- * Place a Palette card beside a pin's on-screen box, in window pixels: right, left,
56
- * below, then above, the first that fits the review area; otherwise the roomiest, clamped.
66
+ * Place a Palette card beside a pin's on-screen box, in window pixels. Candidates are right,
67
+ * left, below and above, then shifted variants; the one that fits the review area and covers
68
+ * the least wins, ties going to the earlier candidate (the classic order).
57
69
  */
58
- export declare function placeCard(pin: Edges, width: number, height: number, area: Edges): {
70
+ export declare function placeCard(pin: Edges, width: number, height: number, area: Edges, avoid?: CardAvoid): {
59
71
  x: number;
60
72
  y: number;
61
73
  };