Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(table): react table schema order #1829

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions packages/sage-react/lib/Table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@
// Ensure headers are built out dynamically
useEffect(() => {
buildHeaders();
}, [schema, headers]);

Check warning on line 176 in packages/sage-react/lib/Table/Table.jsx

View workflow job for this annotation

GitHub Actions / Lint, Test, Build

React Hook useEffect has a missing dependency: 'buildHeaders'. Either include it or remove the dependency array

// Ensure selected rows change when adjusted from the outside
useEffect(() => {
setSelfSelectedRows(selectedRows);
setSelfSelectionType(getSelectionType(selectedRows));
}, [selectedRows]);

Check warning on line 182 in packages/sage-react/lib/Table/Table.jsx

View workflow job for this annotation

GitHub Actions / Lint, Test, Build

React Hook useEffect has a missing dependency: 'getSelectionType'. Either include it or remove the dependency array

const removeFromList = (data, list) => list.filter((each) => each !== data);

Expand Down Expand Up @@ -353,37 +353,83 @@
};

Table.propTypes = {
/**
* Sets the caption for the component.
*/
caption: PropTypes.string,

/** Sets the caption position for the component. */
captionSide: PropTypes.oneOf(Object.values(Table.CAPTION_SIDE)),

/** The CSS class that will be applied to the container. */
className: PropTypes.string,

/** When set to `true`, adds borders for cleaner readability. */
hasBorders: PropTypes.bool,

/** Deprecated */
hasDataBeyondCurrentRows: PropTypes.bool,
// Headers provide a simpler alternative to schema

/**
* An array of strings that will serve as the headers for the table.
* Headers provide a simpler alternative to schema.
*
* The number of items in the array need to coincide with the number of keys in your data.
*
* When combined with the Schema property, the headers can
* be an object and will match based on Key names.
*/
headers: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.shape(cellPropTypes),
PropTypes.string,
])),
PropTypes.shape({}),
]),

/**
* When set to true, allows the table to scroll horizontally without
* breaking its parent container.
*/
isResponsive: PropTypes.bool,

/**
* Allows a function to be passed, which will be executed when a row is
* selected.
*/
onSelectRowHook: PropTypes.func,

/** Resets the top margin of the component. */
resetAbove: PropTypes.bool,

/** Resets the bottom margin of the component. */
resetBelow: PropTypes.bool,

/** Array of items to populate the table. These items are key/value pairs. */
rows: PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.shape(cellPropTypes),
PropTypes.arrayOf(dataPropTypes),
PropTypes.shape({}),
])),
// Schema provides a structure for applying settings to headers and cells

/**
* Provides a structure for applying the column order, and may specify the data types
* to the headers and cells.
*/
schema: PropTypes.shape({}),

/** Adds a background color when a user hovers over rows. */
selectable: PropTypes.bool,

/** Additional information for Select all column. */
selectAllConfigs: PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
onChange: PropTypes.func,
}),

/** An array of the selected rows when `selectable` set to `true` */
selectedRows: PropTypes.oneOfType([
PropTypes.oneOf([SELECTION_TYPES.ALL]),
PropTypes.arrayOf(PropTypes.oneOfType([
Expand All @@ -392,6 +438,10 @@
PropTypes.string,
])),
]),

/** When true, shows the checkbox in the header row. */
showSelectAll: PropTypes.bool,

/** Allows you to provide additional HTML attributes. */
tableAttributes: PropTypes.shape({}),
};
112 changes: 0 additions & 112 deletions packages/sage-react/lib/Table/Table.story.jsx

This file was deleted.

Loading
Loading