@pycolors/ui 1.5.5 → 1.6.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.
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { type TextareaProps } from "./textarea.js";
3
+ export interface AIComposerProps extends Omit<TextareaProps, "value" | "defaultValue" | "onSubmit" | "children" | "form"> {
4
+ value: string;
5
+ onChange: React.ChangeEventHandler<HTMLTextAreaElement>;
6
+ onSubmit: () => void;
7
+ busy?: boolean;
8
+ onStop?: () => void;
9
+ submitLabel?: string;
10
+ stopLabel?: string;
11
+ /** Disable Enter-to-send for editors that should always insert newlines. */
12
+ submitOnEnter?: boolean;
13
+ }
14
+ /** Controlled chat input. Requests, cancellation and draft updates belong to the consumer. */
15
+ declare const AIComposer: React.ForwardRefExoticComponent<AIComposerProps & React.RefAttributes<HTMLTextAreaElement>>;
16
+ export { AIComposer };
17
+ //# sourceMappingURL=ai-composer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-composer.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ai-composer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7D,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,aAAa,EACb,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAC5D;IACC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IACxD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,8FAA8F;AAC9F,QAAA,MAAM,UAAU,6FAoGf,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Button } from "./button.js";
5
+ import { Textarea } from "./textarea.js";
6
+ /** Controlled chat input. Requests, cancellation and draft updates belong to the consumer. */
7
+ const AIComposer = React.forwardRef(({ value, onChange, onSubmit, busy = false, onStop, disabled, submitLabel = "Send message", stopLabel = "Stop response", submitOnEnter = true, onKeyDown, onCompositionStart, onCompositionEnd, ...props }, ref) => {
8
+ const composing = React.useRef(false);
9
+ const submitting = React.useRef(false);
10
+ const canSubmit = !disabled && !busy && value.trim().length > 0;
11
+ return (_jsxs("form", { "data-slot": "ai-composer", className: "flex min-w-0 w-full flex-col gap-3", onSubmit: (event) => {
12
+ event.preventDefault();
13
+ if (!canSubmit || composing.current || submitting.current)
14
+ return;
15
+ // Cover duplicate events in one turn; the consumer owns the request's busy state.
16
+ submitting.current = true;
17
+ queueMicrotask(() => {
18
+ submitting.current = false;
19
+ });
20
+ onSubmit();
21
+ }, children: [_jsx(Textarea, { ...props, ref: ref, value: value, onChange: onChange, disabled: disabled, onCompositionStart: (event) => {
22
+ composing.current = true;
23
+ onCompositionStart?.(event);
24
+ }, onCompositionEnd: (event) => {
25
+ composing.current = false;
26
+ onCompositionEnd?.(event);
27
+ }, onKeyDown: (event) => {
28
+ onKeyDown?.(event);
29
+ if (event.defaultPrevented ||
30
+ !submitOnEnter ||
31
+ event.key !== "Enter" ||
32
+ event.shiftKey ||
33
+ event.altKey ||
34
+ event.ctrlKey ||
35
+ event.metaKey ||
36
+ composing.current ||
37
+ event.nativeEvent.isComposing ||
38
+ event.nativeEvent.keyCode === 229 ||
39
+ window.matchMedia?.("(hover: none) and (pointer: coarse)").matches)
40
+ return;
41
+ event.preventDefault();
42
+ if (!event.repeat && canSubmit)
43
+ event.currentTarget.form?.requestSubmit();
44
+ } }), _jsx("div", { "data-slot": "ai-composer-actions", className: "flex flex-wrap justify-end gap-2", children: busy && onStop ? (_jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: onStop, className: "min-h-11 h-auto max-w-full whitespace-normal break-words motion-reduce:transition-none", children: stopLabel })) : (_jsx(Button, { type: "submit", disabled: !canSubmit, className: "min-h-11 h-auto max-w-full whitespace-normal break-words motion-reduce:transition-none", children: submitLabel })) })] }));
45
+ });
46
+ AIComposer.displayName = "AIComposer";
47
+ export { AIComposer };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,21 @@
1
- export * from './components/ui/button.js';
2
- export * from './components/ui/card.js';
3
- export * from './components/ui/checkbox.js';
4
- export * from './components/ui/badge.js';
5
- export * from './components/ui/input.js';
6
- export * from './components/ui/skeleton.js';
7
- export * from './components/ui/empty-state.js';
8
- export * from './components/ui/alert.js';
9
- export * from './components/ui/dialog.js';
10
- export * from './components/ui/separator.js';
11
- export * from './components/ui/sheet.js';
12
- export * from './components/ui/dropdown-menu.js';
13
- export * from './components/ui/tabs.js';
14
- export * from './components/ui/toast.js';
15
- export * from './components/ui/pagination.js';
16
- export * from './components/ui/table.js';
17
- export * from './components/ui/textarea.js';
18
- export * from './components/ui/password-input.js';
19
- export * from './lib/utils.js';
1
+ export * from "./components/ui/button.js";
2
+ export * from "./components/ui/card.js";
3
+ export * from "./components/ui/checkbox.js";
4
+ export * from "./components/ui/badge.js";
5
+ export * from "./components/ui/input.js";
6
+ export * from "./components/ui/skeleton.js";
7
+ export * from "./components/ui/empty-state.js";
8
+ export * from "./components/ui/alert.js";
9
+ export * from "./components/ui/dialog.js";
10
+ export * from "./components/ui/separator.js";
11
+ export * from "./components/ui/sheet.js";
12
+ export * from "./components/ui/dropdown-menu.js";
13
+ export * from "./components/ui/tabs.js";
14
+ export * from "./components/ui/toast.js";
15
+ export * from "./components/ui/pagination.js";
16
+ export * from "./components/ui/table.js";
17
+ export * from "./components/ui/textarea.js";
18
+ export * from "./components/ui/password-input.js";
19
+ export * from "./lib/utils.js";
20
+ export * from "./components/ui/ai-composer.js";
20
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC"}
package/dist/index.js CHANGED
@@ -1,19 +1,20 @@
1
- export * from './components/ui/button.js';
2
- export * from './components/ui/card.js';
3
- export * from './components/ui/checkbox.js';
4
- export * from './components/ui/badge.js';
5
- export * from './components/ui/input.js';
6
- export * from './components/ui/skeleton.js';
7
- export * from './components/ui/empty-state.js';
8
- export * from './components/ui/alert.js';
9
- export * from './components/ui/dialog.js';
10
- export * from './components/ui/separator.js';
11
- export * from './components/ui/sheet.js';
12
- export * from './components/ui/dropdown-menu.js';
13
- export * from './components/ui/tabs.js';
14
- export * from './components/ui/toast.js';
15
- export * from './components/ui/pagination.js';
16
- export * from './components/ui/table.js';
17
- export * from './components/ui/textarea.js';
18
- export * from './components/ui/password-input.js';
19
- export * from './lib/utils.js';
1
+ export * from "./components/ui/button.js";
2
+ export * from "./components/ui/card.js";
3
+ export * from "./components/ui/checkbox.js";
4
+ export * from "./components/ui/badge.js";
5
+ export * from "./components/ui/input.js";
6
+ export * from "./components/ui/skeleton.js";
7
+ export * from "./components/ui/empty-state.js";
8
+ export * from "./components/ui/alert.js";
9
+ export * from "./components/ui/dialog.js";
10
+ export * from "./components/ui/separator.js";
11
+ export * from "./components/ui/sheet.js";
12
+ export * from "./components/ui/dropdown-menu.js";
13
+ export * from "./components/ui/tabs.js";
14
+ export * from "./components/ui/toast.js";
15
+ export * from "./components/ui/pagination.js";
16
+ export * from "./components/ui/table.js";
17
+ export * from "./components/ui/textarea.js";
18
+ export * from "./components/ui/password-input.js";
19
+ export * from "./lib/utils.js";
20
+ export * from "./components/ui/ai-composer.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pycolors/ui",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "description": "Production-ready UI primitives for modern SaaS apps (Radix + Tailwind-friendly).",
5
5
  "keywords": [
6
6
  "pycolors",
@@ -66,9 +66,9 @@
66
66
  "devDependencies": {
67
67
  "@pycolors/eslint-config": "^1.0.6",
68
68
  "@pycolors/typescript-config": "^1.0.0",
69
- "@storybook/addon-a11y": "10.6.0",
70
- "@storybook/addon-vitest": "10.6.0",
71
- "@storybook/react-vite": "10.6.0",
69
+ "@storybook/addon-a11y": "10.6.1",
70
+ "@storybook/addon-vitest": "10.6.1",
71
+ "@storybook/react-vite": "10.6.1",
72
72
  "@tailwindcss/vite": "^4.3.3",
73
73
  "@testing-library/jest-dom": "^7.0.1",
74
74
  "@testing-library/react": "^16.3.2",
@@ -77,11 +77,11 @@
77
77
  "@types/react-dom": "19.3.0",
78
78
  "@vitest/browser-playwright": "4.1.11",
79
79
  "eslint": "^9.39.5",
80
- "jsdom": "^29.1.1",
80
+ "jsdom": "^30.1.2",
81
81
  "playwright": "1.63.0",
82
82
  "react": "19.3.0",
83
83
  "react-dom": "19.3.0",
84
- "storybook": "10.6.0",
84
+ "storybook": "10.6.1",
85
85
  "tailwindcss": "^4.3.3",
86
86
  "typescript": "6.0.3",
87
87
  "vite": "^8.1.4",