@primer/react
Version:
An implementation of GitHub's Primer Design System using React
241 lines (238 loc) • 5.36 kB
JavaScript
import { c } from 'react-compiler-runtime';
import React from 'react';
import { clsx } from 'clsx';
import { TextInputWrapper } from '../internal/components/TextInputWrapper.js';
import classes from './Select.module.css.js';
import { jsxs, jsx } from 'react/jsx-runtime';
const ArrowIndicatorSVG = t0 => {
const $ = c(3);
const {
className
} = t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = /*#__PURE__*/jsx("path", {
d: "m4.074 9.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.043 9H4.251a.25.25 0 0 0-.177.427ZM4.074 7.47 7.47 4.073a.25.25 0 0 1 .354 0L11.22 7.47a.25.25 0 0 1-.177.426H4.251a.25.25 0 0 1-.177-.426Z"
});
$[0] = t1;
} else {
t1 = $[0];
}
let t2;
if ($[1] !== className) {
t2 = /*#__PURE__*/jsx("svg", {
"aria-hidden": "true",
width: "16",
height: "16",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
className: className,
children: t1
});
$[1] = className;
$[2] = t2;
} else {
t2 = $[2];
}
return t2;
};
const ArrowIndicator = t0 => {
const $ = c(4);
const {
className
} = t0;
let t1;
if ($[0] !== className) {
t1 = clsx(classes.ArrowIndicator, className);
$[0] = className;
$[1] = t1;
} else {
t1 = $[1];
}
let t2;
if ($[2] !== t1) {
t2 = /*#__PURE__*/jsx(ArrowIndicatorSVG, {
className: t1
});
$[2] = t1;
$[3] = t2;
} else {
t2 = $[3];
}
return t2;
};
const Select = /*#__PURE__*/React.forwardRef((t0, ref) => {
var _ref, _defaultValue;
const $ = c(37);
let block;
let children;
let className;
let defaultValue;
let disabled;
let placeholder;
let required;
let rest;
let size;
let validationStatus;
if ($[0] !== t0) {
({
block,
children,
className,
defaultValue,
disabled,
placeholder,
size,
required,
validationStatus,
...rest
} = t0);
$[0] = t0;
$[1] = block;
$[2] = children;
$[3] = className;
$[4] = defaultValue;
$[5] = disabled;
$[6] = placeholder;
$[7] = required;
$[8] = rest;
$[9] = size;
$[10] = validationStatus;
} else {
block = $[1];
children = $[2];
className = $[3];
defaultValue = $[4];
disabled = $[5];
placeholder = $[6];
required = $[7];
rest = $[8];
size = $[9];
validationStatus = $[10];
}
let t1;
if ($[11] !== className) {
t1 = clsx(classes.TextInputWrapper, className);
$[11] = className;
$[12] = t1;
} else {
t1 = $[12];
}
const t2 = validationStatus === "error" ? "true" : "false";
const t3 = disabled && classes.Disabled;
let t4;
if ($[13] !== t3) {
t4 = clsx(classes.Select, t3);
$[13] = t3;
$[14] = t4;
} else {
t4 = $[14];
}
const t5 = Boolean(placeholder);
const t6 = (_ref = (_defaultValue = defaultValue) !== null && _defaultValue !== void 0 ? _defaultValue : placeholder) !== null && _ref !== void 0 ? _ref : undefined;
let t7;
if ($[15] !== placeholder || $[16] !== required) {
t7 = placeholder && /*#__PURE__*/jsx("option", {
value: "",
disabled: required,
hidden: required,
children: placeholder
});
$[15] = placeholder;
$[16] = required;
$[17] = t7;
} else {
t7 = $[17];
}
let t8;
if ($[18] !== children || $[19] !== disabled || $[20] !== ref || $[21] !== required || $[22] !== rest || $[23] !== t2 || $[24] !== t4 || $[25] !== t5 || $[26] !== t6 || $[27] !== t7) {
t8 = /*#__PURE__*/jsxs("select", {
...rest,
ref: ref,
required: required,
disabled: disabled,
"aria-invalid": t2,
className: t4,
"data-hasplaceholder": t5,
defaultValue: t6,
children: [t7, children]
});
$[18] = children;
$[19] = disabled;
$[20] = ref;
$[21] = required;
$[22] = rest;
$[23] = t2;
$[24] = t4;
$[25] = t5;
$[26] = t6;
$[27] = t7;
$[28] = t8;
} else {
t8 = $[28];
}
let t9;
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
t9 = /*#__PURE__*/jsx(ArrowIndicator, {
className: classes.ArrowIndicator
});
$[29] = t9;
} else {
t9 = $[29];
}
let t10;
if ($[30] !== block || $[31] !== disabled || $[32] !== size || $[33] !== t1 || $[34] !== t8 || $[35] !== validationStatus) {
t10 = /*#__PURE__*/jsxs(TextInputWrapper, {
block: block,
disabled: disabled,
size: size,
validationStatus: validationStatus,
className: t1,
children: [t8, t9]
});
$[30] = block;
$[31] = disabled;
$[32] = size;
$[33] = t1;
$[34] = t8;
$[35] = validationStatus;
$[36] = t10;
} else {
t10 = $[36];
}
return t10;
});
const Option = props => {
const $ = c(2);
let t0;
if ($[0] !== props) {
t0 = /*#__PURE__*/jsx("option", {
...props
});
$[0] = props;
$[1] = t0;
} else {
t0 = $[1];
}
return t0;
};
const OptGroup = props => {
const $ = c(2);
let t0;
if ($[0] !== props) {
t0 = /*#__PURE__*/jsx("optgroup", {
...props
});
$[0] = props;
$[1] = t0;
} else {
t0 = $[1];
}
return t0;
};
var Select$1 = Object.assign(Select, {
__SLOT__: Symbol('Select'),
Option,
OptGroup
});
export { Select$1 as default };