Repository URL to install this package:
|
Version:
2.0.4 ▾
|
"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {
value: true
});
/* eslint-disable brace-style */
const react_1 = __importDefault(require("react"));
const exotic_1 = require("exotic");
const link_container_1 = require("uxui-modules/link-container");
const Animations_1 = require("../../components/features/Animations");
const Image_1 = require("../Image");
const deps_1 = require("./deps");
const styled_1 = require("./styled"); // @todo !!!
function renderSnackbarToast(props, state) {// import ToastSnackbar from 'atoms/ToastSnackbar'
// const { ToastSnackbar } = require('atoms/ToastSnackbar')
// const snackbarTimeout = props.snackbarTimeout || 100009
// const snackbarText = props.snackbar || props.snackbarText || 'client customization'
// const handleToastClose = props.onSnackbarClose || NO_OP
// const handleUndo = props.onSnackbarClose || NO_OP
// return (
// <ToastSnackbar
// key="toast"
// autoHideTimeDuration={snackbarTimeout}
// message={snackbarText}
// onToastClose={handleToastClose}
// onToastUndo={handleUndo}
// />
// )
}
function renderSnackbar(props, state, view) {
if (state.isActive !== true) {
return view;
} else {
return react_1.default.createElement(react_1.default.Fragment, null, renderSnackbarToast(props, state), view);
}
}
exports.renderSnackbar = renderSnackbar;
function renderIcon(props) {
const IconComponentOrView = props.icon; // do we have one?
if (IconComponentOrView === undefined) {
return '';
} else if (react_1.default.isValidElement(IconComponentOrView)) {
// did we already render it?
return IconComponentOrView;
} else if (exotic_1.isFunction(IconComponentOrView)) {
// is a class/function/component
return react_1.default.createElement(IconComponentOrView, Object.assign({}, props, {
key: "icon"
}));
} else if (Image_1.isImage(IconComponentOrView)) {
return react_1.default.createElement(Image_1.Image, {
src: IconComponentOrView
});
} else {
/**
* @todo depending on event system - @see ReactEvents
*/
return '';
}
}
exports.renderIcon = renderIcon;
exports.toButtonOrLink = props => props.role === 'button' || props.role !== 'link' ? styled_1.StyledButton : styled_1.StyledDiv; // props: ButtonProps, state: ButtonState
function renderButtonOrLink(attributes, state) {
const accessibleAttributes = deps_1.toAccessibleAttributes(attributes, state);
const StyledComponent = exports.toButtonOrLink(attributes);
const eventHandlers = attributes.eventHandlers;
const value = attributes.children;
return react_1.default.createElement(StyledComponent, Object.assign({}, eventHandlers, attributes, accessibleAttributes), ' ', value, ' ');
}
exports.renderButtonOrLink = renderButtonOrLink;
/**
* @todo !!!!!!!!!! this needs finishing for rendering icon & text
*/
function renderText(props, state) {
const {
children,
isLink,
to
} = props;
let text = exotic_1.isString(children) ? react_1.default.createElement(styled_1.ButtonText, null, children) : children; // const accessibleArea = <span className="button-accessible" />
// we may pass in a link element manually
if (isLink === true && to !== undefined) {
// @todo - linkClassName
text = react_1.default.createElement(link_container_1.Link, {
to: to
}, text);
} // if (this.state.isActive === true && this.hasSnackbar === true) {
// text = <DotLoader />
// }
if (state.isActive === true) {
text = react_1.default.createElement(Animations_1.DotLoader, null);
}
}
exports.renderText = renderText;
function renderIconAndText(props, state) {
const {
icon,
text
} = props; // @todo - text select none with just an icon
const hasIconAndText = icon && text; // add icon if we have one
// to put icon after, either use `order` or we extend this
const value = hasIconAndText ? // both
[icon, text] : icon ? // just icon
icon : // just text
text;
return value;
}
exports.renderIconAndText = renderIconAndText; //# sourceMappingURL=renderProps.js.map