@g4rcez/components 3.0.0 → 3.0.1

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.
Files changed (176) hide show
  1. package/dist/ai/SKILL.md +266 -0
  2. package/dist/ai/docs/Alert.md +167 -0
  3. package/dist/ai/docs/AnimatedList.md +205 -0
  4. package/dist/ai/docs/Autocomplete.md +225 -0
  5. package/dist/ai/docs/Button.md +182 -0
  6. package/dist/ai/docs/Calendar.md +219 -0
  7. package/dist/ai/docs/Card.md +174 -0
  8. package/dist/ai/docs/Checkbox.md +199 -0
  9. package/dist/ai/docs/CommandPalette.md +293 -0
  10. package/dist/ai/docs/DatePicker.md +171 -0
  11. package/dist/ai/docs/Dropdown.md +223 -0
  12. package/dist/ai/docs/Empty.md +163 -0
  13. package/dist/ai/docs/Expand.md +143 -0
  14. package/dist/ai/docs/FileUpload.md +225 -0
  15. package/dist/ai/docs/Form.md +107 -0
  16. package/dist/ai/docs/FormReset.md +117 -0
  17. package/dist/ai/docs/Heading.md +88 -0
  18. package/dist/ai/docs/Input.md +237 -0
  19. package/dist/ai/docs/InputField.md +170 -0
  20. package/dist/ai/docs/List.md +205 -0
  21. package/dist/ai/docs/Menu.md +166 -0
  22. package/dist/ai/docs/Modal.md +280 -0
  23. package/dist/ai/docs/MultiSelect.md +196 -0
  24. package/dist/ai/docs/Notifications.md +231 -0
  25. package/dist/ai/docs/PageCalendar.md +271 -0
  26. package/dist/ai/docs/Polymorph.md +159 -0
  27. package/dist/ai/docs/Progress.md +145 -0
  28. package/dist/ai/docs/Radiobox.md +128 -0
  29. package/dist/ai/docs/RenderOnView.md +138 -0
  30. package/dist/ai/docs/Resizable.md +159 -0
  31. package/dist/ai/docs/Select.md +284 -0
  32. package/dist/ai/docs/Shortcut.md +105 -0
  33. package/dist/ai/docs/Skeleton.md +166 -0
  34. package/dist/ai/docs/Slider.md +144 -0
  35. package/dist/ai/docs/Slot.md +173 -0
  36. package/dist/ai/docs/Spinner.md +118 -0
  37. package/dist/ai/docs/Stats.md +137 -0
  38. package/dist/ai/docs/Step.md +159 -0
  39. package/dist/ai/docs/Switch.md +167 -0
  40. package/dist/ai/docs/Table.md +298 -0
  41. package/dist/ai/docs/Tabs.md +191 -0
  42. package/dist/ai/docs/Tag.md +224 -0
  43. package/dist/ai/docs/TaskList.md +144 -0
  44. package/dist/ai/docs/Textarea.md +167 -0
  45. package/dist/ai/docs/Timeline.md +210 -0
  46. package/dist/ai/docs/Toolbar.md +132 -0
  47. package/dist/ai/docs/Tooltip.md +231 -0
  48. package/dist/ai/docs/TransferList.md +142 -0
  49. package/dist/ai/docs/Typography.md +187 -0
  50. package/dist/ai/docs/Wizard.md +213 -0
  51. package/dist/ai/docs/index.md +183 -0
  52. package/dist/components/core/tag.d.ts +1 -1
  53. package/dist/components/core/tag.d.ts.map +1 -1
  54. package/dist/components/display/list.d.ts.map +1 -1
  55. package/dist/components/floating/dropdown.d.ts +1 -0
  56. package/dist/components/floating/dropdown.d.ts.map +1 -1
  57. package/dist/components/floating/menu.d.ts.map +1 -1
  58. package/dist/config/default-translations.d.ts +4 -4
  59. package/dist/hooks/use-translations.d.ts +4 -4
  60. package/dist/hooks/use-translations.d.ts.map +1 -1
  61. package/dist/index.css +1 -1
  62. package/dist/index.js +28 -20
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +2463 -2458
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/index.umd.js +12 -12
  67. package/dist/index.umd.js.map +1 -1
  68. package/package.json +4 -4
  69. package/dist/components/core/button.jsx +0 -79
  70. package/dist/components/core/heading.jsx +0 -4
  71. package/dist/components/core/polymorph.jsx +0 -5
  72. package/dist/components/core/render-on-view.jsx +0 -31
  73. package/dist/components/core/resizable.jsx +0 -51
  74. package/dist/components/core/slot.jsx +0 -156
  75. package/dist/components/core/tag.jsx +0 -51
  76. package/dist/components/core/typography.jsx +0 -22
  77. package/dist/components/display/alert.jsx +0 -58
  78. package/dist/components/display/calendar.jsx +0 -299
  79. package/dist/components/display/card.jsx +0 -43
  80. package/dist/components/display/empty.jsx +0 -11
  81. package/dist/components/display/list.jsx +0 -81
  82. package/dist/components/display/notifications.jsx +0 -126
  83. package/dist/components/display/progress.jsx +0 -11
  84. package/dist/components/display/shortcut.jsx +0 -23
  85. package/dist/components/display/skeleton.jsx +0 -12
  86. package/dist/components/display/spinner.jsx +0 -7
  87. package/dist/components/display/stats.jsx +0 -20
  88. package/dist/components/display/step.jsx +0 -131
  89. package/dist/components/display/tabs.jsx +0 -98
  90. package/dist/components/display/timeline.jsx +0 -25
  91. package/dist/components/floating/command-palette.jsx +0 -194
  92. package/dist/components/floating/dropdown.jsx +0 -53
  93. package/dist/components/floating/expand.jsx +0 -44
  94. package/dist/components/floating/menu.jsx +0 -147
  95. package/dist/components/floating/modal.jsx +0 -299
  96. package/dist/components/floating/toolbar.jsx +0 -5
  97. package/dist/components/floating/tooltip.jsx +0 -58
  98. package/dist/components/floating/wizard.jsx +0 -161
  99. package/dist/components/form/autocomplete.jsx +0 -279
  100. package/dist/components/form/checkbox.jsx +0 -12
  101. package/dist/components/form/date-picker.jsx +0 -115
  102. package/dist/components/form/file-upload.jsx +0 -133
  103. package/dist/components/form/form.jsx +0 -10
  104. package/dist/components/form/formReset.jsx +0 -17
  105. package/dist/components/form/free-text.jsx +0 -41
  106. package/dist/components/form/input-field.jsx +0 -56
  107. package/dist/components/form/input.jsx +0 -36
  108. package/dist/components/form/multi-select.jsx +0 -328
  109. package/dist/components/form/radiobox.jsx +0 -6
  110. package/dist/components/form/select.jsx +0 -42
  111. package/dist/components/form/slider.jsx +0 -45
  112. package/dist/components/form/switch.jsx +0 -46
  113. package/dist/components/form/task-list.jsx +0 -26
  114. package/dist/components/form/textarea.jsx +0 -12
  115. package/dist/components/form/transfer-list.jsx +0 -39
  116. package/dist/components/index.js +0 -45
  117. package/dist/components/page-calendar/calendar-header.jsx +0 -81
  118. package/dist/components/page-calendar/day-view.jsx +0 -87
  119. package/dist/components/page-calendar/event-pill.jsx +0 -25
  120. package/dist/components/page-calendar/index.js +0 -2
  121. package/dist/components/page-calendar/month-view.jsx +0 -47
  122. package/dist/components/page-calendar/page-calendar.jsx +0 -41
  123. package/dist/components/page-calendar/page-calendar.types.js +0 -1
  124. package/dist/components/page-calendar/page-calendar.utils.js +0 -71
  125. package/dist/components/page-calendar/week-view.jsx +0 -64
  126. package/dist/components/table/filter.jsx +0 -141
  127. package/dist/components/table/group.jsx +0 -68
  128. package/dist/components/table/index.jsx +0 -60
  129. package/dist/components/table/inner-table.jsx +0 -104
  130. package/dist/components/table/metadata.jsx +0 -36
  131. package/dist/components/table/pagination.jsx +0 -73
  132. package/dist/components/table/row.jsx +0 -58
  133. package/dist/components/table/sort.jsx +0 -105
  134. package/dist/components/table/table-lib.js +0 -83
  135. package/dist/components/table/table.context.jsx +0 -4
  136. package/dist/components/table/thead.jsx +0 -103
  137. package/dist/config/context.js +0 -12
  138. package/dist/config/default-translations.jsx +0 -83
  139. package/dist/config/default-tweaks.js +0 -4
  140. package/dist/constants.js +0 -2
  141. package/dist/hooks/use-click-outside.js +0 -17
  142. package/dist/hooks/use-color-parser.js +0 -9
  143. package/dist/hooks/use-components-provider.jsx +0 -19
  144. package/dist/hooks/use-debounce.js +0 -12
  145. package/dist/hooks/use-floating-ref.js +0 -6
  146. package/dist/hooks/use-form.js +0 -550
  147. package/dist/hooks/use-hover.js +0 -18
  148. package/dist/hooks/use-input-id.js +0 -5
  149. package/dist/hooks/use-is-coarse-device.js +0 -12
  150. package/dist/hooks/use-locale.js +0 -10
  151. package/dist/hooks/use-media-query.js +0 -25
  152. package/dist/hooks/use-on-event.js +0 -7
  153. package/dist/hooks/use-parent.js +0 -21
  154. package/dist/hooks/use-preferences.js +0 -23
  155. package/dist/hooks/use-previous.js +0 -9
  156. package/dist/hooks/use-reactive.js +0 -9
  157. package/dist/hooks/use-remove-scroll.js +0 -61
  158. package/dist/hooks/use-resize-observer.js +0 -17
  159. package/dist/hooks/use-stable-ref.js +0 -9
  160. package/dist/hooks/use-swipe.js +0 -17
  161. package/dist/hooks/use-translations.js +0 -9
  162. package/dist/hooks/use-tweaks.js +0 -9
  163. package/dist/hooks/use-window-size.js +0 -14
  164. package/dist/lib/combi-keys.js +0 -60
  165. package/dist/lib/dict.js +0 -39
  166. package/dist/lib/dom.js +0 -62
  167. package/dist/lib/fns.js +0 -46
  168. package/dist/lib/fzf.js +0 -117
  169. package/dist/lib/keyboard-area.js +0 -14
  170. package/dist/styles/common.js +0 -29
  171. package/dist/styles/dark.js +0 -214
  172. package/dist/styles/design-tokens.js +0 -69
  173. package/dist/styles/light.js +0 -214
  174. package/dist/styles/theme.js +0 -4
  175. package/dist/styles/theme.types.js +0 -1
  176. package/dist/types.js +0 -1
@@ -0,0 +1,142 @@
1
+ ---
2
+ title: TransferList
3
+ description: Two-panel component for moving items between a source list and a target list.
4
+ package: "@g4rcez/components"
5
+ export: "{ TransferList }"
6
+ import: "import { TransferList } from '@g4rcez/components/transfer-list'"
7
+ category: form
8
+ ---
9
+
10
+ # TransferList
11
+
12
+ Two-panel component for moving items between a source list and a target list.
13
+
14
+ ## Import
15
+
16
+ ```tsx
17
+ import { TransferList } from "@g4rcez/components/transfer-list";
18
+ ```
19
+
20
+ ## Props
21
+
22
+ | Prop | Type | Default | Description |
23
+ |------|------|---------|-------------|
24
+ | `source` | `T[]` | — | Items in the left (available) list. |
25
+ | `target` | `T[]` | — | Items in the right (selected) list. |
26
+ | `Item` | `React.FC<{ data: T }>` | — | Component used to render each list row. |
27
+ | `reference` | `keyof T` | — | Unique key used to identify and compare items (e.g., `"id"`). |
28
+ | `setSource` | `Dispatch<SetStateAction<T[]>>` | — | State setter for the source list. |
29
+ | `setTarget` | `Dispatch<SetStateAction<T[]>>` | — | State setter for the target list. |
30
+
31
+ ## Design Tokens
32
+
33
+ Tokens this component reads. Customize by overriding these CSS variables in your theme.
34
+
35
+ | Token | CSS Variable | Purpose |
36
+ |-------|-------------|---------|
37
+ | `border-card-border` | `--card-border` | Border around each list panel |
38
+ | `bg-background` | `--background` | Panel background (inherited) |
39
+ | `text-foreground` | `--foreground` | Item text color (inherited) |
40
+ | `border-border` | `--border` | Section divider inside the panel header |
41
+
42
+ ## Examples
43
+
44
+ ### Basic transfer list
45
+
46
+ ```tsx
47
+ import { useState } from "react";
48
+ import { TransferList } from "@g4rcez/components/transfer-list";
49
+
50
+ type Role = { id: string; name: string };
51
+
52
+ const allRoles: Role[] = [
53
+ { id: "admin", name: "Administrator" },
54
+ { id: "editor", name: "Editor" },
55
+ { id: "viewer", name: "Viewer" },
56
+ { id: "auditor", name: "Auditor" },
57
+ ];
58
+
59
+ const RoleItem: React.FC<{ data: Role }> = ({ data }) => (
60
+ <span className="text-sm text-foreground">{data.name}</span>
61
+ );
62
+
63
+ export default function RoleAssignment() {
64
+ const [available, setAvailable] = useState(allRoles);
65
+ const [assigned, setAssigned] = useState<Role[]>([]);
66
+
67
+ return (
68
+ <TransferList
69
+ source={available}
70
+ target={assigned}
71
+ setSource={setAvailable}
72
+ setTarget={setAssigned}
73
+ reference="id"
74
+ Item={RoleItem}
75
+ />
76
+ );
77
+ }
78
+ ```
79
+
80
+ ### With custom item rendering
81
+
82
+ ```tsx
83
+ import { ShieldIcon } from "lucide-react";
84
+ import { TransferList } from "@g4rcez/components/transfer-list";
85
+
86
+ type Permission = { id: string; label: string; scope: string };
87
+
88
+ const PermissionItem: React.FC<{ data: Permission }> = ({ data }) => (
89
+ <span className="flex items-center gap-base">
90
+ <ShieldIcon size={14} className="text-primary" />
91
+ <span className="text-sm text-foreground">{data.label}</span>
92
+ <span className="ml-auto text-xs text-muted-foreground">{data.scope}</span>
93
+ </span>
94
+ );
95
+
96
+ export default function PermissionManager() {
97
+ const [source, setSource] = useState(allPermissions);
98
+ const [target, setTarget] = useState<Permission[]>([]);
99
+
100
+ return (
101
+ <TransferList
102
+ source={source}
103
+ target={target}
104
+ setSource={setSource}
105
+ setTarget={setTarget}
106
+ reference="id"
107
+ Item={PermissionItem}
108
+ />
109
+ );
110
+ }
111
+ ```
112
+
113
+ ## Do
114
+
115
+ - Provide a unique, stable `reference` key for each item (typically the primary key from your data model).
116
+ - Use `TransferList` when users need to pick a significant number of items from a large pool.
117
+ - Keep the `Item` component focused on displaying — handle mutations via `setSource` / `setTarget`.
118
+ - Use design-token classes inside `Item` for text and icon colors (`text-foreground`, `text-primary`, `text-muted-foreground`).
119
+
120
+ ## Don't
121
+
122
+ - Don't use `TransferList` for very small lists (3–5 items) where `MultiSelect` or a `Checkbox` group would be faster.
123
+ - Don't perform expensive side effects inside the `Item` component — keep it purely presentational.
124
+ - Don't pass raw Tailwind color classes (`bg-blue-500`, `text-white`, `border-gray-300`) — use design tokens instead.
125
+ - Don't use arbitrary Tailwind values (`bg-[#abc]`) — override CSS variables in your `@theme` block instead.
126
+
127
+ ## Accessibility
128
+
129
+ - Each item is rendered with a `Checkbox` for selection, giving it full keyboard and screen-reader support.
130
+ - Lists are virtualized using `react-virtuoso` for performance with large datasets.
131
+ - Transfer buttons use `ChevronRightIcon` from `lucide-react` and should have descriptive `aria-label` attributes when used.
132
+
133
+ ## Data Attributes
134
+
135
+ The `TransferList` component does not set component-specific `data-*` attributes directly. Individual list items inherit `data-component` and accessibility attributes from the embedded `Checkbox` components.
136
+
137
+ ## Notes
138
+
139
+ - Uses `react-virtuoso` with a `useWindowScroll` strategy — the list height adapts to the parent container via `useParentHeight`.
140
+ - The source panel includes a built-in `Input` search field for quick filtering.
141
+ - The component is a generic `<T extends POJO>` — TypeScript will infer `T` from `source` and `target` props.
142
+ - Only the source-to-target transfer button (`ChevronRightIcon`) is currently wired in the implementation; bidirectional transfer requires wiring additional buttons if needed.
@@ -0,0 +1,187 @@
1
+ ---
2
+ title: Typography
3
+ description: A set of text and page-structure components for consistent typographic styling.
4
+ package: "@g4rcez/components"
5
+ export: "{ Paragraph, Description, Info, PageTitle, PageHeader }"
6
+ import: "import { Paragraph, Description, Info, PageTitle, PageHeader } from '@g4rcez/components'"
7
+ category: core
8
+ ---
9
+
10
+ # Typography
11
+
12
+ A set of text and page-structure components for consistent typographic styling across the application. Exports `Paragraph`, `Description`, `Info`, `PageTitle`, and `PageHeader`.
13
+
14
+ ## Import
15
+
16
+ ```tsx
17
+ import {
18
+ Paragraph,
19
+ Description,
20
+ Info,
21
+ PageTitle,
22
+ PageHeader,
23
+ } from "@g4rcez/components";
24
+ ```
25
+
26
+ ## Props
27
+
28
+ ### Paragraph
29
+
30
+ Renders a `<p>` element with `text-base leading-snug`.
31
+
32
+ | Prop | Type | Default | Description |
33
+ |------|------|---------|-------------|
34
+ | `children` | `React.ReactNode` | - | Paragraph content |
35
+ | `className` | `string` | - | Additional CSS classes |
36
+ | `...props` | `React.ComponentProps<"p">` | - | All standard `<p>` attributes |
37
+
38
+ ### Description
39
+
40
+ Renders a `<p>` element with `text-sm text-secondary mb-kilo`.
41
+
42
+ | Prop | Type | Default | Description |
43
+ |------|------|---------|-------------|
44
+ | `children` | `React.ReactNode` | - | Description content |
45
+ | `className` | `string` | - | Additional CSS classes |
46
+ | `...props` | `React.ComponentProps<"p">` | - | All standard `<p>` attributes |
47
+
48
+ ### Info
49
+
50
+ Renders a labeled key-value pair in a flex container.
51
+
52
+ | Prop | Type | Default | Description |
53
+ |------|------|---------|-------------|
54
+ | `label` | `Label` | - | The label text (required) |
55
+ | `children` | `React.ReactNode` | - | The value content |
56
+ | `row` | `boolean` | `false` | Renders label and value side-by-side instead of stacked |
57
+ | `disabled` | `Label` | - | When set, applies `text-disabled` to the value |
58
+ | `className` | `string` | - | Additional classes for the container |
59
+ | `info` | `Label` | - | Reserved field (available in type, not currently rendered) |
60
+ | `infoDescription` | `string` | - | Reserved field (available in type, not currently rendered) |
61
+
62
+ ### PageTitle
63
+
64
+ Renders an `<h2>` title with a paragraph subtitle.
65
+
66
+ | Prop | Type | Default | Description |
67
+ |------|------|---------|-------------|
68
+ | `title` | `string` | - | Main title text (required) |
69
+ | `children` | `React.ReactNode` | - | Subtitle or description beneath the title |
70
+
71
+ ### PageHeader
72
+
73
+ Renders a `<header>` element with title/description on the left and action slots on the right.
74
+
75
+ | Prop | Type | Default | Description |
76
+ |------|------|---------|-------------|
77
+ | `title` | `string` | - | Page title (required) |
78
+ | `description` | `Label` | - | Short description beneath the title (required) |
79
+ | `children` | `React.ReactNode` | - | Action buttons or other right-aligned content |
80
+
81
+ ## Design Tokens
82
+
83
+ Tokens these components read. Customize by overriding these CSS variables in your theme.
84
+
85
+ | Token | CSS Variable | Purpose |
86
+ |-------|-------------|---------|
87
+ | `text-secondary` | `--secondary` | Description and subtitle text color |
88
+ | `text-disabled` | `--disabled` | Disabled value text in `Info` |
89
+ | `mb-kilo` | `--spacing-kilo` | Bottom margin on `Description` |
90
+ | `gap-mega` | `--spacing-mega` | Gap in `PageHeader` between sections |
91
+ | `gap-kilo` | `--spacing-kilo` | Gap between action items in `PageHeader` |
92
+
93
+ ## Examples
94
+
95
+ ### Page Header with Actions
96
+
97
+ ```tsx
98
+ import { Button } from "@g4rcez/components/button";
99
+
100
+ <PageHeader title="Orders" description="List of all orders from your shop">
101
+ <Button size="small">Export CSV</Button>
102
+ <Button theme="primary" size="small">Create Order</Button>
103
+ </PageHeader>
104
+ ```
105
+
106
+ ### Standalone Page Title
107
+
108
+ ```tsx
109
+ <PageTitle title="Dashboard">
110
+ Overview of your application metrics
111
+ </PageTitle>
112
+ ```
113
+
114
+ ### Paragraph and Description
115
+
116
+ ```tsx
117
+ <Paragraph>
118
+ This is a standard paragraph with base font size and snug line height.
119
+ </Paragraph>
120
+
121
+ <Description>
122
+ Secondary description text, typically used beneath form fields or titles.
123
+ </Description>
124
+ ```
125
+
126
+ ### Info — Stacked (default)
127
+
128
+ ```tsx
129
+ <Info label="Full Name">John Doe</Info>
130
+ <Info label="Email">john@example.com</Info>
131
+ <Info label="Role">Administrator</Info>
132
+ ```
133
+
134
+ ### Info — Row Layout
135
+
136
+ ```tsx
137
+ <Info label="Status" row>Active</Info>
138
+ <Info label="Plan" row>Pro</Info>
139
+ ```
140
+
141
+ ### Info — Disabled Value
142
+
143
+ ```tsx
144
+ <Info label="API Key" disabled="true">
145
+ sk-••••••••••••••••
146
+ </Info>
147
+ ```
148
+
149
+ ### Profile Card
150
+
151
+ ```tsx
152
+ <div className="flex flex-col gap-base rounded-card border border-border bg-card-background p-4">
153
+ <PageTitle title="John Doe">Software Engineer</PageTitle>
154
+ <div className="flex flex-col gap-sm">
155
+ <Info label="Email" row>john@example.com</Info>
156
+ <Info label="Team" row>Platform</Info>
157
+ <Info label="Joined" row>March 2024</Info>
158
+ </div>
159
+ </div>
160
+ ```
161
+
162
+ ## Do
163
+
164
+ - Use `PageHeader` at the top of every page for consistent title + action layout
165
+ - Use `Paragraph` instead of raw `<p>` to inherit consistent base styling
166
+ - Use `Description` for secondary/supporting text — it signals lower visual hierarchy
167
+ - Use design-token classes for any additional styling (`text-foreground`, `bg-background`)
168
+
169
+ ## Don't
170
+
171
+ - Don't use `PageTitle` more than once per page — it represents the page's main topic
172
+ - Don't pass raw Tailwind color classes (`text-gray-500`, `text-black`) — use `text-secondary` or `text-foreground`
173
+ - Don't use arbitrary Tailwind values (`text-[#555]`) — override CSS variables in your `@theme` block
174
+ - Don't use `Info` for long-form content — it is designed for short labeled values
175
+
176
+ ## Accessibility
177
+
178
+ - `PageTitle` renders an `<h2>` — ensure there is an `<h1>` elsewhere on the page
179
+ - `PageHeader` wraps content in a semantic `<header>` element
180
+ - `Info` labels are `<span>` elements; if the label identifies a form field, prefer a `<label>` with `htmlFor` instead
181
+ - `Description` text should be concise and supplementary — do not place critical content only in `Description`
182
+
183
+ ## Notes
184
+
185
+ - All components accept standard HTML props for their root element and merge `className` correctly
186
+ - `PageHeader` uses `gap-mega` and `gap-kilo` spacing tokens — override these in `@theme` to adjust layout rhythm
187
+ - `Info` with `disabled` prop applies `text-disabled` to the value span only, not the label
@@ -0,0 +1,213 @@
1
+ ---
2
+ title: Wizard
3
+ description: Guided tour overlay that highlights page elements step-by-step with animated SVG masking and floating tooltips.
4
+ package: "@g4rcez/components"
5
+ export: "{ Wizard }"
6
+ import: "import { Wizard } from '@g4rcez/components'"
7
+ category: floating
8
+ ---
9
+
10
+ # Wizard
11
+
12
+ Guided tour overlay that highlights page elements step-by-step with animated SVG masking and floating tooltips.
13
+
14
+ ## Import
15
+
16
+ ```tsx
17
+ import { Wizard } from "@g4rcez/components";
18
+ ```
19
+
20
+ ## Props
21
+
22
+ ### Wizard
23
+
24
+ | Prop | Type | Default | Description |
25
+ |------|------|---------|-------------|
26
+ | `active` | `boolean` | `false` | Controls whether the wizard is visible |
27
+ | `steps` | `WizardStep[]` | — | Ordered array of step configurations |
28
+ | `onClose` | `() => void` | — | Callback when the user skips or dismisses the tour |
29
+ | `onFinish` | `() => void` | — | Callback when the last step is completed |
30
+ | `onChange` | `(index: number) => void` | — | Callback fired when the step index changes |
31
+ | `labels` | `{ next?: string; skip?: string; finish?: string; previous?: string }` | — | Override button labels |
32
+
33
+ ### WizardStep
34
+
35
+ | Prop | Type | Default | Description |
36
+ |------|------|---------|-------------|
37
+ | `element` | `string \| Element \| React.RefObject<Element \| null>` | — | Target element: CSS selector, DOM element, or React ref |
38
+ | `title` | `React.ReactNode` | — | Step title displayed in the tooltip |
39
+ | `description` | `React.ReactNode` | — | Step body content |
40
+ | `side` | `Placement` | `"bottom"` | Tooltip placement relative to the target element |
41
+ | `onEnter` | `() => void` | — | Called when this step becomes active |
42
+ | `onNext` | `() => void` | — | Called before advancing to the next step |
43
+ | `onPrevious` | `() => void` | — | Called before going back to the previous step |
44
+
45
+ ## Design Tokens
46
+
47
+ Tokens this component reads. Customize by overriding these CSS variables in your theme.
48
+
49
+ | Token | CSS Variable | Purpose |
50
+ |-------|-------------|---------|
51
+ | `text-floating-overlay` | `--floating-overlay` | SVG mask fill color (`/70` opacity applied) |
52
+ | `bg-floating-background` | `--floating-background` | Step tooltip surface background |
53
+ | `border-floating-border` | `--floating-border` | Step tooltip border and footer divider |
54
+ | `z-wizard` | `--z-wizard` | Z-index for the overlay layer |
55
+ | `z-floating` | `--z-floating` | Z-index for the step tooltip |
56
+ | `text-muted-foreground` | `--muted-foreground` | Step counter and skip button text |
57
+ | `text-foreground` | `--foreground` | Skip button hover text |
58
+
59
+ ## Examples
60
+
61
+ ### Basic Two-Step Tour
62
+
63
+ ```tsx
64
+ import { useState } from "react";
65
+ import { Wizard } from "@g4rcez/components";
66
+ import { Button } from "@g4rcez/components/button";
67
+
68
+ function OnboardingTour() {
69
+ const [active, setActive] = useState(false);
70
+
71
+ const steps = [
72
+ {
73
+ element: "#create-button",
74
+ title: "Create something new",
75
+ description: "Use this button to create a new project.",
76
+ side: "bottom" as const,
77
+ },
78
+ {
79
+ element: "#notifications-bell",
80
+ title: "Stay up to date",
81
+ description: "Check here for the latest updates.",
82
+ side: "left" as const,
83
+ },
84
+ ];
85
+
86
+ return (
87
+ <>
88
+ <Button onClick={() => setActive(true)}>Start Tour</Button>
89
+
90
+ <Wizard
91
+ active={active}
92
+ steps={steps}
93
+ onClose={() => setActive(false)}
94
+ onFinish={() => {
95
+ setActive(false);
96
+ console.log("Tour complete");
97
+ }}
98
+ />
99
+ </>
100
+ );
101
+ }
102
+ ```
103
+
104
+ ### Using Refs as Targets
105
+
106
+ ```tsx
107
+ import { useRef, useState } from "react";
108
+ import { Wizard } from "@g4rcez/components";
109
+ import { Button } from "@g4rcez/components/button";
110
+
111
+ function RefTour() {
112
+ const [active, setActive] = useState(false);
113
+ const buttonRef = useRef<HTMLButtonElement>(null);
114
+
115
+ const steps = [
116
+ {
117
+ element: buttonRef,
118
+ title: "Action Button",
119
+ description: "Click here to perform the primary action.",
120
+ side: "right" as const,
121
+ },
122
+ ];
123
+
124
+ return (
125
+ <>
126
+ <Button ref={buttonRef} theme="primary">
127
+ Primary Action
128
+ </Button>
129
+
130
+ <Wizard
131
+ active={active}
132
+ steps={steps}
133
+ onClose={() => setActive(false)}
134
+ labels={{ finish: "Got it!", skip: "No thanks" }}
135
+ />
136
+ </>
137
+ );
138
+ }
139
+ ```
140
+
141
+ ### Step Lifecycle Callbacks
142
+
143
+ ```tsx
144
+ const steps = [
145
+ {
146
+ element: "#dashboard-chart",
147
+ title: "Your Analytics",
148
+ description: "This chart shows activity for the last 30 days.",
149
+ onEnter: () => console.log("User reached analytics step"),
150
+ onNext: () => console.log("User advancing past analytics"),
151
+ },
152
+ {
153
+ element: "#export-button",
154
+ title: "Export Data",
155
+ description: "Download your data at any time.",
156
+ side: "left" as const,
157
+ },
158
+ ];
159
+ ```
160
+
161
+ ### Custom Labels
162
+
163
+ ```tsx
164
+ <Wizard
165
+ active={active}
166
+ steps={steps}
167
+ onClose={() => setActive(false)}
168
+ onFinish={() => setActive(false)}
169
+ labels={{
170
+ next: "Continue",
171
+ previous: "Back",
172
+ skip: "Skip tour",
173
+ finish: "Done",
174
+ }}
175
+ />
176
+ ```
177
+
178
+ ## Do
179
+
180
+ - Keep tours to 3–7 steps; fewer steps are completed more often.
181
+ - Ensure target elements are visible in the viewport when each step activates — the wizard scrolls to them automatically.
182
+ - Always provide `onClose` so users can exit at any time without completing the tour.
183
+ - Use `onEnter` to trigger any side effects that make the target element visible (e.g., open a panel) before the step highlights it.
184
+
185
+ ## Don't
186
+
187
+ - Don't use the wizard for critical information that isn't accessible elsewhere — some users will skip it.
188
+ - Don't pass more than ~10 steps; tours that feel long are abandoned.
189
+ - Don't block users from navigating if they skip the wizard.
190
+ - Don't pass raw Tailwind color classes in `title` or `description` content — use design-token classes.
191
+ - Don't use arbitrary Tailwind values (`z-[9999]`) — the wizard already uses `z-wizard`; override the CSS variable if needed.
192
+
193
+ ## Accessibility
194
+
195
+ - The wizard renders in a `FloatingPortal` above all other content.
196
+ - The SVG mask highlights the target element using `pointer-events-auto` so users can interact with it during the tour.
197
+ - Navigation buttons use the `Button` component and are keyboard accessible.
198
+ - Step progress is shown as `{current} / {total}` in the tooltip corner.
199
+ - The `FloatingArrow` provides a visual pointer connecting the tooltip to the target element.
200
+
201
+ ## Data Attributes
202
+
203
+ | Attribute | Applied to | Description |
204
+ |-----------|-----------|-------------|
205
+ | `data-component="wizard"` | Main wizard container | Identifies the wizard overlay root |
206
+
207
+ ## Notes
208
+
209
+ - The SVG mask uses a `<motion.rect>` that animates to the target element's bounding rect with a spring transition. The tooltip appears only after the animation completes (`onAnimationComplete`).
210
+ - The overlay is `pointer-events-none` except for the mask rect, which is `pointer-events-auto` — this allows clicking the highlighted element while the tour is active.
211
+ - When `element` resolves to `null` (selector not found or ref is empty), the tooltip centers on the screen and a console warning is emitted.
212
+ - `useResizeObserver` and scroll/resize event listeners keep the highlight rect in sync as the layout changes.
213
+ - The `labels` prop values fall back to the global translations provided by `useTranslations`.