@pushwoosh/dumb-components 1.0.31 → 1.0.33

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,5 +1,6 @@
1
- import { autoPlacement, offset, useFloating } from '@floating-ui/react-dom';
2
- import React, { useEffect, useState } from 'react';
1
+ import { autoPlacement, size, offset, useFloating } from '@floating-ui/react-dom';
2
+ import React, { useState, useEffect } from 'react';
3
+ import { flushSync } from 'react-dom';
3
4
  import { Place } from './styles';
4
5
  import { DropdownContext } from '../../context';
5
6
  const defaultPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end'];
@@ -9,14 +10,24 @@ export const DropdownMenu = ({
9
10
  isScrollable,
10
11
  menuZIndex,
11
12
  menuPlacement,
13
+ fullWidth,
12
14
  children
13
15
  }) => {
14
16
  const [isOpen, setIsOpen] = useState(false);
17
+ const [width, setWidth] = useState(null);
15
18
  const {
16
19
  refs,
17
20
  floatingStyles
18
21
  } = useFloating({
19
- middleware: [offset(4), autoPlacement({
22
+ middleware: [size({
23
+ apply({
24
+ rects
25
+ }) {
26
+ if (fullWidth) {
27
+ flushSync(() => setWidth(rects.reference.width));
28
+ }
29
+ }
30
+ }), offset(4), autoPlacement({
20
31
  allowedPlacements: menuPlacement ? [menuPlacement] : defaultPlacements
21
32
  })]
22
33
  });
@@ -44,6 +55,7 @@ export const DropdownMenu = ({
44
55
  ref: refs.setFloating,
45
56
  style: floatingStyles,
46
57
  "$color": color,
58
+ "$width": width,
47
59
  "$scrollable": isScrollable,
48
60
  "$zIndex": menuZIndex
49
61
  }, typeof children === 'function' ? children() : children));
@@ -12,6 +12,7 @@ export declare const Place: import("styled-components").StyledComponent<"div", a
12
12
  $gridAutoFlow: string;
13
13
  } & {
14
14
  $color?: string;
15
+ $width: number | null;
15
16
  $zIndex?: number;
16
17
  $scrollable?: boolean;
17
18
  }, "$gridAutoFlow">;
@@ -5,9 +5,11 @@ const scrollableCss = css(["max-height:248px;overflow-y:auto;"]);
5
5
  export const Place = styled(Vertical).withConfig({
6
6
  displayName: "Place",
7
7
  componentId: "sc-ij8wqc-0"
8
- })(["border:1px solid ", ";background:", ";min-width:140px;", " border-radius:", ";box-shadow:", ";z-index:", ";"], Color.FORM, ({
8
+ })(["border:1px solid ", ";background:", ";width:", ";min-width:140px;max-width:480px;", " border-radius:", ";box-shadow:", ";z-index:", ";"], Color.FORM, ({
9
9
  $color
10
10
  }) => $color || Color.FROZEN, ({
11
+ $width
12
+ }) => $width ? `${$width}px` : 'auto', ({
11
13
  $scrollable
12
14
  }) => $scrollable && scrollableCss, ShapeRadius.CONTROL, Shadow.REGULAR, ({
13
15
  $zIndex
@@ -2,15 +2,16 @@ import type { ReferenceType, Placement } from '@floating-ui/react-dom';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { Color } from '@pushwoosh/kit-constants';
4
4
  export type HandlerProps = {
5
- onClick: () => void;
6
- ref: (el: ReferenceType | null) => void;
7
5
  isOpen: boolean;
6
+ ref: (el: ReferenceType | null) => void;
7
+ onClick: () => void;
8
8
  };
9
9
  export type DropdownMenuProps = {
10
- renderHandler: (args: HandlerProps) => ReactNode;
11
- children: (() => ReactNode) | ReactNode;
12
10
  color?: Color.CLEAR | Color.FROZEN;
13
11
  isScrollable?: boolean;
14
12
  menuZIndex?: number;
15
13
  menuPlacement?: Placement;
14
+ fullWidth?: boolean;
15
+ renderHandler: (args: HandlerProps) => ReactNode;
16
+ children: (() => ReactNode) | ReactNode;
16
17
  };
@@ -45,10 +45,10 @@ export function FieldBox(props) {
45
45
  "$alignItems": "center",
46
46
  "$gap": Spacing.S1
47
47
  }, actions)), children, description && !error && React.createElement(Text, {
48
- "$variant": "h5",
48
+ "$variant": "footnote",
49
49
  "$color": Color.LOCKED
50
50
  }, description), error && React.createElement(Text, {
51
- "$variant": "h5",
51
+ "$variant": "footnote",
52
52
  "$color": Color.DANGER
53
53
  }, error));
54
54
  }
@@ -1,5 +1,5 @@
1
1
  import { type ReactElement } from 'react';
2
- import { type GroupBase } from 'react-select';
2
+ import type { GroupBase } from 'react-select';
3
3
  import type { SelectProps, SelectAsyncProps, SelectCreatableProps } from './types';
4
4
  export declare function Select<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectProps<Option, IsMulti, Group>): ReactElement;
5
5
  export declare function SelectAsync<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectAsyncProps<Option, IsMulti, Group>): ReactElement;
