@vllnt/ui 0.4.0-canary.shab30cb4b → 0.4.0-canary.shadc8d754

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.
@@ -8,7 +8,7 @@ function slugify(text) {
8
8
  }
9
9
  function CategoryFilter({ categories, lang }) {
10
10
  const pathname = usePathname();
11
- const allCategories = [...new Set(categories)].sort();
11
+ const allCategories = Array.from(new Set(categories)).sort();
12
12
  if (allCategories.length === 0) {
13
13
  return null;
14
14
  }
@@ -130,29 +130,6 @@ function ChecklistHeader({
130
130
  ] })
131
131
  ] });
132
132
  }
133
- function readPersistedChecklist(persistKey) {
134
- if (typeof window !== "undefined" && persistKey) {
135
- const saved = localStorage.getItem(`checklist:${persistKey}`);
136
- if (saved) {
137
- return new Set(parseChecklistStorageValue(saved));
138
- }
139
- }
140
- return /* @__PURE__ */ new Set();
141
- }
142
- function persistChecklist(persistKey, ids) {
143
- try {
144
- localStorage.setItem(
145
- `checklist:${persistKey}`,
146
- createChecklistStorageValue(ids)
147
- );
148
- window.dispatchEvent(
149
- new CustomEvent(CHECKLIST_PROGRESS_EVENT, {
150
- detail: { persistKey }
151
- })
152
- );
153
- } catch {
154
- }
155
- }
156
133
  function Checklist({
157
134
  as: Heading = "h4",
158
135
  className,
@@ -161,16 +138,33 @@ function Checklist({
161
138
  persistKey,
162
139
  title
163
140
  }) {
164
- const [checked, setChecked] = useState(
165
- () => readPersistedChecklist(persistKey)
166
- );
141
+ const [checked, setChecked] = useState(() => {
142
+ if (typeof window !== "undefined" && persistKey) {
143
+ const saved = localStorage.getItem(`checklist:${persistKey}`);
144
+ if (saved) {
145
+ return new Set(parseChecklistStorageValue(saved));
146
+ }
147
+ }
148
+ return /* @__PURE__ */ new Set();
149
+ });
167
150
  const toggleItem = (id) => {
168
151
  const newChecked = new Set(checked);
169
152
  if (newChecked.has(id)) newChecked.delete(id);
170
153
  else newChecked.add(id);
171
154
  setChecked(newChecked);
172
155
  if (persistKey) {
173
- persistChecklist(persistKey, newChecked);
156
+ try {
157
+ localStorage.setItem(
158
+ `checklist:${persistKey}`,
159
+ createChecklistStorageValue(newChecked)
160
+ );
161
+ window.dispatchEvent(
162
+ new CustomEvent(CHECKLIST_PROGRESS_EVENT, {
163
+ detail: { persistKey }
164
+ })
165
+ );
166
+ } catch {
167
+ }
174
168
  }
175
169
  if (newChecked.size === items.length) {
176
170
  onComplete?.();
@@ -175,6 +175,7 @@ const ChronoEvent = ({
175
175
  return (
176
176
  /* Passive focus tracking: the container observes focus bubbling from
177
177
  its interactive children to drive the scroll-spy active state. */
178
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
178
179
  /* @__PURE__ */ jsxs(
179
180
  "article",
180
181
  {
@@ -30,20 +30,23 @@ const CommandInput = ({
30
30
  className,
31
31
  ref: reference,
32
32
  ...props
33
- }) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
34
- /* @__PURE__ */ jsx(Search, { className: "mr-2 size-4 shrink-0 opacity-50" }),
35
- /* @__PURE__ */ jsx(
36
- CommandPrimitive.Input,
37
- {
38
- className: cn(
39
- "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
40
- className
41
- ),
42
- ref: reference,
43
- ...props
44
- }
45
- )
46
- ] });
33
+ }) => (
34
+ // eslint-disable-next-line react/no-unknown-property
35
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
36
+ /* @__PURE__ */ jsx(Search, { className: "mr-2 size-4 shrink-0 opacity-50" }),
37
+ /* @__PURE__ */ jsx(
38
+ CommandPrimitive.Input,
39
+ {
40
+ className: cn(
41
+ "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
42
+ className
43
+ ),
44
+ ref: reference,
45
+ ...props
46
+ }
47
+ )
48
+ ] })
49
+ );
47
50
  CommandInput.displayName = CommandPrimitive.Input.displayName;
48
51
  const CommandList = ({
49
52
  className,
@@ -3,38 +3,6 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { memo, useEffect, useRef } from "react";
4
4
  import { cn } from "../../lib/utils.js";
5
5
  import { Button } from "../button/button.js";
6
- function DialogCloseButton({
7
- closeIcon,
8
- onClose
9
- }) {
10
- return /* @__PURE__ */ jsx(
11
- "button",
12
- {
13
- "aria-label": "Close",
14
- className: "absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 transition-opacity",
15
- onClick: onClose,
16
- type: "button",
17
- children: closeIcon ?? /* @__PURE__ */ jsx(
18
- "svg",
19
- {
20
- className: "size-4",
21
- fill: "none",
22
- stroke: "currentColor",
23
- viewBox: "0 0 24 24",
24
- children: /* @__PURE__ */ jsx(
25
- "path",
26
- {
27
- d: "M6 18L18 6M6 6l12 12",
28
- strokeLinecap: "round",
29
- strokeLinejoin: "round",
30
- strokeWidth: 2
31
- }
32
- )
33
- }
34
- )
35
- }
36
- );
37
- }
38
6
  function DialogContent({
39
7
  as: Heading = "h2",
40
8
  cancelLabel = "Skip",
@@ -62,7 +30,33 @@ function DialogContent({
62
30
  className
63
31
  ),
64
32
  children: [
65
- /* @__PURE__ */ jsx(DialogCloseButton, { closeIcon, onClose }),
33
+ /* @__PURE__ */ jsx(
34
+ "button",
35
+ {
36
+ "aria-label": "Close",
37
+ className: "absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 transition-opacity",
38
+ onClick: onClose,
39
+ type: "button",
40
+ children: closeIcon ?? /* @__PURE__ */ jsx(
41
+ "svg",
42
+ {
43
+ className: "size-4",
44
+ fill: "none",
45
+ stroke: "currentColor",
46
+ viewBox: "0 0 24 24",
47
+ children: /* @__PURE__ */ jsx(
48
+ "path",
49
+ {
50
+ d: "M6 18L18 6M6 6l12 12",
51
+ strokeLinecap: "round",
52
+ strokeLinejoin: "round",
53
+ strokeWidth: 2
54
+ }
55
+ )
56
+ }
57
+ )
58
+ }
59
+ ),
66
60
  /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
67
61
  /* @__PURE__ */ jsx(Heading, { className: "text-lg font-semibold", id: "completion-dialog-title", children: title }),
68
62
  description ? /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground mt-1.5", children: description }) : null
@@ -89,13 +83,20 @@ function DialogContent({
89
83
  }
90
84
  );
91
85
  }
92
- function useCompletionDialogKeyboard({
93
- cancelShortcut,
94
- confirmShortcut,
86
+ function CompletionDialogImpl({
87
+ as,
88
+ cancelLabel,
89
+ cancelShortcut = "S",
90
+ className,
91
+ closeIcon,
92
+ confirmLabel,
93
+ confirmShortcut = "D",
94
+ description,
95
95
  isOpen,
96
96
  onCancel,
97
97
  onClose,
98
- onConfirm
98
+ onConfirm,
99
+ title
99
100
  }) {
100
101
  const keyDownHandlerRef = useRef(() => {
101
102
  return;
@@ -132,30 +133,6 @@ function useCompletionDialogKeyboard({
132
133
  document.removeEventListener("keydown", onDocumentKeyDown, true);
133
134
  };
134
135
  }, [isOpen]);
135
- }
136
- function CompletionDialogImpl({
137
- as,
138
- cancelLabel,
139
- cancelShortcut = "S",
140
- className,
141
- closeIcon,
142
- confirmLabel,
143
- confirmShortcut = "D",
144
- description,
145
- isOpen,
146
- onCancel,
147
- onClose,
148
- onConfirm,
149
- title
150
- }) {
151
- useCompletionDialogKeyboard({
152
- cancelShortcut,
153
- confirmShortcut,
154
- isOpen,
155
- onCancel,
156
- onClose,
157
- onConfirm
158
- });
159
136
  if (!isOpen) return null;
160
137
  return /* @__PURE__ */ jsxs(
161
138
  "div",
@@ -12,115 +12,22 @@ const EMPTY_CONTENT_INTRO_LABELS = {};
12
12
  function ContentIntroBody({ source }) {
13
13
  return source();
14
14
  }
15
- function ContentIntroToc({
15
+ function ContentIntroImpl({
16
+ additionalContent,
16
17
  completedSections,
17
- isLoading,
18
- label,
19
- onGoToSection,
20
- sections,
21
- TocHeading
22
- }) {
23
- return /* @__PURE__ */ jsxs("section", { className: "mt-8 py-6 border-t border-border", children: [
24
- /* @__PURE__ */ jsx(TocHeading, { className: "text-lg font-semibold mb-4", children: label }),
25
- /* @__PURE__ */ jsx("ol", { className: "space-y-2", children: sections.map((section, index) => {
26
- const isCompleted = !isLoading && completedSections.has(section.id);
27
- return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
28
- "button",
29
- {
30
- className: "w-full flex items-center gap-3 p-2 -m-2 rounded-lg hover:bg-muted/50 transition-colors text-left",
31
- onClick: () => {
32
- onGoToSection(index);
33
- },
34
- type: "button",
35
- children: [
36
- /* @__PURE__ */ jsx(
37
- "span",
38
- {
39
- className: cn(
40
- "flex-shrink-0 size-6 rounded-full flex items-center justify-center text-xs font-medium tabular-nums transition-colors",
41
- isLoading && "animate-pulse bg-muted",
42
- !isLoading && isCompleted && "bg-foreground text-background",
43
- !isLoading && !isCompleted && "bg-muted"
44
- ),
45
- children: isCompleted ? /* @__PURE__ */ jsx(
46
- "svg",
47
- {
48
- className: "size-3",
49
- fill: "none",
50
- stroke: "currentColor",
51
- viewBox: "0 0 24 24",
52
- children: /* @__PURE__ */ jsx(
53
- "path",
54
- {
55
- d: "M5 13l4 4L19 7",
56
- strokeLinecap: "round",
57
- strokeLinejoin: "round",
58
- strokeWidth: 2
59
- }
60
- )
61
- }
62
- ) : index + 1
63
- }
64
- ),
65
- /* @__PURE__ */ jsx(
66
- "span",
67
- {
68
- className: cn(
69
- "text-sm",
70
- isCompleted && "line-through text-muted-foreground"
71
- ),
72
- children: section.title
73
- }
74
- )
75
- ]
76
- }
77
- ) }, section.id);
78
- }) })
79
- ] });
80
- }
81
- function ContentIntroStickyBar({
82
- completedCount,
83
18
  estimatedTime,
84
- hasProgress,
85
- labels: mergedLabels,
19
+ isLoading = false,
20
+ labels = EMPTY_CONTENT_INTRO_LABELS,
21
+ onGoToSection,
86
22
  onStart,
87
- sectionCount
23
+ renderIntroContent,
24
+ sections,
25
+ title,
26
+ titleAs: TitleHeading = "h2",
27
+ tocLabelAs: TocHeading = "h3"
88
28
  }) {
89
- return /* @__PURE__ */ jsx("div", { className: "fixed bottom-0 left-0 right-0 z-50 border-t border-border bg-background/80 backdrop-blur-sm safe-bottom", children: /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-3xl p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
90
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground hidden sm:block", children: hasProgress ? `${completedCount}/${sectionCount} completed` : `${sectionCount} sections \xB7 ${estimatedTime}` }),
91
- /* @__PURE__ */ jsxs(
92
- Button,
93
- {
94
- className: "flex-1 sm:flex-none px-8 py-6 text-lg font-medium gap-2",
95
- onClick: onStart,
96
- size: "lg",
97
- children: [
98
- /* @__PURE__ */ jsx(
99
- "svg",
100
- {
101
- className: "size-5",
102
- fill: "none",
103
- stroke: "currentColor",
104
- viewBox: "0 0 24 24",
105
- children: /* @__PURE__ */ jsx(
106
- "path",
107
- {
108
- d: "M5 3l14 9-14 9V3z",
109
- strokeLinecap: "round",
110
- strokeLinejoin: "round",
111
- strokeWidth: 2
112
- }
113
- )
114
- }
115
- ),
116
- /* @__PURE__ */ jsx("span", { children: hasProgress ? mergedLabels.continueLabel : mergedLabels.startLabel }),
117
- /* @__PURE__ */ jsx("kbd", { className: "hidden md:inline-flex ml-1 px-1.5 py-0.5 text-xs font-mono bg-primary-foreground/20 rounded", children: "\u21B5" })
118
- ]
119
- }
120
- )
121
- ] }) }) });
122
- }
123
- function useEnterToStart(onStart) {
29
+ const mergedLabels = { ...DEFAULT_LABELS, ...labels };
30
+ const hasProgress = completedSections.size > 0;
124
31
  const onStartRef = useRef(onStart);
125
32
  useEffect(() => {
126
33
  onStartRef.current = onStart;
@@ -137,54 +44,104 @@ function useEnterToStart(onStart) {
137
44
  document.removeEventListener("keydown", onDocumentKeyDown);
138
45
  };
139
46
  }, []);
140
- }
141
- function ContentIntroImpl({
142
- additionalContent,
143
- completedSections,
144
- estimatedTime,
145
- isLoading = false,
146
- labels = EMPTY_CONTENT_INTRO_LABELS,
147
- onGoToSection,
148
- onStart,
149
- renderIntroContent,
150
- sections,
151
- title,
152
- titleAs: TitleHeading = "h2",
153
- tocLabelAs: TocHeading = "h3"
154
- }) {
155
- const mergedLabels = { ...DEFAULT_LABELS, ...labels };
156
- const hasProgress = completedSections.size > 0;
157
- useEnterToStart(onStart);
158
47
  return /* @__PURE__ */ jsxs(Fragment, { children: [
159
48
  /* @__PURE__ */ jsxs("div", { className: "animate-in fade-in-0 duration-500 pb-24", children: [
160
49
  /* @__PURE__ */ jsxs("section", { className: "py-6", children: [
161
50
  /* @__PURE__ */ jsx(TitleHeading, { className: "text-2xl md:text-3xl font-semibold mb-6", children: title }),
162
51
  /* @__PURE__ */ jsx("div", { className: cn("max-w-none", "[&_h2:first-of-type]:hidden"), children: /* @__PURE__ */ jsx(ContentIntroBody, { source: renderIntroContent }) })
163
52
  ] }),
164
- /* @__PURE__ */ jsx(
165
- ContentIntroToc,
166
- {
167
- completedSections,
168
- isLoading,
169
- label: mergedLabels.tableOfContentsLabel,
170
- onGoToSection,
171
- sections,
172
- TocHeading
173
- }
174
- ),
53
+ /* @__PURE__ */ jsxs("section", { className: "mt-8 py-6 border-t border-border", children: [
54
+ /* @__PURE__ */ jsx(TocHeading, { className: "text-lg font-semibold mb-4", children: mergedLabels.tableOfContentsLabel }),
55
+ /* @__PURE__ */ jsx("ol", { className: "space-y-2", children: sections.map((section, index) => {
56
+ const isCompleted = !isLoading && completedSections.has(section.id);
57
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
58
+ "button",
59
+ {
60
+ className: "w-full flex items-center gap-3 p-2 -m-2 rounded-lg hover:bg-muted/50 transition-colors text-left",
61
+ onClick: () => {
62
+ onGoToSection(index);
63
+ },
64
+ type: "button",
65
+ children: [
66
+ /* @__PURE__ */ jsx(
67
+ "span",
68
+ {
69
+ className: cn(
70
+ "flex-shrink-0 size-6 rounded-full flex items-center justify-center text-xs font-medium tabular-nums transition-colors",
71
+ isLoading && "animate-pulse bg-muted",
72
+ !isLoading && isCompleted && "bg-foreground text-background",
73
+ !isLoading && !isCompleted && "bg-muted"
74
+ ),
75
+ children: isCompleted ? /* @__PURE__ */ jsx(
76
+ "svg",
77
+ {
78
+ className: "size-3",
79
+ fill: "none",
80
+ stroke: "currentColor",
81
+ viewBox: "0 0 24 24",
82
+ children: /* @__PURE__ */ jsx(
83
+ "path",
84
+ {
85
+ d: "M5 13l4 4L19 7",
86
+ strokeLinecap: "round",
87
+ strokeLinejoin: "round",
88
+ strokeWidth: 2
89
+ }
90
+ )
91
+ }
92
+ ) : index + 1
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsx(
96
+ "span",
97
+ {
98
+ className: cn(
99
+ "text-sm",
100
+ isCompleted && "line-through text-muted-foreground"
101
+ ),
102
+ children: section.title
103
+ }
104
+ )
105
+ ]
106
+ }
107
+ ) }, section.id);
108
+ }) })
109
+ ] }),
175
110
  additionalContent
176
111
  ] }),
177
- /* @__PURE__ */ jsx(
178
- ContentIntroStickyBar,
179
- {
180
- completedCount: completedSections.size,
181
- estimatedTime,
182
- hasProgress,
183
- labels: mergedLabels,
184
- onStart,
185
- sectionCount: sections.length
186
- }
187
- )
112
+ /* @__PURE__ */ jsx("div", { className: "fixed bottom-0 left-0 right-0 z-50 border-t border-border bg-background/80 backdrop-blur-sm safe-bottom", children: /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-3xl p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
113
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground hidden sm:block", children: hasProgress ? `${completedSections.size}/${sections.length} completed` : `${sections.length} sections \xB7 ${estimatedTime}` }),
114
+ /* @__PURE__ */ jsxs(
115
+ Button,
116
+ {
117
+ className: "flex-1 sm:flex-none px-8 py-6 text-lg font-medium gap-2",
118
+ onClick: onStart,
119
+ size: "lg",
120
+ children: [
121
+ /* @__PURE__ */ jsx(
122
+ "svg",
123
+ {
124
+ className: "size-5",
125
+ fill: "none",
126
+ stroke: "currentColor",
127
+ viewBox: "0 0 24 24",
128
+ children: /* @__PURE__ */ jsx(
129
+ "path",
130
+ {
131
+ d: "M5 3l14 9-14 9V3z",
132
+ strokeLinecap: "round",
133
+ strokeLinejoin: "round",
134
+ strokeWidth: 2
135
+ }
136
+ )
137
+ }
138
+ ),
139
+ /* @__PURE__ */ jsx("span", { children: hasProgress ? mergedLabels.continueLabel : mergedLabels.startLabel }),
140
+ /* @__PURE__ */ jsx("kbd", { className: "hidden md:inline-flex ml-1 px-1.5 py-0.5 text-xs font-mono bg-primary-foreground/20 rounded", children: "\u21B5" })
141
+ ]
142
+ }
143
+ )
144
+ ] }) }) })
188
145
  ] });
189
146
  }
