@mamrp/components 1.0.32 → 1.0.34
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/index.d.mts +62 -3
- package/dist/index.d.ts +62 -3
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +72 -72
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ import { SxProps, Theme } from '@mui/material';
|
|
|
6
6
|
import { GridColDef } from '@mui/x-data-grid';
|
|
7
7
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
8
8
|
|
|
9
|
-
interface MultipleSelectChipProps {
|
|
9
|
+
interface MultipleSelectChipProps$1 {
|
|
10
10
|
name: string;
|
|
11
11
|
control: Control<any>;
|
|
12
12
|
label?: string;
|
|
@@ -18,7 +18,7 @@ interface MultipleSelectChipProps {
|
|
|
18
18
|
clear?: boolean;
|
|
19
19
|
}
|
|
20
20
|
declare function MultipleSelectChip({ name, control, label, data, multipleitems, //قابلیت انتخاب چند گزینه ای
|
|
21
|
-
isLoading, disabled, size, clear, }: MultipleSelectChipProps): React.JSX.Element;
|
|
21
|
+
isLoading, disabled, size, clear, }: MultipleSelectChipProps$1): React.JSX.Element;
|
|
22
22
|
|
|
23
23
|
interface AdvancedSearchButtonProps {
|
|
24
24
|
isShowFilter: boolean;
|
|
@@ -305,4 +305,63 @@ type ConnectToBasculeButtonProps = {
|
|
|
305
305
|
};
|
|
306
306
|
declare const ConnectToBasculeButton: React__default.FC<ConnectToBasculeButtonProps>;
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
interface OptionType {
|
|
309
|
+
title: string;
|
|
310
|
+
key: string | number;
|
|
311
|
+
[x: string]: any;
|
|
312
|
+
}
|
|
313
|
+
interface MultipleSelectChipProps<T extends OptionType> {
|
|
314
|
+
name: string;
|
|
315
|
+
control: Control<any>;
|
|
316
|
+
label?: string;
|
|
317
|
+
data?: T[];
|
|
318
|
+
isLoading?: boolean;
|
|
319
|
+
disabled?: boolean;
|
|
320
|
+
size?: "small" | "medium";
|
|
321
|
+
clear?: boolean;
|
|
322
|
+
renderOption?: (props: React.HTMLAttributes<HTMLLIElement>, option: T) => React.ReactNode;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 📦 کامپوننت انتخاب چند گزینهای با پشتیبانی از react-hook-form و MUI Autocomplete
|
|
326
|
+
*
|
|
327
|
+
* @component MultipleSelector
|
|
328
|
+
*
|
|
329
|
+
* @param {string} name - نام فیلدی که در فرم ثبت میشود.
|
|
330
|
+
* @param {string} [label] - برچسب نمایشی برای فیلد.
|
|
331
|
+
* @param {Control<any>} control - کنترل فرم از react-hook-form.
|
|
332
|
+
* @param {{ title: string; key: string | number }[]} [data] - لیستی از گزینهها شامل `title` (متن) و `key` (مقدار).
|
|
333
|
+
* @param {boolean} [isLoading=false] - آیا دادهها در حال بارگذاری هستند.
|
|
334
|
+
* @param {boolean} [disabled=false] - غیرفعالسازی ورودی.
|
|
335
|
+
* @param {"small" | "medium"} [size="medium"] - سایز ورودی.
|
|
336
|
+
* @param {boolean} [clear=false] - آیا امکان پاک کردن وجود دارد یا نه.
|
|
337
|
+
* @param {string} [tooltip] - متن راهنما هنگام هاور.
|
|
338
|
+
* @param {(props, option) => React.ReactNode} [renderOption] - تابعی سفارشی برای رندر آیتمها در لیست.
|
|
339
|
+
*
|
|
340
|
+
* @returns {Array<{ key: string | number }>} لیستی از آیتمهای انتخابشده ( فقط آیدیها).
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```tsx
|
|
344
|
+
* <MultipleSelector<{title:string; key:number;}>
|
|
345
|
+
* name="productIds"
|
|
346
|
+
* label="محصولات"
|
|
347
|
+
* control={control}
|
|
348
|
+
* data={[{ title: "محصول ۱", key: 1 }, { title: "محصول ۲", key: 2 }]}
|
|
349
|
+
* />
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* @description
|
|
353
|
+
* کامپوننتی چندانتخابی با قابلیت انتخاب همهی موارد، سفارشیسازی گزینهها،
|
|
354
|
+
* نمایش راهنمای هاور، و بازگرداندن لیست کامل از آبجکتهای انتخابشده.
|
|
355
|
+
*
|
|
356
|
+
* برای سفارشیسازی نحوه نمایش آیتمها:
|
|
357
|
+
* ```tsx
|
|
358
|
+
* renderOption={(props, option) => (
|
|
359
|
+
* <li {...props} key={`${option.key}`}>
|
|
360
|
+
* <span style={{ color: "green" }}>{option.title}</span>
|
|
361
|
+
* </li>
|
|
362
|
+
* )}
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
declare function MultipleSelector<T extends OptionType>({ name, control, label, data, isLoading, disabled, size, clear, renderOption, }: MultipleSelectChipProps<T>): React.JSX.Element;
|
|
366
|
+
|
|
367
|
+
export { Page as Accordion, AdvancedSearchButton, ConfirmationDialog$1 as ConfirmationDialog, ConnectToBasculeButton, CustomCheckbox, CustomTimePicker, DateFilter, DateFilterRange, JalaliDatePicker$2 as DatePicker, JalaliDatePicker$1 as DateTimePicker, JalaliDateTimeRangePicker as DateTimeRangePicker, FormInputNumber, FormInputText, HorizontalStepper, LicensePlate, JalaliDatePicker as MobileDateTimePicker, ConfirmationDialog as Modal, MultipleSelector, NestedSelect as NestedSelectort, NoResult, PaginationList, RadioButton, SearchLicensePlate, MultipleSelectChip as Selector, SkeletonCard, SonarSpinner, SwitchButton, Table, UploadImage };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { SxProps, Theme } from '@mui/material';
|
|
|
6
6
|
import { GridColDef } from '@mui/x-data-grid';
|
|
7
7
|
import { TextFieldProps } from '@mui/material/TextField';
|
|
8
8
|
|
|
9
|
-
interface MultipleSelectChipProps {
|
|
9
|
+
interface MultipleSelectChipProps$1 {
|
|
10
10
|
name: string;
|
|
11
11
|
control: Control<any>;
|
|
12
12
|
label?: string;
|
|
@@ -18,7 +18,7 @@ interface MultipleSelectChipProps {
|
|
|
18
18
|
clear?: boolean;
|
|
19
19
|
}
|
|
20
20
|
declare function MultipleSelectChip({ name, control, label, data, multipleitems, //قابلیت انتخاب چند گزینه ای
|
|
21
|
-
isLoading, disabled, size, clear, }: MultipleSelectChipProps): React.JSX.Element;
|
|
21
|
+
isLoading, disabled, size, clear, }: MultipleSelectChipProps$1): React.JSX.Element;
|
|
22
22
|
|
|
23
23
|
interface AdvancedSearchButtonProps {
|
|
24
24
|
isShowFilter: boolean;
|
|
@@ -305,4 +305,63 @@ type ConnectToBasculeButtonProps = {
|
|
|
305
305
|
};
|
|
306
306
|
declare const ConnectToBasculeButton: React__default.FC<ConnectToBasculeButtonProps>;
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
interface OptionType {
|
|
309
|
+
title: string;
|
|
310
|
+
key: string | number;
|
|
311
|
+
[x: string]: any;
|
|
312
|
+
}
|
|
313
|
+
interface MultipleSelectChipProps<T extends OptionType> {
|
|
314
|
+
name: string;
|
|
315
|
+
control: Control<any>;
|
|
316
|
+
label?: string;
|
|
317
|
+
data?: T[];
|
|
318
|
+
isLoading?: boolean;
|
|
319
|
+
disabled?: boolean;
|
|
320
|
+
size?: "small" | "medium";
|
|
321
|
+
clear?: boolean;
|
|
322
|
+
renderOption?: (props: React.HTMLAttributes<HTMLLIElement>, option: T) => React.ReactNode;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 📦 کامپوننت انتخاب چند گزینهای با پشتیبانی از react-hook-form و MUI Autocomplete
|
|
326
|
+
*
|
|
327
|
+
* @component MultipleSelector
|
|
328
|
+
*
|
|
329
|
+
* @param {string} name - نام فیلدی که در فرم ثبت میشود.
|
|
330
|
+
* @param {string} [label] - برچسب نمایشی برای فیلد.
|
|
331
|
+
* @param {Control<any>} control - کنترل فرم از react-hook-form.
|
|
332
|
+
* @param {{ title: string; key: string | number }[]} [data] - لیستی از گزینهها شامل `title` (متن) و `key` (مقدار).
|
|
333
|
+
* @param {boolean} [isLoading=false] - آیا دادهها در حال بارگذاری هستند.
|
|
334
|
+
* @param {boolean} [disabled=false] - غیرفعالسازی ورودی.
|
|
335
|
+
* @param {"small" | "medium"} [size="medium"] - سایز ورودی.
|
|
336
|
+
* @param {boolean} [clear=false] - آیا امکان پاک کردن وجود دارد یا نه.
|
|
337
|
+
* @param {string} [tooltip] - متن راهنما هنگام هاور.
|
|
338
|
+
* @param {(props, option) => React.ReactNode} [renderOption] - تابعی سفارشی برای رندر آیتمها در لیست.
|
|
339
|
+
*
|
|
340
|
+
* @returns {Array<{ key: string | number }>} لیستی از آیتمهای انتخابشده ( فقط آیدیها).
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```tsx
|
|
344
|
+
* <MultipleSelector<{title:string; key:number;}>
|
|
345
|
+
* name="productIds"
|
|
346
|
+
* label="محصولات"
|
|
347
|
+
* control={control}
|
|
348
|
+
* data={[{ title: "محصول ۱", key: 1 }, { title: "محصول ۲", key: 2 }]}
|
|
349
|
+
* />
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* @description
|
|
353
|
+
* کامپوننتی چندانتخابی با قابلیت انتخاب همهی موارد، سفارشیسازی گزینهها،
|
|
354
|
+
* نمایش راهنمای هاور، و بازگرداندن لیست کامل از آبجکتهای انتخابشده.
|
|
355
|
+
*
|
|
356
|
+
* برای سفارشیسازی نحوه نمایش آیتمها:
|
|
357
|
+
* ```tsx
|
|
358
|
+
* renderOption={(props, option) => (
|
|
359
|
+
* <li {...props} key={`${option.key}`}>
|
|
360
|
+
* <span style={{ color: "green" }}>{option.title}</span>
|
|
361
|
+
* </li>
|
|
362
|
+
* )}
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
declare function MultipleSelector<T extends OptionType>({ name, control, label, data, isLoading, disabled, size, clear, renderOption, }: MultipleSelectChipProps<T>): React.JSX.Element;
|
|
366
|
+
|
|
367
|
+
export { Page as Accordion, AdvancedSearchButton, ConfirmationDialog$1 as ConfirmationDialog, ConnectToBasculeButton, CustomCheckbox, CustomTimePicker, DateFilter, DateFilterRange, JalaliDatePicker$2 as DatePicker, JalaliDatePicker$1 as DateTimePicker, JalaliDateTimeRangePicker as DateTimeRangePicker, FormInputNumber, FormInputText, HorizontalStepper, LicensePlate, JalaliDatePicker as MobileDateTimePicker, ConfirmationDialog as Modal, MultipleSelector, NestedSelect as NestedSelectort, NoResult, PaginationList, RadioButton, SearchLicensePlate, MultipleSelectChip as Selector, SkeletonCard, SonarSpinner, SwitchButton, Table, UploadImage };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ __export(src_exports, {
|
|
|
47
47
|
LicensePlate: () => LicensePlate,
|
|
48
48
|
MobileDateTimePicker: () => mobile_date_time_picker_default,
|
|
49
49
|
Modal: () => ConfirmationDialog2,
|
|
50
|
+
MultipleSelector: () => MultipleSelector,
|
|
50
51
|
NestedSelectort: () => selector_default,
|
|
51
52
|
NoResult: () => NoResult,
|
|
52
53
|
PaginationList: () => PaginationList,
|
|
@@ -3899,6 +3900,134 @@ var ConnectToBasculeButton = ({
|
|
|
3899
3900
|
));
|
|
3900
3901
|
};
|
|
3901
3902
|
var bascule_connection_button_default = ConnectToBasculeButton;
|
|
3903
|
+
|
|
3904
|
+
// src/multiple-selector/index.tsx
|
|
3905
|
+
var import_Autocomplete2 = __toESM(require("@mui/material/Autocomplete"));
|
|
3906
|
+
var import_TextField4 = __toESM(require("@mui/material/TextField"));
|
|
3907
|
+
var React27 = __toESM(require("react"));
|
|
3908
|
+
var import_react_hook_form14 = require("react-hook-form");
|
|
3909
|
+
var import_material26 = require("@mui/material");
|
|
3910
|
+
function MultipleSelector({
|
|
3911
|
+
name,
|
|
3912
|
+
control,
|
|
3913
|
+
label,
|
|
3914
|
+
data,
|
|
3915
|
+
isLoading,
|
|
3916
|
+
disabled = false,
|
|
3917
|
+
size = "medium",
|
|
3918
|
+
clear = false,
|
|
3919
|
+
renderOption
|
|
3920
|
+
}) {
|
|
3921
|
+
const dataOptions = data?.map((value) => ({
|
|
3922
|
+
...value,
|
|
3923
|
+
key: value.key || `key_${Math.random()}`
|
|
3924
|
+
})) || [];
|
|
3925
|
+
const combinedOptions = dataOptions.length > 0 ? [{ title: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0647\u0645\u0647", key: "All" }, ...dataOptions] : [...dataOptions];
|
|
3926
|
+
const handleChange = (_event, selected, onChange) => {
|
|
3927
|
+
if (selected.some((item) => item.key === "All")) {
|
|
3928
|
+
const allItems = [...dataOptions];
|
|
3929
|
+
onChange(allItems.map((item) => item.key));
|
|
3930
|
+
} else {
|
|
3931
|
+
onChange(selected.map((item) => item.key));
|
|
3932
|
+
}
|
|
3933
|
+
};
|
|
3934
|
+
return /* @__PURE__ */ React27.createElement(
|
|
3935
|
+
import_react_hook_form14.Controller,
|
|
3936
|
+
{
|
|
3937
|
+
name,
|
|
3938
|
+
control,
|
|
3939
|
+
render: ({ field: { onChange, value, ref }, fieldState: { error } }) => {
|
|
3940
|
+
const computedValue = React27.useMemo(() => {
|
|
3941
|
+
if (Array.isArray(value) && dataOptions.length > 0) {
|
|
3942
|
+
return dataOptions.filter(
|
|
3943
|
+
(option) => value.includes(option.key)
|
|
3944
|
+
);
|
|
3945
|
+
}
|
|
3946
|
+
return [];
|
|
3947
|
+
}, [value, dataOptions]);
|
|
3948
|
+
return /* @__PURE__ */ React27.createElement(
|
|
3949
|
+
import_Autocomplete2.default,
|
|
3950
|
+
{
|
|
3951
|
+
multiple: true,
|
|
3952
|
+
disableClearable: clear,
|
|
3953
|
+
disabled: disabled || isLoading,
|
|
3954
|
+
size,
|
|
3955
|
+
disableCloseOnSelect: true,
|
|
3956
|
+
options: combinedOptions,
|
|
3957
|
+
sx: { width: "100%" },
|
|
3958
|
+
noOptionsText: "\u062F\u0627\u062F\u0647\u200C\u0627\u06CC \u0628\u0631\u0627\u06CC \u0646\u0645\u0627\u06CC\u0634 \u0648\u062C\u0648\u062F \u0646\u062F\u0627\u0631\u062F",
|
|
3959
|
+
value: computedValue,
|
|
3960
|
+
onChange: (event, value2) => handleChange(event, value2, onChange),
|
|
3961
|
+
isOptionEqualToValue: (option, value2) => String(option.key) === String(value2?.key),
|
|
3962
|
+
getOptionLabel: (option) => option.title,
|
|
3963
|
+
loading: isLoading,
|
|
3964
|
+
loadingText: "\u062F\u0631 \u062D\u0627\u0644 \u0628\u0627\u0631\u06AF\u0630\u0627\u0631\u06CC...",
|
|
3965
|
+
renderOption: (props, option) => {
|
|
3966
|
+
if (renderOption) {
|
|
3967
|
+
return renderOption(props, option);
|
|
3968
|
+
}
|
|
3969
|
+
return /* @__PURE__ */ React27.createElement(
|
|
3970
|
+
"li",
|
|
3971
|
+
{
|
|
3972
|
+
...props,
|
|
3973
|
+
key: `${option.key}`,
|
|
3974
|
+
style: { margin: 5, borderRadius: 3 }
|
|
3975
|
+
},
|
|
3976
|
+
/* @__PURE__ */ React27.createElement(
|
|
3977
|
+
"div",
|
|
3978
|
+
{
|
|
3979
|
+
style: {
|
|
3980
|
+
display: "flex",
|
|
3981
|
+
flexDirection: "row",
|
|
3982
|
+
width: "100%"
|
|
3983
|
+
}
|
|
3984
|
+
},
|
|
3985
|
+
/* @__PURE__ */ React27.createElement("div", { style: { flexDirection: "column", width: "100%" } }, /* @__PURE__ */ React27.createElement("div", { style: { fontWeight: "normal" } }, option.title))
|
|
3986
|
+
)
|
|
3987
|
+
);
|
|
3988
|
+
},
|
|
3989
|
+
slots: { popper: import_material26.Popper },
|
|
3990
|
+
slotProps: {
|
|
3991
|
+
popper: {
|
|
3992
|
+
modifiers: [
|
|
3993
|
+
{
|
|
3994
|
+
name: "preventOverflow",
|
|
3995
|
+
options: {
|
|
3996
|
+
boundary: "window",
|
|
3997
|
+
rootBoundary: "viewport",
|
|
3998
|
+
altBoundary: true,
|
|
3999
|
+
padding: 10
|
|
4000
|
+
}
|
|
4001
|
+
},
|
|
4002
|
+
{
|
|
4003
|
+
name: "flip",
|
|
4004
|
+
options: {
|
|
4005
|
+
fallbackPlacements: ["top", "bottom"]
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
]
|
|
4009
|
+
}
|
|
4010
|
+
},
|
|
4011
|
+
renderInput: (params) => /* @__PURE__ */ React27.createElement(
|
|
4012
|
+
import_TextField4.default,
|
|
4013
|
+
{
|
|
4014
|
+
...params,
|
|
4015
|
+
label,
|
|
4016
|
+
error: !!error,
|
|
4017
|
+
helperText: error?.message,
|
|
4018
|
+
inputRef: ref,
|
|
4019
|
+
InputProps: {
|
|
4020
|
+
...params.InputProps,
|
|
4021
|
+
endAdornment: /* @__PURE__ */ React27.createElement(React27.Fragment, null, isLoading ? /* @__PURE__ */ React27.createElement(import_material26.CircularProgress, { color: "primary", size: 20 }) : null, params.InputProps.endAdornment)
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
)
|
|
4025
|
+
}
|
|
4026
|
+
);
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
);
|
|
4030
|
+
}
|
|
3902
4031
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3903
4032
|
0 && (module.exports = {
|
|
3904
4033
|
Accordion,
|
|
@@ -3918,6 +4047,7 @@ var bascule_connection_button_default = ConnectToBasculeButton;
|
|
|
3918
4047
|
LicensePlate,
|
|
3919
4048
|
MobileDateTimePicker,
|
|
3920
4049
|
Modal,
|
|
4050
|
+
MultipleSelector,
|
|
3921
4051
|
NestedSelectort,
|
|
3922
4052
|
NoResult,
|
|
3923
4053
|
PaginationList,
|