draft-components 1.0.0-beta.9 → 1.1.0
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/README.md +47 -1
- package/cjs/components/alert/alert.cjs +4 -3
- package/cjs/components/color-picker/color-picker-button.cjs +16 -0
- package/cjs/components/color-picker/color-picker.cjs +24 -0
- package/cjs/components/index.cjs +6 -0
- package/cjs/components/password-input/password-input.cjs +2 -2
- package/cjs/components/selection-control/selection-control.cjs +1 -1
- package/cjs/components/text-input/text-input.cjs +25 -9
- package/cjs/components/toaster/toaster.cjs +2 -2
- package/cjs/index.cjs +6 -0
- package/css/draft-components.css +41 -20
- package/esm/components/alert/alert.js +4 -3
- package/esm/components/color-picker/color-picker-button.js +14 -0
- package/esm/components/color-picker/color-picker.js +22 -0
- package/esm/components/index.js +3 -0
- package/esm/components/password-input/password-input.js +2 -2
- package/esm/components/selection-control/selection-control.js +2 -2
- package/esm/components/text-input/text-input.js +26 -10
- package/esm/components/toaster/toaster.js +2 -2
- package/esm/index.js +3 -0
- package/package.json +30 -29
- package/types/components/alert/alert.d.ts +5 -3
- package/types/components/avatar/avatar.d.ts +1 -1
- package/types/components/button/button.d.ts +1 -1
- package/types/components/button/icon-button.d.ts +1 -1
- package/types/components/caption/caption.d.ts +1 -1
- package/types/components/checkbox/checkbox.d.ts +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
- package/types/components/file-picker/file-picker.d.ts +1 -1
- package/types/components/filter-buttons/filter-button.d.ts +1 -1
- package/types/components/form-field/form-field.d.ts +5 -2
- package/types/components/index.d.ts +3 -0
- package/types/components/label/label.d.ts +1 -1
- package/types/components/menu/menu-item.d.ts +1 -1
- package/types/components/password-input/password-input.d.ts +2 -2
- package/types/components/popover/popover.d.ts +1 -1
- package/types/components/radio/radio.d.ts +1 -1
- package/types/components/select/select.d.ts +3 -3
- package/types/components/selection-control/selection-control.d.ts +2 -2
- package/types/components/slider/slider.d.ts +1 -1
- package/types/components/spinner/spinner.d.ts +1 -1
- package/types/components/switch/switch.d.ts +1 -1
- package/types/components/table/table-body.d.ts +2 -2
- package/types/components/table/table-cell.d.ts +2 -2
- package/types/components/table/table-container.d.ts +1 -1
- package/types/components/table/table-head-cell.d.ts +1 -1
- package/types/components/table/table-head.d.ts +1 -1
- package/types/components/table/table-row.d.ts +1 -1
- package/types/components/table/table.d.ts +1 -1
- package/types/components/text-input/text-input.d.ts +7 -4
- package/types/components/textarea/textarea.d.ts +1 -1
- package/types/components/toast/toast-button.d.ts +2 -2
- package/types/components/toaster/toaster.d.ts +1 -3
package/README.md
CHANGED
|
@@ -5,4 +5,50 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/draft-components?activeTab=dependencies)
|
|
6
6
|
[](https://github.com/alexzimakov/draft-components/blob/master/tsconfig.json)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The React based UI components library.
|
|
9
|
+
|
|
10
|
+
<a href="https://draft-components.netlify.app">
|
|
11
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
|
12
|
+
<path d="M1.58051 1.53345L2.07511 14.7122C2.09077 15.1296 2.42396 15.4653 2.84126 15.484L13.5561 15.9652C13.5681 15.9658 13.5801 15.966 13.5921 15.966C14.0355 15.966 14.3948 15.6067 14.3948 15.1633V0.802758C14.3948 0.786055 14.3943 0.769356 14.3933 0.752685C14.3656 0.310212 13.9845 -0.026064 13.542 0.0015905L12.6607 0.056674L12.7251 1.89911C12.7274 1.9652 12.6757 2.02065 12.6096 2.02296C12.5813 2.02395 12.5535 2.01487 12.5313 1.99735L11.9376 1.5297L11.2348 2.06286C11.1821 2.10283 11.107 2.09251 11.067 2.03982C11.0502 2.01765 11.0416 1.9903 11.0428 1.96248L11.118 0.153093L2.33261 0.70218C1.89791 0.729349 1.56418 1.09821 1.58051 1.53345ZM11.4601 5.96107C11.1777 6.18045 9.07404 6.33013 9.07404 6.01782C9.1185 4.82611 8.58497 4.77387 8.28856 4.77387C8.00697 4.77387 7.53272 4.85899 7.53272 5.49741C7.53272 6.14798 8.22578 6.51526 9.03926 6.94635C10.1949 7.55874 11.5935 8.29992 11.5935 10.1649C11.5935 11.9525 10.1411 12.94 8.28856 12.94C6.37674 12.94 4.70602 12.1665 4.89471 9.48481C4.96881 9.1699 7.39935 9.24475 7.39935 9.48481C7.3697 10.5914 7.62164 10.9169 8.25892 10.9169C8.74799 10.9169 8.9703 10.6473 8.9703 10.1933C8.9703 9.50626 8.24818 9.10084 7.41747 8.63444C6.29269 8.00294 4.96881 7.25965 4.96881 5.55415C4.96881 3.85171 6.13962 2.71675 8.22928 2.71675C10.3189 2.71675 11.4601 3.83432 11.4601 5.96107Z" />
|
|
13
|
+
</svg>
|
|
14
|
+
<span>Storybook</span>
|
|
15
|
+
</a>
|
|
16
|
+
|
|
17
|
+
## Peer dependencies
|
|
18
|
+
|
|
19
|
+
`draft-components` requires the following libraries to be installed:
|
|
20
|
+
|
|
21
|
+
- `react` >= 18
|
|
22
|
+
- `react-dom` >= 18
|
|
23
|
+
|
|
24
|
+
## Getting Started
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm install draft-components
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
// import `draft-components` styles
|
|
32
|
+
import 'draft-components/css/draft-components.css';
|
|
33
|
+
// import necessary components
|
|
34
|
+
import {
|
|
35
|
+
FormField,
|
|
36
|
+
TextInput,
|
|
37
|
+
PasswordInput,
|
|
38
|
+
Button,
|
|
39
|
+
} from 'draft-components';
|
|
40
|
+
|
|
41
|
+
function App() {
|
|
42
|
+
return (
|
|
43
|
+
<form>
|
|
44
|
+
<FormField label="Username" labelFor="username">
|
|
45
|
+
<TextInput id="username" name="username" />
|
|
46
|
+
</FormField>
|
|
47
|
+
<FormField label="Password" labelFor="password">
|
|
48
|
+
<PasswordInput id="password" name="password" />
|
|
49
|
+
</FormField>
|
|
50
|
+
<Button>Sign in</Button>
|
|
51
|
+
</form>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const react = require('react');
|
|
4
5
|
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
5
6
|
|
|
6
|
-
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) {
|
|
7
8
|
const shouldShowIcon = Boolean(icon);
|
|
8
9
|
const shouldRenderHeading = Boolean(heading);
|
|
9
10
|
const shouldRenderContent = Boolean(children);
|
|
10
|
-
return (jsxRuntime.jsxs("
|
|
11
|
+
return (jsxRuntime.jsxs("div", { ...props, ref: ref, className: reactHelpers.classNames(className, {
|
|
11
12
|
'dc-alert': true,
|
|
12
13
|
'dc-alert_has_icon': shouldShowIcon,
|
|
13
14
|
[`dc-alert_variant_${variant}`]: variant,
|
|
14
15
|
[`dc-alert_appearance_${appearance}`]: appearance,
|
|
15
16
|
}), children: [shouldShowIcon && jsxRuntime.jsx("div", { className: "dc-alert__icon", children: icon }), jsxRuntime.jsxs("div", { className: "dc-alert__body", children: [shouldRenderHeading && (jsxRuntime.jsx("h1", { className: "dc-alert__title", children: heading })), shouldRenderContent && (jsxRuntime.jsx("div", { className: "dc-alert__content", children: children }))] })] }));
|
|
16
|
-
}
|
|
17
|
+
});
|
|
17
18
|
|
|
18
19
|
exports.Alert = Alert;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
5
|
+
|
|
6
|
+
function ColorPickerButton({ style, className, label, name, color, value, checked, defaultChecked, onChange, onChangeValue, }) {
|
|
7
|
+
const customProperties = {
|
|
8
|
+
'--dc-color-picker-btn-color': color,
|
|
9
|
+
};
|
|
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
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.ColorPickerButton = ColorPickerButton;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
5
|
+
const colorPickerButton = require('./color-picker-button.cjs');
|
|
6
|
+
|
|
7
|
+
function ColorPicker({ className, name, disabled, options, value, defaultValue, onChange, onChangeValue, ...props }) {
|
|
8
|
+
return (jsxRuntime.jsx("fieldset", { ...props, disabled: disabled, className: reactHelpers.classNames(className, {
|
|
9
|
+
'dc-color-picker': true,
|
|
10
|
+
'dc-color-picker_disabled': disabled,
|
|
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
|
+
}) }));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.ColorPicker = ColorPicker;
|
package/cjs/components/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const iconButton = require('./button/icon-button.cjs');
|
|
|
11
11
|
const buttonGroup = require('./button-group/button-group.cjs');
|
|
12
12
|
const caption = require('./caption/caption.cjs');
|
|
13
13
|
const checkbox = require('./checkbox/checkbox.cjs');
|
|
14
|
+
const colorPicker = require('./color-picker/color-picker.cjs');
|
|
14
15
|
const datePicker = require('./date-picker/date-picker.cjs');
|
|
15
16
|
const dateRangePicker = require('./date-picker/date-range-picker.cjs');
|
|
16
17
|
const datePickerPopover = require('./date-picker-popover/date-picker-popover.cjs');
|
|
@@ -34,9 +35,11 @@ const navListTitle = require('./nav-list/nav-list-title.cjs');
|
|
|
34
35
|
const passwordInput = require('./password-input/password-input.cjs');
|
|
35
36
|
const popover = require('./popover/popover.cjs');
|
|
36
37
|
const portal = require('./portal/portal.cjs');
|
|
38
|
+
const positioner = require('./positioner/positioner.cjs');
|
|
37
39
|
const radio = require('./radio/radio.cjs');
|
|
38
40
|
const segmentedControl = require('./segmented-control/segmented-control.cjs');
|
|
39
41
|
const select = require('./select/select.cjs');
|
|
42
|
+
const selectionControl = require('./selection-control/selection-control.cjs');
|
|
40
43
|
const slider = require('./slider/slider.cjs');
|
|
41
44
|
const sliderTickMarks = require('./slider/slider-tick-marks.cjs');
|
|
42
45
|
const spinner = require('./spinner/spinner.cjs');
|
|
@@ -73,6 +76,7 @@ exports.IconButton = iconButton.IconButton;
|
|
|
73
76
|
exports.ButtonGroup = buttonGroup.ButtonGroup;
|
|
74
77
|
exports.Caption = caption.Caption;
|
|
75
78
|
exports.Checkbox = checkbox.Checkbox;
|
|
79
|
+
exports.ColorPicker = colorPicker.ColorPicker;
|
|
76
80
|
exports.DatePicker = datePicker.DatePicker;
|
|
77
81
|
exports.DateRangePicker = dateRangePicker.DateRangePicker;
|
|
78
82
|
exports.DatePickerPopover = datePickerPopover.DatePickerPopover;
|
|
@@ -96,9 +100,11 @@ exports.NavListTitle = navListTitle.NavListTitle;
|
|
|
96
100
|
exports.PasswordInput = passwordInput.PasswordInput;
|
|
97
101
|
exports.Popover = popover.Popover;
|
|
98
102
|
exports.Portal = portal.Portal;
|
|
103
|
+
exports.Positioner = positioner.Positioner;
|
|
99
104
|
exports.Radio = radio.Radio;
|
|
100
105
|
exports.SegmentedControl = segmentedControl.SegmentedControl;
|
|
101
106
|
exports.Select = select.Select;
|
|
107
|
+
exports.SelectionControl = selectionControl.SelectionControl;
|
|
102
108
|
exports.Slider = slider.Slider;
|
|
103
109
|
exports.SliderTickMarks = sliderTickMarks.SliderTickMarks;
|
|
104
110
|
exports.Spinner = spinner.Spinner;
|
|
@@ -23,8 +23,8 @@ const PasswordInput = react.forwardRef(function PasswordInput({ isDefaultVisible
|
|
|
23
23
|
Icon = icons.EyeSlashIcon;
|
|
24
24
|
}
|
|
25
25
|
const handleButtonClick = () => setVisible(!visible);
|
|
26
|
-
const
|
|
27
|
-
return (jsxRuntime.jsx(textInput.TextInput, { ...props, className: reactHelpers.classNames('dc-password-input', className), ref: ref, type: type,
|
|
26
|
+
const renderRightAddOn = ({ className }) => (jsxRuntime.jsx("div", { className: reactHelpers.classNames('dc-password-input__right-addon', className), children: jsxRuntime.jsx(tooltip.Tooltip, { content: content, children: jsxRuntime.jsx("button", { className: "dc-password-input__btn", type: "button", onClick: handleButtonClick, children: jsxRuntime.jsx(Icon, { className: "dc-password-input__icon", "aria-hidden": true }) }) }) }));
|
|
27
|
+
return (jsxRuntime.jsx(textInput.TextInput, { ...props, className: reactHelpers.classNames('dc-password-input', className), ref: ref, type: type, rightAddOn: renderRightAddOn }));
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
exports.PasswordInput = PasswordInput;
|
|
@@ -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;
|
|
@@ -4,23 +4,39 @@ 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 TextInput = react.forwardRef(function TextInput({ hasError = false, isBlock = false, type = 'text', size = 'md',
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
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
|
-
'dc-text-input__container_disabled': disabled,
|
|
13
|
-
'dc-text-input__container_has_error': hasError,
|
|
14
28
|
'dc-text-input__container_block': isBlock,
|
|
15
|
-
'dc-text-
|
|
16
|
-
'dc-text-
|
|
17
|
-
|
|
29
|
+
'dc-text-input__container_disabled': disabled,
|
|
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;
|
|
@@ -23,7 +23,7 @@ class Toaster {
|
|
|
23
23
|
this._id += 1;
|
|
24
24
|
return this._id;
|
|
25
25
|
}
|
|
26
|
-
showToast(toast
|
|
26
|
+
showToast(toast) {
|
|
27
27
|
const id = this._getNextId();
|
|
28
28
|
const event = new CustomEvent(TOAST_SHOW_EVENT, {
|
|
29
29
|
detail: {
|
|
@@ -31,7 +31,7 @@ class Toaster {
|
|
|
31
31
|
toast: { ...toast, id },
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
|
-
const timeoutMs = toast.timeoutMs ||
|
|
34
|
+
const timeoutMs = toast.timeoutMs || this.timeoutMs;
|
|
35
35
|
this.onShow?.(event.detail.toast);
|
|
36
36
|
window.dispatchEvent(event);
|
|
37
37
|
window.setTimeout(() => this.hideToast(id), timeoutMs);
|
package/cjs/index.cjs
CHANGED
|
@@ -18,6 +18,7 @@ const iconButton = require('./components/button/icon-button.cjs');
|
|
|
18
18
|
const buttonGroup = require('./components/button-group/button-group.cjs');
|
|
19
19
|
const caption = require('./components/caption/caption.cjs');
|
|
20
20
|
const checkbox = require('./components/checkbox/checkbox.cjs');
|
|
21
|
+
const colorPicker = require('./components/color-picker/color-picker.cjs');
|
|
21
22
|
const datePicker = require('./components/date-picker/date-picker.cjs');
|
|
22
23
|
const dateRangePicker = require('./components/date-picker/date-range-picker.cjs');
|
|
23
24
|
const datePickerPopover = require('./components/date-picker-popover/date-picker-popover.cjs');
|
|
@@ -41,9 +42,11 @@ const navListTitle = require('./components/nav-list/nav-list-title.cjs');
|
|
|
41
42
|
const passwordInput = require('./components/password-input/password-input.cjs');
|
|
42
43
|
const popover = require('./components/popover/popover.cjs');
|
|
43
44
|
const portal = require('./components/portal/portal.cjs');
|
|
45
|
+
const positioner = require('./components/positioner/positioner.cjs');
|
|
44
46
|
const radio = require('./components/radio/radio.cjs');
|
|
45
47
|
const segmentedControl = require('./components/segmented-control/segmented-control.cjs');
|
|
46
48
|
const select = require('./components/select/select.cjs');
|
|
49
|
+
const selectionControl = require('./components/selection-control/selection-control.cjs');
|
|
47
50
|
const slider = require('./components/slider/slider.cjs');
|
|
48
51
|
const sliderTickMarks = require('./components/slider/slider-tick-marks.cjs');
|
|
49
52
|
const spinner = require('./components/spinner/spinner.cjs');
|
|
@@ -91,6 +94,7 @@ exports.IconButton = iconButton.IconButton;
|
|
|
91
94
|
exports.ButtonGroup = buttonGroup.ButtonGroup;
|
|
92
95
|
exports.Caption = caption.Caption;
|
|
93
96
|
exports.Checkbox = checkbox.Checkbox;
|
|
97
|
+
exports.ColorPicker = colorPicker.ColorPicker;
|
|
94
98
|
exports.DatePicker = datePicker.DatePicker;
|
|
95
99
|
exports.DateRangePicker = dateRangePicker.DateRangePicker;
|
|
96
100
|
exports.DatePickerPopover = datePickerPopover.DatePickerPopover;
|
|
@@ -114,9 +118,11 @@ exports.NavListTitle = navListTitle.NavListTitle;
|
|
|
114
118
|
exports.PasswordInput = passwordInput.PasswordInput;
|
|
115
119
|
exports.Popover = popover.Popover;
|
|
116
120
|
exports.Portal = portal.Portal;
|
|
121
|
+
exports.Positioner = positioner.Positioner;
|
|
117
122
|
exports.Radio = radio.Radio;
|
|
118
123
|
exports.SegmentedControl = segmentedControl.SegmentedControl;
|
|
119
124
|
exports.Select = select.Select;
|
|
125
|
+
exports.SelectionControl = selectionControl.SelectionControl;
|
|
120
126
|
exports.Slider = slider.Slider;
|
|
121
127
|
exports.SliderTickMarks = sliderTickMarks.SliderTickMarks;
|
|
122
128
|
exports.Spinner = spinner.Spinner;
|
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
|
|
|
@@ -1282,36 +1292,30 @@
|
|
|
1282
1292
|
width: 40.5ch;
|
|
1283
1293
|
}
|
|
1284
1294
|
|
|
1285
|
-
.dc-text-
|
|
1286
|
-
.dc-text-
|
|
1295
|
+
.dc-text-input__left-addon,
|
|
1296
|
+
.dc-text-input__right-addon {
|
|
1287
1297
|
display: inline-flex;
|
|
1288
1298
|
flex: none;
|
|
1289
1299
|
align-items: center;
|
|
1290
1300
|
box-sizing: border-box;
|
|
1291
1301
|
}
|
|
1292
1302
|
|
|
1293
|
-
.dc-text-
|
|
1303
|
+
.dc-text-input__left-addon {
|
|
1294
1304
|
color: var(--dc-input-prefix-color);
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
.dc-text-input__suffix {
|
|
1298
|
-
color: var(--dc-input-suffix-color);
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
.dc-text-input__container_has_prefix {
|
|
1302
1305
|
padding-left: var(--dc-input-padding-x);
|
|
1303
1306
|
}
|
|
1304
1307
|
|
|
1305
|
-
.dc-text-
|
|
1306
|
-
|
|
1308
|
+
.dc-text-input__right-addon {
|
|
1309
|
+
color: var(--dc-input-suffix-color);
|
|
1310
|
+
padding-right: var(--dc-input-padding-x);
|
|
1307
1311
|
}
|
|
1308
1312
|
|
|
1309
|
-
.dc-text-
|
|
1310
|
-
padding-
|
|
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 {
|
|
@@ -1355,6 +1359,10 @@
|
|
|
1355
1359
|
background: var(--dc-password-input-switch-bg);
|
|
1356
1360
|
}
|
|
1357
1361
|
|
|
1362
|
+
.dc-password-input__right-addon {
|
|
1363
|
+
padding-right: 0;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1358
1366
|
.dc-password-input__icon {
|
|
1359
1367
|
width: calc(var(--dc-input-height) * 0.5);
|
|
1360
1368
|
height: calc(var(--dc-input-height) * 0.5);
|
|
@@ -1430,6 +1438,8 @@
|
|
|
1430
1438
|
color: var(--dc-textarea-text-color);
|
|
1431
1439
|
min-width: 192px;
|
|
1432
1440
|
min-height: var(--dc-textarea-leading);
|
|
1441
|
+
margin-top: 0;
|
|
1442
|
+
margin-bottom: 0;
|
|
1433
1443
|
padding: var(--dc-textarea-padding-y) var(--dc-textarea-padding-x);
|
|
1434
1444
|
border: none;
|
|
1435
1445
|
background: none;
|
|
@@ -1449,6 +1459,10 @@
|
|
|
1449
1459
|
outline: none;
|
|
1450
1460
|
}
|
|
1451
1461
|
|
|
1462
|
+
.dc-textarea__container_block .dc-textarea {
|
|
1463
|
+
resize: vertical;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1452
1466
|
.dc-textarea_width_30ch {
|
|
1453
1467
|
width: 30.5ch;
|
|
1454
1468
|
}
|
|
@@ -1593,6 +1607,7 @@
|
|
|
1593
1607
|
--dc-switch-focus-ring-color: var(--dc-focus-ring-color);
|
|
1594
1608
|
|
|
1595
1609
|
color-scheme: light;
|
|
1610
|
+
display: inline-flex;
|
|
1596
1611
|
}
|
|
1597
1612
|
|
|
1598
1613
|
.dc-switch__input {
|
|
@@ -1698,6 +1713,7 @@
|
|
|
1698
1713
|
--dc-checkbox-focus-ring-color: var(--dc-focus-ring-color);
|
|
1699
1714
|
|
|
1700
1715
|
color-scheme: light;
|
|
1716
|
+
display: inline-flex;
|
|
1701
1717
|
}
|
|
1702
1718
|
|
|
1703
1719
|
.dc-checkbox__input {
|
|
@@ -1771,6 +1787,7 @@
|
|
|
1771
1787
|
--dc-radio-color-focus-ring: var(--dc-focus-ring-color);
|
|
1772
1788
|
|
|
1773
1789
|
color-scheme: light;
|
|
1790
|
+
display: inline-flex;
|
|
1774
1791
|
}
|
|
1775
1792
|
|
|
1776
1793
|
.dc-radio__input {
|
|
@@ -2419,6 +2436,7 @@
|
|
|
2419
2436
|
}
|
|
2420
2437
|
|
|
2421
2438
|
.dc-selection-control__input {
|
|
2439
|
+
display: inline-flex;
|
|
2422
2440
|
grid-area: input;
|
|
2423
2441
|
}
|
|
2424
2442
|
|
|
@@ -2503,9 +2521,12 @@
|
|
|
2503
2521
|
clip: rect(0 0 0 0);
|
|
2504
2522
|
}
|
|
2505
2523
|
|
|
2506
|
-
.dc-color-
|
|
2507
|
-
|
|
2508
|
-
|
|
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
|
+
display: inline-flex;
|
|
2509
2530
|
width: 38%;
|
|
2510
2531
|
height: 38%;
|
|
2511
2532
|
border-radius: 50%;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import { classNames } from '../../lib/react-helpers.js';
|
|
3
4
|
|
|
4
|
-
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) {
|
|
5
6
|
const shouldShowIcon = Boolean(icon);
|
|
6
7
|
const shouldRenderHeading = Boolean(heading);
|
|
7
8
|
const shouldRenderContent = Boolean(children);
|
|
8
|
-
return (jsxs("
|
|
9
|
+
return (jsxs("div", { ...props, ref: ref, className: classNames(className, {
|
|
9
10
|
'dc-alert': true,
|
|
10
11
|
'dc-alert_has_icon': shouldShowIcon,
|
|
11
12
|
[`dc-alert_variant_${variant}`]: variant,
|
|
12
13
|
[`dc-alert_appearance_${appearance}`]: appearance,
|
|
13
14
|
}), children: [shouldShowIcon && jsx("div", { className: "dc-alert__icon", children: icon }), jsxs("div", { className: "dc-alert__body", children: [shouldRenderHeading && (jsx("h1", { className: "dc-alert__title", children: heading })), shouldRenderContent && (jsx("div", { className: "dc-alert__content", children: children }))] })] }));
|
|
14
|
-
}
|
|
15
|
+
});
|
|
15
16
|
|
|
16
17
|
export { Alert };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
3
|
+
|
|
4
|
+
function ColorPickerButton({ style, className, label, name, color, value, checked, defaultChecked, onChange, onChangeValue, }) {
|
|
5
|
+
const customProperties = {
|
|
6
|
+
'--dc-color-picker-btn-color': color,
|
|
7
|
+
};
|
|
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
|
+
}
|
|
13
|
+
|
|
14
|
+
export { ColorPickerButton };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../../lib/react-helpers.js';
|
|
3
|
+
import { ColorPickerButton } from './color-picker-button.js';
|
|
4
|
+
|
|
5
|
+
function ColorPicker({ className, name, disabled, options, value, defaultValue, onChange, onChangeValue, ...props }) {
|
|
6
|
+
return (jsx("fieldset", { ...props, disabled: disabled, className: classNames(className, {
|
|
7
|
+
'dc-color-picker': true,
|
|
8
|
+
'dc-color-picker_disabled': disabled,
|
|
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
|
+
}) }));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { ColorPicker };
|
package/esm/components/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { IconButton } from './button/icon-button.js';
|
|
|
9
9
|
export { ButtonGroup } from './button-group/button-group.js';
|
|
10
10
|
export { Caption } from './caption/caption.js';
|
|
11
11
|
export { Checkbox } from './checkbox/checkbox.js';
|
|
12
|
+
export { ColorPicker } from './color-picker/color-picker.js';
|
|
12
13
|
export { DatePicker } from './date-picker/date-picker.js';
|
|
13
14
|
export { DateRangePicker } from './date-picker/date-range-picker.js';
|
|
14
15
|
export { DatePickerPopover } from './date-picker-popover/date-picker-popover.js';
|
|
@@ -32,9 +33,11 @@ export { NavListTitle } from './nav-list/nav-list-title.js';
|
|
|
32
33
|
export { PasswordInput } from './password-input/password-input.js';
|
|
33
34
|
export { Popover } from './popover/popover.js';
|
|
34
35
|
export { Portal } from './portal/portal.js';
|
|
36
|
+
export { Positioner } from './positioner/positioner.js';
|
|
35
37
|
export { Radio } from './radio/radio.js';
|
|
36
38
|
export { SegmentedControl } from './segmented-control/segmented-control.js';
|
|
37
39
|
export { Select } from './select/select.js';
|
|
40
|
+
export { SelectionControl } from './selection-control/selection-control.js';
|
|
38
41
|
export { Slider } from './slider/slider.js';
|
|
39
42
|
export { SliderTickMarks } from './slider/slider-tick-marks.js';
|
|
40
43
|
export { Spinner } from './spinner/spinner.js';
|
|
@@ -21,8 +21,8 @@ const PasswordInput = forwardRef(function PasswordInput({ isDefaultVisible = fal
|
|
|
21
21
|
Icon = EyeSlashIcon;
|
|
22
22
|
}
|
|
23
23
|
const handleButtonClick = () => setVisible(!visible);
|
|
24
|
-
const
|
|
25
|
-
return (jsx(TextInput, { ...props, className: classNames('dc-password-input', className), ref: ref, type: type,
|
|
24
|
+
const renderRightAddOn = ({ className }) => (jsx("div", { className: classNames('dc-password-input__right-addon', className), children: jsx(Tooltip, { content: content, children: jsx("button", { className: "dc-password-input__btn", type: "button", onClick: handleButtonClick, children: jsx(Icon, { className: "dc-password-input__icon", "aria-hidden": true }) }) }) }));
|
|
25
|
+
return (jsx(TextInput, { ...props, className: classNames('dc-password-input', className), ref: ref, type: type, rightAddOn: renderRightAddOn }));
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
export { PasswordInput };
|
|
@@ -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 };
|
|
@@ -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
|
-
const TextInput = forwardRef(function TextInput({ hasError = false, isBlock = false, type = 'text', size = 'md',
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
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
|
-
'dc-text-input__container_disabled': disabled,
|
|
11
|
-
'dc-text-input__container_has_error': hasError,
|
|
12
26
|
'dc-text-input__container_block': isBlock,
|
|
13
|
-
'dc-text-
|
|
14
|
-
'dc-text-
|
|
15
|
-
|
|
27
|
+
'dc-text-input__container_disabled': disabled,
|
|
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 };
|
|
@@ -21,7 +21,7 @@ class Toaster {
|
|
|
21
21
|
this._id += 1;
|
|
22
22
|
return this._id;
|
|
23
23
|
}
|
|
24
|
-
showToast(toast
|
|
24
|
+
showToast(toast) {
|
|
25
25
|
const id = this._getNextId();
|
|
26
26
|
const event = new CustomEvent(TOAST_SHOW_EVENT, {
|
|
27
27
|
detail: {
|
|
@@ -29,7 +29,7 @@ class Toaster {
|
|
|
29
29
|
toast: { ...toast, id },
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
|
-
const timeoutMs = toast.timeoutMs ||
|
|
32
|
+
const timeoutMs = toast.timeoutMs || this.timeoutMs;
|
|
33
33
|
this.onShow?.(event.detail.toast);
|
|
34
34
|
window.dispatchEvent(event);
|
|
35
35
|
window.setTimeout(() => this.hideToast(id), timeoutMs);
|
package/esm/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { IconButton } from './components/button/icon-button.js';
|
|
|
16
16
|
export { ButtonGroup } from './components/button-group/button-group.js';
|
|
17
17
|
export { Caption } from './components/caption/caption.js';
|
|
18
18
|
export { Checkbox } from './components/checkbox/checkbox.js';
|
|
19
|
+
export { ColorPicker } from './components/color-picker/color-picker.js';
|
|
19
20
|
export { DatePicker } from './components/date-picker/date-picker.js';
|
|
20
21
|
export { DateRangePicker } from './components/date-picker/date-range-picker.js';
|
|
21
22
|
export { DatePickerPopover } from './components/date-picker-popover/date-picker-popover.js';
|
|
@@ -39,9 +40,11 @@ export { NavListTitle } from './components/nav-list/nav-list-title.js';
|
|
|
39
40
|
export { PasswordInput } from './components/password-input/password-input.js';
|
|
40
41
|
export { Popover } from './components/popover/popover.js';
|
|
41
42
|
export { Portal } from './components/portal/portal.js';
|
|
43
|
+
export { Positioner } from './components/positioner/positioner.js';
|
|
42
44
|
export { Radio } from './components/radio/radio.js';
|
|
43
45
|
export { SegmentedControl } from './components/segmented-control/segmented-control.js';
|
|
44
46
|
export { Select } from './components/select/select.js';
|
|
47
|
+
export { SelectionControl } from './components/selection-control/selection-control.js';
|
|
45
48
|
export { Slider } from './components/slider/slider.js';
|
|
46
49
|
export { SliderTickMarks } from './components/slider/slider-tick-marks.js';
|
|
47
50
|
export { Spinner } from './components/spinner/spinner.js';
|