tp-react-elements 3.0.7 → 3.0.9

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,3 +1,3 @@
1
- var Month = {};
1
+ var DateInput = {};
2
2
 
3
- export { Month as __exports };
3
+ export { DateInput as __exports };
@@ -1,3 +1,3 @@
1
- var DateInput = {};
1
+ var InputRangeField = {};
2
2
 
3
- export { DateInput as __exports };
3
+ export { InputRangeField as __exports };
@@ -1,3 +1,3 @@
1
- var InputRangeField = {};
1
+ var Month = {};
2
2
 
3
- export { InputRangeField as __exports };
3
+ export { Month as __exports };
@@ -1,3 +1,3 @@
1
- var Calendar = {};
1
+ var DateRange = {};
2
2
 
3
- export { Calendar as __exports };
3
+ export { DateRange as __exports };
@@ -1,3 +1,3 @@
1
- var DateRange = {};
1
+ var DateRangePicker = {};
2
2
 
3
- export { DateRange as __exports };
3
+ export { DateRangePicker as __exports };
@@ -1,3 +1,3 @@
1
- var DateRangePicker = {};
1
+ var Calendar = {};
2
2
 
3
- export { DateRangePicker as __exports };
3
+ export { Calendar as __exports };
@@ -1,6 +1,13 @@
1
1
  import { jsx, Fragment } from 'react/jsx-runtime';
2
2
  import require$$0__default, { lazy, Suspense } from 'react';
3
3
  import FormCheckBox from '../FormComponents/FormCheckBox/FormCheckBox.esm.js';
4
+ import FormCheckBoxGroup from '../FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
5
+ import FormNumberField from '../FormComponents/FormNumberField/FormNumberField.esm.js';
6
+ import FormNumberFieldDecimal from '../FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js';
7
+ import FormRadioGroup from '../FormComponents/FormRadioGroup/FormRadioGroup.esm.js';
8
+ import FormTextAreaField from '../FormComponents/FormTextAreaField/FormTextAreaField.esm.js';
9
+ import FormTextField from '../FormComponents/FormTextField/FormTextField.esm.js';
10
+ import PasswordField from '../FormComponents/PasswordField/PasswordField.esm.js';
4
11
  import SingleSelect from '../FormComponents/Select/SingleSelect.esm.js';
5
12
  import MultiSelectAutocomplete from '../FormComponents/Select/MultiSelectAutocomplete.esm.js';
6
13
  import SingleSelectNonAutoComplete from '../FormComponents/Select/SingleSelectNonAutoComplete.esm.js';
@@ -11,13 +18,6 @@ import DateRangePickerComponent from '../DateRangePicker/DateRangePicker.esm.js'
11
18
  import RichTextEditorWrapper from '../FormComponents/RichTextEditor/RichTextEditorWrapper.esm.js';
12
19
  import SingleSelectSearchApi from '../FormComponents/Select/SingleSelectSearchApi.esm.js';
13
20
  import DatetimepickerWrapper from '../FormComponents/DatePicker/DatetimepickerWrapper.esm.js';
14
- import FormTextAreaField from '../FormComponents/FormTextAreaField/FormTextAreaField.esm.js';
15
- import FormRadioGroup from '../FormComponents/FormRadioGroup/FormRadioGroup.esm.js';
16
- import FormCheckBoxGroup from '../FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
17
- import FormNumberFieldDecimal from '../FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js';
18
- import FormNumberField from '../FormComponents/FormNumberField/FormNumberField.esm.js';
19
- import PasswordField from '../FormComponents/PasswordField/PasswordField.esm.js';
20
- import FormTextField from '../FormComponents/FormTextField/FormTextField.esm.js';
21
21
 
22
22
  // Lazy-loaded heavy components
23
23
  // const RichTextEditorWrapper = lazy(() =>