package/Select/Select.js CHANGED
@@ -1,6 +1,15 @@
1
1
  import React from 'react';
2
+ import { CloseIcon } from '@pushwoosh/kit-icons';
2
3
  import { CLASS_NAME_PREFIX } from './constants';
3
- import { SelectStyled, SelectAsyncStyled, SelectCreatableStyled } from './styles';
4
+ import { SelectStyled, SelectAsyncStyled, SelectCreatableStyled, ClearIndicatorBox } from './styles';
5
+ const componentsProps = {
6
+ ClearIndicator: ({
7
+ clearValue
8
+ }) => React.createElement(ClearIndicatorBox, null, React.createElement(CloseIcon, {
9
+ size: "small",
10
+ onClick: clearValue
11
+ }))
12
+ };
4
13
  export function Select(props) {
5
14
  const {
6
15
  classNamePrefix = CLASS_NAME_PREFIX
@@ -10,6 +19,7 @@ export function Select(props) {
10
19
  classNamePrefix
11
20
  };
12
21
  return React.createElement(SelectStyled, {
22
+ components: componentsProps,
13
23
  ...customProps
14
24
  });
15
25
  }
@@ -22,6 +32,7 @@ export function SelectAsync(props) {
22
32
  classNamePrefix
23
33
  };
24
34
  return React.createElement(SelectAsyncStyled, {
35
+ components: componentsProps,
25
36
  ...customProps
26
37
  });
27
38
  }
@@ -34,6 +45,7 @@ export function CreatableSelect(props) {
34
45
  classNamePrefix
35
46
  };
36
47
  return React.createElement(SelectCreatableStyled, {
48
+ components: componentsProps,
37
49
  ...customProps
38
50
  });
39
51
  }
@@ -4,3 +4,4 @@ import ReactSelectCreatable from 'react-select/creatable';
4
4
  export declare const SelectStyled: typeof ReactSelect;
5
5
  export declare const SelectAsyncStyled: typeof ReactSelectAsync;
6
6
  export declare const SelectCreatableStyled: typeof ReactSelectCreatable;
7
+ export declare const ClearIndicatorBox: import("styled-components").StyledComponent<"div", any, {}, never>;
package/Select/styles.js CHANGED
@@ -4,11 +4,11 @@ import ReactSelectCreatable from 'react-select/creatable';
4
4
  import styled, { css } from 'styled-components';
5
5
  import { Color, Spacing, FontSize, LineHeight, UnitSize } from '@pushwoosh/kit-constants';
6
6
  import { CLASS_NAME_PREFIX } from './constants';