190
147
  const ContentIntro = memo(ContentIntroImpl);
@@ -150,11 +150,18 @@ const DEFAULT_LABELS = {
150
150
  tagsLabel: "Tags:"
151
151
  };
152
152
  const EMPTY_FILTER_BAR_LABELS = {};
153
- function useFilterBarHandlers({
153
+ function FilterBarImpl({
154
+ className,
155
+ currentDifficulty,
154
156
  currentTags,
157
+ difficultyOptions,
158
+ labels = EMPTY_FILTER_BAR_LABELS,
155
159
  onFiltersChange,
156
- startTransition
160
+ searchQuery,
161
+ tags
157
162
  }) {
163
+ const [isPending, startTransition] = useTransition();
164
+ const mergedLabels = { ...DEFAULT_LABELS, ...labels };
158
165
  const handleDifficultyChange = useCallback(
159
166
  (difficulty) => {
160
167
  startTransition(() => {
@@ -181,31 +188,6 @@ function useFilterBarHandlers({
181
188
  const input = document.querySelector("#filter-search");
182
189
  if (input) input.value = "";
183
190
  }, [onFiltersChange]);
184
- return {
185
- handleClearAll,
186
- handleDifficultyChange,
187
- handleSearchChange,
188
- handleTagToggle
189
- };
190
- }
191
- function FilterBarImpl({
192
- className,
193
- currentDifficulty,
194
- currentTags,
195
- difficultyOptions,
196
- labels = EMPTY_FILTER_BAR_LABELS,
197
- onFiltersChange,
198
- searchQuery,
199
- tags
200
- }) {
201
- const [isPending, startTransition] = useTransition();
202
- const mergedLabels = { ...DEFAULT_LABELS, ...labels };
203
- const {
204
- handleClearAll,
205
- handleDifficultyChange,
206
- handleSearchChange,
207
- handleTagToggle
208
- } = useFilterBarHandlers({ currentTags, onFiltersChange, startTransition });
209
191
  const activeDifficulty = currentDifficulty || "all";
210
192
  return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4 mb-8", className), children: [
211
193
  /* @__PURE__ */ jsx(
@@ -2,9 +2,6 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { cn } from "../../lib/utils.js";
4
4
  import { Input } from "../input/input.js";
5
- function focusOnMount(node) {
6
- node?.focus();
7
- }
8
5
  function InlineInput({
9
6
  className,
10
7
  onCancel,
@@ -24,6 +21,7 @@ function InlineInput({
24
21
  return /* @__PURE__ */ jsx(
25
22
  Input,
26
23
  {
24
+ autoFocus: true,
27
25
  className: cn("flex-1 h-7 text-sm", className),
28
26
  onBlur: () => {
29
27
  onCommit(value);
@@ -35,7 +33,6 @@ function InlineInput({
35
33
  event.stopPropagation();
36
34
  },
37
35
  onKeyDown: handleKeyDown,
38
- ref: focusOnMount,
39
36
  value
40
37
  }
41
38
  );