@@ -72,7 +72,10 @@ const MultiSelectAutocomplete = ({ props, variant, maxChips = 2, }) => {
72
72
  // ── Stable callbacks ───────────────────────────────────────────────────────
73
73
  const getOptionLabelCb = useCallback((option) => String(option.label), []);
74
74
  const isOptionEqualCb = useCallback((option, value) => String(option.value) === String(value.value), []);
75
- const renderOptionCb = useCallback((renderProps, option, state) => (jsxs("li", { ...renderProps, style: { fontSize: '11px' }, children: [jsx(Checkbox, { checked: state.selected, size: "small", sx: { mr: 1, p: '2px' } }), option.label] })), []);
75
+ const renderOptionCb = useCallback((renderProps, option, state) => {
76
+ const { key, ...otherProps } = renderProps;
77
+ return (jsxs("li", { ...otherProps, style: { fontSize: '11px' }, children: [jsx(Checkbox, { checked: state.selected, size: "small", sx: { mr: 1, p: '2px' } }), option.label] }, key));
78
+ }, []);
76
79
  const chipSx = useMemo(() => ({
77
80
  mr: 0.5,
78
81
  height: 20,
@@ -109,7 +112,7 @@ const MultiSelectAutocomplete = ({ props, variant, maxChips = 2, }) => {
109
112
  clearErrors?.(name);
110
113
  }, [setValue, clearErrors, name, onChangeFn]);
111
114
  // ── Render ─────────────────────────────────────────────────────────────────
112
- return (jsx(Controller, { control: control, name: name, render: ({ field: { ref, onBlur: fieldOnBlur } }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Autocomplete, { ref: ref, open: open, onOpen: () => setOpen(true), onClose: () => setOpen(false), multiple: true, disableCloseOnSelect: true, id: `${name}-autocomplete-multi`, options: options, value: selectedOptions, getOptionLabel: getOptionLabelCb, isOptionEqualToValue: isOptionEqualCb, getOptionDisabled: (option) => option.disable, onChange: handleChange, onBlur: (e) => {
115
+ return (jsx(Controller, { control: control, name: name, render: ({ field: { ref, onBlur: fieldOnBlur } }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Autocomplete, { ref: ref, fullWidth: true, open: open, onOpen: () => setOpen(true), onClose: () => setOpen(false), multiple: true, disableCloseOnSelect: true, id: `${name}-autocomplete-multi`, options: options, value: selectedOptions, getOptionLabel: getOptionLabelCb, isOptionEqualToValue: isOptionEqualCb, getOptionDisabled: (option) => option.disable, onChange: handleChange, onBlur: (e) => {
113
116
  fieldOnBlur();
114
117
  handleBlur(e);
115
118
  }, size: "small", disablePortal: false, autoHighlight: true, selectOnFocus: true, clearOnBlur: false, renderTags: (tagValue, getTagProps) => (jsx(Box, { ref: tagsContainerRef, sx: {
@@ -14,7 +14,7 @@ const SingleSelect = ({ props, variant }) => {
14
14
  const value = currentValue
15
15
  ? props.item.options?.find((item) => item.value === currentValue)
16
16
  : null;
17
- return (jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Tooltip, { title: props.item.isTooltipEnable ? (value?.label || '') : '', placement: "bottom-start", children: jsxs(Box, { sx: { width: '100%', position: 'relative' }, children: [jsx(Autocomplete, { ...field, id: `${props.item.name}-autocomplete`, value: value, onChange: (_, newValue) => {
17
+ return (jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Tooltip, { title: props.item.isTooltipEnable ? (value?.label || '') : '', placement: "bottom-start", children: jsxs(Box, { sx: { width: '100%', position: 'relative' }, children: [jsx(Autocomplete, { ...field, fullWidth: true, id: `${props.item.name}-autocomplete`, value: value, onChange: (_, newValue) => {
18
18
  props.setValue(props?.item?.name, newValue?.value);
19
19
  props?.item?.onChangeFn && props?.item?.onChangeFn(newValue?.value, newValue);
20
20
  props?.clearErrors && props?.clearErrors(props?.item?.name);
@@ -49,10 +49,14 @@ const SingleSelect = ({ props, variant }) => {
49
49
  fontSize: '11px',
50
50
  },
51
51
  },
52
- }, renderOption: (props, option) => (createElement("li", { ...props, value: option.value, style: {
53
- opacity: option.disable ? 0.5 : 1,
54
- pointerEvents: option.disable ? 'none' : 'auto',
55
- }, key: option.value }, option.label)), renderInput: (params) => (jsx(TextField, { ...params, placeholder: props.item.placeholder, error: isShowBorderError, label: variant !== 'standard'
52
+ }, renderOption: (props, option) => {
53
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
54
+ const { key, ...optionProps } = props;
55
+ return (createElement("li", { ...optionProps, value: option.value, style: {
56
+ opacity: option.disable ? 0.5 : 1,
57
+ pointerEvents: option.disable ? 'none' : 'auto',
58
+ }, key: option.value }, option.label));
59
+ }, renderInput: (params) => (jsx(TextField, { ...params, placeholder: props.item.placeholder, error: isShowBorderError, label: variant !== 'standard'
56
60
  ? `${props.item.label}${props.item.required ? ' *' : ''}`
57
61
  : '', inputProps: {
58
62
  ...params.inputProps,
@@ -197,7 +197,7 @@ const SingleSelectSearchApi = ({ props, variant, minSearchLength = 3, debounceMs
197
197
  return fetchError ?? 'No results found';
198
198
  }, [searchQuery, minSearchLength, fetchError]);
199
199
  // ── Render ────────────────────────────────────────────────────────────────
200
- return (jsx(Controller, { control: control, name: name, render: ({ field: { ref, onBlur } }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Autocomplete, { ref: ref, value: resolvedValue, inputValue: displayText, onInputChange: handleInputChange, onChange: handleChange, onBlur: onBlur, options: options, getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue,
200
+ return (jsx(Controller, { control: control, name: name, render: ({ field: { ref, onBlur } }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Autocomplete, { ref: ref, fullWidth: true, value: resolvedValue, inputValue: displayText, onInputChange: handleInputChange, onChange: handleChange, onBlur: onBlur, options: options, getOptionLabel: getOptionLabel, isOptionEqualToValue: isOptionEqualToValue,
201
201
  // Options come pre-filtered from the server — disable client-side filtering
202
202
  filterOptions: (x) => x, loading: isLoading, disabled: disable, size: "small", noOptionsText: noOptionsText, sx: {
203
203
  '& .MuiAutocomplete-input': {
@@ -1,3 +1,8 @@
1
+ export { default as FormNumberField } from './FormNumberField/FormNumberField.esm.js';
2
+ export { default as FormNumberFieldDecimal } from './FormNumberField/FormNumberFieldDecimal.esm.js';
3
+ export { default as FormTextAreaField } from './FormTextAreaField/FormTextAreaField.esm.js';
4
+ export { default as FormTextField } from './FormTextField/FormTextField.esm.js';
5
+ export { default as PasswordField } from './PasswordField/PasswordField.esm.js';
1
6
  export { default as FormCheckBox } from './FormCheckBox/FormCheckBox.esm.js';
2
7
  export { default as SingleSelect } from './Select/SingleSelect.esm.js';
3
8
  export { default as SingleSelectNonAutoComplete } from './Select/SingleSelectNonAutoComplete.esm.js';
@@ -5,21 +10,33 @@ export { default as SingleSelectSearchApi } from './Select/SingleSelectSearchApi
5
10
  export { default as MultiSelectV1 } from './Select/MultiSelectv1.esm.js';
6
11
  export { default as MultiSelectTable } from './Select/MultiSelectTable.esm.js';
7
12
  export { default as SearchableSelect } from './Select/SearchableSelect.esm.js';
8
- export { default as DatepickerWrapperV2 } from './DatePicker/DatepickerWrapperV2.esm.js';
9
- export { default as FormBottomField } from './FormBottomField/FormBottomField.esm.js';
10
13
  export { default as FormCheckBoxGroup } from './FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
11
- export { default as FormErrorField } from './FormErrorField/FormErrorField.esm.js';
12
- export { default as FormNumberField } from './FormNumberField/FormNumberField.esm.js';
13
- export { default as FormNumberFieldDecimal } from './FormNumberField/FormNumberFieldDecimal.esm.js';
14
14
  export { default as FormRadioGroup } from './FormRadioGroup/FormRadioGroup.esm.js';
15
+ export { default as DatepickerWrapperV2 } from './DatePicker/DatepickerWrapperV2.esm.js';
16
+ export { default as Monthpickerrender } from './DatePicker/Monthpickerrender.esm.js';
17
+ import 'react/jsx-runtime';
18
+ import 'react';
19
+ import '@mui/material';
20
+ import '@mui/icons-material/CalendarToday';
21
+ import '@mui/icons-material/ChevronLeft';
22
+ import '@mui/icons-material/ChevronRight';
23
+ import 'react-hook-form';
24
+ export { default as FormBottomField } from './FormBottomField/FormBottomField.esm.js';
25
+ import 'dayjs';
26
+ export { default as YearPickerField } from './YearPickerField/YearPickerField.esm.js';
27
+ export { default as TimePicker } from './TimePicker/TimePicker.esm.js';
15
28
  export { default as FormRenderFileUpload } from './FileUpload/FormRenderFileUpload.esm.js';
16
29
  export { default as FormRenderMultiFileUpload } from './FileUpload/FormRenderMultiFileUpload.esm.js';
17
- export { default as FormTextAreaField } from './FormTextAreaField/FormTextAreaField.esm.js';
18
- export { default as FormTextField } from './FormTextField/FormTextField.esm.js';
30
+ import '@mui/icons-material/Visibility';
31
+ import '@mui/icons-material/Close';
32
+ import '@mui/icons-material/NavigateBefore';
33
+ import '@mui/icons-material/NavigateNext';
34
+ import '@mui/icons-material/Delete';
35
+ import '@mui/icons-material/UploadFile';
36
+ import '@mui/icons-material/PictureAsPdf';
37
+ import '@mui/icons-material/TableChart';
38
+ import '@mui/icons-material/Description';
39
+ export { default as FormErrorField } from './FormErrorField/FormErrorField.esm.js';
19
40
  export { default as HelperText } from './HelperText/HelperText.esm.js';
20
- export { default as Monthpickerrender } from './DatePicker/Monthpickerrender.esm.js';
21
- export { default as PasswordField } from './PasswordField/PasswordField.esm.js';
22
41
  export { default as RichTextEditor } from './RichTextEditor/RichTextEditor.esm.js';
23
42
  export { default as RichTextEditorWrapper } from './RichTextEditor/RichTextEditorWrapper.esm.js';
24
- export { default as TimePicker } from './TimePicker/TimePicker.esm.js';
25
- export { default as YearPickerField } from './YearPickerField/YearPickerField.esm.js';
@@ -460,12 +460,17 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
460
460
  const allowGrow = layoutMode === 'grid' || layoutMode === 'semantic';
461
461
  return columns.map((col) => {
462
462
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
463
- const { filterType, options, getSearchText, ...mrtCol } = col;
463
+ const { filterType, options, getSearchText, exportExcel, ...mrtCol } = col;
464
464
  if (allowGrow && mrtCol.grow === undefined) {
465
465
  mrtCol.grow = true;
466
466
  }
467
467
  // Auto-inject filterFn only when the user hasn't already supplied one.
468
- if (!mrtCol.filterFn && filterType) {
468
+ // Note: `filterType` omitted defaults to the same plain text-input chip
469
+ // as `filterType: 'text'` (see `ColumnFilterType` doc comment), so the
470
+ // text-matching branch below must handle both, not just the explicit
471
+ // `'text'` value — only `enableColumnFilter: false` / `'number'` should
472
+ // fall through without an injected filterFn.
473
+ if (!mrtCol.filterFn) {
469
474
  if (filterType === 'date') {
470
475
  // ISO date strings: "2026-05-05T00:00:00" → startsWith "2026-05-05"
471
476
  mrtCol.filterFn = (row, columnId, filterValue) => filterValue
@@ -485,7 +490,16 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
485
490
  ? true
486
491
  : filterValue.includes(row.getValue(columnId) ?? '');
487
492
  }
488
- // 'text' and 'number' use MRT's built-in client-side filtering
493
+ else if (!filterType || filterType === 'text') {
494
+ // MRT's own default filterFn ('fuzzy', via match-sorter) is a
495
+ // non-contiguous subsequence match — e.g. "PH-1" would match like
496
+ // "%P%H%-%1%" instead of a plain substring. Use MRT's built-in
497
+ // 'contains' filterFn instead, matching Global Search's substring
498
+ // behavior (case-insensitive `.includes()`). Applies whether
499
+ // `filterType` is explicitly `'text'` or simply omitted.
500
+ mrtCol.filterFn = 'contains';
501
+ }
502
+ // 'number' uses MRT's built-in client-side filtering
489
503
  }
490
504
  return mrtCol;
491
505
  });
@@ -521,8 +535,7 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
521
535
  }, [searchTextGetters]);
522
536
  // Stable references for the two table options below — recreating either
523
537
  // per render would defeat the memoization on every other MRT callback
524
- // (see docs/arch-performance.mdx: all function/object props passed into
525
- // useMaterialReactTable must be memoized).
538
+ // (all function/object props passed into useMaterialReactTable must be memoized).
526
539
  const tpFilterFns = useMemo(() => ({ tpGlobalSearch: tpGlobalSearchFn }), [tpGlobalSearchFn]);
527
540
  const getColumnCanGlobalFilter = useCallback(() => true, []);
528
541
  // ── Derive column list for filter chip picker ──────────────────────────────
@@ -589,7 +602,7 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
589
602
  const exportRows = scope === 'filtered' && tableRef.current
590
603
  ? tableRef.current.getFilteredRowModel().rows.map((r) => r.original)
591
604
  : rows;
592
- const dataCols = columns.filter((c) => 'accessorKey' in c && c.accessorKey);
605
+ const dataCols = columns.filter((c) => 'accessorKey' in c && c.accessorKey && c.exportExcel !== false);
593
606
  const headerArgb = hexToArgb(exportHeaderBgColor ?? headerBgColor) ?? 'FF1565C0';
594
607
  const textArgb = hexToArgb(exportHeaderTextColor) ?? 'FFFFFFFF';
595
608
  const headerRow = dataCols.map((c) => c.header ?? '');
@@ -100,6 +100,25 @@ export type TPColumnDef<TData extends object = object, TValue = any> = MRT_Colum
100
100
  * the raw accessor value is matched by default in that case.
101
101
  */
102
102
  getSearchText?: (row: TData) => string | number | null | undefined;
103
+ /**
104
+ * Whether this column is included in the Excel (`.xlsx`) export.
105
+ *
106
+ * Set to `false` on columns that only render UI (e.g. edit/delete action
107
+ * icons) and have no meaningful exported value:
108
+ *
109
+ * ```ts
110
+ * {
111
+ * id: 'actions',
112
+ * header: 'Actions',
113
+ * Cell: ({ row }) => <IconButton onClick={() => onEdit(row.original)}><EditIcon /></IconButton>,
114
+ * exportExcel: false,
115
+ * }
116
+ * ```
117
+ *
118
+ * Default: `true` — every column with an `accessorKey` is exported unless
119
+ * explicitly opted out.
120
+ */
121
+ exportExcel?: boolean;
103
122
  };
104
123
  export interface InvoiceDetail {
105
124
  Data_from: string;
@@ -1,4 +1,4 @@
1
- import { __exports as Calendar } from '../../../../../_virtual/index.esm4.js';
1
+ import { __exports as Calendar } from '../../../../../_virtual/index.esm7.js';
2
2
  import require$$0__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireDayCell } from '../DayCell/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as DateInput } from '../../../../../_virtual/index.esm13.js';
1
+ import { __exports as DateInput } from '../../../../../_virtual/index.esm12.js';
2
2
  import require$$0__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireClassnames } from '../../../../classnames/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as DateRange } from '../../../../../_virtual/index.esm5.js';
1
+ import { __exports as DateRange } from '../../../../../_virtual/index.esm4.js';
2
2
  import require$$0__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireCalendar } from '../Calendar/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as DateRangePicker } from '../../../../../_virtual/index.esm7.js';
1
+ import { __exports as DateRangePicker } from '../../../../../_virtual/index.esm5.js';
2
2
  import require$$0__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireDateRange } from '../DateRange/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as InputRangeField } from '../../../../../_virtual/index.esm14.js';
1
+ import { __exports as InputRangeField } from '../../../../../_virtual/index.esm13.js';
2
2
  import require$$0__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { __exports as Month } from '../../../../../_virtual/index.esm12.js';
1
+ import { __exports as Month } from '../../../../../_virtual/index.esm14.js';
2
2
  import require$$0__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireDayCell } from '../DayCell/index.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tp-react-elements",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "React form components library built with React Hook Form and Yup",