@simoncomputing/mui-bueno-v2 0.25.3 → 0.25.5
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/CHANGELOG.md +24 -0
- package/dist/@types/index.d.ts +18 -0
- package/dist/components/Form/Diff/Diff.d.ts +2 -0
- package/dist/components/Form/Diff/DiffContext.d.ts +15 -4
- package/dist/components/Table/DiffTable/DiffTable.d.ts +2 -4
- package/dist/components/Table/Table.d.ts +13 -1
- package/dist/index.cjs.js +122 -122
- package/dist/index.es.js +13555 -13527
- package/dist/index.umd.js +123 -123
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
- Minor increment --> singlular/minor changes. Minimal breaking changes.
|
|
12
12
|
- Patch increment --> singlular/minor changes. Zero breaking changes.
|
|
13
13
|
|
|
14
|
+
## [0.25.5] - 2026-02-13
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `DiffTable`
|
|
19
|
+
- Modified rows will now display cell-level changes
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- `DiffTable`
|
|
24
|
+
- Updated `column` type to `DiffTableConfig<T>` which uses `DiffTableColumn<T, K>`. This change was made to include `isEqual` & `ignoreDiff` properties.
|
|
25
|
+
- `isEqual` -- equality check for cells (optional, but highly recommended if your column returns a `ReactNode`). Used to determine if the cell should reflect a content change.
|
|
26
|
+
- `ignoreDiff` -- if true, displays the latest value in the cell instead of displaying the diff
|
|
27
|
+
|
|
28
|
+
## [0.25.4] - 2026-02-09
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- `DiffProvider`
|
|
33
|
+
- Added `getCurrentValue` to `useDiff`. Define `currentSnapshot` prop to use.
|
|
34
|
+
- Renamed `getSnapshotValue` to `getPreviousValue`
|
|
35
|
+
- If nothing is passed to `getCurrentValue`/`getPreviousValue`, the original value (`previousSnapshot`/`currentSnapshot`) will be returned
|
|
36
|
+
- Added 2nd param to `getCurrentValue`/`getPreviousValue` for the default value (recommended for arrays).
|
|
37
|
+
|
|
14
38
|
## [0.25.3] - 2026-02-06
|
|
15
39
|
|
|
16
40
|
### Added
|
package/dist/@types/index.d.ts
CHANGED
|
@@ -131,6 +131,24 @@ export type TableColumn<T, K extends keyof T> = {
|
|
|
131
131
|
tooltip?: string;
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Column Definition for DiffTable.
|
|
136
|
+
*
|
|
137
|
+
* Same properties as TableColumn but includes the following:
|
|
138
|
+
* @property {(beforeObject: T, afterObject: T) => boolean} isEqual - (Optional but recommended when `render` is implemented) if provided, used to determine whether the cell has changed
|
|
139
|
+
* @property {boolean} ignoreDiff - (Optional) if true, disables diff for the column and renders the cell normally.
|
|
140
|
+
*/
|
|
141
|
+
export type DiffTableColumn<T, K extends keyof T> = TableColumn<T, K> & {
|
|
142
|
+
isEqual?: (beforeObject: T, afterObject: T) => boolean;
|
|
143
|
+
ignoreDiff?: boolean;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export type DiffTableConfig<T> = Array<
|
|
147
|
+
{
|
|
148
|
+
[K in keyof T]: DiffTableColumnWithKey<T, K>;
|
|
149
|
+
}[keyof T]
|
|
150
|
+
>;
|
|
151
|
+
|
|
134
152
|
// Sort order for Tables
|
|
135
153
|
export type SortOrder = 'asc' | 'desc';
|
|
136
154
|
|
|
@@ -4,16 +4,26 @@ type DiffContextValue = {
|
|
|
4
4
|
*/
|
|
5
5
|
showDiff: boolean;
|
|
6
6
|
/**
|
|
7
|
-
* Obtains the
|
|
7
|
+
* Obtains the previous value from `previousSnapshot`.
|
|
8
8
|
*
|
|
9
|
-
* @param name - formik field name
|
|
9
|
+
* @param name - formik field name (leave out to get full object)
|
|
10
|
+
* @param defaultVal - default value if undefined (ex. fallback array to [])
|
|
10
11
|
* @returns value in previousSnapshot (ex. name='phone' could return "999-123-1234")
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
getPreviousValue: (name?: string, defaultVal?: any) => any;
|
|
14
|
+
/**
|
|
15
|
+
* Obtains the current value from `currentSnapshot` (alternative to getting the value directly form formik)
|
|
16
|
+
*
|
|
17
|
+
* @param name - formik field name (leave out to get full object)
|
|
18
|
+
* @param defaultVal - default value if undefined (ex. fallback array to [])
|
|
19
|
+
* @returns value in currentSnapshot (ex. name='phone' could return "999-123-1234")
|
|
20
|
+
*/
|
|
21
|
+
getCurrentValue: (name?: string, defaultVal?: any) => any;
|
|
13
22
|
};
|
|
14
23
|
type DiffProviderProps = {
|
|
15
24
|
showDiff?: boolean;
|
|
16
25
|
previousSnapshot?: any;
|
|
26
|
+
currentSnapshot?: any;
|
|
17
27
|
children: React.ReactNode;
|
|
18
28
|
};
|
|
19
29
|
/**
|
|
@@ -21,7 +31,8 @@ type DiffProviderProps = {
|
|
|
21
31
|
*
|
|
22
32
|
* @param showDiff - when true (default), enables text diff. Set to false to return form to normal.
|
|
23
33
|
* @param previousSnapshot - previous snapshot. This should match the same stucture as your fields (i.e. formik initialValues)
|
|
34
|
+
* @param currentSnapshot - current snapshot. This should match the same structure as `previousSnapshot`
|
|
24
35
|
*/
|
|
25
|
-
export declare const DiffProvider: ({ showDiff, previousSnapshot, children }: DiffProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export declare const DiffProvider: ({ showDiff, previousSnapshot, currentSnapshot, children, }: DiffProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
37
|
export declare const useDiff: () => DiffContextValue;
|
|
27
38
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DiffTableConfig } from '../../../@types';
|
|
2
2
|
type ChangeType = 'added' | 'deleted' | 'modified';
|
|
3
3
|
export type TableDiff<T> = {
|
|
4
4
|
changeType: ChangeType;
|
|
@@ -10,7 +10,7 @@ export type DiffTableProps<T> = {
|
|
|
10
10
|
/**
|
|
11
11
|
* See Table.columns
|
|
12
12
|
*/
|
|
13
|
-
columns:
|
|
13
|
+
columns: DiffTableConfig<T>;
|
|
14
14
|
/**
|
|
15
15
|
* See Table.renderExpand
|
|
16
16
|
*
|
|
@@ -25,8 +25,6 @@ export type DiffTableProps<T> = {
|
|
|
25
25
|
* rows will be counted and displayed at the bottom, under the table.
|
|
26
26
|
*
|
|
27
27
|
* Data sets MUST be objects with an id property.
|
|
28
|
-
*
|
|
29
|
-
* NOTE: Changed rows only display that the row was changed. Cell-level diff is not yet implemented.
|
|
30
28
|
*/
|
|
31
29
|
export declare const DiffTable: <T extends {
|
|
32
30
|
id: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableProps as MuiTableProps } from '@mui/material';
|
|
2
2
|
import { SystemStyleObject, Theme } from '@mui/system';
|
|
3
|
-
import { SortOrder, TableConfig } from '../../@types';
|
|
3
|
+
import { TableColumn, SortOrder, TableConfig } from '../../@types';
|
|
4
4
|
import { default as React } from 'react';
|
|
5
5
|
/**
|
|
6
6
|
* Interface for table props.
|
|
@@ -146,3 +146,15 @@ export type TableProps<T> = BaseTableProps<T> & Omit<MuiTableProps, 'stickyHeade
|
|
|
146
146
|
* {@link file://../ListPage/ListPage.tsx} which includes add & search functionality.
|
|
147
147
|
*/
|
|
148
148
|
export declare const Table: <T extends object>(props: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
149
|
+
export declare const getFieldKey: <T>(col: TableColumn<T, keyof T>) => string;
|
|
150
|
+
/**
|
|
151
|
+
* Renders a cell in the table.
|
|
152
|
+
* @param col The configuration for the current column
|
|
153
|
+
* @param obj The object for the current Table row
|
|
154
|
+
* @returns ReactNode of the Table cell
|
|
155
|
+
*/
|
|
156
|
+
export declare const renderCell: <T, K extends keyof T>(col: TableColumn<T, K>, obj: T) => React.ReactNode;
|
|
157
|
+
/**
|
|
158
|
+
* Renders table cell via render method, if provided, or as-is (value).
|
|
159
|
+
*/
|
|
160
|
+
export declare const renderOrValue: <T, K extends keyof T>(col: TableColumn<T, K>, value: T[K], obj: T, isMobileScreen: boolean) => React.ReactNode;
|