draft-components 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/dialog/dialog.cjs +1 -1
- package/cjs/components/filtered-search/filter-item.cjs +23 -0
- package/cjs/components/filtered-search/filter-operator-select.cjs +17 -0
- package/cjs/components/filtered-search/filter-token.cjs +17 -0
- package/cjs/components/filtered-search/filter-value-list.cjs +20 -0
- package/cjs/components/filtered-search/filtered-search.cjs +202 -0
- package/cjs/components/filtered-search/icons.cjs +21 -0
- package/cjs/components/filtered-search/model/abstract-filter.cjs +6 -0
- package/cjs/components/filtered-search/model/string-filter.cjs +46 -0
- package/cjs/components/filtered-search/model/string-set-filter.cjs +44 -0
- package/cjs/components/filtered-search/string-filter-input.cjs +17 -0
- package/cjs/components/filtered-search/string-filter-item.cjs +68 -0
- package/cjs/components/filtered-search/string-set-filter-item.cjs +77 -0
- package/cjs/components/filtered-search/use-combobox-ids.cjs +17 -0
- package/cjs/components/filtered-search/use-translations.cjs +24 -0
- package/cjs/components/index.cjs +12 -0
- package/cjs/components/popover/popover.cjs +3 -4
- package/cjs/components/slide-over/slide-over-body.cjs +10 -0
- package/cjs/components/slide-over/slide-over-context.cjs +24 -0
- package/cjs/components/slide-over/slide-over-header.cjs +21 -0
- package/cjs/components/slide-over/slide-over.cjs +106 -0
- package/cjs/hooks/index.cjs +2 -2
- package/cjs/hooks/use-disable-body-scroll.cjs +3 -1
- package/cjs/hooks/use-esc-key-down.cjs +3 -1
- package/cjs/hooks/use-focus-trap.cjs +3 -1
- package/cjs/index.cjs +16 -2
- package/cjs/lib/helpers.cjs +5 -1
- package/cjs/lib/index.cjs +2 -0
- package/cjs/lib/keyboard-keys.cjs +1 -0
- package/cjs/lib/react-helpers.cjs +8 -0
- package/css/draft-components.css +345 -2
- package/css/draft-components.dark.css +65 -40
- package/esm/components/dialog/dialog.js +1 -1
- package/esm/components/filtered-search/filter-item.js +21 -0
- package/esm/components/filtered-search/filter-operator-select.js +15 -0
- package/esm/components/filtered-search/filter-token.js +15 -0
- package/esm/components/filtered-search/filter-value-list.js +18 -0
- package/esm/components/filtered-search/filtered-search.js +200 -0
- package/esm/components/filtered-search/icons.js +16 -0
- package/esm/components/filtered-search/model/abstract-filter.js +4 -0
- package/esm/components/filtered-search/model/string-filter.js +44 -0
- package/esm/components/filtered-search/model/string-set-filter.js +42 -0
- package/esm/components/filtered-search/string-filter-input.js +15 -0
- package/esm/components/filtered-search/string-filter-item.js +66 -0
- package/esm/components/filtered-search/string-set-filter-item.js +75 -0
- package/esm/components/filtered-search/use-combobox-ids.js +15 -0
- package/esm/components/filtered-search/use-translations.js +21 -0
- package/esm/components/index.js +6 -0
- package/esm/components/popover/popover.js +3 -4
- package/esm/components/slide-over/slide-over-body.js +8 -0
- package/esm/components/slide-over/slide-over-context.js +21 -0
- package/esm/components/slide-over/slide-over-header.js +19 -0
- package/esm/components/slide-over/slide-over.js +104 -0
- package/esm/hooks/index.js +1 -1
- package/esm/hooks/use-disable-body-scroll.js +3 -1
- package/esm/hooks/use-esc-key-down.js +3 -1
- package/esm/hooks/use-focus-trap.js +3 -1
- package/esm/index.js +9 -3
- package/esm/lib/helpers.js +5 -2
- package/esm/lib/index.js +2 -2
- package/esm/lib/keyboard-keys.js +1 -0
- package/esm/lib/react-helpers.js +8 -1
- package/package.json +30 -30
- package/types/components/alert/alert.d.ts +1 -1
- package/types/components/avatar/avatar.d.ts +1 -1
- package/types/components/avatar-group/avatar-group.d.ts +1 -1
- package/types/components/badge/badge.d.ts +1 -1
- package/types/components/breadcrumbs/breadcrumbs-context.d.ts +1 -1
- package/types/components/breadcrumbs/breadcrumbs-item.d.ts +1 -1
- package/types/components/breadcrumbs/breadcrumbs.d.ts +1 -1
- package/types/components/button/button.d.ts +1 -1
- package/types/components/button/icon-button.d.ts +2 -2
- package/types/components/button-group/button-group.d.ts +1 -1
- package/types/components/caption/caption.d.ts +1 -1
- package/types/components/caption/icons.d.ts +1 -1
- package/types/components/checkbox/checkbox.d.ts +1 -1
- package/types/components/color-picker/color-picker-button.d.ts +1 -1
- package/types/components/color-picker/color-picker.d.ts +1 -1
- package/types/components/date-picker/calendar-day.d.ts +1 -1
- package/types/components/date-picker/calendar-grid-head.d.ts +1 -1
- package/types/components/date-picker/calendar-grid.d.ts +1 -1
- package/types/components/date-picker/calendar.d.ts +3 -3
- package/types/components/date-picker/date-picker.d.ts +3 -3
- package/types/components/date-picker/date-range-picker.d.ts +4 -4
- package/types/components/date-picker/date-range.d.ts +1 -1
- package/types/components/date-picker/icons.d.ts +1 -1
- package/types/components/date-picker-popover/date-picker-popover.d.ts +3 -3
- package/types/components/date-range-picker-popover/date-range-picker-popover-footer.d.ts +1 -1
- package/types/components/date-range-picker-popover/date-range-picker-popover-presets.d.ts +1 -1
- package/types/components/date-range-picker-popover/date-range-picker-popover.d.ts +4 -4
- package/types/components/date-range-picker-popover/types.d.ts +1 -1
- package/types/components/dialog/dialog-body.d.ts +1 -1
- package/types/components/dialog/dialog-context.d.ts +1 -1
- package/types/components/dialog/dialog-footer.d.ts +1 -1
- package/types/components/dialog/dialog-header.d.ts +1 -1
- package/types/components/dialog/dialog.d.ts +1 -1
- package/types/components/dialog/x-mark-icon.d.ts +1 -1
- package/types/components/empty-state/empty-state.d.ts +1 -1
- package/types/components/filter-buttons/filter-button.d.ts +1 -1
- package/types/components/filter-buttons/filter-buttons.d.ts +1 -1
- package/types/components/filtered-search/filter-item.d.ts +10 -0
- package/types/components/filtered-search/filter-operator-select.d.ts +10 -0
- package/types/components/filtered-search/filter-token.d.ts +9 -0
- package/types/components/filtered-search/filter-value-list.d.ts +8 -0
- package/types/components/filtered-search/filtered-search.d.ts +15 -0
- package/types/components/filtered-search/icons.d.ts +5 -0
- package/types/components/filtered-search/index.d.ts +4 -0
- package/types/components/filtered-search/model/abstract-filter.d.ts +6 -0
- package/types/components/filtered-search/model/string-filter.d.ts +47 -0
- package/types/components/filtered-search/model/string-set-filter.d.ts +41 -0
- package/types/components/filtered-search/model/validation-result.d.ts +6 -0
- package/types/components/filtered-search/string-filter-input.d.ts +9 -0
- package/types/components/filtered-search/string-filter-item.d.ts +13 -0
- package/types/components/filtered-search/string-set-filter-item.d.ts +15 -0
- package/types/components/filtered-search/types.d.ts +4 -0
- package/types/components/filtered-search/use-combobox-ids.d.ts +5 -0
- package/types/components/filtered-search/use-translations.d.ts +13 -0
- package/types/components/form-field/form-field.d.ts +1 -1
- package/types/components/index.d.ts +2 -0
- package/types/components/label/label.d.ts +1 -1
- package/types/components/menu/menu-item.d.ts +1 -1
- package/types/components/menu/menu-separator.d.ts +1 -1
- package/types/components/menu/menu.d.ts +3 -3
- package/types/components/nav-list/nav-list-item.d.ts +1 -1
- package/types/components/nav-list/nav-list-title.d.ts +1 -1
- package/types/components/nav-list/nav-list.d.ts +1 -1
- package/types/components/password-input/icons.d.ts +1 -1
- package/types/components/password-input/password-input.d.ts +1 -1
- package/types/components/popover/popover.d.ts +3 -1
- package/types/components/portal/portal-context.d.ts +1 -1
- package/types/components/portal/portal.d.ts +1 -1
- package/types/components/positioner/calc-position.d.ts +1 -1
- package/types/components/positioner/positioner.d.ts +2 -2
- package/types/components/radio/radio.d.ts +1 -1
- package/types/components/segmented-control/segmented-control-button.d.ts +1 -1
- package/types/components/segmented-control/segmented-control.d.ts +1 -1
- package/types/components/select/select.d.ts +1 -1
- package/types/components/selection-control/selection-control.d.ts +1 -1
- package/types/components/slide-over/index.d.ts +4 -0
- package/types/components/slide-over/slide-over-body.d.ts +3 -0
- package/types/components/slide-over/slide-over-context.d.ts +14 -0
- package/types/components/slide-over/slide-over-header.d.ts +11 -0
- package/types/components/slide-over/slide-over.d.ts +15 -0
- package/types/components/slide-over/types.d.ts +1 -0
- package/types/components/slider/slider-tick-marks.d.ts +1 -1
- package/types/components/slider/slider.d.ts +2 -2
- 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 +1 -1
- package/types/components/table/table-cell.d.ts +1 -1
- 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/tabs/tab-list.d.ts +1 -1
- package/types/components/tabs/tab-panel.d.ts +2 -2
- package/types/components/tabs/tab.d.ts +1 -1
- package/types/components/tabs/tabs-context.d.ts +2 -2
- package/types/components/tabs/tabs.d.ts +2 -2
- package/types/components/tag/tag.d.ts +1 -1
- package/types/components/text-input/text-input.d.ts +1 -1
- package/types/components/textarea/textarea.d.ts +1 -1
- package/types/components/toast/toast-button.d.ts +1 -1
- package/types/components/toast/toast.d.ts +1 -1
- package/types/components/toaster/toaster.d.ts +1 -1
- package/types/components/tooltip/tooltip.d.ts +2 -2
- package/types/hooks/index.d.ts +1 -1
- package/types/hooks/use-disable-body-scroll.d.ts +1 -1
- package/types/hooks/use-esc-key-down.d.ts +1 -1
- package/types/hooks/use-focus-trap.d.ts +2 -2
- package/types/lib/helpers.d.ts +1 -0
- package/types/lib/keyboard-keys.d.ts +1 -0
- package/types/lib/react-helpers.d.ts +2 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useId, useRef, useCallback, useMemo, useEffect } from 'react';
|
|
3
|
+
import { SlideOverContextProvider } from './slide-over-context.js';
|
|
4
|
+
import { getRefElement, classNames } from '../../lib/react-helpers.js';
|
|
5
|
+
import { useDisableBodyScroll } from '../../hooks/use-disable-body-scroll.js';
|
|
6
|
+
import { useEscKeyDown } from '../../hooks/use-esc-key-down.js';
|
|
7
|
+
import { useFocusTrap } from '../../hooks/use-focus-trap.js';
|
|
8
|
+
import { Portal } from '../portal/portal.js';
|
|
9
|
+
import { SlideOverHeader } from './slide-over-header.js';
|
|
10
|
+
import { SlideOverBody } from './slide-over-body.js';
|
|
11
|
+
|
|
12
|
+
const panelSlideIn = [
|
|
13
|
+
{ transform: 'translateX(100%)' },
|
|
14
|
+
{ transform: 'translateX(0%)' },
|
|
15
|
+
];
|
|
16
|
+
const backdropFade = [
|
|
17
|
+
{ opacity: 0 },
|
|
18
|
+
{ opacity: 1 },
|
|
19
|
+
];
|
|
20
|
+
function SlideOver({ 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, animationDurationMs = 350, animationDisabled = false, className, children, onClose, ...props }) {
|
|
21
|
+
const id = useId();
|
|
22
|
+
const titleId = ariaLabelledby || `${id}dialogTitle`;
|
|
23
|
+
const descriptionId = ariaDescribedby || `${id}dialogDescription`;
|
|
24
|
+
const backdropRef = useRef(null);
|
|
25
|
+
const panelRef = useRef(null);
|
|
26
|
+
const isAnimationDisabled = useRef(animationDisabled);
|
|
27
|
+
const shouldPlayAnimations = useCallback(() => {
|
|
28
|
+
const mediaQueryList = window.matchMedia('(prefers-reduced-motion)');
|
|
29
|
+
return !isAnimationDisabled.current && !mediaQueryList.matches;
|
|
30
|
+
}, []);
|
|
31
|
+
const closePanel = useMemo(() => {
|
|
32
|
+
let isClosing = false;
|
|
33
|
+
return (source) => {
|
|
34
|
+
if (isClosing) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!shouldPlayAnimations()) {
|
|
38
|
+
onClose(source);
|
|
39
|
+
}
|
|
40
|
+
isClosing = true;
|
|
41
|
+
const backdrop = getRefElement(backdropRef);
|
|
42
|
+
const backdropAnimations = backdrop.getAnimations();
|
|
43
|
+
if (backdropAnimations.length === 0) {
|
|
44
|
+
backdropAnimations.push(backdrop.animate(backdropFade, {
|
|
45
|
+
direction: 'reverse',
|
|
46
|
+
fill: 'both',
|
|
47
|
+
easing: 'ease-in-out',
|
|
48
|
+
duration: animationDurationMs,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
backdropAnimations.forEach((animation) => animation.reverse());
|
|
53
|
+
}
|
|
54
|
+
const panel = getRefElement(panelRef);
|
|
55
|
+
const panelAnimations = panel.getAnimations();
|
|
56
|
+
if (panelAnimations.length === 0) {
|
|
57
|
+
backdropAnimations.push(panel.animate(panelSlideIn, {
|
|
58
|
+
direction: 'reverse',
|
|
59
|
+
fill: 'both',
|
|
60
|
+
easing: 'ease-in-out',
|
|
61
|
+
duration: animationDurationMs,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
panelAnimations.forEach((animation) => animation.reverse());
|
|
66
|
+
}
|
|
67
|
+
const animations = [...backdropAnimations, ...panelAnimations];
|
|
68
|
+
Promise.all(animations.map((animation) => animation.finished)).then(() => {
|
|
69
|
+
onClose(source);
|
|
70
|
+
isClosing = false;
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}, [animationDurationMs, onClose, shouldPlayAnimations]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
isAnimationDisabled.current = animationDisabled;
|
|
76
|
+
}, [animationDisabled]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (shouldPlayAnimations()) {
|
|
79
|
+
const backdrop = getRefElement(backdropRef);
|
|
80
|
+
backdrop.animate(backdropFade, {
|
|
81
|
+
fill: 'both',
|
|
82
|
+
easing: 'ease-in-out',
|
|
83
|
+
duration: animationDurationMs,
|
|
84
|
+
});
|
|
85
|
+
const panel = getRefElement(panelRef);
|
|
86
|
+
panel.animate(panelSlideIn, {
|
|
87
|
+
fill: 'both',
|
|
88
|
+
easing: 'ease-in-out',
|
|
89
|
+
duration: animationDurationMs,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}, [shouldPlayAnimations, animationDurationMs]);
|
|
93
|
+
useEscKeyDown(() => closePanel('escape'));
|
|
94
|
+
useFocusTrap(panelRef);
|
|
95
|
+
useDisableBodyScroll();
|
|
96
|
+
const onClickBackdrop = () => {
|
|
97
|
+
closePanel('backdrop');
|
|
98
|
+
};
|
|
99
|
+
return (jsx(Portal, { children: jsxs("div", { className: "dc-slide-over", children: [jsx("div", { "data-testid": "slide-over-backdrop", className: "dc-slide-over__backdrop", ref: backdropRef, onClick: onClickBackdrop }), jsx("div", { ...props, className: classNames('dc-slide-over__panel', className), role: "dialog", ref: panelRef, "aria-modal": true, "aria-labelledby": titleId, "aria-describedby": descriptionId, children: jsx(SlideOverContextProvider, { titleId: titleId, descriptionId: descriptionId, closePanel: closePanel, children: children }) })] }) }));
|
|
100
|
+
}
|
|
101
|
+
SlideOver.Header = SlideOverHeader;
|
|
102
|
+
SlideOver.Body = SlideOverBody;
|
|
103
|
+
|
|
104
|
+
export { SlideOver };
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useMountTransition } from './use-mount-transition.js';
|
|
2
1
|
export { useDisableBodyScroll } from './use-disable-body-scroll.js';
|
|
3
2
|
export { useEscKeyDown } from './use-esc-key-down.js';
|
|
4
3
|
export { useFocusTrap } from './use-focus-trap.js';
|
|
4
|
+
export { useMountTransition } from './use-mount-transition.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { once } from '../lib/helpers.js';
|
|
3
3
|
|
|
4
|
-
function useDisableBodyScroll(options
|
|
4
|
+
function useDisableBodyScroll(options = {
|
|
5
|
+
isEnabled: true,
|
|
6
|
+
}) {
|
|
5
7
|
useEffect(() => {
|
|
6
8
|
if (options.isEnabled) {
|
|
7
9
|
return disableBodyScroll();
|
|
@@ -13,7 +13,9 @@ const handlers = [];
|
|
|
13
13
|
* @param options.isEnabled A flag that determines whether to run
|
|
14
14
|
* the passed handler or not.
|
|
15
15
|
*/
|
|
16
|
-
function useEscKeyDown(handler, options
|
|
16
|
+
function useEscKeyDown(handler, options = {
|
|
17
|
+
isEnabled: true,
|
|
18
|
+
}) {
|
|
17
19
|
const handlerRef = useRef(handler);
|
|
18
20
|
const isEnabled = options.isEnabled;
|
|
19
21
|
useEffect(() => {
|
|
@@ -24,7 +24,9 @@ const focusableElementsSelector = [
|
|
|
24
24
|
* @param {boolean} options.isEnabled - A flag that determines whether
|
|
25
25
|
* to trap focus or not.
|
|
26
26
|
*/
|
|
27
|
-
function useFocusTrap(modalRef, options
|
|
27
|
+
function useFocusTrap(modalRef, options = {
|
|
28
|
+
isEnabled: true,
|
|
29
|
+
}) {
|
|
28
30
|
const isEnabled = options.isEnabled;
|
|
29
31
|
useEffect(() => {
|
|
30
32
|
if (!isEnabled) {
|
package/esm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { KeyboardKeys } from './lib/keyboard-keys.js';
|
|
2
|
-
export { assertIfNullable, once } from './lib/helpers.js';
|
|
3
|
-
export { classNames, focusElement, isReactElementWithRef, mergeRefs } from './lib/react-helpers.js';
|
|
4
|
-
export { useMountTransition } from './hooks/use-mount-transition.js';
|
|
2
|
+
export { assertIfNullable, exhaustiveCheck, once } from './lib/helpers.js';
|
|
3
|
+
export { classNames, focusElement, getRefElement, isReactElementWithRef, mergeRefs } from './lib/react-helpers.js';
|
|
5
4
|
export { useDisableBodyScroll } from './hooks/use-disable-body-scroll.js';
|
|
6
5
|
export { useEscKeyDown } from './hooks/use-esc-key-down.js';
|
|
7
6
|
export { useFocusTrap } from './hooks/use-focus-trap.js';
|
|
7
|
+
export { useMountTransition } from './hooks/use-mount-transition.js';
|
|
8
8
|
export { Alert } from './components/alert/alert.js';
|
|
9
9
|
export { Avatar } from './components/avatar/avatar.js';
|
|
10
10
|
export { AvatarGroup } from './components/avatar-group/avatar-group.js';
|
|
@@ -29,6 +29,9 @@ export { EmptyState } from './components/empty-state/empty-state.js';
|
|
|
29
29
|
export { FilePicker } from './components/file-picker/file-picker.js';
|
|
30
30
|
export { FilterButtons } from './components/filter-buttons/filter-buttons.js';
|
|
31
31
|
export { FilterButton } from './components/filter-buttons/filter-button.js';
|
|
32
|
+
export { StringFilter } from './components/filtered-search/model/string-filter.js';
|
|
33
|
+
export { StringSetFilter } from './components/filtered-search/model/string-set-filter.js';
|
|
34
|
+
export { FilteredSearch } from './components/filtered-search/filtered-search.js';
|
|
32
35
|
export { FormField } from './components/form-field/form-field.js';
|
|
33
36
|
export { Label } from './components/label/label.js';
|
|
34
37
|
export { Menu } from './components/menu/menu.js';
|
|
@@ -45,6 +48,9 @@ export { Radio } from './components/radio/radio.js';
|
|
|
45
48
|
export { SegmentedControl } from './components/segmented-control/segmented-control.js';
|
|
46
49
|
export { Select } from './components/select/select.js';
|
|
47
50
|
export { SelectionControl } from './components/selection-control/selection-control.js';
|
|
51
|
+
export { SlideOver } from './components/slide-over/slide-over.js';
|
|
52
|
+
export { SlideOverHeader } from './components/slide-over/slide-over-header.js';
|
|
53
|
+
export { SlideOverBody } from './components/slide-over/slide-over-body.js';
|
|
48
54
|
export { Slider } from './components/slider/slider.js';
|
|
49
55
|
export { SliderTickMarks } from './components/slider/slider-tick-marks.js';
|
|
50
56
|
export { Spinner } from './components/spinner/spinner.js';
|
package/esm/lib/helpers.js
CHANGED
|
@@ -9,10 +9,13 @@ function once(fn) {
|
|
|
9
9
|
return result;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function exhaustiveCheck(value, message) {
|
|
13
|
+
throw new Error(message);
|
|
14
|
+
}
|
|
15
|
+
function assertIfNullable(value, message = 'assertIfNullable: value is null or undefined.') {
|
|
13
16
|
if (value == null) {
|
|
14
17
|
throw Error(message);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
export { assertIfNullable, once };
|
|
21
|
+
export { assertIfNullable, exhaustiveCheck, once };
|
package/esm/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { KeyboardKeys } from './keyboard-keys.js';
|
|
2
|
-
export { assertIfNullable, once } from './helpers.js';
|
|
3
|
-
export { classNames, focusElement, isReactElementWithRef, mergeRefs } from './react-helpers.js';
|
|
2
|
+
export { assertIfNullable, exhaustiveCheck, once } from './helpers.js';
|
|
3
|
+
export { classNames, focusElement, getRefElement, isReactElementWithRef, mergeRefs } from './react-helpers.js';
|
package/esm/lib/keyboard-keys.js
CHANGED
package/esm/lib/react-helpers.js
CHANGED
|
@@ -41,5 +41,12 @@ function focusElement(element) {
|
|
|
41
41
|
element.focus();
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
function getRefElement(ref, message = 'getElementFromRef: ref value is null.') {
|
|
45
|
+
const value = ref.current;
|
|
46
|
+
if (value == null) {
|
|
47
|
+
throw new Error(message);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
44
51
|
|
|
45
|
-
export { classNames, focusElement, isReactElementWithRef, mergeRefs };
|
|
52
|
+
export { classNames, focusElement, getRefElement, isReactElementWithRef, mergeRefs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "draft-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "The React based UI components library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -56,50 +56,50 @@
|
|
|
56
56
|
"react-dom": ">= 18"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@alexzimakov/eslint-config": "1.
|
|
60
|
-
"@babel/core": "7.22.
|
|
61
|
-
"@babel/preset-env": "7.22.
|
|
59
|
+
"@alexzimakov/eslint-config": "1.6.0",
|
|
60
|
+
"@babel/core": "7.22.9",
|
|
61
|
+
"@babel/preset-env": "7.22.9",
|
|
62
62
|
"@babel/preset-react": "7.22.5",
|
|
63
63
|
"@babel/preset-typescript": "7.22.5",
|
|
64
64
|
"@heroicons/react": "2.0.18",
|
|
65
|
-
"@rollup/plugin-typescript": "11.1.
|
|
66
|
-
"@storybook/addon-actions": "7.
|
|
67
|
-
"@storybook/addon-essentials": "7.
|
|
68
|
-
"@storybook/addon-links": "7.
|
|
69
|
-
"@storybook/react": "7.
|
|
70
|
-
"@storybook/react-vite": "7.
|
|
65
|
+
"@rollup/plugin-typescript": "11.1.2",
|
|
66
|
+
"@storybook/addon-actions": "7.1.1",
|
|
67
|
+
"@storybook/addon-essentials": "7.1.1",
|
|
68
|
+
"@storybook/addon-links": "7.1.1",
|
|
69
|
+
"@storybook/react": "7.1.1",
|
|
70
|
+
"@storybook/react-vite": "7.1.1",
|
|
71
71
|
"@testing-library/dom": "9.3.1",
|
|
72
|
-
"@testing-library/jest-dom": "5.
|
|
72
|
+
"@testing-library/jest-dom": "5.17.0",
|
|
73
73
|
"@testing-library/react": "14.0.0",
|
|
74
74
|
"@testing-library/user-event": "14.4.3",
|
|
75
|
-
"@types/jest": "29.5.
|
|
76
|
-
"@types/node": "18.
|
|
77
|
-
"@types/react": "18.2.
|
|
78
|
-
"@types/react-dom": "18.2.
|
|
79
|
-
"@typescript-eslint/eslint-plugin": "
|
|
80
|
-
"@typescript-eslint/parser": "
|
|
75
|
+
"@types/jest": "29.5.3",
|
|
76
|
+
"@types/node": "18.17.0",
|
|
77
|
+
"@types/react": "18.2.16",
|
|
78
|
+
"@types/react-dom": "18.2.7",
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "6.2.0",
|
|
80
|
+
"@typescript-eslint/parser": "6.2.0",
|
|
81
81
|
"autoprefixer": "10.4.14",
|
|
82
|
-
"eslint": "8.
|
|
82
|
+
"eslint": "8.45.0",
|
|
83
83
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
84
|
-
"eslint-plugin-react": "7.
|
|
84
|
+
"eslint-plugin-react": "7.33.0",
|
|
85
85
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
86
|
-
"eslint-plugin-storybook": "0.6.
|
|
86
|
+
"eslint-plugin-storybook": "0.6.13",
|
|
87
87
|
"eslint-plugin-testing-library": "5.11.0",
|
|
88
88
|
"husky": "8.0.3",
|
|
89
|
-
"jest": "29.
|
|
90
|
-
"jest-environment-jsdom": "29.
|
|
91
|
-
"lint-staged": "13.2.
|
|
92
|
-
"postcss": "8.4.
|
|
89
|
+
"jest": "29.6.1",
|
|
90
|
+
"jest-environment-jsdom": "29.6.1",
|
|
91
|
+
"lint-staged": "13.2.3",
|
|
92
|
+
"postcss": "8.4.27",
|
|
93
93
|
"postcss-import": "15.1.0",
|
|
94
94
|
"react": "18.2.0",
|
|
95
95
|
"react-dom": "18.2.0",
|
|
96
|
-
"rollup": "3.
|
|
97
|
-
"storybook": "7.
|
|
98
|
-
"stylelint": "15.
|
|
99
|
-
"stylelint-config-standard": "
|
|
96
|
+
"rollup": "3.26.3",
|
|
97
|
+
"storybook": "7.1.1",
|
|
98
|
+
"stylelint": "15.10.2",
|
|
99
|
+
"stylelint-config-standard": "34.0.0",
|
|
100
100
|
"stylelint-order": "6.0.3",
|
|
101
|
-
"typescript": "5.1.
|
|
102
|
-
"vite": "4.
|
|
101
|
+
"typescript": "5.1.6",
|
|
102
|
+
"vite": "4.4.7"
|
|
103
103
|
},
|
|
104
104
|
"lint-staged": {
|
|
105
105
|
"*.ts?(x)": "npm run lint",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithRef, JSX, ReactNode } from 'react';
|
|
2
2
|
type AlertHTMLProps = ComponentPropsWithRef<'div'>;
|
|
3
3
|
export type AlertAppearance = 'default' | 'info' | 'success' | 'warning' | 'error';
|
|
4
4
|
export type AlertVariant = 'default' | 'full-width' | 'accent-border';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
2
|
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
3
|
export type AvatarFill = 'gray' | 'pink' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'violet';
|
|
4
4
|
export type AvatarProps = ComponentPropsWithRef<'div'> & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef, JSX } from 'react';
|
|
2
2
|
type AvatarGroupBaseProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'>;
|
|
3
3
|
export type AvatarGroupProps = AvatarGroupBaseProps & {
|
|
4
4
|
children: JSX.Element | JSX.Element[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef, JSX, ReactNode } from 'react';
|
|
2
2
|
type BreadcrumbsItemHTMLProps = ComponentPropsWithoutRef<'a'>;
|
|
3
3
|
export type BreadcrumbsItemRenderFn = (props: {
|
|
4
4
|
className: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithRef, JSX, ReactNode } from 'react';
|
|
2
2
|
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
3
3
|
export type ButtonAppearance = 'default' | 'primary' | 'danger' | 'success';
|
|
4
4
|
export type ButtonVariant = 'filled' | 'tinted' | 'plain';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ButtonProps } from './button';
|
|
3
3
|
export type IconButtonBaseProps = Omit<ButtonProps, 'children' | 'caption' | 'leftIcon' | 'rightIcon'>;
|
|
4
4
|
export type IconButtonProps = {
|
|
5
5
|
icon: ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef, JSX } from 'react';
|
|
2
2
|
type ButtonGroupBaseProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'>;
|
|
3
3
|
export type ButtonGroupProps = ButtonGroupBaseProps & {
|
|
4
4
|
children: JSX.Element | JSX.Element[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
2
|
export type CaptionAppearance = 'default' | 'info' | 'success' | 'error' | 'warning';
|
|
3
3
|
export type CaptionProps = ComponentPropsWithRef<'div'> & {
|
|
4
4
|
showIcon?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
export declare function InfoIcon(props: ComponentPropsWithoutRef<'svg'>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare function SuccessIcon(props: ComponentPropsWithoutRef<'svg'>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare function ErrorIcon(props: ComponentPropsWithoutRef<'svg'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithRef } from 'react';
|
|
2
2
|
type CheckboxHTMLProps = ComponentPropsWithRef<'input'>;
|
|
3
3
|
type CheckboxBaseProps = Omit<CheckboxHTMLProps, 'type'>;
|
|
4
4
|
export type CheckboxToggleHandler = (checked: boolean) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Weekday } from './date-helpers';
|
|
2
|
-
import {
|
|
2
|
+
import { CalendarDayProps } from './calendar-day';
|
|
3
3
|
export type GetCalendarDayProps = (date: Date) => Pick<CalendarDayProps, 'isSelected' | 'inRange' | 'isRangeStart' | 'isRangeEnd'>;
|
|
4
4
|
export type CalendarGridProps = {
|
|
5
5
|
focusDay: Date;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Weekday } from './date-helpers';
|
|
2
|
+
import { CalendarHeaderProps } from './calendar-header';
|
|
3
|
+
import { CalendarGridProps } from './calendar-grid';
|
|
4
4
|
export type CalendarProps = {
|
|
5
5
|
className?: string;
|
|
6
6
|
defaultFocusDay?: Date | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DateISO, Weekday } from './date-helpers';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import { CalendarProps } from './calendar';
|
|
4
4
|
type DatePickerHTMLProps = ComponentPropsWithoutRef<'div'>;
|
|
5
5
|
export type DatePickerProps = {
|
|
6
6
|
value: DateISO | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { DateISORange } from './date-range';
|
|
2
|
+
import { DateISO, Weekday } from './date-helpers';
|
|
3
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
4
|
+
import { CalendarProps } from './calendar';
|
|
5
5
|
type DateRangePickerHTMLProps = ComponentPropsWithoutRef<'div'>;
|
|
6
6
|
export type DateRangePickerProps = {
|
|
7
7
|
value: DateISORange | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
export declare function ChevronLeftIcon(props: ComponentPropsWithoutRef<'svg'>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare function ChevronRightIcon(props: ComponentPropsWithoutRef<'svg'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DateISO } from '../date-picker/date-helpers';
|
|
2
|
+
import { JSX, ReactNode } from 'react';
|
|
3
|
+
import { DatePickerProps } from '../date-picker';
|
|
4
4
|
export type DatePickerChangeValueFn = (value: DateISO) => void;
|
|
5
5
|
export type DatePickerPopoverProps = {
|
|
6
6
|
className?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DateRangePickerPopoverOption, DateRangePickerPopoverSelection } from './types';
|
|
2
2
|
export type DateRangePickerPopoverPresetsProps = {
|
|
3
3
|
isCompactView: boolean;
|
|
4
4
|
customPresetLabel: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { DateRangePickerPopoverOption, DateRangePickerPopoverSelection } from './types';
|
|
2
|
+
import { JSX, ReactNode } from 'react';
|
|
3
|
+
import { PopoverAlignment, PopoverPlacement } from '../popover';
|
|
4
|
+
import { DateRangePickerProps } from '../date-picker';
|
|
5
5
|
export type DateRangePickerPopoverPlacement = PopoverPlacement;
|
|
6
6
|
export type DateRangePickerPopoverAlignment = PopoverAlignment;
|
|
7
7
|
export type DateRangePickerPopoverRenderFooter = (context: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
type DialogBodyHTMLProps = ComponentPropsWithoutRef<'div'>;
|
|
3
3
|
export type DialogBodyProps = DialogBodyHTMLProps;
|
|
4
4
|
export declare function DialogBody({ className, children, }: DialogBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef, RefObject } from 'react';
|
|
2
2
|
type DialogHTMLProps = ComponentPropsWithoutRef<'section'>;
|
|
3
3
|
export type DialogWidth = 'sm' | 'md' | 'lg';
|
|
4
4
|
export type DialogProps = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
export declare function XMarkIcon(props: ComponentPropsWithoutRef<'svg'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
type FilterButtonsHTMLProps = ComponentPropsWithoutRef<'div'>;
|
|
3
3
|
export type FilterButtonsProps = FilterButtonsHTMLProps;
|
|
4
4
|
export declare function FilterButtons({ className, children, ...props }: FilterButtonsProps): import("react/jsx-runtime").JSX.Element;
|