Private
Public Access
1
0

feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
2026-04-14 18:52:25 +00:00
parent 1199eff6c3
commit dfa4010406
34820 changed files with 1003813 additions and 205 deletions

View File

@@ -0,0 +1,19 @@
import type { Middleware } from '@floating-ui/dom';
import type { MiddlewareState } from '@floating-ui/dom';
/**
* devtools middleware
* @public
*/
declare const devtools: (targetDocument?: Document, middlewareDataCallback?: (state: MiddlewareState) => MiddlewareData) => Middleware;
export { devtools }
export { devtools as middleware }
/**
* @public
*/
export declare type MiddlewareData = {
type: `${string}Middleware`;
};
export { }

View File

@@ -0,0 +1,19 @@
import type { Middleware } from '@floating-ui/dom';
import type { MiddlewareState } from '@floating-ui/dom';
/**
* devtools middleware
* @public
*/
declare const devtools: (targetDocument?: Document, middlewareDataCallback?: (state: MiddlewareState) => MiddlewareData) => Middleware;
export { devtools }
export { devtools as middleware }
/**
* @public
*/
export declare type MiddlewareData = {
type: `${string}Middleware`;
};
export { }

View File

@@ -0,0 +1,185 @@
/**
* @internal
*/
const CONTROLLER = '__FUIDT_CONTROLLER__';
/**
* @internal
*/
const ELEMENT_METADATA = '__FUIDT_ELEMENT_METADATA__';
/**
* @internal
*/
const HTML_ELEMENT_REFERENCE = '__FUIDT_HTML_ELEMENT_REFERENCE__';
/**
* @internal
*/
const SERIALIZED_DATA_CHANGE = '__FUIDT_SERIALIZED_DATA_CHANGE__';
/**
* Verifies if a given node is an HTMLElement,
* this method works seamlessly with frames and elements from different documents
*
* This is preferred over simply using `instanceof`.
* Since `instanceof` might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
*
* @example
* ```ts
* isHTMLElement(event.target) && event.target.focus()
* isHTMLElement(event.target, {constructorName: 'HTMLInputElement'}) && event.target.value // some value
* ```
*
*/
function isHTMLElement(element, options) {
var _typedElement$ownerDo, _options$constructorN;
const typedElement = element;
return Boolean((typedElement == null || (_typedElement$ownerDo = typedElement.ownerDocument) == null ? void 0 : _typedElement$ownerDo.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView[(_options$constructorN = void 0 ) != null ? _options$constructorN : 'HTMLElement']);
}
/**
* @internal
*/
const isHTMLElementWithMetadata = element => Boolean(isHTMLElement(element) && ELEMENT_METADATA in element && element.parentElement !== null);
const createController = defaultView => {
let selectedElement = null;
const observer = new MutationObserver(mutations => {
if (!selectedElement) {
return;
}
for (const mutation of mutations) {
if (mutation.type === 'childList' && Array.from(mutation.removedNodes).includes(selectedElement)) {
controller.withdraw();
}
}
});
const controller = {
get selectedElement() {
return selectedElement;
},
select: nextSelectedElement => {
if (isHTMLElementWithMetadata(nextSelectedElement)) {
selectedElement = nextSelectedElement;
observer.observe(nextSelectedElement.parentElement, {
childList: true,
subtree: false
});
}
if (selectedElement && nextSelectedElement) {
const metadata = selectedElement[ELEMENT_METADATA];
if (metadata.references.has(nextSelectedElement)) {
return selectedElement;
}
}
controller.withdraw();
return selectedElement;
},
withdraw: () => {
selectedElement = null;
observer.disconnect();
defaultView.postMessage(SERIALIZED_DATA_CHANGE);
}
};
return controller;
};
const injectController = _ref => {
let {
defaultView
} = _ref;
if (!defaultView) {
return;
}
if (!defaultView[CONTROLLER]) {
defaultView[CONTROLLER] = createController(defaultView);
}
};
const getController = targetDocument => {
var _targetDocument$defau, _targetDocument$defau2;
injectController(targetDocument);
return (_targetDocument$defau = (_targetDocument$defau2 = targetDocument.defaultView) == null ? void 0 : _targetDocument$defau2[CONTROLLER]) != null ? _targetDocument$defau : null;
};
const serialize = (data, references) => {
const serializedData = JSON.parse(JSON.stringify(data, (_, value) => {
if (isHTMLElement(value)) return references.add(value);
if (typeof value === 'object' && value && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== Array.prototype) {
if ('toString' in value) {
return value.toString();
}
return undefined;
}
return value;
}));
return serializedData;
};
let counter = 0;
const generateReferenceId = () => HTML_ELEMENT_REFERENCE + ":" + counter++;
const createReferences = () => {
const map = new Map();
const weakMap = new WeakMap();
const references = {
add: element => {
if (weakMap.has(element)) {
return weakMap.get(element);
}
const id = generateReferenceId();
map.set(id, element);
weakMap.set(element, id);
return id;
},
get: id => {
const element = map.get(id);
if (element && weakMap.has(element)) {
return element;
}
},
has: element => {
return weakMap.has(element);
}
};
return references;
};
/**
* devtools middleware
* @public
*/
const devtools = function (targetDocument, middlewareDataCallback) {
if (targetDocument === void 0) {
targetDocument = document;
}
if (middlewareDataCallback === void 0) {
middlewareDataCallback = floatingUIMiddlewareDataCallback;
}
return {
name: '@floating-ui/devtools',
fn: state => {
const {
[ELEMENT_METADATA]: metadata
} = isHTMLElementWithMetadata(state.elements.floating) ? state.elements.floating : Object.assign(state.elements.floating, {
[ELEMENT_METADATA]: {
references: createReferences(),
serializedData: []
}
});
const serializedData = serialize(middlewareDataCallback(state), metadata.references);
metadata.serializedData.unshift(serializedData);
const controller = getController(targetDocument);
if (metadata.serializedData.length > 1 && state.elements.floating === (controller == null ? void 0 : controller.selectedElement)) {
var _targetDocument$defau;
(_targetDocument$defau = targetDocument.defaultView) == null || _targetDocument$defau.postMessage(SERIALIZED_DATA_CHANGE);
}
return {};
}
};
};
const floatingUIMiddlewareDataCallback = state => ({
...state,
type: 'FloatingUIMiddleware'
});
export { devtools, devtools as middleware };

View File

@@ -0,0 +1,185 @@
/**
* @internal
*/
const CONTROLLER = '__FUIDT_CONTROLLER__';
/**
* @internal
*/
const ELEMENT_METADATA = '__FUIDT_ELEMENT_METADATA__';
/**
* @internal
*/
const HTML_ELEMENT_REFERENCE = '__FUIDT_HTML_ELEMENT_REFERENCE__';
/**
* @internal
*/
const SERIALIZED_DATA_CHANGE = '__FUIDT_SERIALIZED_DATA_CHANGE__';
/**
* Verifies if a given node is an HTMLElement,
* this method works seamlessly with frames and elements from different documents
*
* This is preferred over simply using `instanceof`.
* Since `instanceof` might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
*
* @example
* ```ts
* isHTMLElement(event.target) && event.target.focus()
* isHTMLElement(event.target, {constructorName: 'HTMLInputElement'}) && event.target.value // some value
* ```
*
*/
function isHTMLElement(element, options) {
var _typedElement$ownerDo, _options$constructorN;
const typedElement = element;
return Boolean((typedElement == null || (_typedElement$ownerDo = typedElement.ownerDocument) == null ? void 0 : _typedElement$ownerDo.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView[(_options$constructorN = void 0 ) != null ? _options$constructorN : 'HTMLElement']);
}
/**
* @internal
*/
const isHTMLElementWithMetadata = element => Boolean(isHTMLElement(element) && ELEMENT_METADATA in element && element.parentElement !== null);
const createController = defaultView => {
let selectedElement = null;
const observer = new MutationObserver(mutations => {
if (!selectedElement) {
return;
}
for (const mutation of mutations) {
if (mutation.type === 'childList' && Array.from(mutation.removedNodes).includes(selectedElement)) {
controller.withdraw();
}
}
});
const controller = {
get selectedElement() {
return selectedElement;
},
select: nextSelectedElement => {
if (isHTMLElementWithMetadata(nextSelectedElement)) {
selectedElement = nextSelectedElement;
observer.observe(nextSelectedElement.parentElement, {
childList: true,
subtree: false
});
}
if (selectedElement && nextSelectedElement) {
const metadata = selectedElement[ELEMENT_METADATA];
if (metadata.references.has(nextSelectedElement)) {
return selectedElement;
}
}
controller.withdraw();
return selectedElement;
},
withdraw: () => {
selectedElement = null;
observer.disconnect();
defaultView.postMessage(SERIALIZED_DATA_CHANGE);
}
};
return controller;
};
const injectController = _ref => {
let {
defaultView
} = _ref;
if (!defaultView) {
return;
}
if (!defaultView[CONTROLLER]) {
defaultView[CONTROLLER] = createController(defaultView);
}
};
const getController = targetDocument => {
var _targetDocument$defau, _targetDocument$defau2;
injectController(targetDocument);
return (_targetDocument$defau = (_targetDocument$defau2 = targetDocument.defaultView) == null ? void 0 : _targetDocument$defau2[CONTROLLER]) != null ? _targetDocument$defau : null;
};
const serialize = (data, references) => {
const serializedData = JSON.parse(JSON.stringify(data, (_, value) => {
if (isHTMLElement(value)) return references.add(value);
if (typeof value === 'object' && value && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== Array.prototype) {
if ('toString' in value) {
return value.toString();
}
return undefined;
}
return value;
}));
return serializedData;
};
let counter = 0;
const generateReferenceId = () => HTML_ELEMENT_REFERENCE + ":" + counter++;
const createReferences = () => {
const map = new Map();
const weakMap = new WeakMap();
const references = {
add: element => {
if (weakMap.has(element)) {
return weakMap.get(element);
}
const id = generateReferenceId();
map.set(id, element);
weakMap.set(element, id);
return id;
},
get: id => {
const element = map.get(id);
if (element && weakMap.has(element)) {
return element;
}
},
has: element => {
return weakMap.has(element);
}
};
return references;
};
/**
* devtools middleware
* @public
*/
const devtools = function (targetDocument, middlewareDataCallback) {
if (targetDocument === void 0) {
targetDocument = document;
}
if (middlewareDataCallback === void 0) {
middlewareDataCallback = floatingUIMiddlewareDataCallback;
}
return {
name: '@floating-ui/devtools',
fn: state => {
const {
[ELEMENT_METADATA]: metadata
} = isHTMLElementWithMetadata(state.elements.floating) ? state.elements.floating : Object.assign(state.elements.floating, {
[ELEMENT_METADATA]: {
references: createReferences(),
serializedData: []
}
});
const serializedData = serialize(middlewareDataCallback(state), metadata.references);
metadata.serializedData.unshift(serializedData);
const controller = getController(targetDocument);
if (metadata.serializedData.length > 1 && state.elements.floating === (controller == null ? void 0 : controller.selectedElement)) {
var _targetDocument$defau;
(_targetDocument$defau = targetDocument.defaultView) == null || _targetDocument$defau.postMessage(SERIALIZED_DATA_CHANGE);
}
return {};
}
};
};
const floatingUIMiddlewareDataCallback = state => ({
...state,
type: 'FloatingUIMiddleware'
});
export { devtools, devtools as middleware };

View File

@@ -0,0 +1,194 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIDevtools = {}));
})(this, (function (exports) { 'use strict';
/**
* @internal
*/
const CONTROLLER = '__FUIDT_CONTROLLER__';
/**
* @internal
*/
const ELEMENT_METADATA = '__FUIDT_ELEMENT_METADATA__';
/**
* @internal
*/
const HTML_ELEMENT_REFERENCE = '__FUIDT_HTML_ELEMENT_REFERENCE__';
/**
* @internal
*/
const SERIALIZED_DATA_CHANGE = '__FUIDT_SERIALIZED_DATA_CHANGE__';
/**
* Verifies if a given node is an HTMLElement,
* this method works seamlessly with frames and elements from different documents
*
* This is preferred over simply using `instanceof`.
* Since `instanceof` might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
*
* @example
* ```ts
* isHTMLElement(event.target) && event.target.focus()
* isHTMLElement(event.target, {constructorName: 'HTMLInputElement'}) && event.target.value // some value
* ```
*
*/
function isHTMLElement(element, options) {
var _typedElement$ownerDo, _options$constructorN;
const typedElement = element;
return Boolean((typedElement == null || (_typedElement$ownerDo = typedElement.ownerDocument) == null ? void 0 : _typedElement$ownerDo.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView[(_options$constructorN = void 0 ) != null ? _options$constructorN : 'HTMLElement']);
}
/**
* @internal
*/
const isHTMLElementWithMetadata = element => Boolean(isHTMLElement(element) && ELEMENT_METADATA in element && element.parentElement !== null);
const createController = defaultView => {
let selectedElement = null;
const observer = new MutationObserver(mutations => {
if (!selectedElement) {
return;
}
for (const mutation of mutations) {
if (mutation.type === 'childList' && Array.from(mutation.removedNodes).includes(selectedElement)) {
controller.withdraw();
}
}
});
const controller = {
get selectedElement() {
return selectedElement;
},
select: nextSelectedElement => {
if (isHTMLElementWithMetadata(nextSelectedElement)) {
selectedElement = nextSelectedElement;
observer.observe(nextSelectedElement.parentElement, {
childList: true,
subtree: false
});
}
if (selectedElement && nextSelectedElement) {
const metadata = selectedElement[ELEMENT_METADATA];
if (metadata.references.has(nextSelectedElement)) {
return selectedElement;
}
}
controller.withdraw();
return selectedElement;
},
withdraw: () => {
selectedElement = null;
observer.disconnect();
defaultView.postMessage(SERIALIZED_DATA_CHANGE);
}
};
return controller;
};
const injectController = _ref => {
let {
defaultView
} = _ref;
if (!defaultView) {
return;
}
if (!defaultView[CONTROLLER]) {
defaultView[CONTROLLER] = createController(defaultView);
}
};
const getController = targetDocument => {
var _targetDocument$defau, _targetDocument$defau2;
injectController(targetDocument);
return (_targetDocument$defau = (_targetDocument$defau2 = targetDocument.defaultView) == null ? void 0 : _targetDocument$defau2[CONTROLLER]) != null ? _targetDocument$defau : null;
};
const serialize = (data, references) => {
const serializedData = JSON.parse(JSON.stringify(data, (_, value) => {
if (isHTMLElement(value)) return references.add(value);
if (typeof value === 'object' && value && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== Array.prototype) {
if ('toString' in value) {
return value.toString();
}
return undefined;
}
return value;
}));
return serializedData;
};
let counter = 0;
const generateReferenceId = () => HTML_ELEMENT_REFERENCE + ":" + counter++;
const createReferences = () => {
const map = new Map();
const weakMap = new WeakMap();
const references = {
add: element => {
if (weakMap.has(element)) {
return weakMap.get(element);
}
const id = generateReferenceId();
map.set(id, element);
weakMap.set(element, id);
return id;
},
get: id => {
const element = map.get(id);
if (element && weakMap.has(element)) {
return element;
}
},
has: element => {
return weakMap.has(element);
}
};
return references;
};
/**
* devtools middleware
* @public
*/
const devtools = function (targetDocument, middlewareDataCallback) {
if (targetDocument === void 0) {
targetDocument = document;
}
if (middlewareDataCallback === void 0) {
middlewareDataCallback = floatingUIMiddlewareDataCallback;
}
return {
name: '@floating-ui/devtools',
fn: state => {
const {
[ELEMENT_METADATA]: metadata
} = isHTMLElementWithMetadata(state.elements.floating) ? state.elements.floating : Object.assign(state.elements.floating, {
[ELEMENT_METADATA]: {
references: createReferences(),
serializedData: []
}
});
const serializedData = serialize(middlewareDataCallback(state), metadata.references);
metadata.serializedData.unshift(serializedData);
const controller = getController(targetDocument);
if (metadata.serializedData.length > 1 && state.elements.floating === (controller == null ? void 0 : controller.selectedElement)) {
var _targetDocument$defau;
(_targetDocument$defau = targetDocument.defaultView) == null || _targetDocument$defau.postMessage(SERIALIZED_DATA_CHANGE);
}
return {};
}
};
};
const floatingUIMiddlewareDataCallback = state => ({
...state,
type: 'FloatingUIMiddleware'
});
exports.devtools = devtools;
exports.middleware = devtools;
}));

View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIDevtools={})}(this,(function(e){"use strict";const t="__FUIDT_CONTROLLER__",n="__FUIDT_ELEMENT_METADATA__",o="__FUIDT_SERIALIZED_DATA_CHANGE__";function l(e,t){var n;const o=e;return Boolean((null==o||null==(n=o.ownerDocument)?void 0:n.defaultView)&&o instanceof o.ownerDocument.defaultView[null!=void 0?undefined:"HTMLElement"])}const i=e=>Boolean(l(e)&&n in e&&null!==e.parentElement),r=e=>{let{defaultView:l}=e;l&&(l[t]||(l[t]=(e=>{let t=null;const l=new MutationObserver((e=>{if(t)for(const n of e)"childList"===n.type&&Array.from(n.removedNodes).includes(t)&&r.withdraw()})),r={get selectedElement(){return t},select:e=>(i(e)&&(t=e,l.observe(e.parentElement,{childList:!0,subtree:!1})),t&&e&&t[n].references.has(e)||r.withdraw(),t),withdraw:()=>{t=null,l.disconnect(),e.postMessage(o)}};return r})(l)))};let s=0;const a=()=>{const e=new Map,t=new WeakMap;return{add:n=>{if(t.has(n))return t.get(n);const o="__FUIDT_HTML_ELEMENT_REFERENCE__:"+s++;return e.set(o,n),t.set(n,o),o},get:n=>{const o=e.get(n);if(o&&t.has(o))return o},has:e=>t.has(e)}},d=function(e,s){return void 0===e&&(e=document),void 0===s&&(s=u),{name:"@floating-ui/devtools",fn:d=>{const{[n]:u}=i(d.elements.floating)?d.elements.floating:Object.assign(d.elements.floating,{[n]:{references:a(),serializedData:[]}}),f=(c=s(d),_=u.references,JSON.parse(JSON.stringify(c,((e,t)=>l(t)?_.add(t):"object"==typeof t&&t&&Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==Array.prototype?"toString"in t?t.toString():void 0:t))));var c,_;u.serializedData.unshift(f);const p=(e=>{var n,o;return r(e),null!=(n=null==(o=e.defaultView)?void 0:o[t])?n:null})(e);var g;u.serializedData.length>1&&d.elements.floating===(null==p?void 0:p.selectedElement)&&(null==(g=e.defaultView)||g.postMessage(o));return{}}}},u=e=>({...e,type:"FloatingUIMiddleware"});e.devtools=d,e.middleware=d}));