@uifabric/experiments
Version:
Experimental React components for building experiences for Office 365.
33 lines • 2.5 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { Icon as FabricIcon, Label as FabricLabel } from 'office-ui-fabric-react';
// PersonaPresence is not exported by OUFR, so we have to import it directly.
import { PersonaPresence as FabricPersonaPresence } from 'office-ui-fabric-react/lib/PersonaPresence';
import { createFactory } from '../Foundation';
// TODO: All contents of this file should eventually be removed.
// TODO: createFactory should no longer have to be explicitly called with component options containing defaultProp.
// (Consider adding a defaultProp option to styled so that createFactory can be internalized similar to createComponent)
// TODO: displayName will also be covered by createComponent argument.
// TODO: These components will also have to be modified not to generate rendered output if their props don't call for it
// to eliminate the wrapper functions below.
// Generally to avoid a bunch of "if slot prop exists" checks in parent components, components should
// make sure they have content to render based on their props. For example here, if Icon has no iconName,
// it has no rendered content and returns null. This prevents Button.view from having to check to
// see if its icon Slot is defined.
// These wrappers will temporarily add a layer to the hierarchy (identified with displayName) until their functionality
// can be absorbed into their respective OUFR components.
export var Icon = function (props) { return (props.iconName ? React.createElement(FabricIcon, tslib_1.__assign({}, props)) : null); };
Icon.displayName = 'Icon';
Icon.create = createFactory(Icon, { defaultProp: 'iconName' });
export var Label = function (props) {
return React.Children.count(props.children) > 0 ? React.createElement(FabricLabel, tslib_1.__assign({}, props)) : null;
};
Label.displayName = 'Label';
Label.create = createFactory(Label);
export var PersonaPresence =
// TODO: This is a bug in PersonaPresence that needs to be fixed. 'presence' prop comment mentions that it won't render
// if presence is undefined, but it does render. Check for undefined here for now.
function (props) { return (props.presence !== undefined ? React.createElement(FabricPersonaPresence, tslib_1.__assign({}, props)) : null); };
PersonaPresence.displayName = 'PersonaPresence';
PersonaPresence.create = createFactory(PersonaPresence, { defaultProp: 'presence' });
//# sourceMappingURL=factoryComponents.js.map