@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
99 lines (98 loc) • 3.28 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _iconsReactNative = require("@fruits-chain/icons-react-native");
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _style = require("../button/style.js");
var _checkboxIcon = _interopRequireDefault(require("../checkbox/checkbox-icon.js"));
var _index = _interopRequireDefault(require("../flex/index.js"));
var _index2 = _interopRequireDefault(require("../theme/index.js"));
var _style2 = require("./style.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const hitSlop = {
left: 8,
right: 8
};
const TreeItem = ({
theme,
tier,
indent,
switcherIcon,
switcherHighlight = true,
activeColor,
active,
multiple,
bold,
label,
renderLabel,
labelHighlight,
hasChildren,
onPressSwitcherIcon,
...restProps
}) => {
const [CV, STYLES] = _index2.default.useStyle({
varCreator: _style2.varCreator,
styleCreator: _style2.styleCreator,
theme
});
const [CV_BUTTON] = _index2.default.useStyle({
varCreator: _style.varCreator
});
const leftJSX = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_index.default, {
direction: "row",
align: "center",
children: [indent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View
// eslint-disable-next-line react-native/no-inline-styles
, {
style: {
width: tier * indent,
height: CV.tree_item_height
}
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.default, {
align: "center",
justify: "center",
style: hasChildren && switcherHighlight ? STYLES.tree_item_switcher : undefined,
children: switcherIcon
})]
});
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
...restProps,
activeOpacity: restProps.activeOpacity ?? CV_BUTTON.button_active_opacity,
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: STYLES.tree_item,
children: [hasChildren ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
onPress: onPressSwitcherIcon,
hitSlop: hitSlop,
children: leftJSX
}) : leftJSX, renderLabel ? renderLabel({
label,
disabled: restProps.disabled,
labelHighlight,
active,
activeColor
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [STYLES.tree_item_text, restProps.disabled && !hasChildren ? STYLES.tree_item_disabled_text : null, bold ?
// eslint-disable-next-line react-native/no-inline-styles
{
fontWeight: 'bold'
} : null, labelHighlight ? {
color: activeColor
} : null],
numberOfLines: 1,
children: label
}), multiple ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkboxIcon.default, {
active: active,
activeColor: activeColor,
disabled: restProps.disabled
}) : active ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsReactNative.SuccessOutline, {
color: activeColor
}) : null]
})
});
};
var _default = exports.default = TreeItem;
//# sourceMappingURL=tree-item.js.map
;