draft-components 1.0.0-beta.8 → 1.0.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.
Files changed (56) hide show
  1. package/README.md +47 -1
  2. package/cjs/components/alert/alert.cjs +4 -3
  3. package/cjs/components/button/button.cjs +12 -10
  4. package/cjs/components/button/icon-button.cjs +2 -2
  5. package/cjs/components/color-picker/color-picker-button.cjs +16 -0
  6. package/cjs/components/color-picker/color-picker.cjs +14 -0
  7. package/cjs/components/index.cjs +6 -0
  8. package/cjs/components/password-input/password-input.cjs +2 -2
  9. package/cjs/components/selection-control/selection-control.cjs +1 -1
  10. package/cjs/components/text-input/text-input.cjs +25 -9
  11. package/cjs/components/toaster/toaster.cjs +2 -2
  12. package/cjs/index.cjs +6 -0
  13. package/css/draft-components.css +44 -19
  14. package/esm/components/alert/alert.js +4 -3
  15. package/esm/components/button/button.js +12 -10
  16. package/esm/components/button/icon-button.js +2 -2
  17. package/esm/components/color-picker/color-picker-button.js +14 -0
  18. package/esm/components/color-picker/color-picker.js +12 -0
  19. package/esm/components/index.js +3 -0
  20. package/esm/components/password-input/password-input.js +2 -2
  21. package/esm/components/selection-control/selection-control.js +2 -2
  22. package/esm/components/text-input/text-input.js +26 -10
  23. package/esm/components/toaster/toaster.js +2 -2
  24. package/esm/index.js +3 -0
  25. package/package.json +30 -29
  26. package/types/components/alert/alert.d.ts +5 -3
  27. package/types/components/avatar/avatar.d.ts +1 -1
  28. package/types/components/button/button.d.ts +5 -4
  29. package/types/components/button/icon-button.d.ts +4 -3
  30. package/types/components/caption/caption.d.ts +1 -1
  31. package/types/components/checkbox/checkbox.d.ts +1 -1
  32. package/types/components/file-picker/file-picker.d.ts +1 -1
  33. package/types/components/filter-buttons/filter-button.d.ts +1 -1
  34. package/types/components/form-field/form-field.d.ts +5 -2
  35. package/types/components/index.d.ts +3 -0
  36. package/types/components/label/label.d.ts +1 -1
  37. package/types/components/menu/menu-item.d.ts +1 -1
  38. package/types/components/password-input/password-input.d.ts +2 -2
  39. package/types/components/popover/popover.d.ts +1 -1
  40. package/types/components/radio/radio.d.ts +1 -1
  41. package/types/components/select/select.d.ts +3 -3
  42. package/types/components/selection-control/selection-control.d.ts +2 -2
  43. package/types/components/slider/slider.d.ts +1 -1
  44. package/types/components/spinner/spinner.d.ts +1 -1
  45. package/types/components/switch/switch.d.ts +1 -1
  46. package/types/components/table/table-body.d.ts +2 -2
  47. package/types/components/table/table-cell.d.ts +2 -2
  48. package/types/components/table/table-container.d.ts +1 -1
  49. package/types/components/table/table-head-cell.d.ts +1 -1
  50. package/types/components/table/table-head.d.ts +1 -1
  51. package/types/components/table/table-row.d.ts +1 -1
  52. package/types/components/table/table.d.ts +1 -1
  53. package/types/components/text-input/text-input.d.ts +7 -4
  54. package/types/components/textarea/textarea.d.ts +1 -1
  55. package/types/components/toast/toast-button.d.ts +2 -2
  56. package/types/components/toaster/toaster.d.ts +1 -3
