@quillsql/react 1.1.8 → 1.2.0
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.
- package/lib/BarList.d.ts +1 -0
- package/lib/BarList.js +129 -37
- package/lib/BarList.js.map +1 -1
- package/lib/Chart.d.ts +3 -3
- package/lib/Chart.js +66 -30
- package/lib/Chart.js.map +1 -1
- package/lib/Context.d.ts +1 -1
- package/lib/Dashboard.d.ts +1 -1
- package/lib/Dashboard.js +0 -4
- package/lib/Dashboard.js.map +1 -1
- package/lib/DateRangePicker/Calendar.d.ts +1 -1
- package/lib/DateRangePicker/Calendar.js +122 -23
- package/lib/DateRangePicker/Calendar.js.map +1 -1
- package/lib/DateRangePicker/DateRangePicker.js +5 -6
- package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
- package/lib/DateRangePicker/DateRangePickerButton.d.ts +1 -1
- package/lib/DateRangePicker/DateRangePickerButton.js +101 -17
- package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
- package/lib/DateRangePicker/dateRangePickerUtils.d.ts +1 -3
- package/lib/DateRangePicker/dateRangePickerUtils.js +113 -79
- package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
- package/lib/PieChart.d.ts +3 -10
- package/lib/PieChart.js +51 -103
- package/lib/PieChart.js.map +1 -1
- package/lib/QuillProvider.d.ts +1 -2
- package/lib/assets/ArrowDownHeadIcon.d.ts +1 -2
- package/lib/assets/ArrowDownIcon.d.ts +1 -2
- package/lib/assets/ArrowDownRightIcon.d.ts +1 -2
- package/lib/assets/ArrowLeftHeadIcon.d.ts +1 -2
- package/lib/assets/ArrowRightHeadIcon.d.ts +1 -2
- package/lib/assets/ArrowRightIcon.d.ts +1 -2
- package/lib/assets/ArrowUpHeadIcon.d.ts +1 -2
- package/lib/assets/ArrowUpIcon.d.ts +1 -2
- package/lib/assets/ArrowUpRightIcon.d.ts +1 -2
- package/lib/assets/CalendarIcon.d.ts +1 -2
- package/lib/assets/DoubleArrowLeftHeadIcon.d.ts +1 -2
- package/lib/assets/DoubleArrowRightHeadIcon.d.ts +1 -2
- package/lib/assets/ExclamationFilledIcon.d.ts +1 -2
- package/lib/assets/LoadingSpinner.d.ts +1 -2
- package/lib/assets/SearchIcon.d.ts +1 -2
- package/lib/assets/XCircleIcon.d.ts +1 -2
- package/lib/components/Dropdown/Dropdown.js +45 -14
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/DropdownItem.d.ts +1 -0
- package/lib/components/Dropdown/DropdownItem.js +21 -29
- package/lib/components/Dropdown/DropdownItem.js.map +1 -1
- package/lib/components/Modal/Modal.d.ts +1 -0
- package/lib/components/Modal/Modal.js +47 -9
- package/lib/components/Modal/Modal.js.map +1 -1
- package/lib/components/selectUtils.d.ts +1 -1
- package/lib/components/selectUtils.js +18 -12
- package/lib/components/selectUtils.js.map +1 -1
- package/lib/contexts/BaseColorContext.d.ts +1 -1
- package/lib/contexts/BaseColorContext.js +1 -2
- package/lib/contexts/BaseColorContext.js.map +1 -1
- package/lib/lib/index.d.ts +0 -7
- package/lib/lib/index.js +0 -7
- package/lib/lib/index.js.map +1 -1
- package/lib/lib/utils.d.ts +1 -4
- package/lib/lib/utils.js +4 -33
- package/lib/lib/utils.js.map +1 -1
- package/package.json +1 -8
- package/src/BarList.tsx +193 -96
- package/src/Chart.tsx +108 -48
- package/src/Dashboard.tsx +10 -10
- package/src/DateRangePicker/Calendar.tsx +149 -165
- package/src/DateRangePicker/DateRangePicker.tsx +11 -11
- package/src/DateRangePicker/DateRangePickerButton.tsx +129 -84
- package/src/DateRangePicker/dateRangePickerUtils.tsx +137 -117
- package/src/PieChart.tsx +87 -111
- package/src/components/Dropdown/Dropdown.tsx +50 -69
- package/src/components/Dropdown/DropdownItem.tsx +15 -50
- package/src/components/Modal/Modal.tsx +50 -31
- package/src/components/selectUtils.ts +19 -26
- package/src/contexts/BaseColorContext.tsx +1 -4
- package/src/lib/index.ts +0 -7
- package/src/lib/utils.tsx +8 -43
- package/src/styles.css +0 -5
- package/example/README.md +0 -46
- package/example/package-lock.json +0 -12111
- package/example/package.json +0 -43
- package/example/public/favicon.ico +0 -0
- package/example/public/index.html +0 -43
- package/example/public/logo192.png +0 -0
- package/example/public/logo512.png +0 -0
- package/example/public/manifest.json +0 -25
- package/example/public/robots.txt +0 -3
- package/example/src/App.css +0 -38
- package/example/src/App.test.tsx +0 -9
- package/example/src/App.tsx +0 -47
- package/example/src/index.css +0 -13
- package/example/src/index.tsx +0 -19
- package/example/src/logo.svg +0 -1
- package/example/src/react-app-env.d.ts +0 -1
- package/example/src/reportWebVitals.ts +0 -15
- package/example/src/setupTests.ts +0 -5
- package/example/tsconfig.json +0 -26
- package/postcss.config.js +0 -6
- package/src/lib/colorClassNames.ts +0 -3191
- package/src/lib/constants.ts +0 -58
- package/src/lib/hexColors.ts +0 -28
- package/src/lib/shape.ts +0 -75
- package/src/lib/sizing.ts +0 -47
- package/src/lib/spacing.ts +0 -264
- package/src/lib/theme.ts +0 -49
- package/tailwind.config.js +0 -23
package/src/PieChart.tsx
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/* eslint-disable react/display-name */
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
import React, { useRef, useState, useEffect, CSSProperties } from 'react';
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
6
5
|
import { Pie, PieChart, ResponsiveContainer, Tooltip, Legend } from 'recharts';
|
|
7
6
|
|
|
8
7
|
// const data = [
|
|
@@ -230,83 +229,6 @@ export type FlexDirection = 'row' | 'col' | 'row-reverse' | 'col-reverse';
|
|
|
230
229
|
export const defaultValueFormatter: ValueFormatter = (value: number) =>
|
|
231
230
|
(value * 1).toFixed(1) + '%';
|
|
232
231
|
|
|
233
|
-
export const BaseColors: { [key: string]: Color } = {
|
|
234
|
-
Slate: 'slate',
|
|
235
|
-
Gray: 'gray',
|
|
236
|
-
Zinc: 'zinc',
|
|
237
|
-
Neutral: 'neutral',
|
|
238
|
-
Stone: 'stone',
|
|
239
|
-
Red: 'red',
|
|
240
|
-
Orange: 'orange',
|
|
241
|
-
Amber: 'amber',
|
|
242
|
-
Yellow: 'yellow',
|
|
243
|
-
Lime: 'lime',
|
|
244
|
-
Green: 'green',
|
|
245
|
-
Emerald: 'emerald',
|
|
246
|
-
Teal: 'teal',
|
|
247
|
-
Cyan: 'cyan',
|
|
248
|
-
Sky: 'sky',
|
|
249
|
-
Blue: 'blue',
|
|
250
|
-
Indigo: 'indigo',
|
|
251
|
-
Violet: 'violet',
|
|
252
|
-
Purple: 'purple',
|
|
253
|
-
Fuchsia: 'fuchsia',
|
|
254
|
-
Pink: 'pink',
|
|
255
|
-
Rose: 'rose',
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export const hexColors: { [color: string]: string } = {
|
|
259
|
-
[BaseColors.Slate]: '#64748b',
|
|
260
|
-
[BaseColors.Gray]: '#6b7280',
|
|
261
|
-
[BaseColors.Zinc]: '#71717a',
|
|
262
|
-
[BaseColors.Neutral]: '#737373',
|
|
263
|
-
[BaseColors.Stone]: '#78716c',
|
|
264
|
-
[BaseColors.Red]: '#ef4444',
|
|
265
|
-
[BaseColors.Orange]: '#f97316',
|
|
266
|
-
[BaseColors.Amber]: '#f59e0b',
|
|
267
|
-
[BaseColors.Yellow]: '#eab308',
|
|
268
|
-
[BaseColors.Lime]: '#84cc16',
|
|
269
|
-
[BaseColors.Green]: '#22c55e',
|
|
270
|
-
[BaseColors.Emerald]: '#10b981',
|
|
271
|
-
[BaseColors.Teal]: '#14b8a6',
|
|
272
|
-
[BaseColors.Cyan]: '#06b6d4',
|
|
273
|
-
[BaseColors.Sky]: '#0ea5e9',
|
|
274
|
-
[BaseColors.Blue]: '#3b82f6',
|
|
275
|
-
[BaseColors.Indigo]: '#6366f1',
|
|
276
|
-
[BaseColors.Violet]: '#8b5cf6',
|
|
277
|
-
[BaseColors.Purple]: '#a855f7',
|
|
278
|
-
[BaseColors.Fuchsia]: '#d946ef',
|
|
279
|
-
[BaseColors.Pink]: '#ec4899',
|
|
280
|
-
[BaseColors.Rose]: '#f43f5e',
|
|
281
|
-
[BaseColors.Black]: '#000000',
|
|
282
|
-
[BaseColors.White]: '#ffffff',
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
export const themeColorRange: Color[] = [
|
|
286
|
-
BaseColors.Cyan,
|
|
287
|
-
BaseColors.Sky,
|
|
288
|
-
BaseColors.Blue,
|
|
289
|
-
BaseColors.Indigo,
|
|
290
|
-
BaseColors.Violet,
|
|
291
|
-
BaseColors.Purple,
|
|
292
|
-
BaseColors.Fuchsia,
|
|
293
|
-
BaseColors.Slate,
|
|
294
|
-
BaseColors.Gray,
|
|
295
|
-
BaseColors.Zinc,
|
|
296
|
-
BaseColors.Neutral,
|
|
297
|
-
BaseColors.Stone,
|
|
298
|
-
BaseColors.Red,
|
|
299
|
-
BaseColors.Orange,
|
|
300
|
-
BaseColors.Amber,
|
|
301
|
-
BaseColors.Yellow,
|
|
302
|
-
BaseColors.Lime,
|
|
303
|
-
BaseColors.Green,
|
|
304
|
-
BaseColors.Emerald,
|
|
305
|
-
BaseColors.Teal,
|
|
306
|
-
BaseColors.Pink,
|
|
307
|
-
BaseColors.Rose,
|
|
308
|
-
];
|
|
309
|
-
|
|
310
232
|
export const sumNumericArray = (arr: number[]) =>
|
|
311
233
|
arr.reduce((prefixSum, num) => prefixSum + num, 0);
|
|
312
234
|
|
|
@@ -391,9 +313,14 @@ export const ChartTooltipFrame = ({
|
|
|
391
313
|
borderStyle: 'solid',
|
|
392
314
|
borderColor: theme?.borderColor || '#E5E7EB',
|
|
393
315
|
borderWidth: 1,
|
|
316
|
+
background: theme?.backgroundColor || '#ffffff',
|
|
317
|
+
fontSize: '0.875rem',
|
|
318
|
+
borderRadius: '0.375rem',
|
|
319
|
+
boxShadow:
|
|
320
|
+
'0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
|
394
321
|
}}
|
|
395
322
|
// style={{ transform: 'translateX(-120px)' }}
|
|
396
|
-
className="qq-bg-white qq-text-sm qq-rounded-md qq-shadow-lg"
|
|
323
|
+
// className="qq-bg-white qq-text-sm qq-rounded-md qq-shadow-lg"
|
|
397
324
|
// className={twMerge(
|
|
398
325
|
// 'bg-white',
|
|
399
326
|
// 'font-normal',
|
|
@@ -420,29 +347,52 @@ export const ChartTooltipRow = ({
|
|
|
420
347
|
color,
|
|
421
348
|
theme,
|
|
422
349
|
}: ChartTooltipRowProps) => (
|
|
423
|
-
<div
|
|
424
|
-
|
|
350
|
+
<div
|
|
351
|
+
style={{
|
|
352
|
+
display: 'flex',
|
|
353
|
+
alignItems: 'center',
|
|
354
|
+
justifyContent: 'space-between',
|
|
355
|
+
minWidth: 120,
|
|
356
|
+
// minHeight: 27,
|
|
357
|
+
// margin: '0 2rem',
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
<div
|
|
361
|
+
style={{
|
|
362
|
+
display: 'flex',
|
|
363
|
+
alignItems: 'center',
|
|
364
|
+
justifyContent: 'space-between',
|
|
365
|
+
// margin: '0 0.5rem',
|
|
366
|
+
// minWidth: 120,
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
425
369
|
<span
|
|
426
370
|
style={{
|
|
427
371
|
background: color,
|
|
428
372
|
borderWidth: 2,
|
|
429
373
|
borderStyle: 'solid',
|
|
430
374
|
borderColor: 'white',
|
|
375
|
+
height: '0.5rem',
|
|
376
|
+
width: '0.5rem',
|
|
377
|
+
boxShadow:
|
|
378
|
+
'0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
|
|
379
|
+
borderRadius: '9999px',
|
|
380
|
+
marginRight: 5,
|
|
431
381
|
}}
|
|
432
|
-
className={twMerge(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
)}
|
|
382
|
+
// className={twMerge(
|
|
383
|
+
// 'shrink-0',
|
|
384
|
+
// 'bg-black',
|
|
385
|
+
// 'bg-white',
|
|
386
|
+
// 'border-black',
|
|
387
|
+
// sizing.sm.height,
|
|
388
|
+
// sizing.sm.width,
|
|
389
|
+
// 'qq-h-3',
|
|
390
|
+
// 'qq-w-3',
|
|
391
|
+
// 'qq-shadow',
|
|
392
|
+
// 'qq-rounded-full'
|
|
393
|
+
// border.md.all,
|
|
394
|
+
// boxShadow.md
|
|
395
|
+
// )}
|
|
446
396
|
/>
|
|
447
397
|
<p
|
|
448
398
|
// className={twMerge(
|
|
@@ -454,8 +404,12 @@ export const ChartTooltipRow = ({
|
|
|
454
404
|
marginBottom: 0,
|
|
455
405
|
fontFamily: theme?.fontFamily,
|
|
456
406
|
color: theme?.primaryTextColor,
|
|
407
|
+
paddingTop: 2,
|
|
408
|
+
paddingBottom: 2,
|
|
409
|
+
fontSize: theme?.fontSizeSmall || '0.875rem',
|
|
410
|
+
fontWeight: theme?.fontWeightMedium || '500',
|
|
457
411
|
}}
|
|
458
|
-
className="qq-font-medium qq-tabular-nums qq-text-right qq-whitespace-nowrap"
|
|
412
|
+
// className="qq-font-medium qq-tabular-nums qq-text-right qq-whitespace-nowrap"
|
|
459
413
|
>
|
|
460
414
|
{value}
|
|
461
415
|
</p>
|
|
@@ -466,13 +420,19 @@ export const ChartTooltipRow = ({
|
|
|
466
420
|
marginBottom: 0,
|
|
467
421
|
fontFamily: theme?.fontFamily,
|
|
468
422
|
color: theme?.secondaryTextColor,
|
|
423
|
+
whiteSpace: 'nowrap',
|
|
424
|
+
overflow: 'hidden',
|
|
425
|
+
textOverflow: 'ellipsis',
|
|
426
|
+
textAlign: 'right',
|
|
427
|
+
fontSize: theme?.fontSizeSmall || '0.875rem',
|
|
428
|
+
fontWeight: theme?.fontWeightNormal || '400',
|
|
469
429
|
}}
|
|
470
|
-
className={twMerge(
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
)}
|
|
430
|
+
// className={twMerge(
|
|
431
|
+
// 'qq-text-right qq-whitespace-nowrap'
|
|
432
|
+
// getColorClassNames(DEFAULT_COLOR, colorPalette.text).textColor,
|
|
433
|
+
// 'qq-text-gray-500'
|
|
434
|
+
// fontWeight.sm
|
|
435
|
+
// )}
|
|
476
436
|
>
|
|
477
437
|
{name}
|
|
478
438
|
</p>
|
|
@@ -498,7 +458,13 @@ export const DonutChartTooltip = ({
|
|
|
498
458
|
<ChartTooltipFrame theme={theme}>
|
|
499
459
|
<div
|
|
500
460
|
// style={{ transform: 'translateX(-120px)' }}
|
|
501
|
-
className={twMerge('qq-px-4', 'qq-py-2')}
|
|
461
|
+
// className={twMerge('qq-px-4', 'qq-py-2')}
|
|
462
|
+
style={{
|
|
463
|
+
paddingLeft: '1rem',
|
|
464
|
+
paddingRight: '1rem',
|
|
465
|
+
paddingTop: '0.5rem',
|
|
466
|
+
paddingBottom: '0.5rem',
|
|
467
|
+
}}
|
|
502
468
|
>
|
|
503
469
|
<ChartTooltipRow
|
|
504
470
|
value={valueFormatter(payloadRow.value)}
|
|
@@ -756,11 +722,19 @@ const PieChartWrapper = React.forwardRef<HTMLDivElement, DonutChartProps>(
|
|
|
756
722
|
return (
|
|
757
723
|
<div
|
|
758
724
|
ref={ref}
|
|
759
|
-
style={
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
725
|
+
style={{
|
|
726
|
+
...containerStyle,
|
|
727
|
+
width: '100%',
|
|
728
|
+
// height: '100%',
|
|
729
|
+
display: 'flex',
|
|
730
|
+
flexDirection: 'row',
|
|
731
|
+
alignItems: 'center',
|
|
732
|
+
boxSizing: 'content-box',
|
|
733
|
+
}}
|
|
734
|
+
// className={twMerge(
|
|
735
|
+
// 'w-full h-full flex flex-row items-center',
|
|
736
|
+
// className
|
|
737
|
+
// )}
|
|
764
738
|
{...other}
|
|
765
739
|
>
|
|
766
740
|
<ResponsiveContainer width="100%" height="100%">
|
|
@@ -826,7 +800,9 @@ const PieChartWrapper = React.forwardRef<HTMLDivElement, DonutChartProps>(
|
|
|
826
800
|
|
|
827
801
|
function Legend2({ payload, colors }: { payload: any; colors: string[] }) {
|
|
828
802
|
return (
|
|
829
|
-
<div
|
|
803
|
+
<div
|
|
804
|
+
// className="flex flex-col min-w-[130px] max-w-[130px] w-full"
|
|
805
|
+
>
|
|
830
806
|
{/* @ts-ignore */}
|
|
831
807
|
{payload.map((item, idx) => {
|
|
832
808
|
if (idx > 9) {
|
|
@@ -835,7 +811,7 @@ function Legend2({ payload, colors }: { payload: any; colors: string[] }) {
|
|
|
835
811
|
return (
|
|
836
812
|
<div
|
|
837
813
|
key={item.value}
|
|
838
|
-
className="flex flex-row items-center min-w-[130px] max-w-[130px]"
|
|
814
|
+
// className="flex flex-row items-center min-w-[130px] max-w-[130px]"
|
|
839
815
|
>
|
|
840
816
|
<div
|
|
841
817
|
style={{
|
|
@@ -855,7 +831,7 @@ function Legend2({ payload, colors }: { payload: any; colors: string[] }) {
|
|
|
855
831
|
display: 'block',
|
|
856
832
|
maxWidth: 120,
|
|
857
833
|
}}
|
|
858
|
-
className="qq-text-sm qq-text-gray-600 qq-whitespace-nowrap qq-overflow-hidden qq-overflow-ellipsis qq-text-sm qq-font-normal"
|
|
834
|
+
// className="qq-text-sm qq-text-gray-600 qq-whitespace-nowrap qq-overflow-hidden qq-overflow-ellipsis qq-text-sm qq-font-normal"
|
|
859
835
|
>
|
|
860
836
|
{item.value}
|
|
861
837
|
</div>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/display-name */
|
|
2
2
|
import React, { useRef, useState } from 'react';
|
|
3
|
-
import { twMerge } from 'tailwind-merge';
|
|
4
3
|
|
|
5
4
|
import { HoveredValueContext, SelectedValueContext } from '../../contexts';
|
|
6
5
|
|
|
@@ -8,29 +7,10 @@ import { useInternalState, useSelectOnKeyDown } from '../../hooks';
|
|
|
8
7
|
|
|
9
8
|
import { ArrowDownHeadIcon } from '../../assets';
|
|
10
9
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
border,
|
|
14
|
-
borderRadius,
|
|
15
|
-
boxShadow,
|
|
16
|
-
fontSize,
|
|
17
|
-
fontWeight,
|
|
18
|
-
getColorClassNames,
|
|
19
|
-
makeClassName,
|
|
20
|
-
mergeRefs,
|
|
21
|
-
sizing,
|
|
22
|
-
spacing,
|
|
23
|
-
} from '../../lib';
|
|
24
|
-
import {
|
|
25
|
-
constructValueToNameMapping,
|
|
26
|
-
getSelectButtonColors,
|
|
27
|
-
hasValue,
|
|
28
|
-
} from '../selectUtils';
|
|
10
|
+
import { mergeRefs } from '../../lib';
|
|
11
|
+
import { constructValueToNameMapping, hasValue } from '../selectUtils';
|
|
29
12
|
import { DropdownItemProps } from './DropdownItem';
|
|
30
13
|
import Modal from '../Modal';
|
|
31
|
-
import { DEFAULT_COLOR, colorPalette } from '../../lib/theme';
|
|
32
|
-
|
|
33
|
-
const makeDropdownClassName = makeClassName('Dropdown');
|
|
34
14
|
|
|
35
15
|
export interface DropdownProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
36
16
|
value?: string;
|
|
@@ -92,60 +72,62 @@ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
|
|
|
92
72
|
<div
|
|
93
73
|
ref={mergeRefs([dropdownRef, ref])}
|
|
94
74
|
onKeyDown={handleKeyDown}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
75
|
+
style={{
|
|
76
|
+
position: 'relative',
|
|
77
|
+
width: '100%',
|
|
78
|
+
minWidth: '10rem',
|
|
79
|
+
}}
|
|
100
80
|
{...other}
|
|
101
81
|
>
|
|
102
82
|
<button
|
|
103
83
|
style={{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
84
|
+
display: 'flex',
|
|
85
|
+
justifyContent: 'space-between',
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
width: '100%',
|
|
88
|
+
outline: 'none',
|
|
89
|
+
padding: '1.5rem 2rem',
|
|
90
|
+
borderRadius: '0.375rem',
|
|
91
|
+
border: '2px solid',
|
|
92
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
93
|
+
cursor: 'pointer',
|
|
107
94
|
background: 'white',
|
|
108
95
|
}}
|
|
109
96
|
type="button"
|
|
110
|
-
className={twMerge(
|
|
111
|
-
makeDropdownClassName('button'),
|
|
112
|
-
'qq-flex qq-justify-between qq-items-center qq-w-full focus:qq-outline-none focus:qq-ring-2',
|
|
113
|
-
getSelectButtonColors(hasSelection, disabled),
|
|
114
|
-
getColorClassNames(BaseColors.Blue, colorPalette.lightRing)
|
|
115
|
-
.focusRingColor,
|
|
116
|
-
Icon ? spacing.xl.paddingLeft : spacing.twoXl.paddingLeft,
|
|
117
|
-
spacing.twoXl.paddingRight,
|
|
118
|
-
spacing.sm.paddingY,
|
|
119
|
-
borderRadius.md.all,
|
|
120
|
-
border.sm.all,
|
|
121
|
-
boxShadow.sm
|
|
122
|
-
)}
|
|
123
97
|
onClick={() => setIsFocused(!isFocused)}
|
|
124
98
|
disabled={disabled}
|
|
125
99
|
>
|
|
126
|
-
<div
|
|
100
|
+
<div
|
|
101
|
+
style={{
|
|
102
|
+
display: 'flex',
|
|
103
|
+
justifyContent: 'start',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
whiteSpace: 'nowrap',
|
|
106
|
+
overflow: 'hidden',
|
|
107
|
+
textOverflow: 'ellipsis',
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
127
110
|
{Icon ? (
|
|
128
111
|
<Icon
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
'
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
spacing.lg.marginRight
|
|
137
|
-
)}
|
|
112
|
+
style={{
|
|
113
|
+
flexShrink: 0,
|
|
114
|
+
height: '1.5rem',
|
|
115
|
+
width: '1.5rem',
|
|
116
|
+
color: theme?.secondaryTextColor || '#6C727F',
|
|
117
|
+
marginRight: '1.5rem',
|
|
118
|
+
}}
|
|
138
119
|
aria-hidden="true"
|
|
139
120
|
/>
|
|
140
121
|
) : null}
|
|
141
122
|
<p
|
|
142
|
-
style={{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
123
|
+
style={{
|
|
124
|
+
margin: 0,
|
|
125
|
+
fontSize: '0.875rem',
|
|
126
|
+
fontWeight: '500',
|
|
127
|
+
whiteSpace: 'nowrap',
|
|
128
|
+
overflow: 'hidden',
|
|
129
|
+
textOverflow: 'ellipsis',
|
|
130
|
+
}}
|
|
149
131
|
>
|
|
150
132
|
{selectedValue
|
|
151
133
|
? valueToNameMapping.get(selectedValue)
|
|
@@ -153,19 +135,18 @@ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
|
|
|
153
135
|
</p>
|
|
154
136
|
</div>
|
|
155
137
|
<ArrowDownHeadIcon
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
'
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
.textColor
|
|
164
|
-
)}
|
|
138
|
+
style={{
|
|
139
|
+
flexShrink: 0,
|
|
140
|
+
height: '1.5rem',
|
|
141
|
+
width: '1.5rem',
|
|
142
|
+
marginRight: '-0.25rem',
|
|
143
|
+
color: theme?.secondaryTextColor || '#6C727F',
|
|
144
|
+
}}
|
|
165
145
|
aria-hidden="true"
|
|
166
146
|
/>
|
|
167
147
|
</button>
|
|
168
148
|
<Modal
|
|
149
|
+
theme={theme}
|
|
169
150
|
showModal={isFocused}
|
|
170
151
|
setShowModal={setIsFocused}
|
|
171
152
|
parentRef={dropdownRef}
|
|
@@ -1,97 +1,62 @@
|
|
|
1
1
|
/* eslint-disable react/display-name */
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import { twMerge } from 'tailwind-merge';
|
|
4
3
|
|
|
5
4
|
import { HoveredValueContext, SelectedValueContext } from '../../contexts';
|
|
6
5
|
|
|
7
|
-
import { fontSize } from '../../lib/font';
|
|
8
|
-
import { sizing } from '../../lib/sizing';
|
|
9
|
-
import { spacing } from '../../lib/spacing';
|
|
10
|
-
|
|
11
|
-
import { getColorClassNames, makeClassName } from '../../lib';
|
|
12
|
-
import { DEFAULT_COLOR, colorPalette } from '../../lib/theme';
|
|
13
|
-
|
|
14
|
-
const makeDropdownItemClassName = makeClassName('DropdownItem');
|
|
15
|
-
|
|
16
6
|
export interface DropdownItemProps
|
|
17
7
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
18
8
|
value: string;
|
|
19
9
|
text?: string;
|
|
20
10
|
icon?: React.ElementType;
|
|
21
11
|
theme: any;
|
|
12
|
+
lastItem?: boolean;
|
|
22
13
|
}
|
|
23
14
|
|
|
24
15
|
const DropdownItem = React.forwardRef<HTMLButtonElement, DropdownItemProps>(
|
|
25
16
|
(props, ref) => {
|
|
26
|
-
const { value, text, icon, className, theme, ...other } = props;
|
|
17
|
+
const { value, text, icon, className, theme, lastItem, ...other } = props;
|
|
27
18
|
const { selectedValue, handleValueChange } =
|
|
28
19
|
useContext(SelectedValueContext);
|
|
29
20
|
const { hoveredValue } = useContext(HoveredValueContext);
|
|
30
21
|
const isActive = selectedValue === value;
|
|
31
22
|
const isHovered = hoveredValue === value;
|
|
32
|
-
const bgColor = isActive
|
|
33
|
-
? getColorClassNames(DEFAULT_COLOR, colorPalette.lightBackground).bgColor
|
|
34
|
-
: isHovered
|
|
35
|
-
? getColorClassNames(DEFAULT_COLOR, colorPalette.canvasBackground).bgColor
|
|
36
|
-
: getColorClassNames(DEFAULT_COLOR, colorPalette.canvasBackground)
|
|
37
|
-
.hoverBgColor;
|
|
38
|
-
const textColor = isActive
|
|
39
|
-
? getColorClassNames(DEFAULT_COLOR, colorPalette.darkestText).textColor
|
|
40
|
-
: getColorClassNames(DEFAULT_COLOR, colorPalette.darkText).textColor;
|
|
41
23
|
|
|
42
24
|
const Icon = icon ? icon : null;
|
|
43
25
|
return (
|
|
44
26
|
<button
|
|
45
27
|
ref={ref}
|
|
46
28
|
style={{
|
|
47
|
-
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'start',
|
|
32
|
+
width: '100%',
|
|
33
|
+
overflow: 'hidden',
|
|
34
|
+
textOverflow: 'ellipsis',
|
|
35
|
+
padding: '0.75rem 2rem',
|
|
36
|
+
fontSize: '0.875rem',
|
|
48
37
|
borderStyle: 'solid',
|
|
49
|
-
borderBottomWidth:
|
|
38
|
+
borderBottomWidth: lastItem ? '0px' : '1px',
|
|
50
39
|
borderBottomColor: theme?.borderColor || '#E5E7EB',
|
|
51
40
|
background: theme?.backgroundColor || 'white',
|
|
52
41
|
borderTop: 'none',
|
|
53
42
|
borderRight: 'none',
|
|
54
43
|
borderLeft: 'none',
|
|
55
44
|
cursor: 'pointer',
|
|
45
|
+
color: theme?.primaryTextColor || '#364153',
|
|
56
46
|
}}
|
|
57
47
|
type="button"
|
|
58
48
|
onClick={() => handleValueChange?.(value)}
|
|
59
|
-
className={twMerge(
|
|
60
|
-
makeDropdownItemClassName('root'),
|
|
61
|
-
'qq-flex qq-items-center qq-justify-start qq-w-full qq-truncate',
|
|
62
|
-
spacing.twoXl.paddingX,
|
|
63
|
-
spacing.md.paddingY,
|
|
64
|
-
fontSize.sm,
|
|
65
|
-
// bgColor,
|
|
66
|
-
textColor,
|
|
67
|
-
className
|
|
68
|
-
)}
|
|
69
49
|
{...other}
|
|
70
50
|
>
|
|
71
|
-
{Icon ? (
|
|
72
|
-
<Icon
|
|
73
|
-
className={twMerge(
|
|
74
|
-
makeDropdownItemClassName('icon'),
|
|
75
|
-
'qq-flex-none',
|
|
76
|
-
sizing.lg.height,
|
|
77
|
-
sizing.lg.width,
|
|
78
|
-
spacing.lg.marginRight,
|
|
79
|
-
getColorClassNames(DEFAULT_COLOR, colorPalette.lightText)
|
|
80
|
-
.textColor
|
|
81
|
-
)}
|
|
82
|
-
aria-hidden="true"
|
|
83
|
-
/>
|
|
84
|
-
) : null}
|
|
85
51
|
<p
|
|
86
52
|
style={{
|
|
87
53
|
margin: 0,
|
|
88
54
|
fontFamily: theme?.fontFamily,
|
|
89
55
|
color: theme?.primaryTextColor,
|
|
56
|
+
whiteSpace: 'nowrap',
|
|
57
|
+
overflow: 'hidden',
|
|
58
|
+
textOverflow: 'ellipsis',
|
|
90
59
|
}}
|
|
91
|
-
className={twMerge(
|
|
92
|
-
makeDropdownItemClassName('text'),
|
|
93
|
-
'qq-text-sm qq-whitespace-nowrap qq-truncate'
|
|
94
|
-
)}
|
|
95
60
|
>
|
|
96
61
|
{text ?? value}
|
|
97
62
|
</p>
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
/* eslint-disable react/display-name */
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { twMerge } from 'tailwind-merge';
|
|
4
3
|
|
|
5
4
|
import { useOnClickOutside, useOnWindowResize } from '../../hooks';
|
|
6
5
|
|
|
7
6
|
import { HorizontalPosition } from '../../lib/inputTypes';
|
|
8
|
-
import {
|
|
9
|
-
border,
|
|
10
|
-
borderRadius,
|
|
11
|
-
boxShadow,
|
|
12
|
-
getColorClassNames,
|
|
13
|
-
mergeRefs,
|
|
14
|
-
spacing,
|
|
15
|
-
} from '../../lib';
|
|
16
|
-
import { DEFAULT_COLOR, colorPalette } from '../../lib/theme';
|
|
7
|
+
import { mergeRefs } from '../../lib';
|
|
17
8
|
|
|
18
9
|
export interface ModalProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
19
10
|
showModal: boolean;
|
|
@@ -25,6 +16,7 @@ export interface ModalProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
25
16
|
maxHeight?: string;
|
|
26
17
|
anchorPosition?: HorizontalPosition;
|
|
27
18
|
children: React.ReactNode;
|
|
19
|
+
theme: any;
|
|
28
20
|
}
|
|
29
21
|
|
|
30
22
|
const Modal = React.forwardRef<HTMLDivElement, ModalProps>((props, ref) => {
|
|
@@ -33,9 +25,10 @@ const Modal = React.forwardRef<HTMLDivElement, ModalProps>((props, ref) => {
|
|
|
33
25
|
setShowModal,
|
|
34
26
|
parentRef,
|
|
35
27
|
width,
|
|
36
|
-
maxHeight = '
|
|
28
|
+
maxHeight = '18rem',
|
|
37
29
|
children,
|
|
38
30
|
className,
|
|
31
|
+
theme,
|
|
39
32
|
...other
|
|
40
33
|
} = props;
|
|
41
34
|
const [modalExceedsWindow, setModalExceedsWindow] = useState(false);
|
|
@@ -55,10 +48,7 @@ const Modal = React.forwardRef<HTMLDivElement, ModalProps>((props, ref) => {
|
|
|
55
48
|
);
|
|
56
49
|
|
|
57
50
|
const getAbsoluteSpacing = () => {
|
|
58
|
-
|
|
59
|
-
return spacing.none.left;
|
|
60
|
-
}
|
|
61
|
-
return spacing.none.right;
|
|
51
|
+
return modalExceedsWindow ? '0' : '0';
|
|
62
52
|
};
|
|
63
53
|
|
|
64
54
|
useOnClickOutside(modalRef, e => {
|
|
@@ -87,22 +77,51 @@ const Modal = React.forwardRef<HTMLDivElement, ModalProps>((props, ref) => {
|
|
|
87
77
|
return showModal ? (
|
|
88
78
|
<div
|
|
89
79
|
ref={mergeRefs([modalRef, ref])}
|
|
90
|
-
|
|
91
|
-
'
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
80
|
+
style={{
|
|
81
|
+
position: 'absolute',
|
|
82
|
+
zIndex: 10,
|
|
83
|
+
overflowY: 'auto',
|
|
84
|
+
width: width ? width : '100%',
|
|
85
|
+
left: getAbsoluteSpacing(),
|
|
86
|
+
right: getAbsoluteSpacing(),
|
|
87
|
+
maxHeight: maxHeight,
|
|
88
|
+
backgroundColor: theme?.backgroundColor || 'white',
|
|
89
|
+
borderColor: theme?.borderColor || '#E5E7EB',
|
|
90
|
+
// borderTopColor: getColorClassNames(
|
|
91
|
+
// DEFAULT_COLOR,
|
|
92
|
+
// colorPalette.lightBorder
|
|
93
|
+
// ).borderColor,
|
|
94
|
+
// borderBottomColor: getColorClassNames(
|
|
95
|
+
// DEFAULT_COLOR,
|
|
96
|
+
// colorPalette.lightBorder
|
|
97
|
+
// ).borderColor,
|
|
98
|
+
// borderLeftColor: getColorClassNames(
|
|
99
|
+
// DEFAULT_COLOR,
|
|
100
|
+
// colorPalette.lightBorder
|
|
101
|
+
// ).borderColor,
|
|
102
|
+
// borderRightColor: getColorClassNames(
|
|
103
|
+
// DEFAULT_COLOR,
|
|
104
|
+
// colorPalette.lightBorder
|
|
105
|
+
// ).borderColor,
|
|
106
|
+
borderTopStyle: 'solid',
|
|
107
|
+
borderBottomStyle: 'solid',
|
|
108
|
+
borderLeftStyle: 'solid',
|
|
109
|
+
borderRightStyle: 'solid',
|
|
110
|
+
borderTopWidth: 1,
|
|
111
|
+
borderBottomWidth: 1,
|
|
112
|
+
borderLeftWidth: 1,
|
|
113
|
+
borderRightWidth: 1,
|
|
114
|
+
marginTop: '0.5rem',
|
|
115
|
+
marginBottom: '0.5rem',
|
|
116
|
+
borderRadius: '0.375rem',
|
|
117
|
+
boxShadow:
|
|
118
|
+
'0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
|
|
119
|
+
// boxShadow: '0 1px 3px 0 #0000001A, 0 1px 2px 0 #0000000F',
|
|
120
|
+
// borderTopWidth: '2px',
|
|
121
|
+
// borderBottomWidth: '2px',
|
|
122
|
+
// borderLeftWidth: '2px',
|
|
123
|
+
// borderRightWidth: '2px',
|
|
124
|
+
}}
|
|
106
125
|
{...other}
|
|
107
126
|
>
|
|
108
127
|
{children}
|