@commercetools-uikit/hooks 15.13.2 → 15.14.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.
@@ -448,7 +448,7 @@ var useDataTableSortingState = function useDataTableSortingState() {
448
448
  var useDataTableSortingState$1 = useDataTableSortingState;
449
449
 
450
450
  // NOTE: This string will be replaced on build time with the package version.
451
- var version = "15.13.2";
451
+ var version = "15.14.0";
452
452
 
453
453
  exports.useDataTableSortingState = useDataTableSortingState$1;
454
454
  exports.useFieldId = useFieldId$1;
@@ -448,7 +448,7 @@ var useDataTableSortingState = function useDataTableSortingState() {
448
448
  var useDataTableSortingState$1 = useDataTableSortingState;
449
449
 
450
450
  // NOTE: This string will be replaced on build time with the package version.
451
- var version = "15.13.2";
451
+ var version = "15.14.0";
452
452
 
453
453
  exports.useDataTableSortingState = useDataTableSortingState$1;
454
454
  exports.useFieldId = useFieldId$1;
@@ -424,6 +424,6 @@ var useDataTableSortingState = function useDataTableSortingState() {
424
424
  var useDataTableSortingState$1 = useDataTableSortingState;
425
425
 
426
426
  // NOTE: This string will be replaced on build time with the package version.
427
- var version = "15.13.2";
427
+ var version = "15.14.0";
428
428
 
429
429
  export { useDataTableSortingState$1 as useDataTableSortingState, useFieldId$1 as useFieldId, useMutationObserver, usePaginationState$1 as usePaginationState, usePrevious$1 as usePrevious, useRowSelection$1 as useRowSelection, useSorting$1 as useSorting, useToggleState$1 as useToggleState, version };
@@ -6,5 +6,10 @@ export { default as useRowSelection } from './use-row-selection';
6
6
  export { default as useSorting } from './use-sorting';
7
7
  export { default as usePaginationState } from './use-pagination-state';
8
8
  export { default as useDataTableSortingState } from './use-data-table-sorting-state';
9
+ export * from './use-field-id/export-types';
9
10
  export * from './use-data-table-sorting-state/export-types';
11
+ export * from './use-mutation-observer/export-types';
12
+ export * from './use-pagination-state/export-types';
13
+ export * from './use-row-selection/export-types';
14
+ export * from './use-sorting/export-types';
10
15
  export { default as version } from './version';
@@ -0,0 +1 @@
1
+ export type { TCreateIdFn } from './use-field-id';
@@ -1 +1,2 @@
1
1
  export { default } from './use-field-id';
2
+ export * from './export-types';
@@ -1,3 +1,3 @@
1
- type CreateIdFn = () => string;
2
- declare const useFieldId: (id: string | undefined, createIdFn: CreateIdFn) => string;
1
+ export type TCreateIdFn = () => string;
2
+ declare const useFieldId: (id: string | undefined, createIdFn: TCreateIdFn) => string;
3
3
  export default useFieldId;
@@ -0,0 +1 @@
1
+ export type { TUseMutationObserverCallback } from './use-mutation-observer';
@@ -1 +1,2 @@
1
1
  export { default } from './use-mutation-observer';
2
+ export * from './export-types';
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- type TUseMutationObserverCallback = (mutationsList: MutationRecord[], observer: MutationObserver) => void;
2
+ export type TUseMutationObserverCallback = (mutationsList: MutationRecord[], observer: MutationObserver) => void;
3
3
  declare function useMutationObserver<T extends HTMLElement>(target: React.RefObject<T> | T | null, callback: TUseMutationObserverCallback, options?: MutationObserverInit): MutationObserver;
4
4
  export default useMutationObserver;
@@ -0,0 +1 @@
1
+ export type { TPaginationDefinition, TPaginationState, TState, } from './use-pagination-state';
@@ -1 +1,2 @@
1
1
  export { default } from './use-pagination-state';
2
+ export * from './export-types';
@@ -1,12 +1,12 @@
1
- type TPaginationDefinition = {
1
+ export type TPaginationDefinition = {
2
2
  page: number;
3
3
  perPage: number;
4
4
  };
5
- type TState = {
5
+ export type TState = {
6
6
  value: number;
7
7
  onChange: (value: number) => void;
8
8
  };
9
- type TPaginationState = {
9
+ export type TPaginationState = {
10
10
  [P in keyof TPaginationDefinition]: TState;
11
11
  };
12
12
  declare const usePaginationState: (initialValues?: Partial<TPaginationDefinition>) => TPaginationState;
@@ -0,0 +1 @@
1
+ export type { TRowItem, TSelectionState, TSelectionAction, } from './use-row-selection';
@@ -1 +1,2 @@
1
1
  export { default } from './use-row-selection';
2
+ export * from './export-types';
@@ -1,6 +1,23 @@
1
- interface TRowItem {
1
+ export interface TRowItem {
2
2
  id: string;
3
3
  }
4
+ export type TSelectionState = {
5
+ [id: string]: boolean;
6
+ };
7
+ export type TSelectionAction = {
8
+ type: 'toggle';
9
+ payload: string;
10
+ } | {
11
+ type: 'select';
12
+ payload: string;
13
+ } | {
14
+ type: 'deselect';
15
+ payload: string;
16
+ } | {
17
+ type: 'selectAll';
18
+ } | {
19
+ type: 'deselectAll';
20
+ };
4
21
  declare const useRowSelection: <RowItem extends TRowItem = TRowItem>(keyName: string, rows: RowItem[]) => {
5
22
  rows: (RowItem & {
6
23
  [x: string]: boolean;
@@ -0,0 +1 @@
1
+ export type { TItem, TSortDirection, TSortingState } from './use-sorting';
@@ -1 +1,2 @@
1
1
  export { default } from './use-sorting';
2
+ export * from './export-types';
@@ -1,10 +1,15 @@
1
1
  /// <reference types="lodash" />
2
2
  import sortBy from 'lodash/sortBy';
3
- interface TItem {
3
+ export interface TItem {
4
4
  id: string;
5
5
  }
6
- type TSortDirection = 'asc' | 'desc';
7
- type TSortingFn = typeof sortBy;
6
+ export type TSortDirection = 'asc' | 'desc';
7
+ export type TSortingState<Item extends TItem = TItem> = {
8
+ items: Item[];
9
+ sortedBy?: string;
10
+ sortDirection?: TSortDirection;
11
+ };
12
+ export type TSortingFn = typeof sortBy;
8
13
  declare const useSorting: <Item extends TItem = TItem>(items: Item[], field?: string, sortDirection?: TSortDirection, sortingFunction?: TSortingFn) => {
9
14
  items: Item[];
10
15
  sortedBy: string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/hooks",
3
3
  "description": "A collection of React hooks used across some of the UI-Kit components.",
4
- "version": "15.13.2",
4
+ "version": "15.14.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/utils": "15.13.2",
24
+ "@commercetools-uikit/utils": "15.14.0",
25
25
  "@types/raf-schd": "^4.0.1",
26
26
  "lodash": "4.17.21",
27
27
  "raf-schd": "^4.0.3"