draft-components 1.2.2 → 1.3.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 (71) hide show
  1. package/cjs/components/button/button.cjs +5 -5
  2. package/cjs/components/button/icon-button.cjs +1 -1
  3. package/cjs/components/dialog/dialog-body.cjs +1 -41
  4. package/cjs/components/dialog/dialog-footer.cjs +5 -2
  5. package/cjs/components/dialog/dialog-header.cjs +5 -2
  6. package/cjs/components/select/select.cjs +24 -12
  7. package/css/draft-components-utilities.css +7 -7
  8. package/css/draft-components.css +251 -144
  9. package/css/draft-components.dark.css +73 -73
  10. package/esm/components/button/button.js +5 -5
  11. package/esm/components/button/icon-button.js +1 -1
  12. package/esm/components/dialog/dialog-body.js +2 -42
  13. package/esm/components/dialog/dialog-footer.js +5 -2
  14. package/esm/components/dialog/dialog-header.js +5 -2
  15. package/esm/components/select/select.js +25 -13
  16. package/package.json +35 -36
  17. package/types/components/avatar-group/avatar-group.d.ts +1 -1
  18. package/types/components/badge/badge.d.ts +1 -1
  19. package/types/components/breadcrumbs/breadcrumbs-context.d.ts +1 -1
  20. package/types/components/breadcrumbs/breadcrumbs-item.d.ts +1 -1
  21. package/types/components/breadcrumbs/breadcrumbs.d.ts +1 -1
  22. package/types/components/button/button.d.ts +2 -2
  23. package/types/components/button/icon-button.d.ts +1 -1
  24. package/types/components/button-group/button-group.d.ts +1 -1
  25. package/types/components/caption/icons.d.ts +4 -4
  26. package/types/components/color-picker/color-picker-button.d.ts +1 -1
  27. package/types/components/color-picker/color-picker.d.ts +1 -1
  28. package/types/components/date-picker/calendar-day.d.ts +1 -1
  29. package/types/components/date-picker/calendar-grid-head.d.ts +1 -2
  30. package/types/components/date-picker/calendar-grid.d.ts +1 -2
  31. package/types/components/date-picker/calendar-header.d.ts +1 -2
  32. package/types/components/date-picker/calendar.d.ts +1 -2
  33. package/types/components/date-picker/date-picker.d.ts +1 -1
  34. package/types/components/date-picker/date-range-picker.d.ts +1 -1
  35. package/types/components/date-picker/icons.d.ts +2 -2
  36. package/types/components/date-picker-popover/date-picker-popover.d.ts +1 -1
  37. package/types/components/date-range-picker-popover/date-range-picker-popover-footer.d.ts +1 -1
  38. package/types/components/date-range-picker-popover/date-range-picker-popover-presets.d.ts +1 -2
  39. package/types/components/date-range-picker-popover/date-range-picker-popover.d.ts +1 -1
  40. package/types/components/dialog/dialog-body.d.ts +2 -5
  41. package/types/components/dialog/dialog-context.d.ts +1 -1
  42. package/types/components/dialog/dialog-footer.d.ts +4 -2
  43. package/types/components/dialog/dialog-header.d.ts +2 -1
  44. package/types/components/dialog/dialog.d.ts +1 -1
  45. package/types/components/dialog/x-mark-icon.d.ts +1 -1
  46. package/types/components/empty-state/empty-state.d.ts +1 -1
  47. package/types/components/filter-buttons/filter-buttons.d.ts +1 -1
  48. package/types/components/form-field/form-field.d.ts +1 -1
  49. package/types/components/menu/menu-separator.d.ts +1 -1
  50. package/types/components/menu/menu.d.ts +1 -1
  51. package/types/components/nav-list/nav-list-item.d.ts +1 -1
  52. package/types/components/nav-list/nav-list-title.d.ts +1 -1
  53. package/types/components/nav-list/nav-list.d.ts +1 -1
  54. package/types/components/password-input/icons.d.ts +2 -2
  55. package/types/components/portal/portal-context.d.ts +1 -1
  56. package/types/components/positioner/positioner.d.ts +1 -1
  57. package/types/components/segmented-control/segmented-control-button.d.ts +1 -1
  58. package/types/components/segmented-control/segmented-control.d.ts +1 -1
  59. package/types/components/select/select.d.ts +3 -0
  60. package/types/components/selection-control/selection-control.d.ts +1 -1
  61. package/types/components/slider/slider-tick-marks.d.ts +1 -1
  62. package/types/components/table/icons.d.ts +3 -3
  63. package/types/components/tabs/tab-list.d.ts +1 -1
  64. package/types/components/tabs/tab-panel.d.ts +1 -1
  65. package/types/components/tabs/tab.d.ts +1 -1
  66. package/types/components/tabs/tabs-context.d.ts +1 -1
  67. package/types/components/tabs/tabs.d.ts +1 -1
  68. package/types/components/toast/toast.d.ts +1 -1
  69. package/types/components/toast/x-mark-icon.d.ts +1 -1
  70. package/types/components/toaster/toaster.d.ts +1 -1
  71. package/types/components/tooltip/tooltip.d.ts +1 -1
