@gridui/composer 1.0.3 → 2.0.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gridui/composer
2
2
 
3
- Dashboard family. Public API: `AttachmentItem`, `AttachmentList`, `AttachmentListProps`, `Composer`, `ComposerProps`.
3
+ Dashboard family. Public API: `AttachmentItem`, `AttachmentList`, `Composer`, `ComposerAttachments`, `ComposerInput`, `ComposerActions`, `ComposerFilePicker`, `ComposerSubmit`, and `ComposerStop`.
4
4
 
5
5
  Import components from `@gridui/composer` and load `@gridui/composer/styles.css` after Theme.
6
6
  Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
@@ -4,13 +4,7 @@
4
4
  * @namespace AttachmentList
5
5
  * @description Attachment List
6
6
  */
7
- import type { AttachmentItem } from "../shared/types";
8
- import { type ComponentPropsWithRef, type FC } from "react";
9
- export type AttachmentListProps = Omit<ComponentPropsWithRef<"ul">, "children"> & {
10
- readonly items: readonly AttachmentItem[];
11
- readonly label: string;
12
- readonly removeLabel: (item: AttachmentItem) => string;
13
- readonly onRemove?: (id: string) => void;
14
- readonly disabled?: boolean;
15
- };
7
+ import type { AttachmentListOptions } from "../shared/types";
8
+ import { type FC } from "react";
9
+ export type AttachmentListProps = AttachmentListOptions;
16
10
  export declare const AttachmentList: FC<AttachmentListProps>;
@@ -5,10 +5,8 @@
5
5
  * @description Composer
6
6
  */
7
7
  import type { AttachmentItem } from "../shared/types";
