glacia-native 0.3.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/lib/module/Bars.js +176 -0
  2. package/lib/module/Button.js +15 -2
  3. package/lib/module/Card.js +29 -14
  4. package/lib/module/Carousel.js +103 -0
  5. package/lib/module/Dialog.js +43 -32
  6. package/lib/module/Display.js +240 -0
  7. package/lib/module/Feedback.js +172 -0
  8. package/lib/module/Form.js +51 -12
  9. package/lib/module/Forms2.js +227 -0
  10. package/lib/module/Glass.js +11 -2
  11. package/lib/module/Input.js +19 -7
  12. package/lib/module/Overlays.js +166 -0
  13. package/lib/module/Pickers.js +243 -0
  14. package/lib/module/SegmentedControl.js +65 -21
  15. package/lib/module/Slider.js +121 -25
  16. package/lib/module/Switch.js +33 -15
  17. package/lib/module/TabBar.js +63 -25
  18. package/lib/module/Table.js +24 -6
  19. package/lib/module/Tabs.js +55 -33
  20. package/lib/module/Text.js +37 -0
  21. package/lib/module/ai.js +49 -20
  22. package/lib/module/charts/BarChart.js +4 -2
  23. package/lib/module/charts/FunnelChart.js +4 -2
  24. package/lib/module/charts/HeatmapChart.js +4 -2
  25. package/lib/module/charts/LineChart.js +4 -2
  26. package/lib/module/charts/PlotChart.js +11 -3
  27. package/lib/module/charts/RadarChart.js +4 -2
  28. package/lib/module/charts/RingChart.js +4 -2
  29. package/lib/module/charts/ScatterChart.js +20 -3
  30. package/lib/module/charts/WaterfallChart.js +12 -3
  31. package/lib/module/charts/advanced.js +12 -6
  32. package/lib/module/charts/extra.js +6 -3
  33. package/lib/module/index.js +58 -1
  34. package/lib/module/internal/GlassView.js +31 -17
  35. package/lib/module/internal/fallback.js +14 -3
  36. package/lib/module/internal/glass-routing.js +56 -0
  37. package/lib/module/internal/motion.js +55 -0
  38. package/lib/module/internal/primitives.js +413 -0
  39. package/lib/module/internal/tokens.js +55 -1
  40. package/lib/typescript/Bars.d.ts +121 -0
  41. package/lib/typescript/Button.d.ts +11 -1
  42. package/lib/typescript/Card.d.ts +20 -8
  43. package/lib/typescript/Carousel.d.ts +47 -0
  44. package/lib/typescript/Dialog.d.ts +19 -6
  45. package/lib/typescript/Display.d.ts +119 -0
  46. package/lib/typescript/Feedback.d.ts +138 -0
  47. package/lib/typescript/Form.d.ts +27 -11
  48. package/lib/typescript/Forms2.d.ts +128 -0
  49. package/lib/typescript/Glass.d.ts +10 -1
  50. package/lib/typescript/Input.d.ts +11 -1
  51. package/lib/typescript/Overlays.d.ts +105 -0
  52. package/lib/typescript/Pickers.d.ts +105 -0
  53. package/lib/typescript/SegmentedControl.d.ts +11 -1
  54. package/lib/typescript/Slider.d.ts +13 -1
  55. package/lib/typescript/Switch.d.ts +12 -1
  56. package/lib/typescript/TabBar.d.ts +13 -1
  57. package/lib/typescript/Table.d.ts +14 -5
  58. package/lib/typescript/Tabs.d.ts +8 -5
  59. package/lib/typescript/Text.d.ts +28 -0
  60. package/lib/typescript/ai.d.ts +12 -9
  61. package/lib/typescript/charts/BarChart.d.ts +1 -1
  62. package/lib/typescript/charts/FunnelChart.d.ts +1 -1
  63. package/lib/typescript/charts/HeatmapChart.d.ts +1 -1
  64. package/lib/typescript/charts/LineChart.d.ts +1 -1
  65. package/lib/typescript/charts/PlotChart.d.ts +1 -1
  66. package/lib/typescript/charts/RadarChart.d.ts +1 -1
  67. package/lib/typescript/charts/RingChart.d.ts +1 -1
  68. package/lib/typescript/charts/ScatterChart.d.ts +1 -1
  69. package/lib/typescript/charts/WaterfallChart.d.ts +1 -1
  70. package/lib/typescript/charts/advanced.d.ts +5 -5
  71. package/lib/typescript/charts/extra.d.ts +2 -2
  72. package/lib/typescript/index.d.ts +9 -1
  73. package/lib/typescript/internal/GlassView.d.ts +21 -4
  74. package/lib/typescript/internal/fallback.d.ts +10 -1
  75. package/lib/typescript/internal/glass-routing.d.ts +30 -0
  76. package/lib/typescript/internal/motion.d.ts +19 -0
  77. package/lib/typescript/internal/primitives.d.ts +41 -0
  78. package/lib/typescript/internal/tokens.d.ts +61 -0
  79. package/package.json +2 -2
  80. package/src/Bars.tsx +570 -0
  81. package/src/Button.tsx +47 -22
  82. package/src/Card.tsx +52 -31
  83. package/src/Carousel.tsx +233 -0
  84. package/src/Dialog.tsx +99 -64
  85. package/src/Display.tsx +550 -0
  86. package/src/Feedback.tsx +579 -0
  87. package/src/Form.tsx +90 -25
  88. package/src/Forms2.tsx +608 -0
  89. package/src/Glass.tsx +24 -1
  90. package/src/Input.tsx +33 -12
  91. package/src/Overlays.tsx +474 -0
  92. package/src/Pickers.tsx +590 -0
  93. package/src/SegmentedControl.tsx +104 -32
  94. package/src/Slider.tsx +151 -47
  95. package/src/Switch.tsx +56 -32
  96. package/src/TabBar.tsx +100 -30
  97. package/src/Table.tsx +38 -14
  98. package/src/Tabs.tsx +85 -32
  99. package/src/Text.tsx +83 -0
  100. package/src/ai.tsx +77 -31
  101. package/src/charts/BarChart.tsx +4 -2
  102. package/src/charts/FunnelChart.tsx +4 -2
  103. package/src/charts/HeatmapChart.tsx +4 -2
  104. package/src/charts/LineChart.tsx +4 -2
  105. package/src/charts/PlotChart.tsx +23 -3
  106. package/src/charts/RadarChart.tsx +4 -2
  107. package/src/charts/RingChart.tsx +4 -2
  108. package/src/charts/ScatterChart.tsx +24 -3
  109. package/src/charts/WaterfallChart.tsx +21 -3
  110. package/src/charts/advanced.tsx +12 -6
  111. package/src/charts/extra.tsx +6 -3
  112. package/src/index.ts +101 -1
  113. package/src/internal/GlassView.tsx +51 -19
  114. package/src/internal/fallback.tsx +23 -8
  115. package/src/internal/glass-routing.ts +68 -0
  116. package/src/internal/motion.ts +60 -0
  117. package/src/internal/primitives.ts +482 -0
  118. package/src/internal/tokens.ts +62 -0
  119. package/lib/module/charts/primitives.js +0 -212
  120. package/lib/typescript/charts/primitives.d.ts +0 -23
  121. package/src/charts/primitives.ts +0 -262
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ButtonGroup = exports.InputOTP = exports.ToggleGroup = exports.Toggle = exports.Stepper = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const Glass_1 = require("./Glass");
7
+ const tokens_1 = require("./internal/tokens");
8
+ const primitives_1 = require("./internal/primitives");
9
+ const motion_1 = require("./internal/motion");
10
+ /**
11
+ * Minus / value / plus.
12
+ *
13
+ * The same interaction contract Slider established: `adjustable` with
14
+ * increment and decrement accessibility actions, and clamping at min and max
15
+ * rather than wrapping or drifting past the range.
16
+ */
17
+ exports.Stepper = (0, react_1.forwardRef)(function Stepper({ value: valueProp, defaultValue = 0, onValueChange, min = 0, max = 100, step = 1, disabled = false, accessibilityLabel, formatValue, style, isDark: isDarkProp, testID, ...props }, ref) {
18
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
19
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
20
+ const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
21
+ const [internal, setInternal] = (0, react_1.useState)(defaultValue);
22
+ const value = valueProp !== undefined ? valueProp : internal;
23
+ const apply = (next) => {
24
+ const clamped = Math.min(Math.max(next, min), max);
25
+ if (clamped === value)
26
+ return;
27
+ if (valueProp === undefined)
28
+ setInternal(clamped);
29
+ onValueChange?.(clamped);
30
+ };
31
+ const atMin = value <= min;
32
+ const atMax = value >= max;
33
+ const stepButton = (label, sign, action, blocked) => ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { disabled: disabled || blocked }, disabled: disabled || blocked, onPress: action, style: { width: 36, height: 36, alignItems: "center", justifyContent: "center", opacity: disabled || blocked ? 0.38 : 1 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 20, fontWeight: "500", color: theme.foreground, lineHeight: 22 }, children: sign }) }));
34
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, accessibilityRole: "adjustable", accessibilityLabel: accessibilityLabel, accessibilityValue: { min, max, now: value }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => {
35
+ const delta = event?.nativeEvent?.actionName === "increment" ? step : -step;
36
+ apply(value + delta);
37
+ }, style: {
38
+ flexDirection: "row",
39
+ alignItems: "center",
40
+ alignSelf: "flex-start",
41
+ borderRadius: tokens_1.radii.pill,
42
+ paddingHorizontal: 2,
43
+ opacity: disabled ? 0.38 : 1,
44
+ ...style,
45
+ }, ...props, children: [stepButton(`Decrease ${accessibilityLabel}`, "\u2212", () => apply(value - step), atMin), (0, jsx_runtime_1.jsx)(View, { style: { minWidth: 44, alignItems: "center", justifyContent: "center" }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 16, fontWeight: "600", color: theme.foreground }, numberOfLines: 1, children: formatValue ? formatValue(value) : String(value) }) }), stepButton(`Increase ${accessibilityLabel}`, "+", () => apply(value + step), atMax)] }));
46
+ });
47
+ const toggleSizes = { sm: 30, md: 36, lg: 44 };
48
+ /**
49
+ * A button that stays pressed.
50
+ *
51
+ * Distinct from Switch: this is a button with an on-state (bold, favourite,
52
+ * pinned), not a setting. It reports `selected`, which is what web's Toggle
53
+ * announces.
54
+ */
55
+ exports.Toggle = (0, react_1.forwardRef)(function Toggle({ pressed: pressedProp, defaultPressed = false, onPressedChange, selected, icon, children, variant = "glass", size = "md", disabled = false, accessibilityLabel, style, isDark: isDarkProp, testID, ...props }, ref) {
56
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
57
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
58
+ const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
59
+ // `selected` is accepted as an alias so the controlled prop matches web.
60
+ const controlled = pressedProp !== undefined ? pressedProp : selected;
61
+ const [internal, setInternal] = (0, react_1.useState)(defaultPressed);
62
+ const isPressed = controlled !== undefined ? controlled : internal;
63
+ const dimension = toggleSizes[size];
64
+ const handlePress = () => {
65
+ const next = !isPressed;
66
+ if (controlled === undefined)
67
+ setInternal(next);
68
+ onPressedChange?.(next);
69
+ };
70
+ return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: accessibilityLabel ?? (typeof children === "string" ? children : undefined), accessibilityState: { selected: isPressed, disabled }, disabled: disabled, onPress: handlePress, style: ({ pressed }) => ({ alignSelf: "flex-start", opacity: disabled ? 0.38 : pressed ? 0.8 : 1 }), ...props, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: variant === "ghost" ? "none" : "regular", interactive: !disabled && variant !== "ghost", isDark: isDark, tintColor: isPressed && variant !== "ghost" ? theme.glassActive : undefined, style: {
71
+ height: dimension,
72
+ borderRadius: tokens_1.radii.pill,
73
+ paddingHorizontal: icon && !children ? 0 : 12,
74
+ width: icon && !children ? dimension : undefined,
75
+ flexDirection: "row",
76
+ alignItems: "center",
77
+ justifyContent: "center",
78
+ gap: 6,
79
+ backgroundColor: variant === "ghost" ? "transparent" : undefined,
80
+ ...style,
81
+ }, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, typeof children === "string" ? ((0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: {
82
+ fontSize: size === "sm" ? 12 : size === "lg" ? 15 : 13,
83
+ fontWeight: isPressed ? "600" : "500",
84
+ color: isPressed ? theme.foreground : theme.muted,
85
+ }, children: children })) : (children)] }) }));
86
+ });
87
+ /**
88
+ * A row of toggles acting as one choice.
89
+ *
90
+ * Built from the same pieces as SegmentedControl — one glass container, toggles
91
+ * inside it, `glassActive` marking the active ones — but each item carries the
92
+ * button styling of Toggle.
93
+ */
94
+ exports.ToggleGroup = (0, react_1.forwardRef)(function ToggleGroup({ items, multiple = false, value: valueProp, defaultValue, onValueChange, size = "md", disabled = false, accessibilityLabel = "Toggle group", style, isDark: isDarkProp, testID, ...props }, ref) {
95
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
96
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
97
+ const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
98
+ const initial = defaultValue ?? (multiple ? [] : "");
99
+ const [internal, setInternal] = (0, react_1.useState)(initial);
100
+ const selection = valueProp !== undefined ? valueProp : internal;
101
+ const isOn = (value) => Array.isArray(selection) ? selection.includes(value) : selection === value;
102
+ const toggle = (value) => {
103
+ let next;
104
+ if (multiple) {
105
+ const current = Array.isArray(selection) ? selection : [];
106
+ next = current.includes(value) ? current.filter((v) => v !== value) : [...current, value];
107
+ }
108
+ else {
109
+ // Single mode: the same item pressed again clears it, as Toggle does.
110
+ next = selection === value ? "" : value;
111
+ }
112
+ if (valueProp === undefined)
113
+ setInternal(next);
114
+ onValueChange?.(next);
115
+ };
116
+ const height = size === "sm" ? 30 : size === "lg" ? 42 : 36;
117
+ return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, accessibilityRole: "radiogroup", accessibilityLabel: accessibilityLabel, style: {
118
+ flexDirection: "row",
119
+ alignItems: "center",
120
+ alignSelf: "flex-start",
121
+ padding: 3,
122
+ gap: 3,
123
+ borderRadius: tokens_1.radii.pill,
124
+ ...style,
125
+ }, ...props, children: items.map((item) => {
126
+ const on = isOn(item.value);
127
+ return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: item.label, accessibilityState: { selected: on, disabled }, disabled: disabled, onPress: () => toggle(item.value), style: { opacity: disabled ? 0.38 : 1 }, children: (0, jsx_runtime_1.jsxs)(View, { style: {
128
+ height: height - 6,
129
+ paddingHorizontal: 14,
130
+ borderRadius: tokens_1.radii.pill,
131
+ flexDirection: "row",
132
+ alignItems: "center",
133
+ justifyContent: "center",
134
+ gap: 6,
135
+ backgroundColor: on ? theme.glassActive : "transparent",
136
+ borderWidth: on ? 0.5 : 0,
137
+ borderColor: theme.edge,
138
+ }, children: [item.icon ? (0, jsx_runtime_1.jsx)(View, { children: item.icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 13, fontWeight: on ? "600" : "500", color: on ? theme.foreground : theme.muted }, children: item.label })] }) }, item.value));
139
+ }) }));
140
+ });
141
+ /**
142
+ * A verification-code row.
143
+ *
144
+ * One real text field drives the boxes. Keeping a single field — rather than N
145
+ * inputs — is what makes paste and autofill fill every box in one go, and it is
146
+ * what keeps the caret and keyboard behaviour sane across platforms.
147
+ */
148
+ exports.InputOTP = (0, react_1.forwardRef)(function InputOTP({ value: valueProp, defaultValue = "", onChange, onComplete, length = 6, disabled = false, accessibilityLabel = "Verification code", style, isDark: isDarkProp, testID, ...props }, ref) {
149
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
150
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
151
+ const { View, Text: RNText, TextInput } = (0, primitives_1.primitives)();
152
+ const [internal, setInternal] = (0, react_1.useState)(defaultValue);
153
+ const value = valueProp !== undefined ? valueProp : internal;
154
+ // The code is digits only, and never longer than the boxes available.
155
+ const normalise = (raw) => raw.replace(/[^0-9]/g, "").slice(0, length);
156
+ const handleChange = (raw) => {
157
+ const next = normalise(raw);
158
+ if (valueProp === undefined)
159
+ setInternal(next);
160
+ onChange?.(next);
161
+ if (next.length === length)
162
+ onComplete?.(next);
163
+ };
164
+ const focusedIndex = Math.min(value.length, length - 1);
165
+ return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, style: [{ flexDirection: "row", alignItems: "center", gap: 8, alignSelf: "flex-start" }, style], ...props, children: [Array.from({ length }, (_, index) => {
166
+ const char = value[index] ?? "";
167
+ const isActive = index === focusedIndex && !disabled;
168
+ return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, tintColor: isActive ? theme.glassActive : undefined, style: {
169
+ width: 44,
170
+ height: 52,
171
+ borderRadius: tokens_1.radii.md,
172
+ alignItems: "center",
173
+ justifyContent: "center",
174
+ borderColor: isActive ? theme.fill : theme.edge,
175
+ opacity: disabled ? 0.38 : 1,
176
+ }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 22, fontWeight: "600", color: theme.foreground }, children: char }) }, index));
177
+ }), (0, jsx_runtime_1.jsx)(TextInput, { accessibilityRole: "text", accessibilityLabel: accessibilityLabel, accessibilityValue: { text: value }, value: value, onChangeText: handleChange, editable: !disabled, keyboardType: "number-pad", maxLength: length, textContentType: "oneTimeCode", autoComplete: "one-time-code", style: {
178
+ position: "absolute",
179
+ left: 0,
180
+ right: 0,
181
+ top: 0,
182
+ bottom: 0,
183
+ // Invisible but present: the boxes are the visible representation.
184
+ opacity: 0.02,
185
+ color: "transparent",
186
+ } })] }));
187
+ });
188
+ /**
189
+ * A connected row of buttons.
190
+ *
191
+ * Stateless by design: it reports presses and holds no selection, which is what
192
+ * separates it from SegmentedControl (a stateful choice) and ToggleGroup.
193
+ */
194
+ exports.ButtonGroup = (0, react_1.forwardRef)(function ButtonGroup({ items, size = "md", variant = "attached", onItemPress, accessibilityLabel, style, isDark: isDarkProp, testID, ...props }, ref) {
195
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
196
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
197
+ const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
198
+ const height = size === "sm" ? 32 : size === "lg" ? 46 : 40;
199
+ return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "group", accessibilityLabel: accessibilityLabel, style: {
200
+ flexDirection: "row",
201
+ alignSelf: "flex-start",
202
+ gap: variant === "segmented" ? 6 : 0,
203
+ ...style,
204
+ }, ...props, children: items.map((item, index) => {
205
+ const first = index === 0;
206
+ const last = index === items.length - 1;
207
+ // Attached buttons share edges: only the outer corners are rounded,
208
+ // and the inner edges stay square so the group reads as one control.
209
+ const pill = variant === "segmented" ? tokens_1.radii.pill : 0;
210
+ return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: item.label, accessibilityState: { disabled: item.disabled }, disabled: item.disabled, onPress: () => {
211
+ item.onPress();
212
+ onItemPress?.(item, index);
213
+ }, style: ({ pressed }) => ({
214
+ opacity: item.disabled ? 0.38 : pressed ? 0.85 : 1,
215
+ }), children: (0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", interactive: !item.disabled, isDark: isDark, style: {
216
+ height,
217
+ paddingHorizontal: 18,
218
+ justifyContent: "center",
219
+ alignItems: "center",
220
+ borderRadius: variant === "segmented" ? pill : undefined,
221
+ borderTopLeftRadius: variant === "segmented" ? pill : first ? tokens_1.radii.md : 0,
222
+ borderBottomLeftRadius: variant === "segmented" ? pill : first ? tokens_1.radii.md : 0,
223
+ borderTopRightRadius: variant === "segmented" ? pill : last ? tokens_1.radii.md : 0,
224
+ borderBottomRightRadius: variant === "segmented" ? pill : last ? tokens_1.radii.md : 0,
225
+ }, children: (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: size === "sm" ? 13 : 14, fontWeight: "500", color: theme.foreground }, children: item.label }) }) }, `${item.label}-${index}`));
226
+ }) }));
227
+ });
@@ -4,6 +4,15 @@ exports.Glass = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const GlassView_1 = require("./internal/GlassView");
7
- exports.Glass = (0, react_1.forwardRef)(function Glass({ effect = "regular", tintColor, interactive = false, style, children, ...props }, ref) {
8
- return ((0, jsx_runtime_1.jsx)(GlassView_1.GlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, style: style, ...props, children: children }));
7
+ const motion_1 = require("./internal/motion");
8
+ /**
9
+ * A glass surface.
10
+ *
11
+ * Routes through the package's single switch: Apple's real `UIGlassEffect` on
12
+ * iOS 26+, Glacia's translucent fallback of identical shape on older iOS and
13
+ * Android. `testID` is passed to whichever surface renders.
14
+ */
15
+ exports.Glass = (0, react_1.forwardRef)(function Glass({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
16
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
17
+ return ((0, jsx_runtime_1.jsx)(GlassView_1.GlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, isDark: isDark, style: style, ...props, children: children }));
9
18
  });
@@ -4,7 +4,8 @@ exports.Textarea = exports.Input = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("./internal/tokens");
7
- const primitives_1 = require("./charts/primitives");
7
+ const primitives_1 = require("./internal/primitives");
8
+ const motion_1 = require("./internal/motion");
8
9
  const heights = { sm: 34, md: 42, lg: 50 };
9
10
  const fontSizes = { sm: 14, md: 15, lg: 16 };
10
11
  /**
@@ -13,20 +14,32 @@ const fontSizes = { sm: 14, md: 15, lg: 16 };
13
14
  * The native TextInput has no placeholder styling prop, so the placeholder is
14
15
  * drawn as a sibling Text: that keeps its colour tied to the theme instead of
15
16
  * the OS default, which changes between iOS versions.
17
+ *
18
+ * The field works controlled (`value` + `onChangeText`) or uncontrolled (no
19
+ * `value` prop). In uncontrolled use it tracks its own text so the themed
20
+ * placeholder disappears as soon as the user types; without that state the
21
+ * overlay would sit on top of the typed text until the parent re-rendered.
16
22
  */
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) {
23
+ 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, defaultValue, prefix, suffix, isDark: isDarkProp, style, testID, maxLength, editable, onFocus, onBlur, }, ref) {
24
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
18
25
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
19
26
  const { View, Text, TextInput } = (0, primitives_1.primitives)();
27
+ // Uncontrolled support: with no `value` prop the field owns its text.
28
+ const [internalText, setInternalText] = (0, react_1.useState)(defaultValue ?? "");
29
+ const text = value !== undefined ? value : internalText;
30
+ const handleChangeText = (next) => {
31
+ if (value === undefined)
32
+ setInternalText(next);
33
+ onChangeText?.(next);
34
+ };
20
35
  const isEditable = editable !== undefined ? editable : !disabled;
21
- const showPlaceholder = !value && placeholder;
36
+ const showPlaceholder = !text && Boolean(placeholder);
22
37
  const fieldStyle = {
23
38
  flex: 1,
24
39
  paddingVertical: height_padding(size),
25
40
  paddingHorizontal: 0,
26
41
  fontSize: fontSizes[size],
27
42
  color: theme.foreground,
28
- // RN draws its own underline on Android; the border is ours.
29
- outlineStyle: "none",
30
43
  };
31
44
  return ((0, jsx_runtime_1.jsxs)(View, { style: {
32
45
  flexDirection: "row",
@@ -46,8 +59,7 @@ exports.Input = (0, react_1.forwardRef)(function Input({ value, onChangeText, pl
46
59
  top: multiline ? 0 : undefined,
47
60
  fontSize: fontSizes[size],
48
61
  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] }));
62
+ }, pointerEvents: "none", numberOfLines: 1, children: placeholder })), (0, jsx_runtime_1.jsx)(TextInput, { ref: ref, testID: testID, value: text, onChangeText: handleChangeText, 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
63
  });
