@antscorp/ui 0.1.4 → 0.1.5
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/atoms/AddButton.d.ts +2 -1
- package/dist/atoms/Chip.d.ts +4 -1
- package/dist/atoms/RemoveButton.d.ts +2 -1
- package/dist/atoms/TextAction.d.ts +2 -1
- package/dist/docs.json +1 -1
- package/dist/lib/forwardable.d.ts +8 -0
- package/dist/molecules/CheckGroup.d.ts +2 -1
- package/dist/molecules/CheckRow.d.ts +4 -1
- package/dist/molecules/CommitTextField.d.ts +2 -1
- package/dist/molecules/ConfirmDialog.d.ts +2 -1
- package/dist/molecules/DateTimeInput.d.ts +2 -1
- package/dist/molecules/DurationInput.d.ts +2 -1
- package/dist/molecules/PercentRow.d.ts +2 -1
- package/dist/molecules/RevealRadioGroup.d.ts +2 -1
- package/dist/molecules/RevealSwitch.d.ts +2 -1
- package/dist/molecules/Select.d.ts +2 -1
- package/dist/molecules/StatusButton.d.ts +2 -1
- package/dist/molecules/ToggleGrid.d.ts +2 -1
- package/dist/molecules/TokenTextField.d.ts +2 -1
- package/dist/organisms/TokenPickerDialog.d.ts +2 -1
- package/dist/organisms/TransferPicker.d.ts +2 -1
- package/dist/theme/AntsomiTheme.d.ts +3 -2
- package/dist/theme/AntsomiTheme.js +8 -7
- package/package.json +3 -3
- package/src/atoms/AddButton.tsx +2 -1
- package/src/atoms/Chip.tsx +4 -1
- package/src/atoms/RemoveButton.tsx +3 -1
- package/src/atoms/TextAction.tsx +3 -1
- package/src/lib/forwardable.ts +8 -0
- package/src/molecules/CheckGroup.tsx +3 -3
- package/src/molecules/CheckRow.tsx +4 -1
- package/src/molecules/CommitTextField.tsx +15 -12
- package/src/molecules/ConfirmDialog.tsx +5 -1
- package/src/molecules/DateTimeInput.tsx +3 -2
- package/src/molecules/DurationInput.tsx +4 -1
- package/src/molecules/PercentRow.tsx +3 -2
- package/src/molecules/RevealRadioGroup.tsx +3 -3
- package/src/molecules/RevealSwitch.tsx +3 -1
- package/src/molecules/Select.tsx +16 -13
- package/src/molecules/StatusButton.tsx +3 -1
- package/src/molecules/ToggleGrid.tsx +3 -3
- package/src/molecules/TokenTextField.tsx +3 -3
- package/src/organisms/TokenPickerDialog.tsx +2 -1
- package/src/organisms/TransferPicker.tsx +3 -3
- package/src/theme/AntsomiTheme.tsx +9 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props taken from another component (`Pick`/`Omit`) whose optional ones also accept `undefined`,
|
|
3
|
+
* as the kit's own props do, so a host under `exactOptionalPropertyTypes` can forward its own
|
|
4
|
+
* optional value (`isDisabled={props.isDisabled}`). Required props stay as they are.
|
|
5
|
+
*/
|
|
6
|
+
export type Forwardable<T> = {
|
|
7
|
+
[K in keyof T]: Partial<Pick<T, K>> extends Pick<T, K> ? T[K] | undefined : T[K];
|
|
8
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
2
3
|
import { type FieldGroupProps } from "./FieldGroup.js";
|
|
3
4
|
/** One checkbox of a `CheckGroup`. */
|
|
4
5
|
export type CheckGroupOption<V extends string> = {
|
|
@@ -8,7 +9,7 @@ export type CheckGroupOption<V extends string> = {
|
|
|
8
9
|
readonly label: string;
|
|
9
10
|
};
|
|
10
11
|
/** What `CheckGroup` takes. */
|
|
11
|
-
export type CheckGroupProps<V extends string> = Pick<FieldGroupProps, "label" | "isDisabled" | "error"
|
|
12
|
+
export type CheckGroupProps<V extends string> = Forwardable<Pick<FieldGroupProps, "label" | "isDisabled" | "error">> & {
|
|
12
13
|
/** The checkboxes, in order. */
|
|
13
14
|
readonly options: readonly CheckGroupOption<V>[];
|
|
14
15
|
/** The picked values. */
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type CheckboxInputProps } from "@astryxdesign/core/CheckboxInput";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
/** What `CheckRow` takes. */
|
|
4
|
-
export type CheckRowProps = Pick<CheckboxInputProps, "
|
|
5
|
+
export type CheckRowProps = Forwardable<Pick<CheckboxInputProps, "isDisabled" | "isReadOnly">> & {
|
|
6
|
+
/** The row's text and the checkbox's name; one line, the whole text in a tooltip when cut. */
|
|
7
|
+
readonly label: string;
|
|
5
8
|
/** A second line under the text, such as an id under a name; one line too. */
|
|
6
9
|
readonly description?: string | undefined;
|
|
7
10
|
/** Whether the box is ticked. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type TextInputProps } from "@astryxdesign/core/TextInput";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
/** What `CommitTextField` takes. */
|
|
4
|
-
export type CommitTextFieldProps = Pick<TextInputProps, "label" | "isDisabled" | "isReadOnly" | "isLabelHidden" | "placeholder" | "description" | "isRequired" | "width" | "controlXstyle" | "containerXstyle"
|
|
5
|
+
export type CommitTextFieldProps = Forwardable<Pick<TextInputProps, "label" | "isDisabled" | "isReadOnly" | "isLabelHidden" | "placeholder" | "description" | "isRequired" | "width" | "controlXstyle" | "containerXstyle">> & {
|
|
5
6
|
/** The committed text. A new value from outside (an agent, undo) replaces the draft. */
|
|
6
7
|
readonly value: string;
|
|
7
8
|
/** Called with the draft on blur or Enter, only when it differs from `value`. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type AlertDialogProps } from "@astryxdesign/core/AlertDialog";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
/** What `ConfirmDialog` takes. */
|
|
4
|
-
export type ConfirmDialogProps = Pick<AlertDialogProps, "isOpen" | "title" | "description"
|
|
5
|
+
export type ConfirmDialogProps = Forwardable<Pick<AlertDialogProps, "isOpen" | "title" | "description">> & {
|
|
5
6
|
/** The texts of the two buttons; the host translates them. */
|
|
6
7
|
readonly labels: {
|
|
7
8
|
/** The confirming button, e.g. "Remove". */
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type TimeInputProps } from "@astryxdesign/core/TimeInput";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
import { type FieldGroupProps } from "./FieldGroup.js";
|
|
4
5
|
/** What `DateTimeInput` takes. */
|
|
5
|
-
export type DateTimeInputProps = Pick<FieldGroupProps, "isDisabled"
|
|
6
|
+
export type DateTimeInputProps = Forwardable<Pick<FieldGroupProps, "isDisabled">> & Forwardable<Pick<TimeInputProps, "hourFormat">> & {
|
|
6
7
|
/** The group's label, e.g. "Start date"; it names the group and is not shown. */
|
|
7
8
|
readonly label: string;
|
|
8
9
|
/** The texts the inputs show; the host translates them. */
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
2
3
|
import { type FieldGroupProps } from "./FieldGroup.js";
|
|
3
4
|
declare const PARTS: readonly ["days", "hours", "minutes", "seconds"];
|
|
4
5
|
type Part = (typeof PARTS)[number];
|
|
5
6
|
/** A length of time as stored: whole days, hours, minutes and seconds, each optional. */
|
|
6
7
|
export type DurationValue = Readonly<Partial<Record<Part, number>>>;
|
|
7
8
|
/** What `DurationInput` takes. */
|
|
8
|
-
export type DurationInputProps = Pick<FieldGroupProps, "label" | "isDisabled" | "error"
|
|
9
|
+
export type DurationInputProps = Forwardable<Pick<FieldGroupProps, "label" | "isDisabled" | "error">> & {
|
|
9
10
|
/**
|
|
10
11
|
* The unit of each part, already in the user's language, e.g. "day(s)": shown after its input
|
|
11
12
|
* and naming it for assistive tech.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type NumberInputProps } from "@astryxdesign/core/NumberInput";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
import { type FieldRowProps } from "./FieldRow.js";
|
|
4
5
|
/** What `PercentRow` takes. */
|
|
5
|
-
export type PercentRowProps = Pick<FieldRowProps, "label" | "labelWidth"
|
|
6
|
+
export type PercentRowProps = Forwardable<Pick<FieldRowProps, "label" | "labelWidth">> & Forwardable<Pick<NumberInputProps, "isDisabled" | "isReadOnly" | "disabledMessage">> & {
|
|
6
7
|
/** The controls' accessible name and the optional remove button's name. */
|
|
7
8
|
readonly labels: {
|
|
8
9
|
readonly share: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RadioListProps } from "@astryxdesign/core/RadioList";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
/** One choice of a `RevealRadioGroup`. */
|
|
4
5
|
export type RevealRadioOption<V extends string> = {
|
|
5
6
|
/** What `onChange` gets when this option is picked. */
|
|
@@ -14,7 +15,7 @@ export type RevealRadioOption<V extends string> = {
|
|
|
14
15
|
readonly content?: ReactNode;
|
|
15
16
|
};
|
|
16
17
|
/** What `RevealRadioGroup` takes. */
|
|
17
|
-
export type RevealRadioGroupProps<V extends string> = Pick<RadioListProps, "label" | "isLabelHidden" | "orientation" | "isDisabled"
|
|
18
|
+
export type RevealRadioGroupProps<V extends string> = Forwardable<Pick<RadioListProps, "label" | "isLabelHidden" | "orientation" | "isDisabled">> & {
|
|
18
19
|
/** The choices, in order. */
|
|
19
20
|
readonly options: readonly RevealRadioOption<V>[];
|
|
20
21
|
/** The chosen option's value. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type SwitchProps } from "@astryxdesign/core/Switch";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
/** What `RevealSwitch` takes. */
|
|
4
|
-
export type RevealSwitchProps = Pick<SwitchProps, "label" | "isDisabled" | "value"
|
|
5
|
+
export type RevealSwitchProps = Forwardable<Pick<SwitchProps, "label" | "isDisabled" | "value">> & {
|
|
5
6
|
/** Called with the new state. */
|
|
6
7
|
readonly onChange: (value: boolean) => void;
|
|
7
8
|
/** The switch's size, `md` by default. */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type SelectorOptionType, type SelectorProps } from "@astryxdesign/core/Selector";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
/** One entry of `Select`'s list: an option, a titled section of options, or a divider (Astryx's). */
|
|
4
5
|
export type SelectOption = SelectorOptionType;
|
|
5
6
|
/** What `Select` takes. */
|
|
6
|
-
export type SelectProps = Pick<SelectorProps, "label" | "isLabelHidden" | "description" | "placeholder" | "hasSearch" | "width" | "isDisabled" | "isReadOnly" | "isRequired" | "controlXstyle" | "containerXstyle"
|
|
7
|
+
export type SelectProps = Forwardable<Pick<SelectorProps, "label" | "isLabelHidden" | "description" | "placeholder" | "hasSearch" | "width" | "isDisabled" | "isReadOnly" | "isRequired" | "controlXstyle" | "containerXstyle">> & {
|
|
7
8
|
/** The list, in order. */
|
|
8
9
|
readonly options: readonly SelectOption[];
|
|
9
10
|
/** The picked option's value; `null` or none shows the placeholder. */
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ButtonProps } from "@astryxdesign/core/Button";
|
|
2
2
|
import { StatusDot } from "@astryxdesign/core/StatusDot";
|
|
3
3
|
import type { ComponentProps, ReactNode } from "react";
|
|
4
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
4
5
|
/** The tone of a `StatusButton`'s dot. */
|
|
5
6
|
export type StatusTone = ComponentProps<typeof StatusDot>["variant"];
|
|
6
7
|
/** What `StatusButton` takes. */
|
|
7
|
-
export type StatusButtonProps = Pick<ButtonProps, "label" | "icon" | "isDisabled"
|
|
8
|
+
export type StatusButtonProps = Forwardable<Pick<ButtonProps, "label" | "icon" | "isDisabled">> & {
|
|
8
9
|
/** The dot's tone: neutral, accent, success, warning or error. */
|
|
9
10
|
readonly status: StatusTone;
|
|
10
11
|
/** The texts the view shows; the host translates them. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
2
3
|
import { type FieldGroupProps } from "./FieldGroup.js";
|
|
3
4
|
/** One button of a `ToggleGrid`. */
|
|
4
5
|
export type ToggleGridOption<V extends string> = {
|
|
@@ -10,7 +11,7 @@ export type ToggleGridOption<V extends string> = {
|
|
|
10
11
|
readonly span?: number | undefined;
|
|
11
12
|
};
|
|
12
13
|
/** What `ToggleGrid` takes. */
|
|
13
|
-
export type ToggleGridProps<V extends string> = Pick<FieldGroupProps, "label" | "isDisabled" | "error"
|
|
14
|
+
export type ToggleGridProps<V extends string> = Forwardable<Pick<FieldGroupProps, "label" | "isDisabled" | "error">> & {
|
|
14
15
|
/** The buttons, in order. */
|
|
15
16
|
readonly options: readonly ToggleGridOption<V>[];
|
|
16
17
|
/** How many 40px columns the grid has; one column of Astryx's default without it. */
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type FieldProps } from "@astryxdesign/core/Field";
|
|
2
2
|
import { type IconProps } from "@astryxdesign/core/Icon";
|
|
3
3
|
import { type ReactNode } from "react";
|
|
4
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
4
5
|
import type { TokenLook } from "../lib/tokenEditorConfig.js";
|
|
5
6
|
export type { TokenLook } from "../lib/tokenEditorConfig.js";
|
|
6
7
|
/** What `TokenTextField` takes. */
|
|
7
|
-
export type TokenTextFieldProps = Pick<FieldProps, "label" | "description" | "isLabelHidden" | "isDisabled" | "isRequired"
|
|
8
|
+
export type TokenTextFieldProps = Forwardable<Pick<FieldProps, "label" | "description" | "isLabelHidden" | "isDisabled" | "isRequired">> & {
|
|
8
9
|
/** The committed string; outside changes replace the local draft. */
|
|
9
10
|
readonly value: string;
|
|
10
11
|
/** Commits the local draft on blur, or Enter in a single line. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DialogProps } from "@astryxdesign/core/Dialog";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
import { type TreeItem } from "../molecules/TreeOptions.js";
|
|
4
5
|
import { type TreeSelectProps } from "./TreeSelect.js";
|
|
5
6
|
/** The host-controlled draft of a token definition. */
|
|
@@ -12,7 +13,7 @@ export type TokenPickerValue = {
|
|
|
12
13
|
readonly defaultValue: string;
|
|
13
14
|
};
|
|
14
15
|
/** What `TokenPickerDialog` takes. */
|
|
15
|
-
export type TokenPickerDialogProps = Pick<DialogProps, "isOpen"
|
|
16
|
+
export type TokenPickerDialogProps = Forwardable<Pick<DialogProps, "isOpen">> & {
|
|
16
17
|
/** Closes or cancels the dialog. */
|
|
17
18
|
readonly onClose: () => void;
|
|
18
19
|
/** Dialog heading. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
2
3
|
import { type LoadMoreOptions } from "../lib/useLoadMore.js";
|
|
3
4
|
/** One thing `TransferPicker` offers. */
|
|
4
5
|
export type TransferPickerOption<V extends string> = {
|
|
@@ -16,7 +17,7 @@ export type TransferPickerOption<V extends string> = {
|
|
|
16
17
|
readonly error?: string | undefined;
|
|
17
18
|
};
|
|
18
19
|
/** What `TransferPicker` takes. */
|
|
19
|
-
export type TransferPickerProps<V extends string> = Pick<LoadMoreOptions, "onLoadMore" | "hasMore" | "isLoadingMore"
|
|
20
|
+
export type TransferPickerProps<V extends string> = Forwardable<Pick<LoadMoreOptions, "onLoadMore" | "hasMore" | "isLoadingMore">> & {
|
|
20
21
|
/** Names the list of options (the start column). */
|
|
21
22
|
readonly label: string;
|
|
22
23
|
/** The options to pick from. */
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Theme } from "@astryxdesign/core/theme";
|
|
2
2
|
import type { ComponentProps, ReactElement } from "react";
|
|
3
|
+
import type { Forwardable } from "../lib/forwardable.js";
|
|
3
4
|
/**
|
|
4
5
|
* Astryx Theme props with the Antsomi base theme as the default.
|
|
5
6
|
* Inherited `children` renders the themed subtree; `mode` selects light, dark or system mode.
|
|
6
7
|
*/
|
|
7
|
-
export type AntsomiThemeProps = Omit<ComponentProps<typeof Theme>, "theme"
|
|
8
|
+
export type AntsomiThemeProps = Forwardable<Omit<ComponentProps<typeof Theme>, "theme">> & {
|
|
8
9
|
/** Optional override created with `defineTheme({ extends: antsomiTheme, … })`. */
|
|
9
10
|
readonly theme?: ComponentProps<typeof Theme>["theme"];
|
|
10
11
|
};
|
|
@@ -13,4 +14,4 @@ export type AntsomiThemeProps = Omit<ComponentProps<typeof Theme>, "theme"> & {
|
|
|
13
14
|
* Import `@antscorp/ui/theme.css` separately. Extend the base with Astryx's
|
|
14
15
|
* `defineTheme({ name: "custom", extends: antsomiTheme, tokens: { … } })` and pass it as `theme`.
|
|
15
16
|
*/
|
|
16
|
-
export declare function AntsomiTheme({ theme,
|
|
17
|
+
export declare function AntsomiTheme({ theme, mode, children }: AntsomiThemeProps): ReactElement;
|
|
@@ -4,12 +4,13 @@ import { Theme as n } from "@astryxdesign/core/theme";
|
|
|
4
4
|
import { jsx as r } from "react/jsx-runtime";
|
|
5
5
|
// src/theme/AntsomiTheme.tsx
|
|
6
6
|
function i(i) {
|
|
7
|
-
let a = e(6), o, s;
|
|
8
|
-
a[0] ===
|
|
9
|
-
let
|
|
10
|
-
return a[3] !==
|
|
11
|
-
theme:
|
|
12
|
-
...
|
|
13
|
-
|
|
7
|
+
let a = e(6), { theme: o, mode: s, children: c } = i, l = o ?? t, u;
|
|
8
|
+
a[0] === s ? u = a[1] : (u = s !== void 0 && { mode: s }, a[0] = s, a[1] = u);
|
|
9
|
+
let d;
|
|
10
|
+
return a[2] !== c || a[3] !== l || a[4] !== u ? (d = /* @__PURE__ */ r(n, {
|
|
11
|
+
theme: l,
|
|
12
|
+
...u,
|
|
13
|
+
children: c
|
|
14
|
+
}), a[2] = c, a[3] = l, a[4] = u, a[5] = d) : d = a[5], d;
|
|
14
15
|
}
|
|
15
16
|
export { i as AntsomiTheme };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Generic UI kit: atoms, molecules and organisms over Astryx.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"build": "vite build --config vite.build.ts && tsc -p tsconfig.build.json && bun scripts/build-declarations.ts && node ../../tools/component-catalog/src/main.ts . && bun build src/cli/main.ts --target=node --outfile=dist/cli.js"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@antscorp/astryx-theme-antsomi": "0.1.
|
|
107
|
+
"@antscorp/astryx-theme-antsomi": "0.1.5",
|
|
108
108
|
"@antscorp/immutable": "0.1.1",
|
|
109
109
|
"@astryxdesign/core": "0.7.4",
|
|
110
110
|
"@codemirror/state": "6.7.6",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@antscorp/component-catalog": "0.1.0",
|
|
118
|
-
"@antscorp/vite-stylex": "0.1.
|
|
118
|
+
"@antscorp/vite-stylex": "0.1.5",
|
|
119
119
|
"@storybook/react-vite": "10.6.5",
|
|
120
120
|
"@testing-library/dom": "10.4.2",
|
|
121
121
|
"@testing-library/react": "16.3.3",
|
package/src/atoms/AddButton.tsx
CHANGED
|
@@ -3,10 +3,11 @@ import { radiusVars } from "@astryxdesign/core/theme/tokens.stylex";
|
|
|
3
3
|
import * as stylex from "@stylexjs/stylex";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
5
|
|
|
6
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
6
7
|
import { AddGlyph } from "./AddGlyph";
|
|
7
8
|
|
|
8
9
|
/** What `AddButton` takes. */
|
|
9
|
-
export type AddButtonProps = Pick<ButtonProps, "label" | "isDisabled"
|
|
10
|
+
export type AddButtonProps = Forwardable<Pick<ButtonProps, "label" | "isDisabled">> & {
|
|
10
11
|
/** `ghost` by default; `secondary` for an add that needs more weight. */
|
|
11
12
|
readonly variant?: "ghost" | "secondary" | undefined;
|
|
12
13
|
/** The button's height, `md` by default; its plus follows it. */
|
package/src/atoms/Chip.tsx
CHANGED
|
@@ -15,10 +15,13 @@ import { Tooltip } from "@astryxdesign/core/Tooltip";
|
|
|
15
15
|
import * as stylex from "@stylexjs/stylex";
|
|
16
16
|
import type { ReactNode } from "react";
|
|
17
17
|
|
|
18
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
18
19
|
import { RemoveButton } from "./RemoveButton";
|
|
19
20
|
|
|
20
21
|
/** What `Chip` takes. */
|
|
21
|
-
export type ChipProps = Pick<TokenProps, "
|
|
22
|
+
export type ChipProps = Forwardable<Pick<TokenProps, "isDisabled">> & {
|
|
23
|
+
/** The chip's text; cut short with an ellipsis past `maxWidth`, and shown whole in a tooltip. */
|
|
24
|
+
readonly label: string;
|
|
22
25
|
/** `neutral` (default) is the plain grey chip; `accent` the pale accent one; `danger` a value no longer valid. */
|
|
23
26
|
readonly tone?: "neutral" | "accent" | "danger" | undefined;
|
|
24
27
|
/** The chip's height, `sm` or `md` (default), as the controls beside it. */
|
|
@@ -2,8 +2,10 @@ import { Icon } from "@astryxdesign/core/Icon";
|
|
|
2
2
|
import { IconButton, type IconButtonProps } from "@astryxdesign/core/IconButton";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
|
|
5
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
6
|
+
|
|
5
7
|
/** What `RemoveButton` takes. */
|
|
6
|
-
export type RemoveButtonProps = Pick<IconButtonProps, "label" | "isDisabled"
|
|
8
|
+
export type RemoveButtonProps = Forwardable<Pick<IconButtonProps, "label" | "isDisabled">> & {
|
|
7
9
|
/** The button's height, `md` by default. */
|
|
8
10
|
readonly size?: "sm" | "md" | undefined;
|
|
9
11
|
/** Read-only: a remove is an editing affordance, so nothing is drawn. */
|
package/src/atoms/TextAction.tsx
CHANGED
|
@@ -4,8 +4,10 @@ import { spacingVars } from "@astryxdesign/core/theme/tokens.stylex";
|
|
|
4
4
|
import * as stylex from "@stylexjs/stylex";
|
|
5
5
|
import type { ReactNode } from "react";
|
|
6
6
|
|
|
7
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
8
|
+
|
|
7
9
|
/** What `TextAction` takes. */
|
|
8
|
-
export type TextActionProps = Pick<LinkProps, "isDisabled"
|
|
10
|
+
export type TextActionProps = Forwardable<Pick<LinkProps, "isDisabled">> & {
|
|
9
11
|
/** What it does, such as "Remove all"; shown in capitals by default, so pass it in normal case. */
|
|
10
12
|
readonly label: string;
|
|
11
13
|
/** A glyph before the text, in the text's colour, such as an Astryx `Icon` of a bin for a removal. */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props taken from another component (`Pick`/`Omit`) whose optional ones also accept `undefined`,
|
|
3
|
+
* as the kit's own props do, so a host under `exactOptionalPropertyTypes` can forward its own
|
|
4
|
+
* optional value (`isDisabled={props.isDisabled}`). Required props stay as they are.
|
|
5
|
+
*/
|
|
6
|
+
export type Forwardable<T> = {
|
|
7
|
+
[K in keyof T]: Partial<Pick<T, K>> extends Pick<T, K> ? T[K] | undefined : T[K];
|
|
8
|
+
};
|
|
@@ -3,6 +3,7 @@ import { HStack } from "@astryxdesign/core/HStack";
|
|
|
3
3
|
import { VStack } from "@astryxdesign/core/VStack";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
5
|
|
|
6
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
6
7
|
import { FieldGroup, type FieldGroupProps } from "./FieldGroup";
|
|
7
8
|
|
|
8
9
|
/** One checkbox of a `CheckGroup`. */
|
|
@@ -14,9 +15,8 @@ export type CheckGroupOption<V extends string> = {
|
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
/** What `CheckGroup` takes. */
|
|
17
|
-
export type CheckGroupProps<V extends string> =
|
|
18
|
-
FieldGroupProps,
|
|
19
|
-
"label" | "isDisabled" | "error"
|
|
18
|
+
export type CheckGroupProps<V extends string> = Forwardable<
|
|
19
|
+
Pick<FieldGroupProps, "label" | "isDisabled" | "error">
|
|
20
20
|
> & {
|
|
21
21
|
/** The checkboxes, in order. */
|
|
22
22
|
readonly options: readonly CheckGroupOption<V>[];
|
|
@@ -8,9 +8,12 @@ import type { ReactNode } from "react";
|
|
|
8
8
|
|
|
9
9
|
import { HoverSwap } from "../atoms/HoverSwap";
|
|
10
10
|
import { TruncatedText } from "../atoms/TruncatedText";
|
|
11
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
11
12
|
|
|
12
13
|
/** What `CheckRow` takes. */
|
|
13
|
-
export type CheckRowProps = Pick<CheckboxInputProps, "
|
|
14
|
+
export type CheckRowProps = Forwardable<Pick<CheckboxInputProps, "isDisabled" | "isReadOnly">> & {
|
|
15
|
+
/** The row's text and the checkbox's name; one line, the whole text in a tooltip when cut. */
|
|
16
|
+
readonly label: string;
|
|
14
17
|
/** A second line under the text, such as an id under a name; one line too. */
|
|
15
18
|
readonly description?: string | undefined;
|
|
16
19
|
/** Whether the box is ticked. */
|
|
@@ -4,21 +4,24 @@ import type { ReactNode } from "react";
|
|
|
4
4
|
|
|
5
5
|
import { errorStatus } from "../lib/errorStatus";
|
|
6
6
|
import { fitToMaxLength } from "../lib/fitToMaxLength";
|
|
7
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
7
8
|
import { useDraft } from "../lib/useDraft";
|
|
8
9
|
|
|
9
10
|
/** What `CommitTextField` takes. */
|
|
10
|
-
export type CommitTextFieldProps =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
export type CommitTextFieldProps = Forwardable<
|
|
12
|
+
Pick<
|
|
13
|
+
TextInputProps,
|
|
14
|
+
| "label"
|
|
15
|
+
| "isDisabled"
|
|
16
|
+
| "isReadOnly"
|
|
17
|
+
| "isLabelHidden"
|
|
18
|
+
| "placeholder"
|
|
19
|
+
| "description"
|
|
20
|
+
| "isRequired"
|
|
21
|
+
| "width"
|
|
22
|
+
| "controlXstyle"
|
|
23
|
+
| "containerXstyle"
|
|
24
|
+
>
|
|
22
25
|
> & {
|
|
23
26
|
/** The committed text. A new value from outside (an agent, undo) replaces the draft. */
|
|
24
27
|
readonly value: string;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AlertDialog, type AlertDialogProps } from "@astryxdesign/core/AlertDialog";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
|
|
4
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
5
|
+
|
|
4
6
|
/** What `ConfirmDialog` takes. */
|
|
5
|
-
export type ConfirmDialogProps =
|
|
7
|
+
export type ConfirmDialogProps = Forwardable<
|
|
8
|
+
Pick<AlertDialogProps, "isOpen" | "title" | "description">
|
|
9
|
+
> & {
|
|
6
10
|
/** The texts of the two buttons; the host translates them. */
|
|
7
11
|
readonly labels: {
|
|
8
12
|
/** The confirming button, e.g. "Remove". */
|
|
@@ -6,12 +6,13 @@ import { TimeInput, type TimeInputProps } from "@astryxdesign/core/TimeInput";
|
|
|
6
6
|
import type { ReactNode } from "react";
|
|
7
7
|
|
|
8
8
|
import { errorStatus } from "../lib/errorStatus";
|
|
9
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
9
10
|
import { dateValue, minDate, timeValue } from "../lib/iso";
|
|
10
11
|
import { FieldGroup, type FieldGroupProps } from "./FieldGroup";
|
|
11
12
|
|
|
12
13
|
/** What `DateTimeInput` takes. */
|
|
13
|
-
export type DateTimeInputProps = Pick<FieldGroupProps, "isDisabled"
|
|
14
|
-
Pick<TimeInputProps, "hourFormat"
|
|
14
|
+
export type DateTimeInputProps = Forwardable<Pick<FieldGroupProps, "isDisabled">> &
|
|
15
|
+
Forwardable<Pick<TimeInputProps, "hourFormat">> & {
|
|
15
16
|
/** The group's label, e.g. "Start date"; it names the group and is not shown. */
|
|
16
17
|
readonly label: string;
|
|
17
18
|
/** The texts the inputs show; the host translates them. */
|
|
@@ -3,6 +3,7 @@ import { NumberInput } from "@astryxdesign/core/NumberInput";
|
|
|
3
3
|
import { Text } from "@astryxdesign/core/Text";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
5
|
|
|
6
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
6
7
|
import { FieldGroup, type FieldGroupProps } from "./FieldGroup";
|
|
7
8
|
|
|
8
9
|
const PARTS = ["days", "hours", "minutes", "seconds"] as const;
|
|
@@ -12,7 +13,9 @@ type Part = (typeof PARTS)[number];
|
|
|
12
13
|
export type DurationValue = Readonly<Partial<Record<Part, number>>>;
|
|
13
14
|
|
|
14
15
|
/** What `DurationInput` takes. */
|
|
15
|
-
export type DurationInputProps =
|
|
16
|
+
export type DurationInputProps = Forwardable<
|
|
17
|
+
Pick<FieldGroupProps, "label" | "isDisabled" | "error">
|
|
18
|
+
> & {
|
|
16
19
|
/**
|
|
17
20
|
* The unit of each part, already in the user's language, e.g. "day(s)": shown after its input
|
|
18
21
|
* and naming it for assistive tech.
|
|
@@ -6,11 +6,12 @@ import * as stylex from "@stylexjs/stylex";
|
|
|
6
6
|
import { type ReactNode, useState } from "react";
|
|
7
7
|
|
|
8
8
|
import { RemoveButton } from "../atoms/RemoveButton";
|
|
9
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
9
10
|
import { FieldRow, type FieldRowProps } from "./FieldRow";
|
|
10
11
|
|
|
11
12
|
/** What `PercentRow` takes. */
|
|
12
|
-
export type PercentRowProps = Pick<FieldRowProps, "label" | "labelWidth"
|
|
13
|
-
Pick<NumberInputProps, "isDisabled" | "isReadOnly" | "disabledMessage"
|
|
13
|
+
export type PercentRowProps = Forwardable<Pick<FieldRowProps, "label" | "labelWidth">> &
|
|
14
|
+
Forwardable<Pick<NumberInputProps, "isDisabled" | "isReadOnly" | "disabledMessage">> & {
|
|
14
15
|
/** The controls' accessible name and the optional remove button's name. */
|
|
15
16
|
readonly labels: { readonly share: string; readonly remove: string };
|
|
16
17
|
/** The share, in whole percent. */
|
|
@@ -5,6 +5,7 @@ import * as stylex from "@stylexjs/stylex";
|
|
|
5
5
|
import { Fragment, type ReactNode } from "react";
|
|
6
6
|
|
|
7
7
|
import { InfoTip } from "../atoms/InfoTip";
|
|
8
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
8
9
|
|
|
9
10
|
/** One choice of a `RevealRadioGroup`. */
|
|
10
11
|
export type RevealRadioOption<V extends string> = {
|
|
@@ -21,9 +22,8 @@ export type RevealRadioOption<V extends string> = {
|
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
/** What `RevealRadioGroup` takes. */
|
|
24
|
-
export type RevealRadioGroupProps<V extends string> =
|
|
25
|
-
RadioListProps,
|
|
26
|
-
"label" | "isLabelHidden" | "orientation" | "isDisabled"
|
|
25
|
+
export type RevealRadioGroupProps<V extends string> = Forwardable<
|
|
26
|
+
Pick<RadioListProps, "label" | "isLabelHidden" | "orientation" | "isDisabled">
|
|
27
27
|
> & {
|
|
28
28
|
/** The choices, in order. */
|
|
29
29
|
readonly options: readonly RevealRadioOption<V>[];
|
|
@@ -2,8 +2,10 @@ import { Switch, type SwitchProps } from "@astryxdesign/core/Switch";
|
|
|
2
2
|
import { VStack } from "@astryxdesign/core/VStack";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
|
|
5
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
6
|
+
|
|
5
7
|
/** What `RevealSwitch` takes. */
|
|
6
|
-
export type RevealSwitchProps = Pick<SwitchProps, "label" | "isDisabled" | "value"
|
|
8
|
+
export type RevealSwitchProps = Forwardable<Pick<SwitchProps, "label" | "isDisabled" | "value">> & {
|
|
7
9
|
/** Called with the new state. */
|
|
8
10
|
readonly onChange: (value: boolean) => void;
|
|
9
11
|
/** The switch's size, `md` by default. */
|
package/src/molecules/Select.tsx
CHANGED
|
@@ -8,25 +8,28 @@ import type { ReactNode } from "react";
|
|
|
8
8
|
|
|
9
9
|
import { TruncatedOption } from "../atoms/TruncatedOption";
|
|
10
10
|
import { errorStatus } from "../lib/errorStatus";
|
|
11
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
11
12
|
import { useLoadingShown } from "../lib/useLoadingShown";
|
|
12
13
|
|
|
13
14
|
/** One entry of `Select`'s list: an option, a titled section of options, or a divider (Astryx's). */
|
|
14
15
|
export type SelectOption = SelectorOptionType;
|
|
15
16
|
|
|
16
17
|
/** What `Select` takes. */
|
|
17
|
-
export type SelectProps =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
export type SelectProps = Forwardable<
|
|
19
|
+
Pick<
|
|
20
|
+
SelectorProps,
|
|
21
|
+
| "label"
|
|
22
|
+
| "isLabelHidden"
|
|
23
|
+
| "description"
|
|
24
|
+
| "placeholder"
|
|
25
|
+
| "hasSearch"
|
|
26
|
+
| "width"
|
|
27
|
+
| "isDisabled"
|
|
28
|
+
| "isReadOnly"
|
|
29
|
+
| "isRequired"
|
|
30
|
+
| "controlXstyle"
|
|
31
|
+
| "containerXstyle"
|
|
32
|
+
>
|
|
30
33
|
> & {
|
|
31
34
|
/** The list, in order. */
|
|
32
35
|
readonly options: readonly SelectOption[];
|
|
@@ -2,11 +2,13 @@ import { Button, type ButtonProps } from "@astryxdesign/core/Button";
|
|
|
2
2
|
import { StatusDot } from "@astryxdesign/core/StatusDot";
|
|
3
3
|
import type { ComponentProps, ReactNode } from "react";
|
|
4
4
|
|
|
5
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
6
|
+
|
|
5
7
|
/** The tone of a `StatusButton`'s dot. */
|
|
6
8
|
export type StatusTone = ComponentProps<typeof StatusDot>["variant"];
|
|
7
9
|
|
|
8
10
|
/** What `StatusButton` takes. */
|
|
9
|
-
export type StatusButtonProps = Pick<ButtonProps, "label" | "icon" | "isDisabled"
|
|
11
|
+
export type StatusButtonProps = Forwardable<Pick<ButtonProps, "label" | "icon" | "isDisabled">> & {
|
|
10
12
|
/** The dot's tone: neutral, accent, success, warning or error. */
|
|
11
13
|
readonly status: StatusTone;
|
|
12
14
|
/** The texts the view shows; the host translates them. */
|
|
@@ -3,6 +3,7 @@ import { ToggleButton } from "@astryxdesign/core/ToggleButton";
|
|
|
3
3
|
import * as stylex from "@stylexjs/stylex";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
5
|
|
|
6
|
+
import type { Forwardable } from "../lib/forwardable";
|
|
6
7
|
import { FieldGroup, type FieldGroupProps } from "./FieldGroup";
|
|
7
8
|
|
|
8
9
|
/** One button of a `ToggleGrid`. */
|
|
@@ -16,9 +17,8 @@ export type ToggleGridOption<V extends string> = {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
/** What `ToggleGrid` takes. */
|
|
19
|
-
export type ToggleGridProps<V extends string> =
|
|
20
|
-
FieldGroupProps,
|
|
21
|
-
"label" | "isDisabled" | "error"
|
|
20
|
+
export type ToggleGridProps<V extends string> = Forwardable<
|
|
21
|
+
Pick<FieldGroupProps, "label" | "isDisabled" | "error">
|
|
22
22
|
> & {
|
|
23
23
|
/** The buttons, in order. */
|
|
24
24
|
readonly options: readonly ToggleGridOption<V>[];
|