@contember/bindx-dataview 0.1.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 (114) hide show
  1. package/dist/DataGrid.d.ts +38 -0
  2. package/dist/DataGrid.d.ts.map +1 -0
  3. package/dist/DataViewContext.d.ts +39 -0
  4. package/dist/DataViewContext.d.ts.map +1 -0
  5. package/dist/DataViewKeyProvider.d.ts +8 -0
  6. package/dist/DataViewKeyProvider.d.ts.map +1 -0
  7. package/dist/HasManyDataGrid.d.ts +51 -0
  8. package/dist/HasManyDataGrid.d.ts.map +1 -0
  9. package/dist/columnLeaf.d.ts +72 -0
  10. package/dist/columnLeaf.d.ts.map +1 -0
  11. package/dist/columnTypes.d.ts +35 -0
  12. package/dist/columnTypes.d.ts.map +1 -0
  13. package/dist/columns.d.ts +115 -0
  14. package/dist/columns.d.ts.map +1 -0
  15. package/dist/contextHooks.d.ts +45 -0
  16. package/dist/contextHooks.d.ts.map +1 -0
  17. package/dist/createColumn.d.ts +37 -0
  18. package/dist/createColumn.d.ts.map +1 -0
  19. package/dist/createRelationColumn.d.ts +57 -0
  20. package/dist/createRelationColumn.d.ts.map +1 -0
  21. package/dist/dataAttribute.d.ts +6 -0
  22. package/dist/dataAttribute.d.ts.map +1 -0
  23. package/dist/export.d.ts +46 -0
  24. package/dist/export.d.ts.map +1 -0
  25. package/dist/filterComponents.d.ts +127 -0
  26. package/dist/filterComponents.d.ts.map +1 -0
  27. package/dist/filterContext.d.ts +10 -0
  28. package/dist/filterContext.d.ts.map +1 -0
  29. package/dist/filterHooks.d.ts +74 -0
  30. package/dist/filterHooks.d.ts.map +1 -0
  31. package/dist/filterScope.d.ts +54 -0
  32. package/dist/filterScope.d.ts.map +1 -0
  33. package/dist/filterWrappers.d.ts +66 -0
  34. package/dist/filterWrappers.d.ts.map +1 -0
  35. package/dist/index.d.ts +28 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/infiniteLoad.d.ts +32 -0
  38. package/dist/infiniteLoad.d.ts.map +1 -0
  39. package/dist/loaderComponents.d.ts +75 -0
  40. package/dist/loaderComponents.d.ts.map +1 -0
  41. package/dist/markers.d.ts +36 -0
  42. package/dist/markers.d.ts.map +1 -0
  43. package/dist/pagingComponents.d.ts +50 -0
  44. package/dist/pagingComponents.d.ts.map +1 -0
  45. package/dist/renderCellValue.d.ts +9 -0
  46. package/dist/renderCellValue.d.ts.map +1 -0
  47. package/dist/select/MultiSelect.d.ts +27 -0
  48. package/dist/select/MultiSelect.d.ts.map +1 -0
  49. package/dist/select/Select.d.ts +27 -0
  50. package/dist/select/Select.d.ts.map +1 -0
  51. package/dist/select/SelectDataView.d.ts +46 -0
  52. package/dist/select/SelectDataView.d.ts.map +1 -0
  53. package/dist/select/SelectEachValue.d.ts +20 -0
  54. package/dist/select/SelectEachValue.d.ts.map +1 -0
  55. package/dist/select/SelectItemTrigger.d.ts +25 -0
  56. package/dist/select/SelectItemTrigger.d.ts.map +1 -0
  57. package/dist/select/SelectOption.d.ts +23 -0
  58. package/dist/select/SelectOption.d.ts.map +1 -0
  59. package/dist/select/SelectPlaceholder.d.ts +16 -0
  60. package/dist/select/SelectPlaceholder.d.ts.map +1 -0
  61. package/dist/select/index.d.ts +9 -0
  62. package/dist/select/index.d.ts.map +1 -0
  63. package/dist/select/selectContext.d.ts +20 -0
  64. package/dist/select/selectContext.d.ts.map +1 -0
  65. package/dist/selectionComponents.d.ts +62 -0
  66. package/dist/selectionComponents.d.ts.map +1 -0
  67. package/dist/sortingComponents.d.ts +39 -0
  68. package/dist/sortingComponents.d.ts.map +1 -0
  69. package/dist/stateStorage.d.ts +20 -0
  70. package/dist/stateStorage.d.ts.map +1 -0
  71. package/dist/useDataGridSetup.d.ts +53 -0
  72. package/dist/useDataGridSetup.d.ts.map +1 -0
  73. package/dist/useDataView.d.ts +57 -0
  74. package/dist/useDataView.d.ts.map +1 -0
  75. package/dist/useDataViewState.d.ts +89 -0
  76. package/dist/useDataViewState.d.ts.map +1 -0
  77. package/package.json +33 -0
  78. package/src/DataGrid.tsx +173 -0
  79. package/src/DataViewContext.tsx +56 -0
  80. package/src/DataViewKeyProvider.tsx +16 -0
  81. package/src/HasManyDataGrid.tsx +319 -0
  82. package/src/columnLeaf.ts +148 -0
  83. package/src/columnTypes.ts +160 -0
  84. package/src/columns.tsx +306 -0
  85. package/src/contextHooks.ts +157 -0
  86. package/src/createColumn.ts +128 -0
  87. package/src/createRelationColumn.tsx +203 -0
  88. package/src/dataAttribute.ts +7 -0
  89. package/src/export.tsx +219 -0
  90. package/src/filterComponents.tsx +617 -0
  91. package/src/filterContext.ts +27 -0
  92. package/src/filterHooks.ts +386 -0
  93. package/src/filterScope.tsx +89 -0
  94. package/src/filterWrappers.tsx +187 -0
  95. package/src/index.ts +356 -0
  96. package/src/infiniteLoad.tsx +188 -0
  97. package/src/loaderComponents.tsx +239 -0
  98. package/src/markers.ts +54 -0
  99. package/src/pagingComponents.tsx +149 -0
  100. package/src/select/MultiSelect.tsx +88 -0
  101. package/src/select/Select.tsx +88 -0
  102. package/src/select/SelectDataView.tsx +231 -0
  103. package/src/select/SelectEachValue.tsx +34 -0
  104. package/src/select/SelectItemTrigger.tsx +51 -0
  105. package/src/select/SelectOption.tsx +40 -0
  106. package/src/select/SelectPlaceholder.tsx +22 -0
  107. package/src/select/index.ts +17 -0
  108. package/src/select/selectContext.ts +82 -0
  109. package/src/selectionComponents.tsx +160 -0
  110. package/src/sortingComponents.tsx +104 -0
  111. package/src/stateStorage.ts +188 -0
  112. package/src/useDataGridSetup.ts +230 -0
  113. package/src/useDataView.ts +148 -0
  114. package/src/useDataViewState.ts +404 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagingComponents.d.ts","sourceRoot":"","sources":["../src/pagingComponents.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,EAAc,KAAK,YAAY,EAAE,KAAK,SAAS,EAAe,MAAM,OAAO,CAAA;AAUzF,MAAM,WAAW,8BAA8B;IAC9C,2DAA2D;IAC3D,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;IACrD,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAA;CACtB;AAED,eAAO,MAAM,yBAAyB,0GA4BrC,CAAA;AAoBD,MAAM,WAAW,mCAAmC;IACnD,8CAA8C;IAC9C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAA;CACtB;AAED,eAAO,MAAM,8BAA8B,+GAqB1C,CAAA;AAOD,MAAM,WAAW,uBAAuB;IACvC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAChB,SAAS,EAAE,MAAM,CAAA;QACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;QACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;QACzB,YAAY,EAAE,MAAM,CAAA;KACpB,KAAK,SAAS,CAAA;CACf;AAED,wBAAgB,uBAAuB,CAAC,EACvC,QAAQ,GACR,EAAE,uBAAuB,GAAG,YAAY,CASxC;AAED,wCAAwC;AACxC,eAAO,MAAM,kBAAkB,gCAA0B,CAAA;AAEzD,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Utility for rendering cell values from column metadata and entity accessor.
