castlecraftstudios-ui 1.0.0
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/README.md +73 -0
- package/dist/components/Alert/Alert.d.ts +10 -0
- package/dist/components/Badge/Badge.d.ts +6 -0
- package/dist/components/Button/Button.d.ts +6 -0
- package/dist/components/Card/Card.d.ts +7 -0
- package/dist/components/Checkbox/Checkbox.d.ts +5 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +6 -0
- package/dist/components/ComponentPage/ComponentPage.d.ts +17 -0
- package/dist/components/DatePicker/DatePicker.d.ts +12 -0
- package/dist/components/Input/Input.d.ts +8 -0
- package/dist/components/Modal/Modal.d.ts +10 -0
- package/dist/components/Radio/Radio.d.ts +5 -0
- package/dist/components/Select/Select.d.ts +8 -0
- package/dist/components/SideNav/SideNav.d.ts +10 -0
- package/dist/components/Spinner/Spinner.d.ts +6 -0
- package/dist/components/Tabs/Tabs.d.ts +27 -0
- package/dist/components/Textarea/Textarea.d.ts +7 -0
- package/dist/components/ThemePicker/ThemePicker.d.ts +1 -0
- package/dist/components/Toast/Toast.d.ts +10 -0
- package/dist/components/Toggle/Toggle.d.ts +6 -0
- package/dist/components/Tooltip/Tooltip.d.ts +7 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.js +898 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/index.d.ts +16 -0
- package/package.json +61 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as n, useContext as r, useEffect as i, useId as a, useRef as o, useState as s } from "react";
|
|
3
|
+
import { createPortal as c } from "react-dom";
|
|
4
|
+
//#region src/components/Button/Button.tsx
|
|
5
|
+
function l({ variant: t = "primary", size: n = "md", className: r, children: i, ...a }) {
|
|
6
|
+
return /* @__PURE__ */ e("button", {
|
|
7
|
+
className: [
|
|
8
|
+
"button",
|
|
9
|
+
`button--${t}`,
|
|
10
|
+
`button--${n}`,
|
|
11
|
+
r
|
|
12
|
+
].filter(Boolean).join(" "),
|
|
13
|
+
...a,
|
|
14
|
+
children: i
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/Card/Card.tsx
|
|
19
|
+
function u({ variant: n = "default", header: r, footer: i, className: a, children: o, ...s }) {
|
|
20
|
+
return /* @__PURE__ */ t("div", {
|
|
21
|
+
className: [
|
|
22
|
+
"card",
|
|
23
|
+
`card--${n}`,
|
|
24
|
+
a
|
|
25
|
+
].filter(Boolean).join(" "),
|
|
26
|
+
...s,
|
|
27
|
+
children: [
|
|
28
|
+
r && /* @__PURE__ */ e("div", {
|
|
29
|
+
className: "card__header",
|
|
30
|
+
children: r
|
|
31
|
+
}),
|
|
32
|
+
o && /* @__PURE__ */ e("div", {
|
|
33
|
+
className: "card__body",
|
|
34
|
+
children: o
|
|
35
|
+
}),
|
|
36
|
+
i && /* @__PURE__ */ e("div", {
|
|
37
|
+
className: "card__footer",
|
|
38
|
+
children: i
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/components/Input/Input.tsx
|
|
45
|
+
function d({ label: n, helperText: r, error: i, size: o = "md", className: s, id: c, ...l }) {
|
|
46
|
+
let u = a(), d = c ?? u;
|
|
47
|
+
return /* @__PURE__ */ t("div", {
|
|
48
|
+
className: [
|
|
49
|
+
"input-field",
|
|
50
|
+
`input-field--${o}`,
|
|
51
|
+
i && "input-field--error",
|
|
52
|
+
s
|
|
53
|
+
].filter(Boolean).join(" "),
|
|
54
|
+
children: [
|
|
55
|
+
n && /* @__PURE__ */ e("label", {
|
|
56
|
+
htmlFor: d,
|
|
57
|
+
children: n
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ e("input", {
|
|
60
|
+
id: d,
|
|
61
|
+
...l
|
|
62
|
+
}),
|
|
63
|
+
(i || r) && /* @__PURE__ */ e("span", {
|
|
64
|
+
className: "input-field__hint",
|
|
65
|
+
children: i ?? r
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/components/Textarea/Textarea.tsx
|
|
72
|
+
function f({ label: n, helperText: r, error: i, className: o, id: s, rows: c = 4, ...l }) {
|
|
73
|
+
let u = a(), d = s ?? u;
|
|
74
|
+
return /* @__PURE__ */ t("div", {
|
|
75
|
+
className: [
|
|
76
|
+
"textarea-field",
|
|
77
|
+
i && "textarea-field--error",
|
|
78
|
+
o
|
|
79
|
+
].filter(Boolean).join(" "),
|
|
80
|
+
children: [
|
|
81
|
+
n && /* @__PURE__ */ e("label", {
|
|
82
|
+
htmlFor: d,
|
|
83
|
+
children: n
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ e("textarea", {
|
|
86
|
+
id: d,
|
|
87
|
+
rows: c,
|
|
88
|
+
...l
|
|
89
|
+
}),
|
|
90
|
+
(i || r) && /* @__PURE__ */ e("span", {
|
|
91
|
+
className: "textarea-field__hint",
|
|
92
|
+
children: i ?? r
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/components/Select/Select.tsx
|
|
99
|
+
function p({ label: n, helperText: r, error: i, size: o = "md", className: s, id: c, children: l, ...u }) {
|
|
100
|
+
let d = a(), f = c ?? d;
|
|
101
|
+
return /* @__PURE__ */ t("div", {
|
|
102
|
+
className: [
|
|
103
|
+
"select-field",
|
|
104
|
+
`select-field--${o}`,
|
|
105
|
+
i && "select-field--error",
|
|
106
|
+
s
|
|
107
|
+
].filter(Boolean).join(" "),
|
|
108
|
+
children: [
|
|
109
|
+
n && /* @__PURE__ */ e("label", {
|
|
110
|
+
htmlFor: f,
|
|
111
|
+
children: n
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ e("div", {
|
|
114
|
+
className: "select-field__wrapper",
|
|
115
|
+
children: /* @__PURE__ */ e("select", {
|
|
116
|
+
id: f,
|
|
117
|
+
...u,
|
|
118
|
+
children: l
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
(i || r) && /* @__PURE__ */ e("span", {
|
|
122
|
+
className: "select-field__hint",
|
|
123
|
+
children: i ?? r
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/components/Toggle/Toggle.tsx
|
|
130
|
+
function m({ label: n, size: r = "md", className: i, ...a }) {
|
|
131
|
+
return /* @__PURE__ */ t("label", {
|
|
132
|
+
className: [
|
|
133
|
+
"toggle",
|
|
134
|
+
`toggle--${r}`,
|
|
135
|
+
i
|
|
136
|
+
].filter(Boolean).join(" "),
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ e("input", {
|
|
139
|
+
type: "checkbox",
|
|
140
|
+
role: "switch",
|
|
141
|
+
...a
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ e("span", {
|
|
144
|
+
className: "toggle__track",
|
|
145
|
+
children: /* @__PURE__ */ e("span", { className: "toggle__thumb" })
|
|
146
|
+
}),
|
|
147
|
+
n && /* @__PURE__ */ e("span", {
|
|
148
|
+
className: "toggle__label",
|
|
149
|
+
children: n
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/components/Checkbox/Checkbox.tsx
|
|
156
|
+
function h({ label: n, className: r, ...i }) {
|
|
157
|
+
return /* @__PURE__ */ t("label", {
|
|
158
|
+
className: ["checkbox", r].filter(Boolean).join(" "),
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ e("input", {
|
|
161
|
+
type: "checkbox",
|
|
162
|
+
...i
|
|
163
|
+
}),
|
|
164
|
+
/* @__PURE__ */ e("span", { className: "checkbox__box" }),
|
|
165
|
+
n && /* @__PURE__ */ e("span", {
|
|
166
|
+
className: "checkbox__label",
|
|
167
|
+
children: n
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/components/Radio/Radio.tsx
|
|
174
|
+
function g({ label: n, className: r, ...i }) {
|
|
175
|
+
return /* @__PURE__ */ t("label", {
|
|
176
|
+
className: ["radio", r].filter(Boolean).join(" "),
|
|
177
|
+
children: [
|
|
178
|
+
/* @__PURE__ */ e("input", {
|
|
179
|
+
type: "radio",
|
|
180
|
+
...i
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ e("span", { className: "radio__dot" }),
|
|
183
|
+
n && /* @__PURE__ */ e("span", {
|
|
184
|
+
className: "radio__label",
|
|
185
|
+
children: n
|
|
186
|
+
})
|
|
187
|
+
]
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/components/Modal/Modal.tsx
|
|
192
|
+
function _({ open: n, onClose: r, title: a, footer: o, size: s = "md", children: l }) {
|
|
193
|
+
return i(() => {
|
|
194
|
+
if (!n) return;
|
|
195
|
+
let e = window.innerWidth - document.documentElement.clientWidth;
|
|
196
|
+
document.body.style.overflow = "hidden", document.body.style.paddingRight = `${e}px`;
|
|
197
|
+
let t = (e) => {
|
|
198
|
+
e.key === "Escape" && r();
|
|
199
|
+
};
|
|
200
|
+
return document.addEventListener("keydown", t), () => {
|
|
201
|
+
document.body.style.overflow = "", document.body.style.paddingRight = "", document.removeEventListener("keydown", t);
|
|
202
|
+
};
|
|
203
|
+
}, [n, r]), n ? c(/* @__PURE__ */ e("div", {
|
|
204
|
+
className: "modal-backdrop",
|
|
205
|
+
onClick: r,
|
|
206
|
+
children: /* @__PURE__ */ t("div", {
|
|
207
|
+
className: ["modal", `modal--${s}`].join(" "),
|
|
208
|
+
role: "dialog",
|
|
209
|
+
"aria-modal": "true",
|
|
210
|
+
onClick: (e) => e.stopPropagation(),
|
|
211
|
+
children: [
|
|
212
|
+
a && /* @__PURE__ */ t("div", {
|
|
213
|
+
className: "modal__header",
|
|
214
|
+
children: [/* @__PURE__ */ e("h2", { children: a }), /* @__PURE__ */ e("button", {
|
|
215
|
+
className: "modal__close",
|
|
216
|
+
onClick: r,
|
|
217
|
+
"aria-label": "Close",
|
|
218
|
+
children: /* @__PURE__ */ e("svg", {
|
|
219
|
+
width: "14",
|
|
220
|
+
height: "14",
|
|
221
|
+
viewBox: "0 0 14 14",
|
|
222
|
+
fill: "none",
|
|
223
|
+
children: /* @__PURE__ */ e("path", {
|
|
224
|
+
d: "M1 1l12 12M13 1L1 13",
|
|
225
|
+
stroke: "currentColor",
|
|
226
|
+
strokeWidth: "2",
|
|
227
|
+
strokeLinecap: "round"
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
})]
|
|
231
|
+
}),
|
|
232
|
+
/* @__PURE__ */ e("div", {
|
|
233
|
+
className: "modal__body",
|
|
234
|
+
children: l
|
|
235
|
+
}),
|
|
236
|
+
o && /* @__PURE__ */ e("div", {
|
|
237
|
+
className: "modal__footer",
|
|
238
|
+
children: o
|
|
239
|
+
})
|
|
240
|
+
]
|
|
241
|
+
})
|
|
242
|
+
}), document.body) : null;
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/components/Tooltip/Tooltip.tsx
|
|
246
|
+
function v({ content: n, position: r = "top", children: i }) {
|
|
247
|
+
let [a, o] = s(!1);
|
|
248
|
+
return /* @__PURE__ */ t("span", {
|
|
249
|
+
className: "tooltip-wrapper",
|
|
250
|
+
onMouseEnter: () => o(!0),
|
|
251
|
+
onMouseLeave: () => o(!1),
|
|
252
|
+
onFocus: () => o(!0),
|
|
253
|
+
onBlur: () => o(!1),
|
|
254
|
+
children: [i, /* @__PURE__ */ e("span", {
|
|
255
|
+
className: [
|
|
256
|
+
"tooltip",
|
|
257
|
+
`tooltip--${r}`,
|
|
258
|
+
a && "tooltip--visible"
|
|
259
|
+
].filter(Boolean).join(" "),
|
|
260
|
+
role: "tooltip",
|
|
261
|
+
children: n
|
|
262
|
+
})]
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/components/Badge/Badge.tsx
|
|
267
|
+
function y({ variant: n = "default", dot: r = !1, className: i, children: a, ...o }) {
|
|
268
|
+
return /* @__PURE__ */ t("span", {
|
|
269
|
+
className: [
|
|
270
|
+
"badge",
|
|
271
|
+
`badge--${n}`,
|
|
272
|
+
i
|
|
273
|
+
].filter(Boolean).join(" "),
|
|
274
|
+
...o,
|
|
275
|
+
children: [r && /* @__PURE__ */ e("span", { className: "badge__dot" }), a]
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/components/Alert/Alert.tsx
|
|
280
|
+
var b = {
|
|
281
|
+
success: /* @__PURE__ */ t("svg", {
|
|
282
|
+
width: "16",
|
|
283
|
+
height: "16",
|
|
284
|
+
viewBox: "0 0 16 16",
|
|
285
|
+
fill: "none",
|
|
286
|
+
children: [/* @__PURE__ */ e("circle", {
|
|
287
|
+
cx: "8",
|
|
288
|
+
cy: "8",
|
|
289
|
+
r: "7",
|
|
290
|
+
stroke: "currentColor",
|
|
291
|
+
strokeWidth: "1.5"
|
|
292
|
+
}), /* @__PURE__ */ e("path", {
|
|
293
|
+
d: "M5 8l2 2 4-4",
|
|
294
|
+
stroke: "currentColor",
|
|
295
|
+
strokeWidth: "1.5",
|
|
296
|
+
strokeLinecap: "round",
|
|
297
|
+
strokeLinejoin: "round"
|
|
298
|
+
})]
|
|
299
|
+
}),
|
|
300
|
+
warning: /* @__PURE__ */ t("svg", {
|
|
301
|
+
width: "16",
|
|
302
|
+
height: "16",
|
|
303
|
+
viewBox: "0 0 16 16",
|
|
304
|
+
fill: "none",
|
|
305
|
+
children: [
|
|
306
|
+
/* @__PURE__ */ e("path", {
|
|
307
|
+
d: "M8 2.5L14 13.5H2L8 2.5z",
|
|
308
|
+
stroke: "currentColor",
|
|
309
|
+
strokeWidth: "1.5",
|
|
310
|
+
strokeLinejoin: "round"
|
|
311
|
+
}),
|
|
312
|
+
/* @__PURE__ */ e("path", {
|
|
313
|
+
d: "M8 6.5v3",
|
|
314
|
+
stroke: "currentColor",
|
|
315
|
+
strokeWidth: "1.5",
|
|
316
|
+
strokeLinecap: "round"
|
|
317
|
+
}),
|
|
318
|
+
/* @__PURE__ */ e("circle", {
|
|
319
|
+
cx: "8",
|
|
320
|
+
cy: "11.5",
|
|
321
|
+
r: "0.75",
|
|
322
|
+
fill: "currentColor"
|
|
323
|
+
})
|
|
324
|
+
]
|
|
325
|
+
}),
|
|
326
|
+
error: /* @__PURE__ */ t("svg", {
|
|
327
|
+
width: "16",
|
|
328
|
+
height: "16",
|
|
329
|
+
viewBox: "0 0 16 16",
|
|
330
|
+
fill: "none",
|
|
331
|
+
children: [/* @__PURE__ */ e("circle", {
|
|
332
|
+
cx: "8",
|
|
333
|
+
cy: "8",
|
|
334
|
+
r: "7",
|
|
335
|
+
stroke: "currentColor",
|
|
336
|
+
strokeWidth: "1.5"
|
|
337
|
+
}), /* @__PURE__ */ e("path", {
|
|
338
|
+
d: "M5.5 5.5l5 5M10.5 5.5l-5 5",
|
|
339
|
+
stroke: "currentColor",
|
|
340
|
+
strokeWidth: "1.5",
|
|
341
|
+
strokeLinecap: "round"
|
|
342
|
+
})]
|
|
343
|
+
}),
|
|
344
|
+
info: /* @__PURE__ */ t("svg", {
|
|
345
|
+
width: "16",
|
|
346
|
+
height: "16",
|
|
347
|
+
viewBox: "0 0 16 16",
|
|
348
|
+
fill: "none",
|
|
349
|
+
children: [
|
|
350
|
+
/* @__PURE__ */ e("circle", {
|
|
351
|
+
cx: "8",
|
|
352
|
+
cy: "8",
|
|
353
|
+
r: "7",
|
|
354
|
+
stroke: "currentColor",
|
|
355
|
+
strokeWidth: "1.5"
|
|
356
|
+
}),
|
|
357
|
+
/* @__PURE__ */ e("path", {
|
|
358
|
+
d: "M8 7.5V11",
|
|
359
|
+
stroke: "currentColor",
|
|
360
|
+
strokeWidth: "1.5",
|
|
361
|
+
strokeLinecap: "round"
|
|
362
|
+
}),
|
|
363
|
+
/* @__PURE__ */ e("circle", {
|
|
364
|
+
cx: "8",
|
|
365
|
+
cy: "5",
|
|
366
|
+
r: "0.75",
|
|
367
|
+
fill: "currentColor"
|
|
368
|
+
})
|
|
369
|
+
]
|
|
370
|
+
})
|
|
371
|
+
};
|
|
372
|
+
function x({ variant: n = "info", title: r, onDismiss: i, children: a, className: o }) {
|
|
373
|
+
return /* @__PURE__ */ t("div", {
|
|
374
|
+
className: [
|
|
375
|
+
"alert",
|
|
376
|
+
`alert--${n}`,
|
|
377
|
+
o
|
|
378
|
+
].filter(Boolean).join(" "),
|
|
379
|
+
children: [
|
|
380
|
+
/* @__PURE__ */ e("span", {
|
|
381
|
+
className: "alert__icon",
|
|
382
|
+
children: b[n]
|
|
383
|
+
}),
|
|
384
|
+
/* @__PURE__ */ t("div", {
|
|
385
|
+
className: "alert__content",
|
|
386
|
+
children: [r && /* @__PURE__ */ e("div", {
|
|
387
|
+
className: "alert__title",
|
|
388
|
+
children: r
|
|
389
|
+
}), /* @__PURE__ */ e("div", {
|
|
390
|
+
className: "alert__body",
|
|
391
|
+
children: a
|
|
392
|
+
})]
|
|
393
|
+
}),
|
|
394
|
+
i && /* @__PURE__ */ e("button", {
|
|
395
|
+
className: "alert__dismiss",
|
|
396
|
+
onClick: i,
|
|
397
|
+
"aria-label": "Dismiss",
|
|
398
|
+
children: /* @__PURE__ */ e("svg", {
|
|
399
|
+
width: "12",
|
|
400
|
+
height: "12",
|
|
401
|
+
viewBox: "0 0 12 12",
|
|
402
|
+
fill: "none",
|
|
403
|
+
children: /* @__PURE__ */ e("path", {
|
|
404
|
+
d: "M1 1l10 10M11 1L1 11",
|
|
405
|
+
stroke: "currentColor",
|
|
406
|
+
strokeWidth: "1.5",
|
|
407
|
+
strokeLinecap: "round"
|
|
408
|
+
})
|
|
409
|
+
})
|
|
410
|
+
})
|
|
411
|
+
]
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/components/Toast/Toast.tsx
|
|
416
|
+
var S = {
|
|
417
|
+
success: /* @__PURE__ */ t("svg", {
|
|
418
|
+
width: "16",
|
|
419
|
+
height: "16",
|
|
420
|
+
viewBox: "0 0 16 16",
|
|
421
|
+
fill: "none",
|
|
422
|
+
children: [/* @__PURE__ */ e("circle", {
|
|
423
|
+
cx: "8",
|
|
424
|
+
cy: "8",
|
|
425
|
+
r: "7",
|
|
426
|
+
stroke: "currentColor",
|
|
427
|
+
strokeWidth: "1.5"
|
|
428
|
+
}), /* @__PURE__ */ e("path", {
|
|
429
|
+
d: "M5 8l2 2 4-4",
|
|
430
|
+
stroke: "currentColor",
|
|
431
|
+
strokeWidth: "1.5",
|
|
432
|
+
strokeLinecap: "round",
|
|
433
|
+
strokeLinejoin: "round"
|
|
434
|
+
})]
|
|
435
|
+
}),
|
|
436
|
+
warning: /* @__PURE__ */ t("svg", {
|
|
437
|
+
width: "16",
|
|
438
|
+
height: "16",
|
|
439
|
+
viewBox: "0 0 16 16",
|
|
440
|
+
fill: "none",
|
|
441
|
+
children: [
|
|
442
|
+
/* @__PURE__ */ e("path", {
|
|
443
|
+
d: "M8 2.5L14 13.5H2L8 2.5z",
|
|
444
|
+
stroke: "currentColor",
|
|
445
|
+
strokeWidth: "1.5",
|
|
446
|
+
strokeLinejoin: "round"
|
|
447
|
+
}),
|
|
448
|
+
/* @__PURE__ */ e("path", {
|
|
449
|
+
d: "M8 6.5v3",
|
|
450
|
+
stroke: "currentColor",
|
|
451
|
+
strokeWidth: "1.5",
|
|
452
|
+
strokeLinecap: "round"
|
|
453
|
+
}),
|
|
454
|
+
/* @__PURE__ */ e("circle", {
|
|
455
|
+
cx: "8",
|
|
456
|
+
cy: "11.5",
|
|
457
|
+
r: "0.75",
|
|
458
|
+
fill: "currentColor"
|
|
459
|
+
})
|
|
460
|
+
]
|
|
461
|
+
}),
|
|
462
|
+
error: /* @__PURE__ */ t("svg", {
|
|
463
|
+
width: "16",
|
|
464
|
+
height: "16",
|
|
465
|
+
viewBox: "0 0 16 16",
|
|
466
|
+
fill: "none",
|
|
467
|
+
children: [/* @__PURE__ */ e("circle", {
|
|
468
|
+
cx: "8",
|
|
469
|
+
cy: "8",
|
|
470
|
+
r: "7",
|
|
471
|
+
stroke: "currentColor",
|
|
472
|
+
strokeWidth: "1.5"
|
|
473
|
+
}), /* @__PURE__ */ e("path", {
|
|
474
|
+
d: "M5.5 5.5l5 5M10.5 5.5l-5 5",
|
|
475
|
+
stroke: "currentColor",
|
|
476
|
+
strokeWidth: "1.5",
|
|
477
|
+
strokeLinecap: "round"
|
|
478
|
+
})]
|
|
479
|
+
}),
|
|
480
|
+
info: /* @__PURE__ */ t("svg", {
|
|
481
|
+
width: "16",
|
|
482
|
+
height: "16",
|
|
483
|
+
viewBox: "0 0 16 16",
|
|
484
|
+
fill: "none",
|
|
485
|
+
children: [
|
|
486
|
+
/* @__PURE__ */ e("circle", {
|
|
487
|
+
cx: "8",
|
|
488
|
+
cy: "8",
|
|
489
|
+
r: "7",
|
|
490
|
+
stroke: "currentColor",
|
|
491
|
+
strokeWidth: "1.5"
|
|
492
|
+
}),
|
|
493
|
+
/* @__PURE__ */ e("path", {
|
|
494
|
+
d: "M8 7.5V11",
|
|
495
|
+
stroke: "currentColor",
|
|
496
|
+
strokeWidth: "1.5",
|
|
497
|
+
strokeLinecap: "round"
|
|
498
|
+
}),
|
|
499
|
+
/* @__PURE__ */ e("circle", {
|
|
500
|
+
cx: "8",
|
|
501
|
+
cy: "5",
|
|
502
|
+
r: "0.75",
|
|
503
|
+
fill: "currentColor"
|
|
504
|
+
})
|
|
505
|
+
]
|
|
506
|
+
})
|
|
507
|
+
};
|
|
508
|
+
function C({ open: n, variant: r = "info", title: a, onDismiss: o, children: l }) {
|
|
509
|
+
let [u, d] = s(!1), [f, p] = s(!1);
|
|
510
|
+
return i(() => {
|
|
511
|
+
if (n) {
|
|
512
|
+
d(!0);
|
|
513
|
+
let e = requestAnimationFrame(() => requestAnimationFrame(() => p(!0)));
|
|
514
|
+
return () => cancelAnimationFrame(e);
|
|
515
|
+
} else {
|
|
516
|
+
p(!1);
|
|
517
|
+
let e = setTimeout(() => d(!1), 250);
|
|
518
|
+
return () => clearTimeout(e);
|
|
519
|
+
}
|
|
520
|
+
}, [n]), u ? c(/* @__PURE__ */ t("div", {
|
|
521
|
+
className: [
|
|
522
|
+
"toast",
|
|
523
|
+
`toast--${r}`,
|
|
524
|
+
f && "toast--visible"
|
|
525
|
+
].filter(Boolean).join(" "),
|
|
526
|
+
role: "status",
|
|
527
|
+
children: [
|
|
528
|
+
/* @__PURE__ */ e("span", {
|
|
529
|
+
className: "toast__icon",
|
|
530
|
+
children: S[r]
|
|
531
|
+
}),
|
|
532
|
+
/* @__PURE__ */ t("div", {
|
|
533
|
+
className: "toast__content",
|
|
534
|
+
children: [a && /* @__PURE__ */ e("div", {
|
|
535
|
+
className: "toast__title",
|
|
536
|
+
children: a
|
|
537
|
+
}), /* @__PURE__ */ e("div", {
|
|
538
|
+
className: "toast__body",
|
|
539
|
+
children: l
|
|
540
|
+
})]
|
|
541
|
+
}),
|
|
542
|
+
o && /* @__PURE__ */ e("button", {
|
|
543
|
+
className: "toast__dismiss",
|
|
544
|
+
onClick: o,
|
|
545
|
+
"aria-label": "Dismiss",
|
|
546
|
+
children: /* @__PURE__ */ e("svg", {
|
|
547
|
+
width: "12",
|
|
548
|
+
height: "12",
|
|
549
|
+
viewBox: "0 0 12 12",
|
|
550
|
+
fill: "none",
|
|
551
|
+
children: /* @__PURE__ */ e("path", {
|
|
552
|
+
d: "M1 1l10 10M11 1L1 11",
|
|
553
|
+
stroke: "currentColor",
|
|
554
|
+
strokeWidth: "1.5",
|
|
555
|
+
strokeLinecap: "round"
|
|
556
|
+
})
|
|
557
|
+
})
|
|
558
|
+
})
|
|
559
|
+
]
|
|
560
|
+
}), document.body) : null;
|
|
561
|
+
}
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region src/components/Spinner/Spinner.tsx
|
|
564
|
+
function w({ size: t = "md", className: n }) {
|
|
565
|
+
return /* @__PURE__ */ e("svg", {
|
|
566
|
+
className: [
|
|
567
|
+
"spinner",
|
|
568
|
+
`spinner--${t}`,
|
|
569
|
+
n
|
|
570
|
+
].filter(Boolean).join(" "),
|
|
571
|
+
viewBox: "0 0 24 24",
|
|
572
|
+
fill: "none",
|
|
573
|
+
"aria-label": "Loading",
|
|
574
|
+
children: /* @__PURE__ */ e("circle", {
|
|
575
|
+
cx: "12",
|
|
576
|
+
cy: "12",
|
|
577
|
+
r: "10",
|
|
578
|
+
stroke: "currentColor",
|
|
579
|
+
strokeWidth: "2.5",
|
|
580
|
+
strokeLinecap: "round",
|
|
581
|
+
strokeDasharray: "47 16"
|
|
582
|
+
})
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region src/components/Tabs/Tabs.tsx
|
|
587
|
+
var T = n(null);
|
|
588
|
+
function E() {
|
|
589
|
+
let e = r(T);
|
|
590
|
+
if (!e) throw Error("Tab components must be used inside <Tabs>");
|
|
591
|
+
return e;
|
|
592
|
+
}
|
|
593
|
+
function D({ defaultValue: t, value: n, onChange: r, children: i, className: o }) {
|
|
594
|
+
let [c, l] = s(t), u = a(), d = n ?? c;
|
|
595
|
+
function f(e) {
|
|
596
|
+
n || l(e), r?.(e);
|
|
597
|
+
}
|
|
598
|
+
return /* @__PURE__ */ e(T.Provider, {
|
|
599
|
+
value: {
|
|
600
|
+
activeValue: d,
|
|
601
|
+
setActiveValue: f,
|
|
602
|
+
baseId: u
|
|
603
|
+
},
|
|
604
|
+
children: /* @__PURE__ */ e("div", {
|
|
605
|
+
className: ["tabs", o].filter(Boolean).join(" "),
|
|
606
|
+
children: i
|
|
607
|
+
})
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
function O({ children: t, className: n }) {
|
|
611
|
+
let r = o(null);
|
|
612
|
+
function i(e) {
|
|
613
|
+
let t = r.current?.querySelectorAll("[role=\"tab\"]:not([disabled])");
|
|
614
|
+
if (!t) return;
|
|
615
|
+
let n = Array.from(t), i = document.activeElement, a = n.indexOf(i);
|
|
616
|
+
a !== -1 && (e.key === "ArrowRight" ? (e.preventDefault(), n[(a + 1) % n.length].focus()) : e.key === "ArrowLeft" ? (e.preventDefault(), n[(a - 1 + n.length) % n.length].focus()) : e.key === "Home" ? (e.preventDefault(), n[0].focus()) : e.key === "End" && (e.preventDefault(), n[n.length - 1].focus()));
|
|
617
|
+
}
|
|
618
|
+
return /* @__PURE__ */ e("div", {
|
|
619
|
+
ref: r,
|
|
620
|
+
role: "tablist",
|
|
621
|
+
className: ["tabs__list", n].filter(Boolean).join(" "),
|
|
622
|
+
onKeyDown: i,
|
|
623
|
+
children: t
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
function k({ value: t, disabled: n, children: r, className: i }) {
|
|
627
|
+
let { activeValue: a, setActiveValue: o, baseId: s } = E(), c = a === t;
|
|
628
|
+
return /* @__PURE__ */ e("button", {
|
|
629
|
+
role: "tab",
|
|
630
|
+
"aria-selected": c,
|
|
631
|
+
"aria-controls": `${s}-panel-${t}`,
|
|
632
|
+
id: `${s}-tab-${t}`,
|
|
633
|
+
tabIndex: c ? 0 : -1,
|
|
634
|
+
disabled: n,
|
|
635
|
+
className: [
|
|
636
|
+
"tabs__tab",
|
|
637
|
+
c && "tabs__tab--active",
|
|
638
|
+
i
|
|
639
|
+
].filter(Boolean).join(" "),
|
|
640
|
+
onClick: () => !n && o(t),
|
|
641
|
+
children: r
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function A({ value: t, children: n, className: r }) {
|
|
645
|
+
let { activeValue: i, baseId: a } = E();
|
|
646
|
+
return i === t ? /* @__PURE__ */ e("div", {
|
|
647
|
+
role: "tabpanel",
|
|
648
|
+
id: `${a}-panel-${t}`,
|
|
649
|
+
"aria-labelledby": `${a}-tab-${t}`,
|
|
650
|
+
className: ["tabs__panel", r].filter(Boolean).join(" "),
|
|
651
|
+
children: n
|
|
652
|
+
}) : null;
|
|
653
|
+
}
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region src/components/DatePicker/DatePicker.tsx
|
|
656
|
+
var j = [
|
|
657
|
+
"Su",
|
|
658
|
+
"Mo",
|
|
659
|
+
"Tu",
|
|
660
|
+
"We",
|
|
661
|
+
"Th",
|
|
662
|
+
"Fr",
|
|
663
|
+
"Sa"
|
|
664
|
+
], M = [
|
|
665
|
+
"January",
|
|
666
|
+
"February",
|
|
667
|
+
"March",
|
|
668
|
+
"April",
|
|
669
|
+
"May",
|
|
670
|
+
"June",
|
|
671
|
+
"July",
|
|
672
|
+
"August",
|
|
673
|
+
"September",
|
|
674
|
+
"October",
|
|
675
|
+
"November",
|
|
676
|
+
"December"
|
|
677
|
+
];
|
|
678
|
+
function N(e, t) {
|
|
679
|
+
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
680
|
+
}
|
|
681
|
+
function P(e) {
|
|
682
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate());
|
|
683
|
+
}
|
|
684
|
+
function F(e) {
|
|
685
|
+
return e ? e.toLocaleDateString("en-GB", {
|
|
686
|
+
day: "2-digit",
|
|
687
|
+
month: "short",
|
|
688
|
+
year: "numeric"
|
|
689
|
+
}) : "";
|
|
690
|
+
}
|
|
691
|
+
function I(e, t) {
|
|
692
|
+
return new Date(e, t + 1, 0).getDate();
|
|
693
|
+
}
|
|
694
|
+
function L(e, t) {
|
|
695
|
+
return new Date(e, t, 1).getDay();
|
|
696
|
+
}
|
|
697
|
+
function R({ label: n, value: r, onChange: c, min: l, max: u, placeholder: d = "Select date", disabled: f, className: p }) {
|
|
698
|
+
let m = a(), [h, g] = s(!1), [_, v] = s(() => {
|
|
699
|
+
let e = r ?? /* @__PURE__ */ new Date();
|
|
700
|
+
return {
|
|
701
|
+
year: e.getFullYear(),
|
|
702
|
+
month: e.getMonth()
|
|
703
|
+
};
|
|
704
|
+
}), y = o(null);
|
|
705
|
+
i(() => {
|
|
706
|
+
if (!h) return;
|
|
707
|
+
function e(e) {
|
|
708
|
+
y.current?.contains(e.target) || g(!1);
|
|
709
|
+
}
|
|
710
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
711
|
+
}, [h]), i(() => {
|
|
712
|
+
if (!h) return;
|
|
713
|
+
function e(e) {
|
|
714
|
+
e.key === "Escape" && g(!1);
|
|
715
|
+
}
|
|
716
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
717
|
+
}, [h]);
|
|
718
|
+
function b() {
|
|
719
|
+
v((e) => {
|
|
720
|
+
let t = e.month === 0 ? 11 : e.month - 1;
|
|
721
|
+
return {
|
|
722
|
+
year: e.month === 0 ? e.year - 1 : e.year,
|
|
723
|
+
month: t
|
|
724
|
+
};
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
function x() {
|
|
728
|
+
v((e) => {
|
|
729
|
+
let t = e.month === 11 ? 0 : e.month + 1;
|
|
730
|
+
return {
|
|
731
|
+
year: e.month === 11 ? e.year + 1 : e.year,
|
|
732
|
+
month: t
|
|
733
|
+
};
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
function S(e) {
|
|
737
|
+
let t = new Date(_.year, _.month, e);
|
|
738
|
+
c?.(t), g(!1);
|
|
739
|
+
}
|
|
740
|
+
function C(e) {
|
|
741
|
+
let t = P(new Date(_.year, _.month, e));
|
|
742
|
+
return !!(l && t < P(l) || u && t > P(u));
|
|
743
|
+
}
|
|
744
|
+
let w = I(_.year, _.month), T = L(_.year, _.month), E = [...Array(T).fill(null), ...Array.from({ length: w }, (e, t) => t + 1)];
|
|
745
|
+
for (; E.length % 7 != 0;) E.push(null);
|
|
746
|
+
return /* @__PURE__ */ t("div", {
|
|
747
|
+
ref: y,
|
|
748
|
+
className: [
|
|
749
|
+
"date-picker",
|
|
750
|
+
f && "date-picker--disabled",
|
|
751
|
+
p
|
|
752
|
+
].filter(Boolean).join(" "),
|
|
753
|
+
children: [
|
|
754
|
+
n && /* @__PURE__ */ e("label", {
|
|
755
|
+
className: "date-picker__label",
|
|
756
|
+
htmlFor: m,
|
|
757
|
+
children: n
|
|
758
|
+
}),
|
|
759
|
+
/* @__PURE__ */ t("button", {
|
|
760
|
+
id: m,
|
|
761
|
+
type: "button",
|
|
762
|
+
className: ["date-picker__trigger", h && "date-picker__trigger--open"].filter(Boolean).join(" "),
|
|
763
|
+
disabled: f,
|
|
764
|
+
"aria-haspopup": "dialog",
|
|
765
|
+
"aria-expanded": h,
|
|
766
|
+
onClick: () => g((e) => !e),
|
|
767
|
+
children: [/* @__PURE__ */ e("span", {
|
|
768
|
+
className: r ? "" : "date-picker__placeholder",
|
|
769
|
+
children: r ? F(r) : d
|
|
770
|
+
}), /* @__PURE__ */ t("svg", {
|
|
771
|
+
className: "date-picker__icon",
|
|
772
|
+
width: "16",
|
|
773
|
+
height: "16",
|
|
774
|
+
viewBox: "0 0 24 24",
|
|
775
|
+
fill: "none",
|
|
776
|
+
stroke: "currentColor",
|
|
777
|
+
strokeWidth: "2",
|
|
778
|
+
strokeLinecap: "round",
|
|
779
|
+
strokeLinejoin: "round",
|
|
780
|
+
"aria-hidden": "true",
|
|
781
|
+
children: [
|
|
782
|
+
/* @__PURE__ */ e("rect", {
|
|
783
|
+
x: "3",
|
|
784
|
+
y: "4",
|
|
785
|
+
width: "18",
|
|
786
|
+
height: "18",
|
|
787
|
+
rx: "2",
|
|
788
|
+
ry: "2"
|
|
789
|
+
}),
|
|
790
|
+
/* @__PURE__ */ e("line", {
|
|
791
|
+
x1: "16",
|
|
792
|
+
y1: "2",
|
|
793
|
+
x2: "16",
|
|
794
|
+
y2: "6"
|
|
795
|
+
}),
|
|
796
|
+
/* @__PURE__ */ e("line", {
|
|
797
|
+
x1: "8",
|
|
798
|
+
y1: "2",
|
|
799
|
+
x2: "8",
|
|
800
|
+
y2: "6"
|
|
801
|
+
}),
|
|
802
|
+
/* @__PURE__ */ e("line", {
|
|
803
|
+
x1: "3",
|
|
804
|
+
y1: "10",
|
|
805
|
+
x2: "21",
|
|
806
|
+
y2: "10"
|
|
807
|
+
})
|
|
808
|
+
]
|
|
809
|
+
})]
|
|
810
|
+
}),
|
|
811
|
+
h && /* @__PURE__ */ t("div", {
|
|
812
|
+
className: "date-picker__popover",
|
|
813
|
+
role: "dialog",
|
|
814
|
+
"aria-label": "Date picker",
|
|
815
|
+
children: [/* @__PURE__ */ t("div", {
|
|
816
|
+
className: "date-picker__header",
|
|
817
|
+
children: [
|
|
818
|
+
/* @__PURE__ */ e("button", {
|
|
819
|
+
type: "button",
|
|
820
|
+
className: "date-picker__nav",
|
|
821
|
+
onClick: b,
|
|
822
|
+
"aria-label": "Previous month",
|
|
823
|
+
children: /* @__PURE__ */ e("svg", {
|
|
824
|
+
width: "16",
|
|
825
|
+
height: "16",
|
|
826
|
+
viewBox: "0 0 24 24",
|
|
827
|
+
fill: "none",
|
|
828
|
+
stroke: "currentColor",
|
|
829
|
+
strokeWidth: "2",
|
|
830
|
+
strokeLinecap: "round",
|
|
831
|
+
strokeLinejoin: "round",
|
|
832
|
+
"aria-hidden": "true",
|
|
833
|
+
children: /* @__PURE__ */ e("polyline", { points: "15 18 9 12 15 6" })
|
|
834
|
+
})
|
|
835
|
+
}),
|
|
836
|
+
/* @__PURE__ */ t("span", {
|
|
837
|
+
className: "date-picker__month-label",
|
|
838
|
+
children: [
|
|
839
|
+
M[_.month],
|
|
840
|
+
" ",
|
|
841
|
+
_.year
|
|
842
|
+
]
|
|
843
|
+
}),
|
|
844
|
+
/* @__PURE__ */ e("button", {
|
|
845
|
+
type: "button",
|
|
846
|
+
className: "date-picker__nav",
|
|
847
|
+
onClick: x,
|
|
848
|
+
"aria-label": "Next month",
|
|
849
|
+
children: /* @__PURE__ */ e("svg", {
|
|
850
|
+
width: "16",
|
|
851
|
+
height: "16",
|
|
852
|
+
viewBox: "0 0 24 24",
|
|
853
|
+
fill: "none",
|
|
854
|
+
stroke: "currentColor",
|
|
855
|
+
strokeWidth: "2",
|
|
856
|
+
strokeLinecap: "round",
|
|
857
|
+
strokeLinejoin: "round",
|
|
858
|
+
"aria-hidden": "true",
|
|
859
|
+
children: /* @__PURE__ */ e("polyline", { points: "9 18 15 12 9 6" })
|
|
860
|
+
})
|
|
861
|
+
})
|
|
862
|
+
]
|
|
863
|
+
}), /* @__PURE__ */ t("div", {
|
|
864
|
+
className: "date-picker__grid",
|
|
865
|
+
children: [j.map((t) => /* @__PURE__ */ e("span", {
|
|
866
|
+
className: "date-picker__day-name",
|
|
867
|
+
children: t
|
|
868
|
+
}, t)), E.map((t, n) => {
|
|
869
|
+
if (!t) return /* @__PURE__ */ e("span", {}, `empty-${n}`);
|
|
870
|
+
let i = new Date(_.year, _.month, t), a = r ? N(i, r) : !1, o = N(i, /* @__PURE__ */ new Date()), s = C(t);
|
|
871
|
+
return /* @__PURE__ */ e("button", {
|
|
872
|
+
type: "button",
|
|
873
|
+
disabled: s,
|
|
874
|
+
"aria-pressed": a,
|
|
875
|
+
"aria-label": i.toLocaleDateString("en-GB", {
|
|
876
|
+
day: "numeric",
|
|
877
|
+
month: "long",
|
|
878
|
+
year: "numeric"
|
|
879
|
+
}),
|
|
880
|
+
className: [
|
|
881
|
+
"date-picker__day",
|
|
882
|
+
a && "date-picker__day--selected",
|
|
883
|
+
o && !a && "date-picker__day--today",
|
|
884
|
+
s && "date-picker__day--disabled"
|
|
885
|
+
].filter(Boolean).join(" "),
|
|
886
|
+
onClick: () => !s && S(t),
|
|
887
|
+
children: t
|
|
888
|
+
}, t);
|
|
889
|
+
})]
|
|
890
|
+
})]
|
|
891
|
+
})
|
|
892
|
+
]
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
//#endregion
|
|
896
|
+
export { x as Alert, y as Badge, l as Button, u as Card, h as Checkbox, R as DatePicker, d as Input, _ as Modal, g as Radio, p as Select, w as Spinner, k as Tab, O as TabList, A as TabPanel, D as Tabs, f as Textarea, C as Toast, m as Toggle, v as Tooltip };
|
|
897
|
+
|
|
898
|
+
//# sourceMappingURL=index.js.map
|