@drivenets/design-system 0.14.0 → 0.16.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 +32 -0
- package/README.md +1 -1
- package/dist/index.cjs +1239 -262
- package/dist/index.d.cts +904 -1169
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +904 -1169
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1221 -258
- package/dist/index.js.map +1 -1
- package/dist/index.min.css +1 -1
- package/package.json +15 -12
- package/src/components/ds-alert-banner/ds-alert-banner.tsx +11 -2
- package/src/components/ds-autocomplete/ds-autocomplete.figma.ts +36 -0
- package/src/components/ds-autocomplete/ds-autocomplete.tsx +2 -0
- package/src/components/ds-avatar/ds-avatar.figma.ts +30 -0
- package/src/components/ds-avatar/ds-avatar.tsx +6 -1
- package/src/components/ds-avatar/ds-avatar.types.ts +5 -2
- package/src/components/ds-avatar-group/ds-avatar-group.figma.ts +27 -0
- package/src/components/ds-avatar-group/ds-avatar-group.tsx +6 -1
- package/src/components/ds-avatar-group/ds-avatar-group.types.ts +3 -1
- package/src/components/ds-breadcrumb/ds-breadcrumb.figma.ts +19 -0
- package/src/components/ds-breadcrumb/ds-breadcrumb.tsx +2 -0
- package/src/components/ds-button/ds-button.tsx +2 -0
- package/src/components/ds-button-v3/ds-button-v3.figma.ts +1 -1
- package/src/components/ds-button-v3/ds-button-v3.tsx +6 -0
- package/src/components/ds-button-v3/index.ts +2 -0
- package/src/components/ds-card/ds-card.tsx +7 -3
- package/src/components/ds-catalog-layout/ds-catalog-layout.tsx +8 -0
- package/src/components/ds-checkbox/ds-checkbox-level-2.figma.ts +40 -0
- package/src/components/ds-checkbox/ds-checkbox.figma.ts +45 -0
- package/src/components/ds-checkbox/ds-checkbox.module.scss +1 -1
- package/src/components/ds-checkbox/ds-checkbox.tsx +9 -1
- package/src/components/ds-checkbox-group/ds-checkbox-group.figma.ts +15 -0
- package/src/components/ds-checkbox-group/ds-checkbox-group.tsx +2 -0
- package/src/components/ds-chip/ds-chip.tsx +2 -0
- package/src/components/ds-chip-group/ds-chip-group.tsx +2 -0
- package/src/components/ds-comment-bubble/components/ds-comment-thread/ds-comment-thread.tsx +1 -0
- package/src/components/ds-comment-bubble/components/ds-thread-item/ds-thread-item.tsx +1 -0
- package/src/components/ds-comment-bubble/ds-comment-bubble.tsx +1 -0
- package/src/components/ds-comment-card/ds-comment-card.tsx +1 -0
- package/src/components/ds-comment-indicator/ds-comment-indicator.tsx +1 -0
- package/src/components/ds-comments-drawer/ds-comments-drawer.tsx +1 -0
- package/src/components/ds-confirmation/ds-confirmation.tsx +1 -0
- package/src/components/ds-date-input/ds-date-input.tsx +2 -0
- package/src/components/ds-date-picker/ds-date-picker.tsx +9 -0
- package/src/components/ds-date-picker/ds-date-picker.types.ts +1 -1
- package/src/components/ds-date-range-picker/ds-date-range-picker.tsx +2 -0
- package/src/components/ds-dialog/ds-dialog.tsx +9 -0
- package/src/components/ds-dialog/ds-dialog.types.ts +1 -1
- package/src/components/ds-divider/ds-divider.figma.ts +19 -0
- package/src/components/ds-divider/ds-divider.tsx +2 -0
- package/src/components/ds-drawer/ds-drawer.module.scss +14 -0
- package/src/components/ds-drawer/ds-drawer.tsx +30 -1
- package/src/components/ds-drawer/ds-drawer.types.ts +7 -0
- package/src/components/ds-drawer/figma/ds-drawer-content.figma.ts +15 -0
- package/src/components/ds-drawer/figma/ds-drawer-footer.figma.ts +19 -0
- package/src/components/ds-drawer/figma/ds-drawer-header.figma.ts +16 -0
- package/src/components/ds-drawer/figma/ds-drawer.figma.ts +36 -0
- package/src/components/ds-dropdown-menu/ds-dropdown-menu.module.scss +12 -3
- package/src/components/ds-dropdown-menu/ds-dropdown-menu.tsx +24 -6
- package/src/components/ds-dropdown-menu/ds-dropdown-menu.types.ts +10 -1
- package/src/components/ds-dropdown-menu/figma/ds-dropdown-menu-footer.figma.ts +11 -0
- package/src/components/ds-dropdown-menu/figma/ds-dropdown-menu-group.figma.ts +23 -0
- package/src/components/ds-dropdown-menu/figma/ds-dropdown-menu-item.figma.ts +29 -0
- package/src/components/ds-dropdown-menu/figma/ds-dropdown-menu-separator.figma.ts +11 -0
- package/src/components/ds-dropdown-menu/figma/ds-dropdown-menu.figma.ts +24 -0
- package/src/components/ds-expandable-text-input/ds-expandable-text-input.figma.ts +24 -0
- package/src/components/ds-expandable-text-input/ds-expandable-text-input.tsx +1 -0
- package/src/components/ds-file-upload/ds-file-upload.figma.ts +29 -0
- package/src/components/ds-file-upload/ds-file-upload.tsx +2 -0
- package/src/components/ds-file-upload/hooks/use-file-upload.ts +7 -0
- package/src/components/ds-filter-status-icon/ds-filter-status-icon.figma.ts +22 -0
- package/src/components/ds-filter-status-icon/ds-filter-status-icon.tsx +1 -0
- package/src/components/ds-form-control/ds-form-control.tsx +3 -0
- package/src/components/ds-grid/index.ts +3 -0
- package/src/components/ds-icon/ds-icon.tsx +2 -0
- package/src/components/ds-key-value-pair/ds-key-value-pair.figma.ts +24 -0
- package/src/components/ds-key-value-pair/ds-key-value-pair.tsx +2 -0
- package/src/components/ds-loader/ds-loader.figma.ts +11 -0
- package/src/components/ds-loader/ds-loader.tsx +2 -0
- package/src/components/ds-modal/ds-modal.tsx +9 -0
- package/src/components/ds-number-input/ds-number-input.tsx +2 -0
- package/src/components/ds-panel/ds-panel.figma.ts +16 -0
- package/src/components/ds-panel/index.ts +2 -0
- package/src/components/ds-password-input/ds-password-input.tsx +2 -0
- package/src/components/ds-popover/ds-popover.tsx +9 -0
- package/src/components/ds-popover/figma/ds-popover-content-item.figma.ts +18 -0
- package/src/components/ds-popover/figma/ds-popover-content.figma.ts +15 -0
- package/src/components/ds-popover/figma/ds-popover-footer.figma.ts +19 -0
- package/src/components/ds-popover/figma/ds-popover-header.figma.ts +16 -0
- package/src/components/ds-popover/figma/ds-popover.figma.ts +34 -0
- package/src/components/ds-progress-arc/ds-progress-arc.figma.ts +23 -0
- package/src/components/ds-progress-arc/ds-progress-arc.tsx +2 -0
- package/src/components/ds-progress-donut/ds-progress-donut.figma.ts +45 -0
- package/src/components/ds-progress-donut/ds-progress-donut.tsx +2 -0
- package/src/components/ds-progress-linear/ds-progress-linear.figma.ts +26 -0
- package/src/components/ds-progress-linear/ds-progress-linear.tsx +2 -0
- package/src/components/ds-progress-task-bar/ds-progress-task-bar.figma.ts +29 -0
- package/src/components/ds-progress-task-bar/ds-progress-task-bar.module.scss +39 -0
- package/src/components/ds-progress-task-bar/ds-progress-task-bar.tsx +124 -0
- package/src/components/ds-progress-task-bar/ds-progress-task-bar.types.ts +65 -0
- package/src/components/ds-progress-task-bar/index.ts +2 -0
- package/src/components/ds-progress-task-bar/utils.ts +51 -0
- package/src/components/ds-radio-group/ds-radio-group.tsx +3 -0
- package/src/components/ds-radio-group/figma/ds-radio-group-item.figma.ts +24 -0
- package/src/components/ds-radio-group/figma/ds-radio-group.figma.ts +14 -0
- package/src/components/ds-segment-group/ds-segment-group.tsx +3 -0
- package/src/components/ds-segment-group/figma/ds-segment-group-item.figma.ts +25 -0
- package/src/components/ds-segment-group/figma/ds-segment-group.figma.ts +23 -0
- package/src/components/ds-select/ds-select.tsx +2 -0
- package/src/components/ds-site-node/ds-site-node.figma.ts +27 -0
- package/src/components/ds-site-node/ds-site-node.module.scss +59 -0
- package/src/components/ds-site-node/ds-site-node.tsx +73 -0
- package/src/components/ds-site-node/ds-site-node.types.ts +36 -0
- package/src/components/ds-site-node/hooks/use-is-overflowing.ts +31 -0
- package/src/components/ds-site-node/index.ts +3 -0
- package/src/components/ds-skeleton/ds-skeleton-circle.tsx +2 -0
- package/src/components/ds-skeleton/ds-skeleton-rect.tsx +2 -0
- package/src/components/ds-skeleton/ds-skeleton-text.tsx +2 -0
- package/src/components/ds-skeleton/ds-skeleton.ts +7 -1
- package/src/components/ds-smart-tabs/ds-smart-tabs.tsx +4 -0
- package/src/components/ds-spinner/ds-spinner.figma.ts +19 -0
- package/src/components/ds-spinner/ds-spinner.tsx +2 -0
- package/src/components/ds-split-button/ds-split-button.tsx +6 -0
- package/src/components/ds-status-badge/ds-status-badge.tsx +2 -0
- package/src/components/ds-status-badge-v2/index.ts +2 -0
- package/src/components/ds-stepper/components/ds-step-content.tsx +2 -0
- package/src/components/ds-stepper/components/ds-step-next-button.tsx +2 -0
- package/src/components/ds-stepper/components/ds-step.tsx +2 -0
- package/src/components/ds-stepper/ds-stepper.figma.ts +38 -0
- package/src/components/ds-stepper/ds-stepper.tsx +1 -0
- package/src/components/ds-system-status/ds-system-status.tsx +2 -0
- package/src/components/ds-table/components/ds-table-row/ds-table-row.module.scss +1 -1
- package/src/components/ds-table/components/ds-table-row/ds-table-row.tsx +2 -0
- package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.module.scss +1 -1
- package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.tsx +2 -0
- package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-checkbox.tsx +1 -0
- package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-date.tsx +1 -0
- package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-number.tsx +1 -0
- package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-select.tsx +1 -0
- package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-text.tsx +1 -0
- package/src/components/ds-table/components/edit/ds-table-editable-cell/ds-table-editable-cell.module.scss +14 -2
- package/src/components/ds-table/components/edit/ds-table-editable-cell/ds-table-editable-cell.tsx +20 -0
- package/src/components/ds-table/components/edit/ds-table-editing-cell/ds-table-editing-cell.tsx +1 -0
- package/src/components/ds-table/ds-table-column.types.ts +24 -0
- package/src/components/ds-table/ds-table.tsx +30 -4
- package/src/components/ds-table/ds-table.types.ts +7 -0
- package/src/components/ds-table/index.ts +4 -0
- package/src/components/ds-table/utils/constants.ts +5 -0
- package/src/components/ds-tabs/components/ds-tabs-content/ds-tabs-content.tsx +2 -0
- package/src/components/ds-tabs/components/ds-tabs-list/ds-tabs-list.tsx +2 -0
- package/src/components/ds-tabs/components/ds-tabs-tab/ds-tabs-tab.tsx +2 -0
- package/src/components/ds-tabs/ds-tabs.tsx +2 -0
- package/src/components/ds-tabs/figma/ds-tabs-tab-vertical.figma.ts +78 -0
- package/src/components/ds-tabs/figma/ds-tabs-tab.figma.ts +89 -0
- package/src/components/ds-tabs/figma/ds-tabs-vertical.figma.ts +31 -0
- package/src/components/ds-tabs/figma/ds-tabs.figma.ts +29 -0
- package/src/components/ds-tag/ds-tag.tsx +2 -0
- package/src/components/ds-tag-filter/ds-tag-filter.tsx +2 -0
- package/src/components/ds-text-input/ds-input-field-v02.figma.ts +87 -0
- package/src/components/ds-text-input/ds-text-input.tsx +2 -0
- package/src/components/ds-textarea/ds-textarea.tsx +2 -0
- package/src/components/ds-time-picker/ds-time-picker.tsx +2 -0
- package/src/components/ds-toast/ds-toast-context.tsx +1 -0
- package/src/components/ds-toast/ds-toast.figma.ts +34 -0
- package/src/components/ds-toast/ds-toast.tsx +3 -0
- package/src/components/ds-toggle/ds-toggle.figma.ts +39 -0
- package/src/components/ds-toggle/ds-toggle.tsx +2 -0
- package/src/components/ds-tooltip/ds-tooltip.figma.ts +16 -0
- package/src/components/ds-tooltip/ds-tooltip.module.scss +8 -1
- package/src/components/ds-tooltip/ds-tooltip.tsx +35 -15
- package/src/components/ds-tooltip/ds-tooltip.types.ts +40 -0
- package/src/components/ds-tree/ds-tree.tsx +16 -0
- package/src/components/ds-typography/ds-typography.config.ts +1 -1
- package/src/components/ds-typography/ds-typography.figma.ts +63 -0
- package/src/components/ds-typography/ds-typography.module.scss +16 -0
- package/src/components/ds-typography/ds-typography.tsx +64 -7
- package/src/components/ds-typography/ds-typography.types.ts +13 -0
- package/src/components/ds-typography/hooks/use-truncation.ts +151 -0
- package/src/components/ds-user-card/ds-user-card.figma.ts +16 -0
- package/src/components/ds-user-card/ds-user-card.module.scss +25 -0
- package/src/components/ds-user-card/ds-user-card.tsx +31 -0
- package/src/components/ds-user-card/ds-user-card.types.ts +26 -0
- package/src/components/ds-user-card/index.ts +2 -0
- package/src/components/ds-vertical-tabs/ds-vertical-tabs.tsx +6 -0
- package/src/components/ds-workspace-layout/ds-workspace-layout.tsx +10 -0
- package/src/index.ts +3 -0
- package/src/styles/_root.scss +468 -363
- package/src/styles/shared/_dropdown.scss +2 -2
- package/src/styles/styles.scss +0 -3
- package/src/styles/_colors.scss +0 -65
- package/src/styles/_root_new.scss +0 -451
- package/src/styles/_spacing.scss +0 -47
package/src/components/ds-table/components/edit/ds-table-editable-cell/ds-table-editable-cell.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { MouseEvent } from 'react';
|
|
2
2
|
import { DsButtonV3 } from '../../../../ds-button-v3';
|
|
3
|
+
import { DsIcon } from '../../../../ds-icon';
|
|
4
|
+
import { DsTooltip } from '../../../../ds-tooltip';
|
|
3
5
|
import styles from './ds-table-editable-cell.module.scss';
|
|
4
6
|
import type { DsTableEditableCellProps } from './ds-table-editable-cell.types';
|
|
5
7
|
import { useDsTableContext } from '../../../context/ds-table-context';
|
|
@@ -16,6 +18,23 @@ export const DsTableEditableCell = <TData, TValue>({
|
|
|
16
18
|
beginEdit(cell);
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
const editDisabled = cell.column.columnDef.editDisabled?.(cell.getContext());
|
|
22
|
+
const locked = editDisabled === true || typeof editDisabled === 'object';
|
|
23
|
+
const reason = typeof editDisabled === 'object' ? editDisabled.reason : undefined;
|
|
24
|
+
|
|
25
|
+
if (locked) {
|
|
26
|
+
return (
|
|
27
|
+
<div className={styles.root} data-locked="">
|
|
28
|
+
{children}
|
|
29
|
+
<DsTooltip content={reason}>
|
|
30
|
+
<span className={styles.lockIcon} aria-label="Editing disabled" role="img">
|
|
31
|
+
<DsIcon icon="lock" size="small" color="secondary" />
|
|
32
|
+
</span>
|
|
33
|
+
</DsTooltip>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
return (
|
|
20
39
|
<div
|
|
21
40
|
className={styles.root}
|
|
@@ -37,3 +56,4 @@ export const DsTableEditableCell = <TData, TValue>({
|
|
|
37
56
|
</div>
|
|
38
57
|
);
|
|
39
58
|
};
|
|
59
|
+
DsTableEditableCell.displayName = 'DsTableEditableCell';
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { CellContext, RowData } from '@tanstack/react-table';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Result of a column's `editDisabled` resolver for a single cell.
|
|
6
|
+
*
|
|
7
|
+
* - `false` (or `undefined`) keeps the cell editable.
|
|
8
|
+
* - `true` locks the cell with no tooltip.
|
|
9
|
+
* - `{ reason }` locks the cell and shows `reason` in a tooltip on hover.
|
|
10
|
+
*/
|
|
11
|
+
export type DsTableEditDisabledResult = boolean | { reason?: ReactNode };
|
|
12
|
+
|
|
4
13
|
declare module '@tanstack/react-table' {
|
|
5
14
|
interface ColumnDefBase<TData extends RowData, TValue> {
|
|
6
15
|
/**
|
|
@@ -8,5 +17,20 @@ declare module '@tanstack/react-table' {
|
|
|
8
17
|
* When omitted, the column is not editable.
|
|
9
18
|
*/
|
|
10
19
|
editCell?: (context: CellContext<TData, TValue>) => ReactNode;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Locks individual cells of an otherwise editable column (one that defines
|
|
23
|
+
* `editCell`). When this returns a truthy value for a cell, that cell shows a
|
|
24
|
+
* lock icon instead of the edit affordance and cannot enter edit mode. Return
|
|
25
|
+
* `{ reason }` to surface an optional tooltip explaining why. Has no effect on
|
|
26
|
+
* columns without `editCell`.
|
|
27
|
+
*/
|
|
28
|
+
editDisabled?: (context: CellContext<TData, TValue>) => DsTableEditDisabledResult;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Renders this column's cell content while the table is `loading`.
|
|
32
|
+
* When omitted, a default text skeleton is rendered.
|
|
33
|
+
*/
|
|
34
|
+
loadingCell?: (context: CellContext<TData, TValue>) => ReactNode;
|
|
11
35
|
}
|
|
12
36
|
}
|
|
@@ -26,6 +26,7 @@ import { useDragAndDrop } from './hooks/use-drag-and-drop';
|
|
|
26
26
|
import { type DsTableContextType, DsTableContext, useEditingState } from './context/ds-table-context';
|
|
27
27
|
import { DsTableBodyVirtualized } from './components/ds-table-body-virtualized';
|
|
28
28
|
import { useColumnGroups } from './grouping';
|
|
29
|
+
import { DsSkeletonText } from '../ds-skeleton';
|
|
29
30
|
import {
|
|
30
31
|
EMPTY_TABLE_STATE_TEXT,
|
|
31
32
|
EXPANDER_COLUMN_ID,
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
REORDER_COLUMN_WIDTH,
|
|
35
36
|
SELECT_COLUMN_ID,
|
|
36
37
|
SELECT_COLUMN_WIDTH,
|
|
38
|
+
SKELETON_ROW_COUNT,
|
|
37
39
|
} from './utils/constants';
|
|
38
40
|
|
|
39
41
|
// Row size to pixel height mapping (matches CSS variables)
|
|
@@ -59,6 +61,7 @@ const DsTable = <TData extends { id: string }, TValue>({
|
|
|
59
61
|
bordered = true,
|
|
60
62
|
fullWidth = true,
|
|
61
63
|
rowSize = 'medium',
|
|
64
|
+
loading = false,
|
|
62
65
|
expandable = false,
|
|
63
66
|
renderExpandedRow,
|
|
64
67
|
selectable = false,
|
|
@@ -201,9 +204,29 @@ const DsTable = <TData extends { id: string }, TValue>({
|
|
|
201
204
|
return augmentedColumns;
|
|
202
205
|
}, [columnsProp, hasExpanderColumn, hasReorderColumn, hasSelectColumn, showSelectAllCheckbox]);
|
|
203
206
|
|
|
207
|
+
const skeletonColumns = useMemo<ColumnDef<TData, TValue>[]>(() => {
|
|
208
|
+
const toSkeleton = (cols: ColumnDef<TData, TValue>[]): ColumnDef<TData, TValue>[] =>
|
|
209
|
+
cols.map((column) =>
|
|
210
|
+
'columns' in column && column.columns
|
|
211
|
+
? { ...column, columns: toSkeleton(column.columns) }
|
|
212
|
+
: { ...column, cell: column.loadingCell ?? (() => <DsSkeletonText width="60%" />) },
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
return toSkeleton(columns);
|
|
216
|
+
}, [columns]);
|
|
217
|
+
|
|
218
|
+
const skeletonData = useMemo<TData[]>(
|
|
219
|
+
() =>
|
|
220
|
+
Array.from(
|
|
221
|
+
{ length: SKELETON_ROW_COUNT },
|
|
222
|
+
(_, i) => ({ id: `ds-table-skeleton-${String(i)}` }) as TData,
|
|
223
|
+
),
|
|
224
|
+
[],
|
|
225
|
+
);
|
|
226
|
+
|
|
204
227
|
const table = useReactTable({
|
|
205
|
-
data: reorderable ? data : tableData,
|
|
206
|
-
columns,
|
|
228
|
+
data: loading ? skeletonData : reorderable ? data : tableData,
|
|
229
|
+
columns: loading ? skeletonColumns : columns,
|
|
207
230
|
getCoreRowModel: getCoreRowModel(),
|
|
208
231
|
onSortingChange: handleSortingChange,
|
|
209
232
|
getSortedRowModel: getSortedRowModel(),
|
|
@@ -295,8 +318,9 @@ const DsTable = <TData extends { id: string }, TValue>({
|
|
|
295
318
|
selectable,
|
|
296
319
|
reorderable,
|
|
297
320
|
showSelectAllCheckbox,
|
|
298
|
-
|
|
299
|
-
|
|
321
|
+
loading,
|
|
322
|
+
onRowClick: loading ? undefined : onRowClick,
|
|
323
|
+
onRowDoubleClick: loading ? undefined : onRowDoubleClick,
|
|
300
324
|
primaryRowActions,
|
|
301
325
|
secondaryRowActions,
|
|
302
326
|
renderExpandedRow,
|
|
@@ -362,4 +386,6 @@ const DsTable = <TData extends { id: string }, TValue>({
|
|
|
362
386
|
);
|
|
363
387
|
};
|
|
364
388
|
|
|
389
|
+
DsTable.displayName = 'DsTable';
|
|
390
|
+
|
|
365
391
|
export default DsTable;
|
|
@@ -314,6 +314,13 @@ export interface DsDataTableProps<TData, TValue> {
|
|
|
314
314
|
*/
|
|
315
315
|
rowSize?: DsTableRowSize;
|
|
316
316
|
|
|
317
|
+
/**
|
|
318
|
+
* When `true`, renders placeholder skeleton rows instead of the data. Column
|
|
319
|
+
* headers stay intact and row interactions are disabled while loading.
|
|
320
|
+
* @default false
|
|
321
|
+
*/
|
|
322
|
+
loading?: boolean;
|
|
323
|
+
|
|
317
324
|
/**
|
|
318
325
|
* Whether the table is expandable or if an individual row should be expandable
|
|
319
326
|
*/
|
|
@@ -5,10 +5,14 @@ export type { ScrollParams } from './components/ds-table-body-virtualized';
|
|
|
5
5
|
|
|
6
6
|
export * from './filters';
|
|
7
7
|
export type { DsColumnGroupMeta } from './grouping';
|
|
8
|
+
export type { DsTableEditDisabledResult } from './ds-table-column.types';
|
|
8
9
|
|
|
9
10
|
export { default as DsTable } from './ds-table';
|
|
10
11
|
export * from './ds-table.types';
|
|
11
12
|
|
|
13
|
+
export { createColumnHelper } from '@tanstack/react-table';
|
|
14
|
+
export type { ColumnDef } from '@tanstack/react-table';
|
|
15
|
+
|
|
12
16
|
export { useCellEditor } from './hooks/use-cell-editor';
|
|
13
17
|
export type {
|
|
14
18
|
UseCellEditorOptions,
|
|
@@ -33,3 +33,8 @@ export const REORDER_COLUMN_ID = 'reorder';
|
|
|
33
33
|
* Width (in px) of the reorder column.
|
|
34
34
|
*/
|
|
35
35
|
export const REORDER_COLUMN_WIDTH = 60;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Number of placeholder skeleton rows rendered while the table is `loading`.
|
|
39
|
+
*/
|
|
40
|
+
export const SKELETON_ROW_COUNT = 5;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// url=https://www.figma.com/design/nha3m67y7S57cHCSuQO2gp/DAP-Design-System-1.2?node-id=14841-6024
|
|
2
|
+
// source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-tabs
|
|
3
|
+
// component=DsTabs.Tab
|
|
4
|
+
//
|
|
5
|
+
// `DAP_Tab item - vertical_v01` maps to `DsTabs.Tab`, resolved inside the vertical
|
|
6
|
+
// `tabs slot` (nestable). Same code component as the horizontal tab item; the two
|
|
7
|
+
// differ in Figma only by casing (`Show Leading Icon`) and by the vertical set
|
|
8
|
+
// having no `Menu Actions` property.
|
|
9
|
+
//
|
|
10
|
+
// Variant divergence — `State`, `Selected` and `Size` have no `DsTabs.Tab` prop
|
|
11
|
+
// (see `ds-tabs-tab.figma.ts` for the rationale).
|
|
12
|
+
import figma from 'figma';
|
|
13
|
+
|
|
14
|
+
const instance = figma.selectedInstance;
|
|
15
|
+
|
|
16
|
+
const label = instance.getString('Tab Name');
|
|
17
|
+
const showIcon = instance.getBoolean('Show Leading Icon');
|
|
18
|
+
const showBadge = instance.getBoolean('Show Badge');
|
|
19
|
+
|
|
20
|
+
// `value` is required by `DsTabsTabProps` but is data, not derivable from Figma.
|
|
21
|
+
const value = label
|
|
22
|
+
? label
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
25
|
+
.replace(/^-+|-+$/g, '')
|
|
26
|
+
: 'tab';
|
|
27
|
+
|
|
28
|
+
// Leading icon → `DsTabs.Tab.icon` name, read from the connected ds-icon instance.
|
|
29
|
+
const resolveIcon = (): string | undefined => {
|
|
30
|
+
const node = instance
|
|
31
|
+
.findConnectedInstances((n) => n.codeConnectId()?.startsWith('ds-icon-') ?? false, {
|
|
32
|
+
traverseInstances: true,
|
|
33
|
+
})
|
|
34
|
+
.find((n): n is figma.InstanceHandle => n.type === 'INSTANCE');
|
|
35
|
+
|
|
36
|
+
if (!node) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const id = node.codeConnectId();
|
|
41
|
+
if (id?.startsWith('ds-icon-o-')) {
|
|
42
|
+
return id.slice('ds-icon-o-'.length);
|
|
43
|
+
}
|
|
44
|
+
if (id?.startsWith('ds-icon-s-')) {
|
|
45
|
+
return id.slice('ds-icon-s-'.length);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return node.name
|
|
49
|
+
.replace(/^DAP_GM_[OS]_/, '')
|
|
50
|
+
.replace(/^DAP_/, '')
|
|
51
|
+
.replace(/[\s/]+/g, '_')
|
|
52
|
+
.toLowerCase();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const icon = showIcon ? resolveIcon() : undefined;
|
|
56
|
+
|
|
57
|
+
// Badge count is freeform nested text, read from the badge instance when shown.
|
|
58
|
+
const resolveBadge = (): string | undefined => {
|
|
59
|
+
const badge = instance.findInstance('DAP_Tab badge_v01', { traverseInstances: true });
|
|
60
|
+
if (badge.type !== 'INSTANCE') {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
return badge.children.find((c): c is figma.TextHandle => c.type === 'TEXT')?.textContent;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const badge = showBadge ? resolveBadge() : undefined;
|
|
67
|
+
const badgeAttr = badge ? (/^\d+$/.test(badge) ? `badge={${badge}}` : `badge="${badge}"`) : '';
|
|
68
|
+
|
|
69
|
+
const attrs = [`value="${value}"`, `label="${label}"`, icon ? `icon="${icon}"` : '', badgeAttr]
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
.join(' ');
|
|
72
|
+
|
|
73
|
+
export default {
|
|
74
|
+
example: figma.code`<DsTabs.Tab ${attrs} />`,
|
|
75
|
+
imports: ["import { DsTabs } from '@drivenets/design-system'"],
|
|
76
|
+
id: 'ds-tabs-tab-vertical',
|
|
77
|
+
metadata: { nestable: true },
|
|
78
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// url=https://www.figma.com/design/nha3m67y7S57cHCSuQO2gp/DAP-Design-System-1.2?node-id=14829-217
|
|
2
|
+
// source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-tabs
|
|
3
|
+
// component=DsTabs.Tab
|
|
4
|
+
//
|
|
5
|
+
// `DAP_Tab item - horizontal_v01` maps to `DsTabs.Tab`. It resolves inside the
|
|
6
|
+
// horizontal `tabs slot` (nestable).
|
|
7
|
+
//
|
|
8
|
+
// Variant divergence — these Figma axes intentionally have no `DsTabs.Tab` prop:
|
|
9
|
+
// • `State` (Default/Hover/Pressed) — visual only, driven by CSS.
|
|
10
|
+
// • `Selected` (Yes/No) — selection is owned by `DsTabs.Root` (`value`), not the tab.
|
|
11
|
+
// • `Size` (Base) — size lives on `DsTabs.Root` (`size`), not the tab.
|
|
12
|
+
import figma from 'figma';
|
|
13
|
+
|
|
14
|
+
const instance = figma.selectedInstance;
|
|
15
|
+
|
|
16
|
+
const label = instance.getString('Tab Name');
|
|
17
|
+
const showIcon = instance.getBoolean('Show leading icon');
|
|
18
|
+
const showBadge = instance.getBoolean('Show Badge');
|
|
19
|
+
const hasMenu = instance.getBoolean('Menu Actions');
|
|
20
|
+
|
|
21
|
+
// `value` is required by `DsTabsTabProps` but is data, not derivable from Figma.
|
|
22
|
+
// Slugify the label as a sensible default for the developer to confirm/replace.
|
|
23
|
+
const value = label
|
|
24
|
+
? label
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
27
|
+
.replace(/^-+|-+$/g, '')
|
|
28
|
+
: 'tab';
|
|
29
|
+
|
|
30
|
+
// The leading icon maps to `DsTabs.Tab.icon` (an icon-name string). It is a
|
|
31
|
+
// connected ds-icon instance: read its Code Connect id (`ds-icon-o-`/`-s-`) and
|
|
32
|
+
// fall back to the layer name when it is unavailable.
|
|
33
|
+
const resolveIcon = (): string | undefined => {
|
|
34
|
+
const node = instance
|
|
35
|
+
.findConnectedInstances((n) => n.codeConnectId()?.startsWith('ds-icon-') ?? false, {
|
|
36
|
+
traverseInstances: true,
|
|
37
|
+
})
|
|
38
|
+
.find((n): n is figma.InstanceHandle => n.type === 'INSTANCE');
|
|
39
|
+
|
|
40
|
+
if (!node) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const id = node.codeConnectId();
|
|
45
|
+
if (id?.startsWith('ds-icon-o-')) {
|
|
46
|
+
return id.slice('ds-icon-o-'.length);
|
|
47
|
+
}
|
|
48
|
+
if (id?.startsWith('ds-icon-s-')) {
|
|
49
|
+
return id.slice('ds-icon-s-'.length);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return node.name
|
|
53
|
+
.replace(/^DAP_GM_[OS]_/, '')
|
|
54
|
+
.replace(/^DAP_/, '')
|
|
55
|
+
.replace(/[\s/]+/g, '_')
|
|
56
|
+
.toLowerCase();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const icon = showIcon ? resolveIcon() : undefined;
|
|
60
|
+
|
|
61
|
+
// The badge count is freeform nested text (`DAP_Tab badge_v01`), not a component
|
|
62
|
+
// property, so read it from the badge instance when shown.
|
|
63
|
+
const resolveBadge = (): string | undefined => {
|
|
64
|
+
const badge = instance.findInstance('DAP_Tab badge_v01', { traverseInstances: true });
|
|
65
|
+
if (badge.type !== 'INSTANCE') {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return badge.children.find((c): c is figma.TextHandle => c.type === 'TEXT')?.textContent;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const badge = showBadge ? resolveBadge() : undefined;
|
|
72
|
+
const badgeAttr = badge ? (/^\d+$/.test(badge) ? `badge={${badge}}` : `badge="${badge}"`) : '';
|
|
73
|
+
|
|
74
|
+
const attrs = [
|
|
75
|
+
`value="${value}"`,
|
|
76
|
+
`label="${label}"`,
|
|
77
|
+
icon ? `icon="${icon}"` : '',
|
|
78
|
+
badgeAttr,
|
|
79
|
+
hasMenu ? 'menuActionItems={[]} onMenuActionSelect={() => {}}' : '',
|
|
80
|
+
]
|
|
81
|
+
.filter(Boolean)
|
|
82
|
+
.join(' ');
|
|
83
|
+
|
|
84
|
+
export default {
|
|
85
|
+
example: figma.code`<DsTabs.Tab ${attrs} />`,
|
|
86
|
+
imports: ["import { DsTabs } from '@drivenets/design-system'"],
|
|
87
|
+
id: 'ds-tabs-tab',
|
|
88
|
+
metadata: { nestable: true },
|
|
89
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// url=https://www.figma.com/design/nha3m67y7S57cHCSuQO2gp/DAP-Design-System-1.2?node-id=14841-11560
|
|
2
|
+
// source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-tabs
|
|
3
|
+
// component=DsTabs
|
|
4
|
+
//
|
|
5
|
+
// `DAP_Tabs group-vertical_v01` is the vertical tab bar. Horizontal and vertical
|
|
6
|
+
// are separate Figma component sets but a single code component switched by the
|
|
7
|
+
// `orientation` prop, so this template mirrors `ds-tabs.figma.ts` with
|
|
8
|
+
// `orientation="vertical"`. The `tabs slot` resolves each vertical tab item via
|
|
9
|
+
// its own template (`DsTabs.Tab`); `DsTabs.Content` panels are authored in code.
|
|
10
|
+
import figma from 'figma';
|
|
11
|
+
|
|
12
|
+
// The vertical set labels its size `Base` (= default `medium`); also accept the
|
|
13
|
+
// horizontal naming so a future shared variant keeps mapping to the `size` prop.
|
|
14
|
+
const size = figma.selectedInstance.getEnum('Size', {
|
|
15
|
+
Base: 'medium',
|
|
16
|
+
medium: 'medium',
|
|
17
|
+
small: 'small',
|
|
18
|
+
});
|
|
19
|
+
const sizeAttr = size === 'small' ? ' size="small"' : '';
|
|
20
|
+
|
|
21
|
+
const tabs = figma.selectedInstance.getSlot('tabs slot');
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
example: figma.code`<DsTabs.Root orientation="vertical"${sizeAttr}>
|
|
25
|
+
<DsTabs.List>${tabs}</DsTabs.List>
|
|
26
|
+
{/* Add a <DsTabs.Content value="..."> panel for each tab */}
|
|
27
|
+
</DsTabs.Root>`,
|
|
28
|
+
imports: ["import { DsTabs } from '@drivenets/design-system'"],
|
|
29
|
+
id: 'ds-tabs-vertical',
|
|
30
|
+
metadata: { nestable: false },
|
|
31
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// url=https://www.figma.com/design/nha3m67y7S57cHCSuQO2gp/DAP-Design-System-1.2?node-id=14841-11053
|
|
2
|
+
// source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-tabs
|
|
3
|
+
// component=DsTabs
|
|
4
|
+
//
|
|
5
|
+
// `DAP_Tabs group-horizontal_v01` is the horizontal tab bar. It maps to the
|
|
6
|
+
// composed `DsTabs.Root` + `DsTabs.List`. The `tabs slot` resolves each tab item
|
|
7
|
+
// via its own Code Connect template (`DsTabs.Tab`), so added/removed tabs stay in
|
|
8
|
+
// sync. Figma only models the tab bar — the `DsTabs.Content` panels have no Figma
|
|
9
|
+
// equivalent and are authored in code, so the snippet emits a hint instead.
|
|
10
|
+
import figma from 'figma';
|
|
11
|
+
|
|
12
|
+
const instance = figma.selectedInstance;
|
|
13
|
+
|
|
14
|
+
// Figma's group `Size` is the code `size` prop; `medium` is the default so only
|
|
15
|
+
// `small` is emitted.
|
|
16
|
+
const size = instance.getEnum('Size', { medium: 'medium', small: 'small' });
|
|
17
|
+
const sizeAttr = size === 'small' ? ' size="small"' : '';
|
|
18
|
+
|
|
19
|
+
const tabs = instance.getSlot('tabs slot');
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
example: figma.code`<DsTabs.Root orientation="horizontal"${sizeAttr}>
|
|
23
|
+
<DsTabs.List>${tabs}</DsTabs.List>
|
|
24
|
+
{/* Add a <DsTabs.Content value="..."> panel for each tab */}
|
|
25
|
+
</DsTabs.Root>`,
|
|
26
|
+
imports: ["import { DsTabs } from '@drivenets/design-system'"],
|
|
27
|
+
id: 'ds-tabs',
|
|
28
|
+
metadata: { nestable: false },
|
|
29
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// url=https://www.figma.com/design/nha3m67y7S57cHCSuQO2gp/DAP-Design-System-1.2?node-id=39475-58722
|
|
2
|
+
// source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-text-input
|
|
3
|
+
// component=DsTextInput
|
|
4
|
+
import figma from 'figma';
|
|
5
|
+
|
|
6
|
+
interface FieldInfo {
|
|
7
|
+
component: string;
|
|
8
|
+
fcMember?: string;
|
|
9
|
+
size?: boolean;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
invalid?: boolean;
|
|
12
|
+
data?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const textInfo: FieldInfo = { component: 'DsTextInput', fcMember: 'TextInput', size: true, readOnly: true };
|
|
16
|
+
|
|
17
|
+
const registry: Record<string, FieldInfo> = {
|
|
18
|
+
text: textInfo,
|
|
19
|
+
textArea: { component: 'DsTextarea', fcMember: 'Textarea' },
|
|
20
|
+
number: { component: 'DsNumberInput', fcMember: 'NumberInput', size: true, readOnly: true },
|
|
21
|
+
password: { component: 'DsPasswordInput', fcMember: 'PasswordInput', size: true, readOnly: true },
|
|
22
|
+
select: { component: 'DsSelect', fcMember: 'Select', invalid: true, data: 'options={[]} value=""' },
|
|
23
|
+
date: { component: 'DsDateInput', fcMember: 'DateInput' },
|
|
24
|
+
time: { component: 'DsTimePicker', fcMember: 'TimePicker' },
|
|
25
|
+
autocompleteSearch: {
|
|
26
|
+
component: 'DsAutocomplete',
|
|
27
|
+
invalid: true,
|
|
28
|
+
data: 'options={[]} showTrigger={false}',
|
|
29
|
+
},
|
|
30
|
+
autocompleteCombobox: { component: 'DsAutocomplete', invalid: true, data: 'options={[]}' },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const instance = figma.selectedInstance;
|
|
34
|
+
|
|
35
|
+
const size = instance.getEnum('size', {
|
|
36
|
+
small: 'small',
|
|
37
|
+
medium: 'medium',
|
|
38
|
+
large: 'large',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const state = instance.getEnum('state', {
|
|
42
|
+
default: 'default',
|
|
43
|
+
hover: 'hover',
|
|
44
|
+
focus: 'focus',
|
|
45
|
+
disabled: 'disabled',
|
|
46
|
+
'read-only': 'readOnly',
|
|
47
|
+
error: 'error',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const part = instance.findInstance('DAP-part_InputType_v01', { traverseInstances: true });
|
|
51
|
+
const inputType =
|
|
52
|
+
(part.type === 'INSTANCE'
|
|
53
|
+
? part.getEnum('inputType', {
|
|
54
|
+
text: 'text',
|
|
55
|
+
'text-area': 'textArea',
|
|
56
|
+
select: 'select',
|
|
57
|
+
password: 'password',
|
|
58
|
+
number: 'number',
|
|
59
|
+
date: 'date',
|
|
60
|
+
time: 'time',
|
|
61
|
+
'autocomplete-search': 'autocompleteSearch',
|
|
62
|
+
'autocomplete-combobox': 'autocompleteCombobox',
|
|
63
|
+
})
|
|
64
|
+
: 'text') ?? 'text';
|
|
65
|
+
|
|
66
|
+
const info = registry[inputType] ?? textInfo;
|
|
67
|
+
|
|
68
|
+
const disabled = state === 'disabled';
|
|
69
|
+
const readOnly = state === 'readOnly';
|
|
70
|
+
const error = state === 'error';
|
|
71
|
+
|
|
72
|
+
const attrs = [
|
|
73
|
+
info.size && size === 'small' ? 'size="small"' : '',
|
|
74
|
+
info.data ?? '',
|
|
75
|
+
disabled ? 'disabled' : '',
|
|
76
|
+
info.readOnly && readOnly ? 'readOnly' : '',
|
|
77
|
+
info.invalid && error ? 'invalid' : '',
|
|
78
|
+
]
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join(' ');
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
example: figma.code`<${info.component} ${attrs} />`,
|
|
84
|
+
imports: [`import { ${info.component} } from '@drivenets/design-system'`],
|
|
85
|
+
id: 'ds-input-field-v02',
|
|
86
|
+
metadata: { nestable: true, props: { fcMember: info.fcMember, fcProps: attrs } },
|
|
87
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// url=https://www.figma.com/design/nha3m67y7S57cHCSuQO2gp/DAP-Design-System-1.2?node-id=15100-3016
|
|
2
|
+
// source=https://github.com/drivenets/design-system/tree/main/packages/design-system/src/components/ds-toast
|
|
3
|
+
// component=DsToast
|
|
4
|
+
import figma from 'figma';
|
|
5
|
+
|
|
6
|
+
const instance = figma.selectedInstance;
|
|
7
|
+
|
|
8
|
+
const variant = instance.getEnum('Type', {
|
|
9
|
+
info: 'info',
|
|
10
|
+
success: 'success',
|
|
11
|
+
warning: 'warning',
|
|
12
|
+
error: 'error',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const extended = instance.getEnum('Extended', { True: true, False: false });
|
|
16
|
+
const cta = instance.getEnum('CTA', { True: true, False: false });
|
|
17
|
+
|
|
18
|
+
const titleLine = extended ? `\n\ttitle: 'Title',` : '';
|
|
19
|
+
const actionsLine = cta ? `\n\tactions: <DsButtonV3 variant="secondary">Action</DsButtonV3>,` : '';
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
example: figma.code`const { createToast } = useToaster();
|
|
23
|
+
|
|
24
|
+
createToast({
|
|
25
|
+
variant: '${variant}',${titleLine}
|
|
26
|
+
description: 'Description',${actionsLine}
|
|
27
|
+
});`,
|
|
28
|
+
imports: [
|
|
29
|
+
"import { useToaster } from '@drivenets/design-system'",
|
|
30
|
+
"import { DsButtonV3 } from '@drivenets/design-system'",
|
|
31
|
+
],
|
|
32
|
+
id: 'ds-toast',
|
|
33
|
+
metadata: { nestable: false },
|
|
34
|
+
};
|
|
@@ -51,4 +51,7 @@ const DsToastGroup: React.FC<{ toaster: CreateToasterReturn }> = ({ toaster }) =
|
|
|
51
51
|
return <Toaster toaster={toaster}>{(toast: DsToastProps) => <DsToast {...toast} />}</Toaster>;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
DsToast.displayName = 'DsToast';
|
|
55
|
+
DsToastGroup.displayName = 'DsToastGroup';
|
|
56
|
+
|
|
54
57
|
export { DsToast, DsToastGroup };
|