@pathscale/ui 0.0.2 → 0.0.4
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/Autocomplete-gLkjMHrc.d.ts +28 -0
- package/dist/Field-DfUn85_1.d.ts +49 -0
- package/dist/Progress-gN0xqhAF.d.ts +64 -0
- package/dist/Steps-1miUeyCD.d.ts +34 -0
- package/dist/Table-CGa6Nop3.d.ts +39 -0
- package/dist/Timeline-Bd4SxHMT.d.ts +14 -0
- package/dist/{Upload-BrFuZ4JA.d.ts → Upload-CRljD5jf.d.ts} +1 -1
- package/dist/chunk/3VOILEMN.js +187 -0
- package/dist/chunk/7ROVLN3J.js +175 -0
- package/dist/chunk/BBDVIXAH.jsx +194 -0
- package/dist/chunk/{4RCWSX7S.jsx → C4745OZS.jsx} +7 -7
- package/dist/chunk/C4YO33NN.jsx +179 -0
- package/dist/chunk/D2BEL4SM.jsx +169 -0
- package/dist/chunk/DSTUGZW6.jsx +81 -0
- package/dist/chunk/FKSQPGOD.jsx +170 -0
- package/dist/chunk/GMIXRYN3.js +138 -0
- package/dist/chunk/HWAGW5N4.jsx +118 -0
- package/dist/chunk/JWRGKHDO.js +172 -0
- package/dist/chunk/LAQPAV5I.jsx +187 -0
- package/dist/chunk/MAX47D6F.js +99 -0
- package/dist/chunk/{2JGZSAW5.js → MI773TMC.js} +6 -6
- package/dist/chunk/MYERRMTM.js +200 -0
- package/dist/chunk/OSJ3P7PI.js +189 -0
- package/dist/chunk/{QLESLIWS.jsx → QHJOIUYT.jsx} +14 -7
- package/dist/chunk/QYEMOKUG.js +125 -0
- package/dist/chunk/SCJSBRV2.jsx +39 -0
- package/dist/chunk/STKRVQR6.jsx +130 -0
- package/dist/chunk/{NZZRKP74.js → TFLJI242.js} +1 -25
- package/dist/chunk/TT2JYGLU.js +218 -0
- package/dist/chunk/VN5BKHA2.jsx +97 -0
- package/dist/chunk/WUZETUQR.js +92 -0
- package/dist/chunk/XD34JKSU.jsx +201 -0
- package/dist/chunk/{GA2HCFRS.jsx → YAQK2KFY.jsx} +1 -35
- package/dist/chunk/{S3ZDSQSV.js → YDEDUOFM.js} +8 -4
- package/dist/chunk/YMO6RPS6.js +26 -0
- package/dist/components/Progress/index.d.ts +4 -38
- package/dist/components/Progress/index.js +1 -1
- package/dist/components/Progress/index.jsx +3 -11
- package/dist/components/autocomplete/index.d.ts +8 -0
- package/dist/components/autocomplete/index.js +1 -0
- package/dist/components/autocomplete/index.jsx +7 -0
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/avatar/index.jsx +3 -3
- package/dist/components/button/index.js +1 -1
- package/dist/components/button/index.jsx +2 -1
- package/dist/components/dropdown/index.d.ts +43 -0
- package/dist/components/dropdown/index.js +1 -0
- package/dist/components/dropdown/index.jsx +12 -0
- package/dist/components/field/index.d.ts +7 -0
- package/dist/components/field/index.js +1 -0
- package/dist/components/field/index.jsx +7 -0
- package/dist/components/menu/index.d.ts +66 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/menu/index.jsx +11 -0
- package/dist/components/navbar/index.d.ts +74 -0
- package/dist/components/navbar/index.js +1 -0
- package/dist/components/navbar/index.jsx +11 -0
- package/dist/components/steps/index.d.ts +8 -0
- package/dist/components/steps/index.js +1 -0
- package/dist/components/steps/index.jsx +7 -0
- package/dist/components/table/index.d.ts +8 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/table/index.jsx +7 -0
- package/dist/components/timeline/index.d.ts +7 -0
- package/dist/components/timeline/index.js +1 -0
- package/dist/components/timeline/index.jsx +7 -0
- package/dist/components/toast/index.d.ts +24 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/toast/index.jsx +11 -0
- package/dist/components/upload/index.d.ts +2 -2
- package/dist/components/upload/index.js +1 -1
- package/dist/components/upload/index.jsx +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.js +18 -8
- package/dist/index.jsx +71 -17
- package/package.json +1 -1
- package/dist/Progress-a616LgE0.d.ts +0 -5
- package/dist/chunk/QNOJ6PCD.js +0 -278
- package/dist/chunk/WCBMW2TP.jsx +0 -203
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cva
|
|
3
|
+
} from "./P7WPLZNA.jsx";
|
|
4
|
+
|
|
5
|
+
// src/components/toast/toast.store.ts
|
|
6
|
+
import { createSignal } from "solid-js";
|
|
7
|
+
var [toasts, setToasts] = createSignal([]);
|
|
8
|
+
var toastStore = {
|
|
9
|
+
toasts,
|
|
10
|
+
add(toast2) {
|
|
11
|
+
const id = crypto.randomUUID();
|
|
12
|
+
setToasts((prev) => [...prev, { ...toast2, id }]);
|
|
13
|
+
return id;
|
|
14
|
+
},
|
|
15
|
+
remove(id) {
|
|
16
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
17
|
+
},
|
|
18
|
+
clear() {
|
|
19
|
+
setToasts([]);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/components/toast/toast-api.ts
|
|
24
|
+
function createToastApi() {
|
|
25
|
+
const show = (message, options = {}) => {
|
|
26
|
+
return toastStore.add({ ...options, message });
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
show,
|
|
30
|
+
success: (msg, opts) => show(msg, { ...opts, type: "success" }),
|
|
31
|
+
error: (msg, opts) => show(msg, { ...opts, type: "error" }),
|
|
32
|
+
info: (msg, opts) => show(msg, { ...opts, type: "info" }),
|
|
33
|
+
warning: (msg, opts) => show(msg, { ...opts, type: "warning" }),
|
|
34
|
+
clear: toastStore.clear
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/components/toast/Toaster.tsx
|
|
39
|
+
import { For } from "solid-js";
|
|
40
|
+
|
|
41
|
+
// src/components/toast/Toast.tsx
|
|
42
|
+
import {
|
|
43
|
+
createSignal as createSignal2,
|
|
44
|
+
onMount,
|
|
45
|
+
onCleanup,
|
|
46
|
+
Show
|
|
47
|
+
} from "solid-js";
|
|
48
|
+
|
|
49
|
+
// src/components/toast/utils/remove-element.ts
|
|
50
|
+
function removeElement(el) {
|
|
51
|
+
if (typeof el.remove === "function") {
|
|
52
|
+
el.remove();
|
|
53
|
+
} else {
|
|
54
|
+
el.parentNode?.removeChild(el);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/components/toast/utils/timer.ts
|
|
59
|
+
var Timer = class {
|
|
60
|
+
callback;
|
|
61
|
+
delay;
|
|
62
|
+
startedAt;
|
|
63
|
+
timer;
|
|
64
|
+
constructor(callback, delay) {
|
|
65
|
+
this.callback = callback;
|
|
66
|
+
this.delay = delay;
|
|
67
|
+
this.startedAt = Date.now();
|
|
68
|
+
this.timer = window.setTimeout(callback, delay);
|
|
69
|
+
}
|
|
70
|
+
pause() {
|
|
71
|
+
this.stop();
|
|
72
|
+
this.delay -= Date.now() - this.startedAt;
|
|
73
|
+
}
|
|
74
|
+
resume() {
|
|
75
|
+
this.stop();
|
|
76
|
+
this.startedAt = Date.now();
|
|
77
|
+
this.timer = window.setTimeout(this.callback, this.delay);
|
|
78
|
+
}
|
|
79
|
+
stop() {
|
|
80
|
+
clearTimeout(this.timer);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/components/toast/Toast.styles.ts
|
|
85
|
+
var toastWrapperClass = cva(
|
|
86
|
+
"relative flex items-start gap-3 px-4 py-3 rounded-2xl shadow-lg transition-all duration-300 w-full",
|
|
87
|
+
{
|
|
88
|
+
variants: {
|
|
89
|
+
type: {
|
|
90
|
+
default: "bg-gray-700 text-white",
|
|
91
|
+
success: "bg-green-600 text-white",
|
|
92
|
+
error: "bg-red-600 text-white",
|
|
93
|
+
info: "bg-blue-600 text-white",
|
|
94
|
+
warning: "bg-yellow-400 text-black"
|
|
95
|
+
},
|
|
96
|
+
visible: {
|
|
97
|
+
true: "opacity-100 translate-y-0",
|
|
98
|
+
false: "opacity-0 -translate-y-2 pointer-events-none"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
defaultVariants: {
|
|
102
|
+
type: "default",
|
|
103
|
+
visible: true
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// src/components/toast/Toast.tsx
|
|
109
|
+
var Toast = (props) => {
|
|
110
|
+
const [visible, setVisible] = createSignal2(false);
|
|
111
|
+
let rootRef;
|
|
112
|
+
let timer = null;
|
|
113
|
+
const close = () => {
|
|
114
|
+
timer?.stop();
|
|
115
|
+
setVisible(false);
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
props.onClose?.();
|
|
118
|
+
if (rootRef) removeElement(rootRef);
|
|
119
|
+
}, 150);
|
|
120
|
+
};
|
|
121
|
+
onMount(() => {
|
|
122
|
+
setVisible(true);
|
|
123
|
+
if (props.duration !== false) {
|
|
124
|
+
timer = new Timer(close, props.duration || 4e3);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
onCleanup(() => {
|
|
128
|
+
timer?.stop();
|
|
129
|
+
});
|
|
130
|
+
return <div
|
|
131
|
+
ref={rootRef}
|
|
132
|
+
class={toastWrapperClass({
|
|
133
|
+
type: props.type || "default",
|
|
134
|
+
visible: visible()
|
|
135
|
+
})}
|
|
136
|
+
role="alert"
|
|
137
|
+
onClick={() => props.dismissible && close()}
|
|
138
|
+
innerHTML={props.message}
|
|
139
|
+
>
|
|
140
|
+
<Show when={props.dismissible}>
|
|
141
|
+
<button
|
|
142
|
+
class="absolute top-2 right-2 text-white/80 hover:text-white transition"
|
|
143
|
+
aria-label="Close toast"
|
|
144
|
+
>
|
|
145
|
+
×
|
|
146
|
+
</button>
|
|
147
|
+
</Show>
|
|
148
|
+
</div>;
|
|
149
|
+
};
|
|
150
|
+
var Toast_default = Toast;
|
|
151
|
+
|
|
152
|
+
// src/components/toast/Toaster.tsx
|
|
153
|
+
var Toaster = () => {
|
|
154
|
+
return <div class="fixed bottom-4 right-4 z-50 flex flex-col items-end gap-2 w-[300px] max-w-full">
|
|
155
|
+
<For each={toastStore.toasts()}>
|
|
156
|
+
{(toast2) => <Toast_default {...toast2} onClose={() => toastStore.remove(toast2.id)} />}
|
|
157
|
+
</For>
|
|
158
|
+
</div>;
|
|
159
|
+
};
|
|
160
|
+
var Toaster_default = Toaster;
|
|
161
|
+
|
|
162
|
+
// src/components/toast/index.ts
|
|
163
|
+
var toast = createToastApi();
|
|
164
|
+
var toast_default = toast;
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
Toaster_default,
|
|
168
|
+
toast,
|
|
169
|
+
toast_default
|
|
170
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { cva, classes } from './HKS7ET6T.js';
|
|
2
|
+
import { template, spread, mergeProps, insert, createComponent, effect, className, memo } from 'solid-js/web';
|
|
3
|
+
import { splitProps, createMemo, Show } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
// src/components/progress/Progress.styles.ts
|
|
6
|
+
var progressContainer = cva(
|
|
7
|
+
"relative w-full max-w-md select-none",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
size: {
|
|
11
|
+
sm: "",
|
|
12
|
+
md: "",
|
|
13
|
+
lg: ""
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: { size: "md" }
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
var progressWrapper = cva("overflow-hidden bg-gray-200", {
|
|
20
|
+
variants: {
|
|
21
|
+
size: {
|
|
22
|
+
sm: "h-2",
|
|
23
|
+
md: "h-4",
|
|
24
|
+
lg: "h-6"
|
|
25
|
+
},
|
|
26
|
+
shape: {
|
|
27
|
+
rounded: "rounded-lg",
|
|
28
|
+
circle: "rounded-full"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
size: "md",
|
|
33
|
+
shape: "rounded"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var progressFill = cva("h-full transition-all duration-300", {
|
|
37
|
+
variants: {
|
|
38
|
+
color: {
|
|
39
|
+
default: "bg-gray-500",
|
|
40
|
+
danger: "bg-red-500",
|
|
41
|
+
success: "bg-green-500",
|
|
42
|
+
info: "bg-blue-500",
|
|
43
|
+
warning: "bg-yellow-500"
|
|
44
|
+
},
|
|
45
|
+
variant: {
|
|
46
|
+
filled: "",
|
|
47
|
+
outlined: "bg-opacity-0 ring-1 ring-gray-300",
|
|
48
|
+
ghost: "bg-opacity-50"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
defaultVariants: {
|
|
52
|
+
color: "default",
|
|
53
|
+
variant: "filled"
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
var progressLabel = cva(
|
|
57
|
+
"absolute top-0 right-0 h-full flex items-center pr-2 text-xs font-medium text-gray-700"
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// src/components/progress/Progress.tsx
|
|
61
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
62
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div><div>`);
|
|
63
|
+
var Progress = (props) => {
|
|
64
|
+
const [local, rest] = splitProps(props, ["value", "size", "shape", "variant", "color", "showValue", "format", "className"]);
|
|
65
|
+
const val = createMemo(() => typeof local.value === "number" ? Math.max(0, Math.min(100, local.value)) : null);
|
|
66
|
+
const isDeterminate = () => val() !== null;
|
|
67
|
+
const labelText = createMemo(() => {
|
|
68
|
+
if (!local.showValue || val() == null) return "";
|
|
69
|
+
return local.format === "percent" ? `${val()}%` : String(val());
|
|
70
|
+
});
|
|
71
|
+
return (() => {
|
|
72
|
+
var _el$ = _tmpl$2(), _el$2 = _el$.firstChild;
|
|
73
|
+
spread(_el$, mergeProps(rest, {
|
|
74
|
+
get ["class"]() {
|
|
75
|
+
return classes(progressContainer({
|
|
76
|
+
size: local.size
|
|
77
|
+
}), local.className);
|
|
78
|
+
},
|
|
79
|
+
get ["aria-busy"]() {
|
|
80
|
+
return !isDeterminate();
|
|
81
|
+
}
|
|
82
|
+
}), false, true);
|
|
83
|
+
insert(_el$2, createComponent(Show, {
|
|
84
|
+
get when() {
|
|
85
|
+
return isDeterminate();
|
|
86
|
+
},
|
|
87
|
+
get fallback() {
|
|
88
|
+
return (() => {
|
|
89
|
+
var _el$5 = _tmpl$();
|
|
90
|
+
_el$5.style.setProperty("width", "100%");
|
|
91
|
+
effect(() => className(_el$5, classes(progressFill({
|
|
92
|
+
color: local.color,
|
|
93
|
+
variant: local.variant
|
|
94
|
+
}), "animate-pulse")));
|
|
95
|
+
return _el$5;
|
|
96
|
+
})();
|
|
97
|
+
},
|
|
98
|
+
get children() {
|
|
99
|
+
var _el$3 = _tmpl$();
|
|
100
|
+
effect((_p$) => {
|
|
101
|
+
var _v$ = progressFill({
|
|
102
|
+
color: local.color,
|
|
103
|
+
variant: local.variant
|
|
104
|
+
}), _v$2 = `${val()}%`;
|
|
105
|
+
_v$ !== _p$.e && className(_el$3, _p$.e = _v$);
|
|
106
|
+
_v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$3.style.setProperty("width", _v$2) : _el$3.style.removeProperty("width"));
|
|
107
|
+
return _p$;
|
|
108
|
+
}, {
|
|
109
|
+
e: void 0,
|
|
110
|
+
t: void 0
|
|
111
|
+
});
|
|
112
|
+
return _el$3;
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
insert(_el$, createComponent(Show, {
|
|
116
|
+
get when() {
|
|
117
|
+
return memo(() => !!local.showValue)() && labelText();
|
|
118
|
+
},
|
|
119
|
+
get children() {
|
|
120
|
+
var _el$4 = _tmpl$();
|
|
121
|
+
insert(_el$4, labelText);
|
|
122
|
+
effect(() => className(_el$4, progressLabel()));
|
|
123
|
+
return _el$4;
|
|
124
|
+
}
|
|
125
|
+
}), null);
|
|
126
|
+
effect(() => className(_el$2, classes(progressWrapper({
|
|
127
|
+
size: local.size,
|
|
128
|
+
shape: local.shape
|
|
129
|
+
}))));
|
|
130
|
+
return _el$;
|
|
131
|
+
})();
|
|
132
|
+
};
|
|
133
|
+
var Progress_default = Progress;
|
|
134
|
+
|
|
135
|
+
// src/components/progress/index.ts
|
|
136
|
+
var progress_default = Progress_default;
|
|
137
|
+
|
|
138
|
+
export { progress_default };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
classes,
|
|
3
|
+
cva
|
|
4
|
+
} from "./P7WPLZNA.jsx";
|
|
5
|
+
|
|
6
|
+
// src/components/table/Table.tsx
|
|
7
|
+
import {
|
|
8
|
+
splitProps,
|
|
9
|
+
createMemo,
|
|
10
|
+
createSignal,
|
|
11
|
+
For
|
|
12
|
+
} from "solid-js";
|
|
13
|
+
|
|
14
|
+
// src/components/table/Table.styles.ts
|
|
15
|
+
var tableWrapper = cva(
|
|
16
|
+
"overflow-x-auto rounded-lg border border-gray-200 shadow"
|
|
17
|
+
);
|
|
18
|
+
var tableVariants = cva(
|
|
19
|
+
[
|
|
20
|
+
"min-w-full",
|
|
21
|
+
"text-sm text-left",
|
|
22
|
+
"divide-y divide-gray-100"
|
|
23
|
+
],
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
header: {
|
|
27
|
+
default: "bg-gray-50 font-semibold text-gray-700"
|
|
28
|
+
},
|
|
29
|
+
row: {
|
|
30
|
+
default: ""
|
|
31
|
+
},
|
|
32
|
+
cell: {
|
|
33
|
+
default: "px-4 py-2"
|
|
34
|
+
},
|
|
35
|
+
divider: {
|
|
36
|
+
on: "border-r border-gray-200 last:border-r-0",
|
|
37
|
+
off: ""
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
header: "default",
|
|
42
|
+
row: "default",
|
|
43
|
+
cell: "default",
|
|
44
|
+
divider: "on"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// src/components/table/Table.tsx
|
|
50
|
+
var Table = (props) => {
|
|
51
|
+
const [localProps, variantProps, otherProps] = splitProps(
|
|
52
|
+
props,
|
|
53
|
+
["columns", "rows", "onSort", "className", "rowKey"],
|
|
54
|
+
Object.keys(tableVariants.variantKeys ?? {})
|
|
55
|
+
);
|
|
56
|
+
const [sortKey, setSortKey] = createSignal(null);
|
|
57
|
+
const [sortDir, setSortDir] = createSignal("asc");
|
|
58
|
+
const data = createMemo(() => localProps.rows);
|
|
59
|
+
const baseVars = () => variantProps;
|
|
60
|
+
const wrapperClass = classes(
|
|
61
|
+
tableWrapper(),
|
|
62
|
+
localProps.className
|
|
63
|
+
);
|
|
64
|
+
const tableClass = classes(
|
|
65
|
+
tableVariants(baseVars()),
|
|
66
|
+
localProps.className
|
|
67
|
+
);
|
|
68
|
+
const handleHeaderClick = (colKey, isSortable) => {
|
|
69
|
+
if (!isSortable) return;
|
|
70
|
+
const newDir = sortKey() === colKey && sortDir() === "asc" ? "desc" : "asc";
|
|
71
|
+
setSortKey(() => colKey);
|
|
72
|
+
setSortDir(newDir);
|
|
73
|
+
props.onSort?.(colKey, newDir);
|
|
74
|
+
};
|
|
75
|
+
return <div class={wrapperClass}>
|
|
76
|
+
<table {...otherProps} class={tableClass}>
|
|
77
|
+
<thead>
|
|
78
|
+
<tr>
|
|
79
|
+
{localProps.columns.map((col) => <th
|
|
80
|
+
class={tableVariants({ ...baseVars(), cell: variantProps.cell, divider: "on" })}
|
|
81
|
+
onClick={() => handleHeaderClick(col.key, col.sortable)}
|
|
82
|
+
style={col.sortable ? { cursor: "pointer" } : void 0}
|
|
83
|
+
role="columnheader"
|
|
84
|
+
aria-sort={sortKey() === col.key ? sortDir() === "asc" ? "ascending" : "descending" : void 0}
|
|
85
|
+
>
|
|
86
|
+
{col.header}
|
|
87
|
+
{sortKey() === col.key && (sortDir() === "asc" ? " \u2191" : " \u2193")}
|
|
88
|
+
</th>)}
|
|
89
|
+
</tr>
|
|
90
|
+
</thead>
|
|
91
|
+
<tbody>
|
|
92
|
+
<For each={data()}>
|
|
93
|
+
{(row) => <tr
|
|
94
|
+
class={tableVariants({ ...baseVars(), row: variantProps.row })}
|
|
95
|
+
>
|
|
96
|
+
{localProps.columns.map((col, ci) => <td
|
|
97
|
+
class={tableVariants({
|
|
98
|
+
...baseVars(),
|
|
99
|
+
cell: variantProps.cell,
|
|
100
|
+
divider: ci === localProps.columns.length - 1 ? "off" : "on"
|
|
101
|
+
})}
|
|
102
|
+
>
|
|
103
|
+
{String(row[col.key] ?? "")}
|
|
104
|
+
</td>)}
|
|
105
|
+
</tr>}
|
|
106
|
+
</For>
|
|
107
|
+
</tbody>
|
|
108
|
+
</table>
|
|
109
|
+
</div>;
|
|
110
|
+
};
|
|
111
|
+
var Table_default = Table;
|
|
112
|
+
|
|
113
|
+
// src/components/table/index.ts
|
|
114
|
+
var table_default = Table_default;
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
table_default
|
|
118
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { cva } from './HKS7ET6T.js';
|
|
2
|
+
import { createSignal, For, onMount, onCleanup, Show } from 'solid-js';
|
|
3
|
+
import { delegateEvents, template, insert, createComponent, mergeProps, effect, className, use } from 'solid-js/web';
|
|
4
|
+
|
|
5
|
+
var [toasts, setToasts] = createSignal([]);
|
|
6
|
+
var toastStore = {
|
|
7
|
+
toasts,
|
|
8
|
+
add(toast2) {
|
|
9
|
+
const id = crypto.randomUUID();
|
|
10
|
+
setToasts((prev) => [...prev, { ...toast2, id }]);
|
|
11
|
+
return id;
|
|
12
|
+
},
|
|
13
|
+
remove(id) {
|
|
14
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
15
|
+
},
|
|
16
|
+
clear() {
|
|
17
|
+
setToasts([]);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/components/toast/toast-api.ts
|
|
22
|
+
function createToastApi() {
|
|
23
|
+
const show = (message, options = {}) => {
|
|
24
|
+
return toastStore.add({ ...options, message });
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
show,
|
|
28
|
+
success: (msg, opts) => show(msg, { ...opts, type: "success" }),
|
|
29
|
+
error: (msg, opts) => show(msg, { ...opts, type: "error" }),
|
|
30
|
+
info: (msg, opts) => show(msg, { ...opts, type: "info" }),
|
|
31
|
+
warning: (msg, opts) => show(msg, { ...opts, type: "warning" }),
|
|
32
|
+
clear: toastStore.clear
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/components/toast/utils/remove-element.ts
|
|
37
|
+
function removeElement(el) {
|
|
38
|
+
if (typeof el.remove === "function") {
|
|
39
|
+
el.remove();
|
|
40
|
+
} else {
|
|
41
|
+
el.parentNode?.removeChild(el);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/components/toast/utils/timer.ts
|
|
46
|
+
var Timer = class {
|
|
47
|
+
callback;
|
|
48
|
+
delay;
|
|
49
|
+
startedAt;
|
|
50
|
+
timer;
|
|
51
|
+
constructor(callback, delay) {
|
|
52
|
+
this.callback = callback;
|
|
53
|
+
this.delay = delay;
|
|
54
|
+
this.startedAt = Date.now();
|
|
55
|
+
this.timer = window.setTimeout(callback, delay);
|
|
56
|
+
}
|
|
57
|
+
pause() {
|
|
58
|
+
this.stop();
|
|
59
|
+
this.delay -= Date.now() - this.startedAt;
|
|
60
|
+
}
|
|
61
|
+
resume() {
|
|
62
|
+
this.stop();
|
|
63
|
+
this.startedAt = Date.now();
|
|
64
|
+
this.timer = window.setTimeout(this.callback, this.delay);
|
|
65
|
+
}
|
|
66
|
+
stop() {
|
|
67
|
+
clearTimeout(this.timer);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/components/toast/Toast.styles.ts
|
|
72
|
+
var toastWrapperClass = cva(
|
|
73
|
+
"relative flex items-start gap-3 px-4 py-3 rounded-2xl shadow-lg transition-all duration-300 w-full",
|
|
74
|
+
{
|
|
75
|
+
variants: {
|
|
76
|
+
type: {
|
|
77
|
+
default: "bg-gray-700 text-white",
|
|
78
|
+
success: "bg-green-600 text-white",
|
|
79
|
+
error: "bg-red-600 text-white",
|
|
80
|
+
info: "bg-blue-600 text-white",
|
|
81
|
+
warning: "bg-yellow-400 text-black"
|
|
82
|
+
},
|
|
83
|
+
visible: {
|
|
84
|
+
true: "opacity-100 translate-y-0",
|
|
85
|
+
false: "opacity-0 -translate-y-2 pointer-events-none"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
type: "default",
|
|
90
|
+
visible: true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// src/components/toast/Toast.tsx
|
|
96
|
+
var _tmpl$ = /* @__PURE__ */ template(`<button class="absolute top-2 right-2 text-white/80 hover:text-white transition"aria-label="Close toast">\xD7`);
|
|
97
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<div role=alert>`);
|
|
98
|
+
var Toast = (props) => {
|
|
99
|
+
const [visible, setVisible] = createSignal(false);
|
|
100
|
+
let rootRef;
|
|
101
|
+
let timer = null;
|
|
102
|
+
const close = () => {
|
|
103
|
+
timer?.stop();
|
|
104
|
+
setVisible(false);
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
props.onClose?.();
|
|
107
|
+
if (rootRef) removeElement(rootRef);
|
|
108
|
+
}, 150);
|
|
109
|
+
};
|
|
110
|
+
onMount(() => {
|
|
111
|
+
setVisible(true);
|
|
112
|
+
if (props.duration !== false) {
|
|
113
|
+
timer = new Timer(close, props.duration || 4e3);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
onCleanup(() => {
|
|
117
|
+
timer?.stop();
|
|
118
|
+
});
|
|
119
|
+
return (() => {
|
|
120
|
+
var _el$ = _tmpl$2();
|
|
121
|
+
_el$.$$click = () => props.dismissible && close();
|
|
122
|
+
var _ref$ = rootRef;
|
|
123
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
124
|
+
insert(_el$, createComponent(Show, {
|
|
125
|
+
get when() {
|
|
126
|
+
return props.dismissible;
|
|
127
|
+
},
|
|
128
|
+
get children() {
|
|
129
|
+
return _tmpl$();
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
effect((_p$) => {
|
|
133
|
+
var _v$ = toastWrapperClass({
|
|
134
|
+
type: props.type || "default",
|
|
135
|
+
visible: visible()
|
|
136
|
+
}), _v$2 = props.message;
|
|
137
|
+
_v$ !== _p$.e && className(_el$, _p$.e = _v$);
|
|
138
|
+
_v$2 !== _p$.t && (_el$.innerHTML = _p$.t = _v$2);
|
|
139
|
+
return _p$;
|
|
140
|
+
}, {
|
|
141
|
+
e: void 0,
|
|
142
|
+
t: void 0
|
|
143
|
+
});
|
|
144
|
+
return _el$;
|
|
145
|
+
})();
|
|
146
|
+
};
|
|
147
|
+
var Toast_default = Toast;
|
|
148
|
+
delegateEvents(["click"]);
|
|
149
|
+
|
|
150
|
+
// src/components/toast/Toaster.tsx
|
|
151
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div class="fixed bottom-4 right-4 z-50 flex flex-col items-end gap-2 w-[300px] max-w-full">`);
|
|
152
|
+
var Toaster = () => {
|
|
153
|
+
return (() => {
|
|
154
|
+
var _el$ = _tmpl$3();
|
|
155
|
+
insert(_el$, createComponent(For, {
|
|
156
|
+
get each() {
|
|
157
|
+
return toastStore.toasts();
|
|
158
|
+
},
|
|
159
|
+
children: (toast2) => createComponent(Toast_default, mergeProps(toast2, {
|
|
160
|
+
onClose: () => toastStore.remove(toast2.id)
|
|
161
|
+
}))
|
|
162
|
+
}));
|
|
163
|
+
return _el$;
|
|
164
|
+
})();
|
|
165
|
+
};
|
|
166
|
+
var Toaster_default = Toaster;
|
|
167
|
+
|
|
168
|
+
// src/components/toast/index.ts
|
|
169
|
+
var toast = createToastApi();
|
|
170
|
+
var toast_default = toast;
|
|
171
|
+
|
|
172
|
+
export { Toaster_default, toast, toast_default };
|