@factorialco/f0-react 1.294.0 → 1.295.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/dist/f0.d.ts CHANGED
@@ -1319,7 +1319,7 @@ export declare type DataSourceDefinition<R extends RecordType = RecordType, Filt
1319
1319
  /** Selectable items value under the checkbox column (undefined if not selectable) */
1320
1320
  selectable?: (item: R) => string | number | undefined;
1321
1321
  /** Default selected items */
1322
- defaultSelectedItems?: SelectedItemsState;
1322
+ defaultSelectedItems?: SelectedItemsState<R>;
1323
1323
  /***** GROUPING ***************************************************/
1324
1324
  /** Grouping configuration */
1325
1325
  grouping?: Grouping;
@@ -1595,6 +1595,7 @@ export declare const defaultTranslations: {
1595
1595
  readonly selected: {
1596
1596
  readonly singular: "Selected";
1597
1597
  readonly plural: "Selected";
1598
+ readonly all: "All selected";
1598
1599
  };
1599
1600
  };
1600
1601
  readonly filters: {
@@ -2394,6 +2395,26 @@ export declare const F0Select: <T extends string = string, R = unknown>(props: F
2394
2395
  ref?: React.Ref<HTMLButtonElement>;
2395
2396
  }) => React.ReactElement;
2396
2397
 
