pixel-react 1.1.9 → 1.2.1

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.
Files changed (62) hide show
  1. package/lib/components/AppHeader/types.d.ts +7 -7
  2. package/lib/components/Drawer/Drawer.stories.d.ts +2 -0
  3. package/lib/components/Drawer/Types.d.ts +11 -0
  4. package/lib/components/Icon/Icon.stories.d.ts +1 -0
  5. package/lib/components/Icon/types.d.ts +1 -0
  6. package/lib/components/InputWithDropdown/types.d.ts +1 -1
  7. package/lib/components/LabelEditTextField/LabelEditTextField.d.ts +5 -0
  8. package/lib/components/LabelEditTextField/LabelEditTextField.stories.d.ts +11 -0
  9. package/lib/components/LabelEditTextField/index.d.ts +1 -0
  10. package/lib/components/LabelEditTextField/types.d.ts +38 -0
  11. package/lib/components/Select/Select.d.ts +1 -1
  12. package/lib/components/Select/components/Dropdown/Dropdown.d.ts +1 -1
  13. package/lib/components/Select/components/Dropdown/dropdownTypes.d.ts +2 -0
  14. package/lib/components/Select/types.d.ts +11 -4
  15. package/lib/components/Table/Table.d.ts +1 -1
  16. package/lib/components/Table/Table.stories.d.ts +2 -0
  17. package/lib/components/Table/Types.d.ts +16 -0
  18. package/lib/index.d.ts +92 -16
  19. package/lib/index.esm.js +399 -152
  20. package/lib/index.esm.js.map +1 -1
  21. package/lib/index.js +399 -151
  22. package/lib/index.js.map +1 -1
  23. package/lib/tsconfig.tsbuildinfo +1 -1
  24. package/lib/utils/getSelectOptionValue/getSelectOptionValue.d.ts +8 -0
  25. package/package.json +1 -1
  26. package/src/assets/Themes/BaseTheme.scss +10 -0
  27. package/src/assets/Themes/DarkTheme.scss +19 -7
  28. package/src/assets/icons/eye_closed.svg +3 -0
  29. package/src/components/AppHeader/AppHeader.scss +14 -3
  30. package/src/components/AppHeader/AppHeader.stories.tsx +28 -28
  31. package/src/components/AppHeader/AppHeader.tsx +11 -11
  32. package/src/components/AppHeader/types.ts +7 -7
  33. package/src/components/Button/Button.scss +1 -0
  34. package/src/components/Checkbox/Checkbox.tsx +1 -1
  35. package/src/components/Drawer/Drawer.scss +13 -10
  36. package/src/components/Drawer/Drawer.stories.tsx +28 -0
  37. package/src/components/Drawer/Drawer.tsx +30 -7
  38. package/src/components/Drawer/Types.ts +11 -0
  39. package/src/components/Icon/Icon.stories.tsx +27 -0
  40. package/src/components/Icon/Icon.tsx +5 -1
  41. package/src/components/Icon/Icons.scss +14 -2
  42. package/src/components/Icon/iconList.ts +2 -0
  43. package/src/components/Icon/types.ts +1 -0
  44. package/src/components/InputWithDropdown/types.ts +1 -1
  45. package/src/components/LabelEditTextField/LabelEditTextField.scss +85 -0
  46. package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +136 -0
  47. package/src/components/LabelEditTextField/LabelEditTextField.tsx +207 -0
  48. package/src/components/LabelEditTextField/index.ts +1 -0
  49. package/src/components/LabelEditTextField/types.ts +38 -0
  50. package/src/components/Modal/Modal.tsx +8 -1
  51. package/src/components/Modal/modal.scss +10 -2
  52. package/src/components/Select/Select.stories.tsx +5 -3
  53. package/src/components/Select/Select.tsx +13 -5
  54. package/src/components/Select/components/Dropdown/Dropdown.tsx +3 -1
  55. package/src/components/Select/components/Dropdown/dropdownTypes.ts +3 -0
  56. package/src/components/Select/types.ts +12 -5
  57. package/src/components/Table/Table.scss +16 -4
  58. package/src/components/Table/Table.stories.tsx +36 -12
  59. package/src/components/Table/Table.tsx +33 -16
  60. package/src/components/Table/Types.ts +121 -105
  61. package/src/index.ts +2 -0
  62. package/src/utils/getSelectOptionValue/getSelectOptionValue.ts +31 -0
