@j2-health/design-system 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.
- package/README.md +113 -0
- package/dist/favicon.png +0 -0
- package/dist/index.cjs +3624 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +3606 -0
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +2 -0
- package/dist/src/AppConfigProvider.d.ts +4 -0
- package/dist/src/appTheme.d.ts +2 -0
- package/dist/src/components/alert/Alert.d.ts +11 -0
- package/dist/src/components/alert/index.d.ts +1 -0
- package/dist/src/components/barchart/BarChart.d.ts +30 -0
- package/dist/src/components/barchart/index.d.ts +2 -0
- package/dist/src/components/breadcrumb/Breadcrumb.d.ts +14 -0
- package/dist/src/components/breadcrumb/index.d.ts +1 -0
- package/dist/src/components/bulkActionBar/BulkActionBar.d.ts +38 -0
- package/dist/src/components/bulkActionBar/index.d.ts +1 -0
- package/dist/src/components/button/Button.d.ts +4 -0
- package/dist/src/components/button/index.d.ts +1 -0
- package/dist/src/components/card/Card.d.ts +19 -0
- package/dist/src/components/card/index.d.ts +1 -0
- package/dist/src/components/checkbox/Checkbox.d.ts +7 -0
- package/dist/src/components/checkbox/index.d.ts +1 -0
- package/dist/src/components/checkboxTree/CheckboxTree.d.ts +27 -0
- package/dist/src/components/checkboxTree/TreeNode.d.ts +13 -0
- package/dist/src/components/checkboxTree/index.d.ts +1 -0
- package/dist/src/components/checkboxTree/utils.d.ts +9 -0
- package/dist/src/components/collapse/Collapse.d.ts +9 -0
- package/dist/src/components/collapse/index.d.ts +1 -0
- package/dist/src/components/drawer/Drawer.d.ts +9 -0
- package/dist/src/components/drawer/index.d.ts +1 -0
- package/dist/src/components/dropdown/Dropdown.d.ts +17 -0
- package/dist/src/components/dropdown/index.d.ts +1 -0
- package/dist/src/components/filterform/FilterGroup.d.ts +16 -0
- package/dist/src/components/filterform/FilterInput.d.ts +14 -0
- package/dist/src/components/filterform/FiltersForm.d.ts +10 -0
- package/dist/src/components/filterform/filterHelpers.d.ts +11 -0
- package/dist/src/components/filterform/index.d.ts +2 -0
- package/dist/src/components/filterform/types.d.ts +52 -0
- package/dist/src/components/filterform/useFilterField.d.ts +43 -0
- package/dist/src/components/filterform/useFiltersForm.d.ts +59 -0
- package/dist/src/components/form/Form.d.ts +7 -0
- package/dist/src/components/form/index.d.ts +1 -0
- package/dist/src/components/icons/index.d.ts +1 -0
- package/dist/src/components/input/AntdInput.d.ts +322 -0
- package/dist/src/components/input/AntdSearchInput.d.ts +327 -0
- package/dist/src/components/input/Input.d.ts +4 -0
- package/dist/src/components/input/index.d.ts +3 -0
- package/dist/src/components/inputnumber/InputNumber.d.ts +9 -0
- package/dist/src/components/inputnumber/index.d.ts +1 -0
- package/dist/src/components/legacyNavMenu/LegacyNavMenu.d.ts +27 -0
- package/dist/src/components/legacyNavMenu/UserProfile.d.ts +9 -0
- package/dist/src/components/legacyNavMenu/index.d.ts +4 -0
- package/dist/src/components/listpopover/ListPopover.d.ts +17 -0
- package/dist/src/components/listpopover/index.d.ts +1 -0
- package/dist/src/components/menu/Menu.d.ts +7 -0
- package/dist/src/components/menu/index.d.ts +2 -0
- package/dist/src/components/message/index.d.ts +2 -0
- package/dist/src/components/message/useMessage.d.ts +7 -0
- package/dist/src/components/modal/Modal.d.ts +6 -0
- package/dist/src/components/modal/index.d.ts +2 -0
- package/dist/src/components/navMenu/NavMenu.d.ts +14 -0
- package/dist/src/components/navMenu/index.d.ts +1 -0
- package/dist/src/components/notification/index.d.ts +2 -0
- package/dist/src/components/notification/useNotification.d.ts +10 -0
- package/dist/src/components/notificationModal/NotificationModal.d.ts +11 -0
- package/dist/src/components/notificationModal/index.d.ts +2 -0
- package/dist/src/components/pagination/Pagination.d.ts +18 -0
- package/dist/src/components/pagination/index.d.ts +1 -0
- package/dist/src/components/popover/Popover.d.ts +10 -0
- package/dist/src/components/popover/index.d.ts +1 -0
- package/dist/src/components/progress/Progress.d.ts +3 -0
- package/dist/src/components/progress/index.d.ts +1 -0
- package/dist/src/components/radio/Radio.d.ts +10 -0
- package/dist/src/components/radio/index.d.ts +1 -0
- package/dist/src/components/rate/Rate.d.ts +3 -0
- package/dist/src/components/rate/index.d.ts +1 -0
- package/dist/src/components/select/AntdSelect.d.ts +5 -0
- package/dist/src/components/select/Select.d.ts +7 -0
- package/dist/src/components/select/SummarizedSelect.d.ts +44 -0
- package/dist/src/components/select/index.d.ts +4 -0
- package/dist/src/components/skeleton/Skeleton.d.ts +11 -0
- package/dist/src/components/skeleton/index.d.ts +1 -0
- package/dist/src/components/spinner/Spinner.d.ts +6 -0
- package/dist/src/components/spinner/index.d.ts +1 -0
- package/dist/src/components/steps/Steps.d.ts +10 -0
- package/dist/src/components/steps/index.d.ts +2 -0
- package/dist/src/components/steps/useSteps.d.ts +17 -0
- package/dist/src/components/switch/Switch.d.ts +11 -0
- package/dist/src/components/switch/index.d.ts +1 -0
- package/dist/src/components/table/Table.d.ts +24 -0
- package/dist/src/components/table/index.d.ts +1 -0
- package/dist/src/components/tabs/Tabs.d.ts +3 -0
- package/dist/src/components/tabs/index.d.ts +1 -0
- package/dist/src/components/tag/Tag.d.ts +20 -0
- package/dist/src/components/tag/index.d.ts +1 -0
- package/dist/src/components/tooltip/Tooltip.d.ts +4 -0
- package/dist/src/components/tooltip/index.d.ts +1 -0
- package/dist/src/components/vennDiagram/VennDiagram.d.ts +9 -0
- package/dist/src/components/vennDiagram/index.d.ts +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/vite-env.d.ts +1 -0
- package/dist/style.css +1254 -0
- package/dist/tailwind.cjs +170 -0
- package/dist/tailwind.cjs.map +1 -0
- package/dist/tailwind.config.d.ts +305 -0
- package/dist/tailwind.js +170 -0
- package/dist/tailwind.js.map +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +125 -0
- package/src/stylesheets/index.css +327 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HighchartsReactRefObject } from '@highcharts/react';
|
|
2
|
+
import type * as Highcharts from '../../../node_modules/highcharts/highcharts.src';
|
|
3
|
+
type Series = {
|
|
4
|
+
name?: string;
|
|
5
|
+
data: Highcharts.PointOptionsObject[] | number[];
|
|
6
|
+
color?: string;
|
|
7
|
+
hoverColor?: string;
|
|
8
|
+
};
|
|
9
|
+
type BarChartProps = {
|
|
10
|
+
categories: string[];
|
|
11
|
+
series: Series[];
|
|
12
|
+
min: number;
|
|
13
|
+
max: number | undefined | null;
|
|
14
|
+
tickInterval: number | undefined;
|
|
15
|
+
tickFormat?: (value: number) => string;
|
|
16
|
+
xAxisTitle?: string;
|
|
17
|
+
yAxisTitle?: string;
|
|
18
|
+
gridLineColor?: string;
|
|
19
|
+
gridLineDashStyle?: Highcharts.DashStyleValue;
|
|
20
|
+
xAxisLabelMaxLines?: number;
|
|
21
|
+
tooltip: (category: string | number | undefined, value: number | null | undefined, seriesName: string | undefined) => React.ReactNode;
|
|
22
|
+
chartRef?: React.RefObject<HighchartsReactRefObject>;
|
|
23
|
+
exporting?: Highcharts.ExportingOptions;
|
|
24
|
+
maxBars?: number;
|
|
25
|
+
barsWidth?: number;
|
|
26
|
+
height?: number;
|
|
27
|
+
width?: number;
|
|
28
|
+
};
|
|
29
|
+
declare const BarChart: ({ categories, series, min, max, tickInterval, tickFormat, xAxisTitle, yAxisTitle, gridLineColor, gridLineDashStyle, xAxisLabelMaxLines, tooltip, exporting, chartRef, height, width, maxBars, barsWidth, }: BarChartProps) => import("react").JSX.Element;
|
|
30
|
+
export { BarChart };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Icon } from '@phosphor-icons/react';
|
|
2
|
+
import { BreadcrumbProps } from 'antd';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
type ItemConfig = {
|
|
5
|
+
title: string;
|
|
6
|
+
icon?: Icon;
|
|
7
|
+
href?: string;
|
|
8
|
+
onClick?: React.MouseEventHandler;
|
|
9
|
+
};
|
|
10
|
+
export type Props = Expand<Omit<BreadcrumbProps, 'items'> & {
|
|
11
|
+
items: ItemConfig[];
|
|
12
|
+
}>;
|
|
13
|
+
declare const Breadcrumb: ({ items, ...props }: Props) => React.JSX.Element;
|
|
14
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Breadcrumb } from './Breadcrumb';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type BulkActionBarProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Number of rows currently selected. The bar slides in when count > 0
|
|
5
|
+
* and slides out when count returns to 0.
|
|
6
|
+
*/
|
|
7
|
+
count: number;
|
|
8
|
+
/** Primary action (Archive, Restore, Delete, etc.). */
|
|
9
|
+
action: {
|
|
10
|
+
label: string;
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
};
|
|
15
|
+
/** Optional secondary actions rendered between the primary action and Cancel. */
|
|
16
|
+
secondaryActions?: Array<{
|
|
17
|
+
label: string;
|
|
18
|
+
icon?: ReactNode;
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
onClick: () => void;
|
|
21
|
+
}>;
|
|
22
|
+
/** Clears the selection. Renders as the trailing "Cancel" button. */
|
|
23
|
+
onCancel: () => void;
|
|
24
|
+
/** Custom Cancel label. Defaults to `"Cancel"`. */
|
|
25
|
+
cancelLabel?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Floating bulk-action toolbar. Renders fixed to the bottom-center of the
|
|
29
|
+
* viewport and slides in whenever `count > 0`. Use it above any list/table
|
|
30
|
+
* surface that supports row selection — pair with Ant Design's
|
|
31
|
+
* `rowSelection` prop on `<Table>` (or any controlled selection state).
|
|
32
|
+
*
|
|
33
|
+
* Destructive intent is enforced by whatever confirmation modal the host
|
|
34
|
+
* surface shows after `action.onClick` — the bar itself is always neutral
|
|
35
|
+
* (text-on-navy) so it never reads as a one-click destructive control.
|
|
36
|
+
*/
|
|
37
|
+
export declare const BulkActionBar: ({ count, action, secondaryActions, onCancel, cancelLabel, }: BulkActionBarProps) => import("react").JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BulkActionBar } from './BulkActionBar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from './Button';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CardProps } from 'antd';
|
|
2
|
+
export type Props = Omit<CardProps, 'size'> & {
|
|
3
|
+
/** Card title */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Card contents */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Loading state */
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
/** Card size */
|
|
10
|
+
size?: 'default' | 'small' | 'compact' | 'large';
|
|
11
|
+
/**
|
|
12
|
+
* Inner card type variant.
|
|
13
|
+
* It allows inner card to have variants independent of other props.
|
|
14
|
+
* Works only with type="inner".
|
|
15
|
+
*/
|
|
16
|
+
innerVariant?: 'default' | 'basic';
|
|
17
|
+
};
|
|
18
|
+
declare const Card: ({ title, children, loading, size, innerVariant, className, ...props }: Props) => import("react").JSX.Element;
|
|
19
|
+
export { Card };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Card } from './Card';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CheckboxProps } from 'antd';
|
|
2
|
+
type Props = Expand<CheckboxProps>;
|
|
3
|
+
export declare const Checkbox: {
|
|
4
|
+
(props: Props): import("react").JSX.Element;
|
|
5
|
+
Group: <T = any>(props: import('antd/es/checkbox').CheckboxGroupProps<T> & React.RefAttributes<HTMLDivElement>) => React.ReactElement;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Checkbox';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type CheckboxTreeDataNode = {
|
|
3
|
+
key: string | number;
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
children?: CheckboxTreeDataNode[];
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type CheckboxTreeProps = {
|
|
9
|
+
treeData: CheckboxTreeDataNode[];
|
|
10
|
+
defaultCheckedKeys?: (string | number)[];
|
|
11
|
+
checkedKeys?: (string | number)[];
|
|
12
|
+
onCheck?: (values: Record<string | number, boolean>, info: {
|
|
13
|
+
checked: boolean;
|
|
14
|
+
checkedLeafNodes: Record<string | number, CheckboxTreeDataNode>;
|
|
15
|
+
allCheckedNodes: CheckboxTreeDataNode[];
|
|
16
|
+
node: CheckboxTreeDataNode;
|
|
17
|
+
}) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
defaultExpandAll?: boolean;
|
|
20
|
+
defaultExpandedKeys?: (string | number)[];
|
|
21
|
+
expandedKeys?: (string | number)[];
|
|
22
|
+
onExpand?: (expandedKeys: (string | number)[]) => void;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
lazyChildren?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare const CheckboxTree: ({ treeData, defaultCheckedKeys, checkedKeys: controlledCheckedKeys, onCheck, disabled, defaultExpandAll, defaultExpandedKeys, expandedKeys: controlledExpandedKeys, onExpand, className, style, lazyChildren, }: CheckboxTreeProps) => React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CheckboxTreeDataNode } from './CheckboxTree';
|
|
2
|
+
type TreeNodeProps = {
|
|
3
|
+
node: CheckboxTreeDataNode;
|
|
4
|
+
level: number;
|
|
5
|
+
leafNodeValues: Record<string | number, boolean>;
|
|
6
|
+
onCheck: (key: string | number, checked: boolean, node: CheckboxTreeDataNode) => void;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
expandedKeys: Set<string | number>;
|
|
9
|
+
onToggleExpand: (key: string | number) => void;
|
|
10
|
+
lazyChildren: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const TreeNode: ({ node, level, leafNodeValues, onCheck, disabled, expandedKeys, onToggleExpand, lazyChildren, }: TreeNodeProps) => import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CheckboxTree';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CheckboxTreeDataNode } from './CheckboxTree';
|
|
2
|
+
export declare const getLeafKeys: (node: CheckboxTreeDataNode) => (string | number)[];
|
|
3
|
+
export declare const getAllLeafKeys: (nodes: CheckboxTreeDataNode[]) => (string | number)[];
|
|
4
|
+
export declare const getNodeCheckState: (node: CheckboxTreeDataNode, leafNodeStates: Record<string | number, boolean>) => {
|
|
5
|
+
checked: boolean;
|
|
6
|
+
indeterminate: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const getAllParentKeys: (nodes: CheckboxTreeDataNode[]) => (string | number)[];
|
|
9
|
+
export declare const findNode: (key: string | number, nodes: CheckboxTreeDataNode[]) => CheckboxTreeDataNode | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CollapseProps } from 'antd';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export type CollapseState = 'default' | 'warning' | 'error';
|
|
4
|
+
export type Props = Expand<CollapseProps> & {
|
|
5
|
+
state?: CollapseState;
|
|
6
|
+
showIcon?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const Collapse: ({ state, showIcon, className, items, ...props }: Props) => React.JSX.Element;
|
|
9
|
+
export { Collapse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Collapse } from './Collapse';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DrawerProps } from 'antd';
|
|
2
|
+
type AllProps = Omit<DrawerProps, 'extra' | 'closable'> & {
|
|
3
|
+
fillPage?: boolean;
|
|
4
|
+
footer?: React.ReactNode;
|
|
5
|
+
extraContent?: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export type Props = Expand<AllProps>;
|
|
8
|
+
export declare const Drawer: ({ fillPage, footer, extraContent, ...props }: Props) => import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Drawer } from './Drawer';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DropdownProps } from 'antd';
|
|
2
|
+
export type Props = DropdownProps & {
|
|
3
|
+
type?: 'basic' | 'basic-inline' | 'twofold';
|
|
4
|
+
label?: string;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
menuType?: 'default' | 'slim';
|
|
7
|
+
targetClassName?: string;
|
|
8
|
+
};
|
|
9
|
+
export type TargetProps = {
|
|
10
|
+
label?: string;
|
|
11
|
+
type?: 'basic' | 'basic-inline' | 'twofold';
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
declare const Dropdown: ({ label, type, icon, menu, menuType, targetClassName, ...props }: Props) => import("react").JSX.Element;
|
|
17
|
+
export { Dropdown };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Dropdown } from './Dropdown';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FilterConfig } from '.';
|
|
2
|
+
import { FormFilter } from './types';
|
|
3
|
+
type FilterGroupProps = {
|
|
4
|
+
filterGroup: {
|
|
5
|
+
field: string;
|
|
6
|
+
filters: FormFilter[];
|
|
7
|
+
};
|
|
8
|
+
groupIndex: number;
|
|
9
|
+
filterConfigs: FilterConfig[];
|
|
10
|
+
className?: string;
|
|
11
|
+
onRemove: (index: number) => void;
|
|
12
|
+
onChange: (filter: FormFilter, index: number) => void;
|
|
13
|
+
onDone: (filter: FormFilter, index: number) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const FilterGroup: ({ filterGroup, groupIndex, filterConfigs, className, onRemove, onChange, onDone, }: FilterGroupProps) => import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FilterConfig } from '.';
|
|
2
|
+
import { FormFilter } from './types';
|
|
3
|
+
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
type FilterInputProps = {
|
|
6
|
+
value?: FormFilter;
|
|
7
|
+
filterConfigs: FilterConfig[];
|
|
8
|
+
onChange?: (value: FormFilter) => void;
|
|
9
|
+
onBlur?: (value: FormFilter) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
size?: SizeType;
|
|
12
|
+
};
|
|
13
|
+
export declare const FilterInput: ({ value, filterConfigs, onChange, onBlur, className, size, }: FilterInputProps) => React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FilterForm, FilterConfig } from '.';
|
|
2
|
+
type Props = {
|
|
3
|
+
filterConfigs: FilterConfig[];
|
|
4
|
+
title?: string;
|
|
5
|
+
onSubmit: (values: FilterForm) => void;
|
|
6
|
+
initialValues?: FilterForm;
|
|
7
|
+
maxFiltersPerField?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const FiltersForm: ({ title, filterConfigs, onSubmit, initialValues, maxFiltersPerField, }: Props) => import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Filter, FormFilter } from './types';
|
|
2
|
+
export declare const isEmptyFilter: (filter: Filter) => boolean;
|
|
3
|
+
export declare const isValidFilter: (filter: Filter) => boolean;
|
|
4
|
+
export declare const validateFilterField: (filter: Filter) => {
|
|
5
|
+
field: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const isEmptyFormFilter: (filter: FormFilter) => boolean;
|
|
9
|
+
export declare const isValidFormFilter: (filter: FormFilter) => boolean;
|
|
10
|
+
export declare const validateFormFilter: (filter: FormFilter) => string[];
|
|
11
|
+
export declare const isFilter: (filter: FormFilter) => filter is Filter;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type FilterForm = {
|
|
2
|
+
filters: Filter[];
|
|
3
|
+
};
|
|
4
|
+
export type FormFilter = {
|
|
5
|
+
field: string;
|
|
6
|
+
type: FilterType;
|
|
7
|
+
operator: Operator | undefined;
|
|
8
|
+
values: (number | string | null | undefined)[];
|
|
9
|
+
errors?: string[];
|
|
10
|
+
};
|
|
11
|
+
export type FilterGroup = {
|
|
12
|
+
field: string;
|
|
13
|
+
filters: FormFilter[];
|
|
14
|
+
};
|
|
15
|
+
export type FilterType = 'select' | 'number' | 'text';
|
|
16
|
+
export type SelectOptionsType = {
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
export type NumberOptionsType = {
|
|
21
|
+
max: number;
|
|
22
|
+
min: number;
|
|
23
|
+
step: number;
|
|
24
|
+
};
|
|
25
|
+
export type FilterConfig = {
|
|
26
|
+
label: string;
|
|
27
|
+
field: string;
|
|
28
|
+
type: FilterType;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
options?: SelectOptionsType | NumberOptionsType;
|
|
31
|
+
};
|
|
32
|
+
export type Operator = 'equals' | 'notEqual' | 'blank' | 'notBlank' | 'greaterThan' | 'greaterThanOrEqual' | 'lessThan' | 'lessThanOrEqual' | 'inRange' | 'contains' | 'notContains' | 'startsWith' | 'endsWith';
|
|
33
|
+
type SelectFilter = {
|
|
34
|
+
field: string;
|
|
35
|
+
type: 'select';
|
|
36
|
+
operator: Extract<Operator, 'equals' | 'notEqual' | 'blank' | 'notBlank'> | undefined;
|
|
37
|
+
values: string[];
|
|
38
|
+
};
|
|
39
|
+
type NumberFilter = {
|
|
40
|
+
field: string;
|
|
41
|
+
type: 'number';
|
|
42
|
+
operator: Extract<Operator, 'equals' | 'notEqual' | 'blank' | 'notBlank'> | 'greaterThan' | 'greaterThanOrEqual' | 'lessThan' | 'lessThanOrEqual' | 'inRange' | undefined;
|
|
43
|
+
values: number[];
|
|
44
|
+
};
|
|
45
|
+
type TextFilter = {
|
|
46
|
+
field: string;
|
|
47
|
+
type: 'text';
|
|
48
|
+
operator: Extract<Operator, 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'blank' | 'notBlank'> | undefined;
|
|
49
|
+
values: string[];
|
|
50
|
+
};
|
|
51
|
+
export type Filter = SelectFilter | NumberFilter | TextFilter;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FilterConfig, FilterType, FormFilter, Operator } from './types';
|
|
2
|
+
export type UseFilterFieldInputs = {
|
|
3
|
+
filterConfigs: FilterConfig[];
|
|
4
|
+
filter?: FormFilter;
|
|
5
|
+
};
|
|
6
|
+
type UseFilterFieldOutputs = {
|
|
7
|
+
filter: FormFilter | undefined;
|
|
8
|
+
config: FilterConfig | undefined;
|
|
9
|
+
operatorOptions: {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
13
|
+
valueInputConfig: ValueInputConfig | undefined;
|
|
14
|
+
handleFieldChange: (value: string) => void;
|
|
15
|
+
handleOperatorChange: (value: string) => void;
|
|
16
|
+
handleValuesChange: (value: (string | number | undefined | null)[]) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const TypeToOperatorOptions: Record<FilterType, {
|
|
19
|
+
label: string;
|
|
20
|
+
value: Operator;
|
|
21
|
+
}[]>;
|
|
22
|
+
type SelectValueInputConfig = {
|
|
23
|
+
type: 'select';
|
|
24
|
+
valueOptions: {
|
|
25
|
+
label: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
type NumberValueInputConfig = {
|
|
30
|
+
type: 'number';
|
|
31
|
+
inputCount: number;
|
|
32
|
+
numberOptions?: {
|
|
33
|
+
max: number;
|
|
34
|
+
min: number;
|
|
35
|
+
step: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
type TextValueInputConfig = {
|
|
39
|
+
type: 'text';
|
|
40
|
+
};
|
|
41
|
+
export type ValueInputConfig = SelectValueInputConfig | NumberValueInputConfig | TextValueInputConfig;
|
|
42
|
+
export declare const useFilterField: ({ filterConfigs, filter: initialFilter, }: UseFilterFieldInputs) => UseFilterFieldOutputs;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FilterForm, FilterGroup, FormFilter } from './types';
|
|
2
|
+
type UseFiltersFormInput = {
|
|
3
|
+
initialValues?: FilterForm;
|
|
4
|
+
};
|
|
5
|
+
type UseFiltersFormOutput = {
|
|
6
|
+
dispatch: (action: Action) => void;
|
|
7
|
+
filterGroups: FilterGroup[];
|
|
8
|
+
newFilter: FormFilter | undefined;
|
|
9
|
+
isNewFilterInputOpen: boolean;
|
|
10
|
+
isValid: boolean;
|
|
11
|
+
isEmpty: boolean;
|
|
12
|
+
};
|
|
13
|
+
type InitializeAction = {
|
|
14
|
+
type: 'initialize';
|
|
15
|
+
payload: FilterForm | undefined;
|
|
16
|
+
};
|
|
17
|
+
type OpenNewFilterInputAction = {
|
|
18
|
+
type: 'openNewFilterInput';
|
|
19
|
+
};
|
|
20
|
+
type AddNewFilterAction = {
|
|
21
|
+
type: 'addNewFilter';
|
|
22
|
+
payload: FormFilter;
|
|
23
|
+
};
|
|
24
|
+
type ChangeNewFilterAction = {
|
|
25
|
+
type: 'changeNewFilter';
|
|
26
|
+
payload: FormFilter;
|
|
27
|
+
};
|
|
28
|
+
type RemoveNewFilterAction = {
|
|
29
|
+
type: 'removeNewFilter';
|
|
30
|
+
};
|
|
31
|
+
type ClearAllFiltersAction = {
|
|
32
|
+
type: 'clearAllFilters';
|
|
33
|
+
};
|
|
34
|
+
type UpdateFilterAction = {
|
|
35
|
+
type: 'updateFilter';
|
|
36
|
+
payload: {
|
|
37
|
+
groupIndex: number;
|
|
38
|
+
filterIndex: number;
|
|
39
|
+
filter: FormFilter;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type ChangeFilterAction = {
|
|
43
|
+
type: 'changeFilter';
|
|
44
|
+
payload: {
|
|
45
|
+
groupIndex: number;
|
|
46
|
+
filterIndex: number;
|
|
47
|
+
filter: FormFilter;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
type RemoveFilterAction = {
|
|
51
|
+
type: 'removeFilter';
|
|
52
|
+
payload: {
|
|
53
|
+
groupIndex: number;
|
|
54
|
+
filterIndex: number;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
type Action = AddNewFilterAction | UpdateFilterAction | ClearAllFiltersAction | ChangeNewFilterAction | OpenNewFilterInputAction | ChangeFilterAction | RemoveFilterAction | InitializeAction | RemoveNewFilterAction;
|
|
58
|
+
export declare const useFiltersForm: ({ initialValues, }: UseFiltersFormInput) => UseFiltersFormOutput;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormProps } from 'antd';
|
|
2
|
+
type Props = Expand<FormProps>;
|
|
3
|
+
export declare const Form: {
|
|
4
|
+
({ children, ...props }: Props): import("react").JSX.Element;
|
|
5
|
+
Item: ({ name, __debug, showValidateSuccess, showInitialErrorAfterTouched, children, validate, ...restProps }: import('formik-antd').FormItemProps) => JSX.Element;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form } from './Form';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@phosphor-icons/react';
|