@g4rcez/components 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/SKILL.md +266 -0
- package/dist/ai/docs/Alert.md +167 -0
- package/dist/ai/docs/AnimatedList.md +205 -0
- package/dist/ai/docs/Autocomplete.md +225 -0
- package/dist/ai/docs/Button.md +182 -0
- package/dist/ai/docs/Calendar.md +219 -0
- package/dist/ai/docs/Card.md +174 -0
- package/dist/ai/docs/Checkbox.md +199 -0
- package/dist/ai/docs/CommandPalette.md +293 -0
- package/dist/ai/docs/DatePicker.md +171 -0
- package/dist/ai/docs/Dropdown.md +223 -0
- package/dist/ai/docs/Empty.md +163 -0
- package/dist/ai/docs/Expand.md +143 -0
- package/dist/ai/docs/FileUpload.md +225 -0
- package/dist/ai/docs/Form.md +107 -0
- package/dist/ai/docs/FormReset.md +117 -0
- package/dist/ai/docs/Heading.md +88 -0
- package/dist/ai/docs/Input.md +237 -0
- package/dist/ai/docs/InputField.md +170 -0
- package/dist/ai/docs/List.md +205 -0
- package/dist/ai/docs/Menu.md +166 -0
- package/dist/ai/docs/Modal.md +280 -0
- package/dist/ai/docs/MultiSelect.md +196 -0
- package/dist/ai/docs/Notifications.md +231 -0
- package/dist/ai/docs/PageCalendar.md +271 -0
- package/dist/ai/docs/Polymorph.md +159 -0
- package/dist/ai/docs/Progress.md +145 -0
- package/dist/ai/docs/Radiobox.md +128 -0
- package/dist/ai/docs/RenderOnView.md +138 -0
- package/dist/ai/docs/Resizable.md +159 -0
- package/dist/ai/docs/Select.md +284 -0
- package/dist/ai/docs/Shortcut.md +105 -0
- package/dist/ai/docs/Skeleton.md +166 -0
- package/dist/ai/docs/Slider.md +144 -0
- package/dist/ai/docs/Slot.md +173 -0
- package/dist/ai/docs/Spinner.md +118 -0
- package/dist/ai/docs/Stats.md +137 -0
- package/dist/ai/docs/Step.md +159 -0
- package/dist/ai/docs/Switch.md +167 -0
- package/dist/ai/docs/Table.md +298 -0
- package/dist/ai/docs/Tabs.md +191 -0
- package/dist/ai/docs/Tag.md +224 -0
- package/dist/ai/docs/TaskList.md +144 -0
- package/dist/ai/docs/Textarea.md +167 -0
- package/dist/ai/docs/Timeline.md +210 -0
- package/dist/ai/docs/Toolbar.md +132 -0
- package/dist/ai/docs/Tooltip.md +231 -0
- package/dist/ai/docs/TransferList.md +142 -0
- package/dist/ai/docs/Typography.md +187 -0
- package/dist/ai/docs/Wizard.md +213 -0
- package/dist/ai/docs/index.md +183 -0
- package/dist/components/core/tag.d.ts +1 -1
- package/dist/components/core/tag.d.ts.map +1 -1
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/floating/dropdown.d.ts +1 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/menu.d.ts.map +1 -1
- package/dist/config/default-translations.d.ts +4 -4
- package/dist/hooks/use-translations.d.ts +4 -4
- package/dist/hooks/use-translations.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +28 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2463 -2458
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +12 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/dist/components/core/button.jsx +0 -79
- package/dist/components/core/heading.jsx +0 -4
- package/dist/components/core/polymorph.jsx +0 -5
- package/dist/components/core/render-on-view.jsx +0 -31
- package/dist/components/core/resizable.jsx +0 -51
- package/dist/components/core/slot.jsx +0 -156
- package/dist/components/core/tag.jsx +0 -51
- package/dist/components/core/typography.jsx +0 -22
- package/dist/components/display/alert.jsx +0 -58
- package/dist/components/display/calendar.jsx +0 -299
- package/dist/components/display/card.jsx +0 -43
- package/dist/components/display/empty.jsx +0 -11
- package/dist/components/display/list.jsx +0 -81
- package/dist/components/display/notifications.jsx +0 -126
- package/dist/components/display/progress.jsx +0 -11
- package/dist/components/display/shortcut.jsx +0 -23
- package/dist/components/display/skeleton.jsx +0 -12
- package/dist/components/display/spinner.jsx +0 -7
- package/dist/components/display/stats.jsx +0 -20
- package/dist/components/display/step.jsx +0 -131
- package/dist/components/display/tabs.jsx +0 -98
- package/dist/components/display/timeline.jsx +0 -25
- package/dist/components/floating/command-palette.jsx +0 -194
- package/dist/components/floating/dropdown.jsx +0 -53
- package/dist/components/floating/expand.jsx +0 -44
- package/dist/components/floating/menu.jsx +0 -147
- package/dist/components/floating/modal.jsx +0 -299
- package/dist/components/floating/toolbar.jsx +0 -5
- package/dist/components/floating/tooltip.jsx +0 -58
- package/dist/components/floating/wizard.jsx +0 -161
- package/dist/components/form/autocomplete.jsx +0 -279
- package/dist/components/form/checkbox.jsx +0 -12
- package/dist/components/form/date-picker.jsx +0 -115
- package/dist/components/form/file-upload.jsx +0 -133
- package/dist/components/form/form.jsx +0 -10
- package/dist/components/form/formReset.jsx +0 -17
- package/dist/components/form/free-text.jsx +0 -41
- package/dist/components/form/input-field.jsx +0 -56
- package/dist/components/form/input.jsx +0 -36
- package/dist/components/form/multi-select.jsx +0 -328
- package/dist/components/form/radiobox.jsx +0 -6
- package/dist/components/form/select.jsx +0 -42
- package/dist/components/form/slider.jsx +0 -45
- package/dist/components/form/switch.jsx +0 -46
- package/dist/components/form/task-list.jsx +0 -26
- package/dist/components/form/textarea.jsx +0 -12
- package/dist/components/form/transfer-list.jsx +0 -39
- package/dist/components/index.js +0 -45
- package/dist/components/page-calendar/calendar-header.jsx +0 -81
- package/dist/components/page-calendar/day-view.jsx +0 -87
- package/dist/components/page-calendar/event-pill.jsx +0 -25
- package/dist/components/page-calendar/index.js +0 -2
- package/dist/components/page-calendar/month-view.jsx +0 -47
- package/dist/components/page-calendar/page-calendar.jsx +0 -41
- package/dist/components/page-calendar/page-calendar.types.js +0 -1
- package/dist/components/page-calendar/page-calendar.utils.js +0 -71
- package/dist/components/page-calendar/week-view.jsx +0 -64
- package/dist/components/table/filter.jsx +0 -141
- package/dist/components/table/group.jsx +0 -68
- package/dist/components/table/index.jsx +0 -60
- package/dist/components/table/inner-table.jsx +0 -104
- package/dist/components/table/metadata.jsx +0 -36
- package/dist/components/table/pagination.jsx +0 -73
- package/dist/components/table/row.jsx +0 -58
- package/dist/components/table/sort.jsx +0 -105
- package/dist/components/table/table-lib.js +0 -83
- package/dist/components/table/table.context.jsx +0 -4
- package/dist/components/table/thead.jsx +0 -103
- package/dist/config/context.js +0 -12
- package/dist/config/default-translations.jsx +0 -83
- package/dist/config/default-tweaks.js +0 -4
- package/dist/constants.js +0 -2
- package/dist/hooks/use-click-outside.js +0 -17
- package/dist/hooks/use-color-parser.js +0 -9
- package/dist/hooks/use-components-provider.jsx +0 -19
- package/dist/hooks/use-debounce.js +0 -12
- package/dist/hooks/use-floating-ref.js +0 -6
- package/dist/hooks/use-form.js +0 -550
- package/dist/hooks/use-hover.js +0 -18
- package/dist/hooks/use-input-id.js +0 -5
- package/dist/hooks/use-is-coarse-device.js +0 -12
- package/dist/hooks/use-locale.js +0 -10
- package/dist/hooks/use-media-query.js +0 -25
- package/dist/hooks/use-on-event.js +0 -7
- package/dist/hooks/use-parent.js +0 -21
- package/dist/hooks/use-preferences.js +0 -23
- package/dist/hooks/use-previous.js +0 -9
- package/dist/hooks/use-reactive.js +0 -9
- package/dist/hooks/use-remove-scroll.js +0 -61
- package/dist/hooks/use-resize-observer.js +0 -17
- package/dist/hooks/use-stable-ref.js +0 -9
- package/dist/hooks/use-swipe.js +0 -17
- package/dist/hooks/use-translations.js +0 -9
- package/dist/hooks/use-tweaks.js +0 -9
- package/dist/hooks/use-window-size.js +0 -14
- package/dist/lib/combi-keys.js +0 -60
- package/dist/lib/dict.js +0 -39
- package/dist/lib/dom.js +0 -62
- package/dist/lib/fns.js +0 -46
- package/dist/lib/fzf.js +0 -117
- package/dist/lib/keyboard-area.js +0 -14
- package/dist/styles/common.js +0 -29
- package/dist/styles/dark.js +0 -214
- package/dist/styles/design-tokens.js +0 -69
- package/dist/styles/light.js +0 -214
- package/dist/styles/theme.js +0 -4
- package/dist/styles/theme.types.js +0 -1
- package/dist/types.js +0 -1
|
@@ -1,131 +0,0 @@
|
|
|
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 = { duration: PROGRESS_BAR_DURATION, type: "tween", ease: "easeInOut" };
|
|
7
|
-
const StepContext = createContext(null);
|
|
8
|
-
const iconTransitions = { delay: 0.2, duration: 0.3, type: "tween", ease: "easeOut" };
|
|
9
|
-
const states = {
|
|
10
|
-
initial: { pathLength: 0, opacity: 0 },
|
|
11
|
-
animate: { pathLength: 1, opacity: 1 },
|
|
12
|
-
};
|
|
13
|
-
const ErrorIcon = (props) => (<svg {...props} viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
14
|
-
<motion.path className="currentColor" initial={states.initial} animate={states.animate} transition={iconTransitions} d="M18 6 6 18"/>
|
|
15
|
-
<motion.path className="currentColor" initial={states.initial} animate={states.animate} transition={iconTransitions} d="m6 6 12 12"/>
|
|
16
|
-
</svg>);
|
|
17
|
-
const CheckIcon = (props) => (<svg {...props} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={3}>
|
|
18
|
-
<motion.path d="M5 13l4 4L19 7" strokeLinecap="round" strokeLinejoin="round" animate={states.animate} initial={states.initial} transition={iconTransitions}/>
|
|
19
|
-
</svg>);
|
|
20
|
-
const variants = {
|
|
21
|
-
complete: { scale: 1.25 },
|
|
22
|
-
active: { scale: 1, transition: { delay: 0, duration: 0.3 } },
|
|
23
|
-
};
|
|
24
|
-
const transitions = { duration: 0.6, delay: 0.2, type: "tween", ease: "circOut" };
|
|
25
|
-
const getCurrentStatus = (step, currentStep, status) => {
|
|
26
|
-
if (status === "error")
|
|
27
|
-
return "error";
|
|
28
|
-
if (currentStep === step)
|
|
29
|
-
return "active";
|
|
30
|
-
if (currentStep < step)
|
|
31
|
-
return "inactive";
|
|
32
|
-
return "complete";
|
|
33
|
-
};
|
|
34
|
-
const calculateStepDelay = (step, currentStep, previousStep, duration) => {
|
|
35
|
-
if (currentStep === previousStep)
|
|
36
|
-
return 0;
|
|
37
|
-
const isForward = currentStep > previousStep;
|
|
38
|
-
if (isForward) {
|
|
39
|
-
if (step <= previousStep || step > currentStep)
|
|
40
|
-
return 0;
|
|
41
|
-
return ((step - previousStep) / (currentStep - previousStep)) * duration;
|
|
42
|
-
}
|
|
43
|
-
if (step <= currentStep || step > previousStep)
|
|
44
|
-
return 0;
|
|
45
|
-
return ((previousStep - step) / (previousStep - currentStep)) * duration;
|
|
46
|
-
};
|
|
47
|
-
export const useStepContext = () => useContext(StepContext);
|
|
48
|
-
export const Step = ({ step, currentStep, status, title, titleClassName, ...props }) => {
|
|
49
|
-
const parser = useColorParser();
|
|
50
|
-
const context = useStepContext();
|
|
51
|
-
const [visualCurrentStep, setVisualCurrentStep] = useState(currentStep);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (!context) {
|
|
54
|
-
setVisualCurrentStep(currentStep);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const delay = calculateStepDelay(step, context.currentStep, context.previousStep, context.progressBarDuration);
|
|
58
|
-
if (delay === 0) {
|
|
59
|
-
setVisualCurrentStep(currentStep);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const timer = setTimeout(() => {
|
|
63
|
-
setVisualCurrentStep(currentStep);
|
|
64
|
-
}, delay * 1000);
|
|
65
|
-
return () => clearTimeout(timer);
|
|
66
|
-
}, [currentStep, context, step]);
|
|
67
|
-
const innerStatus = getCurrentStatus(step, visualCurrentStep, status);
|
|
68
|
-
const widthPerStep = context?.steps ? 100 / context?.steps : undefined;
|
|
69
|
-
return (<Fragment>
|
|
70
|
-
<div className={`hidden h-[2px] w-full bg-card-border first:hidden xl:block ${innerStatus === "active" || innerStatus === "complete" ? "bg-success" : ""}`}/>
|
|
71
|
-
<motion.button {...props} type="button" data-step={step} animate={innerStatus} className="relative flex w-auto items-center justify-center text-center">
|
|
72
|
-
<motion.div variants={variants} transition={transitions} className={`absolute inset-0 hidden rounded-full text-center xl:block ${innerStatus === "error" ? "bg-danger" : ""}`}/>
|
|
73
|
-
<motion.div initial={false} animate={innerStatus} transition={transition} className="relative flex aspect-square size-10 items-center justify-center rounded-full font-semibold" variants={{
|
|
74
|
-
error: {
|
|
75
|
-
color: parser("var(--danger-foreground)"),
|
|
76
|
-
borderColor: parser("var(--danger-hover)"),
|
|
77
|
-
backgroundColor: parser("var(--danger-DEFAULT)"),
|
|
78
|
-
},
|
|
79
|
-
inactive: {
|
|
80
|
-
transition,
|
|
81
|
-
color: parser("var(--disabled)"),
|
|
82
|
-
borderColor: parser("var(--card-border)"),
|
|
83
|
-
backgroundColor: parser("var(--background)"),
|
|
84
|
-
},
|
|
85
|
-
active: {
|
|
86
|
-
transition,
|
|
87
|
-
color: parser("var(--primary-foreground)"),
|
|
88
|
-
borderColor: parser("var(--primary-DEFAULT)"),
|
|
89
|
-
backgroundColor: parser("var(--primary-DEFAULT)"),
|
|
90
|
-
},
|
|
91
|
-
complete: {
|
|
92
|
-
transition,
|
|
93
|
-
color: parser("var(--success-foreground)"),
|
|
94
|
-
borderColor: parser("var(--success-DEFAULT)"),
|
|
95
|
-
backgroundColor: parser("var(--success-DEFAULT)"),
|
|
96
|
-
},
|
|
97
|
-
}}>
|
|
98
|
-
<div className="flex items-center justify-center">
|
|
99
|
-
{innerStatus === "complete" ? (<CheckIcon className="size-6 text-primary-foreground"/>) : innerStatus === "error" ? (<ErrorIcon className="size-6 text-danger-foreground"/>) : (<Fragment>
|
|
100
|
-
<span>{step}</span>
|
|
101
|
-
</Fragment>)}
|
|
102
|
-
</div>
|
|
103
|
-
</motion.div>
|
|
104
|
-
<header className="flex flex-col items-start justify-start px-2">
|
|
105
|
-
<h3 className={`flex h-full items-center whitespace-nowrap ${titleClassName}`}>{title}</h3>
|
|
106
|
-
</header>
|
|
107
|
-
</motion.button>
|
|
108
|
-
</Fragment>);
|
|
109
|
-
};
|
|
110
|
-
export const Steps = (props) => {
|
|
111
|
-
const previousStepRef = useRef(props.currentStep);
|
|
112
|
-
const [previousStep, setPreviousStep] = useState(props.currentStep);
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
previousStepRef.current = previousStep;
|
|
115
|
-
const timer = setTimeout(() => {
|
|
116
|
-
setPreviousStep(props.currentStep);
|
|
117
|
-
}, PROGRESS_BAR_DURATION * 1000);
|
|
118
|
-
return () => clearTimeout(timer);
|
|
119
|
-
}, [props.currentStep, previousStep]);
|
|
120
|
-
const contextValue = {
|
|
121
|
-
currentStep: props.currentStep,
|
|
122
|
-
previousStep: previousStepRef.current,
|
|
123
|
-
progressBarDuration: PROGRESS_BAR_DURATION,
|
|
124
|
-
steps: React.Children.count(props.children),
|
|
125
|
-
};
|
|
126
|
-
return (<StepContext.Provider value={contextValue}>
|
|
127
|
-
<div className="relative flex w-full flex-col items-start justify-center gap-4 lg:flex-row lg:items-center lg:justify-between">
|
|
128
|
-
{props.children}
|
|
129
|
-
</div>
|
|
130
|
-
</StepContext.Provider>);
|
|
131
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { createContext, Fragment, useContext, useEffect, useRef } from "react";
|
|
3
|
-
import { Is } from "sidekicker";
|
|
4
|
-
import { useReactive } from "../../hooks/use-reactive";
|
|
5
|
-
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
6
|
-
import { css } from "../../lib/dom";
|
|
7
|
-
import { keyboardKeys } from "../../lib/keyboard-area";
|
|
8
|
-
import { Polymorph } from "../core/polymorph";
|
|
9
|
-
import { Card } from "./card";
|
|
10
|
-
const Context = createContext("");
|
|
11
|
-
const isElementDisabled = (element) => element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true";
|
|
12
|
-
const getNElement = (elements, currentIndex, direction) => {
|
|
13
|
-
const step = direction === "forward" ? 1 : -1;
|
|
14
|
-
const startIndex = currentIndex + step;
|
|
15
|
-
for (let i = startIndex; i >= 0 && i < elements.length; i += step) {
|
|
16
|
-
const element = elements[i];
|
|
17
|
-
if (!isElementDisabled(element))
|
|
18
|
-
return element;
|
|
19
|
-
}
|
|
20
|
-
return direction === "backward" ? getNElement(elements, elements.length - 1, "backward") : getNElement(elements, -1, "forward");
|
|
21
|
-
};
|
|
22
|
-
const moveOn = (ul, direction) => {
|
|
23
|
-
const items = Array.from(ul.querySelectorAll("li"));
|
|
24
|
-
const find = items.findIndex((x) => x.dataset.active === "true");
|
|
25
|
-
if (find === -1)
|
|
26
|
-
return null;
|
|
27
|
-
const item = getNElement(items, find, direction);
|
|
28
|
-
if (item === null)
|
|
29
|
-
return null;
|
|
30
|
-
item.querySelector("button")?.focus({ preventScroll: false });
|
|
31
|
-
return item.getAttribute("data-id") || "";
|
|
32
|
-
};
|
|
33
|
-
const actionKeys = {
|
|
34
|
-
[keyboardKeys.ArrowLeft]: (_, ul) => moveOn(ul, "backward"),
|
|
35
|
-
[keyboardKeys.ArrowRight]: (_, ul) => moveOn(ul, "forward"),
|
|
36
|
-
};
|
|
37
|
-
export const Tabs = (props) => {
|
|
38
|
-
const [active, setActive] = useReactive(props.active);
|
|
39
|
-
const ref = useRef(null);
|
|
40
|
-
const onChangeRef = useStableRef(props.onChange);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
const header = ref.current;
|
|
43
|
-
if (header === null)
|
|
44
|
-
return;
|
|
45
|
-
let first = header.querySelector(`li[data-active=true]`);
|
|
46
|
-
if (first === null) {
|
|
47
|
-
first = header.querySelector(`li[data-id]`);
|
|
48
|
-
const id = first.getAttribute("data-id") || "";
|
|
49
|
-
setActive(id);
|
|
50
|
-
}
|
|
51
|
-
}, [props.active, setActive]);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (onChangeRef.current)
|
|
54
|
-
onChangeRef.current(active);
|
|
55
|
-
}, [onChangeRef, active]);
|
|
56
|
-
const items = React.Children.toArray(props.children);
|
|
57
|
-
const onClick = (e) => {
|
|
58
|
-
const anchor = e.currentTarget;
|
|
59
|
-
setActive(anchor.dataset.id || "");
|
|
60
|
-
};
|
|
61
|
-
const onKeyDown = (e) => {
|
|
62
|
-
if (ref.current === null)
|
|
63
|
-
return;
|
|
64
|
-
const k = e.key;
|
|
65
|
-
if (Is.keyof(actionKeys, k)) {
|
|
66
|
-
const fn = actionKeys[k];
|
|
67
|
-
const result = fn(e, ref.current);
|
|
68
|
-
if (result === null)
|
|
69
|
-
return;
|
|
70
|
-
setActive(result);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
return (<Context.Provider value={active}>
|
|
74
|
-
<Card className={props.className} container={css("pt-0 max-w-full w-full min-w-0", props.container)} header={<header className="relative mb-2 overflow-x-auto">
|
|
75
|
-
<div className="absolute bottom-0 h-[1px] w-full bg-card-border"/>
|
|
76
|
-
<nav className="min-w-0">
|
|
77
|
-
<ul onKeyDown={onKeyDown} ref={ref} className="flex w-0 min-w-full flex-1 justify-start overflow-x-auto">
|
|
78
|
-
{items.map((x) => {
|
|
79
|
-
const inner = x.props;
|
|
80
|
-
const current = active === inner.id;
|
|
81
|
-
return (<li data-id={inner.id} data-active={current} key={`tab-header-${inner.id}`} aria-disabled={inner.disabled} className={css("relative w-fit border-b border-transparent transition-all", current ? "border-primary font-medium text-primary" : "", inner.disabled ? "aria-disabled:text-disabled" : "")}>
|
|
82
|
-
<Polymorph as="button" type="button" data-id={inner.id} aria-current="page" disabled={inner.disabled} onClick={inner.disabled ? undefined : onClick} className="block w-full whitespace-nowrap px-10 py-4 disabled:cursor-not-allowed">
|
|
83
|
-
{inner.title}
|
|
84
|
-
</Polymorph>
|
|
85
|
-
</li>);
|
|
86
|
-
})}
|
|
87
|
-
</ul>
|
|
88
|
-
</nav>
|
|
89
|
-
</header>}>
|
|
90
|
-
{props.children}
|
|
91
|
-
</Card>
|
|
92
|
-
</Context.Provider>);
|
|
93
|
-
};
|
|
94
|
-
const useTabs = () => useContext(Context);
|
|
95
|
-
export const Tab = (props) => {
|
|
96
|
-
const active = useTabs();
|
|
97
|
-
return <Fragment>{props.id === active ? props.children : null}</Fragment>;
|
|
98
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { css } from "../../lib/dom";
|
|
3
|
-
import { Polymorph } from "../core/polymorph";
|
|
4
|
-
export const TimelineItem = (props) => (<li data-component="timeline-item" className="relative pb-12" role="listitem">
|
|
5
|
-
<span aria-hidden="true" className="absolute left-6 top-8 -ml-px h-full w-0.5 bg-card-border"/>
|
|
6
|
-
<div className="relative flex items-stretch justify-start space-x-3">{props.children}</div>
|
|
7
|
-
</li>);
|
|
8
|
-
TimelineItem.Icon = function TimelineIcon(props) {
|
|
9
|
-
return (<header {...props} className={css("flex size-12 items-center justify-center rounded-full bg-primary p-2 text-warn-foreground", props.className)}>
|
|
10
|
-
{props.children}
|
|
11
|
-
</header>);
|
|
12
|
-
};
|
|
13
|
-
TimelineItem.Body = function TimelineItemBody(props) {
|
|
14
|
-
return (<Polymorph {...props} className={css("min-w-0 flex-1", props.className)}>
|
|
15
|
-
{props.children}
|
|
16
|
-
</Polymorph>);
|
|
17
|
-
};
|
|
18
|
-
TimelineItem.Right = function TimelineItemRight(props) {
|
|
19
|
-
return (<footer className="flex gap-6 self-stretch px-4 align-baseline">
|
|
20
|
-
<Polymorph {...props} type="button"/>
|
|
21
|
-
</footer>);
|
|
22
|
-
};
|
|
23
|
-
export const Timeline = (props) => (<ul data-component="timeline" role="list" className="flow-root [&>li:last-child>span[aria-hidden=true]]:hidden">
|
|
24
|
-
{props.children}
|
|
25
|
-
</ul>);
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { autoUpdate, useFloating, useInteractions, useListNavigation } from "@floating-ui/react";
|
|
3
|
-
import { FilterIcon } from "lucide-react";
|
|
4
|
-
import React, { forwardRef, Fragment, useEffect, useId, useRef, useState } from "react";
|
|
5
|
-
import { Is } from "sidekicker";
|
|
6
|
-
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
7
|
-
import { useTranslations } from "../../hooks/use-translations";
|
|
8
|
-
import { CombiKeys } from "../../lib/combi-keys";
|
|
9
|
-
import { Dict } from "../../lib/dict";
|
|
10
|
-
import { css, isChildVisible, isReactFC } from "../../lib/dom";
|
|
11
|
-
import { fzf } from "../../lib/fzf";
|
|
12
|
-
import { Shortcut } from "../display/shortcut";
|
|
13
|
-
import { SkeletonCell } from "../display/skeleton";
|
|
14
|
-
import { Modal } from "./modal";
|
|
15
|
-
const Group = (props) => (<span className="flex h-full items-center text-left text-sm font-medium text-secondary">
|
|
16
|
-
{isReactFC(props.item.title) ? <props.item.title text={props.text}/> : props.item.title}
|
|
17
|
-
</span>);
|
|
18
|
-
const Item = forwardRef((props, ref) => {
|
|
19
|
-
const id = useId();
|
|
20
|
-
const active = props.active;
|
|
21
|
-
const item = props.item;
|
|
22
|
-
if (item.type === "group")
|
|
23
|
-
return (<div id={id} className="h-10 px-2 pb-1 pt-2">
|
|
24
|
-
<Group text={props.text} item={item}/>
|
|
25
|
-
</div>);
|
|
26
|
-
if (item.type !== "shortcut")
|
|
27
|
-
return <Fragment />;
|
|
28
|
-
return (<button {...props} id={id} ref={ref} role="option" type="button" aria-selected={active} data-component="command-palette-item" className={css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-floating-hover", active ? "bg-floating-hover" : "")}>
|
|
29
|
-
<span className="flex items-center gap-2">
|
|
30
|
-
{item.Icon ? item.Icon : null}
|
|
31
|
-
<span>{isReactFC(item.title) ? <item.title text={props.text}/> : item.title}</span>
|
|
32
|
-
</span>
|
|
33
|
-
{item.shortcut ? <Shortcut value={item.shortcut}/> : null}
|
|
34
|
-
</button>);
|
|
35
|
-
});
|
|
36
|
-
const getFuzzyData = (commands, value) => {
|
|
37
|
-
if (value.length === 0)
|
|
38
|
-
return commands;
|
|
39
|
-
const rules = [
|
|
40
|
-
{ key: "title", value },
|
|
41
|
-
{ key: "shortcut", value },
|
|
42
|
-
{ key: "hint", value },
|
|
43
|
-
];
|
|
44
|
-
const normalize = commands.map((x) => ({ ...x, title: Is.function(x.title) ? x.title({ text: value }) : x.title }));
|
|
45
|
-
const target = normalize.reduce((acc, x) => {
|
|
46
|
-
const enabled = Is.function(x.enabled) ? x.enabled({ text: value }) : (x.enabled ?? true);
|
|
47
|
-
if (enabled)
|
|
48
|
-
acc.push({ ...x, enabled: enabled });
|
|
49
|
-
return acc;
|
|
50
|
-
}, []);
|
|
51
|
-
const filter = fzf(target, "title", rules);
|
|
52
|
-
const withEnabled = normalize.filter((x) => (Is.function(x.enabled) ? x.enabled({ text: value }) : false));
|
|
53
|
-
return Dict.unique(filter.concat(withEnabled), (x) => x.title);
|
|
54
|
-
};
|
|
55
|
-
const loadingSkeleton = [0, 0, 0, 0, 0];
|
|
56
|
-
const findFirstClickable = (items) => {
|
|
57
|
-
for (let index = 0; index < items.length; index++) {
|
|
58
|
-
const element = items[index];
|
|
59
|
-
if (element.type === "shortcut")
|
|
60
|
-
return element;
|
|
61
|
-
const recursive = findFirstClickable(element.items);
|
|
62
|
-
if (recursive)
|
|
63
|
-
return recursive;
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
};
|
|
67
|
-
export const CommandPalette = (props) => {
|
|
68
|
-
const id = useId();
|
|
69
|
-
const scrollContainerRef = useRef(null);
|
|
70
|
-
const [text, setText] = useState("");
|
|
71
|
-
const listRef = useRef([]);
|
|
72
|
-
const translations = useTranslations();
|
|
73
|
-
const valueRef = useStableRef(text);
|
|
74
|
-
const [activeIndex, setActiveIndex] = useState(null);
|
|
75
|
-
const bindKey = props.bind ?? "Mod + k";
|
|
76
|
-
const root = useFloating({
|
|
77
|
-
open: props.open,
|
|
78
|
-
strategy: "absolute",
|
|
79
|
-
whileElementsMounted: autoUpdate,
|
|
80
|
-
onOpenChange: props.onChangeVisibility,
|
|
81
|
-
});
|
|
82
|
-
const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
|
|
83
|
-
const fuzzy = getFuzzyData(commands, text);
|
|
84
|
-
const displayItems = text === ""
|
|
85
|
-
? commands
|
|
86
|
-
: [
|
|
87
|
-
{
|
|
88
|
-
type: "group",
|
|
89
|
-
title: "Results",
|
|
90
|
-
items: [],
|
|
91
|
-
},
|
|
92
|
-
...fuzzy.filter((x) => x.type !== "group"),
|
|
93
|
-
];
|
|
94
|
-
const listNav = useListNavigation(root.context, {
|
|
95
|
-
listRef,
|
|
96
|
-
loop: true,
|
|
97
|
-
activeIndex,
|
|
98
|
-
virtual: true,
|
|
99
|
-
allowEscape: false,
|
|
100
|
-
focusItemOnOpen: true,
|
|
101
|
-
focusItemOnHover: true,
|
|
102
|
-
openOnArrowKeyDown: true,
|
|
103
|
-
scrollItemIntoView: false,
|
|
104
|
-
selectedIndex: activeIndex,
|
|
105
|
-
disabledIndices: (n) => {
|
|
106
|
-
const item = displayItems[n];
|
|
107
|
-
if (item)
|
|
108
|
-
return item.type === "group";
|
|
109
|
-
return false;
|
|
110
|
-
},
|
|
111
|
-
onNavigate: (n) => {
|
|
112
|
-
if (Is.number(n)) {
|
|
113
|
-
if (!isChildVisible(scrollContainerRef.current, listRef.current[n]))
|
|
114
|
-
listRef.current[n]?.scrollIntoView({ block: "start", inline: "start" });
|
|
115
|
-
}
|
|
116
|
-
setActiveIndex((prev) => {
|
|
117
|
-
if (Is.number(n))
|
|
118
|
-
return n;
|
|
119
|
-
return props.open ? (prev ?? 0) : null;
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
const { getItemProps, getReferenceProps, getFloatingProps } = useInteractions([listNav]);
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
const combi = new CombiKeys();
|
|
126
|
-
combi.add(bindKey, () => props.onChangeVisibility?.(true));
|
|
127
|
-
commands.forEach((cmd) => {
|
|
128
|
-
if (cmd.type === "group")
|
|
129
|
-
return;
|
|
130
|
-
if (cmd.type === "shortcut" && cmd.shortcut !== undefined)
|
|
131
|
-
combi.add(cmd.shortcut, (event) => cmd.action({
|
|
132
|
-
event,
|
|
133
|
-
setText,
|
|
134
|
-
text: valueRef.current,
|
|
135
|
-
setOpen: props.onChangeVisibility,
|
|
136
|
-
}));
|
|
137
|
-
});
|
|
138
|
-
return combi.register();
|
|
139
|
-
}, [bindKey, commands, props, valueRef]);
|
|
140
|
-
const Icon = props.Icon ?? FilterIcon;
|
|
141
|
-
return (<Fragment>
|
|
142
|
-
<Modal {...getFloatingProps()} animated={false} closable={false} open={props.open} overlayClickClose ariaTitle="Command palette" bodyClassName="px-0 py-0 pt-0" data-component="command-palette" onChange={props.onChangeVisibility} className="container relative overflow-clip py-0 md:max-w-screen-sm lg:max-w-screen-md">
|
|
143
|
-
<header className="sticky top-0 isolate z-floating flex h-12 w-full items-center overflow-clip border-b border-floating-border bg-floating-background">
|
|
144
|
-
<div className="flex size-10 items-center justify-center">
|
|
145
|
-
{props.Icon ? <Icon Default={FilterIcon} text={text} size={16}/> : <FilterIcon size={16}/>}
|
|
146
|
-
</div>
|
|
147
|
-
<input {...getReferenceProps({
|
|
148
|
-
ref: root.refs.setReference,
|
|
149
|
-
onKeyDown: (e) => {
|
|
150
|
-
const item = Is.number(activeIndex) ? displayItems[activeIndex] : null;
|
|
151
|
-
const key = e.key;
|
|
152
|
-
if (key === "Enter") {
|
|
153
|
-
if (item) {
|
|
154
|
-
if (item.type === "shortcut")
|
|
155
|
-
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
const item = findFirstClickable(fuzzy);
|
|
159
|
-
if (item?.type === "shortcut")
|
|
160
|
-
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
})} autoFocus value={text} data-combikeysbypass="true" placeholder="Search for..." onChange={(e) => setText(e.target.value)} className="h-12 w-full items-center bg-transparent px-2 py-2 pb-2 text-left text-lg outline-none"/>
|
|
165
|
-
</header>
|
|
166
|
-
{props.loading ? (<ul role="listbox" data-component="command-palette-list" className="my-2 flex max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2">
|
|
167
|
-
<div className="h-10 px-2 pb-1 pt-2">{translations.commandPaletteLoading}</div>
|
|
168
|
-
{loadingSkeleton.map((_, i) => (<li key={`${id}-${i}-skeleton-index`} className={css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-primary hover:text-primary-foreground")}>
|
|
169
|
-
{SkeletonCell}
|
|
170
|
-
</li>))}
|
|
171
|
-
</ul>) : (<div className="flex min-w-full flex-row flex-nowrap" data-component="command-palette-container">
|
|
172
|
-
<ul role="listbox" ref={scrollContainerRef} data-component="command-palette-list" className="my-2 flex h-fit max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2">
|
|
173
|
-
{displayItems.map((item, index) => (<Item {...getItemProps({
|
|
174
|
-
onMouseEnter: () => setActiveIndex(index),
|
|
175
|
-
ref(node) {
|
|
176
|
-
listRef.current[index] = node;
|
|
177
|
-
},
|
|
178
|
-
onClick(e) {
|
|
179
|
-
e.preventDefault();
|
|
180
|
-
props.onChangeVisibility(false);
|
|
181
|
-
if (item.type === "shortcut")
|
|
182
|
-
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
183
|
-
},
|
|
184
|
-
})} item={item} text={text} active={activeIndex === index} key={`${id}-${item.type}-${index}`}/>))}
|
|
185
|
-
{displayItems.length === 1 ? (<div className={css("flex items-center justify-between rounded-lg p-2 text-secondary")}>
|
|
186
|
-
{translations.commandPaletteEmpty ?? props.emptyMessage}
|
|
187
|
-
</div>) : null}
|
|
188
|
-
</ul>
|
|
189
|
-
{props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={text}/> : null}
|
|
190
|
-
</div>)}
|
|
191
|
-
{props.footer ? (<footer className="flex h-8 items-center rounded-b-lg border-t border-floating-border p-2">{props.footer}</footer>) : null}
|
|
192
|
-
</Modal>
|
|
193
|
-
</Fragment>);
|
|
194
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { arrow, autoUpdate, flip, FloatingArrow, FloatingFocusManager, FloatingPortal, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
3
|
-
import React, { Fragment, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
-
export const Dropdown = (props) => {
|
|
5
|
-
const headingId = useId();
|
|
6
|
-
const [open, setOpen] = useState(props.open);
|
|
7
|
-
useEffect(() => setOpen(props.open), [props.open]);
|
|
8
|
-
const arrowRef = useRef(null);
|
|
9
|
-
const middleware = useMemo(() => [
|
|
10
|
-
offset(10),
|
|
11
|
-
flip({ fallbackAxisSideDirection: "end" }),
|
|
12
|
-
shift(),
|
|
13
|
-
arrow({
|
|
14
|
-
padding: 5,
|
|
15
|
-
element: arrowRef,
|
|
16
|
-
}),
|
|
17
|
-
], [props.arrow]);
|
|
18
|
-
const { refs, floatingStyles, context } = useFloating({
|
|
19
|
-
open,
|
|
20
|
-
middleware,
|
|
21
|
-
transform: true,
|
|
22
|
-
whileElementsMounted: autoUpdate,
|
|
23
|
-
onOpenChange: (nextValue, event) => {
|
|
24
|
-
const element = event?.relatedTarget;
|
|
25
|
-
if (element) {
|
|
26
|
-
if (element.dataset.floating === "true" && !nextValue)
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
setOpen(nextValue);
|
|
30
|
-
props.onChange?.(nextValue);
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
const click = useClick(context);
|
|
34
|
-
const dismiss = useDismiss(context);
|
|
35
|
-
const role = useRole(context, { role: "tooltip" });
|
|
36
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
37
|
-
return (<Fragment>
|
|
38
|
-
<button ref={refs.setReference} {...getReferenceProps(props.buttonProps)} type="button">
|
|
39
|
-
{props.trigger}
|
|
40
|
-
</button>
|
|
41
|
-
{open && (<FloatingPortal preserveTabOrder id={`${headingId}-portal`}>
|
|
42
|
-
<FloatingFocusManager guards restoreFocus={true} returnFocus={true} visuallyHiddenDismiss context={context} modal={false}>
|
|
43
|
-
<div className="relative isolate z-floating min-w-96 rounded-lg border border-floating-border bg-floating-background p-4 shadow-shadow-floating" ref={refs.setFloating} aria-labelledby={headingId} style={floatingStyles} {...getFloatingProps()}>
|
|
44
|
-
<FloatingArrow ref={arrowRef} context={context} strokeWidth={0.1} className="fill-floating-background stroke-floating-border"/>
|
|
45
|
-
<header className="mb-2">
|
|
46
|
-
<h3 className="text-left text-2xl font-medium leading-snug tracking-wide">{props.title}</h3>
|
|
47
|
-
</header>
|
|
48
|
-
{props.children}
|
|
49
|
-
</div>
|
|
50
|
-
</FloatingFocusManager>
|
|
51
|
-
</FloatingPortal>)}
|
|
52
|
-
</Fragment>);
|
|
53
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { FloatingFocusManager, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole } from "@floating-ui/react";
|
|
3
|
-
import { AnimatePresence, motion } from "motion/react";
|
|
4
|
-
import { useEffect, useId, useRef, useState } from "react";
|
|
5
|
-
import { Button } from "../core/button";
|
|
6
|
-
export const Expand = (props) => {
|
|
7
|
-
const root = useRef(null);
|
|
8
|
-
const id = useId();
|
|
9
|
-
const wrapperId = `${id}:wrapper`;
|
|
10
|
-
const titleId = `${id}:title`;
|
|
11
|
-
const [open, setOpen] = useState(props.open ?? false);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
setOpen(props.open ?? false);
|
|
14
|
-
}, [props.open]);
|
|
15
|
-
const { context, refs } = useFloating({
|
|
16
|
-
transform: true,
|
|
17
|
-
open: open !== null,
|
|
18
|
-
nodeId: id,
|
|
19
|
-
onOpenChange: setOpen,
|
|
20
|
-
strategy: "absolute",
|
|
21
|
-
});
|
|
22
|
-
const click = useClick(context, { enabled: props.disabled ?? true });
|
|
23
|
-
const role = useRole(context, { role: "tooltip" });
|
|
24
|
-
const dismiss = useDismiss(context, {
|
|
25
|
-
escapeKey: true,
|
|
26
|
-
referencePress: true,
|
|
27
|
-
outsidePress: true,
|
|
28
|
-
});
|
|
29
|
-
const { getFloatingProps, getReferenceProps } = useInteractions([click, role, dismiss]);
|
|
30
|
-
return (<div className="relative inline-flex items-center justify-center" ref={root}>
|
|
31
|
-
<Button {...getReferenceProps(props)} as={motion.button} layoutId={wrapperId} ref={refs.setReference} size="small" onClick={() => setOpen(true)}>
|
|
32
|
-
<motion.span layoutId={titleId}>{props.trigger}</motion.span>
|
|
33
|
-
</Button>
|
|
34
|
-
<AnimatePresence>
|
|
35
|
-
{open ? (<FloatingPortal root={root}>
|
|
36
|
-
<FloatingFocusManager visuallyHiddenDismiss modal closeOnFocusOut context={context}>
|
|
37
|
-
<motion.div {...getFloatingProps()} ref={refs.setFloating} layoutId={wrapperId} className="absolute -left-1/4 -top-3/4">
|
|
38
|
-
{props.children}
|
|
39
|
-
</motion.div>
|
|
40
|
-
</FloatingFocusManager>
|
|
41
|
-
</FloatingPortal>) : null}
|
|
42
|
-
</AnimatePresence>
|
|
43
|
-
</div>);
|
|
44
|
-
};
|