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
package/cjs/components/index.cjs
CHANGED
|
@@ -24,6 +24,9 @@ const emptyState = require('./empty-state/empty-state.cjs');
|
|
|
24
24
|
const filePicker = require('./file-picker/file-picker.cjs');
|
|
25
25
|
const filterButtons = require('./filter-buttons/filter-buttons.cjs');
|
|
26
26
|
const filterButton = require('./filter-buttons/filter-button.cjs');
|
|
27
|
+
const stringFilter = require('./filtered-search/model/string-filter.cjs');
|
|
28
|
+
const stringSetFilter = require('./filtered-search/model/string-set-filter.cjs');
|
|
29
|
+
const filteredSearch = require('./filtered-search/filtered-search.cjs');
|
|
27
30
|
const formField = require('./form-field/form-field.cjs');
|
|
28
31
|
const label = require('./label/label.cjs');
|
|
29
32
|
const menu = require('./menu/menu.cjs');
|
|
@@ -40,6 +43,9 @@ const radio = require('./radio/radio.cjs');
|
|
|
40
43
|
const segmentedControl = require('./segmented-control/segmented-control.cjs');
|
|
41
44
|
const select = require('./select/select.cjs');
|
|
42
45
|
const selectionControl = require('./selection-control/selection-control.cjs');
|
|
46
|
+
const slideOver = require('./slide-over/slide-over.cjs');
|
|
47
|
+
const slideOverHeader = require('./slide-over/slide-over-header.cjs');
|
|
48
|
+
const slideOverBody = require('./slide-over/slide-over-body.cjs');
|
|
43
49
|
const slider = require('./slider/slider.cjs');
|
|
44
50
|
const sliderTickMarks = require('./slider/slider-tick-marks.cjs');
|
|
45
51
|
const spinner = require('./spinner/spinner.cjs');
|
|
@@ -89,6 +95,9 @@ exports.EmptyState = emptyState.EmptyState;
|
|
|
89
95
|
exports.FilePicker = filePicker.FilePicker;
|
|
90
96
|
exports.FilterButtons = filterButtons.FilterButtons;
|
|
91
97
|
exports.FilterButton = filterButton.FilterButton;
|
|
98
|
+
exports.StringFilter = stringFilter.StringFilter;
|
|
99
|
+
exports.StringSetFilter = stringSetFilter.StringSetFilter;
|
|
100
|
+
exports.FilteredSearch = filteredSearch.FilteredSearch;
|
|
92
101
|
exports.FormField = formField.FormField;
|
|
93
102
|
exports.Label = label.Label;
|
|
94
103
|
exports.Menu = menu.Menu;
|
|
@@ -105,6 +114,9 @@ exports.Radio = radio.Radio;
|
|
|
105
114
|
exports.SegmentedControl = segmentedControl.SegmentedControl;
|
|
106
115
|
exports.Select = select.Select;
|
|
107
116
|
exports.SelectionControl = selectionControl.SelectionControl;
|
|
117
|
+
exports.SlideOver = slideOver.SlideOver;
|
|
118
|
+
exports.SlideOverHeader = slideOverHeader.SlideOverHeader;
|
|
119
|
+
exports.SlideOverBody = slideOverBody.SlideOverBody;
|
|
108
120
|
exports.Slider = slider.Slider;
|
|
109
121
|
exports.SliderTickMarks = sliderTickMarks.SliderTickMarks;
|
|
110
122
|
exports.Spinner = spinner.Spinner;
|
|
@@ -9,14 +9,13 @@ const useFocusTrap = require('../../hooks/use-focus-trap.cjs');
|
|
|
9
9
|
const usePageClick = require('./use-page-click.cjs');
|
|
10
10
|
const positioner = require('../positioner/positioner.cjs');
|
|
11
11
|
|
|
12
|
-
const Popover = react.forwardRef(function Popover({ shouldTrapFocus = true, shouldFocusAnchorAfterEscPress = true, placement = 'bottom', alignment = 'start', anchorGap, viewportGap, anchor, className, children, onOpen, onClose, ...props }, ref) {
|
|
12
|
+
const Popover = react.forwardRef(function Popover({ shouldTrapFocus = true, shouldFocusAnchorAfterEscPress = true, transitionDurationMs = 100, placement = 'bottom', alignment = 'start', anchorGap, viewportGap, anchor, className, children, onOpen, onClose, ...props }, ref) {
|
|
13
13
|
const [defaultIsOpen, setDefaultIsOpen] = react.useState(props.defaultIsOpen ?? false);
|
|
14
14
|
const anchorRef = react.useRef(null);
|
|
15
15
|
const contentRef = react.useRef(null);
|
|
16
16
|
const isOpen = props.isOpen ?? defaultIsOpen;
|
|
17
|
-
const durationMs = 100;
|
|
18
17
|
const { isMounted, className: transitionClass } = useMountTransition.useMountTransition({
|
|
19
|
-
durationMs,
|
|
18
|
+
durationMs: transitionDurationMs,
|
|
20
19
|
isShown: isOpen,
|
|
21
20
|
enterFrom: 'dc-popover_closed',
|
|
22
21
|
enterTo: 'dc-popover_opened',
|
|
@@ -86,7 +85,7 @@ const Popover = react.forwardRef(function Popover({ shouldTrapFocus = true, shou
|
|
|
86
85
|
delete props.defaultIsOpen;
|
|
87
86
|
delete props.isOpen;
|
|
88
87
|
return (jsxRuntime.jsx("div", { ref: portalRef, style: {
|
|
89
|
-
'--dc-popover-transition-duration': `${
|
|
88
|
+
'--dc-popover-transition-duration': `${transitionDurationMs}ms`,
|
|
90
89
|
...portalStyle,
|
|
91
90
|
}, className: reactHelpers.classNames('dc-popover', transitionClass), children: jsxRuntime.jsx("div", { ...props, ref: contentRef, className: reactHelpers.classNames('dc-popover-modal', className), children: children }) }));
|
|
92
91
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
5
|
+
|
|
6
|
+
function SlideOverBody({ className, ...props }) {
|
|
7
|
+
return (jsxRuntime.jsx("div", { className: reactHelpers.classNames('dc-slide-over-body', className), ...props }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.SlideOverBody = SlideOverBody;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const react = require('react');
|
|
5
|
+
|
|
6
|
+
const Context = react.createContext(null);
|
|
7
|
+
function useSlideOverContext() {
|
|
8
|
+
const ctx = react.useContext(Context);
|
|
9
|
+
if (!ctx) {
|
|
10
|
+
throw new Error('useSlideOverContext must be used within SlideOverContextProvider');
|
|
11
|
+
}
|
|
12
|
+
return ctx;
|
|
13
|
+
}
|
|
14
|
+
function SlideOverContextProvider({ titleId, descriptionId, closePanel, children, }) {
|
|
15
|
+
const ctx = react.useMemo(() => ({
|
|
16
|
+
titleId,
|
|
17
|
+
descriptionId,
|
|
18
|
+
closePanel,
|
|
19
|
+
}), [titleId, descriptionId, closePanel]);
|
|
20
|
+
return (jsxRuntime.jsx(Context.Provider, { value: ctx, children: children }));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.SlideOverContextProvider = SlideOverContextProvider;
|
|
24
|
+
exports.useSlideOverContext = useSlideOverContext;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
5
|
+
require('../button/button.cjs');
|
|
6
|
+
const iconButton = require('../button/icon-button.cjs');
|
|
7
|
+
const slideOverContext = require('./slide-over-context.cjs');
|
|
8
|
+
|
|
9
|
+
function SlideOverHeader({ className, htmlTitle, title, description, closeButtonAccessibleName, onClickCloseButton, ...props }) {
|
|
10
|
+
const { titleId, descriptionId, closePanel } = slideOverContext.useSlideOverContext();
|
|
11
|
+
const onCloseButtonClicked = (ev) => {
|
|
12
|
+
closePanel('close-button');
|
|
13
|
+
onClickCloseButton?.(ev);
|
|
14
|
+
};
|
|
15
|
+
return (jsxRuntime.jsxs("div", { className: reactHelpers.classNames('dc-slide-over-header', className), title: htmlTitle, ...props, children: [jsxRuntime.jsxs("div", { className: "dc-slide-over-header__title", children: [jsxRuntime.jsx("h2", { id: titleId, children: title }), jsxRuntime.jsx(iconButton.IconButton, { icon: jsxRuntime.jsx(XMarkIcon, {}), "aria-label": closeButtonAccessibleName, variant: "tinted", size: "xs", onClick: onCloseButtonClicked })] }), description ? (jsxRuntime.jsx("div", { id: descriptionId, className: "dc-slide-over-header__description", children: description })) : null] }));
|
|
16
|
+
}
|
|
17
|
+
function XMarkIcon(props) {
|
|
18
|
+
return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: 20, height: 20, fill: "none", stroke: "currentColor", strokeWidth: 1.5, ...props, children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.SlideOverHeader = SlideOverHeader;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const react = require('react');
|
|
5
|
+
const slideOverContext = require('./slide-over-context.cjs');
|
|
6
|
+
const reactHelpers = require('../../lib/react-helpers.cjs');
|
|
7
|
+
const useDisableBodyScroll = require('../../hooks/use-disable-body-scroll.cjs');
|
|
8
|
+
const useEscKeyDown = require('../../hooks/use-esc-key-down.cjs');
|
|
9
|
+
const useFocusTrap = require('../../hooks/use-focus-trap.cjs');
|
|
10
|
+
const portal = require('../portal/portal.cjs');
|
|
11
|
+
const slideOverHeader = require('./slide-over-header.cjs');
|
|
12
|
+
const slideOverBody = require('./slide-over-body.cjs');
|
|
13
|
+
|
|
14
|
+
const panelSlideIn = [
|
|
15
|
+
{ transform: 'translateX(100%)' },
|
|
16
|
+
{ transform: 'translateX(0%)' },
|
|
17
|
+
];
|
|
18
|
+
const backdropFade = [
|
|
19
|
+
{ opacity: 0 },
|
|
20
|
+
{ opacity: 1 },
|
|
21
|
+
];
|
|
22
|
+
function SlideOver({ 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, animationDurationMs = 350, animationDisabled = false, className, children, onClose, ...props }) {
|
|
23
|
+
const id = react.useId();
|
|
24
|
+
const titleId = ariaLabelledby || `${id}dialogTitle`;
|
|
25
|
+
const descriptionId = ariaDescribedby || `${id}dialogDescription`;
|
|
26
|
+
const backdropRef = react.useRef(null);
|
|
27
|
+
const panelRef = react.useRef(null);
|
|
28
|
+
const isAnimationDisabled = react.useRef(animationDisabled);
|
|
29
|
+
const shouldPlayAnimations = react.useCallback(() => {
|
|
30
|
+
const mediaQueryList = window.matchMedia('(prefers-reduced-motion)');
|
|
31
|
+
return !isAnimationDisabled.current && !mediaQueryList.matches;
|
|
32
|
+
}, []);
|
|
33
|
+
const closePanel = react.useMemo(() => {
|
|
34
|
+
let isClosing = false;
|
|
35
|
+
return (source) => {
|
|
36
|
+
if (isClosing) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!shouldPlayAnimations()) {
|
|
40
|
+
onClose(source);
|
|
41
|
+
}
|
|
42
|
+
isClosing = true;
|
|
43
|
+
const backdrop = reactHelpers.getRefElement(backdropRef);
|
|
44
|
+
const backdropAnimations = backdrop.getAnimations();
|
|
45
|
+
if (backdropAnimations.length === 0) {
|
|
46
|
+
backdropAnimations.push(backdrop.animate(backdropFade, {
|
|
47
|
+
direction: 'reverse',
|
|
48
|
+
fill: 'both',
|
|
49
|
+
easing: 'ease-in-out',
|
|
50
|
+
duration: animationDurationMs,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
backdropAnimations.forEach((animation) => animation.reverse());
|
|
55
|
+
}
|
|
56
|
+
const panel = reactHelpers.getRefElement(panelRef);
|
|
57
|
+
const panelAnimations = panel.getAnimations();
|
|
58
|
+
if (panelAnimations.length === 0) {
|
|
59
|
+
backdropAnimations.push(panel.animate(panelSlideIn, {
|
|
60
|
+
direction: 'reverse',
|
|
61
|
+
fill: 'both',
|
|
62
|
+
easing: 'ease-in-out',
|
|
63
|
+
duration: animationDurationMs,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
panelAnimations.forEach((animation) => animation.reverse());
|
|
68
|
+
}
|
|
69
|
+
const animations = [...backdropAnimations, ...panelAnimations];
|
|
70
|
+
Promise.all(animations.map((animation) => animation.finished)).then(() => {
|
|
71
|
+
onClose(source);
|
|
72
|
+
isClosing = false;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}, [animationDurationMs, onClose, shouldPlayAnimations]);
|
|
76
|
+
react.useEffect(() => {
|
|
77
|
+
isAnimationDisabled.current = animationDisabled;
|
|
78
|
+
}, [animationDisabled]);
|
|
79
|
+
react.useEffect(() => {
|
|
80
|
+
if (shouldPlayAnimations()) {
|
|
81
|
+
const backdrop = reactHelpers.getRefElement(backdropRef);
|
|
82
|
+
backdrop.animate(backdropFade, {
|
|
83
|
+
fill: 'both',
|
|
84
|
+
easing: 'ease-in-out',
|
|
85
|
+
duration: animationDurationMs,
|
|
86
|
+
});
|
|
87
|
+
const panel = reactHelpers.getRefElement(panelRef);
|
|
88
|
+
panel.animate(panelSlideIn, {
|
|
89
|
+
fill: 'both',
|
|
90
|
+
easing: 'ease-in-out',
|
|
91
|
+
duration: animationDurationMs,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}, [shouldPlayAnimations, animationDurationMs]);
|
|
95
|
+
useEscKeyDown.useEscKeyDown(() => closePanel('escape'));
|
|
96
|
+
useFocusTrap.useFocusTrap(panelRef);
|
|
97
|
+
useDisableBodyScroll.useDisableBodyScroll();
|
|
98
|
+
const onClickBackdrop = () => {
|
|
99
|
+
closePanel('backdrop');
|
|
100
|
+
};
|
|
101
|
+
return (jsxRuntime.jsx(portal.Portal, { children: jsxRuntime.jsxs("div", { className: "dc-slide-over", children: [jsxRuntime.jsx("div", { "data-testid": "slide-over-backdrop", className: "dc-slide-over__backdrop", ref: backdropRef, onClick: onClickBackdrop }), jsxRuntime.jsx("div", { ...props, className: reactHelpers.classNames('dc-slide-over__panel', className), role: "dialog", ref: panelRef, "aria-modal": true, "aria-labelledby": titleId, "aria-describedby": descriptionId, children: jsxRuntime.jsx(slideOverContext.SlideOverContextProvider, { titleId: titleId, descriptionId: descriptionId, closePanel: closePanel, children: children }) })] }) }));
|
|
102
|
+
}
|
|
103
|
+
SlideOver.Header = slideOverHeader.SlideOverHeader;
|
|
104
|
+
SlideOver.Body = slideOverBody.SlideOverBody;
|
|
105
|
+
|
|
106
|
+
exports.SlideOver = SlideOver;
|
package/cjs/hooks/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useMountTransition = require('./use-mount-transition.cjs');
|
|
4
3
|
const useDisableBodyScroll = require('./use-disable-body-scroll.cjs');
|
|
5
4
|
const useEscKeyDown = require('./use-esc-key-down.cjs');
|
|
6
5
|
const useFocusTrap = require('./use-focus-trap.cjs');
|
|
6
|
+
const useMountTransition = require('./use-mount-transition.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.useMountTransition = useMountTransition.useMountTransition;
|
|
11
10
|
exports.useDisableBodyScroll = useDisableBodyScroll.useDisableBodyScroll;
|
|
12
11
|
exports.useEscKeyDown = useEscKeyDown.useEscKeyDown;
|
|
13
12
|
exports.useFocusTrap = useFocusTrap.useFocusTrap;
|
|
13
|
+
exports.useMountTransition = useMountTransition.useMountTransition;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
const react = require('react');
|
|
4
4
|
const helpers = require('../lib/helpers.cjs');
|
|
5
5
|
|
|
6
|
-
function useDisableBodyScroll(options
|
|
6
|
+
function useDisableBodyScroll(options = {
|
|
7
|
+
isEnabled: true,
|
|
8
|
+
}) {
|
|
7
9
|
react.useEffect(() => {
|
|
8
10
|
if (options.isEnabled) {
|
|
9
11
|
return disableBodyScroll();
|
|
@@ -15,7 +15,9 @@ const handlers = [];
|
|
|
15
15
|
* @param options.isEnabled A flag that determines whether to run
|
|
16
16
|
* the passed handler or not.
|
|
17
17
|
*/
|
|
18
|
-
function useEscKeyDown(handler, options
|
|
18
|
+
function useEscKeyDown(handler, options = {
|
|
19
|
+
isEnabled: true,
|
|
20
|
+
}) {
|
|
19
21
|
const handlerRef = react.useRef(handler);
|
|
20
22
|
const isEnabled = options.isEnabled;
|
|
21
23
|
react.useEffect(() => {
|
|
@@ -26,7 +26,9 @@ const focusableElementsSelector = [
|
|
|
26
26
|
* @param {boolean} options.isEnabled - A flag that determines whether
|
|
27
27
|
* to trap focus or not.
|
|
28
28
|
*/
|
|
29
|
-
function useFocusTrap(modalRef, options
|
|
29
|
+
function useFocusTrap(modalRef, options = {
|
|
30
|
+
isEnabled: true,
|
|
31
|
+
}) {
|
|
30
32
|
const isEnabled = options.isEnabled;
|
|
31
33
|
react.useEffect(() => {
|
|
32
34
|
if (!isEnabled) {
|
package/cjs/index.cjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
const keyboardKeys = require('./lib/keyboard-keys.cjs');
|
|
4
4
|
const helpers = require('./lib/helpers.cjs');
|
|
5
5
|
const reactHelpers = require('./lib/react-helpers.cjs');
|
|
6
|
-
const useMountTransition = require('./hooks/use-mount-transition.cjs');
|
|
7
6
|
const useDisableBodyScroll = require('./hooks/use-disable-body-scroll.cjs');
|
|
8
7
|
const useEscKeyDown = require('./hooks/use-esc-key-down.cjs');
|
|
9
8
|
const useFocusTrap = require('./hooks/use-focus-trap.cjs');
|
|
9
|
+
const useMountTransition = require('./hooks/use-mount-transition.cjs');
|
|
10
10
|
const alert = require('./components/alert/alert.cjs');
|
|
11
11
|
const avatar = require('./components/avatar/avatar.cjs');
|
|
12
12
|
const avatarGroup = require('./components/avatar-group/avatar-group.cjs');
|
|
@@ -31,6 +31,9 @@ const emptyState = require('./components/empty-state/empty-state.cjs');
|
|
|
31
31
|
const filePicker = require('./components/file-picker/file-picker.cjs');
|
|
32
32
|
const filterButtons = require('./components/filter-buttons/filter-buttons.cjs');
|
|
33
33
|
const filterButton = require('./components/filter-buttons/filter-button.cjs');
|
|
34
|
+
const stringFilter = require('./components/filtered-search/model/string-filter.cjs');
|
|
35
|
+
const stringSetFilter = require('./components/filtered-search/model/string-set-filter.cjs');
|
|
36
|
+
const filteredSearch = require('./components/filtered-search/filtered-search.cjs');
|
|
34
37
|
const formField = require('./components/form-field/form-field.cjs');
|
|
35
38
|
const label = require('./components/label/label.cjs');
|
|
36
39
|
const menu = require('./components/menu/menu.cjs');
|
|
@@ -47,6 +50,9 @@ const radio = require('./components/radio/radio.cjs');
|
|
|
47
50
|
const segmentedControl = require('./components/segmented-control/segmented-control.cjs');
|
|
48
51
|
const select = require('./components/select/select.cjs');
|
|
49
52
|
const selectionControl = require('./components/selection-control/selection-control.cjs');
|
|
53
|
+
const slideOver = require('./components/slide-over/slide-over.cjs');
|
|
54
|
+
const slideOverHeader = require('./components/slide-over/slide-over-header.cjs');
|
|
55
|
+
const slideOverBody = require('./components/slide-over/slide-over-body.cjs');
|
|
50
56
|
const slider = require('./components/slider/slider.cjs');
|
|
51
57
|
const sliderTickMarks = require('./components/slider/slider-tick-marks.cjs');
|
|
52
58
|
const spinner = require('./components/spinner/spinner.cjs');
|
|
@@ -74,15 +80,17 @@ const tooltip = require('./components/tooltip/tooltip.cjs');
|
|
|
74
80
|
|
|
75
81
|
exports.KeyboardKeys = keyboardKeys.KeyboardKeys;
|
|
76
82
|
exports.assertIfNullable = helpers.assertIfNullable;
|
|
83
|
+
exports.exhaustiveCheck = helpers.exhaustiveCheck;
|
|
77
84
|
exports.once = helpers.once;
|
|
78
85
|
exports.classNames = reactHelpers.classNames;
|
|
79
86
|
exports.focusElement = reactHelpers.focusElement;
|
|
87
|
+
exports.getRefElement = reactHelpers.getRefElement;
|
|
80
88
|
exports.isReactElementWithRef = reactHelpers.isReactElementWithRef;
|
|
81
89
|
exports.mergeRefs = reactHelpers.mergeRefs;
|
|
82
|
-
exports.useMountTransition = useMountTransition.useMountTransition;
|
|
83
90
|
exports.useDisableBodyScroll = useDisableBodyScroll.useDisableBodyScroll;
|
|
84
91
|
exports.useEscKeyDown = useEscKeyDown.useEscKeyDown;
|
|
85
92
|
exports.useFocusTrap = useFocusTrap.useFocusTrap;
|
|
93
|
+
exports.useMountTransition = useMountTransition.useMountTransition;
|
|
86
94
|
exports.Alert = alert.Alert;
|
|
87
95
|
exports.Avatar = avatar.Avatar;
|
|
88
96
|
exports.AvatarGroup = avatarGroup.AvatarGroup;
|
|
@@ -107,6 +115,9 @@ exports.EmptyState = emptyState.EmptyState;
|
|
|
107
115
|
exports.FilePicker = filePicker.FilePicker;
|
|
108
116
|
exports.FilterButtons = filterButtons.FilterButtons;
|
|
109
117
|
exports.FilterButton = filterButton.FilterButton;
|
|
118
|
+
exports.StringFilter = stringFilter.StringFilter;
|
|
119
|
+
exports.StringSetFilter = stringSetFilter.StringSetFilter;
|
|
120
|
+
exports.FilteredSearch = filteredSearch.FilteredSearch;
|
|
110
121
|
exports.FormField = formField.FormField;
|
|
111
122
|
exports.Label = label.Label;
|
|
112
123
|
exports.Menu = menu.Menu;
|
|
@@ -123,6 +134,9 @@ exports.Radio = radio.Radio;
|
|
|
123
134
|
exports.SegmentedControl = segmentedControl.SegmentedControl;
|
|
124
135
|
exports.Select = select.Select;
|
|
125
136
|
exports.SelectionControl = selectionControl.SelectionControl;
|
|
137
|
+
exports.SlideOver = slideOver.SlideOver;
|
|
138
|
+
exports.SlideOverHeader = slideOverHeader.SlideOverHeader;
|
|
139
|
+
exports.SlideOverBody = slideOverBody.SlideOverBody;
|
|
126
140
|
exports.Slider = slider.Slider;
|
|
127
141
|
exports.SliderTickMarks = sliderTickMarks.SliderTickMarks;
|
|
128
142
|
exports.Spinner = spinner.Spinner;
|
package/cjs/lib/helpers.cjs
CHANGED
|
@@ -11,11 +11,15 @@ function once(fn) {
|
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function exhaustiveCheck(value, message) {
|
|
15
|
+
throw new Error(message);
|
|
16
|
+
}
|
|
17
|
+
function assertIfNullable(value, message = 'assertIfNullable: value is null or undefined.') {
|
|
15
18
|
if (value == null) {
|
|
16
19
|
throw Error(message);
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
exports.assertIfNullable = assertIfNullable;
|
|
24
|
+
exports.exhaustiveCheck = exhaustiveCheck;
|
|
21
25
|
exports.once = once;
|
package/cjs/lib/index.cjs
CHANGED
|
@@ -8,8 +8,10 @@ const reactHelpers = require('./react-helpers.cjs');
|
|
|
8
8
|
|
|
9
9
|
exports.KeyboardKeys = keyboardKeys.KeyboardKeys;
|
|
10
10
|
exports.assertIfNullable = helpers.assertIfNullable;
|
|
11
|
+
exports.exhaustiveCheck = helpers.exhaustiveCheck;
|
|
11
12
|
exports.once = helpers.once;
|
|
12
13
|
exports.classNames = reactHelpers.classNames;
|
|
13
14
|
exports.focusElement = reactHelpers.focusElement;
|
|
15
|
+
exports.getRefElement = reactHelpers.getRefElement;
|
|
14
16
|
exports.isReactElementWithRef = reactHelpers.isReactElementWithRef;
|
|
15
17
|
exports.mergeRefs = reactHelpers.mergeRefs;
|
|
@@ -43,8 +43,16 @@ function focusElement(element) {
|
|
|
43
43
|
element.focus();
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
function getRefElement(ref, message = 'getElementFromRef: ref value is null.') {
|
|
47
|
+
const value = ref.current;
|
|
48
|
+
if (value == null) {
|
|
49
|
+
throw new Error(message);
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
46
53
|
|
|
47
54
|
exports.classNames = classNames;
|
|
48
55
|
exports.focusElement = focusElement;
|
|
56
|
+
exports.getRefElement = getRefElement;
|
|
49
57
|
exports.isReactElementWithRef = isReactElementWithRef;
|
|
50
58
|
exports.mergeRefs = mergeRefs;
|