@pushwoosh/dumb-components 1.0.23 → 1.0.25

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,7 +1,5 @@
1
- import React, { useRef, useState, useEffect } from 'react';
1
+ import React, { useRef, useEffect } from 'react';
2
2
  import { NativeLabel, NativeCheckbox } from './styles';
3
- // eslint-disable-next-line prefer-const
4
- let counter = 0;
5
3
  export function Checkbox(props) {
6
4
  const {
7
5
  label,
@@ -16,13 +14,6 @@ export function Checkbox(props) {
16
14
  onChange,
17
15
  className
18
16
  } = props;
19
- const [localId] = useState(() => {
20
- if (id) {
21
- return id;
22
- }
23
- const newCounter = counter + 1;
24
- return `checkbox-${newCounter}`;
25
- });
26
17
  const checkboxRef = useRef(null);
27
18
  useEffect(() => {
28
19
  if (checkboxRef.current) {
@@ -30,12 +21,12 @@ export function Checkbox(props) {
30
21
  }
31
22
  }, [checkboxRef, isIndeterminate]);
32
23
  return React.createElement(NativeLabel, {
33
- htmlFor: localId,
24
+ htmlFor: id,
34
25
  "$color": color,
35
26
  className: className
36
27
  }, React.createElement(NativeCheckbox, {
37
28
  type: "checkbox",
38
- id: localId,
29
+ id: id,
39
30
  ref: checkboxRef,
40
31
  value: value,
41
32
  color: activeCheckboxColor,
@@ -0,0 +1,3 @@
1
+ import { type FC } from 'react';
2
+ import { type EnhancedInputProps } from './types';
3
+ export declare const EnhancedInput: FC<EnhancedInputProps>;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { CloseIcon } from '@pushwoosh/kit-icons';
3
+ import { Wrapper } from './styles';
4
+ import { NativeInput } from '../native';
5
+ export const EnhancedInput = ({
6
+ $icon,
7
+ $onClear,
8
+ ...props
9
+ }) => {
10
+ return React.createElement(Wrapper, {
11
+ "$hasIcon": !!$icon,
12
+ "$hasClear": !!$onClear,
13
+ "$hasError": !!props.$isErrored
14
+ }, $icon, React.createElement(NativeInput, {
15
+ ...props
16
+ }), $onClear && React.createElement(CloseIcon, {
17
+ size: "small",
18
+ onClick: $onClear
19
+ }));
20
+ };
@@ -0,0 +1,3 @@
1
+ import { type FC } from 'react';
2
+ import { type SearchInputProps } from './types';
3
+ export declare const SearchInput: FC<SearchInputProps>;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { SearchIcon } from '@pushwoosh/kit-icons';
3
+ import { EnhancedInput } from './EnhancedInput';
4
+ export const SearchInput = props => {
5
+ return React.createElement(EnhancedInput, {
6
+ ...props,
7
+ "$icon": React.createElement(SearchIcon, {
8
+ size: "medium",
9
+ view: "lined"
10
+ })
11
+ });
12
+ };
@@ -0,0 +1,2 @@
1
+ export { EnhancedInput } from './EnhancedInput';
2
+ export { SearchInput } from './SearchInput';
@@ -0,0 +1,2 @@
1
+ export { EnhancedInput } from './EnhancedInput';
2
+ export { SearchInput } from './SearchInput';
@@ -0,0 +1,5 @@
1
+ export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {
2
+ $hasIcon?: boolean;
3
+ $hasClear?: boolean;
4
+ $hasError?: boolean;
5
+ }, never>;
@@ -0,0 +1,13 @@
1
+ import styled from 'styled-components';
2
+ import { Color } from '@pushwoosh/kit-constants';
3
+ import { NativeInput } from '../native';
4
+ export const Wrapper = styled.div.withConfig({
5
+ displayName: "Wrapper",
6
+ componentId: "sc-5f7rba-0"
7
+ })(["display:inline-grid;position:relative;& > :not(", "){position:absolute;top:50%;transform:translateY(-50%);}& > :not(", "):first-child{left:6px;color:", ";}&:focus-within > :not(", "):first-child{color:", ";}& > :not(", "):last-child{right:12px;cursor:pointer;color:", ";transition:transform 0.3s ease,color 0.3s ease;&:hover{transform:translateY(-50%) scale(1.2);color:", ";}}& > ", "{width:100%;", " ", "}"], NativeInput, NativeInput, ({
8
+ $hasError
9
+ }) => $hasError ? Color.DANGER : Color.PHANTOM, NativeInput, Color.BRIGHT, NativeInput, Color.PHANTOM, Color.MAIN, NativeInput, ({
10
+ $hasIcon
11
+ }) => $hasIcon && 'padding-left: 36px;', ({
12
+ $hasClear
13
+ }) => $hasClear && `padding-right: 34px;`);
@@ -0,0 +1,7 @@
1
+ import type { InputHTMLAttributes, ReactNode } from 'react';
2
+ import type { NativeInputProps } from '../native/Input';
3
+ export type EnhancedInputProps = InputHTMLAttributes<HTMLInputElement> & NativeInputProps & {
4
+ $icon?: ReactNode;
5
+ $onClear?: () => void;
6
+ };
7
+ export type SearchInputProps = Omit<EnhancedInputProps, '$icon'>;
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, useState, useEffect, useContext } from 'react';
2
+ import { SearchInput } from '../../../EnhancedInput';
2
3
  import { DataTableContext } from '../../context';
3
- import { ClearableInput } from '../ClearableInput';
4
4
  export function DataTableSearchInput(props) {
5
5
  const context = useContext(DataTableContext);
6
6
  const [inputValue, setInputValue] = useState(context.params.search);
@@ -10,10 +10,19 @@ export function DataTableSearchInput(props) {
10
10
  setInputValue(context.params.search);
11
11
  }
12
12
  }, [context.params.search]); // eslint-disable-line react-hooks/exhaustive-deps
13
- return React.createElement(ClearableInput, {
13
+ return React.createElement(SearchInput, {
14
14
  ...props,
15
15
  value: inputValue,
16
- onChange: value => {
16
+ "$onClear": () => {
17
+ setInputValue('');
18
+ context.onChangeParams({
19
+ ...context.params,
20
+ search: '',
21
+ page: 1
22
+ });
23
+ },
24
+ onChange: event => {
25
+ const value = event.target.value;
17
26
  setInputValue(value);
18
27
  if (timeoutRef.current) {
19
28
  clearTimeout(timeoutRef.current);
package/Table/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { ClearableInput } from './components/ClearableInput';
2
1
  export { DataTable } from './components/DataTable';
3
2
  export { DataTableList } from './components/DataTableList';
4
3
  export { DataTableGetContext } from './components/DataTableGetContext';
package/Table/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { ClearableInput } from './components/ClearableInput';
2
1
  export { DataTable } from './components/DataTable';
3
2
  export { DataTableList } from './components/DataTableList';
4
3
  export { DataTableGetContext } from './components/DataTableGetContext';
package/index.d.ts CHANGED
@@ -26,9 +26,10 @@ export { StatisticCard } from './StatisticCard';
26
26
  export { EmailTemplatePreview, NoEmailTemplatePreview } from './EmailTemplatePreview';
27
27
  export { PushPreview } from './PushPreview';
28
28
  export { Toast, ToastProvider, useToast } from './Toast';
29
- export { ClearableInput, DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext, useDataTableGetParams, Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description, type DataTableParams, type DataTableData, type DataTableContextType, } from './Table';
29
+ export { DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext, useDataTableGetParams, Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description, type DataTableParams, type DataTableData, type DataTableContextType, } from './Table';
30
30
  export { AutosizeInput, PageHeader, PageHeaderEditable } from './PageHeader';
31
31
  export { ExportResult } from './ExportResult';
32
32
  export { NativeInput, NativeTextarea, NativeSelect } from './native';
33
33
  export { FieldBox } from './FieldBox';
34
34
  export { NumberPicker } from './NumberPicker';
35
+ export { EnhancedInput, SearchInput } from './EnhancedInput';
package/index.js CHANGED
@@ -26,9 +26,10 @@ export { StatisticCard } from './StatisticCard';
26
26
  export { EmailTemplatePreview, NoEmailTemplatePreview } from './EmailTemplatePreview';
27
27
  export { PushPreview } from './PushPreview';
28
28
  export { Toast, ToastProvider, useToast } from './Toast';
29
- export { ClearableInput, DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext, useDataTableGetParams, Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description } from './Table';
29
+ export { DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext, useDataTableGetParams, Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description } from './Table';
30
30
  export { AutosizeInput, PageHeader, PageHeaderEditable } from './PageHeader';
31
31
  export { ExportResult } from './ExportResult';
32
32
  export { NativeInput, NativeTextarea, NativeSelect } from './native';
33
33
  export { FieldBox } from './FieldBox';
34
- export { NumberPicker } from './NumberPicker';
34
+ export { NumberPicker } from './NumberPicker';
35
+ export { EnhancedInput, SearchInput } from './EnhancedInput';
package/native/Input.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export declare const NativeInput: import("styled-components").StyledComponent<"input", any, {
1
+ export type NativeInputProps = {
2
2
  $isErrored?: boolean;
3
- }, never>;
3
+ };
4
+ export declare const NativeInput: import("styled-components").StyledComponent<"input", any, NativeInputProps, never>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { ClearableInputProps } from './types';
3
- export declare function ClearableInput(props: ClearableInputProps): ReactElement;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { CloseIcon } from '@pushwoosh/kit-icons';
3
- import { Wrapper, ClearButton } from './styles';
4
- import { NativeInput } from '../../../native';
5
- export function ClearableInput(props) {
6
- const {
7
- value,
8
- placeholder,
9
- onChange
10
- } = props;
11
- return React.createElement(Wrapper, null, React.createElement(NativeInput, {
12
- value: value,
13
- placeholder: placeholder,
14
- onChange: e => onChange(e.target.value)
15
- }), value && React.createElement(ClearButton, {
16
- onClick: () => onChange('')
17
- }, React.createElement(CloseIcon, {
18
- size: "small"
19
- })));
20
- }
@@ -1 +0,0 @@
1
- export { ClearableInput } from './ClearableInput';
@@ -1 +0,0 @@
1
- export { ClearableInput } from './ClearableInput';
@@ -1,14 +0,0 @@
1
- export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {
2
- $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
3
- $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
4
- $gap?: string | number | undefined;
5
- $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
6
- $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
7
- $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
8
- $margin?: string | number | undefined;
9
- $padding?: string | number | undefined;
10
- $placeItems?: "end" | "start" | "center" | "stretch" | undefined;
11
- } & {
12
- $gridAutoFlow: string;
13
- }, "$gridAutoFlow">;
14
- export declare const ClearButton: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,10 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Horizontal } from '@pushwoosh/kit-helpers';
3
- export const Wrapper = styled(Horizontal).withConfig({
4
- displayName: "Wrapper",
5
- componentId: "sc-1c8truw-0"
6
- })(["position:relative;"]);
7
- export const ClearButton = styled.div.withConfig({
8
- displayName: "ClearButton",
9
- componentId: "sc-1c8truw-1"
10
- })(["position:absolute;right:8px;top:50%;transform:translateY(-50%);cursor:pointer;"]);
@@ -1,5 +0,0 @@
1
- export interface ClearableInputProps {
2
- value: string;
3
- placeholder?: string;
4
- onChange: (value: string) => void;
5
- }