@drivenets/design-system 0.18.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/index.cjs +17038 -10114
- package/dist/index.d.cts +1355 -444
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1354 -443
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17073 -10172
- package/dist/index.js.map +1 -1
- package/dist/index.min.css +1 -1
- package/package.json +41 -41
- package/src/components/ds-bot-button/ds-bot-button.figma.ts +38 -0
- package/src/components/ds-bot-button/ds-bot-button.module.scss +41 -0
- package/src/components/ds-bot-button/ds-bot-button.tsx +48 -0
- package/src/components/ds-bot-button/ds-bot-button.types.ts +33 -0
- package/src/components/ds-bot-button/index.ts +2 -0
- package/src/components/ds-bot-button/net-gen-logo.tsx +46 -0
- package/src/components/ds-bulk-actions/components/action-button.tsx +42 -0
- package/src/components/ds-bulk-actions/components/menu-entries.tsx +76 -0
- package/src/components/ds-bulk-actions/components/overflow.tsx +75 -0
- package/src/components/ds-bulk-actions/ds-bulk-actions.figma.ts +28 -0
- package/src/components/ds-bulk-actions/ds-bulk-actions.module.scss +199 -0
- package/src/components/ds-bulk-actions/ds-bulk-actions.tsx +220 -0
- package/src/components/ds-bulk-actions/ds-bulk-actions.types.ts +170 -0
- package/src/components/ds-bulk-actions/ds-bulk-actions.unit.test.ts +195 -0
- package/src/components/ds-bulk-actions/ds-bulk-actions.utils.ts +91 -0
- package/src/components/ds-bulk-actions/ds-bulk-actions.utils.unit.test.ts +134 -0
- package/src/components/ds-bulk-actions/hooks/compute-bulk-actions-overflow.ts +85 -0
- package/src/components/ds-bulk-actions/hooks/use-bulk-actions-overflow.ts +153 -0
- package/src/components/ds-bulk-actions/index.ts +18 -0
- package/src/components/ds-button-v3/ds-button-v3.module.scss +2 -2
- package/src/components/ds-catalog-layout/ds-catalog-layout.figma.ts +1 -1
- package/src/components/ds-checkbox/ds-checkbox.figma.ts +3 -0
- package/src/components/ds-checkbox/ds-checkbox.module.scss +102 -20
- package/src/components/ds-checkbox/ds-checkbox.tsx +30 -2
- package/src/components/ds-checkbox/ds-checkbox.types.ts +10 -0
- package/src/components/ds-code-input/collapsed-code-field/collapsed-code-field.module.scss +169 -0
- package/src/components/ds-code-input/collapsed-code-field/collapsed-code-field.tsx +92 -0
- package/src/components/ds-code-input/collapsed-code-field/index.ts +1 -0
- package/src/components/ds-code-input/ds-code-input-panel/ds-code-input-panel.module.scss +110 -0
- package/src/components/ds-code-input/ds-code-input-panel/ds-code-input-panel.tsx +61 -0
- package/src/components/ds-code-input/ds-code-input-panel/index.ts +1 -0
- package/src/components/ds-code-input/ds-code-input.module.scss +25 -0
- package/src/components/ds-code-input/ds-code-input.tsx +401 -0
- package/src/components/ds-code-input/ds-code-input.types.ts +166 -0
- package/src/components/ds-code-input/ds-code-input.utils.ts +94 -0
- package/src/components/ds-code-input/ds-code-input.utils.unit.test.ts +166 -0
- package/src/components/ds-code-input/index.ts +2 -0
- package/src/components/ds-code-input/use-collapsed-viewport.ts +289 -0
- package/src/components/ds-code-input/use-editor-host.ts +87 -0
- package/src/components/ds-dropdown-menu/ds-dropdown-menu.tsx +2 -0
- package/src/components/ds-empty-state/ds-empty-state.module.scss +16 -0
- package/src/components/ds-empty-state/ds-empty-state.tsx +45 -0
- package/src/components/ds-empty-state/ds-empty-state.types.ts +38 -0
- package/src/components/ds-empty-state/index.ts +3 -0
- package/src/components/ds-file-upload/ds-file-upload.tsx +4 -1
- package/src/components/ds-filters-bar/components/ds-filters-bar-builder/ds-filters-bar-builder.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-builder/ds-filters-bar-builder.types.ts +41 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-builder/index.ts +1 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-clear-all.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-conditions/ds-filters-bar-conditions.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-conditions/ds-filters-bar-conditions.types.ts +30 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-conditions/index.ts +1 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-pinned.ts +31 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-query/ds-filters-bar-query.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-query/ds-filters-bar-query.types.ts +22 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-query/index.ts +1 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-saved-filters.ts +19 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-search.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-summary.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-toolbar.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-view-switch.ts +11 -0
- package/src/components/ds-filters-bar/components/ds-filters-bar-view.ts +11 -0
- package/src/components/ds-filters-bar/components/index.ts +11 -0
- package/src/components/ds-filters-bar/ds-filters-bar.context.ts +69 -0
- package/src/components/ds-filters-bar/ds-filters-bar.tsx +120 -0
- package/src/components/ds-filters-bar/ds-filters-bar.types.ts +440 -0
- package/src/components/ds-filters-bar/ds-filters-bar.unit.test.ts +216 -0
- package/src/components/ds-filters-bar/ds-filters-bar.utils.ts +141 -0
- package/src/components/ds-filters-bar/index.ts +1 -0
- package/src/components/ds-form-control/ds-form-control.module.scss +18 -0
- package/src/components/ds-form-control/ds-form-control.tsx +61 -19
- package/src/components/ds-form-control/ds-form-control.types.ts +2 -1
- package/src/components/ds-icon/custom-icons/index.ts +2 -0
- package/src/components/ds-icon/custom-icons/special-adv-filters.tsx +28 -0
- package/src/components/ds-illustration/ds-illustration.figma.ts +34 -0
- package/src/components/ds-illustration/ds-illustration.module.scss +6 -0
- package/src/components/ds-illustration/ds-illustration.tsx +29 -0
- package/src/components/ds-illustration/ds-illustration.types.ts +45 -0
- package/src/components/ds-illustration/illustrations/configuration.tsx +51 -0
- package/src/components/ds-illustration/illustrations/device.tsx +133 -0
- package/src/components/ds-illustration/illustrations/done.tsx +107 -0
- package/src/components/{ds-catalog-layout/catalog-layout-empty-illustration.tsx → ds-illustration/illustrations/empty-inbox.tsx} +10 -14
- package/src/components/ds-illustration/illustrations/error.tsx +86 -0
- package/src/components/ds-illustration/illustrations/go-filter.tsx +51 -0
- package/src/components/ds-illustration/illustrations/illustration-clouds.tsx +10 -0
- package/src/components/ds-illustration/illustrations/index.ts +39 -0
- package/src/components/ds-illustration/illustrations/no-connection.tsx +54 -0
- package/src/components/ds-illustration/illustrations/no-credit-card.tsx +48 -0
- package/src/components/ds-illustration/illustrations/no-device.tsx +61 -0
- package/src/components/ds-illustration/illustrations/no-documents.tsx +52 -0
- package/src/components/ds-illustration/illustrations/no-gps.tsx +57 -0
- package/src/components/ds-illustration/illustrations/no-images.tsx +82 -0
- package/src/components/ds-illustration/illustrations/no-items-cart.tsx +86 -0
- package/src/components/ds-illustration/illustrations/no-messages.tsx +51 -0
- package/src/components/ds-illustration/illustrations/no-search-result.tsx +76 -0
- package/src/components/ds-illustration/illustrations/no-tasks.tsx +61 -0
- package/src/components/ds-illustration/illustrations/site.tsx +80 -0
- package/src/components/ds-illustration/index.ts +3 -0
- package/src/components/ds-main-menu/components/expanded-item/expanded-item.tsx +108 -0
- package/src/components/ds-main-menu/components/expanded-item/expanded-item.types.ts +8 -0
- package/src/components/ds-main-menu/components/expanded-item/index.ts +1 -0
- package/src/components/ds-main-menu/components/menu-graphic/index.ts +1 -0
- package/src/components/ds-main-menu/components/menu-graphic/menu-graphic.tsx +16 -0
- package/src/components/ds-main-menu/components/menu-graphic/menu-graphic.types.ts +7 -0
- package/src/components/ds-main-menu/components/tile-link/index.ts +1 -0
- package/src/components/ds-main-menu/components/tile-link/tile-link.tsx +85 -0
- package/src/components/ds-main-menu/components/tile-link/tile-link.types.ts +8 -0
- package/src/components/ds-main-menu/components/utility-link/index.ts +1 -0
- package/src/components/ds-main-menu/components/utility-link/utility-link.tsx +37 -0
- package/src/components/ds-main-menu/components/utility-link/utility-link.types.ts +7 -0
- package/src/components/ds-main-menu/ds-main-menu.figma.ts +17 -0
- package/src/components/ds-main-menu/ds-main-menu.module.scss +349 -0
- package/src/components/ds-main-menu/ds-main-menu.tsx +102 -0
- package/src/components/ds-main-menu/ds-main-menu.types.ts +86 -0
- package/src/components/ds-main-menu/ds-main-menu.utils.ts +40 -0
- package/src/components/ds-main-menu/index.ts +9 -0
- package/src/components/ds-modal/figma/ds-modal-footer.figma.ts +1 -1
- package/src/components/ds-pin-toggle/ds-pin-toggle.figma.ts +27 -0
- package/src/components/ds-pin-toggle/ds-pin-toggle.module.scss +41 -0
- package/src/components/ds-pin-toggle/ds-pin-toggle.tsx +43 -0
- package/src/components/ds-pin-toggle/ds-pin-toggle.types.ts +29 -0
- package/src/components/ds-pin-toggle/index.ts +2 -0
- package/src/components/ds-popover/components/popover-trigger/index.ts +1 -0
- package/src/components/ds-popover/components/popover-trigger/popover-trigger.tsx +15 -0
- package/src/components/ds-popover/ds-popover.context.ts +18 -0
- package/src/components/ds-popover/ds-popover.hover-intent.ts +65 -0
- package/src/components/ds-popover/ds-popover.tsx +164 -41
- package/src/components/ds-popover/ds-popover.types.ts +65 -0
- package/src/components/ds-popover/ds-popover.utils.ts +60 -0
- package/src/components/ds-popover/ds-popover.utils.unit.test.ts +25 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-delete-confirm.tsx +53 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-name-entry.tsx +64 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-name-modal.tsx +50 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-row/ds-saved-filters-row.module.scss +68 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-row/ds-saved-filters-row.tsx +83 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-row/index.ts +1 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-save.tsx +164 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-trigger/ds-saved-filters-trigger.module.scss +21 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-trigger/ds-saved-filters-trigger.tsx +237 -0
- package/src/components/ds-saved-filters/components/ds-saved-filters-trigger/index.ts +1 -0
- package/src/components/ds-saved-filters/components/index.ts +2 -0
- package/src/components/ds-saved-filters/ds-saved-filters.ts +6 -0
- package/src/components/ds-saved-filters/ds-saved-filters.types.ts +106 -0
- package/src/components/ds-saved-filters/ds-saved-filters.utils.ts +35 -0
- package/src/components/ds-saved-filters/hooks/index.ts +1 -0
- package/src/components/ds-saved-filters/hooks/use-picker-outside-dismiss.ts +42 -0
- package/src/components/ds-saved-filters/index.ts +2 -0
- package/src/components/ds-segment-group/ds-segment-group.module.scss +65 -37
- package/src/components/ds-segment-group/ds-segment-group.tsx +17 -5
- package/src/components/ds-segment-group/ds-segment-group.types.ts +20 -5
- package/src/components/ds-segment-group/figma/ds-segment-group-v2-item.figma.ts +109 -0
- package/src/components/ds-segment-group/figma/ds-segment-group-v2.figma.ts +31 -0
- package/src/components/ds-site-node/ds-site-node.tsx +2 -2
- package/src/components/ds-table/components/ds-table-body-virtualized/ds-table-body-virtualized.module.scss +12 -2
- package/src/components/ds-table/components/ds-table-body-virtualized/ds-table-body-virtualized.tsx +2 -3
- package/src/components/ds-table/components/ds-table-group-header-cell/ds-table-group-header-cell.module.scss +1 -6
- package/src/components/ds-table/components/ds-table-group-header-cell/ds-table-group-header-cell.tsx +6 -3
- package/src/components/ds-table/components/ds-table-header/ds-table-header.module.scss +18 -7
- package/src/components/ds-table/components/ds-table-header/ds-table-header.tsx +27 -21
- package/src/components/ds-table/components/ds-table-header-label.module.scss +12 -0
- package/src/components/ds-table/components/ds-table-header-label.tsx +28 -0
- package/src/components/ds-table/components/ds-table-row/ds-table-row.module.scss +0 -1
- package/src/components/ds-table/context/ds-table-context.tsx +8 -0
- package/src/components/ds-table/ds-table.module.scss +26 -16
- package/src/components/ds-table/ds-table.tsx +46 -14
- package/src/components/ds-table/ds-table.types.ts +33 -3
- package/src/components/ds-table/hooks/use-column-resize.ts +114 -11
- package/src/components/ds-table/hooks/use-scrollbar-spacer.ts +108 -0
- package/src/components/ds-table/hooks/use-scrollbar-spacer.unit.test.ts +26 -0
- package/src/components/ds-table/styles/_variables.scss +0 -2
- package/src/components/ds-table/utils/column-size.ts +274 -1
- package/src/components/ds-table/utils/column-size.unit.test.ts +157 -0
- package/src/components/ds-table/utils/constants.ts +13 -5
- package/src/components/ds-table/utils/table-columns.tsx +27 -13
- package/src/components/ds-table/utils/table-columns.unit.test.ts +44 -0
- package/src/components/ds-tag/ds-tag.figma.ts +23 -3
- package/src/components/ds-tag/ds-tag.module.scss +71 -7
- package/src/components/ds-tag/ds-tag.tsx +115 -14
- package/src/components/ds-tag/ds-tag.types.ts +70 -3
- package/src/components/ds-tag/ds-tag.unit.test.ts +23 -4
- package/src/components/ds-tag/index.ts +2 -2
- package/src/components/ds-text-input/ds-input-field-v02.figma.ts +2 -0
- package/src/components/ds-toggle/ds-toggle.module.scss +18 -0
- package/src/components/ds-toggle/ds-toggle.tsx +15 -9
- package/src/components/ds-toggle/ds-toggle.types.ts +6 -0
- package/src/components/ds-toggle-filter-data/ds-toggle-filter-data.module.scss +69 -0
- package/src/components/ds-toggle-filter-data/ds-toggle-filter-data.tsx +55 -0
- package/src/components/ds-toggle-filter-data/ds-toggle-filter-data.types.ts +43 -0
- package/src/components/ds-toggle-filter-data/index.ts +1 -0
- package/src/components/ds-tooltip/ds-tooltip.module.scss +8 -0
- package/src/components/ds-tooltip/ds-tooltip.tsx +7 -3
- package/src/components/ds-tooltip/ds-tooltip.types.ts +17 -0
- package/src/components/ds-top-bar-navigation/ds-top-bar-navigation.figma.ts +35 -0
- package/src/components/ds-top-bar-navigation/ds-top-bar-navigation.module.scss +150 -0
- package/src/components/ds-top-bar-navigation/ds-top-bar-navigation.tsx +161 -0
- package/src/components/ds-top-bar-navigation/ds-top-bar-navigation.types.ts +117 -0
- package/src/components/ds-top-bar-navigation/index.ts +2 -0
- package/src/components/ds-tree/ds-tree.tsx +10 -10
- package/src/components/ds-tree/ds-tree.types.ts +40 -7
- package/src/index.ts +8 -0
- package/src/utils/use-is-horizontally-overflowing.ts +35 -0
- package/src/components/ds-site-node/hooks/use-is-overflowing.ts +0 -31
- package/src/components/ds-table/components/ds-table-bulk-actions/ds-table-bulk-actions.module.scss +0 -112
- package/src/components/ds-table/components/ds-table-bulk-actions/ds-table-bulk-actions.tsx +0 -67
- package/src/components/ds-table/components/ds-table-bulk-actions/ds-table-bulk-actions.types.ts +0 -41
- package/src/components/ds-table/components/ds-table-bulk-actions/index.ts +0 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DsPopoverAlign, DsPopoverSide } from './ds-popover.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Collapses a side plus alignment into the single placement string Ark expects.
|
|
5
|
+
* `center` is the implicit alignment, so it carries no suffix.
|
|
6
|
+
*/
|
|
7
|
+
export const toPlacement = (side: DsPopoverSide, align: DsPopoverAlign) =>
|
|
8
|
+
align === 'center' ? side : (`${side}-${align}` as const);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether a pointer can hover at all. Touch fires enter/leave around a tap, which
|
|
12
|
+
* would open and immediately re-toggle the panel — on those the click owns opening.
|
|
13
|
+
*/
|
|
14
|
+
export const isHoverPointer = (pointerType: string) => pointerType !== 'touch';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Adapts a cancelable DS focus handler into Ark's `initialFocusEl` / `finalFocusEl`.
|
|
18
|
+
* `preventDefault` keeps the current focus; otherwise Ark picks the default target.
|
|
19
|
+
*/
|
|
20
|
+
export const toFocusEl = (handler: ((event: Event) => void) | undefined, eventName: string) =>
|
|
21
|
+
handler
|
|
22
|
+
? () => {
|
|
23
|
+
const event = new Event(eventName, { cancelable: true });
|
|
24
|
+
handler(event);
|
|
25
|
+
|
|
26
|
+
return event.defaultPrevented ? (document.activeElement as HTMLElement | null) : undefined;
|
|
27
|
+
}
|
|
28
|
+
: undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Body and the document element dump keyboard users at the top of the page,
|
|
32
|
+
* so they are not useful restore targets.
|
|
33
|
+
*/
|
|
34
|
+
const isRestorableFocusTarget = (el: EventTarget | null): el is HTMLElement =>
|
|
35
|
+
el instanceof HTMLElement && el.isConnected && el !== document.body && el !== document.documentElement;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Runs `onCloseAutoFocus` when Ark's restore is disabled. If the handler
|
|
39
|
+
* prevents default, focus stays on the element that had it at close time.
|
|
40
|
+
*/
|
|
41
|
+
export const invokeCloseAutoFocus = (handler: (event: Event) => void) => {
|
|
42
|
+
const event = new Event('closeAutoFocus', { cancelable: true });
|
|
43
|
+
handler(event);
|
|
44
|
+
|
|
45
|
+
if (!event.defaultPrevented) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const focused = document.activeElement;
|
|
50
|
+
|
|
51
|
+
if (!isRestorableFocusTarget(focused)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
requestAnimationFrame(() => {
|
|
56
|
+
if (focused.isConnected) {
|
|
57
|
+
focused.focus({ preventScroll: true });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { isHoverPointer, toPlacement } from './ds-popover.utils';
|
|
3
|
+
|
|
4
|
+
describe('toPlacement', () => {
|
|
5
|
+
it('joins side and alignment', () => {
|
|
6
|
+
expect(toPlacement('right', 'start')).toBe('right-start');
|
|
7
|
+
expect(toPlacement('top', 'end')).toBe('top-end');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('drops the suffix for the implicit center alignment', () => {
|
|
11
|
+
expect(toPlacement('bottom', 'center')).toBe('bottom');
|
|
12
|
+
expect(toPlacement('left', 'center')).toBe('left');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('isHoverPointer', () => {
|
|
17
|
+
it('accepts pointers that can hover', () => {
|
|
18
|
+
expect(isHoverPointer('mouse')).toBe(true);
|
|
19
|
+
expect(isHoverPointer('pen')).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('rejects touch, so a tap stays a plain click', () => {
|
|
23
|
+
expect(isHoverPointer('touch')).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DsButtonV3 } from '../../ds-button-v3';
|
|
2
|
+
import { DsModal } from '../../ds-modal';
|
|
3
|
+
import { DsTypography } from '../../ds-typography';
|
|
4
|
+
import {
|
|
5
|
+
interpolateName,
|
|
6
|
+
NAME_MODAL_COLUMNS,
|
|
7
|
+
type Locale,
|
|
8
|
+
type NamedTarget,
|
|
9
|
+
} from '../ds-saved-filters.utils';
|
|
10
|
+
|
|
11
|
+
export const DeleteConfirm = ({
|
|
12
|
+
target,
|
|
13
|
+
locale,
|
|
14
|
+
loading,
|
|
15
|
+
onConfirm,
|
|
16
|
+
onClose,
|
|
17
|
+
}: {
|
|
18
|
+
target: NamedTarget;
|
|
19
|
+
locale: Locale;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
onConfirm: () => void;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
}) => (
|
|
24
|
+
<DsModal
|
|
25
|
+
open
|
|
26
|
+
columns={NAME_MODAL_COLUMNS}
|
|
27
|
+
onOpenChange={(next) => {
|
|
28
|
+
if (!next && !loading) {
|
|
29
|
+
onClose();
|
|
30
|
+
}
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<DsModal.Header>
|
|
34
|
+
<DsModal.Title>{locale.deleteTitle}</DsModal.Title>
|
|
35
|
+
<DsModal.CloseTrigger />
|
|
36
|
+
</DsModal.Header>
|
|
37
|
+
<DsModal.Body>
|
|
38
|
+
<DsTypography variant="body-md-reg">{interpolateName(locale.deleteMessage, target.name)}</DsTypography>
|
|
39
|
+
</DsModal.Body>
|
|
40
|
+
<DsModal.Footer>
|
|
41
|
+
<DsModal.Actions>
|
|
42
|
+
<DsButtonV3 variant="secondary" size="small" disabled={loading} onClick={onClose}>
|
|
43
|
+
{locale.cancel}
|
|
44
|
+
</DsButtonV3>
|
|
45
|
+
<DsButtonV3 color="error" size="small" loading={loading} onClick={onConfirm}>
|
|
46
|
+
{locale.deleteConfirm}
|
|
47
|
+
</DsButtonV3>
|
|
48
|
+
</DsModal.Actions>
|
|
49
|
+
</DsModal.Footer>
|
|
50
|
+
</DsModal>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
DeleteConfirm.displayName = 'DeleteConfirm';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { DsButtonV3 } from '../../ds-button-v3';
|
|
3
|
+
import { DsFormControl } from '../../ds-form-control';
|
|
4
|
+
import { DsStack } from '../../ds-stack';
|
|
5
|
+
|
|
6
|
+
interface NameEntryFieldsProps {
|
|
7
|
+
initialName?: string;
|
|
8
|
+
nameLabel: string;
|
|
9
|
+
confirmLabel: string;
|
|
10
|
+
cancelLabel: string;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
onSubmit: (name: string) => void;
|
|
13
|
+
onCancel: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const NameEntryFields = ({
|
|
17
|
+
initialName = '',
|
|
18
|
+
nameLabel,
|
|
19
|
+
confirmLabel,
|
|
20
|
+
cancelLabel,
|
|
21
|
+
loading = false,
|
|
22
|
+
onSubmit,
|
|
23
|
+
onCancel,
|
|
24
|
+
}: NameEntryFieldsProps) => {
|
|
25
|
+
const [name, setName] = useState(initialName);
|
|
26
|
+
const trimmed = name.trim();
|
|
27
|
+
const confirmDisabled = trimmed.length === 0;
|
|
28
|
+
|
|
29
|
+
const handleSubmit = () => {
|
|
30
|
+
if (confirmDisabled || loading) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onSubmit(trimmed);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<DsStack direction="column" gap="var(--sm)">
|
|
39
|
+
<DsFormControl label={nameLabel}>
|
|
40
|
+
<DsFormControl.TextInput
|
|
41
|
+
value={name}
|
|
42
|
+
disabled={loading}
|
|
43
|
+
onValueChange={setName}
|
|
44
|
+
onKeyDown={(event) => {
|
|
45
|
+
if (event.key === 'Enter') {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
handleSubmit();
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
</DsFormControl>
|
|
52
|
+
<DsStack direction="row" gap="var(--xs)" justifyContent="flex-end">
|
|
53
|
+
<DsButtonV3 variant="secondary" size="small" disabled={loading} onClick={onCancel}>
|
|
54
|
+
{cancelLabel}
|
|
55
|
+
</DsButtonV3>
|
|
56
|
+
<DsButtonV3 size="small" disabled={confirmDisabled} loading={loading} onClick={handleSubmit}>
|
|
57
|
+
{confirmLabel}
|
|
58
|
+
</DsButtonV3>
|
|
59
|
+
</DsStack>
|
|
60
|
+
</DsStack>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
NameEntryFields.displayName = 'NameEntryFields';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DsModal } from '../../ds-modal';
|
|
2
|
+
import { NAME_MODAL_COLUMNS, type Locale } from '../ds-saved-filters.utils';
|
|
3
|
+
import { NameEntryFields } from './ds-saved-filters-name-entry';
|
|
4
|
+
|
|
5
|
+
export const NameModal = ({
|
|
6
|
+
title,
|
|
7
|
+
initialName,
|
|
8
|
+
entryKey,
|
|
9
|
+
locale,
|
|
10
|
+
loading,
|
|
11
|
+
onSubmit,
|
|
12
|
+
onClose,
|
|
13
|
+
}: {
|
|
14
|
+
title: string;
|
|
15
|
+
initialName: string;
|
|
16
|
+
entryKey: string;
|
|
17
|
+
locale: Locale;
|
|
18
|
+
loading: boolean;
|
|
19
|
+
onSubmit: (name: string) => void;
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
}) => (
|
|
22
|
+
<DsModal
|
|
23
|
+
open
|
|
24
|
+
columns={NAME_MODAL_COLUMNS}
|
|
25
|
+
onOpenChange={(next) => {
|
|
26
|
+
if (!next && !loading) {
|
|
27
|
+
onClose();
|
|
28
|
+
}
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<DsModal.Header>
|
|
32
|
+
<DsModal.Title>{title}</DsModal.Title>
|
|
33
|
+
<DsModal.CloseTrigger />
|
|
34
|
+
</DsModal.Header>
|
|
35
|
+
<DsModal.Body>
|
|
36
|
+
<NameEntryFields
|
|
37
|
+
key={entryKey}
|
|
38
|
+
initialName={initialName}
|
|
39
|
+
nameLabel={locale.nameLabel}
|
|
40
|
+
confirmLabel={locale.confirm}
|
|
41
|
+
cancelLabel={locale.cancel}
|
|
42
|
+
loading={loading}
|
|
43
|
+
onSubmit={onSubmit}
|
|
44
|
+
onCancel={onClose}
|
|
45
|
+
/>
|
|
46
|
+
</DsModal.Body>
|
|
47
|
+
</DsModal>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
NameModal.displayName = 'NameModal';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
$count-dot-size: 8px;
|
|
2
|
+
|
|
3
|
+
.row {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: var(--xs);
|
|
7
|
+
width: 100%;
|
|
8
|
+
min-height: 20px;
|
|
9
|
+
border-radius: var(--3xs);
|
|
10
|
+
|
|
11
|
+
&[data-selected] {
|
|
12
|
+
min-height: 26px;
|
|
13
|
+
padding-block: var(--3xs);
|
|
14
|
+
background: var(--background-primary-subtle-hover);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
background: var(--background-primary-subtle-hover);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.rowMain {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex: 1;
|
|
25
|
+
gap: var(--3xs);
|
|
26
|
+
align-items: center;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
padding: 0;
|
|
29
|
+
border: none;
|
|
30
|
+
background: transparent;
|
|
31
|
+
text-align: start;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
color: inherit;
|
|
34
|
+
|
|
35
|
+
&:focus-visible {
|
|
36
|
+
outline: 2px solid var(--border-action-primary);
|
|
37
|
+
outline-offset: 2px;
|
|
38
|
+
border-radius: var(--3xs);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.rowName {
|
|
43
|
+
min-width: 0;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.rowMeta {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
gap: var(--xs);
|
|
53
|
+
align-items: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.count {
|
|
57
|
+
display: flex;
|
|
58
|
+
gap: var(--3xs);
|
|
59
|
+
align-items: center;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.countDot {
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
width: $count-dot-size;
|
|
65
|
+
height: $count-dot-size;
|
|
66
|
+
border-radius: 9999px;
|
|
67
|
+
background: var(--color-dap-blue-700);
|
|
68
|
+
}
|
package/src/components/ds-saved-filters/components/ds-saved-filters-row/ds-saved-filters-row.tsx
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { MouseEvent } from 'react';
|
|
2
|
+
import { DsButtonV3 } from '../../../ds-button-v3';
|
|
3
|
+
import { DsDropdownMenu } from '../../../ds-dropdown-menu';
|
|
4
|
+
import { DsIcon } from '../../../ds-icon';
|
|
5
|
+
import { DsTypography } from '../../../ds-typography';
|
|
6
|
+
import styles from './ds-saved-filters-row.module.scss';
|
|
7
|
+
import type { DsSavedFilterItem } from '../../ds-saved-filters.types';
|
|
8
|
+
import { PICKER_GUTTER_PX, type Locale, type NamedTarget } from '../../ds-saved-filters.utils';
|
|
9
|
+
|
|
10
|
+
export const SavedFilterRow = ({
|
|
11
|
+
item,
|
|
12
|
+
selected,
|
|
13
|
+
blocked,
|
|
14
|
+
locale,
|
|
15
|
+
onApply,
|
|
16
|
+
onRename,
|
|
17
|
+
onDelete,
|
|
18
|
+
}: {
|
|
19
|
+
item: DsSavedFilterItem;
|
|
20
|
+
selected: boolean;
|
|
21
|
+
blocked: boolean;
|
|
22
|
+
locale: Locale;
|
|
23
|
+
onApply: (id: string) => void;
|
|
24
|
+
onRename: (target: NamedTarget) => void;
|
|
25
|
+
onDelete: (target: NamedTarget) => void;
|
|
26
|
+
}) => (
|
|
27
|
+
<div className={styles.row} data-selected={selected ? '' : undefined}>
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
className={styles.rowMain}
|
|
31
|
+
aria-pressed={selected}
|
|
32
|
+
aria-disabled={blocked || undefined}
|
|
33
|
+
onClick={() => {
|
|
34
|
+
if (blocked) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
onApply(item.id);
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<DsIcon icon="bookmark" size="small" filled={selected} />
|
|
42
|
+
<DsTypography variant="body-sm-reg" className={styles.rowName}>
|
|
43
|
+
{item.name}
|
|
44
|
+
</DsTypography>
|
|
45
|
+
</button>
|
|
46
|
+
<div className={styles.rowMeta}>
|
|
47
|
+
{item.count !== undefined && (
|
|
48
|
+
<span className={styles.count}>
|
|
49
|
+
<span className={styles.countDot} />
|
|
50
|
+
<DsTypography variant="body-xs-semi-bold">{item.count}</DsTypography>
|
|
51
|
+
</span>
|
|
52
|
+
)}
|
|
53
|
+
<DsDropdownMenu.Root positioning={{ placement: 'bottom-end', gutter: PICKER_GUTTER_PX }}>
|
|
54
|
+
<DsDropdownMenu.Trigger asChild>
|
|
55
|
+
<DsButtonV3
|
|
56
|
+
variant="tertiary"
|
|
57
|
+
size="tiny"
|
|
58
|
+
icon="more_vert"
|
|
59
|
+
aria-label={`${locale.rowActions}: ${item.name}`}
|
|
60
|
+
disabled={blocked}
|
|
61
|
+
onClick={(event: MouseEvent<HTMLButtonElement>) => event.stopPropagation()}
|
|
62
|
+
/>
|
|
63
|
+
</DsDropdownMenu.Trigger>
|
|
64
|
+
<DsDropdownMenu.Content>
|
|
65
|
+
<DsDropdownMenu.Item value="rename" onClick={() => onRename({ id: item.id, name: item.name })}>
|
|
66
|
+
<DsIcon icon="edit" size="small" />
|
|
67
|
+
{locale.renameFilter}
|
|
68
|
+
</DsDropdownMenu.Item>
|
|
69
|
+
<DsDropdownMenu.Item
|
|
70
|
+
value="delete"
|
|
71
|
+
variant="error"
|
|
72
|
+
onClick={() => onDelete({ id: item.id, name: item.name })}
|
|
73
|
+
>
|
|
74
|
+
<DsIcon icon="delete" size="small" />
|
|
75
|
+
{locale.deleteFilter}
|
|
76
|
+
</DsDropdownMenu.Item>
|
|
77
|
+
</DsDropdownMenu.Content>
|
|
78
|
+
</DsDropdownMenu.Root>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
SavedFilterRow.displayName = 'SavedFilterRow';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SavedFilterRow } from './ds-saved-filters-row';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { DsButtonV3 } from '../../ds-button-v3';
|
|
3
|
+
import { DsDropdownMenu } from '../../ds-dropdown-menu';
|
|
4
|
+
import { DsPopover } from '../../ds-popover';
|
|
5
|
+
import type { DsSavedFiltersSaveProps } from '../ds-saved-filters.types';
|
|
6
|
+
import {
|
|
7
|
+
interpolateName,
|
|
8
|
+
isThenable,
|
|
9
|
+
PICKER_GUTTER_PX,
|
|
10
|
+
resolveLocale,
|
|
11
|
+
runMaybeAsync,
|
|
12
|
+
} from '../ds-saved-filters.utils';
|
|
13
|
+
import { NameEntryFields } from './ds-saved-filters-name-entry';
|
|
14
|
+
import { NameModal } from './ds-saved-filters-name-modal';
|
|
15
|
+
|
|
16
|
+
const NAME_POPOVER_WIDTH_PX = 320;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @summary Save control for the current filter document: update or save as new.
|
|
20
|
+
*
|
|
21
|
+
* Internal to the filters component and not exported from the package.
|
|
22
|
+
*/
|
|
23
|
+
export const DsSavedFiltersSave = ({
|
|
24
|
+
items,
|
|
25
|
+
value,
|
|
26
|
+
disabled = false,
|
|
27
|
+
locale: localeProp,
|
|
28
|
+
ref,
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
onUpdate,
|
|
32
|
+
onSaveAs,
|
|
33
|
+
}: DsSavedFiltersSaveProps) => {
|
|
34
|
+
const locale = resolveLocale(localeProp);
|
|
35
|
+
const [nameOpen, setNameOpen] = useState(false);
|
|
36
|
+
const [saveAsOpen, setSaveAsOpen] = useState(false);
|
|
37
|
+
const [updating, setUpdating] = useState(false);
|
|
38
|
+
const [savingAs, setSavingAs] = useState(false);
|
|
39
|
+
const activeItem = items.find((item) => item.id === value);
|
|
40
|
+
const saveBusy = updating || savingAs;
|
|
41
|
+
|
|
42
|
+
const handleUpdate = async () => {
|
|
43
|
+
if (saveBusy) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
await runMaybeAsync(onUpdate(), setUpdating);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const handleSaveAs = async (name: string) => {
|
|
51
|
+
if (saveBusy) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const result = onSaveAs(name);
|
|
56
|
+
|
|
57
|
+
if (!isThenable(result)) {
|
|
58
|
+
setSaveAsOpen(false);
|
|
59
|
+
setNameOpen(false);
|
|
60
|
+
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setSavingAs(true);
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
await result;
|
|
68
|
+
setSaveAsOpen(false);
|
|
69
|
+
setNameOpen(false);
|
|
70
|
+
} catch {
|
|
71
|
+
// Overlay stays open; the consumer handles the error.
|
|
72
|
+
} finally {
|
|
73
|
+
setSavingAs(false);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const saveButton = (
|
|
78
|
+
<DsButtonV3
|
|
79
|
+
ref={ref}
|
|
80
|
+
className={className}
|
|
81
|
+
style={style}
|
|
82
|
+
variant="tertiary"
|
|
83
|
+
size="small"
|
|
84
|
+
icon="bookmark_add"
|
|
85
|
+
disabled={disabled}
|
|
86
|
+
loading={updating}
|
|
87
|
+
>
|
|
88
|
+
{locale.saveFilter}
|
|
89
|
+
</DsButtonV3>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
if (activeItem) {
|
|
93
|
+
return (
|
|
94
|
+
<>
|
|
95
|
+
<DsDropdownMenu.Root>
|
|
96
|
+
<DsDropdownMenu.Trigger asChild>{saveButton}</DsDropdownMenu.Trigger>
|
|
97
|
+
<DsDropdownMenu.Content>
|
|
98
|
+
<DsDropdownMenu.Item value="update" disabled={saveBusy} onClick={handleUpdate}>
|
|
99
|
+
{interpolateName(locale.updateFilter, activeItem.name)}
|
|
100
|
+
</DsDropdownMenu.Item>
|
|
101
|
+
<DsDropdownMenu.Item value="saveAs" disabled={saveBusy} onClick={() => setSaveAsOpen(true)}>
|
|
102
|
+
{locale.saveAsNew}
|
|
103
|
+
</DsDropdownMenu.Item>
|
|
104
|
+
</DsDropdownMenu.Content>
|
|
105
|
+
</DsDropdownMenu.Root>
|
|
106
|
+
{saveAsOpen ? (
|
|
107
|
+
<NameModal
|
|
108
|
+
title={locale.saveAsTitle}
|
|
109
|
+
initialName=""
|
|
110
|
+
entryKey="saveAs"
|
|
111
|
+
locale={locale}
|
|
112
|
+
loading={savingAs}
|
|
113
|
+
onSubmit={handleSaveAs}
|
|
114
|
+
onClose={() => {
|
|
115
|
+
if (!savingAs) {
|
|
116
|
+
setSaveAsOpen(false);
|
|
117
|
+
}
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
) : null}
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<DsPopover.Root
|
|
127
|
+
open={nameOpen}
|
|
128
|
+
side="bottom"
|
|
129
|
+
align="start"
|
|
130
|
+
gutter={PICKER_GUTTER_PX}
|
|
131
|
+
onOpenChange={(next) => {
|
|
132
|
+
if (savingAs) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setNameOpen(next);
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<DsPopover.Trigger>{saveButton}</DsPopover.Trigger>
|
|
140
|
+
<DsPopover.Panel width={NAME_POPOVER_WIDTH_PX}>
|
|
141
|
+
<DsPopover.Header>{locale.saveAsTitle}</DsPopover.Header>
|
|
142
|
+
<DsPopover.Content>
|
|
143
|
+
{nameOpen ? (
|
|
144
|
+
<NameEntryFields
|
|
145
|
+
key="save-popover"
|
|
146
|
+
nameLabel={locale.nameLabel}
|
|
147
|
+
confirmLabel={locale.confirm}
|
|
148
|
+
cancelLabel={locale.cancel}
|
|
149
|
+
loading={savingAs}
|
|
150
|
+
onSubmit={handleSaveAs}
|
|
151
|
+
onCancel={() => {
|
|
152
|
+
if (!savingAs) {
|
|
153
|
+
setNameOpen(false);
|
|
154
|
+
}
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
) : null}
|
|
158
|
+
</DsPopover.Content>
|
|
159
|
+
</DsPopover.Panel>
|
|
160
|
+
</DsPopover.Root>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
DsSavedFiltersSave.displayName = 'DsSavedFilters.Save';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.pickerHeader {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
width: 100%;
|
|
5
|
+
border-bottom: 1px solid var(--border);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.pickerTitle {
|
|
9
|
+
flex: 1;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
border-bottom: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.pickerClose {
|
|
15
|
+
flex-shrink: 0;
|
|
16
|
+
margin-inline-end: var(--sm);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.pickerContent {
|
|
20
|
+
padding: var(--standard);
|
|
21
|
+
}
|