@marigold/system 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Element.d.ts +8 -0
- package/dist/cache.d.ts +4 -0
- package/dist/index.d.ts +6 -4
- package/dist/normalize.d.ts +110 -0
- package/dist/reset.d.ts +24 -0
- package/dist/system.cjs.development.js +332 -95
- package/dist/system.cjs.development.js.map +1 -1
- package/dist/system.cjs.production.min.js +1 -1
- package/dist/system.cjs.production.min.js.map +1 -1
- package/dist/system.esm.js +323 -92
- package/dist/system.esm.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/useClassname.d.ts +2 -0
- package/dist/useStyles.d.ts +15 -0
- package/dist/useTheme.d.ts +10 -0
- package/package.json +7 -10
- package/src/Colors.stories.mdx +616 -448
- package/src/Element.test.tsx +203 -0
- package/src/Element.tsx +59 -0
- package/src/cache.ts +4 -0
- package/src/concepts-principles.mdx +1 -1
- package/src/index.ts +6 -4
- package/src/normalize.test.tsx +42 -0
- package/src/normalize.ts +131 -0
- package/src/reset.ts +108 -0
- package/src/types.ts +16 -0
- package/src/useClassname.test.tsx +70 -0
- package/src/useClassname.ts +23 -0
- package/src/useStyles.stories.mdx +24 -0
- package/src/useStyles.test.tsx +286 -0
- package/src/useStyles.ts +63 -0
- package/src/useTheme.test.tsx +115 -0
- package/src/useTheme.tsx +22 -0
- package/dist/Box/Box.d.ts +0 -6
- package/dist/Box/index.d.ts +0 -1
- package/dist/MarigoldProvider.d.ts +0 -7
- package/dist/categories.d.ts +0 -169
- package/dist/emotion.d.ts +0 -7
- package/dist/system.d.ts +0 -37
- package/src/Box/Box.stories.mdx +0 -148
- package/src/Box/Box.test.tsx +0 -215
- package/src/Box/Box.tsx +0 -58
- package/src/Box/index.ts +0 -1
- package/src/MarigoldProvider.test.tsx +0 -80
- package/src/MarigoldProvider.tsx +0 -37
- package/src/categories.ts +0 -203
- package/src/emotion.ts +0 -39
- package/src/system.test.tsx +0 -84
- package/src/system.tsx +0 -55
- package/src/writeComponent.stories.mdx +0 -114
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.cjs.development.js","sources":["../src/categories.ts","../src/emotion.ts","../src/system.tsx","../src/Box/Box.tsx","../src/MarigoldProvider.tsx"],"sourcesContent":["import { PropertiesFallback } from 'csstype';\n\n/**\n * System categories are based on https://primer.style/components/docs/system-props\n */\n\n// Spacing\n// ---------------\nexport const SPACE_PROPS = [\n 'm',\n 'margin',\n 'mt',\n 'marginTop',\n 'mr',\n 'marginRight',\n 'mb',\n 'marginBottom',\n 'ml',\n 'marginLeft',\n 'mx',\n 'marginX',\n 'my',\n 'marginY',\n 'p',\n 'padding',\n 'pt',\n 'paddingTop',\n 'pr',\n 'paddingRight',\n 'pb',\n 'paddingBottom',\n 'pl',\n 'paddingLeft',\n 'px',\n 'paddingX',\n 'py',\n 'paddingY',\n];\n\ntype StandardCSSProperties = PropertiesFallback<number | string>;\n\nexport type SpacingProps = {\n /**\n * The **`margin`** CSS property sets the margin area on all four sides of an element. It is a shorthand for `margin-top`, `margin-right`, `margin-bottom`, and `margin-left`.\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin\n */\n m?: StandardCSSProperties['margin'];\n /**\n * The **`margin-top`** CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-top\n */\n mt?: StandardCSSProperties['marginTop'];\n /**\n * The **`margin-right`** CSS property sets the margin area on the right side of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-right\n */\n mr?: StandardCSSProperties['marginRight'];\n /**\n * The **`margin-bottom`** CSS property sets the margin area on the bottom of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom\n */\n mb?: StandardCSSProperties['marginBottom'];\n /**\n * The **`margin-left`** CSS property sets the margin area on the left side of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-left\n */\n ml?: StandardCSSProperties['marginLeft'];\n /**\n * The **`mx`** is shorthand for using both **`margin-left`** and **`margin-right`** CSS properties. They set the margin area on the left and right side of an element. A positive value placesit\n * farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-left\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-right\n */\n mx?: StandardCSSProperties['marginLeft'];\n /**\n * The **`marginX`** is shorthand for using both **`margin-left`** and **`margin-right`** CSS properties. They set the margin area on the left and right side of an element. A positive value\n * places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-left\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-right\n */\n marginX?: StandardCSSProperties['marginLeft'];\n /**\n * The **`my`** is shorthard for using both **`margin-top`** and **`margin-bottom`** CSS properties. They set the margin area on the top and bottom of an element. A positive value places it\n * farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-top\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom\n */\n my?: StandardCSSProperties['marginTop'];\n /**\n * The **`marginY`** is shorthard for using both **`margin-top`** and **`margin-bottom`** CSS properties. They set the margin area on the top and bottom of an element. A positive value places\n * it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-top\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom\n */\n marginY?: StandardCSSProperties['marginTop'];\n /**\n * The **`padding`** CSS property sets the padding area on all four sides of an element. It is a shorthand for `padding-top`, `padding-right`, `padding-bottom`, and `padding-left`.\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding\n */\n p?: StandardCSSProperties['padding'];\n /**\n * The **`padding-top`** padding area on the top of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-top\n */\n pt?: StandardCSSProperties['paddingTop'];\n /**\n * The **`padding-right`** CSS property sets the width of the padding area on the right side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-right\n */\n pr?: StandardCSSProperties['paddingRight'];\n /**\n * The **`padding-bottom`** CSS property sets the height of the padding area on the bottom of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom\n */\n pb?: StandardCSSProperties['paddingBottom'];\n /**\n * The **`padding-left`** CSS property sets the width of the padding area on the left side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-left\n */\n pl?: StandardCSSProperties['paddingLeft'];\n /**\n * The **`px`** is shorthand property for CSS properties **`padding-left`** and **`padding-right`**. They set the width of the padding area on the left and right side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-left\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-right\n */\n px?: StandardCSSProperties['paddingLeft'];\n /**\n * The **`paddingX`** is shorthand property for CSS properties **`padding-left`** and **`padding-right`**. They set the width of the padding area on the left and right side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-left\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-right\n */\n paddingX?: StandardCSSProperties['paddingLeft'];\n /**\n * The **`py`** is shorthand property for CSS properties **`padding-top`** and **`padding-bottom`**. They set the width of the padding area on the top and bottom of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-top\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom\n */\n py?: StandardCSSProperties['paddingTop'];\n /**\n * The **`paddingY`** is shorthand property for CSS properties **`padding-top`** and **`padding-bottom`**. They set the width of the padding area on the top and bottom of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-top\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom\n */\n paddingY?: StandardCSSProperties['paddingTop'];\n};\n","import React from 'react';\n\n/**\n * Fix until the global JSX augmentation is not included in\n * `@emotion/core`. See https://github.com/emotion-js/emotion/issues/1257\n * for more information.\n *\n * *Why is this a problem?*\n *\n * (1) Every JSX element accepts a `css` prop, but we don't parse that.\n * (2) Every JSX element only accepts a type that is compatible with emotion's\n * css prop, which we don't care, since we first pass the `css` prop\n * to styled-system.\n *\n * *The fix consist of two parts:*\n *\n * (1) using `.yarnclean` to remove the `emotion/core` typings completly.\n * (2) having this sink file to re-apply the typings and tell TS to ignore\n * the untyped import.\n */\nimport {\n css as cssEmotion,\n jsx as createElement,\n Global as EmotionGlobal,\n ThemeContext as EmotionContext,\n // @ts-ignore\n} from '@emotion/core';\n\n// Emotion API\n// ---------------\nexport const jsx = createElement as typeof React.createElement;\nexport const css = cssEmotion as (\n template: TemplateStringsArray,\n ...args: any[]\n) => object;\nexport const ThemeContext = EmotionContext as React.Context<any>;\nexport const Global = EmotionGlobal as (\n props: React.PropsWithChildren<{ styles: any }>\n) => React.ReactElement;\n","/**\n * Typings are based on [Reach UI](https://github.com/reach/reach-ui/blob/4cb497f530b0f83f80c6f6f2da46ab55b1160cb6/packages/utils/src/types.tsx).\n */\nimport {\n forwardRef,\n ComponentPropsWithRef,\n ElementType,\n ReactElement,\n ValidationMap,\n WeakValidationMap,\n} from 'react';\n\n/**\n * SystemProps support the `as` and `variant` prop. The former\n * is used to changed the rendered root element of a component.\n *\n * These props also infer additional allowed props based on the\n * value of the `as` prop. For example, setting `as=\"button\"` will\n * allow to use HTMLButtonAttributes on the component.\n */\nexport type SystemProps<P, T extends ElementType> = P &\n Omit<ComponentPropsWithRef<T>, 'as' | keyof P> & {\n as?: T;\n variant?: string;\n };\n\n/**\n * Enhanced version of `React.FunctionComponent` that accepts `SystemProps`\n * and infers allowed properties based on the `as` prop.\n */\nexport interface SystemComponent<P, T extends ElementType> {\n /**\n * These types are a bit of a hack, but cover us in cases where the `as` prop\n * is not a JSX string type. Makes the compiler happy so 🤷♂️\n */\n <TT extends ElementType>(props: SystemProps<P, TT>): ReactElement | null;\n (props: SystemProps<P, T>): ReactElement | null;\n\n displayName?: string;\n propTypes?: WeakValidationMap<SystemProps<P, T>>;\n contextTypes?: ValidationMap<any>;\n defaultProps?: Partial<SystemProps<P, T>>;\n}\n\n/**\n * Helper to write components that adhere to a common design system API,\n * which includes the `as` and `variant` prop.\n */\nexport function system<P, T extends ElementType>(\n render: (props: SystemProps<P, T>) => ReactElement | null\n) {\n return forwardRef((props: any, ref) =>\n render({ ...props, ref })\n ) as SystemComponent<P, T>;\n}\n","// @ts-ignore\nimport { css } from '@theme-ui/css';\nimport pick from 'lodash.pick';\nimport { SPACE_PROPS, SpacingProps } from '../categories';\nimport { jsx } from '../emotion';\nimport { system } from '../system';\n\nexport type BoxProps = {\n css?: Object;\n themeSection?: string;\n} & SpacingProps;\n\n/**\n * Props that we have to remove (because they are not valid HTML attributes)\n * and want to process (for styling the component).\n */\nconst SKIP_PROPS = ['css', 'variant', 'themeSection', ...SPACE_PROPS];\n\n/**\n * Gather styling related props (css, variant, space props, ...) and put them in a\n * single `css` prop for emotion. All gathered props will be passed to `@theme-ui/css`\n * before emotion will process them. This way CSS properties will interpolated based on\n * the given theme.\n */\nconst parseProps = (props: { [key: string]: any }) => {\n const next: any = {};\n\n // TODO: optimize loop such that the style props are picked\n // within the loop (and remove lodash.pick!)\n for (let key in props) {\n if (SKIP_PROPS.includes(key)) continue;\n next[key] = props[key];\n }\n\n const styles = {\n ...props.css,\n ...pick(props, SPACE_PROPS),\n };\n\n const variant =\n props.themeSection &&\n props.variant &&\n `${props.themeSection}.${props.variant}`;\n\n next.css = (theme: any) => {\n return [\n { boxSizing: 'border-box', margin: 0, minWidth: 0 },\n css(styles)(theme),\n css({ variant })(theme),\n ];\n };\n\n return next;\n};\n\nexport const Box = system<BoxProps, 'div'>(\n ({ as = 'div', children, ...props }) => jsx(as, parseProps(props), children)\n);\n","import React from 'react';\nimport { Global, ThemeContext } from './emotion';\n\n/**\n * CSS snippet and idea from:\n * https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/\n */\nconst ReduceMotion = () => (\n <Global\n styles={{\n '@media screen and (prefers-reduced-motion: reduce), (update: slow)': {\n '*': {\n animationDuration: '0.001ms !important',\n animationIterationCount: '1 !important',\n transitionDuration: '0.001ms !important',\n },\n },\n }}\n />\n);\n\n// TODO: change any to theme when theme component exists\nexport type MarigoldProviderProps<T extends any> = React.PropsWithChildren<{\n theme: T;\n}>;\n\nexport const MarigoldProvider = <T extends any>({\n theme,\n children,\n}: MarigoldProviderProps<T>) => (\n <ThemeContext.Provider value={theme}>\n <>\n <ReduceMotion />\n {children}\n </>\n </ThemeContext.Provider>\n);\n"],"names":["SPACE_PROPS","jsx","createElement","ThemeContext","EmotionContext","Global","EmotionGlobal","system","render","forwardRef","props","ref","SKIP_PROPS","parseProps","next","key","includes","styles","css","pick","variant","themeSection","theme","boxSizing","margin","minWidth","Box","as","children","ReduceMotion","React","animationDuration","animationIterationCount","transitionDuration","MarigoldProvider","Provider","value"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;AAIA;AACA;IACaA,WAAW,GAAG,CACzB,GADyB,EAEzB,QAFyB,EAGzB,IAHyB,EAIzB,WAJyB,EAKzB,IALyB,EAMzB,aANyB,EAOzB,IA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AAA,CAAzB;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"system.cjs.development.js","sources":["../src/normalize.ts","../src/useTheme.tsx","../src/Element.tsx","../src/useClassname.ts","../src/reset.ts","../src/useStyles.ts"],"sourcesContent":["import { ElementType } from 'react';\n\nconst base = {\n boxSizing: 'border-box',\n margin: 0,\n padding: 0,\n minWidth: 0,\n fontSize: '100%',\n fontFamily: 'inherit',\n verticalAlign: 'baseline',\n WebkitTapHighlightColor: 'transparent',\n} as const;\n\n// Content\n// ---------------\nconst block = {\n display: 'block',\n} as const;\n\nconst list = {\n // empty\n} as const;\n\nconst table = {\n borderCollapse: 'collapse',\n borderSpacing: 0,\n} as const;\n\n// Typography\n// ---------------\nconst a = {\n textDecoration: 'none',\n touchAction: 'manipulation',\n} as const;\n\nconst quote = {\n quotes: 'none',\n selectors: {\n '&:before, &:after': {\n content: \"''\",\n },\n },\n} as const;\n\n// Form Elements\n// ---------------\nconst button = {\n display: 'block',\n appearance: 'none',\n background: 'transparent',\n textAlign: 'center',\n touchAction: 'manipulation',\n} as const;\n\nconst input = {\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-clear': {\n display: 'none',\n },\n '&::-webkit-search-cancel-button': {\n WebkitAppearance: 'none',\n },\n },\n} as const;\n\nconst select = {\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-expand': {\n display: 'none',\n },\n },\n} as const;\n\nconst textarea = {\n display: 'block',\n appearance: 'none',\n} as const;\n\n// Reset\n// ---------------\nconst reset = {\n article: block,\n aside: block,\n details: block,\n figcaption: block,\n figure: block,\n footer: block,\n header: block,\n hgroup: block,\n menu: block,\n nav: block,\n section: block,\n ul: list,\n ol: list,\n blockquote: quote,\n q: quote,\n a,\n base,\n table,\n select,\n button,\n textarea,\n input,\n} as const;\n\nexport type NormalizedElement = keyof typeof reset;\nconst isKnownElement = (input: string): input is NormalizedElement =>\n input in reset;\n\n/**\n * Helper to conveniently get reset styles.\n */\nexport const getNormalizedStyles = (input?: ElementType): object => {\n /**\n * If a React component is given, we don't apply any reset styles\n * and return the base reset.\n */\n if (typeof input !== 'string') {\n return reset.base;\n }\n\n /**\n * Try to find the reset style for a HTML element. If the element\n * is not included return empty styles.\n */\n return isKnownElement(input) ? reset[input] : {};\n};\n","import React, { createContext, useCallback, useContext } from 'react';\nimport { css as themeUi } from '@theme-ui/css';\nimport { Theme } from '@marigold/system';\n\nimport { StyleObject } from './types';\n\nconst Context = createContext<Theme>({});\n\nexport const useTheme = () => {\n const theme = useContext(Context);\n const css = useCallback(\n (style: StyleObject) => themeUi(style)(theme),\n [theme]\n );\n return { theme, css };\n};\n\nexport type ThemeProviderProps = { theme: any };\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({\n theme,\n children,\n}) => <Context.Provider value={theme}>{children}</Context.Provider>;\n","import { jsx } from '@emotion/react';\nimport { forwardRef } from 'react';\nimport {\n PolymorphicPropsWithRef,\n PolymorphicComponentWithRef,\n} from '@marigold/types';\n\nimport { getNormalizedStyles } from './normalize';\nimport { CSSObject } from './types';\nimport { useTheme } from './useTheme';\n\nexport type ElementOwnProps = {\n css?: CSSObject;\n variant?: string | string[];\n};\n\nexport type ElementProps = PolymorphicPropsWithRef<ElementOwnProps, 'div'>;\n\n/**\n * Function expression to check if there is any falsy value or empty object\n */\nconst isNotEmpty = (val: any) =>\n !(val && Object.keys(val).length === 0 && val.constructor === Object);\n\n/**\n * Get the normalized base styles\n */\nconst baseStyles = getNormalizedStyles('base');\n\nexport const Element: PolymorphicComponentWithRef<ElementOwnProps, 'div'> =\n forwardRef(\n ({ as = 'div', css: styles = {}, variant, children, ...props }, ref) => {\n const { css } = useTheme();\n\n /**\n * Transform variant input for `@theme-ui/css`\n */\n const variants = Array.isArray(variant)\n ? variant.map(v => ({ variant: v }))\n : [{ variant }];\n\n return jsx(\n as,\n {\n ...props,\n ...{\n css: [\n baseStyles,\n getNormalizedStyles(as),\n ...variants.map(v => css(v)),\n css(styles),\n ].filter(isNotEmpty),\n },\n ref,\n },\n children\n );\n }\n );\n","import { css as emotion } from '@emotion/css';\nimport { StyleObject } from './types';\nimport { useTheme } from './useTheme';\n\n// 🤫 https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object\n// lodash.isEmpty is tooo much KBs!\nconst isEmpty = (val: any) =>\n val && Object.keys(val).length === 0 && val.constructor === Object;\n\nexport const useClassname = (...styles: StyleObject[]) => {\n const { css } = useTheme();\n return styles\n .map(style => {\n /**\n * emotion will create a `css-0` class whenever an empty object is\n * passed. Since this makes debugging harder we'll do not pass empty\n * objects to emotion.\n */\n const themedStyle = css(style);\n return isEmpty(themedStyle) ? '' : emotion(themedStyle);\n })\n .join(' ');\n};\n","import { css } from '@emotion/css';\n\nconst base = css({\n boxSizing: 'border-box',\n margin: 0,\n padding: 0,\n minWidth: 0,\n fontSize: '100%',\n font: 'inherit',\n verticalAlign: 'baseline',\n WebkitTapHighlightColor: 'transparent',\n});\n\n// Content\n// ---------------\nconst block = css({\n display: 'block',\n});\n\nconst list = css({\n // empty\n});\n\nconst table = css({\n borderCollapse: 'collapse',\n borderSpacing: 0,\n});\n\n// Typography\n// ---------------\nconst a = css({\n textDecoration: 'none',\n touchAction: 'manipulation',\n});\n\nconst quote = css({\n quotes: 'none',\n selectors: {\n '&:before, &:after': {\n content: \"''\",\n },\n },\n});\n\n// Form Elements\n// ---------------\nconst button = css({\n display: 'block',\n appearance: 'none',\n background: 'transparent',\n textAlign: 'center',\n touchAction: 'manipulation',\n});\n\nconst input = css({\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-clear': {\n display: 'none',\n },\n '&::-webkit-search-cancel-button': {\n WebkitAppearance: 'none',\n },\n },\n});\n\nconst select = css({\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-expand': {\n display: 'none',\n },\n },\n});\n\nconst textarea = css({\n display: 'block',\n appearance: 'none',\n});\n\n// Reset\n// ---------------\nexport const reset = {\n article: block,\n aside: block,\n details: block,\n figcaption: block,\n figure: block,\n footer: block,\n header: block,\n hgroup: block,\n menu: block,\n nav: block,\n section: block,\n ul: list,\n ol: list,\n blockquote: quote,\n q: quote,\n a,\n base,\n table,\n select,\n button,\n textarea,\n input,\n} as const;\n","import { ElementType } from 'react';\nimport { reset } from './reset';\nimport { CSSObject } from './types';\nimport { useClassname } from './useClassname';\n\nexport type UseStyleInput = {\n element?: ElementType;\n css?: Omit<CSSObject, 'variant' | 'element'> & {\n variant?: never;\n element?: never;\n };\n variant?: string | string[];\n className?: string;\n};\n\n/**\n * Hook that can adds base styles, reset for certain elements, variants and custom styles\n */\nexport const useStyles = ({\n element,\n css: styles = {},\n variant,\n className = '',\n}: UseStyleInput) => {\n /**\n * Get reset styles. Base is always applied. An additional reset maybe applied\n * based on the passed element.\n *\n * We check the passed className if it already includes the reset styles so no\n * duplicates are applied.\n */\n const baseClassName = className.includes(reset.base) ? '' : reset.base;\n const resetClassName =\n typeof element === 'string'\n ? className.includes((reset as { [key: string]: string })[element])\n ? ''\n : (reset as { [key: string]: string })[element]\n : '';\n\n /**\n * Get variant styles (from theme).\n */\n const variants = Array.isArray(variant)\n ? variant.map(v => ({ variant: v }))\n : [{ variant }];\n const variantsClassName = useClassname(...variants);\n\n /**\n * Custom styles are applied \"on runtime\". They are usually controlled via component\n * props and can change between component instances.\n */\n const customClassName = useClassname(styles);\n\n return [\n baseClassName,\n resetClassName,\n variantsClassName,\n customClassName,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n};\n"],"names":["base","boxSizing","margin","padding","minWidth","fontSize","fontFamily","verticalAlign","WebkitTapHighlightColor","block","display","list","table","borderCollapse","borderSpacing","a","textDecoration","touchAction","quote","quotes","selectors","content","button","appearance","background","textAlign","input","WebkitAppearance","select","textarea","reset","article","aside","details","figcaption","figure","footer","header","hgroup","menu","nav","section","ul","ol","blockquote","q","isKnownElement","getNormalizedStyles","Context","createContext","useTheme","theme","useContext","css","useCallback","style","themeUi","ThemeProvider","children","React","Provider","value","isNotEmpty","val","Object","keys","length","constructor","baseStyles","Element","forwardRef","ref","as","styles","variant","props","variants","Array","isArray","map","v","jsx","filter","isEmpty","useClassname","themedStyle","emotion","join","font","useStyles","element","className","baseClassName","includes","resetClassName","variantsClassName","customClassName","Boolean"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,IAAI,GAAG;AACXC,EAAAA,SAAS,EAAE,YADA;AAEXC,EAAAA,MAAM,EAAE,CAFG;AAGXC,EAAAA,OAAO,EAAE,CAHE;AAIXC,EAAAA,QAAQ,EAAE,CAJC;AAKXC,EAAAA,QAAQ,EAAE,MALC;AAMXC,EAAAA,UAAU,EAAE,SAND;AAOXC,EAAAA,aAAa,EAAE,UAPJ;AAQXC,EAAAA,uBAAuB,EAAE;AARd,CAAb;AAYA;;AACA,IAAMC,KAAK,GAAG;AACZC,EAAAA,OAAO,EAAE;AADG,CAAd;AAIA,IAAMC,IAAI,GAAG;AAAA,CAAb;AAIA,IAAMC,KAAK,GAAG;AACZC,EAAAA,cAAc,EAAE,UADJ;AAEZC,EAAAA,aAAa,EAAE;AAFH,CAAd;AAMA;;AACA,IAAMC,CAAC,GAAG;AACRC,EAAAA,cAAc,EAAE,MADR;AAERC,EAAAA,WAAW,EAAE;AAFL,CAAV;AAKA,IAAMC,KAAK,GAAG;AACZC,EAAAA,MAAM,EAAE,MADI;AAEZC,EAAAA,SAAS,EAAE;AACT,yBAAqB;AACnBC,MAAAA,OAAO,EAAE;AADU;AADZ;AAFC,CAAd;AAUA;;AACA,IAAMC,MAAM,GAAG;AACbZ,EAAAA,OAAO,EAAE,OADI;AAEba,EAAAA,UAAU,EAAE,MAFC;AAGbC,EAAAA,UAAU,EAAE,aAHC;AAIbC,EAAAA,SAAS,EAAE,QAJE;AAKbR,EAAAA,WAAW,EAAE;AALA,CAAf;AAQA,IAAMS,KAAK,GAAG;AACZhB,EAAAA,OAAO,EAAE,OADG;AAEZa,EAAAA,UAAU,EAAE,MAFA;AAGZH,EAAAA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I,CAOGe,OAPH,EAQJV,IARI,CAQC,GARD,CAAP;AASD,CA5CM;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var e,n=require("@emotion/react"),t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,a=require("@theme-ui/css"),o=require("@emotion/css");function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var c={display:"block"},s={},l={quotes:"none",selectors:{"&:before, &:after":{content:"''"}}},u={article:c,aside:c,details:c,figcaption:c,figure:c,footer:c,header:c,hgroup:c,menu:c,nav:c,section:c,ul:s,ol:s,blockquote:l,q:l,a:{textDecoration:"none",touchAction:"manipulation"},base:{boxSizing:"border-box",margin:0,padding:0,minWidth:0,fontSize:"100%",fontFamily:"inherit",verticalAlign:"baseline",WebkitTapHighlightColor:"transparent"},table:{borderCollapse:"collapse",borderSpacing:0},select:{display:"block",appearance:"none",selectors:{"&::-ms-expand":{display:"none"}}},button:{display:"block",appearance:"none",background:"transparent",textAlign:"center",touchAction:"manipulation"},textarea:{display:"block",appearance:"none"},input:{display:"block",appearance:"none",selectors:{"&::-ms-clear":{display:"none"},"&::-webkit-search-cancel-button":{WebkitAppearance:"none"}}}},p=function(e){return"string"!=typeof e?u.base:function(e){return e in u}(e)?u[e]:{}},b=t.createContext({}),d=function(){var e=t.useContext(b),n=t.useCallback((function(n){return a.css(n)(e)}),[e]);return{theme:e,css:n}},f=["as","css","variant","children"],h=function(e){return!(e&&0===Object.keys(e).length&&e.constructor===Object)},g=p("base"),m=t.forwardRef((function(e,t){var r=e.as,a=void 0===r?"div":r,o=e.css,c=void 0===o?{}:o,s=e.variant,l=e.children,u=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(a[t]=e[t]);return a}(e,f),b=d().css,m=Array.isArray(s)?s.map((function(e){return{variant:e}})):[{variant:s}];return n.jsx(a,i({},u,{css:[g,p(a)].concat(m.map((function(e){return b(e)})),[b(c)]).filter(h)},{ref:t}),l)})),y=function(e){return e&&0===Object.keys(e).length&&e.constructor===Object},v=function(){for(var e=d(),n=e.css,t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return r.map((function(e){var t=n(e);return y(t)?"":o.css(t)})).join(" ")},k=o.css({boxSizing:"border-box",margin:0,padding:0,minWidth:0,fontSize:"100%",font:"inherit",verticalAlign:"baseline",WebkitTapHighlightColor:"transparent"}),x=o.css({display:"block"}),A=o.css({}),j=o.css({borderCollapse:"collapse",borderSpacing:0}),q=o.css({textDecoration:"none",touchAction:"manipulation"}),O=o.css({quotes:"none",selectors:{"&:before, &:after":{content:"''"}}}),C=o.css({display:"block",appearance:"none",background:"transparent",textAlign:"center",touchAction:"manipulation"}),S=o.css({display:"block",appearance:"none",selectors:{"&::-ms-clear":{display:"none"},"&::-webkit-search-cancel-button":{WebkitAppearance:"none"}}}),W={article:x,aside:x,details:x,figcaption:x,figure:x,footer:x,header:x,hgroup:x,menu:x,nav:x,section:x,ul:A,ol:A,blockquote:O,q:O,a:q,base:k,table:j,select:o.css({display:"block",appearance:"none",selectors:{"&::-ms-expand":{display:"none"}}}),button:C,textarea:o.css({display:"block",appearance:"none"}),input:S};Object.defineProperty(exports,"cache",{enumerable:!0,get:function(){return o.cache}}),exports.Element=m,exports.ThemeProvider=function(e){return r.createElement(b.Provider,{value:e.theme},e.children)},exports.useClassname=v,exports.useStyles=function(e){var n=e.element,t=e.css,r=void 0===t?{}:t,a=e.variant,o=e.className,i=void 0===o?"":o,c=i.includes(W.base)?"":W.base,s="string"==typeof n?i.includes(W[n])?"":W[n]:"",l=Array.isArray(a)?a.map((function(e){return{variant:e}})):[{variant:a}];return[c,s,v.apply(void 0,l),v(r),i].filter(Boolean).join(" ")},exports.useTheme=d;
|
|
2
2
|
//# sourceMappingURL=system.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.cjs.production.min.js","sources":["../src/categories.ts","../src/emotion.ts","../src/system.tsx","../src/Box/Box.tsx","../src/MarigoldProvider.tsx"],"sourcesContent":["import { PropertiesFallback } from 'csstype';\n\n/**\n * System categories are based on https://primer.style/components/docs/system-props\n */\n\n// Spacing\n// ---------------\nexport const SPACE_PROPS = [\n 'm',\n 'margin',\n 'mt',\n 'marginTop',\n 'mr',\n 'marginRight',\n 'mb',\n 'marginBottom',\n 'ml',\n 'marginLeft',\n 'mx',\n 'marginX',\n 'my',\n 'marginY',\n 'p',\n 'padding',\n 'pt',\n 'paddingTop',\n 'pr',\n 'paddingRight',\n 'pb',\n 'paddingBottom',\n 'pl',\n 'paddingLeft',\n 'px',\n 'paddingX',\n 'py',\n 'paddingY',\n];\n\ntype StandardCSSProperties = PropertiesFallback<number | string>;\n\nexport type SpacingProps = {\n /**\n * The **`margin`** CSS property sets the margin area on all four sides of an element. It is a shorthand for `margin-top`, `margin-right`, `margin-bottom`, and `margin-left`.\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin\n */\n m?: StandardCSSProperties['margin'];\n /**\n * The **`margin-top`** CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-top\n */\n mt?: StandardCSSProperties['marginTop'];\n /**\n * The **`margin-right`** CSS property sets the margin area on the right side of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-right\n */\n mr?: StandardCSSProperties['marginRight'];\n /**\n * The **`margin-bottom`** CSS property sets the margin area on the bottom of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom\n */\n mb?: StandardCSSProperties['marginBottom'];\n /**\n * The **`margin-left`** CSS property sets the margin area on the left side of an element. A positive value places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-left\n */\n ml?: StandardCSSProperties['marginLeft'];\n /**\n * The **`mx`** is shorthand for using both **`margin-left`** and **`margin-right`** CSS properties. They set the margin area on the left and right side of an element. A positive value placesit\n * farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-left\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-right\n */\n mx?: StandardCSSProperties['marginLeft'];\n /**\n * The **`marginX`** is shorthand for using both **`margin-left`** and **`margin-right`** CSS properties. They set the margin area on the left and right side of an element. A positive value\n * places it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-left\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-right\n */\n marginX?: StandardCSSProperties['marginLeft'];\n /**\n * The **`my`** is shorthard for using both **`margin-top`** and **`margin-bottom`** CSS properties. They set the margin area on the top and bottom of an element. A positive value places it\n * farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-top\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom\n */\n my?: StandardCSSProperties['marginTop'];\n /**\n * The **`marginY`** is shorthard for using both **`margin-top`** and **`margin-bottom`** CSS properties. They set the margin area on the top and bottom of an element. A positive value places\n * it farther from its neighbors, while a negative value places it closer.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#margin-props\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-top\n * @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom\n */\n marginY?: StandardCSSProperties['marginTop'];\n /**\n * The **`padding`** CSS property sets the padding area on all four sides of an element. It is a shorthand for `padding-top`, `padding-right`, `padding-bottom`, and `padding-left`.\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding\n */\n p?: StandardCSSProperties['padding'];\n /**\n * The **`padding-top`** padding area on the top of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-top\n */\n pt?: StandardCSSProperties['paddingTop'];\n /**\n * The **`padding-right`** CSS property sets the width of the padding area on the right side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-right\n */\n pr?: StandardCSSProperties['paddingRight'];\n /**\n * The **`padding-bottom`** CSS property sets the height of the padding area on the bottom of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom\n */\n pb?: StandardCSSProperties['paddingBottom'];\n /**\n * The **`padding-left`** CSS property sets the width of the padding area on the left side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-left\n */\n pl?: StandardCSSProperties['paddingLeft'];\n /**\n * The **`px`** is shorthand property for CSS properties **`padding-left`** and **`padding-right`**. They set the width of the padding area on the left and right side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-left\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-right\n */\n px?: StandardCSSProperties['paddingLeft'];\n /**\n * The **`paddingX`** is shorthand property for CSS properties **`padding-left`** and **`padding-right`**. They set the width of the padding area on the left and right side of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-left\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-right\n */\n paddingX?: StandardCSSProperties['paddingLeft'];\n /**\n * The **`py`** is shorthand property for CSS properties **`padding-top`** and **`padding-bottom`**. They set the width of the padding area on the top and bottom of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-top\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom\n */\n py?: StandardCSSProperties['paddingTop'];\n /**\n * The **`paddingY`** is shorthand property for CSS properties **`padding-top`** and **`padding-bottom`**. They set the width of the padding area on the top and bottom of an element.\n *\n * **Initial value**: `0`\n *\n * @see https://styled-system.com/#padding-props\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-top\n * @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom\n */\n paddingY?: StandardCSSProperties['paddingTop'];\n};\n","import React from 'react';\n\n/**\n * Fix until the global JSX augmentation is not included in\n * `@emotion/core`. See https://github.com/emotion-js/emotion/issues/1257\n * for more information.\n *\n * *Why is this a problem?*\n *\n * (1) Every JSX element accepts a `css` prop, but we don't parse that.\n * (2) Every JSX element only accepts a type that is compatible with emotion's\n * css prop, which we don't care, since we first pass the `css` prop\n * to styled-system.\n *\n * *The fix consist of two parts:*\n *\n * (1) using `.yarnclean` to remove the `emotion/core` typings completly.\n * (2) having this sink file to re-apply the typings and tell TS to ignore\n * the untyped import.\n */\nimport {\n css as cssEmotion,\n jsx as createElement,\n Global as EmotionGlobal,\n ThemeContext as EmotionContext,\n // @ts-ignore\n} from '@emotion/core';\n\n// Emotion API\n// ---------------\nexport const jsx = createElement as typeof React.createElement;\nexport const css = cssEmotion as (\n template: TemplateStringsArray,\n ...args: any[]\n) => object;\nexport const ThemeContext = EmotionContext as React.Context<any>;\nexport const Global = EmotionGlobal as (\n props: React.PropsWithChildren<{ styles: any }>\n) => React.ReactElement;\n","/**\n * Typings are based on [Reach UI](https://github.com/reach/reach-ui/blob/4cb497f530b0f83f80c6f6f2da46ab55b1160cb6/packages/utils/src/types.tsx).\n */\nimport {\n forwardRef,\n ComponentPropsWithRef,\n ElementType,\n ReactElement,\n ValidationMap,\n WeakValidationMap,\n} from 'react';\n\n/**\n * SystemProps support the `as` and `variant` prop. The former\n * is used to changed the rendered root element of a component.\n *\n * These props also infer additional allowed props based on the\n * value of the `as` prop. For example, setting `as=\"button\"` will\n * allow to use HTMLButtonAttributes on the component.\n */\nexport type SystemProps<P, T extends ElementType> = P &\n Omit<ComponentPropsWithRef<T>, 'as' | keyof P> & {\n as?: T;\n variant?: string;\n };\n\n/**\n * Enhanced version of `React.FunctionComponent` that accepts `SystemProps`\n * and infers allowed properties based on the `as` prop.\n */\nexport interface SystemComponent<P, T extends ElementType> {\n /**\n * These types are a bit of a hack, but cover us in cases where the `as` prop\n * is not a JSX string type. Makes the compiler happy so 🤷♂️\n */\n <TT extends ElementType>(props: SystemProps<P, TT>): ReactElement | null;\n (props: SystemProps<P, T>): ReactElement | null;\n\n displayName?: string;\n propTypes?: WeakValidationMap<SystemProps<P, T>>;\n contextTypes?: ValidationMap<any>;\n defaultProps?: Partial<SystemProps<P, T>>;\n}\n\n/**\n * Helper to write components that adhere to a common design system API,\n * which includes the `as` and `variant` prop.\n */\nexport function system<P, T extends ElementType>(\n render: (props: SystemProps<P, T>) => ReactElement | null\n) {\n return forwardRef((props: any, ref) =>\n render({ ...props, ref })\n ) as SystemComponent<P, T>;\n}\n","// @ts-ignore\nimport { css } from '@theme-ui/css';\nimport pick from 'lodash.pick';\nimport { SPACE_PROPS, SpacingProps } from '../categories';\nimport { jsx } from '../emotion';\nimport { system } from '../system';\n\nexport type BoxProps = {\n css?: Object;\n themeSection?: string;\n} & SpacingProps;\n\n/**\n * Props that we have to remove (because they are not valid HTML attributes)\n * and want to process (for styling the component).\n */\nconst SKIP_PROPS = ['css', 'variant', 'themeSection', ...SPACE_PROPS];\n\n/**\n * Gather styling related props (css, variant, space props, ...) and put them in a\n * single `css` prop for emotion. All gathered props will be passed to `@theme-ui/css`\n * before emotion will process them. This way CSS properties will interpolated based on\n * the given theme.\n */\nconst parseProps = (props: { [key: string]: any }) => {\n const next: any = {};\n\n // TODO: optimize loop such that the style props are picked\n // within the loop (and remove lodash.pick!)\n for (let key in props) {\n if (SKIP_PROPS.includes(key)) continue;\n next[key] = props[key];\n }\n\n const styles = {\n ...props.css,\n ...pick(props, SPACE_PROPS),\n };\n\n const variant =\n props.themeSection &&\n props.variant &&\n `${props.themeSection}.${props.variant}`;\n\n next.css = (theme: any) => {\n return [\n { boxSizing: 'border-box', margin: 0, minWidth: 0 },\n css(styles)(theme),\n css({ variant })(theme),\n ];\n };\n\n return next;\n};\n\nexport const Box = system<BoxProps, 'div'>(\n ({ as = 'div', children, ...props }) => jsx(as, parseProps(props), children)\n);\n","import React from 'react';\nimport { Global, ThemeContext } from './emotion';\n\n/**\n * CSS snippet and idea from:\n * https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/\n */\nconst ReduceMotion = () => (\n <Global\n styles={{\n '@media screen and (prefers-reduced-motion: reduce), (update: slow)': {\n '*': {\n animationDuration: '0.001ms !important',\n animationIterationCount: '1 !important',\n transitionDuration: '0.001ms !important',\n },\n },\n }}\n />\n);\n\n// TODO: change any to theme when theme component exists\nexport type MarigoldProviderProps<T extends any> = React.PropsWithChildren<{\n theme: T;\n}>;\n\nexport const MarigoldProvider = <T extends any>({\n theme,\n children,\n}: MarigoldProviderProps<T>) => (\n <ThemeContext.Provider value={theme}>\n <>\n <ReduceMotion />\n {children}\n </>\n </ThemeContext.Provider>\n);\n"],"names":["SPACE_PROPS","jsx","createElement","ThemeContext","EmotionContext","Global","EmotionGlobal","system","render","forwardRef","props","ref","SKIP_PROPS","ReduceMotion","React","styles","animationDuration","animationIterationCount","transitionDuration","as","children","next","key","includes","css","pick","variant","themeSection","theme","boxSizing","margin","minWidth","parseProps","Provider","value"],"mappings":"sZAQaA,EAAc,CACzB,IACA,SACA,KACA,YACA,KACA,cACA,KACA,eACA,KACA,aACA,KACA,UACA,KACA,UACA,IACA,UACA,KACA,aACA,KACA,eACA,KACA,gBACA,KACA,cACA,KACA,WACA,KACA,YCNWC,EAAMC,MAKNC,EAAeC,eACfC,EAASC,kBCYNC,EACdC,UAEOC,cAAW,SAACC,EAAYC,UAC7BH,OAAYE,GAAOC,IAAAA,QCpCvB,IAAMC,GAAc,MAAO,UAAW,uBAAmBZ,GCTnDa,EAAe,kBACnBC,gBAACT,GACCU,OAAQ,sEACgE,KAC/D,CACHC,kBAAmB,qBACnBC,wBAAyB,eACzBC,mBAAoB,uCDyCXX,GACjB,oBAAGY,GAAAA,aAAK,QAAOC,IAAAA,SAAaV,iKAAYT,EAAIkB,EAhC3B,SAACT,OACZW,EAAY,OAIb,IAAIC,KAAOZ,EACVE,EAAWW,SAASD,KACxBD,EAAKC,GAAOZ,EAAMY,QAGdP,OACDL,EAAMc,OACNC,EAAKf,EAAOV,IAGX0B,EACJhB,EAAMiB,cACNjB,EAAMgB,SACHhB,EAAMiB,iBAAgBjB,EAAMgB,eAEjCL,EAAKG,IAAM,SAACI,SACH,CACL,CAAEC,UAAW,aAAcC,OAAQ,EAAGC,SAAU,GAChDP,MAAIT,EAAJS,CAAYI,GACZJ,MAAI,CAAEE,QAAAA,GAANF,CAAiBI,KAIdP,EAIyCW,CAAWtB,GAAQU,+BC9BrC,gBAE9BA,IAAAA,gBAEAN,gBAACX,EAAa8B,UAASC,QAHvBN,OAIEd,gCACEA,gBAACD,QACAO"}
|
|
1
|
+
{"version":3,"file":"system.cjs.production.min.js","sources":["../src/normalize.ts","../src/useTheme.tsx","../src/Element.tsx","../src/useClassname.ts","../src/reset.ts","../src/useStyles.ts"],"sourcesContent":["import { ElementType } from 'react';\n\nconst base = {\n boxSizing: 'border-box',\n margin: 0,\n padding: 0,\n minWidth: 0,\n fontSize: '100%',\n fontFamily: 'inherit',\n verticalAlign: 'baseline',\n WebkitTapHighlightColor: 'transparent',\n} as const;\n\n// Content\n// ---------------\nconst block = {\n display: 'block',\n} as const;\n\nconst list = {\n // empty\n} as const;\n\nconst table = {\n borderCollapse: 'collapse',\n borderSpacing: 0,\n} as const;\n\n// Typography\n// ---------------\nconst a = {\n textDecoration: 'none',\n touchAction: 'manipulation',\n} as const;\n\nconst quote = {\n quotes: 'none',\n selectors: {\n '&:before, &:after': {\n content: \"''\",\n },\n },\n} as const;\n\n// Form Elements\n// ---------------\nconst button = {\n display: 'block',\n appearance: 'none',\n background: 'transparent',\n textAlign: 'center',\n touchAction: 'manipulation',\n} as const;\n\nconst input = {\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-clear': {\n display: 'none',\n },\n '&::-webkit-search-cancel-button': {\n WebkitAppearance: 'none',\n },\n },\n} as const;\n\nconst select = {\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-expand': {\n display: 'none',\n },\n },\n} as const;\n\nconst textarea = {\n display: 'block',\n appearance: 'none',\n} as const;\n\n// Reset\n// ---------------\nconst reset = {\n article: block,\n aside: block,\n details: block,\n figcaption: block,\n figure: block,\n footer: block,\n header: block,\n hgroup: block,\n menu: block,\n nav: block,\n section: block,\n ul: list,\n ol: list,\n blockquote: quote,\n q: quote,\n a,\n base,\n table,\n select,\n button,\n textarea,\n input,\n} as const;\n\nexport type NormalizedElement = keyof typeof reset;\nconst isKnownElement = (input: string): input is NormalizedElement =>\n input in reset;\n\n/**\n * Helper to conveniently get reset styles.\n */\nexport const getNormalizedStyles = (input?: ElementType): object => {\n /**\n * If a React component is given, we don't apply any reset styles\n * and return the base reset.\n */\n if (typeof input !== 'string') {\n return reset.base;\n }\n\n /**\n * Try to find the reset style for a HTML element. If the element\n * is not included return empty styles.\n */\n return isKnownElement(input) ? reset[input] : {};\n};\n","import React, { createContext, useCallback, useContext } from 'react';\nimport { css as themeUi } from '@theme-ui/css';\nimport { Theme } from '@marigold/system';\n\nimport { StyleObject } from './types';\n\nconst Context = createContext<Theme>({});\n\nexport const useTheme = () => {\n const theme = useContext(Context);\n const css = useCallback(\n (style: StyleObject) => themeUi(style)(theme),\n [theme]\n );\n return { theme, css };\n};\n\nexport type ThemeProviderProps = { theme: any };\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({\n theme,\n children,\n}) => <Context.Provider value={theme}>{children}</Context.Provider>;\n","import { jsx } from '@emotion/react';\nimport { forwardRef } from 'react';\nimport {\n PolymorphicPropsWithRef,\n PolymorphicComponentWithRef,\n} from '@marigold/types';\n\nimport { getNormalizedStyles } from './normalize';\nimport { CSSObject } from './types';\nimport { useTheme } from './useTheme';\n\nexport type ElementOwnProps = {\n css?: CSSObject;\n variant?: string | string[];\n};\n\nexport type ElementProps = PolymorphicPropsWithRef<ElementOwnProps, 'div'>;\n\n/**\n * Function expression to check if there is any falsy value or empty object\n */\nconst isNotEmpty = (val: any) =>\n !(val && Object.keys(val).length === 0 && val.constructor === Object);\n\n/**\n * Get the normalized base styles\n */\nconst baseStyles = getNormalizedStyles('base');\n\nexport const Element: PolymorphicComponentWithRef<ElementOwnProps, 'div'> =\n forwardRef(\n ({ as = 'div', css: styles = {}, variant, children, ...props }, ref) => {\n const { css } = useTheme();\n\n /**\n * Transform variant input for `@theme-ui/css`\n */\n const variants = Array.isArray(variant)\n ? variant.map(v => ({ variant: v }))\n : [{ variant }];\n\n return jsx(\n as,\n {\n ...props,\n ...{\n css: [\n baseStyles,\n getNormalizedStyles(as),\n ...variants.map(v => css(v)),\n css(styles),\n ].filter(isNotEmpty),\n },\n ref,\n },\n children\n );\n }\n );\n","import { css as emotion } from '@emotion/css';\nimport { StyleObject } from './types';\nimport { useTheme } from './useTheme';\n\n// 🤫 https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object\n// lodash.isEmpty is tooo much KBs!\nconst isEmpty = (val: any) =>\n val && Object.keys(val).length === 0 && val.constructor === Object;\n\nexport const useClassname = (...styles: StyleObject[]) => {\n const { css } = useTheme();\n return styles\n .map(style => {\n /**\n * emotion will create a `css-0` class whenever an empty object is\n * passed. Since this makes debugging harder we'll do not pass empty\n * objects to emotion.\n */\n const themedStyle = css(style);\n return isEmpty(themedStyle) ? '' : emotion(themedStyle);\n })\n .join(' ');\n};\n","import { css } from '@emotion/css';\n\nconst base = css({\n boxSizing: 'border-box',\n margin: 0,\n padding: 0,\n minWidth: 0,\n fontSize: '100%',\n font: 'inherit',\n verticalAlign: 'baseline',\n WebkitTapHighlightColor: 'transparent',\n});\n\n// Content\n// ---------------\nconst block = css({\n display: 'block',\n});\n\nconst list = css({\n // empty\n});\n\nconst table = css({\n borderCollapse: 'collapse',\n borderSpacing: 0,\n});\n\n// Typography\n// ---------------\nconst a = css({\n textDecoration: 'none',\n touchAction: 'manipulation',\n});\n\nconst quote = css({\n quotes: 'none',\n selectors: {\n '&:before, &:after': {\n content: \"''\",\n },\n },\n});\n\n// Form Elements\n// ---------------\nconst button = css({\n display: 'block',\n appearance: 'none',\n background: 'transparent',\n textAlign: 'center',\n touchAction: 'manipulation',\n});\n\nconst input = css({\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-clear': {\n display: 'none',\n },\n '&::-webkit-search-cancel-button': {\n WebkitAppearance: 'none',\n },\n },\n});\n\nconst select = css({\n display: 'block',\n appearance: 'none',\n selectors: {\n '&::-ms-expand': {\n display: 'none',\n },\n },\n});\n\nconst textarea = css({\n display: 'block',\n appearance: 'none',\n});\n\n// Reset\n// ---------------\nexport const reset = {\n article: block,\n aside: block,\n details: block,\n figcaption: block,\n figure: block,\n footer: block,\n header: block,\n hgroup: block,\n menu: block,\n nav: block,\n section: block,\n ul: list,\n ol: list,\n blockquote: quote,\n q: quote,\n a,\n base,\n table,\n select,\n button,\n textarea,\n input,\n} as const;\n","import { ElementType } from 'react';\nimport { reset } from './reset';\nimport { CSSObject } from './types';\nimport { useClassname } from './useClassname';\n\nexport type UseStyleInput = {\n element?: ElementType;\n css?: Omit<CSSObject, 'variant' | 'element'> & {\n variant?: never;\n element?: never;\n };\n variant?: string | string[];\n className?: string;\n};\n\n/**\n * Hook that can adds base styles, reset for certain elements, variants and custom styles\n */\nexport const useStyles = ({\n element,\n css: styles = {},\n variant,\n className = '',\n}: UseStyleInput) => {\n /**\n * Get reset styles. Base is always applied. An additional reset maybe applied\n * based on the passed element.\n *\n * We check the passed className if it already includes the reset styles so no\n * duplicates are applied.\n */\n const baseClassName = className.includes(reset.base) ? '' : reset.base;\n const resetClassName =\n typeof element === 'string'\n ? className.includes((reset as { [key: string]: string })[element])\n ? ''\n : (reset as { [key: string]: string })[element]\n : '';\n\n /**\n * Get variant styles (from theme).\n */\n const variants = Array.isArray(variant)\n ? variant.map(v => ({ variant: v }))\n : [{ variant }];\n const variantsClassName = useClassname(...variants);\n\n /**\n * Custom styles are applied \"on runtime\". They are usually controlled via component\n * props and can change between component instances.\n */\n const customClassName = useClassname(styles);\n\n return [\n baseClassName,\n resetClassName,\n variantsClassName,\n customClassName,\n className,\n ]\n .filter(Boolean)\n .join(' ');\n};\n"],"names":["block","display","list","quote","quotes","selectors","content","reset","article","aside","details","figcaption","figure","footer","header","hgroup","menu","nav","section","ul","ol","blockquote","q","a","textDecoration","touchAction","base","boxSizing","margin","padding","minWidth","fontSize","fontFamily","verticalAlign","WebkitTapHighlightColor","table","borderCollapse","borderSpacing","select","appearance","button","background","textAlign","textarea","input","WebkitAppearance","getNormalizedStyles","isKnownElement","Context","createContext","useTheme","theme","useContext","css","useCallback","style","themeUi","isNotEmpty","val","Object","keys","length","constructor","baseStyles","Element","forwardRef","ref","as","styles","variant","children","props","variants","Array","isArray","map","v","jsx","filter","isEmpty","useClassname","themedStyle","emotion","join","font","React","Provider","value","element","className","baseClassName","includes","resetClassName","Boolean"],"mappings":"6XAEA,IAaMA,EAAQ,CACZC,QAAS,SAGLC,EAAO,GAgBPC,EAAQ,CACZC,OAAQ,OACRC,UAAW,qBACY,CACnBC,QAAS,QA6CTC,EAAQ,CACZC,QAASR,EACTS,MAAOT,EACPU,QAASV,EACTW,WAAYX,EACZY,OAAQZ,EACRa,OAAQb,EACRc,OAAQd,EACRe,OAAQf,EACRgB,KAAMhB,EACNiB,IAAKjB,EACLkB,QAASlB,EACTmB,GAAIjB,EACJkB,GAAIlB,EACJmB,WAAYlB,EACZmB,EAAGnB,EACHoB,EAtEQ,CACRC,eAAgB,OACh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,WAAY,SA2BZK,MAAAA,iIHxFyD,mBAGrDyC,gBAACrC,EAAQsC,UAASC,QAFtBpC,SACAmB,oDIFuB,gBACvBkB,IAAAA,YACAnC,IAAKe,aAAS,KACdC,IAAAA,YACAoB,UAAAA,aAAY,KASNC,EAAgBD,EAAUE,SAASpF,EAAMmB,MAAQ,GAAKnB,EAAMmB,KAC5DkE,EACe,iBAAZJ,EACHC,EAAUE,SAAUpF,EAAoCiF,IACtD,GACCjF,EAAoCiF,GACvC,GAKAhB,EAAWC,MAAMC,QAAQL,GAC3BA,EAAQM,KAAI,SAAAC,SAAM,CAAEP,QAASO,MAC7B,CAAC,CAAEP,QAAAA,UASA,CACLqB,EACAE,EAVwBZ,eAAgBR,GAMlBQ,EAAaZ,GAOnCqB,GAECX,OAAOe,SACPV,KAAK"}
|
package/dist/system.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import React, { useContext, useCallback, createContext, forwardRef } from 'react';
|
|
1
3
|
import { css } from '@theme-ui/css';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import React, { forwardRef } from 'react';
|
|
4
|
+
import { css as css$1 } from '@emotion/css';
|
|
5
|
+
export { cache } from '@emotion/css';
|
|
5
6
|
|
|
6
7
|
function _extends() {
|
|
7
8
|
_extends = Object.assign || function (target) {
|
|
@@ -36,124 +37,354 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
36
37
|
return target;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
var base = {
|
|
41
|
+
boxSizing: 'border-box',
|
|
42
|
+
margin: 0,
|
|
43
|
+
padding: 0,
|
|
44
|
+
minWidth: 0,
|
|
45
|
+
fontSize: '100%',
|
|
46
|
+
fontFamily: 'inherit',
|
|
47
|
+
verticalAlign: 'baseline',
|
|
48
|
+
WebkitTapHighlightColor: 'transparent'
|
|
49
|
+
}; // Content
|
|
43
50
|
// ---------------
|
|
44
|
-
var SPACE_PROPS = ['m', 'margin', 'mt', 'marginTop', 'mr', 'marginRight', 'mb', 'marginBottom', 'ml', 'marginLeft', 'mx', 'marginX', 'my', 'marginY', 'p', 'padding', 'pt', 'paddingTop', 'pr', 'paddingRight', 'pb', 'paddingBottom', 'pl', 'paddingLeft', 'px', 'paddingX', 'py', 'paddingY'];
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* css prop, which we don't care, since we first pass the `css` prop
|
|
56
|
-
* to styled-system.
|
|
57
|
-
*
|
|
58
|
-
* *The fix consist of two parts:*
|
|
59
|
-
*
|
|
60
|
-
* (1) using `.yarnclean` to remove the `emotion/core` typings completly.
|
|
61
|
-
* (2) having this sink file to re-apply the typings and tell TS to ignore
|
|
62
|
-
* the untyped import.
|
|
63
|
-
*/
|
|
52
|
+
var block = {
|
|
53
|
+
display: 'block'
|
|
54
|
+
};
|
|
55
|
+
var list = {// empty
|
|
56
|
+
};
|
|
57
|
+
var table = {
|
|
58
|
+
borderCollapse: 'collapse',
|
|
59
|
+
borderSpacing: 0
|
|
60
|
+
}; // Typography
|
|
64
61
|
// ---------------
|
|
65
62
|
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
var a = {
|
|
64
|
+
textDecoration: 'none',
|
|
65
|
+
touchAction: 'manipulation'
|
|
66
|
+
};
|
|
67
|
+
var quote = {
|
|
68
|
+
quotes: 'none',
|
|
69
|
+
selectors: {
|
|
70
|
+
'&:before, &:after': {
|
|
71
|
+
content: "''"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}; // Form Elements
|
|
75
|
+
// ---------------
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
77
|
+
var button = {
|
|
78
|
+
display: 'block',
|
|
79
|
+
appearance: 'none',
|
|
80
|
+
background: 'transparent',
|
|
81
|
+
textAlign: 'center',
|
|
82
|
+
touchAction: 'manipulation'
|
|
83
|
+
};
|
|
84
|
+
var input = {
|
|
85
|
+
display: 'block',
|
|
86
|
+
appearance: 'none',
|
|
87
|
+
selectors: {
|
|
88
|
+
'&::-ms-clear': {
|
|
89
|
+
display: 'none'
|
|
90
|
+
},
|
|
91
|
+
'&::-webkit-search-cancel-button': {
|
|
92
|
+
WebkitAppearance: 'none'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var select = {
|
|
97
|
+
display: 'block',
|
|
98
|
+
appearance: 'none',
|
|
99
|
+
selectors: {
|
|
100
|
+
'&::-ms-expand': {
|
|
101
|
+
display: 'none'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var textarea = {
|
|
106
|
+
display: 'block',
|
|
107
|
+
appearance: 'none'
|
|
108
|
+
}; // Reset
|
|
109
|
+
// ---------------
|
|
82
110
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
111
|
+
var reset = {
|
|
112
|
+
article: block,
|
|
113
|
+
aside: block,
|
|
114
|
+
details: block,
|
|
115
|
+
figcaption: block,
|
|
116
|
+
figure: block,
|
|
117
|
+
footer: block,
|
|
118
|
+
header: block,
|
|
119
|
+
hgroup: block,
|
|
120
|
+
menu: block,
|
|
121
|
+
nav: block,
|
|
122
|
+
section: block,
|
|
123
|
+
ul: list,
|
|
124
|
+
ol: list,
|
|
125
|
+
blockquote: quote,
|
|
126
|
+
q: quote,
|
|
127
|
+
a: a,
|
|
128
|
+
base: base,
|
|
129
|
+
table: table,
|
|
130
|
+
select: select,
|
|
131
|
+
button: button,
|
|
132
|
+
textarea: textarea,
|
|
133
|
+
input: input
|
|
134
|
+
};
|
|
87
135
|
|
|
88
|
-
var
|
|
136
|
+
var isKnownElement = function isKnownElement(input) {
|
|
137
|
+
return input in reset;
|
|
138
|
+
};
|
|
89
139
|
/**
|
|
90
|
-
*
|
|
91
|
-
* single `css` prop for emotion. All gathered props will be passed to `@theme-ui/css`
|
|
92
|
-
* before emotion will process them. This way CSS properties will interpolated based on
|
|
93
|
-
* the given theme.
|
|
140
|
+
* Helper to conveniently get reset styles.
|
|
94
141
|
*/
|
|
95
142
|
|
|
96
|
-
var parseProps = function parseProps(props) {
|
|
97
|
-
var next = {}; // TODO: optimize loop such that the style props are picked
|
|
98
|
-
// within the loop (and remove lodash.pick!)
|
|
99
143
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
144
|
+
var getNormalizedStyles = function getNormalizedStyles(input) {
|
|
145
|
+
/**
|
|
146
|
+
* If a React component is given, we don't apply any reset styles
|
|
147
|
+
* and return the base reset.
|
|
148
|
+
*/
|
|
149
|
+
if (typeof input !== 'string') {
|
|
150
|
+
return reset.base;
|
|
103
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Try to find the reset style for a HTML element. If the element
|
|
154
|
+
* is not included return empty styles.
|
|
155
|
+
*/
|
|
104
156
|
|
|
105
|
-
var styles = _extends({}, props.css, {}, pick(props, SPACE_PROPS));
|
|
106
157
|
|
|
107
|
-
|
|
158
|
+
return isKnownElement(input) ? reset[input] : {};
|
|
159
|
+
};
|
|
108
160
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
161
|
+
var Context = /*#__PURE__*/createContext({});
|
|
162
|
+
var useTheme = function useTheme() {
|
|
163
|
+
var theme = useContext(Context);
|
|
164
|
+
var css$1 = useCallback(function (style) {
|
|
165
|
+
return css(style)(theme);
|
|
166
|
+
}, [theme]);
|
|
167
|
+
return {
|
|
168
|
+
theme: theme,
|
|
169
|
+
css: css$1
|
|
117
170
|
};
|
|
171
|
+
};
|
|
172
|
+
var ThemeProvider = function ThemeProvider(_ref) {
|
|
173
|
+
var theme = _ref.theme,
|
|
174
|
+
children = _ref.children;
|
|
175
|
+
return React.createElement(Context.Provider, {
|
|
176
|
+
value: theme
|
|
177
|
+
}, children);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
var _excluded = ["as", "css", "variant", "children"];
|
|
181
|
+
/**
|
|
182
|
+
* Function expression to check if there is any falsy value or empty object
|
|
183
|
+
*/
|
|
118
184
|
|
|
119
|
-
|
|
185
|
+
var isNotEmpty = function isNotEmpty(val) {
|
|
186
|
+
return !(val && Object.keys(val).length === 0 && val.constructor === Object);
|
|
120
187
|
};
|
|
188
|
+
/**
|
|
189
|
+
* Get the normalized base styles
|
|
190
|
+
*/
|
|
191
|
+
|
|
121
192
|
|
|
122
|
-
var
|
|
193
|
+
var baseStyles = /*#__PURE__*/getNormalizedStyles('base');
|
|
194
|
+
var Element = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
123
195
|
var _ref$as = _ref.as,
|
|
124
196
|
as = _ref$as === void 0 ? 'div' : _ref$as,
|
|
197
|
+
_ref$css = _ref.css,
|
|
198
|
+
styles = _ref$css === void 0 ? {} : _ref$css,
|
|
199
|
+
variant = _ref.variant,
|
|
125
200
|
children = _ref.children,
|
|
126
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
201
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
202
|
+
|
|
203
|
+
var _useTheme = useTheme(),
|
|
204
|
+
css = _useTheme.css;
|
|
205
|
+
/**
|
|
206
|
+
* Transform variant input for `@theme-ui/css`
|
|
207
|
+
*/
|
|
208
|
+
|
|
127
209
|
|
|
128
|
-
|
|
210
|
+
var variants = Array.isArray(variant) ? variant.map(function (v) {
|
|
211
|
+
return {
|
|
212
|
+
variant: v
|
|
213
|
+
};
|
|
214
|
+
}) : [{
|
|
215
|
+
variant: variant
|
|
216
|
+
}];
|
|
217
|
+
return jsx(as, _extends({}, props, {
|
|
218
|
+
css: [baseStyles, getNormalizedStyles(as)].concat(variants.map(function (v) {
|
|
219
|
+
return css(v);
|
|
220
|
+
}), [css(styles)]).filter(isNotEmpty)
|
|
221
|
+
}, {
|
|
222
|
+
ref: ref
|
|
223
|
+
}), children);
|
|
129
224
|
});
|
|
130
225
|
|
|
131
|
-
|
|
132
|
-
* CSS snippet and idea from:
|
|
133
|
-
* https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/
|
|
134
|
-
*/
|
|
226
|
+
// lodash.isEmpty is tooo much KBs!
|
|
135
227
|
|
|
136
|
-
var
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
228
|
+
var isEmpty = function isEmpty(val) {
|
|
229
|
+
return val && Object.keys(val).length === 0 && val.constructor === Object;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var useClassname = function useClassname() {
|
|
233
|
+
var _useTheme = useTheme(),
|
|
234
|
+
css = _useTheme.css;
|
|
235
|
+
|
|
236
|
+
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
237
|
+
styles[_key] = arguments[_key];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return styles.map(function (style) {
|
|
241
|
+
/**
|
|
242
|
+
* emotion will create a `css-0` class whenever an empty object is
|
|
243
|
+
* passed. Since this makes debugging harder we'll do not pass empty
|
|
244
|
+
* objects to emotion.
|
|
245
|
+
*/
|
|
246
|
+
var themedStyle = css(style);
|
|
247
|
+
return isEmpty(themedStyle) ? '' : css$1(themedStyle);
|
|
248
|
+
}).join(' ');
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
var base$1 = /*#__PURE__*/css$1({
|
|
252
|
+
boxSizing: 'border-box',
|
|
253
|
+
margin: 0,
|
|
254
|
+
padding: 0,
|
|
255
|
+
minWidth: 0,
|
|
256
|
+
fontSize: '100%',
|
|
257
|
+
font: 'inherit',
|
|
258
|
+
verticalAlign: 'baseline',
|
|
259
|
+
WebkitTapHighlightColor: 'transparent'
|
|
260
|
+
}); // Content
|
|
261
|
+
// ---------------
|
|
262
|
+
|
|
263
|
+
var block$1 = /*#__PURE__*/css$1({
|
|
264
|
+
display: 'block'
|
|
265
|
+
});
|
|
266
|
+
var list$1 = /*#__PURE__*/css$1({// empty
|
|
267
|
+
});
|
|
268
|
+
var table$1 = /*#__PURE__*/css$1({
|
|
269
|
+
borderCollapse: 'collapse',
|
|
270
|
+
borderSpacing: 0
|
|
271
|
+
}); // Typography
|
|
272
|
+
// ---------------
|
|
273
|
+
|
|
274
|
+
var a$1 = /*#__PURE__*/css$1({
|
|
275
|
+
textDecoration: 'none',
|
|
276
|
+
touchAction: 'manipulation'
|
|
277
|
+
});
|
|
278
|
+
var quote$1 = /*#__PURE__*/css$1({
|
|
279
|
+
quotes: 'none',
|
|
280
|
+
selectors: {
|
|
281
|
+
'&:before, &:after': {
|
|
282
|
+
content: "''"
|
|
146
283
|
}
|
|
147
|
-
}
|
|
284
|
+
}
|
|
285
|
+
}); // Form Elements
|
|
286
|
+
// ---------------
|
|
287
|
+
|
|
288
|
+
var button$1 = /*#__PURE__*/css$1({
|
|
289
|
+
display: 'block',
|
|
290
|
+
appearance: 'none',
|
|
291
|
+
background: 'transparent',
|
|
292
|
+
textAlign: 'center',
|
|
293
|
+
touchAction: 'manipulation'
|
|
294
|
+
});
|
|
295
|
+
var input$1 = /*#__PURE__*/css$1({
|
|
296
|
+
display: 'block',
|
|
297
|
+
appearance: 'none',
|
|
298
|
+
selectors: {
|
|
299
|
+
'&::-ms-clear': {
|
|
300
|
+
display: 'none'
|
|
301
|
+
},
|
|
302
|
+
'&::-webkit-search-cancel-button': {
|
|
303
|
+
WebkitAppearance: 'none'
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
var select$1 = /*#__PURE__*/css$1({
|
|
308
|
+
display: 'block',
|
|
309
|
+
appearance: 'none',
|
|
310
|
+
selectors: {
|
|
311
|
+
'&::-ms-expand': {
|
|
312
|
+
display: 'none'
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
var textarea$1 = /*#__PURE__*/css$1({
|
|
317
|
+
display: 'block',
|
|
318
|
+
appearance: 'none'
|
|
319
|
+
}); // Reset
|
|
320
|
+
// ---------------
|
|
321
|
+
|
|
322
|
+
var reset$1 = {
|
|
323
|
+
article: block$1,
|
|
324
|
+
aside: block$1,
|
|
325
|
+
details: block$1,
|
|
326
|
+
figcaption: block$1,
|
|
327
|
+
figure: block$1,
|
|
328
|
+
footer: block$1,
|
|
329
|
+
header: block$1,
|
|
330
|
+
hgroup: block$1,
|
|
331
|
+
menu: block$1,
|
|
332
|
+
nav: block$1,
|
|
333
|
+
section: block$1,
|
|
334
|
+
ul: list$1,
|
|
335
|
+
ol: list$1,
|
|
336
|
+
blockquote: quote$1,
|
|
337
|
+
q: quote$1,
|
|
338
|
+
a: a$1,
|
|
339
|
+
base: base$1,
|
|
340
|
+
table: table$1,
|
|
341
|
+
select: select$1,
|
|
342
|
+
button: button$1,
|
|
343
|
+
textarea: textarea$1,
|
|
344
|
+
input: input$1
|
|
148
345
|
};
|
|
149
346
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
347
|
+
/**
|
|
348
|
+
* Hook that can adds base styles, reset for certain elements, variants and custom styles
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
var useStyles = function useStyles(_ref) {
|
|
352
|
+
var element = _ref.element,
|
|
353
|
+
_ref$css = _ref.css,
|
|
354
|
+
styles = _ref$css === void 0 ? {} : _ref$css,
|
|
355
|
+
variant = _ref.variant,
|
|
356
|
+
_ref$className = _ref.className,
|
|
357
|
+
className = _ref$className === void 0 ? '' : _ref$className;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Get reset styles. Base is always applied. An additional reset maybe applied
|
|
361
|
+
* based on the passed element.
|
|
362
|
+
*
|
|
363
|
+
* We check the passed className if it already includes the reset styles so no
|
|
364
|
+
* duplicates are applied.
|
|
365
|
+
*/
|
|
366
|
+
var baseClassName = className.includes(reset$1.base) ? '' : reset$1.base;
|
|
367
|
+
var resetClassName = typeof element === 'string' ? className.includes(reset$1[element]) ? '' : reset$1[element] : '';
|
|
368
|
+
/**
|
|
369
|
+
* Get variant styles (from theme).
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
var variants = Array.isArray(variant) ? variant.map(function (v) {
|
|
373
|
+
return {
|
|
374
|
+
variant: v
|
|
375
|
+
};
|
|
376
|
+
}) : [{
|
|
377
|
+
variant: variant
|
|
378
|
+
}];
|
|
379
|
+
var variantsClassName = useClassname.apply(void 0, variants);
|
|
380
|
+
/**
|
|
381
|
+
* Custom styles are applied "on runtime". They are usually controlled via component
|
|
382
|
+
* props and can change between component instances.
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
var customClassName = useClassname(styles);
|
|
386
|
+
return [baseClassName, resetClassName, variantsClassName, customClassName, className].filter(Boolean).join(' ');
|
|
156
387
|
};
|
|
157
388
|
|
|
158
|
-
export {
|
|
389
|
+
export { Element, ThemeProvider, useClassname, useStyles, useTheme };
|
|
159
390
|
//# sourceMappingURL=system.esm.js.map
|