52
64
  /** Vertical padding tuned per size so the text sits optically centred. */
53
65
  function height_padding(size) {
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Drawer = exports.Sheet = exports.Menu = void 0;
4
+ exports.anchorPopover = anchorPopover;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const Glass_1 = require("./Glass");
8
+ const tokens_1 = require("./internal/tokens");
9
+ const primitives_1 = require("./internal/primitives");
10
+ const motion_1 = require("./internal/motion");
11
+ /**
12
+ * Registers Android's hardware back while an overlay is open.
13
+ *
14
+ * Shared by Menu, Sheet and Drawer so every overlay dismisses the same way a
15
+ * Dialog does: the back button closes the layer, not the screen behind it.
16
+ */
17
+ function useBackDismiss(open, onDismiss) {
18
+ (0, react_1.useEffect)(() => {
19
+ if (!open)
20
+ return;
21
+ const BackHandler = (0, primitives_1.primitives)().getBackHandler();
22
+ if (!BackHandler)
23
+ return;
24
+ const sub = BackHandler.addEventListener("hardwareBackPress", () => {
25
+ onDismiss();
26
+ return true;
27
+ });
28
+ return () => sub.remove();
29
+ }, [open, onDismiss]);
30
+ }
31
+ /**
32
+ * Keeps a popover inside the window.
33
+ *
34
+ * Called with the trigger's measured frame and the popover's own size; returns
35
+ * the offsets that bring it back on screen. A menu near the bottom edge flips
36
+ * above its trigger rather than hanging off the display.
37
+ */
38
+ function anchorPopover(trigger, popover, viewport, gap = 6) {
39
+ const below = trigger.y + trigger.height + gap;
40
+ const above = trigger.y - popover.height - gap;
41
+ const fitsBelow = below + popover.height <= viewport.height;
42
+ const flipped = !fitsBelow && above >= 0;
43
+ const top = Math.max(0, Math.min(flipped ? above : below, viewport.height - popover.height));
44
+ const left = Math.max(0, Math.min(trigger.x, viewport.width - popover.width));
45
+ return { left, top, flipped };
46
+ }
47
+ /**
48
+ * An anchored dropdown menu.
49
+ *
50
+ * A press outside or on an item closes it; Android's back button does too. The
51
+ * popover is a glass surface with `glassActive` rows, matching the way the
52
+ * library marks a tappable row rather than nesting another glass panel.
53
+ */
54
+ exports.Menu = (0, react_1.forwardRef)(function Menu({ trigger, items, open: openProp, onOpenChange, width = 220, accessibilityLabel = "Menu", style, isDark: isDarkProp, testID, ...props }, ref) {
55
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
56
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
57
+ const { View, Text: RNText, Pressable, Modal } = (0, primitives_1.primitives)();
58
+ const [internalOpen, setInternalOpen] = (0, react_1.useState)(false);
59
+ const open = openProp !== undefined ? openProp : internalOpen;
60
+ const setOpen = (0, react_1.useCallback)((next) => {
61
+ if (openProp === undefined)
62
+ setInternalOpen(next);
63
+ onOpenChange?.(next);
64
+ }, [openProp, onOpenChange]);
65
+ const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
66
+ useBackDismiss(open, dismiss);
67
+ const { value: enter, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "snappy");
68
+ const scale = animated ? enter.interpolate({ inputRange: [0, 1], outputRange: [0.96, 1] }) : 1;
69
+ const popover = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID ? `${testID}-popover` : undefined, style: { width, borderRadius: tokens_1.radii.md, paddingVertical: 4, overflow: "hidden", ...style }, children: items.map((item, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: item.accessibilityLabel ?? item.label, accessibilityState: { disabled: item.disabled }, disabled: item.disabled, onPress: () => {
70
+ setOpen(false);
71
+ item.onPress();
72
+ }, style: { flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 10, paddingHorizontal: 12, opacity: item.disabled ? 0.38 : 1 }, children: [item.icon ? (0, jsx_runtime_1.jsx)(View, { children: item.icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 15, color: item.destructive ? theme.destructive : theme.foreground }, children: item.label })] }, `${item.label}-${index}`))) }));
73
+ return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, style: { alignSelf: "flex-start" }, ...props, children: [(0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { expanded: open }, onPress: () => setOpen(!open), children: trigger }), (0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: dismiss, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close menu", onPress: dismiss, style: { flex: 1, backgroundColor: theme.scrim }, children: (0, jsx_runtime_1.jsx)(View, { style: { flex: 1, alignItems: "center", justifyContent: "center", padding: 24 }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, children: animated ? ((0, jsx_runtime_1.jsx)(AnimatedScale, { scale: scale, children: popover })) : (popover) }) }) }) })] }));
74
+ });
75
+ /** Wraps a popover in the entrance scale, which must land on an Animated.View. */
76
+ function AnimatedScale({ scale, children }) {
77
+ const { Animated } = (0, primitives_1.primitives)();
78
+ return (0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ scale }] }, children: children });
79
+ }
80
+ /**
81
+ * A bottom sheet.
82
+ *
83
+ * The general-purpose container: it slides up on the springs token, dismisses
84
+ * on a scrim press and on Android back. ActionSheet remains the action-menu
85
+ * specialisation of this shape; Sheet is for arbitrary content — a form, a
86
+ * calendar, a detail panel.
87
+ */
88
+ exports.Sheet = (0, react_1.forwardRef)(function Sheet({ open: openProp, defaultOpen = false, onOpenChange, title, children, footer, dismissOnBackdropPress = true, showHandle = true, style, isDark: isDarkProp, testID, ...props }, ref) {
89
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
90
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
91
+ const { View, Text: RNText, Pressable, Modal } = (0, primitives_1.primitives)();
92
+ const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
93
+ const open = openProp !== undefined ? openProp : internalOpen;
94
+ const setOpen = (0, react_1.useCallback)((next) => {
95
+ if (openProp === undefined)
96
+ setInternalOpen(next);
97
+ onOpenChange?.(next);
98
+ }, [openProp, onOpenChange]);
99
+ const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
100
+ useBackDismiss(open, dismiss);
101
+ // 0 is fully dismissed, 1 fully presented; the panel rides up this value.
102
+ const { value: rise, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "gentle");
103
+ const translateY = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: [420, 0] }) : 0;
104
+ return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: dismiss, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close sheet", onPress: dismissOnBackdropPress ? dismiss : undefined, style: { flex: 1, justifyContent: "flex-end", backgroundColor: theme.scrim }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { width: "100%" }, children: animated ? ((0, jsx_runtime_1.jsx)(SheetRise, { translateY: translateY, children: (0, jsx_runtime_1.jsx)(SheetPanel, { title: title, footer: footer, showHandle: showHandle, isDark: isDark, testID: testID, style: style, children: children }) })) : ((0, jsx_runtime_1.jsx)(SheetPanel, { title: title, footer: footer, showHandle: showHandle, isDark: isDark, testID: testID, style: style, children: children })) }) }) }));
105
+ });
106
+ function SheetRise({ translateY, children }) {
107
+ const { Animated } = (0, primitives_1.primitives)();
108
+ return (0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ translateY }] }, children: children });
109
+ }
110
+ /** The panel itself: a glass surface with a handle, a title and a footer. */
111
+ function SheetPanel({ title, footer, showHandle, isDark, testID, style, children, }) {
112
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
113
+ const { View, Text: RNText } = (0, primitives_1.primitives)();
114
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID, style: {
115
+ borderTopLeftRadius: tokens_1.radii.xl,
116
+ borderTopRightRadius: tokens_1.radii.xl,
117
+ borderBottomLeftRadius: 0,
118
+ borderBottomRightRadius: 0,
119
+ paddingBottom: 20,
120
+ maxHeight: 560,
121
+ ...style,
122
+ }, children: [showHandle ? ((0, jsx_runtime_1.jsx)(View, { style: { alignItems: "center", paddingTop: 8, paddingBottom: 4 }, children: (0, jsx_runtime_1.jsx)(View, { accessibilityElementsHidden: true,
123
+ // A capsule: the radius is half the handle's own height.
124
+ style: { width: 36, height: 5, borderRadius: 5 / 2, backgroundColor: theme.separator } }) })) : null, title ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 20, paddingVertical: 10 }, children: (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 17, fontWeight: "600", color: theme.foreground }, children: title }) })) : null, (0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 20 }, children: children }), footer ? (0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 20, paddingTop: 12, gap: 8 }, children: footer }) : null] }));
125
+ }
126
+ /**
127
+ * A side navigation drawer.
128
+ *
129
+ * The same overlay discipline as Sheet — scrim, spring slide, Android back —
130
+ * but anchored to a side edge, with a square panel that runs the full height.
131
+ * The caller supplies the content, typically a List.
132
+ */
133
+ exports.Drawer = (0, react_1.forwardRef)(function Drawer({ open: openProp, defaultOpen = false, onOpenChange, side = "left", width = 280, children, dismissOnBackdropPress = true, style, isDark: isDarkProp, testID, ...props }, ref) {
134
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
135
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
136
+ const { View, Pressable, Modal } = (0, primitives_1.primitives)();
137
+ const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
138
+ const open = openProp !== undefined ? openProp : internalOpen;
139
+ const setOpen = (0, react_1.useCallback)((next) => {
140
+ if (openProp === undefined)
141
+ setInternalOpen(next);
142
+ onOpenChange?.(next);
143
+ }, [openProp, onOpenChange]);
144
+ const dismiss = (0, react_1.useCallback)(() => setOpen(false), [setOpen]);
145
+ useBackDismiss(open, dismiss);
146
+ const { value: slide, animated } = (0, motion_1.useSpring)(open ? 1 : 0, "gentle");
147
+ // Slide in from off-screen: negative from the left, positive from the right.
148
+ const translateX = animated
149
+ ? slide.interpolate({ inputRange: [0, 1], outputRange: [side === "left" ? -width : width, 0] })
150
+ : 0;
151
+ const panel = ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { effect: "regular", isDark: isDark, testID: testID, style: {
152
+ width,
153
+ height: "100%",
154
+ borderRadius: 0,
155
+ paddingTop: 56,
156
+ ...style,
157
+ }, children: children }));
158
+ return ((0, jsx_runtime_1.jsx)(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: dismiss, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Close drawer", onPress: dismissOnBackdropPress ? dismiss : undefined, style: { flex: 1, backgroundColor: theme.scrim }, children: (0, jsx_runtime_1.jsx)(View, { style: {
159
+ flex: 1,
160
+ alignItems: side === "left" ? "flex-start" : "flex-end",
161
+ }, children: (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "none", onPress: () => { }, style: { height: "100%" }, children: animated ? (0, jsx_runtime_1.jsx)(DrawerSlide, { translateX: translateX, children: panel }) : panel }) }) }) }));
162
+ });
163
+ function DrawerSlide({ translateX, children }) {
164
+ const { Animated } = (0, primitives_1.primitives)();
165
+ return (0, jsx_runtime_1.jsx)(Animated.View, { style: { height: "100%", transform: [{ translateX }] }, children: children });
166
+ }