@tempots/ui 4.3.8 → 5.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/ui",
3
- "version": "4.3.8",
3
+ "version": "5.1.0",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Executes a callback function when a click event occurs outside of the parent element.
3
+ *
4
+ * @param handler - The callback function to be executed when a click event occurs outside of the parent element.
5
+ * @returns A renderable function that takes a DOMContext and returns a function that takes a boolean indicating whether to remove the tree.
6
+ * @public
7
+ */
8
+ export declare function OnClickOutside(handler: (event: MouseEvent) => void): import('@tempots/dom').Renderable;
@@ -0,0 +1 @@
1
+ export declare function OnEnterKey(handler: (event: KeyboardEvent) => void): import('@tempots/dom').Renderable;
@@ -0,0 +1 @@
1
+ export declare function OnEscapeKey(handler: (event: KeyboardEvent) => void): import('@tempots/dom').Renderable;
@@ -0,0 +1,23 @@
1
+ export type KeyCombo = {
2
+ /** The key value (e.g., 'Enter', 'a', 'ArrowUp') */
3
+ key?: string;
4
+ /** The physical key code (e.g., 'KeyA', 'Enter', 'ArrowUp') - more reliable than key */
5
+ code?: string;
6
+ /** Control key modifier */
7
+ ctrlKey?: boolean;
8
+ /** Alt key modifier (Option key on Mac) */
9
+ altKey?: boolean;
10
+ /** Shift key modifier */
11
+ shiftKey?: boolean;
12
+ /** Meta key modifier (Cmd on Mac, Windows key on PC) */
13
+ metaKey?: boolean;
14
+ /** Whether the key is being held down (auto-repeat) */
15
+ repeat?: boolean;
16
+ /** Cross-platform shortcut: true if either Cmd (Mac) or Ctrl (PC) is pressed */
17
+ commandOrControlKey?: boolean;
18
+ };
19
+ export declare function matchesKeyCombo(keyCombo: KeyCombo | string, event: KeyboardEvent): boolean;
20
+ export declare function OnKeyPressed({ allowedKeys, handler, }: {
21
+ allowedKeys: (KeyCombo | string)[];
22
+ handler: (event: KeyboardEvent) => void;
23
+ }): import('@tempots/dom').Renderable;
@@ -6,69 +6,71 @@ import { TNode, Value, Signal } from '@tempots/dom';
6
6
  */
7
7
  export type Placement = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
8
8
  /**
9
- * Represents the properties for a PopOver component.
9
+ * Represents all possible placements for a pop-over.
10
+ *
11
+ * @public
12
+ */
13
+ export declare const allPlacements: Placement[];
14
+ /**
15
+ * Represents the options for the arrow of a pop-over.
16
+ *
17
+ * @public
18
+ */
19
+ export type PopOverArrowOptions = {
20
+ x?: number;
21
+ y?: number;
22
+ centerOffset: number;
23
+ alignmentOffset?: number;
24
+ placement: Placement;
25
+ containerWidth: number;
26
+ containerHeight: number;
27
+ };
28
+ /**
29
+ * Represents the properties for a pop-over.
10
30
  *
11
31
  * @public
12
32
  */
13
33
  export type PopOverOptions = {
14
- /**
15
- * Specifies whether the PopOver is open or closed.
16
- */
17
- open: Value<boolean>;
18
34
  /**
19
35
  * Specifies the content of the PopOver.
20
36
  * This should be a function that returns a TNode.
21
37
  */
22
- content: () => TNode;
38
+ content: TNode;
23
39
  /**
24
40
  * Specifies the placement of the PopOver.
25
41
  * This is an optional property.
26
42
  */
27
43
  placement?: Value<Placement>;
28
44
  /**
29
- * Specifies the offset of the PopOver.
30
- * This is an optional property.
45
+ * Specifies the offset on the main axis.
31
46
  */
32
- offset?: Value<{
33
- /**
34
- * Specifies the offset on the main axis.
35
- */
36
- mainAxis?: number;
37
- /**
38
- * Specifies the offset on the cross axis.
39
- */
40
- crossAxis?: number;
41
- }>;
47
+ mainAxisOffset?: Value<number>;
42
48
  /**
43
- * Specifies the arrow configuration for the PopOver.
44
- * When provided, an arrow element will be created and positioned.
45
- * This is an optional property.
49
+ * Specifies the offset on the cross axis.
46
50
  */
47
- arrow?: {
48
- /**
49
- * Specifies the padding between the arrow and the edges of the floating element.
50
- */
51
- padding?: number;
52
- /**
53
- * Specifies the content of the arrow.
54
- */
55
- content?: (signal: Signal<PopOverArrowOptions>) => TNode;
56
- };
57
- };
58
- export type PopOverArrowOptions = {
59
- x?: number;
60
- y?: number;
61
- centerOffset: number;
62
- alignmentOffset?: number;
63
- placement: Placement;
64
- containerWidth: number;
65
- containerHeight: number;
51
+ crossAxisOffset?: Value<number>;
52
+ /**
53
+ * Specifies the padding between the arrow and the edges of the floating element.
54
+ */
55
+ arrowPadding?: Value<number>;
56
+ /**
57
+ * Specifies the content of the arrow.
58
+ */
59
+ arrow?: (signal: Signal<PopOverArrowOptions>) => TNode;
60
+ /**
61
+ * Specifies the target element for the PopOver. If not provided, the PopOver will be
62
+ * positioned relative to the parent element.
63
+ */
64
+ target?: string | HTMLElement;
66
65
  };
67
66
  /**
68
- * Renders a PopOver component.
67
+ * Creates a pop-over component.
69
68
  *
70
- * @param props - The properties for the PopOver component.
71
- * @returns The rendered PopOver component.
69
+ * @param fn - A function that returns the content of the pop-over.
70
+ * @param options - The options for the pop-over.
71
+ * @returns The pop-over component.
72
72
  * @public
73
73
  */
74
- export declare const PopOver: ({ content, open, placement: placementOption, offset, arrow: arrowOption, }: PopOverOptions) => import('@tempots/dom').Renderable;
74
+ export declare const PopOver: (fn: (open: (options: PopOverOptions) => void, close: () => void) => TNode, options?: {
75
+ isOpen: Value<boolean>;
76
+ }) => import('@tempots/dom').Renderable<import('@tempots/dom').DOMContext>;