funuicss 3.5.0 → 3.5.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 +467 -3
- package/index.d.ts +1 -0
- package/index.js +4 -2
- package/package.json +1 -1
- package/ui/input/SearchableInput.d.ts +38 -0
- package/ui/input/SearchableInput.js +258 -0
- package/ui/select/Select.d.ts +1 -0
- package/ui/select/Select.js +2 -2
- package/ui/table/Query.d.ts +3 -2
- package/ui/table/Query.js +64 -11
- package/ui/table/Table.d.ts +3 -1
- package/ui/table/Table.js +26 -42
package/css/fun.css
CHANGED
|
@@ -3630,7 +3630,7 @@ border-top: none;
|
|
|
3630
3630
|
border-radius: 0 0 0.5rem 0.5rem;
|
|
3631
3631
|
max-height: 250px;
|
|
3632
3632
|
overflow: hidden;
|
|
3633
|
-
opacity: 0;
|
|
3633
|
+
/* opacity: 0; */
|
|
3634
3634
|
visibility: hidden;
|
|
3635
3635
|
transform: translateY(-10px);
|
|
3636
3636
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -3639,7 +3639,7 @@ z-index: 1000 !important;
|
|
|
3639
3639
|
}
|
|
3640
3640
|
|
|
3641
3641
|
.select-dropdown.open {
|
|
3642
|
-
opacity: 1;
|
|
3642
|
+
/* opacity: 1; */
|
|
3643
3643
|
visibility: visible;
|
|
3644
3644
|
transform: translateY(0);
|
|
3645
3645
|
|
|
@@ -3774,6 +3774,467 @@ padding-right: 2.5rem;
|
|
|
3774
3774
|
|
|
3775
3775
|
}
|
|
3776
3776
|
|
|
3777
|
+
|
|
3778
|
+
/* SearchableInput.css - Matching your theme format */
|
|
3779
|
+
|
|
3780
|
+
/* Reset and base styles */
|
|
3781
|
+
* {
|
|
3782
|
+
box-sizing: border-box;
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
/* Main wrapper */
|
|
3786
|
+
.searchable-input-wrapper {
|
|
3787
|
+
position: relative;
|
|
3788
|
+
display: inline-block;
|
|
3789
|
+
font-family: inherit;
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
.searchable-input-wrapper.full-width {
|
|
3793
|
+
display: block;
|
|
3794
|
+
width: 100%;
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
/* Label styles */
|
|
3798
|
+
.searchable-input__label {
|
|
3799
|
+
display: block;
|
|
3800
|
+
margin-bottom: 0.5rem;
|
|
3801
|
+
font-size: 0.875rem;
|
|
3802
|
+
font-weight: 500;
|
|
3803
|
+
color: var(--text-color);
|
|
3804
|
+
line-height: 1.4;
|
|
3805
|
+
}
|
|
3806
|
+
|
|
3807
|
+
/* Container for input and dropdown */
|
|
3808
|
+
.searchable-input__container {
|
|
3809
|
+
position: relative;
|
|
3810
|
+
display: block;
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
/* Input wrapper with icons */
|
|
3814
|
+
.searchable-input__input-wrapper {
|
|
3815
|
+
position: relative;
|
|
3816
|
+
display: flex;
|
|
3817
|
+
align-items: center;
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
/* Base input styles */
|
|
3821
|
+
.searchable-input {
|
|
3822
|
+
width: 100%;
|
|
3823
|
+
height: var(--inputHeight);
|
|
3824
|
+
padding: 0.6rem 0.8rem;
|
|
3825
|
+
font-size: inherit;
|
|
3826
|
+
line-height: 1.5;
|
|
3827
|
+
color: var(--text-color);
|
|
3828
|
+
background-color: var(--background-color);
|
|
3829
|
+
border: none;
|
|
3830
|
+
border-bottom: var(--inputBorder) solid var(--border-color);
|
|
3831
|
+
border-radius: 0;
|
|
3832
|
+
outline: none;
|
|
3833
|
+
transition: 0.1s linear;
|
|
3834
|
+
}
|
|
3835
|
+
|
|
3836
|
+
.searchable-input:focus {
|
|
3837
|
+
border-bottom: var(--inputBorder) solid var(--primary);
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
.searchable-input::placeholder {
|
|
3841
|
+
color: var(--text-muted);
|
|
3842
|
+
}
|
|
3843
|
+
|
|
3844
|
+
/* Full width modifier */
|
|
3845
|
+
.searchable-input.full-width {
|
|
3846
|
+
width: 100%;
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
/* Status modifiers */
|
|
3850
|
+
.searchable-input.success-input {
|
|
3851
|
+
border-bottom: var(--inputBorder) solid var(--success) !important;
|
|
3852
|
+
}
|
|
3853
|
+
|
|
3854
|
+
.searchable-input.warning-input {
|
|
3855
|
+
border-bottom: var(--inputBorder) solid var(--warning) !important;
|
|
3856
|
+
}
|
|
3857
|
+
|
|
3858
|
+
.searchable-input.danger-input {
|
|
3859
|
+
border-bottom: var(--inputBorder) solid var(--danger) !important;
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
.searchable-input.success-input:focus,
|
|
3863
|
+
.searchable-input.warning-input:focus,
|
|
3864
|
+
.searchable-input.danger-input:focus {
|
|
3865
|
+
outline: none !important;
|
|
3866
|
+
}
|
|
3867
|
+
|
|
3868
|
+
/* Bordered input styles */
|
|
3869
|
+
.searchable-input.borderedInput {
|
|
3870
|
+
border: var(--border);
|
|
3871
|
+
border-radius: var(--InputButtonBorderRadius);
|
|
3872
|
+
transition: 0.1s linear;
|
|
3873
|
+
padding: 0.6rem 0.5rem;
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
.searchable-input.borderedInput:focus {
|
|
3877
|
+
outline: var(--input_outline_size) solid var(--primary);
|
|
3878
|
+
box-shadow: 0 0 0 3px rgba(var(--borderRgb), 0.1);
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
.searchable-input.success-input.borderedInput {
|
|
3882
|
+
border: var(--inputBorder) solid var(--success) !important;
|
|
3883
|
+
outline: var(--input_outline_size) solid var(--success);
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
.searchable-input.warning-input.borderedInput {
|
|
3887
|
+
border: var(--inputBorder) solid var(--warning) !important;
|
|
3888
|
+
outline: var(--input_outline_size) solid var(--warning);
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3891
|
+
.searchable-input.danger-input.borderedInput {
|
|
3892
|
+
border: var(--inputBorder) solid var(--danger) !important;
|
|
3893
|
+
outline: var(--input_outline_size) solid var(--danger);
|
|
3894
|
+
}
|
|
3895
|
+
|
|
3896
|
+
/* Borderless input styles */
|
|
3897
|
+
.searchable-input.borderless {
|
|
3898
|
+
border: none !important;
|
|
3899
|
+
outline: none !important;
|
|
3900
|
+
background-color: var(--light);
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
.searchable-input.borderless:focus {
|
|
3904
|
+
border: none !important;
|
|
3905
|
+
outline: none !important;
|
|
3906
|
+
background-color: rgba(var(--borderRgb), 0.3);
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
/* Flat modifier */
|
|
3910
|
+
.searchable-input.flat {
|
|
3911
|
+
border-radius: 0;
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3914
|
+
/* No outline */
|
|
3915
|
+
.searchable-input.no-outline {
|
|
3916
|
+
outline: none;
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
/* Rounded modifiers */
|
|
3920
|
+
.searchable-input.round,
|
|
3921
|
+
.searchable-input.rounded {
|
|
3922
|
+
border-radius: 100rem !important;
|
|
3923
|
+
padding: var(--inputRoundedPadding);
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3926
|
+
.searchable-input.left-rounded {
|
|
3927
|
+
border-top-left-radius: 100rem !important;
|
|
3928
|
+
border-bottom-left-radius: 100rem !important;
|
|
3929
|
+
padding-left: var(--inputRoundedPadding);
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
.searchable-input.right-rounded {
|
|
3933
|
+
border-top-right-radius: 100rem !important;
|
|
3934
|
+
border-bottom-right-radius: 100rem !important;
|
|
3935
|
+
padding-right: var(--inputRoundedPadding);
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
/* Icon spacing modifiers */
|
|
3939
|
+
.searchable-input.with-left-icon {
|
|
3940
|
+
padding-left: 2.5rem;
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
.searchable-input.with-clear {
|
|
3944
|
+
padding-right: 4.5rem;
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
/* Disabled state */
|
|
3948
|
+
.searchable-input:disabled {
|
|
3949
|
+
background-color: var(--disabled-bg, var(--light));
|
|
3950
|
+
color: var(--text-muted);
|
|
3951
|
+
cursor: not-allowed;
|
|
3952
|
+
opacity: 0.6;
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
/* Left icon */
|
|
3956
|
+
.searchable-input__icon {
|
|
3957
|
+
position: absolute;
|
|
3958
|
+
display: flex;
|
|
3959
|
+
align-items: center;
|
|
3960
|
+
justify-content: center;
|
|
3961
|
+
pointer-events: none;
|
|
3962
|
+
color: var(--text-muted);
|
|
3963
|
+
z-index: 1;
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
.searchable-input__icon--left {
|
|
3967
|
+
left: 0.75rem;
|
|
3968
|
+
top: 50%;
|
|
3969
|
+
transform: translateY(-50%);
|
|
3970
|
+
}
|
|
3971
|
+
|
|
3972
|
+
/* Right actions container */
|
|
3973
|
+
.searchable-input__actions {
|
|
3974
|
+
position: absolute;
|
|
3975
|
+
right: 0.75rem;
|
|
3976
|
+
top: 50%;
|
|
3977
|
+
transform: translateY(-50%);
|
|
3978
|
+
display: flex;
|
|
3979
|
+
align-items: center;
|
|
3980
|
+
gap: 0.25rem;
|
|
3981
|
+
z-index: 1;
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
/* Clear button */
|
|
3985
|
+
.searchable-input__clear-btn {
|
|
3986
|
+
display: flex;
|
|
3987
|
+
align-items: center;
|
|
3988
|
+
justify-content: center;
|
|
3989
|
+
width: 1.25rem;
|
|
3990
|
+
height: 1.25rem;
|
|
3991
|
+
background: none;
|
|
3992
|
+
border: none;
|
|
3993
|
+
border-radius: 0.25rem;
|
|
3994
|
+
color: var(--text-muted);
|
|
3995
|
+
cursor: pointer;
|
|
3996
|
+
transition: 0.1s linear;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
.searchable-input__clear-btn:hover {
|
|
4000
|
+
color: var(--text-color);
|
|
4001
|
+
background-color: rgba(var(--borderRgb), 0.1);
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
.searchable-input__clear-btn:focus {
|
|
4005
|
+
outline: var(--input_outline_size) solid var(--primary);
|
|
4006
|
+
}
|
|
4007
|
+
|
|
4008
|
+
/* Caret container */
|
|
4009
|
+
.searchable-input__caret {
|
|
4010
|
+
display: flex;
|
|
4011
|
+
align-items: center;
|
|
4012
|
+
justify-content: center;
|
|
4013
|
+
color: var(--text-muted);
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
/* Caret icon */
|
|
4017
|
+
.searchable-input__caret-icon {
|
|
4018
|
+
transition: transform 0.2s ease;
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
.searchable-input__caret-icon--open {
|
|
4022
|
+
transform: rotate(180deg);
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
/* Loading spinner */
|
|
4026
|
+
.searchable-input__spinner {
|
|
4027
|
+
width: 1rem;
|
|
4028
|
+
height: 1rem;
|
|
4029
|
+
border: 2px solid rgba(var(--borderRgb), 0.3);
|
|
4030
|
+
border-top: 2px solid var(--primary);
|
|
4031
|
+
border-radius: 50%;
|
|
4032
|
+
animation: spin 1s linear infinite;
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
@keyframes spin {
|
|
4036
|
+
0% { transform: rotate(0deg); }
|
|
4037
|
+
100% { transform: rotate(360deg); }
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
/* Dropdown */
|
|
4041
|
+
.searchable-input__dropdown {
|
|
4042
|
+
position: absolute;
|
|
4043
|
+
left: 0;
|
|
4044
|
+
right: 0;
|
|
4045
|
+
z-index: 1000;
|
|
4046
|
+
background-color: var(--raiseThemes);
|
|
4047
|
+
backdrop-filter: var(--raiseBackdrop);
|
|
4048
|
+
border: var(--border);
|
|
4049
|
+
border-radius: var(--InputButtonBorderRadius);
|
|
4050
|
+
box-shadow: var(--shadow);
|
|
4051
|
+
overflow: hidden;
|
|
4052
|
+
animation: dropdown-appear 0.15s ease-out;
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
.searchable-input__dropdown--up {
|
|
4056
|
+
bottom: 100%;
|
|
4057
|
+
margin-bottom: 0.25rem;
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
.searchable-input__dropdown--down {
|
|
4061
|
+
top: 100%;
|
|
4062
|
+
margin-top: 0.25rem;
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
@keyframes dropdown-appear {
|
|
4066
|
+
0% {
|
|
4067
|
+
opacity: 0;
|
|
4068
|
+
transform: translateY(-0.25rem);
|
|
4069
|
+
}
|
|
4070
|
+
100% {
|
|
4071
|
+
opacity: 1;
|
|
4072
|
+
transform: translateY(0);
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
/* Dropdown content */
|
|
4077
|
+
.searchable-input__dropdown-content {
|
|
4078
|
+
padding: 0.25rem 0;
|
|
4079
|
+
overflow-y: auto;
|
|
4080
|
+
max-height: 12.5rem;
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
.searchable-input__dropdown-content::-webkit-scrollbar {
|
|
4084
|
+
width: 0.375rem;
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
.searchable-input__dropdown-content::-webkit-scrollbar-track {
|
|
4088
|
+
background: rgba(var(--borderRgb), 0.1);
|
|
4089
|
+
}
|
|
4090
|
+
|
|
4091
|
+
.searchable-input__dropdown-content::-webkit-scrollbar-thumb {
|
|
4092
|
+
background: rgba(var(--borderRgb), 0.3);
|
|
4093
|
+
border-radius: 0.1875rem;
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
.searchable-input__dropdown-content::-webkit-scrollbar-thumb:hover {
|
|
4097
|
+
background: rgba(var(--borderRgb), 0.5);
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
/* Option item */
|
|
4101
|
+
.searchable-input__option {
|
|
4102
|
+
padding: 0.75rem 1rem;
|
|
4103
|
+
cursor: pointer;
|
|
4104
|
+
transition: 0.1s linear;
|
|
4105
|
+
border-bottom: 1px solid rgba(var(--borderRgb), 0.1);
|
|
4106
|
+
color: var(--text-color);
|
|
4107
|
+
}
|
|
4108
|
+
|
|
4109
|
+
.searchable-input__option:last-child {
|
|
4110
|
+
border-bottom: none;
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4113
|
+
.searchable-input__option:hover {
|
|
4114
|
+
background-color: rgba(var(--borderRgb), 0.1);
|
|
4115
|
+
}
|
|
4116
|
+
|
|
4117
|
+
.searchable-input__option--highlighted {
|
|
4118
|
+
background-color: rgba(var(--primaryRgb), 0.1);
|
|
4119
|
+
}
|
|
4120
|
+
|
|
4121
|
+
.searchable-input__option--selected {
|
|
4122
|
+
background-color: rgba(var(--primaryRgb), 0.2);
|
|
4123
|
+
color: var(--primary);
|
|
4124
|
+
font-weight: 500;
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
/* Option text */
|
|
4128
|
+
.searchable-input__option-text {
|
|
4129
|
+
font-size: 0.875rem;
|
|
4130
|
+
line-height: 1.4;
|
|
4131
|
+
color: inherit;
|
|
4132
|
+
margin-bottom: 0.125rem;
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4135
|
+
/* Option value (when different from text) */
|
|
4136
|
+
.searchable-input__option-value {
|
|
4137
|
+
font-size: 0.75rem;
|
|
4138
|
+
line-height: 1.3;
|
|
4139
|
+
color: var(--text-muted);
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
.searchable-input__option--selected .searchable-input__option-value {
|
|
4143
|
+
color: var(--primary);
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
/* Highlight matching text */
|
|
4147
|
+
.searchable-input__highlight {
|
|
4148
|
+
background-color: var(--warning);
|
|
4149
|
+
color: var(--text-color);
|
|
4150
|
+
font-weight: 600;
|
|
4151
|
+
padding: 0.0625rem 0.125rem;
|
|
4152
|
+
border-radius: 0.125rem;
|
|
4153
|
+
}
|
|
4154
|
+
|
|
4155
|
+
/* No data message */
|
|
4156
|
+
.searchable-input__no-data {
|
|
4157
|
+
padding: 1rem;
|
|
4158
|
+
text-align: center;
|
|
4159
|
+
color: var(--text-muted);
|
|
4160
|
+
font-size: 0.875rem;
|
|
4161
|
+
font-style: italic;
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
/* Extra content */
|
|
4165
|
+
.searchable-input__extra {
|
|
4166
|
+
margin-top: 0.375rem;
|
|
4167
|
+
font-size: 0.75rem;
|
|
4168
|
+
line-height: 1.4;
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
|
|
4172
|
+
/* Responsive design */
|
|
4173
|
+
@media (max-width: 640px) {
|
|
4174
|
+
.searchable-input-wrapper {
|
|
4175
|
+
width: 100%;
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
.searchable-input {
|
|
4179
|
+
min-height: var(--inputHeight);
|
|
4180
|
+
font-size: 1rem; /* Prevents zoom on iOS */
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
.searchable-input__dropdown {
|
|
4184
|
+
left: -0.25rem;
|
|
4185
|
+
right: -0.25rem;
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4189
|
+
/* Focus-visible for better accessibility */
|
|
4190
|
+
.searchable-input:focus-visible {
|
|
4191
|
+
outline: var(--input_outline_size) solid var(--primary);
|
|
4192
|
+
outline-offset: 0.125rem;
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
.searchable-input__clear-btn:focus-visible {
|
|
4196
|
+
outline: var(--input_outline_size) solid var(--primary);
|
|
4197
|
+
outline-offset: 0.0625rem;
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
/* High contrast mode support */
|
|
4201
|
+
@media (prefers-contrast: high) {
|
|
4202
|
+
.searchable-input {
|
|
4203
|
+
border-width: 0.1875rem;
|
|
4204
|
+
}
|
|
4205
|
+
|
|
4206
|
+
.searchable-input__option--highlighted {
|
|
4207
|
+
background-color: var(--text-color);
|
|
4208
|
+
color: var(--background-color);
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
.searchable-input__highlight {
|
|
4212
|
+
background-color: var(--warning);
|
|
4213
|
+
color: var(--text-color);
|
|
4214
|
+
border: 1px solid var(--text-color);
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4217
|
+
|
|
4218
|
+
/* Reduced motion */
|
|
4219
|
+
@media (prefers-reduced-motion: reduce) {
|
|
4220
|
+
.searchable-input,
|
|
4221
|
+
.searchable-input__caret-icon,
|
|
4222
|
+
.searchable-input__clear-btn,
|
|
4223
|
+
.searchable-input__option {
|
|
4224
|
+
transition: none;
|
|
4225
|
+
}
|
|
4226
|
+
|
|
4227
|
+
.searchable-input__dropdown {
|
|
4228
|
+
animation: none;
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
.searchable-input__spinner {
|
|
4232
|
+
animation: none;
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
|
|
3777
4238
|
@media screen and (max-width: 800px){
|
|
3778
4239
|
.input , input, textarea , .bubble-editor , .bubble-editor-container{
|
|
3779
4240
|
font-size: 16px !important;
|
|
@@ -8763,4 +9224,7 @@ background-color: rgba(0, 0, 0, 0.2);
|
|
|
8763
9224
|
}
|
|
8764
9225
|
.ql-container.ql-snow {
|
|
8765
9226
|
border: 1px solid #ccc;
|
|
8766
|
-
}
|
|
9227
|
+
}
|
|
9228
|
+
|
|
9229
|
+
|
|
9230
|
+
|
package/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as Container } from "./ui/container/Container";
|
|
|
7
7
|
export { default as Grid } from "./ui/grid/Grid";
|
|
8
8
|
export { default as Col } from "./ui/grid/Col";
|
|
9
9
|
export { default as Input } from "./ui/input/Input";
|
|
10
|
+
export { default as SearchableInput } from "./ui/input/SearchableInput";
|
|
10
11
|
export { default as Loader } from "./ui/loader/Loader";
|
|
11
12
|
export { default as Modal } from "./ui/modal/Modal";
|
|
12
13
|
export { default as Table } from "./ui/table/Table";
|
package/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.GoogleAnalytics = exports.FunGet = exports.Cookie = exports.Select = exports.ScrollToTop = exports.FlexItem = exports.Slider = exports.Vista = exports.Calendar = void 0;
|
|
6
|
+
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.SearchableInput = 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.Select = exports.ScrollToTop = exports.FlexItem = exports.Slider = exports.Vista = exports.Calendar = exports.DatePicker = 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");
|
|
@@ -23,6 +23,8 @@ var Col_1 = require("./ui/grid/Col");
|
|
|
23
23
|
Object.defineProperty(exports, "Col", { enumerable: true, get: function () { return __importDefault(Col_1).default; } });
|
|
24
24
|
var Input_1 = require("./ui/input/Input");
|
|
25
25
|
Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return __importDefault(Input_1).default; } });
|
|
26
|
+
var SearchableInput_1 = require("./ui/input/SearchableInput");
|
|
27
|
+
Object.defineProperty(exports, "SearchableInput", { enumerable: true, get: function () { return __importDefault(SearchableInput_1).default; } });
|
|
26
28
|
var Loader_1 = require("./ui/loader/Loader");
|
|
27
29
|
Object.defineProperty(exports, "Loader", { enumerable: true, get: function () { return __importDefault(Loader_1).default; } });
|
|
28
30
|
var Modal_1 = require("./ui/modal/Modal");
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.5.
|
|
2
|
+
"version": "3.5.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",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SearchableOption {
|
|
3
|
+
value: string | number;
|
|
4
|
+
text: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
interface SearchableInputProps {
|
|
8
|
+
id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
status?: 'error' | 'success' | 'warning' | 'default';
|
|
11
|
+
funcss?: string;
|
|
12
|
+
bg?: string;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
flat?: boolean;
|
|
15
|
+
rounded?: boolean;
|
|
16
|
+
leftRounded?: boolean;
|
|
17
|
+
rightRounded?: boolean;
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
extra?: React.ReactNode;
|
|
22
|
+
value?: string;
|
|
23
|
+
data?: SearchableOption[];
|
|
24
|
+
onSelect?: (option: SearchableOption) => void;
|
|
25
|
+
onChange?: (value: string) => void;
|
|
26
|
+
onInputChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
27
|
+
dropDirection?: 'up' | 'down';
|
|
28
|
+
maxHeight?: string;
|
|
29
|
+
minChars?: number;
|
|
30
|
+
clearable?: boolean;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
noDataText?: string;
|
|
34
|
+
autoComplete?: boolean;
|
|
35
|
+
highlightMatch?: boolean;
|
|
36
|
+
}
|
|
37
|
+
declare const SearchableInput: React.FC<SearchableInputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value'>>;
|
|
38
|
+
export default SearchableInput;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
48
|
+
var t = {};
|
|
49
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
+
t[p] = s[p];
|
|
51
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
+
t[p[i]] = s[p[i]];
|
|
55
|
+
}
|
|
56
|
+
return t;
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
var react_1 = __importStar(require("react"));
|
|
60
|
+
var pi_1 = require("react-icons/pi");
|
|
61
|
+
// Mock function - replace with your actual function
|
|
62
|
+
var generateInputClasses = function (options) {
|
|
63
|
+
var baseClasses = 'input-base border border-gray-300 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500';
|
|
64
|
+
var statusClasses = {
|
|
65
|
+
error: 'border-red-500 focus:ring-red-500',
|
|
66
|
+
success: 'border-green-500 focus:ring-green-500',
|
|
67
|
+
warning: 'border-yellow-500 focus:ring-yellow-500',
|
|
68
|
+
default: 'border-gray-300 focus:ring-blue-500'
|
|
69
|
+
};
|
|
70
|
+
var classes = baseClasses;
|
|
71
|
+
if (options.status) {
|
|
72
|
+
classes += ' ' + statusClasses[options.status];
|
|
73
|
+
}
|
|
74
|
+
if (options.rounded)
|
|
75
|
+
classes += ' rounded-lg';
|
|
76
|
+
if (options.leftRounded)
|
|
77
|
+
classes += ' rounded-l-lg';
|
|
78
|
+
if (options.rightRounded)
|
|
79
|
+
classes += ' rounded-r-lg';
|
|
80
|
+
if (options.flat)
|
|
81
|
+
classes += ' shadow-none';
|
|
82
|
+
if (options.fullWidth)
|
|
83
|
+
classes += ' w-full';
|
|
84
|
+
if (options.additionalClasses)
|
|
85
|
+
classes += ' ' + options.additionalClasses;
|
|
86
|
+
return classes;
|
|
87
|
+
};
|
|
88
|
+
var SearchableInput = function (_a) {
|
|
89
|
+
var _b = _a.id, id = _b === void 0 ? 'searchableInput' : _b, name = _a.name, _c = _a.status, status = _c === void 0 ? 'default' : _c, funcss = _a.funcss, bg = _a.bg, _d = _a.fullWidth, fullWidth = _d === void 0 ? false : _d, _e = _a.flat, flat = _e === void 0 ? false : _e, _f = _a.rounded, rounded = _f === void 0 ? false : _f, _g = _a.leftRounded, leftRounded = _g === void 0 ? false : _g, _h = _a.rightRounded, rightRounded = _h === void 0 ? false : _h, label = _a.label, _j = _a.placeholder, placeholder = _j === void 0 ? 'Search...' : _j, icon = _a.icon, extra = _a.extra, _k = _a.value, value = _k === void 0 ? '' : _k, _l = _a.data, data = _l === void 0 ? [] : _l, onSelect = _a.onSelect, onChange = _a.onChange, onInputChange = _a.onInputChange, _m = _a.dropDirection, dropDirection = _m === void 0 ? 'up' : _m, _o = _a.maxHeight, maxHeight = _o === void 0 ? '200px' : _o, _p = _a.minChars, minChars = _p === void 0 ? 1 : _p, _q = _a.clearable, clearable = _q === void 0 ? true : _q, _r = _a.disabled, disabled = _r === void 0 ? false : _r, _s = _a.loading, loading = _s === void 0 ? false : _s, _t = _a.noDataText, noDataText = _t === void 0 ? 'No results found' : _t, _u = _a.autoComplete, autoComplete = _u === void 0 ? true : _u, _v = _a.highlightMatch, highlightMatch = _v === void 0 ? true : _v, rest = __rest(_a, ["id", "name", "status", "funcss", "bg", "fullWidth", "flat", "rounded", "leftRounded", "rightRounded", "label", "placeholder", "icon", "extra", "value", "data", "onSelect", "onChange", "onInputChange", "dropDirection", "maxHeight", "minChars", "clearable", "disabled", "loading", "noDataText", "autoComplete", "highlightMatch"]);
|
|
90
|
+
var _w = (0, react_1.useState)(value), inputValue = _w[0], setInputValue = _w[1];
|
|
91
|
+
var _x = (0, react_1.useState)(false), isOpen = _x[0], setIsOpen = _x[1];
|
|
92
|
+
var _y = (0, react_1.useState)(-1), highlightedIndex = _y[0], setHighlightedIndex = _y[1];
|
|
93
|
+
var _z = (0, react_1.useState)(null), selectedOption = _z[0], setSelectedOption = _z[1];
|
|
94
|
+
var inputRef = (0, react_1.useRef)(null);
|
|
95
|
+
var dropdownRef = (0, react_1.useRef)(null);
|
|
96
|
+
var optionRefs = (0, react_1.useRef)([]);
|
|
97
|
+
// Filter and sort options based on input
|
|
98
|
+
var filteredOptions = (0, react_1.useMemo)(function () {
|
|
99
|
+
if (!inputValue || inputValue.length < minChars)
|
|
100
|
+
return [];
|
|
101
|
+
var filtered = data.filter(function (option) {
|
|
102
|
+
return option.text.toLowerCase().includes(inputValue.toLowerCase()) ||
|
|
103
|
+
option.value.toString().toLowerCase().includes(inputValue.toLowerCase());
|
|
104
|
+
});
|
|
105
|
+
// Sort by relevance (exact matches first, then starts with, then contains)
|
|
106
|
+
return filtered.sort(function (a, b) {
|
|
107
|
+
var aText = a.text.toLowerCase();
|
|
108
|
+
var bText = b.text.toLowerCase();
|
|
109
|
+
var query = inputValue.toLowerCase();
|
|
110
|
+
if (aText === query)
|
|
111
|
+
return -1;
|
|
112
|
+
if (bText === query)
|
|
113
|
+
return 1;
|
|
114
|
+
if (aText.startsWith(query) && !bText.startsWith(query))
|
|
115
|
+
return -1;
|
|
116
|
+
if (bText.startsWith(query) && !aText.startsWith(query))
|
|
117
|
+
return 1;
|
|
118
|
+
return 0;
|
|
119
|
+
});
|
|
120
|
+
}, [inputValue, data, minChars]);
|
|
121
|
+
// Auto-complete logic
|
|
122
|
+
(0, react_1.useEffect)(function () {
|
|
123
|
+
if (autoComplete && filteredOptions.length > 0 && inputValue) {
|
|
124
|
+
var exactMatch = filteredOptions.find(function (option) {
|
|
125
|
+
return option.text.toLowerCase() === inputValue.toLowerCase();
|
|
126
|
+
});
|
|
127
|
+
if (exactMatch) {
|
|
128
|
+
setSelectedOption(exactMatch);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}, [filteredOptions, inputValue, autoComplete]);
|
|
132
|
+
// Handle input change
|
|
133
|
+
var handleInputChange = function (e) {
|
|
134
|
+
var newValue = e.target.value;
|
|
135
|
+
setInputValue(newValue);
|
|
136
|
+
setIsOpen(newValue.length >= minChars);
|
|
137
|
+
setHighlightedIndex(-1);
|
|
138
|
+
setSelectedOption(null);
|
|
139
|
+
if (onChange)
|
|
140
|
+
onChange(newValue);
|
|
141
|
+
if (onInputChange)
|
|
142
|
+
onInputChange(e);
|
|
143
|
+
};
|
|
144
|
+
// Handle option selection
|
|
145
|
+
var handleOptionSelect = function (option) {
|
|
146
|
+
setInputValue(option.text);
|
|
147
|
+
setSelectedOption(option);
|
|
148
|
+
setIsOpen(false);
|
|
149
|
+
setHighlightedIndex(-1);
|
|
150
|
+
if (onSelect)
|
|
151
|
+
onSelect(option);
|
|
152
|
+
if (onChange)
|
|
153
|
+
onChange(option.text);
|
|
154
|
+
};
|
|
155
|
+
// Handle keyboard navigation
|
|
156
|
+
var handleKeyDown = function (e) {
|
|
157
|
+
if (!isOpen || filteredOptions.length === 0)
|
|
158
|
+
return;
|
|
159
|
+
switch (e.key) {
|
|
160
|
+
case 'ArrowDown':
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
setHighlightedIndex(function (prev) {
|
|
163
|
+
return prev < filteredOptions.length - 1 ? prev + 1 : 0;
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
case 'ArrowUp':
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
setHighlightedIndex(function (prev) {
|
|
169
|
+
return prev > 0 ? prev - 1 : filteredOptions.length - 1;
|
|
170
|
+
});
|
|
171
|
+
break;
|
|
172
|
+
case 'Enter':
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
if (highlightedIndex >= 0) {
|
|
175
|
+
handleOptionSelect(filteredOptions[highlightedIndex]);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case 'Escape':
|
|
179
|
+
setIsOpen(false);
|
|
180
|
+
setHighlightedIndex(-1);
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
// Scroll highlighted option into view
|
|
185
|
+
(0, react_1.useEffect)(function () {
|
|
186
|
+
var _a;
|
|
187
|
+
if (highlightedIndex >= 0 && optionRefs.current[highlightedIndex]) {
|
|
188
|
+
(_a = optionRefs.current[highlightedIndex]) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
189
|
+
behavior: 'smooth',
|
|
190
|
+
block: 'nearest'
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}, [highlightedIndex]);
|
|
194
|
+
// Close dropdown when clicking outside
|
|
195
|
+
(0, react_1.useEffect)(function () {
|
|
196
|
+
var handleClickOutside = function (event) {
|
|
197
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target) &&
|
|
198
|
+
inputRef.current && !inputRef.current.contains(event.target)) {
|
|
199
|
+
setIsOpen(false);
|
|
200
|
+
setHighlightedIndex(-1);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
204
|
+
return function () { return document.removeEventListener('mousedown', handleClickOutside); };
|
|
205
|
+
}, []);
|
|
206
|
+
// Clear input
|
|
207
|
+
var handleClear = function () {
|
|
208
|
+
var _a;
|
|
209
|
+
setInputValue('');
|
|
210
|
+
setSelectedOption(null);
|
|
211
|
+
setIsOpen(false);
|
|
212
|
+
if (onChange)
|
|
213
|
+
onChange('');
|
|
214
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
215
|
+
};
|
|
216
|
+
// Highlight matching text
|
|
217
|
+
var highlightText = function (text, highlight) {
|
|
218
|
+
if (!highlightMatch || !highlight)
|
|
219
|
+
return text;
|
|
220
|
+
var parts = text.split(new RegExp("(".concat(highlight, ")"), 'gi'));
|
|
221
|
+
return parts.map(function (part, index) {
|
|
222
|
+
return part.toLowerCase() === highlight.toLowerCase() ? (react_1.default.createElement("span", { key: index, className: "bg-yellow-200 font-medium" }, part)) : part;
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
var className = generateInputClasses({
|
|
226
|
+
status: status,
|
|
227
|
+
rounded: rounded,
|
|
228
|
+
bg: bg,
|
|
229
|
+
funcss: funcss,
|
|
230
|
+
flat: flat,
|
|
231
|
+
leftRounded: leftRounded,
|
|
232
|
+
rightRounded: rightRounded,
|
|
233
|
+
bordered: true,
|
|
234
|
+
borderless: false,
|
|
235
|
+
fullWidth: fullWidth,
|
|
236
|
+
additionalClasses: 'searchableInput'
|
|
237
|
+
});
|
|
238
|
+
var containerStyle = fullWidth ? { width: '100%' } : undefined;
|
|
239
|
+
var dropdownClasses = "absolute z-50 bg-white border border-gray-300 rounded-md shadow-lg ".concat(dropDirection === 'up' ? 'bottom-full mb-1' : 'top-full mt-1', " left-0 right-0");
|
|
240
|
+
return (react_1.default.createElement("div", { className: "searchableInput-wrapper relative", style: containerStyle },
|
|
241
|
+
label && (react_1.default.createElement("label", { htmlFor: id, className: "block text-sm font-medium text-gray-700 mb-1" }, label)),
|
|
242
|
+
react_1.default.createElement("div", { className: "relative" },
|
|
243
|
+
react_1.default.createElement("div", { className: "relative flex items-center" },
|
|
244
|
+
icon && (react_1.default.createElement("div", { className: "absolute left-3 pointer-events-none text-gray-400" }, icon)),
|
|
245
|
+
react_1.default.createElement("input", __assign({ ref: inputRef, id: id, name: name, type: "text", className: "".concat(className, " ").concat(icon ? 'pl-10' : '', " ").concat(clearable && inputValue ? 'pr-16' : 'pr-10'), placeholder: placeholder, value: inputValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onFocus: function () { return inputValue.length >= minChars && setIsOpen(true); }, disabled: disabled }, rest)),
|
|
246
|
+
react_1.default.createElement("div", { className: "absolute right-3 flex items-center space-x-1" },
|
|
247
|
+
clearable && inputValue && !disabled && (react_1.default.createElement("button", { type: "button", onClick: handleClear, className: "text-gray-400 hover:text-gray-600 p-1", tabIndex: -1 },
|
|
248
|
+
react_1.default.createElement(pi_1.PiX, { size: 16 }))),
|
|
249
|
+
react_1.default.createElement("div", { className: "text-gray-400" }, loading ? (react_1.default.createElement("div", { className: "animate-spin w-4 h-4 border-2 border-gray-300 border-t-gray-600 rounded-full" })) : (react_1.default.createElement(pi_1.PiCaretDown, { size: 16, className: "transition-transform ".concat(isOpen ? 'rotate-180' : '') }))))),
|
|
250
|
+
isOpen && !disabled && (react_1.default.createElement("div", { ref: dropdownRef, className: dropdownClasses, style: { maxHeight: maxHeight } },
|
|
251
|
+
react_1.default.createElement("div", { className: "py-1 overflow-y-auto", style: { maxHeight: maxHeight } }, filteredOptions.length > 0 ? (filteredOptions.map(function (option, index) { return (react_1.default.createElement("div", { key: "".concat(option.value, "-").concat(index), ref: function (el) {
|
|
252
|
+
optionRefs.current[index] = el;
|
|
253
|
+
}, className: "px-3 py-2 cursor-pointer hover:bg-blue-50 ".concat(index === highlightedIndex ? 'bg-blue-100' : '', " ").concat((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value ? 'bg-blue-50' : ''), onClick: function () { return handleOptionSelect(option); } },
|
|
254
|
+
react_1.default.createElement("div", { className: "text-sm text-gray-900" }, highlightText(option.text, inputValue)),
|
|
255
|
+
option.value !== option.text && (react_1.default.createElement("div", { className: "text-xs text-gray-500" }, option.value)))); })) : (react_1.default.createElement("div", { className: "px-3 py-2 text-sm text-gray-500" }, noDataText)))))),
|
|
256
|
+
extra && react_1.default.createElement("div", { className: "searchableInput-extra mt-1" }, extra)));
|
|
257
|
+
};
|
|
258
|
+
exports.default = SearchableInput;
|
package/ui/select/Select.d.ts
CHANGED
package/ui/select/Select.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
var react_1 = __importStar(require("react"));
|
|
37
37
|
var Select = function (_a) {
|
|
38
|
-
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, _b = _a.
|
|
38
|
+
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, _b = _a.label, label = _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 ? true : _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, _q = _a.searchAutoFocus, searchAutoFocus = _q === void 0 ? false : _q;
|
|
39
39
|
var _r = (0, react_1.useState)(false), isOpen = _r[0], setIsOpen = _r[1];
|
|
40
40
|
var _s = (0, react_1.useState)(null), selectedOption = _s[0], setSelectedOption = _s[1];
|
|
41
41
|
var _t = (0, react_1.useState)(''), searchQuery = _t[0], setSearchQuery = _t[1];
|
|
@@ -179,7 +179,7 @@ var Select = function (_a) {
|
|
|
179
179
|
};
|
|
180
180
|
return (react_1.default.createElement("div", { ref: containerRef, className: "".concat(funcss, " ").concat(rounded && 'round-edge', " ").concat(getContainerClasses()), style: style },
|
|
181
181
|
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" },
|
|
182
|
-
react_1.default.createElement("span", { className: "select-value ".concat(!selectedOption ? 'select-placeholder' : '') }, selectedOption ? selectedOption.text :
|
|
182
|
+
react_1.default.createElement("span", { className: "select-value ".concat(!selectedOption ? 'select-placeholder' : '') }, selectedOption ? selectedOption.text : label),
|
|
183
183
|
react_1.default.createElement("div", { className: "select-arrow ".concat(isOpen ? 'open' : '') },
|
|
184
184
|
react_1.default.createElement("svg", { width: "16", height: "16", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" },
|
|
185
185
|
react_1.default.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M19 9l-7 7-7-7" })))),
|
package/ui/table/Query.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
interface DataConfig {
|
|
2
2
|
fields: string[];
|
|
3
|
+
priorityFields?: string[];
|
|
3
4
|
}
|
|
4
5
|
type GetNestedValueFunction = (obj: any, path: string) => any;
|
|
5
|
-
export declare const getAdvancedFilteredData: <T = any>(filteredData: T[], searchQuery: string, data: DataConfig, getNestedValue: GetNestedValueFunction) => T[];
|
|
6
|
-
export declare const getFilteredAndPaginatedData: <T = any>(filteredData: T[], searchQuery: string, data: DataConfig, getNestedValue: GetNestedValueFunction, startIndex?: number, endIndex?: number) => T[];
|
|
6
|
+
export declare const getAdvancedFilteredData: <T = any>(filteredData: T[], searchQuery: string, data: DataConfig, getNestedValue: GetNestedValueFunction, priorityFields?: string[]) => T[];
|
|
7
|
+
export declare const getFilteredAndPaginatedData: <T = any>(filteredData: T[], searchQuery: string, data: DataConfig, getNestedValue: GetNestedValueFunction, startIndex?: number, endIndex?: number, priorityFields?: string[]) => T[];
|
|
7
8
|
export {};
|
package/ui/table/Query.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFilteredAndPaginatedData = exports.getAdvancedFilteredData = void 0;
|
|
4
|
+
// Helper function to check if a nested field exists
|
|
5
|
+
var fieldExists = function (obj, path, getNestedValue) {
|
|
6
|
+
try {
|
|
7
|
+
var value = getNestedValue(obj, path);
|
|
8
|
+
return value !== null && value !== undefined;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
4
14
|
// Simple Levenshtein distance function for fuzzy matching
|
|
5
15
|
var levenshteinDistance = function (str1, str2) {
|
|
6
16
|
var matrix = Array(str2.length + 1).fill(null).map(function () {
|
|
@@ -92,8 +102,9 @@ var searchStrategies = [
|
|
|
92
102
|
});
|
|
93
103
|
},
|
|
94
104
|
];
|
|
95
|
-
// MAIN FUNCTION:
|
|
96
|
-
var getAdvancedFilteredData = function (filteredData, searchQuery, data, getNestedValue
|
|
105
|
+
// MAIN FUNCTION: Enhanced with priority fields support
|
|
106
|
+
var getAdvancedFilteredData = function (filteredData, searchQuery, data, getNestedValue, priorityFields // New optional parameter for priority fields
|
|
107
|
+
) {
|
|
97
108
|
return filteredData.filter(function (mdoc, index) {
|
|
98
109
|
if (searchQuery) {
|
|
99
110
|
// Convert search query to lowercase for case-insensitive search
|
|
@@ -102,27 +113,68 @@ var getAdvancedFilteredData = function (filteredData, searchQuery, data, getNest
|
|
|
102
113
|
return true; // If empty query after trim, show all
|
|
103
114
|
// Split query into multiple terms for multi-term search
|
|
104
115
|
var queryTerms_1 = query_1.split(/\s+/).filter(function (term) { return term.length > 0; });
|
|
105
|
-
//
|
|
106
|
-
|
|
116
|
+
// Determine which fields to search and in what order
|
|
117
|
+
var fieldsToSearch = [];
|
|
118
|
+
if (priorityFields && priorityFields.length > 0) {
|
|
119
|
+
// First add priority fields that exist in the data config and in the object
|
|
120
|
+
var validPriorityFields = priorityFields.filter(function (field) {
|
|
121
|
+
return data.fields.includes(field) && fieldExists(mdoc, field, getNestedValue);
|
|
122
|
+
});
|
|
123
|
+
fieldsToSearch.push.apply(fieldsToSearch, validPriorityFields);
|
|
124
|
+
// Then add remaining fields from data.fields that aren't in priority and exist in the object
|
|
125
|
+
var remainingFields = data.fields.filter(function (field) {
|
|
126
|
+
return !priorityFields.includes(field) && fieldExists(mdoc, field, getNestedValue);
|
|
127
|
+
});
|
|
128
|
+
fieldsToSearch.push.apply(fieldsToSearch, remainingFields);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// Use data.priorityFields if available, otherwise use data.fields
|
|
132
|
+
var priorityFromConfig_1 = data.priorityFields || [];
|
|
133
|
+
if (priorityFromConfig_1.length > 0) {
|
|
134
|
+
var validPriorityFields = priorityFromConfig_1.filter(function (field) {
|
|
135
|
+
return data.fields.includes(field) && fieldExists(mdoc, field, getNestedValue);
|
|
136
|
+
});
|
|
137
|
+
fieldsToSearch.push.apply(fieldsToSearch, validPriorityFields);
|
|
138
|
+
var remainingFields = data.fields.filter(function (field) {
|
|
139
|
+
return !priorityFromConfig_1.includes(field) && fieldExists(mdoc, field, getNestedValue);
|
|
140
|
+
});
|
|
141
|
+
fieldsToSearch.push.apply(fieldsToSearch, remainingFields);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
// Just use fields that exist in the object
|
|
145
|
+
fieldsToSearch = data.fields.filter(function (field) { return fieldExists(mdoc, field, getNestedValue); });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
var _loop_1 = function (field) {
|
|
107
149
|
try {
|
|
108
150
|
// Get the value using the same getNestedValue function used for display
|
|
109
151
|
var value = getNestedValue(mdoc, field);
|
|
110
152
|
// Convert value to string and search
|
|
111
153
|
if (value !== null && value !== undefined) {
|
|
112
154
|
var stringValue_1 = String(value).toLowerCase();
|
|
113
|
-
// Use advanced search strategies
|
|
114
|
-
|
|
155
|
+
// Use advanced search strategies
|
|
156
|
+
var foundMatch = searchStrategies.some(function (strategy) {
|
|
115
157
|
return strategy(stringValue_1, query_1, queryTerms_1);
|
|
116
158
|
});
|
|
159
|
+
if (foundMatch) {
|
|
160
|
+
return { value: true };
|
|
161
|
+
}
|
|
117
162
|
}
|
|
118
|
-
return false;
|
|
119
163
|
}
|
|
120
164
|
catch (error) {
|
|
121
165
|
// Handle any errors in accessing nested values
|
|
122
166
|
console.warn("Error accessing field ".concat(field, ":"), error);
|
|
123
|
-
return
|
|
167
|
+
return "continue";
|
|
124
168
|
}
|
|
125
|
-
}
|
|
169
|
+
};
|
|
170
|
+
// Search through fields in priority order - return true on first match
|
|
171
|
+
for (var _i = 0, fieldsToSearch_1 = fieldsToSearch; _i < fieldsToSearch_1.length; _i++) {
|
|
172
|
+
var field = fieldsToSearch_1[_i];
|
|
173
|
+
var state_1 = _loop_1(field);
|
|
174
|
+
if (typeof state_1 === "object")
|
|
175
|
+
return state_1.value;
|
|
176
|
+
}
|
|
177
|
+
return false; // No matches found in any field
|
|
126
178
|
}
|
|
127
179
|
else {
|
|
128
180
|
return true; // If no search query, return all items
|
|
@@ -131,9 +183,10 @@ var getAdvancedFilteredData = function (filteredData, searchQuery, data, getNest
|
|
|
131
183
|
};
|
|
132
184
|
exports.getAdvancedFilteredData = getAdvancedFilteredData;
|
|
133
185
|
// Optional: Simplified version with pagination built-in
|
|
134
|
-
var getFilteredAndPaginatedData = function (filteredData, searchQuery, data, getNestedValue, startIndex, endIndex
|
|
186
|
+
var getFilteredAndPaginatedData = function (filteredData, searchQuery, data, getNestedValue, startIndex, endIndex, priorityFields // Added priority fields parameter
|
|
187
|
+
) {
|
|
135
188
|
if (startIndex === void 0) { startIndex = 0; }
|
|
136
|
-
var filtered = (0, exports.getAdvancedFilteredData)(filteredData, searchQuery, data, getNestedValue);
|
|
189
|
+
var filtered = (0, exports.getAdvancedFilteredData)(filteredData, searchQuery, data, getNestedValue, priorityFields);
|
|
137
190
|
return endIndex !== undefined ? filtered.slice(startIndex, endIndex) : filtered.slice(startIndex);
|
|
138
191
|
};
|
|
139
192
|
exports.getFilteredAndPaginatedData = getFilteredAndPaginatedData;
|
package/ui/table/Table.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ type TableProps = {
|
|
|
18
18
|
"funcss": string[];
|
|
19
19
|
};
|
|
20
20
|
filterOnchange?: (filter?: any, value?: any, totals?: number) => {};
|
|
21
|
+
clearSearch?: boolean;
|
|
21
22
|
head?: React.ReactNode;
|
|
22
23
|
right?: React.ReactNode;
|
|
23
24
|
body?: React.ReactNode;
|
|
@@ -34,8 +35,9 @@ type TableProps = {
|
|
|
34
35
|
onClick?: (data: any) => void;
|
|
35
36
|
}[];
|
|
36
37
|
filterableFields?: string[];
|
|
38
|
+
prioritizeSearchFields?: string[];
|
|
37
39
|
};
|
|
38
40
|
export default function Table({ children, funcss, bordered, noStripped, hoverable, title, showTotal, light, dark, head, body, data, isLoading, right, hideExport, height, pageSize, // Default page size,
|
|
39
41
|
customColumns, filterableFields, // New prop
|
|
40
|
-
emptyResponse, filterOnchange, ...rest }: TableProps): React.JSX.Element;
|
|
42
|
+
emptyResponse, filterOnchange, clearSearch, prioritizeSearchFields, ...rest }: TableProps): React.JSX.Element;
|
|
41
43
|
export {};
|
package/ui/table/Table.js
CHANGED
|
@@ -95,20 +95,25 @@ function Table(_a) {
|
|
|
95
95
|
var _b, _c;
|
|
96
96
|
var children = _a.children, funcss = _a.funcss, bordered = _a.bordered, noStripped = _a.noStripped, hoverable = _a.hoverable, _d = _a.title, title = _d === void 0 ? "" : _d, showTotal = _a.showTotal, light = _a.light, dark = _a.dark, head = _a.head, body = _a.body, data = _a.data, _e = _a.isLoading, isLoading = _e === void 0 ? false : _e, right = _a.right, hideExport = _a.hideExport, height = _a.height, _f = _a.pageSize, pageSize = _f === void 0 ? data ? 10 : 0 : _f, // Default page size,
|
|
97
97
|
customColumns = _a.customColumns, filterableFields = _a.filterableFields, // New prop
|
|
98
|
-
emptyResponse = _a.emptyResponse, filterOnchange = _a.filterOnchange, rest = __rest(_a, ["children", "funcss", "bordered", "noStripped", "hoverable", "title", "showTotal", "light", "dark", "head", "body", "data", "isLoading", "right", "hideExport", "height", "pageSize", "customColumns", "filterableFields", "emptyResponse", "filterOnchange"]);
|
|
98
|
+
emptyResponse = _a.emptyResponse, filterOnchange = _a.filterOnchange, clearSearch = _a.clearSearch, _g = _a.prioritizeSearchFields, prioritizeSearchFields = _g === void 0 ? [] : _g, rest = __rest(_a, ["children", "funcss", "bordered", "noStripped", "hoverable", "title", "showTotal", "light", "dark", "head", "body", "data", "isLoading", "right", "hideExport", "height", "pageSize", "customColumns", "filterableFields", "emptyResponse", "filterOnchange", "clearSearch", "prioritizeSearchFields"]);
|
|
99
99
|
// Check if data is null or undefined before accessing its properties
|
|
100
100
|
// Replace this in your component
|
|
101
|
-
var
|
|
102
|
-
var
|
|
101
|
+
var _h = (0, react_1.useState)(''), search = _h[0], setSearch = _h[1];
|
|
102
|
+
var _j = (0, react_1.useState)(1), currentPage = _j[0], setCurrentPage = _j[1];
|
|
103
103
|
// Determine the total number of pages based on data length and page size
|
|
104
104
|
var totalPages = data ? Math.ceil((((_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.length) || 0) / pageSize) : 0;
|
|
105
105
|
// Calculate start and end indices for data pagination
|
|
106
106
|
var startIndex = data ? (currentPage - 1) * pageSize : 0;
|
|
107
107
|
var endIndex = data ? Math.min(startIndex + pageSize, ((_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.length) || 0) : 0;
|
|
108
|
-
var
|
|
109
|
-
var
|
|
110
|
-
var
|
|
111
|
-
var
|
|
108
|
+
var _k = (0, react_1.useState)(null), selectedField = _k[0], setSelectedField = _k[1];
|
|
109
|
+
var _l = (0, react_1.useState)(null), selectedValue = _l[0], setSelectedValue = _l[1];
|
|
110
|
+
var _m = (0, react_1.useState)(true), showSearch = _m[0], setshowSearch = _m[1];
|
|
111
|
+
var _o = (0, react_1.useState)(""), searchQuery = _o[0], setsearchQuery = _o[1];
|
|
112
|
+
React.useEffect(function () {
|
|
113
|
+
if (clearSearch) {
|
|
114
|
+
setsearchQuery("");
|
|
115
|
+
}
|
|
116
|
+
}, [clearSearch]);
|
|
112
117
|
// Enhanced filter logic:
|
|
113
118
|
var normalize = function (val) { return val === null || val === void 0 ? void 0 : val.toString().toLowerCase().trim(); };
|
|
114
119
|
var matchesSearch = function (item) {
|
|
@@ -269,41 +274,20 @@ function Table(_a) {
|
|
|
269
274
|
head && React.createElement(Head_1.default, null, head),
|
|
270
275
|
body && React.createElement(Body_1.default, null, body),
|
|
271
276
|
data &&
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
// }
|
|
287
|
-
// return false;
|
|
288
|
-
// } catch (error) {
|
|
289
|
-
// // Handle any errors in accessing nested values
|
|
290
|
-
// console.warn(`Error accessing field ${field}:`, error);
|
|
291
|
-
// return false;
|
|
292
|
-
// }
|
|
293
|
-
// });
|
|
294
|
-
// } else {
|
|
295
|
-
// return true; // If no search query, return all items
|
|
296
|
-
// }
|
|
297
|
-
// })
|
|
298
|
-
(0, Query_1.getAdvancedFilteredData)(filteredData, searchQuery, data, getNestedValue).slice(startIndex, endIndex).map(function (mdoc, index) { return (React.createElement("tr", { className: 'animated slide-up', key: index },
|
|
299
|
-
data.fields.map(function (fdoc, findex) {
|
|
300
|
-
var _a;
|
|
301
|
-
return (React.createElement(Data_1.default, { key: fdoc, funcss: data.funcss ? ((_a = data === null || data === void 0 ? void 0 : data.funcss) === null || _a === void 0 ? void 0 : _a[findex]) || '' : '' }, getNestedValue(mdoc, fdoc)));
|
|
302
|
-
}),
|
|
303
|
-
customColumns ?
|
|
304
|
-
customColumns.map(function (column, columnIndex) { return (React.createElement("td", { key: columnIndex },
|
|
305
|
-
column.render && column.render(mdoc),
|
|
306
|
-
column.onClick && (React.createElement(Button_1.default, { onClick: function () { return column.onClick && column.onClick(mdoc); } }, column.title)))); }) : "")); }),
|
|
277
|
+
(function () {
|
|
278
|
+
var results = (0, Query_1.getAdvancedFilteredData)(filteredData, searchQuery, data, getNestedValue, prioritizeSearchFields);
|
|
279
|
+
var shouldSlice = !searchQuery || results.length > 10;
|
|
280
|
+
return (shouldSlice ? results.slice(startIndex, endIndex) : results)
|
|
281
|
+
.map(function (mdoc, index) { return (React.createElement("tr", { className: 'animated slide-up', key: index },
|
|
282
|
+
data.fields.map(function (fdoc, findex) {
|
|
283
|
+
var _a;
|
|
284
|
+
return (React.createElement(Data_1.default, { key: fdoc, funcss: data.funcss ? ((_a = data === null || data === void 0 ? void 0 : data.funcss) === null || _a === void 0 ? void 0 : _a[findex]) || '' : '' }, getNestedValue(mdoc, fdoc)));
|
|
285
|
+
}),
|
|
286
|
+
customColumns ?
|
|
287
|
+
customColumns.map(function (column, columnIndex) { return (React.createElement("td", { key: columnIndex },
|
|
288
|
+
column.render && column.render(mdoc),
|
|
289
|
+
column.onClick && (React.createElement(Button_1.default, { onClick: function () { return column.onClick && column.onClick(mdoc); } }, column.title)))); }) : "")); });
|
|
290
|
+
})(),
|
|
307
291
|
isLoading &&
|
|
308
292
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function () { return (React.createElement(Row_1.default, { funcss: 'skeleton' })); }),
|
|
309
293
|
children ? children : ''),
|