@pushwoosh/dumb-components 1.0.16 → 1.0.18

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.
@@ -5,17 +5,18 @@ import { DropdownContext } from '../../context';
5
5
  const defaultPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end'];
6
6
  export const DropdownMenu = ({
7
7
  renderHandler,
8
- children,
8
+ color,
9
9
  isScrollable,
10
10
  menuZIndex,
11
- menuPlacement
11
+ menuPlacement,
12
+ children
12
13
  }) => {
13
14
  const [isOpen, setIsOpen] = useState(false);
14
15
  const {
15
16
  refs,
16
17
  floatingStyles
17
18
  } = useFloating({
18
- middleware: [offset(2), autoPlacement({
19
+ middleware: [offset(4), autoPlacement({
19
20
  allowedPlacements: menuPlacement ? [menuPlacement] : defaultPlacements
20
21
  })]
21
22
  });
@@ -42,6 +43,7 @@ export const DropdownMenu = ({
42
43
  }), isOpen && React.createElement(Place, {
43
44
  ref: refs.setFloating,
44
45
  style: floatingStyles,
46
+ "$color": color,
45
47
  "$scrollable": isScrollable,
46
48
  "$zIndex": menuZIndex
47
49
  }, typeof children === 'function' ? children() : children));
@@ -11,6 +11,7 @@ export declare const Place: import("styled-components").StyledComponent<"div", a
11
11
  } & {
12
12
  $gridAutoFlow: string;
13
13
  } & {
14
+ $color?: string;
14
15
  $zIndex?: number;
15
16
  $scrollable?: boolean;
16
17
  }, "$gridAutoFlow">;
@@ -5,7 +5,9 @@ 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-color:", ";min-width:140px;", " border-radius:", ";box-shadow:", ";z-index:", ";"], Color.FORM, Color.FROZEN, ({
8
+ })(["border:1px solid ", ";background:", ";min-width:140px;", " border-radius:", ";box-shadow:", ";z-index:", ";"], Color.FORM, ({
9
+ $color
10
+ }) => $color || Color.FROZEN, ({
9
11
  $scrollable
10
12
  }) => $scrollable && scrollableCss, ShapeRadius.CONTROL, Shadow.REGULAR, ({
11
13
  $zIndex
@@ -1,5 +1,6 @@
1
- import { type ReferenceType, type Placement } from '@floating-ui/react-dom';
1
+ import type { ReferenceType, Placement } from '@floating-ui/react-dom';
2
2
  import type { ReactNode } from 'react';
3
+ import type { Color } from '@pushwoosh/kit-constants';
3
4
  export type HandlerProps = {
4
5
  onClick: () => void;
5
6
  ref: (el: ReferenceType | null) => void;
@@ -8,6 +9,7 @@ export type HandlerProps = {
8
9
  export type DropdownMenuProps = {
9
10
  renderHandler: (args: HandlerProps) => ReactNode;
10
11
  children: (() => ReactNode) | ReactNode;
12
+ color?: Color.CLEAR | Color.FROZEN;
11
13
  isScrollable?: boolean;
12
14
  menuZIndex?: number;
13
15
  menuPlacement?: Placement;
@@ -3,7 +3,7 @@ import { Color, Spacing, UnitSize } from '@pushwoosh/kit-constants';
3
3
  export const DropdownMenuItemStyled = styled.button.withConfig({
4
4
  displayName: "DropdownMenuItemStyled",
5
5
  componentId: "sc-1wmyvxp-0"
6
- })(["appearance:none;display:flex;align-items:center;padding:0 ", ";height:", ";border:none;color:", ";background:none;cursor:pointer;&:hover{background:", ";color:", ";}&:disabled{color:", ";cursor:not-allowed;}"], Spacing.S4, UnitSize.FIELD_HEIGHT, ({
6
+ })(["appearance:none;display:flex;align-items:center;padding:0 ", ";min-height:", ";border:none;color:", ";background:none;cursor:pointer;&:hover{background:", ";color:", ";}&:disabled{color:", ";cursor:not-allowed;}"], Spacing.S4, UnitSize.FIELD_HEIGHT, ({
7
7
  $active,
8
8
  $danger
9
9
  }) => {
@@ -16,5 +16,5 @@ export declare const TitleBox: import("styled-components").StyledComponent<"div"
16
16
  $alignItems: string;
17
17
  $justifyContent: string;
18
18
  $gap: Spacing;
19
- }, "$gap" | "$gridAutoFlow" | "$alignItems" | "$justifyContent">;
19
+ }, "$gridAutoFlow" | "$alignItems" | "$gap" | "$justifyContent">;
20
20
  export declare const Link: import("styled-components").StyledComponent<typeof LinkBase, any, {}, never>;
@@ -1,3 +1,2 @@
1
- export declare function pickBy<T extends Record<string, any>>(obj: T): Record<string, any>;
2
1
  export declare function mapKeys<T extends Record<string, any>, K extends string>(obj: T, mapper: (key: string) => K): Record<K, T[keyof T]>;
3
2
  export declare function shallowEqual<T extends Record<string, any>>(a: T, b: T): boolean;
@@ -1,6 +1,3 @@
1
- export function pickBy(obj) {
2
- return Object.fromEntries(Object.entries(obj).filter(([, value]) => !!value));
3
- }
4
1
  export function mapKeys(obj, mapper) {
5
2
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => [mapper(key), value]));
6
3
  }
@@ -1,7 +1,7 @@
1
1
  import { useMemo, useRef } from 'react';
2
2
  import { useHistory, useLocation } from 'react-router-dom';
3
3
  import { usePersistentFunction } from '@pushwoosh/kit-helpers';
4
- import { mapKeys, pickBy, shallowEqual } from './helpers';
4
+ import { mapKeys, shallowEqual } from './helpers';
5
5
  export function useDataTableGetParams({
6
6
  defaultOrder,
7
7
  defaultDirection = 'asc',
@@ -37,10 +37,14 @@ export function useDataTableGetParams({
37
37
  }, [locationSearch, defaultDirection, defaultOrder, defaultPerPage, prefix]);
38
38
  const changeDataTableParams = usePersistentFunction(params => {
39
39
  const searchParams = new URLSearchParams(locationSearch);
40
- const paramsWithPrefix = pickBy(mapKeys(params, key => `${prefix}${key}`));
41
- Object.entries(paramsWithPrefix).forEach(([key, value]) => {
42
- searchParams.set(key, value);
43
- });
40
+ const paramsWithPrefix = mapKeys(params, key => `${prefix}${key}`);
41
+ for (const [key, value] of Object.entries(paramsWithPrefix)) {
42
+ if (value === undefined || value === null || value === '') {
43
+ searchParams.delete(key);
44
+ } else {
45
+ searchParams.set(key, String(value));
46
+ }
47
+ }
44
48
  history.push({
45
49
  search: searchParams.toString()
46
50
  });
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { ActionsGroup, ActionsGroupItem } from './ActionsGroup';
2
1
  export { Badge, type BadgeColor } from './Badge';
3
2
  export { Banner, type BannerType } from './Banner';
4
3
  export { Button, GhostButton } from './Button';
package/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { ActionsGroup, ActionsGroupItem } from './ActionsGroup';
2
1
  export { Badge } from './Badge';
3
2
  export { Banner } from './Banner';
4
3
  export { Button, GhostButton } from './Button';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
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 { ActionsGroupProps } from './types';
3
- export declare function ActionsGroup(props: ActionsGroupProps): ReactElement;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { ActionsGroupBox, ActionsGroupInner } from './styles';
3
- export function ActionsGroup(props) {
4
- const {
5
- boxRef,
6
- align,
7
- gap,
8
- children,
9
- ...rest
10
- } = props;
11
- return React.createElement(ActionsGroupBox, {
12
- ...rest,
13
- ref: boxRef
14
- }, React.createElement(ActionsGroupInner, {
15
- "$align": align,
16
- "$gap": gap
17
- }, children));
18
- }
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { ActionsGroupItemProps } from './types';
3
- export declare function ActionsGroupItem(props: ActionsGroupItemProps): ReactElement;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ActionsGroupItemBox } from './styles';
3
- export function ActionsGroupItem(props) {
4
- const {
5
- boxRef,
6
- ...rest
7
- } = props;
8
- return React.createElement(ActionsGroupItemBox, {
9
- ...rest,
10
- ref: boxRef
11
- });
12
- }
@@ -1,3 +0,0 @@
1
- export { ActionsGroup } from './ActionsGroup';
2
- export { ActionsGroupItem } from './ActionsGroupItem';
3
- export type { ActionsGroupProps, ActionsGroupItemProps } from './types';
@@ -1,2 +0,0 @@
1
- export { ActionsGroup } from './ActionsGroup';
2
- export { ActionsGroupItem } from './ActionsGroupItem';
@@ -1,7 +0,0 @@
1
- import type { ActionsGroupProps } from './types';
2
- export declare const ActionsGroupBox: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export declare const ActionsGroupItemBox: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export declare const ActionsGroupInner: import("styled-components").StyledComponent<"div", any, {
5
- $align: ActionsGroupProps["align"];
6
- $gap: ActionsGroupProps["gap"];
7
- }, never>;
@@ -1,22 +0,0 @@
1
- import styled from 'styled-components';
2
- export const ActionsGroupBox = styled.div.withConfig({
3
- displayName: "ActionsGroupBox",
4
- componentId: "sc-eb6b51-0"
5
- })([""]);
6
- export const ActionsGroupItemBox = styled.div.withConfig({
7
- displayName: "ActionsGroupItemBox",
8
- componentId: "sc-eb6b51-1"
9
- })([""]);
10
- export const ActionsGroupInner = styled.div.withConfig({
11
- displayName: "ActionsGroupInner",
12
- componentId: "sc-eb6b51-2"
13
- })(["display:flex;flex-wrap:nowrap;align-items:center;justify-content:", ";margin:0 ", ";", "{padding:0 ", ";}"], ({
14
- $align
15
- }) => $align === 'end' ? 'flex-end' : 'flex-start', ({
16
- $gap
17
- }) => `calc(-${$gap}/2)`, ActionsGroupItemBox, ({
18
- $gap
19
- }) => `calc(${$gap}/2)`);
20
- ActionsGroupBox.displayName = 'ActionsGroupBox';
21
- ActionsGroupInner.displayName = 'ActionsGroupInner';
22
- ActionsGroupItemBox.displayName = 'ActionsGroupBox';
@@ -1,12 +0,0 @@
1
- import type { Ref, ReactNode } from 'react';
2
- import type { Spacing } from '@pushwoosh/kit-constants';
3
- export type ActionsGroupProps = Omit<JSX.IntrinsicElements['div'], 'ref'> & {
4
- readonly boxRef?: Ref<HTMLDivElement>;
5
- readonly align: 'start' | 'end';
6
- readonly gap: Spacing;
7
- readonly children: ReactNode;
8
- };
9
- export type ActionsGroupItemProps = Omit<JSX.IntrinsicElements['div'], 'ref'> & {
10
- readonly boxRef?: Ref<HTMLDivElement>;
11
- readonly children: ReactNode;
12
- };
@@ -1 +0,0 @@
1
- export {};