@@ -3,6 +3,7 @@ import { createPortal } from 'react-dom';
3
3
  import './modal.scss';
4
4
  import { ModalProps } from './types';
5
5
  import { ThemeContext } from '../ThemeProvider/ThemeProvider';
6
+ import classNames from 'classnames';
6
7
 
7
8
  const Modal: React.FC<ModalProps> = ({
8
9
  isOpen,
@@ -54,7 +55,13 @@ const Modal: React.FC<ModalProps> = ({
54
55
  onClick={shouldCloseOnOverlayClick ? onClose : undefined}
55
56
  >
56
57
  <div
57
- className={`ff-modal-content ${currentTheme} ${contentClassName || ''}`}
58
+ className={classNames(
59
+ `ff-modal-content ${currentTheme} ${contentClassName}`,
60
+ {
61
+ 'modal-bottom-border': !isFooterDisplayed,
62
+ 'modal-top-border': !isHeaderDisplayed,
63
+ }
64
+ )}
58
65
  style={{ width: customWidth, height: customHeight }}
59
66
  onClick={(e) => e.stopPropagation()}
60
67
  aria-label={contentLabel}
@@ -15,7 +15,6 @@
15
15
  background: var(--ff-mini-modal-border);
16
16
  position: relative;
17
17
  max-width: 100%;
18
- border-radius: 12px;
19
18
  padding: 8px;
20
19
 
21
20
  .ff-modal-header {
@@ -24,6 +23,15 @@
24
23
  }
25
24
  }
26
25
 
26
+ .modal-bottom-border {
27
+ border-bottom-left-radius: 12px;
28
+ border-bottom-right-radius: 12px;
29
+ }
30
+ .modal-top-border {
31
+ border-top-left-radius: 12px;
32
+ border-top-right-radius: 12px;
33
+ }
34
+
27
35
  .ff-modal-footer {
28
36
  background-color: var(--expandable-menu-option-bg);
29
37
  max-width: 100%;
@@ -35,5 +43,5 @@
35
43
  justify-content: end;
36
44
  align-items: center;
37
45
  gap: 8px;
38
- padding: 4px 16px;
46
+ padding: 4px 8px;
39
47
  }
@@ -17,10 +17,12 @@ type Story = StoryObj<typeof Select>;
17
17
  export const Primary: Story = {
18
18
  args: {
19
19
  label: 'Select',
20
+ labelAccessor: 'name',
21
+ valueAccessor: 'value',
20
22
  optionsList: [
21
- { label: 'Option 1', value: '1' },
22
- { label: 'Option 2', value: '2' },
23
- { label: 'Option 3', value: '3' },
23
+ { label: 'Option 1', value: '1', name: 'abcd' },
24
+ { label: 'Option 2', value: '2', name: '123' },
25
+ { label: 'Option 3', value: '3', name: '456' },
24
26
  ],
25
27
  },
26
28
  };
@@ -8,6 +8,7 @@ import Icon from '../Icon';
8
8
  import './Select.scss';
9
9
  import usePortalPosition from '../../hooks/usePortalPosition';
10
10
  import Typography from '../Typography';
11
+ import { getValue } from '../../utils/getSelectOptionValue/getSelectOptionValue';
11
12
 
12
13
  const selectReducer = (
13
14
  state: SelectState,
@@ -116,6 +117,8 @@ const Select = ({
116
117
  required = false,
117
118
  optionsRequired = true,
118
119
  selectedOptionColor = 'var(--ff-select-text-color)',
120
+ labelAccessor,
121
+ valueAccessor,
119
122
  }: SelectProps) => {
120
123
  const initialState: SelectState = useMemo(
121
124
  () => ({
@@ -164,7 +167,7 @@ const Select = ({
164
167
  if (actionType === 'SHOW_ERROR' || actionType === 'BLUR_INPUT') {
165
168
  dispatch({
166
169
  type: actionType,
167
- payload: { optionsList, option: selectedOption.value },
170
+ payload: { optionsList, option: getValue(selectedOption) },
168
171
  });
169
172
  } else {
170
173
  dispatch({ type: actionType });
@@ -176,9 +179,10 @@ const Select = ({
176
179
  if (disabled) return;
177
180
  const { value } = e.target;
178
181
  const filteredOptions = optionsList.filter((option) => {
179
- return typeof option.value === 'string'
180
- ? option.value.toLowerCase().includes(value.toLowerCase().trim())
181
- : option.value === Number(value);
182
+ const valueData = getValue(option, valueAccessor);
183
+ return typeof valueData === 'string'
184
+ ? valueData.toLowerCase().includes(value.toLowerCase().trim())
185
+ : valueData === Number(value);
182
186
  });
183
187
  dispatch({ type: 'UPDATE_OPTION_LIST', payload: filteredOptions });
184
188
  dispatch({ type: 'UPDATE_OPTION', payload: value });
@@ -197,7 +201,10 @@ const Select = ({
197
201
  const onSelectOptionSelector = (option: Option) => {
198
202
  if (!disabled) {
199
203
  onSelectBlur();
200
- dispatch({ type: 'UPDATE_OPTION', payload: option.value });
204
+ dispatch({
205
+ type: 'UPDATE_OPTION',
206
+ payload: getValue(option, valueAccessor),
207
+ });
201
208
  if (onChange) {
202
209
  onChange(option);
203
210
  }
@@ -361,6 +368,7 @@ const Select = ({
361
368
  options={options}
362
369
  optionZIndex={optionZIndex}
363
370
  inputRef={InputRef}
371
+ labelAccessor={labelAccessor}
364
372
  />,
365
373
  document.body
366
374
  )}
@@ -7,6 +7,7 @@ import Typography from '../../../Typography';
7
7
  import { ffid } from '../../../../utils/ffID/ffid';
8
8
  import { ThemeContext } from '../../../ThemeProvider/ThemeProvider';
9
9
  import classNames from 'classnames';
10
+ import { getLabel } from '../../../../utils/getSelectOptionValue/getSelectOptionValue';
10
11
 
11
12
  const Dropdown = ({
12
13
  onSelectBlur,
@@ -15,6 +16,7 @@ const Dropdown = ({
15
16
  options = [],
16
17
  optionZIndex = 100,
17
18
  inputRef,
19
+ labelAccessor,
18
20
  }: DropDownListProps) => {
19
21
  const themeContext = useContext(ThemeContext);
20
22
  const currentTheme = themeContext?.currentTheme;
@@ -71,7 +73,7 @@ const Dropdown = ({
71
73
  color="var(--ff-select-text-color)"
72
74
  onClick={() => onSelectOptionSelector(option)}
73
75
  >
74
- {option.label}
76
+ {getLabel(option, labelAccessor)}
75
77
  </Typography>
76
78
  ))
77
79
  ) : (
@@ -7,6 +7,8 @@ export interface DropDownListProps {
7
7
  options?: Option[];
8
8
  optionZIndex?: number;
9
9
  inputRef?: React.RefObject<HTMLInputElement>;
10
+ labelAccessor?: string;
11
+ valueAccessor?: string;
10
12
  }
11
13
 
12
14
  export const dropdownDefaultCSSData = {
@@ -17,3 +19,4 @@ export const dropdownDefaultCSSData = {
17
19
  // Future use case if we provide padding-top, padding-bottom for option wrapper
18
20
  dropDownWrapperPadding: 0,
19
21
  };
22
+
@@ -1,5 +1,3 @@
1
- import { ReactNode } from 'react';
2
-
3
1
  export interface SelectProps {
4
2
  /*
5
3
  * Label for the select dropdown
@@ -69,6 +67,15 @@ export interface SelectProps {
69
67
  * selectedOptionColor prop provides the custom color for the selected option
70
68
  */
71
69
  selectedOptionColor?: string;
70
+
71
+ /**
72
+ * Label accessor
73
+ */
74
+ labelAccessor?: string;
75
+ /**
76
+ * Value accessor
77
+ */
78
+ valueAccessor?: string;
72
79
  }
73
80
 
74
81
  export interface DrowdownPosition {
@@ -124,8 +131,8 @@ export type SelectAction =
124
131
  };
125
132
  };
126
133
 
134
+ type OptionValue = any;
135
+
127
136
  export interface Option {
128
- label: string | ReactNode;
129
- value: string;
130
- disabled?: boolean;
137
+ [key: string]: OptionValue;
131
138
  }
@@ -3,7 +3,14 @@
3
3
  .ff-fixed-header-table {
4
4
  overflow-y: auto;
5
5
  }
6
-
6
+ .ff-table-icon {
7
+ position: absolute;
8
+ top: 10px;
9
+ right: 0;
10
+ margin-right: 10px;
11
+ z-index: 100;
12
+ cursor: pointer;
13
+ }
7
14
  .ff-table {
8
15
  width: 100%;
9
16
  th,
@@ -16,7 +23,6 @@
16
23
  tr {
17
24
  th {
18
25
  @extend .fontMd;
19
- color: var(--text-color);
20
26
  border-bottom: 1px solid var(--slider-table-color);
21
27
  text-transform: uppercase;
22
28
  }
@@ -54,7 +60,7 @@
54
60
  }
55
61
  td {
56
62
  position: relative;
57
- color: var(--text-color);
63
+ color: var(--table-column-text-color);
58
64
  @extend .fontSm;
59
65
 
60
66
  &.clickable-cell {
@@ -81,6 +87,12 @@
81
87
  .default-bg {
82
88
  background-color: transparent;
83
89
  }
90
+ .default-color {
91
+ color: var(--table-header-text-color);
92
+ }
93
+ .primary-color {
94
+ color: var(--brand-color);
95
+ }
84
96
  }
85
97
  .border-borderRadius {
86
98
  border: 1px solid var(--slider-table-color);
@@ -104,4 +116,4 @@
104
116
  tbody tr.disabled-row {
105
117
  opacity: 0.5;
106
118
  cursor: not-allowed;
107
- }
119
+ }
@@ -26,7 +26,7 @@ const sampleData = [
26
26
  type: 'Web',
27
27
  status: 'Open',
28
28
  checked: false,
29
- disabled:true
29
+ disabled: true,
30
30
  },
31
31
  },
32
32
  {
@@ -37,7 +37,7 @@ const sampleData = [
37
37
  type: 'Mobile',
38
38
  status: 'Close',
39
39
  checked: true,
40
- disabled:true
40
+ disabled: true,
41
41
  },
42
42
  },
43
43
  {
@@ -48,7 +48,7 @@ const sampleData = [
48
48
  type: 'Web',
49
49
  status: 'Close',
50
50
  checked: true,
51
- disabled:true
51
+ disabled: true,
52
52
  },
53
53
  },
54
54
  {
@@ -59,7 +59,7 @@ const sampleData = [
59
59
  type: 'Web & Mobile',
60
60
  status: 'Open',
61
61
  checked: false,
62
- disabled:false
62
+ disabled: false,
63
63
  },
64
64
  },
65
65
  {
@@ -70,7 +70,7 @@ const sampleData = [
70
70
  type: 'Web',
71
71
  status: 'Open',
72
72
  checked: false,
73
- disabled:true
73
+ disabled: true,
74
74
  },
75
75
  },
76
76
  {
@@ -81,7 +81,7 @@ const sampleData = [
81
81
  type: 'Mobile',
82
82
  status: 'Close',
83
83
  checked: true,
84
- disabled:true
84
+ disabled: true,
85
85
  },
86
86
  },
87
87
  {
@@ -92,7 +92,7 @@ const sampleData = [
92
92
  type: 'Web',
93
93
  status: 'Close',
94
94
  checked: true,
95
- disabled:true
95
+ disabled: true,
96
96
  },
97
97
  },
98
98
  {
@@ -103,7 +103,7 @@ const sampleData = [
103
103
  type: 'Web & Mobile',
104
104
  status: 'Open',
105
105
  checked: false,
106
- disabled:false
106
+ disabled: false,
107
107
  },
108
108
  },
109
109
  {
@@ -114,7 +114,7 @@ const sampleData = [
114
114
  type: 'Web',
115
115
  status: 'Open',
116
116
  checked: false,
117
- disabled:false
117
+ disabled: false,
118
118
  },
119
119
  },
120
120
  {
@@ -125,7 +125,7 @@ const sampleData = [
125
125
  type: 'Mobile',
126
126
  status: 'Close',
127
127
  checked: true,
128
- disabled:false
128
+ disabled: false,
129
129
  },
130
130
  },
131
131
  {
@@ -136,7 +136,7 @@ const sampleData = [
136
136
  type: 'Web',
137
137
  status: 'Close',
138
138
  checked: true,
139
- disabled:false
139
+ disabled: false,
140
140
  },
141
141
  },
142
142
  {
@@ -147,7 +147,7 @@ const sampleData = [
147
147
  type: 'Web & Mobile',
148
148
  status: 'Open',
149
149
  checked: false,
150
- disabled:false
150
+ disabled: false,
151
151
  },
152
152
  },
153
153
  ];
@@ -202,6 +202,27 @@ export const Default: Story = {
202
202
  columns: columnsData,
203
203
  },
204
204
  };
205
+
206
+ export const PrimaryHeaderTextColor: Story = {
207
+ args: {
208
+ ...defaultArgs,
209
+ data: sampleData.map((x) => x.project),
210
+
211
+ columns: columnsData,
212
+ headerTextColor: 'primary',
213
+ },
214
+ };
215
+
216
+ export const TableDataTextColor: Story = {
217
+ args: {
218
+ ...defaultArgs,
219
+ data: sampleData.map((x) => x.project),
220
+
221
+ columns: columnsData,
222
+ tableDataTextColor: 'var(--brand-color)',
223
+ },
224
+ };
225
+
205
226
  export const PageTable: Story = {
206
227
  args: {
207
228
  ...defaultArgs,
@@ -217,6 +238,7 @@ export const PageTable: Story = {
217
238
  });
218
239
  setTableData(sampleArray);
219
240
  }, []);
241
+ const handleIconClick = () => {};
220
242
 
221
243
  return (
222
244
  <>
@@ -226,6 +248,8 @@ export const PageTable: Story = {
226
248
  columns={columnsData}
227
249
  headerType="secondary"
228
250
  noDataContent="No data found"
251
+ headerIconName={'expand_icon'}
252
+ headerIconOnClick={handleIconClick}
229
253
  />
230
254
  </>
231
255
  );
@@ -1,5 +1,4 @@
1
1
  import './Table.scss';
2
- // import Checkbox from '../Checkbox';
3
2
  import { isFunction } from '../../assets/utils/functionUtils';
4
3
  import classNames from 'classnames';
5
4
  import {
@@ -11,6 +10,8 @@ import {
11
10
  import { prepareData } from '../../utils/TableCell/TableCell';
12
11
  import Checkbox from '../Checkbox';
13
12
  import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
13
+ import Typography from '../Typography';
14
+ import Icon from '../Icon';
14
15
 
15
16
  // import NoData from '../NoData/NoData';
16
17
 
@@ -25,13 +26,17 @@ const Table = ({
25
26
  withFixedHeader = true,
26
27
  borderWithRadius = false,
27
28
  headerCheckboxDisabled = false,
28
- // noDataContent,
29
+ noDataContent,
29
30
  // noDataImage,
30
31
  // noDataImageSize,
31
32
  height = '100%',
32
33
  className = '',
33
34
  tableHeadClass = '',
34
35
  tableBodyRowClass = '',
36
+ headerTextColor,
37
+ tableDataTextColor,
38
+ headerIconName = '',
39
+ headerIconOnClick = () => {},
35
40
  }: TableProps) => {
36
41
  const hanleOnclick = (column: ColumnsProps, row: DataProps) => {
37
42
  let { onClick, accessor } = column;
@@ -48,12 +53,22 @@ const Table = ({
48
53
 
49
54
  return (
50
55
  <div
51
- style={{ height: height }}
56
+ style={{ height: height, position: 'relative' }}
52
57
  className={classNames(className, {
53
58
  'ff-fixed-header-table': withFixedHeader,
54
59
  'border-borderRadius': borderWithRadius,
55
60
  })}
56
61
  >
62
+ {/* {iconContainer ? iconContainer : ''} */}
63
+ <div className="ff-table-icon">
64
+ <Icon
65
+ height={14}
66
+ width={14}
67
+ name={headerIconName}
68
+ onClick={headerIconOnClick}
69
+ ></Icon>
70
+ </div>
71
+
57
72
  <table className={classNames(`ff-table`)} cellSpacing={0}>
58
73
  <thead
59
74
  className={classNames(
@@ -67,7 +82,10 @@ const Table = ({
67
82
  {/* columns.map((column, index) */}
68
83
  {columns.map((column, index) => (
69
84
  <th
70
- className={headerType && `${headerType}-bg`}
85
+ className={classNames(
86
+ `${headerType && `${headerType}-bg`}`,
87
+ `${headerTextColor && `${headerTextColor}-color`}`
88
+ )}
71
89
  key={column.header}
72
90
  style={{ width: column?.width }}
73
91
  >
@@ -98,12 +116,9 @@ const Table = ({
98
116
  data.map((row: any, index: number) => (
99
117
  <tr
100
118
  key={row.id || index}
101
- className={classNames(
102
- tableBodyRowClass,
103
- {
104
- 'disabled-row': row.disabled,
105
- },
106
- )}
119
+ className={classNames(tableBodyRowClass, {
120
+ 'disabled-row': row.disabled,
121
+ })}
107
122
  >
108
123
  {columns.map((column, i) => {
109
124
  return (
@@ -114,7 +129,7 @@ const Table = ({
114
129
  'clickable-cell': column.onClick,
115
130
  })}
116
131
  >
117
- <div>
132
+ <Typography as="div" color={tableDataTextColor}>
118
133
  {i === 0 && withCheckbox && (
119
134
  <span className="ff-table-checkbox">
120
135
  <Checkbox
@@ -127,7 +142,7 @@ const Table = ({
127
142
  </span>
128
143
  )}
129
144
  {prepareData(row, column)}
130
- </div>
145
+ </Typography>
131
146
  </td>
132
147
  );
133
148
  })}
@@ -135,18 +150,20 @@ const Table = ({
135
150
  ))}
136
151
  </tbody>
137
152
  </table>
138
- {/* {data.length <= 0 && (
153
+ {data.length <= 0 && (
139
154
  <div
140
155
  className="no-data-content"
141
156
  style={{ height: `calc(${height} - 50px)` }}
142
157
  >
143
- <NoData
158
+ {/* commented for future requirement for adding image when the data will not be present*/}
159
+ {/* <NoData
144
160
  image={noDataImage ? noDataImage : 'no_data_found'}
145
161
  content={noDataContent}
146
162
  size={noDataImageSize}
147
- />
163
+ /> */}
164
+ {noDataContent}
148
165
  </div>
149
- )} */}
166
+ )}
150
167
  </div>
151
168
  );
152
169
  };