@epam/ai-dial-ui-kit 0.14.0-dev.2 → 0.14.0-dev.4
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 +4 -1
- package/dist/CHANGELOG.md +45 -1
- package/dist/{JsonEditor-CM-CG-FK.js → JsonEditor-CFkmn69x.js} +1 -1
- package/dist/{JsonEditor-DPtZkKQi.cjs → JsonEditor-CPk58Te4.cjs} +1 -1
- package/dist/{MarkdownEditor-DRQoDnC-.js → MarkdownEditor-ALJ17x82.js} +1 -1
- package/dist/{MarkdownEditor-cdq8UZxL.js → MarkdownEditor-CqMQgd-3.js} +1 -1
- package/dist/{MarkdownEditor-DyIvPpmt.cjs → MarkdownEditor-Cz2HKRcy.cjs} +1 -1
- package/dist/{MarkdownEditor-D4WuEafx.cjs → MarkdownEditor-DgPlyntV.cjs} +1 -1
- package/dist/components-manifest.json +802 -43
- package/dist/dial-ui-kit.cjs.js +1 -1
- package/dist/dial-ui-kit.es.js +188 -174
- package/dist/{index-CBk9P1Pa.js → index-BnqboA_3.js} +10936 -10196
- package/dist/{index-A_KNCHda.cjs → index-CBaBO6e_.cjs} +31 -31
- package/dist/index.css +2 -2
- package/dist/migration-guides/0.14.0/control-color-token-rename.md +143 -0
- package/dist/migration-guides/0.14.0/focus-border-token-role-naming.md +87 -0
- package/dist/migration-guides/README.md +2 -0
- package/dist/src/components/New/Calendar/constants.d.ts +5 -5
- package/dist/src/components/New/Checkbox/Checkbox.d.ts +46 -0
- package/dist/src/components/New/Checkbox/constants.d.ts +10 -0
- package/dist/src/components/New/Dropdown/constants.d.ts +1 -1
- package/dist/src/components/New/EllipsisTooltip/EllipsisTooltip.d.ts +51 -0
- package/dist/src/components/New/EllipsisTooltip/use-truncation.d.ts +21 -0
- package/dist/src/components/New/Highlight/Highlight.d.ts +1 -1
- package/dist/src/components/New/Input/Button/constants.d.ts +1 -1
- package/dist/src/components/New/Label/Label.d.ts +5 -0
- package/dist/src/components/New/Notification/Notification.d.ts +7 -0
- package/dist/src/components/New/Notification/NotificationWrapper.d.ts +2 -0
- package/dist/src/components/New/Radio/Radio.d.ts +48 -0
- package/dist/src/components/New/RadioGroup/RadioGroup.d.ts +78 -0
- package/dist/src/components/New/RadioGroup/constants.d.ts +11 -0
- package/dist/src/components/New/RadioGroupPopupField/RadioGroupPopupField.d.ts +93 -0
- package/dist/src/components/New/RadioGroupPopupField/constants.d.ts +22 -0
- package/dist/src/components/New/SegmentedControl/SegmentedControl.d.ts +54 -0
- package/dist/src/components/New/SegmentedControl/constants.d.ts +16 -0
- package/dist/src/components/New/Select/constants.d.ts +1 -1
- package/dist/src/components/New/ToggleIconButton/ToggleIconButton.d.ts +47 -0
- package/dist/src/components/New/Tooltip/Tooltip.d.ts +43 -0
- package/dist/src/components/New/Tooltip/TooltipContainer.d.ts +32 -0
- package/dist/src/components/New/Tooltip/TooltipContent.d.ts +18 -0
- package/dist/src/components/New/Tooltip/TooltipContext.d.ts +115 -0
- package/dist/src/components/New/Tooltip/TooltipTrigger.d.ts +18 -0
- package/dist/src/components/New/Tooltip/constants.d.ts +25 -0
- package/dist/src/components/New/constants/overlay.d.ts +1 -1
- package/dist/src/index.d.ts +23 -1
- package/dist/src/types/notification.d.ts +2 -1
- package/dist/src/types/tooltip.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { CalendarMode } from '../../../types/calendar';
|
|
2
2
|
export declare const DEFAULT_CALENDAR_LOCALE = "en-GB";
|
|
3
3
|
export declare const calendarModeDefaultPlaceholder: Record<CalendarMode, string>;
|
|
4
|
-
export declare const calendarFieldBaseClassName = "flex w-full items-center justify-between gap-2 rounded-xl border border-secondary bg-layer-raised px-4 py-3 dial-small-text text-primary outline-none transition-colors hover:border-
|
|
5
|
-
export declare const calendarFieldDisabledClassName = "!cursor-not-allowed !border-transparent bg-layer-sunken text-control-disable-
|
|
4
|
+
export declare const calendarFieldBaseClassName = "flex w-full items-center justify-between gap-2 rounded-xl border border-secondary bg-layer-raised px-4 py-3 dial-small-text text-primary outline-none transition-colors hover:border-accent-alpha focus-within:border-accent-focus";
|
|
5
|
+
export declare const calendarFieldDisabledClassName = "!cursor-not-allowed !border-transparent bg-layer-sunken text-control-disable-primary hover:!border-transparent";
|
|
6
6
|
export declare const calendarFieldInvalidClassName = "!border-error";
|
|
7
|
-
export declare const calendarPopoverClassName = "z-[53] flex w-[248px] flex-col gap-4 rounded-lg bg-layer-raised px-
|
|
8
|
-
export declare const calendarDayButtonBaseClassName = "flex size-
|
|
7
|
+
export declare const calendarPopoverClassName = "z-[53] flex w-[248px] flex-col gap-4 rounded-lg bg-layer-raised px-2 py-4 shadow-md";
|
|
8
|
+
export declare const calendarDayButtonBaseClassName = "flex size-10 items-center justify-center rounded-full dial-small-text text-primary hover:bg-control-accent-alpha-hover hover:text-primary focus:outline-none focus-visible:outline focus-visible:outline-focus";
|
|
9
9
|
export declare const calendarDaySelectedClassName = "bg-control-accent text-control-permanent";
|
|
10
10
|
export declare const calendarDayTodayClassName = "text-accent dial-small-semi-text";
|
|
11
|
-
export declare const calendarDayOutsideClassName = "text-control-disable-
|
|
11
|
+
export declare const calendarDayOutsideClassName = "text-control-disable-primary";
|
|
12
12
|
export declare const calendarFieldIconClassName = "text-secondary";
|
|
13
13
|
export declare const calendarIcon: import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export declare const calendarNavIcons: {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FC, InputHTMLAttributes } from 'react';
|
|
2
|
+
import { LabelProps } from '../Label/Label';
|
|
3
|
+
type NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'onChange' | 'size'>;
|
|
4
|
+
export interface CheckboxProps extends NativeInputProps {
|
|
5
|
+
labelProps?: LabelProps;
|
|
6
|
+
isSelected?: boolean;
|
|
7
|
+
isIndeterminate?: boolean;
|
|
8
|
+
invalid?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
onChange?: (value: boolean) => void;
|
|
11
|
+
caption?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A checkbox from the 2.0 design system.
|
|
15
|
+
* aliases: ToggleCheckbox|MultiSelectOption|TriStateCheckbox
|
|
16
|
+
* Design system 2.0
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Checkbox
|
|
21
|
+
* labelProps={{ label: 'Accept terms' }}
|
|
22
|
+
* isSelected={accepted}
|
|
23
|
+
* onChange={setAccepted}
|
|
24
|
+
* />
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* `isIndeterminate` takes visual precedence over `isSelected` and announces the
|
|
28
|
+
* control as `mixed` — use it for a parent whose children are partly selected.
|
|
29
|
+
* It also sets the native `indeterminate` DOM property, which no React prop
|
|
30
|
+
* covers. Clicking an indeterminate checkbox selects it, as it does natively.
|
|
31
|
+
*
|
|
32
|
+
* The box and the label text are two sibling `<label for>` elements rather than
|
|
33
|
+
* one wrapper, so the {@link Label} keeps its own `required` marker and
|
|
34
|
+
* `caption` info button — a button nested in a label forwards its clicks to the
|
|
35
|
+
* labelled control. Clicking either one still toggles the checkbox.
|
|
36
|
+
*
|
|
37
|
+
* @param [labelProps] - Props of the {@link Label} rendered next to the control
|
|
38
|
+
* @param [isSelected=false] - The current value of the checkbox
|
|
39
|
+
* @param [isIndeterminate=false] - Whether the checkbox is in the mixed state
|
|
40
|
+
* @param [invalid=false] - Whether the checkbox failed validation (applies error styling)
|
|
41
|
+
* @param [disabled=false] - Whether the checkbox is disabled
|
|
42
|
+
* @param [onChange] - Callback fired with the new value when toggled
|
|
43
|
+
* @param [caption] - Caption text rendered below the label, and described by the checkbox
|
|
44
|
+
*/
|
|
45
|
+
export declare const Checkbox: FC<CheckboxProps>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The check and minus glyphs are decorative: the input's `checked` and
|
|
3
|
+
* `aria-checked` already carry the state, so the icon is hidden from assistive
|
|
4
|
+
* tech. Tabler renders a bare `<svg>` with no role, so `aria-hidden` is explicit.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CHECKBOX_ICON_PROPS: {
|
|
7
|
+
readonly size: 14;
|
|
8
|
+
readonly stroke: 3;
|
|
9
|
+
readonly 'aria-hidden': true;
|
|
10
|
+
};
|
|
@@ -4,6 +4,6 @@ export declare const dropdownSubMenuClassName: string;
|
|
|
4
4
|
export declare const dropdownItemBaseClassName: string;
|
|
5
5
|
export declare const dropdownItemDisabledClassName: string;
|
|
6
6
|
export declare const dropdownItemDangerClassName = "text-error";
|
|
7
|
-
export declare const dropdownDividerClassName = "my-1 border-t border-
|
|
7
|
+
export declare const dropdownDividerClassName = "my-1 border-t border-tertiary";
|
|
8
8
|
export declare const dropdownGap = 4;
|
|
9
9
|
export declare const submenuCaretIcon: import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { TooltipContainerOptions } from '../Tooltip/TooltipContext';
|
|
3
|
+
export interface EllipsisTooltipProps extends TooltipContainerOptions {
|
|
4
|
+
text: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
contentClassName?: string;
|
|
7
|
+
hideTooltip?: boolean;
|
|
8
|
+
id?: string;
|
|
9
|
+
customTooltipContent?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Single-line text with a CSS ellipsis that reveals the full string in a
|
|
13
|
+
* tooltip **only when it is actually clipped**.
|
|
14
|
+
* aliases: TruncatedText|TruncationTooltip
|
|
15
|
+
* Design system 2.0
|
|
16
|
+
*
|
|
17
|
+
* Text that fits gets no tooltip at all, so a row of labels does not sprout
|
|
18
|
+
* tooltips that repeat what is already on screen.
|
|
19
|
+
*
|
|
20
|
+
* The width has to be finite for anything to truncate: the element is a
|
|
21
|
+
* `min-w-0`, `flex-1` block, and `className` sets the width it should fit into.
|
|
22
|
+
*
|
|
23
|
+
* a11y: while truncated, the full string is exposed as the element's
|
|
24
|
+
* `aria-label`, so a screen reader reads the whole label even though the
|
|
25
|
+
* tooltip itself renders nothing on mobile screens.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <EllipsisTooltip text="Very long message that will be truncated" />
|
|
30
|
+
*
|
|
31
|
+
* <EllipsisTooltip
|
|
32
|
+
* text={<span className="dial-small-semi-text">Custom node</span>}
|
|
33
|
+
* className="max-w-[160px]"
|
|
34
|
+
* />
|
|
35
|
+
*
|
|
36
|
+
* <EllipsisTooltip text="Tooltip suppressed even when clipped" hideTooltip />
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param text - The text or node to display, truncated with an ellipsis when it does not fit
|
|
40
|
+
* @param [className] - Additional CSS classes for the text element, typically its width
|
|
41
|
+
* @param [contentClassName] - Additional CSS classes for the tooltip bubble
|
|
42
|
+
* @param [hideTooltip=false] - Suppress the tooltip even while the text is truncated
|
|
43
|
+
* @param [id] - `id` of the text element
|
|
44
|
+
* @param [customTooltipContent] - Shown instead of the full text while truncated
|
|
45
|
+
* @param [placement=TooltipPlacement.Bottom] - Side of the text the tooltip is placed on
|
|
46
|
+
* @param [initialOpen=false] - Whether the tooltip starts open (uncontrolled only)
|
|
47
|
+
* @param [isTriggerClickable=false] - Restrict hover handling to mouse input, ignoring touch
|
|
48
|
+
* @param [open] - Controlled open state; disables the hover and focus triggers
|
|
49
|
+
* @param [onOpenChange] - Callback fired when the open state should change
|
|
50
|
+
*/
|
|
51
|
+
export declare const EllipsisTooltip: FC<EllipsisTooltipProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Reports whether an element's text is being cut off by `text-overflow`, so a
|
|
4
|
+
* tooltip can carry the full string only when there is something to reveal.
|
|
5
|
+
*
|
|
6
|
+
* Truncation is a layout fact, not a prop: it depends on the width the element
|
|
7
|
+
* ends up with. The measurement therefore re-runs on every text change, on
|
|
8
|
+
* window resize, and — since a parent can resize without the window doing so —
|
|
9
|
+
* whenever the element's own box changes size.
|
|
10
|
+
*
|
|
11
|
+
* @param text - The rendered content; a change to it re-measures
|
|
12
|
+
* @returns `ref` to attach to the truncating element, whether it `isTruncated`,
|
|
13
|
+
* its `textContent` (the full string even when `text` is a node), and
|
|
14
|
+
* `remeasure` to force a fresh read before an interaction reads the result
|
|
15
|
+
*/
|
|
16
|
+
export declare const useTruncation: <T extends HTMLElement>(text: ReactNode) => {
|
|
17
|
+
ref: import('react').RefObject<T | null>;
|
|
18
|
+
isTruncated: boolean;
|
|
19
|
+
textContent: string;
|
|
20
|
+
remeasure: () => void;
|
|
21
|
+
};
|
|
@@ -7,7 +7,7 @@ export interface HighlightProps {
|
|
|
7
7
|
query: string;
|
|
8
8
|
/** Optional class name for the highlighted segment. */
|
|
9
9
|
markClassName?: string;
|
|
10
|
-
/** Optional class name forwarded to the `
|
|
10
|
+
/** Optional class name forwarded to the `EllipsisTooltip` container. */
|
|
11
11
|
className?: string;
|
|
12
12
|
/** Maximum number of lines to display before truncating. Use `1` for single-line ellipsis truncation (e.g. list rows). Defaults to `2`. */
|
|
13
13
|
maxLines?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const inputButtonClassName = "bg-control-neutral-active flex items-center justify-center enabled:text-secondary enabled:hover:text-control-
|
|
1
|
+
export declare const inputButtonClassName = "bg-control-neutral-active flex items-center justify-center enabled:text-secondary enabled:hover:text-control-accent-hover enabled:active:bg-control-accent-alpha-active enabled:hover:bg-control-accent-alpha-hover enabled:active:text-control-accent-active";
|
|
@@ -6,6 +6,7 @@ export interface LabelProps extends NativeLabelProps {
|
|
|
6
6
|
required?: boolean;
|
|
7
7
|
caption?: string;
|
|
8
8
|
size?: ElementSize;
|
|
9
|
+
containerClassName?: string;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* A label component
|
|
@@ -28,6 +29,10 @@ export interface LabelProps extends NativeLabelProps {
|
|
|
28
29
|
* plus visually hidden text so the requirement is announced too.
|
|
29
30
|
* @param [caption] - Explanatory text, exposed through an info button next to the label
|
|
30
31
|
* @param [size] - The size of the label, which can be 'small', 'medium', or 'large'.
|
|
32
|
+
* @param [containerClassName] - Additional classes for the wrapper holding the
|
|
33
|
+
* `<label>` and its info button. Needed when the label is a flex item that has
|
|
34
|
+
* to shrink: a wrapper left at `min-width: auto` cannot, so its text overflows
|
|
35
|
+
* instead of truncating.
|
|
31
36
|
*/
|
|
32
37
|
export declare const Label: FC<LabelProps>;
|
|
33
38
|
export {};
|
|
@@ -50,6 +50,13 @@ export interface NotificationProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
50
50
|
* title="Processing"
|
|
51
51
|
* message="Please wait..."
|
|
52
52
|
* />
|
|
53
|
+
*
|
|
54
|
+
* <Notification
|
|
55
|
+
* variant={NotificationVariant.General}
|
|
56
|
+
* type={NotificationType.SectionMessage}
|
|
57
|
+
* title="Title"
|
|
58
|
+
* message="Description text example"
|
|
59
|
+
* />
|
|
53
60
|
* ```
|
|
54
61
|
*
|
|
55
62
|
* @param [variant=NotificationVariant.Info] - Defines the visual style and icon of the alert
|
|
@@ -7,9 +7,11 @@ export declare const InfoToastNotification: FC<NotificationVariantProps>;
|
|
|
7
7
|
export declare const SuccessToastNotification: FC<NotificationVariantProps>;
|
|
8
8
|
export declare const WarningToastNotification: FC<NotificationVariantProps>;
|
|
9
9
|
export declare const LoadingToastNotification: FC<NotificationVariantProps>;
|
|
10
|
+
export declare const GeneralToastNotification: FC<NotificationVariantProps>;
|
|
10
11
|
export declare const ErrorMessageNotification: FC<NotificationTypeProps>;
|
|
11
12
|
export declare const InfoMessageNotification: FC<NotificationTypeProps>;
|
|
12
13
|
export declare const SuccessMessageNotification: FC<NotificationTypeProps>;
|
|
13
14
|
export declare const WarningMessageNotification: FC<NotificationTypeProps>;
|
|
14
15
|
export declare const LoadingMessageNotification: FC<NotificationTypeProps>;
|
|
16
|
+
export declare const GeneralMessageNotification: FC<NotificationTypeProps>;
|
|
15
17
|
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FC, InputHTMLAttributes } from 'react';
|
|
2
|
+
import { LabelProps } from '../Label/Label';
|
|
3
|
+
type NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'onChange' | 'size' | 'value'>;
|
|
4
|
+
export interface RadioProps extends NativeInputProps {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
labelProps?: LabelProps;
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
onChange?: (value: string) => void;
|
|
11
|
+
caption?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A radio button from the 2.0 design system.
|
|
15
|
+
* aliases: RadioButton|ChoiceOption|RadioInput
|
|
16
|
+
* Design system 2.0
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Radio
|
|
21
|
+
* name="plan"
|
|
22
|
+
* value="pro"
|
|
23
|
+
* labelProps={{ label: 'Pro' }}
|
|
24
|
+
* isSelected={plan === 'pro'}
|
|
25
|
+
* onChange={setPlan}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Radios sharing a `name` form one group: the browser gives them a single tab
|
|
30
|
+
* stop and moves the selection with the arrow keys, so no `role="radiogroup"`
|
|
31
|
+
* wiring is needed here. Wrap a set in a `<fieldset>` with a `<legend>` when the
|
|
32
|
+
* group itself needs a name.
|
|
33
|
+
*
|
|
34
|
+
* The circle and the label text are two sibling `<label for>` elements rather
|
|
35
|
+
* than one wrapper, so the {@link Label} keeps its own `required` marker and
|
|
36
|
+
* `caption` info button — a button nested in a label forwards its clicks to the
|
|
37
|
+
* labelled control. Clicking either one still selects the radio.
|
|
38
|
+
*
|
|
39
|
+
* @param name - The group this radio belongs to; radios sharing it are mutually exclusive
|
|
40
|
+
* @param value - The value reported to `onChange` when this radio is selected
|
|
41
|
+
* @param [labelProps] - Props of the {@link Label} rendered next to the control
|
|
42
|
+
* @param [isSelected=false] - Whether this radio is the selected one of its group
|
|
43
|
+
* @param [disabled=false] - Whether the radio is disabled
|
|
44
|
+
* @param [onChange] - Callback fired with `value` when this radio becomes selected
|
|
45
|
+
* @param [caption] - Caption text rendered below the label, and described by the radio
|
|
46
|
+
*/
|
|
47
|
+
export declare const Radio: FC<RadioProps>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { LabelProps } from '../Label/Label';
|
|
3
|
+
import { RadioGroupOrientation } from '../../../types/radio-group';
|
|
4
|
+
export interface RadioGroupItem {
|
|
5
|
+
value: string;
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
/** Explanatory text rendered under the option's label. */
|
|
8
|
+
caption?: string;
|
|
9
|
+
/** Content revealed under the option while it is the selected one. */
|
|
10
|
+
content?: ReactNode;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Names the option when its `label` is not a string (or absent). */
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RadioGroupProps {
|
|
16
|
+
items: RadioGroupItem[];
|
|
17
|
+
value?: string;
|
|
18
|
+
onChange: (value: string) => void;
|
|
19
|
+
name?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
orientation?: RadioGroupOrientation;
|
|
22
|
+
labelProps?: LabelProps;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
error?: string;
|
|
25
|
+
caption?: string;
|
|
26
|
+
ariaLabel?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
optionsClassName?: string;
|
|
29
|
+
radioClassName?: string;
|
|
30
|
+
contentClassName?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A set of mutually exclusive {@link Radio} options with one group label.
|
|
34
|
+
* aliases: SelectionGroup|OptionGroup|RadioList
|
|
35
|
+
* Design system 2.0
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <RadioGroup
|
|
40
|
+
* labelProps={{ label: 'Delivery' }}
|
|
41
|
+
* value={delivery}
|
|
42
|
+
* onChange={setDelivery}
|
|
43
|
+
* items={[
|
|
44
|
+
* { value: 'pickup', label: 'Pickup', caption: 'Free, ready today' },
|
|
45
|
+
* { value: 'courier', label: 'Courier', content: <AddressForm /> },
|
|
46
|
+
* ]}
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* The options are native radios sharing one `name`, so the browser gives the
|
|
51
|
+
* group a single tab stop and moves the selection with the arrow keys — no
|
|
52
|
+
* roving `tabindex` is needed. The wrapper still takes `role="radiogroup"` so
|
|
53
|
+
* the group's own name is announced before the options.
|
|
54
|
+
*
|
|
55
|
+
* An option's `content` is mounted only while that option is selected, so a
|
|
56
|
+
* form or an input inside it never holds focus for an option the user has moved
|
|
57
|
+
* away from.
|
|
58
|
+
*
|
|
59
|
+
* The group is named by `labelProps.label` when that is a string, and by
|
|
60
|
+
* `ariaLabel` otherwise — a group whose label is a node has no other name.
|
|
61
|
+
*
|
|
62
|
+
* @param items - Options to render; each needs a unique `value` and may carry a `label`, `caption`, `content` and `disabled` flag
|
|
63
|
+
* @param [value] - The `value` of the selected option
|
|
64
|
+
* @param onChange - Callback fired with the newly selected `value`
|
|
65
|
+
* @param [name] - The `name` shared by the underlying radios; defaults to the group id
|
|
66
|
+
* @param [id] - Base id for the group; option ids are derived from it
|
|
67
|
+
* @param [orientation=RadioGroupOrientation.Column] - Whether the options stack or sit in a row
|
|
68
|
+
* @param [labelProps] - Props of the {@link Label} rendered above the options
|
|
69
|
+
* @param [disabled] - Disables every option
|
|
70
|
+
* @param [error] - Error message rendered below the options
|
|
71
|
+
* @param [caption] - Helper text rendered below the options when there is no `error`
|
|
72
|
+
* @param [ariaLabel] - Names the group when there is no string `labelProps.label`
|
|
73
|
+
* @param [className] - Additional classes for the outer container
|
|
74
|
+
* @param [optionsClassName] - Additional classes for the options wrapper
|
|
75
|
+
* @param [radioClassName] - Additional classes for every option's control row
|
|
76
|
+
* @param [contentClassName] - Additional classes for the selected option's content
|
|
77
|
+
*/
|
|
78
|
+
export declare const RadioGroup: FC<RadioGroupProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RadioGroupOrientation } from '../../../types/radio-group';
|
|
2
|
+
/** Label, options and caption/error stack, matching the 2.0 field rhythm. */
|
|
3
|
+
export declare const groupBaseClassName = "flex flex-col gap-2";
|
|
4
|
+
export declare const optionsWrapperBaseClassName = "flex";
|
|
5
|
+
/**
|
|
6
|
+
* Content revealed under the selected option. The inline offset is the one
|
|
7
|
+
* `Radio` gives its own caption, so the content lines up with the option's
|
|
8
|
+
* label text rather than with its circle.
|
|
9
|
+
*/
|
|
10
|
+
export declare const selectedContentClassName = "mt-2 ml-[26px]";
|
|
11
|
+
export declare const orientationClassMap: Record<RadioGroupOrientation, string>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { LabelProps } from '../Label/Label';
|
|
3
|
+
import { RadioGroupItem } from '../RadioGroup/RadioGroup';
|
|
4
|
+
import { PopupSize } from '../../../types/popup';
|
|
5
|
+
export interface RadioGroupPopupFieldProps {
|
|
6
|
+
items: RadioGroupItem[];
|
|
7
|
+
value?: string;
|
|
8
|
+
customValue?: string;
|
|
9
|
+
header: ReactNode;
|
|
10
|
+
onApply: (value?: string) => void;
|
|
11
|
+
id?: string;
|
|
12
|
+
labelProps?: LabelProps;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
selectedValue?: string;
|
|
15
|
+
onSelectionChange?: (value: string) => void;
|
|
16
|
+
onCancel?: () => void;
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
isValid?: boolean;
|
|
19
|
+
applyButtonLabel?: string;
|
|
20
|
+
cancelButtonLabel?: string;
|
|
21
|
+
size?: PopupSize;
|
|
22
|
+
portalId?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
invalid?: boolean;
|
|
25
|
+
error?: string;
|
|
26
|
+
caption?: string;
|
|
27
|
+
ariaLabel?: string;
|
|
28
|
+
className?: string;
|
|
29
|
+
fieldClassName?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A field whose value is picked from a {@link RadioGroup} inside a {@link Popup}.
|
|
33
|
+
* aliases: PopupRadio|ChoicePopup|RadioPopupField
|
|
34
|
+
* Design system 2.0
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <RadioGroupPopupField
|
|
39
|
+
* labelProps={{ label: 'Status' }}
|
|
40
|
+
* header="Select status"
|
|
41
|
+
* placeholder="None"
|
|
42
|
+
* items={[
|
|
43
|
+
* { value: 'draft', label: 'Draft' },
|
|
44
|
+
* { value: 'published', label: 'Published' },
|
|
45
|
+
* ]}
|
|
46
|
+
* value={status}
|
|
47
|
+
* onApply={(next) => setStatus(next)}
|
|
48
|
+
* />
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* The collapsed field is a `<button>` rather than a read-only `<input>`: it
|
|
52
|
+
* opens a dialog and holds no text of its own, so the button role and its
|
|
53
|
+
* `Enter` / `Space` activation come from the element itself instead of being
|
|
54
|
+
* re-implemented on an input that would also invite typing.
|
|
55
|
+
*
|
|
56
|
+
* The selection inside the popup is a draft. Uncontrolled, it is seeded from
|
|
57
|
+
* `value` each time the popup opens, so an edit the user cancelled never leaks
|
|
58
|
+
* into the next one, and `onApply` is the only callback reporting a committed
|
|
59
|
+
* value. Pass `selectedValue` with `onSelectionChange` to drive the draft
|
|
60
|
+
* yourself — needed when `isValid` depends on what is currently selected.
|
|
61
|
+
*
|
|
62
|
+
* The field's accessible name is its label followed by the current value, so it
|
|
63
|
+
* announces like a collapsed picker ("Status, Draft"). With no `labelProps`,
|
|
64
|
+
* pass `ariaLabel`: it is exposed through a visually hidden element rather than
|
|
65
|
+
* as `aria-label`, which would replace the value in the name instead of
|
|
66
|
+
* preceding it.
|
|
67
|
+
*
|
|
68
|
+
* @param items - Options offered inside the popup
|
|
69
|
+
* @param [value] - The committed value, shown in the collapsed field
|
|
70
|
+
* @param [customValue] - Text shown in the field in place of the selected option's label
|
|
71
|
+
* @param header - Title of the popup
|
|
72
|
+
* @param onApply - Callback fired with the selected value when Apply is clicked
|
|
73
|
+
* @param [id] - Base id for the field; the label and the options derive theirs from it
|
|
74
|
+
* @param [labelProps] - Props of the {@link Label} rendered above the field
|
|
75
|
+
* @param [placeholder] - Text shown in the field while no value is selected
|
|
76
|
+
* @param [selectedValue] - Controlled draft selection inside the popup
|
|
77
|
+
* @param [onSelectionChange] - Callback fired when the draft selection changes
|
|
78
|
+
* @param [onCancel] - Callback fired when Cancel is clicked, before the popup closes
|
|
79
|
+
* @param [onClose] - Callback fired whenever the popup closes
|
|
80
|
+
* @param [isValid=true] - Whether Apply is enabled
|
|
81
|
+
* @param [applyButtonLabel="Apply"] - Label of the Apply button
|
|
82
|
+
* @param [cancelButtonLabel="Cancel"] - Label of the Cancel button
|
|
83
|
+
* @param [size=PopupSize.Md] - Size of the popup
|
|
84
|
+
* @param [portalId] - Portal container id for the popup
|
|
85
|
+
* @param [disabled] - Disables the field, so the popup cannot be opened
|
|
86
|
+
* @param [invalid] - Paints the field with the error border
|
|
87
|
+
* @param [error] - Error message rendered below the field
|
|
88
|
+
* @param [caption] - Helper text rendered below the field when there is no `error`
|
|
89
|
+
* @param [ariaLabel] - Names the field when there is no string `labelProps.label`
|
|
90
|
+
* @param [className] - Additional classes for the outer container
|
|
91
|
+
* @param [fieldClassName] - Additional classes for the collapsed field
|
|
92
|
+
*/
|
|
93
|
+
export declare const RadioGroupPopupField: FC<RadioGroupPopupFieldProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The collapsed field. `dial-kit-input` gives it the 2.0 field box — 40px tall,
|
|
3
|
+
* raised surface, accent border on hover, accent outline on focus, and the
|
|
4
|
+
* sunken disabled treatment through its own `:disabled` rule, which a `<button>`
|
|
5
|
+
* matches. The utilities after it only lay the row out; the SCSS class is
|
|
6
|
+
* unlayered, so anything it already sets (`truncate`, `w-full`, the height)
|
|
7
|
+
* cannot be overridden from here.
|
|
8
|
+
*
|
|
9
|
+
* No `dial-kit-enhanced-target`: `truncate` puts `overflow: hidden` on the
|
|
10
|
+
* field, which would clip the 44px pseudo-element back to the field's own 40px,
|
|
11
|
+
* and being unlayered it cannot be undone with a utility. The field takes the
|
|
12
|
+
* same documented 2.5.5 exception as `Input` and `Select` — full-width target,
|
|
13
|
+
* 4px short of 44 vertically.
|
|
14
|
+
*/
|
|
15
|
+
export declare const fieldBaseClassName = "dial-kit-input flex flex-row items-center justify-between gap-x-2 px-3 text-left";
|
|
16
|
+
export declare const fieldValueClassName = "min-w-0 flex-1 truncate text-primary";
|
|
17
|
+
export declare const fieldPlaceholderClassName = "min-w-0 flex-1 truncate text-secondary";
|
|
18
|
+
export declare const fieldIconClassName = "shrink-0 text-secondary";
|
|
19
|
+
export declare const popupBodyClassName = "px-6 pb-4";
|
|
20
|
+
export declare const popupFooterClassName = "flex justify-end gap-2 px-6 py-4 border-t border-tertiary";
|
|
21
|
+
export declare const defaultCancelLabel = "Cancel";
|
|
22
|
+
export declare const defaultApplyLabel = "Apply";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface SegmentedControlItem<T extends string = string> {
|
|
3
|
+
value: T;
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
'aria-label'?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SegmentedControlProps<T extends string> {
|
|
10
|
+
items: SegmentedControlItem<T>[];
|
|
11
|
+
value: T;
|
|
12
|
+
onChange: (value: T) => void;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
segmentClassName?: string;
|
|
16
|
+
'aria-label'?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A single-select switch between a few mutually exclusive, equally sized options.
|
|
20
|
+
* aliases: SegmentedButton|ViewSwitcher|ButtonGroup
|
|
21
|
+
* Design system 2.0
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <SegmentedControl
|
|
26
|
+
* aria-label="View"
|
|
27
|
+
* value={view}
|
|
28
|
+
* onChange={setView}
|
|
29
|
+
* items={[
|
|
30
|
+
* { value: 'list', icon: <IconList />, 'aria-label': 'List' },
|
|
31
|
+
* { value: 'grid', icon: <IconGrid />, 'aria-label': 'Grid' },
|
|
32
|
+
* ]}
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* This is a radio group, not a tab list: it selects a value rather than
|
|
37
|
+
* revealing a panel, so it takes `role="radiogroup"` with `role="radio"`
|
|
38
|
+
* segments. The group is a single tab stop — the selected segment holds it, and
|
|
39
|
+
* the arrow keys, `Home` and `End` move the selection, per the ARIA radio-group
|
|
40
|
+
* pattern. `DialSegmentedControl` (1.0) uses `tablist`/`tab` instead; that is
|
|
41
|
+
* the behaviour this replaces.
|
|
42
|
+
*
|
|
43
|
+
* An icon-only segment still needs a name: give it `aria-label`, since the icon
|
|
44
|
+
* carries no text. A segment with a string `label` is named by it.
|
|
45
|
+
*
|
|
46
|
+
* @param items - Segments to render; each needs a unique `value` and may carry a `label`, `icon` and `disabled` flag
|
|
47
|
+
* @param value - The currently selected `value`
|
|
48
|
+
* @param onChange - Callback fired with the newly selected `value`
|
|
49
|
+
* @param [disabled] - Disables every segment
|
|
50
|
+
* @param [className] - Additional classes for the track
|
|
51
|
+
* @param [segmentClassName] - Additional classes for every segment
|
|
52
|
+
* @param [aria-label] - Names the group as a whole
|
|
53
|
+
*/
|
|
54
|
+
export declare const SegmentedControl: <T extends string>({ items, value, onChange, disabled, className, segmentClassName: segmentClassNameProp, "aria-label": ariaLabel, }: SegmentedControlProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Keys that move the selection inside the group. */
|
|
2
|
+
export declare const NAVIGATION_KEYS: string[];
|
|
3
|
+
/** The sunken track the segments sit in. */
|
|
4
|
+
export declare const containerClassName = "inline-flex w-fit items-center gap-1 rounded-full bg-layer-sunken p-1";
|
|
5
|
+
export declare const segmentClassName = "flex h-8 min-w-8 flex-1 shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-full px-4 dial-small-text transition-colors duration-200 outline-offset-0 focus-visible:outline focus-visible:outline-focus";
|
|
6
|
+
/** Selected lifts off the track on a raised surface and keeps the accent at rest. */
|
|
7
|
+
export declare const segmentSelectedClassName = "bg-layer-raised text-accent shadow-xs";
|
|
8
|
+
export declare const segmentUnselectedClassName = "bg-transparent text-secondary";
|
|
9
|
+
export declare const segmentSelectedInteractiveClassName = "cursor-pointer hover:bg-control-accent-alpha-hover active:bg-control-accent-alpha-active";
|
|
10
|
+
export declare const segmentUnselectedInteractiveClassName = "cursor-pointer hover:bg-control-accent-alpha-hover hover:text-accent active:bg-control-accent-alpha-active";
|
|
11
|
+
/**
|
|
12
|
+
* A disabled segment keeps its shape so the group does not reflow, but drops the
|
|
13
|
+
* accent and the shadow.
|
|
14
|
+
*/
|
|
15
|
+
export declare const segmentDisabledSelectedClassName = "cursor-not-allowed bg-control-disable-primary text-control-disable-primary shadow-none";
|
|
16
|
+
export declare const segmentDisabledUnselectedClassName = "cursor-not-allowed bg-transparent text-control-disable-primary";
|
|
@@ -12,7 +12,7 @@ export declare const selectOptionSelectedClassName = "bg-control-accent-alpha-ho
|
|
|
12
12
|
* default this component relies on).
|
|
13
13
|
*/
|
|
14
14
|
export declare const selectListWidthClassName = "!max-w-[var(--reference-width)]";
|
|
15
|
-
export declare const selectOptionDisabledClassName = "
|
|
15
|
+
export declare const selectOptionDisabledClassName = "text-secondary";
|
|
16
16
|
export declare const dropdownMenuMaxHeight = 352;
|
|
17
17
|
export declare const selectSubMenuGap = 4;
|
|
18
18
|
export declare const selectSubMenuClassName: string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { IconButtonProps } from '../IconButton/IconButton';
|
|
3
|
+
import { TooltipProps } from '../Tooltip/Tooltip';
|
|
4
|
+
type ToggleTooltipProps = Omit<TooltipProps, 'children'>;
|
|
5
|
+
export interface ToggleIconButtonProps extends Omit<IconButtonProps, 'variant' | 'appearance' | 'tooltipProps' | 'onToggle'> {
|
|
6
|
+
icon: ReactNode;
|
|
7
|
+
selectedIcon?: ReactNode;
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
onToggle?: (isSelected: boolean) => void;
|
|
10
|
+
tooltipProps?: ToggleTooltipProps;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An icon button that stays pressed, for a setting the icon itself represents.
|
|
14
|
+
* aliases: IconToggle|ToggleButton|BookmarkButton
|
|
15
|
+
* Design system 2.0
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <ToggleIconButton
|
|
20
|
+
* icon={<IconBookmark />}
|
|
21
|
+
* selectedIcon={<IconBookmarkFilled />}
|
|
22
|
+
* isSelected={isBookmarked}
|
|
23
|
+
* onToggle={setIsBookmarked}
|
|
24
|
+
* tooltipProps={{ tooltip: 'Bookmark' }}
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* This is a button, not a checkbox: the state rides on `aria-pressed`, so one
|
|
29
|
+
* unchanging accessible name covers both states and screen readers announce it
|
|
30
|
+
* as "pressed". Do not switch the name between them — a control that renames
|
|
31
|
+
* itself on click reads as a different control.
|
|
32
|
+
*
|
|
33
|
+
* Built on the primary ghost {@link IconButton}, which already supplies the
|
|
34
|
+
* whole unselected column of the design: a secondary-grey icon that turns
|
|
35
|
+
* accent on hover, an accent-alpha tint on hover and active, and a grey icon
|
|
36
|
+
* when disabled. Selected keeps that accent icon at rest and swaps in
|
|
37
|
+
* `selectedIcon` — usually the filled twin of `icon`.
|
|
38
|
+
*
|
|
39
|
+
* @param icon - Icon shown while unselected; rendered at 16px
|
|
40
|
+
* @param [selectedIcon] - Icon shown while selected; falls back to `icon`
|
|
41
|
+
* @param [isSelected=false] - Whether the toggle is on
|
|
42
|
+
* @param [onToggle] - Callback fired with the next value when clicked
|
|
43
|
+
* @param [size=ElementSize.Small] - Defines the size of the button
|
|
44
|
+
* @param [tooltipProps] - Props of the 2.0 {@link Tooltip} wrapping the button
|
|
45
|
+
*/
|
|
46
|
+
export declare const ToggleIconButton: FC<ToggleIconButtonProps>;
|
|
47
|
+
export {};
|