@pnkx-lib/ui 1.9.22 → 1.9.23

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.
@@ -0,0 +1,94 @@
1
+ import { useState, useCallback } from 'react';
2
+ import { c as cloneDeep } from './cloneDeep-BLYi2V0G.js';
3
+ import { P as PAGE_INDEX, S as START_PAGE, a as SORT_DESC, b as SORT_BY } from './common-b3FKGF0Y.js';
4
+ import { message } from 'antd';
5
+
6
+ const useFiltersHandler = (initialFilters) => {
7
+ const [filters, setFilters] = useState(initialFilters || {});
8
+ const [rowsSelected, setRowsSelected] = useState([]);
9
+ const goToPage = useCallback((PageIndex) => {
10
+ setFilters((prev) => {
11
+ const nextFilters = cloneDeep(prev);
12
+ if (nextFilters) {
13
+ nextFilters[PAGE_INDEX] = PageIndex;
14
+ }
15
+ return nextFilters;
16
+ });
17
+ }, []);
18
+ const handleChangePage = useCallback((nextPage) => {
19
+ setFilters((prev) => {
20
+ const nextFilters = cloneDeep(prev);
21
+ if (nextFilters) {
22
+ nextFilters[PAGE_INDEX] = nextPage;
23
+ }
24
+ return nextFilters;
25
+ });
26
+ setRowsSelected([]);
27
+ }, []);
28
+ const changeRowlimit = useCallback((value) => {
29
+ setFilters((prev) => {
30
+ const nextValue = Number(value);
31
+ const nextFilters = cloneDeep(prev);
32
+ if (nextFilters) {
33
+ nextFilters[PAGE_INDEX] = nextValue;
34
+ nextFilters[PAGE_INDEX] = START_PAGE;
35
+ }
36
+ return nextFilters;
37
+ });
38
+ }, []);
39
+ const resetToInitialFilters = useCallback(() => {
40
+ setFilters(cloneDeep(initialFilters));
41
+ }, [initialFilters]);
42
+ const handleCheckBox = useCallback((newSelectedRowKeys) => {
43
+ setRowsSelected(newSelectedRowKeys);
44
+ }, []);
45
+ const handleRequestSort = (sortField) => {
46
+ setFilters((prev) => {
47
+ const nextFilters = cloneDeep(prev);
48
+ if (nextFilters) {
49
+ if (SORT_DESC in nextFilters) {
50
+ const isAsc = nextFilters.SortDesc === false;
51
+ nextFilters[SORT_DESC] = isAsc;
52
+ }
53
+ if (SORT_BY in nextFilters) {
54
+ nextFilters[SORT_BY] = sortField;
55
+ }
56
+ }
57
+ return nextFilters;
58
+ });
59
+ };
60
+ const handleSearch = useCallback((nextFilters) => {
61
+ const nextFiltersTemp = cloneDeep(nextFilters);
62
+ if (PAGE_INDEX in nextFiltersTemp) {
63
+ nextFiltersTemp[PAGE_INDEX] = START_PAGE;
64
+ }
65
+ setFilters(nextFiltersTemp);
66
+ }, []);
67
+ return {
68
+ filters,
69
+ rowsSelected,
70
+ setRowsSelected,
71
+ setFilters,
72
+ goToPage,
73
+ changeRowlimit,
74
+ resetToInitialFilters,
75
+ handleCheckBox,
76
+ handleChangePage,
77
+ handleRequestSort,
78
+ handleSearch
79
+ };
80
+ };
81
+
82
+ const useMessage = (defaultProps) => {
83
+ return (overrideProps) => {
84
+ const mergedProps = {
85
+ type: defaultProps?.type,
86
+ content: defaultProps?.content,
87
+ ...defaultProps,
88
+ ...overrideProps
89
+ };
90
+ message.open(mergedProps);
91
+ };
92
+ };
93
+
94
+ export { useMessage as a, useFiltersHandler as u };
@@ -0,0 +1,2 @@
1
+ export { C as CheckboxField, D as DatePickerField, I as Input, P as PnkxField, R as RangePickerField, a as TinyMCE } from '../chunks/Switch-za5Skgtp.js';
2
+ export { R as RadioGroup, S as Select } from '../chunks/Radio-D2me1zZ-.js';
@@ -0,0 +1,2 @@
1
+ export { u as useToast } from '../chunks/cloneDeep-BLYi2V0G.js';
2
+ export { u as useFiltersHandler, a as useMessage } from '../chunks/useMessage-D_-VT5B4.js';
package/es/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { A as Alert, E as Anchor, G as Appfix, I as AutoComplete, e as Badge, g as Breadcrumb, U as BulkAction, B as Button, C as CascaderField, f as Col, V as ConfirmModal, d as Container, o as Divider, q as Drawer, D as Dropdown, N as Empty, X as ErrorBoundary, F as Flex, H as Heading, O as Image, L as Layout, j as Menu, M as Modal, k as Pagination, J as PnkxCollapse, K as PnkxColorPicker, r as Popconfirm, P as Popover, Q as QRCode, u as Rate, s as Result, R as Row, c as SearchFiltersForm, v as Segmented, m as Sidebar, S as Skeleton, h as Space, p as Spin, i as Splitter, w as Statistic, l as Steps, T as Table, b as Tabs, n as Tag, x as Timeline, a as Tooltip, y as Tour, z as Tree, W as Watermark, t as typeColorMap } from './chunks/CategoryStatus-DwWppmup.js';
2
+ export { C as CheckboxField, D as DatePickerField, E as ErrorMessage, I as Input, L as Label, P as PnkxField, R as RangePickerField, a as TinyMCE, T as Typography } from './chunks/Switch-za5Skgtp.js';
3
+ import 'react-router';
4
+ export { R as RadioGroup, S as Select } from './chunks/Radio-D2me1zZ-.js';
5
+ export { u as useToast } from './chunks/cloneDeep-BLYi2V0G.js';
6
+ export { u as useFiltersHandler, a as useMessage } from './chunks/useMessage-D_-VT5B4.js';
package/es/ui/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { A as Alert, E as Anchor, G as Appfix, I as AutoComplete, e as Badge, g as Breadcrumb, U as BulkAction, B as Button, C as CascaderField, f as Col, V as ConfirmModal, d as Container, o as Divider, q as Drawer, D as Dropdown, N as Empty, X as ErrorBoundary, F as Flex, H as Heading, O as Image, L as Layout, j as Menu, M as Modal, k as Pagination, J as PnkxCollapse, K as PnkxColorPicker, r as Popconfirm, P as Popover, Q as QRCode, u as Rate, s as Result, R as Row, c as SearchFiltersForm, v as Segmented, m as Sidebar, S as Skeleton, h as Space, p as Spin, i as Splitter, w as Statistic, l as Steps, T as Table, b as Tabs, n as Tag, x as Timeline, a as Tooltip, y as Tour, z as Tree, W as Watermark, t as typeColorMap } from '../chunks/CategoryStatus-DwWppmup.js';
2
+ export { E as ErrorMessage, L as Label, T as Typography } from '../chunks/Switch-za5Skgtp.js';
3
+ import 'react-router';
package/es/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pnkx-lib/ui",
3
3
  "private": false,
