Repository URL to install this package:
|
Version:
2.0.2 ▾
|
"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {
value: true
});
/* eslint-disable valid-jsdoc */
const react_1 = __importDefault(require("react"));
const classnames_1 = __importDefault(require("classnames")); // domain
const CheckBoxIcon_1 = __importDefault(require("../../../../components/atoms/Icons/CheckBoxIcon"));
const RadioIcon_1 = __importDefault(require("../../../../components/atoms/Icons/RadioIcon"));
const inputs_1 = require("../inputs"); // mixed these up woop
const ToggleLabel_1 = require("../ToggleLabel");
const Label_1 = __importDefault(require("../Label"));
exports.renderCheckbox = props => react_1.default.createElement(inputs_1.CheckboxInput, null);
exports.renderRadio = props => react_1.default.createElement(inputs_1.RadioInput, null);
exports.renderRadioIcon = props => // console.log('renderRadioIcon____state', props)
react_1.default.createElement(RadioIcon_1.default, {
onClick: props.handleChange,
isSelected: state.isSelected
}); // only giving 1 prop
exports.renderCheckboxIcon = props => react_1.default.createElement(CheckBoxIcon_1.default, {
isSelected: props.isSelected,
shouldAlignRight: props.shouldAlignRight
});
exports.toLabelClassName = props => {
const {
className,
isSelected,
isActive,
isDisabled
} = props;
console.log('[Toggle] selected values', isDisabled); // @todo remove or fixture
const type = props.isRadio ? 'radio' : 'checkbox';
const computedClassName = 'label-wrap label-wrap-' + type; // @todo can optimize with sealed
return classnames_1.default(computedClassName, className, {
active: isSelected,
inactive: !isSelected,
disable: isDisabled
});
};
function renderLabelWrapper(props) {
return (// we click on the wrapper
react_1.default.createElement(Label_1.default, {
identifier: props.identifier,
className: exports.toLabelClassName(props),
onClick: props.onClick,
children: props.children,
isDisabled: props.isDisabled
})
);
}
exports.renderLabelWrapper = renderLabelWrapper;
function renderLabelText(props) {
const {
isColor
} = props;
switch (true) {
case isColor:
return false;
default:
return react_1.default.createElement(ToggleLabel_1.ToggleLabel // could handle this more fancy,
// but if we have a set of props & nothing more
// this works restrictively for now
, {
// could handle this more fancy,
// but if we have a set of props & nothing more
// this works restrictively for now
text: props.text,
// not sure if we need both
// probably would work to have as a renderProp
secondaryText: props.secondaryText || props.count || '',
image: props.image
});
}
}
exports.renderLabelText = renderLabelText; // @todo only the color needed
// const renderColorIcon = props => <ColorContainer {...props} />
function renderColorIcon(props) {
return '@@todo color';
}
exports.renderColorIcon = renderColorIcon;
function renderInput(props) {
const {
isRadio,
isCheckbox
} = props; // @todo @fixme @later @wcag @accessibility
return react_1.default.createElement("input", {
"data-todo": true,
hidden: true
}); // switch (true) {
// case isRadio: return renderCheckbox()
// default: return renderRadio()
// }
}
exports.renderInput = renderInput; // here though, props
function renderIcon(props) {
const {
isRadio,
isCheckbox,
isColor
} = props;
switch (true) {
case isCheckbox:
return exports.renderCheckboxIcon(props);
case isRadio:
return exports.renderRadioIcon(props);
case isColor:
return renderColorIcon(props);
default:
return exports.renderCheckboxIcon(props);
}
}
exports.renderIcon = renderIcon; //# sourceMappingURL=_renderProps.js.map