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.
- package/README.md +22 -3
- package/lib/module/components/calendar/index.js +450 -132
- package/lib/module/components/calendar/index.js.map +1 -1
- package/lib/module/components/code-block/highlight.js +363 -0
- package/lib/module/components/code-block/highlight.js.map +1 -0
- package/lib/module/components/code-block/index.js +313 -0
- package/lib/module/components/code-block/index.js.map +1 -0
- package/lib/module/components/date-picker/index.js +8 -1
- package/lib/module/components/date-picker/index.js.map +1 -1
- package/lib/module/components/heatmap-chart/index.js +9 -8
- package/lib/module/components/heatmap-chart/index.js.map +1 -1
- package/lib/module/components/map/index.js +50 -4
- package/lib/module/components/map/index.js.map +1 -1
- package/lib/module/components/menu/index.js +714 -0
- package/lib/module/components/menu/index.js.map +1 -0
- package/lib/module/components/plan/index.js +582 -0
- package/lib/module/components/plan/index.js.map +1 -0
- package/lib/module/components/popover/index.js +35 -4
- package/lib/module/components/popover/index.js.map +1 -1
- package/lib/module/components/post/index.js +992 -0
- package/lib/module/components/post/index.js.map +1 -0
- package/lib/module/components/radio-group/index.js +13 -8
- package/lib/module/components/radio-group/index.js.map +1 -1
- package/lib/module/components/reasoning/index.js +244 -0
- package/lib/module/components/reasoning/index.js.map +1 -0
- package/lib/module/components/response/index.js +296 -0
- package/lib/module/components/response/index.js.map +1 -0
- package/lib/module/components/response/markdown.js +463 -0
- package/lib/module/components/response/markdown.js.map +1 -0
- package/lib/module/components/select/index.js +97 -15
- package/lib/module/components/select/index.js.map +1 -1
- package/lib/module/components/sources/index.js +221 -0
- package/lib/module/components/sources/index.js.map +1 -0
- package/lib/module/components/table/index.js +632 -0
- package/lib/module/components/table/index.js.map +1 -0
- package/lib/module/components/task/index.js +300 -0
- package/lib/module/components/task/index.js.map +1 -0
- package/lib/module/components/textarea/index.js +295 -0
- package/lib/module/components/textarea/index.js.map +1 -0
- package/lib/module/components/tooltip/index.js +179 -23
- package/lib/module/components/tooltip/index.js.map +1 -1
- package/lib/module/icons/index.js +339 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +12 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/primitives/collapse.js +112 -0
- package/lib/module/primitives/collapse.js.map +1 -0
- package/lib/module/utils/date.js +129 -22
- package/lib/module/utils/date.js.map +1 -1
- package/lib/typescript/src/components/calendar/index.d.ts +79 -5
- package/lib/typescript/src/components/calendar/index.d.ts.map +1 -1
- package/lib/typescript/src/components/code-block/highlight.d.ts +39 -0
- package/lib/typescript/src/components/code-block/highlight.d.ts.map +1 -0
- package/lib/typescript/src/components/code-block/index.d.ts +113 -0
- package/lib/typescript/src/components/code-block/index.d.ts.map +1 -0
- package/lib/typescript/src/components/date-picker/index.d.ts +7 -1
- package/lib/typescript/src/components/date-picker/index.d.ts.map +1 -1
- package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/index.d.ts +8 -1
- package/lib/typescript/src/components/map/index.d.ts.map +1 -1
- package/lib/typescript/src/components/menu/index.d.ts +261 -0
- package/lib/typescript/src/components/menu/index.d.ts.map +1 -0
- package/lib/typescript/src/components/plan/index.d.ts +238 -0
- package/lib/typescript/src/components/plan/index.d.ts.map +1 -0
- package/lib/typescript/src/components/popover/index.d.ts +35 -1
- package/lib/typescript/src/components/popover/index.d.ts.map +1 -1
- package/lib/typescript/src/components/post/index.d.ts +358 -0
- package/lib/typescript/src/components/post/index.d.ts.map +1 -0
- package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/reasoning/index.d.ts +97 -0
- package/lib/typescript/src/components/reasoning/index.d.ts.map +1 -0
- package/lib/typescript/src/components/response/index.d.ts +91 -0
- package/lib/typescript/src/components/response/index.d.ts.map +1 -0
- package/lib/typescript/src/components/response/markdown.d.ts +88 -0
- package/lib/typescript/src/components/response/markdown.d.ts.map +1 -0
- package/lib/typescript/src/components/select/index.d.ts +27 -2
- package/lib/typescript/src/components/select/index.d.ts.map +1 -1
- package/lib/typescript/src/components/sources/index.d.ts +85 -0
- package/lib/typescript/src/components/sources/index.d.ts.map +1 -0
- package/lib/typescript/src/components/table/index.d.ts +274 -0
- package/lib/typescript/src/components/table/index.d.ts.map +1 -0
- package/lib/typescript/src/components/task/index.d.ts +103 -0
- package/lib/typescript/src/components/task/index.d.ts.map +1 -0
- package/lib/typescript/src/components/textarea/index.d.ts +175 -0
- package/lib/typescript/src/components/textarea/index.d.ts.map +1 -0
- package/lib/typescript/src/components/tooltip/index.d.ts +63 -8
- package/lib/typescript/src/components/tooltip/index.d.ts.map +1 -1
- package/lib/typescript/src/icons/index.d.ts +54 -1
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +14 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/collapse.d.ts +42 -0
- package/lib/typescript/src/primitives/collapse.d.ts.map +1 -0
- package/lib/typescript/src/utils/date.d.ts +49 -5
- package/lib/typescript/src/utils/date.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/calendar/index.tsx +519 -139
- package/src/components/code-block/highlight.ts +278 -0
- package/src/components/code-block/index.tsx +341 -0
- package/src/components/date-picker/index.tsx +19 -1
- package/src/components/heatmap-chart/index.tsx +9 -9
- package/src/components/map/index.tsx +53 -4
- package/src/components/menu/index.tsx +812 -0
- package/src/components/plan/index.tsx +648 -0
- package/src/components/popover/index.tsx +69 -2
- package/src/components/post/index.tsx +1116 -0
- package/src/components/radio-group/index.tsx +11 -2
- package/src/components/reasoning/index.tsx +297 -0
- package/src/components/response/index.tsx +390 -0
- package/src/components/response/markdown.ts +489 -0
- package/src/components/select/index.tsx +132 -12
- package/src/components/sources/index.tsx +278 -0
- package/src/components/table/index.tsx +747 -0
- package/src/components/task/index.tsx +329 -0
- package/src/components/textarea/index.tsx +381 -0
- package/src/components/tooltip/index.tsx +203 -20
- package/src/icons/index.tsx +264 -1
- package/src/index.ts +131 -0
- package/src/primitives/collapse.tsx +128 -0
- package/src/utils/date.ts +146 -22
- 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
|
-
|
|
233
|
-
|
|
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 =
|
|
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 >=
|
|
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({
|
|
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
|
-
|
|
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={
|
|
517
|
+
<View className={label({ className: cn(labelSize[size], shade.pill, className) })}>
|
|
474
518
|
{textChildren(children, (text) => (
|
|
475
|
-
<Text
|
|
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
|
))}
|