next-helios-fe 1.8.0 → 1.8.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/dist/components/form/index.d.ts +2 -2
- package/dist/components/form/other/rating.d.ts +9 -0
- package/dist/components/form/other/select.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/form/index.tsx +3 -3
- package/src/components/form/other/{rate.tsx → rating.tsx} +2 -2
- package/src/components/form/other/select.tsx +42 -18
package/package.json
CHANGED
@@ -22,7 +22,7 @@ import {
|
|
22
22
|
type MultipleSelectProps,
|
23
23
|
} from "./other/multipleSelect";
|
24
24
|
import { Autocomplete, type AutocompleteProps } from "./other/autocomplete";
|
25
|
-
import {
|
25
|
+
import { Rating, type RatingProps } from "./other/rating";
|
26
26
|
import { Emoji, type EmojiProps } from "./other/emoji";
|
27
27
|
|
28
28
|
interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
@@ -49,7 +49,7 @@ interface FormComponent extends React.FC<FormProps> {
|
|
49
49
|
Select: React.FC<SelectProps>;
|
50
50
|
MultipleSelect: React.FC<MultipleSelectProps>;
|
51
51
|
Autocomplete: React.FC<AutocompleteProps>;
|
52
|
-
|
52
|
+
Rating: React.FC<RatingProps>;
|
53
53
|
Emoji: React.FC<EmojiProps>;
|
54
54
|
}
|
55
55
|
|
@@ -86,5 +86,5 @@ Form.Textarea = Textarea;
|
|
86
86
|
Form.Select = Select;
|
87
87
|
Form.MultipleSelect = MultipleSelect;
|
88
88
|
Form.Autocomplete = Autocomplete;
|
89
|
-
Form.
|
89
|
+
Form.Rating = Rating;
|
90
90
|
Form.Emoji = Emoji;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import React, { useState, useEffect } from "react";
|
3
3
|
import { Icon } from "@iconify/react";
|
4
4
|
|
5
|
-
export interface
|
5
|
+
export interface RatingProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
6
6
|
label?: string;
|
7
7
|
description?: string;
|
8
8
|
options?: {
|
@@ -10,7 +10,7 @@ export interface RateProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
10
10
|
};
|
11
11
|
}
|
12
12
|
|
13
|
-
export const
|
13
|
+
export const Rating: React.FC<RatingProps> = ({
|
14
14
|
options,
|
15
15
|
label,
|
16
16
|
description,
|
@@ -8,6 +8,7 @@ export interface SelectProps
|
|
8
8
|
menus: {
|
9
9
|
label: string;
|
10
10
|
value: string;
|
11
|
+
disabled?: boolean;
|
11
12
|
[key: string]: any;
|
12
13
|
}[];
|
13
14
|
label?: string;
|
@@ -144,24 +145,47 @@ export const Select: React.FC<SelectProps> = ({
|
|
144
145
|
<span className="px-4 py-1">No data found</span>
|
145
146
|
</div>
|
146
147
|
) : (
|
147
|
-
menus.map((item, index) =>
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
148
|
+
menus.map((item, index) => {
|
149
|
+
if (tempValue === item.value) {
|
150
|
+
return (
|
151
|
+
<button
|
152
|
+
key={index}
|
153
|
+
type="button"
|
154
|
+
className="min-w-40 w-full my-0.5 px-4 py-2 rounded-md text-sm text-left hover:bg-secondary-light disabled:bg-primary-transparent disabled:text-primary"
|
155
|
+
disabled
|
156
|
+
onClick={() => {
|
157
|
+
setTempValue(item.value);
|
158
|
+
if (rest.onChange) {
|
159
|
+
rest.onChange({
|
160
|
+
target: { value: item.value } as HTMLSelectElement,
|
161
|
+
} as any);
|
162
|
+
}
|
163
|
+
}}
|
164
|
+
>
|
165
|
+
{item.label}
|
166
|
+
</button>
|
167
|
+
);
|
168
|
+
} else {
|
169
|
+
return (
|
170
|
+
<button
|
171
|
+
key={index}
|
172
|
+
type="button"
|
173
|
+
className="min-w-40 w-full my-0.5 px-4 py-2 rounded-md text-sm text-left hover:bg-secondary-light disabled:text-slate-400"
|
174
|
+
disabled={item.disabled}
|
175
|
+
onClick={() => {
|
176
|
+
setTempValue(item.value);
|
177
|
+
if (rest.onChange) {
|
178
|
+
rest.onChange({
|
179
|
+
target: { value: item.value } as HTMLSelectElement,
|
180
|
+
} as any);
|
181
|
+
}
|
182
|
+
}}
|
183
|
+
>
|
184
|
+
{item.label}
|
185
|
+
</button>
|
186
|
+
);
|
187
|
+
}
|
188
|
+
})
|
165
189
|
)}
|
166
190
|
</div>
|
167
191
|
</Dropdown>
|