@flood-md/react 0.2.10 → 0.2.12
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/README.md +275 -5
- package/dist/app-shell.d.ts +3 -0
- package/dist/app-shell.js +66 -0
- package/dist/bulk-action-bar.d.ts +3 -0
- package/dist/bulk-action-bar.js +17 -0
- package/dist/collection-toolbar.d.ts +3 -0
- package/dist/collection-toolbar.js +26 -0
- package/dist/collection-view-switcher.d.ts +3 -0
- package/dist/collection-view-switcher.js +19 -0
- package/dist/combobox.d.ts +6 -1
- package/dist/combobox.js +77 -29
- package/dist/command-list.d.ts +5 -1
- package/dist/command-list.js +2 -2
- package/dist/data-display.js +28 -4
- package/dist/data-table-columns.d.ts +25 -0
- package/dist/data-table-columns.js +271 -0
- package/dist/data-table-expansion.d.ts +21 -0
- package/dist/data-table-expansion.js +79 -0
- package/dist/data-table.js +140 -12
- package/dist/date-picker.js +2 -2
- package/dist/date-range-picker.js +2 -2
- package/dist/date-time-picker.js +2 -2
- package/dist/date-time-range-picker.js +2 -2
- package/dist/disclosure.d.ts +2 -1
- package/dist/disclosure.js +4 -4
- package/dist/editable.js +57 -18
- package/dist/filter-condition.d.ts +3 -0
- package/dist/filter-condition.js +21 -0
- package/dist/filter-group.d.ts +2 -0
- package/dist/filter-group.js +62 -0
- package/dist/foundations.css +1131 -93
- package/dist/index.d.ts +469 -5
- package/dist/index.js +72 -9
- package/dist/menu.js +5 -4
- package/dist/menubar.d.ts +2 -0
- package/dist/menubar.js +85 -0
- package/dist/navigation-group.d.ts +3 -0
- package/dist/navigation-group.js +13 -0
- package/dist/navigation-item.d.ts +3 -0
- package/dist/navigation-item.js +68 -0
- package/dist/navigation-layout.d.ts +2 -1
- package/dist/navigation-layout.js +12 -4
- package/dist/navigation-tree.js +51 -7
- package/dist/navigation.js +2 -2
- package/dist/overflow-actions.d.ts +2 -0
- package/dist/overflow-actions.js +75 -0
- package/dist/overlay-runtime.d.ts +6 -2
- package/dist/overlay-runtime.js +41 -5
- package/dist/overlays.d.ts +1 -0
- package/dist/overlays.js +34 -18
- package/dist/select.js +4 -1
- package/dist/sidebar.d.ts +2 -0
- package/dist/sidebar.js +58 -0
- package/dist/sparkline.d.ts +2 -0
- package/dist/sparkline.js +65 -0
- package/dist/toolbar.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
|
+
import { Text } from "./index.js";
|
|
4
|
+
const plotWidth = 96;
|
|
5
|
+
const plotHeight = 32;
|
|
6
|
+
const plotInset = 3;
|
|
7
|
+
function isObservation(value) {
|
|
8
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
9
|
+
}
|
|
10
|
+
function getPlot(values, domain, area) {
|
|
11
|
+
let observedMin = Infinity;
|
|
12
|
+
let observedMax = -Infinity;
|
|
13
|
+
for (const value of values) {
|
|
14
|
+
if (isObservation(value)) {
|
|
15
|
+
observedMin = Math.min(observedMin, value);
|
|
16
|
+
observedMax = Math.max(observedMax, value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (observedMin === Infinity)
|
|
20
|
+
return null;
|
|
21
|
+
const [min, max] = domain && Number.isFinite(domain[0]) && Number.isFinite(domain[1]) && domain[0] < domain[1]
|
|
22
|
+
? domain
|
|
23
|
+
: [observedMin, observedMax];
|
|
24
|
+
const span = max - min;
|
|
25
|
+
const commands = [];
|
|
26
|
+
const areas = [];
|
|
27
|
+
const markers = [];
|
|
28
|
+
let lastPoint;
|
|
29
|
+
let segmentStart = 0;
|
|
30
|
+
let segmentStartX = "";
|
|
31
|
+
for (const [index, value] of values.entries()) {
|
|
32
|
+
if (!isObservation(value))
|
|
33
|
+
continue;
|
|
34
|
+
const clamped = Math.min(max, Math.max(min, value));
|
|
35
|
+
// Halve the operands before subtracting if the finite bounds span more than Number.MAX_VALUE.
|
|
36
|
+
const fraction = span === 0 ? 0.5 : Number.isFinite(span)
|
|
37
|
+
? (clamped - min) / span
|
|
38
|
+
: (clamped / 2 - min / 2) / (max / 2 - min / 2);
|
|
39
|
+
const x = values.length === 1 ? plotWidth / 2 : plotInset + index * (plotWidth - 2 * plotInset) / (values.length - 1);
|
|
40
|
+
const y = plotHeight - plotInset - fraction * (plotHeight - 2 * plotInset);
|
|
41
|
+
const continuesLine = isObservation(values[index - 1]);
|
|
42
|
+
const plotX = x.toFixed(2);
|
|
43
|
+
if (!continuesLine) {
|
|
44
|
+
segmentStart = commands.length;
|
|
45
|
+
segmentStartX = plotX;
|
|
46
|
+
}
|
|
47
|
+
commands.push(`${continuesLine ? "L" : "M"}${plotX} ${y.toFixed(2)}`);
|
|
48
|
+
lastPoint = { x, y, index };
|
|
49
|
+
if (!isObservation(values[index + 1])) {
|
|
50
|
+
if (!continuesLine)
|
|
51
|
+
markers.push(lastPoint);
|
|
52
|
+
else if (area)
|
|
53
|
+
areas.push(`${commands.slice(segmentStart).join(" ")} L${plotX} ${plotHeight} H${segmentStartX} Z`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (lastPoint && markers.at(-1) !== lastPoint)
|
|
57
|
+
markers.push(lastPoint);
|
|
58
|
+
return { path: commands.join(" "), area: areas.join(" "), markers, lastPoint };
|
|
59
|
+
}
|
|
60
|
+
const markerPath = ({ x, y }) => `M${x.toFixed(2)} ${y.toFixed(2)}h0`;
|
|
61
|
+
export const TrendPlot = /* @__PURE__ */ forwardRef(function TrendPlot({ values, domain, label, showLabel, size, tone, variant, className, ...props }, ref) {
|
|
62
|
+
const gradientId = useId();
|
|
63
|
+
const plot = getPlot(values, domain, variant === "area");
|
|
64
|
+
return (_jsxs("div", { ...props, ref: ref, className: ["flood-sparkline", className].filter(Boolean).join(" "), "data-size": size, "data-tone": tone, role: "img", "aria-label": label, children: [plot ? (_jsxs("svg", { className: "flood-sparkline__plot", viewBox: `0 0 ${plotWidth} ${plotHeight}`, preserveAspectRatio: "none", "aria-hidden": "true", focusable: "false", children: [plot.area && _jsxs(_Fragment, { children: [_jsx("defs", { children: _jsxs("linearGradient", { id: gradientId, x1: "0", x2: "0", y1: "0", y2: "1", children: [_jsx("stop", { stopColor: "currentColor", stopOpacity: ".42" }), _jsx("stop", { offset: "100%", stopColor: "currentColor", stopOpacity: "0" })] }) }), _jsx("path", { className: "flood-sparkline__area", d: plot.area, fill: `url(#${gradientId})` })] }), _jsx("path", { className: "flood-sparkline__line", d: plot.path }), plot.lastPoint && _jsx("path", { className: "flood-sparkline__halo", d: markerPath(plot.lastPoint) }), plot.markers.map(point => (_jsx("path", { className: "flood-sparkline__point", d: markerPath(point), "data-latest": point === plot.lastPoint || undefined }, point.index)))] })) : (_jsx(Text, { className: "flood-sparkline__empty", size: "helper", tone: "subtle", "aria-hidden": "true", children: "\u2014" })), showLabel && _jsx(Text, { className: "flood-sparkline__label", size: "helper", tone: "subtle", "aria-hidden": "true", children: label })] }));
|
|
65
|
+
});
|
package/dist/toolbar.js
CHANGED
|
@@ -3,7 +3,7 @@ import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } f
|
|
|
3
3
|
const useBrowserLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
4
4
|
const selector = 'button:not([role]),button[role="button"],a[href]:not([role]),a[href][role="link"]';
|
|
5
5
|
const independent = '[role="menu"],[role="tablist"],[role="radiogroup"],[role="listbox"],[role="combobox"],.flood-toggle-group';
|
|
6
|
-
export const RovingToolbar = /* @__PURE__ */ forwardRef(function RovingToolbar({ label, orientation = "horizontal", loop = true, className, onKeyDown, onKeyDownCapture, onFocus, ...props }, ref) {
|
|
6
|
+
export const RovingToolbar = /* @__PURE__ */ forwardRef(function RovingToolbar({ label, orientation = "horizontal", loop = true, shape = "rounded", variant = "contained", className, onKeyDown, onKeyDownCapture, onFocus, ...props }, ref) {
|
|
7
7
|
const root = useRef(null), current = useRef(null), within = useRef(false);
|
|
8
8
|
const refresh = useRef(() => []);
|
|
9
9
|
useImperativeHandle(ref, () => root.current, []);
|
|
@@ -73,7 +73,7 @@ export const RovingToolbar = /* @__PURE__ */ forwardRef(function RovingToolbar({
|
|
|
73
73
|
controls[next].scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
74
74
|
refresh.current();
|
|
75
75
|
};
|
|
76
|
-
return _jsx("div", { ...props, ref: root, role: "toolbar", "aria-label": label, "aria-orientation": orientation, tabIndex: -1, "data-orientation": orientation, className: ["flood-toolbar", className].filter(Boolean).join(" "), onFocus: event => { onFocus?.(event); if (event.defaultPrevented)
|
|
76
|
+
return _jsx("div", { ...props, ref: root, role: "toolbar", "aria-label": label, "aria-orientation": orientation, tabIndex: -1, "data-orientation": orientation, "data-shape": shape, "data-variant": variant, className: ["flood-toolbar", className].filter(Boolean).join(" "), onFocus: event => { onFocus?.(event); if (event.defaultPrevented)
|
|
77
77
|
return; within.current = true; refresh.current(); }, onKeyDownCapture: event => { onKeyDownCapture?.(event); if (!event.defaultPrevented && orientation === "vertical" && event.target.getAttribute("aria-haspopup") === "menu" && ["ArrowUp", "ArrowDown"].includes(event.key))
|
|
78
78
|
move(event); }, onKeyDown: event => { onKeyDown?.(event); if (!event.defaultPrevented)
|
|
79
79
|
move(event); } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flood-md/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Original Flood components for React and Next.js.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@flood-md/tokens": "0.2.
|
|
33
|
+
"@flood-md/tokens": "0.2.12"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|