@soul-refiner/design-system 1.7.16 → 1.7.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.
@@ -10,6 +10,7 @@ export interface FilterProps {
10
10
  disabled?: boolean;
11
11
  graphic?: React.ReactElement;
12
12
  graphicAlignment?: 'left' | 'right';
13
+ resetGraphic?: boolean;
13
14
  label?: string;
14
15
  sx?: string;
15
16
  triggerType: FilterTriggerTypes;
@@ -23,9 +24,9 @@ export interface FilterProps {
23
24
  applyResetActions?: boolean;
24
25
  }
25
26
  declare const Filter: {
26
- ({ closeOnBlur, disabled, graphic, graphicAlignment, label, sx, triggerType, options, defaultValue, closeOnChange, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }: FilterProps): React.JSX.Element;
27
+ ({ closeOnBlur, disabled, graphic, graphicAlignment, resetGraphic, label, sx, triggerType, options, defaultValue, closeOnChange, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }: FilterProps): React.JSX.Element;
27
28
  Trigger: {
28
- ({ disabled, graphic, graphicAlignment, label, onClick, open, type, value, }: FilterTriggerProps): React.JSX.Element;
29
+ ({ disabled, graphic, graphicAlignment, label, onClick, resetGraphic, open, onReset, type, value, }: FilterTriggerProps): React.JSX.Element;
29
30
  displayName: string;
30
31
  };
31
32
  };
@@ -35,7 +36,9 @@ export interface FilterTriggerProps {
35
36
  graphicAlignment?: 'left' | 'right';
36
37
  label?: string;
37
38
  onClick?: (event: React.MouseEvent) => void;
39
+ onReset?: (event: React.MouseEvent) => void;
38
40
  open: boolean;
41
+ resetGraphic?: boolean;
39
42
  type: FilterTriggerTypes;
40
43
  value?: string;
41
44
  }
@@ -2,10 +2,10 @@
2
2
  import React from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import { Box, Button, P } from '../../';
5
- import { ChevronDown, ChevronUp } from '../../../icons';
5
+ import { ChevronDown, ChevronUp, Close } from '../../../icons';
6
6
  import { Styles } from '../../../common';
7
7
  import { Spacer, Option } from './filter_option';
8
- const Filter = ({ closeOnBlur = true, disabled, graphic, graphicAlignment = 'left', label = '', sx, triggerType, options, defaultValue = '', closeOnChange = true, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }) => {
8
+ const Filter = ({ closeOnBlur = true, disabled, graphic, graphicAlignment = 'left', resetGraphic, label = '', sx, triggerType, options, defaultValue = '', closeOnChange = true, optionOnChange, optionShowClose, checkbox, applyOnClick, resetOnClick, applyResetActions, }) => {
9
9
  const multiple = !!checkbox;
10
10
  const wrapperRef = React.useRef(null);
11
11
  const optionsRef = React.useRef(null);
@@ -98,8 +98,17 @@ const Filter = ({ closeOnBlur = true, disabled, graphic, graphicAlignment = 'lef
98
98
  }),
99
99
  triggerType === 'pill' && React.createElement(Spacer, { key: `spacer-${options.length}` }),
100
100
  ];
101
+ const showResetGraphic = resetGraphic &&
102
+ (typeof selected === 'string' ? !!selected : !!selected.length);
101
103
  return (React.createElement(Wrapper, { "$sx": sx, tabIndex: 0, ref: wrapperRef, onBlurCapture: handleBlur },
102
- React.createElement(FilterTrigger, { disabled: disabled, graphic: graphic, graphicAlignment: graphicAlignment, label: label, onClick: handleOpen, open: open, type: triggerType, value: filterLabel }),
104
+ React.createElement(FilterTrigger, { disabled: disabled, graphic: graphic, graphicAlignment: graphicAlignment, label: label, onClick: handleOpen, onReset: resetGraphic
105
+ ? (event) => {
106
+ event.stopPropagation();
107
+ resetOnClick && resetOnClick(event);
108
+ setSelected(multiple ? [] : '');
109
+ setOpen(false);
110
+ }
111
+ : undefined, open: open, resetGraphic: showResetGraphic, type: triggerType, value: filterLabel }),
103
112
  open && (React.createElement(Container, { ref: optionsRef },
104
113
  React.createElement(React.Fragment, null,
105
114
  dropdownOptions,
@@ -151,13 +160,14 @@ const wrapperProps = {
151
160
  $dir: 'row',
152
161
  $gap: 16,
153
162
  };
154
- const FilterTrigger = ({ disabled, graphic, graphicAlignment, label, onClick, open, type, value, }) => {
163
+ const FilterTrigger = ({ disabled, graphic, graphicAlignment, label, onClick, resetGraphic, open, onReset, type, value, }) => {
155
164
  if (type === 'pill') {
156
165
  return (React.createElement(Pill, { disabled: disabled, onClick: onClick, "$labelIsDefault": value === label, ...wrapperProps },
157
166
  graphicAlignment === 'left' ? graphic : null,
158
167
  React.createElement(P, { ...textProps }, value),
168
+ resetGraphic ? React.createElement(Close, { color: "blue-3", onClick: onReset }) : null,
159
169
  graphicAlignment === 'right' ? graphic : null,
160
- !graphic && (open ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null))));
170
+ !graphic && !resetGraphic && (open ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null))));
161
171
  }
162
172
  if (type === 'labeled') {
163
173
  return (React.createElement(Labeled, { disabled: disabled, onClick: onClick, ...wrapperProps },
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import Image from 'next/image';
4
+ import Link from 'next/link';
4
5
  import styled from 'styled-components';
5
6
  import { H, P } from '../../atoms/typography';
6
7
  import { TimeAgo } from '../../atoms/time_ago/time_ago';
@@ -94,8 +95,8 @@ export const Post = ({ actions, author, authorActive, authorHref, authorImage, a
94
95
  React.createElement(NavArrow, { "$side": "right", "$visible": curr !== images.length - 1, onClick: handleIncrement },
95
96
  React.createElement(ChevronRight, { color: "white", size: 48 }))))),
96
97
  React.createElement(Header, null,
97
- React.createElement(Avatar, { href: authorHref, image: authorImage, size: 64, status: authorActive ? 'online' : undefined, subtitle: React.createElement(P, { as: "span", sx: "vertical-align: top;", "$fontSize": 14, "$lineHeight": 20 },
98
- React.createElement(TimeAgo, { date: new Date(createdDate) })), title: React.createElement(H, { as: "span", "$bold": true, "$fontSize": 18, "$lineHeight": 26 }, author), textPosition: "right", tooltipContent: avatarTooltipContent, tooltipSx: avatarTooltipSx }),
98
+ React.createElement(Avatar, { as: !!authorHref ? Link : 'button', href: authorHref, image: authorImage, size: 64, status: authorActive ? 'online' : undefined, subtitle: React.createElement(P, { as: "span", sx: "vertical-align: top;", "$fontSize": 14, "$lineHeight": 20 },
99
+ React.createElement(TimeAgo, { date: new Date(createdDate) })), title: React.createElement(H, { as: "span", "$bold": true, "$fontSize": 18, "$lineHeight": 26 }, author), textPosition: "right", tooltipContent: avatarTooltipContent, tooltipSx: avatarTooltipSx, sx: !!authorHref ? 'img { cursor: pointer; }' : undefined }),
99
100
  dropdown),
100
101
  !!content?.length && (React.createElement("div", { style: { padding: '16px 24px' } },
101
102
  React.createElement(P, { "$textClampLines": isPaywalled ? 2 : undefined }, content))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "1.7.16",
3
+ "version": "1.7.18",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {