@overdoser/react-toolkit 0.0.7 → 0.0.9

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/llms.txt CHANGED
@@ -222,7 +222,8 @@ Mode B example:
222
222
  Import: `import { Popover } from '@overdoser/react-toolkit'`
223
223
 
224
224
  Props:
225
- - `trigger: ReactNode` — required. Wrapped in an internal `<button>`.
225
+ - `trigger: ReactNode` — required. By default, wrapped in an internal `<button>` (so a plain `'Help'` string or an icon is fine).
226
+ - `asChild?: boolean` — default `false`. When `true` and `trigger` is a single React element, the trigger is rendered **as-is** with click/aria/ref merged into it via `cloneElement` (no wrapping `<button>`). Use this when you want to pass your own interactive element (e.g. a `<Button>`) without producing `<button>` nested inside `<button>` (a hydration error).
226
227
  - `content: ReactNode` — required. Rendered inside an `[role="dialog"]` panel when open.
227
228
  - `position?: 'top' | 'bottom' | 'left' | 'right'` — default `'bottom'`
228
229
  - `open?: boolean` — controlled.
@@ -233,11 +234,20 @@ Closes on outside click and Escape. Auto-focuses the first focusable child of `c
233
234
 
234
235
  `children` is intentionally typed as `never` — pass via `content`.
235
236
 
236
- Example:
237
+ Example — string trigger (default wrapping):
237
238
  ```tsx
238
239
  <Popover trigger="Help" content={<p>Some help text</p>} position="right" />