4
- "version": "1.9.22",
4
+ "version": "1.9.23",
5
5
  "type": "module",
6
6
  "main": "./es/index.js",
7
7
  "module": "./es/index.js",
@@ -0,0 +1,193 @@
1
+ import { CheckboxProps } from 'antd';
2
+ import { Control } from 'react-hook-form';
3
+ import { ControllerFieldState } from 'react-hook-form';
4
+ import { ControllerRenderProps } from 'react-hook-form';
5
+ import { Dayjs } from 'dayjs';
6
+ import { default as default_2 } from 'react';
7
+ import { IAllProps } from '@tinymce/tinymce-react';
8
+ import { InputProps as InputProps_2 } from 'antd';
9
+ import { JSX } from 'react/jsx-runtime';
10
+ import { JSX as JSX_2 } from 'react';
11
+ import { RadioGroupProps } from 'antd';
12
+ import { RangePickerProps } from 'antd/es/date-picker';
13
+ import * as React_2 from 'react';
14
+ import { ReactDatePickerProps } from 'react-datepicker';
15
+ import { SelectProps } from 'antd';
16
+ import { SwitchProps } from 'antd';
17
+ import { TextAreaProps as TextAreaProps_2 } from 'antd/es/input';
18
+ import { UploadFile } from 'antd';
19
+ import { UploadProps } from 'antd';
20
+ import { UseFormSetValue } from 'react-hook-form';
21
+ import { UseFormStateReturn } from 'react-hook-form';
22
+
23
+ export declare const CheckboxField: (props: CheckboxFieldProps) => JSX.Element;
24
+
25
+ export declare interface CheckboxFieldProps extends Omit<CheckboxProps, "onChange" | "checked"> {
26
+ field?: ControllerRenderProps<any, any>;
27
+ formState?: UseFormStateReturn<any>;
28
+ label?: string;
29
+ required?: boolean;
30
+ afterOnChange?: (checked: boolean) => void;
31
+ customStyleContainer?: string;
32
+ customStyleCheckbox?: string;
33
+ }
34
+
35
+ declare type ComponentPropsType<TComponent> = TComponent extends React_2.ComponentType<infer P> ? P : never;
36
+
37
+ declare type CustomInputTypeAttribute = default_2.HTMLInputTypeAttribute | "money";
38
+
39
+ export declare interface DatePickerDMYProps extends Omit<ReactDatePickerProps, "onChange"> {
40
+ field?: ControllerRenderProps<any, any>;
41
+ formState?: UseFormStateReturn<any>;
42
+ setValue?: UseFormSetValue<any>;
43
+ customStyleDatepicker?: string;
44
+ disabledInputChange?: boolean;
45
+ required?: boolean;
46
+ dateFormat?: string | string[];
47
+ placeholder?: string;
48
+ label?: string;
49
+ maxDate?: Date;
50
+ showTimeSelect?: boolean;
51
+ customOnChange?: (date: any, event: default_2.SyntheticEvent<any>) => void;
52
+ customValue?: Date | null;
53
+ size?: TSize;
54
+ }
55
+
56
+ export declare const DatePickerField: (props: DatePickerDMYProps) => JSX.Element;
57
+
58
+ export declare const Input: (props: InputProps) => JSX.Element;
59
+
60
+ export declare interface InputProps extends InputProps_2 {
61
+ field?: ControllerRenderProps<any, any>;
62
+ formState?: UseFormStateReturn<any>;
63
+ label?: string;
64
+ customStyleInput?: string;
65
+ type?: CustomInputTypeAttribute;
66
+ afterOnChange?: (value: number | string | null) => void;
67
+ iconStartInput?: default_2.ReactNode;
68
+ iconEndInput?: default_2.ReactNode;
69
+ allowNegative?: boolean;
70
+ decimalScale?: number;
71
+ prefix?: string;
72
+ suffix?: string;
73
+ }
74
+
75
+ export declare class PnkxField<TComponent extends React_2.ComponentType<any>> extends React_2.PureComponent<PnkxFieldProps<TComponent>> {
76
+ render(): JSX.Element;
77
+ }
78
+
79
+ export declare type PnkxFieldProps<TComponent extends React_2.ComponentType<any>> = {
80
+ control: Control<any, any>;
81
+ name: string;
82
+ component: TComponent;
83
+ } & Omit<ComponentPropsType<TComponent>, "control" | "name" | "formState" | "field" | "fieldState">;
84
+
85
+ export declare interface PropsNumberFormat extends Omit<InputProps, "onChange" | "afterOnChange" | "value" | "defaultValue" | "iconStartInput" | "iconEndInput"> {
86
+ onChange?: (event: any) => void;
87
+ afterOnChange?: (value: string | number) => void;
88
+ value?: string;
89
+ name?: string;
90
+ ref: any;
91
+ type?: TInputNumberType;
92
+ prefix?: string;
93
+ suffix?: string;
94
+ helperText?: () => JSX_2.Element | null;
95
+ }
96
+
97
+ export declare const RadioGroup: (props: RadioProps) => JSX.Element;
98
+
99
+ export declare interface RadioProps extends Omit<RadioGroupProps, "options" | "onChange"> {
100
+ field?: ControllerRenderProps<any, any>;
101
+ formState?: UseFormStateReturn<any>;
102
+ customStyleRadioGroup?: string;
103
+ customStyleRadio?: string;
104
+ customStyleWrap?: string;
105
+ afterOnChange?: (value: any) => void;
106
+ options: TOptionGRadio[];
107
+ position?: TPositionRadio;
108
+ }
109
+
110
+ export declare const RangePickerField: (props: RangePickerFieldProps) => JSX.Element;
111
+
112
+ export declare interface RangePickerFieldProps extends Omit<RangePickerProps, "value" | "onChange"> {
113
+ field?: ControllerRenderProps<any, any>;
114
+ formState?: UseFormStateReturn<any>;
115
+ label?: string;
116
+ required?: boolean;
117
+ afterOnChange?: (dates: [Dayjs | null, Dayjs | null] | null, dateStrings: [string, string]) => void;
118
+ customStyleContainer?: string;
119
+ customStyleDatePicker?: string;
120
+ }
121
+
122
+ export declare const Select: (props: SelectFieldProps) => JSX.Element;
123
+
124
+ export declare interface SelectFieldProps extends SelectProps {
125
+ field?: ControllerRenderProps<any, any>;
126
+ formState?: UseFormStateReturn<any>;
127
+ setValue?: UseFormSetValue<any>;
128
+ label?: string;
129
+ required?: boolean;
130
+ afterOnChange?: (value: any) => void;
131
+ customStyleContainer?: string;
132
+ }
133
+
134
+ export declare interface SwitchFieldProps extends Omit<SwitchProps, "onChange" | "checked"> {
135
+ field?: ControllerRenderProps<any, any>;
136
+ formState?: UseFormStateReturn<any>;
137
+ label?: string;
138
+ required?: boolean;
139
+ afterOnChange?: (checked: boolean) => void;
140
+ customStyleContainer?: string;
141
+ customStyleSwitch?: string;
142
+ }
143
+
144
+ export declare interface TextAreaProps extends TextAreaProps_2 {
145
+ field?: ControllerRenderProps<any, any>;
146
+ formState?: UseFormStateReturn<any>;
147
+ label?: string;
148
+ customStyleTextarea?: string;
149
+ afterOnChange?: (value: string) => void;
150
+ required?: boolean;
151
+ }
152
+
153
+ declare type TInputNumberType = "number" | "money";
154
+
155
+ export declare const TinyMCE: {
156
+ (props: TinyProps): JSX.Element;
157
+ displayName: string;
158
+ };
159
+
160
+ export declare interface TinyProps extends IAllProps {
161
+ height?: number | string;
162
+ openHidenMenubar?: boolean;
163
+ required?: boolean;
164
+ field?: ControllerRenderProps<any, any>;
165
+ formState?: UseFormStateReturn<any>;
166
+ label?: string;
167
+ customStyleLabel?: string;
168
+ text_patterns?: any;
169
+ }
170
+
171
+ declare type TOptionGRadio = {
172
+ label: string;
173
+ value: string | number;
174
+ };
175
+
176
+ declare type TPositionRadio = "before" | "after";
177
+
178
+ declare type TSize = "small" | "medium" | "large";
179
+
180
+ export declare interface UploadFieldProps extends Omit<UploadProps, "value" | "onChange" | "fileList"> {
181
+ field?: ControllerRenderProps<any, any>;
182
+ formState?: UseFormStateReturn<any>;
183
+ fieldState?: ControllerFieldState;
184
+ label?: string;
185
+ required?: boolean;
186
+ maxFiles?: number;
187
+ uploadButtonText?: string;
188
+ customStyleContainer?: string;
189
+ customStyleUpload?: string;
190
+ afterOnChange?: (fileList: UploadFile[]) => void;
191
+ }
192
+
193
+ export { }
@@ -0,0 +1,38 @@
1
+ import { ArgsProps } from 'antd/es/notification';
2
+ import { ArgsProps as ArgsProps_2 } from 'antd/lib/message';
3
+ import { default as default_2 } from 'react';
4
+
5
+ export declare type InitialFiltersSearch<T> = T & PaginationFilters;
6
+
7
+ export declare type OptionalArgsMessage = Partial<ArgsProps_2> & {
8
+ type?: ArgsProps_2["type"];
9
+ };
10
+
11
+ export declare type OptionalArgsToast = Partial<ArgsProps> & {
12
+ message?: React.ReactNode;
13
+ };
14
+
15
+ export declare interface PaginationFilters {
16
+ PageSize: number;
17
+ PageIndex: number;
18
+ }
19
+
20
+ export declare const useFiltersHandler: <T>(initialFilters: InitialFiltersSearch<T>) => {
21
+ filters: InitialFiltersSearch<T>;
22
+ rowsSelected: default_2.Key[];
23
+ setRowsSelected: default_2.Dispatch<default_2.SetStateAction<default_2.Key[]>>;
24
+ setFilters: default_2.Dispatch<default_2.SetStateAction<InitialFiltersSearch<T>>>;
25
+ goToPage: (PageIndex: number) => void;
26
+ changeRowlimit: (value: number) => void;
27
+ resetToInitialFilters: () => void;
28
+ handleCheckBox: (newSelectedRowKeys: default_2.Key[]) => void;
29
+ handleChangePage: (nextPage: number) => void;
30
+ handleRequestSort: (sortField: string | number | symbol) => void;
31
+ handleSearch: (nextFilters: InitialFiltersSearch<T>) => void;
32
+ };
33
+
34
+ export declare const useMessage: (defaultProps?: OptionalArgsMessage) => (overrideProps?: OptionalArgsMessage) => void;
35
+
36
+ export declare const useToast: (defaultProps?: OptionalArgsToast) => (overrideProps?: OptionalArgsToast) => void;
37
+
38
+ export { }