@makeswift/runtime 0.2.2 → 0.2.4

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.
Files changed (56) hide show
  1. package/dist/Box.cjs.js +14 -14
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Button.cjs.js +23 -23
  4. package/dist/Button.cjs.js.map +1 -1
  5. package/dist/Carousel.cjs.js +8 -8
  6. package/dist/Carousel.cjs.js.map +1 -1
  7. package/dist/Carousel.es.js.map +1 -1
  8. package/dist/Countdown.cjs.js +13 -13
  9. package/dist/Countdown.cjs.js.map +1 -1
  10. package/dist/Divider.cjs.js +4 -4
  11. package/dist/Divider.cjs.js.map +1 -1
  12. package/dist/Embed.cjs.js +2 -2
  13. package/dist/Embed.cjs.js.map +1 -1
  14. package/dist/Form.cjs.js +72 -72
  15. package/dist/Form.cjs.js.map +1 -1
  16. package/dist/Image.cjs2.js +10 -10
  17. package/dist/Image.cjs2.js.map +1 -1
  18. package/dist/Navigation.cjs.js +17 -17
  19. package/dist/Navigation.cjs.js.map +1 -1
  20. package/dist/Root.cjs.js +2 -2
  21. package/dist/Root.cjs.js.map +1 -1
  22. package/dist/SocialLinks.cjs.js +3 -3
  23. package/dist/SocialLinks.cjs.js.map +1 -1
  24. package/dist/Text.cjs.js +21 -21
  25. package/dist/Text.cjs.js.map +1 -1
  26. package/dist/actions.es.js +1 -1
  27. package/dist/components.cjs.js +18 -18
  28. package/dist/cssMediaRules.cjs.js +7 -7
  29. package/dist/cssMediaRules.cjs.js.map +1 -1
  30. package/dist/index.cjs.js +374 -8
  31. package/dist/index.cjs.js.map +1 -1
  32. package/dist/index.cjs2.js +10 -10
  33. package/dist/index.cjs2.js.map +1 -1
  34. package/dist/index.cjs3.js +3 -3
  35. package/dist/index.cjs3.js.map +1 -1
  36. package/dist/index.es.js +367 -12
  37. package/dist/index.es.js.map +1 -1
  38. package/dist/index.es2.js.map +1 -1
  39. package/dist/next.cjs.js +22 -402
  40. package/dist/next.cjs.js.map +1 -1
  41. package/dist/next.es.js +12 -388
  42. package/dist/next.es.js.map +1 -1
  43. package/dist/react-builder-preview.cjs.js +11 -11
  44. package/dist/react-builder-preview.cjs.js.map +1 -1
  45. package/dist/react-builder-preview.es.js +1 -1
  46. package/dist/react.cjs.js +8 -8
  47. package/dist/types/src/next/api-handler.d.ts +25 -1
  48. package/dist/types/src/next/api-handler.d.ts.map +1 -1
  49. package/dist/types/src/next/index.d.ts +1 -1
  50. package/dist/types/src/next/index.d.ts.map +1 -1
  51. package/dist/types/src/runtimes/react/use-style.d.ts.map +1 -1
  52. package/dist/useBoxShadow.cjs.js +3 -3
  53. package/dist/useBoxShadow.cjs.js.map +1 -1
  54. package/dist/useMediaQuery.cjs.js +6 -6
  55. package/dist/useMediaQuery.cjs.js.map +1 -1
  56. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"Text.cjs.js","sources":["../src/components/hooks/useTypography.ts","../src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.ts","../src/components/builtin/Text/components/RichTextEditor/components/Mark/index.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.tsx","../src/components/builtin/Text/components/RichTextEditor/components/Block/index.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Link.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.tsx","../src/components/builtin/Text/components/RichTextEditor/index.tsx","../src/components/builtin/Text/Text.tsx"],"sourcesContent":["import type { ColorValue } from '../utils/types'\nimport type { Length as LengthValue } from '../../prop-controllers'\nimport { DeviceOverride } from '../../prop-controllers'\nimport { TYPOGRAPHIES_BY_ID } from '../utils/queries'\nimport { useQuery } from '../../api/react'\n\nexport type TypographyStyleValue = {\n fontFamily?: string\n fontWeight?: number\n fontSize?: LengthValue\n color?: ColorValue\n textAlign?: string\n lineHeight?: number\n letterSpacing?: number\n uppercase?: boolean\n underline?: boolean\n strikethrough?: boolean\n italic?: boolean\n}\n\nexport type TypographyStyle = Array<DeviceOverride<TypographyStyleValue>>\n\nexport type Typography = {\n id: string\n name: string\n style: TypographyStyle\n}\n\nexport function useTypography(\n typographyId: string | null | undefined,\n): Typography | null | undefined {\n const { error, data } = useQuery(TYPOGRAPHIES_BY_ID, {\n skip: typographyId == null,\n variables: { ids: typographyId != null ? [typographyId] : [] },\n })\n\n if (typographyId == null || error != null) return null\n\n return data?.typographies[0] as Typography | null\n}\n","import { Length as LengthValue } from '../../../../../../../../prop-controllers'\nimport { ColorValue as Color } from '../../../../../../../utils/types'\nimport { findDeviceOverride } from '../../../../../../../utils/devices'\nimport type { DeviceOverride } from '../../../../../../../../prop-controllers'\nimport { SWATCHES_BY_ID } from '../../../../../../../utils/queries'\nimport { useTypography, TypographyStyle } from '../../../../../../../hooks/useTypography'\nimport { useQuery } from '../../../../../../../../api/react'\n\nexport type TypographyMarkDataValue = {\n fontWeight?: number\n fontSize?: LengthValue\n fontFamily?: string\n color?: Color\n textAlign?: string\n lineHeight?: number\n letterSpacing?: number\n uppercase?: boolean\n italic?: boolean\n underline?: boolean\n strikethrough?: boolean\n}\n\nexport type TypographyMarkValue = {\n id: string | null | undefined\n style: TypographyStyle\n}\n\nexport type TypographyMarkData = Array<DeviceOverride<TypographyMarkDataValue>>\n\nconst concat = <A extends unknown[], B extends unknown[]>(a: A, b: B) => a.concat(b)\nconst getSwatchId = ({ value: { color } }: any) => color && color.swatchId\nconst getDeviceId = ({ deviceId }: any) => deviceId\n\nconst withColor =\n (swatches: any) =>\n ({ value: { color, ...restOfValue }, ...rest }: any) => ({\n ...rest,\n value: {\n ...restOfValue,\n ...(color\n ? {\n color: {\n swatch: swatches.find((s: any) => s && s.id === color.swatchId),\n alpha: color.alpha,\n },\n }\n : {}),\n },\n })\n\nexport const overrideTypographyStyle = <A>(\n source: Array<DeviceOverride<A>>,\n override: Array<DeviceOverride<A>>,\n): Array<DeviceOverride<A>> => {\n const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))]\n\n return devices.map((deviceId: any) => ({\n deviceId,\n value: {\n ...(findDeviceOverride(source, deviceId) || { value: {} }).value,\n ...(findDeviceOverride(override, deviceId, v => v) || { value: {} }).value,\n },\n })) as DeviceOverride<A>[]\n}\n\nexport default function useTypographyMark(\n value: TypographyMarkValue | null | undefined,\n): TypographyMarkData | null | undefined {\n const typography = useTypography(value && value.id)\n\n const swatchIds = [\n (typography && typography.style.map(getSwatchId)) || [],\n (value && value.style.map(getSwatchId)) || [],\n ]\n .reduce(concat)\n .filter(Boolean)\n\n const { error: colorError, data: colorData = {} } = useQuery(SWATCHES_BY_ID, {\n skip: swatchIds == null || swatchIds.length === 0,\n variables: { ids: swatchIds },\n })\n\n const { swatches = [] } = colorData\n\n if (colorError != null) return null\n\n return overrideTypographyStyle(\n (typography && typography.style.map(withColor(swatches))) || [],\n (value && value.style.map(withColor(swatches))) || [],\n )\n}\n","import { ComponentPropsWithoutRef } from 'react'\nimport styled, { css } from 'styled-components'\n\nimport useTypographyMark, {\n TypographyMarkValue,\n TypographyMarkData,\n overrideTypographyStyle,\n TypographyMarkDataValue,\n} from './hooks/useTypographyMark'\nimport { cssMediaRules } from '../../../../../../utils/cssMediaRules'\nimport { colorToString } from '../../../../../../utils/colorToString'\nimport { shallowMergeFallbacks } from '../../../../../../utils/devices'\n\nexport type { TypographyMarkValue }\nexport { overrideTypographyStyle }\n\nconst Span = styled.span<{ typographyStyle: TypographyMarkData | null | undefined }>`\n ${p =>\n cssMediaRules(\n [p.typographyStyle] as const,\n ([\n {\n color,\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n uppercase,\n underline,\n strikethrough,\n italic,\n } = {} as TypographyMarkDataValue,\n ]) => css`\n ${color == null\n ? ''\n : css`\n color: ${colorToString(color)};\n `}\n\n ${fontFamily == null\n ? ''\n : css`\n font-family: '${fontFamily}';\n `}\n\n ${fontSize == null || fontSize.value == null || fontSize.unit == null\n ? ''\n : css`\n font-size: ${`${fontSize.value}${fontSize.unit}`};\n `}\n\n ${fontWeight == null\n ? ''\n : css`\n font-weight: ${fontWeight};\n `}\n\n ${lineHeight == null\n ? ''\n : css`\n line-height: ${lineHeight};\n `}\n\n ${letterSpacing == null\n ? ''\n : css`\n letter-spacing: ${letterSpacing / 10}em;\n `}\n\n ${underline == null && strikethrough == null\n ? ''\n : css`\n text-decoration: ${[\n Boolean(underline) && 'underline',\n Boolean(strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' ')};\n `}\n\n ${uppercase == null\n ? ''\n : css`\n text-transform: ${uppercase === true ? 'uppercase' : 'initial'};\n `}\n\n ${italic == null\n ? ''\n : css`\n font-style: ${italic === true ? 'italic' : 'initial'};\n `}\n `,\n shallowMergeFallbacks,\n )}\n`\n\ntype BaseProps = { value: TypographyMarkValue }\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<typeof Span>, keyof BaseProps>\n\nexport default function Mark({ value, ...restOfProps }: Props): JSX.Element {\n const typographyStyle = useTypographyMark(value)\n\n return <Span {...restOfProps} typographyStyle={typographyStyle} />\n}\n","import type { Plugin } from 'slate-react'\n\nimport Mark from '../components/Mark'\n\nconst TYPOGRAPHY_TYPE = 'typography'\n\nexport default function DeviceOverridesMarksPlugin(): Plugin {\n return {\n renderMark({ mark, children }, _editor, next) {\n if (mark.type === TYPOGRAPHY_TYPE) {\n return <Mark value={mark.data.get('value')}>{children}</Mark>\n }\n\n return next()\n },\n }\n}\n","import { forwardRef, ElementType, ComponentPropsWithoutRef } from 'react'\nimport styled, { css } from 'styled-components'\n\nimport { cssMediaRules } from '../../../../../../utils/cssMediaRules'\nimport type { ResponsiveValue } from '../../../../../../../prop-controllers'\n\ntype StyledBlockProps = {\n textAlign?: ResponsiveValue<'left' | 'center' | 'right' | 'justify'>\n as?: ElementType\n}\n\nconst StyledBlock = styled.div<StyledBlockProps>`\n margin: 0;\n ${p =>\n cssMediaRules([p.textAlign] as const, ([textAlign]) =>\n textAlign == null\n ? css``\n : css`\n text-align: ${textAlign};\n `,\n )}\n\n ${p =>\n p.as === 'blockquote'\n ? css`\n padding: 0.5em 10px;\n font-size: 1.25em;\n font-weight: 300;\n border-left: 5px solid rgba(0, 0, 0, 0.1);\n `\n : ''}\n`\n\ntype Props = ComponentPropsWithoutRef<typeof StyledBlock>\n\nexport default forwardRef<HTMLDivElement, Props>(function Block(\n { textAlign, ...restOfProps }: Props,\n ref,\n) {\n return <StyledBlock {...restOfProps} ref={ref} textAlign={textAlign} />\n})\n","import { Plugin } from 'slate-react'\n\nimport Block from '../components/Block'\n\nexport default function DeviceOverridesBlockPlugin(): Plugin {\n return {\n renderBlock(props, _editor, next): JSX.Element {\n const { node, attributes, children } = props\n const blockProps = { textAlign: node.data.get('textAlign') }\n\n switch (node.type) {\n case 'paragraph':\n return (\n <Block {...attributes} {...blockProps} as=\"p\">\n {children}\n </Block>\n )\n\n case 'heading-one':\n return (\n <Block {...attributes} {...blockProps} as=\"h1\">\n {children}\n </Block>\n )\n\n case 'heading-two':\n return (\n <Block {...attributes} {...blockProps} as=\"h2\">\n {children}\n </Block>\n )\n\n case 'heading-three':\n return (\n <Block {...attributes} {...blockProps} as=\"h3\">\n {children}\n </Block>\n )\n\n case 'heading-four':\n return (\n <Block {...attributes} {...blockProps} as=\"h4\">\n {children}\n </Block>\n )\n\n case 'heading-five':\n return (\n <Block {...attributes} {...blockProps} as=\"h5\">\n {children}\n </Block>\n )\n\n case 'heading-six':\n return (\n <Block {...attributes} {...blockProps} as=\"h6\">\n {children}\n </Block>\n )\n\n case 'blockquote':\n return (\n <Block {...attributes} {...blockProps} as=\"blockquote\">\n {children}\n </Block>\n )\n\n default:\n return next()\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\nimport styled from 'styled-components'\n\nimport { Link } from '../../../../../shared/Link'\n\nconst StyledLink = styled(Link)`\n text-decoration: none;\n`\n\nexport default function LinkPlugin(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'link': {\n const { data } = node\n\n return (\n <StyledLink {...attributes} link={data.toJS()}>\n {children}\n </StyledLink>\n )\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nexport default function Inlines(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'code': {\n return <code {...attributes}>{children}</code>\n }\n\n case 'superscript': {\n return <sup {...attributes}>{children}</sup>\n }\n\n case 'subscript': {\n return <sub {...attributes}>{children}</sub>\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { ComponentPropsWithoutRef, forwardRef, useMemo } from 'react'\n\nimport { Editor as SlateEditor } from 'slate-react'\n\n// @ts-expect-error: no types for '@convertkit/slate-lists'\nimport Lists from '@convertkit/slate-lists'\nimport styled from 'styled-components'\n\nimport DeviceOverridesMarks from './plugins/DeviceOverridesMarks'\nimport DeviceOverridesBlocks from './plugins/DeviceOverridesBlocks'\nimport Link from './plugins/Link'\nimport Inlines from './plugins/Inlines'\n\nexport { overrideTypographyStyle } from './components/Mark'\n\ntype Props = ComponentPropsWithoutRef<typeof SlateEditor>\n\nexport const RichTextEditor = styled(\n forwardRef<SlateEditor, Props>(function RichTextEditor(\n { placeholder = 'Write some text...', ...restOfProps }: Props,\n ref,\n ) {\n const plugins = useMemo(\n () => [Lists(), Link(), Inlines(), DeviceOverridesBlocks(), DeviceOverridesMarks()],\n [],\n )\n\n return (\n <SlateEditor\n {...restOfProps}\n // Workaround because our Slate editor is broken on Chrome 105\n // Problem: https://linear.app/makeswift/issue/PRD-434/our-rich-text-component-breaks-in-the-latest-version-of-chrome\n // Workaround: https://github.com/ianstormtaylor/slate/issues/5110#issuecomment-1234951122\n style={{ WebkitUserModify: undefined }}\n ref={ref}\n autoFocus={false}\n plugins={plugins}\n placeholder={placeholder}\n />\n )\n }),\n)`\n ul,\n ol {\n margin: 0;\n }\n`\n","import {\n useState,\n Ref,\n useImperativeHandle,\n forwardRef,\n useEffect,\n useCallback,\n useRef,\n KeyboardEvent as ReactKeyboardEvent,\n FocusEvent as ReactFocusEvent,\n} from 'react'\nimport styled from 'styled-components'\nimport { Editor, OnChangeParam } from 'slate-react'\nimport { Value, ValueJSON } from 'slate'\n// @ts-expect-error: no types for 'slate-hotkeys'\nimport Hotkeys from 'slate-hotkeys'\nimport { isHotkey } from 'is-hotkey'\n\nimport {\n ElementIDValue,\n MarginValue,\n RichTextDescriptor,\n RichTextValue,\n WidthValue,\n} from '../../../prop-controllers/descriptors'\nimport { cssMargin, cssWidth } from '../../utils/cssMediaRules'\nimport { BoxModelHandle, getBox } from '../../../box-model'\nimport { PropControllersHandle } from '../../../state/modules/prop-controller-handles'\nimport { RichTextEditor } from './components/RichTextEditor'\nimport { useIsInBuilder } from '../../../runtimes/react'\nimport { DescriptorsPropControllers } from '../../../prop-controllers/instances'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: WidthValue\n margin?: MarginValue\n}\n\nconst StyledRichTextEditor = styled(RichTextEditor).withConfig({\n shouldForwardProp: prop => !['width', 'margin'].includes(prop.toString()),\n})<{ width: Props['width']; margin: Props['margin'] }>`\n ${cssWidth()}\n ${cssMargin()}\n`\n\nconst defaultText: ValueJSON = {\n document: { nodes: [{ object: 'block' as const, type: 'paragraph' as const, nodes: [] }] },\n data: {},\n}\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\ntype Descriptors = { text?: RichTextDescriptor }\n\nconst Text = forwardRef(function Text(\n { id, text, width, margin }: Props,\n ref: Ref<BoxModelHandle & PropControllersHandle<Descriptors>>,\n) {\n const [editor, setEditor] = useState<Editor | null>(null)\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useImperativeHandle(\n ref,\n () => ({\n getBoxModel() {\n const el = editor?.findDOMNode([])\n\n return el instanceof Element ? getBox(el) : null\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n useEffect(() => {\n if (editor) controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n /**\n * We must keep local state so that we can reflect the user's typed changes immediately. At the\n * same time, though, the source of truth for the data is the prop data. This presents a\n * challenge: how do we keep local state in sync with the prop data without mangling user input as\n * data comes in?\n *\n * Consider, for example, that the user types \"Hello\". If at a later time, when the user is trying\n * to type \", world\" the component re-renders with prop data \"H\", \"He\", \"Hel\", \"Hell\", \"Hello\", it\n * will disrupt the user's typing. This could also happen as a result of the prop data changing\n * for other reasons, like collaborators changing the prop data concurrently. We want to avoid to\n * disrupt the user's typing, while at the same time display the \"true\" value as quickly as\n * possible.\n *\n * The approach we take here is to commit the prop data at an opportune time: as the user is\n * typing we avoid to commit prop data. But once they've stopped typing, we commit it as soon as\n * possible. This is known as a debounce.\n */\n const [value, setValue] = useState(() => {\n const { selection, ...textWithoutSelection } = text ?? defaultText\n\n return Value.fromJSON(textWithoutSelection)\n })\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit) {\n const nextValue = Value.fromJSON(text ?? defaultText)\n\n setValue(currentValue =>\n currentValue.selection.isBlurred\n ? Value.fromJSON(nextValue.toJSON({ preserveSelection: false }))\n : nextValue,\n )\n }\n }, [shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n function handleChange(change: OnChangeParam) {\n setValue(change.value as Value)\n\n if (change.value !== value) {\n setShouldCommit(false)\n\n controller?.onChange(change)\n }\n }\n\n // HACK: Slate holds on to the very first DOM event handlers passed in and doesn't update them\n // even if they change. Since `controller` is first `undefined` then we must use a ref.\n const lastController = useRef(controller)\n if (lastController.current !== controller) lastController.current = controller\n const handleFocus = useCallback(() => {\n lastController.current?.focus()\n }, [])\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent, _editor: Editor, next: () => any) => {\n if (Hotkeys.isUndo(event)) {\n lastController.current?.undo()\n\n return true\n }\n\n if (Hotkeys.isRedo(event)) {\n lastController.current?.redo()\n\n return true\n }\n\n if (isHotkey('escape')(event)) {\n lastController.current?.blur()\n\n return true\n }\n\n return next()\n },\n [],\n )\n const handleBlur = useCallback((event: ReactFocusEvent, _editor: Editor, next: () => any) => {\n // Normally, after a user highlight a text, clicking on the panel will remove the text selection.\n // This line is a workaround for that. Because the panel is not in the iframe, relatedTarget\n // would be null, and we return early so we don't remove the selection.\n if (event.relatedTarget == null) return true\n\n // Blur the selection if the user is clicking on other text.\n return next()\n }, [])\n\n const isInBuilder = useIsInBuilder()\n\n return (\n <StyledRichTextEditor\n // @ts-expect-error: types don't allow for 'id' prop even though it's used.\n id={id}\n ref={setEditor}\n width={width}\n readOnly={!isInBuilder}\n margin={margin}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n />\n )\n})\n\nexport default Text\n"],"names":["useQuery","TYPOGRAPHIES_BY_ID","findDeviceOverride","SWATCHES_BY_ID","Span","styled","span","p","cssMediaRules","typographyStyle","color","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","uppercase","underline","strikethrough","italic","css","colorToString","value","unit","Boolean","filter","join","shallowMergeFallbacks","restOfProps","useTypographyMark","TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","data","get","StyledBlock","div","textAlign","as","forwardRef","ref","renderBlock","props","node","attributes","blockProps","StyledLink","Link","renderInline","toJS","RichTextEditor","placeholder","plugins","useMemo","Lists","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","StyledRichTextEditor","withConfig","shouldForwardProp","prop","includes","toString","cssWidth","cssMargin","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","Text","id","text","width","margin","editor","setEditor","useState","propControllers","setPropControllers","controller","useImperativeHandle","getBoxModel","el","findDOMNode","Element","getBox","useEffect","setSlateEditor","setValue","selection","textWithoutSelection","Value","fromJSON","shouldCommit","setShouldCommit","nextValue","currentValue","isBlurred","toJSON","preserveSelection","timeoutId","window","setTimeout","clearTimeout","change","onChange","lastController","useRef","current","handleFocus","useCallback","focus","handleKeyDown","event","Hotkeys","isUndo","undo","isRedo","redo","isHotkey","blur","handleBlur","relatedTarget","isInBuilder","useIsInBuilder","handleChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,uBACL,cAC+B;AAC/B,QAAM,EAAE,OAAO,SAASA,MAAAA,SAASC,MAAAA,oBAAoB;AAAA,IACnD,MAAM,gBAAgB;AAAA,IACtB,WAAW,EAAE,KAAK,gBAAgB,OAAO,CAAC,YAAY,IAAI,GAAG;AAAA,EAAA,CAC9D;AAEG,MAAA,gBAAgB,QAAQ,SAAS;AAAa,WAAA;AAElD,SAAO,6BAAM,aAAa;AAC5B;ACVA,MAAM,SAAS,CAA2C,GAAM,MAAS,EAAE,OAAO,CAAC;AACnF,MAAM,cAAc,CAAC,EAAE,OAAO,EAAE,cAAmB,SAAS,MAAM;AAClE,MAAM,cAAc,CAAC,EAAE,eAAoB;AAE3C,MAAM,YACJ,CAAC,aACD,CAAC,OAAwD;AAAxD,eAAS,EAAP,OAAO,OAAT,IAAS,SAAE,YAAF,IAAY,wBAAZ,IAAY,CAAV,WAA4B,iBAAvC,IAAuC,CAArC;AAAsD,0CACpD,OADoD;AAAA,IAEvD,OAAO,kCACF,cACC,QACA;AAAA,MACE,OAAO;AAAA,QACL,QAAQ,SAAS,KAAK,CAAC,MAAW,KAAK,EAAE,OAAO,MAAM,QAAQ;AAAA,QAC9D,OAAO,MAAM;AAAA,MACf;AAAA,IAAA,IAEF,CAAC;AAAA,EAET;AAAA;AAEW,MAAA,0BAA0B,CACrC,QACA,aAC6B;AAC7B,QAAM,UAAU,CA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AA,IACV,SAAShB;AAAAA,IACT,WAAWG;AAAAA,IACX,QAAQS;AAAAA,EAAAA,CAZZ;AAeD,CA9IsB;;"}
