@primer/components 0.0.0-2021104151625 → 0.0.0-2021104155729
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
@@ -46,9 +46,13 @@ export declare type ItemProps = {
|
|
46
46
|
*/
|
47
47
|
disabled?: boolean;
|
48
48
|
/**
|
49
|
-
* The ARIA role describing the function of `Item` component. `option` is a common value.
|
49
|
+
* The ARIA role describing the function of `Item` component. `option` is a common value.
|
50
50
|
*/
|
51
51
|
role?: AriaRole;
|
52
|
+
/**
|
53
|
+
* id to attach to the root element of the Item
|
54
|
+
*/
|
55
|
+
id?: string;
|
52
56
|
/**
|
53
57
|
* Private API for use internally only. Used by LinkItem to wrap contents in an anchor
|
54
58
|
*/
|
package/lib/ActionList2/Item.js
CHANGED
@@ -70,6 +70,7 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
70
70
|
selected = undefined,
|
71
71
|
onSelect = () => null,
|
72
72
|
sx = {},
|
73
|
+
id,
|
73
74
|
_PrivateItemWrapper = ({
|
74
75
|
children
|
75
76
|
}) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children),
|
@@ -153,11 +154,12 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
153
154
|
const clickHandler = _react.default.useCallback(event => {
|
154
155
|
if (disabled) return;
|
155
156
|
if (!event.defaultPrevented) onSelect(event);
|
156
|
-
}, [onSelect, disabled]);
|
157
|
+
}, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
|
157
158
|
|
158
|
-
|
159
|
-
const
|
160
|
-
const
|
159
|
+
|
160
|
+
const labelId = (0, _ssr.useSSRSafeId)(id);
|
161
|
+
const inlineDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--inline-description`);
|
162
|
+
const blockDescriptionId = (0, _ssr.useSSRSafeId)(id && `${id}--block-description`);
|
161
163
|
return /*#__PURE__*/_react.default.createElement(Slots, {
|
162
164
|
context: {
|
163
165
|
variant,
|
@@ -46,9 +46,13 @@ export declare type ItemProps = {
|
|
46
46
|
*/
|
47
47
|
disabled?: boolean;
|
48
48
|
/**
|
49
|
-
* The ARIA role describing the function of `Item` component. `option` is a common value.
|
49
|
+
* The ARIA role describing the function of `Item` component. `option` is a common value.
|
50
50
|
*/
|
51
51
|
role?: AriaRole;
|
52
|
+
/**
|
53
|
+
* id to attach to the root element of the Item
|
54
|
+
*/
|
55
|
+
id?: string;
|
52
56
|
/**
|
53
57
|
* Private API for use internally only. Used by LinkItem to wrap contents in an anchor
|
54
58
|
*/
|
@@ -49,6 +49,7 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
49
49
|
selected = undefined,
|
50
50
|
onSelect = () => null,
|
51
51
|
sx = {},
|
52
|
+
id,
|
52
53
|
_PrivateItemWrapper = ({
|
53
54
|
children
|
54
55
|
}) => /*#__PURE__*/React.createElement(React.Fragment, null, children),
|
@@ -130,10 +131,11 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
130
131
|
const clickHandler = React.useCallback(event => {
|
131
132
|
if (disabled) return;
|
132
133
|
if (!event.defaultPrevented) onSelect(event);
|
133
|
-
}, [onSelect, disabled]);
|
134
|
-
|
135
|
-
const
|
136
|
-
const
|
134
|
+
}, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
|
135
|
+
|
136
|
+
const labelId = useSSRSafeId(id);
|
137
|
+
const inlineDescriptionId = useSSRSafeId(id && `${id}--inline-description`);
|
138
|
+
const blockDescriptionId = useSSRSafeId(id && `${id}--block-description`);
|
137
139
|
return /*#__PURE__*/React.createElement(Slots, {
|
138
140
|
context: {
|
139
141
|
variant,
|