@stackone/malachite 2.101.0 → 2.102.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/COMPONENTS.md +1 -1
- package/dist/ShadowRootWrapper.js +15 -14
- package/dist/ShadowRootWrapper.js.map +1 -1
- package/dist/components/FilterSearch.js +423 -308
- package/dist/components/FilterSearch.js.map +1 -1
- package/dist/components/droppedFocus.js +35 -0
- package/dist/components/droppedFocus.js.map +1 -0
- package/dist/components/filterSearchModel.js.map +1 -1
- package/dist/components/overlayBehaviour.js +77 -76
- package/dist/components/overlayBehaviour.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -76,7 +76,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
76
76
|
- **`DatePicker`** — Picks one day, or one instant with `precision="minute"` or `"second"`, from Figma's calendar in a popover. Day precision commits on click; a time precision adds hour/minute(/second) columns and holds a draft until Apply, which Escape or an outside click discards. `timeZone="utc"` draws the UTC calendar day and suffixes times with "UTC" whatever the browser's zone, as the logs pages need. Values are `Date`s; ISO strings are accepted (a string without an offset, such as `2025-01-20` or `2025-01-20T10:00`, is read in `timeZone`), and a `formControl` field seeded with a string is written back as an ISO string. `min`/`max` bound the instant (days and times outside are disabled, as are month arrows and keyboard paging that would leave them; a value clamped up to `min` rounds up to the precision, so on `min`'s own day a day-precision value is `min` itself) and `isDateDisabled` rules out single days. The grid is an ARIA grid with a roving tab stop: arrows move by day and week, PageUp/PageDown by month (Shift for a year), Home/End to the week's ends, Enter or Space picks; every day of a range is `aria-selected`, and a hidden live line asks for the end date once the start is picked. The trigger sits on the 28/32/42 control ladder with Dropdown's chrome; `clearable` adds a clear control reported as `onChange(null)`. Colours come from `text`, `accent` and `card`, so a rebrand repaints the picker; the derived states (hover, outside-month text, selected fill, today ring, range band, pressed opacity) can each be overridden through the `datePicker` theme group (`applyTheme({ colors: { datePicker: { selectedBackground } } })`). _Key props:_ `value`, `defaultValue`, `onChange`, `precision` (`day` | `minute` | `second`), `minuteStep`, `timeZone` (`local` | `utc`), `weekStartsOn`, `min`, `max`, `isDateDisabled`, `presets`, `clearable`, `tag` (`{ label, type }` status beside the value), `tone` (`default` | `chosen` | `pending`, paint only), `placeholder`, `size`, `fullWidth`, `width`, `label`, `description`, `hint`, `tooltip`, `helperText`, `required`, `requiredIndicator`, `formControl`, `error`, `disabled`, `loading`, `id`, `aria-label`, `aria-labelledby`.
|
|
77
77
|
- **`DateRangePicker`** — `DatePicker`'s range form, with the same props and a `{ start, end }` value. The second click completes a day range; a click before the start restarts it. The end always covers the whole of its last unit (`23:59:59.999` for a picked day, the last millisecond of the picked minute or second), so a filter on the range keeps its final minutes. In a `formControl` field a cleared range writes `null`. With a time precision a Start/End switch picks which end the time columns edit, end times before the start are not offered, and Apply waits for both ends. `presets` list beside the calendar and apply at once; pass a function (`value: () => ({ start, end })`) for a relative preset such as "Past 1 hour", so it is measured when clicked rather than when the page loaded. _Key props:_ `value` / `defaultValue` (`{ start, end }`), `onChange`, `presets` (`DateRangePreset[]`), plus every `DatePicker` prop.
|
|
78
78
|
- **`MultiSelect`** — Multi-select dropdown. `width` fixes the trigger, as `Dropdown` and `Search` take it, so a toolbar can put its controls on one width — and, as with those two, a container narrower than the value still wins; the menu fills the trigger and left-aligns under it, so that one prop sizes both; `minWidth` raises the 160px floor a narrow trigger falls back to. An option label too long for the menu ellipsises, and hovering it shows the full label — above the description in `hover` mode — as `Dropdown` does for its options. `requiredIndicator` follows the same three-way convention the single-select controls do, so a form choosing asterisks does not get "(Optional)" on one of its fields. _Key props:_ `MultiSelectOption[]`, `MultiSelectSize`, `width`, `minWidth`, `label`, `searchable`, `inlineSearch`, `chips`, `chipsRemovable`, `required`, `requiredIndicator`, `aria-label`, `aria-labelledby`, `id`.
|
|
79
|
-
- **`FilterSearch`** — One search field that filters across several categories. Clicking lists the filters, each with its description and an example; picking one lists its values behind a `Filters > Name` breadcrumb, and typing before picking searches the values of every filter at once, tagging each match with the filter it belongs to. Select All / Deselect All act on whatever the query matches. Each filter becomes a chip
|
|
79
|
+
- **`FilterSearch`** — One search field that filters across several categories. Clicking lists the filters, each with its description and an example; picking one lists its values behind a `Filters > Name` breadcrumb, and typing before picking searches the values of every filter at once, tagging each match with the filter it belongs to. Select All / Deselect All act on whatever the query matches. Each filter becomes a segmented chip, its name then its values (`Connector | Notion, Attio +2`), that reopens its values when clicked; an item `icon` is drawn in its menu row and in the chip, and `chipLabel: false` on a filter drops its name from the chip (`Configured only`); Backspace in an empty field removes the last one. `onQueryChange` reports the text in the field, for analytics or a server-side search. With `textFilter` (`{ value, label }`, under a `value` no filter uses) the typed text is itself the first row while searching (`Search "acme"`); committing it adds a `Search: acme` chip whose selection is `{ filter: textFilter.value, items: [text] }`, replacing any earlier text, so a free-text search can sit in the URL beside the filters, and clicking that chip puts the text back in the field. Controlled: `onChange` gets the next selection and the `changes` that produced it, an empty `items` meaning the filter was removed, so a URL-backed selection writes back only what moved. Chips keep the order filters were added in even when `value` comes back reordered, and keep their labels while `filters` reloads. `filtersButton` puts a Filters button, with the applied count, at the right end of the bar that opens the filter list, right-aligned beneath it; clicking the field then leaves the list shut until something is typed, while the arrow keys and Enter open it as the button does. _Key props:_ `filters`, `value`, `onChange`, `onClear`, `onActiveFilterChange`, `onQueryChange`, `textFilter`, `filtersButton`, `placeholder`, `size`, `width`, `loading`, `disabled`, `clearable`, `maxVisibleChips`, `aria-label`, `aria-labelledby`, `id`.
|
|
80
80
|
- **`QueryInput`** — A textbox with inline syntax colouring and a suggestion menu anchored to the caret. It carries no grammar of its own: the consumer parses the value, hands back `tokens` to colour and `suggestions` to offer, so the vocabulary lives in the consuming app rather than here. _Key props:_ `value`, `onChange`, `tokens`, `suggestions`, `activeRange`, `onAccept`, `onQueryContextChange`, `onSubmit`, `placeholder`, `size`, `disabled`, `loading`, `emptyMessage`, `className`, `style`, `aria-label`, `aria-labelledby`.
|
|
81
81
|
- **`SettingRow`** — One setting: a labelled row with its control on the trailing edge, and the sentence that explains it underneath. `control` may be a render prop receiving the label’s id, so a control that no `<label htmlFor>` can reach — `Toggle` renders a `<button role="switch">` — still names itself via `aria-labelledby`. _Key props:_ `label`, `badge`, `description`, `control`, `className`.
|
|
82
82
|
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as p, useCallback as m, useState as h, useEffect as c } from "react";
|
|
3
3
|
import { createPortal as w } from "react-dom";
|
|
4
|
-
import {
|
|
4
|
+
import { ensureDroppedFocusTracking as S } from "./components/droppedFocus.js";
|
|
5
|
+
import { ensureGeistFontFace as F } from "./geist-font.js";
|
|
5
6
|
import { ensureInterFontFace as R } from "./inter-font.js";
|
|
6
|
-
import { ensureStackSansFontFace as
|
|
7
|
-
import { adoptTailwindSheet as
|
|
8
|
-
import { ensureThemeInitialized as y, applyThemeVars as
|
|
9
|
-
const
|
|
10
|
-
const t =
|
|
7
|
+
import { ensureStackSansFontFace as g } from "./stack-sans-font.js";
|
|
8
|
+
import { adoptTailwindSheet as k } from "./tailwindSheet.js";
|
|
9
|
+
import { ensureThemeInitialized as y, applyThemeVars as T, registerShadowRoot as v, unregisterShadowRoot as E } from "./theme.js";
|
|
10
|
+
const q = ({ children: d, theme: e, hostStyle: i, hostProps: s, hostRef: a, fillHeight: f = !1 }) => {
|
|
11
|
+
const t = p(null), u = m(
|
|
11
12
|
(o) => {
|
|
12
13
|
t.current = o, a && (a.current = o);
|
|
13
14
|
},
|
|
14
15
|
[a]
|
|
15
|
-
), [r,
|
|
16
|
+
), [r, l] = h(null);
|
|
16
17
|
return c(() => {
|
|
17
18
|
if (t.current && !r) {
|
|
18
19
|
const o = t.current.shadowRoot ?? t.current.attachShadow({ mode: "open" });
|
|
19
|
-
|
|
20
|
+
k(o), l(o);
|
|
20
21
|
}
|
|
21
22
|
}, [r]), c(() => {
|
|
22
23
|
if (r) {
|
|
23
|
-
if (y(),
|
|
24
|
-
|
|
24
|
+
if (y(), S(), R(), F(), g(), e) {
|
|
25
|
+
T(r, e);
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
28
|
return v(r), () => {
|
|
28
29
|
try {
|
|
29
|
-
|
|
30
|
+
E(r);
|
|
30
31
|
} catch (o) {
|
|
31
32
|
console.warn("Error during shadow root cleanup:", o);
|
|
32
33
|
}
|
|
@@ -44,7 +45,7 @@ const W = ({ children: d, theme: e, hostStyle: i, hostProps: s, hostRef: a, fill
|
|
|
44
45
|
/* @__PURE__ */ n(
|
|
45
46
|
"div",
|
|
46
47
|
{
|
|
47
|
-
style:
|
|
48
|
+
style: f ? { isolation: "isolate", height: "100%" } : { isolation: "isolate" },
|
|
48
49
|
children: d
|
|
49
50
|
}
|
|
50
51
|
),
|
|
@@ -52,6 +53,6 @@ const W = ({ children: d, theme: e, hostStyle: i, hostProps: s, hostRef: a, fill
|
|
|
52
53
|
) });
|
|
53
54
|
};
|
|
54
55
|
export {
|
|
55
|
-
|
|
56
|
+
q as ShadowRootWrapper
|
|
56
57
|
};
|
|
57
58
|
//# sourceMappingURL=ShadowRootWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureGeistFontFace } from './geist-font';\nimport { ensureInterFontFace } from './inter-font';\nimport { ensureStackSansFontFace } from './stack-sans-font';\nimport { adoptTailwindSheet } from './tailwindSheet';\nimport {\n type ThemeMode,\n applyThemeVars,\n ensureThemeInitialized,\n registerShadowRoot,\n unregisterShadowRoot,\n} from './theme';\n\nexport const ShadowRootWrapper: React.FC<{\n children: React.ReactNode;\n theme?: ThemeMode;\n hostStyle?: React.CSSProperties;\n /** Identity for the shadow host, so host CSS matching unclassed `body` children cannot\n * blanket-hide a portaled one. Narrow on purpose: a wider type would let a caller\n * clobber `style`, `ref` or `data-testid` through the spread below. */\n hostProps?: { className?: string } & Record<`data-${string}`, string>;\n /** Reads back the shadow host, which a caller needs to promote it into the top layer. */\n hostRef?: { current: HTMLDivElement | null };\n /** Stretches the portal's inner wrapper div (inside the shadow root) to 100% height, to\n * match a `hostStyle` height a caller supplies on the host itself — without this, a tall\n * host div still collapses to content height one level in, because this wrapper div has\n * no height of its own. Off by default: sizing it for every consumer would change layout\n * for callers that rely on it hugging its content. */\n fillHeight?: boolean;\n}> = ({ children, theme, hostStyle, hostProps, hostRef: externalHostRef, fillHeight = false }) => {\n const hostRef = useRef<HTMLDivElement | null>(null);\n const takeHost = useCallback(\n (node: HTMLDivElement | null) => {\n hostRef.current = node;\n if (externalHostRef) {\n externalHostRef.current = node;\n }\n },\n [externalHostRef],\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (hostRef.current && !shadowRoot) {\n const shadow =\n hostRef.current.shadowRoot ?? hostRef.current.attachShadow({ mode: 'open' });\n // Adopt the stylesheet before setShadowRoot triggers the render that\n // portals children in: adopting in a later effect leaves a window where\n // the browser can paint the children unstyled (e.g. hover-hidden\n // controls flash fully visible on page load until `opacity: 0` lands).\n adoptTailwindSheet(shadow);\n setShadowRoot(shadow);\n }\n }, [shadowRoot]);\n\n useEffect(() => {\n if (!shadowRoot) {\n return;\n }\n // Both of these belong to the document, not the shadow root: @font-face does not\n // load fonts from inside a shadow root, and the theme's custom properties are set on\n // documentElement so light-DOM content and portals resolve them too.\n ensureThemeInitialized();\n ensureInterFontFace();\n ensureGeistFontFace();\n ensureStackSansFontFace();\n if (theme) {\n applyThemeVars(shadowRoot, theme);\n return;\n }\n registerShadowRoot(shadowRoot);\n return () => {\n try {\n unregisterShadowRoot(shadowRoot);\n } catch (error) {\n // Silently handle cleanup errors during hot reloading\n console.warn('Error during shadow root cleanup:', error);\n }\n };\n }, [shadowRoot, theme]);\n\n if (shadowRoot === null) {\n // Initial render, attach shadow root first\n return (\n <div\n {...hostProps}\n ref={takeHost}\n data-testid=\"shadow-root-wrapper\"\n style={hostStyle}\n />\n );\n }\n\n // Container div inside the shadow root keeps React context working across the portal.\n return (\n <div {...hostProps} ref={takeHost} style={hostStyle}>\n {shadowRoot &&\n createPortal(\n <div\n style={\n fillHeight\n ? { isolation: 'isolate', height: '100%' }\n : { isolation: 'isolate' }\n }\n >\n {children}\n </div>,\n shadowRoot,\n )}\n </div>\n );\n};\n"],"names":["ShadowRootWrapper","children","theme","hostStyle","hostProps","externalHostRef","fillHeight","hostRef","useRef","takeHost","useCallback","node","shadowRoot","setShadowRoot","useState","useEffect","shadow","adoptTailwindSheet","ensureThemeInitialized","ensureInterFontFace","ensureGeistFontFace","ensureStackSansFontFace","applyThemeVars","registerShadowRoot","unregisterShadowRoot","error","jsx","createPortal"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShadowRootWrapper.js","sources":["../src/ShadowRootWrapper.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ensureDroppedFocusTracking } from './components/droppedFocus';\nimport { ensureGeistFontFace } from './geist-font';\nimport { ensureInterFontFace } from './inter-font';\nimport { ensureStackSansFontFace } from './stack-sans-font';\nimport { adoptTailwindSheet } from './tailwindSheet';\nimport {\n type ThemeMode,\n applyThemeVars,\n ensureThemeInitialized,\n registerShadowRoot,\n unregisterShadowRoot,\n} from './theme';\n\nexport const ShadowRootWrapper: React.FC<{\n children: React.ReactNode;\n theme?: ThemeMode;\n hostStyle?: React.CSSProperties;\n /** Identity for the shadow host, so host CSS matching unclassed `body` children cannot\n * blanket-hide a portaled one. Narrow on purpose: a wider type would let a caller\n * clobber `style`, `ref` or `data-testid` through the spread below. */\n hostProps?: { className?: string } & Record<`data-${string}`, string>;\n /** Reads back the shadow host, which a caller needs to promote it into the top layer. */\n hostRef?: { current: HTMLDivElement | null };\n /** Stretches the portal's inner wrapper div (inside the shadow root) to 100% height, to\n * match a `hostStyle` height a caller supplies on the host itself — without this, a tall\n * host div still collapses to content height one level in, because this wrapper div has\n * no height of its own. Off by default: sizing it for every consumer would change layout\n * for callers that rely on it hugging its content. */\n fillHeight?: boolean;\n}> = ({ children, theme, hostStyle, hostProps, hostRef: externalHostRef, fillHeight = false }) => {\n const hostRef = useRef<HTMLDivElement | null>(null);\n const takeHost = useCallback(\n (node: HTMLDivElement | null) => {\n hostRef.current = node;\n if (externalHostRef) {\n externalHostRef.current = node;\n }\n },\n [externalHostRef],\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useEffect(() => {\n if (hostRef.current && !shadowRoot) {\n const shadow =\n hostRef.current.shadowRoot ?? hostRef.current.attachShadow({ mode: 'open' });\n // Adopt the stylesheet before setShadowRoot triggers the render that\n // portals children in: adopting in a later effect leaves a window where\n // the browser can paint the children unstyled (e.g. hover-hidden\n // controls flash fully visible on page load until `opacity: 0` lands).\n adoptTailwindSheet(shadow);\n setShadowRoot(shadow);\n }\n }, [shadowRoot]);\n\n useEffect(() => {\n if (!shadowRoot) {\n return;\n }\n // Both of these belong to the document, not the shadow root: @font-face does not\n // load fonts from inside a shadow root, and the theme's custom properties are set on\n // documentElement so light-DOM content and portals resolve them too.\n ensureThemeInitialized();\n ensureDroppedFocusTracking();\n ensureInterFontFace();\n ensureGeistFontFace();\n ensureStackSansFontFace();\n if (theme) {\n applyThemeVars(shadowRoot, theme);\n return;\n }\n registerShadowRoot(shadowRoot);\n return () => {\n try {\n unregisterShadowRoot(shadowRoot);\n } catch (error) {\n // Silently handle cleanup errors during hot reloading\n console.warn('Error during shadow root cleanup:', error);\n }\n };\n }, [shadowRoot, theme]);\n\n if (shadowRoot === null) {\n // Initial render, attach shadow root first\n return (\n <div\n {...hostProps}\n ref={takeHost}\n data-testid=\"shadow-root-wrapper\"\n style={hostStyle}\n />\n );\n }\n\n // Container div inside the shadow root keeps React context working across the portal.\n return (\n <div {...hostProps} ref={takeHost} style={hostStyle}>\n {shadowRoot &&\n createPortal(\n <div\n style={\n fillHeight\n ? { isolation: 'isolate', height: '100%' }\n : { isolation: 'isolate' }\n }\n >\n {children}\n </div>,\n shadowRoot,\n )}\n </div>\n );\n};\n"],"names":["ShadowRootWrapper","children","theme","hostStyle","hostProps","externalHostRef","fillHeight","hostRef","useRef","takeHost","useCallback","node","shadowRoot","setShadowRoot","useState","useEffect","shadow","adoptTailwindSheet","ensureThemeInitialized","ensureDroppedFocusTracking","ensureInterFontFace","ensureGeistFontFace","ensureStackSansFontFace","applyThemeVars","registerShadowRoot","unregisterShadowRoot","error","jsx","createPortal"],"mappings":";;;;;;;;;AAeO,MAAMA,IAgBR,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,WAAAC,GAAW,WAAAC,GAAW,SAASC,GAAiB,YAAAC,IAAa,SAAY;AAC9F,QAAMC,IAAUC,EAA8B,IAAI,GAC5CC,IAAWC;AAAA,IACb,CAACC,MAAgC;AAC7B,MAAAJ,EAAQ,UAAUI,GACdN,MACAA,EAAgB,UAAUM;AAAA,IAElC;AAAA,IACA,CAACN,CAAe;AAAA,EAAA,GAEd,CAACO,GAAYC,CAAa,IAAIC,EAA4B,IAAI;AA0CpE,SAxCAC,EAAU,MAAM;AACZ,QAAIR,EAAQ,WAAW,CAACK,GAAY;AAChC,YAAMI,IACFT,EAAQ,QAAQ,cAAcA,EAAQ,QAAQ,aAAa,EAAE,MAAM,QAAQ;AAK/E,MAAAU,EAAmBD,CAAM,GACzBH,EAAcG,CAAM;AAAA,IACxB;AAAA,EACJ,GAAG,CAACJ,CAAU,CAAC,GAEfG,EAAU,MAAM;AACZ,QAAKH,GAWL;AAAA,UALAM,EAAA,GACAC,EAAA,GACAC,EAAA,GACAC,EAAA,GACAC,EAAA,GACIpB,GAAO;AACP,QAAAqB,EAAeX,GAAYV,CAAK;AAChC;AAAA,MACJ;AACA,aAAAsB,EAAmBZ,CAAU,GACtB,MAAM;AACT,YAAI;AACA,UAAAa,EAAqBb,CAAU;AAAA,QACnC,SAASc,GAAO;AAEZ,kBAAQ,KAAK,qCAAqCA,CAAK;AAAA,QAC3D;AAAA,MACJ;AAAA;AAAA,EACJ,GAAG,CAACd,GAAYV,CAAK,CAAC,GAElBU,MAAe,OAGX,gBAAAe;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAGvB;AAAA,MACJ,KAAKK;AAAA,MACL,eAAY;AAAA,MACZ,OAAON;AAAA,IAAA;AAAA,EAAA,IAOf,gBAAAwB,EAAC,SAAK,GAAGvB,GAAW,KAAKK,GAAU,OAAON,GACrC,UAAAS,KACGgB;AAAA,IACI,gBAAAD;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,OACIrB,IACM,EAAE,WAAW,WAAW,QAAQ,OAAA,IAChC,EAAE,WAAW,UAAA;AAAA,QAGtB,UAAAL;AAAA,MAAA;AAAA,IAAA;AAAA,IAELW;AAAA,EAAA,GAEZ;AAER;"}
|