7
- const selectStyles = css([".", "__control{width:", ";min-width:", ";height:auto;min-height:", ";font-size:", ";line-height:", ";background-color:", ";border:", ";box-sizing:border-box;}.", "__indicator{display:flex;align-items:center;justify-content:center;padding:", " ", ";}.", "__menu{width:", ";min-width:", ";font-size:", ";line-height:", ";}.", "__indicator-separator{display:none;}.", "__control--is-focused{border:1px solid ", ";box-shadow:none;}.", "__control--is-disabled{background-color:", ";}.", "__control:hover{border:", ";}.", "__control--is-focused:hover{border:1px solid ", ";box-shadow:none;}.", "__placeholder{display:flex;width:100%;text-overflow:clip;white-space:nowrap;}"], CLASS_NAME_PREFIX, ({
7
+ const selectStyles = css([".", "__control{width:", ";min-width:", ";height:auto;min-height:", ";font-size:", ";line-height:", ";color:", ";background-color:", ";border:", ";box-sizing:border-box;}.", "__indicator{display:flex;align-items:center;justify-content:center;padding:", " ", ";}.", "__menu{width:", ";min-width:", ";font-size:", ";line-height:", ";}.", "__indicator-separator{display:none;}.", "__control--is-focused{border:1px solid ", ";box-shadow:none;}.", "__control--is-disabled{background-color:", ";}.", "__control:hover{border:", ";}.", "__control--is-focused:hover{border:1px solid ", ";box-shadow:none;}.", "__placeholder{display:flex;width:100%;color:", ";white-space:nowrap;text-overflow:clip;}"], CLASS_NAME_PREFIX, ({
8
8
  width
9
9
  }) => width || '100%', ({
10
10
  width
11
- }) => width || '150px', UnitSize.FIELD_HEIGHT, FontSize.REGULAR, LineHeight.REGULAR, Color.CLEAR, ({
11
+ }) => width || '150px', UnitSize.FIELD_HEIGHT, FontSize.REGULAR, LineHeight.REGULAR, Color.MAIN, Color.CLEAR, ({
12
12
  $isErrored
13
13
  }) => $isErrored ? `1px solid ${Color.DANGER}` : `1px solid ${Color.FORM}`, CLASS_NAME_PREFIX, Spacing.S2, Spacing.S3, CLASS_NAME_PREFIX, ({
14
14
  width
@@ -16,7 +16,7 @@ const selectStyles = css([".", "__control{width:", ";min-width:", ";height:auto;
16
16
  width
17
17
  }) => width || '150px', FontSize.REGULAR, LineHeight.REGULAR, CLASS_NAME_PREFIX, CLASS_NAME_PREFIX, Color.BRIGHT, CLASS_NAME_PREFIX, Color.FROZEN, CLASS_NAME_PREFIX, ({
18
18
  $isErrored
19
- }) => $isErrored ? `1px solid ${Color.DANGER}` : `1px solid ${Color.FORM}`, CLASS_NAME_PREFIX, Color.BRIGHT, CLASS_NAME_PREFIX);
19
+ }) => $isErrored ? `1px solid ${Color.DANGER}` : `1px solid ${Color.FORM}`, CLASS_NAME_PREFIX, Color.BRIGHT, CLASS_NAME_PREFIX, Color.PHANTOM);
20
20
  export const SelectStyled = styled(ReactSelect).withConfig({
21
21
  displayName: "SelectStyled",
22
22
  componentId: "sc-c2oq4h-0"
@@ -28,4 +28,8 @@ export const SelectAsyncStyled = styled(ReactSelectAsync).withConfig({
28
28
  export const SelectCreatableStyled = styled(ReactSelectCreatable).withConfig({
29
29
  displayName: "SelectCreatableStyled",
30
30
  componentId: "sc-c2oq4h-2"
31
- })(["", ";"], selectStyles);
31
+ })(["", ";"], selectStyles);
32
+ export const ClearIndicatorBox = styled.div.withConfig({
33
+ displayName: "ClearIndicatorBox",
34
+ componentId: "sc-c2oq4h-3"
35
+ })(["color:", ";transition:transform 0.3s ease,color 0.3s ease;&:hover{color:", ";transform:scale(1.2);}"], Color.PHANTOM, Color.MAIN);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",