@overdoser/react-toolkit 0.13.0 → 0.15.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/llms.txt CHANGED
@@ -151,6 +151,8 @@ Example:
151
151
  <CopyButton value={shareUrl} iconOnly aria-label="Copy link" /> // icon only
152
152
  ```
153
153
 
154
+ Floating over content (e.g. pinned to a code snippet's corner): `secondary`/`ghost` are transparent at rest, so wrap the button in a div with a solid `background: var(--crk-color-bg)` and the button's border radius — every state then composites over that surface instead of the content underneath. Prefer `variant="secondary"` there (visible outline at rest; ghost has none). Full copy-paste version: `recipes/floating-copy-button.tsx`.
155
+
154
156
  ### Link
155
157
  Import: `import { Link } from '@overdoser/react-toolkit'`
156
158
  Element: `<a>` (forwards ref, accepts all native anchor props).
@@ -370,6 +372,48 @@ Mode B example:
370
372
  />
371
373
  ```
372
374
 
375
+ ### SplitButton
376
+ Import: `import { SplitButton } from '@overdoser/react-toolkit'`
377
+
378
+ Split button: a primary action button joined to a chevron toggle that opens a menu of secondary actions — the standard "Operations" control for table rows. Takes a **flat `actions` list**; the first entry is the default action exposed as the main button, the rest go into the menu. With a single action no chevron or menu is rendered. Closes on outside click and Escape.
379
+
380
+ Sizing: the control automatically grows to fit its **widest** action label (hidden measurement column), and the open menu sits flush under it at **exactly** the control's width with the meeting corners squared — button + menu always read as one uniform block; menu items never wrap. The main label is left-aligned and menu items share the button's font and per-size padding, so the label and item text form one column. Cap the growth with `maxWidth`; labels then clip with an ellipsis and string labels get a native `title` tooltip with the full text.
381
+
382
+ `SplitButtonAction`:
383
+ - `label: ReactNode`
384
+ - `onClick?: (event: MouseEvent) => void` — JS action.
385
+ - `href?: string` — navigation action; renders a real `<a>` (middle-click / cmd-click work). Can be combined with `onClick` (handler runs before navigation).
386
+ - `target?: string` — anchor target; `'_blank'` gets `rel="noopener noreferrer"` automatically.
387
+ - `disabled?: boolean` — default `false`. A disabled `href` action renders as a disabled `<button>`, not an anchor.
388
+ - `danger?: boolean` — default `false`. Red destructive styling (menu items only).
389
+
390
+ `SplitButtonProps`:
391
+ - `actions: SplitButtonAction[]` — required. First = exposed default action.
392
+ - `variant?: 'primary' | 'secondary' | 'danger' | 'ghost'` — default `'secondary'`. Applied to both segments (same visual scale as `Button`).
393
+ - `size?: 'sm' | 'md' | 'lg'` — default `'md'`
394
+ - `disabled?: boolean` — default `false`. Disables both segments.
395
+ - `align?: 'left' | 'right'` — default `'right'` (split buttons usually sit at the end of a row, where a left-aligned menu would overflow).
396
+ - `portal?: boolean` — default `true`. Same portal behavior as `Dropdown` (`--crk-z-floating`, escapes `overflow: hidden` ancestors).
397
+ - `menuLabel?: string` — default `'More actions'`. Accessible label for the chevron toggle.
398
+ - `maxWidth?: number | string` — caps the control's auto-grow width (numbers are px); the main button label and over-long menu items clip with an ellipsis, and string labels get a native `title` tooltip.
399
+ - `id?: string` — applied to the main button.
400
+ - `onOpen?: () => void` / `onClose?: () => void`
401
+ - `classes?: Partial<SplitButtonClasses>` where `SplitButtonClasses = { root, group, main, toggle, chevron, menu, item }`
402
+
403
+ Example — table row operations:
404
+ ```tsx
405
+ <SplitButton
406
+ size="sm"
407
+ actions={[
408
+ { label: 'Edit', onClick: () => edit(row) },
409
+ { label: 'View', href: `/items/${row.id}` },
410
+ { label: 'Delete', onClick: () => remove(row), danger: true },
411
+ ]}
412
+ />
413
+ ```
414
+
415
+ Use `SplitButton` when one action is the default and the rest are overflow; use `Dropdown` (menu mode) when all actions are equal-weight behind one trigger.
416
+
373
417
  ### Popover
