@factorialco/f0-react 6.17.0 → 6.19.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.
@@ -172,9 +172,14 @@ declare const actionButtonVariants: readonly ["default", "outline", "critical",
172
172
 
173
173
  declare interface ActionCommonProps {
174
174
  /**
175
- * Tooltip
175
+ * Tooltip. A string is the description on its own; the object form adds a
176
+ * bold first line above it — for "which control this is" over "what it holds",
177
+ * the same two-line shape `F0Select`'s trigger tooltip uses.
176
178
  */
177
- tooltip?: string | false;
179
+ tooltip?: string | false | {
180
+ label?: string;
181
+ description: string;
182
+ };
178
183
  /**
179
184
  * The variant of the action.
180
185
  */
@@ -2332,9 +2337,10 @@ export declare const chipVariants: (props?: ({
2332
2337
  className?: ClassValue;
2333
2338
  })) | undefined) => string;
2334
2339
 
2335
- export declare function ClockInControls({ trackedMinutes, remainingMinutes, data, labels, locationId, locations, canShowLocation, locationSelectorDisabled, onClockIn, onClockOut, onBreak, breakTypes, onChangeBreakTypeId, canShowBreakButton, canSeeGraph, canSeeRemainingTime, onChangeLocationId, canShowProject, projectSelectorElement, locationSelectorElement, breakTypeName, }: ClockInControlsProps): JSX_2.Element;
2340
+ export declare function ClockInControls({ trackedMinutes, remainingMinutes, data, labels, locationId, locations, canShowLocation, locationSelectorDisabled, onClockIn, onClockOut, onBreak, breakTypes, onChangeBreakTypeId, canShowBreakButton, canSeeGraph, canSeeRemainingTime, onChangeLocationId, canShowProject, projectSelectorElement, locationSelectorElement, projects, projectId, onChangeProjectId, projectSelectorDisabled, projectRequired, locationRequired, breakTypeName, onBreakPromote, variant, loading, }: ClockInControlsProps): JSX_2.Element;
2336
2341
 
2337
- export declare interface ClockInControlsProps {
2342
+ /** Everything both variants take, on the same terms. */
2343
+ declare interface ClockInControlsBaseProps {
2338
2344
  /** Optional remaining time in minutes */
2339
2345
  remainingMinutes?: number;
2340
2346
  /** Clock in entries data */
@@ -2356,14 +2362,26 @@ export declare interface ClockInControlsProps {
2356
2362
  selectProject: string;
2357
2363
  paid: string;
2358
2364
  unpaid: string;
2365
+ /**
2366
+ * Placeholders for the pickers' search boxes (`horizontal-bar` only).
2367
+ * Optional: without them the pickers fall back to F0Select's own wording.
2368
+ */
2369
+ searchProject?: string;
2370
+ searchLocation?: string;
2359
2371
  };
2372
+ /** The selected location — a leaf, when the list nests. */
2360
2373
  locationId?: string;
2361
2374
  onChangeLocationId: Dispatch<string>;
2362
- locations: {
2363
- id: string;
2364
- name: string;
2365
- icon: IconType;
2366
- }[];
2375
+ /**
2376
+ * The locations to offer. Each may carry `sublocations`, two or three levels
2377
+ * deep (location → workplace → work area), and selection is then a leaf.
2378
+ *
2379
+ * Nesting is drawn by the `horizontal-bar` variant, which owns its picker. The
2380
+ * `default` variant's built-in select is flat and offers only the top level — it
2381
+ * has `locationSelectorElement` for a consumer's own drill-in instead — though
2382
+ * it still DISPLAYS a selected leaf wherever it sits in the tree.
2383
+ */
2384
+ locations: ClockInLocation[];
2367
2385
  breakTypes?: BreakType[];
2368
2386
  onChangeBreakTypeId?: Dispatch<string>;
2369
2387
  canShowLocation?: boolean;
@@ -2378,7 +2396,36 @@ export declare interface ClockInControlsProps {
2378
2396
  /** Callback when Break button is clicked */
2379
2397
  onBreak?: (breakTypeId?: string) => void;
2380
2398
  canShowProject?: boolean;
2381
- projectSelectorElement?: React.ReactNode;
2399
+ breakTypeName?: string;
2400
+ /**
2401
+ * On a break, which action gets the primary button — the other becomes an
2402
+ * icon-only outline beside it.
2403
+ *
2404
+ * Unset, it follows the day: `"clock-out"` once you're into overtime (the hours
2405
+ * are done, so ending them is the useful move), `"resume"` while there are hours
2406
+ * left. Set it to pin one regardless.
2407
+ */
2408
+ onBreakPromote?: "resume" | "clock-out";
2409
+ /**
2410
+ * Draws a placeholder shaped like the chosen `variant` instead of the
2411
+ * controls — for when the day itself hasn't arrived yet. Prefer it over
2412
+ * rendering a zeroed-out day: `trackedMinutes={0}` with no `data` is a real
2413
+ * state ("clocked out, nothing tracked"), not a missing one.
2414
+ */
2415
+ loading?: boolean;
2416
+ }
2417
+
2418
+ /**
2419
+ * The `default` variant, where the consumer may bring its OWN location and
2420
+ * project controls as nodes: this is the arrangement Factorial already ships,
2421
+ * and both slots are in use (e.g. a drill-in location selector).
2422
+ */
2423
+ declare interface ClockInControlsDefaultProps extends ClockInControlsBaseProps {
2424
+ /**
2425
+ * The status and its controls beside the circular `ClockInGraph`, with the
2426
+ * location/project row underneath.
2427
+ */
2428
+ variant?: "default";
2382
2429
  /**
2383
2430
  * Optional custom location control. When provided, it replaces the built-in
2384
2431
  * flat location `F0Select` (in both the editable clocked-out state and the
@@ -2387,19 +2434,130 @@ export declare interface ClockInControlsProps {
2387
2434
  * owns its data and editable/disabled state, mirroring `projectSelectorElement`.
2388
2435
  */
2389
2436
  locationSelectorElement?: React.ReactNode;
2390
- breakTypeName?: string;
2437
+ projectSelectorElement?: React.ReactNode;
2438
+ projects?: never;
2439
+ projectId?: never;
2440
+ onChangeProjectId?: never;
2441
+ projectSelectorDisabled?: never;
2442
+ /** Only the `horizontal-bar` variant owns the pickers, so only it can relax them. */
2443
+ projectRequired?: never;
2444
+ locationRequired?: never;
2391
2445
  }
2392
2446
 
2447
+ /**
2448
+ * The `horizontal-bar` variant, which owns BOTH selectors.
2449
+ *
2450
+ * The custom-render slots are typed away here (`never`) on purpose: this
2451
+ * arrangement puts the two pickers on one line with the day's controls, and a
2452
+ * consumer-supplied node in either slot is what would break that line — so it
2453
+ * takes DATA instead and renders the pickers itself. Location becomes an
2454
+ * `F0ButtonDropdown`, projects an `F0Select` whose groups are the subprojects.
2455
+ */
2456
+ declare interface ClockInControlsHorizontalBarProps extends ClockInControlsBaseProps {
2457
+ /**
2458
+ * The Home-widget shape from the custom-home prototype: four full-width rows,
2459
+ * each pinning its two halves to the tile's ends — status + running total on
2460
+ * one line, the day as a horizontal bar, when it started and what is left of
2461
+ * it, then the location and the controls. Fits a narrow rail, where the 160px
2462
+ * ring does not.
2463
+ */
2464
+ variant: "horizontal-bar";
2465
+ /** Not available in this variant — pass `locations` and let it render them. */
2466
+ locationSelectorElement?: never;
2467
+ /** Not available in this variant — pass `projects` and let it render them. */
2468
+ projectSelectorElement?: never;
2469
+ /** The projects to offer, each optionally with its own subprojects. */
2470
+ projects?: ClockInProject[];
2471
+ /** The selected project — or subproject, since selection is always a leaf. */
2472
+ projectId?: string;
2473
+ onChangeProjectId?: Dispatch<string>;
2474
+ projectSelectorDisabled?: boolean;
2475
+ /**
2476
+ * Whether a project must be chosen to clock in. When it isn't, the picker
2477
+ * offers a clear affordance and reports the empty string once cleared.
2478
+ * Defaults to `true` — the stricter reading, and the behaviour before there
2479
+ * was any way to clear.
2480
+ */
2481
+ projectRequired?: boolean;
2482
+ /** The same for the location. Defaults to `true`. */
2483
+ locationRequired?: boolean;
2484
+ }
2485
+
2486
+ export declare type ClockInControlsProps = ClockInControlsDefaultProps | ClockInControlsHorizontalBarProps;
2487
+
2488
+ /**
2489
+ * How the pieces are laid out. Both variants show the same day, run the same
2490
+ * state machine and use the same controls — only their arrangement differs.
2491
+ */
2492
+ export declare type ClockInControlsVariant = "default" | "horizontal-bar";
2493
+
2393
2494
  declare interface ClockInGraphProps {
2394
2495
  trackedMinutes?: number;
2395
2496
  data?: {
2396
2497
  from: Date;
2397
2498
  to: Date;
2398
2499
  variant: ClockInStatus;
2500
+ /**
2501
+ * EXTRA context for this stretch of the day, beyond its state — which break,
2502
+ * which task.
2503
+ *
2504
+ * The `horizontal-bar` geometry already tells you when a stretch ran and how
2505
+ * long it lasted when you hover it; this is appended after a `•`, so pass only
2506
+ * what that doesn't already say. The ring has nowhere to put either and
2507
+ * ignores them.
2508
+ */
2509
+ label?: string;
2399
2510
  }[];
2400
2511
  remainingMinutes?: number;
2512
+ /**
2513
+ * - `ring` — the 160px dial, with the running total and the day's two ends
2514
+ * inside it.
2515
+ * - `horizontal-bar` — the same day as a full-width 6px rail, and nothing
2516
+ * else: a line that thin has nowhere to put the numbers, so in this variant
2517
+ * the layout around it carries them (see `ClockInControls`).
2518
+ */
2519
+ variant?: ClockInGraphVariant;
2401
2520
  }
2402
2521
 
2522
+ /**
2523
+ * The geometry the day is drawn in. Same segments, same colours, same
2524
+ * `normalizeData` either way — only the shape differs.
2525
+ */
2526
+ declare type ClockInGraphVariant = "ring" | "horizontal-bar";
2527
+
2528
+ /**
2529
+ * A place you can clock in from, and — optionally — the places INSIDE it.
2530
+ *
2531
+ * Up to two or three levels is what this is for: location → workplace → work
2532
+ * area (Office → Barcelona → Llucuna A-3). Selection is always a LEAF: a location
2533
+ * with `sublocations` is clocked into through one of them, one without is clocked
2534
+ * into directly. The icon is usually only worth setting at the top (Office, Home,
2535
+ * Business trip) — deeper levels inherit the nearest one above them.
2536
+ */
2537
+ export declare type ClockInLocation = {
2538
+ id: string;
2539
+ name: string;
2540
+ icon?: IconType;
2541
+ /** The level below. When present, this location itself is not selectable. */
2542
+ sublocations?: ClockInLocation[];
2543
+ };
2544
+
2545
+ /**
2546
+ * A project as the `horizontal-bar` variant takes it, and — optionally — the work
2547
+ * inside it.
2548
+ *
2549
+ * Selection is always a LEAF: a project with `subprojects` is booked through one
2550
+ * of them, a project without them is booked directly. That rule is what lets the
2551
+ * picker show the hierarchy with F0Select's own group headings rather than an
2552
+ * invented indent — a parent is a heading, not an option.
2553
+ */
2554
+ export declare type ClockInProject = {
2555
+ id: string;
2556
+ name: string;
2557
+ /** The level below. When present, the parent itself is not selectable. */
2558
+ subprojects?: ClockInProject[];
2559
+ };
2560
+
2403
2561
  declare type ClockInStatus = "clocked-in" | "break" | "clocked-out";
2404
2562
 
2405
2563
  /**
@@ -6972,6 +7130,15 @@ declare type F0SelectItemObject<T, R = unknown> = {
6972
7130
  type?: "item";
6973
7131
  value: T;
6974
7132
  label: string;
7133
+ /**
7134
+ * What the TRIGGER shows once this item is selected, when that has to differ
7135
+ * from the row's own `label`. The row is read in the context the list gives it
7136
+ * — under a group header, beside its siblings — and the trigger has none of
7137
+ * that, so a label that is clear in the list can be ambiguous on its own
7138
+ * ("Tokens", once the "Design system" header is gone). Give the trigger the
7139
+ * full path there and leave the row short. Defaults to `label`.
7140
+ */
7141
+ selectedLabel?: string;
6975
7142
  description?: string;
6976
7143
  /** Short token shown next to the label (e.g. a dial code) */
6977
7144
  metadata?: F0SelectItemMetadata;