8
- import { type ButtonProps, type ButtonVariants } from "@gridui/button";
9
- import { type TextareaProps } from "@gridui/input";
10
- import { type ComponentPropsWithRef, type FC, type ReactNode } from "react";
11
- export type ComposerProps = Omit<ComponentPropsWithRef<"div">, "children" | "onSubmit"> & {
8
+ import { type ComponentPropsWithRef, type FC } from "react";
9
+ export type ComposerProps = Omit<ComponentPropsWithRef<"div">, "onSubmit"> & {
12
10
  readonly value: string;
13
11
  readonly onValueChange: (value: string) => void;
14
12
  readonly onSubmit: (value: string) => void;
@@ -18,25 +16,8 @@ export type ComposerProps = Omit<ComponentPropsWithRef<"div">, "children" | "onS
18
16
  readonly submitWhileBusy?: boolean;
19
17
  readonly submitShortcut?: "modifier-enter" | "enter";
20
18
  readonly layout?: "stacked" | "inline";
21
- readonly textareaProps?: Omit<TextareaProps, "value" | "defaultValue" | "onValueChange" | "disabled" | "readOnly" | "placeholder">;
22
- readonly submitButtonProps?: Omit<ButtonProps, "children" | "onClick" | "disabled" | "loading" | "type" | "aria-label"> & ButtonVariants;
23
- readonly submitContent?: ReactNode;
24
19
  readonly disabled?: boolean;
25
20
  readonly readOnly?: boolean;
26
- readonly placeholder?: string;
27
21
  readonly attachments?: readonly AttachmentItem[];
28
- readonly onRemoveAttachment?: (id: string) => void;
29
- readonly onFiles?: (files: readonly File[]) => void;
30
- readonly accept?: string;
31
- readonly tools?: ReactNode;
32
- readonly notice?: ReactNode;
33
- readonly labels: {
34
- readonly input: string;
35
- readonly submit: string;
36
- readonly stop: string;
37
- readonly attach: string;
38
- readonly attachments: string;
39
- readonly removeAttachment: (item: AttachmentItem) => string;
40
- };
41
22
  };
42
23
  export declare const Composer: FC<ComposerProps>;
@@ -7,4 +7,3 @@
7
7
  export declare const composerStyles: (props?: ({
8
8
  layout?: "inline" | "stacked" | null | undefined;
9
9
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
- export declare const composerActionsStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace ComposerActions
5
+ * @description Composer Actions
6
+ */
7
+ import type { ComponentPropsWithRef, FC } from "react";
8
+ export type ComposerActionsProps = ComponentPropsWithRef<"div">;
9
+ export declare const ComposerActions: FC<ComposerActionsProps>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace ComposerActions
5
+ * @description Style
6
+ */
7
+ export declare const composerActionsStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace ComposerAttachments
5
+ * @description Composer Attachments
6
+ */
7
+ import type { AttachmentListOptions } from "../shared/types";
8
+ import type { FC } from "react";
9
+ export type ComposerAttachmentsProps = Omit<AttachmentListOptions, "items" | "disabled">;
10
+ export declare const ComposerAttachments: FC<ComposerAttachmentsProps>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace ComposerFilePicker
5
+ * @description Composer File Picker
6
+ */
7
+ import { type FilePickerProps } from "@gridui/file-picker";
8
+ import { type FC } from "react";
9
+ export type ComposerFilePickerProps = Omit<Extract<FilePickerProps, {
10
+ multiple: true;
11
+ }>, "inputId" | "multiple" | "disabled">;
12
+ export declare const ComposerFilePicker: FC<ComposerFilePickerProps>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace ComposerInput
5
+ * @description Composer Input
6
+ */
7
+ import { type TextareaProps } from "@gridui/input";
8
+ import { type FC } from "react";
9
+ export type ComposerInputProps = Omit<TextareaProps, "value" | "defaultValue" | "onValueChange" | "disabled" | "readOnly">;
10
+ export declare const ComposerInput: FC<ComposerInputProps>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace ComposerStop
5
+ * @description Composer Stop
6
+ */
7
+ import type { ComposerActionOptions } from "../shared/composer-action-options";
8
+ import type { FC } from "react";
9
+ export type ComposerStopProps = ComposerActionOptions;
10
+ export declare const ComposerStop: FC<ComposerStopProps>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace ComposerSubmit
5
+ * @description Composer Submit
6
+ */
7
+ import type { ComposerActionOptions } from "../shared/composer-action-options";
8
+ import { type FC } from "react";
9
+ export type ComposerSubmitProps = ComposerActionOptions;
10
+ export declare const ComposerSubmit: FC<ComposerSubmitProps>;
package/dist/index.d.ts CHANGED
@@ -8,4 +8,16 @@ export type { AttachmentListProps } from "./attachment-list/attachment-list";
8
8
  export { AttachmentList } from "./attachment-list/attachment-list";
9
9
  export type { ComposerProps } from "./composer/composer";
10
10
  export { Composer } from "./composer/composer";
11
+ export type { ComposerActionsProps } from "./composer-actions/composer-actions";
12
+ export { ComposerActions } from "./composer-actions/composer-actions";
13
+ export type { ComposerAttachmentsProps } from "./composer-attachments/composer-attachments";
14
+ export { ComposerAttachments } from "./composer-attachments/composer-attachments";
15
+ export type { ComposerFilePickerProps } from "./composer-file-picker/composer-file-picker";
16
+ export { ComposerFilePicker } from "./composer-file-picker/composer-file-picker";
17
+ export type { ComposerInputProps } from "./composer-input/composer-input";
18
+ export { ComposerInput } from "./composer-input/composer-input";
19
+ export type { ComposerStopProps } from "./composer-stop/composer-stop";
20
+ export { ComposerStop } from "./composer-stop/composer-stop";
21
+ export type { ComposerSubmitProps } from "./composer-submit/composer-submit";
22
+ export { ComposerSubmit } from "./composer-submit/composer-submit";
11
23
  export type { AttachmentItem } from "./shared/types";
package/dist/index.js CHANGED
@@ -130,6 +130,17 @@ var AttachmentList = (props) => {
130
130
  );
131
131
  };
132
132
 
133
+ // src/shared/composer-context.ts
134
+ import { createContext, useContext } from "react";
135
+ var composerContext = createContext(null);
136
+ var useComposer = () => {
137
+ const composer = useContext(composerContext);
138
+ if (!composer) {
139
+ throw new Error("Composer parts require a Composer.");
140
+ }
141
+ return composer;
142
+ };
143
+
133
144
  // src/composer/style.ts
134
145
  import { cva as cva2 } from "class-variance-authority";
135
146
  var composerStyles = cva2("gridui-u-min-w-0 gridui-u-gap-gridui-8 gridui-u-border gridui-u-border-border gridui-u-bg-background gridui-u-p-gridui-16 gridui-u-text-foreground", {
@@ -143,15 +154,11 @@ var composerStyles = cva2("gridui-u-min-w-0 gridui-u-gap-gridui-8 gridui-u-borde
143
154
  layout: "stacked"
144
155
  }
145
156
  });
146
- var composerActionsStyles = cva2("gridui-u-flex gridui-u-flex-wrap gridui-u-items-center gridui-u-justify-end gridui-u-gap-gridui-8");
147
157
 
148
158
  // src/composer/composer.tsx
149
- import { Button as Button2 } from "@gridui/button";
150
- import { FilePicker } from "@gridui/file-picker";
151
- import { Textarea } from "@gridui/input";
152
159
  import { cn as cn2 } from "@gridui/style-utils";
153
- import { useId, useRef as useRef2 } from "react";
154
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
160
+ import { useRef as useRef2 } from "react";
161
+ import { jsx as jsx2 } from "react/jsx-runtime";
155
162
  var Composer = (props) => {
156
163
  const {
157
164
  value,
@@ -163,24 +170,13 @@ var Composer = (props) => {
163
170
  submitWhileBusy = false,
164
171
  submitShortcut = "modifier-enter",
165
172
  layout = "stacked",
166
- textareaProps,
167
- submitButtonProps,
168
- submitContent,
169
173
  disabled = false,
170
174
  readOnly = false,
171
- placeholder,
172
175
  attachments = [],
173
- onRemoveAttachment,
174
- onFiles,
175
- accept = "",
176
- tools,
177
- notice,
178
- labels,
176
+ children,
179
177
  className,
180
178
  ...restProps
181
179
  } = props;
182
- const id = useId();
183
- const isComposing = useRef2(false);
184
180
  const input = useRef2(null);
185
181
  const submitButton = useRef2(null);
186
182
  const inputDisabled = disabled || busy && !editableWhileBusy;
@@ -199,9 +195,108 @@ var Composer = (props) => {
199
195
  onSubmit(value);
200
196
  }
201
197
  };
198
+ return /* @__PURE__ */ jsx2(
199
+ composerContext.Provider,
200
+ {
201
+ value: {
202
+ attachments,
203
+ layout,
204
+ value,
205
+ onValueChange,
206
+ readOnly,
207
+ inputDisabled,
208
+ editingDisabled,
209
+ disabled,
210
+ submitShortcut,
211
+ canSubmit,
212
+ showStop: busy && !submitWhileBusy,
213
+ onStop,
214
+ input,
215
+ submitButton,
216
+ submit
217
+ },
218
+ children: /* @__PURE__ */ jsx2(
219
+ "div",
220
+ {
221
+ ...restProps,
222
+ className: cn2(composerStyles({ layout }), className),
223
+ children
224
+ }
225
+ )
226
+ }
227
+ );
228
+ };
229
+
230
+ // src/composer-actions/style.ts
231
+ import { cva as cva3 } from "class-variance-authority";
232
+ var composerActionsStyles = cva3("gridui-u-flex gridui-u-flex-wrap gridui-u-items-center gridui-u-justify-end gridui-u-gap-gridui-8");
233
+
234
+ // src/composer-actions/composer-actions.tsx
235
+ import { cn as cn3 } from "@gridui/style-utils";
236
+ import { jsx as jsx3 } from "react/jsx-runtime";
237
+ var ComposerActions = (props) => {
238
+ const { className, ...restProps } = props;
239
+ return /* @__PURE__ */ jsx3(
240
+ "div",
241
+ {
242
+ ...restProps,
243
+ className: cn3(composerActionsStyles(), className)
244
+ }
245
+ );
246
+ };
247
+
248
+ // src/composer-attachments/composer-attachments.tsx
249
+ import { cn as cn4 } from "@gridui/style-utils";
250
+ import { jsx as jsx4 } from "react/jsx-runtime";
251
+ var ComposerAttachments = (props) => {
252
+ const { attachments, editingDisabled, layout } = useComposer();
253
+ const { className, onRemove, ...restProps } = props;
254
+ return /* @__PURE__ */ jsx4(
255
+ AttachmentList,
256
+ {
257
+ ...restProps,
258
+ ...onRemove ? { onRemove } : {},
259
+ className: cn4(
260
+ layout === "inline" && "gridui-u-col-span-full",
261
+ layout === "inline" && attachments.length === 0 && !onRemove && "gridui-u-hidden",
262
+ className
263
+ ),
264
+ items: attachments,
265
+ disabled: editingDisabled
266
+ }
267
+ );
268
+ };
269
+
270
+ // src/composer-file-picker/composer-file-picker.tsx
271
+ import { FilePicker } from "@gridui/file-picker";
272
+ import { useId } from "react";
273
+ import { jsx as jsx5 } from "react/jsx-runtime";
274
+ var ComposerFilePicker = (props) => {
275
+ const { editingDisabled } = useComposer();
276
+ const inputId = useId();
277
+ return /* @__PURE__ */ jsx5(
278
+ FilePicker,
279
+ {
280
+ ...props,
281
+ inputId,
282
+ multiple: true,
283
+ disabled: editingDisabled
284
+ }
285
+ );
286
+ };
287
+
288
+ // src/composer-input/composer-input.tsx
289
+ import { Textarea } from "@gridui/input";
290
+ import { isComposingKeyEvent } from "@gridui/interaction";
291
+ import { useRef as useRef3 } from "react";
292
+ import { jsx as jsx6 } from "react/jsx-runtime";
293
+ var ComposerInput = (props) => {
294
+ const { ref, onKeyDown, onCompositionStart, onCompositionEnd, ...restProps } = props;
295
+ const { input, value, onValueChange, inputDisabled, readOnly, submit, submitShortcut } = useComposer();
296
+ const isComposing = useRef3(false);
202
297
  const handleKeyDown = (event) => {
203
- textareaProps?.onKeyDown?.(event);
204
- if (event.defaultPrevented || event.nativeEvent.isComposing || isComposing.current) {
298
+ onKeyDown?.(event);
299
+ if (event.defaultPrevented || isComposingKeyEvent(event.nativeEvent) || isComposing.current) {
205
300
  return;
206
301
  }
207
302
  let isSubmitShortcut = false;
@@ -215,122 +310,104 @@ var Composer = (props) => {
215
310
  submit();
216
311
  }
217
312
  };
218
- return /* @__PURE__ */ jsxs2(
219
- "div",
313
+ return /* @__PURE__ */ jsx6(
314
+ Textarea,
220
315
  {
316
+ autoSize: true,
317
+ maxHeight: 240,
221
318
  ...restProps,
222
- className: cn2(composerStyles({ layout }), className),
223
- children: [
224
- /* @__PURE__ */ jsx2(
225
- AttachmentList,
226
- {
227
- className: cn2(
228
- layout === "inline" && "gridui-u-col-span-full",
229
- layout === "inline" && attachments.length === 0 && !onRemoveAttachment && "gridui-u-hidden"
230
- ),
231
- items: attachments,
232
- label: labels.attachments,
233
- removeLabel: labels.removeAttachment,
234
- ...onRemoveAttachment ? { onRemove: onRemoveAttachment } : {},
235
- disabled: editingDisabled
236
- }
237
- ),
238
- /* @__PURE__ */ jsx2(
239
- Textarea,
240
- {
241
- autoSize: true,
242
- maxHeight: 240,
243
- ...textareaProps,
244
- ref: (element) => {
245
- input.current = element;
246
- const ref = textareaProps?.ref;
247
- if (typeof ref === "function") {
248
- return ref(element);
249
- }
250
- if (ref) {
251
- ref.current = element;
252
- }
253
- },
254
- "aria-label": labels.input,
255
- value,
256
- onValueChange,
257
- placeholder,
258
- disabled: inputDisabled,
259
- readOnly,
260
- onCompositionStart: (event) => {
261
- isComposing.current = true;
262
- textareaProps?.onCompositionStart?.(event);
263
- },
264
- onCompositionEnd: (event) => {
265
- isComposing.current = false;
266
- textareaProps?.onCompositionEnd?.(event);
267
- },
268
- onKeyDown: handleKeyDown
269
- }
270
- ),
271
- /* @__PURE__ */ jsxs2(
272
- "div",
273
- {
274
- className: composerActionsStyles(),
275
- children: [
276
- onFiles && /* @__PURE__ */ jsx2(
277
- FilePicker,
278
- {
279
- inputId: id,
280
- label: labels.attach,
281
- action: labels.attach,
282
- accept,
283
- multiple: true,
284
- onFiles,
285
- disabled: editingDisabled
286
- }
287
- ),
288
- tools,
289
- busy && !submitWhileBusy ? /* @__PURE__ */ jsx2(
290
- Button2,
291
- {
292
- variant: "secondary",
293
- onClick: onStop,
294
- disabled: disabled || !onStop,
295
- children: labels.stop
296
- }
297
- ) : /* @__PURE__ */ jsx2(
298
- Button2,
299
- {
300
- ...submitButtonProps,
301
- ref: (element) => {
302
- submitButton.current = element;
303
- const ref = submitButtonProps?.ref;
304
- if (typeof ref === "function") {
305
- return ref(element);
306
- }
307
- if (ref) {
308
- ref.current = element;
309
- }
310
- },
311
- type: "button",
312
- "aria-label": labels.submit,
313
- onClick: submit,
314
- disabled: !canSubmit,
315
- children: submitContent ?? labels.submit
316
- }
317
- )
318
- ]
319
- }
320
- ),
321
- notice && /* @__PURE__ */ jsx2(
322
- "div",
323
- {
324
- className: layout === "inline" ? "gridui-u-col-span-full" : void 0,
325
- children: notice
319
+ ref: (element) => {
320
+ input.current = element;
321
+ const cleanup = typeof ref === "function" ? ref(element) : void 0;
322
+ if (ref && typeof ref !== "function") {
323
+ ref.current = element;
324
+ }
325
+ if (!element) {
326
+ return;
327
+ }
328
+ return () => {
329
+ input.current = null;
330
+ if (typeof cleanup === "function") {
331
+ cleanup();
332
+ } else if (typeof ref === "function") {
333
+ ref(null);
334
+ } else if (ref) {
335
+ ref.current = null;
326
336
  }
327
- )
328
- ]
337
+ };
338
+ },
339
+ value,
340
+ onValueChange,
341
+ disabled: inputDisabled,
342
+ readOnly,
343
+ onCompositionStart: (event) => {
344
+ isComposing.current = true;
345
+ onCompositionStart?.(event);
346
+ },
347
+ onCompositionEnd: (event) => {
348
+ isComposing.current = false;
349
+ onCompositionEnd?.(event);
350
+ },
351
+ onKeyDown: handleKeyDown
352
+ }
353
+ );
354
+ };
355
+
356
+ // src/composer-stop/composer-stop.tsx
357
+ import { Button as Button2 } from "@gridui/button";
358
+ import { jsx as jsx7 } from "react/jsx-runtime";
359
+ var ComposerStop = (props) => {
360
+ const { disabled, onStop, showStop } = useComposer();
361
+ if (!showStop) {
362
+ return null;
363
+ }
364
+ const appearance = props.variant === void 0 || props.variant === null ? {
365
+ ...props,
366
+ variant: "secondary"
367
+ } : props;
368
+ return /* @__PURE__ */ jsx7(
369
+ Button2,
370
+ {
371
+ ...appearance,
372
+ type: "button",
373
+ disabled: disabled || !onStop,
374
+ onClick: onStop
375
+ }
376
+ );
377
+ };
378
+
379
+ // src/composer-submit/composer-submit.tsx
380
+ import { Button as Button3 } from "@gridui/button";
381
+ import { useImperativeHandle } from "react";
382
+ import { jsx as jsx8 } from "react/jsx-runtime";
383
+ var ComposerSubmit = (props) => {
384
+ const { ref, ...restProps } = props;
385
+ const { canSubmit, showStop, submit, submitButton } = useComposer();
386
+ useImperativeHandle(ref, () => {
387
+ return submitButton.current;
388
+ });
389
+ if (showStop) {
390
+ return null;
391
+ }
392
+ return /* @__PURE__ */ jsx8(
393
+ Button3,
394
+ {
395
+ ...restProps,
396
+ ref: submitButton,
397
+ type: "button",
398
+ disabled: !canSubmit,
399
+ onClick: submit
329
400
  }
330
401
  );
331
402
  };
332
403
  export {
333
404
  AttachmentList,
334
- Composer
405
+ Composer,
406
+ ComposerActions,
407
+ ComposerAttachments,
408
+ ComposerFilePicker,
409
+ ComposerInput,
410
+ ComposerStop,
411
+ ComposerSubmit
335
412
  };
336
413
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/attachment-list/style.ts", "../src/attachment-list/attachment-list.tsx", "../src/composer/style.ts", "../src/composer/composer.tsx"],
4
- "sourcesContent": ["/**\n * @author WMXPY\n * @package Composer\n * @namespace AttachmentList\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const attachmentListStyles = cva(\"gridui-u-m-0 gridui-u-flex gridui-u-min-w-0 gridui-u-list-none gridui-u-flex-col gridui-u-p-0 gridui-u-focus:min-h-11\");\n\nexport const attachmentStyles = cva(\"gridui-u-flex gridui-u-min-w-0 gridui-u-flex-wrap gridui-u-items-center gridui-u-gap-gridui-8 gridui-u-border-b gridui-u-border-border gridui-u-py-gridui-8 gridui-u-data-[state=error]:text-danger-foreground\");\n\nexport const attachmentCopyStyles = cva(\"gridui-u-flex gridui-u-min-w-0 gridui-u-flex-1 gridui-u-flex-col gridui-u-wrap-anywhere\");\n\nexport const attachmentMetaStyles = cva(\"gridui-u-text-muted gridui-u-type-caption\");\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace AttachmentList\n * @description Attachment List\n */\n\nimport type { AttachmentItem } from \"../shared/types\";\nimport { attachmentCopyStyles, attachmentListStyles, attachmentMetaStyles, attachmentStyles } from \"./style\";\nimport { Button } from \"@gridui/button\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, useLayoutEffect, useRef } from \"react\";\n\nexport type AttachmentListProps = Omit<ComponentPropsWithRef<\"ul\">, \"children\"> & {\n readonly items: readonly AttachmentItem[];\n readonly label: string;\n readonly removeLabel: (item: AttachmentItem) => string;\n readonly onRemove?: (id: string) => void;\n readonly disabled?: boolean;\n};\n\nexport const AttachmentList: FC<AttachmentListProps> = (props: AttachmentListProps) => {\n const {\n items,\n label,\n removeLabel,\n onRemove,\n disabled = false,\n className,\n ref,\n ...restProps\n } = props;\n const buttons = useRef(new Map<string, HTMLButtonElement>());\n const pending = useRef<{\n id: string;\n index: number;\n element: HTMLButtonElement;\n } | null>(null);\n const list = useRef<HTMLUListElement | null>(null);\n useLayoutEffect(() => {\n const removed = pending.current;\n if (removed && !items.some(item => {\n return item.id === removed.id;\n })) {\n const document = removed.element.ownerDocument;\n const active = document.activeElement;\n if (active === removed.element || active === document.body) {\n const next = items[Math.min(removed.index, items.length - 1)];\n (next ? buttons.current.get(next.id) : list.current)?.focus();\n }\n pending.current = null;\n }\n }, [items]);\n return (<ul\n {...restProps}\n ref={element => {\n list.current = element;\n if (typeof ref === \"function\") {\n return ref(element);\n }\n if (ref) {\n ref.current = element;\n }\n }}\n aria-label={label}\n tabIndex={-1}\n className={cn(attachmentListStyles(), className)}\n >\n {items.map((item, index) => {\n return (<li\n key={item.id}\n className={attachmentStyles()}\n data-state={item.state}\n >\n <div\n className={attachmentCopyStyles()}\n >\n <span>\n {item.name}\n </span>\n <span\n className={attachmentMetaStyles()}\n >\n {item.description}\n </span>\n <span\n className={attachmentMetaStyles()}\n >\n {item.stateLabel}\n </span>\n </div>\n {onRemove && (<Button\n ref={element => {\n if (element) {\n buttons.current.set(item.id, element);\n } else {\n buttons.current.delete(item.id);\n }\n }}\n variant=\"quiet\"\n layout=\"icon\"\n aria-label={removeLabel(item)}\n title={removeLabel(item)}\n disabled={disabled}\n onBlur={event => {\n if (event.relatedTarget && pending.current?.element === event.currentTarget) {\n pending.current = null;\n }\n }}\n onClick={event => {\n pending.current = {\n id: item.id,\n index,\n element: event.currentTarget,\n };\n onRemove(item.id);\n }}\n >\n <span\n aria-hidden=\"true\"\n >\n \u00D7\n </span>\n </Button>)}\n </li>);\n })}\n </ul>);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace Composer\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const composerStyles = cva(\"gridui-u-min-w-0 gridui-u-gap-gridui-8 gridui-u-border gridui-u-border-border gridui-u-bg-background gridui-u-p-gridui-16 gridui-u-text-foreground\", {\n variants: {\n layout: {\n stacked: \"gridui-u-flex gridui-u-flex-col\",\n inline: \"gridui-u-grid gridui-u-grid-cols-[minmax(0,1fr)_auto] gridui-u-items-end\",\n },\n },\n defaultVariants: {\n layout: \"stacked\",\n },\n});\n\nexport const composerActionsStyles = cva(\"gridui-u-flex gridui-u-flex-wrap gridui-u-items-center gridui-u-justify-end gridui-u-gap-gridui-8\");\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace Composer\n * @description Composer\n */\n\nimport { AttachmentList } from \"../attachment-list/attachment-list\";\nimport type { AttachmentItem } from \"../shared/types\";\nimport { composerActionsStyles, composerStyles } from \"./style\";\nimport { Button, type ButtonProps, type ButtonVariants } from \"@gridui/button\";\nimport { FilePicker } from \"@gridui/file-picker\";\nimport { Textarea, type TextareaProps } from \"@gridui/input\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, type KeyboardEvent, type ReactNode, useId, useRef } from \"react\";\n\nexport type ComposerProps = Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onSubmit\"> & {\n readonly value: string;\n readonly onValueChange: (value: string) => void;\n readonly onSubmit: (value: string) => void;\n readonly onStop?: () => void;\n readonly busy?: boolean;\n readonly editableWhileBusy?: boolean;\n readonly submitWhileBusy?: boolean;\n readonly submitShortcut?: \"modifier-enter\" | \"enter\";\n readonly layout?: \"stacked\" | \"inline\";\n readonly textareaProps?: Omit<TextareaProps, \"value\" | \"defaultValue\" | \"onValueChange\" | \"disabled\" | \"readOnly\" | \"placeholder\">;\n readonly submitButtonProps?: Omit<ButtonProps, \"children\" | \"onClick\" | \"disabled\" | \"loading\" | \"type\" | \"aria-label\"> & ButtonVariants;\n readonly submitContent?: ReactNode;\n readonly disabled?: boolean;\n readonly readOnly?: boolean;\n readonly placeholder?: string;\n readonly attachments?: readonly AttachmentItem[];\n readonly onRemoveAttachment?: (id: string) => void;\n readonly onFiles?: (files: readonly File[]) => void;\n readonly accept?: string;\n readonly tools?: ReactNode;\n readonly notice?: ReactNode;\n readonly labels: {\n readonly input: string;\n readonly submit: string;\n readonly stop: string;\n readonly attach: string;\n readonly attachments: string;\n readonly removeAttachment: (item: AttachmentItem) => string;\n };\n};\n\nexport const Composer: FC<ComposerProps> = (props: ComposerProps) => {\n const {\n value,\n onValueChange,\n onSubmit,\n onStop,\n busy = false,\n editableWhileBusy = false,\n submitWhileBusy = false,\n submitShortcut = \"modifier-enter\",\n layout = \"stacked\",\n textareaProps,\n submitButtonProps,\n submitContent,\n disabled = false,\n readOnly = false,\n placeholder,\n attachments = [],\n onRemoveAttachment,\n onFiles,\n accept = \"\",\n tools,\n notice,\n labels,\n className,\n ...restProps\n } = props;\n const id = useId();\n const isComposing = useRef(false);\n const input = useRef<HTMLTextAreaElement>(null);\n const submitButton = useRef<HTMLButtonElement>(null);\n const inputDisabled = disabled || (busy && !editableWhileBusy);\n const editingDisabled = inputDisabled || readOnly;\n const hasContent = value.trim().length > 0 || attachments.length > 0;\n const attachmentsReady = attachments.every(item => {\n return item.state === \"ready\";\n });\n const canSubmit = !disabled && !readOnly && (!busy || submitWhileBusy) && hasContent && attachmentsReady;\n const submit = () => {\n const element = input.current;\n if (!canSubmit || !element || !submitButton.current || submitButton.current.matches(\":disabled\")) {\n return;\n }\n if (element.reportValidity()) {\n onSubmit(value);\n }\n };\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n textareaProps?.onKeyDown?.(event);\n if (event.defaultPrevented || event.nativeEvent.isComposing || isComposing.current) {\n return;\n }\n let isSubmitShortcut = false;\n if (submitShortcut === \"enter\") {\n isSubmitShortcut = event.key === \"Enter\" && !event.shiftKey;\n } else {\n isSubmitShortcut = event.key === \"Enter\" && (event.ctrlKey || event.metaKey);\n }\n if (isSubmitShortcut) {\n event.preventDefault();\n submit();\n }\n };\n return (<div\n {...restProps}\n className={cn(composerStyles({ layout }), className)}\n >\n <AttachmentList\n className={cn(\n layout === \"inline\" && \"gridui-u-col-span-full\",\n layout === \"inline\" && attachments.length === 0 && !onRemoveAttachment && \"gridui-u-hidden\",\n )}\n items={attachments}\n label={labels.attachments}\n removeLabel={labels.removeAttachment}\n {...(onRemoveAttachment ? { onRemove: onRemoveAttachment } : {})}\n disabled={editingDisabled}\n />\n <Textarea\n autoSize\n maxHeight={240}\n {...textareaProps}\n ref={element => {\n input.current = element;\n const ref = textareaProps?.ref;\n if (typeof ref === \"function\") {\n return ref(element);\n }\n if (ref) {\n ref.current = element;\n }\n }}\n aria-label={labels.input}\n value={value}\n onValueChange={onValueChange}\n placeholder={placeholder}\n disabled={inputDisabled}\n readOnly={readOnly}\n onCompositionStart={event => {\n isComposing.current = true;\n textareaProps?.onCompositionStart?.(event);\n }}\n onCompositionEnd={event => {\n isComposing.current = false;\n textareaProps?.onCompositionEnd?.(event);\n }}\n onKeyDown={handleKeyDown}\n />\n <div\n className={composerActionsStyles()}\n >\n {onFiles && (<FilePicker\n inputId={id}\n label={labels.attach}\n action={labels.attach}\n accept={accept}\n multiple\n onFiles={onFiles}\n disabled={editingDisabled}\n />)}\n {tools}\n {busy && !submitWhileBusy ? (<Button\n variant=\"secondary\"\n onClick={onStop}\n disabled={disabled || !onStop}\n >\n {labels.stop}\n </Button>)\n : (<Button\n {...submitButtonProps}\n ref={element => {\n submitButton.current = element;\n const ref = submitButtonProps?.ref;\n if (typeof ref === \"function\") {\n return ref(element);\n }\n if (ref) {\n ref.current = element;\n }\n }}\n type=\"button\"\n aria-label={labels.submit}\n onClick={submit}\n disabled={!canSubmit}\n >\n {submitContent ?? labels.submit}\n </Button>)}\n </div>\n {notice && (<div\n className={layout === \"inline\" ? \"gridui-u-col-span-full\" : undefined}\n >\n {notice}\n </div>)}\n </div>);\n};\n"],
5
- "mappings": ";AAOA,SAAS,WAAW;AAEb,IAAM,uBAAuB,IAAI,uHAAuH;AAExJ,IAAM,mBAAmB,IAAI,gNAAgN;AAE7O,IAAM,uBAAuB,IAAI,yFAAyF;AAE1H,IAAM,uBAAuB,IAAI,2CAA2C;;;ACNnF,SAA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AA,YAE3D;AAAA;AAAA,QACL;AAAA;AAAA;AAAA,EACJ;AACJ;",
6
- "names": ["cva", "Button", "cn", "useRef", "jsx", "jsxs"]
3
+ "sources": ["../src/attachment-list/style.ts", "../src/attachment-list/attachment-list.tsx", "../src/shared/composer-context.ts", "../src/composer/style.ts", "../src/composer/composer.tsx", "../src/composer-actions/style.ts", "../src/composer-actions/composer-actions.tsx", "../src/composer-attachments/composer-attachments.tsx", "../src/composer-file-picker/composer-file-picker.tsx", "../src/composer-input/composer-input.tsx", "../src/composer-stop/composer-stop.tsx", "../src/composer-submit/composer-submit.tsx"],
4
+ "sourcesContent": ["/**\n * @author WMXPY\n * @package Composer\n * @namespace AttachmentList\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const attachmentListStyles = cva(\"gridui-u-m-0 gridui-u-flex gridui-u-min-w-0 gridui-u-list-none gridui-u-flex-col gridui-u-p-0 gridui-u-focus:min-h-11\");\n\nexport const attachmentStyles = cva(\"gridui-u-flex gridui-u-min-w-0 gridui-u-flex-wrap gridui-u-items-center gridui-u-gap-gridui-8 gridui-u-border-b gridui-u-border-border gridui-u-py-gridui-8 gridui-u-data-[state=error]:text-danger-foreground\");\n\nexport const attachmentCopyStyles = cva(\"gridui-u-flex gridui-u-min-w-0 gridui-u-flex-1 gridui-u-flex-col gridui-u-wrap-anywhere\");\n\nexport const attachmentMetaStyles = cva(\"gridui-u-text-muted gridui-u-type-caption\");\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace AttachmentList\n * @description Attachment List\n */\n\nimport type { AttachmentListOptions } from \"../shared/types\";\nimport { attachmentCopyStyles, attachmentListStyles, attachmentMetaStyles, attachmentStyles } from \"./style\";\nimport { Button } from \"@gridui/button\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type FC, useLayoutEffect, useRef } from \"react\";\n\nexport type AttachmentListProps = AttachmentListOptions;\n\nexport const AttachmentList: FC<AttachmentListProps> = (props: AttachmentListProps) => {\n const {\n items,\n label,\n removeLabel,\n onRemove,\n disabled = false,\n className,\n ref,\n ...restProps\n } = props;\n const buttons = useRef(new Map<string, HTMLButtonElement>());\n const pending = useRef<{\n id: string;\n index: number;\n element: HTMLButtonElement;\n } | null>(null);\n const list = useRef<HTMLUListElement | null>(null);\n useLayoutEffect(() => {\n const removed = pending.current;\n if (removed && !items.some(item => {\n return item.id === removed.id;\n })) {\n const document = removed.element.ownerDocument;\n const active = document.activeElement;\n if (active === removed.element || active === document.body) {\n const next = items[Math.min(removed.index, items.length - 1)];\n (next ? buttons.current.get(next.id) : list.current)?.focus();\n }\n pending.current = null;\n }\n }, [items]);\n return (<ul\n {...restProps}\n ref={element => {\n list.current = element;\n if (typeof ref === \"function\") {\n return ref(element);\n }\n if (ref) {\n ref.current = element;\n }\n }}\n aria-label={label}\n tabIndex={-1}\n className={cn(attachmentListStyles(), className)}\n >\n {items.map((item, index) => {\n return (<li\n key={item.id}\n className={attachmentStyles()}\n data-state={item.state}\n >\n <div\n className={attachmentCopyStyles()}\n >\n <span>\n {item.name}\n </span>\n <span\n className={attachmentMetaStyles()}\n >\n {item.description}\n </span>\n <span\n className={attachmentMetaStyles()}\n >\n {item.stateLabel}\n </span>\n </div>\n {onRemove && (<Button\n ref={element => {\n if (element) {\n buttons.current.set(item.id, element);\n } else {\n buttons.current.delete(item.id);\n }\n }}\n variant=\"quiet\"\n layout=\"icon\"\n aria-label={removeLabel(item)}\n title={removeLabel(item)}\n disabled={disabled}\n onBlur={event => {\n if (event.relatedTarget && pending.current?.element === event.currentTarget) {\n pending.current = null;\n }\n }}\n onClick={event => {\n pending.current = {\n id: item.id,\n index,\n element: event.currentTarget,\n };\n onRemove(item.id);\n }}\n >\n <span\n aria-hidden=\"true\"\n >\n \u00D7\n </span>\n </Button>)}\n </li>);\n })}\n </ul>);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace Shared\n * @description Composer Context\n */\n\nimport type { AttachmentItem } from \"./types\";\nimport { createContext, type RefObject, useContext } from \"react\";\n\nexport type ComposerContext = {\n readonly attachments: readonly AttachmentItem[];\n readonly layout: \"stacked\" | \"inline\";\n readonly value: string;\n readonly onValueChange: (value: string) => void;\n readonly readOnly: boolean;\n readonly inputDisabled: boolean;\n readonly editingDisabled: boolean;\n readonly disabled: boolean;\n readonly submitShortcut: \"modifier-enter\" | \"enter\";\n readonly canSubmit: boolean;\n readonly showStop: boolean;\n readonly onStop: (() => void) | undefined;\n readonly input: RefObject<HTMLTextAreaElement | null>;\n readonly submitButton: RefObject<HTMLButtonElement | null>;\n readonly submit: () => void;\n};\n\nexport const composerContext = createContext<ComposerContext | null>(null);\n\nexport const useComposer = (): ComposerContext => {\n const composer = useContext(composerContext);\n if (!composer) {\n throw new Error(\"Composer parts require a Composer.\");\n }\n return composer;\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace Composer\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const composerStyles = cva(\"gridui-u-min-w-0 gridui-u-gap-gridui-8 gridui-u-border gridui-u-border-border gridui-u-bg-background gridui-u-p-gridui-16 gridui-u-text-foreground\", {\n variants: {\n layout: {\n stacked: \"gridui-u-flex gridui-u-flex-col\",\n inline: \"gridui-u-grid gridui-u-grid-cols-[minmax(0,1fr)_auto] gridui-u-items-end\",\n },\n },\n defaultVariants: {\n layout: \"stacked\",\n },\n});\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace Composer\n * @description Composer\n */\n\nimport { composerContext } from \"../shared/composer-context\";\nimport type { AttachmentItem } from \"../shared/types\";\nimport { composerStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, useRef } from \"react\";\n\nexport type ComposerProps = Omit<ComponentPropsWithRef<\"div\">, \"onSubmit\"> & {\n readonly value: string;\n readonly onValueChange: (value: string) => void;\n readonly onSubmit: (value: string) => void;\n readonly onStop?: () => void;\n readonly busy?: boolean;\n readonly editableWhileBusy?: boolean;\n readonly submitWhileBusy?: boolean;\n readonly submitShortcut?: \"modifier-enter\" | \"enter\";\n readonly layout?: \"stacked\" | \"inline\";\n readonly disabled?: boolean;\n readonly readOnly?: boolean;\n readonly attachments?: readonly AttachmentItem[];\n};\n\nexport const Composer: FC<ComposerProps> = (props: ComposerProps) => {\n const { value, onValueChange, onSubmit, onStop, busy = false, editableWhileBusy = false,\n submitWhileBusy = false, submitShortcut = \"modifier-enter\", layout = \"stacked\",\n disabled = false, readOnly = false, attachments = [], children, className, ...restProps } = props;\n const input = useRef<HTMLTextAreaElement>(null);\n const submitButton = useRef<HTMLButtonElement>(null);\n const inputDisabled = disabled || (busy && !editableWhileBusy);\n const editingDisabled = inputDisabled || readOnly;\n const hasContent = value.trim().length > 0 || attachments.length > 0;\n const attachmentsReady = attachments.every(item => {\n return item.state === \"ready\";\n });\n const canSubmit = !disabled && !readOnly && (!busy || submitWhileBusy) && hasContent && attachmentsReady;\n const submit = () => {\n const element = input.current;\n if (!canSubmit || !element || !submitButton.current || submitButton.current.matches(\":disabled\")) {\n return;\n }\n if (element.reportValidity()) {\n onSubmit(value);\n }\n };\n\n return (<composerContext.Provider\n value={{\n attachments,\n layout,\n value,\n onValueChange,\n readOnly,\n inputDisabled,\n editingDisabled,\n disabled,\n submitShortcut,\n canSubmit,\n showStop: busy && !submitWhileBusy,\n onStop,\n input,\n submitButton,\n submit,\n }}\n >\n <div\n {...restProps}\n className={cn(composerStyles({ layout }), className)}\n >\n {children}\n </div>\n </composerContext.Provider>);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace ComposerActions\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const composerActionsStyles = cva(\"gridui-u-flex gridui-u-flex-wrap gridui-u-items-center gridui-u-justify-end gridui-u-gap-gridui-8\");\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace ComposerActions\n * @description Composer Actions\n */\n\nimport { composerActionsStyles } from \"./style\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ComposerActionsProps = ComponentPropsWithRef<\"div\">;\n\nexport const ComposerActions: FC<ComposerActionsProps> = (props: ComposerActionsProps) => {\n const { className, ...restProps } = props;\n return (<div\n {...restProps}\n className={cn(composerActionsStyles(), className)}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace ComposerAttachments\n * @description Composer Attachments\n */\n\nimport { AttachmentList } from \"../attachment-list/attachment-list\";\nimport { useComposer } from \"../shared/composer-context\";\nimport type { AttachmentListOptions } from \"../shared/types\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type ComposerAttachmentsProps = Omit<AttachmentListOptions, \"items\" | \"disabled\">;\n\nexport const ComposerAttachments: FC<ComposerAttachmentsProps> = (props: ComposerAttachmentsProps) => {\n const { attachments, editingDisabled, layout } = useComposer();\n const { className, onRemove, ...restProps } = props;\n return (<AttachmentList\n {...restProps}\n {...(onRemove ? { onRemove } : {})}\n className={cn(\n layout === \"inline\" && \"gridui-u-col-span-full\",\n layout === \"inline\" && attachments.length === 0 && !onRemove && \"gridui-u-hidden\",\n className,\n )}\n items={attachments}\n disabled={editingDisabled}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace ComposerFilePicker\n * @description Composer File Picker\n */\n\nimport { useComposer } from \"../shared/composer-context\";\nimport { FilePicker, type FilePickerProps } from \"@gridui/file-picker\";\nimport { type FC, useId } from \"react\";\n\nexport type ComposerFilePickerProps = Omit<Extract<FilePickerProps, {\n multiple: true;\n}>, \"inputId\" | \"multiple\" | \"disabled\">;\n\nexport const ComposerFilePicker: FC<ComposerFilePickerProps> = (props: ComposerFilePickerProps) => {\n const { editingDisabled } = useComposer();\n const inputId = useId();\n return (<FilePicker\n {...props}\n inputId={inputId}\n multiple\n disabled={editingDisabled}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace ComposerInput\n * @description Composer Input\n */\n\nimport { useComposer } from \"../shared/composer-context\";\nimport { Textarea, type TextareaProps } from \"@gridui/input\";\nimport { isComposingKeyEvent } from \"@gridui/interaction\";\nimport { type FC, type KeyboardEvent, useRef } from \"react\";\n\nexport type ComposerInputProps = Omit<TextareaProps, \"value\" | \"defaultValue\" | \"onValueChange\" | \"disabled\" | \"readOnly\">;\n\nexport const ComposerInput: FC<ComposerInputProps> = (props: ComposerInputProps) => {\n const { ref, onKeyDown, onCompositionStart, onCompositionEnd, ...restProps } = props;\n const { input, value, onValueChange, inputDisabled, readOnly, submit, submitShortcut } = useComposer();\n const isComposing = useRef(false);\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isComposingKeyEvent(event.nativeEvent) || isComposing.current) {\n return;\n }\n let isSubmitShortcut = false;\n if (submitShortcut === \"enter\") {\n isSubmitShortcut = event.key === \"Enter\" && !event.shiftKey;\n } else {\n isSubmitShortcut = event.key === \"Enter\" && (event.ctrlKey || event.metaKey);\n }\n if (isSubmitShortcut) {\n event.preventDefault();\n submit();\n }\n };\n\n return (<Textarea\n autoSize\n maxHeight={240}\n {...restProps}\n ref={element => {\n input.current = element;\n const cleanup = typeof ref === \"function\" ? ref(element) : undefined;\n if (ref && typeof ref !== \"function\") {\n ref.current = element;\n }\n if (!element) {\n return;\n }\n return () => {\n input.current = null;\n if (typeof cleanup === \"function\") {\n cleanup();\n } else if (typeof ref === \"function\") {\n ref(null);\n } else if (ref) {\n ref.current = null;\n }\n };\n }}\n value={value}\n onValueChange={onValueChange}\n disabled={inputDisabled}\n readOnly={readOnly}\n onCompositionStart={event => {\n isComposing.current = true;\n onCompositionStart?.(event);\n }}\n onCompositionEnd={event => {\n isComposing.current = false;\n onCompositionEnd?.(event);\n }}\n onKeyDown={handleKeyDown}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace ComposerStop\n * @description Composer Stop\n */\n\nimport type { ComposerActionOptions } from \"../shared/composer-action-options\";\nimport { useComposer } from \"../shared/composer-context\";\nimport { Button } from \"@gridui/button\";\nimport type { FC } from \"react\";\n\nexport type ComposerStopProps = ComposerActionOptions;\n\nexport const ComposerStop: FC<ComposerStopProps> = (props: ComposerStopProps) => {\n const { disabled, onStop, showStop } = useComposer();\n if (!showStop) {\n return null;\n }\n const appearance = props.variant === undefined || props.variant === null ? {\n ...props,\n variant: \"secondary\" as const,\n } : props;\n return (<Button\n {...appearance}\n type=\"button\"\n disabled={disabled || !onStop}\n onClick={onStop}\n />);\n};\n", "/**\n * @author WMXPY\n * @package Composer\n * @namespace ComposerSubmit\n * @description Composer Submit\n */\n\nimport type { ComposerActionOptions } from \"../shared/composer-action-options\";\nimport { useComposer } from \"../shared/composer-context\";\nimport { Button } from \"@gridui/button\";\nimport { type FC, useImperativeHandle } from \"react\";\n\nexport type ComposerSubmitProps = ComposerActionOptions;\n\nexport const ComposerSubmit: FC<ComposerSubmitProps> = (props: ComposerSubmitProps) => {\n const { ref, ...restProps } = props;\n const { canSubmit, showStop, submit, submitButton } = useComposer();\n useImperativeHandle(ref, () => {\n return submitButton.current!;\n });\n if (showStop) {\n return null;\n }\n return (<Button\n {...restProps}\n ref={submitButton}\n type=\"button\"\n disabled={!canSubmit}\n onClick={submit}\n />);\n};\n"],
5
+ "mappings": ";AAOA,SAAS,WAAW;AAEb,IAAM,uBAAuB,IAAI,uHAAuH;AAExJ,IAAM,mBAAmB,IAAI,gNAAgN;AAE7O,IAAM,uBAAuB,IAAI,yFAAyF;AAE1H,IAAM,uBAAuB,IAAI,2CAA2C;;;ACNnF,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAkB,iBAAiB,cAAc;AAyDjC,SAGI,KAHJ;AArDT,IAAM,iBAA0C,CAAC,UAA+B;AACnF,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACP,IAAI;AACJ,QAAM,UAAU,OAAO,oBAAI,IAA+B,CAAC;AAC3D,QAAM,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x", "Button", "jsx"]
7
7
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace Shared
5
+ * @description Composer Action Options
6
+ */
7
+ import type { ButtonProps, ButtonVariants } from "@gridui/button";
8
+ export type ComposerActionOptions = Omit<ButtonProps, "disabled" | "loading" | "onClick" | "type"> & ButtonVariants;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Composer
4
+ * @namespace Shared
5
+ * @description Composer Context
6
+ */
7
+ import type { AttachmentItem } from "./types";
8
+ import { type RefObject } from "react";
9
+ export type ComposerContext = {
10
+ readonly attachments: readonly AttachmentItem[];
11
+ readonly layout: "stacked" | "inline";
12
+ readonly value: string;
13
+ readonly onValueChange: (value: string) => void;
14
+ readonly readOnly: boolean;
15
+ readonly inputDisabled: boolean;
16
+ readonly editingDisabled: boolean;
17
+ readonly disabled: boolean;
18
+ readonly submitShortcut: "modifier-enter" | "enter";
19
+ readonly canSubmit: boolean;
20
+ readonly showStop: boolean;
21
+ readonly onStop: (() => void) | undefined;
22
+ readonly input: RefObject<HTMLTextAreaElement | null>;
23
+ readonly submitButton: RefObject<HTMLButtonElement | null>;
24
+ readonly submit: () => void;
25
+ };
26
+ export declare const composerContext: import("react").Context<ComposerContext | null>;
27
+ export declare const useComposer: () => ComposerContext;
@@ -4,6 +4,7 @@
4
4
  * @namespace Shared
5
5
  * @description Types
6
6
  */
7
+ import type { ComponentPropsWithRef } from "react";
7
8
  export type AttachmentItem = {
8
9
  readonly id: string;
9
10
  readonly name: string;
@@ -11,3 +12,10 @@ export type AttachmentItem = {
11
12
  readonly stateLabel: string;
12
13
  readonly description?: string;
13
14
  };
15
+ export type AttachmentListOptions = Omit<ComponentPropsWithRef<"ul">, "children"> & {
16
+ readonly items: readonly AttachmentItem[];
17
+ readonly label: string;
18
+ readonly removeLabel: (item: AttachmentItem) => string;
19
+ readonly onRemove?: (id: string) => void;
20
+ readonly disabled?: boolean;
21
+ };
package/dist/styles.css CHANGED
@@ -1,4 +1,4 @@
1
- /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
1
+ /*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
2
2
  @layer properties;
3
3
  @layer theme, base, components, utilities;
4
4
  @layer theme {
@@ -101,7 +101,7 @@
101
101
  initial-value: solid;
102
102
  }
103
103
  @layer properties {
104
- @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
104
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: block))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
105
105
  *, ::before, ::after, ::backdrop {
106
106
  --tw-border-style: solid;
107
107
  }
@@ -0,0 +1,110 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "name": "@gridui/composer",
4
+ "version": "2.0.0",
5
+ "category": "dashboard",
6
+ "description": "GridUI React composer",
7
+ "usage": "Button and keyboard submission share the textarea's native constraint validation, including `required`, `minLength`, and custom validity. Invalid enabled inputs report their validation message and retain focus. Textarea and submit button refs are forwarded through their respective props. A disabled fieldset blocks both submission paths.",
8
+ "documentation": [
9
+ "README.md"
10
+ ],
11
+ "exports": [
12
+ {
13
+ "name": "AttachmentItem",
14
+ "kind": "type",
15
+ "importPath": "@gridui/composer"
16
+ },
17
+ {
18
+ "name": "AttachmentList",
19
+ "kind": "component",
20
+ "importPath": "@gridui/composer"
21
+ },
22
+ {
23
+ "name": "AttachmentListProps",
24
+ "kind": "type",
25
+ "importPath": "@gridui/composer"
26
+ },
27
+ {
28
+ "name": "Composer",
29
+ "kind": "component",
30
+ "importPath": "@gridui/composer"
31
+ },
32
+ {
33
+ "name": "ComposerActions",
34
+ "kind": "component",
35
+ "importPath": "@gridui/composer"
36
+ },
37
+ {
38
+ "name": "ComposerActionsProps",
39
+ "kind": "type",
40
+ "importPath": "@gridui/composer"
41
+ },
42
+ {
43
+ "name": "ComposerAttachments",
44
+ "kind": "component",
45
+ "importPath": "@gridui/composer"
46
+ },
47
+ {
48
+ "name": "ComposerAttachmentsProps",
49
+ "kind": "type",
50
+ "importPath": "@gridui/composer"
51
+ },
52
+ {
53
+ "name": "ComposerFilePicker",
54
+ "kind": "component",
55
+ "importPath": "@gridui/composer"
56
+ },
57
+ {
58
+ "name": "ComposerFilePickerProps",
59
+ "kind": "type",
60
+ "importPath": "@gridui/composer"
61
+ },
62
+ {
63
+ "name": "ComposerInput",
64
+ "kind": "component",
65
+ "importPath": "@gridui/composer"
66
+ },
67
+ {
68
+ "name": "ComposerInputProps",
69
+ "kind": "type",
70
+ "importPath": "@gridui/composer"
71
+ },
72
+ {
73
+ "name": "ComposerProps",
74
+ "kind": "type",
75
+ "importPath": "@gridui/composer"
76
+ },
77
+ {
78
+ "name": "ComposerStop",
79
+ "kind": "component",
80
+ "importPath": "@gridui/composer"
81
+ },
82
+ {
83
+ "name": "ComposerStopProps",
84
+ "kind": "type",
85
+ "importPath": "@gridui/composer"
86
+ },
87
+ {
88
+ "name": "ComposerSubmit",
89
+ "kind": "component",
90
+ "importPath": "@gridui/composer"
91
+ },
92
+ {
93
+ "name": "ComposerSubmitProps",
94
+ "kind": "type",
95
+ "importPath": "@gridui/composer"
96
+ }
97
+ ],
98
+ "styles": [
99
+ "@gridui/theme/styles.css",
100
+ "@gridui/button/styles.css",
101
+ "@gridui/form/styles.css",
102
+ "@gridui/overlay/styles.css",
103
+ "@gridui/input/styles.css",
104
+ "@gridui/file-picker/styles.css",
105
+ "@gridui/composer/styles.css"
106
+ ],
107
+ "examples": [
108
+ "https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-dashboard/composer/stories/composer.stories.tsx"
109
+ ]
110
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@gridui/composer",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "description": "GridUI React composer",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist",
9
- "README.md"
9
+ "README.md",
10
+ "docs"
10
11
  ],
11
12
  "sideEffects": [
12
13
  "**/*.css"
@@ -26,17 +27,18 @@
26
27
  "react-dom": "^19.2.0"
27
28
  },
28
29
  "dependencies": {
29
- "@gridui/button": "^3.0.0",
30
- "@gridui/file-picker": "^1.0.4",
31
- "@gridui/input": "^1.1.2",
32
- "@gridui/style-utils": "^2.1.4",
33
- "@gridui/theme": "^2.4.0",
30
+ "@gridui/button": "^3.1.2",
31
+ "@gridui/file-picker": "^1.0.7",
32
+ "@gridui/input": "^1.1.6",
33
+ "@gridui/interaction": "^1.2.1",
34
+ "@gridui/style-utils": "^2.2.2",
35
+ "@gridui/theme": "^2.5.3",
34
36
  "class-variance-authority": "0.7.1"
35
37
  },
36
38
  "devDependencies": {
37
39
  "@gridui-internal/configuration": "0.0.0-internal",
38
40
  "@jest/globals": "30.5.2",
39
- "@storybook/react-vite": "10.6.5",
41
+ "@storybook/react-vite": "10.6.6",
40
42
  "@types/jest": "30.0.0",
41
43
  "@types/node": "26.6.6",
42
44
  "@types/react": "19.3.0",