@antscorp/ui 0.1.3 → 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.
Files changed (198) hide show
  1. package/README.md +25 -1
  2. package/dist/atoms/AddButton.d.ts +3 -5
  3. package/dist/atoms/Chip.d.ts +3 -3
  4. package/dist/atoms/Chip.js +1 -1
  5. package/dist/atoms/RemoveButton.d.ts +3 -5
  6. package/dist/atoms/TextAction.d.ts +3 -3
  7. package/dist/docs.json +1 -1
  8. package/dist/lib/forwardable.d.ts +8 -0
  9. package/dist/lib/iso.d.ts +2 -2
  10. package/dist/lib/iso.js +16 -8
  11. package/dist/lib/tokenEditorExtensions.js +1 -1
  12. package/dist/molecules/AccentCard.js +2 -2
  13. package/dist/molecules/CheckGroup.d.ts +2 -1
  14. package/dist/molecules/CheckRow.d.ts +3 -5
  15. package/dist/molecules/ChoiceTiles.js +1 -1
  16. package/dist/molecules/CommitTextField.d.ts +2 -19
  17. package/dist/molecules/CommitTextField.js +21 -18
  18. package/dist/molecules/ConfirmDialog.d.ts +3 -7
  19. package/dist/molecules/DateTimeInput.d.ts +7 -3
  20. package/dist/molecules/DateTimeInput.js +82 -73
  21. package/dist/molecules/DurationInput.d.ts +2 -1
  22. package/dist/molecules/PercentRow.d.ts +2 -1
  23. package/dist/molecules/RemovableRow.js +32 -32
  24. package/dist/molecules/RevealRadioGroup.d.ts +3 -9
  25. package/dist/molecules/RevealSwitch.d.ts +3 -7
  26. package/dist/molecules/Select.d.ts +8 -23
  27. package/dist/molecules/Select.js +26 -20
  28. package/dist/molecules/StatusButton.d.ts +3 -7
  29. package/dist/molecules/ToggleGrid.d.ts +2 -1
  30. package/dist/molecules/TokenTextField.d.ts +2 -1
  31. package/dist/molecules/TreeOptions.d.ts +3 -2
  32. package/dist/molecules/TreeOptions.js +67 -44
  33. package/dist/organisms/HourOfDayRow.js +2 -2
  34. package/dist/organisms/HourOfWeekGrid.js +2 -2
  35. package/dist/organisms/TokenPickerDialog.d.ts +2 -1
  36. package/dist/organisms/TransferPicker.d.ts +2 -1
  37. package/dist/organisms/TreeSearchPanel.js +50 -47
  38. package/dist/theme/AntsomiTheme.d.ts +3 -2
  39. package/dist/theme/AntsomiTheme.js +8 -7
  40. package/dist/ui.css +1 -1
  41. package/package.json +23 -17
  42. package/src/atoms/AddButton.tsx +3 -6
  43. package/src/atoms/Chip.tsx +6 -5
  44. package/src/atoms/RemoveButton.tsx +4 -6
  45. package/src/atoms/TextAction.tsx +4 -4
  46. package/src/lib/forwardable.ts +8 -0
  47. package/src/lib/iso.ts +15 -3
  48. package/src/lib/tokenEditorExtensions.ts +1 -1
  49. package/src/molecules/AccentCard.tsx +4 -2
  50. package/src/molecules/CheckGroup.tsx +3 -3
  51. package/src/molecules/CheckRow.tsx +3 -6
  52. package/src/molecules/ChoiceTiles.tsx +3 -1
  53. package/src/molecules/CommitTextField.tsx +18 -20
  54. package/src/molecules/ConfirmDialog.tsx +6 -8
  55. package/src/molecules/DateTimeInput.tsx +87 -68
  56. package/src/molecules/DurationInput.tsx +4 -1
  57. package/src/molecules/PercentRow.tsx +3 -2
  58. package/src/molecules/RemovableRow.tsx +1 -1
  59. package/src/molecules/RevealRadioGroup.tsx +5 -10
  60. package/src/molecules/RevealSwitch.tsx +4 -8
  61. package/src/molecules/Select.tsx +25 -22
  62. package/src/molecules/StatusButton.tsx +4 -8
  63. package/src/molecules/ToggleGrid.tsx +3 -3
  64. package/src/molecules/TokenTextField.tsx +3 -3
  65. package/src/molecules/TreeOptions.tsx +86 -62
  66. package/src/organisms/HourOfDayRow.tsx +4 -2
  67. package/src/organisms/HourOfWeekGrid.tsx +4 -2
  68. package/src/organisms/TokenPickerDialog.tsx +2 -1
  69. package/src/organisms/TransferPicker.tsx +3 -3
  70. package/src/organisms/TreeSearchPanel.tsx +1 -1
  71. package/src/theme/AntsomiTheme.tsx +9 -3
  72. package/dist/atoms/AddButton.doc.d.ts +0 -21
  73. package/dist/atoms/AddGlyph.doc.d.ts +0 -16
  74. package/dist/atoms/Chip.doc.d.ts +0 -29
  75. package/dist/atoms/ChipSkeletons.doc.d.ts +0 -21
  76. package/dist/atoms/FieldHeading.doc.d.ts +0 -15
  77. package/dist/atoms/HoverSwap.doc.d.ts +0 -25
  78. package/dist/atoms/InfoTip.doc.d.ts +0 -25
  79. package/dist/atoms/JointLabel.doc.d.ts +0 -15
  80. package/dist/atoms/LabeledDivider.doc.d.ts +0 -21
  81. package/dist/atoms/LogoImage.doc.d.ts +0 -21
  82. package/dist/atoms/PanelSearchInput.doc.d.ts +0 -25
  83. package/dist/atoms/PathMark.doc.d.ts +0 -16
  84. package/dist/atoms/RemoveButton.doc.d.ts +0 -16
  85. package/dist/atoms/RowSkeletons.doc.d.ts +0 -25
  86. package/dist/atoms/TextAction.doc.d.ts +0 -25
  87. package/dist/atoms/TruncatedOption.doc.d.ts +0 -24
  88. package/dist/atoms/TruncatedText.doc.d.ts +0 -15
  89. package/dist/molecules/AccentCard.doc.d.ts +0 -25
  90. package/dist/molecules/CheckGroup.doc.d.ts +0 -25
  91. package/dist/molecules/CheckRow.doc.d.ts +0 -25
  92. package/dist/molecules/ChoiceDialog.doc.d.ts +0 -21
  93. package/dist/molecules/ChoiceTiles.doc.d.ts +0 -21
  94. package/dist/molecules/CommitTextField.doc.d.ts +0 -29
  95. package/dist/molecules/ConfirmDialog.doc.d.ts +0 -21
  96. package/dist/molecules/DateTimeInput.doc.d.ts +0 -25
  97. package/dist/molecules/DurationInput.doc.d.ts +0 -25
  98. package/dist/molecules/FieldGroup.doc.d.ts +0 -25
  99. package/dist/molecules/FieldRow.doc.d.ts +0 -24
  100. package/dist/molecules/FieldSkeleton.doc.d.ts +0 -25
  101. package/dist/molecules/FrequencyLimitRow.doc.d.ts +0 -25
  102. package/dist/molecules/InlineEditableText.doc.d.ts +0 -25
  103. package/dist/molecules/LoadMoreRow.doc.d.ts +0 -21
  104. package/dist/molecules/LoadState.doc.d.ts +0 -21
  105. package/dist/molecules/MetaTable.doc.d.ts +0 -25
  106. package/dist/molecules/PercentRow.doc.d.ts +0 -25
  107. package/dist/molecules/PhoneFrame.doc.d.ts +0 -21
  108. package/dist/molecules/ProblemsButton.doc.d.ts +0 -25
  109. package/dist/molecules/RemovableRow.doc.d.ts +0 -25
  110. package/dist/molecules/RevealRadioGroup.doc.d.ts +0 -25
  111. package/dist/molecules/RevealSwitch.doc.d.ts +0 -25
  112. package/dist/molecules/RuleRow.doc.d.ts +0 -25
  113. package/dist/molecules/Select.doc.d.ts +0 -30
  114. package/dist/molecules/SideLabelRow.doc.d.ts +0 -20
  115. package/dist/molecules/SplitButton.doc.d.ts +0 -25
  116. package/dist/molecules/StatusButton.doc.d.ts +0 -25
  117. package/dist/molecules/TagSelect.doc.d.ts +0 -25
  118. package/dist/molecules/ToggleGrid.doc.d.ts +0 -25
  119. package/dist/molecules/TokenTextField.doc.d.ts +0 -29
  120. package/dist/molecules/TransferLayout.doc.d.ts +0 -25
  121. package/dist/molecules/TreeOptions.doc.d.ts +0 -25
  122. package/dist/organisms/ChipListAddPopover.doc.d.ts +0 -25
  123. package/dist/organisms/HourOfDayRow.doc.d.ts +0 -25
  124. package/dist/organisms/HourOfWeekGrid.doc.d.ts +0 -25
  125. package/dist/organisms/RepeatableList.doc.d.ts +0 -21
  126. package/dist/organisms/ResizableDrawer.doc.d.ts +0 -25
  127. package/dist/organisms/RuleGroups.doc.d.ts +0 -21
  128. package/dist/organisms/RuleList.doc.d.ts +0 -25
  129. package/dist/organisms/SearchableGroupedList.doc.d.ts +0 -25
  130. package/dist/organisms/TokenPickerDialog.doc.d.ts +0 -21
  131. package/dist/organisms/TransferPicker.doc.d.ts +0 -29
  132. package/dist/organisms/TreeSearchPanel.doc.d.ts +0 -25
  133. package/dist/organisms/TreeSelect.doc.d.ts +0 -29
  134. package/dist/theme/AntsomiTheme.doc.d.ts +0 -15
  135. package/dist/theme/AntsomiTheme.doc.js +0 -22
  136. package/src/atoms/AddButton.doc.ts +0 -36
  137. package/src/atoms/AddGlyph.doc.ts +0 -26
  138. package/src/atoms/Chip.doc.ts +0 -45
  139. package/src/atoms/ChipSkeletons.doc.ts +0 -31
  140. package/src/atoms/FieldHeading.doc.ts +0 -22
  141. package/src/atoms/HoverSwap.doc.ts +0 -39
  142. package/src/atoms/InfoTip.doc.ts +0 -37
  143. package/src/atoms/JointLabel.doc.ts +0 -23
  144. package/src/atoms/LabeledDivider.doc.ts +0 -35
  145. package/src/atoms/LogoImage.doc.ts +0 -42
  146. package/src/atoms/PanelSearchInput.doc.ts +0 -41
  147. package/src/atoms/PathMark.doc.ts +0 -25
  148. package/src/atoms/RemoveButton.doc.ts +0 -26
  149. package/src/atoms/RowSkeletons.doc.ts +0 -43
  150. package/src/atoms/TextAction.doc.ts +0 -40
  151. package/src/atoms/TruncatedOption.doc.ts +0 -39
  152. package/src/atoms/TruncatedText.doc.ts +0 -22
  153. package/src/molecules/AccentCard.doc.ts +0 -43
  154. package/src/molecules/CheckGroup.doc.ts +0 -40
  155. package/src/molecules/CheckRow.doc.ts +0 -43
  156. package/src/molecules/ChoiceDialog.doc.ts +0 -48
  157. package/src/molecules/ChoiceTiles.doc.ts +0 -42
  158. package/src/molecules/CommitTextField.doc.ts +0 -41
  159. package/src/molecules/ConfirmDialog.doc.ts +0 -43
  160. package/src/molecules/DateTimeInput.doc.ts +0 -48
  161. package/src/molecules/DurationInput.doc.ts +0 -36
  162. package/src/molecules/FieldGroup.doc.ts +0 -41
  163. package/src/molecules/FieldRow.doc.ts +0 -36
  164. package/src/molecules/FieldSkeleton.doc.ts +0 -38
  165. package/src/molecules/FrequencyLimitRow.doc.ts +0 -48
  166. package/src/molecules/InlineEditableText.doc.ts +0 -41
  167. package/src/molecules/LoadMoreRow.doc.ts +0 -36
  168. package/src/molecules/LoadState.doc.ts +0 -42
  169. package/src/molecules/MetaTable.doc.ts +0 -46
  170. package/src/molecules/PercentRow.doc.ts +0 -48
  171. package/src/molecules/PhoneFrame.doc.ts +0 -46
  172. package/src/molecules/ProblemsButton.doc.ts +0 -41
  173. package/src/molecules/RemovableRow.doc.ts +0 -48
  174. package/src/molecules/RevealRadioGroup.doc.ts +0 -41
  175. package/src/molecules/RevealSwitch.doc.ts +0 -38
  176. package/src/molecules/RuleRow.doc.ts +0 -43
  177. package/src/molecules/Select.doc.ts +0 -62
  178. package/src/molecules/SideLabelRow.doc.ts +0 -35
  179. package/src/molecules/SplitButton.doc.ts +0 -41
  180. package/src/molecules/StatusButton.doc.ts +0 -39
  181. package/src/molecules/TagSelect.doc.ts +0 -41
  182. package/src/molecules/ToggleGrid.doc.ts +0 -43
  183. package/src/molecules/TokenTextField.doc.ts +0 -41
  184. package/src/molecules/TransferLayout.doc.ts +0 -42
  185. package/src/molecules/TreeOptions.doc.ts +0 -38
  186. package/src/organisms/ChipListAddPopover.doc.ts +0 -54
  187. package/src/organisms/HourOfDayRow.doc.ts +0 -43
  188. package/src/organisms/HourOfWeekGrid.doc.ts +0 -48
  189. package/src/organisms/RepeatableList.doc.ts +0 -49
  190. package/src/organisms/ResizableDrawer.doc.ts +0 -48
  191. package/src/organisms/RuleGroups.doc.ts +0 -49
  192. package/src/organisms/RuleList.doc.ts +0 -43
  193. package/src/organisms/SearchableGroupedList.doc.ts +0 -49
  194. package/src/organisms/TokenPickerDialog.doc.ts +0 -54
  195. package/src/organisms/TransferPicker.doc.ts +0 -69
  196. package/src/organisms/TreeSearchPanel.doc.ts +0 -43
  197. package/src/organisms/TreeSelect.doc.ts +0 -56
  198. package/src/theme/AntsomiTheme.doc.ts +0 -23
@@ -4,36 +4,37 @@ 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
- /** The field's label; also its accessible name when hidden. */
12
- readonly label: string;
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
+ >
25
+ > & {
13
26
  /** The committed text. A new value from outside (an agent, undo) replaces the draft. */
14
27
  readonly value: string;
15
28
  /** Called with the draft on blur or Enter, only when it differs from `value`. */
16
29
  readonly onCommit: (value: string) => void;
17
30
  /** The input's height, `md` by default. */
18
31
  readonly size?: "sm" | "md";
19
- /** Dims the field and blocks typing. */
20
- readonly isDisabled?: boolean;
21
- /** Shows the text, not dimmed, and blocks typing. */
22
- readonly isReadOnly?: boolean;
23
- /** Keeps the label for screen readers only. */
24
- readonly isLabelHidden?: boolean;
25
- /** Shown while the field is empty. */
26
- readonly placeholder?: string;
27
- /** Help under the label. */
28
- readonly description?: string;
29
32
  /** A problem with the value, already in the user's language. */
30
33
  readonly error?: string | undefined;
31
34
  /** A text area instead of a single line; Enter then adds a line. */
32
35
  readonly isMultiline?: boolean;
33
36
  /** For `isMultiline`: how many rows the text area shows, `4` by default. */
34
37
  readonly rows?: number;
35
- /** Marks the field as required. */
36
- readonly isRequired?: boolean;
37
38
  /**
38
39
  * `false` (default): after a commit the draft goes back to `value`, so a refused text does not
39
40
  * stay in the field. `true` keeps the typed text until `value` changes from outside.
@@ -43,10 +44,6 @@ export type CommitTextFieldProps = {
43
44
  readonly maxLength?: number;
44
45
  /** Fresh global pattern for whole tokens, counted as one character even in plain text. */
45
46
  readonly pattern?: () => RegExp;
46
- /** For a single line: the field's width, in pixels or any CSS length such as `"100%"`. */
47
- readonly width?: number | string;
48
- /** For a single line: StyleX styles for the input's box, e.g. to make it read as plain text. */
49
- readonly controlXstyle?: TextInputProps["controlXstyle"];
50
47
  };
