funuicss 3.2.0 → 3.2.2
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/css/fun.css +214 -4
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +1 -1
- package/ui/flex/Flex.js +1 -1
- package/ui/input/Input.d.ts +44 -19
- package/ui/input/Input.js +112 -77
- package/ui/select/Select.d.ts +28 -0
- package/ui/select/Select.js +189 -0
package/css/fun.css
CHANGED
|
@@ -2774,6 +2774,7 @@ color: var(--text-color);
|
|
|
2774
2774
|
box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px;
|
|
2775
2775
|
}
|
|
2776
2776
|
|
|
2777
|
+
|
|
2777
2778
|
._center-play-icon{
|
|
2778
2779
|
position: absolute;
|
|
2779
2780
|
top: 50%;
|
|
@@ -3211,13 +3212,13 @@ color: var(--text-color);
|
|
|
3211
3212
|
border-radius: 50%;
|
|
3212
3213
|
}
|
|
3213
3214
|
.round-edge, .roundEdge {
|
|
3214
|
-
border-radius: var(--borderRadius);
|
|
3215
|
+
border-radius: var(--borderRadius) !important;
|
|
3215
3216
|
}
|
|
3216
3217
|
.roundEdgeSmall{
|
|
3217
|
-
border-radius: var(--borderRadiusSmall);
|
|
3218
|
+
border-radius: var(--borderRadiusSmall) !important;
|
|
3218
3219
|
}
|
|
3219
3220
|
.roundEdgeMax{
|
|
3220
|
-
border-radius: var(--borderRadiusMax);
|
|
3221
|
+
border-radius: var(--borderRadiusMax) !important;
|
|
3221
3222
|
}
|
|
3222
3223
|
.leftEdge{
|
|
3223
3224
|
border-top-right-radius: 0 ;
|
|
@@ -3367,7 +3368,7 @@ color: var(--text-color);
|
|
|
3367
3368
|
}
|
|
3368
3369
|
|
|
3369
3370
|
|
|
3370
|
-
|
|
3371
|
+
.button
|
|
3371
3372
|
/*inputs*/
|
|
3372
3373
|
.input {
|
|
3373
3374
|
padding: var(--inputPadding);
|
|
@@ -3496,6 +3497,7 @@ background-color: rgba(var(--borderRgb), 0.3);
|
|
|
3496
3497
|
|
|
3497
3498
|
.input.borderedInput:focus {
|
|
3498
3499
|
outline: var(--input_outline_size) solid var(--primary);
|
|
3500
|
+
box-shadow: 0 0 0 3px rgba(var(--borderRgb), 0.1);
|
|
3499
3501
|
}
|
|
3500
3502
|
|
|
3501
3503
|
.input.borderless {
|
|
@@ -3517,6 +3519,214 @@ background-color: rgba(var(--borderRgb), 0.3);
|
|
|
3517
3519
|
}
|
|
3518
3520
|
|
|
3519
3521
|
|
|
3522
|
+
.custom-select {position: relative; width: 100%; border-radius: var(--InputButtonBorderRadius);}
|
|
3523
|
+
|
|
3524
|
+
.custom-select.fullWidth {max-width: none;}
|
|
3525
|
+
|
|
3526
|
+
|
|
3527
|
+
.select-trigger {
|
|
3528
|
+
display: flex;
|
|
3529
|
+
align-items: center;
|
|
3530
|
+
justify-content: space-between;
|
|
3531
|
+
padding: var(--inputRoundedPadding);
|
|
3532
|
+
background: inherit;
|
|
3533
|
+
border: var(--border);
|
|
3534
|
+
border-radius: var(--InputButtonBorderRadius);
|
|
3535
|
+
cursor: pointer;
|
|
3536
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
3537
|
+
font-size: 14px;
|
|
3538
|
+
line-height: 1.5;
|
|
3539
|
+
min-height: 48px;
|
|
3540
|
+
user-select: none;
|
|
3541
|
+
outline: none;
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
|
|
3545
|
+
|
|
3546
|
+
.select-trigger.open {
|
|
3547
|
+
border-color: var(--primary);
|
|
3548
|
+
box-shadow: 0 0 0 3px rgba(var(--borderRgb), 0.1);
|
|
3549
|
+
border-bottom-left-radius: 0;
|
|
3550
|
+
border-bottom-right-radius: 0;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
.select-trigger.borderless {
|
|
3556
|
+
border: none !important;
|
|
3557
|
+
background: transparent;
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
|
|
3561
|
+
.select-trigger.rounded {
|
|
3562
|
+
border-radius: 24px;
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
.select-trigger.rounded.open {
|
|
3566
|
+
border-bottom-left-radius: 0;
|
|
3567
|
+
border-bottom-right-radius: 0;
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
.select-trigger.flat {
|
|
3571
|
+
box-shadow: none;
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
.select-trigger.flat:hover:not(.disabled),
|
|
3575
|
+
.select-trigger.flat:focus:not(.disabled) {
|
|
3576
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
.select-trigger.success {
|
|
3580
|
+
border-color: var(--success);
|
|
3581
|
+
}
|
|
3582
|
+
|
|
3583
|
+
.select-trigger.warning {
|
|
3584
|
+
border-color: var(--warning);
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3587
|
+
.select-trigger.danger {
|
|
3588
|
+
border-color: var(--error);
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
.select-trigger.disabled {
|
|
3592
|
+
background: var(--gray);
|
|
3593
|
+
cursor: not-allowed;
|
|
3594
|
+
opacity: 0.6;
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3597
|
+
.select-value {
|
|
3598
|
+
flex: 1;
|
|
3599
|
+
text-align: left;
|
|
3600
|
+
white-space: nowrap;
|
|
3601
|
+
overflow: hidden;
|
|
3602
|
+
text-overflow: ellipsis;
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
.select-placeholder {
|
|
3606
|
+
color: inherit;
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
.select-arrow {
|
|
3610
|
+
width: 20px;
|
|
3611
|
+
height: 20px;
|
|
3612
|
+
display: flex;
|
|
3613
|
+
align-items: center;
|
|
3614
|
+
justify-content: center;
|
|
3615
|
+
transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
3616
|
+
color: inherit;
|
|
3617
|
+
flex-shrink: 0;
|
|
3618
|
+
margin-left: 8px;
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
.select-arrow.open {
|
|
3622
|
+
transform: rotate(180deg);
|
|
3623
|
+
}
|
|
3624
|
+
|
|
3625
|
+
.select-dropdown {
|
|
3626
|
+
position: absolute;
|
|
3627
|
+
top: 100%;
|
|
3628
|
+
left: 0;
|
|
3629
|
+
right: 0;
|
|
3630
|
+
background: var(--raiseOpaque);
|
|
3631
|
+
backdrop-filter: blur(12px);
|
|
3632
|
+
border-top: none;
|
|
3633
|
+
border-radius: 0 0 8px 8px;
|
|
3634
|
+
max-height: 250px;
|
|
3635
|
+
overflow: hidden;
|
|
3636
|
+
z-index: 1000;
|
|
3637
|
+
opacity: 0;
|
|
3638
|
+
visibility: hidden;
|
|
3639
|
+
transform: translateY(-10px);
|
|
3640
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
3641
|
+
box-shadow: var(--card);
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
.select-dropdown.open {
|
|
3645
|
+
opacity: 1;
|
|
3646
|
+
visibility: visible;
|
|
3647
|
+
transform: translateY(0);
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
.select-dropdown.rounded {
|
|
3651
|
+
border-radius: 0 0 24px 24px;
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3654
|
+
.select-search {
|
|
3655
|
+
padding: 12px 16px;
|
|
3656
|
+
border: none;
|
|
3657
|
+
width: 100%;
|
|
3658
|
+
font-size: 14px;
|
|
3659
|
+
outline: none;
|
|
3660
|
+
background: var(--page-bg);
|
|
3661
|
+
color: inherit;
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
.select-search:focus {
|
|
3665
|
+
background: var(--lighter);
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3668
|
+
.select-options {
|
|
3669
|
+
max-height: 200px;
|
|
3670
|
+
overflow-y: auto;
|
|
3671
|
+
}
|
|
3672
|
+
|
|
3673
|
+
.select-options::-webkit-scrollbar {
|
|
3674
|
+
width: 6px;
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
|
|
3678
|
+
.select-option {
|
|
3679
|
+
padding: 12px 16px;
|
|
3680
|
+
cursor: pointer;
|
|
3681
|
+
transition: all 0.15s ease;
|
|
3682
|
+
font-size: 14px;
|
|
3683
|
+
color: inherit;
|
|
3684
|
+
border: none;
|
|
3685
|
+
background: none;
|
|
3686
|
+
width: 100%;
|
|
3687
|
+
text-align: left;
|
|
3688
|
+
display: flex;
|
|
3689
|
+
align-items: center;
|
|
3690
|
+
}
|
|
3691
|
+
|
|
3692
|
+
.select-option:hover {
|
|
3693
|
+
background: var(--lighter);
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
.select-option.selected {
|
|
3697
|
+
background: var(--page-bg);
|
|
3698
|
+
font-weight: 500;
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
.select-option.focused {
|
|
3702
|
+
background: var(--lighter);
|
|
3703
|
+
outline: none;
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
.select-option.no-results {
|
|
3707
|
+
cursor: default;
|
|
3708
|
+
font-style: italic;
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
.select-option.no-results:hover {
|
|
3712
|
+
background: transparent;
|
|
3713
|
+
}
|
|
3714
|
+
|
|
3715
|
+
@keyframes fadeInUp {
|
|
3716
|
+
from {
|
|
3717
|
+
opacity: 0;
|
|
3718
|
+
transform: translateY(10px);
|
|
3719
|
+
}
|
|
3720
|
+
to {
|
|
3721
|
+
opacity: 1;
|
|
3722
|
+
transform: translateY(0);
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
|
|
3726
|
+
.select-option {
|
|
3727
|
+
animation: fadeInUp 0.1s ease forwards;
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3520
3730
|
.icon-container {
|
|
3521
3731
|
position: relative;
|
|
3522
3732
|
display: flex;
|
package/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export { default as Vista } from "./ui/vista/Vista";
|
|
|
53
53
|
export { default as Slider } from "./ui/slider/Slider";
|
|
54
54
|
export { default as FlexItem } from "./ui/flex/FlexItem";
|
|
55
55
|
export { default as ScrollToTop } from "./ui/scrolltotop/ScrollToTop";
|
|
56
|
+
export { default as Select } from "./ui/select/Select";
|
|
56
57
|
export { default as Cookie } from "./js/Cookie";
|
|
57
58
|
export { FunGet } from "./js/Fun";
|
|
58
59
|
export { default as GoogleAnalytics } from "./js/google/analytics";
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DatePicker = exports.View = exports.ScrollInView = exports.Accordion = exports.Flex = exports.RichText = exports.Carousel = exports.Video = exports.SideBar = exports.ChartPie = exports.Lines = exports.Bars = exports.FullCenteredPage = exports.CircleGroup = exports.Circle = exports.Hr = exports.Section = exports.RowFlex = exports.Tip = exports.AppBar = exports.ToolTip = exports.Notification = exports.FunLoader = exports.ProgressBar = exports.DropMenu = exports.DropItem = exports.Dropdown = exports.DropDown = exports.DropUp = exports.UnAuthorized = exports.NotFound = exports.StepLine = exports.StepHeader = exports.Step = exports.StepContainer = exports.Div = exports.Text = exports.List = exports.Table = exports.Modal = exports.Loader = exports.Input = exports.Col = exports.Grid = exports.Container = exports.BreadCrumb = exports.Card = exports.Button = exports.ThemeProvider = exports.Alert = void 0;
|
|
7
|
-
exports.GoogleAnalytics = exports.FunGet = exports.Cookie = exports.ScrollToTop = exports.FlexItem = exports.Slider = exports.Vista = exports.Calendar = void 0;
|
|
7
|
+
exports.GoogleAnalytics = exports.FunGet = exports.Cookie = exports.Select = exports.ScrollToTop = exports.FlexItem = exports.Slider = exports.Vista = exports.Calendar = void 0;
|
|
8
8
|
var Alert_1 = require("./ui/alert/Alert");
|
|
9
9
|
Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
|
|
10
10
|
var theme_1 = require("./ui/theme/theme");
|
|
@@ -115,6 +115,8 @@ var FlexItem_1 = require("./ui/flex/FlexItem");
|
|
|
115
115
|
Object.defineProperty(exports, "FlexItem", { enumerable: true, get: function () { return __importDefault(FlexItem_1).default; } });
|
|
116
116
|
var ScrollToTop_1 = require("./ui/scrolltotop/ScrollToTop");
|
|
117
117
|
Object.defineProperty(exports, "ScrollToTop", { enumerable: true, get: function () { return __importDefault(ScrollToTop_1).default; } });
|
|
118
|
+
var Select_1 = require("./ui/select/Select");
|
|
119
|
+
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(Select_1).default; } });
|
|
118
120
|
// js
|
|
119
121
|
var Cookie_1 = require("./js/Cookie");
|
|
120
122
|
Object.defineProperty(exports, "Cookie", { enumerable: true, get: function () { return __importDefault(Cookie_1).default; } });
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.2.
|
|
2
|
+
"version": "3.2.2",
|
|
3
3
|
"name": "funuicss",
|
|
4
4
|
"description": "React and Next.js component UI Library for creating Easy and good looking websites with fewer lines of code. Elevate your web development experience with our cutting-edge React/Next.js component UI Library. Craft stunning websites effortlessly, boasting both seamless functionality and aesthetic appeal—all achieved with minimal lines of code. Unleash the power of simplicity and style in your projects!",
|
|
5
5
|
"main": "index.js",
|
package/ui/flex/Flex.js
CHANGED
|
@@ -49,5 +49,5 @@ function Flex(_a) {
|
|
|
49
49
|
]
|
|
50
50
|
.filter(Boolean)
|
|
51
51
|
.join(' ');
|
|
52
|
-
return (react_1.default.createElement("div", __assign({ id: id, className: combinedClassName, style: __assign({ display: 'flex', flexDirection: direction, flexWrap: wrap, justifyContent: justify, alignItems: alignItems, alignContent: alignContent, gap: gap ? "".concat(gap).concat(gapUnit) : 0, columnGap: gapX ? "".concat(gapX).concat(gapUnit) : gap ? "".concat(gap).concat(gapUnit) : 0, rowGap: gapY ? "".concat(gapY).concat(gapUnit) : gap ? "".concat(gap).concat(gapUnit) : 0, width: width ? width : '
|
|
52
|
+
return (react_1.default.createElement("div", __assign({ id: id, className: combinedClassName, style: __assign({ display: 'flex', flexDirection: direction, flexWrap: wrap, justifyContent: justify, alignItems: alignItems, alignContent: alignContent, gap: gap ? "".concat(gap).concat(gapUnit) : 0, columnGap: gapX ? "".concat(gapX).concat(gapUnit) : gap ? "".concat(gap).concat(gapUnit) : 0, rowGap: gapY ? "".concat(gapY).concat(gapUnit) : gap ? "".concat(gap).concat(gapUnit) : 0, width: width ? width : 'fit-content', height: height ? height : 'fit-content' }, style) }, rest), children));
|
|
53
53
|
}
|
package/ui/input/Input.d.ts
CHANGED
|
@@ -1,35 +1,60 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
interface
|
|
3
|
-
|
|
2
|
+
interface BaseInputProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
value?: any;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
8
|
+
status?: 'success' | 'warning' | 'danger' | '';
|
|
9
|
+
funcss?: string;
|
|
10
|
+
bg?: string;
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
flat?: boolean;
|
|
4
13
|
bordered?: boolean;
|
|
5
14
|
borderless?: boolean;
|
|
15
|
+
rounded?: boolean;
|
|
16
|
+
leftRounded?: boolean;
|
|
17
|
+
rightRounded?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface SelectOption {
|
|
20
|
+
value: string;
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
interface TextInputProps extends BaseInputProps {
|
|
24
|
+
type?: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
}
|
|
27
|
+
interface SelectProps extends BaseInputProps {
|
|
28
|
+
options?: SelectOption[];
|
|
29
|
+
}
|
|
30
|
+
interface TextareaProps extends BaseInputProps {
|
|
31
|
+
label?: string;
|
|
32
|
+
rows?: number;
|
|
33
|
+
}
|
|
34
|
+
interface FileInputProps extends BaseInputProps {
|
|
35
|
+
label?: string;
|
|
36
|
+
icon?: React.ReactNode;
|
|
37
|
+
extra?: React.ReactNode;
|
|
38
|
+
button?: React.ReactNode;
|
|
39
|
+
btn?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare const TextInput: React.FC<TextInputProps & React.InputHTMLAttributes<HTMLInputElement>>;
|
|
42
|
+
export declare const SelectInput: React.FC<SelectProps & React.SelectHTMLAttributes<HTMLSelectElement>>;
|
|
43
|
+
export declare const TextareaInput: React.FC<TextareaProps & React.TextareaHTMLAttributes<HTMLTextAreaElement>>;
|
|
44
|
+
export declare const FileInput: React.FC<FileInputProps & React.InputHTMLAttributes<HTMLInputElement>>;
|
|
45
|
+
interface InputProps extends BaseInputProps {
|
|
46
|
+
select?: boolean;
|
|
6
47
|
multiline?: boolean;
|
|
7
48
|
file?: boolean;
|
|
8
49
|
noBorder?: boolean;
|
|
9
50
|
icon?: React.ReactNode;
|
|
10
51
|
extra?: React.ReactNode;
|
|
11
52
|
button?: React.ReactNode;
|
|
12
|
-
id?: string;
|
|
13
|
-
status?: 'success' | 'warning' | 'danger' | '';
|
|
14
|
-
funcss?: string;
|
|
15
|
-
flat?: boolean;
|
|
16
|
-
leftRounded?: boolean;
|
|
17
|
-
rightRounded?: boolean;
|
|
18
|
-
rounded?: boolean;
|
|
19
|
-
fullWidth?: boolean;
|
|
20
53
|
btn?: boolean;
|
|
21
54
|
type?: string;
|
|
22
55
|
label?: string;
|
|
23
|
-
|
|
24
|
-
value?: any;
|
|
25
|
-
defaultValue?: string;
|
|
26
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
27
|
-
options?: {
|
|
28
|
-
value: string;
|
|
29
|
-
text: string;
|
|
30
|
-
}[];
|
|
56
|
+
options?: SelectOption[];
|
|
31
57
|
rows?: number;
|
|
32
|
-
bg?: string;
|
|
33
58
|
}
|
|
34
59
|
declare const Input: React.FC<InputProps>;
|
|
35
60
|
export default Input;
|
package/ui/input/Input.js
CHANGED
|
@@ -59,12 +59,79 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
59
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
60
|
};
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.FileInput = exports.TextareaInput = exports.SelectInput = exports.TextInput = void 0;
|
|
62
63
|
var react_1 = __importStar(require("react"));
|
|
63
64
|
var pi_1 = require("react-icons/pi");
|
|
64
65
|
var Button_1 = __importDefault(require("../button/Button"));
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var
|
|
66
|
+
// Utility function to generate CSS classes
|
|
67
|
+
var generateInputClasses = function (_a) {
|
|
68
|
+
var status = _a.status, rounded = _a.rounded, bg = _a.bg, funcss = _a.funcss, flat = _a.flat, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, bordered = _a.bordered, borderless = _a.borderless, _b = _a.additionalClasses, additionalClasses = _b === void 0 ? '' : _b;
|
|
69
|
+
var statusClass = status ? "".concat(status, "-input") : '';
|
|
70
|
+
var roundedClass = rounded ? 'rounded' : '';
|
|
71
|
+
var bgClass = bg || '';
|
|
72
|
+
var flatClass = flat ? 'flat' : '';
|
|
73
|
+
var cornerClass = leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '';
|
|
74
|
+
var borderClass = bordered ? 'borderedInput' : borderless ? 'borderless' : '';
|
|
75
|
+
return "\n ".concat(statusClass, "\n ").concat(roundedClass, "\n ").concat(bgClass, "\n ").concat(funcss || '', "\n ").concat(flatClass, "\n ").concat(cornerClass, "\n ").concat(borderClass, "\n ").concat(additionalClasses, "\n input\n ").trim().replace(/\s+/g, ' ');
|
|
76
|
+
};
|
|
77
|
+
// Text Input Component
|
|
78
|
+
var TextInput = function (_a) {
|
|
79
|
+
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, status = _a.status, funcss = _a.funcss, bg = _a.bg, fullWidth = _a.fullWidth, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, _b = _a.type, type = _b === void 0 ? 'text' : _b, label = _a.label, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "type", "label"]);
|
|
80
|
+
var className = generateInputClasses({
|
|
81
|
+
status: status,
|
|
82
|
+
rounded: rounded,
|
|
83
|
+
bg: bg,
|
|
84
|
+
funcss: funcss,
|
|
85
|
+
flat: flat,
|
|
86
|
+
leftRounded: leftRounded,
|
|
87
|
+
rightRounded: rightRounded,
|
|
88
|
+
bordered: bordered,
|
|
89
|
+
borderless: borderless
|
|
90
|
+
});
|
|
91
|
+
var style = fullWidth ? { width: '100%' } : undefined;
|
|
92
|
+
return (react_1.default.createElement("input", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, type: type, placeholder: label, style: style, value: value }, rest)));
|
|
93
|
+
};
|
|
94
|
+
exports.TextInput = TextInput;
|
|
95
|
+
// Select Component
|
|
96
|
+
var SelectInput = function (_a) {
|
|
97
|
+
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, status = _a.status, funcss = _a.funcss, bg = _a.bg, fullWidth = _a.fullWidth, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, _b = _a.options, options = _b === void 0 ? [] : _b, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "options"]);
|
|
98
|
+
var className = generateInputClasses({
|
|
99
|
+
status: status,
|
|
100
|
+
rounded: rounded,
|
|
101
|
+
bg: bg,
|
|
102
|
+
funcss: funcss,
|
|
103
|
+
flat: flat,
|
|
104
|
+
leftRounded: leftRounded,
|
|
105
|
+
rightRounded: rightRounded,
|
|
106
|
+
bordered: bordered,
|
|
107
|
+
borderless: borderless
|
|
108
|
+
});
|
|
109
|
+
var style = fullWidth ? { width: '100%' } : undefined;
|
|
110
|
+
return (react_1.default.createElement("select", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, value: value, style: style }, rest), options.map(function (option) { return (react_1.default.createElement("option", { key: option.value, value: option.value }, option.text)); })));
|
|
111
|
+
};
|
|
112
|
+
exports.SelectInput = SelectInput;
|
|
113
|
+
// Textarea Component
|
|
114
|
+
var TextareaInput = function (_a) {
|
|
115
|
+
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, status = _a.status, funcss = _a.funcss, bg = _a.bg, fullWidth = _a.fullWidth, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, label = _a.label, _b = _a.rows, rows = _b === void 0 ? 2 : _b, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "label", "rows"]);
|
|
116
|
+
var className = generateInputClasses({
|
|
117
|
+
status: status,
|
|
118
|
+
rounded: rounded,
|
|
119
|
+
bg: bg,
|
|
120
|
+
funcss: funcss,
|
|
121
|
+
flat: flat,
|
|
122
|
+
leftRounded: leftRounded,
|
|
123
|
+
rightRounded: rightRounded,
|
|
124
|
+
bordered: bordered,
|
|
125
|
+
borderless: borderless
|
|
126
|
+
});
|
|
127
|
+
var style = fullWidth ? { width: '100%' } : undefined;
|
|
128
|
+
return (react_1.default.createElement("textarea", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, placeholder: label, style: style, value: value, rows: rows }, rest)));
|
|
129
|
+
};
|
|
130
|
+
exports.TextareaInput = TextareaInput;
|
|
131
|
+
// File Input Component
|
|
132
|
+
var FileInput = function (_a) {
|
|
133
|
+
var _b = _a.id, id = _b === void 0 ? 'fileInput' : _b, name = _a.name, onChange = _a.onChange, status = _a.status, funcss = _a.funcss, bg = _a.bg, fullWidth = _a.fullWidth, flat = _a.flat, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, _c = _a.label, label = _c === void 0 ? 'Upload File' : _c, icon = _a.icon, extra = _a.extra, button = _a.button, btn = _a.btn, value = _a.value, rest = __rest(_a, ["id", "name", "onChange", "status", "funcss", "bg", "fullWidth", "flat", "rounded", "leftRounded", "rightRounded", "label", "icon", "extra", "button", "btn", "value"]);
|
|
134
|
+
var _d = (0, react_1.useState)(''), fileName = _d[0], setFileName = _d[1];
|
|
68
135
|
var handleChange = function (e) {
|
|
69
136
|
var _a;
|
|
70
137
|
var file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -74,83 +141,51 @@ var Input = function (_a) {
|
|
|
74
141
|
if (onChange)
|
|
75
142
|
onChange(e);
|
|
76
143
|
};
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
width: "".concat(fullWidth ? '100%' : '')
|
|
95
|
-
} }), options
|
|
96
|
-
? options.map(function (doc) { return (react_1.default.createElement("option", { value: doc.value, key: doc.value }, doc.text)); })
|
|
97
|
-
: ''));
|
|
98
|
-
}
|
|
144
|
+
if (btn) {
|
|
145
|
+
var className = generateInputClasses({
|
|
146
|
+
status: status,
|
|
147
|
+
rounded: rounded,
|
|
148
|
+
bg: bg,
|
|
149
|
+
funcss: funcss,
|
|
150
|
+
flat: flat,
|
|
151
|
+
leftRounded: leftRounded,
|
|
152
|
+
rightRounded: rightRounded,
|
|
153
|
+
bordered: true,
|
|
154
|
+
borderless: false,
|
|
155
|
+
additionalClasses: 'filedInput'
|
|
156
|
+
});
|
|
157
|
+
var style = fullWidth ? { width: '100%' } : undefined;
|
|
158
|
+
return (react_1.default.createElement("div", { className: "fileInput" },
|
|
159
|
+
button || (react_1.default.createElement(Button_1.default, { funcss: funcss, startIcon: icon || react_1.default.createElement(pi_1.PiCloudArrowUp, null), bg: "primary", fullWidth: true, raised: true }, fileName || label)),
|
|
160
|
+
react_1.default.createElement("input", __assign({ id: id, name: name, className: className, onChange: handleChange, type: "file", style: style, value: value }, rest))));
|
|
99
161
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
width:
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
162
|
+
return (react_1.default.createElement("div", { className: "_upload_container" },
|
|
163
|
+
react_1.default.createElement("label", { htmlFor: id, className: "_upload_label" },
|
|
164
|
+
react_1.default.createElement("div", { className: "_upload_icon" }, icon || react_1.default.createElement(pi_1.PiCloudArrowUp, null)),
|
|
165
|
+
react_1.default.createElement("div", { className: "_upload_text", style: {
|
|
166
|
+
whiteSpace: 'nowrap',
|
|
167
|
+
overflow: 'hidden',
|
|
168
|
+
textOverflow: 'ellipsis',
|
|
169
|
+
display: 'inline-block',
|
|
170
|
+
width: '100%',
|
|
171
|
+
} }, fileName || label),
|
|
172
|
+
extra && react_1.default.createElement("div", { className: "text-small opacity-3" }, extra)),
|
|
173
|
+
react_1.default.createElement("input", __assign({ onChange: handleChange, type: "file", id: id, className: "_upload_input" }, rest))));
|
|
174
|
+
};
|
|
175
|
+
exports.FileInput = FileInput;
|
|
176
|
+
var Input = function (_a) {
|
|
177
|
+
var select = _a.select, multiline = _a.multiline, file = _a.file, noBorder = _a.noBorder, props = __rest(_a, ["select", "multiline", "file", "noBorder"]);
|
|
178
|
+
// Handle legacy noBorder prop
|
|
179
|
+
var inputProps = __assign(__assign({}, props), { borderless: noBorder || props.borderless });
|
|
180
|
+
if (select) {
|
|
181
|
+
return react_1.default.createElement(exports.SelectInput, __assign({}, inputProps));
|
|
116
182
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return (react_1.default.createElement("div", { className: "fileInput" },
|
|
120
|
-
button ? (button) : (react_1.default.createElement(Button_1.default, { funcss: " ".concat(funcss, " "), startIcon: icon ? icon : react_1.default.createElement(pi_1.PiCloudArrowUp, null), bg: "primary", fullWidth: true, raised: true }, fileName || label || 'Upload File')),
|
|
121
|
-
react_1.default.createElement("input", __assign({ name: name, id: id, className: "\n ".concat(status === 'success' ? 'success-input' : '', "\n ").concat(status === 'warning' ? 'warning-input' : '', "\n ").concat(status === 'danger' ? 'danger-input' : '', "\n input \n ").concat(rounded ? "rounded" : '', "\n ").concat(bg ? bg : '', "\n ").concat(funcss, " ").concat(flat ? 'flat' : '', "\n ").concat(leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '', "\n borderedInput\n filedInput\n "), onChange: handleChange, type: 'file', style: {
|
|
122
|
-
width: "".concat(fullWidth ? '100%' : '')
|
|
123
|
-
}, value: value }, rest))));
|
|
124
|
-
return (react_1.default.createElement("div", { className: "_upload_container" },
|
|
125
|
-
react_1.default.createElement("label", { htmlFor: id || "fileInput", className: "_upload_label" },
|
|
126
|
-
react_1.default.createElement("div", { className: "_upload_icon" }, icon || react_1.default.createElement(react_1.default.Fragment, null,
|
|
127
|
-
react_1.default.createElement(pi_1.PiCloudArrowUp, null))),
|
|
128
|
-
react_1.default.createElement("div", { className: "_upload_text", style: {
|
|
129
|
-
whiteSpace: 'nowrap',
|
|
130
|
-
overflow: 'hidden',
|
|
131
|
-
textOverflow: 'ellipsis',
|
|
132
|
-
display: 'inline-block',
|
|
133
|
-
width: '100%',
|
|
134
|
-
} }, fileName || label || "Upload File"),
|
|
135
|
-
react_1.default.createElement("div", { className: "text-small opacity-3" }, extra || '')),
|
|
136
|
-
react_1.default.createElement("input", __assign({ onChange: handleChange, type: "file", id: id || "fileInput", className: "_upload_input" }, rest))));
|
|
183
|
+
if (multiline) {
|
|
184
|
+
return react_1.default.createElement(exports.TextareaInput, __assign({}, inputProps));
|
|
137
185
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return (react_1.default.createElement("input", __assign({ name: name, id: id, className: "\n ".concat(status === 'success' ? 'success-input' : '', "\n ").concat(status === 'warning' ? 'warning-input' : '', "\n ").concat(status === 'danger' ? 'danger-input' : '', "\n input \n ").concat(rounded ? "rounded" : '', "\n ").concat(bg ? bg : '', "\n ").concat(funcss, " ").concat(flat ? 'flat' : '', "\n ").concat(leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '', "\n borderedInput\n "), onChange: onChange, defaultValue: defaultValue, type: type, placeholder: label, style: {
|
|
141
|
-
width: "".concat(fullWidth ? '100%' : '')
|
|
142
|
-
}, value: value }, rest)));
|
|
143
|
-
}
|
|
144
|
-
else if (borderless) {
|
|
145
|
-
return (react_1.default.createElement("input", __assign({ name: name, id: id, className: "\n ".concat(status === 'success' ? 'success-input' : '', "\n ").concat(status === 'warning' ? 'warning-input' : '', "\n ").concat(status === 'danger' ? 'danger-input' : '', "\n input \n ").concat(rounded ? "rounded" : '', "\n ").concat(bg ? bg : '', "\n ").concat(funcss, " ").concat(flat ? 'flat' : '', "\n ").concat(leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '', "\n borderless\n "), onChange: onChange, defaultValue: defaultValue, type: type, placeholder: label, value: value, style: {
|
|
146
|
-
width: "".concat(fullWidth ? '100%' : '')
|
|
147
|
-
} }, rest)));
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
return (react_1.default.createElement("input", __assign({ name: name, id: id, className: "\n ".concat(status === 'success' ? 'success-input' : '', "\n ").concat(status === 'warning' ? 'warning-input' : '', "\n ").concat(status === 'danger' ? 'danger-input' : '', "\n input \n ").concat(rounded ? "rounded" : '', "\n ").concat(bg ? bg : '', "\n ").concat(funcss, " ").concat(flat ? 'flat' : '', "\n ").concat(leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '', "\n "), onChange: onChange, defaultValue: defaultValue, type: type, placeholder: label, value: value, style: {
|
|
151
|
-
width: "".concat(fullWidth ? '100%' : '')
|
|
152
|
-
} }, rest)));
|
|
153
|
-
}
|
|
186
|
+
if (file) {
|
|
187
|
+
return react_1.default.createElement(exports.FileInput, __assign({}, inputProps));
|
|
154
188
|
}
|
|
189
|
+
return react_1.default.createElement(exports.TextInput, __assign({}, inputProps));
|
|
155
190
|
};
|
|
156
191
|
exports.default = Input;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SelectOption {
|
|
3
|
+
value: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
interface CustomSelectProps {
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
options: SelectOption[];
|
|
13
|
+
onChange?: (value: string, option: SelectOption) => void;
|
|
14
|
+
onBlur?: (event: React.FocusEvent) => void;
|
|
15
|
+
searchable?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
bordered?: boolean;
|
|
18
|
+
borderless?: boolean;
|
|
19
|
+
rounded?: boolean;
|
|
20
|
+
flat?: boolean;
|
|
21
|
+
fullWidth?: boolean;
|
|
22
|
+
status?: 'success' | 'warning' | 'danger' | '';
|
|
23
|
+
className?: string;
|
|
24
|
+
funcss?: string;
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
}
|
|
27
|
+
declare const Select: React.FC<CustomSelectProps>;
|
|
28
|
+
export default Select;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
var react_1 = __importStar(require("react"));
|
|
37
|
+
var Select = function (_a) {
|
|
38
|
+
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, _b = _a.placeholder, placeholder = _b === void 0 ? 'Select an option' : _b, _c = _a.options, options = _c === void 0 ? [] : _c, onChange = _a.onChange, onBlur = _a.onBlur, _d = _a.searchable, searchable = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.bordered, bordered = _f === void 0 ? false : _f, _g = _a.borderless, borderless = _g === void 0 ? false : _g, _h = _a.rounded, rounded = _h === void 0 ? false : _h, _j = _a.flat, flat = _j === void 0 ? false : _j, _k = _a.fullWidth, fullWidth = _k === void 0 ? false : _k, _l = _a.status, status = _l === void 0 ? '' : _l, _m = _a.className, className = _m === void 0 ? '' : _m, _o = _a.funcss, funcss = _o === void 0 ? '' : _o, _p = _a.style, style = _p === void 0 ? {} : _p;
|
|
39
|
+
var _q = (0, react_1.useState)(false), isOpen = _q[0], setIsOpen = _q[1];
|
|
40
|
+
var _r = (0, react_1.useState)(null), selectedOption = _r[0], setSelectedOption = _r[1];
|
|
41
|
+
var _s = (0, react_1.useState)(''), searchQuery = _s[0], setSearchQuery = _s[1];
|
|
42
|
+
var _t = (0, react_1.useState)(-1), focusedIndex = _t[0], setFocusedIndex = _t[1];
|
|
43
|
+
var _u = (0, react_1.useState)(options), filteredOptions = _u[0], setFilteredOptions = _u[1];
|
|
44
|
+
var containerRef = (0, react_1.useRef)(null);
|
|
45
|
+
var triggerRef = (0, react_1.useRef)(null);
|
|
46
|
+
var searchInputRef = (0, react_1.useRef)(null);
|
|
47
|
+
// Initialize selected option
|
|
48
|
+
(0, react_1.useEffect)(function () {
|
|
49
|
+
var initialValue = value || defaultValue;
|
|
50
|
+
if (initialValue) {
|
|
51
|
+
var option = options.find(function (opt) { return opt.value === initialValue; });
|
|
52
|
+
if (option) {
|
|
53
|
+
setSelectedOption(option);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, [value, defaultValue, options]);
|
|
57
|
+
// Update filtered options when search query changes
|
|
58
|
+
(0, react_1.useEffect)(function () {
|
|
59
|
+
if (searchQuery) {
|
|
60
|
+
var filtered = options.filter(function (option) {
|
|
61
|
+
return option.text.toLowerCase().includes(searchQuery.toLowerCase());
|
|
62
|
+
});
|
|
63
|
+
setFilteredOptions(filtered);
|
|
64
|
+
setFocusedIndex(filtered.length > 0 ? 0 : -1);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
setFilteredOptions(options);
|
|
68
|
+
setFocusedIndex(-1);
|
|
69
|
+
}
|
|
70
|
+
}, [searchQuery, options]);
|
|
71
|
+
// Handle outside clicks
|
|
72
|
+
(0, react_1.useEffect)(function () {
|
|
73
|
+
var handleClickOutside = function (event) {
|
|
74
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
75
|
+
closeDropdown();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if (isOpen) {
|
|
79
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
80
|
+
return function () { return document.removeEventListener('mousedown', handleClickOutside); };
|
|
81
|
+
}
|
|
82
|
+
}, [isOpen]);
|
|
83
|
+
var openDropdown = function () {
|
|
84
|
+
if (disabled)
|
|
85
|
+
return;
|
|
86
|
+
setIsOpen(true);
|
|
87
|
+
if (searchable && searchInputRef.current) {
|
|
88
|
+
setTimeout(function () { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, 100);
|
|
89
|
+
}
|
|
90
|
+
else if (selectedOption) {
|
|
91
|
+
var index = filteredOptions.findIndex(function (opt) { return opt.value === selectedOption.value; });
|
|
92
|
+
setFocusedIndex(index >= 0 ? index : 0);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
setFocusedIndex(0);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var closeDropdown = function () {
|
|
99
|
+
setIsOpen(false);
|
|
100
|
+
setSearchQuery('');
|
|
101
|
+
setFocusedIndex(-1);
|
|
102
|
+
};
|
|
103
|
+
var selectOption = function (option) {
|
|
104
|
+
setSelectedOption(option);
|
|
105
|
+
closeDropdown();
|
|
106
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option.value, option);
|
|
107
|
+
};
|
|
108
|
+
var handleKeyDown = function (event) {
|
|
109
|
+
var _a;
|
|
110
|
+
switch (event.key) {
|
|
111
|
+
case 'Enter':
|
|
112
|
+
case ' ':
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (isOpen && focusedIndex >= 0) {
|
|
115
|
+
selectOption(filteredOptions[focusedIndex]);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
openDropdown();
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case 'ArrowDown':
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
if (!isOpen) {
|
|
124
|
+
openDropdown();
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
setFocusedIndex(function (prev) { return Math.min(prev + 1, filteredOptions.length - 1); });
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case 'ArrowUp':
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
if (isOpen) {
|
|
133
|
+
setFocusedIndex(function (prev) { return Math.max(prev - 1, 0); });
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case 'Escape':
|
|
137
|
+
if (isOpen) {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
closeDropdown();
|
|
140
|
+
(_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var handleSearchKeyDown = function (event) {
|
|
146
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
handleKeyDown(event);
|
|
149
|
+
}
|
|
150
|
+
else if (event.key === 'Enter' && focusedIndex >= 0) {
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
selectOption(filteredOptions[focusedIndex]);
|
|
153
|
+
}
|
|
154
|
+
else if (event.key === 'Escape') {
|
|
155
|
+
closeDropdown();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var getTriggerClasses = function () {
|
|
159
|
+
var classes = [
|
|
160
|
+
'select-trigger',
|
|
161
|
+
isOpen && 'open',
|
|
162
|
+
bordered && 'bordered',
|
|
163
|
+
borderless && 'borderless',
|
|
164
|
+
flat && 'flat',
|
|
165
|
+
status && status,
|
|
166
|
+
disabled && 'disabled'
|
|
167
|
+
].filter(Boolean);
|
|
168
|
+
return classes.join(' ');
|
|
169
|
+
};
|
|
170
|
+
var getContainerClasses = function () {
|
|
171
|
+
var classes = [
|
|
172
|
+
'custom-select',
|
|
173
|
+
fullWidth && 'fullWidth',
|
|
174
|
+
,
|
|
175
|
+
].filter(Boolean);
|
|
176
|
+
return classes.join(' ');
|
|
177
|
+
};
|
|
178
|
+
return (react_1.default.createElement("div", { ref: containerRef, className: "".concat(funcss, " ").concat(rounded && 'round-edge', " ").concat(getContainerClasses()), style: style },
|
|
179
|
+
react_1.default.createElement("div", { ref: triggerRef, className: "".concat(funcss, " ").concat(rounded && 'round-edge', " ").concat(getTriggerClasses()), onClick: openDropdown, onKeyDown: handleKeyDown, tabIndex: disabled ? -1 : 0, role: "button", "aria-expanded": isOpen, "aria-haspopup": "listbox" },
|
|
180
|
+
react_1.default.createElement("span", { className: "select-value ".concat(!selectedOption ? 'select-placeholder' : '') }, selectedOption ? selectedOption.text : placeholder),
|
|
181
|
+
react_1.default.createElement("div", { className: "select-arrow ".concat(isOpen ? 'open' : '') },
|
|
182
|
+
react_1.default.createElement("svg", { width: "16", height: "16", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
183
|
+
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M19 9l-7 7-7-7" })))),
|
|
184
|
+
react_1.default.createElement("div", { className: "select-dropdown ".concat(isOpen ? 'open' : '', " ") },
|
|
185
|
+
searchable && (react_1.default.createElement("input", { ref: searchInputRef, type: "text", className: "select-search", placeholder: "Search options...", value: searchQuery, onChange: function (e) { return setSearchQuery(e.target.value); }, onKeyDown: handleSearchKeyDown })),
|
|
186
|
+
react_1.default.createElement("div", { className: "select-options", role: "listbox" }, filteredOptions.length === 0 ? (react_1.default.createElement("div", { className: "select-option no-results" }, "No options found")) : (filteredOptions.map(function (option, index) { return (react_1.default.createElement("button", { key: option.value, type: "button", className: "select-option ".concat((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value ? 'selected' : '', " ").concat(index === focusedIndex ? 'focused' : ''), onClick: function () { return selectOption(option); }, role: "option", "aria-selected": (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value }, option.text)); })))),
|
|
187
|
+
react_1.default.createElement("input", { type: "hidden", id: id, name: name, value: (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '' })));
|
|
188
|
+
};
|
|
189
|
+
exports.default = Select;
|