glacia-native 0.3.3 → 0.3.4

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.
Files changed (67) hide show
  1. package/lib/module/Dialog.js +128 -0
  2. package/lib/module/Form.js +125 -0
  3. package/lib/module/Input.js +64 -0
  4. package/lib/module/Table.js +81 -0
  5. package/lib/module/ai.js +246 -0
  6. package/lib/module/charts/AreaChart.js +32 -0
  7. package/lib/module/charts/BarChart.js +65 -0
  8. package/lib/module/charts/FunnelChart.js +48 -0
  9. package/lib/module/charts/HeatmapChart.js +69 -0
  10. package/lib/module/charts/LineChart.js +79 -0
  11. package/lib/module/charts/PlotChart.js +44 -0
  12. package/lib/module/charts/RadarChart.js +76 -0
  13. package/lib/module/charts/RingChart.js +50 -0
  14. package/lib/module/charts/ScatterChart.js +78 -0
  15. package/lib/module/charts/WaterfallChart.js +76 -0
  16. package/lib/module/charts/advanced.js +307 -0
  17. package/lib/module/charts/extra.js +105 -0
  18. package/lib/module/charts/index.js +50 -0
  19. package/lib/module/charts/primitives.js +212 -0
  20. package/lib/module/charts/scales.js +140 -0
  21. package/lib/module/index.js +48 -1
  22. package/lib/module/internal/tokens.js +3 -0
  23. package/lib/typescript/Dialog.d.ts +71 -0
  24. package/lib/typescript/Form.d.ts +81 -0
  25. package/lib/typescript/Input.d.ts +47 -0
  26. package/lib/typescript/Table.d.ts +55 -0
  27. package/lib/typescript/ai.d.ts +163 -0
  28. package/lib/typescript/charts/AreaChart.d.ts +44 -0
  29. package/lib/typescript/charts/BarChart.d.ts +19 -0
  30. package/lib/typescript/charts/FunnelChart.d.ts +25 -0
  31. package/lib/typescript/charts/HeatmapChart.d.ts +23 -0
  32. package/lib/typescript/charts/LineChart.d.ts +30 -0
  33. package/lib/typescript/charts/PlotChart.d.ts +31 -0
  34. package/lib/typescript/charts/RadarChart.d.ts +27 -0
  35. package/lib/typescript/charts/RingChart.d.ts +28 -0
  36. package/lib/typescript/charts/ScatterChart.d.ts +34 -0
  37. package/lib/typescript/charts/WaterfallChart.d.ts +22 -0
  38. package/lib/typescript/charts/advanced.d.ts +107 -0
  39. package/lib/typescript/charts/extra.d.ts +63 -0
  40. package/lib/typescript/charts/index.d.ts +13 -0
  41. package/lib/typescript/charts/primitives.d.ts +23 -0
  42. package/lib/typescript/charts/scales.d.ts +35 -0
  43. package/lib/typescript/index.d.ts +6 -0
  44. package/lib/typescript/internal/tokens.d.ts +2 -0
  45. package/package.json +10 -3
  46. package/src/Dialog.tsx +345 -0
  47. package/src/Form.tsx +360 -0
  48. package/src/Input.tsx +172 -0
  49. package/src/Table.tsx +207 -0
  50. package/src/ai.tsx +655 -0
  51. package/src/charts/AreaChart.tsx +73 -0
  52. package/src/charts/BarChart.tsx +181 -0
  53. package/src/charts/FunnelChart.tsx +123 -0
  54. package/src/charts/HeatmapChart.tsx +153 -0
  55. package/src/charts/LineChart.tsx +245 -0
  56. package/src/charts/PlotChart.tsx +148 -0
  57. package/src/charts/RadarChart.tsx +206 -0
  58. package/src/charts/RingChart.tsx +131 -0
  59. package/src/charts/ScatterChart.tsx +202 -0
  60. package/src/charts/WaterfallChart.tsx +183 -0
  61. package/src/charts/advanced.tsx +670 -0
  62. package/src/charts/extra.tsx +239 -0
  63. package/src/charts/index.ts +86 -0
  64. package/src/charts/primitives.ts +262 -0
  65. package/src/charts/scales.ts +163 -0
  66. package/src/index.ts +68 -0
  67. package/src/internal/tokens.ts +3 -0
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativePolarAreaChart = NativePolarAreaChart;
4
+ exports.NativePyramidChart = NativePyramidChart;
5
+ exports.NativeLiveLineChart = NativeLiveLineChart;
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const tokens_1 = require("../internal/tokens");
9
+ const primitives_1 = require("./primitives");
10
+ const LineChart_1 = require("./LineChart");
11
+ const scales_1 = require("./scales");
12
+ const TAU = Math.PI * 2;
13
+ /** Point on a circle at `angle` radians, measured from 12 o'clock. */
14
+ function polar(angle, radius, cx, cy) {
15
+ return { x: cx + Math.sin(angle) * radius, y: cy - Math.cos(angle) * radius };
16
+ }
17
+ /**
18
+ * Equal-angle wedges whose radius encodes value.
19
+ *
20
+ * Unlike a pie chart, every wedge uses the same angle, so the reader compares
21
+ * one dimension (radius) rather than area. Each wedge is separately tappable
22
+ * because a phone has no hover.
23
+ */
24
+ function NativePolarAreaChart({ segments, size = 240, max, isDark = false, palette, style, onSegmentPress, }) {
25
+ const [active, setActive] = (0, react_1.useState)(null);
26
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
27
+ const { View, Text, Pressable, Svg, G, Path, Circle } = (0, primitives_1.primitives)();
28
+ if (segments.length === 0) {
29
+ return ((0, jsx_runtime_1.jsx)(View, { style: [{ width: size, alignItems: "center", paddingVertical: 20 }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No segments to display" }) }));
30
+ }
31
+ const centre = size / 2;
32
+ const outer = centre - 8;
33
+ const highest = Math.max(...segments.map((segment) => segment.value));
34
+ const scaleMax = max ?? (highest || 1);
35
+ const step = TAU / segments.length;
36
+ return ((0, jsx_runtime_1.jsxs)(View, { style: [{ width: size }, style], children: [(0, jsx_runtime_1.jsxs)(Svg, { width: size, height: size, children: [segments.map((segment, index) => {
37
+ const ratio = Math.max(0.04, Math.min(1, segment.value / scaleMax));
38
+ const radius = outer * ratio;
39
+ const start = index * step - step / 2;
40
+ const end = start + step;
41
+ const from = polar(start, radius, centre, centre);
42
+ const to = polar(end, radius, centre, centre);
43
+ const color = segment.color ?? (0, scales_1.seriesColor)(index, palette);
44
+ // Large-arc is always 0 here: a wedge never exceeds half the circle.
45
+ const path = [
46
+ `M ${centre} ${centre}`,
47
+ `L ${from.x} ${from.y}`,
48
+ `A ${radius} ${radius} 0 0 1 ${to.x} ${to.y}`,
49
+ "Z",
50
+ ].join(" ");
51
+ return ((0, jsx_runtime_1.jsx)(Path, { d: path, fill: color, fillOpacity: active === null || active === index ? 0.85 : 0.4, stroke: theme.edge, strokeWidth: 1, onPress: () => {
52
+ setActive((current) => (current === index ? null : index));
53
+ onSegmentPress?.(index);
54
+ } }, segment.label));
55
+ }), (0, jsx_runtime_1.jsx)(Circle, { cx: centre, cy: centre, r: outer * 0.18, fill: theme.glass })] }), (0, jsx_runtime_1.jsx)(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 8, marginTop: 8 }, children: segments.map((segment, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${segment.label}: ${(0, scales_1.formatValue)(segment.value)}`, onPress: () => {
56
+ setActive((current) => (current === index ? null : index));
57
+ onSegmentPress?.(index);
58
+ }, style: { flexDirection: "row", alignItems: "center", gap: 4 }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
59
+ width: 8,
60
+ height: 8,
61
+ borderRadius: 4,
62
+ backgroundColor: segment.color ?? (0, scales_1.seriesColor)(index, palette),
63
+ } }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted }, children: segment.label })] }, segment.label))) })] }));
64
+ }
65
+ /**
66
+ * Stacked bands that narrow toward the top.
67
+ *
68
+ * Bands are Views rather than SVG: each is a centred rectangle whose width is
69
+ * the band's share of the widest level, which native layout computes exactly.
70
+ */
71
+ function NativePyramidChart({ levels, levelHeight = 34, width = 320, isDark = false, palette, style, onLevelPress, }) {
72
+ const [active, setActive] = (0, react_1.useState)(null);
73
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
74
+ const { View, Text, Pressable } = (0, primitives_1.primitives)();
75
+ if (levels.length === 0) {
76
+ return ((0, jsx_runtime_1.jsx)(View, { style: [{ width, alignItems: "center", paddingVertical: 20 }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No levels to display" }) }));
77
+ }
78
+ const widest = Math.max(...levels.map((level) => level.value)) || 1;
79
+ return ((0, jsx_runtime_1.jsx)(View, { style: [{ width }, style], children: levels.map((level, index) => {
80
+ const share = Math.max(0.06, level.value / widest);
81
+ const color = level.color ?? (0, scales_1.seriesColor)(index, palette);
82
+ return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: `${level.label}: ${(0, scales_1.formatValue)(level.value)}`, onPress: () => {
83
+ setActive((current) => (current === index ? null : index));
84
+ onLevelPress?.(index);
85
+ }, style: { alignItems: "center", marginBottom: 2 }, children: (0, jsx_runtime_1.jsx)(View, { style: {
86
+ width: `${share * 100}%`,
87
+ height: levelHeight,
88
+ borderRadius: 4,
89
+ backgroundColor: color,
90
+ opacity: active === null || active === index ? 1 : 0.45,
91
+ alignItems: "center",
92
+ justifyContent: "center",
93
+ }, children: (0, jsx_runtime_1.jsxs)(Text, { style: { fontSize: 10, fontWeight: "600", color: "#fff" }, numberOfLines: 1, children: [level.label, " \u00B7 ", (0, scales_1.formatValue)(level.value, { compact: true })] }) }) }, level.label));
94
+ }) }));
95
+ }
96
+ /**
97
+ * A line chart that keeps only the most recent window of points.
98
+ *
99
+ * The caller pushes new values; this trims to `labels.length` so the window
100
+ * slides instead of growing without bound. Pausing is the caller's decision —
101
+ * a chart that stops itself would hide data the user expects to see arrive.
102
+ */
103
+ function NativeLiveLineChart(props) {
104
+ return (0, jsx_runtime_1.jsx)(LineChart_1.NativeLineChart, { ...props, smooth: false, showDots: false });
105
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ // Native charts, drawn with react-native-svg.
3
+ //
4
+ // These share their scale maths and colour ramp with the web package, so the
5
+ // same series produces the same axis values on both platforms. Touch replaces
6
+ // hover: tapping a bar, point or slice selects it.
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.NativePlotChart = exports.NativeHexChart = exports.NativeBumpChart = exports.NativeSankeyChart = exports.NativeTreemapChart = exports.NativeCandlestickChart = exports.NativeLiveLineChart = exports.NativePyramidChart = exports.NativePolarAreaChart = exports.SERIES_COLORS = exports.seriesColor = exports.formatValue = exports.arcPath = exports.smoothPath = exports.bandScale = exports.ticks = exports.niceDomain = exports.linearScale = exports.NativeWaterfallChart = exports.NativeRadarChart = exports.NativeHeatmapChart = exports.NativeFunnelChart = exports.NativeBubbleChart = exports.NativeScatterChart = exports.NativeMirrorAreaChart = exports.NativeAreaChart = exports.NativeRingChart = exports.NativeBarChart = exports.NativeLineChart = void 0;
9
+ var LineChart_1 = require("./LineChart");
10
+ Object.defineProperty(exports, "NativeLineChart", { enumerable: true, get: function () { return LineChart_1.NativeLineChart; } });
11
+ var BarChart_1 = require("./BarChart");
12
+ Object.defineProperty(exports, "NativeBarChart", { enumerable: true, get: function () { return BarChart_1.NativeBarChart; } });
13
+ var RingChart_1 = require("./RingChart");
14
+ Object.defineProperty(exports, "NativeRingChart", { enumerable: true, get: function () { return RingChart_1.NativeRingChart; } });
15
+ var AreaChart_1 = require("./AreaChart");
16
+ Object.defineProperty(exports, "NativeAreaChart", { enumerable: true, get: function () { return AreaChart_1.NativeAreaChart; } });
17
+ Object.defineProperty(exports, "NativeMirrorAreaChart", { enumerable: true, get: function () { return AreaChart_1.NativeMirrorAreaChart; } });
18
+ var ScatterChart_1 = require("./ScatterChart");
19
+ Object.defineProperty(exports, "NativeScatterChart", { enumerable: true, get: function () { return ScatterChart_1.NativeScatterChart; } });
20
+ Object.defineProperty(exports, "NativeBubbleChart", { enumerable: true, get: function () { return ScatterChart_1.NativeBubbleChart; } });
21
+ var FunnelChart_1 = require("./FunnelChart");
22
+ Object.defineProperty(exports, "NativeFunnelChart", { enumerable: true, get: function () { return FunnelChart_1.NativeFunnelChart; } });
23
+ var HeatmapChart_1 = require("./HeatmapChart");
24
+ Object.defineProperty(exports, "NativeHeatmapChart", { enumerable: true, get: function () { return HeatmapChart_1.NativeHeatmapChart; } });
25
+ var RadarChart_1 = require("./RadarChart");
26
+ Object.defineProperty(exports, "NativeRadarChart", { enumerable: true, get: function () { return RadarChart_1.NativeRadarChart; } });
27
+ var WaterfallChart_1 = require("./WaterfallChart");
28
+ Object.defineProperty(exports, "NativeWaterfallChart", { enumerable: true, get: function () { return WaterfallChart_1.NativeWaterfallChart; } });
29
+ var scales_1 = require("./scales");
30
+ Object.defineProperty(exports, "linearScale", { enumerable: true, get: function () { return scales_1.linearScale; } });
31
+ Object.defineProperty(exports, "niceDomain", { enumerable: true, get: function () { return scales_1.niceDomain; } });
32
+ Object.defineProperty(exports, "ticks", { enumerable: true, get: function () { return scales_1.ticks; } });
33
+ Object.defineProperty(exports, "bandScale", { enumerable: true, get: function () { return scales_1.bandScale; } });
34
+ Object.defineProperty(exports, "smoothPath", { enumerable: true, get: function () { return scales_1.smoothPath; } });
35
+ Object.defineProperty(exports, "arcPath", { enumerable: true, get: function () { return scales_1.arcPath; } });
36
+ Object.defineProperty(exports, "formatValue", { enumerable: true, get: function () { return scales_1.formatValue; } });
37
+ Object.defineProperty(exports, "seriesColor", { enumerable: true, get: function () { return scales_1.seriesColor; } });
38
+ Object.defineProperty(exports, "SERIES_COLORS", { enumerable: true, get: function () { return scales_1.SERIES_COLORS; } });
39
+ var extra_1 = require("./extra");
40
+ Object.defineProperty(exports, "NativePolarAreaChart", { enumerable: true, get: function () { return extra_1.NativePolarAreaChart; } });
41
+ Object.defineProperty(exports, "NativePyramidChart", { enumerable: true, get: function () { return extra_1.NativePyramidChart; } });
42
+ Object.defineProperty(exports, "NativeLiveLineChart", { enumerable: true, get: function () { return extra_1.NativeLiveLineChart; } });
43
+ var advanced_1 = require("./advanced");
44
+ Object.defineProperty(exports, "NativeCandlestickChart", { enumerable: true, get: function () { return advanced_1.NativeCandlestickChart; } });
45
+ Object.defineProperty(exports, "NativeTreemapChart", { enumerable: true, get: function () { return advanced_1.NativeTreemapChart; } });
46
+ Object.defineProperty(exports, "NativeSankeyChart", { enumerable: true, get: function () { return advanced_1.NativeSankeyChart; } });
47
+ Object.defineProperty(exports, "NativeBumpChart", { enumerable: true, get: function () { return advanced_1.NativeBumpChart; } });
48
+ Object.defineProperty(exports, "NativeHexChart", { enumerable: true, get: function () { return advanced_1.NativeHexChart; } });
49
+ var PlotChart_1 = require("./PlotChart");
50
+ Object.defineProperty(exports, "NativePlotChart", { enumerable: true, get: function () { return PlotChart_1.NativePlotChart; } });
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ // React Native component resolution.
3
+ //
4
+ // The package never imports `react-native` or `react-native-svg` statically:
5
+ // both ship Flow-typed sources that a plain JS bundler (and the jsdom test
6
+ // environment) cannot parse. Resolving them at runtime keeps the package
7
+ // importable everywhere, matching how GlassView already locates the native
8
+ // liquid glass module.
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.primitives = primitives;
11
+ /**
12
+ * Resolves the primitives, falling back to pass-through DOM elements so the
13
+ * package can be rendered in a non-native environment (tests, web preview)
14
+ * without throwing.
15
+ */
16
+ function resolve() {
17
+ let View;
18
+ let Text;
19
+ let Pressable;
20
+ let svg = null;
21
+ let rn = null;
22
+ try {
23
+ rn = require("react-native");
24
+ View = rn.View;
25
+ Text = rn.Text;
26
+ Pressable = rn.Pressable;
27
+ }
28
+ catch {
29
+ // Non-native environment: render simple elements instead.
30
+ }
31
+ try {
32
+ svg = require("react-native-svg");
33
+ }
34
+ catch {
35
+ svg = null;
36
+ }
37
+ /**
38
+ * Adapts React Native props to the DOM preview used when RN is absent.
39
+ * Without this, `accessibilityRole` and `onPress` reach the DOM untranslated
40
+ * and the element is neither reachable nor clickable in tests.
41
+ */
42
+ const fallback = (tag) => function Primitive(props) {
43
+ const { children, style, accessibilityRole, accessibilityLabel, accessibilityState, onPress, numberOfLines, onChangeText, value, editable, nativeID, disabled, keyboardType: _keyboardType, returnKeyType: _returnKeyType, onSubmitEditing: _onSubmitEditing, secureTextEntry: _secureTextEntry, autoCapitalize: _autoCapitalize, autoCorrect: _autoCorrect, multiline, onFocus: _onFocus, onBlur: _onBlur, editable: _editable, ...rest } = props ?? {};
44
+ const { createElement } = require("react");
45
+ // RN accepts unitless numbers where the DOM requires "px"; convert the
46
+ // length properties so the preview lays out instead of throwing.
47
+ const domProps = { style: toDomStyle(style), ...rest };
48
+ // RN roles that already exist in ARIA pass straight through.
49
+ const ROLE_MAP = {
50
+ button: "button",
51
+ checkbox: "checkbox",
52
+ radio: "radio",
53
+ radiogroup: "radiogroup",
54
+ alert: "alert",
55
+ text: "text",
56
+ link: "link",
57
+ image: "img",
58
+ tab: "tab",
59
+ progressbar: "progressbar",
60
+ tablist: "tablist",
61
+ switch: "switch",
62
+ slider: "slider",
63
+ heading: "heading",
64
+ };
65
+ // "none" means presentational: emit no role rather than a misleading one.
66
+ if (accessibilityRole && accessibilityRole !== "none") {
67
+ domProps.role = ROLE_MAP[accessibilityRole] ?? "text";
68
+ }
69
+ if (accessibilityLabel != null)
70
+ domProps["aria-label"] = accessibilityLabel;
71
+ if (numberOfLines != null)
72
+ domProps["data-lines"] = numberOfLines;
73
+ if (nativeID != null)
74
+ domProps.id = nativeID;
75
+ if (accessibilityState) {
76
+ const state = accessibilityState;
77
+ if (state.checked !== undefined)
78
+ domProps["aria-checked"] = state.checked;
79
+ if (state.selected !== undefined)
80
+ domProps["aria-selected"] = state.selected;
81
+ if (state.expanded !== undefined)
82
+ domProps["aria-expanded"] = state.expanded;
83
+ if (state.disabled !== undefined)
84
+ domProps["aria-disabled"] = state.disabled;
85
+ }
86
+ // Inputs: bridge the RN controlled-value contract to the DOM one.
87
+ if (tag === "input") {
88
+ // A multiline field must be a real textarea: an <input> cannot wrap.
89
+ if (multiline) {
90
+ tag = "textarea";
91
+ if (typeof numberOfLines === "number")
92
+ domProps.rows = numberOfLines;
93
+ }
94
+ }
95
+ if (tag === "input" || tag === "textarea") {
96
+ if (value != null)
97
+ domProps.value = value;
98
+ if (onChangeText) {
99
+ domProps.onChange = (event) => onChangeText(event.target.value);
100
+ }
101
+ if (editable === false || disabled)
102
+ domProps.disabled = true;
103
+ }
104
+ if (onPress) {
105
+ if (tag === "button" || tag === "input")
106
+ domProps.onClick = onPress;
107
+ else {
108
+ // A non-button element needs to be operable from the keyboard too.
109
+ domProps.onClick = onPress;
110
+ if (domProps.role === "button" || domProps.role === "checkbox" || domProps.role === "radio") {
111
+ domProps.tabIndex = 0;
112
+ }
113
+ }
114
+ }
115
+ if (disabled)
116
+ domProps["aria-disabled"] = true;
117
+ return createElement(tag, domProps, children);
118
+ };
119
+ /** Resolves React Native's BackHandler, or null off-device. */
120
+ const getBackHandler = () => rn?.BackHandler ?? null;
121
+ /**
122
+ * A Modal that only mounts its children while visible.
123
+ *
124
+ * The generic fallback would render the content regardless of `visible`,
125
+ * which would surface every closed dialog in the DOM preview.
126
+ */
127
+ const modalFallback = (tag) => function Primitive(props) {
128
+ const { children, visible, onRequestClose, ...rest } = props ?? {};
129
+ if (!visible)
130
+ return null;
131
+ const { createElement } = require("react");
132
+ return createElement(tag, { style: toDomStyle(rest.style) }, children);
133
+ };
134
+ /** An image that reads its remote source in the DOM preview. */
135
+ function imageFallback(props) {
136
+ const { source, accessibilityLabel, style } = props ?? {};
137
+ const { createElement } = require("react");
138
+ return createElement("img", {
139
+ src: source?.uri,
140
+ alt: accessibilityLabel ?? "",
141
+ style: toDomStyle(style),
142
+ });
143
+ }
144
+ const SvgComponent = svg?.default ?? fallback("svg");
145
+ const SvgText = svg?.Text ?? fallback("text");
146
+ return {
147
+ View: View ?? fallback("div"),
148
+ Text: Text ?? fallback("span"),
149
+ Pressable: Pressable ?? fallback("button"),
150
+ Svg: SvgComponent,
151
+ G: svg?.G ?? fallback("g"),
152
+ Line: svg?.Line ?? fallback("line"),
153
+ Path: svg?.Path ?? fallback("path"),
154
+ Circle: svg?.Circle ?? fallback("circle"),
155
+ Rect: svg?.Rect ?? fallback("rect"),
156
+ Polygon: svg?.Polygon ?? fallback("polygon"),
157
+ // TextInput is not an SVG primitive, but resolving it here keeps every
158
+ // component on one runtime-resolution path instead of two.
159
+ TextInput: rn?.TextInput ?? fallback("input"),
160
+ // Modal is resolved the same way so dialogs degrade to a plain overlay
161
+ // outside a native runtime instead of failing to mount.
162
+ Modal: rn?.Modal ?? modalFallback("div"),
163
+ Image: rn?.Image ?? imageFallback,
164
+ getScrollView: () => rn?.ScrollView ?? null,
165
+ getBackHandler,
166
+ SvgText,
167
+ };
168
+ }
169
+ const LENGTH_PROPS = new Set([
170
+ "width",
171
+ "height",
172
+ "top",
173
+ "left",
174
+ "right",
175
+ "bottom",
176
+ "marginTop",
177
+ "marginBottom",
178
+ "marginLeft",
179
+ "marginRight",
180
+ "paddingTop",
181
+ "paddingBottom",
182
+ "paddingLeft",
183
+ "paddingRight",
184
+ "fontSize",
185
+ "borderRadius",
186
+ "gap",
187
+ ]);
188
+ /** Converts an RN style object to DOM-compatible CSS. */
189
+ function toDomStyle(style) {
190
+ if (!style)
191
+ return style;
192
+ const list = Array.isArray(style) ? style : [style];
193
+ const merged = {};
194
+ for (const entry of list) {
195
+ if (!entry)
196
+ continue;
197
+ for (const [key, value] of Object.entries(entry)) {
198
+ if (value == null)
199
+ continue;
200
+ merged[key] =
201
+ typeof value === "number" && LENGTH_PROPS.has(key) ? `${value}px` : value;
202
+ }
203
+ }
204
+ return merged;
205
+ }
206
+ let cache = null;
207
+ /** The resolved primitives, computed once per process. */
208
+ function primitives() {
209
+ if (!cache)
210
+ cache = resolve();
211
+ return cache;
212
+ }
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ // Native chart scales.
3
+ //
4
+ // This mirrors the web package's chart maths so a series drawn on a phone and
5
+ // the same series drawn in a browser land on the same axis values. It is
6
+ // deliberately duplicated rather than imported from `glacia`: glacia-native is
7
+ // a standalone package with no dependency on the web build.
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.seriesColor = exports.SERIES_COLORS = void 0;
10
+ exports.linearScale = linearScale;
11
+ exports.niceDomain = niceDomain;
12
+ exports.ticks = ticks;
13
+ exports.bandScale = bandScale;
14
+ exports.formatValue = formatValue;
15
+ exports.smoothPath = smoothPath;
16
+ exports.arcPath = arcPath;
17
+ function linearScale(domain, range, options = {}) {
18
+ let [d0, d1] = domain;
19
+ if (d0 === d1) {
20
+ d0 = d0 === 0 ? 0 : d0 * 0.9;
21
+ d1 = d1 === 0 ? 1 : d1 * 1.1;
22
+ }
23
+ const base = options.nice === false ? [d0, d1] : niceDomain(d0, d1, options.ticks ?? 5);
24
+ const [a, b] = base;
25
+ const [r0, r1] = range;
26
+ const span = b - a || 1;
27
+ const scale = ((value) => r0 + ((value - a) / span) * (r1 - r0));
28
+ scale.invert = (pixel) => a + ((pixel - r0) / (r1 - r0)) * span;
29
+ scale.domain = [a, b];
30
+ scale.range = range;
31
+ return scale;
32
+ }
33
+ /** Rounds a domain outward to values that read cleanly on an axis. */
34
+ function niceDomain(min, max, tickCount = 5) {
35
+ if (min === max)
36
+ return [min === 0 ? 0 : min * 0.9, max === 0 ? 1 : max * 1.1];
37
+ const span = max - min;
38
+ const step = Math.pow(10, Math.floor(Math.log10(span / tickCount)));
39
+ const error = span / tickCount / step;
40
+ const factor = error >= 7.5 ? 10 : error >= 3.5 ? 5 : error >= 1.5 ? 2 : 1;
41
+ const niceStep = step * factor;
42
+ return [Math.floor(min / niceStep) * niceStep, Math.ceil(max / niceStep) * niceStep];
43
+ }
44
+ function ticks(domain, count = 4) {
45
+ const [d0, d1] = domain;
46
+ if (d0 === d1)
47
+ return [d0];
48
+ return Array.from({ length: count + 1 }, (_, i) => d0 + ((d1 - d0) * i) / count);
49
+ }
50
+ /** Evenly divided bands; returns the centre and width of each. */
51
+ function bandScale(count, range, padding = 0.2) {
52
+ const [r0, r1] = range;
53
+ const step = (r1 - r0) / Math.max(1, count);
54
+ const width = step * (1 - padding);
55
+ return {
56
+ bandWidth: step,
57
+ width,
58
+ start: (i) => r0 + i * step + (step - width) / 2,
59
+ center: (i) => r0 + i * step + step / 2,
60
+ };
61
+ }
62
+ /** Compact number formatting, matching the web charts. */
63
+ function formatValue(value, options = {}) {
64
+ if (Number.isNaN(value))
65
+ return "—";
66
+ if (options.compact) {
67
+ const abs = Math.abs(value);
68
+ if (abs >= 1_000_000_000)
69
+ return trim(value / 1_000_000_000) + "B";
70
+ if (abs >= 1_000_000)
71
+ return trim(value / 1_000_000) + "M";
72
+ if (abs >= 1_000)
73
+ return trim(value / 1_000) + "k";
74
+ }
75
+ const fixed = options.decimals ?? (Number.isInteger(value) ? 0 : 2);
76
+ return value
77
+ .toFixed(fixed)
78
+ .replace(/(\.\d*?)0+$/, "$1")
79
+ .replace(/\.$/, "");
80
+ }
81
+ function trim(value) {
82
+ return (Math.round(value * 10) / 10).toString();
83
+ }
84
+ /** Points along a smooth (monotone) path, as SVG path segments. */
85
+ function smoothPath(points) {
86
+ if (points.length === 0)
87
+ return "";
88
+ if (points.length === 1)
89
+ return `M ${points[0].x} ${points[0].y}`;
90
+ if (points.length === 2)
91
+ return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`;
92
+ let d = `M ${points[0].x} ${points[0].y}`;
93
+ for (let i = 0; i < points.length - 1; i++) {
94
+ const p0 = points[i - 1] ?? points[i];
95
+ const p1 = points[i];
96
+ const p2 = points[i + 1];
97
+ const p3 = points[i + 2] ?? p2;
98
+ const t = 0.2;
99
+ const c1x = p1.x + (p2.x - p0.x) * t;
100
+ const c1y = p1.y + (p2.y - p0.y) * t;
101
+ const c2x = p2.x - (p3.x - p1.x) * t;
102
+ const c2y = p2.y - (p3.y - p1.y) * t;
103
+ // Clamp so the curve cannot overshoot the segment's own y-range.
104
+ const lo = Math.min(p1.y, p2.y);
105
+ const hi = Math.max(p1.y, p2.y);
106
+ d += ` C ${c1x} ${Math.min(hi, Math.max(lo, c1y))} ${c2x} ${Math.min(hi, Math.max(lo, c2y))} ${p2.x} ${p2.y}`;
107
+ }
108
+ return d;
109
+ }
110
+ /** A pie/donut arc, with an optional inner radius. */
111
+ function arcPath(cx, cy, outer, inner, startAngle, endAngle) {
112
+ const sweep = endAngle - startAngle;
113
+ if (sweep >= Math.PI * 2 - 1e-6) {
114
+ const mid = startAngle + Math.PI;
115
+ return (arcPath(cx, cy, outer, inner, startAngle, mid) +
116
+ " " +
117
+ arcPath(cx, cy, outer, inner, mid, endAngle - 1e-6));
118
+ }
119
+ const p = (r, a) => [cx + r * Math.cos(a), cy + r * Math.sin(a)];
120
+ const large = sweep > Math.PI ? 1 : 0;
121
+ const [x1, y1] = p(outer, startAngle);
122
+ const [x2, y2] = p(outer, endAngle);
123
+ if (inner <= 0) {
124
+ return `M ${cx} ${cy} L ${x1} ${y1} A ${outer} ${outer} 0 ${large} 1 ${x2} ${y2} Z`;
125
+ }
126
+ const [x3, y3] = p(inner, endAngle);
127
+ const [x4, y4] = p(inner, startAngle);
128
+ return `M ${x1} ${y1} A ${outer} ${outer} 0 ${large} 1 ${x2} ${y2} L ${x3} ${y3} A ${inner} ${inner} 0 ${large} 0 ${x4} ${y4} Z`;
129
+ }
130
+ exports.SERIES_COLORS = [
131
+ "#0088ff",
132
+ "#34c759",
133
+ "#ff9f0a",
134
+ "#ff375f",
135
+ "#bf5af2",
136
+ "#64d2ff",
137
+ "#ffd60a",
138
+ ];
139
+ const seriesColor = (index, palette) => (palette ?? exports.SERIES_COLORS)[index % (palette ?? exports.SERIES_COLORS).length];
140
+ exports.seriesColor = seriesColor;
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.springs = exports.radii = exports.colors = exports.isGlassSupported = exports.CardFooter = exports.CardBody = exports.CardContent = exports.CardDescription = exports.CardTitle = exports.CardHeader = exports.Card = exports.Tabs = exports.TabBar = exports.SegmentedControl = exports.Slider = exports.Switch = exports.Button = exports.Glass = void 0;
17
+ exports.springs = exports.radii = exports.colors = exports.isGlassSupported = exports.NativeScrollArea = exports.NativeTable = exports.NativeImageGeneration = exports.NativeAIInput = exports.NativePanelside = exports.NativeThinkingOrb = exports.NativeSoundwave = exports.NativeTask = exports.NativeResponse = exports.NativeSources = exports.NativePlan = exports.ActionSheet = exports.AlertDialog = exports.DialogTrigger = exports.Dialog = exports.Select = exports.RadioGroup = exports.Checkbox = exports.Field = exports.Label = exports.Textarea = exports.Input = exports.CardFooter = exports.CardBody = exports.CardContent = exports.CardDescription = exports.CardTitle = exports.CardHeader = exports.Card = exports.Tabs = exports.TabBar = exports.SegmentedControl = exports.Slider = exports.Switch = exports.Button = exports.Glass = void 0;
4
18
  var Glass_1 = require("./Glass");
5
19
  Object.defineProperty(exports, "Glass", { enumerable: true, get: function () { return Glass_1.Glass; } });
6
20
  var Button_1 = require("./Button");
@@ -23,6 +37,39 @@ Object.defineProperty(exports, "CardDescription", { enumerable: true, get: funct
23
37
  Object.defineProperty(exports, "CardContent", { enumerable: true, get: function () { return Card_1.CardContent; } });
24
38
  Object.defineProperty(exports, "CardBody", { enumerable: true, get: function () { return Card_1.CardBody; } });
25
39
  Object.defineProperty(exports, "CardFooter", { enumerable: true, get: function () { return Card_1.CardFooter; } });
40
+ // Forms.
41
+ var Input_1 = require("./Input");
42
+ Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return Input_1.Input; } });
43
+ Object.defineProperty(exports, "Textarea", { enumerable: true, get: function () { return Input_1.Textarea; } });
44
+ var Form_1 = require("./Form");
45
+ Object.defineProperty(exports, "Label", { enumerable: true, get: function () { return Form_1.Label; } });
46
+ Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return Form_1.Field; } });
47
+ Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return Form_1.Checkbox; } });
48
+ Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return Form_1.RadioGroup; } });
49
+ Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return Form_1.Select; } });
50
+ // Overlays.
51
+ var Dialog_1 = require("./Dialog");
52
+ Object.defineProperty(exports, "Dialog", { enumerable: true, get: function () { return Dialog_1.Dialog; } });
53
+ Object.defineProperty(exports, "DialogTrigger", { enumerable: true, get: function () { return Dialog_1.DialogTrigger; } });
54
+ Object.defineProperty(exports, "AlertDialog", { enumerable: true, get: function () { return Dialog_1.AlertDialog; } });
55
+ Object.defineProperty(exports, "ActionSheet", { enumerable: true, get: function () { return Dialog_1.ActionSheet; } });
56
+ // AI conversation primitives.
57
+ var ai_1 = require("./ai");
58
+ Object.defineProperty(exports, "NativePlan", { enumerable: true, get: function () { return ai_1.NativePlan; } });
59
+ Object.defineProperty(exports, "NativeSources", { enumerable: true, get: function () { return ai_1.NativeSources; } });
60
+ Object.defineProperty(exports, "NativeResponse", { enumerable: true, get: function () { return ai_1.NativeResponse; } });
61
+ Object.defineProperty(exports, "NativeTask", { enumerable: true, get: function () { return ai_1.NativeTask; } });
62
+ Object.defineProperty(exports, "NativeSoundwave", { enumerable: true, get: function () { return ai_1.NativeSoundwave; } });
63
+ Object.defineProperty(exports, "NativeThinkingOrb", { enumerable: true, get: function () { return ai_1.NativeThinkingOrb; } });
64
+ Object.defineProperty(exports, "NativePanelside", { enumerable: true, get: function () { return ai_1.NativePanelside; } });
65
+ Object.defineProperty(exports, "NativeAIInput", { enumerable: true, get: function () { return ai_1.NativeAIInput; } });
66
+ Object.defineProperty(exports, "NativeImageGeneration", { enumerable: true, get: function () { return ai_1.NativeImageGeneration; } });
67
+ // Data display.
68
+ var Table_1 = require("./Table");
69
+ Object.defineProperty(exports, "NativeTable", { enumerable: true, get: function () { return Table_1.NativeTable; } });
70
+ Object.defineProperty(exports, "NativeScrollArea", { enumerable: true, get: function () { return Table_1.NativeScrollArea; } });
71
+ // Charts, drawn with react-native-svg using the same maths as the web package.
72
+ __exportStar(require("./charts"), exports);
26
73
  var GlassView_1 = require("./internal/GlassView");
