@ntragas/pouncejstest
Version:
A collection of UI components from Panther labs
69 lines (58 loc) • 2.24 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.pseudoProps = exports.pseudoSelectors = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _css = _interopRequireDefault(require("@styled-system/css"));
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* The selectors are based on [WAI-ARIA state properties](https://www.w3.org/WAI/PF/aria-1.1/states_and_properties)
* and common CSS Selectors
*/
var pseudoSelectors = {
_before: '&::before',
_after: '&::after',
_hover: '&:hover',
_active: '&:active, &[data-active=true]',
_focus: '&:focus',
_focusWithin: '&:focus-within',
_visited: '&:visited',
_empty: '&:empty',
_even: '&:nth-of-type(even)',
_odd: '&:nth-of-type(odd)',
_disabled: '&:disabled, &:disabled:focus, &:disabled:hover, &[aria-disabled=true], &[aria-disabled=true]:focus, &[aria-disabled=true]:hover',
// prettier-ignore
_checked: '&[aria-checked=true]',
_mixed: '&[aria-checked=mixed]',
_selected: '&[aria-selected=true], [data-selected] > &',
_invalid: '&[aria-invalid=true]',
_pressed: '&[aria-pressed=true]',
_readOnly: '&[aria-readonly=true], &[readonly]',
_first: '&:first-of-type',
_last: '&:last-of-type',
_expanded: '&[aria-expanded=true]',
_grabbed: '&[aria-grabbed=true]',
_notFirst: '&:not(:first-of-type)',
_notLast: '&:not(:last-of-type)',
_groupHover: '[role=group]:hover &',
_autofill: '&:-webkit-autofill',
_placeholder: '&::placeholder'
};
exports.pseudoSelectors = pseudoSelectors;
var pseudoProps = function pseudoProps(_ref) {
var theme = _ref.theme,
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["theme"]);
var result = {};
for (var prop in props) {
if (prop in pseudoSelectors) {
var pseudoProp = prop;
var style = (0, _css.default)({
[pseudoSelectors[pseudoProp]]: props[pseudoProp]
})(theme);
result = (0, _extends2.default)({}, result, style);
}
}
return result;
};
exports.pseudoProps = pseudoProps;