UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

42 lines (41 loc) 2.18 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; /** * @deprecated ⚠️ `filterOutProps` is deprecated and will be removed in a future major version. Use our `createComponent` and `handleCsProp` helpers to handle props. For more information, view our [Meriging Styles Docs](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-merging-styles--docs#handlecsprop). */ 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); }; } /** * @deprecated ⚠️ `styled` is deprecated and will be removed in a future major version. Please use `createStyles` or `createStencil` instead with [CSS logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values). For more information, view our [Styling docs](https://workday.github.io/canvas-kit/?path=/docs/styling-getting-started-overview--docs). */ exports.default = styled;