27
74
  Object.defineProperty(exports, "isGlassSupported", { enumerable: true, get: function () { return GlassView_1.isGlassSupported; } });
28
75
  var tokens_1 = require("./internal/tokens");
@@ -23,6 +23,8 @@ exports.colors = {
23
23
  edge: "rgba(0, 0, 0, 0.08)",
24
24
  fill: "#0088FF",
25
25
  destructive: "#FF3B30",
26
+ // Chart axis and grid lines: low-contrast, so they never compete with data.
27
+ axis: "#3C3C43",
26
28
  },
27
29
  dark: {
28
30
  foreground: "#FFFFFF",
@@ -32,5 +34,6 @@ exports.colors = {
32
34
  edge: "rgba(255, 255, 255, 0.08)",
33
35
  fill: "#0091FF",
34
36
  destructive: "#FF4245",
37
+ axis: "#EBEBF5",
35
38
  },
36
39
  };
@@ -0,0 +1,71 @@
1
+ import { type ReactNode } from "react";
2
+ export interface DialogProps {
3
+ /** Controlled visibility. Omit to use `trigger` and uncontrolled state. */
4
+ open?: boolean;
5
+ onOpenChange?: (open: boolean) => void;
6
+ title?: string;
7
+ description?: string;
8
+ children?: ReactNode;
9
+ footer?: ReactNode;
10
+ /** Tapping the backdrop dismisses. Off for destructive confirmations. */
11
+ dismissOnBackdropPress?: boolean;
12
+ isDark?: boolean;
13
+ style?: any;
14
+ }
15
+ /**
16
+ * A centred modal surface above a dimmed backdrop.
17
+ *
18
+ * React Native has no built-in focus trap, so this component covers what the
19
+ * platform can actually do: `Modal` blocks touches behind it, Android's back
20
+ * button routes to `onOpenChange(false)`, and the heading is marked as such so
21
+ * screen readers announce the dialog as it appears.
22
+ */
23
+ export declare function Dialog({ open: controlledOpen, onOpenChange, title, description, children, footer, dismissOnBackdropPress, isDark, style, }: DialogProps): import("react").JSX.Element;
24
+ /** Opens the dialog without the caller tracking state. */
25
+ export declare function DialogTrigger({ label, children, ...dialogProps }: Omit<DialogProps, "open" | "onOpenChange"> & {
26
+ label: string;
27
+ }): import("react").JSX.Element;
28
+ export interface AlertDialogProps {
29
+ open?: boolean;
30
+ onOpenChange?: (open: boolean) => void;
31
+ title: string;
32
+ description?: string;
33
+ /** Label for the confirming action. */
34
+ confirmLabel?: string;
35
+ cancelLabel?: string;
36
+ /** Tints the confirm button destructive. */
37
+ destructive?: boolean;
38
+ onConfirm?: () => void;
39
+ onCancel?: () => void;
40
+ isDark?: boolean;
41
+ }
42
+ /**
43
+ * A dialog that asks for confirmation.
44
+ *
45
+ * Deliberately not dismissible by tapping the backdrop: a destructive question
46
+ * should require a real answer, so the only ways out are the two buttons or the
47
+ * Android back button, which counts as cancel.
48
+ */
49
+ export declare function AlertDialog({ open: controlledOpen, onOpenChange, title, description, confirmLabel, cancelLabel, destructive, onConfirm, onCancel, isDark, }: AlertDialogProps): import("react").JSX.Element;
50
+ export interface ActionSheetOption {
51
+ label: string;
52
+ /** Tints the row destructive, for delete actions. */
53
+ destructive?: boolean;
54
+ onPress?: () => void;
55
+ }
56
+ export interface ActionSheetProps {
57
+ open?: boolean;
58
+ onOpenChange?: (open: boolean) => void;
59
+ title?: string;
60
+ message?: string;
61
+ options: ActionSheetOption[];
62
+ cancelLabel?: string;
63
+ isDark?: boolean;
64
+ }
65
+ /**
66
+ * A list of choices attached to the bottom of the screen.
67
+ *
68
+ * Anchored to the bottom because that is where a thumb reaches, and it keeps a
69
+ * separate Cancel row so a mis-tap is always reversible.
70
+ */
71
+ export declare function ActionSheet({ open: controlledOpen, onOpenChange, title, message, options, cancelLabel, isDark, }: ActionSheetProps): import("react").JSX.Element;