feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
Lago committed 2026-04-14 18:52:25 +00:00
1 parent 1199eff6c3
commit dfa4010406
34820 files changed
+1003810 -202

No files matched your search

@@ -0,0 +1,170 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
adjustColumnWidthsToFitContainer: function() {
return adjustColumnWidthsToFitContainer;
},
columnDefinitionsToState: function() {
return columnDefinitionsToState;
},
getColumnById: function() {
return getColumnById;
},
getColumnByIndex: function() {
return getColumnByIndex;
},
getColumnWidth: function() {
return getColumnWidth;
},
getLength: function() {
return getLength;
},
getTotalWidth: function() {
return getTotalWidth;
},
setColumnProperty: function() {
return setColumnProperty;
}
});
const DEFAULT_WIDTH = 150;
const DEFAULT_MIN_WIDTH = 100;
function columnDefinitionsToState(columns, state = [], columnSizingOptions = {}) {
let updated = false;
const stateMap = new Map(state.map((s)=>[
s.columnId,
s
]));
const updatedState = columns.map((column)=>{
const existingColumnState = stateMap.get(column.columnId);
if (existingColumnState) {
var _columnSizingOptions_column_columnId;
const { idealWidth = existingColumnState.idealWidth, minWidth = existingColumnState.minWidth, padding = existingColumnState.padding } = (_columnSizingOptions_column_columnId = columnSizingOptions[column.columnId]) !== null && _columnSizingOptions_column_columnId !== void 0 ? _columnSizingOptions_column_columnId : {};
if (idealWidth !== existingColumnState.idealWidth || minWidth !== existingColumnState.minWidth || padding !== existingColumnState.padding) {
updated = true;
return {
...existingColumnState,
idealWidth,
width: idealWidth,
minWidth,
padding
};
}
return existingColumnState;
}
var _columnSizingOptions_column_columnId1;
const { defaultWidth, idealWidth = DEFAULT_WIDTH, minWidth = DEFAULT_MIN_WIDTH, padding } = (_columnSizingOptions_column_columnId1 = columnSizingOptions[column.columnId]) !== null && _columnSizingOptions_column_columnId1 !== void 0 ? _columnSizingOptions_column_columnId1 : {};
updated = true;
return {
columnId: column.columnId,
width: Math.max(defaultWidth !== null && defaultWidth !== void 0 ? defaultWidth : idealWidth, minWidth),
minWidth,
idealWidth: Math.max(defaultWidth !== null && defaultWidth !== void 0 ? defaultWidth : idealWidth, minWidth),
padding: padding !== null && padding !== void 0 ? padding : 16
};
});
// If the length of the new state changed (column was added or removed) or any of
// the individual states has a new reference (column was replaced),
// we have to reset the column widths to their ideal width (because the column which was last may not be last now).
// Then the adjustColumnWidthsToFitContainer can do its job and properly stretch the last column.
if (updatedState.length !== state.length || updated) {
const column = updatedState.find((col)=>col.width > col.idealWidth);
if (column) {
column.width = column.idealWidth;
}
updated = true;
}
return updated ? updatedState : state;
}
function getColumnById(state, columnId) {
return state.find((c)=>c.columnId === columnId);
}
function getColumnByIndex(state, index) {
return state[index];
}
function getTotalWidth(state) {
return state.reduce((sum, column)=>sum + column.width + column.padding, 0);
}
function getLength(state) {
return state.length;
}
function getColumnWidth(state, columnId) {
const column = getColumnById(state, columnId);
var _column_width;
return (_column_width = column === null || column === void 0 ? void 0 : column.width) !== null && _column_width !== void 0 ? _column_width : 0;
}
function setColumnProperty(localState, columnId, property, value) {
const currentColumn = getColumnById(localState, columnId);
if (!currentColumn || (currentColumn === null || currentColumn === void 0 ? void 0 : currentColumn[property]) === value) {
return localState;
}
const updatedColumn = {
...currentColumn,
[property]: value
};
const newState = localState.reduce((acc, current)=>{
if (current.columnId === updatedColumn.columnId) {
return [
...acc,
updatedColumn
];
}
return [
...acc,
current
];
}, []);
return newState;
}
function adjustColumnWidthsToFitContainer(state, containerWidth) {
let newState = state;
const totalWidth = getTotalWidth(newState);
// The total width is smaller, we are expanding columns
if (totalWidth < containerWidth) {
let difference = containerWidth - totalWidth;
let i = 0;
// We start at the beginning and assign the columns their ideal width
while(i < newState.length && difference > 0){
const currentCol = getColumnByIndex(newState, i);
if (!currentCol) {
break;
}
const colAdjustment = Math.min(currentCol.idealWidth - currentCol.width, difference);
newState = setColumnProperty(newState, currentCol.columnId, 'width', currentCol.width + colAdjustment);
difference -= colAdjustment;
// if there is still empty space, after all columns are their ideal sizes, assign it to the last column
if (i === newState.length - 1 && difference !== 0) {
const lastCol = getColumnByIndex(newState, i);
if (lastCol) {
newState = setColumnProperty(newState, lastCol.columnId, 'width', lastCol.width + difference);
}
}
i++;
}
} else if (totalWidth >= containerWidth) {
let difference = totalWidth - containerWidth;
// We start with the last column
let j = newState.length - 1;
while(j >= 0 && difference > 0){
const currentCol = getColumnByIndex(newState, j);
if (!currentCol) {
j--;
continue;
}
if (currentCol.width > currentCol.minWidth) {
const colAdjustment = Math.min(currentCol.width - currentCol.minWidth, difference);
difference -= colAdjustment;
newState = setColumnProperty(newState, currentCol.columnId, 'width', currentCol.width - colAdjustment);
}
j--;
}
}
return newState;
}
@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/columnResizeUtils.ts"],"sourcesContent":["import { TableColumnDefinition, ColumnWidthState, TableColumnId, TableColumnSizingOptions } from '../hooks';\n\nconst DEFAULT_WIDTH = 150;\nconst DEFAULT_MIN_WIDTH = 100;\n\n/**\n * This function takes the column definitions and the curent ColumnWidthState and returns new state.\n * - It uses existing state for existing columns.\n * - It removes any state for columns no longer present.\n * - It checks if any column has been replaced and returns updated state if so\n * - It returns old state if no changes in the state have been made (so that react doesn't call effects)\n * @param columns\n * @param state\n * @returns\n */\n\nexport function columnDefinitionsToState<T>(\n columns: TableColumnDefinition<T>[],\n state: ColumnWidthState[] = [],\n columnSizingOptions: TableColumnSizingOptions = {},\n): ColumnWidthState[] {\n let updated = false;\n const stateMap = new Map(state.map(s => [s.columnId, s]));\n\n const updatedState = columns.map(column => {\n const existingColumnState = stateMap.get(column.columnId);\n\n if (existingColumnState) {\n const {\n idealWidth = existingColumnState.idealWidth,\n minWidth = existingColumnState.minWidth,\n padding = existingColumnState.padding,\n } = columnSizingOptions[column.columnId] ?? {};\n\n if (\n idealWidth !== existingColumnState.idealWidth ||\n minWidth !== existingColumnState.minWidth ||\n padding !== existingColumnState.padding\n ) {\n updated = true;\n return {\n ...existingColumnState,\n idealWidth,\n width: idealWidth,\n minWidth,\n padding,\n };\n }\n return existingColumnState;\n }\n\n const {\n defaultWidth,\n idealWidth = DEFAULT_WIDTH,\n minWidth = DEFAULT_MIN_WIDTH,\n padding,\n } = columnSizingOptions[column.columnId] ?? {};\n\n updated = true;\n return {\n columnId: column.columnId,\n width: Math.max(defaultWidth ?? idealWidth, minWidth),\n minWidth,\n idealWidth: Math.max(defaultWidth ?? idealWidth, minWidth),\n padding: padding ?? 16,\n };\n });\n\n // If the length of the new state changed (column was added or removed) or any of\n // the individual states has a new reference (column was replaced),\n // we have to reset the column widths to their ideal width (because the column which was last may not be last now).\n // Then the adjustColumnWidthsToFitContainer can do its job and properly stretch the last column.\n if (updatedState.length !== state.length || updated) {\n const column = updatedState.find(col => col.width > col.idealWidth);\n if (column) {\n column.width = column.idealWidth;\n }\n\n updated = true;\n }\n\n return updated ? updatedState : state;\n}\n\nexport function getColumnById(state: ColumnWidthState[], columnId: TableColumnId): ColumnWidthState | undefined {\n return state.find(c => c.columnId === columnId);\n}\n\nexport function getColumnByIndex(state: ColumnWidthState[], index: number): ColumnWidthState | undefined {\n return state[index];\n}\n\nexport function getTotalWidth(state: ColumnWidthState[]): number {\n return state.reduce((sum, column) => sum + column.width + column.padding, 0);\n}\n\nexport function getLength(state: ColumnWidthState[]): number {\n return state.length;\n}\n\nexport function getColumnWidth(state: ColumnWidthState[], columnId: TableColumnId): number {\n const column = getColumnById(state, columnId);\n return column?.width ?? 0;\n}\n\n/**\n * This function takes the current state and returns an updated state, so that it can be set.\n * The reason for this is that we can update the state multiple times before commiting to render.\n * This is an optimization and also prevents flickering.\n * It also returns new copy of the state only if the value is different than the one currently in\n * the state, further preventing unnecessary updates.\n * @param localState\n * @param columnId\n * @param property\n * @param value\n * @returns\n */\nexport function setColumnProperty(\n localState: ColumnWidthState[],\n columnId: TableColumnId,\n property: keyof ColumnWidthState,\n value: number,\n): ColumnWidthState[] {\n const currentColumn = getColumnById(localState, columnId);\n\n if (!currentColumn || currentColumn?.[property] === value) {\n return localState;\n }\n\n const updatedColumn = { ...currentColumn, [property]: value };\n\n const newState = localState.reduce((acc, current) => {\n if (current.columnId === updatedColumn.columnId) {\n return [...acc, updatedColumn];\n }\n return [...acc, current];\n }, [] as ColumnWidthState[]);\n\n return newState;\n}\n\n/**\n * This function takes the state and container width and makes sure the each column in the state\n * is its optimal width, and that the columns\n * a) fit to the container\n * b) always fill the whole contaLine truncated
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isColumnSortable", {
enumerable: true,
get: function() {
return isColumnSortable;
}
});
function isColumnSortable(column) {
return column.compare.length > 0;
}
@@ -0,0 +1 @@
{"version":3,"sources":["../src/utils/isColumnSortable.ts"],"sourcesContent":["import { TableColumnDefinition } from '../hooks/types';\n\nexport function isColumnSortable(column: TableColumnDefinition<unknown>): boolean {\n return column.compare.length > 0;\n}\n"],"names":["isColumnSortable","column","compare","length"],"mappings":";;;;;;;;;;AAEO,SAASA,iBAAiBC,MAAsC;IACrE,OAAOA,OAAOC,OAAO,CAACC,MAAM,GAAG;AACjC"}