@rangular-framework/compiler 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/compiler/src/catalog.d.ts +63 -0
  2. package/dist/compiler/src/catalog.js +198 -0
  3. package/dist/compiler/src/class/formInit.d.ts +119 -0
  4. package/dist/compiler/src/class/formInit.js +370 -0
  5. package/dist/compiler/src/class/parseComponent.d.ts +232 -0
  6. package/dist/compiler/src/class/parseComponent.js +430 -0
  7. package/dist/compiler/src/class/parseDirective.d.ts +42 -0
  8. package/dist/compiler/src/class/parseDirective.js +227 -0
  9. package/dist/compiler/src/class/parseRoutes.d.ts +59 -0
  10. package/dist/compiler/src/class/parseRoutes.js +163 -0
  11. package/dist/compiler/src/codegen/generate.d.ts +166 -0
  12. package/dist/compiler/src/codegen/generate.js +3466 -0
  13. package/dist/compiler/src/codegen/methods.d.ts +148 -0
  14. package/dist/compiler/src/codegen/methods.js +975 -0
  15. package/dist/compiler/src/codegen/sourceMap.d.ts +42 -0
  16. package/dist/compiler/src/codegen/sourceMap.js +77 -0
  17. package/dist/compiler/src/compile.d.ts +101 -0
  18. package/dist/compiler/src/compile.js +775 -0
  19. package/dist/compiler/src/diagnostics.d.ts +37 -0
  20. package/dist/compiler/src/diagnostics.js +113 -0
  21. package/dist/compiler/src/doctor.d.ts +35 -0
  22. package/dist/compiler/src/doctor.js +144 -0
  23. package/dist/compiler/src/fix.d.ts +21 -0
  24. package/dist/compiler/src/fix.js +44 -0
  25. package/dist/compiler/src/index.d.ts +22 -0
  26. package/dist/compiler/src/index.js +38 -0
  27. package/dist/compiler/src/preview/renderPreview.d.ts +101 -0
  28. package/dist/compiler/src/preview/renderPreview.js +7158 -0
  29. package/dist/compiler/src/preview/styleSnapshot.d.ts +36 -0
  30. package/dist/compiler/src/preview/styleSnapshot.js +268 -0
  31. package/dist/compiler/src/propTable.d.ts +22 -0
  32. package/dist/compiler/src/propTable.js +107 -0
  33. package/dist/compiler/src/style/css.d.ts +23 -0
  34. package/dist/compiler/src/style/css.js +161 -0
  35. package/dist/compiler/src/template/ast.d.ts +66 -0
  36. package/dist/compiler/src/template/ast.js +19 -0
  37. package/dist/compiler/src/template/evaluate.d.ts +45 -0
  38. package/dist/compiler/src/template/evaluate.js +151 -0
  39. package/dist/compiler/src/template/expr.d.ts +94 -0
  40. package/dist/compiler/src/template/expr.js +360 -0
  41. package/dist/compiler/src/template/forms.d.ts +42 -0
  42. package/dist/compiler/src/template/forms.js +80 -0
  43. package/dist/compiler/src/template/literal.d.ts +38 -0
  44. package/dist/compiler/src/template/literal.js +248 -0
  45. package/dist/compiler/src/template/parser.d.ts +14 -0
  46. package/dist/compiler/src/template/parser.js +230 -0
  47. package/dist/compiler/src/template/pipes.d.ts +48 -0
  48. package/dist/compiler/src/template/pipes.js +225 -0
  49. package/dist/compiler/src/template/printAst.d.ts +3 -0
  50. package/dist/compiler/src/template/printAst.js +38 -0
  51. package/dist/compiler/src/template/structural.d.ts +27 -0
  52. package/dist/compiler/src/template/structural.js +51 -0
  53. package/dist/runtime/src/index.d.ts +486 -0
  54. package/dist/runtime/src/index.js +1197 -0
  55. package/dist/ui/src/chart.d.ts +81 -0
  56. package/dist/ui/src/chart.js +196 -0
  57. package/dist/ui/src/datetime.d.ts +92 -0
  58. package/dist/ui/src/datetime.js +240 -0
  59. package/dist/ui/src/icons.d.ts +63 -0
  60. package/dist/ui/src/icons.js +310 -0
  61. package/dist/ui/src/mask.d.ts +38 -0
  62. package/dist/ui/src/mask.js +103 -0
  63. package/dist/ui/src/palette.d.ts +66 -0
  64. package/dist/ui/src/palette.js +141 -0
  65. package/dist/ui/src/tokens.d.ts +129 -0
  66. package/dist/ui/src/tokens.js +173 -0
  67. package/package.json +24 -4
  68. package/README.md +0 -3
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Chart geometry (Stage 15), pure TypeScript with no imports: the
3
+ * one small engine the RgChart primitive, the compiler's preview
4
+ * paint and the preview page runtime all share. The page runtime
5
+ * mirrors these functions in plain JavaScript; the two are
6
+ * parity-tested against the same case tables in tests/stage15.test.ts.
7
+ *
8
+ * The data shape is one documented form, an array of label and
9
+ * value pairs:
10
+ *
11
+ * [ { label: 'Mon', value: 12 }, { label: 'Tue', value: 19 } ]
12
+ *
13
+ * A point may carry its own `color` (a hex string); without one it
14
+ * takes the next colour of the palette the caller passes in. The
15
+ * engine returns a model of plain shapes (rects, paths, circles,
16
+ * texts) in a width by height box, and each surface serializes the
17
+ * same model: react-native-svg in the app, inline SVG in both
18
+ * preview renderers. Coordinates are rounded to two decimals in the
19
+ * model itself, so the three serializations agree byte for byte on
20
+ * the geometry.
21
+ *
22
+ * Scope, stated plainly: three chart types (bar, line, pie), one
23
+ * series, no axes lines, no gridlines, no animation, no interaction.
24
+ * Bar and pie values are counts: a negative value reads as 0. A
25
+ * line scales between the data's own minimum and maximum.
26
+ */
27
+ export interface ChartPoint {
28
+ label: string;
29
+ value: number;
30
+ color?: string;
31
+ }
32
+ export type ChartShape = {
33
+ kind: 'rect';
34
+ x: number;
35
+ y: number;
36
+ width: number;
37
+ height: number;
38
+ fill: string;
39
+ } | {
40
+ kind: 'path';
41
+ d: string;
42
+ fill?: string;
43
+ stroke?: string;
44
+ strokeWidth?: number;
45
+ } | {
46
+ kind: 'circle';
47
+ cx: number;
48
+ cy: number;
49
+ r: number;
50
+ fill: string;
51
+ } | {
52
+ kind: 'text';
53
+ x: number;
54
+ y: number;
55
+ text: string;
56
+ fill: string;
57
+ size: number;
58
+ anchor: 'middle' | 'start';
59
+ };
60
+ export interface ChartModel {
61
+ width: number;
62
+ height: number;
63
+ shapes: ChartShape[];
64
+ }
65
+ export declare const CHART_TYPES: string[];
66
+ /** Coerce unknown input into chart points; anything unusable drops out. */
67
+ export declare function normalizeChartData(data: unknown): ChartPoint[];
68
+ /**
69
+ * Mix two #rrggbb colours: `frac` of the second colour into the
70
+ * first. A colour that is not a plain six-digit hex passes
71
+ * through unchanged, so a data colour the mixer cannot read
72
+ * still paints.
73
+ */
74
+ export declare function mixHex(hex: string, other: string, frac: number): string;
75
+ /**
76
+ * Build the shape model for one chart. `width` is the chart's full
77
+ * width; `height` is the plotting height the author asked for (the
78
+ * returned model's height adds the label strip, and for pie the
79
+ * legend rows, below it).
80
+ */
81
+ export declare function chartModel(type: string, data: unknown, width: number, height: number, palette: string[], labelColor: string): ChartModel;
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ /**
3
+ * Chart geometry (Stage 15), pure TypeScript with no imports: the
4
+ * one small engine the RgChart primitive, the compiler's preview
5
+ * paint and the preview page runtime all share. The page runtime
6
+ * mirrors these functions in plain JavaScript; the two are
7
+ * parity-tested against the same case tables in tests/stage15.test.ts.
8
+ *
9
+ * The data shape is one documented form, an array of label and
10
+ * value pairs:
11
+ *
12
+ * [ { label: 'Mon', value: 12 }, { label: 'Tue', value: 19 } ]
13
+ *
14
+ * A point may carry its own `color` (a hex string); without one it
15
+ * takes the next colour of the palette the caller passes in. The
16
+ * engine returns a model of plain shapes (rects, paths, circles,
17
+ * texts) in a width by height box, and each surface serializes the
18
+ * same model: react-native-svg in the app, inline SVG in both
19
+ * preview renderers. Coordinates are rounded to two decimals in the
20
+ * model itself, so the three serializations agree byte for byte on
21
+ * the geometry.
22
+ *
23
+ * Scope, stated plainly: three chart types (bar, line, pie), one
24
+ * series, no axes lines, no gridlines, no animation, no interaction.
25
+ * Bar and pie values are counts: a negative value reads as 0. A
26
+ * line scales between the data's own minimum and maximum.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.CHART_TYPES = void 0;
30
+ exports.normalizeChartData = normalizeChartData;
31
+ exports.mixHex = mixHex;
32
+ exports.chartModel = chartModel;
33
+ exports.CHART_TYPES = ['bar', 'line', 'pie'];
34
+ /** Coerce unknown input into chart points; anything unusable drops out. */
35
+ function normalizeChartData(data) {
36
+ if (!Array.isArray(data))
37
+ return [];
38
+ const out = [];
39
+ for (const item of data) {
40
+ if (item === null || typeof item !== 'object')
41
+ continue;
42
+ const rec = item;
43
+ const value = Number(rec['value']);
44
+ if (!Number.isFinite(value))
45
+ continue;
46
+ out.push({
47
+ label: rec['label'] === undefined || rec['label'] === null ? '' : String(rec['label']),
48
+ value,
49
+ ...(typeof rec['color'] === 'string' ? { color: rec['color'] } : {}),
50
+ });
51
+ }
52
+ return out;
53
+ }
54
+ function r2(n) {
55
+ return Math.round(n * 100) / 100;
56
+ }
57
+ function colorOf(point, index, palette) {
58
+ return point.color ?? palette[index % Math.max(palette.length, 1)] ?? '#000000';
59
+ }
60
+ /**
61
+ * Mix two #rrggbb colours: `frac` of the second colour into the
62
+ * first. A colour that is not a plain six-digit hex passes
63
+ * through unchanged, so a data colour the mixer cannot read
64
+ * still paints.
65
+ */
66
+ function mixHex(hex, other, frac) {
67
+ const m = /^#([0-9a-fA-F]{6})$/.exec(hex);
68
+ const o = /^#([0-9a-fA-F]{6})$/.exec(other);
69
+ if (!m || !o)
70
+ return hex;
71
+ const a = parseInt(m[1], 16);
72
+ const b = parseInt(o[1], 16);
73
+ const ch = (shift) => Math.round(((a >> shift) & 255) * (1 - frac) + ((b >> shift) & 255) * frac);
74
+ return `#${((1 << 24) + (ch(16) << 16) + (ch(8) << 8) + ch(0)).toString(16).slice(1)}`;
75
+ }
76
+ const LABEL_STRIP = 18;
77
+ const LEGEND_ROW = 18;
78
+ /**
79
+ * Build the shape model for one chart. `width` is the chart's full
80
+ * width; `height` is the plotting height the author asked for (the
81
+ * returned model's height adds the label strip, and for pie the
82
+ * legend rows, below it).
83
+ */
84
+ function chartModel(type, data, width, height, palette, labelColor) {
85
+ const points = normalizeChartData(data);
86
+ const w = Math.max(40, Math.floor(width) || 40);
87
+ const plotH = Math.max(40, Math.floor(height) || 40);
88
+ const shapes = [];
89
+ if (!points.length)
90
+ return { width: w, height: plotH, shapes };
91
+ if (type === 'pie') {
92
+ const total = points.reduce((sum, p) => sum + Math.max(0, p.value), 0);
93
+ const r = Math.min(w, plotH) / 2;
94
+ const cx = w / 2;
95
+ const cy = plotH / 2;
96
+ let angle = -90;
97
+ points.forEach((p, i) => {
98
+ const frac = total > 0 ? Math.max(0, p.value) / total : 0;
99
+ const sweep = frac * 360;
100
+ const fill = colorOf(p, i, palette);
101
+ if (frac > 0) {
102
+ if (frac >= 0.9999) {
103
+ shapes.push({ kind: 'circle', cx: r2(cx), cy: r2(cy), r: r2(r), fill });
104
+ }
105
+ else {
106
+ const a0 = (angle * Math.PI) / 180;
107
+ const a1 = ((angle + sweep) * Math.PI) / 180;
108
+ const x0 = cx + r * Math.cos(a0);
109
+ const y0 = cy + r * Math.sin(a0);
110
+ const x1 = cx + r * Math.cos(a1);
111
+ const y1 = cy + r * Math.sin(a1);
112
+ const large = sweep > 180 ? 1 : 0;
113
+ shapes.push({
114
+ kind: 'path',
115
+ d: `M ${r2(cx)} ${r2(cy)} L ${r2(x0)} ${r2(y0)} A ${r2(r)} ${r2(r)} 0 ${large} 1 ${r2(x1)} ${r2(y1)} Z`,
116
+ fill,
117
+ });
118
+ }
119
+ }
120
+ angle += sweep;
121
+ });
122
+ // The legend lives in the model (one swatch rect and one text
123
+ // per point) so all three surfaces lay it out identically.
124
+ points.forEach((p, i) => {
125
+ const y = plotH + 6 + i * LEGEND_ROW;
126
+ shapes.push({ kind: 'rect', x: 0, y: r2(y), width: 10, height: 10, fill: colorOf(p, i, palette) });
127
+ shapes.push({
128
+ kind: 'text', x: 16, y: r2(y + 10), text: `${p.label} ${p.value}`,
129
+ fill: labelColor, size: 12, anchor: 'start',
130
+ });
131
+ });
132
+ return { width: w, height: plotH + 6 + points.length * LEGEND_ROW, shapes };
133
+ }
134
+ if (type === 'line') {
135
+ let min = Math.min(...points.map((p) => p.value));
136
+ let max = Math.max(...points.map((p) => p.value));
137
+ if (min === max) {
138
+ min -= 1;
139
+ max += 1;
140
+ }
141
+ const stroke = colorOf(points[0], 0, palette);
142
+ const coords = points.map((p, i) => {
143
+ const x = points.length === 1 ? w / 2 : (i * w) / (points.length - 1);
144
+ const y = plotH - ((p.value - min) / (max - min)) * (plotH - 8) - 4;
145
+ return { x: r2(x), y: r2(y) };
146
+ });
147
+ const d = coords.map((c, i) => `${i === 0 ? 'M' : 'L'} ${c.x} ${c.y}`).join(' ');
148
+ shapes.push({ kind: 'path', d, stroke, strokeWidth: 2 });
149
+ coords.forEach((c) => shapes.push({ kind: 'circle', cx: c.x, cy: c.y, r: 3, fill: stroke }));
150
+ points.forEach((p, i) => {
151
+ shapes.push({
152
+ kind: 'text', x: coords[i].x, y: plotH + 14, text: p.label,
153
+ fill: labelColor, size: 12, anchor: 'middle',
154
+ });
155
+ });
156
+ return { width: w, height: plotH + LABEL_STRIP, shapes };
157
+ }
158
+ // bar (the default; an unknown type is a compile error long
159
+ // before the engine sees it, GEN_CHART_TYPE).
160
+ const max = Math.max(1, ...points.map((p) => Math.max(0, p.value)));
161
+ const slot = w / points.length;
162
+ const barW = slot * 0.6;
163
+ points.forEach((p, i) => {
164
+ const v = Math.max(0, p.value);
165
+ const h = (v / max) * (plotH - 4);
166
+ const x = slot * i + slot * 0.2;
167
+ const y = plotH - h;
168
+ const colour = colorOf(p, i, palette);
169
+ if (h > 0) {
170
+ // Frosted glass (Bigyan's pick for the History week chart,
171
+ // 2026-11-24, keeping the per-bar palette colours): the
172
+ // bar's own colour stands at its edge, the body is that
173
+ // colour mixed toward white, and a paler gloss band lies
174
+ // over the top. The top corners round; the base stays
175
+ // square on the axis line.
176
+ const r = Math.min(6, barW / 2, h / 2);
177
+ const top = `M ${r2(x)} ${r2(y + h)} L ${r2(x)} ${r2(y + r)} Q ${r2(x)} ${r2(y)} ${r2(x + r)} ${r2(y)} L ${r2(x + barW - r)} ${r2(y)} Q ${r2(x + barW)} ${r2(y)} ${r2(x + barW)} ${r2(y + r)}`;
178
+ shapes.push({
179
+ kind: 'path', d: `${top} L ${r2(x + barW)} ${r2(y + h)} Z`,
180
+ fill: mixHex(colour, '#ffffff', 0.45), stroke: colour, strokeWidth: 1,
181
+ });
182
+ const gh = Math.max(0, h * 0.45);
183
+ if (gh > 1) {
184
+ shapes.push({
185
+ kind: 'path', d: `${top} L ${r2(x + barW)} ${r2(y + gh)} L ${r2(x)} ${r2(y + gh)} Z`,
186
+ fill: mixHex(colour, '#ffffff', 0.72),
187
+ });
188
+ }
189
+ }
190
+ shapes.push({
191
+ kind: 'text', x: r2(slot * i + slot / 2), y: plotH + 14, text: p.label,
192
+ fill: labelColor, size: 12, anchor: 'middle',
193
+ });
194
+ });
195
+ return { width: w, height: plotH + LABEL_STRIP, shapes };
196
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Date and time value helpers for the Rangular date-time picker
3
+ * (Stage 10), pure TypeScript with no imports: the value model the
4
+ * RgDateTimePicker primitive, the compiler's preview paint and the
5
+ * preview page runtime all share. The page runtime mirrors these
6
+ * functions in plain JavaScript; the two implementations are
7
+ * parity-tested against the same case tables in tests/stage10.test.ts.
8
+ *
9
+ * The value that crosses the template boundary is an ISO string in
10
+ * local time with no zone suffix, `YYYY-MM-DDTHH:mm:00`, the string
11
+ * form of the parts. A `Date` is also accepted on the way in (a
12
+ * component may hold one), its local fields are read. Composition
13
+ * always produces the ISO string, which is what the picker's
14
+ * `(change)` event emits as `$event`.
15
+ */
16
+ export interface DateTimeParts {
17
+ /** Full year, e.g. 2026. */
18
+ year: number;
19
+ /** Month, 1 to 12. */
20
+ month: number;
21
+ /** Day of month, 1 to 31. */
22
+ day: number;
23
+ /** Hour, 0 to 23. */
24
+ hour: number;
25
+ /** Minute, 0 to 59. */
26
+ minute: number;
27
+ }
28
+ export type PickerMode = 'date' | 'time' | 'datetime';
29
+ export declare const PICKER_MODES: PickerMode[];
30
+ export declare const MONTH_SHORT: string[];
31
+ /** Days in a month, leap years handled (1900 is not, 2000 is). */
32
+ export declare function daysInMonth(year: number, month: number): number;
33
+ /** Clamp parts into range: month 1 to 12, day into its month, hour 0 to 23, minute 0 to 59. */
34
+ export declare function clampDateTimeParts(parts: DateTimeParts): DateTimeParts;
35
+ /**
36
+ * Parse a picker value (an ISO string as produced here, a date-only
37
+ * ISO string, or a Date) into parts. Returns null for anything else,
38
+ * including out-of-range fields like month 13 or February 30.
39
+ */
40
+ export declare function parseDateTimeValue(value: unknown): DateTimeParts | null;
41
+ /** Compose parts into the ISO string form the picker emits. */
42
+ export declare function composeDateTimeIso(parts: DateTimeParts): string;
43
+ /** The current local date and time as parts (the picker's fallback value). */
44
+ export declare function nowParts(): DateTimeParts;
45
+ /** The 12-hour clock hour of parts (1 to 12); iOS wheels use this form. */
46
+ export declare function hour12Of(parts: DateTimeParts): number;
47
+ /** 'AM' or 'PM' for parts. */
48
+ export declare function ampmOf(parts: DateTimeParts): 'AM' | 'PM';
49
+ /**
50
+ * The field display text of a value, the same text in the generated
51
+ * app and the preview: `Nov 13, 2026` for date mode, `9:00 AM` for
52
+ * time mode, both joined for datetime mode.
53
+ */
54
+ export declare function formatDateTimeValue(parts: DateTimeParts, mode: PickerMode): string;
55
+ /** The year wheel of date mode: a FIXED range, 150 years either
56
+ * side of the current year (301 entries), extended only to
57
+ * include the value's year when that lies outside it. The range
58
+ * never follows the pending value. A value-centred list rebuilt
59
+ * itself under the scroll offset on every selection, so the
60
+ * year wheel jumped several years per flick and could move
61
+ * against the scroll direction (his phone report, 2026-11-20).
62
+ * A fixed list makes one notch exactly one year. */
63
+ export declare function pickerYears(valueYear: number, todayYear: number): number[];
64
+ /** The minute wheel values for a minute interval (1 or 5 in this version). */
65
+ export declare function pickerMinutes(minuteInterval: number): number[];
66
+ /** One wheel of the picker: its name, its options and its selected value. */
67
+ export interface WheelSpec {
68
+ name: 'month' | 'day' | 'year' | 'hour' | 'minute' | 'ampm';
69
+ options: {
70
+ value: string;
71
+ label: string;
72
+ }[];
73
+ value: string;
74
+ }
75
+ /**
76
+ * The wheels of one picker mode for a pending value:
77
+ * - date: year, month, day wheels;
78
+ * - time: hour (1 to 12), minute, AM/PM wheels, the iOS form;
79
+ * - datetime: the same year, month and day wheels, then hour,
80
+ * minute and AM/PM wheels. The picker shows them in two separate
81
+ * steps, date first, time second (the overhaul of 2026-11-20: a
82
+ * single combined day list scrolled wildly and gave no precise
83
+ * control; separate wheels are the Apple Calendar form).
84
+ */
85
+ export declare function dateTimeWheels(parts: DateTimeParts, mode: PickerMode, minuteInterval: number): WheelSpec[];
86
+ /**
87
+ * Apply one wheel selection to a pending value and return the new
88
+ * pending value. Day clamps into its month (January 31 to February
89
+ * becomes February 28 or 29); hour and AM/PM compose the 24-hour
90
+ * hour between them.
91
+ */
92
+ export declare function applyWheelValue(parts: DateTimeParts, wheel: string, value: string): DateTimeParts;
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ /**
3
+ * Date and time value helpers for the Rangular date-time picker
4
+ * (Stage 10), pure TypeScript with no imports: the value model the
5
+ * RgDateTimePicker primitive, the compiler's preview paint and the
6
+ * preview page runtime all share. The page runtime mirrors these
7
+ * functions in plain JavaScript; the two implementations are
8
+ * parity-tested against the same case tables in tests/stage10.test.ts.
9
+ *
10
+ * The value that crosses the template boundary is an ISO string in
11
+ * local time with no zone suffix, `YYYY-MM-DDTHH:mm:00`, the string
12
+ * form of the parts. A `Date` is also accepted on the way in (a
13
+ * component may hold one), its local fields are read. Composition
14
+ * always produces the ISO string, which is what the picker's
15
+ * `(change)` event emits as `$event`.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.MONTH_SHORT = exports.PICKER_MODES = void 0;
19
+ exports.daysInMonth = daysInMonth;
20
+ exports.clampDateTimeParts = clampDateTimeParts;
21
+ exports.parseDateTimeValue = parseDateTimeValue;
22
+ exports.composeDateTimeIso = composeDateTimeIso;
23
+ exports.nowParts = nowParts;
24
+ exports.hour12Of = hour12Of;
25
+ exports.ampmOf = ampmOf;
26
+ exports.formatDateTimeValue = formatDateTimeValue;
27
+ exports.pickerYears = pickerYears;
28
+ exports.pickerMinutes = pickerMinutes;
29
+ exports.dateTimeWheels = dateTimeWheels;
30
+ exports.applyWheelValue = applyWheelValue;
31
+ exports.PICKER_MODES = ['date', 'time', 'datetime'];
32
+ exports.MONTH_SHORT = [
33
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
34
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
35
+ ];
36
+ /** Days in a month, leap years handled (1900 is not, 2000 is). */
37
+ function daysInMonth(year, month) {
38
+ const lengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
39
+ if (month === 2) {
40
+ const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
41
+ return leap ? 29 : 28;
42
+ }
43
+ return lengths[month - 1] ?? 31;
44
+ }
45
+ /** Clamp parts into range: month 1 to 12, day into its month, hour 0 to 23, minute 0 to 59. */
46
+ function clampDateTimeParts(parts) {
47
+ const month = Math.min(12, Math.max(1, Math.trunc(parts.month) || 1));
48
+ const year = Math.trunc(parts.year) || 2000;
49
+ const day = Math.min(daysInMonth(year, month), Math.max(1, Math.trunc(parts.day) || 1));
50
+ const hour = Math.min(23, Math.max(0, Math.trunc(parts.hour) || 0));
51
+ const minute = Math.min(59, Math.max(0, Math.trunc(parts.minute) || 0));
52
+ return { year, month, day, hour, minute };
53
+ }
54
+ function pad2(n) {
55
+ return n < 10 ? `0${n}` : `${n}`;
56
+ }
57
+ const ISO_RE = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::\d{2}(?:\.\d+)?)?)?\s*(?:Z)?$/;
58
+ /**
59
+ * Parse a picker value (an ISO string as produced here, a date-only
60
+ * ISO string, or a Date) into parts. Returns null for anything else,
61
+ * including out-of-range fields like month 13 or February 30.
62
+ */
63
+ function parseDateTimeValue(value) {
64
+ if (value instanceof Date) {
65
+ if (Number.isNaN(value.getTime()))
66
+ return null;
67
+ return {
68
+ year: value.getFullYear(),
69
+ month: value.getMonth() + 1,
70
+ day: value.getDate(),
71
+ hour: value.getHours(),
72
+ minute: value.getMinutes(),
73
+ };
74
+ }
75
+ if (typeof value !== 'string')
76
+ return null;
77
+ const m = ISO_RE.exec(value.trim());
78
+ if (!m)
79
+ return null;
80
+ const parts = {
81
+ year: Number(m[1]),
82
+ month: Number(m[2]),
83
+ day: Number(m[3]),
84
+ hour: m[4] === undefined ? 0 : Number(m[4]),
85
+ minute: m[5] === undefined ? 0 : Number(m[5]),
86
+ };
87
+ if (parts.month < 1 || parts.month > 12)
88
+ return null;
89
+ if (parts.day < 1 || parts.day > daysInMonth(parts.year, parts.month))
90
+ return null;
91
+ if (parts.hour < 0 || parts.hour > 23 || parts.minute < 0 || parts.minute > 59)
92
+ return null;
93
+ return parts;
94
+ }
95
+ /** Compose parts into the ISO string form the picker emits. */
96
+ function composeDateTimeIso(parts) {
97
+ const p = clampDateTimeParts(parts);
98
+ return `${p.year}-${pad2(p.month)}-${pad2(p.day)}T${pad2(p.hour)}:${pad2(p.minute)}:00`;
99
+ }
100
+ /** The current local date and time as parts (the picker's fallback value). */
101
+ function nowParts() {
102
+ const d = new Date();
103
+ return {
104
+ year: d.getFullYear(),
105
+ month: d.getMonth() + 1,
106
+ day: d.getDate(),
107
+ hour: d.getHours(),
108
+ minute: d.getMinutes(),
109
+ };
110
+ }
111
+ /** The 12-hour clock hour of parts (1 to 12); iOS wheels use this form. */
112
+ function hour12Of(parts) {
113
+ const h = parts.hour % 12;
114
+ return h === 0 ? 12 : h;
115
+ }
116
+ /** 'AM' or 'PM' for parts. */
117
+ function ampmOf(parts) {
118
+ return parts.hour < 12 ? 'AM' : 'PM';
119
+ }
120
+ /**
121
+ * The field display text of a value, the same text in the generated
122
+ * app and the preview: `Nov 13, 2026` for date mode, `9:00 AM` for
123
+ * time mode, both joined for datetime mode.
124
+ */
125
+ function formatDateTimeValue(parts, mode) {
126
+ const p = clampDateTimeParts(parts);
127
+ const date = `${exports.MONTH_SHORT[p.month - 1]} ${p.day}, ${p.year}`;
128
+ const time = `${hour12Of(p)}:${pad2(p.minute)} ${ampmOf(p)}`;
129
+ if (mode === 'date')
130
+ return date;
131
+ if (mode === 'time')
132
+ return time;
133
+ return `${date} ${time}`;
134
+ }
135
+ /** The year wheel of date mode: a FIXED range, 150 years either
136
+ * side of the current year (301 entries), extended only to
137
+ * include the value's year when that lies outside it. The range
138
+ * never follows the pending value. A value-centred list rebuilt
139
+ * itself under the scroll offset on every selection, so the
140
+ * year wheel jumped several years per flick and could move
141
+ * against the scroll direction (his phone report, 2026-11-20).
142
+ * A fixed list makes one notch exactly one year. */
143
+ function pickerYears(valueYear, todayYear) {
144
+ const start = Math.min(todayYear - 150, valueYear);
145
+ const end = Math.max(todayYear + 150, valueYear);
146
+ const years = [];
147
+ for (let y = start; y <= end; y++)
148
+ years.push(y);
149
+ return years;
150
+ }
151
+ /** The minute wheel values for a minute interval (1 or 5 in this version). */
152
+ function pickerMinutes(minuteInterval) {
153
+ const step = minuteInterval === 5 ? 5 : 1;
154
+ const minutes = [];
155
+ for (let m = 0; m < 60; m += step)
156
+ minutes.push(m);
157
+ return minutes;
158
+ }
159
+ /**
160
+ * The wheels of one picker mode for a pending value:
161
+ * - date: year, month, day wheels;
162
+ * - time: hour (1 to 12), minute, AM/PM wheels, the iOS form;
163
+ * - datetime: the same year, month and day wheels, then hour,
164
+ * minute and AM/PM wheels. The picker shows them in two separate
165
+ * steps, date first, time second (the overhaul of 2026-11-20: a
166
+ * single combined day list scrolled wildly and gave no precise
167
+ * control; separate wheels are the Apple Calendar form).
168
+ */
169
+ function dateTimeWheels(parts, mode, minuteInterval) {
170
+ const p = clampDateTimeParts(parts);
171
+ const wheels = [];
172
+ if (mode === 'date' || mode === 'datetime') {
173
+ // Order is year, month, day (his word, 2026-11-20).
174
+ wheels.push({
175
+ name: 'year',
176
+ options: pickerYears(p.year, new Date().getFullYear()).map((y) => ({ value: `${y}`, label: `${y}` })),
177
+ value: `${p.year}`,
178
+ });
179
+ wheels.push({
180
+ name: 'month',
181
+ options: exports.MONTH_SHORT.map((label, i) => ({ value: `${i + 1}`, label })),
182
+ value: `${p.month}`,
183
+ });
184
+ const days = [];
185
+ for (let d = 1; d <= daysInMonth(p.year, p.month); d++)
186
+ days.push({ value: `${d}`, label: `${d}` });
187
+ wheels.push({ name: 'day', options: days, value: `${p.day}` });
188
+ }
189
+ if (mode === 'time' || mode === 'datetime') {
190
+ const hours = [];
191
+ for (let h = 1; h <= 12; h++)
192
+ hours.push({ value: `${h}`, label: `${h}` });
193
+ wheels.push({ name: 'hour', options: hours, value: `${hour12Of(p)}` });
194
+ // A value between steps (9:03 with a 5 minute interval) selects
195
+ // the nearest step, the way the iOS wheel settles; picking any
196
+ // step then sets the minute exactly.
197
+ const step = minuteInterval === 5 ? 5 : 1;
198
+ const snappedMinute = Math.min(60 - step, Math.round(p.minute / step) * step);
199
+ wheels.push({
200
+ name: 'minute',
201
+ options: pickerMinutes(minuteInterval).map((m) => ({ value: `${m}`, label: pad2(m) })),
202
+ value: `${snappedMinute}`,
203
+ });
204
+ wheels.push({
205
+ name: 'ampm',
206
+ options: [{ value: 'AM', label: 'AM' }, { value: 'PM', label: 'PM' }],
207
+ value: ampmOf(p),
208
+ });
209
+ }
210
+ return wheels;
211
+ }
212
+ /**
213
+ * Apply one wheel selection to a pending value and return the new
214
+ * pending value. Day clamps into its month (January 31 to February
215
+ * becomes February 28 or 29); hour and AM/PM compose the 24-hour
216
+ * hour between them.
217
+ */
218
+ function applyWheelValue(parts, wheel, value) {
219
+ const p = clampDateTimeParts(parts);
220
+ switch (wheel) {
221
+ case 'month': return clampDateTimeParts({ ...p, month: Number(value) });
222
+ case 'day': return clampDateTimeParts({ ...p, day: Number(value) });
223
+ case 'year': return clampDateTimeParts({ ...p, year: Number(value) });
224
+ case 'hour': {
225
+ const h12 = Number(value);
226
+ if (!Number.isFinite(h12))
227
+ return p;
228
+ return { ...p, hour: (h12 % 12) + (p.hour >= 12 ? 12 : 0) };
229
+ }
230
+ case 'minute': return { ...p, minute: Number(value) || 0 };
231
+ case 'ampm': {
232
+ const wantPm = value === 'PM';
233
+ const isPm = p.hour >= 12;
234
+ if (wantPm === isPm)
235
+ return p;
236
+ return { ...p, hour: wantPm ? p.hour + 12 : p.hour - 12 };
237
+ }
238
+ default: return p;
239
+ }
240
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The Rangular icon set: Google Material Symbols, one fixed
3
+ * hand for the whole set, the rounded style, filled, at
4
+ * weight 400. The drawings are Google's own, taken from the
5
+ * @material-symbols/svg-400 package (built from Google's
6
+ * files, Apache License 2.0) and transformed from the
7
+ * Symbols 960 grid onto the 24 by 24 viewBox this file has
8
+ * always used, so nothing else in the framework moved.
9
+ * Before 2026-11-21 the set held 31 drawings from the older,
10
+ * frozen Material Icons set, gathered one feature at a
11
+ * time; when a needed glyph was missing, the nearest wrong
12
+ * one got used (History wore a calendar) or the app built
13
+ * the shape by hand (the menu dots). The standard now:
14
+ *
15
+ * 1. Never substitute a near glyph for the right word.
16
+ * 2. Never hand-draw. If a glyph is missing, add the
17
+ * official Symbols drawing, in the same hand.
18
+ *
19
+ * Names are the framework's own (kebab case, the words an
20
+ * app would say: bell, plus, arrow-left). Each value is a
21
+ * list of path `d` strings; almost every icon needs one.
22
+ * The three outline entries (bookmark-outline, star-outline,
23
+ * heart-outline) take the unfilled drawing on purpose:
24
+ * they are the unsaved and unlit states of their pairs.
25
+ *
26
+ * This file is the single source of truth for icons. The
27
+ * generated app draws these paths through the RgIcon
28
+ * primitive (react-native-svg), and the dev preview draws
29
+ * the exact same path data as inline SVG, so the preview
30
+ * and the app can never show different drawings. The
31
+ * compiler validates <icon name="..."> against this set,
32
+ * and the catalog is generated from it.
33
+ *
34
+ * App side note: RgIcon in primitives.tsx renders with
35
+ * react-native-svg. That library ships inside Expo Go and
36
+ * is a standard part of Expo and React Native projects, so
37
+ * a generated app needs nothing unusual, but it is a real
38
+ * dependency of the generated app, named here so nobody is
39
+ * surprised by it.
40
+ */
41
+ export declare const ICON_PATHS: Record<string, string[]>;
42
+ /**
43
+ * Brand marks: multi-colour drawings that are not icons. An icon is
44
+ * one colour and takes the colour it is given; a brand mark carries
45
+ * its own colours and is drawn exactly as designed, so the `color`
46
+ * attribute does not recolour it. Each value is the inner markup of
47
+ * an SVG with the viewBox in BRAND_MARK_VIEWBOX, and every renderer
48
+ * (RgIcon in the app, both preview layers) draws from this one
49
+ * source, the same rule the icon paths follow.
50
+ *
51
+ * `logo` is the Rangular framework's own mark, the Split Shield
52
+ * (picked 2026-11-18): the top half is the Angular shield in red
53
+ * with a white R, the bottom half is dark with the React atom in
54
+ * cyan. The master artwork lives at assets/logo.svg in the repo.
55
+ */
56
+ export declare const BRAND_MARK_VIEWBOX = "0 0 100 100";
57
+ export declare const BRAND_MARKS: Record<string, string>;
58
+ /** Every valid icon name, sorted, brand marks included. The compiler validates against this. */
59
+ export declare const ICON_NAMES: string[];
60
+ /** The fixed icon size scale, in px. Template sizes snap to this. */
61
+ export declare const ICON_SIZES: number[];
62
+ /** The size an icon gets when the template does not say. */
63
+ export declare const DEFAULT_ICON_SIZE = 24;