2398
+ /**
2399
+ * Base props shared across all F0Select variants
2400
+ */
2401
+ declare type F0SelectBaseProps<T extends string, R = unknown> = {
2402
+ onChangeSelectedOption?: (option: F0SelectItemObject<T, ResolvedRecordType<R>> | undefined, checked: boolean) => void;
2403
+ children?: React.ReactNode;
2404
+ open?: boolean;
2405
+ showSearchBox?: boolean;
2406
+ searchBoxPlaceholder?: string;
2407
+ onSearchChange?: (value: string) => void;
2408
+ searchValue?: string;
2409
+ onOpenChange?: (open: boolean) => void;
2410
+ searchEmptyMessage?: string;
2411
+ className?: string;
2412
+ selectContentClassName?: string;
2413
+ actions?: Action_2[];
2414
+ /** Container element to render the portal content into */
2415
+ portalContainer?: HTMLElement | null;
2416
+ };
2417
+
2397
2418
  export declare type F0SelectItemObject<T, R = unknown> = {
2398
2419
  type?: "item";
2399
2420
  value: T;
@@ -2413,42 +2434,43 @@ export declare type F0SelectItemProps<T, R = unknown> = F0SelectItemObject<T, R>
2413
2434
  /**
2414
2435
  * Select component for choosing from a list of options.
2415
2436
  *
2416
- * @template T - The type of the emitted value
2437
+ * @template T - The type of the emitted value
2417
2438
  * @template R - The type of the record/item data (used with data source)
2418
- *
2419
2439
  */
2420
- export declare type F0SelectProps<T extends string, R = unknown> = {
2421
- onChangeSelectedOption?: (option: F0SelectItemObject<T, ResolvedRecordType<R>> | undefined, checked: boolean) => void;
2422
- children?: React.ReactNode;
2423
- open?: boolean;
2424
- showSearchBox?: boolean;
2425
- searchBoxPlaceholder?: string;
2426
- onSearchChange?: (value: string) => void;
2427
- searchValue?: string;
2428
- onOpenChange?: (open: boolean) => void;
2429
- searchEmptyMessage?: string;
2430
- className?: string;
2431
- selectContentClassName?: string;
2432
- actions?: Action_2[];
2433
- portalContainer?: HTMLElement | null;
2434
- } & ({
2440
+ export declare type F0SelectProps<T extends string, R = unknown> = F0SelectBaseProps<T, R> & // Single select not clearable
2441
+ ({
2435
2442
  clearable?: false;
2436
2443
  multiple?: false;
2437
2444
  value?: T;
2438
2445
  defaultItem?: F0SelectItemObject<T, ResolvedRecordType<R>>;
2439
2446
  onChange?: (value: T, originalItem?: ResolvedRecordType<R> | undefined, option?: F0SelectItemObject<T, ResolvedRecordType<R>>) => void;
2447
+ /** Callback for selection changes - provides full selection state for advanced use cases (e.g., "Select All" with exclusions) */
2448
+ onSelectItems?: never;
2440
2449
  } | {
2441
2450
  clearable: true;
2442
2451
  multiple?: false;
2443
2452
  value?: T;
2444
2453
  defaultItem?: F0SelectItemObject<T, ResolvedRecordType<R>>;
2445
2454
  onChange?: (value: T, originalItem?: ResolvedRecordType<R> | undefined, option?: F0SelectItemObject<T, ResolvedRecordType<R>>) => void;
2455
+ onSelectItems?: never;
2446
2456
  } | {
2447
2457
  multiple: true;
2448
2458
  clearable?: boolean;
2449
2459
  value?: T[];
2450
2460
  defaultItem?: F0SelectItemObject<T, ResolvedRecordType<R>>[];
2451
2461
  onChange?: (value: T[], originalItems: ResolvedRecordType<R>[], options: F0SelectItemObject<T, ResolvedRecordType<R>>[]) => void;
2462
+ /**
2463
+ * Callback for selection changes - provides full selection state including:
2464
+ * - `status.allSelected`: true if "Select All" was used, "indeterminate" if some items deselected after Select All
2465
+ * - `status.items`: Map of all items with their checked state
2466
+ * - `filters`: Current applied filters
2467
+ * - `selectedCount`: Total number of selected items
2468
+ *
2469
+ * Use this for "chunked" selection mode where you need to track:
2470
+ * - When allSelected is true/indeterminate: excluded items are those with checked=false
2471
+ * - When allSelected is false: included items are those with checked=true
2472
+ */
2473
+ onSelectItems?: OnSelectItemsCallback<ResolvedRecordType<R>, FiltersDefinition>;
2452
2474
  }) & ({
2453
2475
  source: DataSourceDefinition<ResolvedRecordType<R>, FiltersDefinition, SortingsDefinition, GroupingDefinition<ResolvedRecordType<R>>>;
2454
2476
  mapOptions: (item: ResolvedRecordType<R>) => F0SelectItemProps<T, ResolvedRecordType<R>>;
@@ -3707,10 +3729,13 @@ export declare type SelectedItems<T> = ReadonlyArray<T>;
3707
3729
 
3708
3730
  export declare type SelectedItemsDetailedStatus<R extends RecordType, Filters extends FiltersDefinition> = {
3709
3731
  allSelected: boolean | "indeterminate";
3732
+ /** Status of items that have been loaded. Items not yet loaded won't appear here. */
3710
3733
  itemsStatus: ReadonlyArray<{
3711
3734
  item: R;
3712
3735
  checked: boolean;
3713
3736
  }>;
3737
+ /** All selected item IDs, including those not yet loaded */
3738
+ selectedIds: ReadonlyArray<SelectionId>;
3714
3739
  groupsStatus: Record<string, boolean>;
3715
3740
  filters: FiltersState<Filters>;
3716
3741
  selectedCount: number;
@@ -3719,16 +3744,45 @@ export declare type SelectedItemsDetailedStatus<R extends RecordType, Filters ex
3719
3744
  /**
3720
3745
  * Represents the selected items by id
3721
3746
  */
3722
- export declare type SelectedItemsState = {
3723
- allSelected?: boolean | "indeterminate";
3724
- items?: ReadonlyArray<{
3725
- id: string;
3726
- checked: boolean;
3727
- }>;
3728
- groups?: ReadonlyArray<{
3729
- groupId: string;
3747
+ export declare type SelectedItemsState<R extends RecordType> = {
3748
+ allSelected: boolean | "indeterminate";
3749
+ items: Map<SelectedItemState<R>["id"], SelectedItemState<R>>;
3750
+ groups: Map<SelectedState["id"], SelectedState>;
3751
+ };
3752
+
3753
+ export declare type SelectedItemState<R extends RecordType> = SelectedState & {
3754
+ item?: WithGroupId<R>;
3755
+ };
3756
+
3757
+ export declare type SelectedState = {
3758
+ id: SelectionId;
3759
+ checked: boolean;
3760
+ };
3761
+
3762
+ export declare type SelectionId = number | string;
3763
+
3764
+ export declare type SelectionMeta<R extends RecordType> = {
3765
+ selectedItemsCount: number;
3766
+ totalKnownItemsCount: number;
3767
+ checkedItems: ReadonlyArray<R>;
3768
+ uncheckedItems: ReadonlyArray<R>;
3769
+ };
3770
+
3771
+ export declare type SelectionStatus<R extends RecordType, Filters extends FiltersDefinition> = {
3772
+ allChecked: boolean | "indeterminate";
3773
+ /** Status of items that have been loaded. Items not yet loaded won't appear here. */
3774
+ itemsStatus: ReadonlyArray<{
3775
+ item: R;
3730
3776
  checked: boolean;
3731
3777
  }>;
3778
+ /** All selected item IDs, including those not yet loaded */
3779
+ selectedIds: ReadonlyArray<SelectionId>;
3780
+ checkedItems: ReadonlyArray<R>;
3781
+ uncheckedItems: ReadonlyArray<R>;
3782
+ groupsStatus: Record<string, boolean>;
3783
+ filters: FiltersState<Filters>;
3784
+ selectedCount: number;
3785
+ totalKnownItemsCount: number;
3732
3786
  };
3733
3787
 
3734
3788
  export declare const selectSizes: readonly ["sm", "md"];
@@ -4399,20 +4453,55 @@ export declare const usePrivacyMode: () => {
4399
4453
 
4400
4454
  export declare const useReducedMotion: () => boolean;
4401
4455
 
4402
- export declare type UseSelectable<R extends RecordType> = {
4456
+ export declare function useSelectable<R extends RecordType, Filters extends FiltersDefinition, Sortings extends SortingsDefinition, Grouping extends GroupingDefinition<R>>({ data, paginationInfo, source, selectionMode, selectedState, onSelectItems, }: UseSelectableProps<R, Filters, Sortings, Grouping>): UseSelectableReturn<R, Filters>;
4457
+
4458
+ export declare type UseSelectableProps<R extends RecordType, Filters extends FiltersDefinition, Sortings extends SortingsDefinition, Grouping extends GroupingDefinition<R>> = {
4459
+ data: Data<R>;
4460
+ paginationInfo: PaginationInfo | null;
4461
+ source: DataSourceDefinition<R, Filters, Sortings, Grouping>;
4462
+ onSelectItems?: OnSelectItemsCallback<R, Filters>;
4463
+ selectionMode?: "multi" | "single";
4464
+ selectedState?: SelectedItemsState<R>;
4465
+ };
4466
+
4467
+ export declare type UseSelectableReturn<R extends RecordType, Filters extends FiltersDefinition> = {
4403
4468
  isAllSelected: boolean;
4404
- selectedItems: Map<number | string, R>;
4405
- selectedGroups: Map<string, GroupRecord<R>>;
4469
+ selectedItems: Map<SelectionId, R>;
4470
+ selectedGroups: Map<SelectionId, GroupRecord<R>>;
4406
4471
  isPartiallySelected: boolean;
4407
- handleSelectItemChange: (item: R, checked: boolean) => void;
4408
- handleSelectAll: (checked: boolean) => void;
4409
- handleSelectGroupChange: (group: GroupRecord<R>, checked: boolean) => void;
4410
- groupAllSelectedStatus: Record<string, AllSelectionStatus>;
4472
+ groupAllSelectedStatus: Record<SelectionId, AllSelectionStatus>;
4411
4473
  allSelectedStatus: AllSelectionStatus;
4474
+ selectionStatus: SelectionStatus<R, Filters>;
4475
+ /**
4476
+ * The current selected state
4477
+ */
4478
+ selectedState: SelectedItemsState<R>;
4479
+ /**
4480
+ * The meta data about the selection
4481
+ */
4482
+ selectionMeta: SelectionMeta<R>;
4483
+ /**
4484
+ * Clears the selection
4485
+ */
4486
+ clearSelection: () => void;
4487
+ /**
4488
+ * Handles the change of the selected item.
4489
+ * Accepts either SelectionId(s) or the item itself (R).
4490
+ * When passing an item, the ID will be extracted using source.selectable.
4491
+ */
4492
+ handleSelectItemChange: (itemOrId: R | SelectionId | readonly SelectionId[], checked: boolean) => void;
4493
+ /**
4494
+ * Handles the change of the selected all items
4495
+ */
4496
+ handleSelectAll: (checked: boolean) => void;
4497
+ /**
4498
+ * Handles the change of the selected group.
4499
+ * Accepts either SelectionId(s) or a GroupRecord.
4500
+ * When passing a GroupRecord, the key will be used as the ID.
4501
+ */
4502
+ handleSelectGroupChange: (groupOrId: GroupRecord<R> | SelectionId | readonly SelectionId[], checked: boolean) => void;
4412
4503
  };
4413
4504
 
4414
- export declare function useSelectable<R extends RecordType, Filters extends FiltersDefinition, Sortings extends SortingsDefinition, Grouping extends GroupingDefinition<R>>(data: Data<R>, paginationInfo: PaginationInfo | null, source: DataSourceDefinition<R, Filters, Sortings, Grouping>, onSelectItems: OnSelectItemsCallback<R, Filters> | undefined, defaultSelectedItems?: SelectedItemsState | undefined): UseSelectable<R>;
4415
-
4416
4505
  export declare const useXRay: () => {
4417
4506
  enabled: boolean;
4418
4507
  filter: ComponentTypes[];
@@ -4527,31 +4616,6 @@ declare global {
4527
4616
  }
4528
4617
 
4529
4618
 
4530
- declare module "gridstack" {
4531
- interface GridStackWidget {
4532
- id?: string;
4533
- allowedSizes?: Array<{
4534
- w: number;
4535
- h: number;
4536
- }>;
4537
- renderFn?: () => React.ReactElement | null;
4538
- meta?: Record<string, unknown>;
4539
- }
4540
- interface GridStackNode {
4541
- id?: string;
4542
- w?: number;
4543
- h?: number;
4544
- x?: number;
4545
- y?: number;
4546
- allowedSizes?: Array<{
4547
- w: number;
4548
- h: number;
4549
- }>;
4550
- renderFn?: () => React.ReactElement | null;
4551
- }
4552
- }
4553
-
4554
-
4555
4619
  declare module "@tiptap/core" {
4556
4620
  interface Commands<ReturnType> {
4557
4621
  aiBlock: {
@@ -4579,6 +4643,31 @@ declare module "@tiptap/core" {
4579
4643
  }
4580
4644
 
4581
4645
 
4646
+ declare module "gridstack" {
4647
+ interface GridStackWidget {
4648
+ id?: string;
4649
+ allowedSizes?: Array<{
4650
+ w: number;
4651
+ h: number;
4652
+ }>;
4653
+ renderFn?: () => React.ReactElement | null;
4654
+ meta?: Record<string, unknown>;
4655
+ }
4656
+ interface GridStackNode {
4657
+ id?: string;
4658
+ w?: number;
4659
+ h?: number;
4660
+ x?: number;
4661
+ y?: number;
4662
+ allowedSizes?: Array<{
4663
+ w: number;
4664
+ h: number;
4665
+ }>;
4666
+ renderFn?: () => React.ReactElement | null;
4667
+ }
4668
+ }
4669
+
4670
+
4582
4671
  declare namespace Calendar {
4583
4672
  var displayName: string;
4584
4673
  }
package/dist/f0.js CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Ge, a as Kt, f as Ce, L as J, b as Vt, A as qt, i as ae, c as tt, d as it, E as Xt, g as he, e as Yt, h as Jt, C as Zt, j as Qt, k as V, l as st, u as ei, G as ti, m as ii, n as $e, o as si, p as rt, q as ri, B as nt, X as ot, Y as ze, r as ni, s as at, t as oi, v as ai, w as li, x as hi, y as di, z as ci, D as ui, F as fi, H as Ue, I as gi, J as Z, K as Ne, M as pi, N as mi, O as vi, P as lt, Q as L, R as F, T as yi, U as bi, V as xi, W as _i, Z as wi, _ as Ei, $ as Ci, a0 as ht, a1 as Ni, a2 as de, a3 as dt, a4 as ct, a5 as Ri, a6 as ut, a7 as ft, a8 as gt, a9 as pt, aa as zi, ab as Di, ac as mt, ad as Pi, ae as Si, af as vt, ag as ki, ah as yt, ai as Oi, aj as Ai, ak as Ti, al as Li, am as Mi, an as Hi, ao as Bi, ap as Fi, aq as bt, ar as q, as as xt, at as Ii, au as Wi, av as je, aw as Gi, ax as _t, ay as $i, az as Ui, aA as ji, aB as Ki, aC as Vi, aD as qi, aE as Xi, aF as Yi, aG as Ji, aH as Zi, aI as Qi, aJ as es } from "./hooks-B9lijBjS.js";
2
- import { bc as Fr, bp as Ir, by as Wr, aK as Gr, aL as $r, aM as Ur, aN as jr, aO as Kr, aP as Vr, aQ as qr, aR as Xr, aT as Yr, aU as Jr, aV as Zr, aW as Qr, aX as en, aY as tn, aZ as sn, bu as rn, a$ as nn, b0 as on, b3 as an, b4 as ln, b5 as hn, b6 as dn, b9 as cn, ba as un, bb as fn, be as gn, b2 as pn, bd as mn, b8 as vn, bv as yn, bo as bn, bj as xn, bm as _n, bi as wn, bz as En, bh as Cn, bg as Nn, aS as Rn, a_ as zn, b1 as Dn, b7 as Pn, bf as Sn, bk as kn, bq as On, br as An, bs as Tn, bA as Ln, bl as Mn, bt as Hn, bx as Bn, bn as Fn, bw as In } from "./hooks-B9lijBjS.js";
1
+ import { S as Ge, a as Kt, f as Ce, L as J, b as Vt, A as qt, i as ae, c as tt, d as it, E as Xt, g as he, e as Yt, h as Jt, C as Zt, j as Qt, k as V, l as st, u as ei, G as ti, m as ii, n as $e, o as si, p as rt, q as ri, B as nt, X as ot, Y as ze, r as ni, s as at, t as oi, v as ai, w as li, x as hi, y as di, z as ci, D as ui, F as fi, H as Ue, I as gi, J as Z, K as Ne, M as pi, N as mi, O as vi, P as lt, Q as L, R as F, T as yi, U as bi, V as xi, W as _i, Z as wi, _ as Ei, $ as Ci, a0 as ht, a1 as Ni, a2 as de, a3 as dt, a4 as ct, a5 as Ri, a6 as ut, a7 as ft, a8 as gt, a9 as pt, aa as zi, ab as Di, ac as mt, ad as Pi, ae as Si, af as vt, ag as ki, ah as yt, ai as Oi, aj as Ai, ak as Ti, al as Li, am as Mi, an as Hi, ao as Bi, ap as Fi, aq as bt, ar as q, as as xt, at as Ii, au as Wi, av as je, aw as Gi, ax as _t, ay as $i, az as Ui, aA as ji, aB as Ki, aC as Vi, aD as qi, aE as Xi, aF as Yi, aG as Ji, aH as Zi, aI as Qi, aJ as es } from "./hooks-BmarskJY.js";
2
+ import { bc as Fr, bp as Ir, by as Wr, aK as Gr, aL as $r, aM as Ur, aN as jr, aO as Kr, aP as Vr, aQ as qr, aR as Xr, aT as Yr, aU as Jr, aV as Zr, aW as Qr, aX as en, aY as tn, aZ as sn, bu as rn, a$ as nn, b0 as on, b3 as an, b4 as ln, b5 as hn, b6 as dn, b9 as cn, ba as un, bb as fn, be as gn, b2 as pn, bd as mn, b8 as vn, bv as yn, bo as bn, bj as xn, bm as _n, bi as wn, bz as En, bh as Cn, bg as Nn, aS as Rn, a_ as zn, b1 as Dn, b7 as Pn, bf as Sn, bk as kn, bq as On, br as An, bs as Tn, bA as Ln, bl as Mn, bt as Hn, bx as Bn, bn as Fn, bw as In } from "./hooks-BmarskJY.js";
3
3
  import { jsx as g, jsxs as R, Fragment as xe } from "react/jsx-runtime";
4
4
  import * as ke from "react";
5
5
  import P, { PureComponent as ts, useState as M, forwardRef as U, createElement as Ke, useRef as Q, useImperativeHandle as wt, Children as is, createContext as _e, useContext as Et, useCallback as K, useEffect as ce, useLayoutEffect as Ve, useMemo as Ct } from "react";