@ostack.tech/ui 0.3.1 → 0.3.3

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.
@@ -1,4 +1,5 @@
1
- import { ComponentPropsWithoutRef, ReactNode } from 'react';
1
+ import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactNode } from 'react';
2
+ import { IconButton } from '../IconButton';
2
3
  /** Properties of the data table pagination component. */
3
4
  export interface DataTablePaginationProps extends ComponentPropsWithoutRef<"div"> {
4
5
  /**
@@ -13,6 +14,13 @@ export interface DataTablePaginationProps extends ComponentPropsWithoutRef<"div"
13
14
  previousPageButtonLabel?: string;
14
15
  /** Label of the next page button (only relevant in paged mode). */
15
16
  nextPageButtonLabel?: string;
17
+ /**
18
+ * Properties to pass to the previous page button (only relevant in paged
19
+ * mode).
20
+ */
21
+ previousPageButtonProps?: ComponentPropsWithRef<typeof IconButton>;
22
+ /** Properties to pass to the next page button (only relevant in paged mode). */
23
+ nextPageButtonProps?: ComponentPropsWithRef<typeof IconButton>;
16
24
  }
17
25
  /** Component used to provide pagination to the data table. */
18
26
  export declare const DataTablePagination: import('react').ForwardRefExoticComponent<DataTablePaginationProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,7 @@
1
1
  import { ComponentPropsWithoutRef } from 'react';
2
2
  import { DataTablePaginationProps } from './DataTablePagination.tsx';
3
3
  /** Properties of the scrolled data table pagination. */
4
- export interface PagedDataTablePaginationProps extends ComponentPropsWithoutRef<"div">, Pick<DataTablePaginationProps, "rowsRange" | "previousPageButtonLabel" | "nextPageButtonLabel"> {
4
+ export interface PagedDataTablePaginationProps extends ComponentPropsWithoutRef<"div">, Pick<DataTablePaginationProps, "rowsRange" | "previousPageButtonLabel" | "nextPageButtonLabel" | "previousPageButtonProps" | "nextPageButtonProps"> {
5
5
  }
6
6
  /** Pagination component of the scrolled data table. */
7
7
  export declare const PagedDataTablePagination: import('react').ForwardRefExoticComponent<PagedDataTablePaginationProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -71,6 +71,7 @@ export * from './utils/control.ts';
71
71
  export * from './utils/cx.ts';
72
72
  export * from './utils/filtering.ts';
73
73
  export * from './utils/keyboardShortcut.ts';
74
+ export * from './utils/locationUtils.ts';
74
75
  export * from './utils/mergeAriaIds.ts';
75
76
  export * from './utils/nativeControls.ts';
76
77
  export * from './utils/numericStringUtils.ts';
@@ -0,0 +1,85 @@
1
+ /** Representation of the URL's location path (`pathname`, `search`, and `hash`). */
2
+ interface LocationPath {
3
+ /**
4
+ * String containing the pathname of the URL.
5
+ *
6
+ * _E.g._, `/foo/bar` in `https://example.org:8080/foo/bar?q=baz#bang`.
7
+ */
8
+ readonly pathname: string;
9
+ /**
10
+ * Search string (also known as _query string_): `"?"` followed by the
11
+ * parameters of the URL or an empty string if there are no such parameters.
12
+ *
13
+ * _E.g._, `?q=baz` in `https://example.org:8080/foo/bar?q=baz#bang`.
14
+ */
15
+ readonly search: string;
16
+ /**
17
+ * `"#"` followed by the fragment identifier of the URL or an empty string if
18
+ * there is no fragment identifier.
19
+ *
20
+ * _E.g._, `#bang` in `https://example.org:8080/foo/bar?q=baz#bang`.
21
+ */
22
+ readonly hash: string;
23
+ }
24
+ /** Options used to navigate to a new location. */
25
+ export interface NavigationOptions {
26
+ /** Optional state to push. */
27
+ state?: unknown;
28
+ /**
29
+ * Whether to replace the current history entry.
30
+ *
31
+ * @default false
32
+ */
33
+ replace?: boolean;
34
+ }
35
+ /** Result of the {@link useLocation} hook. */
36
+ export type UseLocationResult = [
37
+ location: LocationPath,
38
+ navigate: (url: string | URL, options?: NavigationOptions) => void
39
+ ];
40
+ /**
41
+ * Hook exposing the current location and a function to navigate to a new
42
+ * location.
43
+ */
44
+ export declare function useLocation(): UseLocationResult;
45
+ /** Options used to navigate to the new search parameters. */
46
+ export interface SetSearchParamsOptions extends NavigationOptions {
47
+ /**
48
+ * Whether to clear the URL's hash when navigating.
49
+ *
50
+ * @default false
51
+ */
52
+ clearHash?: boolean;
53
+ }
54
+ /** Result of the {@link useSearchParams} hook. */
55
+ export type UseSearchParamsResult = [
56
+ searchParams: URLSearchParams,
57
+ setSearchParams: (nextSearchParams: (string[][] | Record<string, string> | string | URLSearchParams) | ((prevSearchParams: URLSearchParams) => string[][] | Record<string, string> | string | URLSearchParams), options?: SetSearchParamsOptions) => void
58
+ ];
59
+ /**
60
+ * Hook exposing the current URL search parameters and a function to update
61
+ * them.
62
+ */
63
+ export declare function useSearchParams(): UseSearchParamsResult;
64
+ /** Options used to navigate to the new search parameter. */
65
+ export interface SetSearchParamOptions extends SetSearchParamsOptions {
66
+ /**
67
+ * Whether the search parameter should be cleared when its value equals the
68
+ * default value.
69
+ *
70
+ * @default false
71
+ */
72
+ clearDefaultValue?: boolean;
73
+ }
74
+ /** Result of the {@link useSearchParam} hook. */
75
+ export type UseSearchParamResult<TValue extends string | undefined = string | undefined> = [
76
+ searchParamValue: TValue,
77
+ setSearchParamValue: (nextSearchParamValue: string | number | bigint | boolean | null | undefined | ((prevSearchParamValue: TValue) => string | number | bigint | boolean | null | undefined), options?: SetSearchParamOptions) => void
78
+ ];
79
+ /**
80
+ * Hook exposing the value of a single URL search parameter and a function to
81
+ * update it.
82
+ */
83
+ export declare function useSearchParam(searchParam: string): UseSearchParamResult;
84
+ export declare function useSearchParam(searchParam: string, defaultValue: string): UseSearchParamResult<string>;
85
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ostack.tech/ui",
3
3
  "description": "ostack/UI component library.",
4
- "version": "0.3.1",
4
+ "version": "0.3.3",
5
5
  "homepage": "https://ui.ostack.tech/",
6
6
  "author": {
7
7
  "name": "Opensoft",