@yuzu-jobs/ui-components 0.0.6 → 0.0.8
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/index.ts +2 -0
- package/package.json +1 -1
- package/src/InputSwitch.astro +50 -0
- package/src/InputText.astro +24 -33
package/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import InputText from "./src/InputText.astro";
|
|
5
5
|
import InputSelect from "./src/InputSelect.astro";
|
|
6
|
+
import InputSwitch from "./src/InputSwitch.astro";
|
|
6
7
|
import InputContainer from "./src/InputContainer.astro";
|
|
7
8
|
import InputLabel from "./src/InputLabel.astro";
|
|
8
9
|
import Alert from "./src/Alert.astro";
|
|
@@ -14,6 +15,7 @@ export {
|
|
|
14
15
|
Button,
|
|
15
16
|
InputText,
|
|
16
17
|
InputSelect,
|
|
18
|
+
InputSwitch,
|
|
17
19
|
InputContainer,
|
|
18
20
|
InputLabel,
|
|
19
21
|
Alert,
|
package/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
"data-pref-type"?: string;
|
|
9
|
+
"data-pref-channel"?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
id,
|
|
14
|
+
name,
|
|
15
|
+
label,
|
|
16
|
+
checked,
|
|
17
|
+
required,
|
|
18
|
+
"data-pref-type": dataPrefType,
|
|
19
|
+
"data-pref-channel": dataPrefChannel,
|
|
20
|
+
} = Astro.props;
|
|
21
|
+
|
|
22
|
+
const hasSlot = Astro.slots.has("default");
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<label class="flex items-center gap-3 cursor-pointer group" for={id}>
|
|
26
|
+
<div class="relative">
|
|
27
|
+
<input
|
|
28
|
+
class="sr-only peer"
|
|
29
|
+
type="checkbox"
|
|
30
|
+
id={id}
|
|
31
|
+
name={name}
|
|
32
|
+
required={required ?? false}
|
|
33
|
+
checked={checked ?? false}
|
|
34
|
+
data-pref-type={dataPrefType}
|
|
35
|
+
data-pref-channel={dataPrefChannel}
|
|
36
|
+
/>
|
|
37
|
+
<div
|
|
38
|
+
class="w-10 h-6 bg-gray-200 rounded-full transition-colors peer-checked:bg-primary peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-primary peer-focus-visible:ring-offset-2"
|
|
39
|
+
>
|
|
40
|
+
</div>
|
|
41
|
+
<div
|
|
42
|
+
class="absolute top-1 left-1 w-4 h-4 bg-white rounded-full shadow-sm transition-transform peer-checked:translate-x-4"
|
|
43
|
+
>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<span class="text-sm group-hover:text-primary transition-colors">
|
|
47
|
+
{hasSlot ? <slot /> : label}
|
|
48
|
+
{required && <span class="text-red-500 text-lg">*</span>}
|
|
49
|
+
</span>
|
|
50
|
+
</label>
|
package/src/InputText.astro
CHANGED
|
@@ -9,6 +9,9 @@ interface Props {
|
|
|
9
9
|
maxLength?: number;
|
|
10
10
|
minLength?: number;
|
|
11
11
|
autocomplete?: string;
|
|
12
|
+
step?: number | "any";
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
const {
|
|
@@ -16,46 +19,34 @@ const {
|
|
|
16
19
|
name,
|
|
17
20
|
placeholder,
|
|
18
21
|
required,
|
|
19
|
-
type,
|
|
22
|
+
type = "text",
|
|
20
23
|
value,
|
|
21
24
|
maxLength,
|
|
22
25
|
minLength,
|
|
23
26
|
autocomplete,
|
|
27
|
+
step = 1,
|
|
28
|
+
min,
|
|
29
|
+
max,
|
|
24
30
|
} = Astro.props;
|
|
25
31
|
|
|
32
|
+
const isNumber = type === "number";
|
|
33
|
+
|
|
26
34
|
const className =
|
|
27
35
|
"p-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent";
|
|
28
36
|
---
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
type != "number" && (
|
|
48
|
-
<input
|
|
49
|
-
class={className}
|
|
50
|
-
type={type ?? "text"}
|
|
51
|
-
id={id}
|
|
52
|
-
name={name}
|
|
53
|
-
placeholder={placeholder ?? ""}
|
|
54
|
-
required={required ?? false}
|
|
55
|
-
value={value ?? ""}
|
|
56
|
-
maxlength={maxLength ?? 500}
|
|
57
|
-
minlength={minLength ?? 0}
|
|
58
|
-
autocomplete={autocomplete}
|
|
59
|
-
/>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
38
|
+
<input
|
|
39
|
+
class={className}
|
|
40
|
+
type={type}
|
|
41
|
+
id={id}
|
|
42
|
+
name={name}
|
|
43
|
+
placeholder={placeholder ?? ""}
|
|
44
|
+
required={required ?? false}
|
|
45
|
+
value={value ?? ""}
|
|
46
|
+
autocomplete={autocomplete}
|
|
47
|
+
step={isNumber ? step : undefined}
|
|
48
|
+
min={isNumber ? min : undefined}
|
|
49
|
+
max={isNumber ? max : undefined}
|
|
50
|
+
maxlength={!isNumber ? (maxLength ?? 500) : undefined}
|
|
51
|
+
minlength={!isNumber ? (minLength ?? 0) : undefined}
|
|
52
|
+
/>
|