UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

36 lines (35 loc) 1.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.filterOutProps = void 0; const styled_1 = __importDefault(require("@emotion/styled")); const index_1 = require("./index"); const rtl_css_js_1 = __importDefault(require("rtl-css-js")); const noop = (styles) => styles; const filterOutProps = (omittedProps) => { return (prop) => !omittedProps.includes(prop); }; exports.filterOutProps = filterOutProps; function styled(node, options) { return (...args) => { const newArgs = args.map(interpolation => (props) => { props.theme = (0, index_1.useTheme)(props.theme); const direction = props.theme.canvas.direction; const maybeFlip = direction === index_1.ContentDirection.RTL ? rtl_css_js_1.default : noop; const maybeConvert = props.theme._styleRewriteFn || noop; try { if (typeof interpolation === 'function') { return maybeFlip(maybeConvert(interpolation(props))); } return maybeFlip(maybeConvert(interpolation)); } catch (e) { return maybeConvert(interpolation); } }); return (0, styled_1.default)(node, options)(newArgs); }; } exports.default = styled;