@overdoser/react-toolkit 0.16.0 → 0.17.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.
@@ -0,0 +1,36 @@
1
+ type EscapeHandler = (e: KeyboardEvent) => void;
2
+ /** One open overlay. Opaque to callers; pass it to `EscapeLayerProvider`. */
3
+ export interface EscapeLayer {
4
+ handler: {
5
+ current: EscapeHandler;
6
+ };
7
+ /** The overlay this one is rendered inside, in the React tree. */
8
+ parent: EscapeLayer | null;
9
+ }
10
+ /**
11
+ * Wrap an overlay's content in this (with the layer `useEscapeLayer` returned)
12
+ * so overlays rendered inside it know their parent. Context follows the React
13
+ * tree, so it keeps working through portals, where DOM containment doesn't.
14
+ */
15
+ export declare const EscapeLayerProvider: import('react').Provider<EscapeLayer | null>;
16
+ /**
17
+ * Registers an overlay (modal, drawer, dropdown, popover…) as an Escape layer.
18
+ * Only the topmost open layer receives Escape, so dismissing a dropdown doesn't
19
+ * also dismiss the modal containing it. A layer that ignores Escape (e.g.
20
+ * `closeOnEscape={false}`) still shields the layers beneath it.
21
+ *
22
+ * Escape presses that an element-level handler already `preventDefault()`ed
23
+ * are skipped entirely.
24
+ *
25
+ * @param onEscape - Called when Escape is pressed while this layer is topmost.
26
+ * @param active - Whether the overlay is currently open.
27
+ * @returns The layer, to hand to `EscapeLayerProvider` around the overlay's content.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * const layer = useEscapeLayer(() => closeOnEscape && onClose(), open);
32
+ * return <EscapeLayerProvider value={layer}>{children}</EscapeLayerProvider>;
33
+ * ```
34
+ */
35
+ export declare function useEscapeLayer(onEscape: EscapeHandler, active: boolean): EscapeLayer;
36
+ export {};
@@ -0,0 +1,33 @@
1
+ import { useRef as s, useContext as l, useEffect as a, createContext as d } from "react";
2
+ const r = [], f = d(null), h = f.Provider;
3
+ function i(e) {
4
+ if (e.key !== "Escape" || e.defaultPrevented) return;
5
+ const n = r[r.length - 1];
6
+ n && n.handler.current(e);
7
+ }
8
+ function p(e, n) {
9
+ for (let t = e.parent; t; t = t.parent)
10
+ if (t === n) return !0;
11
+ return !1;
12
+ }
13
+ function y(e) {
14
+ const n = r.findIndex((t) => p(t, e));
15
+ return n === -1 ? r.length : n;
16
+ }
17
+ function m(e, n) {
18
+ const t = s(e);
19
+ t.current = e;
20
+ const c = l(f), u = s(null);
21
+ u.current === null && (u.current = { handler: t, parent: c });
22
+ const o = u.current;
23
+ return o.parent = c, a(() => {
24
+ if (n)
25
+ return r.length === 0 && document.addEventListener("keydown", i), r.splice(y(o), 0, o), () => {
26
+ r.splice(r.indexOf(o), 1), r.length === 0 && document.removeEventListener("keydown", i);
27
+ };
28
+ }, [n, o]), o;
29
+ }
30
+ export {
31
+ h as EscapeLayerProvider,
32
+ m as useEscapeLayer
33
+ };
package/llms.txt CHANGED
@@ -454,7 +454,7 @@ Compound component: `Modal.Header`, `Modal.Body`, `Modal.Footer`. Renders into a
454
454
  - `open: boolean` — required.
455
455
  - `onClose: () => void` — required.
456
456
  - `closeOnBackdrop?: boolean` — default `true`
457
- - `closeOnEscape?: boolean` — default `true`
457
+ - `closeOnEscape?: boolean` — default `true`. Overlays stack: Escape only reaches the topmost open one, so closing a `Dropdown` / `Popover` / `Select` / date picker inside a Modal or Drawer leaves the Modal open (a second Escape closes it).
458
458
  - `size?: 'sm' | 'md' | 'lg' | 'fullscreen'` — default `'md'`
459
459
  - `aria-label?: string` — use this OR `aria-labelledby`. If neither is provided, the `Modal.Header` content is auto-wired as the `aria-labelledby` target.
460
460
  - `aria-labelledby?: string`
@@ -874,6 +874,7 @@ Props:
874
874
  - `createLabel?: (query: string) => ReactNode` — Multi-mode only. Custom render for the create row. Default: `Create "<query>"`.
875
875
  - `portal?: boolean` — default `true`. Applies to `searchable` + `multiple` modes (native `<select>` is unaffected). The open menu is rendered in a portal at `document.body` with `position: fixed` + `--crk-z-floating` (1060), so it escapes `overflow: hidden` ancestors and sits above `--crk-z-modal` (1050). Means a `<Select>` inside a `<Modal>` works without needing to size the modal. Pass `false` if you need the menu inside the trigger's subtree.
876
876
  - `classes?: Partial<SelectClasses>` where `SelectClasses = { wrapper, root, arrow, search, menu, item, chip, chipRemove }`
877
+ - Native props in searchable/multi modes: `name` and `form` go to a hidden native `<select>`, so the value is submitted with native `FormData` (multi submits one entry per value, including `allowCreate` values not yet in `options`). `aria-*`, `data-*`, `title`, `autoFocus`, `tabIndex` go to the visible control; `required` becomes `aria-required` there (no native constraint validation — validate through `FormField` rules). While a searchable Select is open, its search input carries the same `aria-*` props and takes over `id`, so `<label htmlFor>` keeps naming the focused element. `onFocus` / `onBlur` fire when focus enters / leaves the whole widget (trigger, search input and portaled menu count as inside), so blur-based `FormField` validation works.
877
878
 
878
879
  Searchable example:
879
880
  ```tsx
@@ -1035,7 +1036,7 @@ Quick mapping from shadcn variant names to LineChart props:
1035
1036
  AreaChart extras (covers every shadcn area-chart variant via composable props):
1036
1037
  - `curve?: 'linear' | 'monotone' | 'step'` — default `'monotone'`.
1037
1038
  - `stacked?: boolean` — default `false`. Stacks series bottom-up in config-key order.
1038
- - `stackOffset?: 'none' | 'expand'` — default `'none'`. `'expand'` normalizes each row to sum to 1 (percentage stack). Requires `stacked`.
1039
+ - `stackOffset?: 'none' | 'expand'` — default `'none'`. `'expand'` normalizes each row to sum to 1 (percentage stack). Requires `stacked`. The default tooltip then shows `<value> · <share>%` per series (value through `valueFormat`).
1039
1040
  - `fillGradient?: boolean` — default `false`. Replaces flat fill with a per-series vertical linear gradient (opaque top → transparent bottom).
1040
1041
  - `showXAxis?: boolean` / `showYAxis?: boolean` — default `true`. Pass `false` to hide either axis.
1041
1042
  - `SeriesConfig.icon?: ReactNode` — if set on a series, the legend renders the icon (colored to match) in place of the swatch.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overdoser/react-toolkit",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "homepage": "https://react-toolkit.overdoser.org",
5
5
  "type": "module",
6
6
  "main": "./index.js",