@up42/up-components 8.1.0 → 8.3.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/cjs/index.js +2 -2
- package/dist/cjs/types/components/ActionToolbar/ActionToolbar.d.ts +49 -0
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/cjs/types/utils/hooks/useUrlParams/index.d.ts +3 -0
- package/dist/cjs/types/utils/hooks/useUrlParams/types.d.ts +22 -0
- package/dist/cjs/types/utils/hooks/useUrlParams/useUrlParams.d.ts +11 -0
- package/dist/cjs/types/utils/hooks/useUrlParams/useUrlParams.test.d.ts +1 -0
- package/dist/cjs/types/utils/hooks/useUrlParams/utils.d.ts +19 -0
- package/dist/cjs/types/utils/hooks/useUrlParams/utils.test.d.ts +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/types/components/ActionToolbar/ActionToolbar.d.ts +49 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/utils/hooks/useUrlParams/index.d.ts +3 -0
- package/dist/esm/types/utils/hooks/useUrlParams/types.d.ts +22 -0
- package/dist/esm/types/utils/hooks/useUrlParams/useUrlParams.d.ts +11 -0
- package/dist/esm/types/utils/hooks/useUrlParams/useUrlParams.test.d.ts +1 -0
- package/dist/esm/types/utils/hooks/useUrlParams/utils.d.ts +19 -0
- package/dist/esm/types/utils/hooks/useUrlParams/utils.test.d.ts +1 -0
- package/dist/index.d.ts +105 -5
- package/package.json +3 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
export type ActionToolbarProps = {
|
|
4
|
+
count: number;
|
|
5
|
+
singleLabel?: string;
|
|
6
|
+
multipleLabel?: string;
|
|
7
|
+
clearLabel?: string;
|
|
8
|
+
onClearSelection: () => void;
|
|
9
|
+
centerSlot?: ReactNode;
|
|
10
|
+
actionsSlot?: ReactNode;
|
|
11
|
+
color?: Color;
|
|
12
|
+
sx?: SxProps<Theme>;
|
|
13
|
+
/**
|
|
14
|
+
* This property defines the position where the component will be displayed.
|
|
15
|
+
* It is not part of the styling properties since this is taken as a configuration property.
|
|
16
|
+
*/
|
|
17
|
+
position: 'bottom' | 'top';
|
|
18
|
+
/**
|
|
19
|
+
* This property defines the padding applied to the component in relation to the "position" property.
|
|
20
|
+
* It is not part of the styling properties since this is taken as a configuration property.
|
|
21
|
+
*/
|
|
22
|
+
padding: string;
|
|
23
|
+
};
|
|
24
|
+
declare const COLORS: {
|
|
25
|
+
readonly primary: {
|
|
26
|
+
readonly bgColor: string;
|
|
27
|
+
readonly borderColor: string;
|
|
28
|
+
readonly textColor: string;
|
|
29
|
+
readonly badgeColor: string;
|
|
30
|
+
readonly badgeText: string;
|
|
31
|
+
};
|
|
32
|
+
readonly info: {
|
|
33
|
+
readonly bgColor: string;
|
|
34
|
+
readonly borderColor: string;
|
|
35
|
+
readonly textColor: string;
|
|
36
|
+
readonly badgeColor: string;
|
|
37
|
+
readonly badgeText: string;
|
|
38
|
+
};
|
|
39
|
+
readonly warning: {
|
|
40
|
+
readonly bgColor: string;
|
|
41
|
+
readonly borderColor: string;
|
|
42
|
+
readonly textColor: string;
|
|
43
|
+
readonly badgeColor: string;
|
|
44
|
+
readonly badgeText: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
type Color = keyof typeof COLORS;
|
|
48
|
+
export declare const ActionToolbar: ({ count, singleLabel, multipleLabel, clearLabel, onClearSelection, centerSlot, actionsSlot, color, sx, position, padding, }: ActionToolbarProps) => React.JSX.Element;
|
|
49
|
+
export {};
|
|
@@ -63,6 +63,7 @@ export { DataGrid, GridRow, GridCell, GridEditInputCell, GridCellModes, GridFoot
|
|
|
63
63
|
export type { GridColDef, GridRenderEditCellParams, GridCellModesModel, GridCellParams, GridRenderCellParams, GridRowId, GridRowParams, GridRowSelectionModel, GridRowsProp, GridSortModel, GridTreeNodeWithRender, GridColumnHeaderParams, GridEditCellProps, GridInitialState, GridPreProcessEditCellProps, } from './components/DataGrid/DataGrid';
|
|
64
64
|
export { ToggleButton, type ToggleButtonProps } from './components/ToggleButton/ToggleButton';
|
|
65
65
|
export { FindUsersButton, LearnMoreButton, RoleBanner, type FindUsersButtonProps, type LearnMoreButtonProps, type RoleBannerProps, } from './components/RoleBanner/RoleBanner';
|
|
66
|
+
export { ActionToolbar, type ActionToolbarProps } from './components/ActionToolbar/ActionToolbar';
|
|
66
67
|
export { capitalize } from './utils/helpers/capitalize';
|
|
67
68
|
export { copyToClipboard } from './utils/helpers/copyToClipboard';
|
|
68
69
|
export { formatNumber } from './utils/helpers/formatNumber';
|
|
@@ -76,3 +77,4 @@ export { useCursorPagination, type CursorPaginatedResponse } from './utils/hooks
|
|
|
76
77
|
export { useToggle, type UseToggleResult } from './utils/hooks/useToggle';
|
|
77
78
|
export { useDebounce } from './utils/hooks/useDebounce';
|
|
78
79
|
export { useAlert, type CreateAlertProps, type CreateSnackbarProps, } from './global/providers/AlertProvider/AlertProvider';
|
|
80
|
+
export { useUrlParams, searchParamsToObject, objectToSearchParams, valueToString, type ParamsObject, type RemoveParamRules, type SearchParamObject, } from './utils/hooks/useUrlParams';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type SearchParamObject = Record<string, string>;
|
|
2
|
+
export type ParamsObject = Record<string, unknown>;
|
|
3
|
+
export type RemoveParamRules<T extends ParamsObject = ParamsObject> = {
|
|
4
|
+
[K in keyof T]?: (value: T[K]) => boolean;
|
|
5
|
+
};
|
|
6
|
+
export type Options<T extends ParamsObject> = {
|
|
7
|
+
cast: (search: SearchParamObject) => T;
|
|
8
|
+
parse: (searchParam: URLSearchParams) => SearchParamObject;
|
|
9
|
+
stringify: (searchParamsObject: T) => ReturnType<URLSearchParams['toString']>;
|
|
10
|
+
removeParams: RemoveParamRules<T>;
|
|
11
|
+
};
|
|
12
|
+
export type PartialOptions<T extends ParamsObject> = Partial<Options<T>>;
|
|
13
|
+
export type UseUrlParamsReturn<T extends ParamsObject> = {
|
|
14
|
+
/** Search params object literal. */
|
|
15
|
+
params: T;
|
|
16
|
+
/** Navigate using given search params object literal. */
|
|
17
|
+
setParams: (params: ParamsObject) => void;
|
|
18
|
+
/** Stringified search params for use when navigating to other paths. */
|
|
19
|
+
stringParams: string;
|
|
20
|
+
/** Default params obtained by running the cast function with an empty object. Useful for resetting filters to their initial state. */
|
|
21
|
+
defaultParams: T;
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ParamsObject, PartialOptions, UseUrlParamsReturn } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses URLSearchParams into an object and supports navigating with updated search params.
|
|
4
|
+
* Supports custom parsing (e.g. arrays, dates) and serialization back to a search string.
|
|
5
|
+
*
|
|
6
|
+
* @param options.cast - How to turn Record<string, string> into the params object (required when using typed params).
|
|
7
|
+
* @param options.parse - How to turn URLSearchParams into Record<string, string>. Default: entries as-is.
|
|
8
|
+
* @param options.stringify - How to stringify the params object. Default: arrays as comma-separated, dates as YYYY-MM-DD.
|
|
9
|
+
* @param options.removeParams - Map of param keys to predicate functions; when setParams runs, params whose predicate returns true are removed from the URL.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useUrlParams<TParams extends ParamsObject>(options?: PartialOptions<TParams>): UseUrlParamsReturn<TParams>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ParamsObject, SearchParamObject } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* There could be many ways to parse URLSearchParams to an object.
|
|
4
|
+
* For example, how should `a` be treated in `a=1&b=2&a=3`?
|
|
5
|
+
* This implementation is a choice.
|
|
6
|
+
*/
|
|
7
|
+
export declare function searchParamsToObject(searchParam: URLSearchParams): SearchParamObject;
|
|
8
|
+
/**
|
|
9
|
+
* Stringify a value to a string.
|
|
10
|
+
* @param value - The value to stringify.
|
|
11
|
+
* @returns The stringified value.
|
|
12
|
+
*/
|
|
13
|
+
export declare function valueToString(value: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* There could be many ways to serialize an object to URLSearchParams.
|
|
16
|
+
* For example, how should `d` be treated in `{ d: new Date() }`? How should arrays behave?
|
|
17
|
+
* This implementation is a choice.
|
|
18
|
+
*/
|
|
19
|
+
export declare function objectToSearchParams<T extends ParamsObject = ParamsObject>(object: T): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -11255,7 +11255,7 @@ type FeatureCardHeaderActionsProps = {
|
|
|
11255
11255
|
};
|
|
11256
11256
|
declare const FeatureCardHeaderActions: ({ iconActions, menuActions }: FeatureCardHeaderActionsProps) => React__default.JSX.Element;
|
|
11257
11257
|
|
|
11258
|
-
declare const COLORS: {
|
|
11258
|
+
declare const COLORS$1: {
|
|
11259
11259
|
primary: string;
|
|
11260
11260
|
secondary: string;
|
|
11261
11261
|
success: string;
|
|
@@ -11285,12 +11285,12 @@ declare const SIZES: {
|
|
|
11285
11285
|
};
|
|
11286
11286
|
};
|
|
11287
11287
|
type Variant = 'filled' | 'half';
|
|
11288
|
-
type Color = keyof typeof COLORS;
|
|
11288
|
+
type Color$1 = keyof typeof COLORS$1;
|
|
11289
11289
|
type Size = keyof typeof SIZES;
|
|
11290
11290
|
type StatusLightProps = {
|
|
11291
11291
|
label: string;
|
|
11292
11292
|
variant?: Variant;
|
|
11293
|
-
color?: Color;
|
|
11293
|
+
color?: Color$1;
|
|
11294
11294
|
size?: Size;
|
|
11295
11295
|
sx?: SxProps<Theme>;
|
|
11296
11296
|
};
|
|
@@ -11486,6 +11486,53 @@ declare function LearnMoreButton(props: LearnMoreButtonProps): React__default.JS
|
|
|
11486
11486
|
type FindUsersButtonProps = ButtonProps;
|
|
11487
11487
|
declare function FindUsersButton(props: FindUsersButtonProps): React__default.JSX.Element;
|
|
11488
11488
|
|
|
11489
|
+
type ActionToolbarProps = {
|
|
11490
|
+
count: number;
|
|
11491
|
+
singleLabel?: string;
|
|
11492
|
+
multipleLabel?: string;
|
|
11493
|
+
clearLabel?: string;
|
|
11494
|
+
onClearSelection: () => void;
|
|
11495
|
+
centerSlot?: ReactNode;
|
|
11496
|
+
actionsSlot?: ReactNode;
|
|
11497
|
+
color?: Color;
|
|
11498
|
+
sx?: SxProps<Theme>;
|
|
11499
|
+
/**
|
|
11500
|
+
* This property defines the position where the component will be displayed.
|
|
11501
|
+
* It is not part of the styling properties since this is taken as a configuration property.
|
|
11502
|
+
*/
|
|
11503
|
+
position: 'bottom' | 'top';
|
|
11504
|
+
/**
|
|
11505
|
+
* This property defines the padding applied to the component in relation to the "position" property.
|
|
11506
|
+
* It is not part of the styling properties since this is taken as a configuration property.
|
|
11507
|
+
*/
|
|
11508
|
+
padding: string;
|
|
11509
|
+
};
|
|
11510
|
+
declare const COLORS: {
|
|
11511
|
+
readonly primary: {
|
|
11512
|
+
readonly bgColor: string;
|
|
11513
|
+
readonly borderColor: string;
|
|
11514
|
+
readonly textColor: string;
|
|
11515
|
+
readonly badgeColor: string;
|
|
11516
|
+
readonly badgeText: string;
|
|
11517
|
+
};
|
|
11518
|
+
readonly info: {
|
|
11519
|
+
readonly bgColor: string;
|
|
11520
|
+
readonly borderColor: string;
|
|
11521
|
+
readonly textColor: string;
|
|
11522
|
+
readonly badgeColor: string;
|
|
11523
|
+
readonly badgeText: string;
|
|
11524
|
+
};
|
|
11525
|
+
readonly warning: {
|
|
11526
|
+
readonly bgColor: string;
|
|
11527
|
+
readonly borderColor: string;
|
|
11528
|
+
readonly textColor: string;
|
|
11529
|
+
readonly badgeColor: string;
|
|
11530
|
+
readonly badgeText: string;
|
|
11531
|
+
};
|
|
11532
|
+
};
|
|
11533
|
+
type Color = keyof typeof COLORS;
|
|
11534
|
+
declare const ActionToolbar: ({ count, singleLabel, multipleLabel, clearLabel, onClearSelection, centerSlot, actionsSlot, color, sx, position, padding, }: ActionToolbarProps) => React__default.JSX.Element;
|
|
11535
|
+
|
|
11489
11536
|
/**
|
|
11490
11537
|
* It should to be noted that this helper isn't equivalent to `text-transform: capitalize`.
|
|
11491
11538
|
* A strict capitalization should uppercase the first letter of each word in the sentence.
|
|
@@ -11714,5 +11761,58 @@ type ContextState = {
|
|
|
11714
11761
|
*/
|
|
11715
11762
|
declare const useAlert: () => ContextState;
|
|
11716
11763
|
|
|
11717
|
-
|
|
11718
|
-
|
|
11764
|
+
type SearchParamObject = Record<string, string>;
|
|
11765
|
+
type ParamsObject = Record<string, unknown>;
|
|
11766
|
+
type RemoveParamRules<T extends ParamsObject = ParamsObject> = {
|
|
11767
|
+
[K in keyof T]?: (value: T[K]) => boolean;
|
|
11768
|
+
};
|
|
11769
|
+
type Options<T extends ParamsObject> = {
|
|
11770
|
+
cast: (search: SearchParamObject) => T;
|
|
11771
|
+
parse: (searchParam: URLSearchParams) => SearchParamObject;
|
|
11772
|
+
stringify: (searchParamsObject: T) => ReturnType<URLSearchParams['toString']>;
|
|
11773
|
+
removeParams: RemoveParamRules<T>;
|
|
11774
|
+
};
|
|
11775
|
+
type PartialOptions<T extends ParamsObject> = Partial<Options<T>>;
|
|
11776
|
+
type UseUrlParamsReturn<T extends ParamsObject> = {
|
|
11777
|
+
/** Search params object literal. */
|
|
11778
|
+
params: T;
|
|
11779
|
+
/** Navigate using given search params object literal. */
|
|
11780
|
+
setParams: (params: ParamsObject) => void;
|
|
11781
|
+
/** Stringified search params for use when navigating to other paths. */
|
|
11782
|
+
stringParams: string;
|
|
11783
|
+
/** Default params obtained by running the cast function with an empty object. Useful for resetting filters to their initial state. */
|
|
11784
|
+
defaultParams: T;
|
|
11785
|
+
};
|
|
11786
|
+
|
|
11787
|
+
/**
|
|
11788
|
+
* Parses URLSearchParams into an object and supports navigating with updated search params.
|
|
11789
|
+
* Supports custom parsing (e.g. arrays, dates) and serialization back to a search string.
|
|
11790
|
+
*
|
|
11791
|
+
* @param options.cast - How to turn Record<string, string> into the params object (required when using typed params).
|
|
11792
|
+
* @param options.parse - How to turn URLSearchParams into Record<string, string>. Default: entries as-is.
|
|
11793
|
+
* @param options.stringify - How to stringify the params object. Default: arrays as comma-separated, dates as YYYY-MM-DD.
|
|
11794
|
+
* @param options.removeParams - Map of param keys to predicate functions; when setParams runs, params whose predicate returns true are removed from the URL.
|
|
11795
|
+
*/
|
|
11796
|
+
declare function useUrlParams<TParams extends ParamsObject>(options?: PartialOptions<TParams>): UseUrlParamsReturn<TParams>;
|
|
11797
|
+
|
|
11798
|
+
/**
|
|
11799
|
+
* There could be many ways to parse URLSearchParams to an object.
|
|
11800
|
+
* For example, how should `a` be treated in `a=1&b=2&a=3`?
|
|
11801
|
+
* This implementation is a choice.
|
|
11802
|
+
*/
|
|
11803
|
+
declare function searchParamsToObject(searchParam: URLSearchParams): SearchParamObject;
|
|
11804
|
+
/**
|
|
11805
|
+
* Stringify a value to a string.
|
|
11806
|
+
* @param value - The value to stringify.
|
|
11807
|
+
* @returns The stringified value.
|
|
11808
|
+
*/
|
|
11809
|
+
declare function valueToString(value: unknown): string;
|
|
11810
|
+
/**
|
|
11811
|
+
* There could be many ways to serialize an object to URLSearchParams.
|
|
11812
|
+
* For example, how should `d` be treated in `{ d: new Date() }`? How should arrays behave?
|
|
11813
|
+
* This implementation is a choice.
|
|
11814
|
+
*/
|
|
11815
|
+
declare function objectToSearchParams<T extends ParamsObject = ParamsObject>(object: T): string;
|
|
11816
|
+
|
|
11817
|
+
export { ActionToolbar, Alert, Avatar, Badge, Banner, Button, Checkbox, CodeBlock, CodeInline, CodeSnippet, ContactBox, ControlButton, CopyButton, DataGrid, DateTime, Divider, DocumentationPopover, EditTagsButton, EmptyState, FeatureCard, FeatureCardHeader, FeatureCardHeaderActions, FeatureFlagCheckbox, FilterPopover, FindUsersButton, FormCheckbox, FormDatePicker, FormDateRangePicker, FormDateRangePickerList, FormDateTimePicker, FormInput, FormRadio, FormSelect, FormSwitch, GridContainer, GridItem, Icon, Illustration, InfoCard, InfoModal, InfoPopover, Input, LearnMoreButton, Link, Loading, Logo, NotFound, PageContainer, PageHeader, PageHeaderV2, Popover, Radio, RoleBanner, Select, Slider, StatusLight, Switch, Tab, TabGroup, Table, TableBody, TableCell, TableContainer, TableFooter, TableHead, TablePagination, TableRow, TableSortLabel, Tabs, Tag, TagsList, ToggleButton, Typography, UpComponentsProvider, analytics, capitalize, copyToClipboard, formatDate, formatFileSize, formatNumber, generateQueryKey, objectToSearchParams, searchParamsToObject, theme, useAlert, useCursorPagination, useDebounce, useQueryParams, useRemotePagination, useToggle, useUrlParams, valueToString };
|
|
11818
|
+
export type { ActionToolbarProps, AlertProps, AnalyticsConfig, AvatarProps, BadgeProps, BannerProps, ButtonProps, CheckboxProps, CodeBlockProps, CodeInlineProps, CodeSnippetItemProps, CodeSnippetProps, ContactBoxProps, ControlButtonProps, CopyButtonProps, CreateAlertProps, CreateSnackbarProps, CursorPaginatedResponse, DateRange, DateTimeProps, DividerProps, DocumentationPopoverProps, EditTagsButtonProps, EmptyStateProps, FeatureCardHeaderActionsProps, FeatureCardHeaderProps, FeatureCardProps, FeatureFlagCheckboxProps, FilterPopoverProps, FindUsersButtonProps, FormCheckboxProps, FormDatePickerDateType, FormDatePickerProps, FormDateRangePickerListProps, FormDateRangePickerProps, FormDateTimePickerProps, FormInputProps, FormRadioProps, FormSelectProps, FormSwitchProps, GridContainerProps, GridItemProps, IconAction, IconProps$1 as IconProps, IllustrationProps, InfoCardProps, InfoModalProps, InfoPopoverProps, InputProps, LearnMoreButtonProps, LinkProps, LoadingProps, LogoProps, MenuAction, NotFoundProps, PageContainerProps, PageHeaderProps, PageHeaderV2Props, PaginatedResponse, ParamsObject, PopoverProps, RadioProps, RemoveParamRules, RoleBannerProps, SearchParamObject, SelectProps, SliderProps, StatusLightProps, SwitchProps, TabGroupProps, TabProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TableSortLabelProps, TabsProps, TagItem, TagProps, TagsListProps, ToggleButtonProps, TypographyProps, UseToggleResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@up42/up-components",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "UP42 Component Library",
|
|
5
5
|
"author": "Axel Fuhrmann axel.fuhrmann@up42.com",
|
|
6
6
|
"license": "ISC",
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"lint-staged": "^12.3.1",
|
|
79
79
|
"prettier": "^2.5.1",
|
|
80
80
|
"react": "^18.3.1",
|
|
81
|
-
"react-router": "^7.12.0",
|
|
82
81
|
"rimraf": "^6.1.2",
|
|
83
82
|
"rollup": "^4.59.0",
|
|
84
83
|
"rollup-plugin-dts": "^6.1.0",
|
|
@@ -99,7 +98,8 @@
|
|
|
99
98
|
"@mui/x-data-grid-premium": "^6.8.0",
|
|
100
99
|
"@mui/x-date-pickers-pro": "^6.8.0",
|
|
101
100
|
"react": "^18.3.1",
|
|
102
|
-
"react-dom": "^18.3.1"
|
|
101
|
+
"react-dom": "^18.3.1",
|
|
102
|
+
"react-router": "^7.12.0"
|
|
103
103
|
},
|
|
104
104
|
"lint-staged": {
|
|
105
105
|
"*.{js,tsx,ts}": "eslint --cache --fix",
|