draft-components 1.0.0-beta.14 → 1.0.0-beta.16
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/alert/alert.cjs +2 -2
- package/cjs/components/text-input/text-input.cjs +23 -7
- package/css/draft-components.css +17 -13
- package/esm/components/alert/alert.js +2 -2
- package/esm/components/text-input/text-input.js +24 -8
- package/package.json +1 -1
- package/types/components/alert/alert.d.ts +2 -2
- package/types/components/caption/caption.d.ts +1 -1
- package/types/components/text-input/text-input.d.ts +5 -2
|
@@ -4,11 +4,11 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
const react = require('react');
|
|
5
5
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
6
6
|
|
|
7
|
-
const Alert = react.forwardRef(function Alert({ icon = null, heading = null, variant = 'default', appearance = 'default', className, children, ...props }) {
|
|
7
|
+
const Alert = react.forwardRef(function Alert({ icon = null, heading = null, variant = 'default', appearance = 'default', className, children, ...props }, ref) {
|
|
8
8
|
const shouldShowIcon = Boolean(icon);
|
|
9
9
|
const shouldRenderHeading = Boolean(heading);
|
|
10
10
|
const shouldRenderContent = Boolean(children);
|
|
11
|
-
return (jsxRuntime.jsxs("
|
|
11
|
+
return (jsxRuntime.jsxs("div", { ...props, ref: ref, className: reactHelpers.classNames(className, {
|
|
12
12
|
'dc-alert': true,
|
|
13
13
|
'dc-alert_has_icon': shouldShowIcon,
|
|
14
14
|
[`dc-alert_variant_${variant}`]: variant,
|
|
@@ -5,22 +5,38 @@ const react = require('react');
|
|
|
5
5
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
6
6
|
|
|
7
7
|
const TextInput = react.forwardRef(function TextInput({ hasError = false, isBlock = false, type = 'text', size = 'md', leftAddOn, rightAddOn, style, className, disabled, width, htmlSize, onChange, onChangeValue, ...props }, ref) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
if (leftAddOn) {
|
|
9
|
+
const className = 'dc-text-input__left-addon';
|
|
10
|
+
if (typeof leftAddOn === 'function') {
|
|
11
|
+
leftAddOn = leftAddOn({ className });
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
leftAddOn = jsxRuntime.jsx("div", { className: className, children: leftAddOn });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (rightAddOn) {
|
|
18
|
+
const className = 'dc-text-input__right-addon';
|
|
19
|
+
if (typeof rightAddOn === 'function') {
|
|
20
|
+
rightAddOn = rightAddOn({ className });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
rightAddOn = jsxRuntime.jsx("div", { className: className, children: rightAddOn });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
10
26
|
return (jsxRuntime.jsxs("div", { style: style, className: reactHelpers.classNames(className, 'dc-text-input__container', {
|
|
11
27
|
[`dc-text-input__container_${size}`]: size,
|
|
12
28
|
'dc-text-input__container_block': isBlock,
|
|
13
29
|
'dc-text-input__container_disabled': disabled,
|
|
14
|
-
'dc-text-
|
|
15
|
-
'dc-text-
|
|
16
|
-
'dc-text-
|
|
17
|
-
}), children: [
|
|
30
|
+
'dc-text-input__container_invalid': hasError,
|
|
31
|
+
'dc-text-input__container_left-addon': leftAddOn,
|
|
32
|
+
'dc-text-input__container_right-addon': rightAddOn,
|
|
33
|
+
}), children: [leftAddOn, jsxRuntime.jsx("input", { ...props, className: reactHelpers.classNames({
|
|
18
34
|
'dc-text-input': true,
|
|
19
35
|
[`dc-text-input_width_${width}`]: width,
|
|
20
36
|
}), ref: ref, type: type, size: htmlSize, disabled: disabled, onChange: (event) => {
|
|
21
37
|
onChange?.(event);
|
|
22
38
|
onChangeValue?.(event.target.value);
|
|
23
|
-
} }),
|
|
39
|
+
} }), rightAddOn] }));
|
|
24
40
|
});
|
|
25
41
|
|
|
26
42
|
exports.TextInput = TextInput;
|
package/css/draft-components.css
CHANGED
|
@@ -1194,6 +1194,16 @@
|
|
|
1194
1194
|
background: var(--dc-input-bg);
|
|
1195
1195
|
}
|
|
1196
1196
|
|
|
1197
|
+
.dc-text-input__container > :first-child {
|
|
1198
|
+
border-top-left-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
1199
|
+
border-bottom-left-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
.dc-text-input__container > :last-child {
|
|
1203
|
+
border-top-right-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
1204
|
+
border-bottom-right-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1197
1207
|
.dc-text-input__container:focus-within {
|
|
1198
1208
|
border-color: var(--dc-input-focus-ring-color);
|
|
1199
1209
|
box-shadow: 0 0 0 1px var(--dc-input-focus-ring-color);
|
|
@@ -1203,7 +1213,7 @@
|
|
|
1203
1213
|
opacity: var(--dc-disabled-state-opacity);
|
|
1204
1214
|
}
|
|
1205
1215
|
|
|
1206
|
-
.dc-text-
|
|
1216
|
+
.dc-text-input__container_invalid {
|
|
1207
1217
|
border-color: var(--dc-input-border-color-error);
|
|
1208
1218
|
}
|
|
1209
1219
|
|
|
@@ -1292,26 +1302,20 @@
|
|
|
1292
1302
|
|
|
1293
1303
|
.dc-text-input__left-addon {
|
|
1294
1304
|
color: var(--dc-input-prefix-color);
|
|
1305
|
+
padding-left: var(--dc-input-padding-x);
|
|
1295
1306
|
}
|
|
1296
1307
|
|
|
1297
1308
|
.dc-text-input__right-addon {
|
|
1298
1309
|
color: var(--dc-input-suffix-color);
|
|
1310
|
+
padding-right: var(--dc-input-padding-x);
|
|
1299
1311
|
}
|
|
1300
1312
|
|
|
1301
|
-
.dc-text-
|
|
1302
|
-
padding-left: var(--dc-input-padding-x);
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
.dc-text-input__container_has_left-addon .dc-text-input {
|
|
1306
|
-
padding-left: calc(var(--dc-input-padding-x) * 0.5);
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
.dc-text-input__container_has_right-addon {
|
|
1310
|
-
padding-right: var(--dc-input-padding-x);
|
|
1313
|
+
.dc-text-input__container_left-addon .dc-text-input {
|
|
1314
|
+
padding-left: calc(var(--dc-input-padding-x) / 2);
|
|
1311
1315
|
}
|
|
1312
1316
|
|
|
1313
|
-
.dc-text-
|
|
1314
|
-
padding-right: calc(var(--dc-input-padding-x)
|
|
1317
|
+
.dc-text-input__container_right-addon .dc-text-input {
|
|
1318
|
+
padding-right: calc(var(--dc-input-padding-x) / 2);
|
|
1315
1319
|
}
|
|
1316
1320
|
|
|
1317
1321
|
.dc-password-input {
|
|
@@ -2,11 +2,11 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
|
|
5
|
-
const Alert = forwardRef(function Alert({ icon = null, heading = null, variant = 'default', appearance = 'default', className, children, ...props }) {
|
|
5
|
+
const Alert = forwardRef(function Alert({ icon = null, heading = null, variant = 'default', appearance = 'default', className, children, ...props }, ref) {
|
|
6
6
|
const shouldShowIcon = Boolean(icon);
|
|
7
7
|
const shouldRenderHeading = Boolean(heading);
|
|
8
8
|
const shouldRenderContent = Boolean(children);
|
|
9
|
-
return (jsxs("
|
|
9
|
+
return (jsxs("div", { ...props, ref: ref, className: classNames(className, {
|
|
10
10
|
'dc-alert': true,
|
|
11
11
|
'dc-alert_has_icon': shouldShowIcon,
|
|
12
12
|
[`dc-alert_variant_${variant}`]: variant,
|
|
@@ -1,24 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
4
4
|
|
|
5
5
|
const TextInput = forwardRef(function TextInput({ hasError = false, isBlock = false, type = 'text', size = 'md', leftAddOn, rightAddOn, style, className, disabled, width, htmlSize, onChange, onChangeValue, ...props }, ref) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
if (leftAddOn) {
|
|
7
|
+
const className = 'dc-text-input__left-addon';
|
|
8
|
+
if (typeof leftAddOn === 'function') {
|
|
9
|
+
leftAddOn = leftAddOn({ className });
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
leftAddOn = jsx("div", { className: className, children: leftAddOn });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (rightAddOn) {
|
|
16
|
+
const className = 'dc-text-input__right-addon';
|
|
17
|
+
if (typeof rightAddOn === 'function') {
|
|
18
|
+
rightAddOn = rightAddOn({ className });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
rightAddOn = jsx("div", { className: className, children: rightAddOn });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
8
24
|
return (jsxs("div", { style: style, className: classNames(className, 'dc-text-input__container', {
|
|
9
25
|
[`dc-text-input__container_${size}`]: size,
|
|
10
26
|
'dc-text-input__container_block': isBlock,
|
|
11
27
|
'dc-text-input__container_disabled': disabled,
|
|
12
|
-
'dc-text-
|
|
13
|
-
'dc-text-
|
|
14
|
-
'dc-text-
|
|
15
|
-
}), children: [
|
|
28
|
+
'dc-text-input__container_invalid': hasError,
|
|
29
|
+
'dc-text-input__container_left-addon': leftAddOn,
|
|
30
|
+
'dc-text-input__container_right-addon': rightAddOn,
|
|
31
|
+
}), children: [leftAddOn, jsx("input", { ...props, className: classNames({
|
|
16
32
|
'dc-text-input': true,
|
|
17
33
|
[`dc-text-input_width_${width}`]: width,
|
|
18
34
|
}), ref: ref, type: type, size: htmlSize, disabled: disabled, onChange: (event) => {
|
|
19
35
|
onChange?.(event);
|
|
20
36
|
onChangeValue?.(event.target.value);
|
|
21
|
-
} }),
|
|
37
|
+
} }), rightAddOn] }));
|
|
22
38
|
});
|
|
23
39
|
|
|
24
40
|
export { TextInput };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef, type ReactNode } from 'react';
|
|
2
|
-
type AlertHTMLProps = ComponentPropsWithRef<'
|
|
2
|
+
type AlertHTMLProps = ComponentPropsWithRef<'div'>;
|
|
3
3
|
export type AlertAppearance = 'default' | 'info' | 'success' | 'warning' | 'error';
|
|
4
4
|
export type AlertVariant = 'default' | 'full-width' | 'accent-border';
|
|
5
5
|
export type AlertProps = {
|
|
@@ -8,5 +8,5 @@ export type AlertProps = {
|
|
|
8
8
|
variant?: AlertVariant;
|
|
9
9
|
appearance?: AlertAppearance;
|
|
10
10
|
} & AlertHTMLProps;
|
|
11
|
-
export declare const Alert: import("react").ForwardRefExoticComponent<Pick<AlertProps, "key" | keyof import("react").HTMLAttributes<
|
|
11
|
+
export declare const Alert: import("react").ForwardRefExoticComponent<Pick<AlertProps, "key" | keyof import("react").HTMLAttributes<HTMLDivElement> | "icon" | "heading" | "variant" | "appearance"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
12
|
export {};
|
|
@@ -4,4 +4,4 @@ export type CaptionProps = ComponentPropsWithRef<'div'> & {
|
|
|
4
4
|
showIcon?: boolean;
|
|
5
5
|
appearance?: CaptionAppearance;
|
|
6
6
|
};
|
|
7
|
-
export declare const Caption: import("react").ForwardRefExoticComponent<Pick<CaptionProps, "key" |
|
|
7
|
+
export declare const Caption: import("react").ForwardRefExoticComponent<Pick<CaptionProps, "key" | keyof import("react").HTMLAttributes<HTMLDivElement> | "appearance" | "showIcon"> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
@@ -5,6 +5,9 @@ export type TextInputType = 'date' | 'datetime-local' | 'email' | 'number' | 'pa
|
|
|
5
5
|
export type TextInputWidth = '2ch' | '3ch' | '4ch' | '5ch' | '10ch' | '20ch' | '40ch';
|
|
6
6
|
export type TextInputSize = 'sm' | 'md' | 'lg';
|
|
7
7
|
export type TextInputChangeValueHandler = (value: string) => void;
|
|
8
|
+
export type TextInputRenderAddOn = (props: {
|
|
9
|
+
className: string;
|
|
10
|
+
}) => ReactNode;
|
|
8
11
|
export type TextInputProps = TextInputBaseProps & {
|
|
9
12
|
hasError?: boolean;
|
|
10
13
|
isBlock?: boolean;
|
|
@@ -12,8 +15,8 @@ export type TextInputProps = TextInputBaseProps & {
|
|
|
12
15
|
width?: TextInputWidth;
|
|
13
16
|
widthCh?: number;
|
|
14
17
|
size?: TextInputSize;
|
|
15
|
-
leftAddOn?: ReactNode;
|
|
16
|
-
rightAddOn?: ReactNode;
|
|
18
|
+
leftAddOn?: ReactNode | TextInputRenderAddOn;
|
|
19
|
+
rightAddOn?: ReactNode | TextInputRenderAddOn;
|
|
17
20
|
htmlSize?: TextInputHTMLProps['size'];
|
|
18
21
|
onChangeValue?: TextInputChangeValueHandler;
|
|
19
22
|
};
|