glacia-native 0.3.3 → 0.3.5

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,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dialog = Dialog;
4
+ exports.DialogTrigger = DialogTrigger;
5
+ exports.AlertDialog = AlertDialog;
6
+ exports.ActionSheet = ActionSheet;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
9
+ const tokens_1 = require("./internal/tokens");
10
+ const primitives_1 = require("./charts/primitives");
11
+ const Button_1 = require("./Button");
12
+ /**
13
+ * A centred modal surface above a dimmed backdrop.
14
+ *
15
+ * React Native has no built-in focus trap, so this component covers what the
16
+ * platform can actually do: `Modal` blocks touches behind it, Android's back
17
+ * button routes to `onOpenChange(false)`, and the heading is marked as such so
18
+ * screen readers announce the dialog as it appears.
19
+ */
20
+ function Dialog({ open: controlledOpen, onOpenChange, title, description, children, footer, dismissOnBackdropPress = true, isDark = false, style, }) {
21
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
22
+ const { View, Text, Pressable, Modal, getBackHandler } = (0, primitives_1.primitives)();
23
+ const [uncontrolled, setUncontrolled] = (0, react_1.useState)(false);
24
+ const open = controlledOpen ?? uncontrolled;
25
+ const setOpen = (0, react_1.useCallback)((next) => {
26
+ if (controlledOpen === undefined)
27
+ setUncontrolled(next);
28
+ onOpenChange?.(next);
29
+ }, [controlledOpen, onOpenChange]);
30
+ // Android's hardware back must close the dialog, not the screen behind it.
31
+ (0, react_1.useEffect)(() => {
32
+ if (!open)
33
+ return;
34
+ const BackHandler = getBackHandler();
35
+ if (!BackHandler)
36
+ return;
37
+ const sub = BackHandler.addEventListener("hardwareBackPress", () => {
38
+ setOpen(false);
39
+ return true;
40
+ });
41
+ return () => sub.remove();
42
+ }, [open, setOpen, getBackHandler]);
43
+ return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: () => setOpen(false), children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close dialog", onPress: dismissOnBackdropPress ? () => setOpen(false) : undefined, style: {
44
+ flex: 1,
45
+ alignItems: "center",
46
+ justifyContent: "center",
47
+ padding: 24,
48
+ backgroundColor: "rgba(0, 0, 0, 0.45)",
49
+ }, children: (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: {
50
+ width: "100%",
51
+ maxWidth: 380,
52
+ borderRadius: tokens_1.radii.lg,
53
+ borderWidth: 1,
54
+ borderColor: theme.edge,
55
+ backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
56
+ padding: 20,
57
+ gap: 8,
58
+ ...style,
59
+ }, children: [title && ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: "heading", style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: title })), description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, color: theme.muted, lineHeight: 18 }, children: description })), children, footer && (0, jsx_runtime_1.jsx)(View, { style: { marginTop: 12, gap: 8 }, children: footer })] }) }) }));
60
+ }
61
+ /** Opens the dialog without the caller tracking state. */
62
+ function DialogTrigger({ label, children, ...dialogProps }) {
63
+ const [open, setOpen] = (0, react_1.useState)(false);
64
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { accessibilityLabel: label, onPress: () => setOpen(true), children: label }), (0, jsx_runtime_1.jsx)(Dialog, { ...dialogProps, open: open, onOpenChange: setOpen })] }));
65
+ }
66
+ /**
67
+ * A dialog that asks for confirmation.
68
+ *
69
+ * Deliberately not dismissible by tapping the backdrop: a destructive question
70
+ * should require a real answer, so the only ways out are the two buttons or the
71
+ * Android back button, which counts as cancel.
72
+ */
73
+ function AlertDialog({ open: controlledOpen, onOpenChange, title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", destructive = false, onConfirm, onCancel, isDark = false, }) {
74
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
75
+ const { View } = (0, primitives_1.primitives)();
76
+ const [uncontrolled, setUncontrolled] = (0, react_1.useState)(false);
77
+ const open = controlledOpen ?? uncontrolled;
78
+ const close = (next) => {
79
+ if (controlledOpen === undefined)
80
+ setUncontrolled(next);
81
+ onOpenChange?.(next);
82
+ };
83
+ return ((0, jsx_runtime_1.jsx)(Dialog, { open: open, onOpenChange: close, title: title, description: description, dismissOnBackdropPress: false, isDark: isDark, footer: (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", gap: 8, justifyContent: "flex-end" }, children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { accessibilityLabel: cancelLabel, variant: "ghost", onPress: () => {
84
+ onCancel?.();
85
+ close(false);
86
+ }, children: cancelLabel }), (0, jsx_runtime_1.jsx)(Button_1.Button, { accessibilityLabel: confirmLabel, variant: "filled", tint: destructive ? theme.destructive : undefined, onPress: () => {
87
+ onConfirm?.();
88
+ close(false);
89
+ }, children: confirmLabel })] }) }));
90
+ }
91
+ /**
92
+ * A list of choices attached to the bottom of the screen.
93
+ *
94
+ * Anchored to the bottom because that is where a thumb reaches, and it keeps a
95
+ * separate Cancel row so a mis-tap is always reversible.
96
+ */
97
+ function ActionSheet({ open: controlledOpen, onOpenChange, title, message, options, cancelLabel = "Cancel", isDark = false, }) {
98
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
99
+ const { View, Text, Pressable, Modal, getBackHandler } = (0, primitives_1.primitives)();
100
+ const [uncontrolled, setUncontrolled] = (0, react_1.useState)(false);
101
+ const open = controlledOpen ?? uncontrolled;
102
+ const close = () => {
103
+ if (controlledOpen === undefined)
104
+ setUncontrolled(false);
105
+ onOpenChange?.(false);
106
+ };
107
+ return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "slide", onRequestClose: close, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss actions", onPress: close, style: { flex: 1, justifyContent: "flex-end", backgroundColor: "rgba(0,0,0,0.4)" }, children: (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { padding: 10, gap: 8 }, children: [(0, jsx_runtime_1.jsxs)(View, { style: {
108
+ borderRadius: tokens_1.radii.lg,
109
+ overflow: "hidden",
110
+ backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
111
+ }, children: [(title || message) && ((0, jsx_runtime_1.jsxs)(View, { style: { paddingVertical: 12, paddingHorizontal: 16, alignItems: "center" }, children: [title && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: theme.foreground }, children: title })), message && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginTop: 4, textAlign: "center" }, children: message }))] })), options.map((option, index) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: option.label, onPress: () => {
112
+ option.onPress?.();
113
+ close();
114
+ }, style: {
115
+ paddingVertical: 14,
116
+ alignItems: "center",
117
+ borderTopWidth: index === 0 && !title && !message ? 0 : 1,
118
+ borderTopColor: theme.edge,
119
+ }, children: (0, jsx_runtime_1.jsx)(Text, { style: {
120
+ fontSize: 16,
121
+ color: option.destructive ? theme.destructive : theme.foreground,
122
+ }, children: option.label }) }, option.label)))] }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: cancelLabel, onPress: close, style: {
123
+ paddingVertical: 14,
124
+ alignItems: "center",
125
+ borderRadius: tokens_1.radii.lg,
126
+ backgroundColor: isDark ? "#1c1c1e" : "#ffffff",
127
+ }, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 16, fontWeight: "600", color: theme.foreground }, children: cancelLabel }) })] }) }) }));
128
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Label = void 0;
4
+ exports.Field = Field;
5
+ exports.Checkbox = Checkbox;
6
+ exports.RadioGroup = RadioGroup;
7
+ exports.Select = Select;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ const tokens_1 = require("./internal/tokens");
11
+ const primitives_1 = require("./charts/primitives");
12
+ /** The text above a control. */
13
+ exports.Label = (0, react_1.forwardRef)(function Label({ children, required = false, disabled = false, htmlFor, isDark = false, style }, ref) {
14
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
15
+ const { Text } = (0, primitives_1.primitives)();
16
+ return ((0, jsx_runtime_1.jsxs)(Text, { ref: ref, nativeID: htmlFor, accessibilityRole: "text", style: {
17
+ fontSize: 13,
18
+ fontWeight: "600",
19
+ color: disabled ? theme.muted : theme.foreground,
20
+ opacity: disabled ? 0.6 : 1,
21
+ ...style,
22
+ }, children: [children, required && (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.destructive }, children: " *" })] }));
23
+ });
24
+ /**
25
+ * Label, control and message stacked in the order assistive tech announces
26
+ * them, so a caller never has to place these three by hand.
27
+ */
28
+ function Field({ label, description, error, required = false, disabled = false, isDark = false, children, style, }) {
29
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
30
+ const { View, Text } = (0, primitives_1.primitives)();
31
+ const message = error ?? description;
32
+ return ((0, jsx_runtime_1.jsxs)(View, { style: { gap: 6, ...style }, children: [label && ((0, jsx_runtime_1.jsx)(exports.Label, { required: required, disabled: disabled, isDark: isDark, children: label })), children, message && ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: error ? "alert" : "text", style: {
33
+ fontSize: 11,
34
+ color: error ? theme.destructive : theme.muted,
35
+ }, children: message }))] }));
36
+ }
37
+ /** A tick box for a single boolean, with an optional label and description. */
38
+ function Checkbox({ checked = false, onCheckedChange, label, description, indeterminate = false, disabled = false, isDark = false, style, }) {
39
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
40
+ const { View, Text, Pressable } = (0, primitives_1.primitives)();
41
+ const filled = checked || indeterminate;
42
+ return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "checkbox", accessibilityState: { checked, disabled }, accessibilityLabel: label, disabled: disabled, onPress: () => !disabled && onCheckedChange?.(!checked), style: {
43
+ flexDirection: "row",
44
+ alignItems: "flex-start",
45
+ gap: 10,
46
+ opacity: disabled ? 0.45 : 1,
47
+ ...style,
48
+ }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
49
+ width: 20,
50
+ height: 20,
51
+ borderRadius: 6,
52
+ borderWidth: filled ? 0 : 1.5,
53
+ borderColor: theme.edge,
54
+ backgroundColor: filled ? theme.fill : "transparent",
55
+ alignItems: "center",
56
+ justifyContent: "center",
57
+ marginTop: 1,
58
+ }, children: indeterminate ? ((0, jsx_runtime_1.jsx)(View, { style: { width: 10, height: 2, borderRadius: 1, backgroundColor: "#fff" } })) : checked ? (
59
+ // A glyph rather than an icon dependency: one text node, no package.
60
+ (0, jsx_runtime_1.jsx)(Text, { style: { color: "#fff", fontSize: 12, fontWeight: "700", lineHeight: 14 }, children: "\u2713" })) : null }), (label || description) && ((0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [label && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground, fontWeight: "500" }, children: label })), description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 2 }, children: description }))] }))] }));
61
+ }
62
+ /** One choice from a small, always-visible set. */
63
+ function RadioGroup({ value, onValueChange, options, horizontal = false, disabled = false, isDark = false, style, }) {
64
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
65
+ const { View, Text, Pressable } = (0, primitives_1.primitives)();
66
+ return ((0, jsx_runtime_1.jsx)(View, { accessibilityRole: "radiogroup", style: { gap: horizontal ? 14 : 10, flexDirection: horizontal ? "row" : "column", ...style }, children: options.map((option) => {
67
+ const isSelected = option.value === value;
68
+ const isDisabled = disabled || option.disabled;
69
+ return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "radio", accessibilityState: { checked: isSelected, disabled: isDisabled }, accessibilityLabel: option.label, disabled: isDisabled, onPress: () => !isDisabled && onValueChange?.(option.value), style: {
70
+ flexDirection: "row",
71
+ alignItems: "flex-start",
72
+ gap: 9,
73
+ opacity: isDisabled ? 0.45 : 1,
74
+ }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
75
+ width: 20,
76
+ height: 20,
77
+ borderRadius: 10,
78
+ borderWidth: isSelected ? 6 : 1.5,
79
+ borderColor: isSelected ? theme.fill : theme.edge,
80
+ marginTop: 1,
81
+ } }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label }), option.description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 2 }, children: option.description }))] })] }, option.value));
82
+ }) }));
83
+ }
84
+ /**
85
+ * A dropdown of mutually exclusive options.
86
+ *
87
+ * Native has no built-in picker that looks the same on iOS and Android, so the
88
+ * list opens inline: predictable across platforms and reachable without a
89
+ * modal. A long list scrolls naturally with the page.
90
+ */
91
+ function Select({ value, onValueChange, options, placeholder = "Select an option", disabled = false, isDark = false, style, }) {
92
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
93
+ const { View, Text, Pressable } = (0, primitives_1.primitives)();
94
+ const [open, setOpen] = (0, react_1.useState)(false);
95
+ const selected = options.find((option) => option.value === value);
96
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityState: { expanded: open, disabled }, accessibilityLabel: selected?.label ?? placeholder, disabled: disabled, onPress: () => setOpen(!open), style: {
97
+ minHeight: 42,
98
+ flexDirection: "row",
99
+ alignItems: "center",
100
+ justifyContent: "space-between",
101
+ paddingHorizontal: 12,
102
+ borderRadius: tokens_1.radii.md,
103
+ borderWidth: 1,
104
+ borderColor: theme.edge,
105
+ backgroundColor: theme.glass,
106
+ opacity: disabled ? 0.5 : 1,
107
+ }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 15, color: selected ? theme.foreground : theme.muted }, children: selected?.label ?? placeholder }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted }, children: open ? "▲" : "▼" })] }), open && ((0, jsx_runtime_1.jsx)(View, { style: {
108
+ marginTop: 6,
109
+ borderRadius: tokens_1.radii.md,
110
+ borderWidth: 1,
111
+ borderColor: theme.edge,
112
+ backgroundColor: theme.glass,
113
+ overflow: "hidden",
114
+ }, children: options.map((option) => {
115
+ const isSelected = option.value === value;
116
+ return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isSelected }, accessibilityLabel: option.label, onPress: () => {
117
+ onValueChange?.(option.value);
118
+ setOpen(false);
119
+ }, style: {
120
+ paddingVertical: 10,
121
+ paddingHorizontal: 12,
122
+ backgroundColor: isSelected ? theme.glassActive : "transparent",
123
+ }, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label }) }, option.value));
124
+ }) }))] }));
125
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Textarea = exports.Input = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const tokens_1 = require("./internal/tokens");
7
+ const primitives_1 = require("./charts/primitives");
8
+ const heights = { sm: 34, md: 42, lg: 50 };
9
+ const fontSizes = { sm: 14, md: 15, lg: 16 };
10
+ /**
11
+ * A single-line or multiline text field.
12
+ *
13
+ * The native TextInput has no placeholder styling prop, so the placeholder is
14
+ * drawn as a sibling Text: that keeps its colour tied to the theme instead of
15
+ * the OS default, which changes between iOS versions.
16
+ */
17
+ exports.Input = (0, react_1.forwardRef)(function Input({ value, onChangeText, placeholder, invalid = false, disabled = false, secureTextEntry = false, keyboardType = "default", autoCapitalize, autoCorrect, multiline = false, minLines = 3, size = "md", accessibilityLabel, returnKeyType, onSubmitEditing, prefix, suffix, isDark = false, style, maxLength, editable, onFocus, onBlur, }, ref) {
18
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
19
+ const { View, Text, TextInput } = (0, primitives_1.primitives)();
20
+ const isEditable = editable !== undefined ? editable : !disabled;
21
+ const showPlaceholder = !value && placeholder;
22
+ const fieldStyle = {
23
+ flex: 1,
24
+ paddingVertical: height_padding(size),
25
+ paddingHorizontal: 0,
26
+ fontSize: fontSizes[size],
27
+ color: theme.foreground,
28
+ // RN draws its own underline on Android; the border is ours.
29
+ outlineStyle: "none",
30
+ };
31
+ return ((0, jsx_runtime_1.jsxs)(View, { style: {
32
+ flexDirection: "row",
33
+ alignItems: multiline ? "flex-start" : "center",
34
+ gap: 8,
35
+ minHeight: multiline ? undefined : heights[size],
36
+ borderRadius: tokens_1.radii.md,
37
+ borderWidth: 1,
38
+ borderColor: invalid ? theme.destructive : theme.edge,
39
+ backgroundColor: theme.glass,
40
+ paddingHorizontal: 12,
41
+ opacity: disabled ? 0.5 : 1,
42
+ ...style,
43
+ }, children: [prefix, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, justifyContent: "center" }, children: [showPlaceholder && ((0, jsx_runtime_1.jsx)(Text, { style: {
44
+ position: "absolute",
45
+ left: 0,
46
+ top: multiline ? 0 : undefined,
47
+ fontSize: fontSizes[size],
48
+ color: theme.muted,
49
+ pointerEvents: "none",
50
+ }, numberOfLines: 1, children: placeholder })), (0, jsx_runtime_1.jsx)(TextInput, { ref: ref, value: value, onChangeText: onChangeText, editable: isEditable, secureTextEntry: secureTextEntry, keyboardType: keyboardType, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, multiline: multiline, numberOfLines: multiline ? minLines : undefined, maxLength: maxLength, returnKeyType: returnKeyType, onSubmitEditing: onSubmitEditing, onFocus: onFocus, onBlur: onBlur, accessibilityLabel: accessibilityLabel ?? placeholder, accessibilityState: { disabled: !isEditable }, style: fieldStyle })] }), suffix] }));
51
+ });
52
+ /** Vertical padding tuned per size so the text sits optically centred. */
53
+ function height_padding(size) {
54
+ return size === "sm" ? 6 : size === "lg" ? 12 : 9;
55
+ }
56
+ /**
57
+ * A multi-line field.
58
+ *
59
+ * Separate from Input so `multiline` cannot silently turn off the single-line
60
+ * sizing, and so callers get a `rows` prop instead of guessing a pixel height.
61
+ */
62
+ exports.Textarea = (0, react_1.forwardRef)(function Textarea({ rows = 4, ...props }, ref) {
63
+ return (0, jsx_runtime_1.jsx)(exports.Input, { ref: ref, ...props, multiline: true, minLines: rows });
64
+ });
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativeTable = NativeTable;
4
+ exports.NativeScrollArea = NativeScrollArea;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const tokens_1 = require("./internal/tokens");
7
+ const primitives_1 = require("./charts/primitives");
8
+ /**
9
+ * Tabular data laid out for a phone.
10
+ *
11
+ * A wide table cannot simply shrink: at phone width the columns become
12
+ * unreadable. Instead the first column is promoted to a row title and the rest
13
+ * are laid out as labelled pairs beneath it, which keeps every value readable
14
+ * without horizontal scrolling.
15
+ */
16
+ function NativeTable({ columns, rows, onRowPress, caption, isDark = false, style, emptyMessage = "No rows to display", }) {
17
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
18
+ const { View, Text, Pressable } = (0, primitives_1.primitives)();
19
+ if (rows.length === 0) {
20
+ return ((0, jsx_runtime_1.jsx)(View, { style: [{ paddingVertical: 20, alignItems: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted }, children: emptyMessage }) }));
21
+ }
22
+ // The first column becomes the row's title when the caller marks none.
23
+ const primaryKey = columns.find((column) => column.primary)?.key ?? columns[0]?.key;
24
+ const primaryColumn = columns.find((column) => column.key === primaryKey);
25
+ const detailColumns = columns.filter((column) => column.key !== primaryKey);
26
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [caption && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginBottom: 8 }, children: caption })), rows.map((row) => {
27
+ const RowWrapper = onRowPress ? Pressable : View;
28
+ const wrapperProps = onRowPress
29
+ ? {
30
+ accessibilityRole: "button",
31
+ accessibilityLabel: String(row.cells[primaryKey ?? ""] ?? ""),
32
+ onPress: () => onRowPress(row),
33
+ }
34
+ : { accessibilityRole: "text" };
35
+ return ((0, jsx_runtime_1.jsxs)(RowWrapper, { ...wrapperProps, style: {
36
+ paddingVertical: 10,
37
+ borderBottomWidth: 1,
38
+ borderBottomColor: theme.edge,
39
+ }, children: [primaryColumn && ((0, jsx_runtime_1.jsx)(Text, { style: {
40
+ fontSize: 14,
41
+ fontWeight: "600",
42
+ color: theme.foreground,
43
+ textAlign: primaryColumn.align ?? "left",
44
+ }, children: row.cells[primaryColumn.key] ?? "" })), detailColumns.length > 0 && ((0, jsx_runtime_1.jsx)(View, { style: { marginTop: 6, gap: 4 }, children: detailColumns.map((column) => ((0, jsx_runtime_1.jsxs)(View, { style: {
45
+ flexDirection: "row",
46
+ justifyContent: "space-between",
47
+ alignItems: "baseline",
48
+ gap: 12,
49
+ }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: column.header }), (0, jsx_runtime_1.jsx)(Text, { style: {
50
+ fontSize: 12,
51
+ color: theme.foreground,
52
+ textAlign: column.align ?? "left",
53
+ }, children: row.cells[column.key] ?? "" })] }, column.key))) }))] }, row.id));
54
+ })] }));
55
+ }
56
+ /**
57
+ * A bounded scroll region.
58
+ *
59
+ * Uses the platform ScrollView rather than drawing a custom scrollbar: the OS
60
+ * scroll indicator is the one users already recognise, and it stays correct
61
+ * under momentum, bouncing and accessibility settings.
62
+ */
63
+ function NativeScrollArea({ children, maxHeight, bordered = false, horizontal = false, isDark = false, style, accessibilityLabel, }) {
64
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
65
+ const { View, getScrollView } = (0, primitives_1.primitives)();
66
+ const ScrollView = getScrollView();
67
+ const containerStyle = {
68
+ maxHeight,
69
+ borderRadius: bordered ? 12 : undefined,
70
+ borderWidth: bordered ? 1 : 0,
71
+ borderColor: theme.edge,
72
+ overflow: "hidden",
73
+ ...style,
74
+ };
75
+ if (!ScrollView) {
76
+ // Off-device there is no ScrollView; render the content in a clipped box so
77
+ // layout still matches instead of dropping children.
78
+ return ((0, jsx_runtime_1.jsx)(View, { accessibilityLabel: accessibilityLabel, style: { ...containerStyle, overflow: "auto" }, children: children }));
79
+ }
80
+ return ((0, jsx_runtime_1.jsx)(View, { style: containerStyle, children: (0, jsx_runtime_1.jsx)(ScrollView, { horizontal: horizontal, showsVerticalScrollIndicator: true, showsHorizontalScrollIndicator: horizontal, accessibilityLabel: accessibilityLabel, children: children }) }));
81
+ }