@g4rcez/components 5.0.1 → 5.0.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/core/button.d.ts +77 -0
- package/dist/components/core/button.d.ts.map +1 -0
- package/dist/components/core/button.jsx +79 -0
- package/dist/components/core/heading.d.ts +3 -0
- package/dist/components/core/heading.d.ts.map +1 -0
- package/dist/components/core/heading.jsx +4 -0
- package/dist/components/core/polymorph.d.ts +10 -0
- package/dist/components/core/polymorph.d.ts.map +1 -0
- package/dist/components/core/polymorph.jsx +5 -0
- package/dist/components/core/render-on-view.d.ts +7 -0
- package/dist/components/core/render-on-view.d.ts.map +1 -0
- package/dist/components/core/render-on-view.jsx +31 -0
- package/dist/components/core/resizable.d.ts +3 -0
- package/dist/components/core/resizable.d.ts.map +1 -0
- package/dist/components/core/resizable.jsx +51 -0
- package/dist/components/core/slot.d.ts +16 -0
- package/dist/components/core/slot.d.ts.map +1 -0
- package/dist/components/core/slot.jsx +156 -0
- package/dist/components/core/tag.d.ts +35 -0
- package/dist/components/core/tag.d.ts.map +1 -0
- package/dist/components/core/tag.jsx +53 -0
- package/dist/components/core/typography.d.ts +25 -0
- package/dist/components/core/typography.d.ts.map +1 -0
- package/dist/components/core/typography.jsx +20 -0
- package/dist/components/display/alert.d.ts +28 -0
- package/dist/components/display/alert.d.ts.map +1 -0
- package/dist/components/display/alert.jsx +61 -0
- package/dist/components/display/calendar.d.ts +42 -0
- package/dist/components/display/calendar.d.ts.map +1 -0
- package/dist/components/display/calendar.jsx +318 -0
- package/dist/components/display/card.d.ts +29 -0
- package/dist/components/display/card.d.ts.map +1 -0
- package/dist/components/display/card.jsx +43 -0
- package/dist/components/display/empty.d.ts +8 -0
- package/dist/components/display/empty.d.ts.map +1 -0
- package/dist/components/display/empty.jsx +11 -0
- package/dist/components/display/list.d.ts +16 -0
- package/dist/components/display/list.d.ts.map +1 -0
- package/dist/components/display/list.jsx +85 -0
- package/dist/components/display/notifications.d.ts +27 -0
- package/dist/components/display/notifications.d.ts.map +1 -0
- package/dist/components/display/notifications.jsx +130 -0
- package/dist/components/display/progress.d.ts +16 -0
- package/dist/components/display/progress.d.ts.map +1 -0
- package/dist/components/display/progress.jsx +21 -0
- package/dist/components/display/shortcut.d.ts +4 -0
- package/dist/components/display/shortcut.d.ts.map +1 -0
- package/dist/components/display/shortcut.jsx +23 -0
- package/dist/components/display/skeleton.d.ts +12 -0
- package/dist/components/display/skeleton.d.ts.map +1 -0
- package/dist/components/display/skeleton.jsx +19 -0
- package/dist/components/display/spinner.d.ts +5 -0
- package/dist/components/display/spinner.d.ts.map +1 -0
- package/dist/components/display/spinner.jsx +11 -0
- package/dist/components/display/stats.d.ts +12 -0
- package/dist/components/display/stats.d.ts.map +1 -0
- package/dist/components/display/stats.jsx +16 -0
- package/dist/components/display/step.d.ts +24 -0
- package/dist/components/display/step.d.ts.map +1 -0
- package/dist/components/display/step.jsx +145 -0
- package/dist/components/display/tabs.d.ts +24 -0
- package/dist/components/display/tabs.d.ts.map +1 -0
- package/dist/components/display/tabs.jsx +125 -0
- package/dist/components/display/timeline.d.ts +10 -0
- package/dist/components/display/timeline.d.ts.map +1 -0
- package/dist/components/display/timeline.jsx +25 -0
- package/dist/components/floating/command-palette.d.ts +49 -0
- package/dist/components/floating/command-palette.d.ts.map +1 -0
- package/dist/components/floating/command-palette.jsx +223 -0
- package/dist/components/floating/dropdown.d.ts +15 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -0
- package/dist/components/floating/dropdown.jsx +56 -0
- package/dist/components/floating/expand.d.ts +11 -0
- package/dist/components/floating/expand.d.ts.map +1 -0
- package/dist/components/floating/expand.jsx +44 -0
- package/dist/components/floating/menu.d.ts +52 -0
- package/dist/components/floating/menu.d.ts.map +1 -0
- package/dist/components/floating/menu.jsx +165 -0
- package/dist/components/floating/modal.d.ts +60 -0
- package/dist/components/floating/modal.d.ts.map +1 -0
- package/dist/components/floating/modal.jsx +336 -0
- package/dist/components/floating/toolbar.d.ts +6 -0
- package/dist/components/floating/toolbar.d.ts.map +1 -0
- package/dist/components/floating/toolbar.jsx +5 -0
- package/dist/components/floating/tooltip.d.ts +17 -0
- package/dist/components/floating/tooltip.d.ts.map +1 -0
- package/dist/components/floating/tooltip.jsx +67 -0
- package/dist/components/floating/wizard.d.ts +26 -0
- package/dist/components/floating/wizard.d.ts.map +1 -0
- package/dist/components/floating/wizard.jsx +165 -0
- package/dist/components/form/autocomplete.d.ts +16 -0
- package/dist/components/form/autocomplete.d.ts.map +1 -0
- package/dist/components/form/autocomplete.jsx +290 -0
- package/dist/components/form/checkbox.d.ts +12 -0
- package/dist/components/form/checkbox.d.ts.map +1 -0
- package/dist/components/form/checkbox.jsx +12 -0
- package/dist/components/form/date-picker.d.ts +10 -0
- package/dist/components/form/date-picker.d.ts.map +1 -0
- package/dist/components/form/date-picker.jsx +115 -0
- package/dist/components/form/file-upload.d.ts +15 -0
- package/dist/components/form/file-upload.d.ts.map +1 -0
- package/dist/components/form/file-upload.jsx +138 -0
- package/dist/components/form/form.d.ts +3 -0
- package/dist/components/form/form.d.ts.map +1 -0
- package/dist/components/form/form.jsx +10 -0
- package/dist/components/form/formReset.d.ts +2 -0
- package/dist/components/form/formReset.d.ts.map +1 -0
- package/dist/components/form/formReset.jsx +17 -0
- package/dist/components/form/free-text.d.ts +11 -0
- package/dist/components/form/free-text.d.ts.map +1 -0
- package/dist/components/form/free-text.jsx +41 -0
- package/dist/components/form/input-field.d.ts +34 -0
- package/dist/components/form/input-field.d.ts.map +1 -0
- package/dist/components/form/input-field.jsx +58 -0
- package/dist/components/form/input.d.ts +52 -0
- package/dist/components/form/input.d.ts.map +1 -0
- package/dist/components/form/input.jsx +36 -0
- package/dist/components/form/multi-select.d.ts +19 -0
- package/dist/components/form/multi-select.d.ts.map +1 -0
- package/dist/components/form/multi-select.jsx +344 -0
- package/dist/components/form/radiobox.d.ts +7 -0
- package/dist/components/form/radiobox.d.ts.map +1 -0
- package/dist/components/form/radiobox.jsx +6 -0
- package/dist/components/form/select.d.ts +13 -0
- package/dist/components/form/select.d.ts.map +1 -0
- package/dist/components/form/select.jsx +44 -0
- package/dist/components/form/slider.d.ts +7 -0
- package/dist/components/form/slider.d.ts.map +1 -0
- package/dist/components/form/slider.jsx +45 -0
- package/dist/components/form/switch.d.ts +9 -0
- package/dist/components/form/switch.d.ts.map +1 -0
- package/dist/components/form/switch.jsx +46 -0
- package/dist/components/form/task-list.d.ts +3 -0
- package/dist/components/form/task-list.d.ts.map +1 -0
- package/dist/components/form/task-list.jsx +26 -0
- package/dist/components/form/textarea.d.ts +5 -0
- package/dist/components/form/textarea.d.ts.map +1 -0
- package/dist/components/form/textarea.jsx +26 -0
- package/dist/components/index.d.ts +45 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +44 -0
- package/dist/components/page-calendar/calendar-header.d.ts +16 -0
- package/dist/components/page-calendar/calendar-header.d.ts.map +1 -0
- package/dist/components/page-calendar/calendar-header.jsx +83 -0
- package/dist/components/page-calendar/day-view.d.ts +12 -0
- package/dist/components/page-calendar/day-view.d.ts.map +1 -0
- package/dist/components/page-calendar/day-view.jsx +89 -0
- package/dist/components/page-calendar/event-pill.d.ts +9 -0
- package/dist/components/page-calendar/event-pill.d.ts.map +1 -0
- package/dist/components/page-calendar/event-pill.jsx +25 -0
- package/dist/components/page-calendar/index.d.ts +4 -0
- package/dist/components/page-calendar/index.d.ts.map +1 -0
- package/dist/components/page-calendar/index.js +2 -0
- package/dist/components/page-calendar/month-view.d.ts +11 -0
- package/dist/components/page-calendar/month-view.d.ts.map +1 -0
- package/dist/components/page-calendar/month-view.jsx +46 -0
- package/dist/components/page-calendar/page-calendar.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.jsx +41 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.types.js +1 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts +24 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.utils.js +93 -0
- package/dist/components/page-calendar/week-view.d.ts +11 -0
- package/dist/components/page-calendar/week-view.d.ts.map +1 -0
- package/dist/components/page-calendar/week-view.jsx +66 -0
- package/dist/components/table/filter.d.ts +42 -0
- package/dist/components/table/filter.d.ts.map +1 -0
- package/dist/components/table/filter.jsx +169 -0
- package/dist/components/table/group.d.ts +17 -0
- package/dist/components/table/group.d.ts.map +1 -0
- package/dist/components/table/group.jsx +75 -0
- package/dist/components/table/index.d.ts +19 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/components/table/index.jsx +63 -0
- package/dist/components/table/inner-table.d.ts +29 -0
- package/dist/components/table/inner-table.d.ts.map +1 -0
- package/dist/components/table/inner-table.jsx +102 -0
- package/dist/components/table/metadata.d.ts +4 -0
- package/dist/components/table/metadata.d.ts.map +1 -0
- package/dist/components/table/metadata.jsx +36 -0
- package/dist/components/table/pagination.d.ts +5 -0
- package/dist/components/table/pagination.d.ts.map +1 -0
- package/dist/components/table/pagination.jsx +74 -0
- package/dist/components/table/row.d.ts +11 -0
- package/dist/components/table/row.d.ts.map +1 -0
- package/dist/components/table/row.jsx +49 -0
- package/dist/components/table/sort.d.ts +28 -0
- package/dist/components/table/sort.d.ts.map +1 -0
- package/dist/components/table/sort.jsx +109 -0
- package/dist/components/table/table-lib.d.ts +135 -0
- package/dist/components/table/table-lib.d.ts.map +1 -0
- package/dist/components/table/table-lib.js +83 -0
- package/dist/components/table/table.context.d.ts +10 -0
- package/dist/components/table/table.context.d.ts.map +1 -0
- package/dist/components/table/table.context.jsx +5 -0
- package/dist/components/table/thead.d.ts +9 -0
- package/dist/components/table/thead.d.ts.map +1 -0
- package/dist/components/table/thead.jsx +103 -0
- package/dist/config/context.d.ts +21 -0
- package/dist/config/context.d.ts.map +1 -0
- package/dist/config/context.js +12 -0
- package/dist/config/default-translations.d.ts +94 -0
- package/dist/config/default-translations.d.ts.map +1 -0
- package/dist/config/default-translations.jsx +87 -0
- package/dist/config/default-tweaks.d.ts +13 -0
- package/dist/config/default-tweaks.d.ts.map +1 -0
- package/dist/config/default-tweaks.js +4 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -0
- package/dist/hooks/use-click-outside.d.ts +3 -0
- package/dist/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/hooks/use-click-outside.js +17 -0
- package/dist/hooks/use-color-parser.d.ts +2 -0
- package/dist/hooks/use-color-parser.d.ts.map +1 -0
- package/dist/hooks/use-color-parser.js +9 -0
- package/dist/hooks/use-components-provider.d.ts +15 -0
- package/dist/hooks/use-components-provider.d.ts.map +1 -0
- package/dist/hooks/use-components-provider.jsx +22 -0
- package/dist/hooks/use-debounce.d.ts +5 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-debounce.js +12 -0
- package/dist/hooks/use-floating-ref.d.ts +2 -0
- package/dist/hooks/use-floating-ref.d.ts.map +1 -0
- package/dist/hooks/use-floating-ref.js +6 -0
- package/dist/hooks/use-form.d.ts +394 -0
- package/dist/hooks/use-form.d.ts.map +1 -0
- package/dist/hooks/use-form.js +563 -0
- package/dist/hooks/use-hover.d.ts +3 -0
- package/dist/hooks/use-hover.d.ts.map +1 -0
- package/dist/hooks/use-hover.js +18 -0
- package/dist/hooks/use-input-id.d.ts +4 -0
- package/dist/hooks/use-input-id.d.ts.map +1 -0
- package/dist/hooks/use-input-id.js +5 -0
- package/dist/hooks/use-is-coarse-device.d.ts +2 -0
- package/dist/hooks/use-is-coarse-device.d.ts.map +1 -0
- package/dist/hooks/use-is-coarse-device.js +12 -0
- package/dist/hooks/use-locale.d.ts +3 -0
- package/dist/hooks/use-locale.d.ts.map +1 -0
- package/dist/hooks/use-locale.js +10 -0
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +25 -0
- package/dist/hooks/use-on-event.d.ts +4 -0
- package/dist/hooks/use-on-event.d.ts.map +1 -0
- package/dist/hooks/use-on-event.js +10 -0
- package/dist/hooks/use-parent.d.ts +3 -0
- package/dist/hooks/use-parent.d.ts.map +1 -0
- package/dist/hooks/use-parent.js +21 -0
- package/dist/hooks/use-preferences.d.ts +2 -0
- package/dist/hooks/use-preferences.d.ts.map +1 -0
- package/dist/hooks/use-preferences.js +23 -0
- package/dist/hooks/use-previous.d.ts +2 -0
- package/dist/hooks/use-previous.d.ts.map +1 -0
- package/dist/hooks/use-previous.js +9 -0
- package/dist/hooks/use-reactive.d.ts +2 -0
- package/dist/hooks/use-reactive.d.ts.map +1 -0
- package/dist/hooks/use-reactive.js +9 -0
- package/dist/hooks/use-remove-scroll.d.ts +4 -0
- package/dist/hooks/use-remove-scroll.d.ts.map +1 -0
- package/dist/hooks/use-remove-scroll.js +48 -0
- package/dist/hooks/use-resize-observer.d.ts +2 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -0
- package/dist/hooks/use-resize-observer.js +17 -0
- package/dist/hooks/use-stable-ref.d.ts +2 -0
- package/dist/hooks/use-stable-ref.d.ts.map +1 -0
- package/dist/hooks/use-stable-ref.js +9 -0
- package/dist/hooks/use-swipe.d.ts +8 -0
- package/dist/hooks/use-swipe.d.ts.map +1 -0
- package/dist/hooks/use-swipe.js +17 -0
- package/dist/hooks/use-translations.d.ts +92 -0
- package/dist/hooks/use-translations.d.ts.map +1 -0
- package/dist/hooks/use-translations.js +9 -0
- package/dist/hooks/use-tweaks.d.ts +3 -0
- package/dist/hooks/use-tweaks.d.ts.map +1 -0
- package/dist/hooks/use-tweaks.js +9 -0
- package/dist/hooks/use-window-size.d.ts +5 -0
- package/dist/hooks/use-window-size.d.ts.map +1 -0
- package/dist/hooks/use-window-size.js +14 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -7932
- package/dist/lib/combi-keys.d.ts +15 -0
- package/dist/lib/combi-keys.d.ts.map +1 -0
- package/dist/lib/combi-keys.js +60 -0
- package/dist/lib/dict.d.ts +9 -0
- package/dist/lib/dict.d.ts.map +1 -0
- package/dist/lib/dict.js +28 -0
- package/dist/lib/dom.d.ts +20 -0
- package/dist/lib/dom.d.ts.map +1 -0
- package/dist/lib/dom.js +185 -0
- package/dist/lib/fns.d.ts +11 -0
- package/dist/lib/fns.d.ts.map +1 -0
- package/dist/lib/fns.js +46 -0
- package/dist/lib/fzf.d.ts +16 -0
- package/dist/lib/fzf.d.ts.map +1 -0
- package/dist/lib/fzf.js +115 -0
- package/dist/lib/keyboard-area.d.ts +16 -0
- package/dist/lib/keyboard-area.d.ts.map +1 -0
- package/dist/lib/keyboard-area.js +14 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
3
|
+
import { AnimatePresence, motion, MotionConfig } from "motion/react";
|
|
4
|
+
import { XIcon } from "@phosphor-icons/react";
|
|
5
|
+
import React, { Fragment, useCallback, useId, useState } from "react";
|
|
6
|
+
const FloatItem = ({ item, context, setter, get, refs }) => (<FloatingPortal>
|
|
7
|
+
<MotionConfig reducedMotion="user" transition={{ type: "spring", damping: 30, stiffness: 350 }}>
|
|
8
|
+
<AnimatePresence mode="wait" presenceAffectsLayout>
|
|
9
|
+
{item ? (<motion.div key="overlay" exit={{ opacity: 0 }} animate={{ opacity: 1 }} initial={{ opacity: 0 }} transition={{ type: "tween", duration: 0.15, ease: "easeOut" }} className="pointer-events-none fixed inset-0 top-0 z-overlay h-screen w-screen bg-floating-overlay/70"/>) : null}
|
|
10
|
+
{item ? (<FloatingOverlay key="card" lockScroll className="absolute inset-0 z-floating flex items-center justify-center">
|
|
11
|
+
<FloatingFocusManager visuallyHiddenDismiss modal closeOnFocusOut context={context}>
|
|
12
|
+
<motion.div layout layoutId={`item-${item.id}`} initial={{ opacity: 0.6, scale: 0.98 }} animate={{ opacity: 1, scale: 1 }} exit={{ opacity: 0, scale: 0.98 }} className="relative flex h-min w-min min-w-xs flex-col gap-list-card-gap rounded-list-radius border border-card-border bg-card-background p-list-card-p py-list-card-py pb-list-card-pb shadow-shadow-card" ref={refs.setFloating} {...get()}>
|
|
13
|
+
<nav className="absolute right-4 top-1 lg:right-2">
|
|
14
|
+
<button type="button" onClick={setter} className="p-list-close-p opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger">
|
|
15
|
+
<XIcon />
|
|
16
|
+
</button>
|
|
17
|
+
</nav>
|
|
18
|
+
<motion.header layout className="flex w-full flex-wrap items-center justify-between gap-list-header-gap">
|
|
19
|
+
<h3 className="min-w-full text-balance text-list-title-text font-medium">{item.title}</h3>
|
|
20
|
+
<p className="text-typography-sm leading-snug text-secondary">{item.description}</p>
|
|
21
|
+
</motion.header>
|
|
22
|
+
<motion.div layout>{item.children}</motion.div>
|
|
23
|
+
</motion.div>
|
|
24
|
+
</FloatingFocusManager>
|
|
25
|
+
</FloatingOverlay>) : null}
|
|
26
|
+
</AnimatePresence>
|
|
27
|
+
</MotionConfig>
|
|
28
|
+
</FloatingPortal>);
|
|
29
|
+
export const AnimatedList = (props) => {
|
|
30
|
+
const [selected, setSelected] = useState(null);
|
|
31
|
+
const id = useId();
|
|
32
|
+
const { context, refs } = useFloating({
|
|
33
|
+
open: selected !== null,
|
|
34
|
+
transform: true,
|
|
35
|
+
onOpenChange: (open) => (open ? undefined : setSelected(null)),
|
|
36
|
+
});
|
|
37
|
+
const click = useClick(context);
|
|
38
|
+
const role = useRole(context, { role: "dialog" });
|
|
39
|
+
const dismiss = useDismiss(context, {
|
|
40
|
+
escapeKey: true,
|
|
41
|
+
referencePress: true,
|
|
42
|
+
outsidePress: true,
|
|
43
|
+
});
|
|
44
|
+
const { getFloatingProps } = useInteractions([click, role, dismiss]);
|
|
45
|
+
const clear = useCallback(() => {
|
|
46
|
+
setSelected(null);
|
|
47
|
+
}, []);
|
|
48
|
+
const items = React.Children.toArray(props.children);
|
|
49
|
+
return (<Fragment>
|
|
50
|
+
<FloatItem refs={refs} context={context} get={getFloatingProps} item={selected} setter={clear}/>
|
|
51
|
+
<ul role="list">
|
|
52
|
+
{items.map((x, index) => {
|
|
53
|
+
const item = x.props;
|
|
54
|
+
const innerId = `${id}-${index}`;
|
|
55
|
+
const setter = () => setSelected({ ...item, id: innerId });
|
|
56
|
+
const Leading = item.leading;
|
|
57
|
+
return (<motion.li layout key={innerId} layoutId={`item-${innerId}`} className={`border-b border-card-border py-list-item-py last:border-transparent`}>
|
|
58
|
+
<motion.div layoutId={`toast-${innerId}`} className="relative">
|
|
59
|
+
<div className="relative flex items-start space-x-3">
|
|
60
|
+
<Fragment>
|
|
61
|
+
{item.avatar ? (<div>
|
|
62
|
+
<div className="relative px-list-avatar-px">
|
|
63
|
+
<button onClick={setter} className="flex size-10 items-center justify-center ring-primary">
|
|
64
|
+
{item.avatar}
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
</div>) : null}
|
|
68
|
+
<div className="min-w-0 flex-1 py-list-body-py text-foreground">
|
|
69
|
+
<div className="flex flex-row flex-nowrap justify-between gap-list-item-gap">
|
|
70
|
+
<button onClick={setter} className="cursor-pointer text-left transition-all ease-out hover:text-primary">
|
|
71
|
+
<h3>{item.title}</h3>
|
|
72
|
+
<p className="text-typography-sm leading-snug text-secondary">{item.description}</p>
|
|
73
|
+
</button>
|
|
74
|
+
{Leading ? <Leading open={setter}/> : null}
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</Fragment>
|
|
78
|
+
</div>
|
|
79
|
+
</motion.div>
|
|
80
|
+
</motion.li>);
|
|
81
|
+
})}
|
|
82
|
+
</ul>
|
|
83
|
+
</Fragment>);
|
|
84
|
+
};
|
|
85
|
+
export const AnimatedListItem = (props) => <Fragment>{props.children}</Fragment>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import { type PropsWithChildren } from "react";
|
|
3
|
+
import { Label } from "../../types";
|
|
4
|
+
declare const variants: (props?: ({
|
|
5
|
+
theme?: "warn" | "secondary" | "info" | "danger" | "success" | "muted" | "default" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
type NotificationOptions = Partial<{
|
|
8
|
+
id: string;
|
|
9
|
+
title: Label;
|
|
10
|
+
timeout: number;
|
|
11
|
+
closable: boolean;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
theme: VariantProps<typeof variants>["theme"];
|
|
14
|
+
}>;
|
|
15
|
+
type NotificationSubscriber = {
|
|
16
|
+
close: () => void;
|
|
17
|
+
clear: () => void;
|
|
18
|
+
};
|
|
19
|
+
type ContextFunction = (description: Label, args?: NotificationOptions) => NotificationSubscriber;
|
|
20
|
+
export declare const useNotification: () => ContextFunction;
|
|
21
|
+
export type NotificationProps = Partial<{
|
|
22
|
+
max: number;
|
|
23
|
+
timeout: number;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function Notifications({ children, max, timeout }: PropsWithChildren<NotificationProps>): import("react").JSX.Element;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/components/display/notifications.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAiB,KAAK,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAG/F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,QAAA,MAAM,QAAQ;;8EAgBb,CAAC;AAYF,KAAK,mBAAmB,GAAG,OAAO,CAAC;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;CACjD,CAAC,CAAC;AAQH,KAAK,sBAAsB,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEvE,KAAK,eAAe,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,mBAAmB,KAAK,sBAAsB,CAAC;AAMlG,eAAO,MAAM,eAAe,uBAAwC,CAAC;AAkDrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AA0F1E,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAO,EAAE,OAAc,EAAE,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,+BAMxG"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Toast as Base } from "@base-ui/react/toast";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { XIcon, CheckCircleIcon, WarningIcon, InfoIcon, CircleNotchIcon } from "@phosphor-icons/react";
|
|
5
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
6
|
+
import { createContext, useCallback, useContext, useRef } from "react";
|
|
7
|
+
import { useHover } from "../../hooks/use-hover";
|
|
8
|
+
import { css } from "../../lib/dom";
|
|
9
|
+
const variants = cva("shadow-notification text-typography-sm relative isolate z-tooltip flex w-full flex-col overflow-hidden rounded-notification-radius border bg-card-background backdrop-blur-md transition-all duration-300", {
|
|
10
|
+
variants: {
|
|
11
|
+
theme: {
|
|
12
|
+
default: "border-card-border text-foreground shadow-black/5",
|
|
13
|
+
info: "border-alert-info-border bg-alert-info-bg text-alert-info-text",
|
|
14
|
+
warn: "border-alert-warn-border bg-alert-warn-bg text-alert-warn-text",
|
|
15
|
+
muted: "border-alert-muted-border bg-alert-muted-bg text-alert-muted-text",
|
|
16
|
+
danger: "border-alert-danger-border bg-alert-danger-bg text-alert-danger-text",
|
|
17
|
+
success: "border-alert-success-border bg-alert-success-bg text-alert-success-text",
|
|
18
|
+
secondary: "border-alert-secondary-border bg-alert-secondary-bg text-alert-secondary-text",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: { theme: "default" },
|
|
22
|
+
});
|
|
23
|
+
const themeIcons = {
|
|
24
|
+
default: InfoIcon,
|
|
25
|
+
info: InfoIcon,
|
|
26
|
+
warn: WarningIcon,
|
|
27
|
+
muted: InfoIcon,
|
|
28
|
+
danger: WarningIcon,
|
|
29
|
+
success: CheckCircleIcon,
|
|
30
|
+
secondary: InfoIcon,
|
|
31
|
+
};
|
|
32
|
+
const NotificationContext = createContext(() => {
|
|
33
|
+
throw new Error("Not implemented");
|
|
34
|
+
});
|
|
35
|
+
export const useNotification = () => useContext(NotificationContext);
|
|
36
|
+
function Notification(props) {
|
|
37
|
+
const closable = props.toast.data?.closable ?? true;
|
|
38
|
+
const loading = props.toast.data?.loading ?? false;
|
|
39
|
+
const theme = props.toast.data?.theme || "default";
|
|
40
|
+
const className = variants({ theme });
|
|
41
|
+
const Icon = loading ? CircleNotchIcon : themeIcons[theme] || InfoIcon;
|
|
42
|
+
return (<Base.Root toast={props.toast} swipeDirection="right">
|
|
43
|
+
<motion.li layout initial={{ opacity: 0, y: -20, scale: 0.95 }} animate={{ opacity: 1, y: 0, scale: 1 }} exit={{ opacity: 0, scale: 0.9, y: -20, transition: { duration: 0.2 } }} transition={{
|
|
44
|
+
type: "spring",
|
|
45
|
+
damping: 25,
|
|
46
|
+
stiffness: 300,
|
|
47
|
+
}} className="pointer-events-auto w-full list-none">
|
|
48
|
+
<Base.Content className={className}>
|
|
49
|
+
<div className="flex items-start gap-notification-gap p-notification-p">
|
|
50
|
+
<div className={css("mt-0.5 shrink-0 opacity-80", loading && "animate-spin")}>
|
|
51
|
+
<Icon className="size-4"/>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div className="flex flex-1 flex-col gap-notification-inner-gap overflow-hidden">
|
|
55
|
+
{props.toast.title ? <Base.Title className="select-text truncate font-semibold leading-tight tracking-tight"/> : null}
|
|
56
|
+
<Base.Description className="line-clamp-2 select-text text-typography-xs font-medium leading-relaxed opacity-90"/>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
{closable && !loading ? (<Base.Close className="rounded-notification-close-radius -mr-1 -mt-1 shrink-0 p-notification-close-p text-foreground/40 transition hover:bg-foreground/10 hover:text-foreground">
|
|
60
|
+
<XIcon className="size-3.5"/>
|
|
61
|
+
</Base.Close>) : null}
|
|
62
|
+
</div>
|
|
63
|
+
</Base.Content>
|
|
64
|
+
</motion.li>
|
|
65
|
+
</Base.Root>);
|
|
66
|
+
}
|
|
67
|
+
function NotificationsViewport({ max = 5 }) {
|
|
68
|
+
const ref = useRef(null);
|
|
69
|
+
const hover = useHover(ref);
|
|
70
|
+
const toastManager = Base.useToastManager();
|
|
71
|
+
const allToasts = max ? toastManager.toasts.slice(0, max) : toastManager.toasts;
|
|
72
|
+
const visibleToasts = hover ? allToasts : allToasts.slice(0, 3);
|
|
73
|
+
const hiddenCount = allToasts.length - visibleToasts.length;
|
|
74
|
+
return (<Base.Viewport ref={ref} className="pointer-events-none fixed left-1/2 top-notification-list-top z-floating flex w-full max-w-notification-list-max-w -translate-x-1/2 flex-col gap-notification-list-gap overflow-visible outline-none">
|
|
75
|
+
<AnimatePresence mode="popLayout" initial={false}>
|
|
76
|
+
{visibleToasts.map((toast) => (<Notification key={toast.id} toast={toast}/>))}
|
|
77
|
+
</AnimatePresence>
|
|
78
|
+
|
|
79
|
+
{!hover && hiddenCount > 0 && (<motion.div layout initial={{ opacity: 0, y: -10 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -10 }} className="pointer-events-auto cursor-default self-center rounded-full border border-card-border bg-card-background/80 px-notification-badge-px py-notification-badge-py text-notification-badge-text font-bold uppercase tracking-wider text-foreground/50 shadow-notification backdrop-blur transition-all hover:bg-card-background hover:text-foreground/80">
|
|
80
|
+
+{hiddenCount} more
|
|
81
|
+
</motion.div>)}
|
|
82
|
+
</Base.Viewport>);
|
|
83
|
+
}
|
|
84
|
+
function NotificationsInner({ children, max = 5 }) {
|
|
85
|
+
const toastManager = Base.useToastManager();
|
|
86
|
+
const clear = useCallback(() => {
|
|
87
|
+
toastManager.toasts.forEach((t) => toastManager.close(t.id));
|
|
88
|
+
}, [toastManager]);
|
|
89
|
+
const notify = useCallback((description, args) => {
|
|
90
|
+
const data = {
|
|
91
|
+
theme: args?.theme,
|
|
92
|
+
closable: args?.closable,
|
|
93
|
+
loading: args?.loading,
|
|
94
|
+
};
|
|
95
|
+
if (args?.id) {
|
|
96
|
+
const existing = toastManager.toasts.find((t) => t.id === args.id);
|
|
97
|
+
if (existing) {
|
|
98
|
+
toastManager.update(args.id, {
|
|
99
|
+
description,
|
|
100
|
+
title: args.title,
|
|
101
|
+
timeout: args.timeout,
|
|
102
|
+
data,
|
|
103
|
+
});
|
|
104
|
+
return { close: () => toastManager.close(args.id), clear };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const id = toastManager.add({
|
|
108
|
+
description,
|
|
109
|
+
id: args?.id,
|
|
110
|
+
title: args?.title,
|
|
111
|
+
timeout: args?.timeout,
|
|
112
|
+
data,
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
close: () => toastManager.close(id),
|
|
116
|
+
clear,
|
|
117
|
+
};
|
|
118
|
+
}, [toastManager, clear]);
|
|
119
|
+
return (<NotificationContext.Provider value={notify}>
|
|
120
|
+
{children}
|
|
121
|
+
<Base.Portal>
|
|
122
|
+
<NotificationsViewport max={max}/>
|
|
123
|
+
</Base.Portal>
|
|
124
|
+
</NotificationContext.Provider>);
|
|
125
|
+
}
|
|
126
|
+
export function Notifications({ children, max = 5, timeout = 5000 }) {
|
|
127
|
+
return (<Base.Provider limit={max} timeout={timeout}>
|
|
128
|
+
<NotificationsInner max={max}>{children}</NotificationsInner>
|
|
129
|
+
</Base.Provider>);
|
|
130
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PropsWithoutRef } from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
type ProgressProps = {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
value?: number;
|
|
7
|
+
/** @deprecated use value */
|
|
8
|
+
percent?: number;
|
|
9
|
+
label?: Label;
|
|
10
|
+
className?: string;
|
|
11
|
+
container?: string;
|
|
12
|
+
textClassName?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const Progress: (props: PropsWithoutRef<ProgressProps>) => import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/components/display/progress.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,KAAK,aAAa,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAKF,eAAO,MAAM,QAAQ,GAAI,OAAO,eAAe,CAAC,aAAa,CAAC,gCAuC7D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Is } from "sidekicker";
|
|
3
|
+
import { Progress as RadixProgress } from "@base-ui/react/progress";
|
|
4
|
+
import { css } from "../../lib/dom";
|
|
5
|
+
const clamp = (n, min, max) => Math.min(Math.max(n, min), max);
|
|
6
|
+
export const Progress = (props) => {
|
|
7
|
+
const min = props.min ?? 0;
|
|
8
|
+
const max = props.max ?? 100;
|
|
9
|
+
const range = max - min;
|
|
10
|
+
const rawValue = props.value ?? props.percent;
|
|
11
|
+
const hasValue = Is.number(rawValue) && range > 0;
|
|
12
|
+
const percent = hasValue
|
|
13
|
+
? clamp(((rawValue - min) / range) * 100, 0, 100)
|
|
14
|
+
: null;
|
|
15
|
+
return (<RadixProgress.Root min={min} max={max} value={hasValue ? rawValue : null} style={{ transform: "translateZ(0)" }} className={css("relative h-progress-track-h w-full overflow-hidden rounded-progress-radius bg-background", props.container)}>
|
|
16
|
+
<RadixProgress.Indicator className={css("h-full bg-primary transition-[width] duration-500 ease-in-out", props.className)}/>
|
|
17
|
+
{percent !== null ? (<p className={css("absolute inset-0 flex w-full items-center justify-center font-semibold tabular-nums text-primary-foreground", props.textClassName)}>
|
|
18
|
+
{props.label ? props.label : `${Math.round(percent)} %`}
|
|
19
|
+
</p>) : null}
|
|
20
|
+
</RadixProgress.Root>);
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortcut.d.ts","sourceRoot":"","sources":["../../../src/components/display/shortcut.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,QAAQ,GAAI,OAAO;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,gCAehD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CommandIcon, OptionIcon } from "@phosphor-icons/react";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { isMac } from "../../lib/combi-keys";
|
|
4
|
+
const remap = (x) => {
|
|
5
|
+
x = x.trim();
|
|
6
|
+
if (x === "Alt")
|
|
7
|
+
return isMac() ? <OptionIcon aria-label="Option" size={12}/> : "Alt";
|
|
8
|
+
if (x === "Mod")
|
|
9
|
+
return isMac() ? <CommandIcon aria-label="Command" size={12}/> : "Ctrl";
|
|
10
|
+
return x;
|
|
11
|
+
};
|
|
12
|
+
export const Shortcut = (props) => {
|
|
13
|
+
const p = props.value.trim().split("+");
|
|
14
|
+
return (<span className="flex items-center gap-shortcut-gap text-shortcut-text">
|
|
15
|
+
{p.map((x, i) => {
|
|
16
|
+
const isLast = p.length - 1 === i;
|
|
17
|
+
return (<Fragment key={`${props.value}-${x}-key-${i}`}>
|
|
18
|
+
<kbd aria-label={x}>{remap(x)}</kbd>
|
|
19
|
+
{isLast ? null : <span>+</span>}
|
|
20
|
+
</Fragment>);
|
|
21
|
+
})}
|
|
22
|
+
</span>);
|
|
23
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { CSSProperties, type ElementType } from "react";
|
|
2
|
+
export declare const SkeletonCell: React.JSX.Element;
|
|
3
|
+
export declare const Skeleton: (props: {
|
|
4
|
+
className?: string;
|
|
5
|
+
as?: ElementType;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
}) => React.JSX.Element;
|
|
8
|
+
export declare const SkeletonList: (props: {
|
|
9
|
+
className?: string;
|
|
10
|
+
rows: number;
|
|
11
|
+
}) => React.JSX.Element;
|
|
12
|
+
//# sourceMappingURL=skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/display/skeleton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAU,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAKvE,eAAO,MAAM,YAAY,mBAOxB,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,sBAY9F,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,sBAavE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
3
|
+
import { css } from "../../lib/dom";
|
|
4
|
+
import { Polymorph } from "../core/polymorph";
|
|
5
|
+
export const SkeletonCell = (<div role="status" aria-busy="true" aria-label="Loading content" className="h-skeleton-cell-h w-10/12 animate-pulse rounded-skeleton-radius bg-muted"/>);
|
|
6
|
+
export const Skeleton = (props) => {
|
|
7
|
+
const t = useTranslations();
|
|
8
|
+
return (<Polymorph {...props} role="status" aria-busy="true" aria-label={t.skeletonLoading} as={props.as || "span"} className={css("block h-skeleton-height w-skeleton-width animate-pulse rounded-skeleton-radius bg-muted", props.className)}/>);
|
|
9
|
+
};
|
|
10
|
+
export const SkeletonList = (props) => {
|
|
11
|
+
const t = useTranslations();
|
|
12
|
+
const items = useRef(Array.from({ length: props.rows }).map((_, i) => {
|
|
13
|
+
const rand = Math.max(100, Math.random() * 99);
|
|
14
|
+
return <Skeleton key={`skeleton-${rand}-${i}`} style={{ width: `${rand}%` }} as="li"/>;
|
|
15
|
+
}));
|
|
16
|
+
return (<ul role="status" aria-busy="true" aria-label={t.skeletonLoading} className={css("flex flex-col gap-skeleton-list-gap", props.className)}>
|
|
17
|
+
{items.current}
|
|
18
|
+
</ul>);
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/display/spinner.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,OAAO;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,gCAapD,CAAC;AAEF,eAAO,MAAM,OAAO,mCAMnB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
2
|
+
import { css } from "../../lib/dom";
|
|
3
|
+
export const Spinner = (props) => {
|
|
4
|
+
const t = useTranslations();
|
|
5
|
+
return (<span role="status" aria-live="polite" aria-label={t.spinnerLoading} className={css("box-border inline-block aspect-square size-spinner-size animate-spin rounded-full border-spinner-border border-background border-b-primary", props.className)}/>);
|
|
6
|
+
};
|
|
7
|
+
export const Loading = () => {
|
|
8
|
+
return (<div className="flex h-full w-full items-center justify-center p-spinner-container-p">
|
|
9
|
+
<Spinner />
|
|
10
|
+
</div>);
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
export type StatsProps = {
|
|
4
|
+
title: Label;
|
|
5
|
+
iconContainer?: string;
|
|
6
|
+
footer?: React.ReactElement;
|
|
7
|
+
Icon: React.FC<{
|
|
8
|
+
className: string;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
export declare const Stats: (props: React.PropsWithChildren<StatsProps>) => React.JSX.Element;
|
|
12
|
+
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/components/display/stats.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,sBAe/D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { css } from "../../lib/dom";
|
|
3
|
+
export const Stats = (props) => {
|
|
4
|
+
return (<div className="divide-y divide-card-border overflow-hidden rounded-stats-radius border border-card-border bg-card-background shadow-shadow-card">
|
|
5
|
+
<header className="flex items-stretch gap-stats-gap">
|
|
6
|
+
<div className={css("flex shrink-0 items-center justify-center bg-primary p-stats-icon-p", props.iconContainer)}>
|
|
7
|
+
<props.Icon className="aspect-square size-stats-icon-size text-primary-foreground"/>
|
|
8
|
+
</div>
|
|
9
|
+
<div className="flex flex-col justify-center gap-stats-inner-gap py-stats-p pr-stats-p">
|
|
10
|
+
<h3 className="text-typography-base leading-none">{props.title}</h3>
|
|
11
|
+
<p className="text-stats-value-text font-semibold">{props.children}</p>
|
|
12
|
+
</div>
|
|
13
|
+
</header>
|
|
14
|
+
{props.footer ? <footer className="px-stats-footer-px py-stats-footer-py">{props.footer}</footer> : null}
|
|
15
|
+
</div>);
|
|
16
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
type StepContextValue = {
|
|
4
|
+
currentStep: number;
|
|
5
|
+
previousStep: number;
|
|
6
|
+
progressBarDuration: number;
|
|
7
|
+
steps: number;
|
|
8
|
+
};
|
|
9
|
+
type StepStatus = "active" | "inactive" | "complete" | "error";
|
|
10
|
+
export type StepProps = React.ComponentProps<"button"> & {
|
|
11
|
+
step: number;
|
|
12
|
+
title?: Label;
|
|
13
|
+
currentStep: number;
|
|
14
|
+
status?: StepStatus;
|
|
15
|
+
titleClassName?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const useStepContext: () => StepContextValue | null;
|
|
18
|
+
export declare const Step: ({ step, currentStep, status, title, titleClassName, ...props }: StepProps) => React.JSX.Element;
|
|
19
|
+
export declare const Steps: (props: PropsWithChildren<{
|
|
20
|
+
steps: number;
|
|
21
|
+
currentStep: number;
|
|
22
|
+
}>) => React.JSX.Element;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../src/components/display/step.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA2C,iBAAiB,EAA2C,MAAM,OAAO,CAAC;AAEnI,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAUpC,KAAK,gBAAgB,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAoCF,KAAK,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAgCF,eAAO,MAAM,cAAc,+BAAgC,CAAC;AAE5D,eAAO,MAAM,IAAI,GAAI,gEAAgE,SAAS,sBA6F7F,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO,iBAAiB,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,sBA0BrF,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { motion } from "motion/react";
|
|
3
|
+
import React, { createContext, Fragment, useContext, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useColorParser } from "../../hooks/use-color-parser";
|
|
5
|
+
const PROGRESS_BAR_DURATION = 0.3;
|
|
6
|
+
const transition = {
|
|
7
|
+
duration: PROGRESS_BAR_DURATION,
|
|
8
|
+
type: "tween",
|
|
9
|
+
ease: "easeInOut",
|
|
10
|
+
};
|
|
11
|
+
const StepContext = createContext(null);
|
|
12
|
+
const iconTransitions = {
|
|
13
|
+
delay: 0.2,
|
|
14
|
+
duration: 0.3,
|
|
15
|
+
type: "tween",
|
|
16
|
+
ease: "easeOut",
|
|
17
|
+
};
|
|
18
|
+
const states = {
|
|
19
|
+
initial: { pathLength: 0, opacity: 0 },
|
|
20
|
+
animate: { pathLength: 1, opacity: 1 },
|
|
21
|
+
};
|
|
22
|
+
const ErrorIcon = (props) => (<svg {...props} viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
23
|
+
<motion.path className="currentColor" initial={states.initial} animate={states.animate} transition={iconTransitions} d="M18 6 6 18"/>
|
|
24
|
+
<motion.path className="currentColor" initial={states.initial} animate={states.animate} transition={iconTransitions} d="m6 6 12 12"/>
|
|
25
|
+
</svg>);
|
|
26
|
+
const CheckIcon = (props) => (<svg {...props} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3}>
|
|
27
|
+
<motion.path d="M5 13l4 4L19 7" strokeLinecap="round" strokeLinejoin="round" animate={states.animate} initial={states.initial} transition={iconTransitions}/>
|
|
28
|
+
</svg>);
|
|
29
|
+
const variants = {
|
|
30
|
+
complete: { scale: 1.25 },
|
|
31
|
+
active: { scale: 1, transition: { delay: 0, duration: 0.3 } },
|
|
32
|
+
};
|
|
33
|
+
const transitions = {
|
|
34
|
+
duration: 0.6,
|
|
35
|
+
delay: 0.2,
|
|
36
|
+
type: "tween",
|
|
37
|
+
ease: "circOut",
|
|
38
|
+
};
|
|
39
|
+
const getCurrentStatus = (step, currentStep, status) => {
|
|
40
|
+
if (status === "error")
|
|
41
|
+
return "error";
|
|
42
|
+
if (currentStep === step)
|
|
43
|
+
return "active";
|
|
44
|
+
if (currentStep < step)
|
|
45
|
+
return "inactive";
|
|
46
|
+
return "complete";
|
|
47
|
+
};
|
|
48
|
+
const calculateStepDelay = (step, currentStep, previousStep, duration) => {
|
|
49
|
+
if (currentStep === previousStep)
|
|
50
|
+
return 0;
|
|
51
|
+
const isForward = currentStep > previousStep;
|
|
52
|
+
if (isForward) {
|
|
53
|
+
if (step <= previousStep || step > currentStep)
|
|
54
|
+
return 0;
|
|
55
|
+
return ((step - previousStep) / (currentStep - previousStep)) * duration;
|
|
56
|
+
}
|
|
57
|
+
if (step <= currentStep || step > previousStep)
|
|
58
|
+
return 0;
|
|
59
|
+
return ((previousStep - step) / (previousStep - currentStep)) * duration;
|
|
60
|
+
};
|
|
61
|
+
export const useStepContext = () => useContext(StepContext);
|
|
62
|
+
export const Step = ({ step, currentStep, status, title, titleClassName, ...props }) => {
|
|
63
|
+
const parser = useColorParser();
|
|
64
|
+
const context = useStepContext();
|
|
65
|
+
const [visualCurrentStep, setVisualCurrentStep] = useState(currentStep);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!context) {
|
|
68
|
+
setVisualCurrentStep(currentStep);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const delay = calculateStepDelay(step, context.currentStep, context.previousStep, context.progressBarDuration);
|
|
72
|
+
if (delay === 0) {
|
|
73
|
+
setVisualCurrentStep(currentStep);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const timer = setTimeout(() => {
|
|
77
|
+
setVisualCurrentStep(currentStep);
|
|
78
|
+
}, delay * 1000);
|
|
79
|
+
return () => clearTimeout(timer);
|
|
80
|
+
}, [currentStep, context, step]);
|
|
81
|
+
const innerStatus = getCurrentStatus(step, visualCurrentStep, status);
|
|
82
|
+
const _widthPerStep = context?.steps ? 100 / context?.steps : undefined;
|
|
83
|
+
return (<Fragment>
|
|
84
|
+
<div className={`hidden h-step-connector-h w-full bg-card-border first:hidden xl:block ${innerStatus === "active" || innerStatus === "complete" ? "bg-success" : ""}`}/>
|
|
85
|
+
<motion.button {...props} type="button" data-step={step} animate={innerStatus} className="relative flex w-auto items-center justify-center text-center">
|
|
86
|
+
<motion.div variants={variants} transition={transitions} className={`absolute inset-0 hidden rounded-full text-center xl:block ${innerStatus === "error" ? "bg-danger" : ""}`}/>
|
|
87
|
+
<motion.div initial={false} animate={innerStatus} transition={transition} className="relative flex aspect-square size-step-size items-center justify-center rounded-full font-medium" variants={{
|
|
88
|
+
error: {
|
|
89
|
+
color: parser("var(--danger-foreground)"),
|
|
90
|
+
borderColor: parser("var(--danger-hover)"),
|
|
91
|
+
backgroundColor: parser("var(--danger-DEFAULT)"),
|
|
92
|
+
},
|
|
93
|
+
inactive: {
|
|
94
|
+
transition,
|
|
95
|
+
color: parser("var(--disabled)"),
|
|
96
|
+
borderColor: parser("var(--card-border)"),
|
|
97
|
+
backgroundColor: parser("var(--background)"),
|
|
98
|
+
},
|
|
99
|
+
active: {
|
|
100
|
+
transition,
|
|
101
|
+
color: parser("var(--primary-foreground)"),
|
|
102
|
+
borderColor: parser("var(--primary-DEFAULT)"),
|
|
103
|
+
backgroundColor: parser("var(--primary-DEFAULT)"),
|
|
104
|
+
},
|
|
105
|
+
complete: {
|
|
106
|
+
transition,
|
|
107
|
+
color: parser("var(--success-foreground)"),
|
|
108
|
+
borderColor: parser("var(--success-DEFAULT)"),
|
|
109
|
+
backgroundColor: parser("var(--success-DEFAULT)"),
|
|
110
|
+
},
|
|
111
|
+
}}>
|
|
112
|
+
<div className="flex items-center justify-center">
|
|
113
|
+
{innerStatus === "complete" ? (<CheckIcon className="size-step-icon-size text-primary-foreground"/>) : innerStatus === "error" ? (<ErrorIcon className="size-step-icon-size text-danger-foreground"/>) : (<Fragment>
|
|
114
|
+
<span>{step}</span>
|
|
115
|
+
</Fragment>)}
|
|
116
|
+
</div>
|
|
117
|
+
</motion.div>
|
|
118
|
+
<header className="flex flex-col items-start justify-start px-step-label-px">
|
|
119
|
+
<h3 className={`flex h-full items-center whitespace-nowrap font-normal ${titleClassName}`}>{title}</h3>
|
|
120
|
+
</header>
|
|
121
|
+
</motion.button>
|
|
122
|
+
</Fragment>);
|
|
123
|
+
};
|
|
124
|
+
export const Steps = (props) => {
|
|
125
|
+
const previousStepRef = useRef(props.currentStep);
|
|
126
|
+
const [previousStep, setPreviousStep] = useState(props.currentStep);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
previousStepRef.current = previousStep;
|
|
129
|
+
const timer = setTimeout(() => {
|
|
130
|
+
setPreviousStep(props.currentStep);
|
|
131
|
+
}, PROGRESS_BAR_DURATION * 1000);
|
|
132
|
+
return () => clearTimeout(timer);
|
|
133
|
+
}, [props.currentStep, previousStep]);
|
|
134
|
+
const contextValue = {
|
|
135
|
+
currentStep: props.currentStep,
|
|
136
|
+
previousStep: previousStepRef.current,
|
|
137
|
+
progressBarDuration: PROGRESS_BAR_DURATION,
|
|
138
|
+
steps: React.Children.count(props.children),
|
|
139
|
+
};
|
|
140
|
+
return (<StepContext.Provider value={contextValue}>
|
|
141
|
+
<div className="relative flex w-full flex-col items-start justify-center gap-step-gap lg:flex-row lg:items-center lg:justify-between">
|
|
142
|
+
{props.children}
|
|
143
|
+
</div>
|
|
144
|
+
</StepContext.Provider>);
|
|
145
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
import { CardProps } from "./card";
|
|
4
|
+
export type TabsProps = Omit<CardProps<"div">, "onChange"> & {
|
|
5
|
+
active: string;
|
|
6
|
+
container?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
onChange?: (id: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const Tabs: (props: PropsWithChildren<TabsProps>) => React.JSX.Element;
|
|
11
|
+
type CommonTabProps = {
|
|
12
|
+
id: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type TabProps = CommonTabProps & ({
|
|
16
|
+
title: string;
|
|
17
|
+
label?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
label: string;
|
|
20
|
+
title: Omit<Label, string>;
|
|
21
|
+
});
|
|
22
|
+
export declare const Tab: (props: PropsWithChildren<TabProps>) => React.JSX.Element | null;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/components/display/tabs.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAiC,MAAM,OAAO,CAAC;AAM/F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAQ,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AA2CF,eAAO,MAAM,IAAI,GAAI,OAAO,iBAAiB,CAAC,SAAS,CAAC,sBAiGvD,CAAC;AAIF,KAAK,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzD,MAAM,MAAM,QAAQ,GAAG,cAAc,GACjC,CACM;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GACpC;IACI,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC9B,CACN,CAAC;AAEN,eAAO,MAAM,GAAG,GAAI,OAAO,iBAAiB,CAAC,QAAQ,CAAC,6BAQrD,CAAC"}
|