@squiz/generic-browser-lib 1.67.0 → 1.67.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @squiz/generic-browser-lib
2
2
 
3
+ ## 1.67.2
4
+
5
+ ### Patch Changes
6
+
7
+ - ebcb0d2: Changed id attribute to data-id for component buttons in component browser
8
+
9
+ ## 1.67.1
10
+
11
+ ### Patch Changes
12
+
13
+ - e60bb77: Added ID attribute to component buttons
14
+
3
15
  ## 1.67.0
4
16
 
5
17
  ### Minor Changes
@@ -16,6 +16,7 @@ interface ResourceItem<T> {
16
16
  componentIcon?: ReactElement | undefined;
17
17
  iconSource?: ResourceSources;
18
18
  showChevron?: boolean;
19
+ id?: string;
19
20
  }
20
- declare const ResourceItem: <T>({ item, selected, label, type, childCount, previewModalState, onSelect, onDrillDown, className, allowedTypes, componentIcon, iconSource, showChevron, }: ResourceItem<T>) => React.JSX.Element;
21
+ declare const ResourceItem: <T>({ item, selected, label, type, childCount, previewModalState, onSelect, onDrillDown, className, allowedTypes, componentIcon, iconSource, showChevron, id, }: ResourceItem<T>) => React.JSX.Element;
21
22
  export { ResourceItem };
@@ -9,14 +9,14 @@ const react_aria_1 = require("react-aria");
9
9
  const ModalOpeningButton_1 = require("../Modal/ModalOpeningButton");
10
10
  const Icon_1 = require("../Icons/Icon");
11
11
  const utils_1 = require("../Utils/utils");
12
- const ResourceItem = ({ item, selected, label, type, childCount, previewModalState, onSelect, onDrillDown, className, allowedTypes, componentIcon, iconSource = 'matrix', showChevron = false, }) => {
12
+ const ResourceItem = ({ item, selected, label, type, childCount, previewModalState, onSelect, onDrillDown, className, allowedTypes, componentIcon, iconSource = 'matrix', showChevron = false, id, }) => {
13
13
  const { triggerProps, overlayProps } = (0, react_aria_1.useOverlayTrigger)({ type: 'dialog' }, previewModalState);
14
14
  const isDisabled = allowedTypes !== undefined && !allowedTypes.includes((0, utils_1.transformSnakeCase)(type));
15
15
  const title = isDisabled ? "You can't select this item" : label;
16
16
  return (react_1.default.createElement("li", { className: `squiz-gb-scope flex items-stretch p-1 bg-white border-1 border-grey-200 min-h-[64px] ${className}`, key: (0, utils_1.uuid)() },
17
17
  react_1.default.createElement(ModalOpeningButton_1.ModalOpeningButton, { type: "button", ...triggerProps, isDisabled: isDisabled, onPress: () => onSelect(item, overlayProps), "aria-label": childCount === undefined ? `Drill down to ${label} children` : '', className: `
18
18
  relative grow flex items-center px-4 py-2 rounded outline-0 ${selected ? 'bg-blue-100 text-blue-400' : ''} ${childCount !== undefined && childCount > 0 ? 'mr-2' : ''} ${isDisabled ? 'font-normal text-gray-600 cursor-not-allowed' : 'hover:bg-gray-50 focus:bg-gray-50'}
19
- `, title: title },
19
+ `, title: title, "data-id": id },
20
20
  react_1.default.createElement(Icon_1.Icon, { icon: type, resourceSource: iconSource, "aria-label": type, className: `mr-4 shrink-0 ${isDisabled && 'opacity-40'}`, componentIcon: componentIcon }),
21
21
  react_1.default.createElement("span", { className: `relative flex items-center ${selected ? 'mr-8' : ''}` },
22
22
  react_1.default.createElement("span", { className: "line-clamp-2 text-left break-word" }, label),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/generic-browser-lib",
3
- "version": "1.67.0",
3
+ "version": "1.67.2",
4
4
  "description": "Package with reusable components used by resource/component browsers",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -21,6 +21,7 @@ interface ResourceItem<T> {
21
21
  componentIcon?: ReactElement | undefined;
22
22
  iconSource?: ResourceSources;
23
23
  showChevron?: boolean;
24
+ id?: string;
24
25
  }
25
26
 
26
27
  const ResourceItem = <T,>({
@@ -37,6 +38,7 @@ const ResourceItem = <T,>({
37
38
  componentIcon,
38
39
  iconSource = 'matrix',
39
40
  showChevron = false,
41
+ id,
40
42
  }: ResourceItem<T>) => {
41
43
  const { triggerProps, overlayProps } = useOverlayTrigger({ type: 'dialog' }, previewModalState);
42
44
  const isDisabled = allowedTypes !== undefined && !allowedTypes.includes(transformSnakeCase(type));
@@ -59,6 +61,7 @@ const ResourceItem = <T,>({
59
61
  } ${isDisabled ? 'font-normal text-gray-600 cursor-not-allowed' : 'hover:bg-gray-50 focus:bg-gray-50'}
60
62
  `}
61
63
  title={title}
64
+ data-id={id}
62
65
  >
63
66
  <Icon
64
67
  icon={type as IconOptions}