package/README.md CHANGED
@@ -5,4 +5,50 @@
5
5
  [![dependencies](https://badgen.net/bundlephobia/dependency-count/draft-components?label=dependencies&color=green)](https://www.npmjs.com/package/draft-components?activeTab=dependencies)
6
6
  [![types](https://badgen.net/npm/types/tslib?color=green)](https://github.com/alexzimakov/draft-components/blob/master/tsconfig.json)
7
7
 
8
- `draft-components` is a React based UI components library.
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("section", { ...props, className: reactHelpers.classNames(className, {
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;
@@ -5,23 +5,25 @@ const react = require('react');
5
5
  const reactHelpers = require('../../lib/react-helpers.cjs');
6
6
  const spinner = require('../spinner/spinner.cjs');
7
7
 
8
- const Button = react.forwardRef(function Button({ isBlock = false, disabled = false, loading = false, type = 'button', size = 'sm', variant = 'filled', appearance = 'default', icon = null, caption = null, renderAs, className, children, ...props }, ref) {
9
- const shouldRenderIcon = Boolean(icon);
10
- const shouldRenderLabel = Boolean(children);
11
- const shouldRenderCaption = Boolean(caption);
12
- let leadingAddOn = null;
8
+ const Button = react.forwardRef(function Button({ isBlock = false, disabled = false, loading = false, type = 'button', size = 'sm', variant = 'filled', appearance = 'default', iconLeft = null, iconRight = null, caption = null, renderAs, className, children, ...props }, ref) {
9
+ let addOnLeft = null;
13
10
  if (loading) {
14
- leadingAddOn = (jsxRuntime.jsx("span", { "data-testid": "button-spinner", className: "dc-button__spinner", children: jsxRuntime.jsx(spinner.Spinner, { size: "1.15em" }) }));
11
+ addOnLeft = (jsxRuntime.jsx("span", { "data-testid": "button-spinner", className: "dc-button__spinner", children: jsxRuntime.jsx(spinner.Spinner, { size: "1.15em" }) }));
12
+ }
13
+ else if (iconLeft) {
14
+ addOnLeft = (jsxRuntime.jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: iconLeft }));
15
15
  }
16
- else if (shouldRenderIcon) {
17
- leadingAddOn = (jsxRuntime.jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: icon }));
16
+ let addOnRight = null;
17
+ if (iconRight) {
18
+ addOnRight = (jsxRuntime.jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: iconRight }));
18
19
  }
19
- const content = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [leadingAddOn, shouldRenderLabel && (jsxRuntime.jsxs("span", { className: "dc-button__body", children: [jsxRuntime.jsx("span", { className: "dc-button__label", children: children }), shouldRenderCaption && (jsxRuntime.jsx("small", { className: "dc-button__caption", children: caption }))] }))] }));
20
+ const shouldRenderLabel = Boolean(children);
21
+ const shouldRenderCaption = Boolean(caption);
22
+ const content = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [addOnLeft, shouldRenderLabel && (jsxRuntime.jsxs("span", { className: "dc-button__body", children: [jsxRuntime.jsx("span", { className: "dc-button__label", children: children }), shouldRenderCaption && (jsxRuntime.jsx("small", { className: "dc-button__caption", children: caption }))] })), addOnRight] }));
20
23
  className = reactHelpers.classNames(className, {
21
24
  'dc-button': true,
22
25
  'dc-button_block': isBlock,
23
26
  'dc-button_loading': loading,
24
- 'dc-button_has_icon': shouldRenderIcon,
25
27
  'dc-button_has_caption': shouldRenderCaption,
26
28
  [`dc-button_${size}`]: size,
27
29
  [`dc-button_appearance_${appearance}`]: appearance,
@@ -5,8 +5,8 @@ const react = require('react');
5
5
  const reactHelpers = require('../../lib/react-helpers.cjs');
6
6
  const button = require('./button.cjs');
7
7
 
8
- const IconButton = react.forwardRef(function IconButton({ className, ...props }, ref) {
9
- return jsxRuntime.jsx(button.Button, { ref: ref, className: reactHelpers.classNames('dc-button_icon-only', className), ...props });
8
+ const IconButton = react.forwardRef(function IconButton({ className, icon, ...props }, ref) {
9
+ return jsxRuntime.jsx(button.Button, { ...props, ref: ref, iconLeft: icon, className: reactHelpers.classNames('dc-button_icon-only', className) });
10
10
  });
11
11
 
12
12
  exports.IconButton = IconButton;
@@ -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, onChangeValue, }) {
7
+ const customProperties = {
8
+ '--dc-color-picker-btn-color': color,
9
+ };
10
+ return (jsxRuntime.jsxs("label", { style: { ...customProperties, ...style }, className: reactHelpers.classNames(className, {
11
+ 'dc-color-picker__btn': true,
12
+ 'dc-color-picker__btn_checked': checked,
13
+ }), children: [jsxRuntime.jsx("input", { type: "radio", name: name, value: value, checked: checked, onChange: () => onChangeValue(value) }), label] }));
14
+ }
15
+
16
+ exports.ColorPickerButton = ColorPickerButton;
@@ -0,0 +1,14 @@
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, options, value, disabled, 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) => (jsxRuntime.jsx(colorPickerButton.ColorPickerButton, { name: name, label: option.label, color: option.color, value: option.value, checked: option.value === value, onChangeValue: onChangeValue }, option.value))) }));
12
+ }
13
+
14
+ exports.ColorPicker = ColorPicker;
@@ -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 button = (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, suffix: button }));
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', prefix, suffix, style, className, disabled, width, htmlSize, onChange, onChangeValue, ...props }, ref) {
8
- const shouldRenderPrefix = Boolean(prefix);
9
- const shouldRenderSuffix = Boolean(suffix);
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-input__container_has_prefix': shouldRenderPrefix,
16
- 'dc-text-input__container_has_suffix': shouldRenderSuffix,
17
- }), children: [shouldRenderPrefix && (jsxRuntime.jsx("div", { className: "dc-text-input__prefix", children: prefix })), jsxRuntime.jsx("input", { ...props, className: reactHelpers.classNames({
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
- } }), shouldRenderSuffix && (jsxRuntime.jsx("div", { className: "dc-text-input__suffix", children: suffix }))] }));
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, params) {
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 || params?.timeoutMs || this.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;
@@ -751,12 +751,20 @@
751
751
  justify-content: center;
752
752
  }
