@aiconstructions/graficos 0.0.0-stage → 0.2.1
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/ALTERACOES.md +53 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +188 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useId,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
useSyncExternalStore
|
|
10
|
+
} from "react";
|
|
11
|
+
function shallowEqual(a, b) {
|
|
12
|
+
if (!a) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const aRecord = a;
|
|
16
|
+
const bRecord = b;
|
|
17
|
+
const aKeys = Object.keys(aRecord);
|
|
18
|
+
if (aKeys.length !== Object.keys(bRecord).length) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return aKeys.every((key) => Object.is(aRecord[key], bRecord[key]));
|
|
22
|
+
}
|
|
23
|
+
function defaultToView(inputs) {
|
|
24
|
+
const keys = Object.keys(inputs);
|
|
25
|
+
return keys.length === 1 ? inputs[keys[0]] : inputs;
|
|
26
|
+
}
|
|
27
|
+
function defaultFromView(view, inputs) {
|
|
28
|
+
const keys = Object.keys(inputs);
|
|
29
|
+
if (keys.length === 1) {
|
|
30
|
+
return { ...inputs, [keys[0]]: view };
|
|
31
|
+
}
|
|
32
|
+
if (view && typeof view === "object" && !Array.isArray(view)) {
|
|
33
|
+
const next = {
|
|
34
|
+
...inputs
|
|
35
|
+
};
|
|
36
|
+
for (const key of keys) {
|
|
37
|
+
if (key in view) {
|
|
38
|
+
next[key] = view[key];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return next;
|
|
42
|
+
}
|
|
43
|
+
return inputs;
|
|
44
|
+
}
|
|
45
|
+
function createChartDataOverrideStore() {
|
|
46
|
+
const order = [];
|
|
47
|
+
const registrations = /* @__PURE__ */ new Map();
|
|
48
|
+
const slotListeners = /* @__PURE__ */ new Set();
|
|
49
|
+
const overrideListeners = /* @__PURE__ */ new Set();
|
|
50
|
+
let overrides = null;
|
|
51
|
+
let slots = null;
|
|
52
|
+
const emit = (listeners) => {
|
|
53
|
+
for (const listener of listeners) {
|
|
54
|
+
listener();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const slotsChanged = () => {
|
|
58
|
+
slots = null;
|
|
59
|
+
emit(slotListeners);
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
getSlots() {
|
|
63
|
+
if (!slots) {
|
|
64
|
+
const next = [];
|
|
65
|
+
for (const id of order) {
|
|
66
|
+
const registration = registrations.get(id);
|
|
67
|
+
if (registration?.inputs) {
|
|
68
|
+
next.push({
|
|
69
|
+
id,
|
|
70
|
+
component: registration.component,
|
|
71
|
+
view: registration.view
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
slots = next;
|
|
76
|
+
}
|
|
77
|
+
return slots;
|
|
78
|
+
},
|
|
79
|
+
subscribeSlots(listener) {
|
|
80
|
+
slotListeners.add(listener);
|
|
81
|
+
return () => slotListeners.delete(listener);
|
|
82
|
+
},
|
|
83
|
+
setOverrides(views) {
|
|
84
|
+
const unchanged = views === overrides || views && overrides && views.length === overrides.length && views.every((view, index) => Object.is(view, overrides?.[index]));
|
|
85
|
+
overrides = views;
|
|
86
|
+
if (!unchanged) {
|
|
87
|
+
emit(overrideListeners);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
getOverride(id) {
|
|
91
|
+
if (!overrides) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const index = order.indexOf(id);
|
|
95
|
+
return index === -1 ? void 0 : overrides[index];
|
|
96
|
+
},
|
|
97
|
+
subscribeOverrides(listener) {
|
|
98
|
+
overrideListeners.add(listener);
|
|
99
|
+
return () => overrideListeners.delete(listener);
|
|
100
|
+
},
|
|
101
|
+
register(id, component) {
|
|
102
|
+
order.push(id);
|
|
103
|
+
registrations.set(id, {
|
|
104
|
+
component,
|
|
105
|
+
inputs: void 0,
|
|
106
|
+
codec: void 0,
|
|
107
|
+
view: void 0
|
|
108
|
+
});
|
|
109
|
+
slotsChanged();
|
|
110
|
+
emit(overrideListeners);
|
|
111
|
+
return () => {
|
|
112
|
+
const index = order.indexOf(id);
|
|
113
|
+
if (index !== -1) {
|
|
114
|
+
order.splice(index, 1);
|
|
115
|
+
}
|
|
116
|
+
registrations.delete(id);
|
|
117
|
+
slotsChanged();
|
|
118
|
+
emit(overrideListeners);
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
update(id, inputs, codec) {
|
|
122
|
+
const registration = registrations.get(id);
|
|
123
|
+
if (!registration || shallowEqual(registration.inputs, inputs)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
registration.inputs = inputs;
|
|
127
|
+
registration.codec = codec;
|
|
128
|
+
registration.view = (codec?.toView ?? defaultToView)(inputs);
|
|
129
|
+
slotsChanged();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const ChartDataOverrideContext = createContext(
|
|
134
|
+
null
|
|
135
|
+
);
|
|
136
|
+
function ChartDataOverrideProvider({
|
|
137
|
+
store,
|
|
138
|
+
children
|
|
139
|
+
}) {
|
|
140
|
+
return /* @__PURE__ */ jsx(ChartDataOverrideContext.Provider, { value: store, children });
|
|
141
|
+
}
|
|
142
|
+
function ChartDataOverrideExempt({ children }) {
|
|
143
|
+
return /* @__PURE__ */ jsx(ChartDataOverrideContext.Provider, { value: null, children });
|
|
144
|
+
}
|
|
145
|
+
const noOverride = () => void 0;
|
|
146
|
+
function useRegisteredChartData(store, component, inputs, codec) {
|
|
147
|
+
const id = useId();
|
|
148
|
+
const view = useSyncExternalStore(
|
|
149
|
+
store.subscribeOverrides,
|
|
150
|
+
() => store.getOverride(id),
|
|
151
|
+
noOverride
|
|
152
|
+
);
|
|
153
|
+
useLayoutEffect(() => store.register(id, component), [store, id, component]);
|
|
154
|
+
useLayoutEffect(() => {
|
|
155
|
+
store.update(
|
|
156
|
+
id,
|
|
157
|
+
inputs,
|
|
158
|
+
codec
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
const cacheRef = useRef(null);
|
|
162
|
+
if (view === void 0) {
|
|
163
|
+
cacheRef.current = null;
|
|
164
|
+
return inputs;
|
|
165
|
+
}
|
|
166
|
+
const cached = cacheRef.current;
|
|
167
|
+
if (cached && cached.view === view && shallowEqual(cached.inputs, inputs)) {
|
|
168
|
+
return cached.result;
|
|
169
|
+
}
|
|
170
|
+
const result = (codec?.fromView ?? defaultFromView)(view, inputs);
|
|
171
|
+
cacheRef.current = { view, inputs, result };
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
function useChartDataOverride(component, inputs, codec) {
|
|
175
|
+
const store = useContext(ChartDataOverrideContext);
|
|
176
|
+
if (!store) {
|
|
177
|
+
return inputs;
|
|
178
|
+
}
|
|
179
|
+
return useRegisteredChartData(store, component, inputs, codec);
|
|
180
|
+
}
|
|
181
|
+
export {
|
|
182
|
+
ChartDataOverrideExempt,
|
|
183
|
+
ChartDataOverrideProvider,
|
|
184
|
+
createChartDataOverrideStore,
|
|
185
|
+
useChartDataOverride
|
|
186
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
isValidElement
|
|
4
|
+
} from "react";
|
|
5
|
+
function getChartChildComponentName(child) {
|
|
6
|
+
const childType = child.type;
|
|
7
|
+
return typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
|
|
8
|
+
}
|
|
9
|
+
const VISX_PATTERN_COMPONENT_NAMES = /* @__PURE__ */ new Set([
|
|
10
|
+
"Lines",
|
|
11
|
+
"Circles",
|
|
12
|
+
"Waves",
|
|
13
|
+
"Hexagons",
|
|
14
|
+
"Path",
|
|
15
|
+
"Pattern"
|
|
16
|
+
]);
|
|
17
|
+
function isPatternDefComponent(child) {
|
|
18
|
+
const name = getChartChildComponentName(child);
|
|
19
|
+
return name.includes("Pattern") || VISX_PATTERN_COMPONENT_NAMES.has(name);
|
|
20
|
+
}
|
|
21
|
+
function isGradientDefComponent(child) {
|
|
22
|
+
const name = getChartChildComponentName(child);
|
|
23
|
+
return name.includes("Gradient") || name === "LinearGradient" || name === "RadialGradient";
|
|
24
|
+
}
|
|
25
|
+
function isChartDefsComponent(child) {
|
|
26
|
+
return isPatternDefComponent(child) || isGradientDefComponent(child);
|
|
27
|
+
}
|
|
28
|
+
function partitionChartDefNodes(defNodes) {
|
|
29
|
+
const patternDefNodes = [];
|
|
30
|
+
const gradientDefNodes = [];
|
|
31
|
+
for (const node of defNodes) {
|
|
32
|
+
if (isPatternDefComponent(node)) {
|
|
33
|
+
patternDefNodes.push(node);
|
|
34
|
+
} else {
|
|
35
|
+
gradientDefNodes.push(node);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { patternDefNodes, gradientDefNodes };
|
|
39
|
+
}
|
|
40
|
+
function collectChartDefsChildren(children) {
|
|
41
|
+
const defNodes = [];
|
|
42
|
+
Children.forEach(children, (child) => {
|
|
43
|
+
if (isValidElement(child) && isChartDefsComponent(child)) {
|
|
44
|
+
defNodes.push(child);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return defNodes;
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
collectChartDefsChildren,
|
|
51
|
+
getChartChildComponentName,
|
|
52
|
+
isChartDefsComponent,
|
|
53
|
+
isGradientDefComponent,
|
|
54
|
+
isPatternDefComponent,
|
|
55
|
+
partitionChartDefNodes
|
|
56
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const shortDateFmt = new Intl.DateTimeFormat("pt-BR", {
|
|
2
|
+
month: "short",
|
|
3
|
+
day: "numeric"
|
|
4
|
+
});
|
|
5
|
+
const weekdayDateFmt = new Intl.DateTimeFormat("pt-BR", {
|
|
6
|
+
weekday: "short",
|
|
7
|
+
month: "short",
|
|
8
|
+
day: "numeric"
|
|
9
|
+
});
|
|
10
|
+
const hmsTimeFmt = new Intl.DateTimeFormat("pt-BR", {
|
|
11
|
+
hour: "2-digit",
|
|
12
|
+
minute: "2-digit",
|
|
13
|
+
second: "2-digit",
|
|
14
|
+
hour12: false
|
|
15
|
+
});
|
|
16
|
+
const intFmt = new Intl.NumberFormat("pt-BR").format;
|
|
17
|
+
const valueLabelFmt = new Intl.NumberFormat("pt-BR", {
|
|
18
|
+
maximumFractionDigits: 0
|
|
19
|
+
}).format;
|
|
20
|
+
function isFiniteNumber(value) {
|
|
21
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
22
|
+
}
|
|
23
|
+
function formatBandRange(point, upperKey, lowerKey, format = intFmt) {
|
|
24
|
+
const upper = point[upperKey];
|
|
25
|
+
const lower = point[lowerKey];
|
|
26
|
+
if (!(isFiniteNumber(upper) && isFiniteNumber(lower))) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (upperKey === lowerKey) {
|
|
30
|
+
return upper;
|
|
31
|
+
}
|
|
32
|
+
return `${format(Math.min(lower, upper))} \u2013 ${format(Math.max(lower, upper))}`;
|
|
33
|
+
}
|
|
34
|
+
const EAGER_LABEL_LIMIT = 64;
|
|
35
|
+
function toArrayIndex(prop, length) {
|
|
36
|
+
if (typeof prop !== "string" || prop.length === 0) {
|
|
37
|
+
return -1;
|
|
38
|
+
}
|
|
39
|
+
const first = prop.charCodeAt(0);
|
|
40
|
+
if (first < 48 || first > 57) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
const index = Number(prop);
|
|
44
|
+
return Number.isInteger(index) && index < length && String(index) === prop ? index : -1;
|
|
45
|
+
}
|
|
46
|
+
function lazyLabels(length, format) {
|
|
47
|
+
if (length <= EAGER_LABEL_LIMIT) {
|
|
48
|
+
return Array.from({ length }, (_, index) => format(index));
|
|
49
|
+
}
|
|
50
|
+
const cache = new Array(length);
|
|
51
|
+
return new Proxy(cache, {
|
|
52
|
+
get(target, prop, receiver) {
|
|
53
|
+
const index = toArrayIndex(prop, length);
|
|
54
|
+
if (index === -1) {
|
|
55
|
+
return Reflect.get(target, prop, receiver);
|
|
56
|
+
}
|
|
57
|
+
let label = target[index];
|
|
58
|
+
if (label === void 0) {
|
|
59
|
+
label = format(index);
|
|
60
|
+
target[index] = label;
|
|
61
|
+
}
|
|
62
|
+
return label;
|
|
63
|
+
},
|
|
64
|
+
has(target, prop) {
|
|
65
|
+
return toArrayIndex(prop, length) !== -1 || Reflect.has(target, prop);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
formatBandRange,
|
|
71
|
+
hmsTimeFmt,
|
|
72
|
+
intFmt,
|
|
73
|
+
lazyLabels,
|
|
74
|
+
shortDateFmt,
|
|
75
|
+
valueLabelFmt,
|
|
76
|
+
weekdayDateFmt
|
|
77
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
const ChartLegendHoverContext = createContext(null);
|
|
5
|
+
function ChartLegendHoverProvider({
|
|
6
|
+
hoveredIndex,
|
|
7
|
+
onHoverChange,
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
10
|
+
const value = useMemo(
|
|
11
|
+
() => ({ hoveredIndex, setHoveredIndex: onHoverChange }),
|
|
12
|
+
[hoveredIndex, onHoverChange]
|
|
13
|
+
);
|
|
14
|
+
return /* @__PURE__ */ jsx(ChartLegendHoverContext.Provider, { value, children });
|
|
15
|
+
}
|
|
16
|
+
function useChartLegendHover() {
|
|
17
|
+
const context = useContext(ChartLegendHoverContext);
|
|
18
|
+
return context ?? {
|
|
19
|
+
hoveredIndex: null,
|
|
20
|
+
setHoveredIndex: () => {
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
ChartLegendHoverProvider,
|
|
26
|
+
useChartLegendHover
|
|
27
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Progress } from "@base-ui/react/progress";
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
import { intFmt } from "./chart-formatters";
|
|
6
|
+
function ProgressItem({
|
|
7
|
+
item,
|
|
8
|
+
showMarker,
|
|
9
|
+
showValue,
|
|
10
|
+
showPercentage,
|
|
11
|
+
formatValue,
|
|
12
|
+
labelClassName,
|
|
13
|
+
valueClassName
|
|
14
|
+
}) {
|
|
15
|
+
const percentage = item.maxValue ? item.value / item.maxValue * 100 : 0;
|
|
16
|
+
return /* @__PURE__ */ jsxs(
|
|
17
|
+
Progress.Root,
|
|
18
|
+
{
|
|
19
|
+
className: "grid w-full grid-cols-[auto_1fr_auto] items-center gap-x-3 gap-y-1",
|
|
20
|
+
max: item.maxValue,
|
|
21
|
+
value: item.value,
|
|
22
|
+
children: [
|
|
23
|
+
showMarker && /* @__PURE__ */ jsx(
|
|
24
|
+
"div",
|
|
25
|
+
{
|
|
26
|
+
className: "h-2.5 w-2.5 shrink-0 rounded-full",
|
|
27
|
+
style: { backgroundColor: item.color }
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ jsx(Progress.Label, { className: cn("text-legend-foreground", labelClassName), children: item.label }),
|
|
31
|
+
showValue ? /* @__PURE__ */ jsx("span", { className: cn("text-legend-muted-foreground", valueClassName), children: formatValue(item.value) }) : null,
|
|
32
|
+
/* @__PURE__ */ jsx(Progress.Track, { className: "col-span-full h-1.5 overflow-hidden rounded-full bg-legend-track", children: /* @__PURE__ */ jsx(
|
|
33
|
+
Progress.Indicator,
|
|
34
|
+
{
|
|
35
|
+
className: "h-full rounded-full transition-all duration-500",
|
|
36
|
+
style: { backgroundColor: item.color }
|
|
37
|
+
}
|
|
38
|
+
) }),
|
|
39
|
+
showPercentage && /* @__PURE__ */ jsxs("span", { className: "col-start-3 text-legend-muted-foreground text-xs tabular-nums", children: [
|
|
40
|
+
percentage.toFixed(0),
|
|
41
|
+
"%"
|
|
42
|
+
] })
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function SimpleItem({
|
|
48
|
+
item,
|
|
49
|
+
showMarker,
|
|
50
|
+
showValue,
|
|
51
|
+
formatValue,
|
|
52
|
+
labelClassName,
|
|
53
|
+
valueClassName
|
|
54
|
+
}) {
|
|
55
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
56
|
+
showMarker && /* @__PURE__ */ jsx(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
className: "h-2.5 w-2.5 shrink-0 rounded-full",
|
|
60
|
+
style: { backgroundColor: item.color }
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsx("span", { className: cn("flex-1 text-legend-foreground", labelClassName), children: item.label }),
|
|
64
|
+
showValue ? /* @__PURE__ */ jsx("span", { className: cn("text-legend-muted-foreground", valueClassName), children: formatValue(item.value) }) : null
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
function ChartLegend({
|
|
68
|
+
items,
|
|
69
|
+
hoveredIndex = null,
|
|
70
|
+
onHover,
|
|
71
|
+
showProgress = false,
|
|
72
|
+
showMarker = true,
|
|
73
|
+
showValue = true,
|
|
74
|
+
showPercentage,
|
|
75
|
+
formatValue = intFmt,
|
|
76
|
+
title,
|
|
77
|
+
className = "",
|
|
78
|
+
titleClassName = "text-sm font-semibold",
|
|
79
|
+
itemClassName = "",
|
|
80
|
+
labelClassName = "text-sm font-medium",
|
|
81
|
+
valueClassName = "text-sm tabular-nums",
|
|
82
|
+
renderItem
|
|
83
|
+
}) {
|
|
84
|
+
const displayPercentage = showPercentage ?? showProgress;
|
|
85
|
+
return /* @__PURE__ */ jsxs(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
className: cn("legend-container flex flex-col gap-2", className),
|
|
89
|
+
"data-chart-legend": "",
|
|
90
|
+
children: [
|
|
91
|
+
title && /* @__PURE__ */ jsx("h3", { className: cn("mb-1 text-legend-foreground", titleClassName), children: title }),
|
|
92
|
+
items.map((item, i) => {
|
|
93
|
+
const percentage = item.maxValue ? item.value / item.maxValue * 100 : 0;
|
|
94
|
+
const isHovered = hoveredIndex === i;
|
|
95
|
+
const isFaded = hoveredIndex !== null && hoveredIndex !== i;
|
|
96
|
+
if (renderItem) {
|
|
97
|
+
return (
|
|
98
|
+
// biome-ignore lint/a11y/noNoninteractiveElementInteractions: Legend item hover interaction
|
|
99
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: Legend item hover interaction
|
|
100
|
+
/* @__PURE__ */ jsx(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
"data-hovered": isHovered ? "" : void 0,
|
|
104
|
+
onMouseEnter: () => onHover?.(i),
|
|
105
|
+
onMouseLeave: () => onHover?.(null),
|
|
106
|
+
children: renderItem({ item, index: i, isHovered, isFaded, percentage })
|
|
107
|
+
},
|
|
108
|
+
`legend-${item.label}-${item.value}`
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return (
|
|
113
|
+
// biome-ignore lint/a11y/noNoninteractiveElementInteractions: Legend item hover interaction
|
|
114
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: Legend item hover interaction
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
className: cn(
|
|
119
|
+
"cursor-pointer rounded-lg px-2 py-1.5 transition-all duration-150 ease-out",
|
|
120
|
+
isHovered && "bg-legend-muted",
|
|
121
|
+
isFaded && "opacity-40",
|
|
122
|
+
itemClassName
|
|
123
|
+
),
|
|
124
|
+
"data-hovered": isHovered ? "" : void 0,
|
|
125
|
+
onMouseEnter: () => onHover?.(i),
|
|
126
|
+
onMouseLeave: () => onHover?.(null),
|
|
127
|
+
children: showProgress && item.maxValue ? /* @__PURE__ */ jsx(
|
|
128
|
+
ProgressItem,
|
|
129
|
+
{
|
|
130
|
+
formatValue,
|
|
131
|
+
item,
|
|
132
|
+
labelClassName,
|
|
133
|
+
showMarker,
|
|
134
|
+
showPercentage: displayPercentage,
|
|
135
|
+
showValue,
|
|
136
|
+
valueClassName
|
|
137
|
+
}
|
|
138
|
+
) : /* @__PURE__ */ jsx(
|
|
139
|
+
SimpleItem,
|
|
140
|
+
{
|
|
141
|
+
formatValue,
|
|
142
|
+
item,
|
|
143
|
+
labelClassName,
|
|
144
|
+
showMarker,
|
|
145
|
+
showValue,
|
|
146
|
+
valueClassName
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
},
|
|
150
|
+
`legend-${item.label}-${item.value}`
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
ChartLegend.displayName = "ChartLegend";
|
|
159
|
+
var chart_legend_default = ChartLegend;
|
|
160
|
+
export {
|
|
161
|
+
ChartLegend,
|
|
162
|
+
chart_legend_default as default
|
|
163
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "motion/react";
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
import { ShimmeringText } from "../shimmering-text";
|
|
6
|
+
import {
|
|
7
|
+
LINE_LOADING_PULSE_EASE,
|
|
8
|
+
LOADING_LABEL_EXIT_S,
|
|
9
|
+
LOADING_LABEL_EXIT_Y_PX
|
|
10
|
+
} from "./line-loading-timing";
|
|
11
|
+
function ChartLoadingLabel({
|
|
12
|
+
text = "Carregando",
|
|
13
|
+
className,
|
|
14
|
+
exiting = false
|
|
15
|
+
}) {
|
|
16
|
+
if (!text.trim()) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
m.div,
|
|
21
|
+
{
|
|
22
|
+
animate: {
|
|
23
|
+
y: exiting ? LOADING_LABEL_EXIT_Y_PX : 0,
|
|
24
|
+
opacity: exiting ? 0 : 1,
|
|
25
|
+
filter: exiting ? "blur(2px)" : "blur(0px)"
|
|
26
|
+
},
|
|
27
|
+
"aria-live": "polite",
|
|
28
|
+
className: cn(
|
|
29
|
+
"pointer-events-none absolute inset-0 flex items-center justify-center",
|
|
30
|
+
className
|
|
31
|
+
),
|
|
32
|
+
initial: false,
|
|
33
|
+
role: "status",
|
|
34
|
+
transition: {
|
|
35
|
+
duration: LOADING_LABEL_EXIT_S,
|
|
36
|
+
ease: [...LINE_LOADING_PULSE_EASE]
|
|
37
|
+
},
|
|
38
|
+
children: /* @__PURE__ */ jsx(
|
|
39
|
+
ShimmeringText,
|
|
40
|
+
{
|
|
41
|
+
className: "whitespace-nowrap font-medium text-sm tracking-normal [--color:var(--chart-foreground-muted)] [--shimmering-color:var(--chart-foreground)]",
|
|
42
|
+
text
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
var chart_loading_label_default = ChartLoadingLabel;
|
|
49
|
+
export {
|
|
50
|
+
ChartLoadingLabel,
|
|
51
|
+
chart_loading_label_default as default
|
|
52
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState
|
|
8
|
+
} from "react";
|
|
9
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
10
|
+
const ZERO_SIZE = { width: 0, height: 0 };
|
|
11
|
+
function readElementSize(element) {
|
|
12
|
+
const style = getComputedStyle(element);
|
|
13
|
+
const width = Number.parseFloat(style.width);
|
|
14
|
+
const height = Number.parseFloat(style.height);
|
|
15
|
+
return {
|
|
16
|
+
width: Number.isFinite(width) ? width : element.clientWidth,
|
|
17
|
+
height: Number.isFinite(height) ? height : element.clientHeight
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const sameSize = (a, b) => a.width === b.width && a.height === b.height;
|
|
21
|
+
function leadingDebounce(fn, wait) {
|
|
22
|
+
let timeout;
|
|
23
|
+
let pending = null;
|
|
24
|
+
const debounced = (arg) => {
|
|
25
|
+
if (timeout === void 0) {
|
|
26
|
+
fn(arg);
|
|
27
|
+
pending = null;
|
|
28
|
+
} else {
|
|
29
|
+
pending = { arg };
|
|
30
|
+
}
|
|
31
|
+
clearTimeout(timeout);
|
|
32
|
+
timeout = setTimeout(() => {
|
|
33
|
+
timeout = void 0;
|
|
34
|
+
if (pending !== null) {
|
|
35
|
+
fn(pending.arg);
|
|
36
|
+
pending = null;
|
|
37
|
+
}
|
|
38
|
+
}, wait);
|
|
39
|
+
};
|
|
40
|
+
debounced.cancel = () => {
|
|
41
|
+
clearTimeout(timeout);
|
|
42
|
+
timeout = void 0;
|
|
43
|
+
pending = null;
|
|
44
|
+
};
|
|
45
|
+
return debounced;
|
|
46
|
+
}
|
|
47
|
+
function useElementSize(ref, debounceTime = 0, { timing = "layout" } = {}) {
|
|
48
|
+
const [size, setSize] = useState(ZERO_SIZE);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const element = ref.current;
|
|
51
|
+
if (timing !== "observer" || !element || typeof ResizeObserver === "undefined") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const resize = leadingDebounce((next) => {
|
|
55
|
+
setSize((prev) => sameSize(prev, next) ? prev : next);
|
|
56
|
+
}, debounceTime);
|
|
57
|
+
let frame = 0;
|
|
58
|
+
const observer = new ResizeObserver((entries) => {
|
|
59
|
+
for (const entry of entries) {
|
|
60
|
+
const { width, height } = entry.contentRect;
|
|
61
|
+
frame = requestAnimationFrame(() => resize({ width, height }));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
observer.observe(element);
|
|
65
|
+
return () => {
|
|
66
|
+
cancelAnimationFrame(frame);
|
|
67
|
+
observer.disconnect();
|
|
68
|
+
resize.cancel();
|
|
69
|
+
};
|
|
70
|
+
}, [ref, debounceTime, timing]);
|
|
71
|
+
useIsomorphicLayoutEffect(() => {
|
|
72
|
+
const element = ref.current;
|
|
73
|
+
if (timing !== "layout" || !element) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const apply = () => {
|
|
77
|
+
const next = readElementSize(element);
|
|
78
|
+
setSize((prev) => sameSize(prev, next) ? prev : next);
|
|
79
|
+
};
|
|
80
|
+
apply();
|
|
81
|
+
if (typeof ResizeObserver === "undefined") {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
let timeout = null;
|
|
85
|
+
let trailing = false;
|
|
86
|
+
const observer = new ResizeObserver(() => {
|
|
87
|
+
if (debounceTime <= 0) {
|
|
88
|
+
apply();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (timeout !== null) {
|
|
92
|
+
trailing = true;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
apply();
|
|
96
|
+
const flush = () => {
|
|
97
|
+
if (trailing) {
|
|
98
|
+
trailing = false;
|
|
99
|
+
apply();
|
|
100
|
+
timeout = setTimeout(flush, debounceTime);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
timeout = null;
|
|
104
|
+
};
|
|
105
|
+
timeout = setTimeout(flush, debounceTime);
|
|
106
|
+
});
|
|
107
|
+
observer.observe(element);
|
|
108
|
+
return () => {
|
|
109
|
+
observer.disconnect();
|
|
110
|
+
if (timeout !== null) {
|
|
111
|
+
clearTimeout(timeout);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}, [ref, debounceTime, timing]);
|
|
115
|
+
return size;
|
|
116
|
+
}
|
|
117
|
+
function ParentSize({
|
|
118
|
+
children,
|
|
119
|
+
className,
|
|
120
|
+
debounceTime,
|
|
121
|
+
style
|
|
122
|
+
}) {
|
|
123
|
+
const parentRef = useRef(null);
|
|
124
|
+
const { width, height } = useElementSize(parentRef, debounceTime ?? 300);
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
className,
|
|
129
|
+
style: { position: "relative", width: "100%", height: "100%", ...style },
|
|
130
|
+
children: /* @__PURE__ */ jsx("div", { ref: parentRef, style: { position: "absolute", inset: 0 }, children: children({ width, height }) })
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
ParentSize,
|
|
136
|
+
useElementSize,
|
|
137
|
+
useIsomorphicLayoutEffect
|
|
138
|
+
};
|