draft-components 1.0.0 → 1.1.1
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/cjs/components/color-picker/color-picker-button.cjs +5 -5
- package/cjs/components/color-picker/color-picker.cjs +12 -2
- package/css/draft-components.css +11 -2
- package/esm/components/color-picker/color-picker-button.js +5 -5
- package/esm/components/color-picker/color-picker.js +12 -2
- package/package.json +1 -1
- package/types/components/color-picker/color-picker-button.d.ts +6 -4
- package/types/components/color-picker/color-picker.d.ts +6 -4
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
const jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
5
5
|
|
|
6
|
-
function ColorPickerButton({ style, className, label, name, color, value, checked, onChangeValue, }) {
|
|
6
|
+
function ColorPickerButton({ style, className, label, name, color, value, checked, defaultChecked, onChange, onChangeValue, }) {
|
|
7
7
|
const customProperties = {
|
|
8
8
|
'--dc-color-picker-btn-color': color,
|
|
9
9
|
};
|
|
10
|
-
return (jsxRuntime.jsxs("label", { style: { ...customProperties, ...style }, className: reactHelpers.classNames(className, {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
return (jsxRuntime.jsxs("label", { style: { ...customProperties, ...style }, className: reactHelpers.classNames('dc-color-picker__btn', className), children: [jsxRuntime.jsx("input", { type: "radio", name: name, value: value, checked: checked, defaultChecked: defaultChecked, onChange: (event) => {
|
|
11
|
+
onChange?.(event);
|
|
12
|
+
onChangeValue?.(value);
|
|
13
|
+
} }), jsxRuntime.jsx("span", { className: "dc-color-picker__btn-check", "aria-hidden": true }), label] }));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
exports.ColorPickerButton = ColorPickerButton;
|
|
@@ -4,11 +4,21 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
5
5
|
const colorPickerButton = require('./color-picker-button.cjs');
|
|
6
6
|
|
|
7
|
-
function ColorPicker({ className, name, options, value,
|
|
7
|
+
function ColorPicker({ className, name, disabled, options, value, defaultValue, onChange, onChangeValue, ...props }) {
|
|
8
8
|
return (jsxRuntime.jsx("fieldset", { ...props, disabled: disabled, className: reactHelpers.classNames(className, {
|
|
9
9
|
'dc-color-picker': true,
|
|
10
10
|
'dc-color-picker_disabled': disabled,
|
|
11
|
-
}), children: options.map((option) =>
|
|
11
|
+
}), children: options.map((option) => {
|
|
12
|
+
let checked;
|
|
13
|
+
let defaultChecked;
|
|
14
|
+
if (value !== undefined) {
|
|
15
|
+
checked = option.value === value;
|
|
16
|
+
}
|
|
17
|
+
else if (defaultValue !== undefined) {
|
|
18
|
+
defaultChecked = option.value === defaultValue;
|
|
19
|
+
}
|
|
20
|
+
return (jsxRuntime.jsx(colorPickerButton.ColorPickerButton, { name: name, label: option.label, color: option.color, value: option.value, checked: checked, defaultChecked: defaultChecked, onChange: onChange, onChangeValue: onChangeValue }, option.value));
|
|
21
|
+
}) }));
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
exports.ColorPicker = ColorPicker;
|
package/css/draft-components.css
CHANGED
|
@@ -1438,6 +1438,8 @@
|
|
|
1438
1438
|
color: var(--dc-textarea-text-color);
|
|
1439
1439
|
min-width: 192px;
|
|
1440
1440
|
min-height: var(--dc-textarea-leading);
|
|
1441
|
+
margin-top: 0;
|
|
1442
|
+
margin-bottom: 0;
|
|
1441
1443
|
padding: var(--dc-textarea-padding-y) var(--dc-textarea-padding-x);
|
|
1442
1444
|
border: none;
|
|
1443
1445
|
background: none;
|
|
@@ -2519,11 +2521,18 @@
|
|
|
2519
2521
|
clip: rect(0 0 0 0);
|
|
2520
2522
|
}
|
|
2521
2523
|
|
|
2522
|
-
.dc-color-
|
|
2523
|
-
|
|
2524
|
+
.dc-color-picker__btn > input + .dc-color-picker__btn-check {
|
|
2525
|
+
display: none;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
.dc-color-picker__btn > input:checked + .dc-color-picker__btn-check {
|
|
2529
|
+
position: absolute;
|
|
2530
|
+
top: 50%;
|
|
2531
|
+
left: 50%;
|
|
2524
2532
|
display: inline-block;
|
|
2525
2533
|
width: 38%;
|
|
2526
2534
|
height: 38%;
|
|
2535
|
+
transform: translate(-50%, -50%);
|
|
2527
2536
|
border-radius: 50%;
|
|
2528
2537
|
background: var(--dc-color-picker-btn-check-color);
|
|
2529
2538
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { classNames } from '../../lib/react-helpers.js';
|
|
3
3
|
|
|
4
|
-
function ColorPickerButton({ style, className, label, name, color, value, checked, onChangeValue, }) {
|
|
4
|
+
function ColorPickerButton({ style, className, label, name, color, value, checked, defaultChecked, onChange, onChangeValue, }) {
|
|
5
5
|
const customProperties = {
|
|
6
6
|
'--dc-color-picker-btn-color': color,
|
|
7
7
|
};
|
|
8
|
-
return (jsxs("label", { style: { ...customProperties, ...style }, className: classNames(className, {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
return (jsxs("label", { style: { ...customProperties, ...style }, className: classNames('dc-color-picker__btn', className), children: [jsx("input", { type: "radio", name: name, value: value, checked: checked, defaultChecked: defaultChecked, onChange: (event) => {
|
|
9
|
+
onChange?.(event);
|
|
10
|
+
onChangeValue?.(value);
|
|
11
|
+
} }), jsx("span", { className: "dc-color-picker__btn-check", "aria-hidden": true }), label] }));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export { ColorPickerButton };
|
|
@@ -2,11 +2,21 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { classNames } from '../../lib/react-helpers.js';
|
|
3
3
|
import { ColorPickerButton } from './color-picker-button.js';
|
|
4
4
|
|
|
5
|
-
function ColorPicker({ className, name, options, value,
|
|
5
|
+
function ColorPicker({ className, name, disabled, options, value, defaultValue, onChange, onChangeValue, ...props }) {
|
|
6
6
|
return (jsx("fieldset", { ...props, disabled: disabled, className: classNames(className, {
|
|
7
7
|
'dc-color-picker': true,
|
|
8
8
|
'dc-color-picker_disabled': disabled,
|
|
9
|
-
}), children: options.map((option) =>
|
|
9
|
+
}), children: options.map((option) => {
|
|
10
|
+
let checked;
|
|
11
|
+
let defaultChecked;
|
|
12
|
+
if (value !== undefined) {
|
|
13
|
+
checked = option.value === value;
|
|
14
|
+
}
|
|
15
|
+
else if (defaultValue !== undefined) {
|
|
16
|
+
defaultChecked = option.value === defaultValue;
|
|
17
|
+
}
|
|
18
|
+
return (jsx(ColorPickerButton, { name: name, label: option.label, color: option.color, value: option.value, checked: checked, defaultChecked: defaultChecked, onChange: onChange, onChangeValue: onChangeValue }, option.value));
|
|
19
|
+
}) }));
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
export { ColorPicker };
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CSSProperties, ReactNode } from 'react';
|
|
1
|
+
import { type CSSProperties, type ChangeEventHandler, type ReactNode } from 'react';
|
|
2
2
|
export type ColorPickerButtonProps<T extends string | number> = {
|
|
3
3
|
style?: CSSProperties;
|
|
4
4
|
className?: string;
|
|
@@ -6,7 +6,9 @@ export type ColorPickerButtonProps<T extends string | number> = {
|
|
|
6
6
|
name: string;
|
|
7
7
|
color: string;
|
|
8
8
|
value: T;
|
|
9
|
-
checked
|
|
10
|
-
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
12
|
+
onChangeValue?: (value: T) => void;
|
|
11
13
|
};
|
|
12
|
-
export declare function ColorPickerButton<T extends string | number>({ style, className, label, name, color, value, checked, onChangeValue, }: ColorPickerButtonProps<T>): JSX.Element;
|
|
14
|
+
export declare function ColorPickerButton<T extends string | number>({ style, className, label, name, color, value, checked, defaultChecked, onChange, onChangeValue, }: ColorPickerButtonProps<T>): JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
1
|
+
import { type ChangeEventHandler, type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
2
2
|
export type ColorPickerOption<T extends string | number> = {
|
|
3
3
|
value: T;
|
|
4
4
|
color: string;
|
|
@@ -6,8 +6,10 @@ export type ColorPickerOption<T extends string | number> = {
|
|
|
6
6
|
};
|
|
7
7
|
export type ColorPickerProps<T extends string | number> = {
|
|
8
8
|
name: string;
|
|
9
|
-
value?: T;
|
|
10
9
|
options: ColorPickerOption<T>[] | Readonly<ColorPickerOption<T>[]>;
|
|
11
|
-
|
|
10
|
+
value?: T;
|
|
11
|
+
defaultValue?: T;
|
|
12
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
13
|
+
onChangeValue?: (value: T) => void;
|
|
12
14
|
} & ComponentPropsWithoutRef<'fieldset'>;
|
|
13
|
-
export declare function ColorPicker<T extends string | number>({ className, name, options, value,
|
|
15
|
+
export declare function ColorPicker<T extends string | number>({ className, name, disabled, options, value, defaultValue, onChange, onChangeValue, ...props }: ColorPickerProps<T>): JSX.Element;
|