@pushwoosh/dumb-components 1.1.81 → 1.1.83

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.
@@ -1,3 +1,3 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import type { DatePickerFieldProps } from './types';
3
- export declare function DatePickerField({ value, error, allowedPlacements, zIndex, closeOnSelect, onChange, }: DatePickerFieldProps): ReactElement;
3
+ export declare function DatePickerField(props: DatePickerFieldProps): ReactElement;
@@ -4,14 +4,17 @@ import { CalendarIcon } from '@pushwoosh/kit-icons';
4
4
  import { format, monthName, get } from '../../helpers';
5
5
  import { InputFrame } from '../../styles';
6
6
  import { DatePicker } from '../DatePicker';
7
- export function DatePickerField({
8
- value,
9
- error,
10
- allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
11
- zIndex = 1000,
12
- closeOnSelect = false,
13
- onChange
14
- }) {
7
+ export function DatePickerField(props) {
8
+ const {
9
+ value,
10
+ minDate,
11
+ maxDate,
12
+ error,
13
+ allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
14
+ zIndex = 1000,
15
+ closeOnSelect = false,
16
+ onChange
17
+ } = props;
15
18
  const [showPicker, setShowPicker] = useState(false);
16
19
  const {
17
20
  refs,
@@ -61,6 +64,8 @@ export function DatePickerField({
61
64
  }
62
65
  }, React.createElement(DatePicker, {
63
66
  value: value,
67
+ minDate: minDate,
68
+ maxDate: maxDate,
64
69
  onChange: onSelect
65
70
  })));
66
71
  }
@@ -1,6 +1,8 @@
1
1
  import type { Placement } from '@floating-ui/react-dom';