@@ -5,17 +5,17 @@ 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', iconLeft = null, iconRight = null, caption = null, renderAs, className, children, ...props }, ref) {
8
+ const Button = react.forwardRef(function Button({ isBlock = false, disabled = false, loading = false, type = 'button', size = 'sm', variant = 'filled', appearance = 'default', leftIcon = null, rightIcon = null, caption = null, renderAs, className, children, ...props }, ref) {
9
9
  let addOnLeft = null;
10
10
  if (loading) {
11
11
  addOnLeft = (jsxRuntime.jsx("span", { "data-testid": "button-spinner", className: "dc-button__spinner", children: jsxRuntime.jsx(spinner.Spinner, { size: "1.15em" }) }));
12
12
  }
13
- else if (iconLeft) {
14
- addOnLeft = (jsxRuntime.jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: iconLeft }));
13
+ else if (leftIcon) {
14
+ addOnLeft = (jsxRuntime.jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: leftIcon }));
15
15
  }
16
16
  let addOnRight = null;
17
- if (iconRight) {
18
- addOnRight = (jsxRuntime.jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: iconRight }));
17
+ if (rightIcon) {
18
+ addOnRight = (jsxRuntime.jsx("span", { "data-testid": "button-icon", className: "dc-button__icon", children: rightIcon }));
19
19
  }
20
20
  const shouldRenderLabel = Boolean(children);
21
21
  const shouldRenderCaption = Boolean(caption);
@@ -6,7 +6,7 @@ const reactHelpers = require('../../lib/react-helpers.cjs');
6
6
  const button = require('./button.cjs');
7
7
 
8
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) });
9
+ return jsxRuntime.jsx(button.Button, { ...props, ref: ref, leftIcon: icon, className: reactHelpers.classNames('dc-button_icon-only', className) });
10
10
  });
11
11
 
12
12
  exports.IconButton = IconButton;
@@ -2,50 +2,10 @@
2
2
 
3
3
  const jsxRuntime = require('react/jsx-runtime');
4
4
  const react = require('react');
5
- const helpers = require('../../lib/helpers.cjs');
6
5
  const reactHelpers = require('../../lib/react-helpers.cjs');
7
6
 