239
240
  ```
240
241
 
242
+ Example — passing a `<Button>` without nested-button warning:
243
+ ```tsx
244
+ <Popover
245
+ asChild
246
+ trigger={<Button iconOnly aria-label="Settings"><GearIcon /></Button>}
247
+ content={<Settings />}
248
+ />
249
+ ```
250
+
241
251
  ### Modal
242
252
  Import: `import { Modal } from '@overdoser/react-toolkit'`
243
253
 
@@ -357,6 +367,9 @@ Props:
357
367
  - `onValueChange?: (value: string) => void` — single-mode value-only callback.
358
368
  - `onValuesChange?: (values: string[]) => void` — multi-mode callback.
359
369
  - `clearSearchOnSelect?: boolean` — default `true`. Multi-mode only.
370
+ - `allowCreate?: boolean` — default `false`. Multi-mode only. Adds a "Create '<query>'" row when the search query doesn't match an existing option. Pressing Enter (or clicking the row) pushes the trimmed query into `onValuesChange` and fires `onCreate`.
371
+ - `onCreate?: (value: string) => void` — Multi-mode only, paired with `allowCreate`. Fires with the new value; consumers typically persist it (e.g. push it back into `options`).
372
+ - `createLabel?: (query: string) => ReactNode` — Multi-mode only. Custom render for the create row. Default: `Create "<query>"`.
360
373
  - `classes?: Partial<SelectClasses>` where `SelectClasses = { wrapper, root, arrow, search, menu, item, chip, chipRemove }`
361
374
 
362
375
  Searchable example:
package/manifest.json CHANGED
@@ -143,7 +143,8 @@
143
143
  "import": "import { Popover } from '@overdoser/react-toolkit'",
144
144
  "element": "div",
145
145
  "props": {
146
- "trigger": { "type": "ReactNode", "required": true },
146
+ "trigger": { "type": "ReactNode", "required": true, "notes": "Default mode wraps the value in an internal <button>. Set asChild=true to pass your own interactive element instead." },
147
+ "asChild": { "type": "boolean", "default": false, "notes": "When true and trigger is a single React element, the element is rendered as-is with onClick/aria-*/ref cloned onto it (no wrapping <button>). Use to avoid the button-in-button hydration warning when passing <Button> as the trigger." },
147
148
  "content": { "type": "ReactNode", "required": true },
148
149
  "position": { "type": "enum", "values": ["top", "bottom", "left", "right"], "default": "bottom" },
149
150
  "open": { "type": "boolean", "notes": "Controlled mode." },
@@ -252,6 +253,9 @@
252
253
  "onValueChange": { "type": "(value: string) => void", "notes": "Single-mode value-only callback." },
253
254
  "onValuesChange": { "type": "(values: string[]) => void", "notes": "Multi-mode callback." },
254
255
  "clearSearchOnSelect": { "type": "boolean", "default": true, "notes": "Multi-mode only." },
256
+ "allowCreate": { "type": "boolean", "default": false, "notes": "Multi-mode only. Adds a 'Create <query>' row when the query doesn't match an existing option; pressing Enter (or clicking it) pushes the trimmed query into onValuesChange and fires onCreate." },
257
+ "onCreate": { "type": "(value: string) => void", "notes": "Multi-mode only. Paired with allowCreate." },
258
+ "createLabel": { "type": "(query: string) => ReactNode", "notes": "Multi-mode only. Custom render for the Create row." },
255
259
  "classes": { "type": "Partial<SelectClasses>", "shape": ["wrapper", "root", "arrow", "search", "menu", "item", "chip", "chipRemove"] }
256
260
  }
257
261
  },
@@ -658,6 +662,7 @@
658
662
  "recipes/interactive-line-chart.tsx",
659
663
  "recipes/interactive-area-chart.tsx",
660
664
  "recipes/interactive-pie-chart.tsx",
661
- "recipes/trading-chart.tsx"
665
+ "recipes/trading-chart.tsx",
666
+ "recipes/tag-input.tsx"
662
667
  ]
663
668
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overdoser/react-toolkit",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -0,0 +1,71 @@
1
+ import { useState } from 'react';
2
+ import { useForm } from 'react-hook-form';
3
+ import { Button, Form, FormField, Select } from '@overdoser/react-toolkit';
4
+
5
+ interface TagOption {
6
+ value: string;
7
+ label: string;
8
+ }
9
+
10
+ const INITIAL_TAGS: TagOption[] = [
11
+ { value: 'react', label: 'React' },
12
+ { value: 'typescript', label: 'TypeScript' },
13
+ { value: 'rust', label: 'Rust' },
14
+ { value: 'go', label: 'Go' },
15
+ { value: 'python', label: 'Python' },
16
+ ];
17
+
18
+ /**
19
+ * Tag-input pattern using `<Select multiple allowCreate>`. Users can pick
20
+ * from existing tags or type a new one + Enter to create it. The freshly
21
+ * created value is selected immediately; the consumer persists it back into
22
+ * `options` via `onCreate` so future searches surface it.
23
+ *
24
+ * Wired through `<FormField>` to show react-hook-form integration. The
25
+ * standalone uncontrolled form (no `<Form>`) works just as well — just use
26
+ * `useState` for the selected values + the options list.
27
+ */
28
+ export function TagInputRecipe({
29
+ onSubmit,
30
+ }: {
31
+ onSubmit?: (values: { tags: string[] }) => void;
32
+ }) {
33
+ const form = useForm<{ tags: string[] }>({ defaultValues: { tags: [] } });
34
+ const [options, setOptions] = useState<TagOption[]>(INITIAL_TAGS);
35
+
36
+ return (
37
+ <Form
38
+ form={form}
39
+ onSubmit={(values) => onSubmit?.(values)}
40
+ >
41
+ <FormField
42
+ name="tags"
43
+ label="Tags"
44
+ helperText="Pick existing tags or type a new one and press Enter"
45
+ >
46
+ <Select
47
+ multiple
48
+ allowCreate
49
+ options={options}
50
+ onCreate={(value) => {
51
+ // Persist the new tag back into the option list so future searches
52
+ // find it. Avoid duplicating if a race added it elsewhere.
53
+ setOptions((prev) =>
54
+ prev.some((o) => o.value === value) ? prev : [...prev, { value, label: value }],
55
+ );
56
+ }}
57
+ placeholder="Pick or create tags…"
58
+ searchPlaceholder="Type a tag…"
59
+ createLabel={(q) => (
60
+ <>
61
+ Add tag &ldquo;<strong>{q}</strong>&rdquo;
62
+ </>
63
+ )}
64
+ />
65
+ </FormField>
66
+ <Button type="submit" variant="primary">
67
+ Save
68
+ </Button>
69
+ </Form>
70
+ );
71
+ }