753
753
 
754
- .dc-button__icon,
755
- .dc-button__spinner {
754
+ .dc-button__spinner,
755
+ .dc-button__icon {
756
756
  flex: none;
757
+ }
758
+
759
+ .dc-button__spinner,
760
+ .dc-button__icon:first-child {
757
761
  margin-right: 0.5em;
758
762
  }
759
763
 
764
+ .dc-button__icon:last-child {
765
+ margin-left: 0.5em;
766
+ }
767
+
760
768
  .dc-button__body {
761
769
  flex: auto;
762
770
  flex-direction: column;
@@ -771,6 +779,7 @@
771
779
  .dc-button_icon-only .dc-button__icon,
772
780
  .dc-button_icon-only .dc-button__spinner {
773
781
  margin-right: 0;
782
+ margin-left: 0;
774
783
  }
775
784
 
776
785
  .dc-button_has_caption .dc-button__icon,
@@ -1185,6 +1194,16 @@
1185
1194
  background: var(--dc-input-bg);
1186
1195
  }
1187
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
+
1188
1207
  .dc-text-input__container:focus-within {
1189
1208
  border-color: var(--dc-input-focus-ring-color);
1190
1209
  box-shadow: 0 0 0 1px var(--dc-input-focus-ring-color);
@@ -1194,7 +1213,7 @@
1194
1213
  opacity: var(--dc-disabled-state-opacity);
1195
1214
  }
1196
1215
 
1197
- .dc-text-input__container_has_error {
1216
+ .dc-text-input__container_invalid {
1198
1217
  border-color: var(--dc-input-border-color-error);
1199
1218
  }
1200
1219
 
@@ -1273,36 +1292,30 @@
1273
1292
  width: 40.5ch;
1274
1293
  }
1275
1294
 
1276
- .dc-text-input__prefix,
1277
- .dc-text-input__suffix {
1295
+ .dc-text-input__left-addon,
1296
+ .dc-text-input__right-addon {
1278
1297
  display: inline-flex;
1279
1298
  flex: none;
1280
1299
  align-items: center;
1281
1300
  box-sizing: border-box;
1282
1301
  }
1283
1302
 
1284
- .dc-text-input__prefix {
1303
+ .dc-text-input__left-addon {
1285
1304
  color: var(--dc-input-prefix-color);
1286
- }
1287
-
1288
- .dc-text-input__suffix {
1289
- color: var(--dc-input-suffix-color);
1290
- }
1291
-
1292
- .dc-text-input__container_has_prefix {
1293
1305
  padding-left: var(--dc-input-padding-x);
1294
1306
  }
1295
1307
 
1296
- .dc-text-input__container_has_prefix .dc-text-input {
1297
- padding-left: calc(var(--dc-input-padding-x) * 0.5);
1308
+ .dc-text-input__right-addon {
1309
+ color: var(--dc-input-suffix-color);
1310
+ padding-right: var(--dc-input-padding-x);
1298
1311
  }
1299
1312
 
1300
- .dc-text-input__container_has_suffix {
1301
- 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);
1302
1315
  }
1303
1316
 
1304
- .dc-text-input__container_has_suffix .dc-text-input {
1305
- padding-right: calc(var(--dc-input-padding-x) * 0.5);
1317
+ .dc-text-input__container_right-addon .dc-text-input {
1318
+ padding-right: calc(var(--dc-input-padding-x) / 2);
1306
1319
  }
1307
1320
 
1308
1321
  .dc-password-input {
@@ -1346,6 +1359,10 @@
1346
1359
  background: var(--dc-password-input-switch-bg);
1347
1360
  }
1348
1361
 
1362
+ .dc-password-input__right-addon {
1363
+ padding-right: 0;
1364
+ }
1365
+
1349
1366
  .dc-password-input__icon {
1350
1367
  width: calc(var(--dc-input-height) * 0.5);
1351
1368
  height: calc(var(--dc-input-height) * 0.5);
@@ -1440,6 +1457,10 @@
1440
1457
  outline: none;
1441
1458
  }
1442
1459
 
1460
+ .dc-textarea__container_block .dc-textarea {
1461
+ resize: vertical;
1462
+ }
1463
+
1443
1464
  .dc-textarea_width_30ch {
1444
1465
  width: 30.5ch;
1445
1466
  }
@@ -1584,6 +1605,7 @@
1584
1605
  --dc-switch-focus-ring-color: var(--dc-focus-ring-color);
1585
1606
 
1586
1607
  color-scheme: light;
1608
+ display: inline-flex;
1587
1609
  }
1588
1610
 
1589
1611
  .dc-switch__input {
@@ -1689,6 +1711,7 @@
1689
1711
  --dc-checkbox-focus-ring-color: var(--dc-focus-ring-color);
1690
1712
 
1691
1713
  color-scheme: light;
1714
+ display: inline-flex;
1692
1715
  }
1693
1716
 
1694
1717
  .dc-checkbox__input {
@@ -1762,6 +1785,7 @@
1762
1785
  --dc-radio-color-focus-ring: var(--dc-focus-ring-color);
1763
1786
 
1764
1787
  color-scheme: light;
1788
+ display: inline-flex;
1765
1789
  }
1766
1790
 
1767
1791
  .dc-radio__input {
@@ -2410,6 +2434,7 @@
2410
2434
  }
2411
2435
 
2412
2436
  .dc-selection-control__input {
2437
+ display: inline-flex;
2413
2438
  grid-area: input;
2414
2439
  }
2415
2440
 
@@ -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("section", { ...props, className: classNames(className, {
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 };
@@ -3,23 +3,25 @@ import { forwardRef } from 'react';
3
3
  import { classNames } from '../../lib/react-helpers.js';
4
4
  import { Spinner } from '../spinner/spinner.js';
5
5
 
6
- const Button = forwardRef(function Button({ isBlock = false, disabled = false, loading = false, type = 'button', size = 'sm', variant = 'filled', appearance = 'default', icon = null, caption = null, renderAs, className, children, ...props }, ref) {
7
- const shouldRenderIcon = Boolean(icon);
8
- const shouldRenderLabel = Boolean(children);
9
- const shouldRenderCaption = Boolean(caption);
10
- let leadingAddOn = null;
6
+ const Button = forwardRef(function Button({ isBlock = false, disabled = false, loading = false, type = 'button', size = 'sm', variant = 'filled', appearance = 'default', iconLeft = null, iconRight = null, caption = null, renderAs, className, children, ...props }, ref) {
7
+ let addOnLeft = null;
11
8
  if (loading) {
12
- leadingAddOn = (jsx("span", { "data-testid": "button-spinner", className: "dc-button__spinner", children: jsx(Spinner, { size: "1.15em" }) }));
9
+ addOnLeft = (jsx("span", { "data-testid": "button-spinner", className: "dc-button__spinner", children: jsx(Spinner, { size: "1.15em" }) }));
10
+ }
11
+ else if (iconLeft) {
12
+ addOnLeft = (jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: iconLeft }));
13
13
  }
14
- else if (shouldRenderIcon) {
15
- leadingAddOn = (jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: icon }));
14
+ let addOnRight = null;
15
+ if (iconRight) {
16
+ addOnRight = (jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: iconRight }));
16
17
  }
17
- const content = (jsxs(Fragment, { children: [leadingAddOn, shouldRenderLabel && (jsxs("span", { className: "dc-button__body", children: [jsx("span", { className: "dc-button__label", children: children }), shouldRenderCaption && (jsx("small", { className: "dc-button__caption", children: caption }))] }))] }));
18
+ const shouldRenderLabel = Boolean(children);
19
+ const shouldRenderCaption = Boolean(caption);
20
+ const content = (jsxs(Fragment, { children: [addOnLeft, shouldRenderLabel && (jsxs("span", { className: "dc-button__body", children: [jsx("span", { className: "dc-button__label", children: children }), shouldRenderCaption && (jsx("small", { className: "dc-button__caption", children: caption }))] })), addOnRight] }));
18
21
  className = classNames(className, {
19
22
  'dc-button': true,
20
23
  'dc-button_block': isBlock,
21
24
  'dc-button_loading': loading,
22
- 'dc-button_has_icon': shouldRenderIcon,
23
25
  'dc-button_has_caption': shouldRenderCaption,
24
26
  [`dc-button_${size}`]: size,
25
27
  [`dc-button_appearance_${appearance}`]: appearance,
@@ -3,8 +3,8 @@ import { forwardRef } from 'react';
3
3
  import { classNames } from '../../lib/react-helpers.js';
4
4
  import { Button } from './button.js';
5
5
 
6
- const IconButton = forwardRef(function IconButton({ className, ...props }, ref) {
7
- return jsx(Button, { ref: ref, className: classNames('dc-button_icon-only', className), ...props });
6
+ const IconButton = forwardRef(function IconButton({ className, icon, ...props }, ref) {
7
+ return jsx(Button, { ...props, ref: ref, iconLeft: icon, className: classNames('dc-button_icon-only', className) });
8
8
  });
9
9
 
10
10
  export { IconButton };
@@ -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, onChangeValue, }) {
5
+ const customProperties = {
6
+ '--dc-color-picker-btn-color': color,
7
+ };
8
+ return (jsxs("label", { style: { ...customProperties, ...style }, className: classNames(className, {
9
+ 'dc-color-picker__btn': true,
10
+ 'dc-color-picker__btn_checked': checked,
11
+ }), children: [jsx("input", { type: "radio", name: name, value: value, checked: checked, onChange: () => onChangeValue(value) }), label] }));
12
+ }
13
+
14
+ export { ColorPickerButton };
@@ -0,0 +1,12 @@
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, options, value, disabled, 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) => (jsx(ColorPickerButton, { name: name, label: option.label, color: option.color, value: option.value, checked: option.value === value, onChangeValue: onChangeValue }, option.value))) }));
10
+ }
11
+
12
+ export { ColorPicker };
@@ -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 button = (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, suffix: button }));
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 };