@pushwoosh/dumb-components 1.1.14 → 1.1.16

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/Radio/Radio.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import React, { useState } from 'react';
2
- import { NativeLabel, NativeRadio } from './styles';
2
+ import { Color } from '@pushwoosh/kit-constants';
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';
3
7
  let counter = 0;
4
8
  export function Radio(props) {
5
9
  const {
@@ -7,10 +11,11 @@ export function Radio(props) {
7
11
  id,
8
12
  name,
9
13
  value,
10
- color,
14
+ type = 'normal',
11
15
  isChecked,
12
16
  isDisabled,
13
- size = 'normal',
17
+ tooltip,
18
+ size = 'regular',
14
19
  onChange,
15
20
  onBlur
16
21
  } = props;
@@ -21,10 +26,14 @@ export function Radio(props) {
21
26
  const newCounter = counter++;
22
27
  return `radio-id-${newCounter}`;
23
28
  });
24
- return React.createElement(NativeLabel, {
29
+ const radioMarkup = React.createElement(NativeLabel, {
25
30
  htmlFor: localId,
26
- "$color": isDisabled ? 'locked' : color,
31
+ "$color": isDisabled ? Color.LOCKED : Color.MAIN,
27
32
  "$size": size
33
+ }, React.createElement(InputContainer, {
34
+ "$size": size,
35
+ "$alignItems": "center",
36
+ "$justifyContent": "center"
28
37
  }, React.createElement(NativeRadio, {
29
38
  type: "radio",
30
39
  id: localId,
@@ -33,7 +42,23 @@ export function Radio(props) {
33
42
  checked: isChecked,
34
43
  disabled: isDisabled,
35
44
  "$size": size,
45
+ "$type": type,
36
46
  onChange: event => onChange === null || onChange === void 0 ? void 0 : onChange(event.currentTarget.value),
37
47
  onBlur: onBlur
38
- }), 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;
39
64
  }
@@ -0,0 +1,5 @@
1
+ import { type RadioType } from './types';
2
+ export declare const ColorByType: Record<RadioType, {
3
+ checked: string;
4
+ notChecked: string;
5
+ }>;
@@ -0,0 +1,11 @@
1
+ import { Color } from '@pushwoosh/kit-constants';
2
+ export const ColorByType = {
3
+ normal: {
4
+ checked: Color.PRIMARY,
5
+ notChecked: Color.PHANTOM
6
+ },
7
+ error: {
8
+ checked: Color.DANGER,
9
+ notChecked: Color.DANGER
10
+ }
11
+ };
package/Radio/styles.d.ts CHANGED
@@ -1,8 +1,67 @@
1
- import type { RadioSize, RadioTextColor } from './types';
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;
62
+ $type: RadioType;
4
63
  }, never>;
5
64
  export declare const NativeLabel: import("styled-components").StyledComponent<"label", any, {
6
- $color?: RadioTextColor;
65
+ $color: string;
7
66
  $size: RadioSize;
8
67
  }, never>;
package/Radio/styles.js CHANGED
@@ -1,23 +1,56 @@
1
+ import { rgba } from 'polished';
1
2
  import styled from 'styled-components';
2
- import { Color, Spacing, FontSize, LineHeight } from '@pushwoosh/kit-constants';
3
- import { ColorMap } from './maps';
3
+ import { Color, FontSize, LineHeight } from '@pushwoosh/kit-constants';
4
+ import { Horizontal } from '@pushwoosh/kit-helpers';
5
+ import { ColorByType } from './mappers';
6
+ export const InputContainer = styled(Horizontal).withConfig({
7
+ displayName: "InputContainer",
8
+ componentId: "sc-34lgtl-0"
9
+ })(["width:", ";height:", ";"], ({
10
+ $size
11
+ }) => $size === 'compact' ? '16px' : '24px', ({
12
+ $size
13
+ }) => $size === 'compact' ? '16px' : '24px');
4
14
  export const NativeRadio = styled.input.withConfig({
5
15
  displayName: "NativeRadio",
6
- componentId: "sc-34lgtl-0"
7
- })(["appearance:none;-webkit-appearance:none;-moz-appearance:none;width:", ";height:", ";border:", ";border-radius:50%;background-color:", ";transition:border 0.1s,background-color 0.1s;cursor:pointer;&:focus{outline:none;}&[type=radio]:hover{border-color:", ";}&[type=radio]:disabled{cursor:not-allowed;border-color:", ";background-color:", ";}&[type=radio]:checked{border:", ";}&[type=radio]:checked:hover{border-color:", ";}&[type=radio]:checked:disabled{border-color:", ";background-color:", ";}"], ({
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', ({
8
22
  $size
9
- }) => $size === 'compact' ? '12px' : '20px', ({
23
+ }) => $size === 'compact' ? '1px' : '2px', ({
24
+ $type
25
+ }) => `2px solid ${ColorByType[$type].notChecked}`, Color.CLEAR, Color.FORM, ({
10
26
  $size
11
- }) => $size === 'compact' ? '12px' : '20px', ({
27
+ }) => `${$size === 'compact' ? '4px' : '6px'} solid ${Color.LOCKED}`, Color.LOCKED, Color.FORM, ({
28
+ $size,
29
+ $type
30
+ }) => `${$size === 'compact' ? '4px' : '6px'} solid ${ColorByType[$type].checked}`, Color.CLEAR, ({
31
+ $type
32
+ }) => rgba(ColorByType[$type].notChecked, 0.3), ({
12
33
  $size
13
- }) => `${$size === 'compact' ? '1px' : '2px'} solid ${Color.PHANTOM}`, Color.CLEAR, Color.PRIMARY_HOVER, Color.LOCKED, Color.FROZEN, ({
34
+ }) => $size === 'compact' ? '3px' : '4px', ({
14
35
  $size
15
- }) => `${$size === 'compact' ? '4px' : '6px'} solid ${Color.PRIMARY}`, Color.PRIMARY_HOVER, Color.LOCKED, Color.FROZEN);
36
+ }) => $size === 'compact' ? '3px' : '4px', ({
37
+ $size
38
+ }) => $size === 'compact' ? '4px' : '8px', ({
39
+ $size
40
+ }) => $size === 'compact' ? '4px' : '8px');
16
41
  export const NativeLabel = styled.label.withConfig({
17
42
  displayName: "NativeLabel",
18
- componentId: "sc-34lgtl-1"
19
- })(["display:inline-flex;align-items:center;font-size:", ";line-height:", ";user-select:none;", " & > ", "{&:not(:last-child){margin-right:", ";}}"], ({
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:", ";}"], ({
45
+ $size
46
+ }) => $size === 'compact' ? FontSize.SMALL : FontSize.REGULAR, ({
20
47
  $size
21
- }) => $size === 'compact' ? FontSize.SMALL : FontSize.REGULAR, LineHeight.REGULAR, ({
48
+ }) => $size === 'compact' ? LineHeight.SMALL : LineHeight.REGULAR, ({
49
+ $size
50
+ }) => $size === 'compact' ? '600px' : '800px', ({
22
51
  $color
23
- }) => $color && `color: ${ColorMap[$color]};`, NativeRadio, Spacing.S3);
52
+ }) => `color: ${$color};`, InputContainer, ({
53
+ $size
54
+ }) => $size === 'compact' ? '6px' : '8px', ({
55
+ $size
56
+ }) => $size === 'compact' ? '0px' : '2px 0');
package/Radio/types.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- export type RadioTextColor = 'main' | 'primary' | 'danger' | 'current' | 'locked';
2
- export type RadioSize = 'normal' | 'compact';
1
+ export type RadioType = 'normal' | 'error';
2
+ export type RadioSize = 'regular' | 'compact';
3
3
  export type RadioProps = {
4
4
  label?: string;
5
5
  id?: string;
6
6
  name?: string;
7
7
  value?: string;
8
- color?: RadioTextColor;
8
+ type?: RadioType;
9
9
  isChecked?: boolean;
10
10
  isDisabled?: boolean;
11
11
  size?: RadioSize;
12
+ tooltip?: string;
12
13
  onChange?: (checked: string | number) => void;
13
14
  onBlur?: () => void;
14
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
package/Radio/maps.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Color } from '@pushwoosh/kit-constants';
2
- import type { RadioTextColor } from './types';
3
- export declare const ColorMap: Record<RadioTextColor, Color>;
package/Radio/maps.js DELETED
@@ -1,8 +0,0 @@
1
- import { Color } from '@pushwoosh/kit-constants';
2
- export const ColorMap = {
3
- main: Color.MAIN,
4
- primary: Color.PRIMARY,
5
- danger: Color.DANGER,
6
- current: Color.CURRENT,
7
- locked: Color.LOCKED
8
- };