374
418
  Import: `import { Popover } from '@overdoser/react-toolkit'`
375
419
 
package/manifest.json CHANGED
@@ -248,7 +248,7 @@
248
248
  "element": "button",
249
249
  "extendsNativeProps": "button (except children)",
250
250
  "forwardsRef": true,
251
- "notes": "Preconfigured ActionButton for copy-to-clipboard: clipboard icon morphs into a check, label swaps Copy \u2192 Copied, success tint, auto-reset. All ActionButton props apply. Falls back to execCommand('copy') without the Clipboard API.",
251
+ "notes": "Preconfigured ActionButton for copy-to-clipboard: clipboard icon morphs into a check, label swaps Copy \u2192 Copied, success tint, auto-reset. All ActionButton props apply. Falls back to execCommand('copy') without the Clipboard API. Floating over content (e.g. a code snippet): secondary/ghost are transparent at rest, so give a wrapper a solid --crk-color-bg fill + the button's radius \u2014 see recipes/floating-copy-button.tsx.",
252
252
  "props": {
253
253
  "value": {
254
254
  "type": "string | (() => string | Promise<string>)",
@@ -648,6 +648,89 @@
648
648
  }
649
649
  }
650
650
  },
651
+ "SplitButton": {
652
+ "import": "import { SplitButton, type SplitButtonAction } from '@overdoser/react-toolkit'",
653
+ "element": "div",
654
+ "forwardsRef": true,
655
+ "description": "Primary action button joined to a chevron that opens a menu of secondary actions (the standard table-row 'Operations' control). Flat actions list; first entry is the exposed default action, the rest go in the menu. Single action renders a plain button with no chevron/menu. The control auto-grows to fit its widest action label and the open menu renders flush under it at exactly the control's width (meeting corners squared), so button + menu read as one block.",
656
+ "props": {
657
+ "actions": {
658
+ "type": "SplitButtonAction[]",
659
+ "required": true,
660
+ "notes": "SplitButtonAction = { label: ReactNode; onClick?: (e) => void; href?: string; target?: string; disabled?: boolean; danger?: boolean }. href actions render as real <a> elements; target='_blank' gets rel='noopener noreferrer'; a disabled href action renders as a disabled <button>. danger gives red destructive styling (menu items only)."
661
+ },
662
+ "variant": {
663
+ "type": "enum",
664
+ "values": [
665
+ "primary",
666
+ "secondary",
667
+ "danger",
668
+ "ghost"
669
+ ],
670
+ "default": "secondary",
671
+ "notes": "Applied to both segments; same visual scale as Button."
672
+ },
673
+ "size": {
674
+ "type": "enum",
675
+ "values": [
676
+ "sm",
677
+ "md",
678
+ "lg"
679
+ ],
680
+ "default": "md"
681
+ },
682
+ "disabled": {
683
+ "type": "boolean",
684
+ "default": false,
685
+ "notes": "Disables both segments."
686
+ },
687
+ "align": {
688
+ "type": "enum",
689
+ "values": [
690
+ "left",
691
+ "right"
692
+ ],
693
+ "default": "right",
694
+ "notes": "Defaults right because split buttons usually sit at the end of a row/table."
695
+ },
696
+ "portal": {
697
+ "type": "boolean",
698
+ "default": true,
699
+ "notes": "Same portal behavior as Dropdown (--crk-z-floating, escapes overflow:hidden ancestors)."
700
+ },
701
+ "menuLabel": {
702
+ "type": "string",
703
+ "default": "More actions",
704
+ "notes": "Accessible label for the chevron toggle."
705
+ },
706
+ "maxWidth": {
707
+ "type": "number | string",
708
+ "notes": "Caps the control's auto-grow width (numbers are px); the main button label and over-long menu items clip with an ellipsis, and string labels get a native title tooltip with the full text."
709
+ },
710
+ "id": {
711
+ "type": "string",
712
+ "notes": "Applied to the main button."
713
+ },
714
+ "onOpen": {
715
+ "type": "() => void"
716
+ },
717
+ "onClose": {
718
+ "type": "() => void"
719
+ },
720
+ "classes": {
721
+ "type": "Partial<SplitButtonClasses>",
722
+ "shape": [
723
+ "root",
724
+ "group",
725
+ "main",
726
+ "toggle",
727
+ "chevron",
728
+ "menu",
729
+ "item"
730
+ ]
731
+ }
732
+ }
733
+ },
651
734
  "Popover": {
652
735
  "import": "import { Popover } from '@overdoser/react-toolkit'",
653
736
  "element": "div",
@@ -3499,6 +3582,9 @@
3499
3582
  "recipes/interactive-pie-chart.tsx",
3500
3583
  "recipes/trading-chart.tsx",
3501
3584
  "recipes/tag-input.tsx",
3502
- "recipes/multi-select-in-modal.tsx"
3585
+ "recipes/multi-select-in-modal.tsx",
3586
+ "recipes/comparison-table.tsx",
3587
+ "recipes/live-timeline-feed.tsx",
3588
+ "recipes/floating-copy-button.tsx"
3503
3589
  ]
