@jobber/components 6.8.0 → 6.9.0
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/List/List.d.ts +22 -1
- package/dist/List-cjs.js +19 -13
- package/dist/List-es.js +19 -13
- package/package.json +2 -2
package/dist/List/List.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface ListProps<T extends BaseListItemProps = ListItemProps> {
|
|
|
8
8
|
/**
|
|
9
9
|
* A function that will be called for each item instead of the default
|
|
10
10
|
* rendering
|
|
11
|
+
* @argument item - The item to render
|
|
11
12
|
*/
|
|
12
13
|
readonly customRenderItem?: (item: T) => React.ReactNode;
|
|
13
14
|
/**
|
|
@@ -15,6 +16,26 @@ interface ListProps<T extends BaseListItemProps = ListItemProps> {
|
|
|
15
16
|
* when used with customRenderItem.
|
|
16
17
|
*/
|
|
17
18
|
readonly customItemStyles?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A function that will be called for each section heading instead of the default
|
|
21
|
+
* rendering
|
|
22
|
+
* @argument sectionName - The name of the section to render
|
|
23
|
+
*/
|
|
24
|
+
readonly customRenderSection?: (sectionName: string) => React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Set to true for more control over the section heading styles. Only modifies styles
|
|
27
|
+
* when used with customRenderItem.
|
|
28
|
+
*/
|
|
29
|
+
readonly customSectionStyles?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* An ID of an element that provides the labelling for this list.
|
|
32
|
+
*/
|
|
33
|
+
readonly labelledBy?: string;
|
|
34
|
+
/**
|
|
35
|
+
* A default section header value for items that do not have a section.
|
|
36
|
+
* @default "Other"
|
|
37
|
+
*/
|
|
38
|
+
readonly defaultSectionHeader?: string;
|
|
18
39
|
}
|
|
19
|
-
export declare function List<T extends BaseListItemProps = ListItemProps>({ items, customRenderItem, customItemStyles, }: ListProps<T>): JSX.Element;
|
|
40
|
+
export declare function List<T extends BaseListItemProps = ListItemProps>({ items, customRenderItem, customItemStyles, customRenderSection, customSectionStyles, defaultSectionHeader, labelledBy, }: ListProps<T>): JSX.Element;
|
|
20
41
|
export {};
|
package/dist/List-cjs.js
CHANGED
|
@@ -165,31 +165,37 @@ var sectionStyles = {"sectionHeader":"htH4y2JBFNQ-","spinning":"Y3FXizLWanA-"};
|
|
|
165
165
|
|
|
166
166
|
var styles = {"list":"sFlecO8-wnY-","item":"dbZy6dviEis-","section":"vz43PAcPYt0-","spinning":"gv8zs1Wo4EY-"};
|
|
167
167
|
|
|
168
|
-
function List({ items, customRenderItem, customItemStyles, }) {
|
|
168
|
+
function List({ items, customRenderItem, customItemStyles, customRenderSection, customSectionStyles, defaultSectionHeader = "Other", labelledBy, }) {
|
|
169
169
|
const isSectioned = items.some(item => "section" in item && item.section);
|
|
170
170
|
if (isSectioned) {
|
|
171
|
-
return (React.createElement(SectionedList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles }));
|
|
171
|
+
return (React.createElement(SectionedList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles, customRenderSection: customRenderSection, customSectionStyles: customSectionStyles, defaultSectionHeader: defaultSectionHeader, labelledBy: labelledBy }));
|
|
172
172
|
}
|
|
173
173
|
else {
|
|
174
|
-
return (React.createElement(DisplayList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles }));
|
|
174
|
+
return (React.createElement(DisplayList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles, labelledBy: labelledBy }));
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
function DisplayList({ items, customRenderItem, customItemStyles, }) {
|
|
177
|
+
function DisplayList({ items, customRenderItem, customItemStyles, labelledBy, }) {
|
|
178
178
|
const omitDefaultStyles = customRenderItem && customItemStyles;
|
|
179
179
|
const itemClassNames = classnames(!omitDefaultStyles && styles.item);
|
|
180
|
-
return (React.createElement("ul", { className: styles.list }, items.map(item => (React.createElement("li", { key: item.id, className: itemClassNames },
|
|
180
|
+
return (React.createElement("ul", { className: styles.list, "aria-labelledby": labelledBy }, items.map(item => (React.createElement("li", { key: item.id, className: itemClassNames },
|
|
181
181
|
React.createElement(ListItem, Object.assign({}, item, { customRenderItem: customRenderItem, customItemStyles: customItemStyles })))))));
|
|
182
182
|
}
|
|
183
|
-
function SectionedList({ items, customRenderItem, customItemStyles, }) {
|
|
184
|
-
const sectionedItems = groupBy$1(items, item => _baseEach.get(item, "section",
|
|
185
|
-
const sectionHeaderClassNames = classnames(sectionStyles.sectionHeader);
|
|
183
|
+
function SectionedList({ items, customRenderItem, customItemStyles, customRenderSection, customSectionStyles, defaultSectionHeader, labelledBy, }) {
|
|
184
|
+
const sectionedItems = groupBy$1(items, item => _baseEach.get(item, "section", defaultSectionHeader));
|
|
186
185
|
const omitDefaultStyles = customRenderItem && customItemStyles;
|
|
186
|
+
const omitDefaultSectionStyles = customRenderSection && customSectionStyles;
|
|
187
187
|
const itemClassNames = classnames(!omitDefaultStyles && styles.item);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
React.createElement(
|
|
188
|
+
const sectionHeaderClassNames = classnames(!omitDefaultSectionStyles && sectionStyles.sectionHeader);
|
|
189
|
+
return (React.createElement("ul", { className: styles.list, "aria-labelledby": labelledBy }, Object.keys(sectionedItems).map(sectionName => {
|
|
190
|
+
return (React.createElement("li", { key: sectionName, className: classnames(!omitDefaultSectionStyles && styles.section) },
|
|
191
|
+
getSectionHeader(sectionName, sectionHeaderClassNames, customRenderSection),
|
|
192
|
+
React.createElement("ul", { className: styles.list }, sectionedItems[sectionName].map(item => (React.createElement("li", { key: item.id, className: itemClassNames },
|
|
193
|
+
React.createElement(ListItem, Object.assign({}, item, { customRenderItem: customRenderItem, customItemStyles: customItemStyles }))))))));
|
|
194
|
+
})));
|
|
195
|
+
}
|
|
196
|
+
function getSectionHeader(sectionName, sectionHeaderClassNames, customRenderSection) {
|
|
197
|
+
const sectionHeader = customRenderSection ? (customRenderSection(sectionName)) : (React.createElement(Typography.Typography, { element: "h4", fontWeight: "bold", size: "large" }, sectionName));
|
|
198
|
+
return React.createElement("div", { className: sectionHeaderClassNames }, sectionHeader);
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
exports.List = List;
|
package/dist/List-es.js
CHANGED
|
@@ -163,31 +163,37 @@ var sectionStyles = {"sectionHeader":"htH4y2JBFNQ-","spinning":"Y3FXizLWanA-"};
|
|
|
163
163
|
|
|
164
164
|
var styles = {"list":"sFlecO8-wnY-","item":"dbZy6dviEis-","section":"vz43PAcPYt0-","spinning":"gv8zs1Wo4EY-"};
|
|
165
165
|
|
|
166
|
-
function List({ items, customRenderItem, customItemStyles, }) {
|
|
166
|
+
function List({ items, customRenderItem, customItemStyles, customRenderSection, customSectionStyles, defaultSectionHeader = "Other", labelledBy, }) {
|
|
167
167
|
const isSectioned = items.some(item => "section" in item && item.section);
|
|
168
168
|
if (isSectioned) {
|
|
169
|
-
return (React.createElement(SectionedList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles }));
|
|
169
|
+
return (React.createElement(SectionedList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles, customRenderSection: customRenderSection, customSectionStyles: customSectionStyles, defaultSectionHeader: defaultSectionHeader, labelledBy: labelledBy }));
|
|
170
170
|
}
|
|
171
171
|
else {
|
|
172
|
-
return (React.createElement(DisplayList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles }));
|
|
172
|
+
return (React.createElement(DisplayList, { items: items, customRenderItem: customRenderItem, customItemStyles: customItemStyles, labelledBy: labelledBy }));
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
function DisplayList({ items, customRenderItem, customItemStyles, }) {
|
|
175
|
+
function DisplayList({ items, customRenderItem, customItemStyles, labelledBy, }) {
|
|
176
176
|
const omitDefaultStyles = customRenderItem && customItemStyles;
|
|
177
177
|
const itemClassNames = classnames(!omitDefaultStyles && styles.item);
|
|
178
|
-
return (React.createElement("ul", { className: styles.list }, items.map(item => (React.createElement("li", { key: item.id, className: itemClassNames },
|
|
178
|
+
return (React.createElement("ul", { className: styles.list, "aria-labelledby": labelledBy }, items.map(item => (React.createElement("li", { key: item.id, className: itemClassNames },
|
|
179
179
|
React.createElement(ListItem, Object.assign({}, item, { customRenderItem: customRenderItem, customItemStyles: customItemStyles })))))));
|
|
180
180
|
}
|
|
181
|
-
function SectionedList({ items, customRenderItem, customItemStyles, }) {
|
|
182
|
-
const sectionedItems = groupBy$1(items, item => get(item, "section",
|
|
183
|
-
const sectionHeaderClassNames = classnames(sectionStyles.sectionHeader);
|
|
181
|
+
function SectionedList({ items, customRenderItem, customItemStyles, customRenderSection, customSectionStyles, defaultSectionHeader, labelledBy, }) {
|
|
182
|
+
const sectionedItems = groupBy$1(items, item => get(item, "section", defaultSectionHeader));
|
|
184
183
|
const omitDefaultStyles = customRenderItem && customItemStyles;
|
|
184
|
+
const omitDefaultSectionStyles = customRenderSection && customSectionStyles;
|
|
185
185
|
const itemClassNames = classnames(!omitDefaultStyles && styles.item);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
React.createElement(
|
|
186
|
+
const sectionHeaderClassNames = classnames(!omitDefaultSectionStyles && sectionStyles.sectionHeader);
|
|
187
|
+
return (React.createElement("ul", { className: styles.list, "aria-labelledby": labelledBy }, Object.keys(sectionedItems).map(sectionName => {
|
|
188
|
+
return (React.createElement("li", { key: sectionName, className: classnames(!omitDefaultSectionStyles && styles.section) },
|
|
189
|
+
getSectionHeader(sectionName, sectionHeaderClassNames, customRenderSection),
|
|
190
|
+
React.createElement("ul", { className: styles.list }, sectionedItems[sectionName].map(item => (React.createElement("li", { key: item.id, className: itemClassNames },
|
|
191
|
+
React.createElement(ListItem, Object.assign({}, item, { customRenderItem: customRenderItem, customItemStyles: customItemStyles }))))))));
|
|
192
|
+
})));
|
|
193
|
+
}
|
|
194
|
+
function getSectionHeader(sectionName, sectionHeaderClassNames, customRenderSection) {
|
|
195
|
+
const sectionHeader = customRenderSection ? (customRenderSection(sectionName)) : (React.createElement(Typography, { element: "h4", fontWeight: "bold", size: "large" }, sectionName));
|
|
196
|
+
return React.createElement("div", { className: sectionHeaderClassNames }, sectionHeader);
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
export { List as L, ListItem as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -487,5 +487,5 @@
|
|
|
487
487
|
"> 1%",
|
|
488
488
|
"IE 10"
|
|
489
489
|
],
|
|
490
|
-
"gitHead": "
|
|
490
|
+
"gitHead": "e3061144a300e82ee790f5c7d99f90e8e21adfc0"
|
|
491
491
|
}
|