1
+ {"version":3,"file":"Text.cjs.js","sources":["../src/components/hooks/useTypography.ts","../src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.ts","../src/components/builtin/Text/components/RichTextEditor/components/Mark/index.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.tsx","../src/components/builtin/Text/components/RichTextEditor/components/Block/index.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Link.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.tsx","../src/components/builtin/Text/components/RichTextEditor/index.tsx","../src/components/builtin/Text/Text.tsx"],"sourcesContent":["import type { ColorValue } from '../utils/types'\nimport type { Length as LengthValue } from '../../prop-controllers'\nimport { DeviceOverride } from '../../prop-controllers'\nimport { TYPOGRAPHIES_BY_ID } from '../utils/queries'\nimport { useQuery } from '../../api/react'\n\nexport type TypographyStyleValue = {\n fontFamily?: string\n fontWeight?: number\n fontSize?: LengthValue\n color?: ColorValue\n textAlign?: string\n lineHeight?: number\n letterSpacing?: number\n uppercase?: boolean\n underline?: boolean\n strikethrough?: boolean\n italic?: boolean\n}\n\nexport type TypographyStyle = Array<DeviceOverride<TypographyStyleValue>>\n\nexport type Typography = {\n id: string\n name: string\n style: TypographyStyle\n}\n\nexport function useTypography(\n typographyId: string | null | undefined,\n): Typography | null | undefined {\n const { error, data } = useQuery(TYPOGRAPHIES_BY_ID, {\n skip: typographyId == null,\n variables: { ids: typographyId != null ? [typographyId] : [] },\n })\n\n if (typographyId == null || error != null) return null\n\n return data?.typographies[0] as Typography | null\n}\n","import { Length as LengthValue } from '../../../../../../../../prop-controllers'\nimport { ColorValue as Color } from '../../../../../../../utils/types'\nimport { findDeviceOverride } from '../../../../../../../utils/devices'\nimport type { DeviceOverride } from '../../../../../../../../prop-controllers'\nimport { SWATCHES_BY_ID } from '../../../../../../../utils/queries'\nimport { useTypography, TypographyStyle } from '../../../../../../../hooks/useTypography'\nimport { useQuery } from '../../../../../../../../api/react'\n\nexport type TypographyMarkDataValue = {\n fontWeight?: number\n fontSize?: LengthValue\n fontFamily?: string\n color?: Color\n textAlign?: string\n lineHeight?: number\n letterSpacing?: number\n uppercase?: boolean\n italic?: boolean\n underline?: boolean\n strikethrough?: boolean\n}\n\nexport type TypographyMarkValue = {\n id: string | null | undefined\n style: TypographyStyle\n}\n\nexport type TypographyMarkData = Array<DeviceOverride<TypographyMarkDataValue>>\n\nconst concat = <A extends unknown[], B extends unknown[]>(a: A, b: B) => a.concat(b)\nconst getSwatchId = ({ value: { color } }: any) => color && color.swatchId\nconst getDeviceId = ({ deviceId }: any) => deviceId\n\nconst withColor =\n (swatches: any) =>\n ({ value: { color, ...restOfValue }, ...rest }: any) => ({\n ...rest,\n value: {\n ...restOfValue,\n ...(color\n ? {\n color: {\n swatch: swatches.find((s: any) => s && s.id === color.swatchId),\n alpha: color.alpha,\n },\n }\n : {}),\n },\n })\n\nexport const overrideTypographyStyle = <A>(\n source: Array<DeviceOverride<A>>,\n override: Array<DeviceOverride<A>>,\n): Array<DeviceOverride<A>> => {\n const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))]\n\n return devices.map((deviceId: any) => ({\n deviceId,\n value: {\n ...(findDeviceOverride(source, deviceId) || { value: {} }).value,\n ...(findDeviceOverride(override, deviceId, v => v) || { value: {} }).value,\n },\n })) as DeviceOverride<A>[]\n}\n\nexport default function useTypographyMark(\n value: TypographyMarkValue | null | undefined,\n): TypographyMarkData | null | undefined {\n const typography = useTypography(value && value.id)\n\n const swatchIds = [\n (typography && typography.style.map(getSwatchId)) || [],\n (value && value.style.map(getSwatchId)) || [],\n ]\n .reduce(concat)\n .filter(Boolean)\n\n const { error: colorError, data: colorData = {} } = useQuery(SWATCHES_BY_ID, {\n skip: swatchIds == null || swatchIds.length === 0,\n variables: { ids: swatchIds },\n })\n\n const { swatches = [] } = colorData\n\n if (colorError != null) return null\n\n return overrideTypographyStyle(\n (typography && typography.style.map(withColor(swatches))) || [],\n (value && value.style.map(withColor(swatches))) || [],\n )\n}\n","import { ComponentPropsWithoutRef } from 'react'\nimport styled, { css } from 'styled-components'\n\nimport useTypographyMark, {\n TypographyMarkValue,\n TypographyMarkData,\n overrideTypographyStyle,\n TypographyMarkDataValue,\n} from './hooks/useTypographyMark'\nimport { cssMediaRules } from '../../../../../../utils/cssMediaRules'\nimport { colorToString } from '../../../../../../utils/colorToString'\nimport { shallowMergeFallbacks } from '../../../../../../utils/devices'\n\nexport type { TypographyMarkValue }\nexport { overrideTypographyStyle }\n\nconst Span = styled.span<{ typographyStyle: TypographyMarkData | null | undefined }>`\n ${p =>\n cssMediaRules(\n [p.typographyStyle] as const,\n ([\n {\n color,\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n uppercase,\n underline,\n strikethrough,\n italic,\n } = {} as TypographyMarkDataValue,\n ]) => css`\n ${color == null\n ? ''\n : css`\n color: ${colorToString(color)};\n `}\n\n ${fontFamily == null\n ? ''\n : css`\n font-family: '${fontFamily}';\n `}\n\n ${fontSize == null || fontSize.value == null || fontSize.unit == null\n ? ''\n : css`\n font-size: ${`${fontSize.value}${fontSize.unit}`};\n `}\n\n ${fontWeight == null\n ? ''\n : css`\n font-weight: ${fontWeight};\n `}\n\n ${lineHeight == null\n ? ''\n : css`\n line-height: ${lineHeight};\n `}\n\n ${letterSpacing == null\n ? ''\n : css`\n letter-spacing: ${letterSpacing / 10}em;\n `}\n\n ${underline == null && strikethrough == null\n ? ''\n : css`\n text-decoration: ${[\n Boolean(underline) && 'underline',\n Boolean(strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' ')};\n `}\n\n ${uppercase == null\n ? ''\n : css`\n text-transform: ${uppercase === true ? 'uppercase' : 'initial'};\n `}\n\n ${italic == null\n ? ''\n : css`\n font-style: ${italic === true ? 'italic' : 'initial'};\n `}\n `,\n shallowMergeFallbacks,\n )}\n`\n\ntype BaseProps = { value: TypographyMarkValue }\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<typeof Span>, keyof BaseProps>\n\nexport default function Mark({ value, ...restOfProps }: Props): JSX.Element {\n const typographyStyle = useTypographyMark(value)\n\n return <Span {...restOfProps} typographyStyle={typographyStyle} />\n}\n","import type { Plugin } from 'slate-react'\n\nimport Mark from '../components/Mark'\n\nconst TYPOGRAPHY_TYPE = 'typography'\n\nexport default function DeviceOverridesMarksPlugin(): Plugin {\n return {\n renderMark({ mark, children }, _editor, next) {\n if (mark.type === TYPOGRAPHY_TYPE) {\n return <Mark value={mark.data.get('value')}>{children}</Mark>\n }\n\n return next()\n },\n }\n}\n","import { forwardRef, ElementType, ComponentPropsWithoutRef } from 'react'\nimport styled, { css } from 'styled-components'\n\nimport { cssMediaRules } from '../../../../../../utils/cssMediaRules'\nimport type { ResponsiveValue } from '../../../../../../../prop-controllers'\n\ntype StyledBlockProps = {\n textAlign?: ResponsiveValue<'left' | 'center' | 'right' | 'justify'>\n as?: ElementType\n}\n\nconst StyledBlock = styled.div<StyledBlockProps>`\n margin: 0;\n ${p =>\n cssMediaRules([p.textAlign] as const, ([textAlign]) =>\n textAlign == null\n ? css``\n : css`\n text-align: ${textAlign};\n `,\n )}\n\n ${p =>\n p.as === 'blockquote'\n ? css`\n padding: 0.5em 10px;\n font-size: 1.25em;\n font-weight: 300;\n border-left: 5px solid rgba(0, 0, 0, 0.1);\n `\n : ''}\n`\n\ntype Props = ComponentPropsWithoutRef<typeof StyledBlock>\n\nexport default forwardRef<HTMLDivElement, Props>(function Block(\n { textAlign, ...restOfProps }: Props,\n ref,\n) {\n return <StyledBlock {...restOfProps} ref={ref} textAlign={textAlign} />\n})\n","import { Plugin } from 'slate-react'\n\nimport Block from '../components/Block'\n\nexport default function DeviceOverridesBlockPlugin(): Plugin {\n return {\n renderBlock(props, _editor, next): JSX.Element {\n const { node, attributes, children } = props\n const blockProps = { textAlign: node.data.get('textAlign') }\n\n switch (node.type) {\n case 'paragraph':\n return (\n <Block {...attributes} {...blockProps} as=\"p\">\n {children}\n </Block>\n )\n\n case 'heading-one':\n return (\n <Block {...attributes} {...blockProps} as=\"h1\">\n {children}\n </Block>\n )\n\n case 'heading-two':\n return (\n <Block {...attributes} {...blockProps} as=\"h2\">\n {children}\n </Block>\n )\n\n case 'heading-three':\n return (\n <Block {...attributes} {...blockProps} as=\"h3\">\n {children}\n </Block>\n )\n\n case 'heading-four':\n return (\n <Block {...attributes} {...blockProps} as=\"h4\">\n {children}\n </Block>\n )\n\n case 'heading-five':\n return (\n <Block {...attributes} {...blockProps} as=\"h5\">\n {children}\n </Block>\n )\n\n case 'heading-six':\n return (\n <Block {...attributes} {...blockProps} as=\"h6\">\n {children}\n </Block>\n )\n\n case 'blockquote':\n return (\n <Block {...attributes} {...blockProps} as=\"blockquote\">\n {children}\n </Block>\n )\n\n default:\n return next()\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\nimport styled from 'styled-components'\n\nimport { Link } from '../../../../../shared/Link'\n\nconst StyledLink = styled(Link)`\n text-decoration: none;\n`\n\nexport default function LinkPlugin(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'link': {\n const { data } = node\n\n return (\n <StyledLink {...attributes} link={data.toJS()}>\n {children}\n </StyledLink>\n )\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nexport default function Inlines(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'code': {\n return <code {...attributes}>{children}</code>\n }\n\n case 'superscript': {\n return <sup {...attributes}>{children}</sup>\n }\n\n case 'subscript': {\n return <sub {...attributes}>{children}</sub>\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { ComponentPropsWithoutRef, forwardRef, useMemo } from 'react'\n\nimport { Editor as SlateEditor } from 'slate-react'\n\n// @ts-expect-error: no types for '@convertkit/slate-lists'\nimport Lists from '@convertkit/slate-lists'\nimport styled from 'styled-components'\n\nimport DeviceOverridesMarks from './plugins/DeviceOverridesMarks'\nimport DeviceOverridesBlocks from './plugins/DeviceOverridesBlocks'\nimport Link from './plugins/Link'\nimport Inlines from './plugins/Inlines'\n\nexport { overrideTypographyStyle } from './components/Mark'\n\ntype Props = ComponentPropsWithoutRef<typeof SlateEditor>\n\nexport const RichTextEditor = styled(\n forwardRef<SlateEditor, Props>(function RichTextEditor(\n { placeholder = 'Write some text...', ...restOfProps }: Props,\n ref,\n ) {\n const plugins = useMemo(\n () => [Lists(), Link(), Inlines(), DeviceOverridesBlocks(), DeviceOverridesMarks()],\n [],\n )\n\n return (\n <SlateEditor\n {...restOfProps}\n // Workaround because our Slate editor is broken on Chrome 105\n // Problem: https://linear.app/makeswift/issue/PRD-434/our-rich-text-component-breaks-in-the-latest-version-of-chrome\n // Workaround: https://github.com/ianstormtaylor/slate/issues/5110#issuecomment-1234951122\n style={{ WebkitUserModify: undefined }}\n ref={ref}\n autoFocus={false}\n plugins={plugins}\n placeholder={placeholder}\n />\n )\n }),\n)`\n ul,\n ol {\n margin: 0;\n }\n`\n","import {\n useState,\n Ref,\n useImperativeHandle,\n forwardRef,\n useEffect,\n useCallback,\n useRef,\n KeyboardEvent as ReactKeyboardEvent,\n FocusEvent as ReactFocusEvent,\n} from 'react'\nimport styled from 'styled-components'\nimport { Editor, OnChangeParam } from 'slate-react'\nimport { Value, ValueJSON } from 'slate'\n// @ts-expect-error: no types for 'slate-hotkeys'\nimport Hotkeys from 'slate-hotkeys'\nimport { isHotkey } from 'is-hotkey'\n\nimport {\n ElementIDValue,\n MarginValue,\n RichTextDescriptor,\n RichTextValue,\n WidthValue,\n} from '../../../prop-controllers/descriptors'\nimport { cssMargin, cssWidth } from '../../utils/cssMediaRules'\nimport { BoxModelHandle, getBox } from '../../../box-model'\nimport { PropControllersHandle } from '../../../state/modules/prop-controller-handles'\nimport { RichTextEditor } from './components/RichTextEditor'\nimport { useIsInBuilder } from '../../../runtimes/react'\nimport { DescriptorsPropControllers } from '../../../prop-controllers/instances'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: WidthValue\n margin?: MarginValue\n}\n\nconst StyledRichTextEditor = styled(RichTextEditor).withConfig({\n shouldForwardProp: prop => !['width', 'margin'].includes(prop.toString()),\n})<{ width: Props['width']; margin: Props['margin'] }>`\n ${cssWidth()}\n ${cssMargin()}\n`\n\nconst defaultText: ValueJSON = {\n document: { nodes: [{ object: 'block' as const, type: 'paragraph' as const, nodes: [] }] },\n data: {},\n}\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\ntype Descriptors = { text?: RichTextDescriptor }\n\nconst Text = forwardRef(function Text(\n { id, text, width, margin }: Props,\n ref: Ref<BoxModelHandle & PropControllersHandle<Descriptors>>,\n) {\n const [editor, setEditor] = useState<Editor | null>(null)\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useImperativeHandle(\n ref,\n () => ({\n getBoxModel() {\n const el = editor?.findDOMNode([])\n\n return el instanceof Element ? getBox(el) : null\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n useEffect(() => {\n if (editor) controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n /**\n * We must keep local state so that we can reflect the user's typed changes immediately. At the\n * same time, though, the source of truth for the data is the prop data. This presents a\n * challenge: how do we keep local state in sync with the prop data without mangling user input as\n * data comes in?\n *\n * Consider, for example, that the user types \"Hello\". If at a later time, when the user is trying\n * to type \", world\" the component re-renders with prop data \"H\", \"He\", \"Hel\", \"Hell\", \"Hello\", it\n * will disrupt the user's typing. This could also happen as a result of the prop data changing\n * for other reasons, like collaborators changing the prop data concurrently. We want to avoid to\n * disrupt the user's typing, while at the same time display the \"true\" value as quickly as\n * possible.\n *\n * The approach we take here is to commit the prop data at an opportune time: as the user is\n * typing we avoid to commit prop data. But once they've stopped typing, we commit it as soon as\n * possible. This is known as a debounce.\n */\n const [value, setValue] = useState(() => {\n const { selection, ...textWithoutSelection } = text ?? defaultText\n\n return Value.fromJSON(textWithoutSelection)\n })\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit) {\n const nextValue = Value.fromJSON(text ?? defaultText)\n\n setValue(currentValue =>\n currentValue.selection.isBlurred\n ? Value.fromJSON(nextValue.toJSON({ preserveSelection: false }))\n : nextValue,\n )\n }\n }, [shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n function handleChange(change: OnChangeParam) {\n setValue(change.value as Value)\n\n if (change.value !== value) {\n setShouldCommit(false)\n\n controller?.onChange(change)\n }\n }\n\n // HACK: Slate holds on to the very first DOM event handlers passed in and doesn't update them\n // even if they change. Since `controller` is first `undefined` then we must use a ref.\n const lastController = useRef(controller)\n if (lastController.current !== controller) lastController.current = controller\n const handleFocus = useCallback(() => {\n lastController.current?.focus()\n }, [])\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent, _editor: Editor, next: () => any) => {\n if (Hotkeys.isUndo(event)) {\n lastController.current?.undo()\n\n return true\n }\n\n if (Hotkeys.isRedo(event)) {\n lastController.current?.redo()\n\n return true\n }\n\n if (isHotkey('escape')(event)) {\n lastController.current?.blur()\n\n return true\n }\n\n return next()\n },\n [],\n )\n const handleBlur = useCallback((event: ReactFocusEvent, _editor: Editor, next: () => any) => {\n // Normally, after a user highlight a text, clicking on the panel will remove the text selection.\n // This line is a workaround for that. Because the panel is not in the iframe, relatedTarget\n // would be null, and we return early so we don't remove the selection.\n if (event.relatedTarget == null) return true\n\n // Blur the selection if the user is clicking on other text.\n return next()\n }, [])\n\n const isInBuilder = useIsInBuilder()\n\n return (\n <StyledRichTextEditor\n // @ts-expect-error: types don't allow for 'id' prop even though it's used.\n id={id}\n ref={setEditor}\n width={width}\n readOnly={!isInBuilder}\n margin={margin}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n />\n )\n})\n\nexport default Text\n"],"names":["useQuery","TYPOGRAPHIES_BY_ID","findDeviceOverride","SWATCHES_BY_ID","Span","styled","span","p","cssMediaRules","typographyStyle","color","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","uppercase","underline","strikethrough","italic","css","colorToString","value","unit","Boolean","filter","join","shallowMergeFallbacks","restOfProps","useTypographyMark","TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","data","get","StyledBlock","div","textAlign","as","forwardRef","ref","renderBlock","props","node","attributes","blockProps","StyledLink","Link","renderInline","toJS","RichTextEditor","placeholder","plugins","useMemo","Lists","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","StyledRichTextEditor","withConfig","shouldForwardProp","prop","includes","toString","cssWidth","cssMargin","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","Text","id","text","width","margin","editor","setEditor","useState","propControllers","setPropControllers","controller","useImperativeHandle","getBoxModel","el","findDOMNode","Element","getBox","useEffect","setSlateEditor","setValue","selection","textWithoutSelection","Value","fromJSON","shouldCommit","setShouldCommit","nextValue","currentValue","isBlurred","toJSON","preserveSelection","timeoutId","window","setTimeout","clearTimeout","change","onChange","lastController","useRef","current","handleFocus","useCallback","focus","handleKeyDown","event","Hotkeys","isUndo","undo","isRedo","redo","isHotkey","blur","handleBlur","relatedTarget","isInBuilder","useIsInBuilder","handleChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,uBACL,cAC+B;AAC/B,QAAM,EAAE,OAAO,SAASA,KAAAA,SAASC,KAAAA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AAA;AAG/B,QAAMC,gBAAgBF,MAAAA,YACpB,CAACG,OAA2BxF,SAAiBC,UAAoB;;AAC3DwF,QAAAA,iBAAAA,WAAQC,OAAOF,KAAf,GAAuB;AACzBP,2BAAeE,YAAfF,mBAAwBU;AAEjB,aAAA;AAAA,IACR;AAEGF,QAAAA,iBAAAA,WAAQG,OAAOJ,KAAf,GAAuB;AACzBP,2BAAeE,YAAfF,mBAAwBY;AAEjB,aAAA;AAAA,IACR;AAED,QAAIC,kBAAS,QAAD,EAAWN,KAAnB,GAA2B;AAC7BP,2BAAeE,YAAfF,mBAAwBc;AAEjB,aAAA;AAAA,IACR;AAED,WAAO9F,MAAP;AAAA,EApB6B,GAsB/B,CAtB+B,CAAA;AAwBjC,QAAM+F,aAAaX,MAAAA,YAAY,CAACG,OAAwBxF,SAAiBC,UAAoB;AAIvFuF,QAAAA,MAAMS,iBAAiB;AAAa,aAAA;AAGxC,WAAOhG,MAAP;AAAA,EAP4B,GAQ3B,CAR2B,CAAA;AAUxBiG,QAAAA,cAAcC,KAAAA;AAGlB,wCAAC,sBAAD;AAAA,IAEE;AAAA,IACA,KAAKjD;AAAAA,IACL;AAAA,IACA,UAAU,CAACgD;AAAAA,IACX;AAAA,IACA;AAAA,IACA,UAAUE;AAAAA,IACV,SAAShB;AAAAA,IACT,WAAWG;AAAAA,IACX,QAAQS;AAAAA,EAAAA,CAZZ;AAeD,CA9IsB;;"}
@@ -182,5 +182,5 @@ function setIsInBuilder(isInBuilder) {
182
182
  function handleWheel(payload) {
183
183
  return { type: ActionTypes.HANDLE_WHEEL, payload };
184
184
  }
185
- export { ActionTypes as A, messageBuilderPropController as B, changeDocumentElementScrollTop as a, cleanUp as b, changeDocument as c, changeApiResource as d, evictApiResource as e, registerComponentHandleEffect as f, mountComponentEffect as g, registerComponentEffect as h, init as i, registerReactComponentEffect as j, registerDocumentEffect as k, changeElementBoxModels as l, messageHostPropController as m, changeDocumentElementSize as n, handleWheel as o, setIsInBuilder as p, registerBuilderComponent as q, registerDocument as r, scrollDocumentElement as s, unregisterBuilderComponent as t, unregisterDocument as u, unregisterMeasurable as v, registerMeasurable as w, unregisterPropControllers as x, registerPropControllers as y, registerPropControllersHandle as z };
185
+ export { ActionTypes as A, messageBuilderPropController as B, changeDocumentElementScrollTop as a, cleanUp as b, changeDocument as c, changeApiResource as d, evictApiResource as e, registerDocumentEffect as f, registerComponentHandleEffect as g, mountComponentEffect as h, init as i, registerComponentEffect as j, registerReactComponentEffect as k, changeElementBoxModels as l, messageHostPropController as m, changeDocumentElementSize as n, handleWheel as o, setIsInBuilder as p, registerBuilderComponent as q, registerDocument as r, scrollDocumentElement as s, unregisterBuilderComponent as t, unregisterDocument as u, unregisterMeasurable as v, registerMeasurable as w, unregisterPropControllers as x, registerPropControllers as y, registerPropControllersHandle as z };
186
186
  //# sourceMappingURL=actions.es.js.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  var Box = require("./Box.cjs.js");
4
- var index = require("./index.cjs.js");
4
+ var next = require("./index.cjs.js");
5
5
  var Button = require("./Button.cjs.js");
6
6
  var Carousel = require("./Carousel.cjs.js");
7
7
  var Countdown = require("./Countdown.cjs.js");
@@ -15,7 +15,7 @@ var SocialLinks = require("./SocialLinks.cjs.js");
15
15
  var Text = require("./Text.cjs.js");
16
16
  var Video = require("./Video.cjs.js");
17
17
  var cssMediaRules = require("./cssMediaRules.cjs.js");
18
- var index$1 = require("./index.cjs2.js");
18
+ var index = require("./index.cjs2.js");
19
19
  var useBoxShadow = require("./useBoxShadow.cjs.js");
20
20
  var useMediaQuery = require("./useMediaQuery.cjs.js");
21
21
  require("react");
@@ -68,21 +68,21 @@ require("slate-react");
68
68
  require("@convertkit/slate-lists");
69
69
  require("react-player");
70
70
  exports.Box = Box["default"];
71
- exports.DEFAULT_BOX_ANIMATE_DELAY = index.DEFAULT_BOX_ANIMATE_DELAY;
72
- exports.DEFAULT_BOX_ANIMATE_DURATION = index.DEFAULT_BOX_ANIMATE_DURATION;
73
- exports.DEFAULT_BOX_ANIMATE_TYPE = index.DEFAULT_BOX_ANIMATE_TYPE;
74
- exports.DEFAULT_ITEM_ANIMATE_DELAY = index.DEFAULT_ITEM_ANIMATE_DELAY;
75
- exports.DEFAULT_ITEM_ANIMATE_DURATION = index.DEFAULT_ITEM_ANIMATE_DURATION;
76
- exports.DEFAULT_ITEM_ANIMATE_TYPE = index.DEFAULT_ITEM_ANIMATE_TYPE;
77
- exports.DEFAULT_ITEM_STAGGER_DURATION = index.DEFAULT_ITEM_STAGGER_DURATION;
78
- exports.MakeswiftComponentType = index.MakeswiftComponentType;
79
- exports.PAGE_SNIPPETS_QUERY = index.PAGE_SNIPPETS_QUERY;
80
- exports.Page = index.Page;
81
- exports.SITE_FONTS_QUERY = index.SITE_FONTS_QUERY;
82
- exports.useBorder = index.useBorder;
83
- exports.useFile = index.useFile;
84
- exports.usePage = index.usePage;
85
- exports.useResponsiveColor = index.useResponsiveColor;
71
+ exports.DEFAULT_BOX_ANIMATE_DELAY = next.DEFAULT_BOX_ANIMATE_DELAY;
72
+ exports.DEFAULT_BOX_ANIMATE_DURATION = next.DEFAULT_BOX_ANIMATE_DURATION;
73
+ exports.DEFAULT_BOX_ANIMATE_TYPE = next.DEFAULT_BOX_ANIMATE_TYPE;
74
+ exports.DEFAULT_ITEM_ANIMATE_DELAY = next.DEFAULT_ITEM_ANIMATE_DELAY;
75
+ exports.DEFAULT_ITEM_ANIMATE_DURATION = next.DEFAULT_ITEM_ANIMATE_DURATION;
76
+ exports.DEFAULT_ITEM_ANIMATE_TYPE = next.DEFAULT_ITEM_ANIMATE_TYPE;
77
+ exports.DEFAULT_ITEM_STAGGER_DURATION = next.DEFAULT_ITEM_STAGGER_DURATION;
78
+ exports.MakeswiftComponentType = next.MakeswiftComponentType;
79
+ exports.PAGE_SNIPPETS_QUERY = next.PAGE_SNIPPETS_QUERY;
80
+ exports.Page = next.Page;
81
+ exports.SITE_FONTS_QUERY = next.SITE_FONTS_QUERY;
82
+ exports.useBorder = next.useBorder;
83
+ exports.useFile = next.useFile;
84
+ exports.usePage = next.usePage;
85
+ exports.useResponsiveColor = next.useResponsiveColor;
86
86
  exports.Button = Button["default"];
87
87
  exports.Carousel = Carousel["default"];
88
88
  exports.Countdown = Countdown["default"];
@@ -104,7 +104,7 @@ exports.cssMediaRules = cssMediaRules.cssMediaRules;
104
104
  exports.cssPadding = cssMediaRules.cssPadding;
105
105
  exports.cssTextStyle = cssMediaRules.cssTextStyle;
106
106
  exports.cssWidth = cssMediaRules.cssWidth;
107
- exports.useBackgrounds = index$1.useBackgrounds;
107
+ exports.useBackgrounds = index.useBackgrounds;
108
108
  exports.useBoxShadow = useBoxShadow.useBoxShadow;
109
109
  exports.useMediaQuery = useMediaQuery.useMediaQuery;
110
110
  //# sourceMappingURL=components.cjs.js.map
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  var styled = require("styled-components");
3
- var index = require("./index.cjs.js");
3
+ var next = require("./index.cjs.js");
4
4
  function cssMediaRules(responsiveValues, join, strategy) {
5
- return (props) => index.join(typeof responsiveValues === "function" ? responsiveValues(props) : responsiveValues, join, strategy).reduce((acc, { deviceId, value }) => {
6
- const device = index.getDevice(deviceId);
7
- const mediaQuery = index.getDeviceMediaQuery(device);
5
+ return (props) => next.join(typeof responsiveValues === "function" ? responsiveValues(props) : responsiveValues, join, strategy).reduce((acc, { deviceId, value }) => {
6
+ const device = next.getDevice(deviceId);
7
+ const mediaQuery = next.getDeviceMediaQuery(device);
8
8
  return styled.css`
9
9
  ${acc}${mediaQuery} {
10
10
  ${value}
@@ -69,7 +69,7 @@ function cssPadding(defaultValue = {}) {
69
69
  `;
70
70
  }
71
71
  const defaultBorderSide = { width: 0, style: "solid", color: null };
72
- const getBorderSide = ({ width, style, color }) => `${width != null ? width : 0}px ${style} ${color != null ? index.colorToString(color) : "black"}`;
72
+ const getBorderSide = ({ width, style, color }) => `${width != null ? width : 0}px ${style} ${color != null ? next.colorToString(color) : "black"}`;
73
73
  function cssBorder(defaultValue = {}) {
74
74
  const defaultBorderTop = defaultValue.borderTop === void 0 ? defaultBorderSide : defaultValue.borderTop;
75
75
  const defaultBorderRight = defaultValue.borderRight === void 0 ? defaultBorderSide : defaultValue.borderRight;
@@ -115,7 +115,7 @@ function cssBorderRadius(defaultValue = {}) {
115
115
  `)}
116
116
  `;
117
117
  }
118
- const getBoxShadow = (shadows) => shadows.map(({ payload: { inset, offsetX, offsetY, blurRadius, spreadRadius, color } }) => `${inset ? "inset " : ""}${offsetX.toFixed(1)}px ${offsetY.toFixed(1)}px ${blurRadius}px ${spreadRadius}px ${color != null ? index.colorToString(color) : "rgba(0,0,0,0.2)"}`).filter(Boolean).join();
118
+ const getBoxShadow = (shadows) => shadows.map(({ payload: { inset, offsetX, offsetY, blurRadius, spreadRadius, color } }) => `${inset ? "inset " : ""}${offsetX.toFixed(1)}px ${offsetY.toFixed(1)}px ${blurRadius}px ${spreadRadius}px ${color != null ? next.colorToString(color) : "rgba(0,0,0,0.2)"}`).filter(Boolean).join();
119
119
  function cssBoxShadow(defaultValue = []) {
120
120
  return (props) => styled.css`
121
121
  ${cssMediaRules([props.boxShadow], ([boxShadow = defaultValue]) => styled.css`
@@ -134,7 +134,7 @@ function cssGridItem() {
134
134
  columnGap = { value: 0, unit: "px" },
135
135
  rowGap = { value: 0, unit: "px" }
136
136
  ]) => {
137
- const [rowIndex, columnIndex] = index.getIndexes(spans, props.index);
137
+ const [rowIndex, columnIndex] = next.getIndexes(spans, props.index);
138
138
  const firstCol = columnIndex === 0;
139
139
  const lastCol = columnIndex === spans[rowIndex].length - 1;
140
140
  const span = spans[rowIndex][columnIndex];
@@ -1 +1 @@
1
- {"version":3,"file":"cssMediaRules.cjs.js","sources":["../src/components/utils/cssMediaRules.ts"],"sourcesContent":["import { css, CSSObject } from 'styled-components'\nimport {\n WidthProperty,\n MarginProperty,\n MarginTopProperty,\n MarginRightProperty,\n MarginBottomProperty,\n MarginLeftProperty,\n PaddingProperty,\n PaddingTopProperty,\n PaddingRightProperty,\n PaddingBottomProperty,\n PaddingLeftProperty,\n BorderRadiusProperty,\n BorderTopLeftRadiusProperty,\n BorderTopRightRadiusProperty,\n BorderBottomLeftRadiusProperty,\n BorderBottomRightRadiusProperty,\n} from 'csstype'\n\nimport {\n ResponsiveValue,\n ResponsiveValueType as ExtractResponsiveValue,\n Length as LengthValue,\n} from '../../prop-controllers'\nimport {\n FallbackStrategy,\n getDevice,\n getDeviceMediaQuery,\n join as joinResponsiveValues,\n} from './devices'\nimport { getIndexes } from './columns'\nimport {\n BorderRadiusValue,\n MarginValue,\n PaddingValue,\n TextStyleValue,\n WidthValue,\n} from '../../prop-controllers/descriptors'\nimport { colorToString } from './colorToString'\nimport {\n BorderSide,\n BorderPropControllerData,\n BoxShadowData,\n BoxShadowPropControllerData,\n} from '../hooks'\n\ntype CSSRules = ReturnType<typeof css>\n\nexport function cssMediaRules<V, A extends ReadonlyArray<ResponsiveValue<V> | null | undefined>, P>(\n responsiveValues: A | ((props: P) => A),\n join: (values: { [K in keyof A]: ExtractResponsiveValue<A[K]> | undefined }) =>\n | CSSRules\n | CSSObject,\n strategy?: FallbackStrategy<V>,\n): (props: P) => CSSRules {\n return props =>\n joinResponsiveValues(\n typeof responsiveValues === 'function' ? responsiveValues(props) : responsiveValues,\n join,\n strategy,\n ).reduce((acc, { deviceId, value }) => {\n const device = getDevice(deviceId)\n const mediaQuery = getDeviceMediaQuery(device)\n\n return css`\n ${acc}${mediaQuery} {\n ${value}\n }\n `\n }, css`` as CSSRules)\n}\n\nexport function cssWidth(\n defaultValue: LengthValue | WidthProperty<string | number> = '100%',\n): (props: { width?: WidthValue }) => CSSRules {\n return props => css`\n max-width: 100%;\n ${cssMediaRules(\n [props.width] as const,\n ([width = defaultValue]) => css`\n width: ${typeof width === 'object' ? `${width.value}${width.unit}` : width};\n `,\n )}\n `\n}\n\nfunction getMarginSide(marginSide: LengthValue | MarginProperty<string | number>) {\n return typeof marginSide === 'object' ? `${marginSide.value}${marginSide.unit}` : marginSide\n}\n\nexport function cssMargin(\n defaultValue: {\n marginTop?: LengthValue | MarginTopProperty<string | number>\n marginRight?: LengthValue | MarginRightProperty<string | number>\n marginBottom?: LengthValue | MarginBottomProperty<string | number>\n marginLeft?: LengthValue | MarginLeftProperty<string | number>\n } = {},\n): (props: { margin?: MarginValue }) => CSSRules {\n const defaultMarginTop = defaultValue.marginTop === undefined ? 0 : defaultValue.marginTop\n const defaultMarginRight =\n defaultValue.marginRight === undefined ? 'auto' : defaultValue.marginRight\n const defaultMarginBottom =\n defaultValue.marginBottom === undefined ? 0 : defaultValue.marginBottom\n const defaultMarginLeft = defaultValue.marginLeft === undefined ? 'auto' : defaultValue.marginLeft\n\n return props => css`\n ${cssMediaRules(\n [props.margin] as const,\n ([\n {\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n } = {} as ExtractResponsiveValue<MarginValue>,\n ]) => css`\n margin-top: ${getMarginSide(marginTop || defaultMarginTop)};\n margin-right: ${getMarginSide(marginRight || defaultMarginRight)};\n margin-bottom: ${getMarginSide(marginBottom || defaultMarginBottom)};\n margin-left: ${getMarginSide(marginLeft || defaultMarginLeft)};\n `,\n )}\n `\n}\n\nfunction getPaddingSide(paddingSide: LengthValue | PaddingProperty<string | number>) {\n return typeof paddingSide === 'object' ? `${paddingSide.value}${paddingSide.unit}` : paddingSide\n}\n\nexport function cssPadding(\n defaultValue: {\n paddingTop?: LengthValue | PaddingTopProperty<string | number>\n paddingRight?: LengthValue | PaddingRightProperty<string | number>\n paddingBottom?: LengthValue | PaddingBottomProperty<string | number>\n paddingLeft?: LengthValue | PaddingLeftProperty<string | number>\n } = {},\n): (props: { padding?: PaddingValue }) => CSSRules {\n const defaultPaddingTop = defaultValue.paddingTop === undefined ? 0 : defaultValue.paddingTop\n const defaultPaddingRight =\n defaultValue.paddingRight === undefined ? 0 : defaultValue.paddingRight\n const defaultPaddingBottom =\n defaultValue.paddingBottom === undefined ? 0 : defaultValue.paddingBottom\n const defaultPaddingLeft = defaultValue.paddingLeft === undefined ? 0 : defaultValue.paddingLeft\n\n return props => css`\n ${cssMediaRules(\n [props.padding] as const,\n ([\n {\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n } = {} as ExtractResponsiveValue<PaddingValue>,\n ]) => css`\n padding-top: ${getPaddingSide(paddingTop || defaultPaddingTop)};\n padding-right: ${getPaddingSide(paddingRight || defaultPaddingRight)};\n padding-bottom: ${getPaddingSide(paddingBottom || defaultPaddingBottom)};\n padding-left: ${getPaddingSide(paddingLeft || defaultPaddingLeft)};\n `,\n )}\n `\n}\n\nconst defaultBorderSide = { width: 0, style: 'solid', color: null }\n\nconst getBorderSide = ({ width, style, color }: BorderSide) =>\n `${width != null ? width : 0}px ${style} ${color != null ? colorToString(color) : 'black'}`\n\nexport function cssBorder(\n defaultValue: {\n borderTop?: BorderSide\n borderRight?: BorderSide\n borderBottom?: BorderSide\n borderLeft?: BorderSide\n } = {},\n): (props: { border?: BorderPropControllerData | null | undefined }) => CSSRules {\n const defaultBorderTop =\n defaultValue.borderTop === undefined ? defaultBorderSide : defaultValue.borderTop\n const defaultBorderRight =\n defaultValue.borderRight === undefined ? defaultBorderSide : defaultValue.borderRight\n const defaultBorderBottom =\n defaultValue.borderBottom === undefined ? defaultBorderSide : defaultValue.borderBottom\n const defaultBorderLeft =\n defaultValue.borderLeft === undefined ? defaultBorderSide : defaultValue.borderLeft\n\n return props => css`\n ${cssMediaRules(\n [props.border] as const,\n ([\n {\n borderTop,\n borderRight,\n borderBottom,\n borderLeft,\n } = {} as ExtractResponsiveValue<BorderPropControllerData>,\n ]) => css`\n border-top: ${getBorderSide(borderTop || defaultBorderTop)};\n border-right: ${getBorderSide(borderRight || defaultBorderRight)};\n border-bottom: ${getBorderSide(borderBottom || defaultBorderBottom)};\n border-left: ${getBorderSide(borderLeft || defaultBorderLeft)};\n `,\n )}\n `\n}\n\nfunction getBorderRadiusCorner(\n borderRadiusCorner: LengthValue | BorderRadiusProperty<string | number>,\n) {\n return typeof borderRadiusCorner === 'object'\n ? `${borderRadiusCorner.value}${borderRadiusCorner.unit}`\n : borderRadiusCorner\n}\n\nexport function cssBorderRadius(\n defaultValue: {\n borderTopLeftRadius?: LengthValue | BorderTopLeftRadiusProperty<string | number>\n borderTopRightRadius?: LengthValue | BorderTopRightRadiusProperty<string | number>\n borderBottomLeftRadius?: LengthValue | BorderBottomLeftRadiusProperty<string | number>\n borderBottomRightRadius?: LengthValue | BorderBottomRightRadiusProperty<string | number>\n } = {},\n): (props: { borderRadius?: BorderRadiusValue }) => CSSRules {\n const defaultBorderTopLeftRadius =\n defaultValue.borderTopLeftRadius === undefined ? 0 : defaultValue.borderTopLeftRadius\n const defaultBorderTopRightRadius =\n defaultValue.borderTopRightRadius === undefined ? 0 : defaultValue.borderTopRightRadius\n const defaultPaddingBottom =\n defaultValue.borderBottomLeftRadius === undefined ? 0 : defaultValue.borderBottomLeftRadius\n const defaultPaddingLeft =\n defaultValue.borderBottomRightRadius === undefined ? 0 : defaultValue.borderBottomRightRadius\n\n return props => css`\n ${cssMediaRules(\n [props.borderRadius] as const,\n ([\n {\n borderTopLeftRadius,\n borderTopRightRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n } = {} as ExtractResponsiveValue<BorderRadiusValue>,\n ]) => css`\n border-top-left-radius: ${getBorderRadiusCorner(\n borderTopLeftRadius || defaultBorderTopLeftRadius,\n )};\n border-top-right-radius: ${getBorderRadiusCorner(\n borderTopRightRadius || defaultBorderTopRightRadius,\n )};\n border-bottom-left-radius: ${getBorderRadiusCorner(\n borderBottomLeftRadius || defaultPaddingBottom,\n )};\n border-bottom-right-radius: ${getBorderRadiusCorner(\n borderBottomRightRadius || defaultPaddingLeft,\n )};\n `,\n )}\n `\n}\n\nconst getBoxShadow = (shadows: BoxShadowData) =>\n shadows\n .map(\n ({ payload: { inset, offsetX, offsetY, blurRadius, spreadRadius, color } }) =>\n `${inset ? 'inset ' : ''}${offsetX.toFixed(1)}px ${offsetY.toFixed(\n 1,\n )}px ${blurRadius}px ${spreadRadius}px ${\n color != null ? colorToString(color) : 'rgba(0,0,0,0.2)'\n }`,\n )\n .filter(Boolean)\n .join()\n\nexport function cssBoxShadow(\n defaultValue: BoxShadowData = [],\n): (props: { boxShadow?: BoxShadowPropControllerData | null | undefined }) => CSSRules {\n return props => css`\n ${cssMediaRules(\n [props.boxShadow] as const,\n ([boxShadow = defaultValue]) => css`\n box-shadow: ${getBoxShadow(boxShadow)};\n `,\n )}\n `\n}\n\nconst floor =\n (d: number) =>\n (v: number): number =>\n Math.floor(10 ** d * v) / 10 ** d\n\nexport function cssGridItem(): (props: {\n grid: ResponsiveValue<{ spans: Array<Array<number>>; count: number }>\n index: number\n columnGap?: ResponsiveValue<LengthValue>\n rowGap?: ResponsiveValue<LengthValue>\n}) => CSSRules {\n return props => css`\n display: flex;\n\n /* TODO: A default span of 12 won't work once the column count is modifiable. */\n ${cssMediaRules(\n [props.grid, props.columnGap, props.rowGap] as const,\n ([\n { spans, count } = { spans: [[12]], count: 12 },\n columnGap = { value: 0, unit: 'px' },\n rowGap = { value: 0, unit: 'px' },\n ]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, props.index)\n const firstCol = columnIndex === 0\n const lastCol = columnIndex === spans[rowIndex].length - 1\n const span = spans[rowIndex][columnIndex]\n const fraction = floor(5)(span / count)\n const width = `${fraction} * (100% + ${columnGap.value}${columnGap.unit})`\n const excessWidth = `${Number(firstCol) + Number(lastCol)} * ${columnGap.value}${\n columnGap.unit\n } / 2`\n const iePrecisionError = '0.01px'\n const flexBasis = `calc(${width} - ${excessWidth} - ${iePrecisionError})`\n const firstRow = rowIndex === 0\n const lastRow = rowIndex === spans.length - 1\n\n return span === 0\n ? { display: 'none' }\n : {\n flexBasis,\n minWidth: flexBasis,\n // NOTE: IE11 width breaks without max width\n // https://github.com/philipwalton/flexbugs/issues/3\n maxWidth: flexBasis,\n paddingLeft: firstCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,\n paddingRight: lastCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,\n paddingTop: firstRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,\n paddingBottom: lastRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,\n }\n },\n )}\n `\n}\n\nexport function cssTextStyle(\n defaultValue: {\n fontFamily?: string | null | undefined\n letterSpacing: number | null | undefined\n fontSize: LengthValue | null | undefined\n fontWeight: number | null | undefined\n textTransform: Array<'uppercase'>\n fontStyle: Array<'italic'>\n } = {\n fontFamily: null,\n letterSpacing: null,\n fontSize: null,\n fontWeight: null,\n textTransform: [],\n fontStyle: [],\n },\n): (arg0: { textStyle?: TextStyleValue | null | undefined }) => CSSRules {\n return props => css`\n ${cssMediaRules([props.textStyle], ([textStyle = defaultValue]) => {\n const {\n fontSize,\n fontWeight,\n fontStyle = [],\n textTransform = [],\n letterSpacing,\n fontFamily,\n } = textStyle\n\n return css`\n ${fontFamily != null\n ? css`\n font-family: '${fontFamily}';\n `\n : ''};\n ${fontWeight != null\n ? css`\n font-weight: ${fontWeight};\n `\n : ''};\n ${letterSpacing != null\n ? css`\n letter-spacing: ${letterSpacing}px;\n `\n : ''};\n ${fontSize != null\n ? css`\n font-size: ${`${fontSize.value}${fontSize.unit}`};\n `\n : ''};\n ${textTransform.includes('uppercase')\n ? css`\n text-transform: uppercase;\n `\n : ''};\n ${fontStyle.includes('italic')\n ? css`\n font-style: italic;\n `\n : ''};\n `\n })}\n `\n}\n"],"names":["joinResponsiveValues","getDevice","getDeviceMediaQuery","css","colorToString","getIndexes"],"mappings":";;;AAkDE,uBAAA,kBACA,MAGA,UACwB;AACxB,SAAO,WACLA,WACE,OAAO,qBAAqB,aAAa,iBAAiB,KAAK,IAAI,kBACnE,MACA,QACF,EAAE,OAAO,CAAC,KAAK,EAAE,UAAU,YAAY;AAC/B,UAAA,SAASC,gBAAU,QAAQ;AAC3B,UAAA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AA,MACjB;AAAA,MACA;AAAA,QACE;AAEG,WAAAA;UACH,cAAc,OACZA;8BACkB;AAAA,gBAElB;AAAA,UACF,cAAc,OACZA;6BACiB;AAAA,gBAEjB;AAAA,UACF,iBAAiB,OACfA;gCACoB;AAAA,gBAEpB;AAAA,UACF,YAAY,OACVA;2BACe,GAAG,SAAS,QAAQ,SAAS;AAAA,gBAE5C;AAAA,UACF,cAAc,SAAS,WAAW,IAChCA,OAAAA;AAAAA;AAAAA,gBAGA;AAAA,UACF,UAAU,SAAS,QAAQ,IACzBA,OAAAA;AAAAA;AAAAA,gBAGA;AAAA;AAAA,EAAA,CAEP;AAAA;AAEL;;;;;;;;;;"}
1
+ {"version":3,"file":"cssMediaRules.cjs.js","sources":["../src/components/utils/cssMediaRules.ts"],"sourcesContent":["import { css, CSSObject } from 'styled-components'\nimport {\n WidthProperty,\n MarginProperty,\n MarginTopProperty,\n MarginRightProperty,\n MarginBottomProperty,\n MarginLeftProperty,\n PaddingProperty,\n PaddingTopProperty,\n PaddingRightProperty,\n PaddingBottomProperty,\n PaddingLeftProperty,\n BorderRadiusProperty,\n BorderTopLeftRadiusProperty,\n BorderTopRightRadiusProperty,\n BorderBottomLeftRadiusProperty,\n BorderBottomRightRadiusProperty,\n} from 'csstype'\n\nimport {\n ResponsiveValue,\n ResponsiveValueType as ExtractResponsiveValue,\n Length as LengthValue,\n} from '../../prop-controllers'\nimport {\n FallbackStrategy,\n getDevice,\n getDeviceMediaQuery,\n join as joinResponsiveValues,\n} from './devices'\nimport { getIndexes } from './columns'\nimport {\n BorderRadiusValue,\n MarginValue,\n PaddingValue,\n TextStyleValue,\n WidthValue,\n} from '../../prop-controllers/descriptors'\nimport { colorToString } from './colorToString'\nimport {\n BorderSide,\n BorderPropControllerData,\n BoxShadowData,\n BoxShadowPropControllerData,\n} from '../hooks'\n\ntype CSSRules = ReturnType<typeof css>\n\nexport function cssMediaRules<V, A extends ReadonlyArray<ResponsiveValue<V> | null | undefined>, P>(\n responsiveValues: A | ((props: P) => A),\n join: (values: { [K in keyof A]: ExtractResponsiveValue<A[K]> | undefined }) =>\n | CSSRules\n | CSSObject,\n strategy?: FallbackStrategy<V>,\n): (props: P) => CSSRules {\n return props =>\n joinResponsiveValues(\n typeof responsiveValues === 'function' ? responsiveValues(props) : responsiveValues,\n join,\n strategy,\n ).reduce((acc, { deviceId, value }) => {\n const device = getDevice(deviceId)\n const mediaQuery = getDeviceMediaQuery(device)\n\n return css`\n ${acc}${mediaQuery} {\n ${value}\n }\n `\n }, css`` as CSSRules)\n}\n\nexport function cssWidth(\n defaultValue: LengthValue | WidthProperty<string | number> = '100%',\n): (props: { width?: WidthValue }) => CSSRules {\n return props => css`\n max-width: 100%;\n ${cssMediaRules(\n [props.width] as const,\n ([width = defaultValue]) => css`\n width: ${typeof width === 'object' ? `${width.value}${width.unit}` : width};\n `,\n )}\n `\n}\n\nfunction getMarginSide(marginSide: LengthValue | MarginProperty<string | number>) {\n return typeof marginSide === 'object' ? `${marginSide.value}${marginSide.unit}` : marginSide\n}\n\nexport function cssMargin(\n defaultValue: {\n marginTop?: LengthValue | MarginTopProperty<string | number>\n marginRight?: LengthValue | MarginRightProperty<string | number>\n marginBottom?: LengthValue | MarginBottomProperty<string | number>\n marginLeft?: LengthValue | MarginLeftProperty<string | number>\n } = {},\n): (props: { margin?: MarginValue }) => CSSRules {\n const defaultMarginTop = defaultValue.marginTop === undefined ? 0 : defaultValue.marginTop\n const defaultMarginRight =\n defaultValue.marginRight === undefined ? 'auto' : defaultValue.marginRight\n const defaultMarginBottom =\n defaultValue.marginBottom === undefined ? 0 : defaultValue.marginBottom\n const defaultMarginLeft = defaultValue.marginLeft === undefined ? 'auto' : defaultValue.marginLeft\n\n return props => css`\n ${cssMediaRules(\n [props.margin] as const,\n ([\n {\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n } = {} as ExtractResponsiveValue<MarginValue>,\n ]) => css`\n margin-top: ${getMarginSide(marginTop || defaultMarginTop)};\n margin-right: ${getMarginSide(marginRight || defaultMarginRight)};\n margin-bottom: ${getMarginSide(marginBottom || defaultMarginBottom)};\n margin-left: ${getMarginSide(marginLeft || defaultMarginLeft)};\n `,\n )}\n `\n}\n\nfunction getPaddingSide(paddingSide: LengthValue | PaddingProperty<string | number>) {\n return typeof paddingSide === 'object' ? `${paddingSide.value}${paddingSide.unit}` : paddingSide\n}\n\nexport function cssPadding(\n defaultValue: {\n paddingTop?: LengthValue | PaddingTopProperty<string | number>\n paddingRight?: LengthValue | PaddingRightProperty<string | number>\n paddingBottom?: LengthValue | PaddingBottomProperty<string | number>\n paddingLeft?: LengthValue | PaddingLeftProperty<string | number>\n } = {},\n): (props: { padding?: PaddingValue }) => CSSRules {\n const defaultPaddingTop = defaultValue.paddingTop === undefined ? 0 : defaultValue.paddingTop\n const defaultPaddingRight =\n defaultValue.paddingRight === undefined ? 0 : defaultValue.paddingRight\n const defaultPaddingBottom =\n defaultValue.paddingBottom === undefined ? 0 : defaultValue.paddingBottom\n const defaultPaddingLeft = defaultValue.paddingLeft === undefined ? 0 : defaultValue.paddingLeft\n\n return props => css`\n ${cssMediaRules(\n [props.padding] as const,\n ([\n {\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n } = {} as ExtractResponsiveValue<PaddingValue>,\n ]) => css`\n padding-top: ${getPaddingSide(paddingTop || defaultPaddingTop)};\n padding-right: ${getPaddingSide(paddingRight || defaultPaddingRight)};\n padding-bottom: ${getPaddingSide(paddingBottom || defaultPaddingBottom)};\n padding-left: ${getPaddingSide(paddingLeft || defaultPaddingLeft)};\n `,\n )}\n `\n}\n\nconst defaultBorderSide = { width: 0, style: 'solid', color: null }\n\nconst getBorderSide = ({ width, style, color }: BorderSide) =>\n `${width != null ? width : 0}px ${style} ${color != null ? colorToString(color) : 'black'}`\n\nexport function cssBorder(\n defaultValue: {\n borderTop?: BorderSide\n borderRight?: BorderSide\n borderBottom?: BorderSide\n borderLeft?: BorderSide\n } = {},\n): (props: { border?: BorderPropControllerData | null | undefined }) => CSSRules {\n const defaultBorderTop =\n defaultValue.borderTop === undefined ? defaultBorderSide : defaultValue.borderTop\n const defaultBorderRight =\n defaultValue.borderRight === undefined ? defaultBorderSide : defaultValue.borderRight\n const defaultBorderBottom =\n defaultValue.borderBottom === undefined ? defaultBorderSide : defaultValue.borderBottom\n const defaultBorderLeft =\n defaultValue.borderLeft === undefined ? defaultBorderSide : defaultValue.borderLeft\n\n return props => css`\n ${cssMediaRules(\n [props.border] as const,\n ([\n {\n borderTop,\n borderRight,\n borderBottom,\n borderLeft,\n } = {} as ExtractResponsiveValue<BorderPropControllerData>,\n ]) => css`\n border-top: ${getBorderSide(borderTop || defaultBorderTop)};\n border-right: ${getBorderSide(borderRight || defaultBorderRight)};\n border-bottom: ${getBorderSide(borderBottom || defaultBorderBottom)};\n border-left: ${getBorderSide(borderLeft || defaultBorderLeft)};\n `,\n )}\n `\n}\n\nfunction getBorderRadiusCorner(\n borderRadiusCorner: LengthValue | BorderRadiusProperty<string | number>,\n) {\n return typeof borderRadiusCorner === 'object'\n ? `${borderRadiusCorner.value}${borderRadiusCorner.unit}`\n : borderRadiusCorner\n}\n\nexport function cssBorderRadius(\n defaultValue: {\n borderTopLeftRadius?: LengthValue | BorderTopLeftRadiusProperty<string | number>\n borderTopRightRadius?: LengthValue | BorderTopRightRadiusProperty<string | number>\n borderBottomLeftRadius?: LengthValue | BorderBottomLeftRadiusProperty<string | number>\n borderBottomRightRadius?: LengthValue | BorderBottomRightRadiusProperty<string | number>\n } = {},\n): (props: { borderRadius?: BorderRadiusValue }) => CSSRules {\n const defaultBorderTopLeftRadius =\n defaultValue.borderTopLeftRadius === undefined ? 0 : defaultValue.borderTopLeftRadius\n const defaultBorderTopRightRadius =\n defaultValue.borderTopRightRadius === undefined ? 0 : defaultValue.borderTopRightRadius\n const defaultPaddingBottom =\n defaultValue.borderBottomLeftRadius === undefined ? 0 : defaultValue.borderBottomLeftRadius\n const defaultPaddingLeft =\n defaultValue.borderBottomRightRadius === undefined ? 0 : defaultValue.borderBottomRightRadius\n\n return props => css`\n ${cssMediaRules(\n [props.borderRadius] as const,\n ([\n {\n borderTopLeftRadius,\n borderTopRightRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n } = {} as ExtractResponsiveValue<BorderRadiusValue>,\n ]) => css`\n border-top-left-radius: ${getBorderRadiusCorner(\n borderTopLeftRadius || defaultBorderTopLeftRadius,\n )};\n border-top-right-radius: ${getBorderRadiusCorner(\n borderTopRightRadius || defaultBorderTopRightRadius,\n )};\n border-bottom-left-radius: ${getBorderRadiusCorner(\n borderBottomLeftRadius || defaultPaddingBottom,\n )};\n border-bottom-right-radius: ${getBorderRadiusCorner(\n borderBottomRightRadius || defaultPaddingLeft,\n )};\n `,\n )}\n `\n}\n\nconst getBoxShadow = (shadows: BoxShadowData) =>\n shadows\n .map(\n ({ payload: { inset, offsetX, offsetY, blurRadius, spreadRadius, color } }) =>\n `${inset ? 'inset ' : ''}${offsetX.toFixed(1)}px ${offsetY.toFixed(\n 1,\n )}px ${blurRadius}px ${spreadRadius}px ${\n color != null ? colorToString(color) : 'rgba(0,0,0,0.2)'\n }`,\n )\n .filter(Boolean)\n .join()\n\nexport function cssBoxShadow(\n defaultValue: BoxShadowData = [],\n): (props: { boxShadow?: BoxShadowPropControllerData | null | undefined }) => CSSRules {\n return props => css`\n ${cssMediaRules(\n [props.boxShadow] as const,\n ([boxShadow = defaultValue]) => css`\n box-shadow: ${getBoxShadow(boxShadow)};\n `,\n )}\n `\n}\n\nconst floor =\n (d: number) =>\n (v: number): number =>\n Math.floor(10 ** d * v) / 10 ** d\n\nexport function cssGridItem(): (props: {\n grid: ResponsiveValue<{ spans: Array<Array<number>>; count: number }>\n index: number\n columnGap?: ResponsiveValue<LengthValue>\n rowGap?: ResponsiveValue<LengthValue>\n}) => CSSRules {\n return props => css`\n display: flex;\n\n /* TODO: A default span of 12 won't work once the column count is modifiable. */\n ${cssMediaRules(\n [props.grid, props.columnGap, props.rowGap] as const,\n ([\n { spans, count } = { spans: [[12]], count: 12 },\n columnGap = { value: 0, unit: 'px' },\n rowGap = { value: 0, unit: 'px' },\n ]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, props.index)\n const firstCol = columnIndex === 0\n const lastCol = columnIndex === spans[rowIndex].length - 1\n const span = spans[rowIndex][columnIndex]\n const fraction = floor(5)(span / count)\n const width = `${fraction} * (100% + ${columnGap.value}${columnGap.unit})`\n const excessWidth = `${Number(firstCol) + Number(lastCol)} * ${columnGap.value}${\n columnGap.unit\n } / 2`\n const iePrecisionError = '0.01px'\n const flexBasis = `calc(${width} - ${excessWidth} - ${iePrecisionError})`\n const firstRow = rowIndex === 0\n const lastRow = rowIndex === spans.length - 1\n\n return span === 0\n ? { display: 'none' }\n : {\n flexBasis,\n minWidth: flexBasis,\n // NOTE: IE11 width breaks without max width\n // https://github.com/philipwalton/flexbugs/issues/3\n maxWidth: flexBasis,\n paddingLeft: firstCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,\n paddingRight: lastCol ? 0 : `${columnGap.value / 2}${columnGap.unit}`,\n paddingTop: firstRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,\n paddingBottom: lastRow ? 0 : `${rowGap.value / 2}${rowGap.unit}`,\n }\n },\n )}\n `\n}\n\nexport function cssTextStyle(\n defaultValue: {\n fontFamily?: string | null | undefined\n letterSpacing: number | null | undefined\n fontSize: LengthValue | null | undefined\n fontWeight: number | null | undefined\n textTransform: Array<'uppercase'>\n fontStyle: Array<'italic'>\n } = {\n fontFamily: null,\n letterSpacing: null,\n fontSize: null,\n fontWeight: null,\n textTransform: [],\n fontStyle: [],\n },\n): (arg0: { textStyle?: TextStyleValue | null | undefined }) => CSSRules {\n return props => css`\n ${cssMediaRules([props.textStyle], ([textStyle = defaultValue]) => {\n const {\n fontSize,\n fontWeight,\n fontStyle = [],\n textTransform = [],\n letterSpacing,\n fontFamily,\n } = textStyle\n\n return css`\n ${fontFamily != null\n ? css`\n font-family: '${fontFamily}';\n `\n : ''};\n ${fontWeight != null\n ? css`\n font-weight: ${fontWeight};\n `\n : ''};\n ${letterSpacing != null\n ? css`\n letter-spacing: ${letterSpacing}px;\n `\n : ''};\n ${fontSize != null\n ? css`\n font-size: ${`${fontSize.value}${fontSize.unit}`};\n `\n : ''};\n ${textTransform.includes('uppercase')\n ? css`\n text-transform: uppercase;\n `\n : ''};\n ${fontStyle.includes('italic')\n ? css`\n font-style: italic;\n `\n : ''};\n `\n })}\n `\n}\n"],"names":["joinResponsiveValues","getDevice","getDeviceMediaQuery","css","colorToString","getIndexes"],"mappings":";;;AAkDE,uBAAA,kBACA,MAGA,UACwB;AACxB,SAAO,WACLA,UACE,OAAO,qBAAqB,aAAa,iBAAiB,KAAK,IAAI,kBACnE,MACA,QACF,EAAE,OAAO,CAAC,KAAK,EAAE,UAAU,YAAY;AAC/B,UAAA,SAASC,eAAU,QAAQ;AAC3B,UAAA,aAAaC,yBAAoB,MAAM;AAEtC,WAAAC;UACH,MAAM;AAAA,YACJ;AAAA;AAAA;AAAA,EAAA,GAGLA,OAAAA,KAAiB;AACxB;AAEO,kBACL,eAA6D,QAChB;AAC7C,SAAO,CAAS,UAAAA;;MAEZ,cACA,CAAC,MAAM,KAAK,GACZ,CAAC,CAAC,QAAQ,kBAAkBA;iBACjB,OAAO,UAAU,WAAW,GAAG,MAAM,QAAQ,MAAM,SAAS;AAAA,OAEzE;AAAA;AAEJ;AAEA,uBAAuB,YAA2D;AAChF,SAAO,OAAO,eAAe,WAAW,GAAG,WAAW,QAAQ,WAAW,SAAS;AACpF;AAGE,mBAAA,eAKI,IAC2C;AAC/C,QAAM,mBAAmB,aAAa,cAAc,SAAY,IAAI,aAAa;AACjF,QAAM,qBACJ,aAAa,gBAAgB,SAAY,SAAS,aAAa;AACjE,QAAM,sBACJ,aAAa,iBAAiB,SAAY,IAAI,aAAa;AAC7D,QAAM,oBAAoB,aAAa,eAAe,SAAY,SAAS,aAAa;AAExF,SAAO,CAAS,UAAAA;MACZ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