8
- function DialogBody({ scrollShadowTop = false, scrollShadowBottom = false, className, children, }) {
7
+ function DialogBody({ className, children, }) {
9
8
  const ref = react.useRef(null);
10
- react.useEffect(() => {
11
- if (!scrollShadowTop && !scrollShadowBottom) {
12
- return;
13
- }
14
- const el = ref.current;
15
- helpers.assertIfNullable(el, 'DialogBody ref was not set');
16
- const topShadowClass = 'dc-dialog-body_scroll-shadow-top';
17
- const bottomShadowClass = 'dc-dialog-body_scroll-shadow-bottom';
18
- const changeShadowsVisibility = () => {
19
- const scrollTop = el.scrollTop;
20
- const scrollHeight = el.scrollHeight;
21
- const clientHeight = el.clientHeight;
22
- if (scrollShadowTop) {
23
- if (scrollTop > 0) {
24
- el.classList.add(topShadowClass);
25
- }
26
- else {
27
- el.classList.remove(topShadowClass);
28
- }
29
- }
30
- if (scrollShadowBottom) {
31
- if (scrollTop + clientHeight < scrollHeight) {
32
- el.classList.add(bottomShadowClass);
33
- }
34
- else {
35
- el.classList.remove(bottomShadowClass);
36
- }
37
- }
38
- };
39
- const resizeObserver = typeof ResizeObserver === 'undefined'
40
- ? null
41
- : new ResizeObserver(changeShadowsVisibility);
42
- resizeObserver?.observe(el);
43
- el.addEventListener('scroll', changeShadowsVisibility);
44
- return () => {
45
- resizeObserver?.unobserve(el);
46
- el.removeEventListener('scroll', changeShadowsVisibility);
47
- };
48
- }, [scrollShadowTop, scrollShadowBottom]);
49
9
  return (jsxRuntime.jsx("div", { ref: ref, className: reactHelpers.classNames('dc-dialog-body', className), children: children }));
50
10
  }
51
11
 
@@ -3,8 +3,11 @@
3
3
  const jsxRuntime = require('react/jsx-runtime');
4
4
  const reactHelpers = require('../../lib/react-helpers.cjs');
5
5
 
6
- function DialogFooter({ className, children, }) {
7
- return (jsxRuntime.jsx("div", { className: reactHelpers.classNames('dc-dialog-footer', className), children: children }));
6
+ function DialogFooter({ hasBorder, className, children, }) {
7
+ return (jsxRuntime.jsx("div", { className: reactHelpers.classNames(className, {
8
+ 'dc-dialog-footer': true,
9
+ 'dc-dialog-footer_has_border': hasBorder,
10
+ }), children: children }));
8
11
  }
9
12
 
10
13
  exports.DialogFooter = DialogFooter;
@@ -7,12 +7,15 @@ require('../button/button.cjs');
7
7
  const iconButton = require('../button/icon-button.cjs');
8
8
  const xMarkIcon = require('./x-mark-icon.cjs');
9
9
 
10
- function DialogHeader({ heading, subheading, className, children, }) {
10
+ function DialogHeader({ hasBorder, heading, subheading, className, children, }) {
11
11
  const { titleId, descriptionId, onClose, } = dialogContext.useDialogContext();
12
12
  const shouldRenderHeading = Boolean(heading);
13
13
  const shouldRenderDescription = Boolean(subheading);
14
14
  const shouldRenderChildren = Boolean(children);
15
- return (jsxRuntime.jsxs("div", { className: reactHelpers.classNames(className, 'dc-dialog-header'), children: [jsxRuntime.jsxs("div", { className: "dc-dialog-header__title-bar", children: [shouldRenderHeading && (jsxRuntime.jsx("h2", { id: titleId, className: "dc-dialog-header__heading", children: heading })), jsxRuntime.jsx(iconButton.IconButton, { icon: jsxRuntime.jsx(xMarkIcon.XMarkIcon, { width: 18, height: 18, strokeWidth: 2 }), variant: "plain", className: "dc-dialog-header__close-btn", onClick: () => onClose() })] }), shouldRenderDescription && (jsxRuntime.jsx("div", { id: descriptionId, className: "dc-dialog-header__subheading", children: subheading })), shouldRenderChildren && (jsxRuntime.jsx("div", { className: "dc-dialog-header__body", children: children }))] }));
15
+ return (jsxRuntime.jsxs("div", { className: reactHelpers.classNames(className, {
16
+ 'dc-dialog-header': true,
17
+ 'dc-dialog-header_has_border': hasBorder,
18
+ }), children: [jsxRuntime.jsxs("div", { className: "dc-dialog-header__title-bar", children: [shouldRenderHeading && (jsxRuntime.jsx("h2", { id: titleId, className: "dc-dialog-header__heading", children: heading })), jsxRuntime.jsx(iconButton.IconButton, { icon: jsxRuntime.jsx(xMarkIcon.XMarkIcon, { width: 18, height: 18, strokeWidth: 2 }), variant: "plain", className: "dc-dialog-header__close-btn", onClick: () => onClose() })] }), shouldRenderDescription && (jsxRuntime.jsx("div", { id: descriptionId, className: "dc-dialog-header__subheading", children: subheading })), shouldRenderChildren && (jsxRuntime.jsx("div", { className: "dc-dialog-header__body", children: children }))] }));
16
19
  }
17
20
 
18
21
  exports.DialogHeader = DialogHeader;
@@ -3,25 +3,37 @@
3
3
  const jsxRuntime = require('react/jsx-runtime');
4
4
  const react = require('react');
5
5
  const reactHelpers = require('../../lib/react-helpers.cjs');
6
+ const spinner = require('../spinner/spinner.cjs');
6
7
 
7
- const Select = react.forwardRef(function Select({ hasError, isBlock, size = 'md', style, className, disabled, multiple, htmlSize, children, onChange, onChangeValue, ...props }, ref) {
8
+ const Select = react.forwardRef(function Select({ hasError, isBlock, size = 'md', style, className, loading, disabled, multiple, htmlSize, children, onChange, onChangeValue, ...props }, ref) {
9
+ const onValueChanged = (event) => {
10
+ if (typeof onChange === 'function') {
11
+ onChange(event);
12
+ }
13
+ if (typeof onChangeValue === 'function') {
14
+ if (multiple === true) {
15
+ const values = Array.from(event.target.options)
16
+ .filter((option) => option.selected)
17
+ .map((option) => option.value);
18
+ onChangeValue(values);
19
+ }
20
+ else {
21
+ onChangeValue(event.target.value);
22
+ }
23
+ }
24
+ };
25
+ let addOn = (jsxRuntime.jsx("svg", { className: "dc-select__arrow", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: 24, height: 24, fill: "none", stroke: "currentColor", strokeWidth: 1.5, "aria-hidden": true, children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) }));
26
+ if (loading) {
27
+ addOn = (jsxRuntime.jsx(spinner.Spinner, { className: "dc-select__spinner", color: "currentColor", size: 16 }));
28
+ }
8
29
  return (jsxRuntime.jsxs("div", { style: style, className: reactHelpers.classNames(className, 'dc-select__container', {
9
30
  [`dc-select__container_${size}`]: size !== undefined,
10
31
  'dc-select__container_multiple': multiple,
32
+ 'dc-select__container_loading': loading,
11
33
  'dc-select__container_disabled': disabled,
12
34
  'dc-select__container_has_error': hasError,
13
35
  'dc-select__container_block': isBlock,
14
- }), children: [jsxRuntime.jsx("select", { ...props, ref: ref, className: "dc-select", size: htmlSize, multiple: multiple, disabled: disabled, onChange: (event) => {
15
- onChange?.(event);
16
- if (multiple === true) {
17
- onChangeValue?.(Array.from(event.target.options)
18
- .filter((option) => option.selected)
19
- .map((option) => option.value));
20
- }
21
- else {
22
- onChangeValue?.(event.target.value);
23
- }
24
- }, children: children }), jsxRuntime.jsx("svg", { className: "dc-select__icon", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: 24, height: 24, fill: "none", stroke: "currentColor", strokeWidth: 1.5, "aria-hidden": true, children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) })] }));
36
+ }), children: [jsxRuntime.jsx("select", { ...props, ref: ref, className: "dc-select", size: htmlSize, multiple: multiple, disabled: disabled || loading, onChange: onValueChanged, children: children }), jsxRuntime.jsx("span", { className: "dc-select__add-on", "aria-hidden": true, children: addOn })] }));
25
37
  });
26
38
 
27
39
  exports.Select = Select;
@@ -42,20 +42,20 @@
42
42
 
43
43
  /* Text style */
44
44
 
45
- .text-italic {
46
- font-style: italic !important;
45
+ .text-no-decoration {
46
+ text-decoration: none !important;
47
47
  }
48
48
 
49
- .text-not-italic {
49
+ .text-no-style {
50
50
  font-style: normal !important;
51
51
  }
52
52
 
53
- .text-underline {
54
- text-decoration: underline !important;
53
+ .text-italic {
54
+ font-style: italic !important;
55
55
  }
56
56
 
57
- .text-not-underline {
58
- text-decoration: none !important;
57
+ .text-underline {
58
+ text-decoration: underline !important;
59
59
  }
60
60
 
61
61
  .text-uppercase {