ionbase-ui 0.51.0 → 0.69.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/dist/components/Accordion.d.ts +54 -0
- package/dist/components/Accordion.d.ts.map +1 -0
- package/dist/components/Accordion.js +68 -0
- package/dist/components/Accordion.js.map +1 -0
- package/dist/components/AgentActivity.d.ts +2 -1
- package/dist/components/AgentActivity.d.ts.map +1 -1
- package/dist/components/AgentActivity.js +4 -17
- package/dist/components/AgentActivity.js.map +1 -1
- package/dist/components/Breadcrumb.d.ts +45 -0
- package/dist/components/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb.js +31 -0
- package/dist/components/Breadcrumb.js.map +1 -0
- package/dist/components/Calendar.d.ts +20 -0
- package/dist/components/Calendar.d.ts.map +1 -0
- package/dist/components/Calendar.js +151 -0
- package/dist/components/Calendar.js.map +1 -0
- package/dist/components/CalendarPopover.d.ts +26 -0
- package/dist/components/CalendarPopover.d.ts.map +1 -0
- package/dist/components/CalendarPopover.js +45 -0
- package/dist/components/CalendarPopover.js.map +1 -0
- package/dist/components/Checkbox.d.ts +2 -1
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +4 -2
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Combobox.d.ts +86 -0
- package/dist/components/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox.js +261 -0
- package/dist/components/Combobox.js.map +1 -0
- package/dist/components/DateField.d.ts +15 -0
- package/dist/components/DateField.d.ts.map +1 -0
- package/dist/components/DateField.js +74 -0
- package/dist/components/DateField.js.map +1 -0
- package/dist/components/DatePicker.d.ts +81 -0
- package/dist/components/DatePicker.d.ts.map +1 -0
- package/dist/components/DatePicker.js +102 -0
- package/dist/components/DatePicker.js.map +1 -0
- package/dist/components/DateRangePicker.d.ts +117 -0
- package/dist/components/DateRangePicker.d.ts.map +1 -0
- package/dist/components/DateRangePicker.js +152 -0
- package/dist/components/DateRangePicker.js.map +1 -0
- package/dist/components/Drawer.d.ts +52 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +66 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/FileUpload.d.ts +79 -0
- package/dist/components/FileUpload.d.ts.map +1 -0
- package/dist/components/FileUpload.js +218 -0
- package/dist/components/FileUpload.js.map +1 -0
- package/dist/components/Header.d.ts +10 -0
- package/dist/components/Header.d.ts.map +1 -1
- package/dist/components/Header.js +18 -3
- package/dist/components/Header.js.map +1 -1
- package/dist/components/NumberInput.d.ts +63 -0
- package/dist/components/NumberInput.d.ts.map +1 -0
- package/dist/components/NumberInput.js +102 -0
- package/dist/components/NumberInput.js.map +1 -0
- package/dist/components/ProgressBar.d.ts +46 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +52 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/PromptInput.d.ts +89 -0
- package/dist/components/PromptInput.d.ts.map +1 -0
- package/dist/components/PromptInput.js +130 -0
- package/dist/components/PromptInput.js.map +1 -0
- package/dist/components/SegmentedControl.d.ts +63 -0
- package/dist/components/SegmentedControl.d.ts.map +1 -0
- package/dist/components/SegmentedControl.js +79 -0
- package/dist/components/SegmentedControl.js.map +1 -0
- package/dist/components/Select.d.ts +9 -2
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Sidebar.d.ts +109 -0
- package/dist/components/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar.js +106 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/Skeleton.d.ts +39 -0
- package/dist/components/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton.js +50 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/Spinner.d.ts +45 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +44 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Stepper.d.ts +73 -0
- package/dist/components/Stepper.d.ts.map +1 -0
- package/dist/components/Stepper.js +82 -0
- package/dist/components/Stepper.js.map +1 -0
- package/dist/components/Toggle.d.ts +2 -1
- package/dist/components/Toggle.d.ts.map +1 -1
- package/dist/components/Toggle.js +4 -2
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/ToolCall.d.ts +66 -0
- package/dist/components/ToolCall.d.ts.map +1 -0
- package/dist/components/ToolCall.js +78 -0
- package/dist/components/ToolCall.js.map +1 -0
- package/dist/components/agent-status.d.ts +14 -0
- package/dist/components/agent-status.d.ts.map +1 -0
- package/dist/components/agent-status.js +16 -0
- package/dist/components/agent-status.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +16 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/iso-date.d.ts +53 -0
- package/dist/components/iso-date.d.ts.map +1 -0
- package/dist/components/iso-date.js +102 -0
- package/dist/components/iso-date.js.map +1 -0
- package/dist/components/resolve-selection.d.ts +36 -0
- package/dist/components/resolve-selection.d.ts.map +1 -0
- package/dist/components/resolve-selection.js +14 -0
- package/dist/components/resolve-selection.js.map +1 -0
- package/dist/figma-descriptions.json +255 -145
- package/dist/figma-map.json +3205 -1860
- package/dist/meta/Accordion.json +123 -0
- package/dist/meta/AccordionItem.json +90 -0
- package/dist/meta/AgentActivityStep.json +2 -2
- package/dist/meta/Breadcrumb.json +87 -0
- package/dist/meta/BreadcrumbItem.json +78 -0
- package/dist/meta/Checkbox.json +18 -1
- package/dist/meta/Combobox.json +265 -0
- package/dist/meta/DatePicker.json +270 -0
- package/dist/meta/DateRangePicker.json +284 -0
- package/dist/meta/Drawer.json +234 -0
- package/dist/meta/EmptyState.json +1 -1
- package/dist/meta/FileUpload.json +246 -0
- package/dist/meta/Header.json +32 -2
- package/dist/meta/NumberInput.json +407 -0
- package/dist/meta/PhoneInput.json +39 -39
- package/dist/meta/Popover.json +3 -3
- package/dist/meta/ProgressBar.json +166 -0
- package/dist/meta/PromptInput.json +212 -0
- package/dist/meta/SegmentedControl.json +217 -0
- package/dist/meta/SegmentedControlItem.json +122 -0
- package/dist/meta/Select.json +4 -3
- package/dist/meta/Sidebar.json +150 -0
- package/dist/meta/SidebarItem.json +184 -0
- package/dist/meta/SidebarSection.json +131 -0
- package/dist/meta/Skeleton.json +120 -0
- package/dist/meta/Spinner.json +123 -0
- package/dist/meta/Stepper.json +135 -0
- package/dist/meta/StepperStep.json +148 -0
- package/dist/meta/Tabs.json +5 -0
- package/dist/meta/Toggle.json +18 -1
- package/dist/meta/ToolCall.json +192 -0
- package/dist/meta/Tooltip.json +3 -3
- package/dist/meta/components.json +6759 -2705
- package/dist/meta/contrast.json +11075 -3098
- package/dist/meta/index.json +266 -8
- package/dist/meta/patterns/AgentRun.json +27 -0
- package/dist/meta/patterns/Form.json +9 -0
- package/dist/meta/patterns/PageShell.json +43 -3
- package/dist/meta/patterns/Wizard.json +20 -1
- package/dist/meta/patterns/index.json +10 -1
- package/dist/styles/accordion.css +102 -0
- package/dist/styles/breadcrumb.css +72 -0
- package/dist/styles/combobox.css +154 -0
- package/dist/styles/date-picker.css +420 -0
- package/dist/styles/date-range-picker.css +280 -0
- package/dist/styles/drawer.css +181 -0
- package/dist/styles/empty-state.css +16 -4
- package/dist/styles/file-upload.css +236 -0
- package/dist/styles/header.css +26 -0
- package/dist/styles/index.css +23 -0
- package/dist/styles/number-input.css +83 -0
- package/dist/styles/progress-bar.css +107 -0
- package/dist/styles/prompt-input.css +127 -0
- package/dist/styles/segmented-control.css +182 -0
- package/dist/styles/sidebar.css +307 -0
- package/dist/styles/skeleton.css +76 -0
- package/dist/styles/spinner.css +70 -0
- package/dist/styles/stepper.css +250 -0
- package/dist/styles/tool-call.css +202 -0
- package/llms.txt +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type PromptInputSubmitKey = 'enter' | 'mod-enter';
|
|
3
|
+
export interface PromptInputProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue' | 'onChange' | 'onSubmit' | 'rows' | 'disabled' | 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* The accessible name of the text field. Required, and not a placeholder:
|
|
6
|
+
* placeholder text disappears the moment the user types, and is not reliably
|
|
7
|
+
* announced as a name.
|
|
8
|
+
*/
|
|
9
|
+
label: string;
|
|
10
|
+
/** Controlled text. Pass `onChange` with it. */
|
|
11
|
+
value?: string;
|
|
12
|
+
/** Uncontrolled starting text. */
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onChange?: (value: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Fires with the text as typed. Uncontrolled, the field clears straight away;
|
|
17
|
+
* if the returned promise rejects, the text is put back — a prompt lost to a
|
|
18
|
+
* network error is the one thing a composer must never do.
|
|
19
|
+
*/
|
|
20
|
+
onSubmit?: (value: string) => void | Promise<unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Which key sends. `enter` sends on Enter with Shift+Enter for a new line —
|
|
23
|
+
* a chat. `mod-enter` sends on Cmd/Ctrl+Enter and leaves Enter for new lines —
|
|
24
|
+
* a composer where messages are long and a stray Enter is expensive.
|
|
25
|
+
*/
|
|
26
|
+
submitKey?: PromptInputSubmitKey;
|
|
27
|
+
/**
|
|
28
|
+
* A run is in progress. The send control becomes an `AgentStop` in the same
|
|
29
|
+
* place, and submitting is refused. The field stays editable, so the user can
|
|
30
|
+
* draft the next message while the agent works.
|
|
31
|
+
*/
|
|
32
|
+
isRunning?: boolean;
|
|
33
|
+
/** Called by the stop control while `isRunning`. */
|
|
34
|
+
onStop?: () => void;
|
|
35
|
+
/** Passed to the stop control once the stop has been requested. */
|
|
36
|
+
isStopping?: boolean;
|
|
37
|
+
isDisabled?: boolean;
|
|
38
|
+
/** Rows the field starts at. */
|
|
39
|
+
minRows?: number;
|
|
40
|
+
/** Rows the field grows to before it scrolls. */
|
|
41
|
+
maxRows?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Controls at the start of the toolbar — attach, a model picker, a tool
|
|
44
|
+
* toggle. Icon-only controls here need their own `aria-label`.
|
|
45
|
+
*/
|
|
46
|
+
actions?: React.ReactNode;
|
|
47
|
+
/** Rendered above the text — attached files, a quoted message. */
|
|
48
|
+
attachments?: React.ReactNode;
|
|
49
|
+
/** Accessible name of the send control. */
|
|
50
|
+
sendLabel?: string;
|
|
51
|
+
/** Class names for the outer box. */
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* PromptInput — where a person writes to an agent.
|
|
56
|
+
*
|
|
57
|
+
* WHY IT IS NOT A TEXTAREA AND A BUTTON
|
|
58
|
+
*
|
|
59
|
+
* Every composer is assembled that way, and every one re-implements the same
|
|
60
|
+
* four bugs:
|
|
61
|
+
*
|
|
62
|
+
* Enter during IME composition sends half a word. Japanese, Chinese and
|
|
63
|
+
* Korean input confirm a candidate with Enter; a handler that does not check
|
|
64
|
+
* `isComposing` sends the message mid-character. That excludes whole
|
|
65
|
+
* languages from the product, silently, and nobody on an English keyboard
|
|
66
|
+
* ever sees it.
|
|
67
|
+
*
|
|
68
|
+
* The prompt is lost when sending fails. Clearing on submit is right —
|
|
69
|
+
* waiting for the server makes the composer feel broken — but clearing and
|
|
70
|
+
* never restoring destroys what may have been a long message. Uncontrolled,
|
|
71
|
+
* a rejected `onSubmit` promise puts the text back.
|
|
72
|
+
*
|
|
73
|
+
* The stop control lives somewhere else. While a run is going, the send
|
|
74
|
+
* button's place is exactly where the user's pointer and attention already
|
|
75
|
+
* are, so that is where `AgentStop` goes — the same control, the same
|
|
76
|
+
* guarantees, not a second stop button with different ones.
|
|
77
|
+
*
|
|
78
|
+
* The keyboard contract is invisible. "Enter sends, Shift+Enter for a new
|
|
79
|
+
* line" is announced through `aria-describedby`, because a screen-reader
|
|
80
|
+
* user who presses Enter expecting a newline has just sent a message.
|
|
81
|
+
*
|
|
82
|
+
* WHAT IT DOES NOT DO
|
|
83
|
+
*
|
|
84
|
+
* It does not upload, pick models or render messages. `attachments` and
|
|
85
|
+
* `actions` are slots, because what a product attaches and which tools it
|
|
86
|
+
* offers are the product's decisions.
|
|
87
|
+
*/
|
|
88
|
+
export declare const PromptInput: React.ForwardRefExoticComponent<PromptInputProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
89
|
+
//# sourceMappingURL=PromptInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptInput.d.ts","sourceRoot":"","sources":["../../src/components/PromptInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAQN,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,WAAW,CAAC;AAEzD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EAC/C,OAAO,GACP,cAAc,GACd,UAAU,GACV,UAAU,GACV,MAAM,GACN,UAAU,GACV,UAAU,CACb;IACC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD;;;;OAIG;IACH,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,kEAAkE;IAClE,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAyBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,WAAW,8FAkKvB,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState, } from 'react';
|
|
4
|
+
import { Button } from './Button.js';
|
|
5
|
+
import { AgentStop } from './AgentStop.js';
|
|
6
|
+
const SendGlyph = () => (_jsx("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M12 19V5m0 0-6 6m6-6 6 6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
7
|
+
/* useLayoutEffect warns during server rendering; the resize only matters in a browser. */
|
|
8
|
+
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
9
|
+
/**
|
|
10
|
+
* PromptInput — where a person writes to an agent.
|
|
11
|
+
*
|
|
12
|
+
* WHY IT IS NOT A TEXTAREA AND A BUTTON
|
|
13
|
+
*
|
|
14
|
+
* Every composer is assembled that way, and every one re-implements the same
|
|
15
|
+
* four bugs:
|
|
16
|
+
*
|
|
17
|
+
* Enter during IME composition sends half a word. Japanese, Chinese and
|
|
18
|
+
* Korean input confirm a candidate with Enter; a handler that does not check
|
|
19
|
+
* `isComposing` sends the message mid-character. That excludes whole
|
|
20
|
+
* languages from the product, silently, and nobody on an English keyboard
|
|
21
|
+
* ever sees it.
|
|
22
|
+
*
|
|
23
|
+
* The prompt is lost when sending fails. Clearing on submit is right —
|
|
24
|
+
* waiting for the server makes the composer feel broken — but clearing and
|
|
25
|
+
* never restoring destroys what may have been a long message. Uncontrolled,
|
|
26
|
+
* a rejected `onSubmit` promise puts the text back.
|
|
27
|
+
*
|
|
28
|
+
* The stop control lives somewhere else. While a run is going, the send
|
|
29
|
+
* button's place is exactly where the user's pointer and attention already
|
|
30
|
+
* are, so that is where `AgentStop` goes — the same control, the same
|
|
31
|
+
* guarantees, not a second stop button with different ones.
|
|
32
|
+
*
|
|
33
|
+
* The keyboard contract is invisible. "Enter sends, Shift+Enter for a new
|
|
34
|
+
* line" is announced through `aria-describedby`, because a screen-reader
|
|
35
|
+
* user who presses Enter expecting a newline has just sent a message.
|
|
36
|
+
*
|
|
37
|
+
* WHAT IT DOES NOT DO
|
|
38
|
+
*
|
|
39
|
+
* It does not upload, pick models or render messages. `attachments` and
|
|
40
|
+
* `actions` are slots, because what a product attaches and which tools it
|
|
41
|
+
* offers are the product's decisions.
|
|
42
|
+
*/
|
|
43
|
+
export const PromptInput = forwardRef(({ label, value: valueProp, defaultValue = '', onChange, onSubmit, submitKey = 'enter', isRunning = false, onStop, isStopping = false, isDisabled = false, minRows = 1, maxRows = 8, actions, attachments, sendLabel = 'Send', placeholder, className, onKeyDown, ...rest }, forwardedRef) => {
|
|
44
|
+
const ref = useRef(null);
|
|
45
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
46
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
47
|
+
const isControlled = valueProp !== undefined;
|
|
48
|
+
const value = isControlled ? valueProp : internal;
|
|
49
|
+
const setValue = (next) => {
|
|
50
|
+
if (!isControlled)
|
|
51
|
+
setInternal(next);
|
|
52
|
+
onChange?.(next);
|
|
53
|
+
};
|
|
54
|
+
const hintId = useId();
|
|
55
|
+
const canSubmit = !isDisabled && !isRunning && value.trim().length > 0 && !!onSubmit;
|
|
56
|
+
/*
|
|
57
|
+
* Grow with the text up to `maxRows`, then scroll. Measured from the
|
|
58
|
+
* rendered line-height rather than a token, so it stays right inside a
|
|
59
|
+
* caller's own type scale.
|
|
60
|
+
*/
|
|
61
|
+
useIsomorphicLayoutEffect(() => {
|
|
62
|
+
const el = ref.current;
|
|
63
|
+
if (!el)
|
|
64
|
+
return;
|
|
65
|
+
const style = window.getComputedStyle(el);
|
|
66
|
+
const line = parseFloat(style.lineHeight) || 24;
|
|
67
|
+
const padding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
|
|
68
|
+
el.style.height = 'auto';
|
|
69
|
+
const min = line * minRows + padding;
|
|
70
|
+
const max = line * maxRows + padding;
|
|
71
|
+
const next = Math.min(Math.max(el.scrollHeight, min), max);
|
|
72
|
+
el.style.height = `${next}px`;
|
|
73
|
+
el.style.overflowY = el.scrollHeight > max ? 'auto' : 'hidden';
|
|
74
|
+
}, [value, minRows, maxRows]);
|
|
75
|
+
const submit = () => {
|
|
76
|
+
if (!canSubmit || !onSubmit)
|
|
77
|
+
return;
|
|
78
|
+
const sent = value;
|
|
79
|
+
const result = onSubmit(sent);
|
|
80
|
+
if (isControlled)
|
|
81
|
+
return;
|
|
82
|
+
setInternal('');
|
|
83
|
+
if (result && typeof result.then === 'function') {
|
|
84
|
+
result.then(undefined, () => {
|
|
85
|
+
// Put it back only if the user has not started typing something new.
|
|
86
|
+
setInternal((current) => (current === '' ? sent : current));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const handleKeyDown = (event) => {
|
|
91
|
+
onKeyDown?.(event);
|
|
92
|
+
if (event.defaultPrevented || event.key !== 'Enter')
|
|
93
|
+
return;
|
|
94
|
+
// An IME confirming a candidate also presses Enter. 229 covers Safari,
|
|
95
|
+
// which reports the keydown before setting isComposing.
|
|
96
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229)
|
|
97
|
+
return;
|
|
98
|
+
const wantsSubmit = submitKey === 'enter'
|
|
99
|
+
? !event.shiftKey && !event.metaKey && !event.ctrlKey && !event.altKey
|
|
100
|
+
: event.metaKey || event.ctrlKey;
|
|
101
|
+
if (!wantsSubmit)
|
|
102
|
+
return;
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
submit();
|
|
105
|
+
};
|
|
106
|
+
const hint = submitKey === 'enter'
|
|
107
|
+
? 'Press Enter to send, Shift and Enter for a new line.'
|
|
108
|
+
: 'Press Command or Control and Enter to send.';
|
|
109
|
+
return (_jsxs("div", { className: [
|
|
110
|
+
'ion-prompt-input',
|
|
111
|
+
isDisabled ? 'ion-prompt-input--disabled' : '',
|
|
112
|
+
className || '',
|
|
113
|
+
]
|
|
114
|
+
.filter(Boolean)
|
|
115
|
+
.join(' '),
|
|
116
|
+
/*
|
|
117
|
+
* The whole box looks like the field, so a click on its padding should
|
|
118
|
+
* behave like a click on the field. Controls inside keep their own
|
|
119
|
+
* clicks.
|
|
120
|
+
*/
|
|
121
|
+
onMouseDown: (event) => {
|
|
122
|
+
if (event.target === event.currentTarget) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
ref.current?.focus();
|
|
125
|
+
}
|
|
126
|
+
}, children: [attachments && (_jsx("div", { className: "ion-prompt-input__attachments", children: attachments })), _jsx("textarea", { ...rest, ref: ref, rows: minRows, value: value, placeholder: placeholder, "aria-label": label, "aria-describedby": [rest['aria-describedby'], hintId].filter(Boolean).join(' ') ||
|
|
127
|
+
undefined, disabled: isDisabled, className: "ion-prompt-input__field", onChange: (event) => setValue(event.target.value), onKeyDown: handleKeyDown }), _jsxs("div", { className: "ion-prompt-input__toolbar", children: [_jsx("div", { className: "ion-prompt-input__actions", children: actions }), isRunning && onStop ? (_jsx(AgentStop, { size: "sm", onStop: onStop, isStopping: isStopping, className: "ion-prompt-input__stop" })) : (_jsx(Button, { variant: "primary-brand", size: "sm", "aria-label": sendLabel, startIcon: _jsx(SendGlyph, {}), isDisabled: !canSubmit, onPress: submit, className: "ion-prompt-input__send" }))] }), _jsx("span", { id: hintId, className: "ion-visually-hidden", children: hint })] }));
|
|
128
|
+
});
|
|
129
|
+
PromptInput.displayName = 'PromptInput';
|
|
130
|
+
//# sourceMappingURL=PromptInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptInput.js","sourceRoot":"","sources":["../../src/components/PromptInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EACZ,UAAU,EACV,SAAS,EACT,KAAK,EACL,mBAAmB,EACnB,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAiE3C,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CACtB,cACE,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,IAAI,EAAC,MAAM,iBACC,MAAM,EAClB,SAAS,EAAC,OAAO,YAEjB,eACE,CAAC,EAAC,0BAA0B,EAC5B,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AAEF,0FAA0F;AAC1F,MAAM,yBAAyB,GAC7B,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,CACE,EACE,KAAK,EACL,KAAK,EAAE,SAAS,EAChB,YAAY,GAAG,EAAE,EACjB,QAAQ,EACR,QAAQ,EACR,SAAS,GAAG,OAAO,EACnB,SAAS,GAAG,KAAK,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S,EAAC,+BAA+B,YAAE,WAAW,GAAO,CACnE,EACD,sBACM,IAAI,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,gBACZ,KAAK,sBAEf,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;oBAC5D,SAAS,EAEX,QAAQ,EAAE,UAAU,EACpB,SAAS,EAAC,yBAAyB,EACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACjD,SAAS,EAAE,aAAa,GACxB,EACF,eAAK,SAAS,EAAC,2BAA2B,aACxC,cAAK,SAAS,EAAC,2BAA2B,YAAE,OAAO,GAAO,EACzD,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,CACrB,KAAC,SAAS,IACR,IAAI,EAAC,IAAI,EACT,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,SAAS,EAAC,wBAAwB,GAClC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,IACL,OAAO,EAAC,eAAe,EACvB,IAAI,EAAC,IAAI,gBACG,SAAS,EACrB,SAAS,EAAE,KAAC,SAAS,KAAG,EACxB,UAAU,EAAE,CAAC,SAAS,EACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAC,wBAAwB,GAClC,CACH,IACG,EACN,eAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAC,qBAAqB,YAC9C,IAAI,GACA,IACH,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SegmentedControlSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
export interface SegmentedControlProps {
|
|
4
|
+
/**
|
|
5
|
+
* The accessible name of the group. Required: "List, Board, Calendar" means
|
|
6
|
+
* nothing until something says they are views.
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/** Show `label` above the control, as a form field does. Hidden by default. */
|
|
10
|
+
showLabel?: boolean;
|
|
11
|
+
/** Controlled selected value. Pass `onChange` with it. */
|
|
12
|
+
value?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Uncontrolled starting value. One option should always be selected — a
|
|
15
|
+
* segmented control with nothing chosen reads as broken, not as "no choice".
|
|
16
|
+
*/
|
|
17
|
+
defaultValue?: string;
|
|
18
|
+
onChange?: (value: string) => void;
|
|
19
|
+
size?: SegmentedControlSize;
|
|
20
|
+
/** Stretch to the container, with equal-width segments. */
|
|
21
|
+
isFullWidth?: boolean;
|
|
22
|
+
isDisabled?: boolean;
|
|
23
|
+
/** Submitted with a form under this name. */
|
|
24
|
+
name?: string;
|
|
25
|
+
/** `SegmentedControlItem` elements. Two to five of them. */
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SegmentedControlItemProps {
|
|
30
|
+
/** The value this segment selects. */
|
|
31
|
+
value: string;
|
|
32
|
+
/** Icon before the label. `aria-hidden` is applied for you. */
|
|
33
|
+
icon?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Required when the segment has no visible text — an icon-only segment is
|
|
36
|
+
* otherwise announced as an unnamed radio button.
|
|
37
|
+
*/
|
|
38
|
+
'aria-label'?: string;
|
|
39
|
+
isDisabled?: boolean;
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
className?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* SegmentedControl — pick one of a few options, and see all of them.
|
|
45
|
+
*
|
|
46
|
+
* NOT TABS, ALTHOUGH IT LOOKS LIKE THE PILL TYPE, and the difference is the
|
|
47
|
+
* contract. Tabs switch between panels: `tablist`, `tab`, `tabpanel`, and each
|
|
48
|
+
* tab controls a region. This sets a VALUE — a view mode, a time range, a
|
|
49
|
+
* unit — and controls no panel. It is a `radiogroup`, so it has one tab stop,
|
|
50
|
+
* arrow keys move and select, and it submits with a form like any radio.
|
|
51
|
+
*
|
|
52
|
+
* Built from real radio inputs, visually hidden, not from buttons with
|
|
53
|
+
* `aria-pressed`. A row of toggle buttons is a tab stop per option and no
|
|
54
|
+
* mutual exclusion that assistive tech can announce; radios give "2 of 3,
|
|
55
|
+
* selected" for free.
|
|
56
|
+
*
|
|
57
|
+
* The look is Tabs' pill track, token for token, so the two cannot drift
|
|
58
|
+
* apart visually — which is exactly why the intent file spends its words on
|
|
59
|
+
* when to use which.
|
|
60
|
+
*/
|
|
61
|
+
export declare const SegmentedControl: React.ForwardRefExoticComponent<SegmentedControlProps & React.RefAttributes<HTMLDivElement>>;
|
|
62
|
+
export declare const SegmentedControlItem: React.ForwardRefExoticComponent<SegmentedControlItemProps & React.RefAttributes<HTMLLabelElement>>;
|
|
63
|
+
//# sourceMappingURL=SegmentedControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../src/components/SegmentedControl.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAU7E,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAItD,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,8FAoE3B,CAAC;AAIH,eAAO,MAAM,oBAAoB,oGAkD/B,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, forwardRef, useContext, useRef } from 'react';
|
|
4
|
+
import { useFocusRing, useRadio, useRadioGroup, VisuallyHidden, } from 'react-aria';
|
|
5
|
+
import { useRadioGroupState } from 'react-stately';
|
|
6
|
+
const SegmentedContext = createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* SegmentedControl — pick one of a few options, and see all of them.
|
|
9
|
+
*
|
|
10
|
+
* NOT TABS, ALTHOUGH IT LOOKS LIKE THE PILL TYPE, and the difference is the
|
|
11
|
+
* contract. Tabs switch between panels: `tablist`, `tab`, `tabpanel`, and each
|
|
12
|
+
* tab controls a region. This sets a VALUE — a view mode, a time range, a
|
|
13
|
+
* unit — and controls no panel. It is a `radiogroup`, so it has one tab stop,
|
|
14
|
+
* arrow keys move and select, and it submits with a form like any radio.
|
|
15
|
+
*
|
|
16
|
+
* Built from real radio inputs, visually hidden, not from buttons with
|
|
17
|
+
* `aria-pressed`. A row of toggle buttons is a tab stop per option and no
|
|
18
|
+
* mutual exclusion that assistive tech can announce; radios give "2 of 3,
|
|
19
|
+
* selected" for free.
|
|
20
|
+
*
|
|
21
|
+
* The look is Tabs' pill track, token for token, so the two cannot drift
|
|
22
|
+
* apart visually — which is exactly why the intent file spends its words on
|
|
23
|
+
* when to use which.
|
|
24
|
+
*/
|
|
25
|
+
export const SegmentedControl = forwardRef((props, ref) => {
|
|
26
|
+
const { label, showLabel = false, size = 'md', isFullWidth = false, isDisabled = false, children, className, } = props;
|
|
27
|
+
const state = useRadioGroupState({ ...props, isDisabled });
|
|
28
|
+
/*
|
|
29
|
+
* A hidden label is an `aria-label`, not a visually hidden element inside
|
|
30
|
+
* the group: a label node inside the radiogroup is read again as part of
|
|
31
|
+
* its content.
|
|
32
|
+
*/
|
|
33
|
+
const { radioGroupProps, labelProps } = useRadioGroup({
|
|
34
|
+
...props,
|
|
35
|
+
isDisabled,
|
|
36
|
+
orientation: 'horizontal',
|
|
37
|
+
label: showLabel ? label : undefined,
|
|
38
|
+
'aria-label': showLabel ? undefined : label,
|
|
39
|
+
}, state);
|
|
40
|
+
const track = (_jsx("div", { ...radioGroupProps, ref: ref, className: [
|
|
41
|
+
'ion-segmented-control',
|
|
42
|
+
size !== 'md' ? `ion-segmented-control--${size}` : '',
|
|
43
|
+
isFullWidth ? 'ion-segmented-control--full-width' : '',
|
|
44
|
+
className || '',
|
|
45
|
+
]
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.join(' '), children: _jsx(SegmentedContext.Provider, { value: state, children: children }) }));
|
|
48
|
+
if (!showLabel)
|
|
49
|
+
return track;
|
|
50
|
+
return (_jsxs("div", { className: [
|
|
51
|
+
'ion-field',
|
|
52
|
+
'ion-segmented-control-field',
|
|
53
|
+
isFullWidth ? 'ion-segmented-control-field--full-width' : '',
|
|
54
|
+
]
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join(' '), children: [_jsx("span", { ...labelProps, className: "ion-field__label", children: label }), track] }));
|
|
57
|
+
});
|
|
58
|
+
SegmentedControl.displayName = 'SegmentedControl';
|
|
59
|
+
export const SegmentedControlItem = forwardRef((props, ref) => {
|
|
60
|
+
const { value, icon, isDisabled = false, children, className } = props;
|
|
61
|
+
const state = useContext(SegmentedContext);
|
|
62
|
+
if (!state) {
|
|
63
|
+
throw new Error('SegmentedControlItem must be rendered inside a SegmentedControl');
|
|
64
|
+
}
|
|
65
|
+
const inputRef = useRef(null);
|
|
66
|
+
const { inputProps, isSelected, isDisabled: disabled, } = useRadio({ value, isDisabled, children, 'aria-label': props['aria-label'] }, state, inputRef);
|
|
67
|
+
const { focusProps, isFocusVisible } = useFocusRing();
|
|
68
|
+
return (_jsxs("label", { ref: ref, className: [
|
|
69
|
+
'ion-segmented-control__item',
|
|
70
|
+
isSelected ? 'ion-segmented-control__item--selected' : '',
|
|
71
|
+
disabled ? 'ion-segmented-control__item--disabled' : '',
|
|
72
|
+
isFocusVisible ? 'ion-segmented-control__item--focus-visible' : '',
|
|
73
|
+
className || '',
|
|
74
|
+
]
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.join(' '), children: [_jsx(VisuallyHidden, { children: _jsx("input", { ...inputProps, ...focusProps, ref: inputRef }) }), icon && (_jsx("span", { className: "ion-segmented-control__icon", "aria-hidden": "true", children: icon })), children && (_jsx("span", { className: "ion-segmented-control__label", children: children }))] }));
|
|
77
|
+
});
|
|
78
|
+
SegmentedControlItem.displayName = 'SegmentedControlItem';
|
|
79
|
+
//# sourceMappingURL=SegmentedControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","sourceRoot":"","sources":["../../src/components/SegmentedControl.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MA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AC7B,UAAU,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC,CAAC,EAAE;YACzD,QAAQ,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC,CAAC,EAAE;YACvD,cAAc,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,EAAE;YAClE,SAAS,IAAI,EAAE;SAChB;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEZ,KAAC,cAAc,cACb,mBAAW,UAAU,KAAM,UAAU,EAAE,GAAG,EAAE,QAAQ,GAAI,GACzC,EAChB,IAAI,IAAI,CACP,eAAM,SAAS,EAAC,6BAA6B,iBAAa,MAAM,YAC7D,IAAI,GACA,CACR,EACA,QAAQ,IAAI,CACX,eAAM,SAAS,EAAC,8BAA8B,YAAE,QAAQ,GAAQ,CACjE,IACK,CACT,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC"}
|
|
@@ -8,8 +8,15 @@ export interface SelectOption {
|
|
|
8
8
|
export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size' | 'disabled'> {
|
|
9
9
|
/** Matches the Figma `Size` variant: Small, Medium, Large. */
|
|
10
10
|
size?: SelectSize;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The options to render. Omit and pass `children` for grouped options.
|
|
13
|
+
*
|
|
14
|
+
* `readonly` because an options list is almost always a module-level constant,
|
|
15
|
+
* and `as const` on one produces a readonly array that a mutable parameter
|
|
16
|
+
* rejects. The component only ever maps over it, so demanding a mutable array
|
|
17
|
+
* bought nothing and cost callers a spread or a cast.
|
|
18
|
+
*/
|
|
19
|
+
options?: readonly SelectOption[];
|
|
13
20
|
/**
|
|
14
21
|
* Text shown when nothing is selected. Renders as a disabled option so the
|
|
15
22
|
* field can start empty without that being a valid choice.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAC7C,MAAM,GAAG,UAAU,CACpB;IACC,8DAA8D;IAC9D,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAC7C,MAAM,GAAG,UAAU,CACpB;IACC,8DAA8D;IAC9D,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,mCAAmC;IACnC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,wDAAwD;IACxD,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAuBD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,uFAiIlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAmDxD;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,CACxB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,cAAc,EAChB,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,C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AQ,EAAE,CAAC,CAAC,UAAU,YACzD,CAAC,CAAC,KAAK,IADG,CAAC,CAAC,KAAK,CAEX,CACV,CAAC,EACD,QAAQ,IACF,EACT,eAAM,SAAS,EAAC,qBAAqB,YACnC,KAAC,WAAW,KAAG,GACV,IACH,CACP,CAAC;IAEF,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC;IAElC,OAAO,CACL,eACE,SAAS,EAAE;YACT,WAAW;YACX,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE;YACnC,gBAAgB,IAAI,EAAE;SACvB;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEX,KAAK,IAAI,CACR,gBAAO,OAAO,EAAE,EAAE,EAAE,SAAS,EAAC,kBAAkB,YAC7C,KAAK,GACA,CACT,EACA,GAAG,EACH,MAAM,IAAI,CACT,eAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,mBAAmB,YAC9C,MAAM,GACF,CACR,IACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SidebarProps extends React.HTMLAttributes<HTMLElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Names the navigation landmark. Required: a page with a sidebar usually has
|
|
5
|
+
* a second `<nav>` too, and "navigation, navigation" tells nobody which is
|
|
6
|
+
* which.
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* Pinned above the scrolling body — a workspace switcher, a search trigger,
|
|
11
|
+
* icon buttons. Any component.
|
|
12
|
+
*/
|
|
13
|
+
header?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Pinned below the scrolling body — an Invite button, help, a trial notice.
|
|
16
|
+
* Any component.
|
|
17
|
+
*/
|
|
18
|
+
footer?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* `SidebarSection`s, and anything that sits between them — a `Divider`, a
|
|
21
|
+
* promotional card. Items themselves always go inside a section.
|
|
22
|
+
*/
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
export interface SidebarSectionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
26
|
+
/** The group's name — "Spaces", "Favorites". Omit for the top group. */
|
|
27
|
+
title?: string;
|
|
28
|
+
/** Lets the title fold the section away. Needs a `title`. */
|
|
29
|
+
isCollapsible?: boolean;
|
|
30
|
+
/** Uncontrolled: whether a collapsible section starts open. */
|
|
31
|
+
defaultExpanded?: boolean;
|
|
32
|
+
/** Controlled: whether a collapsible section is open. */
|
|
33
|
+
isExpanded?: boolean;
|
|
34
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Controls beside the title — a `+` Button to create a space. Icon-only
|
|
37
|
+
* buttons need their own `aria-label`.
|
|
38
|
+
*/
|
|
39
|
+
actions?: React.ReactNode;
|
|
40
|
+
/** `SidebarItem`s only — the section renders a list. */
|
|
41
|
+
children?: React.ReactNode;
|
|
42
|
+
}
|
|
43
|
+
export interface SidebarItemProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'onClick'> {
|
|
44
|
+
/**
|
|
45
|
+
* The item's text. A string, because it also names the expand button of an
|
|
46
|
+
* item that has children.
|
|
47
|
+
*/
|
|
48
|
+
label: string;
|
|
49
|
+
/** Leading icon. Decorative — `label` names the item. */
|
|
50
|
+
icon?: React.ReactNode;
|
|
51
|
+
/** Where it goes. Omit for an item that only groups its children. */
|
|
52
|
+
href?: string;
|
|
53
|
+
/** For an item that acts rather than navigates. Ignored with `href`. */
|
|
54
|
+
onPress?: () => void;
|
|
55
|
+
/** The page the user is on. Marked `aria-current="page"`. */
|
|
56
|
+
isCurrent?: boolean;
|
|
57
|
+
isDisabled?: boolean;
|
|
58
|
+
/** Trailing text — a count, a shortcut, a status. */
|
|
59
|
+
badge?: React.ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Controls for this row — `…` and `+`. Revealed on hover and whenever focus
|
|
62
|
+
* is inside the row; always shown on touch screens. Icon-only buttons need
|
|
63
|
+
* their own `aria-label`.
|
|
64
|
+
*/
|
|
65
|
+
actions?: React.ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
* Uncontrolled: whether the children start open. Defaults to open when the
|
|
68
|
+
* current page is somewhere inside.
|
|
69
|
+
*/
|
|
70
|
+
defaultExpanded?: boolean;
|
|
71
|
+
/** Controlled: whether the children are open. */
|
|
72
|
+
isExpanded?: boolean;
|
|
73
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
74
|
+
/** Nested `SidebarItem`s. Their presence is what makes the item expandable. */
|
|
75
|
+
children?: React.ReactNode;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sidebar — an application's navigation, as a column.
|
|
79
|
+
*
|
|
80
|
+
* DISCLOSURE NAVIGATION, NOT `role="tree"`
|
|
81
|
+
*
|
|
82
|
+
* A file-tree look invites the tree role, and the tree role is wrong here.
|
|
83
|
+
* A treeview takes the arrow keys, allows one tab stop for the whole widget,
|
|
84
|
+
* and does not permit interactive content inside an item — so the `…` and `+`
|
|
85
|
+
* buttons on a row, which are half the point of a workspace sidebar, could not
|
|
86
|
+
* exist in it. This is the WAI-ARIA disclosure navigation pattern instead:
|
|
87
|
+
* nested lists of links, each expandable level behind a real button with
|
|
88
|
+
* `aria-expanded`, and everything reachable with Tab.
|
|
89
|
+
*
|
|
90
|
+
* AN ITEM THAT IS A LINK AND HAS CHILDREN GETS TWO CONTROLS
|
|
91
|
+
*
|
|
92
|
+
* A button cannot sit inside a link. So a row that navigates AND expands
|
|
93
|
+
* renders the link and a separate chevron button beside it; a row with no
|
|
94
|
+
* `href` is one button that expands. The actions slot is a sibling of both,
|
|
95
|
+
* never nested inside either.
|
|
96
|
+
*
|
|
97
|
+
* THE CURRENT PAGE IS NEVER FOLDED AWAY
|
|
98
|
+
*
|
|
99
|
+
* An item whose subtree contains the current page starts open. A sidebar that
|
|
100
|
+
* loads with the user's location collapsed inside a closed group tells a
|
|
101
|
+
* sighted user nothing and a screen-reader user less.
|
|
102
|
+
*
|
|
103
|
+
* Expansion is per item, controlled or not. Remembering it across visits is the
|
|
104
|
+
* caller's job — this component cannot know where that state should live.
|
|
105
|
+
*/
|
|
106
|
+
export declare const Sidebar: React.ForwardRefExoticComponent<SidebarProps & React.RefAttributes<HTMLElement>>;
|
|
107
|
+
export declare const SidebarSection: React.ForwardRefExoticComponent<SidebarSectionProps & React.RefAttributes<HTMLDivElement>>;
|
|
108
|
+
export declare const SidebarItem: React.ForwardRefExoticComponent<SidebarItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
109
|
+
//# sourceMappingURL=Sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["../../src/components/Sidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACrE;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,OAAO,CACR;IACC,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,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