draft-components 1.0.0-beta.10 → 1.0.0-beta.11
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.
|
@@ -12,7 +12,7 @@ function SelectionControl({ label: label$1, labelFor, caption: caption$1, classN
|
|
|
12
12
|
const shouldRenderCaption = Boolean(caption$1);
|
|
13
13
|
return (jsxRuntime.jsxs("div", { ...props, className: reactHelpers.classNames('dc-selection-control', className), children: [jsxRuntime.jsx("div", { className: "dc-selection-control__input", children: typeof children === 'function'
|
|
14
14
|
? children({ id: controlId })
|
|
15
|
-
: children }), jsxRuntime.jsx(label.Label, { className: "dc-selection-control__label", htmlFor: controlId, children: label$1 }), shouldRenderCaption && (jsxRuntime.jsx(caption.Caption, { className: "dc-selection-control__caption", children: caption$1 }))] }));
|
|
15
|
+
: react.cloneElement(children, { id: children.props.id || controlId }) }), jsxRuntime.jsx(label.Label, { className: "dc-selection-control__label", htmlFor: controlId, children: label$1 }), shouldRenderCaption && (jsxRuntime.jsx(caption.Caption, { className: "dc-selection-control__caption", children: caption$1 }))] }));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
exports.SelectionControl = SelectionControl;
|
package/css/draft-components.css
CHANGED
|
@@ -1593,6 +1593,7 @@
|
|
|
1593
1593
|
--dc-switch-focus-ring-color: var(--dc-focus-ring-color);
|
|
1594
1594
|
|
|
1595
1595
|
color-scheme: light;
|
|
1596
|
+
display: inline-flex;
|
|
1596
1597
|
}
|
|
1597
1598
|
|
|
1598
1599
|
.dc-switch__input {
|
|
@@ -1698,6 +1699,7 @@
|
|
|
1698
1699
|
--dc-checkbox-focus-ring-color: var(--dc-focus-ring-color);
|
|
1699
1700
|
|
|
1700
1701
|
color-scheme: light;
|
|
1702
|
+
display: inline-flex;
|
|
1701
1703
|
}
|
|
1702
1704
|
|
|
1703
1705
|
.dc-checkbox__input {
|
|
@@ -1771,6 +1773,7 @@
|
|
|
1771
1773
|
--dc-radio-color-focus-ring: var(--dc-focus-ring-color);
|
|
1772
1774
|
|
|
1773
1775
|
color-scheme: light;
|
|
1776
|
+
display: inline-flex;
|
|
1774
1777
|
}
|
|
1775
1778
|
|
|
1776
1779
|
.dc-radio__input {
|
|
@@ -2419,6 +2422,7 @@
|
|
|
2419
2422
|
}
|
|
2420
2423
|
|
|
2421
2424
|
.dc-selection-control__input {
|
|
2425
|
+
display: inline-flex;
|
|
2422
2426
|
grid-area: input;
|
|
2423
2427
|
}
|
|
2424
2428
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useId } from 'react';
|
|
2
|
+
import { useId, cloneElement } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
import { Label } from '../label/label.js';
|
|
5
5
|
import { Caption } from '../caption/caption.js';
|
|
@@ -10,7 +10,7 @@ function SelectionControl({ label, labelFor, caption, className, children, ...pr
|
|
|
10
10
|
const shouldRenderCaption = Boolean(caption);
|
|
11
11
|
return (jsxs("div", { ...props, className: classNames('dc-selection-control', className), children: [jsx("div", { className: "dc-selection-control__input", children: typeof children === 'function'
|
|
12
12
|
? children({ id: controlId })
|
|
13
|
-
: children }), jsx(Label, { className: "dc-selection-control__label", htmlFor: controlId, children: label }), shouldRenderCaption && (jsx(Caption, { className: "dc-selection-control__caption", children: caption }))] }));
|
|
13
|
+
: cloneElement(children, { id: children.props.id || controlId }) }), jsx(Label, { className: "dc-selection-control__label", htmlFor: controlId, children: label }), shouldRenderCaption && (jsx(Caption, { className: "dc-selection-control__caption", children: caption }))] }));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export { SelectionControl };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
2
2
|
export type SelectionControlRenderFn = (props: {
|
|
3
3
|
id: string;
|
|
4
|
-
}) =>
|
|
4
|
+
}) => JSX.Element;
|
|
5
5
|
type SelectionControlHTMLProps = ComponentPropsWithoutRef<'div'>;
|
|
6
6
|
type SelectionControlBaseProps = Omit<SelectionControlHTMLProps, 'children'>;
|
|
7
7
|
export type SelectionControlProps = {
|
|
8
8
|
labelFor?: string;
|
|
9
9
|
caption?: ReactNode;
|
|
10
10
|
label: ReactNode;
|
|
11
|
-
children:
|
|
11
|
+
children: JSX.Element | SelectionControlRenderFn;
|
|
12
12
|
} & SelectionControlBaseProps;
|
|
13
13
|
export declare function SelectionControl({ label, labelFor, caption, className, children, ...props }: SelectionControlProps): JSX.Element;
|
|
14
14
|
export {};
|