@makeswift/runtime 0.8.11 → 0.9.1
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/Box.cjs.js +16 -15
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +11 -10
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +13 -12
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +11 -10
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +28 -27
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +7 -6
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +16 -15
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +8 -7
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +13 -12
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +11 -10
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +4 -29
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +3 -28
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +52 -51
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +8 -7
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +9 -8
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +8 -7
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +6 -5
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +8 -7
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +28 -27
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +7 -6
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +23 -7
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +24 -8
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +22 -20
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +18 -16
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +19 -17
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +16 -14
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +8 -7
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +6 -5
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +15 -14
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +11 -10
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +5 -4
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +6 -5
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +4 -29
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +3 -28
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +16 -1
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +14 -2
- package/dist/actions.es.js.map +1 -1
- package/dist/builder.cjs.js +5 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +5 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +10 -9
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +10 -9
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +89 -10
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +90 -11
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +12 -3
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +6 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/deepEqual.cjs.js +40 -0
- package/dist/deepEqual.cjs.js.map +1 -0
- package/dist/deepEqual.es.js +39 -0
- package/dist/deepEqual.es.js.map +1 -0
- package/dist/index.cjs.js +298 -292
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +18 -16
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs2.js +14 -14
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs4.js +2 -1
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +0 -522
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +1 -2
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +0 -52
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +5 -4
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +72 -69
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +282 -275
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +16 -14
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es2.js +3 -3
- package/dist/index.es3.js +1 -1
- package/dist/index.es4.js +2 -1
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +2 -514
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -2
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +2 -53
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +5 -4
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +74 -71
- package/dist/index.es9.js.map +1 -1
- package/dist/leaf.cjs.js +1 -1
- package/dist/leaf.cjs.js.map +1 -1
- package/dist/leaf.es.js +2 -2
- package/dist/main.cjs.js +8 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +7 -2
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +5 -4
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +6 -5
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +5 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +5 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +1013 -190
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +968 -185
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +5 -4
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +5 -4
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +96 -14
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +89 -6
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
- package/dist/types/src/api/graphql/generated/types.d.ts +0 -8
- package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/control-serialization.d.ts +3 -3
- package/dist/types/src/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts +2 -2
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts +5 -0
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Countdown/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Divider/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Embed/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Video/register.d.ts.map +1 -1
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/src/controls/control.d.ts +3 -2
- package/dist/types/src/controls/control.d.ts.map +1 -1
- package/dist/types/src/controls/index.d.ts +1 -0
- package/dist/types/src/controls/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +10 -5
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/style-v2.d.ts +55 -0
- package/dist/types/src/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts +3 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/index.d.ts +2 -1
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts +7 -7
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts +8 -5
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/next/preview-mode.d.ts +17 -3
- package/dist/types/src/next/preview-mode.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +4 -3
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/instances.d.ts +2 -2
- package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +3 -2
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +2 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts +3 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/constants.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/dedent.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/indent.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts +29 -3
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/toggleList.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/unwrapList.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/getSelectedListItems.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/location.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/wrapList.d.ts.map +1 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +2 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +9 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/index.d.ts +1 -1
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +18 -0
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/types/src/slate/utils/element.d.ts +1 -2
- package/dist/types/src/slate/utils/element.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +26 -1
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/components-meta.d.ts +25 -1
- package/dist/types/src/state/modules/components-meta.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts +16 -0
- package/dist/types/src/state/modules/locales.d.ts.map +1 -0
- package/dist/types/src/state/react-builder-preview.d.ts +2 -0
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/src/state/react-page.d.ts +5 -1
- package/dist/types/src/state/react-page.d.ts.map +1 -1
- package/dist/useMediaQuery.es.js +1 -1
- package/package.json +6 -3
- package/dist/select.cjs.js +0 -8
- package/dist/select.cjs.js.map +0 -1
- package/dist/select.es.js +0 -6
- package/dist/select.es.js.map +0 -1
- package/dist/types/src/slate/ListPlugin/constants.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/indent.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/index.d.ts +0 -17
- package/dist/types/src/slate/ListPlugin/index.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +0 -1
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/constants.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/dedent.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/indent.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/toggleList.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/unwrapList.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/getSelectedListItems.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/location.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/wrapList.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Countdown.cjs.js","sources":["../src/components/builtin/Countdown/Countdown.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef, ForwardedRef, forwardRef, Ref, useEffect, useState } from 'react'\nimport {\n DateValue,\n ElementIDValue,\n FontValue,\n GapXValue,\n ResponsiveIconRadioGroupValue,\n ResponsiveValue,\n TextInputValue,\n} from '../../../prop-controllers/descriptors'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { colorToString } from '../../utils/colorToString'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { ColorValue as Color } from '../../utils/types'\n\ntype Props = {\n id?: ElementIDValue\n date?: DateValue\n variant?: ResponsiveIconRadioGroupValue<\n 'filled' | 'filled-split' | 'outline' | 'outline-split' | 'clear'\n >\n shape?: ResponsiveIconRadioGroupValue<'pill' | 'rounded' | 'square'>\n size?: ResponsiveIconRadioGroupValue<'small' | 'medium' | 'large'>\n gap?: GapXValue\n numberFont?: FontValue\n numberColor?: ResponsiveColor | null\n blockColor?: ResponsiveColor | null\n labelFont?: FontValue\n labelColor?: ResponsiveColor | null\n width?: string\n margin?: string\n daysLabel?: TextInputValue\n hoursLabel?: TextInputValue\n minutesLabel?: TextInputValue\n secondsLabel?: TextInputValue\n}\n\nconst BLOCK_CLASS_NAME = 'block'\n\ntype BlockProps = ComponentPropsWithoutRef<'div'>\n\nfunction Block({ className, ...restOfProps }: BlockProps) {\n return (\n <div\n {...restOfProps}\n className={cx(\n BLOCK_CLASS_NAME,\n useStyle({ display: 'block', padding: '0.5em', fontSize: '1em' }),\n className,\n )}\n />\n )\n}\n\nconst LABEL_CLASS_NAME = 'label'\n\ntype LabelProps = ComponentPropsWithoutRef<'div'>\n\nfunction Label({ className, ...restOfProps }: LabelProps) {\n return (\n <div\n {...restOfProps}\n className={cx(LABEL_CLASS_NAME, useStyle({ marginTop: '0.25em' }), className)}\n />\n )\n}\n\nconst SEGMENT_CLASS_NAME = 'segment'\n\ntype SegmentProps = ComponentPropsWithoutRef<'div'>\n\nfunction Segment({ className, ...restOfProps }: SegmentProps) {\n return (\n <div\n {...restOfProps}\n className={cx(SEGMENT_CLASS_NAME, useStyle({ flex: 1, textAlign: 'center' }), className)}\n />\n )\n}\n\ntype ContainerBaseProps = {\n width?: string\n margin?: string\n variant: Props['variant']\n size: Props['size']\n shape: Props['shape']\n gap: Props['gap']\n labelColor?: ResponsiveValue<Color> | null\n numberFont?: ResponsiveValue<string>\n numberColor?: ResponsiveValue<Color> | null\n blockColor?: ResponsiveValue<Color> | null\n labelFont?: ResponsiveValue<string>\n}\n\ntype ContainerProps = ContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof ContainerBaseProps>\n\nconst Container = forwardRef(function Container(\n {\n className,\n width,\n margin,\n variant,\n size,\n shape,\n gap,\n labelColor,\n numberFont,\n numberColor,\n blockColor,\n labelFont,\n ...restOfProps\n }: ContainerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <div\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({ display: 'flex' }),\n width,\n margin,\n useStyle(\n useResponsiveStyle([size] as const, ([size = 'medium']) => {\n switch (size) {\n case 'small':\n return { fontSize: 18, [`.${LABEL_CLASS_NAME}`]: { fontSize: 14 } }\n\n case 'large':\n return { fontSize: 32, [`.${LABEL_CLASS_NAME}`]: { fontSize: 18 } }\n\n default:\n return { fontSize: 24, [`.${LABEL_CLASS_NAME}`]: { fontSize: 16 } }\n }\n }),\n ),\n useStyle({\n [`.${SEGMENT_CLASS_NAME}`]: useResponsiveStyle([gap] as const, ([gap]) => ({\n margin: `0 ${gap == null ? 0 : `${gap.value / 2}${gap.unit}`}`,\n\n '&:first-child': {\n marginLeft: 0,\n },\n\n '&:last-child': {\n marginRight: 0,\n },\n })),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle([shape] as const, ([shape = 'rounded']) => {\n switch (shape) {\n case 'pill':\n return { borderRadius: 500 }\n\n case 'rounded':\n return { borderRadius: 6 }\n\n default:\n return { borderRadius: 0 }\n }\n }),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle(\n [variant, blockColor, numberColor, numberFont] as const,\n ([\n variant = 'filled',\n blockColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n numberColor = { swatch: { hue: 0, saturation: 0, lightness: 100 }, alpha: 1 },\n numberFont = 'sans-serif',\n ]) => {\n switch (variant) {\n case 'filled':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: colorToString(blockColor),\n }\n\n case 'filled-split':\n return {\n position: 'relative',\n color: colorToString(numberColor),\n fontFamily: `\"${numberFont}\"`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 'calc(50% + 1px)',\n borderTopLeftRadius: 'inherit',\n borderTopRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n\n '::after': {\n content: '\"\"',\n position: 'absolute',\n left: 0,\n right: 0,\n top: 'calc(50% + 1px)',\n bottom: 0,\n borderBottomLeftRadius: 'inherit',\n borderBottomRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n }\n\n case 'outline':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: 'transparent',\n border: `2px solid ${colorToString(blockColor)}`,\n }\n\n case 'outline-split':\n return {\n position: 'relative',\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n border: `2px solid ${colorToString(blockColor)}`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: '50%',\n left: 0,\n right: 0,\n height: 2,\n marginTop: -1,\n background: colorToString(blockColor),\n },\n }\n\n default:\n return {\n fontFamily: `\"${numberFont}\"`,\n background: 'transparent',\n color: colorToString(numberColor),\n paddingTop: 0,\n paddingBottom: 0,\n }\n }\n },\n ),\n }),\n useStyle({\n [`.${LABEL_CLASS_NAME}`]: useResponsiveStyle(\n [labelColor, labelFont] as const,\n ([\n labelColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n labelFont = 'sans-serif',\n ]) => ({\n fontFamily: `\"${labelFont}\"`,\n color: colorToString(labelColor),\n }),\n ),\n }),\n className,\n )}\n />\n )\n})\n\nconst getRemaining = (date: Props['date'] | null | undefined) => {\n if (date == null) return { days: '0', hours: '0', minutes: '0', seconds: '0' }\n\n const timeDiff = new Date(date).getTime() - Date.now()\n\n if (timeDiff <= 0) return { days: 0, hours: 0, minutes: 0, seconds: 0 }\n\n let delta = Math.abs(timeDiff) / 1000\n\n const days = Math.floor(delta / 86400)\n delta -= days * 86400\n\n const hours = Math.floor(delta / 3600) % 24\n delta -= hours * 3600\n\n const minutes = Math.floor(delta / 60) % 60\n delta -= minutes * 60\n\n const seconds = parseInt(String(delta % 60), 10)\n\n return {\n days: days.toString(),\n hours: hours.toString(),\n minutes: minutes.toString(),\n seconds: seconds.toString(),\n }\n}\n\nconst Countdown = forwardRef(function Countdown(\n {\n id,\n margin,\n width,\n date,\n variant,\n size,\n shape,\n gap,\n labelColor,\n labelFont,\n numberColor,\n numberFont,\n blockColor,\n daysLabel,\n hoursLabel,\n minutesLabel,\n secondsLabel,\n }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n const [{ days, hours, minutes, seconds }, setRemaining] = useState(getRemaining(null))\n\n useEffect(() => {\n setRemaining(getRemaining(date))\n\n const intervalId = setInterval(() => {\n setRemaining(getRemaining(date))\n }, 1000)\n\n return () => clearInterval(intervalId)\n }, [date])\n\n return (\n <Container\n ref={ref}\n id={id}\n width={width}\n margin={margin}\n variant={variant}\n size={size}\n shape={shape}\n labelColor={labelColor}\n labelFont={labelFont}\n numberColor={numberColor}\n numberFont={numberFont}\n blockColor={blockColor}\n gap={gap}\n >\n <Segment>\n <Block>\n <span>{days}</span>\n </Block>\n <Label>{daysLabel == null ? 'Days' : daysLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{hours}</span>\n </Block>\n <Label>{hoursLabel == null ? 'Hours' : hoursLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{minutes}</span>\n </Block>\n <Label>{minutesLabel == null ? 'Minutes' : minutesLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{seconds}</span>\n </Block>\n <Label>{secondsLabel == null ? 'Seconds' : secondsLabel}</Label>\n </Segment>\n </Container>\n )\n})\n\nexport default Countdown\n"],"names":["BLOCK_CLASS_NAME","className","restOfProps","cx","useStyle","display","padding","fontSize","LABEL_CLASS_NAME","marginTop","SEGMENT_CLASS_NAME","flex","textAlign","Container","forwardRef","ref","width","margin","variant","size","shape","gap","labelColor","numberFont","numberColor","blockColor","labelFont","useResponsiveStyle","value","unit","marginLeft","marginRight","borderRadius","swatch","hue","saturation","lightness","alpha","fontFamily","color","colorToString","background","position","zIndex","content","top","left","right","bottom","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","height","paddingTop","paddingBottom","getRemaining","date","days","hours","minutes","seconds","timeDiff","Date","getTime","now","delta","Math","abs","floor","parseInt","String","toString","Countdown","id","daysLabel","hoursLabel","minutesLabel","secondsLabel","setRemaining","useState","useEffect","intervalId","setInterval","clearInterval","_jsxs","_jsx"],"mappings":";;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AAAA,MAAAA,CAJ7C,CAAA;AAAA,IAAA,CA3BF,GAiCEQ,2BAAA,KAAC,SAAD;AAAA,MAAA,UAAA,CACEC,2BAAA,IAAC,OAAD;AAAA,QACE,yCAAA,QAAA;AAAA,UAAOzB,UAAAA;AAAAA,QAAAA,CAAP;AAAA,MAAA,CAFJ,GAIEyB,2BAAA,IAAC,OAAD;AAAA,QAAA,UAAQR,gBAAgB,OAAO,YAAYA;AAAAA,MAAAA,CAJ7C,CAAA;AAAA,IAAA,CAjCF,CAAA;AAAA,EAAA,CADF;AA0CD,CA5E2B;;"}
|
|
1
|
+
{"version":3,"file":"Countdown.cjs.js","sources":["../src/components/builtin/Countdown/Countdown.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef, ForwardedRef, forwardRef, Ref, useEffect, useState } from 'react'\nimport {\n DateValue,\n ElementIDValue,\n FontValue,\n GapXValue,\n ResponsiveIconRadioGroupValue,\n ResponsiveValue,\n TextInputValue,\n} from '../../../prop-controllers/descriptors'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { colorToString } from '../../utils/colorToString'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { ColorValue as Color } from '../../utils/types'\n\ntype Props = {\n id?: ElementIDValue\n date?: DateValue\n variant?: ResponsiveIconRadioGroupValue<\n 'filled' | 'filled-split' | 'outline' | 'outline-split' | 'clear'\n >\n shape?: ResponsiveIconRadioGroupValue<'pill' | 'rounded' | 'square'>\n size?: ResponsiveIconRadioGroupValue<'small' | 'medium' | 'large'>\n gap?: GapXValue\n numberFont?: FontValue\n numberColor?: ResponsiveColor | null\n blockColor?: ResponsiveColor | null\n labelFont?: FontValue\n labelColor?: ResponsiveColor | null\n width?: string\n margin?: string\n daysLabel?: TextInputValue\n hoursLabel?: TextInputValue\n minutesLabel?: TextInputValue\n secondsLabel?: TextInputValue\n}\n\nconst BLOCK_CLASS_NAME = 'block'\n\ntype BlockProps = ComponentPropsWithoutRef<'div'>\n\nfunction Block({ className, ...restOfProps }: BlockProps) {\n return (\n <div\n {...restOfProps}\n className={cx(\n BLOCK_CLASS_NAME,\n useStyle({ display: 'block', padding: '0.5em', fontSize: '1em' }),\n className,\n )}\n />\n )\n}\n\nconst LABEL_CLASS_NAME = 'label'\n\ntype LabelProps = ComponentPropsWithoutRef<'div'>\n\nfunction Label({ className, ...restOfProps }: LabelProps) {\n return (\n <div\n {...restOfProps}\n className={cx(LABEL_CLASS_NAME, useStyle({ marginTop: '0.25em' }), className)}\n />\n )\n}\n\nconst SEGMENT_CLASS_NAME = 'segment'\n\ntype SegmentProps = ComponentPropsWithoutRef<'div'>\n\nfunction Segment({ className, ...restOfProps }: SegmentProps) {\n return (\n <div\n {...restOfProps}\n className={cx(SEGMENT_CLASS_NAME, useStyle({ flex: 1, textAlign: 'center' }), className)}\n />\n )\n}\n\ntype ContainerBaseProps = {\n width?: string\n margin?: string\n variant: Props['variant']\n size: Props['size']\n shape: Props['shape']\n gap: Props['gap']\n labelColor?: ResponsiveValue<Color> | null\n numberFont?: ResponsiveValue<string>\n numberColor?: ResponsiveValue<Color> | null\n blockColor?: ResponsiveValue<Color> | null\n labelFont?: ResponsiveValue<string>\n}\n\ntype ContainerProps = ContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof ContainerBaseProps>\n\nconst Container = forwardRef(function Container(\n {\n className,\n width,\n margin,\n variant,\n size,\n shape,\n gap,\n labelColor,\n numberFont,\n numberColor,\n blockColor,\n labelFont,\n ...restOfProps\n }: ContainerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <div\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({ display: 'flex' }),\n width,\n margin,\n useStyle(\n useResponsiveStyle([size] as const, ([size = 'medium']) => {\n switch (size) {\n case 'small':\n return { fontSize: 18, [`.${LABEL_CLASS_NAME}`]: { fontSize: 14 } }\n\n case 'large':\n return { fontSize: 32, [`.${LABEL_CLASS_NAME}`]: { fontSize: 18 } }\n\n default:\n return { fontSize: 24, [`.${LABEL_CLASS_NAME}`]: { fontSize: 16 } }\n }\n }),\n ),\n useStyle({\n [`.${SEGMENT_CLASS_NAME}`]: useResponsiveStyle([gap] as const, ([gap]) => ({\n margin: `0 ${gap == null ? 0 : `${gap.value / 2}${gap.unit}`}`,\n\n '&:first-child': {\n marginLeft: 0,\n },\n\n '&:last-child': {\n marginRight: 0,\n },\n })),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle([shape] as const, ([shape = 'rounded']) => {\n switch (shape) {\n case 'pill':\n return { borderRadius: 500 }\n\n case 'rounded':\n return { borderRadius: 6 }\n\n default:\n return { borderRadius: 0 }\n }\n }),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle(\n [variant, blockColor, numberColor, numberFont] as const,\n ([\n variant = 'filled',\n blockColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n numberColor = { swatch: { hue: 0, saturation: 0, lightness: 100 }, alpha: 1 },\n numberFont = 'sans-serif',\n ]) => {\n switch (variant) {\n case 'filled':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: colorToString(blockColor),\n }\n\n case 'filled-split':\n return {\n position: 'relative',\n color: colorToString(numberColor),\n fontFamily: `\"${numberFont}\"`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 'calc(50% + 1px)',\n borderTopLeftRadius: 'inherit',\n borderTopRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n\n '::after': {\n content: '\"\"',\n position: 'absolute',\n left: 0,\n right: 0,\n top: 'calc(50% + 1px)',\n bottom: 0,\n borderBottomLeftRadius: 'inherit',\n borderBottomRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n }\n\n case 'outline':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: 'transparent',\n border: `2px solid ${colorToString(blockColor)}`,\n }\n\n case 'outline-split':\n return {\n position: 'relative',\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n border: `2px solid ${colorToString(blockColor)}`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: '50%',\n left: 0,\n right: 0,\n height: 2,\n marginTop: -1,\n background: colorToString(blockColor),\n },\n }\n\n default:\n return {\n fontFamily: `\"${numberFont}\"`,\n background: 'transparent',\n color: colorToString(numberColor),\n paddingTop: 0,\n paddingBottom: 0,\n }\n }\n },\n ),\n }),\n useStyle({\n [`.${LABEL_CLASS_NAME}`]: useResponsiveStyle(\n [labelColor, labelFont] as const,\n ([\n labelColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n labelFont = 'sans-serif',\n ]) => ({\n fontFamily: `\"${labelFont}\"`,\n color: colorToString(labelColor),\n }),\n ),\n }),\n className,\n )}\n />\n )\n})\n\nconst getRemaining = (date: Props['date'] | null | undefined) => {\n if (date == null) return { days: '0', hours: '0', minutes: '0', seconds: '0' }\n\n const timeDiff = new Date(date).getTime() - Date.now()\n\n if (timeDiff <= 0) return { days: 0, hours: 0, minutes: 0, seconds: 0 }\n\n let delta = Math.abs(timeDiff) / 1000\n\n const days = Math.floor(delta / 86400)\n delta -= days * 86400\n\n const hours = Math.floor(delta / 3600) % 24\n delta -= hours * 3600\n\n const minutes = Math.floor(delta / 60) % 60\n delta -= minutes * 60\n\n const seconds = parseInt(String(delta % 60), 10)\n\n return {\n days: days.toString(),\n hours: hours.toString(),\n minutes: minutes.toString(),\n seconds: seconds.toString(),\n }\n}\n\nconst Countdown = forwardRef(function Countdown(\n {\n id,\n margin,\n width,\n date,\n variant,\n size,\n shape,\n gap,\n labelColor,\n labelFont,\n numberColor,\n numberFont,\n blockColor,\n daysLabel,\n hoursLabel,\n minutesLabel,\n secondsLabel,\n }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n const [{ days, hours, minutes, seconds }, setRemaining] = useState(getRemaining(null))\n\n useEffect(() => {\n setRemaining(getRemaining(date))\n\n const intervalId = setInterval(() => {\n setRemaining(getRemaining(date))\n }, 1000)\n\n return () => clearInterval(intervalId)\n }, [date])\n\n return (\n <Container\n ref={ref}\n id={id}\n width={width}\n margin={margin}\n variant={variant}\n size={size}\n shape={shape}\n labelColor={labelColor}\n labelFont={labelFont}\n numberColor={numberColor}\n numberFont={numberFont}\n blockColor={blockColor}\n gap={gap}\n >\n <Segment>\n <Block>\n <span>{days}</span>\n </Block>\n <Label>{daysLabel == null ? 'Days' : daysLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{hours}</span>\n </Block>\n <Label>{hoursLabel == null ? 'Hours' : hoursLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{minutes}</span>\n </Block>\n <Label>{minutesLabel == null ? 'Minutes' : minutesLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{seconds}</span>\n </Block>\n <Label>{secondsLabel == null ? 'Seconds' : secondsLabel}</Label>\n </Segment>\n </Container>\n )\n})\n\nexport default Countdown\n"],"names":["BLOCK_CLASS_NAME","className","restOfProps","cx","useStyle","display","padding","fontSize","LABEL_CLASS_NAME","marginTop","SEGMENT_CLASS_NAME","flex","textAlign","Container","forwardRef","ref","width","margin","variant","size","shape","gap","labelColor","numberFont","numberColor","blockColor","labelFont","useResponsiveStyle","value","unit","marginLeft","marginRight","borderRadius","swatch","hue","saturation","lightness","alpha","fontFamily","color","colorToString","background","position","zIndex","content","top","left","right","bottom","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","height","paddingTop","paddingBottom","getRemaining","date","days","hours","minutes","seconds","timeDiff","Date","getTime","now","delta","Math","abs","floor","parseInt","String","toString","Countdown","id","daysLabel","hoursLabel","minutesLabel","secondsLabel","setRemaining","useState","useEffect","intervalId","setInterval","clearInter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,UAAQT,gBAAgB,OAAO,YAAYA;AAAAA,MAAAA,CAJ7C,CAAA;AAAA,IAAA,CA3BF,GAiCEQ,2BAAA,KAAC,SAAD;AAAA,MAAA,UAAA,CACEC,2BAAA,IAAC,OAAD;AAAA,QACE,yCAAA,QAAA;AAAA,UAAOzB,UAAAA;AAAAA,QAAAA,CAAP;AAAA,MAAA,CAFJ,GAIEyB,2BAAA,IAAC,OAAD;AAAA,QAAA,UAAQR,gBAAgB,OAAO,YAAYA;AAAAA,MAAAA,CAJ7C,CAAA;AAAA,IAAA,CAjCF,CAAA;AAAA,EAAA,CADF;AA0CD,CA5E2B;;"}
|
package/dist/Countdown.es.js
CHANGED
|
@@ -31,25 +31,25 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
};
|
|
32
32
|
import { cx } from "@emotion/css";
|
|
33
33
|
import { forwardRef, useState, useEffect } from "react";
|
|
34
|
-
import {
|
|
34
|
+
import { Z as useStyle } from "./react-page.es.js";
|
|
35
|
+
import { n as useResponsiveStyle, q as colorToString } from "./index.es.js";
|
|
35
36
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
36
|
-
import "use-sync-external-store/shim/with-selector";
|
|
37
|
-
import "next/dynamic";
|
|
38
|
-
import "./react-page.es.js";
|
|
39
37
|
import "redux";
|
|
40
38
|
import "redux-thunk";
|
|
41
39
|
import "./actions.es.js";
|
|
42
40
|
import "./state/breakpoints.es.js";
|
|
41
|
+
import "@emotion/serialize";
|
|
42
|
+
import "@emotion/utils";
|
|
43
43
|
import "slate";
|
|
44
44
|
import "is-hotkey";
|
|
45
45
|
import "slate-react";
|
|
46
|
-
import "
|
|
47
|
-
import "
|
|
46
|
+
import "use-sync-external-store/shim/with-selector";
|
|
47
|
+
import "next/dynamic";
|
|
48
48
|
import "./text-input.es.js";
|
|
49
49
|
import "./combobox.es.js";
|
|
50
|
-
import "./select.es.js";
|
|
51
50
|
import "use-sync-external-store/shim";
|
|
52
51
|
import "./types.es.js";
|
|
52
|
+
import "./deepEqual.es.js";
|
|
53
53
|
import "./box-models.es.js";
|
|
54
54
|
import "css-box-model";
|
|
55
55
|
import "color";
|
|
@@ -57,6 +57,7 @@ import "scroll-into-view-if-needed";
|
|
|
57
57
|
import "react-dom";
|
|
58
58
|
import "html-react-parser";
|
|
59
59
|
import "next/head";
|
|
60
|
+
import "zod";
|
|
60
61
|
import "@emotion/server/create-instance";
|
|
61
62
|
import "next/document";
|
|
62
63
|
import "cors";
|
package/dist/Countdown.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Countdown.es.js","sources":["../src/components/builtin/Countdown/Countdown.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef, ForwardedRef, forwardRef, Ref, useEffect, useState } from 'react'\nimport {\n DateValue,\n ElementIDValue,\n FontValue,\n GapXValue,\n ResponsiveIconRadioGroupValue,\n ResponsiveValue,\n TextInputValue,\n} from '../../../prop-controllers/descriptors'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { colorToString } from '../../utils/colorToString'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { ColorValue as Color } from '../../utils/types'\n\ntype Props = {\n id?: ElementIDValue\n date?: DateValue\n variant?: ResponsiveIconRadioGroupValue<\n 'filled' | 'filled-split' | 'outline' | 'outline-split' | 'clear'\n >\n shape?: ResponsiveIconRadioGroupValue<'pill' | 'rounded' | 'square'>\n size?: ResponsiveIconRadioGroupValue<'small' | 'medium' | 'large'>\n gap?: GapXValue\n numberFont?: FontValue\n numberColor?: ResponsiveColor | null\n blockColor?: ResponsiveColor | null\n labelFont?: FontValue\n labelColor?: ResponsiveColor | null\n width?: string\n margin?: string\n daysLabel?: TextInputValue\n hoursLabel?: TextInputValue\n minutesLabel?: TextInputValue\n secondsLabel?: TextInputValue\n}\n\nconst BLOCK_CLASS_NAME = 'block'\n\ntype BlockProps = ComponentPropsWithoutRef<'div'>\n\nfunction Block({ className, ...restOfProps }: BlockProps) {\n return (\n <div\n {...restOfProps}\n className={cx(\n BLOCK_CLASS_NAME,\n useStyle({ display: 'block', padding: '0.5em', fontSize: '1em' }),\n className,\n )}\n />\n )\n}\n\nconst LABEL_CLASS_NAME = 'label'\n\ntype LabelProps = ComponentPropsWithoutRef<'div'>\n\nfunction Label({ className, ...restOfProps }: LabelProps) {\n return (\n <div\n {...restOfProps}\n className={cx(LABEL_CLASS_NAME, useStyle({ marginTop: '0.25em' }), className)}\n />\n )\n}\n\nconst SEGMENT_CLASS_NAME = 'segment'\n\ntype SegmentProps = ComponentPropsWithoutRef<'div'>\n\nfunction Segment({ className, ...restOfProps }: SegmentProps) {\n return (\n <div\n {...restOfProps}\n className={cx(SEGMENT_CLASS_NAME, useStyle({ flex: 1, textAlign: 'center' }), className)}\n />\n )\n}\n\ntype ContainerBaseProps = {\n width?: string\n margin?: string\n variant: Props['variant']\n size: Props['size']\n shape: Props['shape']\n gap: Props['gap']\n labelColor?: ResponsiveValue<Color> | null\n numberFont?: ResponsiveValue<string>\n numberColor?: ResponsiveValue<Color> | null\n blockColor?: ResponsiveValue<Color> | null\n labelFont?: ResponsiveValue<string>\n}\n\ntype ContainerProps = ContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof ContainerBaseProps>\n\nconst Container = forwardRef(function Container(\n {\n className,\n width,\n margin,\n variant,\n size,\n shape,\n gap,\n labelColor,\n numberFont,\n numberColor,\n blockColor,\n labelFont,\n ...restOfProps\n }: ContainerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <div\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({ display: 'flex' }),\n width,\n margin,\n useStyle(\n useResponsiveStyle([size] as const, ([size = 'medium']) => {\n switch (size) {\n case 'small':\n return { fontSize: 18, [`.${LABEL_CLASS_NAME}`]: { fontSize: 14 } }\n\n case 'large':\n return { fontSize: 32, [`.${LABEL_CLASS_NAME}`]: { fontSize: 18 } }\n\n default:\n return { fontSize: 24, [`.${LABEL_CLASS_NAME}`]: { fontSize: 16 } }\n }\n }),\n ),\n useStyle({\n [`.${SEGMENT_CLASS_NAME}`]: useResponsiveStyle([gap] as const, ([gap]) => ({\n margin: `0 ${gap == null ? 0 : `${gap.value / 2}${gap.unit}`}`,\n\n '&:first-child': {\n marginLeft: 0,\n },\n\n '&:last-child': {\n marginRight: 0,\n },\n })),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle([shape] as const, ([shape = 'rounded']) => {\n switch (shape) {\n case 'pill':\n return { borderRadius: 500 }\n\n case 'rounded':\n return { borderRadius: 6 }\n\n default:\n return { borderRadius: 0 }\n }\n }),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle(\n [variant, blockColor, numberColor, numberFont] as const,\n ([\n variant = 'filled',\n blockColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n numberColor = { swatch: { hue: 0, saturation: 0, lightness: 100 }, alpha: 1 },\n numberFont = 'sans-serif',\n ]) => {\n switch (variant) {\n case 'filled':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: colorToString(blockColor),\n }\n\n case 'filled-split':\n return {\n position: 'relative',\n color: colorToString(numberColor),\n fontFamily: `\"${numberFont}\"`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 'calc(50% + 1px)',\n borderTopLeftRadius: 'inherit',\n borderTopRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n\n '::after': {\n content: '\"\"',\n position: 'absolute',\n left: 0,\n right: 0,\n top: 'calc(50% + 1px)',\n bottom: 0,\n borderBottomLeftRadius: 'inherit',\n borderBottomRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n }\n\n case 'outline':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: 'transparent',\n border: `2px solid ${colorToString(blockColor)}`,\n }\n\n case 'outline-split':\n return {\n position: 'relative',\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n border: `2px solid ${colorToString(blockColor)}`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: '50%',\n left: 0,\n right: 0,\n height: 2,\n marginTop: -1,\n background: colorToString(blockColor),\n },\n }\n\n default:\n return {\n fontFamily: `\"${numberFont}\"`,\n background: 'transparent',\n color: colorToString(numberColor),\n paddingTop: 0,\n paddingBottom: 0,\n }\n }\n },\n ),\n }),\n useStyle({\n [`.${LABEL_CLASS_NAME}`]: useResponsiveStyle(\n [labelColor, labelFont] as const,\n ([\n labelColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n labelFont = 'sans-serif',\n ]) => ({\n fontFamily: `\"${labelFont}\"`,\n color: colorToString(labelColor),\n }),\n ),\n }),\n className,\n )}\n />\n )\n})\n\nconst getRemaining = (date: Props['date'] | null | undefined) => {\n if (date == null) return { days: '0', hours: '0', minutes: '0', seconds: '0' }\n\n const timeDiff = new Date(date).getTime() - Date.now()\n\n if (timeDiff <= 0) return { days: 0, hours: 0, minutes: 0, seconds: 0 }\n\n let delta = Math.abs(timeDiff) / 1000\n\n const days = Math.floor(delta / 86400)\n delta -= days * 86400\n\n const hours = Math.floor(delta / 3600) % 24\n delta -= hours * 3600\n\n const minutes = Math.floor(delta / 60) % 60\n delta -= minutes * 60\n\n const seconds = parseInt(String(delta % 60), 10)\n\n return {\n days: days.toString(),\n hours: hours.toString(),\n minutes: minutes.toString(),\n seconds: seconds.toString(),\n }\n}\n\nconst Countdown = forwardRef(function Countdown(\n {\n id,\n margin,\n width,\n date,\n variant,\n size,\n shape,\n gap,\n labelColor,\n labelFont,\n numberColor,\n numberFont,\n blockColor,\n daysLabel,\n hoursLabel,\n minutesLabel,\n secondsLabel,\n }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n const [{ days, hours, minutes, seconds }, setRemaining] = useState(getRemaining(null))\n\n useEffect(() => {\n setRemaining(getRemaining(date))\n\n const intervalId = setInterval(() => {\n setRemaining(getRemaining(date))\n }, 1000)\n\n return () => clearInterval(intervalId)\n }, [date])\n\n return (\n <Container\n ref={ref}\n id={id}\n width={width}\n margin={margin}\n variant={variant}\n size={size}\n shape={shape}\n labelColor={labelColor}\n labelFont={labelFont}\n numberColor={numberColor}\n numberFont={numberFont}\n blockColor={blockColor}\n gap={gap}\n >\n <Segment>\n <Block>\n <span>{days}</span>\n </Block>\n <Label>{daysLabel == null ? 'Days' : daysLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{hours}</span>\n </Block>\n <Label>{hoursLabel == null ? 'Hours' : hoursLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{minutes}</span>\n </Block>\n <Label>{minutesLabel == null ? 'Minutes' : minutesLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{seconds}</span>\n </Block>\n <Label>{secondsLabel == null ? 'Seconds' : secondsLabel}</Label>\n </Segment>\n </Container>\n )\n})\n\nexport default Countdown\n"],"names":["BLOCK_CLASS_NAME","className","restOfProps","cx","useStyle","display","padding","fontSize","LABEL_CLASS_NAME","marginTop","SEGMENT_CLASS_NAME","flex","textAlign","Container","forwardRef","ref","width","margin","variant","size","shape","gap","labelColor","numberFont","numberColor","blockColor","labelFont","useResponsiveStyle","value","unit","marginLeft","marginRight","borderRadius","swatch","hue","saturation","lightness","alpha","fontFamily","color","colorToString","background","position","zIndex","content","top","left","right","bottom","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","height","paddingTop","paddingBottom","getRemaining","date","days","hours","minutes","seconds","timeDiff","Date","getTime","now","delta","Math","abs","floor","parseInt","String","toString","Countdown","id","daysLabel","hoursLabel","minutesLabel","secondsLabel","setRemaining","useState","useEffect","intervalId","setInterval","clearInterval","_jsxs","_jsx"],"mappings":";;;;;;;;;;;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AAC,OAAD;AAAA,QAAA,UAAQR,gBAAgB,OAAO,YAAYA;AAAAA,MAAAA,CAJ7C,CAAA;AAAA,IAAA,CAjCF,CAAA;AAAA,EAAA,CADF;AA0CD,CA5E2B;;"}
|
|
1
|
+
{"version":3,"file":"Countdown.es.js","sources":["../src/components/builtin/Countdown/Countdown.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef, ForwardedRef, forwardRef, Ref, useEffect, useState } from 'react'\nimport {\n DateValue,\n ElementIDValue,\n FontValue,\n GapXValue,\n ResponsiveIconRadioGroupValue,\n ResponsiveValue,\n TextInputValue,\n} from '../../../prop-controllers/descriptors'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { colorToString } from '../../utils/colorToString'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { ColorValue as Color } from '../../utils/types'\n\ntype Props = {\n id?: ElementIDValue\n date?: DateValue\n variant?: ResponsiveIconRadioGroupValue<\n 'filled' | 'filled-split' | 'outline' | 'outline-split' | 'clear'\n >\n shape?: ResponsiveIconRadioGroupValue<'pill' | 'rounded' | 'square'>\n size?: ResponsiveIconRadioGroupValue<'small' | 'medium' | 'large'>\n gap?: GapXValue\n numberFont?: FontValue\n numberColor?: ResponsiveColor | null\n blockColor?: ResponsiveColor | null\n labelFont?: FontValue\n labelColor?: ResponsiveColor | null\n width?: string\n margin?: string\n daysLabel?: TextInputValue\n hoursLabel?: TextInputValue\n minutesLabel?: TextInputValue\n secondsLabel?: TextInputValue\n}\n\nconst BLOCK_CLASS_NAME = 'block'\n\ntype BlockProps = ComponentPropsWithoutRef<'div'>\n\nfunction Block({ className, ...restOfProps }: BlockProps) {\n return (\n <div\n {...restOfProps}\n className={cx(\n BLOCK_CLASS_NAME,\n useStyle({ display: 'block', padding: '0.5em', fontSize: '1em' }),\n className,\n )}\n />\n )\n}\n\nconst LABEL_CLASS_NAME = 'label'\n\ntype LabelProps = ComponentPropsWithoutRef<'div'>\n\nfunction Label({ className, ...restOfProps }: LabelProps) {\n return (\n <div\n {...restOfProps}\n className={cx(LABEL_CLASS_NAME, useStyle({ marginTop: '0.25em' }), className)}\n />\n )\n}\n\nconst SEGMENT_CLASS_NAME = 'segment'\n\ntype SegmentProps = ComponentPropsWithoutRef<'div'>\n\nfunction Segment({ className, ...restOfProps }: SegmentProps) {\n return (\n <div\n {...restOfProps}\n className={cx(SEGMENT_CLASS_NAME, useStyle({ flex: 1, textAlign: 'center' }), className)}\n />\n )\n}\n\ntype ContainerBaseProps = {\n width?: string\n margin?: string\n variant: Props['variant']\n size: Props['size']\n shape: Props['shape']\n gap: Props['gap']\n labelColor?: ResponsiveValue<Color> | null\n numberFont?: ResponsiveValue<string>\n numberColor?: ResponsiveValue<Color> | null\n blockColor?: ResponsiveValue<Color> | null\n labelFont?: ResponsiveValue<string>\n}\n\ntype ContainerProps = ContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof ContainerBaseProps>\n\nconst Container = forwardRef(function Container(\n {\n className,\n width,\n margin,\n variant,\n size,\n shape,\n gap,\n labelColor,\n numberFont,\n numberColor,\n blockColor,\n labelFont,\n ...restOfProps\n }: ContainerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <div\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({ display: 'flex' }),\n width,\n margin,\n useStyle(\n useResponsiveStyle([size] as const, ([size = 'medium']) => {\n switch (size) {\n case 'small':\n return { fontSize: 18, [`.${LABEL_CLASS_NAME}`]: { fontSize: 14 } }\n\n case 'large':\n return { fontSize: 32, [`.${LABEL_CLASS_NAME}`]: { fontSize: 18 } }\n\n default:\n return { fontSize: 24, [`.${LABEL_CLASS_NAME}`]: { fontSize: 16 } }\n }\n }),\n ),\n useStyle({\n [`.${SEGMENT_CLASS_NAME}`]: useResponsiveStyle([gap] as const, ([gap]) => ({\n margin: `0 ${gap == null ? 0 : `${gap.value / 2}${gap.unit}`}`,\n\n '&:first-child': {\n marginLeft: 0,\n },\n\n '&:last-child': {\n marginRight: 0,\n },\n })),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle([shape] as const, ([shape = 'rounded']) => {\n switch (shape) {\n case 'pill':\n return { borderRadius: 500 }\n\n case 'rounded':\n return { borderRadius: 6 }\n\n default:\n return { borderRadius: 0 }\n }\n }),\n }),\n useStyle({\n [`.${BLOCK_CLASS_NAME}`]: useResponsiveStyle(\n [variant, blockColor, numberColor, numberFont] as const,\n ([\n variant = 'filled',\n blockColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n numberColor = { swatch: { hue: 0, saturation: 0, lightness: 100 }, alpha: 1 },\n numberFont = 'sans-serif',\n ]) => {\n switch (variant) {\n case 'filled':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: colorToString(blockColor),\n }\n\n case 'filled-split':\n return {\n position: 'relative',\n color: colorToString(numberColor),\n fontFamily: `\"${numberFont}\"`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 'calc(50% + 1px)',\n borderTopLeftRadius: 'inherit',\n borderTopRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n\n '::after': {\n content: '\"\"',\n position: 'absolute',\n left: 0,\n right: 0,\n top: 'calc(50% + 1px)',\n bottom: 0,\n borderBottomLeftRadius: 'inherit',\n borderBottomRightRadius: 'inherit',\n background: colorToString(blockColor),\n },\n }\n\n case 'outline':\n return {\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n background: 'transparent',\n border: `2px solid ${colorToString(blockColor)}`,\n }\n\n case 'outline-split':\n return {\n position: 'relative',\n fontFamily: `\"${numberFont}\"`,\n color: colorToString(numberColor),\n border: `2px solid ${colorToString(blockColor)}`,\n\n '> span': {\n position: 'relative',\n zIndex: 1,\n },\n\n '::before': {\n content: '\"\"',\n position: 'absolute',\n top: '50%',\n left: 0,\n right: 0,\n height: 2,\n marginTop: -1,\n background: colorToString(blockColor),\n },\n }\n\n default:\n return {\n fontFamily: `\"${numberFont}\"`,\n background: 'transparent',\n color: colorToString(numberColor),\n paddingTop: 0,\n paddingBottom: 0,\n }\n }\n },\n ),\n }),\n useStyle({\n [`.${LABEL_CLASS_NAME}`]: useResponsiveStyle(\n [labelColor, labelFont] as const,\n ([\n labelColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n labelFont = 'sans-serif',\n ]) => ({\n fontFamily: `\"${labelFont}\"`,\n color: colorToString(labelColor),\n }),\n ),\n }),\n className,\n )}\n />\n )\n})\n\nconst getRemaining = (date: Props['date'] | null | undefined) => {\n if (date == null) return { days: '0', hours: '0', minutes: '0', seconds: '0' }\n\n const timeDiff = new Date(date).getTime() - Date.now()\n\n if (timeDiff <= 0) return { days: 0, hours: 0, minutes: 0, seconds: 0 }\n\n let delta = Math.abs(timeDiff) / 1000\n\n const days = Math.floor(delta / 86400)\n delta -= days * 86400\n\n const hours = Math.floor(delta / 3600) % 24\n delta -= hours * 3600\n\n const minutes = Math.floor(delta / 60) % 60\n delta -= minutes * 60\n\n const seconds = parseInt(String(delta % 60), 10)\n\n return {\n days: days.toString(),\n hours: hours.toString(),\n minutes: minutes.toString(),\n seconds: seconds.toString(),\n }\n}\n\nconst Countdown = forwardRef(function Countdown(\n {\n id,\n margin,\n width,\n date,\n variant,\n size,\n shape,\n gap,\n labelColor,\n labelFont,\n numberColor,\n numberFont,\n blockColor,\n daysLabel,\n hoursLabel,\n minutesLabel,\n secondsLabel,\n }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n const [{ days, hours, minutes, seconds }, setRemaining] = useState(getRemaining(null))\n\n useEffect(() => {\n setRemaining(getRemaining(date))\n\n const intervalId = setInterval(() => {\n setRemaining(getRemaining(date))\n }, 1000)\n\n return () => clearInterval(intervalId)\n }, [date])\n\n return (\n <Container\n ref={ref}\n id={id}\n width={width}\n margin={margin}\n variant={variant}\n size={size}\n shape={shape}\n labelColor={labelColor}\n labelFont={labelFont}\n numberColor={numberColor}\n numberFont={numberFont}\n blockColor={blockColor}\n gap={gap}\n >\n <Segment>\n <Block>\n <span>{days}</span>\n </Block>\n <Label>{daysLabel == null ? 'Days' : daysLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{hours}</span>\n </Block>\n <Label>{hoursLabel == null ? 'Hours' : hoursLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{minutes}</span>\n </Block>\n <Label>{minutesLabel == null ? 'Minutes' : minutesLabel}</Label>\n </Segment>\n <Segment>\n <Block>\n <span>{seconds}</span>\n </Block>\n <Label>{secondsLabel == null ? 'Seconds' : secondsLabel}</Label>\n </Segment>\n </Container>\n )\n})\n\nexport default Countdown\n"],"names":["BLOCK_CLASS_NAME","className","restOfProps","cx","useStyle","display","padding","fontSize","LABEL_CLASS_NAME","marginTop","SEGMENT_CLASS_NAME","flex","textAlign","Container","forwardRef","ref","width","margin","variant","size","shape","gap","labelColor","numberFont","numberColor","blockColor","labelFont","useResponsiveStyle","value","unit","marginLeft","marginRight","borderRadius","swatch","hue","saturation","lightness","alpha","fontFamily","color","colorToString","background","position","zIndex","content","top","left","right","bottom","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","height","paddingTop","paddingBottom","getRemaining","date","days","hours","minutes","seconds","timeDiff","Date","getTime","now","delta","Math","abs","floor","parseInt","String","toString","Countdown","id","daysLabel","hoursLabel","minutesLabel","secondsLabel","setRemaining","useState","useEffect","intervalId","setInterval","clearInterval","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAMA,mBAAmB;AAIzB,eAAe,IAA2C;AAA3C,eAAEC;AAAAA;AAAAA,MAAF,IAAgBC,wBAAhB,IAAgBA;AAAAA,IAAdD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33 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
var React = require("react");
|
|
4
4
|
var next = require("./index.cjs.js");
|
|
5
|
+
var reactPage = require("./react-page.cjs.js");
|
|
5
6
|
var css = require("@emotion/css");
|
|
6
7
|
var jsxRuntime = require("react/jsx-runtime");
|
|
7
8
|
require("use-sync-external-store/shim/with-selector");
|
|
8
9
|
require("next/dynamic");
|
|
9
|
-
require("./react-page.cjs.js");
|
|
10
|
-
require("redux");
|
|
11
|
-
require("redux-thunk");
|
|
12
10
|
require("./actions.cjs.js");
|
|
13
|
-
require("./
|
|
11
|
+
require("./text-input.cjs.js");
|
|
12
|
+
require("./combobox.cjs.js");
|
|
14
13
|
require("slate");
|
|
14
|
+
require("./state/breakpoints.cjs.js");
|
|
15
15
|
require("is-hotkey");
|
|
16
16
|
require("slate-react");
|
|
17
|
-
require("@emotion/serialize");
|
|
18
|
-
require("@emotion/utils");
|
|
19
|
-
require("./text-input.cjs.js");
|
|
20
|
-
require("./combobox.cjs.js");
|
|
21
|
-
require("./select.cjs.js");
|
|
22
17
|
require("use-sync-external-store/shim");
|
|
18
|
+
require("redux");
|
|
19
|
+
require("redux-thunk");
|
|
23
20
|
require("./types.cjs.js");
|
|
21
|
+
require("./deepEqual.cjs.js");
|
|
24
22
|
require("./box-models.cjs.js");
|
|
25
23
|
require("css-box-model");
|
|
26
24
|
require("color");
|
|
25
|
+
require("@emotion/serialize");
|
|
26
|
+
require("@emotion/utils");
|
|
27
27
|
require("scroll-into-view-if-needed");
|
|
28
28
|
require("react-dom");
|
|
29
29
|
require("html-react-parser");
|
|
30
30
|
require("next/head");
|
|
31
|
+
require("zod");
|
|
31
32
|
require("@emotion/server/create-instance");
|
|
32
33
|
require("next/document");
|
|
33
34
|
require("cors");
|
|
@@ -49,12 +50,12 @@ const Divider = React.forwardRef(function Divider2({
|
|
|
49
50
|
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
50
51
|
ref,
|
|
51
52
|
id,
|
|
52
|
-
className: css.cx(
|
|
53
|
+
className: css.cx(reactPage.useStyle({
|
|
53
54
|
display: "flex",
|
|
54
55
|
width: "100%"
|
|
55
56
|
}), width, margin),
|
|
56
57
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
57
|
-
className:
|
|
58
|
+
className: reactPage.useStyle({
|
|
58
59
|
display: "flex",
|
|
59
60
|
flexDirection: "column",
|
|
60
61
|
justifyContent: "center",
|
|
@@ -62,7 +63,7 @@ const Divider = React.forwardRef(function Divider2({
|
|
|
62
63
|
width: "100%"
|
|
63
64
|
}),
|
|
64
65
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
65
|
-
className:
|
|
66
|
+
className: reactPage.useStyle(next.useResponsiveStyle([variant, thickness, color], ([variant2 = "solid", thickness2 = {
|
|
66
67
|
value: 1,
|
|
67
68
|
unit: "px"
|
|
68
69
|
}, color2 = {
|
package/dist/Divider.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Divider.cjs.js","sources":["../src/components/builtin/Divider/Divider.tsx"],"sourcesContent":["import { forwardRef, Ref } from 'react'\n\nimport {\n ElementIDValue,\n ResponsiveLengthValue,\n ResponsiveSelectValue,\n} from '../../../prop-controllers/descriptors'\nimport { colorToString } from '../../utils/colorToString'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\n\ntype DividerVariant = 'solid' | 'dashed' | 'dotted' | 'blended'\n\ntype Props = {\n id?: ElementIDValue\n variant?: ResponsiveSelectValue<DividerVariant>\n thickness?: ResponsiveLengthValue\n color?: ResponsiveColor | null\n width?: string\n margin?: string\n}\n\nconst Divider = forwardRef(function Divider(\n { id, variant, thickness, color, width, margin }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n return (\n // IE11 has a bug with Flexbox vertical centering with min height if height is not set.\n // Wrapping it in another flex container fixes it for some reason, read more here:\n // https://stackoverflow.com/questions/19371626/flexbox-not-centering-vertically-in-ie\n <div\n ref={ref}\n id={id}\n className={cx(useStyle({ display: 'flex', width: '100%' }), width, margin)}\n >\n <div\n className={useStyle({\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'center',\n minHeight: 40,\n width: '100%',\n })}\n >\n <div\n className={useStyle(\n useResponsiveStyle(\n [variant, thickness, color] as const,\n ([\n variant = 'solid',\n thickness = { value: 1, unit: 'px' },\n color = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n ]) => {\n switch (variant) {\n case 'solid':\n case 'dashed':\n case 'dotted':\n return {\n borderBottomWidth:\n thickness == null ? 1 : `${thickness.value}${thickness.unit}`,\n borderBottomStyle: variant,\n borderBottomColor: colorToString(color),\n }\n\n case 'blended':\n return {\n height: `${thickness.value}${thickness.unit}`,\n background: `linear-gradient(${[\n '90deg',\n colorToString({ swatch: color.swatch, alpha: 0 }),\n colorToString(color),\n colorToString({ swatch: color.swatch, alpha: 0 }),\n ].join(', ')})`,\n }\n\n default:\n variant as never\n throw new Error(`Invalid variant ${variant}.`)\n }\n },\n ),\n )}\n />\n </div>\n </div>\n )\n})\n\nexport default Divider\n"],"names":["Divider","forwardRef","id","variant","thickness","color","width","margin","ref","cx","useStyle","display","flexDirection","justifyContent","minHeight","useResponsiveStyle","value","unit","swatch","hue","saturation","lightness","alpha","borderBottomWidth","borderBottomStyle","borderBottomColor","colorToString","height","background","join","Error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Divider.cjs.js","sources":["../src/components/builtin/Divider/Divider.tsx"],"sourcesContent":["import { forwardRef, Ref } from 'react'\n\nimport {\n ElementIDValue,\n ResponsiveLengthValue,\n ResponsiveSelectValue,\n} from '../../../prop-controllers/descriptors'\nimport { colorToString } from '../../utils/colorToString'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\n\ntype DividerVariant = 'solid' | 'dashed' | 'dotted' | 'blended'\n\ntype Props = {\n id?: ElementIDValue\n variant?: ResponsiveSelectValue<DividerVariant>\n thickness?: ResponsiveLengthValue\n color?: ResponsiveColor | null\n width?: string\n margin?: string\n}\n\nconst Divider = forwardRef(function Divider(\n { id, variant, thickness, color, width, margin }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n return (\n // IE11 has a bug with Flexbox vertical centering with min height if height is not set.\n // Wrapping it in another flex container fixes it for some reason, read more here:\n // https://stackoverflow.com/questions/19371626/flexbox-not-centering-vertically-in-ie\n <div\n ref={ref}\n id={id}\n className={cx(useStyle({ display: 'flex', width: '100%' }), width, margin)}\n >\n <div\n className={useStyle({\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'center',\n minHeight: 40,\n width: '100%',\n })}\n >\n <div\n className={useStyle(\n useResponsiveStyle(\n [variant, thickness, color] as const,\n ([\n variant = 'solid',\n thickness = { value: 1, unit: 'px' },\n color = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n ]) => {\n switch (variant) {\n case 'solid':\n case 'dashed':\n case 'dotted':\n return {\n borderBottomWidth:\n thickness == null ? 1 : `${thickness.value}${thickness.unit}`,\n borderBottomStyle: variant,\n borderBottomColor: colorToString(color),\n }\n\n case 'blended':\n return {\n height: `${thickness.value}${thickness.unit}`,\n background: `linear-gradient(${[\n '90deg',\n colorToString({ swatch: color.swatch, alpha: 0 }),\n colorToString(color),\n colorToString({ swatch: color.swatch, alpha: 0 }),\n ].join(', ')})`,\n }\n\n default:\n variant as never\n throw new Error(`Invalid variant ${variant}.`)\n }\n },\n ),\n )}\n />\n </div>\n </div>\n )\n})\n\nexport default Divider\n"],"names":["Divider","forwardRef","id","variant","thickness","color","width","margin","ref","cx","useStyle","display","flexDirection","justifyContent","minHeight","useResponsiveStyle","value","unit","swatch","hue","saturation","lightness","alpha","borderBottomWidth","borderBott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BAAER,QAAQb,OAAMa;AAAAA,kBAAQI,OAAO;AAAA,gBAAhC,CAAA,GACbI,KAAcrB,cAAAA,MAAD,GACbqB,mBAAc;AAAA,kBAAER,QAAQb,OAAMa;AAAAA,kBAAQI,OAAO;AAAA,gBAAhC,CAAA,CAJgB,EAK7BO,KAAK,IALwB;AAAA,cAAA;AAAA;AAU3B,oBAAA,IAAIC,MAAO,mBAAkB3B,WAA7B;AAAA;AAAA,QAAA,CA/BI,CADD;AAAA,MAAA,CADrB;AAAA,IAAA,CATF;AAAA,EAAA,CALF;AAwDH,CAhEyB;;"}
|
package/dist/Divider.es.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { forwardRef } from "react";
|
|
2
|
-
import { n as
|
|
2
|
+
import { n as useResponsiveStyle, q as colorToString } from "./index.es.js";
|
|
3
|
+
import { Z as useStyle } from "./react-page.es.js";
|
|
3
4
|
import { cx } from "@emotion/css";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import "use-sync-external-store/shim/with-selector";
|
|
6
7
|
import "next/dynamic";
|
|
7
|
-
import "./react-page.es.js";
|
|
8
|
-
import "redux";
|
|
9
|
-
import "redux-thunk";
|
|
10
8
|
import "./actions.es.js";
|
|
11
|
-
import "./
|
|
9
|
+
import "./text-input.es.js";
|
|
10
|
+
import "./combobox.es.js";
|
|
12
11
|
import "slate";
|
|
12
|
+
import "./state/breakpoints.es.js";
|
|
13
13
|
import "is-hotkey";
|
|
14
14
|
import "slate-react";
|
|
15
|
-
import "@emotion/serialize";
|
|
16
|
-
import "@emotion/utils";
|
|
17
|
-
import "./text-input.es.js";
|
|
18
|
-
import "./combobox.es.js";
|
|
19
|
-
import "./select.es.js";
|
|
20
15
|
import "use-sync-external-store/shim";
|
|
16
|
+
import "redux";
|
|
17
|
+
import "redux-thunk";
|
|
21
18
|
import "./types.es.js";
|
|
19
|
+
import "./deepEqual.es.js";
|
|
22
20
|
import "./box-models.es.js";
|
|
23
21
|
import "css-box-model";
|
|
24
22
|
import "color";
|
|
23
|
+
import "@emotion/serialize";
|
|
24
|
+
import "@emotion/utils";
|
|
25
25
|
import "scroll-into-view-if-needed";
|
|
26
26
|
import "react-dom";
|
|
27
27
|
import "html-react-parser";
|
|
28
28
|
import "next/head";
|
|
29
|
+
import "zod";
|
|
29
30
|
import "@emotion/server/create-instance";
|
|
30
31
|
import "next/document";
|
|
31
32
|
import "cors";
|
package/dist/Divider.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Divider.es.js","sources":["../src/components/builtin/Divider/Divider.tsx"],"sourcesContent":["import { forwardRef, Ref } from 'react'\n\nimport {\n ElementIDValue,\n ResponsiveLengthValue,\n ResponsiveSelectValue,\n} from '../../../prop-controllers/descriptors'\nimport { colorToString } from '../../utils/colorToString'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\n\ntype DividerVariant = 'solid' | 'dashed' | 'dotted' | 'blended'\n\ntype Props = {\n id?: ElementIDValue\n variant?: ResponsiveSelectValue<DividerVariant>\n thickness?: ResponsiveLengthValue\n color?: ResponsiveColor | null\n width?: string\n margin?: string\n}\n\nconst Divider = forwardRef(function Divider(\n { id, variant, thickness, color, width, margin }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n return (\n // IE11 has a bug with Flexbox vertical centering with min height if height is not set.\n // Wrapping it in another flex container fixes it for some reason, read more here:\n // https://stackoverflow.com/questions/19371626/flexbox-not-centering-vertically-in-ie\n <div\n ref={ref}\n id={id}\n className={cx(useStyle({ display: 'flex', width: '100%' }), width, margin)}\n >\n <div\n className={useStyle({\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'center',\n minHeight: 40,\n width: '100%',\n })}\n >\n <div\n className={useStyle(\n useResponsiveStyle(\n [variant, thickness, color] as const,\n ([\n variant = 'solid',\n thickness = { value: 1, unit: 'px' },\n color = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n ]) => {\n switch (variant) {\n case 'solid':\n case 'dashed':\n case 'dotted':\n return {\n borderBottomWidth:\n thickness == null ? 1 : `${thickness.value}${thickness.unit}`,\n borderBottomStyle: variant,\n borderBottomColor: colorToString(color),\n }\n\n case 'blended':\n return {\n height: `${thickness.value}${thickness.unit}`,\n background: `linear-gradient(${[\n '90deg',\n colorToString({ swatch: color.swatch, alpha: 0 }),\n colorToString(color),\n colorToString({ swatch: color.swatch, alpha: 0 }),\n ].join(', ')})`,\n }\n\n default:\n variant as never\n throw new Error(`Invalid variant ${variant}.`)\n }\n },\n ),\n )}\n />\n </div>\n </div>\n )\n})\n\nexport default Divider\n"],"names":["Divider","forwardRef","id","variant","thickness","color","width","margin","ref","cx","useStyle","display","flexDirection","justifyContent","minHeight","useResponsiveStyle","value","unit","swatch","hue","saturation","lightness","alpha","borderBottomWidth","borderBottomStyle","borderBottomColor","colorToString","height","background","join","Error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Divider.es.js","sources":["../src/components/builtin/Divider/Divider.tsx"],"sourcesContent":["import { forwardRef, Ref } from 'react'\n\nimport {\n ElementIDValue,\n ResponsiveLengthValue,\n ResponsiveSelectValue,\n} from '../../../prop-controllers/descriptors'\nimport { colorToString } from '../../utils/colorToString'\nimport { ResponsiveColor } from '../../../runtimes/react/controls'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\n\ntype DividerVariant = 'solid' | 'dashed' | 'dotted' | 'blended'\n\ntype Props = {\n id?: ElementIDValue\n variant?: ResponsiveSelectValue<DividerVariant>\n thickness?: ResponsiveLengthValue\n color?: ResponsiveColor | null\n width?: string\n margin?: string\n}\n\nconst Divider = forwardRef(function Divider(\n { id, variant, thickness, color, width, margin }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n return (\n // IE11 has a bug with Flexbox vertical centering with min height if height is not set.\n // Wrapping it in another flex container fixes it for some reason, read more here:\n // https://stackoverflow.com/questions/19371626/flexbox-not-centering-vertically-in-ie\n <div\n ref={ref}\n id={id}\n className={cx(useStyle({ display: 'flex', width: '100%' }), width, margin)}\n >\n <div\n className={useStyle({\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'center',\n minHeight: 40,\n width: '100%',\n })}\n >\n <div\n className={useStyle(\n useResponsiveStyle(\n [variant, thickness, color] as const,\n ([\n variant = 'solid',\n thickness = { value: 1, unit: 'px' },\n color = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 },\n ]) => {\n switch (variant) {\n case 'solid':\n case 'dashed':\n case 'dotted':\n return {\n borderBottomWidth:\n thickness == null ? 1 : `${thickness.value}${thickness.unit}`,\n borderBottomStyle: variant,\n borderBottomColor: colorToString(color),\n }\n\n case 'blended':\n return {\n height: `${thickness.value}${thickness.unit}`,\n background: `linear-gradient(${[\n '90deg',\n colorToString({ swatch: color.swatch, alpha: 0 }),\n colorToString(color),\n colorToString({ swatch: color.swatch, alpha: 0 }),\n ].join(', ')})`,\n }\n\n default:\n variant as never\n throw new Error(`Invalid variant ${variant}.`)\n }\n },\n ),\n )}\n />\n </div>\n </div>\n )\n})\n\nexport default Divider\n"],"names":["Divider","forwardRef","id","variant","thickness","color","width","margin","ref","cx","useStyle","display","flexDirection","justifyContent","minHeight","useResponsiveStyle","value","unit","swatch","hue","saturation","lightness","alpha","borderBottomWidth","borderBottomStyle","borderBottomColor","colorToString","height","background","join","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBMA,MAAAA,UAAUC,WAAW,kBACzB;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAASC;AAAAA,EAAWC;AAAAA,EAAOC;AAAAA,EAAOC;AAAAA,GACxCC,KACA;AACA,6BAIE,OAAA;AAAA,IACE;AAAA,IACA;AAAA,IACA,WAAWC,GAAGC,SAAS;AAAA,MAAEC,SAAS;AAAA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;"}
|
package/dist/Embed.cjs.js
CHANGED
|
@@ -2,43 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
var React = require("react");
|
|
4
4
|
var useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect.cjs.js");
|
|
5
|
-
var
|
|
5
|
+
var reactPage = require("./react-page.cjs.js");
|
|
6
6
|
var css = require("@emotion/css");
|
|
7
7
|
var jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
require("use-sync-external-store/shim/with-selector");
|
|
9
|
-
require("next/dynamic");
|
|
10
|
-
require("./react-page.cjs.js");
|
|
11
8
|
require("redux");
|
|
12
9
|
require("redux-thunk");
|
|
13
10
|
require("./actions.cjs.js");
|
|
14
11
|
require("./state/breakpoints.cjs.js");
|
|
12
|
+
require("@emotion/serialize");
|
|
13
|
+
require("@emotion/utils");
|
|
15
14
|
require("slate");
|
|
16
15
|
require("is-hotkey");
|
|
17
16
|
require("slate-react");
|
|
18
|
-
require("@emotion/serialize");
|
|
19
|
-
require("@emotion/utils");
|
|
20
|
-
require("./text-input.cjs.js");
|
|
21
|
-
require("./combobox.cjs.js");
|
|
22
|
-
require("./select.cjs.js");
|
|
23
|
-
require("use-sync-external-store/shim");
|
|
24
|
-
require("./types.cjs.js");
|
|
25
|
-
require("./box-models.cjs.js");
|
|
26
|
-
require("css-box-model");
|
|
27
|
-
require("color");
|
|
28
|
-
require("scroll-into-view-if-needed");
|
|
29
|
-
require("react-dom");
|
|
30
|
-
require("html-react-parser");
|
|
31
|
-
require("next/head");
|
|
32
|
-
require("@emotion/server/create-instance");
|
|
33
|
-
require("next/document");
|
|
34
|
-
require("cors");
|
|
35
|
-
require("path-to-regexp");
|
|
36
|
-
require("cookie");
|
|
37
|
-
require("http-proxy");
|
|
38
|
-
require("set-cookie-parser");
|
|
39
|
-
require("./constants.cjs.js");
|
|
40
|
-
require("uuid");
|
|
41
|
-
require("corporate-ipsum");
|
|
42
17
|
const defaultHtml = `<div style="padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;">
|
|
43
18
|
<svg width="316" height="168" viewBox="0 0 316 168" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
44
19
|
<rect width="70" height="8" rx="2" fill="#A1A8C2" fill-opacity="0.5"/>
|
|
@@ -112,7 +87,7 @@ const Embed = React.forwardRef(function Embed2({
|
|
|
112
87
|
console.error(error);
|
|
113
88
|
});
|
|
114
89
|
}, [container, html]);
|
|
115
|
-
const className =
|
|
90
|
+
const className = reactPage.useStyle({
|
|
116
91
|
minHeight: 15
|
|
117
92
|
});
|
|
118
93
|
if (shouldRender === false)
|
package/dist/Embed.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.cjs.js","sources":["../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { ElementIDValue, TextAreaValue } from '../../../prop-controllers/descriptors'\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: ElementIDValue\n html?: TextAreaValue\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle(ref, () => container, [container])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n )\n})\n\nexport default Embed\n"],"names":["defaultHtml","SCRIPT_TAG","Embed","forwardRef","id","width","margin","html","ref","container","setContainer","useState","shouldRender","setShouldRender","useIsomorphicLayoutEffect","useImperativeHandle","useEffect","walker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","node","tagName","toLowerCase","FILTER_ACCEPT","FILTER_REJECT","nodes","nextNode","push","currentNode","i","length","Promise","resolve","script","createElement","textContent","Array","from","attributes","forEach","name","value","setAttribute","onload","onerror","parentNode","insertBefore","removeChild","hasAttribute","catch","error","console","className","useStyle","minHeight","cx","__html"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Embed.cjs.js","sources":["../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { ElementIDValue, TextAreaValue } from '../../../prop-controllers/descriptors'\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: ElementIDValue\n html?: TextAreaValue\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle(ref, () => container, [container])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n )\n})\n\nexport default Embed\n"],"names":["defaultHtml","SCRIPT_TAG","Embed","forwardRef","id","width","margin","html","ref","container","setContainer","useState","shouldRender","setShouldRender","useIsomorphicLayoutEffect","useImperativeHandle","useEffect","walker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","node","tagName","toLowerCase","FILTER_ACCEPT","FILTER_REJECT","nodes","nextNode","push","currentNode","i","length","Promise","resolve","script","createElement","textContent","Array","from","attributes","forEach","name","value","setAttribute","onload","onerror","parentNode","insertBefore","removeChild","hasAttribute","catch","error","console","className","useStyle","minHeight","cx","__html"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAMA,cAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBrB,MAAMC,aAAa;AAEbC,MAAAA,QAAQC,MAAAA,WAAW,gBACvB;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAOC;AAAAA,EAAQC,OAAOP;AAAAA,GAC5BQ,KACA;AACA,QAAM,CAACC,WAAWC,gBAAgBC,MAAAA,SAAgC,IAAxB;AACpC,QAAA,CAACC,cAAcC,mBAAmBF,MAAAA,SAAS,KAAD;AAEhDG,4BAAAA,0BAA0B,MAAM;AAC9BD,oBAAgB,IAAD;AAAA,EADQ,GAEtB,CAFsB,CAAA;AAIzBE,QAAAA,oBAAoBP,KAAK,MAAMC,WAAW,CAACA,SAAD,CAAvB;AAEnBO,QAAAA,UAAU,MAAM;AAGV,QAAA,CAACP;AAAW;AAEhB,UAAMQ,SAASR,UAAUS,cAAcC,iBAAiBV,WAAWW,WAAWC,cAAc;AAAA,MAC1FC,WAAWC,MAAe;AACxB,eAAOA,KAAKC,QAAQC,kBAAkBxB,aAClCmB,WAAWM,gBACXN,WAAWO;AAAAA,MAChB;AAAA,IAAA,CALY;AAQf,UAAMC,QAAmB,CAAA;AAEzB,WAAOX,OAAOY,SAAP;AAAyBC,YAAAA,KAAKb,OAAOc;AAOL,2CAAA;AACrC,eAASC,IAAI,GAAGA,IAAIJ,MAAMK,QAAQD,KAAK;AAC/B,cAAA,IAAIE,QAAcC,CAAW,YAAA;;AACjC,gBAAMZ,OAAOK,MAAMI;AACbI,gBAAAA,SAASb,KAAKL,cAAcmB,cAAcpC,UAAjC;AAEfmC,iBAAOE,cAAcf,KAAKe;AAC1BC,gBAAMC,KAAKjB,KAAKkB,UAAhB,EAA4BC,QAAQ,CAAC;AAAA,YAAEC;AAAAA,YAAMC;AAAAA,gBAAY;AAChDC,mBAAAA,aAAaF,MAAMC,KAA1B;AAAA,UAAA,CADF;AAIOE,iBAAAA,SAAS,MAAMX;AACfY,iBAAAA,UAAU,MAAMZ;AAElBa,qBAAAA,eAAAA,mBAAYC,aAAab,QAAQb;AACjCyB,qBAAAA,eAAAA,mBAAYE,YAAY3B;AAEzB,cAAA,CAACa,OAAOe,aAAa,KAApB;AAAmC;QAAA,CAfpC;AAAA,MAiBP;AAAA,IACF;AAEoB,0BAAA,EAAGC,MAAMC,CAAS,UAAA;AAErCC,cAAQD,MAAMA,KAAd;AAAA,IAAA,CAFF;AAAA,EAAA,GAIC,CAAC5C,WAAWF,IAAZ,CAhDM;AAkDHgD,QAAAA,YAAYC,UAAAA,SAAS;AAAA,IAAEC,WAAW;AAAA,EAAA,CAAd;AAE1B,MAAI7C,iBAAiB;AAAc,WAAA;AAGjC,wCAAA,OAAA;AAAA,IACE,KAAKF;AAAAA,IACL;AAAA,IACA,WAAWgD,IAAAA,GAAGH,WAAWlD,OAAOC,MAAnB;AAAA,IACb,yBAAyB;AAAA,MAAEqD,QAAQpD;AAAAA,IAAV;AAAA,EAAA,CAL7B;AAQD,CA3EuB;;"}
|
package/dist/Embed.es.js
CHANGED
|
@@ -1,42 +1,17 @@
|
|
|
1
1
|
import { forwardRef, useState, useImperativeHandle, useEffect } from "react";
|
|
2
2
|
import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Z as useStyle } from "./react-page.es.js";
|
|
4
4
|
import { cx } from "@emotion/css";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import "use-sync-external-store/shim/with-selector";
|
|
7
|
-
import "next/dynamic";
|
|
8
|
-
import "./react-page.es.js";
|
|
9
6
|
import "redux";
|
|
10
7
|
import "redux-thunk";
|
|
11
8
|
import "./actions.es.js";
|
|
12
9
|
import "./state/breakpoints.es.js";
|
|
10
|
+
import "@emotion/serialize";
|
|
11
|
+
import "@emotion/utils";
|
|
13
12
|
import "slate";
|
|
14
13
|
import "is-hotkey";
|
|
15
14
|
import "slate-react";
|
|
16
|
-
import "@emotion/serialize";
|
|
17
|
-
import "@emotion/utils";
|
|
18
|
-
import "./text-input.es.js";
|
|
19
|
-
import "./combobox.es.js";
|
|
20
|
-
import "./select.es.js";
|
|
21
|
-
import "use-sync-external-store/shim";
|
|
22
|
-
import "./types.es.js";
|
|
23
|
-
import "./box-models.es.js";
|
|
24
|
-
import "css-box-model";
|
|
25
|
-
import "color";
|
|
26
|
-
import "scroll-into-view-if-needed";
|
|
27
|
-
import "react-dom";
|
|
28
|
-
import "html-react-parser";
|
|
29
|
-
import "next/head";
|
|
30
|
-
import "@emotion/server/create-instance";
|
|
31
|
-
import "next/document";
|
|
32
|
-
import "cors";
|
|
33
|
-
import "path-to-regexp";
|
|
34
|
-
import "cookie";
|
|
35
|
-
import "http-proxy";
|
|
36
|
-
import "set-cookie-parser";
|
|
37
|
-
import "./constants.es.js";
|
|
38
|
-
import "uuid";
|
|
39
|
-
import "corporate-ipsum";
|
|
40
15
|
const defaultHtml = `<div style="padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;">
|
|
41
16
|
<svg width="316" height="168" viewBox="0 0 316 168" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
42
17
|
<rect width="70" height="8" rx="2" fill="#A1A8C2" fill-opacity="0.5"/>
|
package/dist/Embed.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.es.js","sources":["../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { ElementIDValue, TextAreaValue } from '../../../prop-controllers/descriptors'\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: ElementIDValue\n html?: TextAreaValue\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle(ref, () => container, [container])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n )\n})\n\nexport default Embed\n"],"names":["defaultHtml","SCRIPT_TAG","Embed","forwardRef","id","width","margin","html","ref","container","setContainer","useState","shouldRender","setShouldRender","useIsomorphicLayoutEffect","useImperativeHandle","useEffect","walker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","node","tagName","toLowerCase","FILTER_ACCEPT","FILTER_REJECT","nodes","nextNode","push","currentNode","i","length","Promise","resolve","script","createElement","textContent","Array","from","attributes","forEach","name","value","setAttribute","onload","onerror","parentNode","insertBefore","removeChild","hasAttribute","catch","error","console","className","useStyle","minHeight","cx","__html"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Embed.es.js","sources":["../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { ElementIDValue, TextAreaValue } from '../../../prop-controllers/descriptors'\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: ElementIDValue\n html?: TextAreaValue\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle(ref, () => container, [container])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n )\n})\n\nexport default Embed\n"],"names":["defaultHtml","SCRIPT_TAG","Embed","forwardRef","id","width","margin","html","ref","container","setContainer","useState","shouldRender","setShouldRender","useIsomorphicLayoutEffect","useImperativeHandle","useEffect","walker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","node","tagName","toLowerCase","FILTER_ACCEPT","FILTER_REJECT","nodes","nextNode","push","currentNode","i","length","Promise","resolve","script","createElement","textContent","Array","from","attributes","forEach","name","value","setAttribute","onload","onerror","parentNode","insertBefore","removeChild","hasAttribute","catch","error","console","className","useStyle","minHeight","cx","__html"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAMA,cAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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