@dooherceg/material-react-table 3.2.12 → 3.2.14

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.ts CHANGED
@@ -412,7 +412,12 @@ interface MRT_Localization {
412
412
  filterEndsWith: string;
413
413
  filterEquals: string;
414
414
  filterEqualsString: string;
415
+ filterIs: string;
416
+ filterNot: string;
415
417
  filterFuzzy: string;
418
+ filterBefore: string;
419
+ filterAfter: string;
420
+ filterRange: string;
416
421
  filterGreaterThan: string;
417
422
  filterGreaterThanOrEqualTo: string;
418
423
  filterInArray: string;
@@ -1527,7 +1532,7 @@ type UseServerTableStateReturn = {
1527
1532
  refetch: () => void;
1528
1533
  };
1529
1534
  type ColumnType = 'string' | 'number' | 'date' | 'dateTime' | 'enum' | 'icon' | 'dimension' | 'boolean' | 'actions' | 'object';
1530
- type MRT_FilterOperator = 'between' | 'contains' | 'current-month' | 'current-week' | 'endsWith' | 'equals' | 'from-today' | 'fuzzy' | 'greaterThan' | 'greaterThanOrEqualTo' | 'isAnyOf' | 'isEmpty' | 'isNotEmpty' | 'last-7-days' | 'last-month' | 'last-week' | 'lessThan' | 'lessThanOrEqualTo' | 'notContains' | 'notEquals' | 'startsWith' | 'to-today';
1535
+ type MRT_FilterOperator = '!=' | '<' | '<=' | '=' | '>' | '>=' | 'after' | 'before' | 'contains' | 'current-month' | 'current-week' | 'doesNotContain' | 'doesNotEqual' | 'endsWith' | 'equals' | 'from-today' | 'fuzzy' | 'is' | 'isAnyOf' | 'isEmpty' | 'isNotEmpty' | 'last-7-days' | 'last-month' | 'last-week' | 'not' | 'range' | 'startsWith' | 'to-today';
1531
1536
  interface MRT_SavedFilter {
1532
1537
  name: string;
1533
1538
  logicOperator: MRT_FiltersLogicOperator;
package/dist/index.esm.js CHANGED
@@ -2333,6 +2333,11 @@ const MRT_Localization_EN = {
2333
2333
  filterEndsWith: 'Ends With',
2334
2334
  filterEquals: 'Equals',
2335
2335
  filterEqualsString: 'Equals',
2336
+ filterIs: 'Is',
2337
+ filterNot: 'Not',
2338
+ filterBefore: 'Before',
2339
+ filterAfter: 'After',
2340
+ filterRange: 'Range',
2336
2341
  filterFuzzy: 'Fuzzy',
2337
2342
  filterGreaterThan: 'Greater Than',
2338
2343
  filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
@@ -3797,10 +3802,10 @@ const BooleanColumnResolver = {
3797
3802
  // A boolean filter only makes sense as equality — true or false
3798
3803
  editComponent: MRT_FilterRuleBooleanEditor,
3799
3804
  getInitialValue: () => '',
3800
- id: 'equals',
3805
+ id: 'is',
3801
3806
  // Empty unless the user has explicitly picked true or false
3802
3807
  isValueEmpty: (value) => value !== true && value !== false,
3803
- label: 'Equals',
3808
+ label: 'Is',
3804
3809
  valueShape: 'single',
3805
3810
  },
3806
3811
  ],
@@ -3943,7 +3948,7 @@ const DateColumnResolver = {
3943
3948
  {
3944
3949
  editComponent: MRT_FilterRuleDateEditor,
3945
3950
  getInitialValue: () => null,
3946
- id: 'lessThan',
3951
+ id: 'before',
3947
3952
  // null means no date selected
3948
3953
  isValueEmpty: (value) => !value,
3949
3954
  label: 'Before',
@@ -3952,7 +3957,7 @@ const DateColumnResolver = {
3952
3957
  {
3953
3958
  editComponent: MRT_FilterRuleDateEditor,
3954
3959
  getInitialValue: () => null,
3955
- id: 'greaterThan',
3960
+ id: 'after',
3956
3961
  isValueEmpty: (value) => !value,
3957
3962
  label: 'After',
3958
3963
  valueShape: 'single',
@@ -3961,7 +3966,7 @@ const DateColumnResolver = {
3961
3966
  // Range value is stored as {from, to} Unix ms timestamps
3962
3967
  editComponent: MRT_FilterRuleRangeDateEditor,
3963
3968
  getInitialValue: () => ({ from: null, to: null }),
3964
- id: 'between',
3969
+ id: 'range',
3965
3970
  isValueEmpty: (value) => {
3966
3971
  const v = value;
3967
3972
  return !v || !v.from || !v.to;
@@ -4112,7 +4117,7 @@ const DateTimeColumnResolver = {
4112
4117
  {
4113
4118
  editComponent: MRT_FilterRuleDateTimeEditor,
4114
4119
  getInitialValue: () => null,
4115
- id: 'lessThan',
4120
+ id: 'before',
4116
4121
  // null means no datetime selected
4117
4122
  isValueEmpty: (value) => !value,
4118
4123
  label: 'Before',
@@ -4121,7 +4126,7 @@ const DateTimeColumnResolver = {
4121
4126
  {
4122
4127
  editComponent: MRT_FilterRuleDateTimeEditor,
4123
4128
  getInitialValue: () => null,
4124
- id: 'greaterThan',
4129
+ id: 'after',
4125
4130
  isValueEmpty: (value) => !value,
4126
4131
  label: 'After',
4127
4132
  valueShape: 'single',
@@ -4130,7 +4135,7 @@ const DateTimeColumnResolver = {
4130
4135
  // Range value is stored as {from, to} Unix ms timestamps
4131
4136
  editComponent: MRT_FilterRuleRangeDateTimeEditor,
4132
4137
  getInitialValue: () => ({ from: null, to: null }),
4133
- id: 'between',
4138
+ id: 'range',
4134
4139
  isValueEmpty: (value) => {
4135
4140
  const v = value;
4136
4141
  return !v || !v.from || !v.to;
@@ -4279,7 +4284,7 @@ const DimensionColumnResolver = {
4279
4284
  {
4280
4285
  editComponent: MRT_DimensionFilterEditor,
4281
4286
  getInitialValue: () => ({}),
4282
- id: 'equals',
4287
+ id: 'is',
4283
4288
  // Value is empty when no dimension field has been filled in (ignoring rotation)
4284
4289
  isValueEmpty: (value) => {
4285
4290
  const dimensionValue = value;
@@ -4288,7 +4293,7 @@ const DimensionColumnResolver = {
4288
4293
  const fieldKeys = Object.keys(dimensionValue).filter((key) => key !== 'rotation');
4289
4294
  return fieldKeys.every((key) => dimensionValue[key] == null);
4290
4295
  },
4291
- label: 'Equals',
4296
+ label: 'Is',
4292
4297
  valueShape: 'single',
4293
4298
  },
4294
4299
  ],
@@ -4380,7 +4385,7 @@ const EnumColumnResolver = {
4380
4385
  if (!enumOptions.length) {
4381
4386
  return [];
4382
4387
  }
4383
- // Shared single-select editor factory — used by 'equals' and 'notEquals'
4388
+ // Shared single-select editor factory — used by 'is' and 'not'
4384
4389
  const createSingleSelectEditor = (props) => MRT_SingleValueEditor(Object.assign(Object.assign({}, props), { options: enumOptions }));
4385
4390
  // Multi-select editor factory — used by 'inArray'
4386
4391
  const createMultiSelectEditor = (props) => MRT_MultiValueEditor(Object.assign(Object.assign({}, props), { options: enumOptions }));
@@ -4389,18 +4394,18 @@ const EnumColumnResolver = {
4389
4394
  // 'Je' — single value must match exactly
4390
4395
  editComponent: createSingleSelectEditor,
4391
4396
  getInitialValue: () => '',
4392
- id: 'equals',
4397
+ id: 'is',
4393
4398
  isValueEmpty: (value) => value === '' || value === null,
4394
- label: 'Equals',
4399
+ label: 'Is',
4395
4400
  valueShape: 'single',
4396
4401
  },
4397
4402
  {
4398
4403
  // 'Nije' — single value must not match
4399
4404
  editComponent: createSingleSelectEditor,
4400
4405
  getInitialValue: () => '',
4401
- id: 'notEquals',
4406
+ id: 'not',
4402
4407
  isValueEmpty: (value) => value === '' || value === null,
4403
- label: 'Not Equals',
4408
+ label: 'Not',
4404
4409
  valueShape: 'single',
4405
4410
  },
4406
4411
  {
@@ -4538,7 +4543,7 @@ const MRT_IconMultiValueEditor = ({ availableIcons, column, iconsList, onChange,
4538
4543
  };
4539
4544
 
4540
4545
  // Single-select filter editor for icon column type.
4541
- // Used by the 'equals' (Je) and 'notEquals' (Nije) operators.
4546
+ // Used by the 'is' (Je) and 'not' (Nije) operators.
4542
4547
  // Stores the selected iconCode as a string in the filter rule value.
4543
4548
  const MRT_IconSingleValueEditor = ({ availableIcons, column, iconsList, onChange, rule, table, }) => {
4544
4549
  // Render a localised fallback when no options are available (guard against misconfigured columns)
@@ -4618,7 +4623,7 @@ const IconColumnResolver = {
4618
4623
  if (!availableIcons.length) {
4619
4624
  return [];
4620
4625
  }
4621
- // Single-select editor factory — used by 'equals' and 'notEquals'
4626
+ // Single-select editor factory — used by 'is' and 'not'
4622
4627
  const createSingleSelectEditor = (props) => MRT_IconSingleValueEditor(Object.assign(Object.assign({}, props), { availableIcons,
4623
4628
  iconsList }));
4624
4629
  // Multi-select editor factory — used by 'inArray'
@@ -4629,18 +4634,18 @@ const IconColumnResolver = {
4629
4634
  // 'Je' — selected iconCode must match the cell value exactly
4630
4635
  editComponent: createSingleSelectEditor,
4631
4636
  getInitialValue: () => '',
4632
- id: 'equals',
4637
+ id: 'is',
4633
4638
  isValueEmpty: (value) => value === '' || value == null,
4634
- label: 'Equals',
4639
+ label: 'Is',
4635
4640
  valueShape: 'single',
4636
4641
  },
4637
4642
  {
4638
4643
  // 'Nije' — selected iconCode must not match the cell value
4639
4644
  editComponent: createSingleSelectEditor,
4640
4645
  getInitialValue: () => '',
4641
- id: 'notEquals',
4646
+ id: 'not',
4642
4647
  isValueEmpty: (value) => value === '' || value == null,
4643
- label: 'Not Equals',
4648
+ label: 'Not',
4644
4649
  valueShape: 'single',
4645
4650
  },
4646
4651
  {
@@ -4683,9 +4688,6 @@ const MRT_FormNumberInput = ({ name, columnDef, fieldConfig, }) => {
4683
4688
  const NumberActiveFilterItem = (table, rule) => {
4684
4689
  if (typeof rule.value !== 'number' && !Array.isArray(rule.value))
4685
4690
  return null;
4686
- if (rule.operator === 'between' && Array.isArray(rule.value)) {
4687
- return (jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsx(Typography, { variant: "body2", children: `${rule.value[0]} - ${rule.value[1]}` }) }));
4688
- }
4689
4691
  if (rule.operator === 'isAnyOf' && Array.isArray(rule.value)) {
4690
4692
  return (jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsx(Typography, { variant: "body2", children: rule.value.join(', ') }) }));
4691
4693
  }
@@ -4701,7 +4703,7 @@ const NumberColumnResolver = {
4701
4703
  {
4702
4704
  editComponent: MRT_FilterRuleNumberEditor,
4703
4705
  getInitialValue: () => '',
4704
- id: 'equals',
4706
+ id: '=',
4705
4707
  isValueEmpty: (value) => value === '' || value === null,
4706
4708
  label: 'Equals',
4707
4709
  triggerMode: 'commit',
@@ -4711,7 +4713,7 @@ const NumberColumnResolver = {
4711
4713
  // Mirrors MUI != operator — cell value must not equal the entered number
4712
4714
  editComponent: MRT_FilterRuleNumberEditor,
4713
4715
  getInitialValue: () => '',
4714
- id: 'notEquals',
4716
+ id: '!=',
4715
4717
  isValueEmpty: (value) => value === '' || value === null,
4716
4718
  label: 'Not Equals',
4717
4719
  triggerMode: 'commit',
@@ -4720,7 +4722,7 @@ const NumberColumnResolver = {
4720
4722
  {
4721
4723
  editComponent: MRT_FilterRuleNumberEditor,
4722
4724
  getInitialValue: () => '',
4723
- id: 'greaterThan',
4725
+ id: '>',
4724
4726
  isValueEmpty: (value) => value === '' || value === null,
4725
4727
  label: 'Greater Than',
4726
4728
  triggerMode: 'commit',
@@ -4729,7 +4731,7 @@ const NumberColumnResolver = {
4729
4731
  {
4730
4732
  editComponent: MRT_FilterRuleNumberEditor,
4731
4733
  getInitialValue: () => '',
4732
- id: 'greaterThanOrEqualTo',
4734
+ id: '>=',
4733
4735
  isValueEmpty: (value) => value === '' || value === null,
4734
4736
  label: 'Greater Than Or Equal To',
4735
4737
  triggerMode: 'commit',
@@ -4738,7 +4740,7 @@ const NumberColumnResolver = {
4738
4740
  {
4739
4741
  editComponent: MRT_FilterRuleNumberEditor,
4740
4742
  getInitialValue: () => '',
4741
- id: 'lessThan',
4743
+ id: '<',
4742
4744
  isValueEmpty: (value) => value === '' || value === null,
4743
4745
  label: 'Less Than',
4744
4746
  triggerMode: 'commit',
@@ -4747,7 +4749,7 @@ const NumberColumnResolver = {
4747
4749
  {
4748
4750
  editComponent: MRT_FilterRuleNumberEditor,
4749
4751
  getInitialValue: () => '',
4750
- id: 'lessThanOrEqualTo',
4752
+ id: '<=',
4751
4753
  isValueEmpty: (value) => value === '' || value === null,
4752
4754
  label: 'Less Than Or Equal To',
4753
4755
  triggerMode: 'commit',
@@ -4850,7 +4852,7 @@ const StringColumnResolver = {
4850
4852
  // Mirrors MUI doesNotEqual — text must not match the cell value exactly
4851
4853
  editComponent: MRT_FilterRuleTextEditor,
4852
4854
  getInitialValue: () => '',
4853
- id: 'notEquals',
4855
+ id: 'doesNotEqual',
4854
4856
  isValueEmpty: (value) => !`${value !== null && value !== void 0 ? value : ''}`.trim(),
4855
4857
  label: 'Does Not Equal',
4856
4858
  triggerMode: 'commit',
@@ -4878,7 +4880,7 @@ const StringColumnResolver = {
4878
4880
  // Mirrors MUI doesNotContain — cell value must not include the typed substring
4879
4881
  editComponent: MRT_FilterRuleTextEditor,
4880
4882
  getInitialValue: () => '',
4881
- id: 'notContains',
4883
+ id: 'doesNotContain',
4882
4884
  isValueEmpty: (value) => !`${value !== null && value !== void 0 ? value : ''}`.trim(),
4883
4885
  label: 'Does Not Contain',
4884
4886
  triggerMode: 'commit',
@@ -4958,25 +4960,31 @@ const getColumnFilterOperators = (column) => {
4958
4960
  // Lookup map: operator id → localization key.
4959
4961
  // Using a map avoids a long switch statement and makes it easy to extend.
4960
4962
  const OPERATOR_LOCALIZATION_KEYS = {
4961
- between: 'filterBetween',
4963
+ '!=': 'filterNotEquals',
4964
+ '<': 'filterLessThan',
4965
+ '<=': 'filterLessThanOrEqualTo',
4966
+ '=': 'filterEquals',
4967
+ '>': 'filterGreaterThan',
4968
+ '>=': 'filterGreaterThanOrEqualTo',
4969
+ after: 'filterAfter',
4970
+ before: 'filterBefore',
4962
4971
  contains: 'filterContains',
4963
4972
  'current-month': 'filterCurrentMonth',
4964
4973
  'current-week': 'filterCurrentWeek',
4974
+ doesNotContain: 'filterNotContains',
4975
+ doesNotEqual: 'filterNotEquals',
4965
4976
  endsWith: 'filterEndsWith',
4966
4977
  equals: 'filterEquals',
4967
4978
  'from-today': 'filterFromToday',
4968
- greaterThan: 'filterGreaterThan',
4969
- greaterThanOrEqualTo: 'filterGreaterThanOrEqualTo',
4979
+ is: 'filterIs',
4970
4980
  isAnyOf: 'filterIsAnyOf',
4971
4981
  isEmpty: 'filterEmpty',
4972
4982
  isNotEmpty: 'filterNotEmpty',
4973
4983
  'last-7-days': 'filterLast7Days',
4974
4984
  'last-month': 'filterLastMonth',
4975
4985
  'last-week': 'filterLastWeek',
4976
- lessThan: 'filterLessThan',
4977
- lessThanOrEqualTo: 'filterLessThanOrEqualTo',
4978
- notContains: 'filterNotContains',
4979
- notEquals: 'filterNotEquals',
4986
+ not: 'filterNot',
4987
+ range: 'filterRange',
4980
4988
  startsWith: 'filterStartsWith',
4981
4989
  'to-today': 'filterToToday',
4982
4990
  };
@@ -5444,6 +5452,11 @@ const MRT_Localization_HR = {
5444
5452
  filterEndsWith: 'Završava s',
5445
5453
  filterEquals: 'Jednako',
5446
5454
  filterEqualsString: 'Jednako',
5455
+ filterIs: 'Je',
5456
+ filterNot: 'Nije',
5457
+ filterBefore: 'Prije',
5458
+ filterAfter: 'Poslije',
5459
+ filterRange: 'Raspon',
5447
5460
  filterFuzzy: 'Maglovito',
5448
5461
  filterGreaterThan: 'Veće od',
5449
5462
  filterGreaterThanOrEqualTo: 'Veće od ili jednako',
@@ -7047,13 +7060,14 @@ const MRT_NewEntryFormActions = ({ table, }) => {
7047
7060
  var _a, _b;
7048
7061
  const methods = useFormContext();
7049
7062
  const { handleCancel, handleSave } = useMRT_NewEntryFormActions();
7063
+ const { isSubmitting } = methods.formState;
7050
7064
  const { options: { formConfig, localization, muiNewEntryModalProps }, } = table;
7051
7065
  const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
7052
7066
  const mode = (_a = newEntryModal.mode) !== null && _a !== void 0 ? _a : 'create';
7053
7067
  const resolvedModalProps = muiNewEntryModalProps !== null && muiNewEntryModalProps !== void 0 ? muiNewEntryModalProps : {};
7054
7068
  const { footerProps, footerSx } = resolvedModalProps;
7055
7069
  const callbackProps = { form: methods, mode, table };
7056
- return (jsxs(Stack, Object.assign({ direction: "row", justifyContent: "flex-end" }, footerProps, { sx: Object.assign({ gap: 1, pt: 1, px: 2 }, footerSx), children: [(formConfig === null || formConfig === void 0 ? void 0 : formConfig.renderSaveButton) ? (formConfig.renderSaveButton(Object.assign(Object.assign({}, callbackProps), { handleAction: handleSave }))) : (formConfig === null || formConfig === void 0 ? void 0 : formConfig.onSave) ? (jsx(Button, { type: "submit", variant: "contained", children: localization.save })) : null, (formConfig === null || formConfig === void 0 ? void 0 : formConfig.renderCancelButton) ? (formConfig.renderCancelButton(Object.assign(Object.assign({}, callbackProps), { handleAction: handleCancel }))) : (jsx(Button, { onClick: handleCancel, variant: "outlined", children: localization.cancel })), (_b = formConfig === null || formConfig === void 0 ? void 0 : formConfig.customActions) === null || _b === void 0 ? void 0 : _b.map((customAction) => (jsx(Fragment$1, { children: customAction.render(callbackProps) }, customAction.key)))] })));
7070
+ return (jsxs(Stack, Object.assign({ direction: "row", justifyContent: "flex-end" }, footerProps, { sx: Object.assign({ gap: 1, pt: 1, px: 2 }, footerSx), children: [(formConfig === null || formConfig === void 0 ? void 0 : formConfig.renderSaveButton) ? (formConfig.renderSaveButton(Object.assign(Object.assign({}, callbackProps), { handleAction: handleSave }))) : (formConfig === null || formConfig === void 0 ? void 0 : formConfig.onSave) ? (jsx(Button, { loading: isSubmitting, type: "submit", variant: "contained", children: localization.save })) : null, (formConfig === null || formConfig === void 0 ? void 0 : formConfig.renderCancelButton) ? (formConfig.renderCancelButton(Object.assign(Object.assign({}, callbackProps), { handleAction: handleCancel }))) : (jsx(Button, { onClick: handleCancel, variant: "outlined", children: localization.cancel })), (_b = formConfig === null || formConfig === void 0 ? void 0 : formConfig.customActions) === null || _b === void 0 ? void 0 : _b.map((customAction) => (jsx(Fragment$1, { children: customAction.render(callbackProps) }, customAction.key)))] })));
7057
7071
  };
7058
7072
 
7059
7073
  // Thin wrapper that provides RHF context to all descendants and wraps them in a native <form>.