@kamaldgrt/ui 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kamal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,115 @@
1
- # Temporary Holding Version
1
+ # @kamaldgrt/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared React UI primitives styled with Tailwind CSS theme tokens:
4
+
5
+ - **`Modal`**: centered dialog. Backdrop click and Escape close it, and the first field gets focus on open.
6
+ - **`ConfirmModal`**: message plus Cancel and Confirm, with an optional `danger` style and an optional secondary action.
7
+ - **`PromptModal`**: one or more labeled text inputs plus Cancel and OK. It replaces `window.prompt`.
8
+ - **`Drawer`**: right-side slide-over panel with an enter and exit transition and an optional header icon.
9
+ - **`SearchableSelect`**: single-select with a search box. Ids can be strings or numbers, options can have icons, and an optional `allLabel` is a pinned "no filter" choice.
10
+
11
+ All components are client components (`"use client"` is included in the build).
12
+
13
+ ## Requirements
14
+
15
+ - React 19
16
+ - `lucide-react` (peer dependency, used by `Drawer`)
17
+ - Tailwind CSS v4 in the consuming app
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm i @kamaldgrt/ui
23
+ ```
24
+
25
+ ## Setup in the consuming app
26
+
27
+ The components carry Tailwind class names, so the app's Tailwind build has to scan the package. Add this to the app's main stylesheet. The path is relative to that file:
28
+
29
+ ```css
30
+ @import "tailwindcss";
31
+ @source "../../node_modules/@kamaldgrt/ui/dist";
32
+ ```
33
+
34
+ Without the `@source` line, Tailwind never sees the package's classes and the components render unstyled.
35
+
36
+ ### Theme tokens
37
+
38
+ The components use semantic color tokens, so each app keeps its own look. The app must define these under `@theme` as `--color-*` variables:
39
+
40
+ | Token | Used for |
41
+ |---|---|
42
+ | `surface`, `surface-elevated`, `surface-hover` | backgrounds, dialog card, hover state |
43
+ | `foreground`, `muted` | text |
44
+ | `border`, `border-subtle` | borders |
45
+ | `cta`, `cta-foreground`, `cta-hover` | primary button |
46
+ | `danger-bg`, `danger-text` | destructive button |
47
+ | `warning-bg`, `warning-text` | drawer icon chip |
48
+
49
+ ```css
50
+ @theme {
51
+ --color-surface: #ffffff;
52
+ --color-foreground: #111827;
53
+ /* ...and so on for every token above */
54
+ }
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ```tsx
60
+ import { ConfirmModal, Drawer, Modal, PromptModal, SearchableSelect } from "@kamaldgrt/ui";
61
+
62
+ <ConfirmModal
63
+ isOpen={open}
64
+ onClose={() => setOpen(false)}
65
+ onConfirm={remove}
66
+ title="Delete item"
67
+ message="This cannot be undone."
68
+ confirmLabel="Delete"
69
+ danger
70
+ />
71
+
72
+ <Drawer isOpen={open} onClose={() => setOpen(false)} title="New item" icon={Plus}>
73
+ <ItemForm />
74
+ </Drawer>
75
+
76
+ <PromptModal
77
+ isOpen={open}
78
+ onClose={() => setOpen(false)}
79
+ onSubmit={({ name }) => rename(name)}
80
+ title="Rename"
81
+ fields={[{ name: "name", label: "Name", defaultValue: current }]}
82
+ />
83
+
84
+ <SearchableSelect
85
+ ariaLabel="Status"
86
+ options={[{ id: "open", label: "Open" }, { id: "done", label: "Done" }]}
87
+ value={status}
88
+ onChange={setStatus}
89
+ allLabel="Any status"
90
+ />
91
+ ```
92
+
93
+ Behavior worth knowing:
94
+
95
+ - A `Drawer` stays mounted for 200 ms after `isOpen` turns false so the slide-out can play. Its children remount on every open, so forms start fresh.
96
+ - Pressing Escape inside a `Drawer` that contains an open dialog closes only the dialog.
97
+ - `Modal` takes an optional `className` that replaces the default card styling.
98
+ - There is no focus trap. One dialog at a time is the supported case.
99
+
100
+ ## Development
101
+
102
+ ```bash
103
+ npm install
104
+ npm test # vitest (jsdom, testing-library)
105
+ npm run typecheck # tsc --noEmit
106
+ npm run build # tsup -> dist/ (ESM + .d.ts)
107
+ ```
108
+
109
+ ## API changes
110
+
111
+ Everything is imported from the package root. Treat exported names, props and the list of theme tokens as a public API:
112
+
113
+ - Additive changes (new optional props, new components, new tokens with a fallback) bump the minor version.
114
+ - Breaking changes (removed or renamed props, new required tokens) bump the major version.
115
+ - Tag each release (`vX.Y.Z`) to match the published version.
@@ -0,0 +1,66 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { LucideIcon } from 'lucide-react';
4
+
5
+ declare function ConfirmModal({ isOpen, onClose, onConfirm, title, message, confirmLabel, danger, secondaryLabel, onSecondary, }: {
6
+ isOpen: boolean;
7
+ onClose: () => void;
8
+ onConfirm: () => void;
9
+ title: string;
10
+ message: string;
11
+ confirmLabel?: string;
12
+ danger?: boolean;
13
+ secondaryLabel?: string;
14
+ onSecondary?: () => void;
15
+ }): react.JSX.Element;
16
+
17
+ declare function Drawer({ isOpen, onClose, title, icon: Icon, children, }: {
18
+ isOpen: boolean;
19
+ onClose: () => void;
20
+ title: string;
21
+ icon?: LucideIcon;
22
+ children: ReactNode;
23
+ }): react.JSX.Element | null;
24
+
25
+ declare function Modal({ isOpen, onClose, title, children, className, }: {
26
+ isOpen: boolean;
27
+ onClose: () => void;
28
+ title: string;
29
+ children: ReactNode;
30
+ className?: string;
31
+ }): react.JSX.Element | null;
32
+
33
+ type PromptField = {
34
+ name: string;
35
+ label: string;
36
+ placeholder?: string;
37
+ defaultValue?: string;
38
+ optional?: boolean;
39
+ };
40
+ declare function PromptModal({ isOpen, onClose, onSubmit, title, fields, submitLabel, }: {
41
+ isOpen: boolean;
42
+ onClose: () => void;
43
+ onSubmit: (values: Record<string, string>) => void;
44
+ title: string;
45
+ fields: PromptField[];
46
+ submitLabel?: string;
47
+ }): react.JSX.Element;
48
+
49
+ type SearchableSelectOption<T extends string | number = number> = {
50
+ id: T;
51
+ label: string;
52
+ icon?: ReactNode;
53
+ };
54
+ declare function SearchableSelect<T extends string | number = number>({ options, value, onChange, allLabel, placeholder, className, compact, ariaLabel, }: {
55
+ options: SearchableSelectOption<T>[];
56
+ value: T | null;
57
+ onChange: (id: T | null) => void;
58
+ allLabel?: string;
59
+ placeholder?: string;
60
+ className?: string;
61
+ compact?: boolean;
62
+ ariaLabel?: string;
63
+ }): react.JSX.Element;
64
+
65
+ export { ConfirmModal, Drawer, Modal, PromptModal, SearchableSelect };
66
+ export type { PromptField, SearchableSelectOption };
package/dist/index.js ADDED
@@ -0,0 +1,413 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+
22
+ // src/Modal.tsx
23
+ import { useEffect, useRef } from "react";
24
+ import { jsx, jsxs } from "react/jsx-runtime";
25
+ function Modal({
26
+ isOpen,
27
+ onClose,
28
+ title,
29
+ children,
30
+ className
31
+ }) {
32
+ const cardRef = useRef(null);
33
+ useEffect(() => {
34
+ var _a, _b;
35
+ if (!isOpen) return;
36
+ (_b = (_a = cardRef.current) == null ? void 0 : _a.querySelector("input, button, textarea, select")) == null ? void 0 : _b.focus();
37
+ }, [isOpen]);
38
+ useEffect(() => {
39
+ if (!isOpen) return;
40
+ function handleKeyDown(e) {
41
+ if (e.key === "Escape") onClose();
42
+ }
43
+ document.addEventListener("keydown", handleKeyDown);
44
+ return () => document.removeEventListener("keydown", handleKeyDown);
45
+ }, [isOpen, onClose]);
46
+ if (!isOpen) return null;
47
+ return /* @__PURE__ */ jsx(
48
+ "div",
49
+ {
50
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40",
51
+ onClick: onClose,
52
+ children: /* @__PURE__ */ jsxs(
53
+ "div",
54
+ {
55
+ ref: cardRef,
56
+ role: "dialog",
57
+ "aria-modal": "true",
58
+ "aria-label": title,
59
+ onClick: (e) => e.stopPropagation(),
60
+ className: className != null ? className : "w-80 rounded-lg border-2 border-border bg-surface-elevated p-4",
61
+ children: [
62
+ /* @__PURE__ */ jsx("p", { className: "mb-3 text-sm font-semibold text-foreground", children: title }),
63
+ children
64
+ ]
65
+ }
66
+ )
67
+ }
68
+ );
69
+ }
70
+
71
+ // src/ConfirmModal.tsx
72
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
73
+ function ConfirmModal({
74
+ isOpen,
75
+ onClose,
76
+ onConfirm,
77
+ title,
78
+ message,
79
+ confirmLabel = "Confirm",
80
+ danger = false,
81
+ // Optional third button, rendered between Cancel and Confirm — for
82
+ // dialogs offering a safe alternative to a destructive Confirm (e.g.
83
+ // "Mark Inactive" next to "Delete Permanently"). Never itself styled
84
+ // `danger`; that's reserved for the main destructive action.
85
+ secondaryLabel,
86
+ onSecondary
87
+ }) {
88
+ return /* @__PURE__ */ jsxs2(Modal, { isOpen, onClose, title, children: [
89
+ /* @__PURE__ */ jsx2("p", { className: "mb-4 text-sm text-foreground", children: message }),
90
+ /* @__PURE__ */ jsxs2("div", { className: "flex justify-end gap-2", children: [
91
+ /* @__PURE__ */ jsx2(
92
+ "button",
93
+ {
94
+ type: "button",
95
+ onClick: onClose,
96
+ className: "rounded-md px-3 py-1.5 text-sm text-muted hover:bg-surface-hover",
97
+ children: "Cancel"
98
+ }
99
+ ),
100
+ secondaryLabel && onSecondary && /* @__PURE__ */ jsx2(
101
+ "button",
102
+ {
103
+ type: "button",
104
+ onClick: onSecondary,
105
+ className: "rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground hover:bg-surface-hover",
106
+ children: secondaryLabel
107
+ }
108
+ ),
109
+ /* @__PURE__ */ jsx2(
110
+ "button",
111
+ {
112
+ type: "button",
113
+ onClick: onConfirm,
114
+ className: danger ? "rounded-md bg-danger-bg px-3 py-1.5 text-sm font-medium text-danger-text hover:opacity-90" : "rounded-md bg-cta px-3 py-1.5 text-sm font-medium text-cta-foreground hover:bg-cta-hover hover:font-semibold",
115
+ children: confirmLabel
116
+ }
117
+ )
118
+ ] })
119
+ ] });
120
+ }
121
+
122
+ // src/Drawer.tsx
123
+ import { X } from "lucide-react";
124
+ import { useEffect as useEffect2, useRef as useRef2, useState } from "react";
125
+
126
+ // src/constants.ts
127
+ var DRAWER_TRANSITION_DURATION_MS = 200;
128
+
129
+ // src/Drawer.tsx
130
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
131
+ function Drawer({
132
+ isOpen,
133
+ onClose,
134
+ title,
135
+ icon: Icon,
136
+ children
137
+ }) {
138
+ const [mounted, setMounted] = useState(isOpen);
139
+ const [visible, setVisible] = useState(false);
140
+ const contentRef = useRef2(null);
141
+ useEffect2(() => {
142
+ if (isOpen) {
143
+ setMounted(true);
144
+ const raf = requestAnimationFrame(() => setVisible(true));
145
+ return () => cancelAnimationFrame(raf);
146
+ }
147
+ setVisible(false);
148
+ const timer = setTimeout(() => setMounted(false), DRAWER_TRANSITION_DURATION_MS);
149
+ return () => clearTimeout(timer);
150
+ }, [isOpen]);
151
+ useEffect2(() => {
152
+ var _a, _b;
153
+ if (!isOpen) return;
154
+ (_b = (_a = contentRef.current) == null ? void 0 : _a.querySelector("input, button, textarea, select")) == null ? void 0 : _b.focus();
155
+ }, [isOpen]);
156
+ useEffect2(() => {
157
+ if (!isOpen) return;
158
+ function handleKeyDown(e) {
159
+ var _a;
160
+ if (e.key !== "Escape") return;
161
+ if ((_a = contentRef.current) == null ? void 0 : _a.querySelector('[role="dialog"]')) return;
162
+ onClose();
163
+ }
164
+ document.addEventListener("keydown", handleKeyDown);
165
+ return () => document.removeEventListener("keydown", handleKeyDown);
166
+ }, [isOpen, onClose]);
167
+ if (!mounted) return null;
168
+ return /* @__PURE__ */ jsx3(
169
+ "div",
170
+ {
171
+ className: `fixed inset-0 z-50 bg-black/40 transition-opacity duration-200 ${visible ? "opacity-100" : "opacity-0"}`,
172
+ onClick: onClose,
173
+ children: /* @__PURE__ */ jsxs3(
174
+ "div",
175
+ {
176
+ role: "dialog",
177
+ "aria-modal": "true",
178
+ "aria-label": title,
179
+ onClick: (e) => e.stopPropagation(),
180
+ className: `fixed inset-y-0 right-0 flex w-full flex-col border-l border-border-subtle bg-surface-elevated shadow-lg transition-transform duration-200 sm:max-w-md ${visible ? "translate-x-0" : "translate-x-full"}`,
181
+ children: [
182
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between border-b border-border-subtle px-4 py-3", children: [
183
+ /* @__PURE__ */ jsxs3("p", { className: "flex min-w-0 items-center gap-2.5 text-sm font-semibold text-foreground", children: [
184
+ Icon && /* @__PURE__ */ jsx3("span", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-warning-bg text-warning-text", children: /* @__PURE__ */ jsx3(Icon, { "aria-hidden": true, className: "h-4 w-4" }) }),
185
+ /* @__PURE__ */ jsx3("span", { className: "break-words", children: title })
186
+ ] }),
187
+ /* @__PURE__ */ jsx3(
188
+ "button",
189
+ {
190
+ type: "button",
191
+ onClick: onClose,
192
+ "aria-label": "Close",
193
+ className: "rounded p-1 text-muted hover:bg-surface-hover hover:text-foreground",
194
+ children: /* @__PURE__ */ jsx3(X, { "aria-hidden": true, className: "h-4 w-4" })
195
+ }
196
+ )
197
+ ] }),
198
+ /* @__PURE__ */ jsx3("div", { ref: contentRef, className: "flex-1 overflow-y-auto p-4", children })
199
+ ]
200
+ }
201
+ )
202
+ }
203
+ );
204
+ }
205
+
206
+ // src/PromptModal.tsx
207
+ import { useEffect as useEffect3, useState as useState2 } from "react";
208
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
209
+ function PromptModal({
210
+ isOpen,
211
+ onClose,
212
+ onSubmit,
213
+ title,
214
+ fields,
215
+ submitLabel = "OK"
216
+ }) {
217
+ const [values, setValues] = useState2({});
218
+ useEffect3(() => {
219
+ if (isOpen) {
220
+ setValues(
221
+ Object.fromEntries(fields.map((f) => {
222
+ var _a;
223
+ return [f.name, (_a = f.defaultValue) != null ? _a : ""];
224
+ }))
225
+ );
226
+ }
227
+ }, [isOpen]);
228
+ const canSubmit = fields.every(
229
+ (f) => {
230
+ var _a;
231
+ return f.optional || ((_a = values[f.name]) != null ? _a : "").trim();
232
+ }
233
+ );
234
+ function handleSubmit() {
235
+ if (!canSubmit) return;
236
+ onSubmit(
237
+ Object.fromEntries(fields.map((f) => [f.name, values[f.name].trim()]))
238
+ );
239
+ }
240
+ return /* @__PURE__ */ jsx4(Modal, { isOpen, onClose, title, children: /* @__PURE__ */ jsxs4(
241
+ "form",
242
+ {
243
+ onSubmit: (e) => {
244
+ e.preventDefault();
245
+ handleSubmit();
246
+ },
247
+ children: [
248
+ /* @__PURE__ */ jsx4("div", { className: "mb-4 space-y-3", children: fields.map((f) => {
249
+ var _a;
250
+ return /* @__PURE__ */ jsxs4("label", { className: "block", children: [
251
+ /* @__PURE__ */ jsx4("span", { className: "mb-1 block text-xs font-medium text-muted", children: f.label }),
252
+ /* @__PURE__ */ jsx4(
253
+ "input",
254
+ {
255
+ type: "text",
256
+ value: (_a = values[f.name]) != null ? _a : "",
257
+ onChange: (e) => setValues((prev) => __spreadProps(__spreadValues({}, prev), { [f.name]: e.target.value })),
258
+ placeholder: f.placeholder,
259
+ className: "w-full rounded-md border border-border bg-surface px-2 py-1.5 text-sm text-foreground"
260
+ }
261
+ )
262
+ ] }, f.name);
263
+ }) }),
264
+ /* @__PURE__ */ jsxs4("div", { className: "flex justify-end gap-2", children: [
265
+ /* @__PURE__ */ jsx4(
266
+ "button",
267
+ {
268
+ type: "button",
269
+ onClick: onClose,
270
+ className: "rounded-md px-3 py-1.5 text-sm text-muted hover:bg-surface-hover",
271
+ children: "Cancel"
272
+ }
273
+ ),
274
+ /* @__PURE__ */ jsx4(
275
+ "button",
276
+ {
277
+ type: "submit",
278
+ disabled: !canSubmit,
279
+ className: "rounded-md bg-cta px-3 py-1.5 text-sm font-medium text-cta-foreground hover:bg-cta-hover hover:font-semibold disabled:opacity-50",
280
+ children: submitLabel
281
+ }
282
+ )
283
+ ] })
284
+ ]
285
+ }
286
+ ) });
287
+ }
288
+
289
+ // src/SearchableSelect.tsx
290
+ import { useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState3 } from "react";
291
+ import { ChevronDown } from "lucide-react";
292
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
293
+ function SearchableSelect({
294
+ options,
295
+ value,
296
+ onChange,
297
+ allLabel,
298
+ placeholder = "Search\u2026",
299
+ className,
300
+ compact = false,
301
+ ariaLabel
302
+ }) {
303
+ var _a;
304
+ const triggerSize = compact ? "py-0.5 text-xs" : "py-1.5 text-sm";
305
+ const rowSize = compact ? "py-0.5 text-xs" : "py-1 text-sm";
306
+ const [open, setOpen] = useState3(false);
307
+ const [query, setQuery] = useState3("");
308
+ const containerRef = useRef3(null);
309
+ const inputRef = useRef3(null);
310
+ useEffect4(() => {
311
+ if (!open) return;
312
+ function handlePointerDown(e) {
313
+ var _a2;
314
+ if (!((_a2 = containerRef.current) == null ? void 0 : _a2.contains(e.target))) {
315
+ setOpen(false);
316
+ }
317
+ }
318
+ document.addEventListener("pointerdown", handlePointerDown);
319
+ return () => document.removeEventListener("pointerdown", handlePointerDown);
320
+ }, [open]);
321
+ useEffect4(() => {
322
+ var _a2;
323
+ if (open) (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
324
+ }, [open]);
325
+ const filtered = useMemo(
326
+ () => options.filter(
327
+ (o) => o.label.toLowerCase().includes(query.trim().toLowerCase())
328
+ ),
329
+ [options, query]
330
+ );
331
+ const selected = options.find((o) => o.id === value);
332
+ const selectedLabel = value === null ? allLabel != null ? allLabel : "Select\u2026" : (_a = selected == null ? void 0 : selected.label) != null ? _a : "Select\u2026";
333
+ function toggleOpen() {
334
+ setOpen((wasOpen) => {
335
+ const nowOpen = !wasOpen;
336
+ if (nowOpen) setQuery("");
337
+ return nowOpen;
338
+ });
339
+ }
340
+ function select(id) {
341
+ onChange(id);
342
+ setOpen(false);
343
+ }
344
+ return /* @__PURE__ */ jsxs5("div", { ref: containerRef, className: `relative ${className != null ? className : ""}`, children: [
345
+ /* @__PURE__ */ jsxs5(
346
+ "button",
347
+ {
348
+ type: "button",
349
+ "aria-label": ariaLabel,
350
+ "aria-haspopup": "listbox",
351
+ "aria-expanded": open,
352
+ onClick: toggleOpen,
353
+ className: `flex w-full items-center justify-between gap-2 rounded-md border border-border bg-surface px-3 ${triggerSize} text-left text-foreground`,
354
+ children: [
355
+ /* @__PURE__ */ jsxs5("span", { className: "flex min-w-0 items-center gap-2", children: [
356
+ selected == null ? void 0 : selected.icon,
357
+ /* @__PURE__ */ jsx5("span", { className: "min-w-0 break-words", children: selectedLabel })
358
+ ] }),
359
+ /* @__PURE__ */ jsx5(
360
+ ChevronDown,
361
+ {
362
+ className: `h-4 w-4 shrink-0 text-muted transition-transform ${open ? "rotate-180" : ""}`
363
+ }
364
+ )
365
+ ]
366
+ }
367
+ ),
368
+ open && /* @__PURE__ */ jsxs5("div", { className: "absolute z-30 mt-1 w-full min-w-48 rounded-md border border-border-subtle bg-surface-elevated p-2 shadow-lg", children: [
369
+ /* @__PURE__ */ jsx5(
370
+ "input",
371
+ {
372
+ ref: inputRef,
373
+ type: "text",
374
+ value: query,
375
+ onChange: (e) => setQuery(e.target.value),
376
+ placeholder,
377
+ className: `mb-2 w-full rounded-md border border-border bg-surface px-2 ${rowSize} text-foreground`
378
+ }
379
+ ),
380
+ /* @__PURE__ */ jsxs5("ul", { className: "max-h-56 overflow-y-auto", children: [
381
+ allLabel && !query.trim() && /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5(
382
+ "button",
383
+ {
384
+ type: "button",
385
+ onClick: () => select(null),
386
+ className: `block w-full rounded px-2 ${rowSize} text-left hover:bg-surface-hover ${value === null ? "font-medium text-cta" : "text-foreground"}`,
387
+ children: allLabel
388
+ }
389
+ ) }),
390
+ filtered.length === 0 && /* @__PURE__ */ jsx5("li", { className: `px-2 ${rowSize} text-muted`, children: "No matches" }),
391
+ filtered.map((option) => /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsxs5(
392
+ "button",
393
+ {
394
+ type: "button",
395
+ onClick: () => select(option.id),
396
+ className: `flex w-full items-center gap-2 rounded px-2 ${rowSize} text-left hover:bg-surface-hover ${value === option.id ? "font-medium text-cta" : "text-foreground"}`,
397
+ children: [
398
+ option.icon,
399
+ /* @__PURE__ */ jsx5("span", { className: "min-w-0 break-words", children: option.label })
400
+ ]
401
+ }
402
+ ) }, option.id))
403
+ ] })
404
+ ] })
405
+ ] });
406
+ }
407
+ export {
408
+ ConfirmModal,
409
+ Drawer,
410
+ Modal,
411
+ PromptModal,
412
+ SearchableSelect
413
+ };
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@kamaldgrt/ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Shared React UI primitives (modals, drawer) styled with Tailwind theme tokens.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "sideEffects": false,
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/KamalDGRT/nico-ui.git"
21
+ },
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "test": "vitest run",
25
+ "typecheck": "tsc --noEmit",
26
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
27
+ },
28
+ "peerDependencies": {
29
+ "lucide-react": "^1.37.0",
30
+ "react": "^19.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@testing-library/jest-dom": "^7.0.1",
34
+ "@testing-library/react": "^16.3.3",
35
+ "@testing-library/user-event": "^14.6.8",
36
+ "@types/react": "^19.3.0",
37
+ "@types/react-dom": "^19.3.0",
38
+ "jsdom": "^29.1.1",
39
+ "lucide-react": "^1.61.0",
40
+ "react": "^19.2.8",
41
+ "react-dom": "^19.2.8",
42
+ "tsup": "^9.0.0",
43
+ "typescript": "^5.9.3",
44
+ "vitest": "^4.1.12"
45
+ }
46
+ }