panelui-native 0.28.1 → 0.32.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/README.md +22 -3
  2. package/lib/module/components/calendar/index.js +450 -132
  3. package/lib/module/components/calendar/index.js.map +1 -1
  4. package/lib/module/components/code-block/highlight.js +363 -0
  5. package/lib/module/components/code-block/highlight.js.map +1 -0
  6. package/lib/module/components/code-block/index.js +313 -0
  7. package/lib/module/components/code-block/index.js.map +1 -0
  8. package/lib/module/components/date-picker/index.js +8 -1
  9. package/lib/module/components/date-picker/index.js.map +1 -1
  10. package/lib/module/components/heatmap-chart/index.js +9 -8
  11. package/lib/module/components/heatmap-chart/index.js.map +1 -1
  12. package/lib/module/components/map/index.js +50 -4
  13. package/lib/module/components/map/index.js.map +1 -1
  14. package/lib/module/components/menu/index.js +714 -0
  15. package/lib/module/components/menu/index.js.map +1 -0
  16. package/lib/module/components/plan/index.js +582 -0
  17. package/lib/module/components/plan/index.js.map +1 -0
  18. package/lib/module/components/popover/index.js +35 -4
  19. package/lib/module/components/popover/index.js.map +1 -1
  20. package/lib/module/components/post/index.js +992 -0
  21. package/lib/module/components/post/index.js.map +1 -0
  22. package/lib/module/components/radio-group/index.js +13 -8
  23. package/lib/module/components/radio-group/index.js.map +1 -1
  24. package/lib/module/components/reasoning/index.js +244 -0
  25. package/lib/module/components/reasoning/index.js.map +1 -0
  26. package/lib/module/components/response/index.js +296 -0
  27. package/lib/module/components/response/index.js.map +1 -0
  28. package/lib/module/components/response/markdown.js +463 -0
  29. package/lib/module/components/response/markdown.js.map +1 -0
  30. package/lib/module/components/select/index.js +97 -15
  31. package/lib/module/components/select/index.js.map +1 -1
  32. package/lib/module/components/sources/index.js +221 -0
  33. package/lib/module/components/sources/index.js.map +1 -0
  34. package/lib/module/components/table/index.js +632 -0
  35. package/lib/module/components/table/index.js.map +1 -0
  36. package/lib/module/components/task/index.js +300 -0
  37. package/lib/module/components/task/index.js.map +1 -0
  38. package/lib/module/components/textarea/index.js +295 -0
  39. package/lib/module/components/textarea/index.js.map +1 -0
  40. package/lib/module/components/tooltip/index.js +179 -23
  41. package/lib/module/components/tooltip/index.js.map +1 -1
  42. package/lib/module/icons/index.js +339 -0
  43. package/lib/module/icons/index.js.map +1 -1
  44. package/lib/module/index.js +12 -1
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/primitives/collapse.js +112 -0
  47. package/lib/module/primitives/collapse.js.map +1 -0
  48. package/lib/module/utils/date.js +129 -22
  49. package/lib/module/utils/date.js.map +1 -1
  50. package/lib/typescript/src/components/calendar/index.d.ts +79 -5
  51. package/lib/typescript/src/components/calendar/index.d.ts.map +1 -1
  52. package/lib/typescript/src/components/code-block/highlight.d.ts +39 -0
  53. package/lib/typescript/src/components/code-block/highlight.d.ts.map +1 -0
  54. package/lib/typescript/src/components/code-block/index.d.ts +113 -0
  55. package/lib/typescript/src/components/code-block/index.d.ts.map +1 -0
  56. package/lib/typescript/src/components/date-picker/index.d.ts +7 -1
  57. package/lib/typescript/src/components/date-picker/index.d.ts.map +1 -1
  58. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
  59. package/lib/typescript/src/components/map/index.d.ts +8 -1
  60. package/lib/typescript/src/components/map/index.d.ts.map +1 -1
  61. package/lib/typescript/src/components/menu/index.d.ts +261 -0
  62. package/lib/typescript/src/components/menu/index.d.ts.map +1 -0
  63. package/lib/typescript/src/components/plan/index.d.ts +238 -0
  64. package/lib/typescript/src/components/plan/index.d.ts.map +1 -0
  65. package/lib/typescript/src/components/popover/index.d.ts +35 -1
  66. package/lib/typescript/src/components/popover/index.d.ts.map +1 -1
  67. package/lib/typescript/src/components/post/index.d.ts +358 -0
  68. package/lib/typescript/src/components/post/index.d.ts.map +1 -0
  69. package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
  70. package/lib/typescript/src/components/reasoning/index.d.ts +97 -0
  71. package/lib/typescript/src/components/reasoning/index.d.ts.map +1 -0
  72. package/lib/typescript/src/components/response/index.d.ts +91 -0
  73. package/lib/typescript/src/components/response/index.d.ts.map +1 -0
  74. package/lib/typescript/src/components/response/markdown.d.ts +88 -0
  75. package/lib/typescript/src/components/response/markdown.d.ts.map +1 -0
  76. package/lib/typescript/src/components/select/index.d.ts +27 -2
  77. package/lib/typescript/src/components/select/index.d.ts.map +1 -1
  78. package/lib/typescript/src/components/sources/index.d.ts +85 -0
  79. package/lib/typescript/src/components/sources/index.d.ts.map +1 -0
  80. package/lib/typescript/src/components/table/index.d.ts +274 -0
  81. package/lib/typescript/src/components/table/index.d.ts.map +1 -0
  82. package/lib/typescript/src/components/task/index.d.ts +103 -0
  83. package/lib/typescript/src/components/task/index.d.ts.map +1 -0
  84. package/lib/typescript/src/components/textarea/index.d.ts +175 -0
  85. package/lib/typescript/src/components/textarea/index.d.ts.map +1 -0
  86. package/lib/typescript/src/components/tooltip/index.d.ts +63 -8
  87. package/lib/typescript/src/components/tooltip/index.d.ts.map +1 -1
  88. package/lib/typescript/src/icons/index.d.ts +54 -1
  89. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  90. package/lib/typescript/src/index.d.ts +14 -3
  91. package/lib/typescript/src/index.d.ts.map +1 -1
  92. package/lib/typescript/src/primitives/collapse.d.ts +42 -0
  93. package/lib/typescript/src/primitives/collapse.d.ts.map +1 -0
  94. package/lib/typescript/src/utils/date.d.ts +49 -5
  95. package/lib/typescript/src/utils/date.d.ts.map +1 -1
  96. package/package.json +1 -1
  97. package/src/components/calendar/index.tsx +519 -139
  98. package/src/components/code-block/highlight.ts +278 -0
  99. package/src/components/code-block/index.tsx +341 -0
  100. package/src/components/date-picker/index.tsx +19 -1
  101. package/src/components/heatmap-chart/index.tsx +9 -9
  102. package/src/components/map/index.tsx +53 -4
  103. package/src/components/menu/index.tsx +812 -0
  104. package/src/components/plan/index.tsx +648 -0
  105. package/src/components/popover/index.tsx +69 -2
  106. package/src/components/post/index.tsx +1116 -0
  107. package/src/components/radio-group/index.tsx +11 -2
  108. package/src/components/reasoning/index.tsx +297 -0
  109. package/src/components/response/index.tsx +390 -0
  110. package/src/components/response/markdown.ts +489 -0
  111. package/src/components/select/index.tsx +132 -12
  112. package/src/components/sources/index.tsx +278 -0
  113. package/src/components/table/index.tsx +747 -0
  114. package/src/components/task/index.tsx +329 -0
  115. package/src/components/textarea/index.tsx +381 -0
  116. package/src/components/tooltip/index.tsx +203 -20
  117. package/src/icons/index.tsx +264 -1
  118. package/src/index.ts +131 -0
  119. package/src/primitives/collapse.tsx +128 -0
  120. package/src/utils/date.ts +146 -22
  121. package/theme.css +112 -0