3
+ * Extracted from DataGrid to be usable by any table rendering component.
4
+ */
5
+ import React from 'react';
6
+ import type { ColumnMeta } from './columns.js';
7
+ import type { EntityAccessor } from '@contember/bindx-react';
8
+ export declare function renderCellValue(col: ColumnMeta, accessor: EntityAccessor<unknown>): React.ReactNode;
9
+ //# sourceMappingURL=renderCellValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderCellValue.d.ts","sourceRoot":"","sources":["../src/renderCellValue.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,SAAS,CAqEnG"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * MultiSelect — headless multi-select component for has-many relations.
3
+ *
4
+ * Manages selection state for a has-many relation field and provides
5
+ * context for descendant components (SelectDataView, SelectOption, etc.).
6
+ *
7
+ * Usage:
8
+ * ```tsx
9
+ * <MultiSelect relation={article.tags} options={schema.Tag}>
10
+ * <SelectDataView queryField={['name']}>
11
+ * {it => <SelectOption><SelectItemTrigger><Field field={it.name} /></SelectItemTrigger></SelectOption>}
12
+ * </SelectDataView>
13
+ * </MultiSelect>
14
+ * ```
15
+ */
16
+ import { type ReactNode } from 'react';
17
+ import type { EntityDef, HasManyRef } from '@contember/bindx';
18
+ import { type SelectEvents } from './selectContext.js';
19
+ export interface MultiSelectProps extends SelectEvents {
20
+ /** Has-many relation ref from parent entity */
21
+ relation: HasManyRef<object>;
22
+ /** Entity definition for the options list */
23
+ options: EntityDef;
24
+ children: ReactNode;
25
+ }
26
+ export declare function MultiSelect({ relation, options, children, onSelect, onUnselect, }: MultiSelectProps): ReactNode;
27
+ //# sourceMappingURL=MultiSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../src/select/MultiSelect.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAwB,MAAM,OAAO,CAAA;AAC5D,OAAO,KAAK,EAAkB,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAMN,KAAK,YAAY,EAEjB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACrD,+CAA+C;IAC/C,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IAC5B,6CAA6C;IAC7C,OAAO,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;CACnB;AAED,wBAAgB,WAAW,CAAC,EAC3B,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,GACV,EAAE,gBAAgB,GAAG,SAAS,CA6C9B"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Select — headless single-select component for has-one relations.
3
+ *
4
+ * Manages selection state for a has-one relation field and provides
5
+ * context for descendant components (SelectDataView, SelectOption, etc.).
6
+ *
7
+ * Usage:
8
+ * ```tsx
9
+ * <Select relation={article.category} options={schema.Category}>
10
+ * <SelectDataView queryField={['name']}>
11
+ * ...options rendering...
12
+ * </SelectDataView>
13
+ * </Select>
14
+ * ```
15
+ */
16
+ import { type ReactNode } from 'react';
17
+ import type { EntityDef, HasOneRef } from '@contember/bindx';
18
+ import { type SelectEvents } from './selectContext.js';
19
+ export interface SelectProps extends SelectEvents {
20
+ /** Has-one relation ref from parent entity */
21
+ relation: HasOneRef<object>;
22
+ /** Entity definition for the options list */
23
+ options: EntityDef;
24
+ children: ReactNode;
25
+ }
26
+ export declare function Select({ relation, options, children, onSelect, onUnselect, }: SelectProps): ReactNode;
27
+ //# sourceMappingURL=Select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/select/Select.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAwB,MAAM,OAAO,CAAA;AAC5D,OAAO,KAAK,EAAkB,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5E,OAAO,EAMN,KAAK,YAAY,EAEjB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,WAAW,WAAY,SAAQ,YAAY;IAChD,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IAC3B,6CAA6C;IAC7C,OAAO,EAAE,SAAS,CAAA;IAClB,QAAQ,EAAE,SAAS,CAAA;CACnB;AAED,wBAAgB,MAAM,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,GACV,EAAE,WAAW,GAAG,SAAS,CA4CzB"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * SelectDataView — provides a DataView context for select option lists.
3
+ *
4
+ * Analyzes the children render function for field selection, loads data
5
+ * from the options entity, and provides a DataView context for rendering.
6
+ * Children are rendered directly inside the DataView — use DataViewEachRow
7
+ * or DataViewLoaderState to iterate items and show loading states.
8
+ *
9
+ * Usage:
10
+ * ```tsx
11
+ * <Select relation={article.category} options={schema.Category}>
12
+ * <SelectDataView queryField={['name']}>
13
+ * <DataViewEachRow>
14
+ * {(item) => (
15
+ * <SelectOption entity={item}>
16
+ * <SelectItemTrigger entity={item}>
17
+ * <button>{item.name.value}</button>
18
+ * </SelectItemTrigger>
19
+ * </SelectOption>
20
+ * )}
21
+ * </DataViewEachRow>
22
+ * </SelectDataView>
23
+ * </Select>
24
+ * ```
25
+ */
26
+ import { type ReactElement, type ReactNode } from 'react';
27
+ import type { EntityAccessor, OrderDirection } from '@contember/bindx';
28
+ import type { FieldRefBase } from '@contember/bindx';
29
+ export interface SelectDataViewProps {
30
+ /** Children rendered inside the DataView context */
31
+ children: ReactNode;
32
+ /** Selection definer — called with collector proxy to discover fields */
33
+ selection?: (it: EntityAccessor<object>) => ReactNode;
34
+ /** Field(s) to search across */
35
+ queryField?: FieldRefBase<unknown> | FieldRefBase<unknown>[] | string[];
36
+ /** Initial sort order */
37
+ initialSorting?: Partial<Record<string, OrderDirection>>;
38
+ /** Static filter for the options list */
39
+ filter?: Record<string, unknown>;
40
+ /** Items per page (null = all). Default: 50 */
41
+ itemsPerPage?: number | null;
42
+ }
43
+ declare function SelectDataViewImpl({ children, selection: selectionDefiner, queryField, initialSorting, filter: staticFilter, itemsPerPage, }: SelectDataViewProps): ReactElement | null;
44
+ export declare const SelectDataView: typeof SelectDataViewImpl;
45
+ export {};
46
+ //# sourceMappingURL=SelectDataView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectDataView.d.ts","sourceRoot":"","sources":["../../src/select/SelectDataView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AAClH,OAAO,KAAK,EACX,cAAc,EAGd,cAAc,EAEd,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAYpD,MAAM,WAAW,mBAAmB;IACnC,oDAAoD;IACpD,QAAQ,EAAE,SAAS,CAAA;IACnB,yEAAyE;IACzE,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,SAAS,CAAA;IACrD,gCAAgC;IAChC,UAAU,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,CAAA;IACvE,yBAAyB;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;IACxD,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAID,iBAAS,kBAAkB,CAAC,EAC3B,QAAQ,EACR,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EACV,cAAc,EACd,MAAM,EAAE,YAAY,EACpB,YAAiB,GACjB,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CA6J3C;AAED,eAAO,MAAM,cAAc,EAA0C,OAAO,kBAAkB,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * SelectEachValue — iterates over currently selected entities.
3
+ *
4
+ * Renders its children once for each selected entity,
5
+ * providing the entity accessor and index.
6
+ *
7
+ * Usage:
8
+ * ```tsx
9
+ * <SelectEachValue>
10
+ * {(entity) => <span>{entity.name.value}</span>}
11
+ * </SelectEachValue>
12
+ * ```
13
+ */
14
+ import { type ReactNode } from 'react';
15
+ import type { EntityAccessor } from '@contember/bindx';
16
+ export interface SelectEachValueProps {
17
+ children: (entity: EntityAccessor<object>, index: number) => ReactNode;
18
+ }
19
+ export declare function SelectEachValue({ children }: SelectEachValueProps): ReactNode;
20
+ //# sourceMappingURL=SelectEachValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectEachValue.d.ts","sourceRoot":"","sources":["../../src/select/SelectEachValue.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGtD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAA;CACtE;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAW7E"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * SelectItemTrigger — clickable handler for option items.
3
+ *
4
+ * Slot-based: wraps its single child element, adding an onClick handler
5
+ * that calls the select handler with the specified action.
6
+ *
7
+ * Usage:
8
+ * ```tsx
9
+ * <SelectItemTrigger action="toggle">
10
+ * <button><Field field={it.name} /></button>
11
+ * </SelectItemTrigger>
12
+ * ```
13
+ */
14
+ import React, { type ReactElement } from 'react';
15
+ import { type SelectAction } from './selectContext.js';
16
+ import type { EntityAccessor } from '@contember/bindx';
17
+ export interface SelectItemTriggerProps {
18
+ /** Entity accessor for this option */
19
+ entity: EntityAccessor<object>;
20
+ /** Action to perform on click. Default: 'toggle' */
21
+ action?: SelectAction;
22
+ children: ReactElement;
23
+ }
24
+ export declare const SelectItemTrigger: React.ForwardRefExoticComponent<SelectItemTriggerProps & React.RefAttributes<HTMLElement>>;
25
+ //# sourceMappingURL=SelectItemTrigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectItemTrigger.d.ts","sourceRoot":"","sources":["../../src/select/SelectItemTrigger.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,EAAc,KAAK,YAAY,EAAe,MAAM,OAAO,CAAA;AAGzE,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,MAAM,WAAW,sBAAsB;IACtC,sCAAsC;IACtC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;IAC9B,oDAAoD;IACpD,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,QAAQ,EAAE,YAAY,CAAA;CACtB;AAED,eAAO,MAAM,iBAAiB,4FAqB7B,CAAA"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * SelectOption — marks an option item with data-selected attribute.
3
+ *
4
+ * Slot-based: wraps its single child element, adding `data-selected`
5
+ * when the current entity is selected.
6
+ *
7
+ * Usage:
8
+ * ```tsx
9
+ * <SelectOption>
10
+ * <button>Option label</button>
11
+ * </SelectOption>
12
+ * ```
13
+ */
14
+ import { type ReactElement } from 'react';
15
+ export interface SelectOptionProps {
16
+ /** Entity accessor for this option (passed automatically by DataViewEachRow) */
17
+ entity: {
18
+ id: string;
19
+ };
20
+ children: ReactElement;
21
+ }
22
+ export declare const SelectOption: import("react").ForwardRefExoticComponent<SelectOptionProps & import("react").RefAttributes<HTMLElement>>;
23
+ //# sourceMappingURL=SelectOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectOption.d.ts","sourceRoot":"","sources":["../../src/select/SelectOption.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AAKrD,MAAM,WAAW,iBAAiB;IACjC,gFAAgF;IAChF,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACtB,QAAQ,EAAE,YAAY,CAAA;CACtB;AAED,eAAO,MAAM,YAAY,2GAaxB,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * SelectPlaceholder — renders children only when no entities are selected.
3
+ *
4
+ * Usage:
5
+ * ```tsx
6
+ * <SelectPlaceholder>
7
+ * <span>Select an option...</span>
8
+ * </SelectPlaceholder>
9
+ * ```
10
+ */
11
+ import type { ReactNode } from 'react';
12
+ export interface SelectPlaceholderProps {
13
+ children: ReactNode;
14
+ }
15
+ export declare function SelectPlaceholder({ children }: SelectPlaceholderProps): ReactNode;
16
+ //# sourceMappingURL=SelectPlaceholder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectPlaceholder.d.ts","sourceRoot":"","sources":["../../src/select/SelectPlaceholder.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,WAAW,sBAAsB;IACtC,QAAQ,EAAE,SAAS,CAAA;CACnB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,sBAAsB,GAAG,SAAS,CAGjF"}
@@ -0,0 +1,9 @@
1
+ export { Select, type SelectProps } from './Select.js';
2
+ export { MultiSelect, type MultiSelectProps } from './MultiSelect.js';
3
+ export { SelectDataView, type SelectDataViewProps } from './SelectDataView.js';
4
+ export { SelectOption, type SelectOptionProps } from './SelectOption.js';
5
+ export { SelectItemTrigger, type SelectItemTriggerProps } from './SelectItemTrigger.js';
6
+ export { SelectEachValue, type SelectEachValueProps } from './SelectEachValue.js';
7
+ export { SelectPlaceholder, type SelectPlaceholderProps } from './SelectPlaceholder.js';
8
+ export { useSelectCurrentEntities, useSelectIsSelected, useSelectHandleSelect, useSelectOptions, SelectOptionsContext, type SelectHandler, type SelectAction, type SelectEvents, } from './selectContext.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/select/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACvF,OAAO,EACN,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GACjB,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Select context — provides selection state and handlers to descendant components.
3
+ */
4
+ import type { EntityAccessor, EntityDef } from '@contember/bindx';
5
+ export type SelectAction = 'select' | 'unselect' | 'toggle';
6
+ export type SelectHandler = (entity: EntityAccessor<object>, action?: SelectAction) => void;
7
+ export interface SelectEvents {
8
+ onSelect?: (entity: EntityAccessor<object>) => void;
9
+ onUnselect?: (entity: EntityAccessor<object>) => void;
10
+ }
11
+ declare const SelectCurrentEntitiesContext: import("react").Context<readonly EntityAccessor<object>[] | null>;
12
+ declare const SelectIsSelectedContext: import("react").Context<((entity: EntityAccessor<object>) => boolean) | null>;
13
+ declare const SelectHandleSelectContext: import("react").Context<SelectHandler | null>;
14
+ declare const SelectOptionsContext: import("react").Context<EntityDef<Record<string, object>> | null>;
15
+ export declare function useSelectCurrentEntities(): readonly EntityAccessor<object>[];
16
+ export declare function useSelectIsSelected(): (entity: EntityAccessor<object>) => boolean;
17
+ export declare function useSelectHandleSelect(): SelectHandler;
18
+ export declare function useSelectOptions(): EntityDef;
19
+ export { SelectCurrentEntitiesContext, SelectIsSelectedContext, SelectHandleSelectContext, SelectOptionsContext, };
20
+ //# sourceMappingURL=selectContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectContext.d.ts","sourceRoot":"","sources":["../../src/select/selectContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAMjE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE3D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,KAAK,IAAI,CAAA;AAE3F,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;IACnD,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;CACrD;AAMD,QAAA,MAAM,4BAA4B,mEAAgE,CAAA;AAGlG,QAAA,MAAM,uBAAuB,oCAA2B,cAAc,CAAC,MAAM,CAAC,KAAK,OAAO,SAAe,CAAA;AAGzG,QAAA,MAAM,yBAAyB,+CAA4C,CAAA;AAG3E,QAAA,MAAM,oBAAoB,mEAAwC,CAAA;AAOlE,wBAAgB,wBAAwB,IAAI,SAAS,cAAc,CAAC,MAAM,CAAC,EAAE,CAM5E;AAED,wBAAgB,mBAAmB,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,OAAO,CAMjF;AAED,wBAAgB,qBAAqB,IAAI,aAAa,CAMrD;AAED,wBAAgB,gBAAgB,IAAI,SAAS,CAM5C;AAMD,OAAO,EACN,4BAA4B,EAC5B,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,GACpB,CAAA"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Selection components — column visibility + layout switching using Radix Slot.
3
+ *
4
+ * Usage:
5
+ * ```tsx
6
+ * <DataViewVisibilityTrigger name="description">
7
+ * <button>Toggle Description</button>
8
+ * </DataViewVisibilityTrigger>
9
+ *
10
+ * <DataViewElement name="description">
11
+ * <DescriptionColumn />
12
+ * </DataViewElement>
13
+ *
14
+ * <DataViewLayout name="table">
15
+ * <TableView />
16
+ * </DataViewLayout>
17
+ *
18
+ * <DataViewLayoutTrigger name="table">
19
+ * <button>Table View</button>
20
+ * </DataViewLayoutTrigger>
21
+ * ```
22
+ */
23
+ import React, { type ReactElement } from 'react';
24
+ export interface DataViewVisibilityTriggerProps {
25
+ /** Element name to toggle */
26
+ name: string;
27
+ /** Value to set. Can be boolean or function. Default: toggle */
28
+ value?: boolean | ((current: boolean) => boolean);
29
+ /** Fallback visibility when not explicitly set. Default: true */
30
+ fallbackValue?: boolean;
31
+ /** Button element */
32
+ children: ReactElement;
33
+ }
34
+ export declare const DataViewVisibilityTrigger: React.ForwardRefExoticComponent<DataViewVisibilityTriggerProps & React.RefAttributes<HTMLButtonElement>>;
35
+ export interface DataViewElementProps {
36
+ /** Element name (used for visibility toggle) */
37
+ name: string;
38
+ /** Label for the element (for UI display) */
39
+ label?: React.ReactNode;
40
+ /** Default visibility when not explicitly set. Default: true */
41
+ fallback?: boolean;
42
+ children: React.ReactNode;
43
+ }
44
+ export declare function DataViewElement({ name, fallback, children, }: DataViewElementProps): ReactElement | null;
45
+ /** @deprecated Use DataViewElement instead */
46
+ export declare const DataViewIsVisible: typeof DataViewElement;
47
+ export interface DataViewLayoutProps {
48
+ /** Layout name */
49
+ name: string;
50
+ /** Label for the layout */
51
+ label?: React.ReactNode;
52
+ children: React.ReactNode;
53
+ }
54
+ export declare function DataViewLayout({ name, children, }: DataViewLayoutProps): ReactElement | null;
55
+ export interface DataViewLayoutTriggerProps {
56
+ /** Layout name to switch to */
57
+ name: string;
58
+ /** Button element */
59
+ children: ReactElement;
60
+ }
61
+ export declare const DataViewLayoutTrigger: React.ForwardRefExoticComponent<DataViewLayoutTriggerProps & React.RefAttributes<HTMLButtonElement>>;
62
+ //# sourceMappingURL=selectionComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionComponents.d.ts","sourceRoot":"","sources":["../src/selectionComponents.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,EAAc,KAAK,YAAY,EAAe,MAAM,OAAO,CAAA;AAUzE,MAAM,WAAW,8BAA8B;IAC9C,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAA;IACjD,iEAAiE;IACjE,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAA;CACtB;AAED,eAAO,MAAM,yBAAyB,0GA2BrC,CAAA;AAOD,MAAM,WAAW,oBAAoB;IACpC,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,6CAA6C;IAC7C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACzB;AAED,wBAAgB,eAAe,CAAC,EAC/B,IAAI,EACJ,QAAe,EACf,QAAQ,GACR,EAAE,oBAAoB,GAAG,YAAY,GAAG,IAAI,CAM5C;AAED,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB,wBAAkB,CAAA;AAMhD,MAAM,WAAW,mBAAmB;IACnC,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,2BAA2B;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACzB;AAED,wBAAgB,cAAc,CAAC,EAC9B,IAAI,EACJ,QAAQ,GACR,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CAQ3C;AAED,MAAM,WAAW,0BAA0B;IAC1C,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAA;CACtB;AAED,eAAO,MAAM,qBAAqB,sGAuBjC,CAAA"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Composable sorting UI components using Radix Slot pattern.
3
+ *
4
+ * Usage:
5
+ * ```tsx
6
+ * <DataViewSortingTrigger field={it.title}>
7
+ * <button>Sort by Title</button>
8
+ * </DataViewSortingTrigger>
9
+ *
10
+ * <DataViewSortingSwitch field={it.title}
11
+ * asc={<span>↑</span>}
12
+ * desc={<span>↓</span>}
13
+ * none={<span>↕</span>}
14
+ * />
15
+ * ```
16
+ */
17
+ import React, { type ReactElement } from 'react';
18
+ import type { SortingDirectionAction, FieldRefBase } from '@contember/bindx';
19
+ export interface DataViewSortingTriggerProps<T> {
20
+ /** Field to sort by */
21
+ field: FieldRefBase<T>;
22
+ /** Sorting action. Default: 'next' (cycles asc → desc → none) */
23
+ action?: SortingDirectionAction;
24
+ /** Button element to render */
25
+ children: ReactElement;
26
+ }
27
+ export declare const DataViewSortingTrigger: <T>(props: DataViewSortingTriggerProps<T> & React.RefAttributes<HTMLButtonElement>) => ReactElement | null;
28
+ export interface DataViewSortingSwitchProps<T> {
29
+ /** Field to check sorting direction for */
30
+ field: FieldRefBase<T>;
31
+ /** Render when sorted ascending */
32
+ asc?: React.ReactNode;
33
+ /** Render when sorted descending */
34
+ desc?: React.ReactNode;
35
+ /** Render when not sorted */
36
+ none?: React.ReactNode;
37
+ }
38
+ export declare function DataViewSortingSwitch<T>({ field, asc, desc, none, }: DataViewSortingSwitchProps<T>): ReactElement;
39
+ //# sourceMappingURL=sortingComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortingComponents.d.ts","sourceRoot":"","sources":["../src/sortingComponents.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAc,KAAK,YAAY,EAAe,MAAM,OAAO,CAAA;AAKzE,OAAO,KAAK,EAAE,sBAAsB,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAM5F,MAAM,WAAW,2BAA2B,CAAC,CAAC;IAC7C,uBAAuB;IACvB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IACtB,iEAAiE;IACjE,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B,+BAA+B;IAC/B,QAAQ,EAAE,YAAY,CAAA;CACtB;AASD,eAAO,MAAM,sBAAsB,EA6B9B,CAAC,CAAC,EAAE,KAAK,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,YAAY,GAAG,IAAI,CAC9G;AAMD,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC5C,2CAA2C;IAC3C,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IACtB,mCAAmC;IACnC,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,oCAAoC;IACpC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,EACxC,KAAK,EACL,GAAG,EACH,IAAI,EACJ,IAAI,GACJ,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,YAAY,CAO9C"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * State storage abstraction for DataView state persistence.
3
+ *
4
+ * Supports URL params, sessionStorage, localStorage, or custom backends.
5
+ *
6
+ * Usage:
7
+ * ```tsx
8
+ * const [value, setValue] = useStoredState('url', ['myGrid', 'sorting'], initialValue)
9
+ * ```
10
+ */
11
+ export interface StateStorage {
12
+ get<T>(key: string): T | undefined;
13
+ set<T>(key: string, value: T): void;
14
+ remove(key: string): void;
15
+ }
16
+ export type StateStorageOrName = 'url' | 'session' | 'local' | 'null' | StateStorage;
17
+ export type SetStoredState<T> = (value: T | ((current: T) => T)) => void;
18
+ export declare function useStoredState<T>(storageOrName: StateStorageOrName | StateStorageOrName[], key: readonly string[], initializer: (storedValue: T | undefined) => T): [T, SetStoredState<T>];
19
+ export declare function buildDataViewKey(parts: readonly string[]): string;
20
+ //# sourceMappingURL=stateStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stateStorage.d.ts","sourceRoot":"","sources":["../src/stateStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,MAAM,WAAW,YAAY;IAC5B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAA;IAClC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IACnC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,CAAA;AAoIpF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAA;AAExE,wBAAgB,cAAc,CAAC,CAAC,EAC/B,aAAa,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,EACxD,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,WAAW,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,GAC5C,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAkBxB;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEjE"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Shared setup logic for DataGrid and HasManyDataGrid.
3
+ * Handles collection phase (JSX analysis), state management, and filter building.
4
+ */
5
+ import { type ReactNode } from 'react';
6
+ import type { EntityAccessor, OrderDirection, DataViewLayout, SelectionMeta, SelectionValues, SchemaRegistry } from '@contember/bindx';
7
+ import { type ColumnLeafProps } from './columnLeaf.js';
8
+ import { useFilteringState, useSortingState, usePagingState, useSelectionState } from './useDataViewState.js';
9
+ import type { StateStorageOrName } from './stateStorage.js';
10
+ import type { DataViewContextValue, DataViewElementData } from './DataViewContext.js';
11
+ export declare const QUERY_FILTER_NAME = "__query";
12
+ export interface DataGridCommonProps<TEntity extends object> {
13
+ children: (it: EntityAccessor<TEntity>) => ReactNode;
14
+ initialSorting?: Partial<Record<string, OrderDirection>>;
15
+ itemsPerPage?: number | null;
16
+ filter?: Record<string, unknown>;
17
+ layouts?: readonly DataViewLayout[];
18
+ initialSelection?: SelectionValues;
19
+ stateStorage?: StateStorageOrName;
20
+ currentPageStateStorage?: StateStorageOrName;
21
+ pagingSettingsStorage?: StateStorageOrName;
22
+ storageKey?: string;
23
+ }
24
+ export interface DataGridSetupResult {
25
+ childrenJsx: ReactNode;
26
+ columns: ColumnLeafProps[];
27
+ selection: SelectionMeta;
28
+ queryKey: string;
29
+ toolbarContent: ReactNode | undefined;
30
+ layoutRenders: Map<string, (item: DataViewContextValue['items'][number]) => ReactNode>;
31
+ layoutElements: Map<string, readonly DataViewElementData[]>;
32
+ effectiveLayouts: readonly DataViewLayout[];
33
+ filtering: ReturnType<typeof useFilteringState>;
34
+ sorting: ReturnType<typeof useSortingState>;
35
+ paging: ReturnType<typeof usePagingState>;
36
+ selectionState: ReturnType<typeof useSelectionState>;
37
+ combinedFilter: Record<string, unknown> | undefined;
38
+ }
39
+ export declare function useDataGridSetup<TEntity extends object>({ entityType, schemaRegistry, children, initialSorting, itemsPerPage, staticFilter, layouts, initialSelection, stateStorage, currentPageStateStorage, pagingSettingsStorage, storageKey, }: {
40
+ entityType: string;
41
+ schemaRegistry: SchemaRegistry | null;
42
+ children: (it: EntityAccessor<TEntity>) => ReactNode;
43
+ initialSorting?: Partial<Record<string, OrderDirection>>;
44
+ itemsPerPage?: number | null;
45
+ staticFilter?: Record<string, unknown>;
46
+ layouts?: readonly DataViewLayout[];
47
+ initialSelection?: SelectionValues;
48
+ stateStorage?: StateStorageOrName;
49
+ currentPageStateStorage?: StateStorageOrName;
50
+ pagingSettingsStorage?: StateStorageOrName;
51
+ storageKey?: string;
52
+ }): DataGridSetupResult;
53
+ //# sourceMappingURL=useDataGridSetup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataGridSetup.d.ts","sourceRoot":"","sources":["../src/useDataGridSetup.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * useDataView — low-level hook for building custom data views.
3
+ *
4
+ * Manages filtering, sorting, paging, and selection state, and loads data
5
+ * from the backend adapter. This is the hook API that DataGrid
6
+ * uses internally, exposed for building custom grid/list UIs.
7
+ */
8
+ import type { EntityDef, EntityAccessor, FilterHandler, FilterArtifact, SelectionMeta, FieldError, SortingDirections, DataViewLayout, SelectionValues } from '@contember/bindx';
9
+ import { type FilteringState, type SortingStateResult, type PagingStateResult, type SelectionStateResult } from './useDataViewState.js';
10
+ import type { StateStorageOrName } from './stateStorage.js';
11
+ export interface UseDataViewOptions {
12
+ /** Filter definitions: name → { handler, initialArtifact? } */
13
+ filters?: ReadonlyMap<string, {
14
+ handler: FilterHandler<FilterArtifact>;
15
+ initialArtifact?: FilterArtifact;
16
+ }>;
17
+ /** Fields that can be sorted */
18
+ sortableFields?: ReadonlySet<string>;
19
+ /** Initial sorting directions (supports multi-column) */
20
+ initialSorting?: SortingDirections;
21
+ /** Items per page. null = show all. Default: 50 */
22
+ itemsPerPage?: number | null;
23
+ /** Static filter (always applied) */
24
+ filter?: Record<string, unknown>;
25
+ /** Selection metadata for building the query */
26
+ selection: SelectionMeta;
27
+ /** Available layouts */
28
+ layouts?: readonly DataViewLayout[];
29
+ /** Initial selection (layout + visibility) */
30
+ initialSelection?: SelectionValues;
31
+ /** State storage for filter/sorting/selection state */
32
+ stateStorage?: StateStorageOrName;
33
+ /** State storage for current page (typically 'url') */
34
+ currentPageStateStorage?: StateStorageOrName;
35
+ /** State storage for page size preference (typically 'session' or 'local') */
36
+ pagingSettingsStorage?: StateStorageOrName;
37
+ /** Storage key prefix for isolation */
38
+ storageKey?: string;
39
+ }
40
+ export interface DataViewResult {
41
+ /** Current load status */
42
+ readonly status: 'loading' | 'error' | 'ready';
43
+ /** Error if status is 'error' */
44
+ readonly error?: FieldError;
45
+ /** Loaded items as entity accessors */
46
+ readonly items: readonly EntityAccessor<object>[];
47
+ /** Filtering state and controls */
48
+ readonly filtering: FilteringState;
49
+ /** Sorting state and controls */
50
+ readonly sorting: SortingStateResult;
51
+ /** Paging state and controls */
52
+ readonly paging: PagingStateResult;
53
+ /** Selection state (visibility + layout) */
54
+ readonly selection: SelectionStateResult;
55
+ }
56
+ export declare function useDataView(entity: EntityDef, options: UseDataViewOptions): DataViewResult;
57
+ //# sourceMappingURL=useDataView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataView.d.ts","sourceRoot":"","sources":["../src/useDataView.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACX,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAKN,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAM3D,MAAM,WAAW,kBAAkB;IAClC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;QAAC,eAAe,CAAC,EAAE,cAAc,CAAA;KAAE,CAAC,CAAA;IAC3G,gCAAgC;IAChC,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACpC,yDAAyD;IACzD,cAAc,CAAC,EAAE,iBAAiB,CAAA;IAClC,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,gDAAgD;IAChD,SAAS,EAAE,aAAa,CAAA;IACxB,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IACnC,8CAA8C;IAC9C,gBAAgB,CAAC,EAAE,eAAe,CAAA;IAClC,uDAAuD;IACvD,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,uDAAuD;IACvD,uBAAuB,CAAC,EAAE,kBAAkB,CAAA;IAC5C,8EAA8E;IAC9E,qBAAqB,CAAC,EAAE,kBAAkB,CAAA;IAC1C,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,cAAc;IAC9B,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;IAC9C,iCAAiC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAA;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,CAAC,MAAM,CAAC,EAAE,CAAA;IACjD,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAClC,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;IACpC,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAA;CACxC;AASD,wBAAgB,WAAW,CAC1B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,kBAAkB,GACzB,cAAc,CAwDhB"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * State management hooks for DataView filtering, sorting, paging, and selection.
3
+ *
4
+ * All hooks support optional state storage (URL, session, local, custom)
5
+ * for persisting state across navigations.
6
+ */
7
+ import type { FilterHandler, FilterArtifact, SortingState, SortingDirections, SortingDirectionAction, PagingState, PagingInfo, OrderDirection, DataViewLayout, SelectionValues, SelectionState, FieldRefBase } from '@contember/bindx';
8
+ import { type StateStorageOrName } from './stateStorage.js';
9
+ export interface RegisteredFilter {
10
+ readonly name: string;
11
+ readonly handler: FilterHandler<FilterArtifact>;
12
+ artifact: FilterArtifact;
13
+ }
14
+ export interface FilteringState {
15
+ readonly filters: ReadonlyMap<string, RegisteredFilter>;
16
+ getArtifact(name: string): FilterArtifact | undefined;
17
+ setArtifact(name: string, artifact: FilterArtifact): void;
18
+ resetFilter(name: string): void;
19
+ resetAll(): void;
20
+ readonly hasActiveFilters: boolean;
21
+ readonly resolvedWhere: Record<string, unknown> | undefined;
22
+ }
23
+ export interface UseFilteringOptions {
24
+ filters: ReadonlyMap<string, {
25
+ handler: FilterHandler<FilterArtifact>;
26
+ initialArtifact?: FilterArtifact;
27
+ }>;
28
+ /** State storage backend. Default: 'null' (no persistence) */
29
+ stateStorage?: StateStorageOrName;
30
+ /** Storage key prefix */
31
+ storageKey?: string;
32
+ }
33
+ export declare function useFilteringState(options: UseFilteringOptions): FilteringState;
34
+ export interface UseSortingOptions {
35
+ sortableFields: ReadonlySet<string>;
36
+ initialSorting?: SortingDirections;
37
+ stateStorage?: StateStorageOrName;
38
+ storageKey?: string;
39
+ }
40
+ export interface SortingStateResult {
41
+ readonly state: SortingState;
42
+ setOrderBy<T>(field: FieldRefBase<T>, action: SortingDirectionAction, append?: boolean): void;
43
+ clear(): void;
44
+ directionOf<T>(field: FieldRefBase<T>): OrderDirection | null;
45
+ readonly resolvedOrderBy: readonly Record<string, unknown>[] | undefined;
46
+ }
47
+ export declare function useSortingState(options: UseSortingOptions): SortingStateResult;
48
+ export interface UsePagingOptions {
49
+ /** Initial items per page. null = show all. Default: 50 */
50
+ initialItemsPerPage?: number | null;
51
+ /** State storage for current page */
52
+ currentPageStateStorage?: StateStorageOrName;
53
+ /** State storage for page size preference */
54
+ pagingSettingsStorage?: StateStorageOrName;
55
+ /** Storage key prefix */
56
+ storageKey?: string;
57
+ }
58
+ export interface PagingStateResult {
59
+ readonly state: PagingState;
60
+ readonly info: PagingInfo;
61
+ readonly hasPrevious: boolean;
62
+ readonly hasNext: boolean;
63
+ goTo(page: number): void;
64
+ next(): void;
65
+ previous(): void;
66
+ first(): void;
67
+ last(): void;
68
+ setItemsPerPage(count: number | null): void;
69
+ setTotalCount(count: number): void;
70
+ refreshTotalCount(): void;
71
+ readonly queryLimit: number | undefined;
72
+ readonly queryOffset: number | undefined;
73
+ }
74
+ export declare function usePagingState(options?: UsePagingOptions): PagingStateResult;
75
+ export interface UseSelectionOptions {
76
+ layouts?: readonly DataViewLayout[];
77
+ initialSelection?: SelectionValues;
78
+ stateStorage?: StateStorageOrName;
79
+ storageKey?: string;
80
+ }
81
+ export interface SelectionStateResult {
82
+ readonly state: SelectionState;
83
+ setLayout(layout: string | undefined): void;
84
+ setVisibility(name: string, visible: boolean | undefined): void;
85
+ isVisible(name: string, fallback?: boolean): boolean;
86
+ readonly currentLayout: string | undefined;
87
+ }
88
+ export declare function useSelectionState(options?: UseSelectionOptions): SelectionStateResult;
89
+ //# sourceMappingURL=useDataViewState.d.ts.map