@emporix/component-library 1.7.1 → 1.8.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/README.md CHANGED
@@ -228,6 +228,55 @@ const tabs: TabItem[] = [
228
228
  | label | string | Display label for the tab |
229
229
  | content | ReactNode | Content to display when active |
230
230
 
231
+ ### Tooltip
232
+
233
+ Floating overlays on hover or focus, similar to [PrimeReact Tooltip](https://primereact.org/tooltip/). Use **children mode** to wrap a button, input, or other component, or **selector mode** with a CSS `target` and `data-pr-tooltip` / `data-pr-position` on matching elements.
234
+
235
+ ```tsx
236
+ import { Tooltip } from '@emporix/component-library'
237
+
238
+ // Wrap a control (content prop required)
239
+ <Tooltip content="Save your changes" position="top">
240
+ <PrimaryButton>Save</PrimaryButton>
241
+ </Tooltip>
242
+
243
+ // Attach to existing markup — targets use data attributes
244
+ <Tooltip target=".my-help-icon" />
245
+ <i
246
+ className="my-help-icon pi pi-question-circle"
247
+ data-pr-tooltip="Extra help"
248
+ data-pr-position="right"
249
+ />
250
+
251
+ // Reactive label while open
252
+ <Tooltip content={saveHint} position="bottom">
253
+ <PrimaryButton onClick={() => setSaveHint('Saved')}>Save</PrimaryButton>
254
+ </Tooltip>
255
+ ```
256
+
257
+ #### Props
258
+
259
+ | Prop | Type | Default | Description |
260
+ | -------------- | -------------------------------------------------- | ------- | --------------------------------------------------------------------------- |
261
+ | target | string | - | CSS selector for anchor elements; when set, `children` is ignored |
262
+ | content | ReactNode | - | Tooltip body; required for children mode; fallback for selector mode |
263
+ | position | `top` \| `bottom` \| `left` \| `right` \| `mouse` | `top` | Placement; `mouse` follows the pointer |
264
+ | event | `hover` \| `focus` \| `both` | `hover` | How the tooltip is triggered |
265
+ | showDelay | number | `0` | Delay before show (ms) |
266
+ | hideDelay | number | `0` | Delay before hide (ms) |
267
+ | autoHide | boolean | `true` | When `false`, pointer can move to the tooltip without hiding it |
268
+ | mouseTrack | boolean | `false` | While visible, position tracks the pointer |
269
+ | mouseTrackTop | number | `0` | Vertical offset when using mouse track |
270
+ | mouseTrackLeft | number | `0` | Horizontal offset when using mouse track |
271
+ | disabled | boolean | `false` | Disable the tooltip |
272
+ | className | string | - | Extra class on the anchor wrapper (children mode) or merged on single child |
273
+ | panelClassName | string | - | Extra class on the floating panel |
274
+ | id | string | - | Optional id for the tooltip (`aria-describedby` on the anchor) |
275
+ | children | ReactNode | - | Single element recommended; multiple nodes are wrapped in an inline span |
276
+ | data-testid | string | - | Adds `data-testid` on the panel as `{id}-panel` |
277
+
278
+ Selector targets can override position per element with `data-pr-position`. Escape closes the tooltip.
279
+
231
280
  ### Accordion
232
281
 
233
282
  Collapsible content panels grouped in tabs.
@@ -363,6 +412,13 @@ Reusable focus outline for inputs, dropdowns, SelectButton, etc. Override to cha
363
412
  --focus-ring-box-shadow: 0 0 0 2px rgba(38, 101, 183, 0.35);
364
413
  ```
365
414
 
415
+ #### Tooltip
416
+
417
+ ```css
418
+ --color-tooltip-bg: #3e4759;
419
+ --color-tooltip-text: #ffffff;
420
+ ```
421
+
366
422
  #### Spacing
367
423
 
368
424
  ```css
@@ -0,0 +1,47 @@
1
+ import { default as React } from 'react';
2
+ export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right' | 'mouse';
3
+ export type TooltipEventMode = 'hover' | 'focus' | 'both';
4
+ export interface TooltipProps {
5
+ /**
6
+ * CSS selector for target elements (comma-separated allowed).
7
+ * When set, `children` is ignored. Per-target text: `data-pr-tooltip`.
8
+ * Optional per-target position: `data-pr-position` (top|bottom|left|right|mouse).
9
+ */
10
+ target?: string;
11
+ /**
12
+ * Tooltip body. Required when wrapping `children`. For `target` mode, used when an element has no `data-pr-tooltip`.
13
+ */
14
+ content?: React.ReactNode;
15
+ /** Placement relative to the anchor. Use `mouse` to pin near the pointer. */
16
+ position?: TooltipPosition;
17
+ /** hover (default), focus, or both */
18
+ event?: TooltipEventMode;
19
+ showDelay?: number;
20
+ hideDelay?: number;
21
+ /**
22
+ * When false, the tooltip stays visible when the pointer moves from the anchor to the tooltip panel.
23
+ */
24
+ autoHide?: boolean;
25
+ /** While visible, follow the pointer */
26
+ mouseTrack?: boolean;
27
+ mouseTrackTop?: number;
28
+ mouseTrackLeft?: number;
29
+ /** Do not show the tooltip */
30
+ disabled?: boolean;
31
+ /**
32
+ * Extra class on the anchor wrapper (children mode only). Ignored when using `target` only.
33
+ */
34
+ className?: string;
35
+ /** Class name on the floating tooltip panel */
36
+ panelClassName?: string;
37
+ /** Stable id for the tooltip node (`aria-describedby` on the anchor while open) */
38
+ id?: string;
39
+ /**
40
+ * Element(s) to attach the tooltip to. Not used when `target` is set.
41
+ * Multiple nodes are wrapped in an inline container.
42
+ */
43
+ children?: React.ReactNode;
44
+ 'data-testid'?: string;
45
+ }
46
+ export declare const Tooltip: ({ target, content, position, event: eventMode, showDelay, hideDelay, autoHide, mouseTrack, mouseTrackTop, mouseTrackLeft, disabled, className, panelClassName, id: idProp, children, "data-testid": testId, }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
47
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KASN,MAAM,OAAO,CAAA;AAOd,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;AAE3E,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;AAEzD,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,sCAAsC;IACtC,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mFAAmF;IACnF,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AA+MD,eAAO,MAAM,OAAO,GAAI,+MAiBrB,YAAY,4CA4Ud,CAAA"}
package/dist/index.d.ts CHANGED
@@ -24,6 +24,8 @@ export { AccordionTab } from './components/accordion/AccordionTab';
24
24
  export type { AccordionTabProps } from './components/accordion/AccordionTab';
25
25
  export { SelectButton } from './components/selectbutton/SelectButton';
26
26
  export type { SelectButtonProps, SelectButtonOption, SelectButtonChangeEvent, } from './components/selectbutton/SelectButton';
27
+ export { Tooltip } from './components/tooltip/Tooltip';
28
+ export type { TooltipProps, TooltipPosition, TooltipEventMode, } from './components/tooltip/Tooltip';
27
29
  export { ToastProvider, useToast, ToastTemplate } from './components/toast';
28
30
  export type { ToastProviderProps, ToastTemplateProps, ToastErrorItem, ToastErrorMessage, ToastSeverity, } from './components/toast';
29
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,YAAY,EAAE,kBAAkB,EAAE,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