3504
3590
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overdoser/react-toolkit",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "homepage": "https://react-toolkit.overdoser.org",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -0,0 +1,68 @@
1
+ import { CopyButton } from '@overdoser/react-toolkit';
2
+
3
+ /**
4
+ * Copy button floating over a code snippet (docs-site pattern).
5
+ *
6
+ * The two things this recipe encodes:
7
+ *
8
+ * 1. **Solid wrapper surface.** The `secondary` and `ghost` variants are
9
+ * transparent at rest by design, so a button floated over content would
10
+ * let the code text run straight under the glyph. Give the *wrapper* a
11
+ * solid `--crk-color-bg` fill (with the button's border radius) — every
12
+ * button state then composites over that surface instead of the code.
13
+ * 2. **`secondary` over `ghost` for floating use.** Ghost has no border in
14
+ * its resting state; secondary's inset outline gives the floating button
15
+ * a visible affordance against the snippet background.
16
+ *
17
+ * The hover/success fills themselves are opaque (they mix the accent into
18
+ * `--crk-color-bg`), so mid-morph the code never shines through the button.
19
+ */
20
+
21
+ interface CodeSnippetProps {
22
+ code: string;
23
+ /** Language hint rendered as a class for external highlighters. @default undefined */
24
+ language?: string;
25
+ }
26
+
27
+ export function CodeSnippet({ code, language }: CodeSnippetProps) {
28
+ return (
29
+ <div style={{ position: 'relative' }}>
30
+ <pre
31
+ style={{
32
+ margin: 0,
33
+ padding: '16px 20px',
34
+ // Keep long lines scrollable; the button stays pinned to the box.
35
+ overflowX: 'auto',
36
+ background: 'var(--crk-color-bg-muted)',
37
+ border: '1px solid var(--crk-color-border-hover)',
38
+ borderRadius: 'var(--crk-border-radius-md)',
39
+ fontSize: 'var(--crk-font-size-sm)',
40
+ lineHeight: 1.6,
41
+ }}
42
+ >
43
+ <code className={language ? `language-${language}` : undefined}>{code}</code>
44
+ </pre>
45
+ {/* Solid layer under the (transparent-at-rest) button — see note above. */}
46
+ <div
47
+ style={{
48
+ position: 'absolute',
49
+ top: 8,
50
+ right: 8,
51
+ background: 'var(--crk-color-bg)',
52
+ borderRadius: 'var(--crk-border-radius-md)',
53
+ }}
54
+ >
55
+ <CopyButton value={code} variant="secondary" iconOnly aria-label="Copy code" />
56
+ </div>
57
+ </div>
58
+ );
59
+ }
60
+
61
+ export function Example() {
62
+ return (
63
+ <CodeSnippet
64
+ language="bash"
65
+ code={'npm install @overdoser/react-toolkit\n# then import the theme once:\n# import "@overdoser/react-toolkit/theme.css"'}
66
+ />
67
+ );
68
+ }