2
2
  export interface DatePickerFieldProps {
3
3
  value: string;
4
+ minDate?: Date | string;
5
+ maxDate?: Date | string;
4
6
  error?: boolean;
5
7
  allowedPlacements?: Placement[];
6
8
  zIndex?: number;
@@ -6,6 +6,8 @@ import { NumberPicker } from '../NumberPicker';
6
6
  export function DateTimePicker(props) {
7
7
  const {
8
8
  value,
9
+ minDate,
10
+ maxDate,
9
11
  userInputDay,
10
12
  onChange
11
13
  } = props;
@@ -30,6 +32,8 @@ export function DateTimePicker(props) {
30
32
  return React.createElement(DatePicker, {
31
33
  value: format(date, 'year-month-dayThour:minute:second'),
32
34
  userInputDay: userInputDay,
35
+ minDate: minDate,
36
+ maxDate: maxDate,
33
37
  onChange: handleChange,
34
38
  slotAfterMonth: () => React.createElement(Collapse, {
35
39
  expanded: !!value
@@ -1,5 +1,7 @@
1
1
  export interface DateTimePickerProps {
2
2
  value: string;
3
+ minDate?: Date | string;
4
+ maxDate?: Date | string;
3
5
  userInputDay?: string;
4
6
  onChange: (day: string) => void;
5
7
  }
@@ -1,3 +1,3 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import type { DateTimePickerFieldProps } from './types';
3
- export declare function DateTimePickerField({ value, error, allowedPlacements, zIndex, closeOnSelect, onChange, }: DateTimePickerFieldProps): ReactElement;
3
+ export declare function DateTimePickerField(props: DateTimePickerFieldProps): ReactElement;
@@ -4,14 +4,17 @@ import { CalendarIcon } from '@pushwoosh/kit-icons';
4
4
  import { useUTCDate } from './helpers';
5
5
  import { InputFrame } from '../../styles';
6
6
  import { DateTimePicker } from '../DateTimePicker';
7
- export function DateTimePickerField({
8
- value,
9
- error,
10
- allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
11
- zIndex = 1000,
12
- closeOnSelect = false,
13
- onChange
14
- }) {
7
+ export function DateTimePickerField(props) {
8
+ const {
9
+ value,
10
+ minDate,
11
+ maxDate,
12
+ error,
13
+ allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
14
+ zIndex = 1000,
15
+ closeOnSelect = false,
16
+ onChange
17
+ } = props;
15
18
  const [showPicker, setShowPicker] = useState(false);
16
19
  const {
17
20
  refs,
@@ -68,6 +71,8 @@ export function DateTimePickerField({
68
71
  }
69
72
  }, React.createElement(DateTimePicker, {
70
73
  value: value,
74
+ minDate: minDate,
75
+ maxDate: maxDate,
71
76
  onChange: onSelect
72
77
  })));
73
78
  }
@@ -1,6 +1,8 @@
1
1
  import type { Placement } from '@floating-ui/react-dom';
2
2
  export interface DateTimePickerFieldProps {
3
3
  value: string;
4
+ minDate?: Date | string;
5
+ maxDate?: Date | string;
4
6
  error?: boolean;
5
7
  allowedPlacements?: Placement[];
6
8
  zIndex?: number;
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ExternalImagePreviewProps } from './types';
3
+ export declare function ExternalImagePreview(props: ExternalImagePreviewProps): ReactElement;
@@ -0,0 +1,50 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Color } from '@pushwoosh/kit-constants';
3
+ import { Spinner } from '../Spinner';
4
+ import { RootBox, ImgPreview, PlaceholderWrapper } from './styles';
5
+ export function ExternalImagePreview(props) {
6
+ const {
7
+ src,
8
+ alt = 'External image preview',
9
+ width,
10
+ height,
11
+ placeholder,
12
+ onError
13
+ } = props;
14
+ const [isLoading, setIsLoading] = useState(false);
15
+ const [isError, setIsError] = useState(false);
16
+ useEffect(() => {
17
+ if (src) {
18
+ setIsLoading(true);
19
+ setIsError(false);
20
+ }
21
+ }, [src]);
22
+ const handleOnError = error => {
23
+ setIsLoading(false);
24
+ setIsError(true);
25
+ if (onError) {
26
+ onError(error);
27
+ }
28
+ };
29
+ return React.createElement(RootBox, {
30
+ width: width,
31
+ height: height
32
+ }, (!src || isError) && React.createElement(PlaceholderWrapper, {
33
+ width: width,
34
+ height: height
35
+ }, placeholder), isLoading && React.createElement(PlaceholderWrapper, {
36
+ width: width,
37
+ height: height
38
+ }, React.createElement(Spinner, {
39
+ size: "small",
40
+ color: Color.CLEAR
41
+ })), React.createElement(ImgPreview, {
42
+ width: width,
43
+ height: height,
44
+ isHide: !src || isLoading || isError,
45
+ alt: alt,
46
+ src: src,
47
+ onError: handleOnError,
48
+ onLoad: () => setIsLoading(false)
49
+ }));
50
+ }
@@ -0,0 +1 @@
1
+ export { ExternalImagePreview } from './ExternalImagePreview';
@@ -0,0 +1 @@
1
+ export { ExternalImagePreview } from './ExternalImagePreview';
@@ -0,0 +1,13 @@
1
+ export declare const RootBox: import("styled-components").StyledComponent<"div", any, {
2
+ width: string | number;
3
+ height: string | number;
4
+ }, never>;
5
+ export declare const ImgPreview: import("styled-components").StyledComponent<"img", any, {
6
+ width: string | number;
7
+ height: string | number;
8
+ isHide: boolean;
9
+ }, never>;
10
+ export declare const PlaceholderWrapper: import("styled-components").StyledComponent<"div", any, {
11
+ width: string | number;
12
+ height: string | number;
13
+ }, never>;
@@ -0,0 +1,29 @@
1
+ import styled from 'styled-components';
2
+ import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
3
+ import { toCssValue } from '@pushwoosh/kit-helpers';
4
+ export const RootBox = styled.div.withConfig({
5
+ displayName: "RootBox",
6
+ componentId: "sc-irvho3-0"
7
+ })(["position:relative;width:", ";height:", ";"], ({
8
+ width
9
+ }) => toCssValue(width), ({
10
+ height
11
+ }) => toCssValue(height));
12
+ export const ImgPreview = styled.img.withConfig({
13
+ displayName: "ImgPreview",
14
+ componentId: "sc-irvho3-1"
15
+ })(["width:", ";height:", ";border-radius:", ";opacity:", ";z-index:1;"], ({
16
+ width
17
+ }) => toCssValue(width), ({
18
+ height
19
+ }) => toCssValue(height), ShapeRadius.CONTROL, ({
20
+ isHide
21
+ }) => isHide ? 0 : 1);
22
+ export const PlaceholderWrapper = styled.div.withConfig({
23
+ displayName: "PlaceholderWrapper",
24
+ componentId: "sc-irvho3-2"
25
+ })(["width:", ";height:", ";display:flex;align-items:center;justify-content:center;border-radius:", ";position:absolute;top:0;left:0;z-index:2;background:", ";"], ({
26
+ width
27
+ }) => toCssValue(width), ({
28
+ height
29
+ }) => toCssValue(height), ShapeRadius.CONTROL, Color.MAIN);
@@ -0,0 +1,9 @@
1
+ import type { ReactElement, ReactEventHandler } from 'react';
2
+ export interface ExternalImagePreviewProps {
3
+ src: string;
4
+ alt?: string;
5
+ width: string | number;
6
+ height: string | number;
7
+ placeholder: ReactElement;
8
+ onError?: (error: ReactEventHandler<HTMLImageElement>) => void;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.81",
3
+ "version": "1.1.83",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",