@pushwoosh/dumb-components 2.9.7 → 2.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/Calendar/CalendarMonth/styles.js +2 -2
  2. package/Calendar/__tests__/CellBox.test.d.ts +1 -0
  3. package/Calendar/__tests__/CellBox.test.js +34 -0
  4. package/RichMessageEditor/{EditorEmojiPicker.js → EditorEmojiPicker/EditorEmojiPicker.js} +3 -3
  5. package/RichMessageEditor/EditorEmojiPicker/index.d.ts +1 -0
  6. package/RichMessageEditor/EditorEmojiPicker/index.js +1 -0
  7. package/RichMessageEditor/{EditorEmojiPicker.styles.js → EditorEmojiPicker/styles.js} +1 -1
  8. package/RichMessageEditor/RichMessageEditor.js +1 -1
  9. package/RichMessageEditor/slate/SlateEditor.js +1 -1
  10. package/RichMessageEditor/slate/{SlateEditor.styles.js → styles.js} +1 -1
  11. package/RichMessageEditor/{RichMessageEditor.styles.js → styles.js} +4 -4
  12. package/Skeleton/__tests__/Skeleton.test.d.ts +1 -0
  13. package/Skeleton/__tests__/Skeleton.test.js +56 -0
  14. package/Skeleton/styles.js +4 -0
  15. package/package.json +1 -1
  16. /package/RichMessageEditor/{EditorEmojiPicker.d.ts → EditorEmojiPicker/EditorEmojiPicker.d.ts} +0 -0
  17. /package/RichMessageEditor/{EditorEmojiPicker.helpers.d.ts → EditorEmojiPicker/EditorEmojiPicker.helpers.d.ts} +0 -0
  18. /package/RichMessageEditor/{EditorEmojiPicker.helpers.js → EditorEmojiPicker/EditorEmojiPicker.helpers.js} +0 -0
  19. /package/RichMessageEditor/{EditorEmojiPicker.styles.d.ts → EditorEmojiPicker/styles.d.ts} +0 -0
  20. /package/RichMessageEditor/slate/{SlateEditor.styles.d.ts → styles.d.ts} +0 -0
  21. /package/RichMessageEditor/{RichMessageEditor.styles.d.ts → styles.d.ts} +0 -0
@@ -8,8 +8,8 @@ const periodToCss = css(["border-top-left-radius:0;border-bottom-left-radius:0;"
8
8
  const disabledCss = css(["font-weight:", ";color:", ";border:1px solid ", ";background:linear-gradient( to top left,rgba(0,0,0,0) 0%,rgba(0,0,0,0) calc(50% - 0.8px),", " 50%,rgba(0,0,0,0) calc(50% + 0.8px),rgba(0,0,0,0) 100% );pointer-events:none;"], FontWeight.REGULAR, Color.PHANTOM, Color.DIVIDER, Color.DIVIDER);
9
9
  const outdatedCss = css(["opacity:0;pointer-events:none;"]);
10
10
  const highlightedCss = css(["outline:1px solid ", ";"], Color.SOFT_LIGHT);
11
- const periodCss = css(["position:relative;z-index:0;:before{content:'';position:absolute;top:0;left:-1px;right:-1px;bottom:0;background:", ";z-index:-1;}"], Color.SOFT_LIGHT);
12
- const periodOutdatedCss = css(["position:relative;z-index:0;color:transparent;pointer-events:none;:before{content:'';position:absolute;top:0;left:-1px;right:-1px;bottom:0;background:", ";z-index:-1;}"], Color.SOFT_LIGHT);
11
+ const periodCss = css(["position:relative;z-index:0;&:before{content:'';position:absolute;top:0;left:-1px;right:-1px;bottom:0;background:", ";z-index:-1;}"], Color.SOFT_LIGHT);
12
+ const periodOutdatedCss = css(["position:relative;z-index:0;color:transparent;pointer-events:none;&:before{content:'';position:absolute;top:0;left:-1px;right:-1px;bottom:0;background:", ";z-index:-1;}"], Color.SOFT_LIGHT);
13
13
  const cssMap = {
14
14
  selected: selectedCss,
15
15
  selectedDisabled: selectedDisabledCss,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen } from '@testing-library/react';
3
+ import { CellBox } from '../CalendarMonth/styles';
4
+ const PERIOD_VARIANTS = ['period', 'periodOutdated'];
5
+ function variantCss(variant) {
6
+ const {
7
+ rules
8
+ } = CellBox.componentStyle;
9
+ const flatten = part => {
10
+ if (Array.isArray(part)) return part.map(flatten).join('');
11
+ return typeof part === 'string' ? part : '';
12
+ };
13
+ return rules.filter(rule => typeof rule === 'function').map(rule => flatten(rule({
14
+ $variant: variant
15
+ }))).join('');
16
+ }
17
+ describe('CellBox period variants', () => {
18
+ it.each(PERIOD_VARIANTS)('anchors :before of %s to the cell with &, so stylis 4 does not turn it into a descendant selector', variant => {
19
+ const css = variantCss(variant);
20
+ expect(css).toContain('&:before');
21
+ expect(css).not.toMatch(/(^|[\s;{}])::?before/);
22
+ });
23
+ it.each(PERIOD_VARIANTS)('paints the %s background on the cell pseudo-element', variant => {
24
+ render(_jsx(CellBox, {
25
+ "data-testid": "cell",
26
+ "$variant": variant,
27
+ children: "1"
28
+ }));
29
+ const [className] = [...screen.getByTestId('cell').classList].slice(-1);
30
+ const styles = [...document.querySelectorAll('style')].map(node => node.textContent).join('');
31
+ expect(styles).toMatch(new RegExp(`\\.${className}:before\\{[^}]*background:`));
32
+ expect(styles).not.toContain(`.${className} :before`);
33
+ });
34
+ });
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useRef } from 'react';
3
- import { EditorEmojiPickerStyled } from './EditorEmojiPicker.styles';
4
- import { EmojiPicker } from '../EmojiPicker';
5
- import { useThemeName } from '../hooks';
3
+ import { EditorEmojiPickerStyled } from './styles';
4
+ import { EmojiPicker } from '../../EmojiPicker';
5
+ import { useThemeName } from '../../hooks';
6
6
  export const EditorEmojiPicker = ({
7
7
  onEmojiSelect
8
8
  }) => {
@@ -0,0 +1 @@
1
+ export * from './EditorEmojiPicker';
@@ -0,0 +1 @@
1
+ export * from './EditorEmojiPicker';
@@ -3,7 +3,7 @@ import { Color, getThemeColors, Shadow, ShapeRadius } from '@pushwoosh/kit-const
3
3
  import { rgbChannels } from './EditorEmojiPicker.helpers';
4
4
  export const EditorEmojiPickerStyled = styled.div.withConfig({
5
5
  displayName: "EditorEmojiPickerStyled",
6
- componentId: "sc-1jl3t23-0"
6
+ componentId: "sc-1y0c927-0"
7
7
  })(["min-width:352px;em-emoji-picker{border:1px solid ", ";--border-radius:", ";--shadow:", ";background-color:", ";--rgb-background:", ";}"], Color.FORM, ShapeRadius.CONTROL, Shadow.REGULAR, Color.FROZEN, ({
8
8
  $theme
9
9
  }) => rgbChannels(getThemeColors($theme).FROZEN));
@@ -10,9 +10,9 @@ import EmojiIcon from './assets/EmojiIcon.svg';
10
10
  import PersonalizationIcon from './assets/PersonalizationIcon.svg';
11
11
  import { EditorEmojiPicker } from './EditorEmojiPicker';
12
12
  import { placementToDirection } from './RichMessageEditor.helpers';
13
- import { Arrow, DropArea, DropContent, ImSpan } from './RichMessageEditor.styles';
14
13
  import { getDcByPath } from './slate/helpers';
15
14
  import { SlateEditable, SlateEditor } from './slate/SlateEditor';
15
+ import { Arrow, DropArea, DropContent, ImSpan } from './styles';
16
16
  /**
17
17
  * Slate-based message editor with optional personalization (dynamic-content) tokens
18
18
  * and an emoji picker; serializes to a string via `onChange`. Render the result with
@@ -4,8 +4,8 @@ import { Slate } from 'slate-react';
4
4
  import { usePersistentFunction } from '@pushwoosh/kit-helpers';
5
5
  import { renderElement } from './DynamicContentElement';
6
6
  import { content2string, string2content } from './helpers';
7
- import { EditableStyled } from './SlateEditor.styles';
8
7
  import { createMKEditor } from './SlateEditor.utils';
8
+ import { EditableStyled } from './styles';
9
9
  export const SlateEditor = ({
10
10
  initialValue: initialValueString,
11
11
  onChange,
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
  import { Color, FontSize, FontWeight, ShapeRadius } from '@pushwoosh/kit-constants';
4
4
  export const EditableStyled = styled(Editable).withConfig({
5
5
  displayName: "EditableStyled",
6
- componentId: "sc-13jikil-0"
6
+ componentId: "sc-16lukqt-0"
7
7
  })(["font-weight:", ";font-size:", ";line-height:140%;padding:8px;color:", ";background:", ";caret-color:", ";border:1px solid ", ";border-radius:", ";overflow-x:auto;& [data-slate-placeholder='true']{color:", ";opacity:1 !important;}&:focus{border-color:", ";outline:none;}& > p{position:relative;margin:4px 0;&:first-child{margin-top:0;}&:last-child{margin-bottom:0;}}"], FontWeight.REGULAR, FontSize.REGULAR, Color.MAIN, Color.CLEAR, Color.BRIGHT, ({
8
8
  $isErrored
9
9
  }) => $isErrored ? Color.DANGER : Color.FORM, ShapeRadius.CONTROL, Color.PHANTOM, Color.BRIGHT);
@@ -3,15 +3,15 @@ import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
3
3
  import { Horizontal } from '@pushwoosh/kit-helpers';
4
4
  export const ImSpan = styled.span.withConfig({
5
5
  displayName: "ImSpan",
6
- componentId: "sc-1l3r9n8-0"
6
+ componentId: "sc-1n9vpwc-0"
7
7
  })(["color:", ";position:relative;padding-left:20px;font-size:12px;font-style:normal;font-weight:500;line-height:130%;text-transform:uppercase;cursor:pointer;> svg{position:absolute;left:0;top:-1px;}"], Color.SOFT);
8
8
  export const DropArea = styled.div.withConfig({
9
9
  displayName: "DropArea",
10
- componentId: "sc-1l3r9n8-1"
10
+ componentId: "sc-1n9vpwc-1"
11
11
  })(["z-index:1000;"]);
12
12
  export const DropContent = styled.div.withConfig({
13
13
  displayName: "DropContent",
14
- componentId: "sc-1l3r9n8-2"
14
+ componentId: "sc-1n9vpwc-2"
15
15
  })(["border:1px solid ", ";border-radius:", ";box-shadow:", ";background-color:", ";"], Color.FORM, ShapeRadius.CONTROL, Shadow.REGULAR, Color.FROZEN);
16
16
  const transforms = {
17
17
  left: 'scaleX(-1)',
@@ -23,7 +23,7 @@ export const Arrow = styled(Horizontal).attrs({
23
23
  $placeItems: 'center'
24
24
  }).withConfig({
25
25
  displayName: "Arrow",
26
- componentId: "sc-1l3r9n8-3"
26
+ componentId: "sc-1n9vpwc-3"
27
27
  })(["position:absolute;width:20px;height:20px;transform:", " translateX(11px);", ":0;"], ({
28
28
  $direction
29
29
  }) => transforms[$direction], ({
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen } from '@testing-library/react';
3
+ import { CircularSkeleton, RectangularSkeleton } from '../styles';
4
+ describe('RectangularSkeleton', () => {
5
+ it('keeps style props off the DOM and still paints them', () => {
6
+ render(_jsx(RectangularSkeleton, {
7
+ "data-testid": "rect",
8
+ width: 120,
9
+ height: 16,
10
+ color: "red",
11
+ borderRadius: 4
12
+ }));
13
+ const node = screen.getByTestId('rect');
14
+ expect(node).not.toHaveAttribute('width');
15
+ expect(node).not.toHaveAttribute('height');
16
+ expect(node).not.toHaveAttribute('color');
17
+ expect(node).not.toHaveAttribute('borderradius');
18
+ expect(getComputedStyle(node)).toMatchObject({
19
+ width: '120px',
20
+ height: '16px',
21
+ backgroundColor: 'rgb(255, 0, 0)',
22
+ borderRadius: '4px'
23
+ });
24
+ });
25
+ it('still forwards regular attributes', () => {
26
+ render(_jsx(RectangularSkeleton, {
27
+ "data-testid": "rect",
28
+ title: "loading",
29
+ "aria-busy": "true",
30
+ width: 1,
31
+ height: 1
32
+ }));
33
+ const node = screen.getByTestId('rect');
34
+ expect(node).toHaveAttribute('title', 'loading');
35
+ expect(node).toHaveAttribute('aria-busy', 'true');
36
+ });
37
+ });
38
+ describe('CircularSkeleton', () => {
39
+ it('keeps style props off the DOM and still paints them', () => {
40
+ render(_jsx(CircularSkeleton, {
41
+ "data-testid": "circle",
42
+ "aria-label": "avatar",
43
+ diameter: 32,
44
+ color: "red"
45
+ }));
46
+ const node = screen.getByTestId('circle');
47
+ expect(node).not.toHaveAttribute('diameter');
48
+ expect(node).not.toHaveAttribute('color');
49
+ expect(node).toHaveAttribute('aria-label', 'avatar');
50
+ expect(getComputedStyle(node)).toMatchObject({
51
+ width: '32px',
52
+ height: '32px',
53
+ backgroundColor: 'rgb(255, 0, 0)'
54
+ });
55
+ });
56
+ });
@@ -15,6 +15,8 @@ const skeletonCommonCss = css(["background-color:", ";animation:", " 1.5s ease-i
15
15
  }) => !color && accentCycleCss);
16
16
  /** Pulsing rectangular loading placeholder of a fixed `width`/`height`. */
17
17
  export const RectangularSkeleton = styled.div.withConfig({
18
+ shouldForwardProp: prop => !['width', 'height', 'color', 'borderRadius'].includes(prop)
19
+ }).withConfig({
18
20
  displayName: "RectangularSkeleton",
19
21
  componentId: "sc-mdyfd6-0"
20
22
  })(["width:", ";height:", ";", " ", ""], ({
@@ -24,6 +26,8 @@ export const RectangularSkeleton = styled.div.withConfig({
24
26
  }) => toCssValue(height), skeletonCommonCss, borderRadiusCss);
25
27
  /** Pulsing circular loading placeholder of a given `diameter` (e.g. for avatars). */
26
28
  export const CircularSkeleton = styled.div.withConfig({
29
+ shouldForwardProp: prop => !['diameter', 'color'].includes(prop)
30
+ }).withConfig({
27
31
  displayName: "CircularSkeleton",
28
32
  componentId: "sc-mdyfd6-1"
29
33
  })(["width:", ";height:", ";border-radius:100%;", ""], ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "2.9.7",
3
+ "version": "2.9.9",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",