51
48
 
52
49
  /**
@@ -86,6 +83,8 @@ export function CommitTextField(props: CommitTextFieldProps): ReactNode {
86
83
  isRequired: props.isRequired ?? false,
87
84
  ...(props.placeholder === undefined ? {} : { placeholder: props.placeholder }),
88
85
  ...(props.description === undefined ? {} : { description: props.description }),
86
+ ...(props.controlXstyle === undefined ? {} : { controlXstyle: props.controlXstyle }),
87
+ ...(props.containerXstyle === undefined ? {} : { containerXstyle: props.containerXstyle }),
89
88
  ...errorStatus(error),
90
89
  };
91
90
  if (isMultiline) return <TextArea {...common} rows={props.rows ?? 4} />;
@@ -94,7 +93,6 @@ export function CommitTextField(props: CommitTextFieldProps): ReactNode {
94
93
  {...common}
95
94
  onEnter={commitAndReset}
96
95
  {...(props.width === undefined ? {} : { width: props.width })}
97
- {...(props.controlXstyle === undefined ? {} : { controlXstyle: props.controlXstyle })}
98
96
  />
99
97
  );
100
98
  }
@@ -1,14 +1,12 @@
1
- import { AlertDialog } from "@astryxdesign/core/AlertDialog";
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 = {
6
- /** Open while a change waits for an answer. */
7
- readonly isOpen: boolean;
8
- /** The question, e.g. "Remove these rows?". */
9
- readonly title: string;
10
- /** What the change does. */
11
- readonly description: string;
7
+ export type ConfirmDialogProps = Forwardable<
8
+ Pick<AlertDialogProps, "isOpen" | "title" | "description">
9
+ > & {
12
10
  /** The texts of the two buttons; the host translates them. */
13
11
  readonly labels: {
14
12
  /** The confirming button, e.g. "Remove". */
@@ -1,101 +1,115 @@
1
1
  import { DateInput } from "@astryxdesign/core/DateInput";
2
2
  import { HStack } from "@astryxdesign/core/HStack";
3
3
  import { Text } from "@astryxdesign/core/Text";
4
- import { TimeInput } from "@astryxdesign/core/TimeInput";
4
+ import { TextInput } from "@astryxdesign/core/TextInput";
5
+ import { TimeInput, type TimeInputProps } from "@astryxdesign/core/TimeInput";
5
6
  import type { ReactNode } from "react";
6
7
 
7
8
  import { errorStatus } from "../lib/errorStatus";
9
+ import type { Forwardable } from "../lib/forwardable";
8
10
  import { dateValue, minDate, timeValue } from "../lib/iso";
9
11
  import { FieldGroup, type FieldGroupProps } from "./FieldGroup";
10
12
 
11
13
  /** What `DateTimeInput` takes. */
12
- export type DateTimeInputProps = Pick<FieldGroupProps, "isDisabled"> & {
13
- /** The group's label, e.g. "Start date"; it names the group and is not shown. */
14
- readonly label: string;
15
- /** The texts the inputs show; the host translates them. */
16
- readonly labels: {
17
- /** The date input's label: its accessible name in a group, shown with `frame="none"`. */
18
- readonly date: string;
19
- /** The time input's label: its accessible name in a group, shown with `frame="none"`. */
20
- readonly time: string;
21
- /** A time zone, or any note, shown beside the time. */
22
- readonly timezone?: string | undefined;
14
+ export type DateTimeInputProps = Forwardable<Pick<FieldGroupProps, "isDisabled">> &
15
+ Forwardable<Pick<TimeInputProps, "hourFormat">> & {
16
+ /** The group's label, e.g. "Start date"; it names the group and is not shown. */
17
+ readonly label: string;
18
+ /** The texts the inputs show; the host translates them. */
19
+ readonly labels: {
20
+ /** The date input's label: its accessible name in a group, shown with `frame="none"`. */
21
+ readonly date: string;
22
+ /** The time input's label: its accessible name in a group, shown with `frame="none"`. */
23
+ readonly time: string;
24
+ /** A time zone, or any note, shown beside the time. */
25
+ readonly timezone?: string | undefined;
26
+ };
27
+ /** The local date-time (`YYYY-MM-DD HH:mm:ss`); empty or partial while it is being filled in. */
28
+ readonly value: string;
29
+ /** The inputs' size, `md` by default. */
30
+ readonly size?: "sm" | "md" | undefined;
31
+ /** Shows readable date and time fields at full opacity, without clear or picker actions. */
32
+ readonly isReadOnly?: boolean | undefined;
33
+ /** A problem with the date-time, already in the user's language. */
34
+ readonly error?: string | undefined;
35
+ /** `false` picks a date only: the time input is left out and `onChange` gets `YYYY-MM-DD`, or empty. */
36
+ readonly hasTime?: boolean;
37
+ /**
38
+ * `bare` (default) puts both inputs, with hidden labels, in an unframed group that `label` names
39
+ * for assistive tech, for a host that shows the label itself. `none` draws no group: it shows
40
+ * `labels.date` and `labels.time` above the inputs and hangs `description` and `error` on the
41
+ * date input.
42
+ */
43
+ readonly frame?: "bare" | "none";
44
+ /** Help above the inputs, or under the date input with `frame="none"`. */
45
+ readonly description?: string | undefined;
46
+ /** Marks the date as required. */
47
+ readonly isRequired?: boolean;
48
+ /** The time input stays disabled until a date is picked. */
49
+ readonly isTimeLockedWithoutDate?: boolean;
50
+ /** The earliest valid calendar date (`YYYY-MM-DD`); an absent or invalid minimum leaves dates unconstrained. */
51
+ readonly min?: string | undefined;
52
+ /** Called with the new date-time; a part not picked yet is empty, a new date starts at 00:00:00. */
53
+ readonly onChange: (value: string) => void;
23
54
  };
24
- /** The local date-time (`YYYY-MM-DD HH:mm:ss`); empty or partial while it is being filled in. */
25
- readonly value: string;
26
- /** The inputs' size, `md` by default. */
27
- readonly size?: "sm" | "md" | undefined;
28
- /** Shows the date-time, not dimmed, and ignores changes. */
29
- readonly isReadOnly?: boolean | undefined;
30
- /** A problem with the date-time, already in the user's language. */
31
- readonly error?: string | undefined;
32
- /** `false` picks a date only: the time input is left out and `onChange` gets `YYYY-MM-DD`, or empty. */
33
- readonly hasTime?: boolean;
34
- /**
35
- * `bare` (default) puts both inputs, with hidden labels, in an unframed group that `label` names
36
- * for assistive tech, for a host that shows the label itself. `none` draws no group: it shows
37
- * `labels.date` and `labels.time` above the inputs and hangs `description` and `error` on the
38
- * date input.
39
- */
40
- readonly frame?: "bare" | "none";
41
- /** Help above the inputs, or under the date input with `frame="none"`. */
42
- readonly description?: string | undefined;
43
- /** Marks the date as required. */
44
- readonly isRequired?: boolean;
45
- /** The time input stays disabled until a date is picked. */
46
- readonly isTimeLockedWithoutDate?: boolean;
47
- /** The earliest date the calendar offers (`YYYY-MM-DD`), such as an end's start; any without it or with another text. */
48
- readonly min?: string | undefined;
49
- /** Called with the new date-time; a part not picked yet is empty, a new date starts at 00:00:00. */
50
- readonly onChange: (value: string) => void;
51
- };
52
55
 
53
56
  /**
54
57
  * A date and a time of day under one label. It composes `DateInput` and `TimeInput` rather than
55
58
  * using Astryx's `DateTimeInput`, which holds only a complete value: here a date or a time may be
56
59
  * set alone while the other is still empty.
60
+ * `hourFormat` defaults to `12h`; choose `24h` for a 24-hour clock. Calendar and clear text use
61
+ * the facade's `InternationalizationProvider`, alongside host-translated `label` and `labels`.
57
62
  */
58
63
  export function DateTimeInput(props: DateTimeInputProps): ReactNode {
59
64
  const { label, isDisabled = false, isReadOnly = false, error, hasTime = true, frame } = props;
60
65
  const size = props.size ?? "md";
61
- const onChange = (next: string): void => {
62
- if (!isReadOnly) props.onChange(next);
63
- };
64
66
  const isInline = frame === "none";
65
67
  const [date = "", time = ""] = props.value.split(" ");
66
- const dateInput = (
68
+ const dateProps = {
69
+ label: props.labels.date,
70
+ size,
71
+ isLabelHidden: !isInline,
72
+ isRequired: props.isRequired ?? false,
73
+ ...(isInline && props.description !== undefined ? { description: props.description } : {}),
74
+ ...(isInline ? errorStatus(error) : {}),
75
+ };
76
+ const dateInput = isReadOnly ? (
77
+ <TextInput {...dateProps} value={date} isReadOnly />
78
+ ) : (
67
79
  <DateInput
68
- label={props.labels.date}
69
- size={size}
70
- isLabelHidden={!isInline}
80
+ {...dateProps}
71
81
  isDisabled={isDisabled}
72
- isRequired={props.isRequired ?? false}
73
82
  {...dateValue(date)}
74
83
  {...minDate(props.min)}
75
84
  onChange={(next) => {
76
85
  // join turns a cleared date (undefined) into an empty one.
77
- onChange(hasTime ? [next, time === "" ? "00:00:00" : time].join(" ") : (next ?? ""));
78
- }}
79
- {...(isInline && props.description !== undefined ? { description: props.description } : {})}
80
- {...(isInline ? errorStatus(error) : {})}
81
- />
82
- );
83
- const timeInput = hasTime && (
84
- <TimeInput
85
- label={props.labels.time}
86
- size={size}
87
- isLabelHidden={!isInline}
88
- hourFormat="12h"
89
- hasSeconds
90
- width={size === "sm" ? 150 : 168}
91
- isDisabled={isDisabled || (props.isTimeLockedWithoutDate === true && date === "")}
92
- {...timeValue(time)}
93
- onChange={(next) => {
94
- // Astryx may hand back HH:mm; the stored time always has seconds.
95
- onChange([date, next?.length === 5 ? `${next}:00` : next].join(" "));
86
+ props.onChange(hasTime ? [next, time === "" ? "00:00:00" : time].join(" ") : (next ?? ""));
96
87
  }}
97
88
  />
98
89
  );
90
+ const timeProps = {
91
+ label: props.labels.time,
92
+ size,
93
+ isLabelHidden: !isInline,
94
+ width: size === "sm" ? 150 : 168,
95
+ };
96
+ const timeInput =
97
+ hasTime &&
98
+ (isReadOnly ? (
99
+ <TextInput {...timeProps} value={time} isReadOnly />
100
+ ) : (
101
+ <TimeInput
102
+ {...timeProps}
103
+ hourFormat={props.hourFormat ?? "12h"}
104
+ hasSeconds
105
+ isDisabled={isDisabled || (props.isTimeLockedWithoutDate === true && date === "")}
106
+ {...timeValue(time)}
107
+ onChange={(next) => {
108
+ // Astryx may hand back HH:mm; the stored time always has seconds.
109
+ props.onChange([date, next?.length === 5 ? `${next}:00` : next].join(" "));
110
+ }}
111
+ />
112
+ ));
99
113
  const zone = props.labels.timezone !== undefined && (
100
114
  <Text type="supporting">{props.labels.timezone}</Text>
101
115
  );
@@ -110,7 +124,12 @@ export function DateTimeInput(props: DateTimeInputProps): ReactNode {
110
124
  );
111
125
  }
112
126
  return (
113
- <FieldGroup label={label} description={props.description} isDisabled={isDisabled} error={error}>
127
+ <FieldGroup
128
+ label={label}
129
+ description={props.description}
130
+ isDisabled={isDisabled && !isReadOnly}
131
+ error={error}
132
+ >
114
133
  <HStack gap={2} wrap="wrap" align="center">
115
134
  {dateInput}
116
135
  {timeInput}
@@ -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 = Pick<FieldGroupProps, "label" | "isDisabled" | "error"> & {
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. */
@@ -67,7 +67,7 @@ export function RemovableRow(props: RemovableRowProps): ReactNode {
67
67
  <RemoveButton
68
68
  label={props.labels.remove}
69
69
  size={props.size}
70
- isDisabled={props.isDisabled}
70
+ isDisabled={props.isDisabled ?? false}
71
71
  isReadOnly={props.isReadOnly}
72
72
  onClick={props.onRemove}
73
73
  />
@@ -1,10 +1,11 @@
1
- import { RadioList, RadioListItem } from "@astryxdesign/core/RadioList";
1
+ import { RadioList, RadioListItem, type RadioListProps } from "@astryxdesign/core/RadioList";
2
2
  import { spacingVars } from "@astryxdesign/core/theme/tokens.stylex";
3
3
  import { VStack } from "@astryxdesign/core/VStack";
4
4
  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,13 +22,9 @@ export type RevealRadioOption<V extends string> = {
21
22
  };
22
23
 
23
24
  /** What `RevealRadioGroup` takes. */
24
- export type RevealRadioGroupProps<V extends string> = {
25
- /** Names the group; also its accessible name when hidden. */
26
- readonly label: string;
27
- /** Keeps the label for screen readers only. */
28
- readonly isLabelHidden?: boolean | undefined;
29
- /** Lays the options out in a row instead of a column. */
30
- readonly orientation?: "vertical" | "horizontal" | undefined;
25
+ export type RevealRadioGroupProps<V extends string> = Forwardable<
26
+ Pick<RadioListProps, "label" | "isLabelHidden" | "orientation" | "isDisabled">
27
+ > & {
31
28
  /** The choices, in order. */
32
29
  readonly options: readonly RevealRadioOption<V>[];
33
30
  /** The chosen option's value. */
@@ -36,8 +33,6 @@ export type RevealRadioGroupProps<V extends string> = {
36
33
  readonly onChange: (value: V) => void;
37
34
  /** The radios' size, `md` by default (Astryx's default; the theme draws it at 18px). */
38
35
  readonly size?: "sm" | "md" | undefined;
39
- /** Dims the radios and blocks them. */
40
- readonly isDisabled?: boolean | undefined;
41
36
  /** Shows the value, not dimmed, and ignores changes. */
42
37
  readonly isReadOnly?: boolean | undefined;
43
38
  /** The space between the list and the revealed content, `2` by default. */
@@ -1,19 +1,15 @@
1
- import { Switch } from "@astryxdesign/core/Switch";
1
+ 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 = {
7
- /** What the switch turns on. */
8
- readonly label: string;
9
- /** Whether the switch is on. */
10
- readonly value: boolean;
8
+ export type RevealSwitchProps = Forwardable<Pick<SwitchProps, "label" | "isDisabled" | "value">> & {
11
9
  /** Called with the new state. */
12
10
  readonly onChange: (value: boolean) => void;
13
11
  /** The switch's size, `md` by default. */
14
12
  readonly size?: "sm" | "md" | undefined;
15
- /** Dims the switch and blocks it. */
16
- readonly isDisabled?: boolean | undefined;
17
13
  /** Shows the value, not dimmed, and ignores changes. */
18
14
  readonly isReadOnly?: boolean | undefined;
19
15
  /** What shows below the switch while it is on. */
@@ -2,24 +2,35 @@ import {
2
2
  Selector,
3
3
  type SelectorOptionData,
4
4
  type SelectorOptionType,
5
+ type SelectorProps,
5
6
  } from "@astryxdesign/core/Selector";
6
7
  import type { ReactNode } from "react";
7
8
 
8
9
  import { TruncatedOption } from "../atoms/TruncatedOption";
9
10
  import { errorStatus } from "../lib/errorStatus";
11
+ import type { Forwardable } from "../lib/forwardable";
10
12
  import { useLoadingShown } from "../lib/useLoadingShown";
11
13
 
12
14
  /** One entry of `Select`'s list: an option, a titled section of options, or a divider (Astryx's). */
13
15
  export type SelectOption = SelectorOptionType;
14
16
 
15
17
  /** What `Select` takes. */
16
- export type SelectProps = {
17
- /** Names the control for assistive tech; shown above it unless `isLabelHidden`. */
18
- readonly label: string;
19
- /** Hides the label, as in a rule row. */
20
- readonly isLabelHidden?: boolean | undefined;
21
- /** A line under the label that explains the choice. */
22
- readonly description?: string | undefined;
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
+ >
33
+ > & {
23
34
  /** The list, in order. */
24
35
  readonly options: readonly SelectOption[];
25
36
  /** The picked option's value; `null` or none shows the placeholder. */
@@ -28,22 +39,10 @@ export type SelectProps = {
28
39
  readonly onChange: (value: string) => void;
29
40
  /** Called by the clear button, which shows only when this is given and an option is picked. */
30
41
  readonly onClear?: (() => void) | undefined;
31
- /** Shown in the trigger while nothing is picked. */
32
- readonly placeholder?: string | undefined;
33
- /** A search box over the list, filtering it as it is typed. */
34
- readonly hasSearch?: boolean | undefined;
35
42
  /** The trigger's look: an underlined field (`input`, the default) or a bare text button (`ghost`). */
36
43
  readonly variant?: "input" | "ghost" | undefined;
37
- /** The trigger's size, `md` by default (the theme's 30px control height). */
38
- readonly size?: "sm" | "md" | undefined;
39
- /** The trigger's width, in pixels or any CSS length such as `"100%"`. */
40
- readonly width?: number | string | undefined;
41
- /** Dims the trigger and blocks it. */
42
- readonly isDisabled?: boolean | undefined;
43
- /** Shows the picked label without the chevron; the list does not open. */
44
- readonly isReadOnly?: boolean | undefined;
45
- /** Marks the field as required. */
46
- readonly isRequired?: boolean | undefined;
44
+ /** The trigger's size, md by default; the kit narrows the upstream sizes to sm and md. */
45
+ readonly size?: Extract<SelectorProps["size"], "sm" | "md"> | undefined;
47
46
  /**
48
47
  * The options are loading: a spinner in place of the chevron and the trigger busy from 300 ms
49
48
  * on, for at least 300 ms (`useLoadingShown`), and the list does not open meanwhile. The picked
@@ -53,7 +52,7 @@ export type SelectProps = {
53
52
  readonly isLoading?: boolean | undefined;
54
53
  /** A problem with the pick, already in the user's language, shown under the trigger. */
55
54
  readonly error?: string | undefined;
56
- /** The texts the view shows; the host translates them. Astryx's English stands in for a missing one. */
55
+ /** Host texts; missing strings use the facade's InternationalizationProvider locale (English by default). */
57
56
  readonly labels?:
58
57
  | {
59
58
  /** The search box's placeholder, such as "Search". */
@@ -72,6 +71,8 @@ export type SelectProps = {
72
71
  * The kit's select on Astryx's `Selector`: the list is as wide as the
73
72
  * trigger (the theme) and a long option label ends in an ellipsis with the whole label in a
74
73
  * tooltip. Every select is one rather than Astryx's `Selector` (lint-enforced). It holds no state.
74
+ * Localize upstream search, clear and empty text with `InternationalizationProvider` from
75
+ * `@antscorp/ui/astryx/i18n`; `labels` overrides individual kit captions.
75
76
  */
76
77
  export function Select(props: SelectProps): ReactNode {
77
78
  const { labels = {}, onClear, onChange } = props;
@@ -106,6 +107,8 @@ export function Select(props: SelectProps): ReactNode {
106
107
  ...(props.isDisabled !== undefined && { isDisabled: props.isDisabled }),
107
108
  ...(props.isReadOnly !== undefined && !isBusy && { isReadOnly: props.isReadOnly }),
108
109
  ...(props.isRequired !== undefined && { isRequired: props.isRequired }),
110
+ ...(props.controlXstyle !== undefined && { controlXstyle: props.controlXstyle }),
111
+ ...(props.containerXstyle !== undefined && { containerXstyle: props.containerXstyle }),
109
112
  ...(labels.search !== undefined && { searchPlaceholder: labels.search }),
110
113
  ...(labels.noMatch !== undefined && { emptySearchText: labels.noMatch }),
111
114
  };
@@ -1,14 +1,14 @@
1
- import { Button } from "@astryxdesign/core/Button";
1
+ 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 = {
10
- /** The button's text. */
11
- readonly label: string;
11
+ export type StatusButtonProps = Forwardable<Pick<ButtonProps, "label" | "icon" | "isDisabled">> & {
12
12
  /** The dot's tone: neutral, accent, success, warning or error. */
13
13
  readonly status: StatusTone;
14
14
  /** The texts the view shows; the host translates them. */
@@ -16,14 +16,10 @@ export type StatusButtonProps = {
16
16
  /** What the dot means, read out for it, e.g. "Connected". */
17
17
  readonly status: string;
18
18
  };
19
- /** A glyph before the text. */
20
- readonly icon?: ReactNode;
21
19
  /** Called when the button is pressed. */
22
20
  readonly onClick: () => void;
23
21
  /** The button's height, `md` by default. */
24
22
  readonly size?: "sm" | "md" | undefined;
25
- /** Dimmed and not pressable. */
26
- readonly isDisabled?: boolean | undefined;
27
23
  };
28
24
 
29
25
  /** A button whose dot shows a state beside its text, such as a connection. */
@@ -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> = Pick<
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>[];
@@ -14,6 +14,7 @@ import { mergeProps, themeProps } from "@astryxdesign/core/utils";
14
14
  import * as stylex from "@stylexjs/stylex";
15
15
  import { lazy, type ReactNode, Suspense, useId, useRef, useState } from "react";
16
16
 
17
+ import type { Forwardable } from "../lib/forwardable";
17
18
  import type { TokenLook } from "../lib/tokenEditorConfig";
18
19
  import { FieldSkeleton } from "./FieldSkeleton";
19
20
  import { TokenEditorBoundary } from "./token-editor-boundary";
@@ -24,9 +25,8 @@ const Editor = lazy(() => import("./token-editor"));
24
25
  export type { TokenLook } from "../lib/tokenEditorConfig";
25
26
 
26
27
  /** What `TokenTextField` takes. */
27
- export type TokenTextFieldProps = Pick<
28
- FieldProps,
29
- "label" | "description" | "isLabelHidden" | "isDisabled" | "isRequired"
28
+ export type TokenTextFieldProps = Forwardable<
29
+ Pick<FieldProps, "label" | "description" | "isLabelHidden" | "isDisabled" | "isRequired">
30
30
  > & {
31
31
  /** The committed string; outside changes replace the local draft. */
32
32
  readonly value: string;