@atlaskit/checkbox
Version:
A checkbox is an input control that allows a user to select one or more options from a number of choices.
97 lines (94 loc) • 4.33 kB
JavaScript
/* checkbox-icon.tsx generated by @compiled/babel-plugin v0.36.1 */
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
var _svg = _interopRequireDefault(require("@atlaskit/icon/svg"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function getIcon(isIndeterminate, isChecked) {
if (isIndeterminate) {
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
if ((0, _platformFeatureFlags.fg)('platform-visual-refresh-icons') && (0, _platformFeatureFlags.fg)('platform-icon-control-migration')) {
return /*#__PURE__*/React.createElement("path", {
fillRule: "evenodd",
clipRule: "evenodd",
d: "M7.75 12.75H16.25V11.25H7.75V12.75Z",
fill: "inherit"
});
} else {
return /*#__PURE__*/React.createElement("rect", {
fill: "inherit",
x: "8",
y: "11",
width: "8",
height: "2",
rx: "1"
});
}
}
if (isChecked) {
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
if ((0, _platformFeatureFlags.fg)('platform-visual-refresh-icons') && (0, _platformFeatureFlags.fg)('platform-icon-control-migration')) {
return /*#__PURE__*/React.createElement("path", {
fillRule: "evenodd",
clipRule: "evenodd",
d: "M16.3262 9.48011L15.1738 8.51984L10.75 13.8284L8.82616 11.5198L7.67383 12.4801L10.1738 15.4801C10.3163 15.6511 10.5274 15.75 10.75 15.75C10.9726 15.75 11.1837 15.6511 11.3262 15.4801L16.3262 9.48011Z",
fill: "inherit"
});
} else {
return /*#__PURE__*/React.createElement("path", {
d: "M9.707 11.293a1 1 0 1 0-1.414 1.414l2 2a1 1 0 0 0 1.414 0l4-4a1 1 0 1 0-1.414-1.414L11 12.586l-1.293-1.293z",
fill: "inherit"
});
}
}
// No icon
return null;
}
/**
* __Checkbox icon__
*
* A checkbox icon is the visual representation of checkbox state,
* which is shown instead of the native input.
*
* @internal
*/
var CheckboxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
var isIndeterminate = _ref.isIndeterminate,
isChecked = _ref.isChecked;
var icon = (0, _react.useMemo)(function () {
return getIcon(isIndeterminate, isChecked);
}, [isIndeterminate, isChecked]);
return /*#__PURE__*/React.createElement(_svg.default, {
label: "",
primaryColor: "var(--checkbox-background-color)",
secondaryColor: "var(--checkbox-tick-color)"
}, /*#__PURE__*/React.createElement("g", {
fillRule: "evenodd"
},
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
(0, _platformFeatureFlags.fg)('platform-visual-refresh-icons') && (0, _platformFeatureFlags.fg)('platform-icon-control-migration') ? /*#__PURE__*/React.createElement("rect", {
fill: "currentColor",
x: "5.5",
y: "5.5",
width: "13",
height: "13",
rx: "1.5"
}) : /*#__PURE__*/React.createElement("rect", {
fill: "currentColor",
x: "6",
y: "6",
width: "12",
height: "12",
rx: "2"
}), icon));
});
var _default = exports.default = CheckboxIcon;