@drivenets/design-system 0.18.1 → 0.19.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 +20 -0
- package/dist/index.cjs +17138 -12075
- package/dist/index.d.cts +783 -238
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +783 -238
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17123 -12076
- package/dist/index.js.map +1 -1
- package/dist/index.min.css +1 -1
- package/package.json +15 -15
- 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-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-form-control/ds-form-control.tsx +18 -10
- 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-popover/ds-popover.tsx +2 -1
- package/src/components/ds-popover/ds-popover.types.ts +7 -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-toggle/ds-toggle.module.scss +18 -0
- package/src/components/ds-toggle/ds-toggle.tsx +15 -13
- package/src/components/ds-tooltip/ds-tooltip.tsx +6 -2
- 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/index.ts +6 -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,161 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import styles from './ds-top-bar-navigation.module.scss';
|
|
3
|
+
import { DsAvatar } from '../ds-avatar';
|
|
4
|
+
import { DsButtonV3 } from '../ds-button-v3';
|
|
5
|
+
import { DsDropdownMenu } from '../ds-dropdown-menu';
|
|
6
|
+
import { DsIcon } from '../ds-icon';
|
|
7
|
+
import {
|
|
8
|
+
notificationCountCap,
|
|
9
|
+
type DsTopBarNavigationActionsProps,
|
|
10
|
+
type DsTopBarNavigationBreadcrumbProps,
|
|
11
|
+
type DsTopBarNavigationCenterProps,
|
|
12
|
+
type DsTopBarNavigationLogoProps,
|
|
13
|
+
type DsTopBarNavigationNotificationsProps,
|
|
14
|
+
type DsTopBarNavigationProps,
|
|
15
|
+
type DsTopBarNavigationUserMenuProps,
|
|
16
|
+
} from './ds-top-bar-navigation.types';
|
|
17
|
+
|
|
18
|
+
const DEFAULT_LOCALE = Object.freeze({
|
|
19
|
+
appsButtonLabel: 'Apps',
|
|
20
|
+
notificationsButtonLabel: 'Notifications',
|
|
21
|
+
notificationsButtonLabelWithCount: (count: number) => `Notifications, ${String(count)} unread`,
|
|
22
|
+
userMenuButtonLabel: (name: string) => `Account menu for ${name}`,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const DEFAULT_USER_MENU_POSITIONING = Object.freeze({ placement: 'bottom-end' } as const);
|
|
26
|
+
|
|
27
|
+
const DsTopBarNavigationRoot = ({ className, ...rest }: DsTopBarNavigationProps) => (
|
|
28
|
+
<div {...rest} className={classNames(styles.root, className)} />
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const Logo = ({
|
|
32
|
+
className,
|
|
33
|
+
logo,
|
|
34
|
+
wordmark,
|
|
35
|
+
href,
|
|
36
|
+
locale,
|
|
37
|
+
onLogoClick,
|
|
38
|
+
onAppsClick,
|
|
39
|
+
appsMenu,
|
|
40
|
+
...rest
|
|
41
|
+
}: DsTopBarNavigationLogoProps) => {
|
|
42
|
+
const lockup = (
|
|
43
|
+
<>
|
|
44
|
+
{logo ? <span className={styles.logoGlyph}>{logo}</span> : null}
|
|
45
|
+
{wordmark ? <span className={styles.logoWordmark}>{wordmark}</span> : null}
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div {...rest} className={classNames(styles.logo, className)}>
|
|
51
|
+
{href ? (
|
|
52
|
+
<a className={styles.logoLockup} href={href} aria-label={locale?.homeLinkLabel} onClick={onLogoClick}>
|
|
53
|
+
{lockup}
|
|
54
|
+
</a>
|
|
55
|
+
) : (
|
|
56
|
+
<span className={styles.logoLockup}>{lockup}</span>
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
{appsMenu}
|
|
60
|
+
|
|
61
|
+
{!appsMenu && onAppsClick ? (
|
|
62
|
+
<DsButtonV3
|
|
63
|
+
variant="tertiary"
|
|
64
|
+
color="light"
|
|
65
|
+
size="small"
|
|
66
|
+
icon="apps"
|
|
67
|
+
aria-label={locale?.appsButtonLabel ?? DEFAULT_LOCALE.appsButtonLabel}
|
|
68
|
+
onClick={onAppsClick}
|
|
69
|
+
/>
|
|
70
|
+
) : null}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const Breadcrumb = ({ className, ...rest }: DsTopBarNavigationBreadcrumbProps) => (
|
|
76
|
+
<div {...rest} className={classNames(styles.breadcrumb, className)} />
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
/** Reserved zone between the breadcrumb trail and the actions. Empty by design today. */
|
|
80
|
+
const Center = ({ className, ...rest }: DsTopBarNavigationCenterProps) => (
|
|
81
|
+
<div {...rest} className={classNames(styles.center, className)} />
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const Actions = ({ className, ...rest }: DsTopBarNavigationActionsProps) => (
|
|
85
|
+
<div {...rest} className={classNames(styles.actions, className)} />
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const Notifications = ({ count = 0, locale, ...rest }: DsTopBarNavigationNotificationsProps) => {
|
|
89
|
+
const hasCount = count > 0;
|
|
90
|
+
const label = hasCount
|
|
91
|
+
? (locale?.notificationsButtonLabelWithCount ?? DEFAULT_LOCALE.notificationsButtonLabelWithCount)(count)
|
|
92
|
+
: (locale?.notificationsButtonLabel ?? DEFAULT_LOCALE.notificationsButtonLabel);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<DsButtonV3 {...rest} variant="tertiary" size="small" icon="notifications_active" aria-label={label}>
|
|
96
|
+
{/*
|
|
97
|
+
Always rendered so DsButtonV3 never switches to its icon-only geometry,
|
|
98
|
+
which would re-pad the bell when the count clears.
|
|
99
|
+
*/}
|
|
100
|
+
<span className={styles.notificationsBadge} aria-hidden data-empty={hasCount ? undefined : ''}>
|
|
101
|
+
{count > notificationCountCap ? `${String(notificationCountCap)}+` : count}
|
|
102
|
+
</span>
|
|
103
|
+
</DsButtonV3>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const UserMenu = ({
|
|
108
|
+
className,
|
|
109
|
+
name,
|
|
110
|
+
src,
|
|
111
|
+
children,
|
|
112
|
+
open,
|
|
113
|
+
positioning,
|
|
114
|
+
locale,
|
|
115
|
+
onOpenChange,
|
|
116
|
+
onSelect,
|
|
117
|
+
...rest
|
|
118
|
+
}: DsTopBarNavigationUserMenuProps) => (
|
|
119
|
+
<DsDropdownMenu.Root
|
|
120
|
+
open={open}
|
|
121
|
+
// Merged, not replaced: a caller who only overrides `gutter` keeps `bottom-end`, which is
|
|
122
|
+
// what stops the menu from spilling past the right edge of the bar.
|
|
123
|
+
positioning={{ ...DEFAULT_USER_MENU_POSITIONING, ...positioning }}
|
|
124
|
+
onOpenChange={onOpenChange}
|
|
125
|
+
onSelect={onSelect}
|
|
126
|
+
>
|
|
127
|
+
<DsDropdownMenu.Trigger asChild>
|
|
128
|
+
<button
|
|
129
|
+
{...rest}
|
|
130
|
+
type="button"
|
|
131
|
+
className={classNames(styles.userMenuTrigger, className)}
|
|
132
|
+
aria-label={(locale?.userMenuButtonLabel ?? DEFAULT_LOCALE.userMenuButtonLabel)(name)}
|
|
133
|
+
>
|
|
134
|
+
<DsAvatar className={styles.userMenuAvatar} name={name} src={src} size="regular" type="circle" />
|
|
135
|
+
<span className={styles.userMenuCaret}>
|
|
136
|
+
<DsIcon icon="arrow_drop_down" size="small" aria-hidden />
|
|
137
|
+
</span>
|
|
138
|
+
</button>
|
|
139
|
+
</DsDropdownMenu.Trigger>
|
|
140
|
+
<DsDropdownMenu.Content>{children}</DsDropdownMenu.Content>
|
|
141
|
+
</DsDropdownMenu.Root>
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
DsTopBarNavigationRoot.displayName = 'DsTopBarNavigation';
|
|
145
|
+
Logo.displayName = 'DsTopBarNavigation.Logo';
|
|
146
|
+
Breadcrumb.displayName = 'DsTopBarNavigation.Breadcrumb';
|
|
147
|
+
Center.displayName = 'DsTopBarNavigation.Center';
|
|
148
|
+
Actions.displayName = 'DsTopBarNavigation.Actions';
|
|
149
|
+
Notifications.displayName = 'DsTopBarNavigation.Notifications';
|
|
150
|
+
UserMenu.displayName = 'DsTopBarNavigation.UserMenu';
|
|
151
|
+
|
|
152
|
+
const DsTopBarNavigation = Object.assign(DsTopBarNavigationRoot, {
|
|
153
|
+
Logo,
|
|
154
|
+
Breadcrumb,
|
|
155
|
+
Center,
|
|
156
|
+
Actions,
|
|
157
|
+
Notifications,
|
|
158
|
+
UserMenu,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
export default DsTopBarNavigation;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import type { DsDropdownMenuPositioning } from '../ds-dropdown-menu';
|
|
3
|
+
|
|
4
|
+
/** Count above which the notification badge collapses to `<cap>+`. */
|
|
5
|
+
export const notificationCountCap = 99;
|
|
6
|
+
|
|
7
|
+
export type DsTopBarNavigationProps = ComponentPropsWithRef<'div'>;
|
|
8
|
+
|
|
9
|
+
export interface DsTopBarNavigationLogoProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
10
|
+
/**
|
|
11
|
+
* Brand glyph rendered at 32px before the wordmark. Kept as a slot, so the bar stays
|
|
12
|
+
* tenant-neutral — no brand asset ships with the design system.
|
|
13
|
+
*/
|
|
14
|
+
logo?: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Brand wordmark rendered beside the glyph. Styled with the heading font; pass a node
|
|
17
|
+
* when the mark needs custom kerning.
|
|
18
|
+
*/
|
|
19
|
+
wordmark?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Turns the glyph and wordmark into a link to the platform home.
|
|
22
|
+
*/
|
|
23
|
+
href?: string;
|
|
24
|
+
locale?: {
|
|
25
|
+
/**
|
|
26
|
+
* Accessible name for the logo link. Only applied when `href` is set; useful when the
|
|
27
|
+
* wordmark is an image rather than text.
|
|
28
|
+
*/
|
|
29
|
+
homeLinkLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* @default 'Apps'
|
|
32
|
+
*/
|
|
33
|
+
appsButtonLabel?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Fires on the logo link itself, not the surrounding zone. Call `preventDefault` here to
|
|
37
|
+
* hand navigation to a client-side router instead of letting the browser reload the document.
|
|
38
|
+
*/
|
|
39
|
+
onLogoClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Renders the app-switcher button. Omit to hide the button entirely. Ignored when
|
|
42
|
+
* `appsMenu` is set.
|
|
43
|
+
*/
|
|
44
|
+
onAppsClick?: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Takes over the app-switcher slot with your own control — pass a `DsMainMenu` to open the
|
|
47
|
+
* app grid from the brand zone. The node is rendered as-is, so it owns its own trigger,
|
|
48
|
+
* open state, and positioning.
|
|
49
|
+
*/
|
|
50
|
+
appsMenu?: ReactNode;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type DsTopBarNavigationBreadcrumbProps = ComponentPropsWithRef<'div'>;
|
|
54
|
+
|
|
55
|
+
export type DsTopBarNavigationCenterProps = ComponentPropsWithRef<'div'>;
|
|
56
|
+
|
|
57
|
+
export type DsTopBarNavigationActionsProps = ComponentPropsWithRef<'div'>;
|
|
58
|
+
|
|
59
|
+
export interface DsTopBarNavigationNotificationsProps extends Omit<
|
|
60
|
+
ComponentPropsWithRef<'button'>,
|
|
61
|
+
'children' | 'aria-label' | 'color'
|
|
62
|
+
> {
|
|
63
|
+
/**
|
|
64
|
+
* Unread count. `0` or omitted renders the bell with no badge; anything above
|
|
65
|
+
* `notificationCountCap` collapses to a capped label.
|
|
66
|
+
*/
|
|
67
|
+
count?: number;
|
|
68
|
+
locale?: {
|
|
69
|
+
/**
|
|
70
|
+
* Accessible name when there are no unread notifications.
|
|
71
|
+
* @default 'Notifications'
|
|
72
|
+
*/
|
|
73
|
+
notificationsButtonLabel?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Accessible name when unread notifications exist. Receives the uncapped count.
|
|
76
|
+
* @default (count) => `Notifications, ${count} unread`
|
|
77
|
+
*/
|
|
78
|
+
notificationsButtonLabelWithCount?: (count: number) => string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface DsTopBarNavigationUserMenuProps extends Omit<
|
|
83
|
+
ComponentPropsWithRef<'button'>,
|
|
84
|
+
'children' | 'aria-label' | 'onSelect'
|
|
85
|
+
> {
|
|
86
|
+
/**
|
|
87
|
+
* Drives the avatar initials and its accessible name.
|
|
88
|
+
*/
|
|
89
|
+
name: string;
|
|
90
|
+
/**
|
|
91
|
+
* Avatar photo URL. Omit, or let it fail to load, to fall back to initials.
|
|
92
|
+
*/
|
|
93
|
+
src?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Menu entries — `DsDropdownMenu.Item`, `.Separator`, `.ItemGroup` and friends.
|
|
96
|
+
*/
|
|
97
|
+
children?: ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* Open state for controlled usage.
|
|
100
|
+
*/
|
|
101
|
+
open?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Placement and offset of the menu. Defaults to `bottom-end` so the menu stays inside the
|
|
104
|
+
* viewport when the trigger sits against the right edge of the bar.
|
|
105
|
+
*/
|
|
106
|
+
positioning?: DsDropdownMenuPositioning;
|
|
107
|
+
locale?: {
|
|
108
|
+
/**
|
|
109
|
+
* Accessible name for the trigger. Receives `name`; the default distinguishes the
|
|
110
|
+
* control from the avatar's own name tooltip.
|
|
111
|
+
* @default (name) => `Account menu for ${name}`
|
|
112
|
+
*/
|
|
113
|
+
userMenuButtonLabel?: (name: string) => string;
|
|
114
|
+
};
|
|
115
|
+
onOpenChange?: (open: boolean) => void;
|
|
116
|
+
onSelect?: (value: string) => void;
|
|
117
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,9 @@ export * from './components/ds-alert-banner';
|
|
|
2
2
|
export * from './components/ds-autocomplete';
|
|
3
3
|
export * from './components/ds-avatar';
|
|
4
4
|
export * from './components/ds-avatar-group';
|
|
5
|
+
export * from './components/ds-bot-button';
|
|
5
6
|
export * from './components/ds-breadcrumb';
|
|
7
|
+
export * from './components/ds-bulk-actions';
|
|
6
8
|
export * from './components/ds-button';
|
|
7
9
|
export * from './components/ds-button-v3';
|
|
8
10
|
export * from './components/ds-card';
|
|
@@ -23,14 +25,17 @@ export * from './components/ds-dialog';
|
|
|
23
25
|
export * from './components/ds-divider';
|
|
24
26
|
export * from './components/ds-drawer';
|
|
25
27
|
export * from './components/ds-dropdown-menu';
|
|
28
|
+
export * from './components/ds-empty-state';
|
|
26
29
|
export * from './components/ds-expandable-text-input';
|
|
27
30
|
export * from './components/ds-file-upload';
|
|
28
31
|
export * from './components/ds-filter-status-icon';
|
|
29
32
|
export * from './components/ds-form-control';
|
|
30
33
|
export * from './components/ds-grid';
|
|
31
34
|
export * from './components/ds-icon';
|
|
35
|
+
export * from './components/ds-illustration';
|
|
32
36
|
export * from './components/ds-key-value-pair';
|
|
33
37
|
export * from './components/ds-loader';
|
|
38
|
+
export * from './components/ds-main-menu';
|
|
34
39
|
export * from './components/ds-modal';
|
|
35
40
|
export * from './components/ds-number-input';
|
|
36
41
|
export * from './components/ds-panel';
|
|
@@ -64,6 +69,7 @@ export * from './components/ds-time-picker';
|
|
|
64
69
|
export * from './components/ds-toast';
|
|
65
70
|
export * from './components/ds-toggle';
|
|
66
71
|
export * from './components/ds-tooltip';
|
|
72
|
+
export * from './components/ds-top-bar-navigation';
|
|
67
73
|
export * from './components/ds-tree';
|
|
68
74
|
export * from './components/ds-typography';
|
|
69
75
|
export * from './components/ds-user-card';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useIsHorizontallyOverflowing = <T extends HTMLElement = HTMLElement>(content?: string) => {
|
|
4
|
+
const [element, setElement] = useState<T | null>(null);
|
|
5
|
+
const [measuredOverflow, setMeasuredOverflow] = useState(false);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!element || !content) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const measure = () => {
|
|
13
|
+
setMeasuredOverflow(element.scrollWidth > element.clientWidth);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
measure();
|
|
17
|
+
|
|
18
|
+
const resizeObserver = new ResizeObserver(measure);
|
|
19
|
+
resizeObserver.observe(element);
|
|
20
|
+
|
|
21
|
+
// document.fonts is missing in jsdom; `'fonts' in document` (not optional chaining) satisfies TS.
|
|
22
|
+
const fonts = 'fonts' in document ? document.fonts : undefined;
|
|
23
|
+
fonts?.addEventListener('loadingdone', measure);
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
resizeObserver.disconnect();
|
|
27
|
+
fonts?.removeEventListener('loadingdone', measure);
|
|
28
|
+
};
|
|
29
|
+
}, [content, element]);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
ref: setElement,
|
|
33
|
+
isOverflowing: Boolean(content) && measuredOverflow,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export const useIsOverflowing = <T extends HTMLElement = HTMLElement>(text: string | undefined) => {
|
|
4
|
-
const ref = useRef<T>(null);
|
|
5
|
-
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
6
|
-
|
|
7
|
-
useLayoutEffect(() => {
|
|
8
|
-
const element = ref.current;
|
|
9
|
-
if (!element) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const measure = () => setIsOverflowing(element.scrollWidth > element.clientWidth);
|
|
14
|
-
measure();
|
|
15
|
-
|
|
16
|
-
const observer = new ResizeObserver(measure);
|
|
17
|
-
observer.observe(element);
|
|
18
|
-
|
|
19
|
-
const frame = requestAnimationFrame(measure);
|
|
20
|
-
document.fonts.ready.then(measure).catch(() => undefined);
|
|
21
|
-
document.fonts.addEventListener('loadingdone', measure);
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
cancelAnimationFrame(frame);
|
|
25
|
-
observer.disconnect();
|
|
26
|
-
document.fonts.removeEventListener('loadingdone', measure);
|
|
27
|
-
};
|
|
28
|
-
}, [text]);
|
|
29
|
-
|
|
30
|
-
return { ref, isOverflowing };
|
|
31
|
-
};
|
package/src/components/ds-table/components/ds-table-bulk-actions/ds-table-bulk-actions.module.scss
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
@use '../../../../styles/typography';
|
|
2
|
-
|
|
3
|
-
.bulkActionsContainer {
|
|
4
|
-
position: absolute;
|
|
5
|
-
bottom: 20px;
|
|
6
|
-
left: 50%;
|
|
7
|
-
transform: translateX(-50%);
|
|
8
|
-
background-color: var(--color-dap-gray-050);
|
|
9
|
-
border-radius: 8px;
|
|
10
|
-
box-shadow: 0 4px 12px #0445cc66;
|
|
11
|
-
z-index: 1;
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
border-radius: 8px;
|
|
15
|
-
overflow: hidden;
|
|
16
|
-
animation-duration: 0.3s;
|
|
17
|
-
animation-timing-function: ease-out;
|
|
18
|
-
animation-fill-mode: forwards;
|
|
19
|
-
|
|
20
|
-
&.entering {
|
|
21
|
-
animation-name: slideUpFadeIn;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&.exiting {
|
|
25
|
-
animation-name: slideDownFadeOut;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.bulkActionsContent {
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
padding-right: 6px;
|
|
33
|
-
padding-left: 6px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.selectedCountContainer {
|
|
37
|
-
background-color: var(--color-dap-blue-600);
|
|
38
|
-
display: flex;
|
|
39
|
-
align-items: center;
|
|
40
|
-
padding: 6px 22px;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.selectedCountBadge {
|
|
44
|
-
color: var(--color-dap-gray-050);
|
|
45
|
-
margin: 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.bulkActionsInfo {
|
|
49
|
-
color: var(--color-dap-gray-600);
|
|
50
|
-
text-wrap: nowrap;
|
|
51
|
-
padding-left: 8px;
|
|
52
|
-
padding-right: 56px;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.bulkActionsActions {
|
|
56
|
-
display: flex;
|
|
57
|
-
align-items: center;
|
|
58
|
-
gap: 8px;
|
|
59
|
-
|
|
60
|
-
> .actionButton {
|
|
61
|
-
display: flex;
|
|
62
|
-
flex-direction: column;
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: center;
|
|
65
|
-
gap: var(--3xs);
|
|
66
|
-
border-right: 1px solid var(--color-dap-gray-400);
|
|
67
|
-
width: 68px;
|
|
68
|
-
height: 48px;
|
|
69
|
-
border-radius: 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
> .actionButton:first-child {
|
|
73
|
-
border-left: 1px solid var(--color-dap-gray-400);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.escapeButtonContent {
|
|
78
|
-
display: flex;
|
|
79
|
-
flex-direction: column;
|
|
80
|
-
justify-content: center;
|
|
81
|
-
align-items: center;
|
|
82
|
-
color: var(--color-dap-gray-600);
|
|
83
|
-
gap: 2px !important;
|
|
84
|
-
width: 36px;
|
|
85
|
-
padding-left: 4px;
|
|
86
|
-
|
|
87
|
-
&:hover {
|
|
88
|
-
color: var(--color-dap-gray-500);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@keyframes slideUpFadeIn {
|
|
93
|
-
0% {
|
|
94
|
-
opacity: 0;
|
|
95
|
-
transform: translate(-50%, 100%);
|
|
96
|
-
}
|
|
97
|
-
100% {
|
|
98
|
-
opacity: 1;
|
|
99
|
-
transform: translate(-50%, 0);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@keyframes slideDownFadeOut {
|
|
104
|
-
0% {
|
|
105
|
-
opacity: 1;
|
|
106
|
-
transform: translate(-50%, 0);
|
|
107
|
-
}
|
|
108
|
-
100% {
|
|
109
|
-
opacity: 0;
|
|
110
|
-
transform: translate(-50%, 100%);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import classnames from 'classnames';
|
|
4
|
-
import { DsButton } from '../../../ds-button';
|
|
5
|
-
import { DsIcon } from '../../../ds-icon';
|
|
6
|
-
import styles from './ds-table-bulk-actions.module.scss';
|
|
7
|
-
import type { BulkActionsProps } from './ds-table-bulk-actions.types';
|
|
8
|
-
import { DsTypography } from '../../../ds-typography';
|
|
9
|
-
|
|
10
|
-
const DsTableBulkActions: React.FC<BulkActionsProps> = ({ numSelectedRows, actions, onClearSelection }) => {
|
|
11
|
-
const [isRendered, setIsRendered] = useState(false);
|
|
12
|
-
const [animationClass, setAnimationClass] = useState('');
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (numSelectedRows > 0) {
|
|
16
|
-
setIsRendered(true);
|
|
17
|
-
setAnimationClass(styles.entering);
|
|
18
|
-
} else if (isRendered) {
|
|
19
|
-
setAnimationClass(styles.exiting);
|
|
20
|
-
const timer = setTimeout(() => {
|
|
21
|
-
setIsRendered(false);
|
|
22
|
-
setAnimationClass('');
|
|
23
|
-
}, 300);
|
|
24
|
-
return () => clearTimeout(timer);
|
|
25
|
-
}
|
|
26
|
-
}, [numSelectedRows, isRendered]);
|
|
27
|
-
|
|
28
|
-
if (!isRendered) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div className={classnames(styles.bulkActionsContainer, animationClass)}>
|
|
34
|
-
<div className={styles.selectedCountContainer}>
|
|
35
|
-
<DsTypography variant="heading1" className={styles.selectedCountBadge}>
|
|
36
|
-
{numSelectedRows}
|
|
37
|
-
</DsTypography>
|
|
38
|
-
</div>
|
|
39
|
-
<div className={styles.bulkActionsContent}>
|
|
40
|
-
<DsTypography variant="body-md-semi-bold" className={styles.bulkActionsInfo}>
|
|
41
|
-
Items selected
|
|
42
|
-
</DsTypography>
|
|
43
|
-
|
|
44
|
-
<div className={styles.bulkActionsActions}>
|
|
45
|
-
{actions.map((action, index) => (
|
|
46
|
-
<button key={index} type="button" className={styles.actionButton} onClick={action.onClick}>
|
|
47
|
-
<DsIcon icon={action.icon} />
|
|
48
|
-
<DsTypography variant="body-xs-md">{action.label}</DsTypography>
|
|
49
|
-
</button>
|
|
50
|
-
))}
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
<DsButton
|
|
54
|
-
variant="borderless"
|
|
55
|
-
size="small"
|
|
56
|
-
color="neutral-2"
|
|
57
|
-
contentClassName={styles.escapeButtonContent}
|
|
58
|
-
onClick={onClearSelection}
|
|
59
|
-
>
|
|
60
|
-
<DsIcon icon="close" />
|
|
61
|
-
</DsButton>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default DsTableBulkActions;
|
package/src/components/ds-table/components/ds-table-bulk-actions/ds-table-bulk-actions.types.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { IconType } from '../../../ds-icon';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a bulk action that can be performed on selected table rows
|
|
5
|
-
*/
|
|
6
|
-
export interface Action {
|
|
7
|
-
/**
|
|
8
|
-
* Icon to be displayed for the action
|
|
9
|
-
*/
|
|
10
|
-
icon: IconType;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Label text for the action
|
|
14
|
-
*/
|
|
15
|
-
label: string;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Function to be called when the action is clicked
|
|
19
|
-
*/
|
|
20
|
-
onClick: () => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Props for the bulk actions component
|
|
25
|
-
*/
|
|
26
|
-
export interface BulkActionsProps {
|
|
27
|
-
/**
|
|
28
|
-
* Number of rows currently selected in the table
|
|
29
|
-
*/
|
|
30
|
-
numSelectedRows: number;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Array of actions to be displayed in the bulk actions bar
|
|
34
|
-
*/
|
|
35
|
-
actions: Action[];
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Function to be called when the selection should be cleared
|
|
39
|
-
*/
|
|
40
|
-
onClearSelection: () => void;
|
|
41
|
-
}
|