h2o-library 2.0.0 → 2.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/CHANGELOG.md +33 -0
- package/dist/charts/components/index.d.ts +2 -0
- package/dist/charts/components/src/button/button.d.ts +3 -0
- package/dist/charts/components/src/chip/chip.d.ts +4 -1
- package/dist/charts/components/src/content-switch/content-switch.d.ts +3 -0
- package/dist/charts/components/src/expandable-search/expandable-search.d.ts +40 -0
- package/dist/charts/components/src/input/input.d.ts +5 -0
- package/dist/charts/components/src/onboarding/onboarding.d.ts +100 -0
- package/dist/charts/components/src/radio-group/radio-group.d.ts +3 -0
- package/dist/charts/hooks/index.d.ts +1 -0
- package/dist/charts/hooks/src/use-onboarding.d.ts +66 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/src/button/button.d.ts +3 -0
- package/dist/components/src/chip/chip.d.ts +4 -1
- package/dist/components/src/content-switch/content-switch.d.ts +3 -0
- package/dist/components/src/expandable-search/expandable-search.d.ts +40 -0
- package/dist/components/src/input/input.d.ts +5 -0
- package/dist/components/src/onboarding/onboarding.d.ts +100 -0
- package/dist/components/src/radio-group/radio-group.d.ts +3 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/src/button/button.d.ts +3 -0
- package/dist/esm/components/src/button/button.js +1 -1
- package/dist/esm/components/src/chip/chip.d.ts +4 -1
- package/dist/esm/components/src/chip/chip.js +1 -1
- package/dist/esm/components/src/content-switch/content-switch.d.ts +3 -0
- package/dist/esm/components/src/content-switch/content-switch.js +1 -1
- package/dist/esm/components/src/expandable-search/expandable-search.css +120 -0
- package/dist/esm/components/src/expandable-search/expandable-search.d.ts +40 -0
- package/dist/esm/components/src/expandable-search/expandable-search.js +2 -0
- package/dist/esm/components/src/input/input.d.ts +5 -0
- package/dist/esm/components/src/input/input.js +1 -1
- package/dist/esm/components/src/modal/modal.js +1 -1
- package/dist/esm/components/src/onboarding/onboarding.css +178 -0
- package/dist/esm/components/src/onboarding/onboarding.d.ts +100 -0
- package/dist/esm/components/src/onboarding/onboarding.js +2 -0
- package/dist/esm/components/src/radio-group/radio-group.d.ts +3 -0
- package/dist/esm/components/src/radio-group/radio-group.js +1 -1
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/src/use-onboarding.d.ts +66 -0
- package/dist/esm/hooks/src/use-onboarding.js +2 -0
- package/dist/esm/index.js +1 -1
- package/dist/hooks/components/index.d.ts +2 -0
- package/dist/hooks/components/src/button/button.d.ts +3 -0
- package/dist/hooks/components/src/chip/chip.d.ts +4 -1
- package/dist/hooks/components/src/content-switch/content-switch.d.ts +3 -0
- package/dist/hooks/components/src/expandable-search/expandable-search.d.ts +40 -0
- package/dist/hooks/components/src/input/input.d.ts +5 -0
- package/dist/hooks/components/src/onboarding/onboarding.d.ts +100 -0
- package/dist/hooks/components/src/radio-group/radio-group.d.ts +3 -0
- package/dist/hooks/hooks/index.d.ts +1 -0
- package/dist/hooks/hooks/src/use-onboarding.d.ts +66 -0
- package/dist/hooks/index.cjs.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/src/use-onboarding.d.ts +66 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.css +1 -1
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/src/button/button.d.ts +3 -0
- package/dist/types/components/src/chip/chip.d.ts +4 -1
- package/dist/types/components/src/content-switch/content-switch.d.ts +3 -0
- package/dist/types/components/src/expandable-search/expandable-search.d.ts +40 -0
- package/dist/types/components/src/input/input.d.ts +5 -0
- package/dist/types/components/src/onboarding/onboarding.d.ts +100 -0
- package/dist/types/components/src/radio-group/radio-group.d.ts +3 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/src/use-onboarding.d.ts +66 -0
- package/dist/utils/components/index.d.ts +2 -0
- package/dist/utils/components/src/button/button.d.ts +3 -0
- package/dist/utils/components/src/chip/chip.d.ts +4 -1
- package/dist/utils/components/src/content-switch/content-switch.d.ts +3 -0
- package/dist/utils/components/src/expandable-search/expandable-search.d.ts +40 -0
- package/dist/utils/components/src/input/input.d.ts +5 -0
- package/dist/utils/components/src/onboarding/onboarding.d.ts +100 -0
- package/dist/utils/components/src/radio-group/radio-group.d.ts +3 -0
- package/dist/utils/hooks/index.d.ts +1 -0
- package/dist/utils/hooks/src/use-onboarding.d.ts +66 -0
- package/package.json +7 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import "./onboarding.css";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { type OnboardingStorage, type UseOnboardingReturn } from "../../../hooks/src/use-onboarding";
|
|
5
|
+
/** Where a step popup sits relative to its target. `"center"` ignores the target and centers on screen. */
|
|
6
|
+
export type OnboardingPlacement = "top" | "bottom" | "left" | "right" | "auto" | "center";
|
|
7
|
+
/**
|
|
8
|
+
* How a step finds its anchor element:
|
|
9
|
+
* - `string` — a CSS selector (e.g. `"#sidebar"`, `".profile"`, `"[data-tour=save]"`). A bare word falls back to an element id.
|
|
10
|
+
* - `HTMLElement` — the element directly.
|
|
11
|
+
* - `() => HTMLElement | null` — resolved lazily when the step shows.
|
|
12
|
+
*/
|
|
13
|
+
export type OnboardingTarget = string | HTMLElement | (() => HTMLElement | null);
|
|
14
|
+
/**
|
|
15
|
+
* A single step in an onboarding flow.
|
|
16
|
+
*
|
|
17
|
+
* @property {OnboardingTarget} [target] - Element to anchor + spotlight. Omit for a centered step (welcome/finish screens).
|
|
18
|
+
* @property {ReactNode} [title] - Heading shown at the top of the popup.
|
|
19
|
+
* @property {ReactNode} content - Body message (required).
|
|
20
|
+
* @property {OnboardingPlacement} [placement] - Popup side. Default: the flow's `placement` (which defaults to `"auto"`).
|
|
21
|
+
* @property {number} [spotlightPadding] - Extra px around the target in the spotlight cutout.
|
|
22
|
+
* @property {number} [spotlightRadius] - Spotlight corner radius in px.
|
|
23
|
+
* @property {boolean} [disableInteraction] - Block clicks on the spotlighted element. Default: the flow's `disableInteraction`.
|
|
24
|
+
*/
|
|
25
|
+
export interface OnboardingStep {
|
|
26
|
+
target?: OnboardingTarget;
|
|
27
|
+
title?: ReactNode;
|
|
28
|
+
content: ReactNode;
|
|
29
|
+
placement?: OnboardingPlacement;
|
|
30
|
+
spotlightPadding?: number;
|
|
31
|
+
spotlightRadius?: number;
|
|
32
|
+
disableInteraction?: boolean;
|
|
33
|
+
showBack?: boolean;
|
|
34
|
+
showSkip?: boolean;
|
|
35
|
+
nextLabel?: string;
|
|
36
|
+
backLabel?: string;
|
|
37
|
+
finishLabel?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Context passed to `renderStep` / `renderFooter` for fully custom popup UI. */
|
|
40
|
+
export interface OnboardingRenderContext extends UseOnboardingReturn {
|
|
41
|
+
step: OnboardingStep;
|
|
42
|
+
}
|
|
43
|
+
/** Imperative handle exposed via `ref` on `Onboarding`. */
|
|
44
|
+
export type OnboardingHandle = UseOnboardingReturn;
|
|
45
|
+
/**
|
|
46
|
+
* Props for `Onboarding`. Most are flow-wide defaults that individual steps can override.
|
|
47
|
+
*
|
|
48
|
+
* @property {string} id - Stable flow id; persistence key.
|
|
49
|
+
* @property {OnboardingStep[]} steps - Ordered steps.
|
|
50
|
+
* @property {boolean} [run] - Controlled active state. Omit to auto-manage (see `autoStart`).
|
|
51
|
+
*/
|
|
52
|
+
export interface OnboardingProps {
|
|
53
|
+
id: string;
|
|
54
|
+
steps: OnboardingStep[];
|
|
55
|
+
run?: boolean;
|
|
56
|
+
autoStart?: boolean;
|
|
57
|
+
persist?: boolean;
|
|
58
|
+
storage?: OnboardingStorage;
|
|
59
|
+
startDelay?: number;
|
|
60
|
+
placement?: OnboardingPlacement;
|
|
61
|
+
spotlightPadding?: number;
|
|
62
|
+
spotlightRadius?: number;
|
|
63
|
+
disableInteraction?: boolean;
|
|
64
|
+
closeOnOverlayClick?: boolean;
|
|
65
|
+
closeOnEsc?: boolean;
|
|
66
|
+
keyboardNavigation?: boolean;
|
|
67
|
+
scrollIntoView?: boolean;
|
|
68
|
+
scrollBehavior?: ScrollBehavior;
|
|
69
|
+
offset?: number;
|
|
70
|
+
zIndex?: number;
|
|
71
|
+
showProgress?: boolean;
|
|
72
|
+
showSkip?: boolean;
|
|
73
|
+
showBack?: boolean;
|
|
74
|
+
showClose?: boolean;
|
|
75
|
+
nextLabel?: string;
|
|
76
|
+
backLabel?: string;
|
|
77
|
+
skipLabel?: string;
|
|
78
|
+
finishLabel?: string;
|
|
79
|
+
className?: string;
|
|
80
|
+
overlayClassName?: string;
|
|
81
|
+
onStart?: () => void;
|
|
82
|
+
onStepChange?: (index: number, previous: number, step: OnboardingStep) => void;
|
|
83
|
+
onSkip?: (index: number) => void;
|
|
84
|
+
onFinish?: () => void;
|
|
85
|
+
onClose?: () => void;
|
|
86
|
+
renderStep?: (ctx: OnboardingRenderContext) => ReactNode;
|
|
87
|
+
renderFooter?: (ctx: OnboardingRenderContext) => ReactNode;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Modular onboarding / product-tour overlay. Drive a flow by `id` with a `steps`
|
|
91
|
+
* array — each step spotlights an element (by selector/id) and shows a popup with
|
|
92
|
+
* Back / Skip / Next controls. Persists completion so a flow shows once.
|
|
93
|
+
*
|
|
94
|
+
* Headless control lives in {@link useOnboarding}; this component is the batteries-included UI.
|
|
95
|
+
*
|
|
96
|
+
* @param {OnboardingProps} props
|
|
97
|
+
* @param {React.Ref<OnboardingHandle>} ref - Imperative controls (`start`, `next`, `skip`, `reset`, …).
|
|
98
|
+
* @returns {JSX.Element | null} A portal with the spotlight overlay + popup while active.
|
|
99
|
+
*/
|
|
100
|
+
export declare const Onboarding: React.ForwardRefExoticComponent<OnboardingProps & React.RefAttributes<UseOnboardingReturn>>;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import "./radio-group.css";
|
|
2
|
+
import { Icon } from "../icon/icon";
|
|
2
3
|
import type { IconType, TooltipPosition } from "../../../types";
|
|
3
4
|
/**
|
|
4
5
|
* One entry in a `RadioGroup` `options` array.
|
|
5
6
|
* @property {string} label - Option title.
|
|
6
7
|
* @property {string} value - Emitted to `onChange` when selected.
|
|
7
8
|
* @property {import("../../../types").IconType} [icon] - Optional leading icon.
|
|
9
|
+
* @property {Omit<React.ComponentProps<typeof Icon>, "icon">} [iconProps] - Extra props forwarded to the built-in `Icon` (and its `<svg>`).
|
|
8
10
|
* @property {"active"|"inactive"} [dot] - Optional status dot style when no icon.
|
|
9
11
|
*/
|
|
10
12
|
export interface RadioOption {
|
|
11
13
|
label: string;
|
|
12
14
|
value: string;
|
|
13
15
|
icon?: IconType;
|
|
16
|
+
iconProps?: Omit<React.ComponentProps<typeof Icon>, "icon">;
|
|
14
17
|
dot?: "active" | "inactive";
|
|
15
18
|
disabled?: boolean;
|
|
16
19
|
tooltip?: string;
|
|
@@ -12,6 +12,7 @@ export * from "./src/use-key-press";
|
|
|
12
12
|
export * from "./src/use-long-press";
|
|
13
13
|
export * from "./src/use-media-query";
|
|
14
14
|
export * from "./src/use-mouse";
|
|
15
|
+
export * from "./src/use-onboarding";
|
|
15
16
|
export * from "./src/use-timeout";
|
|
16
17
|
export { useToast, ToastContext, type ToastContextType } from "./src/use-toast";
|
|
17
18
|
export * from "./src/use-window-scroll";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable persistence adapter for onboarding flows. Swap to back completion
|
|
3
|
+
* with cookies, a backend, or anything else by implementing these two methods.
|
|
4
|
+
*
|
|
5
|
+
* @property {(id: string) => boolean} isCompleted - Whether the flow `id` was already finished/skipped.
|
|
6
|
+
* @property {(id: string, completed: boolean) => void} setCompleted - Persist (or clear) completion for `id`.
|
|
7
|
+
*/
|
|
8
|
+
export interface OnboardingStorage {
|
|
9
|
+
isCompleted: (id: string) => boolean;
|
|
10
|
+
setCompleted: (id: string, completed: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const localStorageOnboarding: OnboardingStorage;
|
|
13
|
+
export declare const memoryOnboarding: OnboardingStorage;
|
|
14
|
+
/**
|
|
15
|
+
* Options for {@link useOnboarding}.
|
|
16
|
+
*
|
|
17
|
+
* @property {string} id - Stable flow identifier; used as the persistence key.
|
|
18
|
+
* @property {number} total - Number of steps in the flow.
|
|
19
|
+
* @property {boolean} [run] - Controlled active state. Omit to let the hook manage start/stop internally.
|
|
20
|
+
* @property {boolean} [autoStart] - In uncontrolled mode, start on mount when the flow is not yet completed. Default `true`.
|
|
21
|
+
* @property {boolean} [persist] - Persist completion so a finished/skipped flow does not auto-restart. Default `true`.
|
|
22
|
+
* @property {OnboardingStorage} [storage] - Persistence adapter. Default `localStorageOnboarding`.
|
|
23
|
+
* @property {number} [startDelay] - Delay (ms) before auto-start, e.g. to let the page settle. Default `0`.
|
|
24
|
+
*/
|
|
25
|
+
export interface UseOnboardingOptions {
|
|
26
|
+
id: string;
|
|
27
|
+
total: number;
|
|
28
|
+
run?: boolean;
|
|
29
|
+
autoStart?: boolean;
|
|
30
|
+
persist?: boolean;
|
|
31
|
+
storage?: OnboardingStorage;
|
|
32
|
+
startDelay?: number;
|
|
33
|
+
onStart?: () => void;
|
|
34
|
+
onStepChange?: (index: number, previous: number) => void;
|
|
35
|
+
onSkip?: (index: number) => void;
|
|
36
|
+
onFinish?: () => void;
|
|
37
|
+
onStop?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/** Imperative control surface + state returned by {@link useOnboarding}. */
|
|
40
|
+
export interface UseOnboardingReturn {
|
|
41
|
+
active: boolean;
|
|
42
|
+
index: number;
|
|
43
|
+
total: number;
|
|
44
|
+
isFirst: boolean;
|
|
45
|
+
isLast: boolean;
|
|
46
|
+
completed: boolean;
|
|
47
|
+
start: () => void;
|
|
48
|
+
stop: () => void;
|
|
49
|
+
next: () => void;
|
|
50
|
+
prev: () => void;
|
|
51
|
+
goTo: (index: number) => void;
|
|
52
|
+
skip: () => void;
|
|
53
|
+
finish: () => void;
|
|
54
|
+
reset: () => void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Headless onboarding/tour state machine: drives a flow by `id`, tracks the
|
|
58
|
+
* current step, persists completion, and supports controlled or uncontrolled use.
|
|
59
|
+
*
|
|
60
|
+
* Pair with the `Onboarding` component for ready-made coachmarks, or render your
|
|
61
|
+
* own UI from the returned state for a fully custom flow.
|
|
62
|
+
*
|
|
63
|
+
* @param {UseOnboardingOptions} options
|
|
64
|
+
* @returns {UseOnboardingReturn} State (`active`, `index`, `isFirst`, …) and controls (`next`, `prev`, `skip`, `finish`, `reset`, …).
|
|
65
|
+
*/
|
|
66
|
+
export declare function useOnboarding({ id, total, run, autoStart, persist, storage, startDelay, onStart, onStepChange, onSkip, onFinish, onStop, }: UseOnboardingOptions): UseOnboardingReturn;
|
|
@@ -34,3 +34,5 @@ export * from "./src/segmented-toggle/segmented-toggle";
|
|
|
34
34
|
export * from "./src/skeleton/skeleton";
|
|
35
35
|
export * from "./src/date-picker/date-picker";
|
|
36
36
|
export * from "./src/time-picker/time-picker";
|
|
37
|
+
export * from "./src/expandable-search/expandable-search";
|
|
38
|
+
export * from "./src/onboarding/onboarding";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./button.css";
|
|
2
2
|
import type { IconType, TooltipPosition } from "../../../types";
|
|
3
|
+
import { Icon } from "../icon/icon";
|
|
3
4
|
import React from "react";
|
|
4
5
|
/**
|
|
5
6
|
* Extends native `HTMLButtonElement` attributes
|
|
@@ -11,6 +12,7 @@ import React from "react";
|
|
|
11
12
|
* @property {"left"|"right"} [iconPosition] - Icon position relative to the label. Default `"right"`.
|
|
12
13
|
* @property {boolean} [iconOnly] - Icon without visible text.
|
|
13
14
|
* @property {number} [iconStrokeWidth] - SVG stroke width for the icon. Default `1.5`.
|
|
15
|
+
* @property {Omit<React.ComponentProps<typeof Icon>, "icon">} [iconProps] - Extra props forwarded to the built-in `Icon` (and its `<svg>`); overrides defaults like `size`/`strokeWidth`.
|
|
14
16
|
* @property {boolean} [isLoading] - Shows a spinner and disables the button. Default `false`.
|
|
15
17
|
* @property {boolean} [fullWidth] - Stretches to 100% width of the container. Default `false`.
|
|
16
18
|
* @property {string} [tooltip] - If set, wraps the button in a `Tooltip` with this text.
|
|
@@ -22,6 +24,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
22
24
|
label?: string;
|
|
23
25
|
iconStrokeWidth?: number;
|
|
24
26
|
icon?: IconType;
|
|
27
|
+
iconProps?: Omit<React.ComponentProps<typeof Icon>, "icon">;
|
|
25
28
|
iconPosition?: "left" | "right";
|
|
26
29
|
iconOnly?: boolean;
|
|
27
30
|
isLoading?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./chip.css";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
import { Icon } from "../icon/icon";
|
|
3
4
|
import type { IconType, TooltipPosition } from "../../../types";
|
|
4
5
|
/**
|
|
5
6
|
* Props for the `Chip` component: extends `HTMLAttributes<HTMLElement>` with H2O badge fields.
|
|
@@ -7,6 +8,7 @@ import type { IconType, TooltipPosition } from "../../../types";
|
|
|
7
8
|
*
|
|
8
9
|
* @property {string} label - Visible text (required).
|
|
9
10
|
* @property {import("../../../types").IconType} [icon] - Leading icon; overrides `dot` when present.
|
|
11
|
+
* @property {Omit<React.ComponentProps<typeof Icon>, "icon">} [iconProps] - Extra props forwarded to the built-in `Icon` (and its `<svg>`); overrides `iconSize`/`iconStrokeWidth`/`iconClassName`.
|
|
10
12
|
* @property {"neutral"|"primary"|"success"|"warning"|"error"} [variant] - Color family. Default `"neutral"`.
|
|
11
13
|
* @property {"sm"|"md"|"lg"} [size] - Padding and font. Default `"md"`.
|
|
12
14
|
* @property {boolean} [dot] - Renders a status dot instead of an icon when no `icon`.
|
|
@@ -16,6 +18,7 @@ import type { IconType, TooltipPosition } from "../../../types";
|
|
|
16
18
|
type ChipProps = React.HTMLAttributes<HTMLElement> & {
|
|
17
19
|
label: string;
|
|
18
20
|
icon?: IconType;
|
|
21
|
+
iconProps?: Omit<React.ComponentProps<typeof Icon>, "icon">;
|
|
19
22
|
variant?: "neutral" | "primary" | "success" | "warning" | "error";
|
|
20
23
|
size?: "sm" | "md" | "lg";
|
|
21
24
|
iconStrokeWidth?: number;
|
|
@@ -33,5 +36,5 @@ type ChipProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
33
36
|
* @param {ChipProps} props - Extends native element props; includes `label` and presentation.
|
|
34
37
|
* @returns {JSX.Element} A `span` or `button`-like chip per `onClick` usage.
|
|
35
38
|
*/
|
|
36
|
-
export declare const Chip: ({ label, icon, variant, size, iconStrokeWidth, iconClassName, iconSize, disabled, showBorder, dot, tooltip, tooltipPosition, className, onClick, ...props }: ChipProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare const Chip: ({ label, icon, iconProps, variant, size, iconStrokeWidth, iconClassName, iconSize, disabled, showBorder, dot, tooltip, tooltipPosition, className, onClick, ...props }: ChipProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
40
|
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import "./content-switch.css";
|
|
2
|
+
import { Icon } from "../icon/icon";
|
|
2
3
|
import type { IconType } from "../../../types";
|
|
3
4
|
/**
|
|
4
5
|
* Tab-like option in a `ContentSwitch` row (`role="tablist"` / `role="tab"`).
|
|
5
6
|
* @property {string} value - Passed to `onChange` when selected.
|
|
6
7
|
* @property {IconType} [icon] - Optional leading icon on the tab.
|
|
8
|
+
* @property {Omit<React.ComponentProps<typeof Icon>, "icon">} [iconProps] - Extra props forwarded to the built-in `Icon` (and its `<svg>`).
|
|
7
9
|
*/
|
|
8
10
|
export type ContentSwitchOption = {
|
|
9
11
|
label: string;
|
|
10
12
|
value: string;
|
|
11
13
|
icon?: IconType;
|
|
14
|
+
iconProps?: Omit<React.ComponentProps<typeof Icon>, "icon">;
|
|
12
15
|
disabled?: boolean;
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "./expandable-search.css";
|
|
2
|
+
/**
|
|
3
|
+
* Props for `ExpandableSearch`.
|
|
4
|
+
*
|
|
5
|
+
* @property {"sm"|"md"|"lg"} [size] - Trigger and expanded field height. Default `"md"`.
|
|
6
|
+
* @property {string} [value] - Controlled value. When provided, the parent owns state.
|
|
7
|
+
* @property {string} [defaultValue] - Initial value when uncontrolled. Default `""`.
|
|
8
|
+
* @property {boolean} [defaultExpanded] - Initial expanded state when uncontrolled. Default `false`.
|
|
9
|
+
* @property {string} [placeholder] - Input placeholder. Default `"Search..."`.
|
|
10
|
+
* @property {number} [expandedWidth] - Width of the input area in px when expanded. Default `200`.
|
|
11
|
+
* @property {(value: string) => void} [onChange] - Fires on each keystroke with the new value.
|
|
12
|
+
* @property {(expanded: boolean) => void} [onExpandedChange] - Fires when expanded state changes.
|
|
13
|
+
* @property {string} [className] - Extra class names on the wrapper.
|
|
14
|
+
* @property {string} [openAriaLabel] - Aria label for the trigger when collapsed. Default `"Open search"`.
|
|
15
|
+
* @property {string} [closeAriaLabel] - Aria label for the trigger when expanded. Default `"Close search"`.
|
|
16
|
+
*/
|
|
17
|
+
interface ExpandableSearchProps {
|
|
18
|
+
size?: "sm" | "md" | "lg";
|
|
19
|
+
value?: string;
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
defaultExpanded?: boolean;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
expandedWidth?: number;
|
|
24
|
+
onChange?: (value: string) => void;
|
|
25
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
26
|
+
className?: string;
|
|
27
|
+
openAriaLabel?: string;
|
|
28
|
+
closeAriaLabel?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Icon-only search trigger that expands into an inline input on click.
|
|
32
|
+
*
|
|
33
|
+
* Collapses automatically when the user clicks outside while the input is empty.
|
|
34
|
+
* Toggling while expanded clears the value. Supports controlled or uncontrolled value.
|
|
35
|
+
*
|
|
36
|
+
* @param {ExpandableSearchProps} props - Controlled/uncontrolled value and presentation.
|
|
37
|
+
* @returns {JSX.Element} A pill-shaped wrapper containing the input and toggle button.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ExpandableSearch: ({ size, value, defaultValue, defaultExpanded, placeholder, expandedWidth, onChange, onExpandedChange, className, openAriaLabel, closeAriaLabel, }: ExpandableSearchProps) => JSX.Element;
|
|
40
|
+
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import "./input.css";
|
|
2
2
|
import type { IconType, TooltipPosition } from "../../../types";
|
|
3
|
+
import { Icon } from "../icon/icon";
|
|
3
4
|
/**
|
|
4
5
|
* Extends `HTMLInputElement` attributes
|
|
5
6
|
*
|
|
6
7
|
* @property {"sm"|"md"|"lg"} [size] - Field height and font scale. Default `"md"`.
|
|
7
8
|
* @property {import("../../../types").IconType} [leftIcon] - Optional left decorative/action icon.
|
|
9
|
+
* @property {Omit<React.ComponentProps<typeof Icon>, "icon">} [leftIconProps] - Extra props forwarded to the left `Icon` (and its `<svg>`).
|
|
8
10
|
* @property {import("../../../types").IconType} [rightIcon] - Optional right icon; pair with `onRightIconClick` for an action.
|
|
11
|
+
* @property {Omit<React.ComponentProps<typeof Icon>, "icon">} [rightIconProps] - Extra props forwarded to the right `Icon` (and its `<svg>`).
|
|
9
12
|
* @property {boolean} [showClear] - Shows a clear control when the field has a value. Default `false`.
|
|
10
13
|
* @property {string} [note] - Helper text below the field (non-error).
|
|
11
14
|
* @property {string} [error] - Error message; styles the field as invalid when set.
|
|
@@ -16,7 +19,9 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
|
|
16
19
|
size?: "sm" | "md" | "lg";
|
|
17
20
|
label?: string;
|
|
18
21
|
leftIcon?: IconType;
|
|
22
|
+
leftIconProps?: Omit<React.ComponentProps<typeof Icon>, "icon">;
|
|
19
23
|
rightIcon?: IconType;
|
|
24
|
+
rightIconProps?: Omit<React.ComponentProps<typeof Icon>, "icon">;
|
|
20
25
|
onRightIconClick?: () => void;
|
|
21
26
|
showClear?: boolean;
|
|
22
27
|
note?: string;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import "./onboarding.css";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { type OnboardingStorage, type UseOnboardingReturn } from "../../../hooks/src/use-onboarding";
|
|
5
|
+
/** Where a step popup sits relative to its target. `"center"` ignores the target and centers on screen. */
|
|
6
|
+
export type OnboardingPlacement = "top" | "bottom" | "left" | "right" | "auto" | "center";
|
|
7
|
+
/**
|
|
8
|
+
* How a step finds its anchor element:
|
|
9
|
+
* - `string` — a CSS selector (e.g. `"#sidebar"`, `".profile"`, `"[data-tour=save]"`). A bare word falls back to an element id.
|
|
10
|
+
* - `HTMLElement` — the element directly.
|
|
11
|
+
* - `() => HTMLElement | null` — resolved lazily when the step shows.
|
|
12
|
+
*/
|
|
13
|
+
export type OnboardingTarget = string | HTMLElement | (() => HTMLElement | null);
|
|
14
|
+
/**
|
|
15
|
+
* A single step in an onboarding flow.
|
|
16
|
+
*
|
|
17
|
+
* @property {OnboardingTarget} [target] - Element to anchor + spotlight. Omit for a centered step (welcome/finish screens).
|
|
18
|
+
* @property {ReactNode} [title] - Heading shown at the top of the popup.
|
|
19
|
+
* @property {ReactNode} content - Body message (required).
|
|
20
|
+
* @property {OnboardingPlacement} [placement] - Popup side. Default: the flow's `placement` (which defaults to `"auto"`).
|
|
21
|
+
* @property {number} [spotlightPadding] - Extra px around the target in the spotlight cutout.
|
|
22
|
+
* @property {number} [spotlightRadius] - Spotlight corner radius in px.
|
|
23
|
+
* @property {boolean} [disableInteraction] - Block clicks on the spotlighted element. Default: the flow's `disableInteraction`.
|
|
24
|
+
*/
|
|
25
|
+
export interface OnboardingStep {
|
|
26
|
+
target?: OnboardingTarget;
|
|
27
|
+
title?: ReactNode;
|
|
28
|
+
content: ReactNode;
|
|
29
|
+
placement?: OnboardingPlacement;
|
|
30
|
+
spotlightPadding?: number;
|
|
31
|
+
spotlightRadius?: number;
|
|
32
|
+
disableInteraction?: boolean;
|
|
33
|
+
showBack?: boolean;
|
|
34
|
+
showSkip?: boolean;
|
|
35
|
+
nextLabel?: string;
|
|
36
|
+
backLabel?: string;
|
|
37
|
+
finishLabel?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Context passed to `renderStep` / `renderFooter` for fully custom popup UI. */
|
|
40
|
+
export interface OnboardingRenderContext extends UseOnboardingReturn {
|
|
41
|
+
step: OnboardingStep;
|
|
42
|
+
}
|
|
43
|
+
/** Imperative handle exposed via `ref` on `Onboarding`. */
|
|
44
|
+
export type OnboardingHandle = UseOnboardingReturn;
|
|
45
|
+
/**
|
|
46
|
+
* Props for `Onboarding`. Most are flow-wide defaults that individual steps can override.
|
|
47
|
+
*
|
|
48
|
+
* @property {string} id - Stable flow id; persistence key.
|
|
49
|
+
* @property {OnboardingStep[]} steps - Ordered steps.
|
|
50
|
+
* @property {boolean} [run] - Controlled active state. Omit to auto-manage (see `autoStart`).
|
|
51
|
+
*/
|
|
52
|
+
export interface OnboardingProps {
|
|
53
|
+
id: string;
|
|
54
|
+
steps: OnboardingStep[];
|
|
55
|
+
run?: boolean;
|
|
56
|
+
autoStart?: boolean;
|
|
57
|
+
persist?: boolean;
|
|
58
|
+
storage?: OnboardingStorage;
|
|
59
|
+
startDelay?: number;
|
|
60
|
+
placement?: OnboardingPlacement;
|
|
61
|
+
spotlightPadding?: number;
|
|
62
|
+
spotlightRadius?: number;
|
|
63
|
+
disableInteraction?: boolean;
|
|
64
|
+
closeOnOverlayClick?: boolean;
|
|
65
|
+
closeOnEsc?: boolean;
|
|
66
|
+
keyboardNavigation?: boolean;
|
|
67
|
+
scrollIntoView?: boolean;
|
|
68
|
+
scrollBehavior?: ScrollBehavior;
|
|
69
|
+
offset?: number;
|
|
70
|
+
zIndex?: number;
|
|
71
|
+
showProgress?: boolean;
|
|
72
|
+
showSkip?: boolean;
|
|
73
|
+
showBack?: boolean;
|
|
74
|
+
showClose?: boolean;
|
|
75
|
+
nextLabel?: string;
|
|
76
|
+
backLabel?: string;
|
|
77
|
+
skipLabel?: string;
|
|
78
|
+
finishLabel?: string;
|
|
79
|
+
className?: string;
|
|
80
|
+
overlayClassName?: string;
|
|
81
|
+
onStart?: () => void;
|
|
82
|
+
onStepChange?: (index: number, previous: number, step: OnboardingStep) => void;
|
|
83
|
+
onSkip?: (index: number) => void;
|
|
84
|
+
onFinish?: () => void;
|
|
85
|
+
onClose?: () => void;
|
|
86
|
+
renderStep?: (ctx: OnboardingRenderContext) => ReactNode;
|
|
87
|
+
renderFooter?: (ctx: OnboardingRenderContext) => ReactNode;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Modular onboarding / product-tour overlay. Drive a flow by `id` with a `steps`
|
|
91
|
+
* array — each step spotlights an element (by selector/id) and shows a popup with
|
|
92
|
+
* Back / Skip / Next controls. Persists completion so a flow shows once.
|
|
93
|
+
*
|
|
94
|
+
* Headless control lives in {@link useOnboarding}; this component is the batteries-included UI.
|
|
95
|
+
*
|
|
96
|
+
* @param {OnboardingProps} props
|
|
97
|
+
* @param {React.Ref<OnboardingHandle>} ref - Imperative controls (`start`, `next`, `skip`, `reset`, …).
|
|
98
|
+
* @returns {JSX.Element | null} A portal with the spotlight overlay + popup while active.
|
|
99
|
+
*/
|
|
100
|
+
export declare const Onboarding: React.ForwardRefExoticComponent<OnboardingProps & React.RefAttributes<UseOnboardingReturn>>;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import "./radio-group.css";
|
|
2
|
+
import { Icon } from "../icon/icon";
|
|
2
3
|
import type { IconType, TooltipPosition } from "../../../types";
|
|
3
4
|
/**
|
|
4
5
|
* One entry in a `RadioGroup` `options` array.
|
|
5
6
|
* @property {string} label - Option title.
|
|
6
7
|
* @property {string} value - Emitted to `onChange` when selected.
|
|
7
8
|
* @property {import("../../../types").IconType} [icon] - Optional leading icon.
|
|
9
|
+
* @property {Omit<React.ComponentProps<typeof Icon>, "icon">} [iconProps] - Extra props forwarded to the built-in `Icon` (and its `<svg>`).
|
|
8
10
|
* @property {"active"|"inactive"} [dot] - Optional status dot style when no icon.
|
|
9
11
|
*/
|
|
10
12
|
export interface RadioOption {
|
|
11
13
|
label: string;
|
|
12
14
|
value: string;
|
|
13
15
|
icon?: IconType;
|
|
16
|
+
iconProps?: Omit<React.ComponentProps<typeof Icon>, "icon">;
|
|
14
17
|
dot?: "active" | "inactive";
|
|
15
18
|
disabled?: boolean;
|
|
16
19
|
tooltip?: string;
|
|
@@ -12,6 +12,7 @@ export * from "./src/use-key-press";
|
|
|
12
12
|
export * from "./src/use-long-press";
|
|
13
13
|
export * from "./src/use-media-query";
|
|
14
14
|
export * from "./src/use-mouse";
|
|
15
|
+
export * from "./src/use-onboarding";
|
|
15
16
|
export * from "./src/use-timeout";
|
|
16
17
|
export { useToast, ToastContext, type ToastContextType } from "./src/use-toast";
|
|
17
18
|
export * from "./src/use-window-scroll";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable persistence adapter for onboarding flows. Swap to back completion
|
|
3
|
+
* with cookies, a backend, or anything else by implementing these two methods.
|
|
4
|
+
*
|
|
5
|
+
* @property {(id: string) => boolean} isCompleted - Whether the flow `id` was already finished/skipped.
|
|
6
|
+
* @property {(id: string, completed: boolean) => void} setCompleted - Persist (or clear) completion for `id`.
|
|
7
|
+
*/
|
|
8
|
+
export interface OnboardingStorage {
|
|
9
|
+
isCompleted: (id: string) => boolean;
|
|
10
|
+
setCompleted: (id: string, completed: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const localStorageOnboarding: OnboardingStorage;
|
|
13
|
+
export declare const memoryOnboarding: OnboardingStorage;
|
|
14
|
+
/**
|
|
15
|
+
* Options for {@link useOnboarding}.
|
|
16
|
+
*
|
|
17
|
+
* @property {string} id - Stable flow identifier; used as the persistence key.
|
|
18
|
+
* @property {number} total - Number of steps in the flow.
|
|
19
|
+
* @property {boolean} [run] - Controlled active state. Omit to let the hook manage start/stop internally.
|
|
20
|
+
* @property {boolean} [autoStart] - In uncontrolled mode, start on mount when the flow is not yet completed. Default `true`.
|
|
21
|
+
* @property {boolean} [persist] - Persist completion so a finished/skipped flow does not auto-restart. Default `true`.
|
|
22
|
+
* @property {OnboardingStorage} [storage] - Persistence adapter. Default `localStorageOnboarding`.
|
|
23
|
+
* @property {number} [startDelay] - Delay (ms) before auto-start, e.g. to let the page settle. Default `0`.
|
|
24
|
+
*/
|
|
25
|
+
export interface UseOnboardingOptions {
|
|
26
|
+
id: string;
|
|
27
|
+
total: number;
|
|
28
|
+
run?: boolean;
|
|
29
|
+
autoStart?: boolean;
|
|
30
|
+
persist?: boolean;
|
|
31
|
+
storage?: OnboardingStorage;
|
|
32
|
+
startDelay?: number;
|
|
33
|
+
onStart?: () => void;
|
|
34
|
+
onStepChange?: (index: number, previous: number) => void;
|
|
35
|
+
onSkip?: (index: number) => void;
|
|
36
|
+
onFinish?: () => void;
|
|
37
|
+
onStop?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/** Imperative control surface + state returned by {@link useOnboarding}. */
|
|
40
|
+
export interface UseOnboardingReturn {
|
|
41
|
+
active: boolean;
|
|
42
|
+
index: number;
|
|
43
|
+
total: number;
|
|
44
|
+
isFirst: boolean;
|
|
45
|
+
isLast: boolean;
|
|
46
|
+
completed: boolean;
|
|
47
|
+
start: () => void;
|
|
48
|
+
stop: () => void;
|
|
49
|
+
next: () => void;
|
|
50
|
+
prev: () => void;
|
|
51
|
+
goTo: (index: number) => void;
|
|
52
|
+
skip: () => void;
|
|
53
|
+
finish: () => void;
|
|
54
|
+
reset: () => void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Headless onboarding/tour state machine: drives a flow by `id`, tracks the
|
|
58
|
+
* current step, persists completion, and supports controlled or uncontrolled use.
|
|
59
|
+
*
|
|
60
|
+
* Pair with the `Onboarding` component for ready-made coachmarks, or render your
|
|
61
|
+
* own UI from the returned state for a fully custom flow.
|
|
62
|
+
*
|
|
63
|
+
* @param {UseOnboardingOptions} options
|
|
64
|
+
* @returns {UseOnboardingReturn} State (`active`, `index`, `isFirst`, …) and controls (`next`, `prev`, `skip`, `finish`, `reset`, …).
|
|
65
|
+
*/
|
|
66
|
+
export declare function useOnboarding({ id, total, run, autoStart, persist, storage, startDelay, onStart, onStepChange, onSkip, onFinish, onStop, }: UseOnboardingOptions): UseOnboardingReturn;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "h2o-library",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "A set of components for H2O
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "A set of components for H2O Apps development",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -103,5 +103,10 @@
|
|
|
103
103
|
"clsx": "^2.1.1",
|
|
104
104
|
"recharts": "^2.15.3",
|
|
105
105
|
"tailwind-merge": "^3.0.2"
|
|
106
|
+
},
|
|
107
|
+
"overrides": {
|
|
108
|
+
"@storybook/addon-actions": {
|
|
109
|
+
"uuid": "^11.1.1"
|
|
110
|
+
}
|
|
106
111
|
}
|
|
107
112
|
}
|