@soul-refiner/design-system 0.2.89 → 0.2.90

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.
@@ -15,9 +15,13 @@ export interface DropdownProps extends NativeProps, React.PropsWithChildren {
15
15
  options?: (Omit<DropdownOptionProps, 'selected' | 'onClick'> | 'break')[];
16
16
  sx?: string;
17
17
  trigger: React.ReactElement;
18
+ containerSx?: string;
19
+ additionalOptions?: Omit<DropdownOptionProps, 'selected' | 'onClick'>[];
20
+ additionalOnChange?: (value: string) => void;
21
+ defaultAdditionalValue?: string;
18
22
  }
19
23
  declare const Dropdown: {
20
- ({ checkbox, children, closeOnChange, closeOnBlur, defaultValue, disabled, hasArrow, maintainState, multiple, offset, onChange, open: openDirection, options, sx, trigger, ...rest }: DropdownProps): React.JSX.Element;
24
+ ({ checkbox, children, closeOnChange, closeOnBlur, defaultValue, disabled, hasArrow, maintainState, multiple, offset, onChange, open: openDirection, options, sx, trigger, containerSx, additionalOptions, additionalOnChange, defaultAdditionalValue, ...rest }: DropdownProps): React.JSX.Element;
21
25
  Option: {
22
26
  ({ checkbox, disabled, icon, label, onClick, selected, sublabel, sx, value, color, }: DropdownOptionProps): React.JSX.Element;
23
27
  displayName: string;
@@ -2,12 +2,13 @@
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { Box, Checkbox, P } from '../../';
5
- const Dropdown = ({ checkbox, children, closeOnChange = true, closeOnBlur = true, defaultValue = '', disabled = false, hasArrow, maintainState = true, multiple, offset = [0, 16], onChange, open: openDirection = 'right', options, sx, trigger, ...rest }) => {
5
+ const Dropdown = ({ checkbox, children, closeOnChange = true, closeOnBlur = true, defaultValue = '', disabled = false, hasArrow, maintainState = true, multiple, offset = [0, 16], onChange, open: openDirection = 'right', options, sx, trigger, containerSx, additionalOptions, additionalOnChange, defaultAdditionalValue, ...rest }) => {
6
6
  const id = React.useId();
7
7
  const wrapperRef = React.useRef(null);
8
8
  const optionsRef = React.useRef(null);
9
9
  const [open, setOpen] = React.useState(false);
10
10
  const [selected, setSelected] = React.useState(() => defaultValue ? defaultValue : multiple ? [] : '');
11
+ const [additionalSelected, setAdditionalSelected] = React.useState(defaultAdditionalValue || '');
11
12
  React.useEffect(() => {
12
13
  if (disabled) {
13
14
  setOpen(false);
@@ -57,6 +58,18 @@ const Dropdown = ({ checkbox, children, closeOnChange = true, closeOnBlur = true
57
58
  onChange(event);
58
59
  };
59
60
  const handleChange = multiple ? handleChangeMultiple : handleChangeSingle;
61
+ const handleAdditionalChange = (event) => {
62
+ event.stopPropagation();
63
+ const value = event.target.getAttribute('data-value') ?? '';
64
+ if (additionalSelected !== value) {
65
+ setAdditionalSelected(value);
66
+ }
67
+ else {
68
+ setAdditionalSelected('');
69
+ }
70
+ if (additionalOnChange)
71
+ additionalOnChange(value);
72
+ };
60
73
  const isSelected = (value) => maintainState && (multiple ? selected.includes(value) : value === selected);
61
74
  /**
62
75
  * allow for the API to accept children as options
@@ -91,7 +104,10 @@ const Dropdown = ({ checkbox, children, closeOnChange = true, closeOnBlur = true
91
104
  trigger.type?.name !== 'Button')
92
105
  ? { onClick: handleOpen }
93
106
  : { isDropdownOpen: open, onClick: handleOpen }),
94
- open && (React.createElement(Container, { "$hasArrow": hasArrow, "$offset": offset, "$openDirection": openDirection, ref: optionsRef }, dropdownOptions))));
107
+ open && (React.createElement(Container, { "$hasArrow": hasArrow, "$offset": offset, "$openDirection": openDirection, ref: optionsRef, "$sx": containerSx },
108
+ React.createElement("div", { style: { display: 'flex' } },
109
+ React.createElement("div", { style: { display: 'flex', flexDirection: 'column' } }, dropdownOptions),
110
+ !!additionalOptions?.length && (React.createElement("div", { style: { display: 'flex', flexDirection: 'column' } }, additionalOptions.map((additionalOption) => (React.createElement(Option, { key: additionalOption.value, onClick: handleAdditionalChange, selected: additionalSelected === additionalOption.value, label: additionalOption.label, value: additionalOption.value }))))))))));
95
111
  };
96
112
  const Wrapper = styled.div `
97
113
  position: relative;
@@ -109,6 +125,7 @@ const Container = styled.div `
109
125
  cursor: pointer;
110
126
  box-shadow: var(--elevation-2);
111
127
  border-radius: 8px;
128
+ overflow: scroll;
112
129
 
113
130
  & > div:first-of-type {
114
131
  border-radius: 8px 8px 0px 0px;
@@ -118,6 +135,8 @@ const Container = styled.div `
118
135
  border-radius: 0px 0px 8px 8px;
119
136
  }
120
137
 
138
+ ${({ $sx }) => ($sx ? $sx : '')}
139
+
121
140
  ${({ $openDirection }) => ($openDirection === 'left' ? 'right: 100%;' : '')}
122
141
 
123
142
  ${({ $hasArrow, $offset }) => $hasArrow
@@ -16,3 +16,5 @@ export { TextInput } from './text_input';
16
16
  export type { TextInputProps } from './text_input';
17
17
  export { CalendarInput } from './calendar';
18
18
  export type { CalendarInputProps } from './calendar';
19
+ export { Time } from './time';
20
+ export type { TimeProps } from './time';
@@ -7,3 +7,4 @@ export { Select } from './select';
7
7
  export { TextArea } from './text_area';
8
8
  export { TextInput } from './text_input';
9
9
  export { CalendarInput } from './calendar';
10
+ export { Time } from './time';
@@ -0,0 +1,2 @@
1
+ export { Time } from './time';
2
+ export type { TimeProps } from './time';
@@ -0,0 +1 @@
1
+ export { Time } from './time';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export type TimeProps = {
3
+ selectedTime: string;
4
+ setTime: (value: string) => void;
5
+ selectedPeriod: string;
6
+ setPeriod: (value: string) => void;
7
+ };
8
+ export declare const Time: ({ selectedTime, setTime, selectedPeriod, setPeriod, }: TimeProps) => React.JSX.Element;
@@ -0,0 +1,69 @@
1
+ 'use client';
2
+ import { Dropdown } from 'components/actions/dropdown/dropdown';
3
+ import { Icons } from 'index';
4
+ import React from 'react';
5
+ import styled from 'styled-components';
6
+ export const Time = ({ selectedTime, setTime, selectedPeriod, setPeriod, }) => {
7
+ const hours = React.useMemo(() => {
8
+ const hours = [];
9
+ for (let i = 1; i <= 12; i++) {
10
+ hours.push(`${i}:00`);
11
+ hours.push(`${i}:15`);
12
+ hours.push(`${i}:30`);
13
+ hours.push(`${i}:45`);
14
+ }
15
+ return hours;
16
+ }, []);
17
+ return (React.createElement(Dropdown, { options: hours.map((hour) => ({
18
+ value: hour,
19
+ label: hour,
20
+ })), containerSx: "height: 440px;", trigger: React.createElement(InputWrapper, null,
21
+ React.createElement(Input, { readOnly: true, value: `${selectedTime} ${selectedPeriod}` }),
22
+ React.createElement(Icons.Clock, null)), additionalOptions: [
23
+ {
24
+ label: 'AM',
25
+ value: 'AM',
26
+ },
27
+ {
28
+ label: 'PM',
29
+ value: 'PM',
30
+ },
31
+ ], onChange: (event) => {
32
+ const value = event.target.getAttribute('data-value') ?? '';
33
+ setTime(value);
34
+ }, additionalOnChange: setPeriod, defaultValue: selectedTime, defaultAdditionalValue: selectedPeriod }));
35
+ };
36
+ const InputWrapper = styled.div `
37
+ display: flex;
38
+ gap: 8px;
39
+ align-items: center;
40
+ box-sizing: border-box;
41
+ padding: 12px;
42
+ background-color: var(--color-blue-10);
43
+ border-radius: 8px;
44
+ border: 1px solid transparent;
45
+
46
+ &:hover {
47
+ border-color: var(--color-grey-8);
48
+ }
49
+
50
+ &:focus-within {
51
+ border-color: var(--color-primary-blue-2);
52
+ }
53
+ `;
54
+ const Input = styled.input `
55
+ padding: 0px;
56
+ flex: 1;
57
+ font-family: var(--font-inter);
58
+ font-size: 16px;
59
+ line-height: 24px;
60
+ color: var(--color-grey-3);
61
+ border: none;
62
+ outline: none;
63
+ border-radius: 8px;
64
+ background-color: transparent;
65
+
66
+ &::placeholder {
67
+ color: var(--color-grey-6);
68
+ }
69
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.89",
3
+ "version": "0.2.90",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {