@pushwoosh/dumb-components 1.1.15 → 1.1.17
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/EmailTemplatePreview/helpers.js +2 -2
- package/Radio/Radio.js +26 -3
- package/Radio/styles.d.ts +58 -0
- package/Radio/styles.js +27 -14
- package/Radio/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export function replaceLocalization(str, values) {
|
|
2
|
-
const re = /{{([
|
|
2
|
+
const re = /{{([^|{}]+)\|(text|html|color)\|([^}]*)?}}/g;
|
|
3
3
|
return str.replace(re, (_, key, _type, defaultValue) => {
|
|
4
4
|
return (key in values ? values[key] : defaultValue) || '';
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
7
|
export function replacePlaceholders(str, values) {
|
|
8
8
|
const allAvailableModifiers = ['CapitalizeFirst', 'CapitalizeAllFirst', 'UPPERCASE', 'lowercase', 'regular', 'cent', 'dollar', 'comma', 'euro', 'jpy', 'lira', 'M-d-y', 'm-d-y', 'M d y', 'M d Y', 'l', 'M d', 'H:i', 'm-d-y H:i'];
|
|
9
|
-
const re = new RegExp(`{([
|
|
9
|
+
const re = new RegExp(`{([^|{}]{1,64})\\|(${allAvailableModifiers.join('|')})(?:\\|([^}]*))?}`, 'g');
|
|
10
10
|
return str.replace(re, (_, key, _modifier, defaultValue) => {
|
|
11
11
|
return (key in values ? values[key] : defaultValue) || '';
|
|
12
12
|
});
|
package/Radio/Radio.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
-
import {
|
|
3
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { HelpRoundIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { InputContainer, NativeLabel, NativeRadio } from './styles';
|
|
6
|
+
import { Tooltip } from '../Tooltip';
|
|
4
7
|
let counter = 0;
|
|
5
8
|
export function Radio(props) {
|
|
6
9
|
const {
|
|
@@ -11,6 +14,7 @@ export function Radio(props) {
|
|
|
11
14
|
type = 'normal',
|
|
12
15
|
isChecked,
|
|
13
16
|
isDisabled,
|
|
17
|
+
tooltip,
|
|
14
18
|
size = 'regular',
|
|
15
19
|
onChange,
|
|
16
20
|
onBlur
|
|
@@ -22,10 +26,14 @@ export function Radio(props) {
|
|
|
22
26
|
const newCounter = counter++;
|
|
23
27
|
return `radio-id-${newCounter}`;
|
|
24
28
|
});
|
|
25
|
-
|
|
29
|
+
const radioMarkup = React.createElement(NativeLabel, {
|
|
26
30
|
htmlFor: localId,
|
|
27
31
|
"$color": isDisabled ? Color.LOCKED : Color.MAIN,
|
|
28
32
|
"$size": size
|
|
33
|
+
}, React.createElement(InputContainer, {
|
|
34
|
+
"$size": size,
|
|
35
|
+
"$alignItems": "center",
|
|
36
|
+
"$justifyContent": "center"
|
|
29
37
|
}, React.createElement(NativeRadio, {
|
|
30
38
|
type: "radio",
|
|
31
39
|
id: localId,
|
|
@@ -37,5 +45,20 @@ export function Radio(props) {
|
|
|
37
45
|
"$type": type,
|
|
38
46
|
onChange: event => onChange === null || onChange === void 0 ? void 0 : onChange(event.currentTarget.value),
|
|
39
47
|
onBlur: onBlur
|
|
40
|
-
}), label && React.createElement("span", null, label));
|
|
48
|
+
})), label && React.createElement("span", null, label));
|
|
49
|
+
if (tooltip) {
|
|
50
|
+
return React.createElement(Horizontal, {
|
|
51
|
+
"$gap": 4,
|
|
52
|
+
"$alignItems": "start"
|
|
53
|
+
}, radioMarkup, React.createElement(Tooltip, {
|
|
54
|
+
content: tooltip
|
|
55
|
+
}, React.createElement(Horizontal, {
|
|
56
|
+
"$padding": size === 'compact' ? 0 : '4px 0'
|
|
57
|
+
}, React.createElement(HelpRoundIcon, {
|
|
58
|
+
size: "small",
|
|
59
|
+
view: "lined",
|
|
60
|
+
color: Color.PHANTOM
|
|
61
|
+
}))));
|
|
62
|
+
}
|
|
63
|
+
return radioMarkup;
|
|
41
64
|
}
|
package/Radio/styles.d.ts
CHANGED
|
@@ -1,4 +1,62 @@
|
|
|
1
1
|
import type { RadioSize, RadioType } from './types';
|
|
2
|
+
export declare const InputContainer: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
4
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
5
|
+
$bgColor?: string | undefined;
|
|
6
|
+
$border?: string | ({
|
|
7
|
+
top?: string | undefined;
|
|
8
|
+
right?: string | undefined;
|
|
9
|
+
bottom?: string | undefined;
|
|
10
|
+
left?: string | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
horizontal: string;
|
|
13
|
+
top?: string | undefined;
|
|
14
|
+
bottom?: string | undefined;
|
|
15
|
+
} | {
|
|
16
|
+
vertical: string;
|
|
17
|
+
right?: string | undefined;
|
|
18
|
+
left?: string | undefined;
|
|
19
|
+
}) | undefined;
|
|
20
|
+
$borderRadius?: (string | number) | undefined;
|
|
21
|
+
$boxShadow?: string | undefined;
|
|
22
|
+
$gap?: (string | number) | undefined;
|
|
23
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
24
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
25
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
26
|
+
$margin?: (string | number) | ({
|
|
27
|
+
top?: (string | number) | undefined;
|
|
28
|
+
right?: (string | number) | undefined;
|
|
29
|
+
bottom?: (string | number) | undefined;
|
|
30
|
+
left?: (string | number) | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
horizontal: string | number;
|
|
33
|
+
top?: (string | number) | undefined;
|
|
34
|
+
bottom?: (string | number) | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
vertical: string | number;
|
|
37
|
+
right?: (string | number) | undefined;
|
|
38
|
+
left?: (string | number) | undefined;
|
|
39
|
+
}) | undefined;
|
|
40
|
+
$padding?: (string | number) | ({
|
|
41
|
+
top?: (string | number) | undefined;
|
|
42
|
+
right?: (string | number) | undefined;
|
|
43
|
+
bottom?: (string | number) | undefined;
|
|
44
|
+
left?: (string | number) | undefined;
|
|
45
|
+
} | {
|
|
46
|
+
horizontal: string | number;
|
|
47
|
+
top?: (string | number) | undefined;
|
|
48
|
+
bottom?: (string | number) | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
vertical: string | number;
|
|
51
|
+
right?: (string | number) | undefined;
|
|
52
|
+
left?: (string | number) | undefined;
|
|
53
|
+
}) | undefined;
|
|
54
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
55
|
+
} & {
|
|
56
|
+
$gridAutoFlow: string;
|
|
57
|
+
} & {
|
|
58
|
+
$size: RadioSize;
|
|
59
|
+
}, "$gridAutoFlow">;
|
|
2
60
|
export declare const NativeRadio: import("styled-components").StyledComponent<"input", any, {
|
|
3
61
|
$size: RadioSize;
|
|
4
62
|
$type: RadioType;
|
package/Radio/styles.js
CHANGED
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
import { rgba } from 'polished';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { Color, FontSize, LineHeight } from '@pushwoosh/kit-constants';
|
|
4
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
5
|
import { ColorByType } from './mappers';
|
|
5
|
-
export const
|
|
6
|
-
displayName: "
|
|
6
|
+
export const InputContainer = styled(Horizontal).withConfig({
|
|
7
|
+
displayName: "InputContainer",
|
|
7
8
|
componentId: "sc-34lgtl-0"
|
|
8
|
-
})(["
|
|
9
|
+
})(["width:", ";height:", ";"], ({
|
|
9
10
|
$size
|
|
10
11
|
}) => $size === 'compact' ? '16px' : '24px', ({
|
|
11
12
|
$size
|
|
12
|
-
}) => $size === 'compact' ? '16px' : '24px'
|
|
13
|
+
}) => $size === 'compact' ? '16px' : '24px');
|
|
14
|
+
export const NativeRadio = styled.input.withConfig({
|
|
15
|
+
displayName: "NativeRadio",
|
|
16
|
+
componentId: "sc-34lgtl-1"
|
|
17
|
+
})(["appearance:none;-webkit-appearance:none;-moz-appearance:none;position:relative;width:", ";height:", ";padding:", ";border:", ";border-radius:50%;background-color:", ";transition:border 0.1s,background-color 0.1s;cursor:pointer;&:focus{outline:none;}&[type=radio]:checked:disabled{cursor:not-allowed;background-color:", ";border:", ";}&[type=radio]:not(:checked):disabled{cursor:not-allowed;border-color:", ";background-color:", ";}&[type=radio]:checked{border:", ";background-color:", ";}&[type=radio]:not(:checked):not(:disabled):hover::before{background:", ";content:\"\";position:absolute;top:", ";left:", ";width:", ";height:", ";border-radius:50%;transition:background 0.2s;}"], ({
|
|
18
|
+
$size
|
|
19
|
+
}) => $size === 'compact' ? '14px' : '20px', ({
|
|
20
|
+
$size
|
|
21
|
+
}) => $size === 'compact' ? '14px' : '20px', ({
|
|
22
|
+
$size
|
|
23
|
+
}) => $size === 'compact' ? '1px' : '2px', ({
|
|
13
24
|
$type
|
|
14
25
|
}) => `2px solid ${ColorByType[$type].notChecked}`, Color.CLEAR, Color.FORM, ({
|
|
15
26
|
$size
|
|
16
|
-
}) => `${$size === 'compact' ? '4px' : '
|
|
27
|
+
}) => `${$size === 'compact' ? '4px' : '6px'} solid ${Color.LOCKED}`, Color.LOCKED, Color.FORM, ({
|
|
17
28
|
$size,
|
|
18
29
|
$type
|
|
19
|
-
}) => `${$size === 'compact' ? '4px' : '
|
|
30
|
+
}) => `${$size === 'compact' ? '4px' : '6px'} solid ${ColorByType[$type].checked}`, Color.CLEAR, ({
|
|
20
31
|
$type
|
|
21
32
|
}) => rgba(ColorByType[$type].notChecked, 0.3), ({
|
|
22
33
|
$size
|
|
23
|
-
}) => $size === 'compact' ? '3px' : '
|
|
34
|
+
}) => $size === 'compact' ? '3px' : '4px', ({
|
|
24
35
|
$size
|
|
25
|
-
}) => $size === 'compact' ? '3px' : '
|
|
36
|
+
}) => $size === 'compact' ? '3px' : '4px', ({
|
|
26
37
|
$size
|
|
27
|
-
}) => $size === 'compact' ? '
|
|
38
|
+
}) => $size === 'compact' ? '4px' : '8px', ({
|
|
28
39
|
$size
|
|
29
|
-
}) => $size === 'compact' ? '
|
|
40
|
+
}) => $size === 'compact' ? '4px' : '8px');
|
|
30
41
|
export const NativeLabel = styled.label.withConfig({
|
|
31
42
|
displayName: "NativeLabel",
|
|
32
|
-
componentId: "sc-34lgtl-
|
|
33
|
-
})(["display:inline-flex;align-items:
|
|
43
|
+
componentId: "sc-34lgtl-2"
|
|
44
|
+
})(["display:inline-flex;align-items:start;font-size:", ";line-height:", ";span{max-width:", ";white-space:normal;overflow-wrap:break-word;}user-select:none;", " &:has(input:disabled){cursor:not-allowed;}&:has(input:not(:disabled)){cursor:pointer;}& > ", "{&:not(:last-child){margin-right:", ";}}& > span{padding:", ";}"], ({
|
|
34
45
|
$size
|
|
35
46
|
}) => $size === 'compact' ? FontSize.SMALL : FontSize.REGULAR, ({
|
|
36
47
|
$size
|
|
@@ -38,6 +49,8 @@ export const NativeLabel = styled.label.withConfig({
|
|
|
38
49
|
$size
|
|
39
50
|
}) => $size === 'compact' ? '600px' : '800px', ({
|
|
40
51
|
$color
|
|
41
|
-
}) => `color: ${$color};`,
|
|
52
|
+
}) => `color: ${$color};`, InputContainer, ({
|
|
53
|
+
$size
|
|
54
|
+
}) => $size === 'compact' ? '6px' : '8px', ({
|
|
42
55
|
$size
|
|
43
|
-
}) => $size === 'compact' ? '
|
|
56
|
+
}) => $size === 'compact' ? '0px' : '2px 0');
|
package/Radio/types.d.ts
CHANGED