@pathscale/ui 0.0.1
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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/Avatar-CzIirpVq.d.ts +33 -0
- package/dist/Button-B50OLXuV.d.ts +63 -0
- package/dist/Input-BQbTzjIO.d.ts +34 -0
- package/dist/Textarea-Cpdk7m6S.d.ts +37 -0
- package/dist/chunk/2JGZSAW5.js +107 -0
- package/dist/chunk/4RCWSX7S.jsx +101 -0
- package/dist/chunk/EB7KXR65.js +102 -0
- package/dist/chunk/G6RG4LR7.js +87 -0
- package/dist/chunk/GA2HCFRS.jsx +228 -0
- package/dist/chunk/HKS7ET6T.js +56 -0
- package/dist/chunk/KACNXPUM.jsx +103 -0
- package/dist/chunk/N7BXP7EI.jsx +102 -0
- package/dist/chunk/NZZRKP74.js +214 -0
- package/dist/chunk/P7WPLZNA.jsx +59 -0
- package/dist/chunk/T2DPPLBQ.js +100 -0
- package/dist/chunk/WB6NEEQV.jsx +107 -0
- package/dist/classes-B_S9K-9I.d.ts +13 -0
- package/dist/components/Progress/index.d.ts +42 -0
- package/dist/components/Progress/index.js +278 -0
- package/dist/components/Progress/index.jsx +202 -0
- package/dist/components/accordion/index.d.ts +27 -0
- package/dist/components/accordion/index.js +118 -0
- package/dist/components/accordion/index.jsx +104 -0
- package/dist/components/avatar/index.d.ts +8 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/avatar/index.jsx +7 -0
- package/dist/components/breadcrumb/index.d.ts +47 -0
- package/dist/components/breadcrumb/index.js +133 -0
- package/dist/components/breadcrumb/index.jsx +125 -0
- package/dist/components/button/index.d.ts +9 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/index.jsx +8 -0
- package/dist/components/checkbox/index.d.ts +40 -0
- package/dist/components/checkbox/index.js +137 -0
- package/dist/components/checkbox/index.jsx +147 -0
- package/dist/components/input/index.d.ts +8 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/index.jsx +7 -0
- package/dist/components/pagination/index.d.ts +43 -0
- package/dist/components/pagination/index.js +189 -0
- package/dist/components/pagination/index.jsx +178 -0
- package/dist/components/polymorphic/index.d.ts +35 -0
- package/dist/components/polymorphic/index.js +1 -0
- package/dist/components/polymorphic/index.jsx +8 -0
- package/dist/components/select/index.d.ts +44 -0
- package/dist/components/select/index.js +98 -0
- package/dist/components/select/index.jsx +95 -0
- package/dist/components/switch/index.d.ts +72 -0
- package/dist/components/switch/index.js +144 -0
- package/dist/components/switch/index.jsx +159 -0
- package/dist/components/tabs/index.d.ts +42 -0
- package/dist/components/tabs/index.js +166 -0
- package/dist/components/tabs/index.jsx +174 -0
- package/dist/components/tag/index.d.ts +42 -0
- package/dist/components/tag/index.js +115 -0
- package/dist/components/tag/index.jsx +131 -0
- package/dist/components/textarea/index.d.ts +8 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/textarea/index.jsx +7 -0
- package/dist/components/tooltip/index.d.ts +53 -0
- package/dist/components/tooltip/index.js +103 -0
- package/dist/components/tooltip/index.jsx +99 -0
- package/dist/components/upload/index.d.ts +39 -0
- package/dist/components/upload/index.js +98 -0
- package/dist/components/upload/index.jsx +109 -0
- package/dist/index.css +73 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.jsx +20 -0
- package/package.json +67 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { JSX, Component } from 'solid-js';
|
|
2
|
+
import { C as ConfigVariants, a as ClassProps, V as VariantProps } from '../../classes-B_S9K-9I.js';
|
|
3
|
+
|
|
4
|
+
declare const switchVariants: {
|
|
5
|
+
(props?: (ConfigVariants<{
|
|
6
|
+
size: {
|
|
7
|
+
sm: string;
|
|
8
|
+
md: string;
|
|
9
|
+
lg: string;
|
|
10
|
+
};
|
|
11
|
+
disabled: {
|
|
12
|
+
true: string;
|
|
13
|
+
false: string;
|
|
14
|
+
};
|
|
15
|
+
rounded: {
|
|
16
|
+
true: string;
|
|
17
|
+
false: string;
|
|
18
|
+
};
|
|
19
|
+
outlined: {
|
|
20
|
+
true: string;
|
|
21
|
+
false: string;
|
|
22
|
+
};
|
|
23
|
+
}> & ClassProps) | undefined): string;
|
|
24
|
+
variantKeys: ("size" | "disabled" | "rounded" | "outlined")[];
|
|
25
|
+
};
|
|
26
|
+
declare const checkVariants: {
|
|
27
|
+
(props?: (ConfigVariants<{
|
|
28
|
+
size: {
|
|
29
|
+
sm: string;
|
|
30
|
+
md: string;
|
|
31
|
+
lg: string;
|
|
32
|
+
};
|
|
33
|
+
color: {
|
|
34
|
+
blue: string;
|
|
35
|
+
green: string;
|
|
36
|
+
red: string;
|
|
37
|
+
yellow: string;
|
|
38
|
+
gray: string;
|
|
39
|
+
};
|
|
40
|
+
passiveColor: {
|
|
41
|
+
blue: string;
|
|
42
|
+
green: string;
|
|
43
|
+
red: string;
|
|
44
|
+
yellow: string;
|
|
45
|
+
gray: string;
|
|
46
|
+
};
|
|
47
|
+
rounded: {
|
|
48
|
+
true: string;
|
|
49
|
+
false: string;
|
|
50
|
+
};
|
|
51
|
+
outlined: {
|
|
52
|
+
true: string;
|
|
53
|
+
false: string;
|
|
54
|
+
};
|
|
55
|
+
}> & ClassProps) | undefined): string;
|
|
56
|
+
variantKeys: ("size" | "rounded" | "outlined" | "color" | "passiveColor")[];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type SwitchProps = {
|
|
60
|
+
children?: JSX.Element;
|
|
61
|
+
checked?: boolean;
|
|
62
|
+
defaultChecked?: boolean;
|
|
63
|
+
onChange?: (checked: boolean) => void;
|
|
64
|
+
name?: string;
|
|
65
|
+
required?: boolean;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
"aria-label"?: string;
|
|
68
|
+
"aria-describedby"?: string;
|
|
69
|
+
} & VariantProps<typeof switchVariants> & VariantProps<typeof checkVariants> & Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "onChange">;
|
|
70
|
+
declare const Switch: Component<SwitchProps>;
|
|
71
|
+
|
|
72
|
+
export { type SwitchProps, Switch as default };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { cva } from '../../chunk/HKS7ET6T.js';
|
|
2
|
+
import { template, spread, mergeProps, insert, effect, className, setAttribute } from 'solid-js/web';
|
|
3
|
+
import { splitProps, createSignal, createMemo, untrack } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
// src/components/switch/Switch.styles.ts
|
|
6
|
+
var switchVariants = cva(
|
|
7
|
+
"switch inline-flex items-center gap-2 select-none",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
size: {
|
|
11
|
+
sm: "text-sm",
|
|
12
|
+
md: "text-base",
|
|
13
|
+
lg: "text-lg"
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
true: "opacity-50 cursor-not-allowed",
|
|
17
|
+
false: ""
|
|
18
|
+
},
|
|
19
|
+
rounded: {
|
|
20
|
+
true: "",
|
|
21
|
+
false: ""
|
|
22
|
+
},
|
|
23
|
+
outlined: {
|
|
24
|
+
true: "",
|
|
25
|
+
false: ""
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
size: "md",
|
|
30
|
+
disabled: false,
|
|
31
|
+
rounded: true,
|
|
32
|
+
outlined: false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
var checkVariants = cva(
|
|
37
|
+
[
|
|
38
|
+
"relative transition-colors duration-200",
|
|
39
|
+
"after:content-[''] after:absolute after:bg-white after:transition-transform after:duration-700 after:ease-in-out"
|
|
40
|
+
].join(" "),
|
|
41
|
+
{
|
|
42
|
+
variants: {
|
|
43
|
+
size: {
|
|
44
|
+
sm: "w-8 h-4 after:w-3 after:h-3 after:left-0.5 after:top-0.5 peer-checked:after:translate-x-4",
|
|
45
|
+
md: "w-10 h-6 after:w-4 after:h-4 after:left-1 after:top-1 peer-checked:after:translate-x-4",
|
|
46
|
+
lg: "w-12 h-7 after:w-5 after:h-5 after:left-1 after:top-1 peer-checked:after:translate-x-5"
|
|
47
|
+
},
|
|
48
|
+
color: {
|
|
49
|
+
blue: "peer-checked:bg-blue-500",
|
|
50
|
+
green: "peer-checked:bg-green-500",
|
|
51
|
+
red: "peer-checked:bg-red-500",
|
|
52
|
+
yellow: "peer-checked:bg-yellow-400",
|
|
53
|
+
gray: "peer-checked:bg-gray-500"
|
|
54
|
+
},
|
|
55
|
+
passiveColor: {
|
|
56
|
+
blue: "bg-blue-200",
|
|
57
|
+
green: "bg-green-200",
|
|
58
|
+
red: "bg-red-200",
|
|
59
|
+
yellow: "bg-yellow-200",
|
|
60
|
+
gray: "bg-gray-300"
|
|
61
|
+
},
|
|
62
|
+
rounded: {
|
|
63
|
+
true: "rounded-full after:rounded-full",
|
|
64
|
+
false: "rounded-md after:rounded-sm"
|
|
65
|
+
},
|
|
66
|
+
outlined: {
|
|
67
|
+
true: "ring-2 ring-inset ring-white",
|
|
68
|
+
false: ""
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
defaultVariants: {
|
|
72
|
+
size: "md",
|
|
73
|
+
color: "blue",
|
|
74
|
+
passiveColor: "gray",
|
|
75
|
+
rounded: true,
|
|
76
|
+
outlined: false
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// src/components/switch/Switch.tsx
|
|
82
|
+
var _tmpl$ = /* @__PURE__ */ template(`<label role=switch><input type=checkbox class="sr-only peer"aria-hidden=true><span></span><span class=control-label>`);
|
|
83
|
+
var Switch = (props) => {
|
|
84
|
+
const [localProps, variantProps, otherProps] = splitProps(props, ["children", "checked", "defaultChecked", "onChange", "name", "required", "disabled", "aria-label", "aria-describedby"], ["size", "rounded", "outlined", "color", "passiveColor"]);
|
|
85
|
+
const isControlled = localProps.checked !== void 0;
|
|
86
|
+
const [internalChecked, setInternalChecked] = createSignal(localProps.defaultChecked ?? false);
|
|
87
|
+
const checkedValue = createMemo(() => untrack(() => isControlled ? localProps.checked : internalChecked()));
|
|
88
|
+
const switchClasses = createMemo(() => switchVariants(variantProps));
|
|
89
|
+
const checkClasses = createMemo(() => checkVariants({
|
|
90
|
+
size: variantProps.size,
|
|
91
|
+
color: variantProps.color,
|
|
92
|
+
passiveColor: variantProps.passiveColor,
|
|
93
|
+
rounded: variantProps.rounded,
|
|
94
|
+
outlined: variantProps.outlined
|
|
95
|
+
}));
|
|
96
|
+
const handleChange = (e) => {
|
|
97
|
+
const next = e.currentTarget.checked;
|
|
98
|
+
untrack(() => {
|
|
99
|
+
if (!isControlled) setInternalChecked(next);
|
|
100
|
+
localProps.onChange?.(next);
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
return (() => {
|
|
104
|
+
var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.nextSibling;
|
|
105
|
+
_el$2.addEventListener("change", handleChange);
|
|
106
|
+
spread(_el$2, mergeProps({
|
|
107
|
+
get checked() {
|
|
108
|
+
return checkedValue();
|
|
109
|
+
},
|
|
110
|
+
get name() {
|
|
111
|
+
return localProps.name;
|
|
112
|
+
},
|
|
113
|
+
get required() {
|
|
114
|
+
return localProps.required;
|
|
115
|
+
},
|
|
116
|
+
get disabled() {
|
|
117
|
+
return localProps.disabled;
|
|
118
|
+
}
|
|
119
|
+
}, otherProps), false, false);
|
|
120
|
+
insert(_el$4, () => localProps.children);
|
|
121
|
+
effect((_p$) => {
|
|
122
|
+
var _v$ = switchClasses(), _v$2 = checkedValue(), _v$3 = localProps["aria-label"], _v$4 = localProps["aria-describedby"], _v$5 = checkClasses();
|
|
123
|
+
_v$ !== _p$.e && className(_el$, _p$.e = _v$);
|
|
124
|
+
_v$2 !== _p$.t && setAttribute(_el$, "aria-checked", _p$.t = _v$2);
|
|
125
|
+
_v$3 !== _p$.a && setAttribute(_el$, "aria-label", _p$.a = _v$3);
|
|
126
|
+
_v$4 !== _p$.o && setAttribute(_el$, "aria-describedby", _p$.o = _v$4);
|
|
127
|
+
_v$5 !== _p$.i && className(_el$3, _p$.i = _v$5);
|
|
128
|
+
return _p$;
|
|
129
|
+
}, {
|
|
130
|
+
e: void 0,
|
|
131
|
+
t: void 0,
|
|
132
|
+
a: void 0,
|
|
133
|
+
o: void 0,
|
|
134
|
+
i: void 0
|
|
135
|
+
});
|
|
136
|
+
return _el$;
|
|
137
|
+
})();
|
|
138
|
+
};
|
|
139
|
+
var Switch_default = Switch;
|
|
140
|
+
|
|
141
|
+
// src/components/switch/index.ts
|
|
142
|
+
var switch_default = Switch_default;
|
|
143
|
+
|
|
144
|
+
export { switch_default as default };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cva
|
|
3
|
+
} from "../../chunk/P7WPLZNA.jsx";
|
|
4
|
+
|
|
5
|
+
// src/components/switch/Switch.tsx
|
|
6
|
+
import {
|
|
7
|
+
createSignal,
|
|
8
|
+
splitProps,
|
|
9
|
+
createMemo,
|
|
10
|
+
untrack
|
|
11
|
+
} from "solid-js";
|
|
12
|
+
|
|
13
|
+
// src/components/switch/Switch.styles.ts
|
|
14
|
+
var switchVariants = cva(
|
|
15
|
+
"switch inline-flex items-center gap-2 select-none",
|
|
16
|
+
{
|
|
17
|
+
variants: {
|
|
18
|
+
size: {
|
|
19
|
+
sm: "text-sm",
|
|
20
|
+
md: "text-base",
|
|
21
|
+
lg: "text-lg"
|
|
22
|
+
},
|
|
23
|
+
disabled: {
|
|
24
|
+
true: "opacity-50 cursor-not-allowed",
|
|
25
|
+
false: ""
|
|
26
|
+
},
|
|
27
|
+
rounded: {
|
|
28
|
+
true: "",
|
|
29
|
+
false: ""
|
|
30
|
+
},
|
|
31
|
+
outlined: {
|
|
32
|
+
true: "",
|
|
33
|
+
false: ""
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
size: "md",
|
|
38
|
+
disabled: false,
|
|
39
|
+
rounded: true,
|
|
40
|
+
outlined: false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
var checkVariants = cva(
|
|
45
|
+
[
|
|
46
|
+
"relative transition-colors duration-200",
|
|
47
|
+
"after:content-[''] after:absolute after:bg-white after:transition-transform after:duration-700 after:ease-in-out"
|
|
48
|
+
].join(" "),
|
|
49
|
+
{
|
|
50
|
+
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
sm: "w-8 h-4 after:w-3 after:h-3 after:left-0.5 after:top-0.5 peer-checked:after:translate-x-4",
|
|
53
|
+
md: "w-10 h-6 after:w-4 after:h-4 after:left-1 after:top-1 peer-checked:after:translate-x-4",
|
|
54
|
+
lg: "w-12 h-7 after:w-5 after:h-5 after:left-1 after:top-1 peer-checked:after:translate-x-5"
|
|
55
|
+
},
|
|
56
|
+
color: {
|
|
57
|
+
blue: "peer-checked:bg-blue-500",
|
|
58
|
+
green: "peer-checked:bg-green-500",
|
|
59
|
+
red: "peer-checked:bg-red-500",
|
|
60
|
+
yellow: "peer-checked:bg-yellow-400",
|
|
61
|
+
gray: "peer-checked:bg-gray-500"
|
|
62
|
+
},
|
|
63
|
+
passiveColor: {
|
|
64
|
+
blue: "bg-blue-200",
|
|
65
|
+
green: "bg-green-200",
|
|
66
|
+
red: "bg-red-200",
|
|
67
|
+
yellow: "bg-yellow-200",
|
|
68
|
+
gray: "bg-gray-300"
|
|
69
|
+
},
|
|
70
|
+
rounded: {
|
|
71
|
+
true: "rounded-full after:rounded-full",
|
|
72
|
+
false: "rounded-md after:rounded-sm"
|
|
73
|
+
},
|
|
74
|
+
outlined: {
|
|
75
|
+
true: "ring-2 ring-inset ring-white",
|
|
76
|
+
false: ""
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
defaultVariants: {
|
|
80
|
+
size: "md",
|
|
81
|
+
color: "blue",
|
|
82
|
+
passiveColor: "gray",
|
|
83
|
+
rounded: true,
|
|
84
|
+
outlined: false
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// src/components/switch/Switch.tsx
|
|
90
|
+
var Switch = (props) => {
|
|
91
|
+
const [localProps, variantProps, otherProps] = splitProps(
|
|
92
|
+
props,
|
|
93
|
+
[
|
|
94
|
+
"children",
|
|
95
|
+
"checked",
|
|
96
|
+
"defaultChecked",
|
|
97
|
+
"onChange",
|
|
98
|
+
"name",
|
|
99
|
+
"required",
|
|
100
|
+
"disabled",
|
|
101
|
+
"aria-label",
|
|
102
|
+
"aria-describedby"
|
|
103
|
+
],
|
|
104
|
+
["size", "rounded", "outlined", "color", "passiveColor"]
|
|
105
|
+
);
|
|
106
|
+
const isControlled = localProps.checked !== void 0;
|
|
107
|
+
const [internalChecked, setInternalChecked] = createSignal(
|
|
108
|
+
localProps.defaultChecked ?? false
|
|
109
|
+
);
|
|
110
|
+
const checkedValue = createMemo(
|
|
111
|
+
() => untrack(() => isControlled ? localProps.checked : internalChecked())
|
|
112
|
+
);
|
|
113
|
+
const switchClasses = createMemo(() => switchVariants(variantProps));
|
|
114
|
+
const checkClasses = createMemo(
|
|
115
|
+
() => checkVariants({
|
|
116
|
+
size: variantProps.size,
|
|
117
|
+
color: variantProps.color,
|
|
118
|
+
passiveColor: variantProps.passiveColor,
|
|
119
|
+
rounded: variantProps.rounded,
|
|
120
|
+
outlined: variantProps.outlined
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
const handleChange = (e) => {
|
|
124
|
+
const next = e.currentTarget.checked;
|
|
125
|
+
untrack(() => {
|
|
126
|
+
if (!isControlled) setInternalChecked(next);
|
|
127
|
+
localProps.onChange?.(next);
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
return <label
|
|
131
|
+
class={switchClasses()}
|
|
132
|
+
role="switch"
|
|
133
|
+
aria-checked={checkedValue()}
|
|
134
|
+
aria-label={localProps["aria-label"]}
|
|
135
|
+
aria-describedby={localProps["aria-describedby"]}
|
|
136
|
+
>
|
|
137
|
+
<input
|
|
138
|
+
type="checkbox"
|
|
139
|
+
class="sr-only peer"
|
|
140
|
+
checked={checkedValue()}
|
|
141
|
+
onChange={handleChange}
|
|
142
|
+
name={localProps.name}
|
|
143
|
+
required={localProps.required}
|
|
144
|
+
disabled={localProps.disabled}
|
|
145
|
+
aria-hidden="true"
|
|
146
|
+
{...otherProps}
|
|
147
|
+
/>
|
|
148
|
+
|
|
149
|
+
<span class={checkClasses()} />
|
|
150
|
+
<span class="control-label">{localProps.children}</span>
|
|
151
|
+
</label>;
|
|
152
|
+
};
|
|
153
|
+
var Switch_default = Switch;
|
|
154
|
+
|
|
155
|
+
// src/components/switch/index.ts
|
|
156
|
+
var switch_default = Switch_default;
|
|
157
|
+
export {
|
|
158
|
+
switch_default as default
|
|
159
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { JSX, Component } from 'solid-js';
|
|
2
|
+
import { C as ConfigVariants, a as ClassProps, V as VariantProps } from '../../classes-B_S9K-9I.js';
|
|
3
|
+
|
|
4
|
+
declare const tabsNavVariants: {
|
|
5
|
+
(props?: (ConfigVariants<{
|
|
6
|
+
type: {
|
|
7
|
+
basic: string;
|
|
8
|
+
boxed: string;
|
|
9
|
+
toggle: string;
|
|
10
|
+
"toggle-rounded": string;
|
|
11
|
+
};
|
|
12
|
+
size: {
|
|
13
|
+
sm: string;
|
|
14
|
+
md: string;
|
|
15
|
+
lg: string;
|
|
16
|
+
};
|
|
17
|
+
alignment: {
|
|
18
|
+
left: string;
|
|
19
|
+
center: string;
|
|
20
|
+
right: string;
|
|
21
|
+
};
|
|
22
|
+
expanded: {
|
|
23
|
+
true: string;
|
|
24
|
+
false: string;
|
|
25
|
+
};
|
|
26
|
+
}> & ClassProps) | undefined): string;
|
|
27
|
+
variantKeys: ("type" | "size" | "alignment" | "expanded")[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type TabItem = {
|
|
31
|
+
label: string;
|
|
32
|
+
content: JSX.Element;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
};
|
|
35
|
+
type TabsProps = {
|
|
36
|
+
items: TabItem[];
|
|
37
|
+
value?: number;
|
|
38
|
+
onChange?: (index: number) => void;
|
|
39
|
+
} & VariantProps<typeof tabsNavVariants>;
|
|
40
|
+
declare const Tabs: Component<TabsProps>;
|
|
41
|
+
|
|
42
|
+
export { type TabsProps, Tabs as default };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { cva } from '../../chunk/HKS7ET6T.js';
|
|
2
|
+
import { delegateEvents, template, spread, insert, createComponent, effect, className } from 'solid-js/web';
|
|
3
|
+
import { splitProps, createSignal, createMemo, For, Show } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
// src/components/tabs/Tabs.styles.ts
|
|
6
|
+
var tabsNavVariants = cva(
|
|
7
|
+
"flex text-sm font-medium text-gray-600 dark:text-gray-300",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
type: {
|
|
11
|
+
basic: "",
|
|
12
|
+
boxed: "flex gap-2",
|
|
13
|
+
toggle: "inline-flex rounded-md p-1",
|
|
14
|
+
"toggle-rounded": "inline-flex rounded-full p-1"
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
sm: "text-xs gap-1",
|
|
18
|
+
md: "text-sm gap-2",
|
|
19
|
+
lg: "text-base gap-3"
|
|
20
|
+
},
|
|
21
|
+
alignment: {
|
|
22
|
+
left: "justify-start",
|
|
23
|
+
center: "justify-center",
|
|
24
|
+
right: "justify-end"
|
|
25
|
+
},
|
|
26
|
+
expanded: {
|
|
27
|
+
true: "w-full",
|
|
28
|
+
false: ""
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
type: "basic",
|
|
33
|
+
size: "md",
|
|
34
|
+
alignment: "left",
|
|
35
|
+
expanded: false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
var tabTriggerVariants = cva(
|
|
40
|
+
"inline-flex items-center justify-center whitespace-nowrap font-medium text-sm transition-colors",
|
|
41
|
+
{
|
|
42
|
+
variants: {
|
|
43
|
+
size: {
|
|
44
|
+
sm: "text-xs px-2 py-1",
|
|
45
|
+
md: "text-sm px-3 py-2",
|
|
46
|
+
lg: "text-base px-4 py-3"
|
|
47
|
+
},
|
|
48
|
+
type: {
|
|
49
|
+
basic: "border-b-2 transition-colors hover:text-blue-600",
|
|
50
|
+
boxed: "rounded-t px-4 py-2 hover:text-blue-600",
|
|
51
|
+
toggle: "border -ml-px px-4 py-2 transition-colors first:ml-0 first:rounded-l-md last:rounded-r-md",
|
|
52
|
+
"toggle-rounded": "border -ml-px first:ml-0 first:rounded-l-full last:rounded-r-full transition-colors"
|
|
53
|
+
},
|
|
54
|
+
active: {
|
|
55
|
+
true: "",
|
|
56
|
+
false: ""
|
|
57
|
+
},
|
|
58
|
+
disabled: {
|
|
59
|
+
true: "opacity-50 cursor-not-allowed pointer-events-none",
|
|
60
|
+
false: ""
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
compoundVariants: [
|
|
64
|
+
{
|
|
65
|
+
type: "basic",
|
|
66
|
+
active: true,
|
|
67
|
+
class: "border-blue-600 text-blue-600"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: "basic",
|
|
71
|
+
active: false,
|
|
72
|
+
class: "border-transparent text-gray-500 dark:text-gray-400"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "boxed",
|
|
76
|
+
active: true,
|
|
77
|
+
class: "border-x border-t border-b-0 border-gray-400 dark:border-gray-600 text-blue-600"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: "boxed",
|
|
81
|
+
active: false,
|
|
82
|
+
class: "border-b border-transparent text-gray-500 dark:text-gray-400 hover:text-blue-600"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: "toggle",
|
|
86
|
+
active: true,
|
|
87
|
+
class: "bg-blue-600 text-white border-blue-600"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "toggle",
|
|
91
|
+
active: false,
|
|
92
|
+
class: "bg-transparent text-gray-600 dark:text-gray-300 border-gray-300 dark:border-gray-600"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "toggle-rounded",
|
|
96
|
+
active: true,
|
|
97
|
+
class: "bg-blue-600 text-white border-blue-600"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "toggle-rounded",
|
|
101
|
+
active: false,
|
|
102
|
+
class: "bg-transparent text-gray-600 dark:text-gray-300 border-gray-300 dark:border-gray-600"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
defaultVariants: {
|
|
106
|
+
active: false,
|
|
107
|
+
disabled: false
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// src/components/tabs/Tabs.tsx
|
|
113
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div><nav><ul class="flex gap-0"></ul></nav><div class=pt-4>`);
|
|
114
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<li><button>`);
|
|
115
|
+
var Tabs = (props) => {
|
|
116
|
+
const [local, variantProps, otherProps] = splitProps(props, ["items", "value", "onChange"], ["size", "type", "alignment", "expanded"]);
|
|
117
|
+
const [internalActive, setInternalActive] = createSignal(local.value ?? 0);
|
|
118
|
+
const isControlled = () => local.value !== void 0;
|
|
119
|
+
const active = createMemo(() => isControlled() ? local.value : internalActive());
|
|
120
|
+
const handleChange = (i) => {
|
|
121
|
+
const item = local.items[i];
|
|
122
|
+
if (!item || item.disabled) return;
|
|
123
|
+
if (!isControlled()) {
|
|
124
|
+
setInternalActive(i);
|
|
125
|
+
}
|
|
126
|
+
local.onChange?.(i);
|
|
127
|
+
};
|
|
128
|
+
return (() => {
|
|
129
|
+
var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$2.nextSibling;
|
|
130
|
+
spread(_el$, otherProps, false, true);
|
|
131
|
+
insert(_el$3, createComponent(For, {
|
|
132
|
+
get each() {
|
|
133
|
+
return local.items;
|
|
134
|
+
},
|
|
135
|
+
children: (tab, i) => (() => {
|
|
136
|
+
var _el$5 = _tmpl$2(), _el$6 = _el$5.firstChild;
|
|
137
|
+
_el$6.$$click = () => handleChange(i());
|
|
138
|
+
insert(_el$6, () => tab.label);
|
|
139
|
+
effect(() => className(_el$6, tabTriggerVariants({
|
|
140
|
+
type: variantProps.type ?? "basic",
|
|
141
|
+
size: variantProps.size ?? "md",
|
|
142
|
+
active: i() === active(),
|
|
143
|
+
disabled: tab.disabled
|
|
144
|
+
})));
|
|
145
|
+
return _el$5;
|
|
146
|
+
})()
|
|
147
|
+
}));
|
|
148
|
+
insert(_el$4, createComponent(Show, {
|
|
149
|
+
get when() {
|
|
150
|
+
return local.items[active()];
|
|
151
|
+
},
|
|
152
|
+
get children() {
|
|
153
|
+
return local.items[active()]?.content;
|
|
154
|
+
}
|
|
155
|
+
}));
|
|
156
|
+
effect(() => className(_el$2, tabsNavVariants(variantProps)));
|
|
157
|
+
return _el$;
|
|
158
|
+
})();
|
|
159
|
+
};
|
|
160
|
+
var Tabs_default = Tabs;
|
|
161
|
+
delegateEvents(["click"]);
|
|
162
|
+
|
|
163
|
+
// src/components/tabs/index.ts
|
|
164
|
+
var tabs_default = Tabs_default;
|
|
165
|
+
|
|
166
|
+
export { tabs_default as default };
|