@yoamigo.com/core 0.2.0 → 0.3.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.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React, { ReactNode, CSSProperties } from 'react';
2
+ import React$1, { ReactNode, CSSProperties } from 'react';
3
3
  export { C as ContentStoreProviderProd, d as MarkdownText, e as MarkdownTextProps, P as PageInfo, b as StaticImage, c as StaticImageProps, M as StaticText, S as StaticTextProps, Y as YaLink, f as YaLinkProps, u as useContentStoreProd } from './MarkdownText-BUTYfqXS.js';
4
4
  export { Link, LinkProps, NavigateFunction, Router, RouterProps, useNavigate } from './router.js';
5
5
  export { Route, Switch, useParams } from 'wouter';
@@ -7,6 +7,7 @@ export { A as AssetResolverFn, C as ContentRegistry, c as contentRegistry, a as
7
7
  export { i as initBuilderSelection } from './builder-selection-CYP91nRu.js';
8
8
 
9
9
  type EditMode = 'read-only' | 'inline-edit';
10
+ type ChangeSource = 'user' | 'ai' | 'initial';
10
11
  interface PageInfo {
11
12
  path: string;
12
13
  label: string;
@@ -16,7 +17,8 @@ interface ActiveFieldCallbacks {
16
17
  }
17
18
  interface ContentStore {
18
19
  getValue: (fieldId: string) => string;
19
- setValue: (fieldId: string, value: string) => void;
20
+ setValue: (fieldId: string, value: string, source?: ChangeSource) => void;
21
+ getChangeSource: (fieldId: string) => ChangeSource;
20
22
  mode: EditMode;
21
23
  setMode: (mode: EditMode) => void;
22
24
  subscribe: (listener: () => void) => () => void;
@@ -44,7 +46,7 @@ interface YaTextProps {
44
46
  className?: string;
45
47
  as?: YaTextElement;
46
48
  /** Optional fallback content (used if fieldId not in store) */
47
- children?: React.ReactNode;
49
+ children?: React$1.ReactNode;
48
50
  }
49
51
  declare module '@tiptap/core' {
50
52
  interface Commands<ReturnType> {
@@ -125,7 +127,9 @@ interface YaVideoProps {
125
127
  objectFit?: 'cover' | 'contain' | 'fill';
126
128
  /** Loading strategy */
127
129
  loading?: 'lazy' | 'eager';
128
- /** Fallback for backward compatibility */
130
+ /** Default video value (used when nothing in content store) */
131
+ defaultValue?: VideoFieldValue;
132
+ /** Fallback for backward compatibility (deprecated: use defaultValue) */
129
133
  fallbackSrc?: string;
130
134
  /** Fallback poster image */
131
135
  fallbackPoster?: string;
@@ -134,7 +138,7 @@ interface YaVideoProps {
134
138
  * Serialize video field value for storage
135
139
  */
136
140
  declare function serializeVideoValue(value: VideoFieldValue): string;
137
- declare function YaVideo({ fieldId, className, aspectRatio: propAspectRatio, objectFit: propObjectFit, loading, fallbackSrc, fallbackPoster, }: YaVideoProps): react_jsx_runtime.JSX.Element;
141
+ declare function YaVideo({ fieldId, className, aspectRatio: propAspectRatio, objectFit: propObjectFit, loading, defaultValue, fallbackSrc, fallbackPoster, }: YaVideoProps): react_jsx_runtime.JSX.Element;
138
142
 
139
143
  interface BackgroundImageConfig {
140
144
  src: string;
@@ -191,6 +195,40 @@ interface SafeHtmlProps {
191
195
  */
192
196
  declare function SafeHtml({ content, className, mode }: SafeHtmlProps): react_jsx_runtime.JSX.Element;
193
197
 
198
+ interface SafeTriangleBelowProps {
199
+ /** Ref to the trigger element */
200
+ triggerRef: React.RefObject<HTMLElement | null>;
201
+ /** Ref to the popover element */
202
+ popoverRef: React.RefObject<HTMLElement | null>;
203
+ /** Whether the popover is currently visible */
204
+ isVisible: boolean;
205
+ /** Called when mouse leaves the safe zone */
206
+ onLeave?: () => void;
207
+ /** Called when mouse stays inside the safe zone (cancels hide timeout) */
208
+ onStayInside?: () => void;
209
+ }
210
+ /**
211
+ * SafeTriangleBelow creates a safe zone between a trigger element and a popover,
212
+ * preventing the popover from closing when users move their mouse through the gap.
213
+ *
214
+ * The safe zone is a bounding box around both elements. Mouse position is tracked
215
+ * and onLeave is called when the mouse exits this zone.
216
+ *
217
+ * The SVG visualization is purely for debugging (pointer-events: none) -
218
+ * all mouse tracking is done via position checking, allowing clicks to pass through.
219
+ *
220
+ * Usage:
221
+ * ```tsx
222
+ * <SafeTriangleBelow
223
+ * triggerRef={triggerRef}
224
+ * popoverRef={popoverRef}
225
+ * isVisible={isOpen}
226
+ * onLeave={() => setIsOpen(false)}
227
+ * />
228
+ * ```
229
+ */
230
+ declare function SafeTriangleBelow({ triggerRef, popoverRef, isVisible, onLeave, onStayInside, }: SafeTriangleBelowProps): null;
231
+
194
232
  /**
195
233
  * Animation state for a single field
196
234
  */
@@ -580,4 +618,61 @@ interface AnimatedTextOptions {
580
618
  */
581
619
  declare function useAnimatedText(fieldId: string, content: string, options?: AnimatedTextOptions): AnimatedTextResult;
582
620
 
583
- export { type AIEditContextValue, AIEditProvider, type AnimatedTextOptions, type AnimatedTextResult, type AnimationConfig, type AnimationMetadata, type AnimationOptions, type AnimationPhase, type AnimationResult, type AnimationState, type AnimationStrategy, type BackgroundConfig, type BackgroundImageConfig, type ContentStoreContextType, type ContentStoreMode, ContentStoreProvider, type ImageFieldValue, type ImageValue, type LinkValue, type OverlayConfig, SafeHtml, type SafeHtmlProps, type TextAnimationMetadata, type TextDiff, type VideoFieldValue, YaContainer, type YaContainerProps, YaImage, type YaImageProps, YaText, type YaTextProps, YaVideo, type YaVideoProps, buildIntermediateText, calculateAnimationTiming, computeTextDiff, containsHtml, getTextCursorPosition, imageCrossfadeStrategy, linkTransitionStrategy, parseBackgroundConfig, serializeBackgroundConfig, serializeImageValue, serializeVideoValue, stripHtml, textTypingStrategy, useAIEditAnimation, useAIEditContext, useAIEditContextOptional, useAnimatedText, useContentStore };
621
+ interface UseSafeTriangleOptions {
622
+ /** Delay before showing popover (ms) */
623
+ showDelay?: number;
624
+ /** Delay before hiding popover after mouse leaves (ms) */
625
+ hideDelay?: number;
626
+ /** Whether the hook is enabled (for edit mode check) */
627
+ enabled?: boolean;
628
+ }
629
+ interface UseSafeTriangleReturn<T extends HTMLElement, U extends HTMLElement> {
630
+ /** Ref to attach to the trigger element */
631
+ triggerRef: React.RefObject<T | null>;
632
+ /** Ref to attach to the popover element */
633
+ popoverRef: React.RefObject<U | null>;
634
+ /** Whether the popover should be visible */
635
+ isVisible: boolean;
636
+ /** Event handlers to spread on the trigger container */
637
+ handlers: {
638
+ onMouseEnter: () => void;
639
+ onMouseLeave: () => void;
640
+ onFocus: () => void;
641
+ };
642
+ /** Props to spread on the SafeTriangleBelow component */
643
+ triangleProps: {
644
+ triggerRef: React.RefObject<T | null>;
645
+ popoverRef: React.RefObject<U | null>;
646
+ isVisible: boolean;
647
+ onLeave: () => void;
648
+ onStayInside: () => void;
649
+ };
650
+ /** Manually show the popover */
651
+ show: () => void;
652
+ /** Manually hide the popover */
653
+ hide: () => void;
654
+ }
655
+ /**
656
+ * Hook for managing safe triangle popover state.
657
+ * Handles show/hide delays and provides all necessary refs and handlers.
658
+ *
659
+ * @example
660
+ * ```tsx
661
+ * const { triggerRef, popoverRef, isVisible, handlers, triangleProps } = useSafeTriangle()
662
+ *
663
+ * return (
664
+ * <div>
665
+ * <a ref={triggerRef} {...handlers}>
666
+ * Hover me
667
+ * </a>
668
+ * {isVisible && (
669
+ * <div ref={popoverRef}>Popover content</div>
670
+ * )}
671
+ * <SafeTriangleBelow {...triangleProps} />
672
+ * </div>
673
+ * )
674
+ * ```
675
+ */
676
+ declare function useSafeTriangle<T extends HTMLElement = HTMLElement, U extends HTMLElement = HTMLDivElement>(options?: UseSafeTriangleOptions): UseSafeTriangleReturn<T, U>;
677
+
678
+ export { type AIEditContextValue, AIEditProvider, type AnimatedTextOptions, type AnimatedTextResult, type AnimationConfig, type AnimationMetadata, type AnimationOptions, type AnimationPhase, type AnimationResult, type AnimationState, type AnimationStrategy, type BackgroundConfig, type BackgroundImageConfig, type ContentStoreContextType, type ContentStoreMode, ContentStoreProvider, type ImageFieldValue, type ImageValue, type LinkValue, type OverlayConfig, SafeHtml, type SafeHtmlProps, SafeTriangleBelow, type TextAnimationMetadata, type TextDiff, type VideoFieldValue, YaContainer, type YaContainerProps, YaImage, type YaImageProps, YaText, type YaTextProps, YaVideo, type YaVideoProps, buildIntermediateText, calculateAnimationTiming, computeTextDiff, containsHtml, getTextCursorPosition, imageCrossfadeStrategy, linkTransitionStrategy, parseBackgroundConfig, serializeBackgroundConfig, serializeImageValue, serializeVideoValue, stripHtml, textTypingStrategy, useAIEditAnimation, useAIEditContext, useAIEditContextOptional, useAnimatedText, useContentStore, useSafeTriangle };