@@ -60,6 +60,7 @@ import Svg, { ClipPath, Defs, G, Line as SvgLine, Rect } from 'react-native-svg'
60
60
  import { useCSSVariable } from 'uniwind';
61
61
  import { Text } from '../../primitives/text';
62
62
  import { cn } from '../../utils/cn';
63
+ import { normalizeWeekStart, startOfDay } from '../../utils/date';
63
64
 
64
65
  const AnimatedRect = Animated.createAnimatedComponent(Rect);
65
66
 
@@ -225,12 +226,15 @@ export function buildHeatmapCalendar(
225
226
  entries: { date: Date; count: number }[],
226
227
  options: { start?: Date; end?: Date; weekStartDay?: number } = {}
227
228
  ): HeatmapColumn[] {
228
- const weekStartDay = options.weekStartDay ?? 0;
229
+ const weekStartDay = normalizeWeekStart(options.weekStartDay ?? 0);
229
230
  if (!entries.length && !options.start) return [];
230
231
 
231
232
  const times = entries.map((entry) => entry.date.getTime());
232
- const start = options.start ?? new Date(Math.min(...times));
233
- const end = options.end ?? new Date(Math.max(...times));
233
+ // Both bounds at local midnight, and both the same way. Comparing a
234
+ // normalised lower bound against a raw upper one drops the last day whenever
235
+ // the caller's `end` carries a time earlier than the cell being tested.
236
+ const start = startOfDay(options.start ?? new Date(Math.min(...times)));
237
+ const end = startOfDay(options.end ?? new Date(Math.max(...times)));
234
238
 
235
239
  const byDay = new Map<string, number>();
236
240
  for (const entry of entries) {
@@ -240,7 +244,7 @@ export function buildHeatmapCalendar(
240
244
 
241
245
  // Back up to the first day of the week the range starts in, so column 0 is a
242
246
  // whole week and every row lines up with a weekday for the rest of the chart.
243
- const cursor = new Date(start.getFullYear(), start.getMonth(), start.getDate());
247
+ const cursor = startOfDay(start);
244
248
  cursor.setDate(cursor.getDate() - ((cursor.getDay() - weekStartDay + 7) % 7));
245
249
 
246
250
  const columns: HeatmapColumn[] = [];
@@ -251,7 +255,7 @@ export function buildHeatmapCalendar(
251
255
  const date = new Date(cursor);
252
256
  // Before the range starts and after it ends the cell exists but has no
253
257
  // reading — `count: 0` and no date, so the tooltip stays quiet on it.
254
- const inRange = date >= startOfDay(start) && date <= end;
258
+ const inRange = date >= start && date <= end;
255
259
  column.push({
256
260
  bin: row,
257
261
  count: inRange ? (byDay.get(dayKey(date)) ?? 0) : 0,
@@ -269,10 +273,6 @@ export function buildHeatmapCalendar(
269
273
  return columns;
270
274
  }
271
275
 
272
- function startOfDay(date: Date) {
273
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
274
- }
275
-
276
276
  function dayKey(date: Date) {
277
277
  return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
278
278
  }
@@ -78,6 +78,11 @@ const mapVariants = tv({
78
78
  control: 'h-9 w-9 items-center justify-center active:bg-muted',
79
79
  popup: 'rounded-xl border border-border bg-popover px-3 py-2 shadow-lg',
80
80
  pin: 'h-3.5 w-3.5 rounded-full border-2 border-background bg-primary shadow-md',
81
+ // Opaque enough to read over a landmass fill, with an edge and a shadow so
82
+ // it sits on the map rather than in it. At 85% the basemap's own roads and
83
+ // borders showed through the text.
84
+ label: 'rounded-md border border-border bg-background/95 shadow-sm',
85
+ labelText: 'text-foreground',
81
86
  },
82
87
  variants: {
83
88
  position: {
@@ -90,6 +95,27 @@ const mapVariants = tv({
90
95
  defaultVariants: { position: 'bottom-right' },
91
96
  });
92
97
 
98
+ /**
99
+ * The two knobs on a label's pill.
100
+ *
101
+ * Lookups rather than `tv()` variants because they belong to `Map.Label`, not
102
+ * to `Map` — a variant here would be read off the root and documented as
103
+ * something you could pass to the map itself.
104
+ */
105
+ const labelSize: Record<'sm' | 'md', string> = {
106
+ sm: 'px-1.5 py-px',
107
+ md: 'px-2 py-0.5',
108
+ };
109
+
110
+ const labelTone: Record<'default' | 'muted' | 'primary', { pill: string; text: string }> = {
111
+ default: { pill: '', text: '' },
112
+ muted: { pill: '', text: 'text-muted-foreground' },
113
+ primary: {
114
+ pill: 'border-primary/24 bg-primary',
115
+ text: 'text-primary-foreground',
116
+ },
117
+ };
118
+
93
119
  export type MapControlsPosition =
94
120
  | 'top-left'
95
121
  | 'top-right'
@@ -445,6 +471,13 @@ export interface MapLabelProps {
445
471
  className?: string;
446
472
  /** Which side of the marker the label sits on. */
447
473
  side?: 'top' | 'bottom';
474
+ /** `sm` for a map carrying a lot of them, where the pills start to collide. */
475
+ size?: 'sm' | 'md';
476
+ /**
477
+ * How loud the label is. `muted` for codes and counts that support the map
478
+ * without being its subject; `primary` for the one place being pointed at.
479
+ */
480
+ tone?: 'default' | 'muted' | 'primary';
448
481
  }
449
482
 
450
483
  /**
@@ -460,19 +493,35 @@ export interface MapLabelProps {
460
493
  * without widening the marker — a name is usually far wider than the dot it
461
494
  * belongs to, and a box sized to the name would be anchored by the name.
462
495
  */
463
- function MapLabel({ children, className, side = 'bottom' }: MapLabelProps) {
496
+ function MapLabel({
497
+ children,
498
+ className,
499
+ side = 'bottom',
500
+ size = 'md',
501
+ tone = 'default',
502
+ }: MapLabelProps) {
503
+ const { label, labelText } = mapVariants();
504
+ const shade = labelTone[tone];
505
+
464
506
  return (
465
507
  <View
466
508
  pointerEvents="none"
467
509
  className={cn(
468
510
  'absolute items-center',
469
- side === 'top' ? 'bottom-full mb-1' : 'top-full mt-1'
511
+ // 6pt of clearance rather than 4: the pill has a border now, and at 4
512
+ // its edge and the pin's ring read as one smudged shape.
513
+ side === 'top' ? 'bottom-full mb-1.5' : 'top-full mt-1.5'
470
514
  )}
471
515
  style={{ left: -120, right: -120 }}
472
516
  >
473
- <View className={cn('rounded-md bg-background/85 px-1.5 py-0.5', className)}>
517
+ <View className={label({ className: cn(labelSize[size], shade.pill, className) })}>
474
518
  {textChildren(children, (text) => (
475
- <Text size="xs" weight="medium" numberOfLines={1}>
519
+ <Text
520
+ size="xs"
521
+ weight="medium"
522
+ numberOfLines={1}
523
+ className={labelText({ className: shade.text })}
524
+ >
476
525
  {text}
477
526
  </Text>
478
527
  ))}