@primer/react
Version:
An implementation of GitHub's Primer Design System using React
237 lines (232 loc) • 6.05 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var reactCompilerRuntime = require('react-compiler-runtime');
var reactIs = require('react-is');
var SegmentedControl_module = require('./SegmentedControl.module.css.js');
var clsx = require('clsx');
var BoxWithFallback = require('../internal/components/BoxWithFallback.js');
var jsxRuntime = require('react/jsx-runtime');
var useFeatureFlag = require('../FeatureFlags/useFeatureFlag.js');
var Tooltip = require('../TooltipV2/Tooltip.js');
const SegmentedControlIconButton = t0 => {
const $ = reactCompilerRuntime.c(50);
let Icon;
let ariaLabel;
let className;
let description;
let rest;
let selected;
let sxProp;
let tooltipDirection;
if ($[0] !== t0) {
({
"aria-label": ariaLabel,
icon: Icon,
selected,
sx: sxProp,
className,
description,
tooltipDirection,
...rest
} = t0);
$[0] = t0;
$[1] = Icon;
$[2] = ariaLabel;
$[3] = className;
$[4] = description;
$[5] = rest;
$[6] = selected;
$[7] = sxProp;
$[8] = tooltipDirection;
} else {
Icon = $[1];
ariaLabel = $[2];
className = $[3];
description = $[4];
rest = $[5];
selected = $[6];
sxProp = $[7];
tooltipDirection = $[8];
}
const tooltipFlagEnabled = useFeatureFlag.useFeatureFlag("primer_react_segmented_control_tooltip");
if (tooltipFlagEnabled) {
let t1;
if ($[9] !== className) {
t1 = clsx.clsx(SegmentedControl_module.Item, className);
$[9] = className;
$[10] = t1;
} else {
t1 = $[10];
}
const t2 = selected || undefined;
const t3 = description ? undefined : "label";
const t4 = description ? description : ariaLabel;
const t5 = description ? ariaLabel : undefined;
let t6;
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
t6 = clsx.clsx(SegmentedControl_module.Button, SegmentedControl_module.IconButton);
$[11] = t6;
} else {
t6 = $[11];
}
let t7;
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
t7 = clsx.clsx(SegmentedControl_module.Content, "segmentedControl-content");
$[12] = t7;
} else {
t7 = $[12];
}
let t8;
if ($[13] !== Icon) {
t8 = reactIs.isElement(Icon) ? Icon : /*#__PURE__*/jsxRuntime.jsx(Icon, {});
$[13] = Icon;
$[14] = t8;
} else {
t8 = $[14];
}
let t9;
if ($[15] !== t8) {
t9 = /*#__PURE__*/jsxRuntime.jsx("span", {
className: t7,
children: t8
});
$[15] = t8;
$[16] = t9;
} else {
t9 = $[16];
}
let t10;
if ($[17] !== rest || $[18] !== selected || $[19] !== t5 || $[20] !== t9) {
t10 = /*#__PURE__*/jsxRuntime.jsx(BoxWithFallback.BoxWithFallback, {
as: "button",
"aria-current": selected,
"aria-label": t5,
className: t6,
...rest,
children: t9
});
$[17] = rest;
$[18] = selected;
$[19] = t5;
$[20] = t9;
$[21] = t10;
} else {
t10 = $[21];
}
let t11;
if ($[22] !== t10 || $[23] !== t3 || $[24] !== t4 || $[25] !== tooltipDirection) {
t11 = /*#__PURE__*/jsxRuntime.jsx(Tooltip.Tooltip, {
type: t3,
text: t4,
direction: tooltipDirection,
children: t10
});
$[22] = t10;
$[23] = t3;
$[24] = t4;
$[25] = tooltipDirection;
$[26] = t11;
} else {
t11 = $[26];
}
let t12;
if ($[27] !== sxProp || $[28] !== t1 || $[29] !== t11 || $[30] !== t2) {
t12 = /*#__PURE__*/jsxRuntime.jsx(BoxWithFallback.BoxWithFallback, {
as: "li",
sx: sxProp,
className: t1,
"data-selected": t2,
children: t11
});
$[27] = sxProp;
$[28] = t1;
$[29] = t11;
$[30] = t2;
$[31] = t12;
} else {
t12 = $[31];
}
return t12;
} else {
let t1;
if ($[32] !== className) {
t1 = clsx.clsx(SegmentedControl_module.Item, className);
$[32] = className;
$[33] = t1;
} else {
t1 = $[33];
}
const t2 = selected || undefined;
let t3;
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
t3 = clsx.clsx(SegmentedControl_module.Button, SegmentedControl_module.IconButton);
$[34] = t3;
} else {
t3 = $[34];
}
let t4;
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
t4 = clsx.clsx(SegmentedControl_module.Content, "segmentedControl-content");
$[35] = t4;
} else {
t4 = $[35];
}
let t5;
if ($[36] !== Icon) {
t5 = reactIs.isElement(Icon) ? Icon : /*#__PURE__*/jsxRuntime.jsx(Icon, {});
$[36] = Icon;
$[37] = t5;
} else {
t5 = $[37];
}
let t6;
if ($[38] !== t5) {
t6 = /*#__PURE__*/jsxRuntime.jsx("span", {
className: t4,
children: t5
});
$[38] = t5;
$[39] = t6;
} else {
t6 = $[39];
}
let t7;
if ($[40] !== ariaLabel || $[41] !== rest || $[42] !== selected || $[43] !== t6) {
t7 = /*#__PURE__*/jsxRuntime.jsx(BoxWithFallback.BoxWithFallback, {
as: "button",
"aria-label": ariaLabel,
"aria-current": selected,
className: t3,
...rest,
children: t6
});
$[40] = ariaLabel;
$[41] = rest;
$[42] = selected;
$[43] = t6;
$[44] = t7;
} else {
t7 = $[44];
}
let t8;
if ($[45] !== sxProp || $[46] !== t1 || $[47] !== t2 || $[48] !== t7) {
t8 = /*#__PURE__*/jsxRuntime.jsx(BoxWithFallback.BoxWithFallback, {
as: "li",
sx: sxProp,
className: t1,
"data-selected": t2,
children: t7
});
$[45] = sxProp;
$[46] = t1;
$[47] = t2;
$[48] = t7;
$[49] = t8;
} else {
t8 = $[49];
}
return t8;
}
};
exports.SegmentedControlIconButton = SegmentedControlIconButton;
exports.default = SegmentedControlIconButton;