@7shifts/sous-chef 4.15.0 → 4.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/Button/Button.d.ts +5 -1
- package/dist/actions/Link/Link.d.ts +7 -0
- package/dist/actions/PaginationControls/PaginationControls.d.ts +7 -5
- package/dist/actions/Toggle/Toggle.d.ts +2 -0
- package/dist/controls/DateFilter/DateFilter.d.ts +16 -1
- package/dist/controls/SegmentedControl/SegmentedControl.d.ts +6 -0
- package/dist/controls/ToolbarSelect/ToolbarSelect.d.ts +9 -1
- package/dist/core/SousChefProvider/SousChefProvider.d.ts +7 -0
- package/dist/empty_states/EmptyStateContainer/types.d.ts +16 -2
- package/dist/feedback/CircularProgress/CircularProgress.d.ts +1 -0
- package/dist/feedback/InlineBanner/InlineBanner.d.ts +1 -0
- package/dist/feedback/MicroBanner/MicroBanner.d.ts +1 -0
- package/dist/feedback/PersistentBanner/PersistentBanner.d.ts +6 -0
- package/dist/feedback/ProgressBar/ProgressBar.d.ts +7 -1
- package/dist/feedback/Spinner/Spinner.d.ts +6 -0
- package/dist/feedback/Toast/Toast.d.ts +13 -0
- package/dist/forms/CheckboxField/CheckboxField.d.ts +4 -0
- package/dist/forms/CurrencyField/CurrencyField.d.ts +5 -21
- package/dist/forms/DateField/DateField.d.ts +13 -1
- package/dist/forms/DateRangeField/DateRangeCalendar/DateRangeCalendar.d.ts +6 -3
- package/dist/forms/DateRangeField/DateRangeField.d.ts +17 -3
- package/dist/forms/Form/Form.d.ts +13 -2
- package/dist/forms/FormFeedback/FormFeedback.d.ts +1 -0
- package/dist/forms/FormFooter/FormFooter.d.ts +11 -5
- package/dist/forms/FormFooter/FormFooterActions/FormFooterActions.d.ts +2 -5
- package/dist/forms/FormFooter/types.d.ts +10 -0
- package/dist/forms/FormRow/FormRow.d.ts +6 -0
- package/dist/forms/FormSection/FormSection.d.ts +4 -0
- package/dist/forms/MultiSelectField/MultiSelectField.d.ts +6 -2
- package/dist/forms/NumberField/NumberField.d.ts +4 -0
- package/dist/forms/PasswordField/PasswordField.d.ts +3 -0
- package/dist/forms/PercentageField/PercentageField.d.ts +13 -0
- package/dist/forms/PhoneField/PhoneField.d.ts +10 -0
- package/dist/forms/PillSelectField/PillSelectField.d.ts +9 -0
- package/dist/forms/PillSelectField/types.d.ts +2 -0
- package/dist/forms/RadioGroupBoxOption/RadioGroupBoxOption.d.ts +7 -0
- package/dist/forms/RadioGroupField/RadioGroupField.d.ts +8 -1
- package/dist/forms/RadioGroupField/RadioGroupFieldContext.d.ts +2 -1
- package/dist/forms/RadioGroupOption/RadioGroupOption.d.ts +6 -1
- package/dist/forms/SelectField/SelectField.d.ts +20 -3
- package/dist/forms/SelectField/types.d.ts +27 -0
- package/dist/forms/TextAreaField/TextAreaField.d.ts +7 -1
- package/dist/forms/TextField/TextField.d.ts +8 -0
- package/dist/forms/TimeField/TimeField.d.ts +23 -1
- package/dist/forms/TimeRangeField/TimeRangeField.d.ts +15 -2
- package/dist/forms/WeekField/WeekField.d.ts +4 -0
- package/dist/forms/WeekSelectField/WeekSelectField.d.ts +4 -0
- package/dist/forms/hooks/useRadioGroupFieldControllers.d.ts +1 -2
- package/dist/forms/hooks/useSelectFieldControllers.d.ts +2 -2
- package/dist/forms/index.d.ts +2 -0
- package/dist/foundation/tokens/color/color-constants.d.ts +34 -0
- package/dist/foundation/tokens/color/color-types.d.ts +1 -1
- package/dist/foundation/tokens/dimension/dimension-tokens.d.ts +1 -0
- package/dist/foundation/tokens/layout/TokenTable.d.ts +14 -0
- package/dist/foundation/tokens/layout/layout-tokens.d.ts +12 -0
- package/dist/hooks/useIsOverflowing.d.ts +2 -0
- package/dist/index.css +755 -479
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1295 -941
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1431 -1098
- package/dist/index.modern.js.map +1 -1
- package/dist/ink_illustrations/components/design/Ink3DModeling.d.ts +7 -0
- package/dist/ink_illustrations/components/design/index.d.ts +1 -1
- package/dist/ink_illustrations/components/index.d.ts +2 -2
- package/dist/ink_illustrations/components/other/InkSculptureBust.d.ts +7 -0
- package/dist/ink_illustrations/components/other/index.d.ts +1 -1
- package/dist/ink_illustrations/components/{design/Ink3DModeling02.d.ts → travel/InkBoardingPass.d.ts} +2 -2
- package/dist/ink_illustrations/components/travel/InkVolcano.d.ts +7 -0
- package/dist/ink_illustrations/components/travel/index.d.ts +2 -2
- package/dist/ink_illustrations/components/weather/InkSun.d.ts +7 -0
- package/dist/ink_illustrations/components/weather/index.d.ts +1 -1
- package/dist/ink_illustrations/deprecatedAliases.d.ts +27 -0
- package/dist/ink_illustrations/index.d.ts +1 -0
- package/dist/layout/CalloutCard/CalloutCard.d.ts +1 -0
- package/dist/layout/Card/Card.d.ts +14 -0
- package/dist/layout/Inline/Inline.d.ts +20 -4
- package/dist/layout/Page/Page.d.ts +11 -3
- package/dist/layout/Page/PageBreadcrumbs/PageBreadcrumbs.d.ts +2 -2
- package/dist/layout/Page/types.d.ts +11 -2
- package/dist/layout/PageLayout/PageLayout.d.ts +18 -0
- package/dist/layout/PageLayout/types.d.ts +10 -0
- package/dist/layout/Stack/Stack.d.ts +16 -4
- package/dist/layout/index.d.ts +1 -0
- package/dist/lists/Accordion/Accordion.d.ts +10 -0
- package/dist/lists/Accordion/types.d.ts +4 -0
- package/dist/lists/ActionList/ActionList.d.ts +12 -0
- package/dist/lists/ActionList/type.d.ts +5 -0
- package/dist/lists/ActionListItem/ActionListItem.d.ts +17 -0
- package/dist/lists/BasicTable/BasicTable.d.ts +22 -0
- package/dist/lists/BasicTable/BasicTableSectionContext.d.ts +4 -0
- package/dist/lists/BasicTable/constants.d.ts +13 -0
- package/dist/lists/BasicTable/index.d.ts +1 -0
- package/dist/lists/BasicTable/types.d.ts +4 -0
- package/dist/lists/BasicTableBody/BasicTableBody.d.ts +9 -0
- package/dist/lists/BasicTableBody/index.d.ts +1 -0
- package/dist/lists/BasicTableCell/BasicTableCell.d.ts +14 -0
- package/dist/lists/BasicTableCell/index.d.ts +1 -0
- package/dist/lists/BasicTableHeader/BasicTableHeader.d.ts +9 -0
- package/dist/lists/BasicTableHeader/index.d.ts +1 -0
- package/dist/lists/BasicTableRow/BasicTableRow.d.ts +9 -0
- package/dist/lists/BasicTableRow/index.d.ts +1 -0
- package/dist/lists/DataTable/DataTable.d.ts +31 -8
- package/dist/lists/DataTable/types.d.ts +35 -0
- package/dist/lists/DataTableCell/DataTableCell.d.ts +1 -0
- package/dist/lists/DataTableEditableCell/DataTableEditableCell.d.ts +1 -0
- package/dist/lists/DataTableRow/DataTableRow.d.ts +12 -0
- package/dist/lists/index.d.ts +7 -1
- package/dist/media/Avatar/Avatar.d.ts +1 -0
- package/dist/media/Badge/Badge.d.ts +7 -2
- package/dist/media/Pill/Pill.d.ts +8 -0
- package/dist/media/Pill/constants.d.ts +2 -0
- package/dist/media/Pill/types.d.ts +3 -1
- package/dist/navigation/BreadcrumbItem/BreadcrumbItem.d.ts +1 -0
- package/dist/navigation/Breadcrumbs/Breadcrumbs.d.ts +1 -0
- package/dist/navigation/PrimaryNav/PrimaryNav.d.ts +1 -0
- package/dist/navigation/PrimaryNavFooter/PrimaryNavFooter.d.ts +1 -0
- package/dist/navigation/PrimaryNavItem/PrimaryNavItem.d.ts +1 -0
- package/dist/navigation/PrimaryNavSubItem/PrimaryNavSubItem.d.ts +1 -0
- package/dist/navigation/Tab/Tab.d.ts +1 -0
- package/dist/navigation/TabList/TabList.d.ts +1 -0
- package/dist/navigation/TabPanel/TabPanel.d.ts +1 -0
- package/dist/navigation/Tabs/Tabs.d.ts +1 -0
- package/dist/overlay/Calendar/Calendar.d.ts +15 -4
- package/dist/overlay/Dropdown/Dropdown.d.ts +1 -0
- package/dist/overlay/DropdownListDivider/DropdownListDivider.d.ts +1 -0
- package/dist/overlay/DropdownListItem/DropdownListItem.d.ts +1 -0
- package/dist/overlay/DropdownListItemSelectable/DropdownListItemSelectable.d.ts +1 -0
- package/dist/overlay/DropdownSubmenu/DropdownSubmenu.d.ts +1 -0
- package/dist/overlay/HintModal/HintModal.d.ts +1 -0
- package/dist/overlay/KebabMenu/types.d.ts +5 -0
- package/dist/overlay/Modal/Modal.d.ts +3 -0
- package/dist/overlay/Modal/ModalBody/ModalBody.d.ts +1 -0
- package/dist/overlay/Modal/ModalFooter/ModalFooter.d.ts +11 -6
- package/dist/overlay/Modal/ModalFooter/types.d.ts +10 -0
- package/dist/overlay/Popover/Popover.d.ts +8 -1
- package/dist/overlay/Tooltip/Tooltip.d.ts +2 -1
- package/dist/overlay/index.d.ts +1 -0
- package/dist/typography/KeyboardKey/KeyboardKey.d.ts +1 -0
- package/dist/typography/Text/Bold/Bold.d.ts +1 -0
- package/dist/typography/Text/Italic/Italic.d.ts +1 -0
- package/dist/typography/Text/Text.d.ts +23 -0
- package/dist/typography/Text/Underline/Underline.d.ts +1 -0
- package/dist/utils/formik.d.ts +5 -0
- package/llms-instructions/guidelines/ActionList.guidelines.md +1 -3
- package/llms-instructions/guidelines/Avatar.guidelines.md +6 -5
- package/llms-instructions/guidelines/Badge.guidelines.md +24 -8
- package/llms-instructions/guidelines/BasicTable.guidelines.md +80 -0
- package/llms-instructions/guidelines/Breadcrumbs.guidelines.md +2 -2
- package/llms-instructions/guidelines/Button.guidelines.md +3 -3
- package/llms-instructions/guidelines/Calendar.guidelines.md +12 -0
- package/llms-instructions/guidelines/Card.guidelines.md +2 -2
- package/llms-instructions/guidelines/CircularProgress.guidelines.md +1 -1
- package/llms-instructions/guidelines/DateFilter.guidelines.md +2 -2
- package/llms-instructions/guidelines/Dropdown.guidelines.md +3 -2
- package/llms-instructions/guidelines/EmptyState.guidelines.md +3 -1
- package/llms-instructions/guidelines/{Forms.guidelines.md → Form.guidelines.md} +41 -6
- package/llms-instructions/guidelines/Icons.guidelines.md +11 -10
- package/llms-instructions/guidelines/InkIllustrations.guidelines.md +5 -4
- package/llms-instructions/guidelines/Inline.guidelines.md +55 -0
- package/llms-instructions/guidelines/InlineBanner.guidelines.md +5 -3
- package/llms-instructions/guidelines/MultiSelectField.guidelines.md +2 -2
- package/llms-instructions/guidelines/Page.guidelines.md +65 -0
- package/llms-instructions/guidelines/PageLayout.guidelines.md +85 -0
- package/llms-instructions/guidelines/Paywall.guidelines.md +3 -2
- package/llms-instructions/guidelines/PersistentBanner.guidelines.md +2 -2
- package/llms-instructions/guidelines/Pill.guidelines.md +31 -3
- package/llms-instructions/guidelines/PillSelectField.guidelines.md +1 -1
- package/llms-instructions/guidelines/PrimaryNav.guidelines.md +144 -0
- package/llms-instructions/guidelines/SegmentedControl.guidelines.md +2 -2
- package/llms-instructions/guidelines/Skeleton.guidelines.md +3 -3
- package/llms-instructions/guidelines/Spinner.guidelines.md +6 -4
- package/llms-instructions/guidelines/Stack.guidelines.md +53 -0
- package/llms-instructions/guidelines/Text.guidelines.md +70 -0
- package/llms-instructions/guidelines/Toast.guidelines.md +2 -1
- package/llms-instructions/guidelines/Toggle.guidelines.md +2 -2
- package/llms-instructions/guidelines/ToolbarSelect.guidelines.md +2 -2
- package/llms-instructions/guidelines/Tooltip.guidelines.md +1 -1
- package/llms-instructions/llms-components.md +91 -19
- package/llms-instructions/llms-composing-components.md +583 -219
- package/llms-instructions/llms-icons-and-illustrations.md +305 -1011
- package/llms-instructions/llms-tokens.md +227 -164
- package/llms-instructions/llms.md +12 -28
- package/package.json +2 -2
- package/dist/ink_illustrations/components/other/InkS/321/201ulptureBust.d.ts +0 -7
- package/dist/ink_illustrations/components/travel/InkDrawing.d.ts +0 -7
- package/dist/ink_illustrations/components/travel/InkDrawing1.d.ts +0 -7
- package/dist/ink_illustrations/components/weather/InkGroup7975.d.ts +0 -7
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/Ink3DGlasses.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkAmusementPark.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkBallet.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkBowling.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkCardGames.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkCarouselWithHorses.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkDiscoBall.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkDj.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkFirecracker.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkJoystick.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkMagicTricks.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkMascarade.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkNotesChart.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkRollerSkating.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkSlotMachine.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/InkTheatre.d.ts +0 -0
- /package/dist/ink_illustrations/components/{enterteniment → entertainment}/index.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkAnatomy.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkAsteroid.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkAstronaut.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkBacteria.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkChemistry.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkDna.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkLabTube.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkMicroChips.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkMicroscope.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkNewtonsCradle.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkNuclearEnergy.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkPlanet.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkPlantInTube.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkRobotics.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkSpaceTravel.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/InkTelescope.d.ts +0 -0
- /package/dist/ink_illustrations/components/{sciency → science}/index.d.ts +0 -0
|
@@ -4,6 +4,7 @@ type NoOptionsMessageFunction = (input: {
|
|
|
4
4
|
inputValue: string;
|
|
5
5
|
}) => string | null;
|
|
6
6
|
type Props<T> = {
|
|
7
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass is called in addition to the Formik update. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
7
8
|
name: string;
|
|
8
9
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
9
10
|
id?: string;
|
|
@@ -12,8 +13,11 @@ type Props<T> = {
|
|
|
12
13
|
onChange?: (e: SelectOption<T>[]) => void;
|
|
13
14
|
onBlur?: (e: SelectOption<T>[]) => void;
|
|
14
15
|
CustomOption?: React.ElementType;
|
|
16
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
15
17
|
label?: React.ReactNode;
|
|
18
|
+
/** Helper text shown below the field. */
|
|
16
19
|
caption?: React.ReactNode;
|
|
20
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
17
21
|
error?: React.ReactNode;
|
|
18
22
|
placeholder?: string;
|
|
19
23
|
/** Use a prefix for things like currency symbols (“$”, “¥”, “£”) or icons. */
|
|
@@ -21,10 +25,10 @@ type Props<T> = {
|
|
|
21
25
|
noOptionsMessage?: string | NoOptionsMessageFunction;
|
|
22
26
|
disabled?: boolean;
|
|
23
27
|
closeOnSelect?: boolean;
|
|
24
|
-
/** When the user opens the menu, if this prop is `true`, it will scroll the page into to the menu view (if its content falls under a scroll). It is
|
|
28
|
+
/** When the user opens the menu, if this prop is `true`, it will scroll the page into to the menu view (if its content falls under a scroll). It is recommended to disable this behaviour when using the `MultiSelectField` inside a modal. */
|
|
25
29
|
menuShouldScrollIntoView?: boolean;
|
|
26
30
|
testId?: string;
|
|
27
|
-
/** This
|
|
31
|
+
/** This allows disabling the search functionality. Use it only in some edge cases, for example on touch devices, where clicking the field opens a virtual keyboard to search; sometimes that virtual keyboard takes up too much space, and passing `isSearchable={false}` prevents opening it. */
|
|
28
32
|
isSearchable?: boolean;
|
|
29
33
|
creatableButton?: React.ReactNode;
|
|
30
34
|
/** Callback when creating a new option. For grouped options, the groupLabel parameter will be provided. For non-grouped options, groupLabel will be undefined. */
|
|
@@ -4,9 +4,13 @@ import type { Props as TextFieldProps } from '../TextField/TextField';
|
|
|
4
4
|
* A special text input field that only accepts numbers. It has validation and formatting in place to properly display number values. In its default state it only allows whole numbers, but it can be configured to allow decimals and negative values.
|
|
5
5
|
*/
|
|
6
6
|
declare const NumberField: React.ForwardRefExoticComponent<{
|
|
7
|
+
/** Largest allowed value. A larger number is replaced with `max` as the user types. No limit when not set. */
|
|
7
8
|
max?: number | undefined;
|
|
9
|
+
/** Smallest allowed value. A smaller number is replaced with `min` as the user types. The minus key is blocked unless `min` is negative, so set e.g. `min={-100}` to allow negative numbers. */
|
|
8
10
|
min?: number | undefined;
|
|
11
|
+
/** Number of decimal places the user can type. `0` only allows whole numbers. */
|
|
9
12
|
precision?: number | undefined;
|
|
13
|
+
/** Amount the value changes by when using the arrow keys (the native `step` attribute). */
|
|
10
14
|
stepSize?: number | undefined;
|
|
11
15
|
} & Omit<TextFieldProps, "maxLength"> & React.RefAttributes<HTMLInputElement>>;
|
|
12
16
|
export default NumberField;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PasswordCriteria } from './types';
|
|
3
3
|
type Props = {
|
|
4
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass replaces the Formik update, so call `formik.setFieldValue` yourself if you still need it. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
4
5
|
name: string;
|
|
5
6
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
6
7
|
id?: string;
|
|
7
8
|
value?: string;
|
|
8
9
|
onChange?: (e: string) => void;
|
|
9
10
|
onBlur?: (e: string) => void;
|
|
11
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
10
12
|
label?: React.ReactNode;
|
|
13
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
11
14
|
error?: React.ReactNode;
|
|
12
15
|
placeholder?: string;
|
|
13
16
|
disabled?: boolean;
|
|
@@ -4,9 +4,22 @@ import type { Props as TextFieldProps } from '../TextField/TextField';
|
|
|
4
4
|
* A special text input field that only accepts numbers. Comes with validation and formatting in place to properly display percentage values. In its default state it only allows integers between 0 and 100, but it can be configured to allow decimals and negative values.
|
|
5
5
|
*/
|
|
6
6
|
declare const PercentageField: React.ForwardRefExoticComponent<{
|
|
7
|
+
/** Largest allowed value. A larger number is replaced with `max` as the user types. */
|
|
7
8
|
max?: number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Smallest allowed value. A smaller number is replaced with `min` as the user types. The minus key is blocked unless `min` is negative, so set e.g. `min={-100}` to allow negative percentages.
|
|
11
|
+
* @default 0
|
|
12
|
+
*/
|
|
8
13
|
min?: number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Number of decimal places the user can type. `0` only allows whole numbers.
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
9
18
|
precision?: number | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Amount the value changes by when using the arrow keys (the native `step` attribute).
|
|
21
|
+
* @default 1
|
|
22
|
+
*/
|
|
10
23
|
stepSize?: number | undefined;
|
|
11
24
|
} & Omit<TextFieldProps, "suffix" | "maxLength"> & React.RefAttributes<HTMLInputElement>>;
|
|
12
25
|
export default PercentageField;
|
|
@@ -2,21 +2,31 @@ import React from 'react';
|
|
|
2
2
|
import { CountryCode } from 'libphonenumber-js';
|
|
3
3
|
export type Props = {
|
|
4
4
|
autoFocus?: boolean;
|
|
5
|
+
/** Helper text shown below the field. */
|
|
5
6
|
caption?: React.ReactNode;
|
|
6
7
|
disabled?: boolean;
|
|
8
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
7
9
|
error?: React.ReactNode;
|
|
8
10
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
9
11
|
id?: string;
|
|
12
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
10
13
|
label?: React.ReactNode;
|
|
11
14
|
maxLength?: number;
|
|
15
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A non-empty `value` you pass overrides the Formik value (an empty string falls back to the Formik value); an `onChange` you pass is called in addition to the Formik update. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
12
16
|
name: string;
|
|
13
17
|
onBlur?: (value: string) => void;
|
|
14
18
|
onChange?: (value: string) => void;
|
|
15
19
|
placeholder?: string;
|
|
16
20
|
value?: string;
|
|
17
21
|
testId?: string;
|
|
22
|
+
/** When `true` the country selector is hidden. */
|
|
18
23
|
disabledCountry?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* ISO 3166-1 alpha-2 country code (e.g. `'US'`, `'CA'`) selected when the value has no country calling code. Defaults to the `country` set on `SousChefProvider`, which defaults to `'US'`.
|
|
26
|
+
* @default SousChefProvider country ("US")
|
|
27
|
+
*/
|
|
19
28
|
defaultCountry?: CountryCode;
|
|
29
|
+
/** Country codes listed at the top of the country selector. */
|
|
20
30
|
priorityCountries?: CountryCode[];
|
|
21
31
|
};
|
|
22
32
|
/**
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PillSelectOption } from './types';
|
|
3
3
|
type Props<T> = {
|
|
4
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass is called in addition to the Formik update. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
4
5
|
name: string;
|
|
5
6
|
/** If not provided it will generate a random id so the label links properly with the pill select input */
|
|
6
7
|
id?: string;
|
|
8
|
+
/** The selected options, as full `PillSelectOption` objects. */
|
|
7
9
|
value?: PillSelectOption<T>[];
|
|
10
|
+
/**
|
|
11
|
+
* Pills to choose from. Each `PillSelectOption` is `{ value: T, label: string, isDisabled?: boolean, isRemovable?: boolean }`. Removable pills show a remove button that calls `onRemoveOption` when it is provided.
|
|
12
|
+
*/
|
|
8
13
|
options: PillSelectOption<T>[];
|
|
14
|
+
/** Called with the full list of selected `PillSelectOption` objects. */
|
|
9
15
|
onChange?: (e: PillSelectOption<T>[]) => void;
|
|
16
|
+
/** Label shown above the pills. */
|
|
10
17
|
label?: React.ReactNode;
|
|
18
|
+
/** Helper text shown below the field. */
|
|
11
19
|
caption?: React.ReactNode;
|
|
20
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
12
21
|
error?: React.ReactNode;
|
|
13
22
|
disabled?: boolean;
|
|
14
23
|
/** This is used for setting the data-testid */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { SelectOption } from '../SelectField/types';
|
|
2
|
+
/** A `SelectOption` (`{ value, label, isDisabled? }`) that can also be removable. */
|
|
2
3
|
export type PillSelectOption<T> = SelectOption<T> & {
|
|
4
|
+
/** When `true` the pill shows a remove button that calls `onRemoveOption`. */
|
|
3
5
|
isRemovable?: boolean;
|
|
4
6
|
};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
|
+
/** Value reported by the parent `RadioGroupField` when this option is selected. */
|
|
3
4
|
value: string | number;
|
|
5
|
+
/** DOM id of the radio input. One is generated from the group `name` when not provided. */
|
|
4
6
|
id?: string;
|
|
7
|
+
/** Text shown inside the box, below the `children` content. */
|
|
5
8
|
label?: React.ReactNode;
|
|
9
|
+
/** Helper text shown inside the box, below the label. */
|
|
6
10
|
caption?: React.ReactNode;
|
|
11
|
+
/** Content shown at the top of the box, above the label, such as an icon or illustration. */
|
|
7
12
|
children?: React.ReactNode;
|
|
8
13
|
testId?: string;
|
|
14
|
+
/** Disables this option. The whole group can be disabled with the `RadioGroupField` `disabled` prop. */
|
|
9
15
|
disabled?: boolean;
|
|
10
16
|
};
|
|
17
|
+
/** A radio option shown as a selectable box, used as a child of `RadioGroupField`. Use it instead of `RadioGroupOption` when each option needs more room, such as an icon or illustration (`children`) above a `label` and `caption`. Its `value` is what the group reports in `onChange` when the option is selected. */
|
|
11
18
|
declare const RadioGroupBoxOption: ({ value, id: inputId, label, caption, testId, children, disabled }: Props) => React.JSX.Element;
|
|
12
19
|
export default RadioGroupBoxOption;
|
|
@@ -2,12 +2,18 @@ import React from 'react';
|
|
|
2
2
|
import RadioGroupOption from '../RadioGroupOption';
|
|
3
3
|
import RadioGroupBoxOption from '../RadioGroupBoxOption';
|
|
4
4
|
import { Space } from '../../layout/Flex/types';
|
|
5
|
+
type RadioGroupChild = React.ReactElement<typeof RadioGroupOption> | React.ReactElement<typeof RadioGroupBoxOption> | null | undefined | boolean;
|
|
6
|
+
type RadioGroupChildren = RadioGroupChild | RadioGroupChild[];
|
|
5
7
|
type Props = {
|
|
8
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass is called in addition to the Formik update. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
6
9
|
name: string;
|
|
7
10
|
value?: string | number;
|
|
8
11
|
onChange?: (e: string | number) => void;
|
|
12
|
+
/** Label shown above the group of options. */
|
|
9
13
|
label?: React.ReactNode;
|
|
14
|
+
/** Helper text shown below the options. */
|
|
10
15
|
caption?: React.ReactNode;
|
|
16
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
11
17
|
error?: React.ReactNode;
|
|
12
18
|
space?: Space;
|
|
13
19
|
/**
|
|
@@ -17,7 +23,8 @@ type Props = {
|
|
|
17
23
|
*/
|
|
18
24
|
inline?: boolean;
|
|
19
25
|
disabled?: boolean;
|
|
20
|
-
|
|
26
|
+
/** The options: either `RadioGroupOption` or `RadioGroupBoxOption` elements. Don't mix both kinds. `null`, `undefined` and booleans are skipped, so options can be rendered conditionally (e.g. `{cond && <RadioGroupOption />}`). */
|
|
27
|
+
children: RadioGroupChildren | RadioGroupChildren[];
|
|
21
28
|
/** This is used for setting the data-testid */
|
|
22
29
|
testId?: string;
|
|
23
30
|
/** It states the radio options will be inline and defines how many columns it will have */
|
|
@@ -3,7 +3,8 @@ export type RadioGroupFieldContextType = {
|
|
|
3
3
|
name: string;
|
|
4
4
|
value?: string | number;
|
|
5
5
|
disabled: boolean;
|
|
6
|
-
|
|
6
|
+
/** Receives the selected option's original `value` prop (not the stringified DOM value) */
|
|
7
|
+
onChange: (value: string | number) => void;
|
|
7
8
|
};
|
|
8
9
|
declare const RadioGroupFieldContext: React.Context<RadioGroupFieldContextType | null>;
|
|
9
10
|
export declare const useRadioGroupFieldContext: () => RadioGroupFieldContextType;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
|
+
/** Value reported by the parent `RadioGroupField` when this option is selected. */
|
|
3
4
|
value: string | number;
|
|
5
|
+
/** If not provided it will generate a random id so the label links properly with the radio input */
|
|
4
6
|
id?: string;
|
|
7
|
+
/** Text shown next to the radio button. Clicking it also selects the option. */
|
|
5
8
|
label?: React.ReactNode;
|
|
9
|
+
/** Helper text shown below the option label. */
|
|
6
10
|
caption?: React.ReactNode;
|
|
7
11
|
testId?: string;
|
|
12
|
+
/** Disables this option. The whole group can be disabled with the `RadioGroupField` `disabled` prop. */
|
|
8
13
|
disabled?: boolean;
|
|
9
14
|
};
|
|
10
|
-
/** RadioGroupField
|
|
15
|
+
/** A single radio button option, used as a child of `RadioGroupField`. Its `value` is what the group reports in `onChange` when the option is selected. */
|
|
11
16
|
declare const RadioGroupOption: React.FC<Props>;
|
|
12
17
|
export default RadioGroupOption;
|
|
@@ -9,35 +9,52 @@ export type Props<T> = {
|
|
|
9
9
|
* @deprecated `asToolbarFilter` prop has been replaced with the `ToolbarSelect` component.
|
|
10
10
|
*/
|
|
11
11
|
asToolbarFilter?: boolean;
|
|
12
|
+
/** Helper text shown below the field. */
|
|
12
13
|
caption?: React.ReactNode;
|
|
13
14
|
disabled?: boolean;
|
|
15
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
14
16
|
error?: React.ReactNode;
|
|
15
|
-
/** If not provided it will generate a random id so the
|
|
17
|
+
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
16
18
|
id?: string;
|
|
17
19
|
isClearable?: boolean;
|
|
20
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
18
21
|
label?: React.ReactNode;
|
|
19
22
|
/** When the user opens the menu, if this prop is `true`, it will scroll the page into to the menu view (if its content falls under a scroll). It is recommended to disable this behaviour when using the `SelectField` inside a modal. */
|
|
20
23
|
menuShouldScrollIntoView?: boolean;
|
|
24
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass is called in addition to the Formik update. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
21
25
|
name: string;
|
|
22
26
|
noOptionsMessage?: string | NoOptionsMessageFunction;
|
|
27
|
+
/** Called with the selected `SelectOption` object (not only its `value`). When `isClearable` is set and the user clears the field, it is called with `null`. */
|
|
23
28
|
onChange?: (e: SelectOption<T>) => void;
|
|
24
29
|
onBlur?: (e: SelectOption<T>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Options to choose from. Either a flat list of `SelectOption` objects, `{ value: T, label: string, isDisabled?: boolean }`, or a list of `GroupOption` objects, `{ label: string, options: SelectOption[] }`, to show the options under group headings.
|
|
32
|
+
*/
|
|
25
33
|
options: SelectOptions<T>;
|
|
26
34
|
placeholder?: React.ReactNode;
|
|
27
35
|
/** Use a prefix for things like currency symbols (“$”, “¥”, “£”) or icons. */
|
|
28
36
|
prefix?: React.ReactNode;
|
|
29
37
|
/** Use a suffix for things like (“%”, “Jr.”, “.00”) or icons. */
|
|
30
38
|
suffix?: React.ReactNode;
|
|
31
|
-
value
|
|
39
|
+
/** The selected option, as a full `SelectOption` object (`{ value, label }`), not only its `value`. Pass `null` to clear the selection, including when the field is bound to Formik. */
|
|
40
|
+
value?: SelectOption<T> | null;
|
|
41
|
+
/** The initially selected option for an uncontrolled field, as a full `SelectOption` object. */
|
|
32
42
|
defaultValue?: SelectOption<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Component used to render each option in the menu. It receives the react-select option props (`CustomOptionProps`): `label`, `data` (the full `SelectOption`), `isSelected`, `isFocused` and `isDisabled`.
|
|
45
|
+
*/
|
|
33
46
|
CustomOption?: React.ElementType;
|
|
47
|
+
/**
|
|
48
|
+
* Component rendered before the selected value inside the field, e.g. an avatar or icon. It is only rendered when an option is selected and receives `selectedOption` (the selected `SelectOption`) plus the react-select control props (`SelectedOptionPrefixProps`).
|
|
49
|
+
*/
|
|
34
50
|
SelectedOptionPrefix?: React.ElementType;
|
|
35
51
|
/** This is used for setting the data-testid */
|
|
36
52
|
testId?: string;
|
|
53
|
+
/** A string label, or a `Button` element, shown in the menu to let the user create a new option. Use it together with `onCreate`. */
|
|
37
54
|
creatableButton?: React.ReactNode;
|
|
38
55
|
/** Callback when creating a new option. For grouped options, the groupLabel parameter will be provided. For non-grouped options, groupLabel will be undefined. */
|
|
39
56
|
onCreate?: (option: string, groupLabel?: string) => void;
|
|
40
|
-
/** This
|
|
57
|
+
/** This allows disabling the search functionality. Use it only in some edge cases, for example on touch devices, where clicking the field opens a virtual keyboard to search; sometimes that virtual keyboard takes up too much space, and passing `isSearchable={false}` prevents opening it. */
|
|
41
58
|
isSearchable?: boolean;
|
|
42
59
|
autoFocus?: boolean;
|
|
43
60
|
} & DataProps;
|
|
@@ -1,23 +1,50 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ControlProps } from 'react-select';
|
|
3
|
+
/**
|
|
4
|
+
* A titled group of options, shown under a group heading in the menu.
|
|
5
|
+
* Example: `{ label: 'Managers', options: [{ value: 1, label: 'Alex' }] }`
|
|
6
|
+
*/
|
|
3
7
|
export type GroupOption<T> = {
|
|
8
|
+
/** Group heading shown in the menu. */
|
|
4
9
|
label: string;
|
|
10
|
+
/** Options inside the group. */
|
|
5
11
|
options: SelectOption<T>[];
|
|
6
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* A single option. Example: `{ value: 'en', label: 'English' }`
|
|
15
|
+
*/
|
|
7
16
|
export type SelectOption<T> = {
|
|
17
|
+
/** When `true` the option is shown but cannot be selected. */
|
|
8
18
|
isDisabled?: boolean;
|
|
19
|
+
/** Value of the option. It can be any value: object, number, string... `onChange` receives the whole `SelectOption`, so read it from `option.value`. */
|
|
9
20
|
value: T;
|
|
21
|
+
/** Text shown for the option. */
|
|
10
22
|
label: string;
|
|
11
23
|
};
|
|
24
|
+
/** A flat list of `SelectOption`s, a list of `GroupOption`s, or a mix of both. */
|
|
12
25
|
export type SelectOptions<T> = Array<SelectOption<T> | GroupOption<T>>;
|
|
26
|
+
/**
|
|
27
|
+
* Props received by the component passed to `CustomOption`. It receives the react-select option props, the most useful being listed here.
|
|
28
|
+
*/
|
|
13
29
|
export type CustomOptionProps<T> = {
|
|
30
|
+
/** Not passed by react-select. Read `data.value` instead. */
|
|
14
31
|
value: T;
|
|
32
|
+
/** Label of the option. */
|
|
15
33
|
label: string;
|
|
34
|
+
/** The full option object (`SelectOption`), including its `value`. */
|
|
35
|
+
data: SelectOption<T>;
|
|
36
|
+
/** Whether the option is the selected one. */
|
|
16
37
|
isSelected: boolean;
|
|
38
|
+
/** Whether the option is disabled. */
|
|
17
39
|
isDisabled: boolean;
|
|
40
|
+
/** Whether the option is focused by mouse hover or keyboard navigation. */
|
|
18
41
|
isFocused: boolean;
|
|
19
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Props received by the component passed to `SelectedOptionPrefix`: the react-select control props plus `selectedOption`.
|
|
45
|
+
*/
|
|
20
46
|
export interface SelectedOptionPrefixProps<T> extends ControlProps<T, false> {
|
|
47
|
+
/** The currently selected option. The prefix is only rendered when there is one. */
|
|
21
48
|
selectedOption: SelectOption<T>;
|
|
22
49
|
}
|
|
23
50
|
export type CustomComponentsExtraProps = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { KeyboardEvent } from 'react';
|
|
2
2
|
type Props = {
|
|
3
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass replaces the Formik update, so call `formik.setFieldValue` yourself if you still need it. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
3
4
|
name: string;
|
|
4
5
|
/** If not provided it will generate a random id so the label links properly with the text input. */
|
|
5
6
|
id?: string;
|
|
@@ -7,8 +8,11 @@ type Props = {
|
|
|
7
8
|
onChange?: (e: string) => void;
|
|
8
9
|
onBlur?: (e: string) => void;
|
|
9
10
|
onKeyPress?: (e: KeyboardEvent) => void;
|
|
11
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
10
12
|
label?: React.ReactNode;
|
|
13
|
+
/** Helper text shown below the field. */
|
|
11
14
|
caption?: React.ReactNode;
|
|
15
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
12
16
|
error?: React.ReactNode;
|
|
13
17
|
placeholder?: string;
|
|
14
18
|
disabled?: boolean;
|
|
@@ -24,6 +28,8 @@ type Props = {
|
|
|
24
28
|
testId?: string;
|
|
25
29
|
maxLength?: number;
|
|
26
30
|
};
|
|
27
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* A multi-line text input used to get longer text from the user, such as notes or messages. It can grow with its content (`autoGrow`), show a character count (`maxLength`) and host a `toolbar` of actions below the text.
|
|
33
|
+
*/
|
|
28
34
|
declare const TextAreaField: React.FC<Props>;
|
|
29
35
|
export default TextAreaField;
|
|
@@ -4,14 +4,18 @@ type AutoCompleteType = 'off' | 'on';
|
|
|
4
4
|
export type Props = {
|
|
5
5
|
autoComplete?: AutoCompleteType;
|
|
6
6
|
autoFocus?: boolean;
|
|
7
|
+
/** Helper text shown below the field. */
|
|
7
8
|
caption?: React.ReactNode;
|
|
8
9
|
defaultValue?: string;
|
|
9
10
|
disabled?: boolean;
|
|
11
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
10
12
|
error?: React.ReactNode;
|
|
11
13
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
12
14
|
id?: string;
|
|
15
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
13
16
|
label?: React.ReactNode;
|
|
14
17
|
maxLength?: number;
|
|
18
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass replaces the Formik update, so call `formik.setFieldValue` yourself if you still need it. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
15
19
|
name: string;
|
|
16
20
|
onBlur?: (value: string) => void;
|
|
17
21
|
onChange?: (value: string) => void;
|
|
@@ -31,14 +35,18 @@ export type Props = {
|
|
|
31
35
|
declare const TextField: React.ForwardRefExoticComponent<{
|
|
32
36
|
autoComplete?: AutoCompleteType | undefined;
|
|
33
37
|
autoFocus?: boolean | undefined;
|
|
38
|
+
/** Helper text shown below the field. */
|
|
34
39
|
caption?: React.ReactNode;
|
|
35
40
|
defaultValue?: string | undefined;
|
|
36
41
|
disabled?: boolean | undefined;
|
|
42
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
37
43
|
error?: React.ReactNode;
|
|
38
44
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
39
45
|
id?: string | undefined;
|
|
46
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
40
47
|
label?: React.ReactNode;
|
|
41
48
|
maxLength?: number | undefined;
|
|
49
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass replaces the Formik update, so call `formik.setFieldValue` yourself if you still need it. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
42
50
|
name: string;
|
|
43
51
|
onBlur?: ((value: string) => void) | undefined;
|
|
44
52
|
onChange?: ((value: string) => void) | undefined;
|
|
@@ -4,13 +4,23 @@ import { StartTime, TimeInterval, TimeRange } from '../../utils/date';
|
|
|
4
4
|
import { TimeFormat } from './types';
|
|
5
5
|
type Props = TextFieldProps & {
|
|
6
6
|
onClick?: () => void;
|
|
7
|
+
/** Minutes between the preset options in the dropdown: `15` or `30`. */
|
|
7
8
|
interval?: TimeInterval;
|
|
9
|
+
/** Time the dropdown options start from: `'now'` or a time string such as `'9:00am'`. Defaults to midnight. */
|
|
8
10
|
startTime?: StartTime;
|
|
9
11
|
prefix?: React.ReactElement;
|
|
12
|
+
/** When `true` (together with `startTime`), the field acts as the end of a range: each option shows its duration from `startTime`. */
|
|
10
13
|
endField?: boolean;
|
|
14
|
+
/** Text shown as a suffix inside the field, e.g. the duration of a shift. */
|
|
11
15
|
duration?: string;
|
|
16
|
+
/** Minutes subtracted from the durations shown in the options, e.g. for unpaid breaks. Only used by the default duration calculation; ignored when `calculateDuration` is set. */
|
|
12
17
|
subtractDuration?: number;
|
|
18
|
+
/** Custom function to compute the duration label of each option, replacing the default calculation. It receives a `TimeRange` where `start` is the `startTime` prop as given (including the literal `'now'`) and `end` is the option time string. */
|
|
13
19
|
calculateDuration?: (e: TimeRange) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether times are shown as `'ampm'` (e.g. `9:00 AM`) or `'24h'` (e.g. `09:00`). Defaults to the `timeFormat` set on `SousChefProvider`, which defaults to `'ampm'`.
|
|
22
|
+
* @default SousChefProvider timeFormat ("ampm")
|
|
23
|
+
*/
|
|
14
24
|
timeFormat?: TimeFormat;
|
|
15
25
|
};
|
|
16
26
|
export declare const TimeRangeSelector: React.ForwardRefExoticComponent<{
|
|
@@ -35,19 +45,31 @@ export declare const TimeRangeSelector: React.ForwardRefExoticComponent<{
|
|
|
35
45
|
testId?: string | undefined;
|
|
36
46
|
} & import("../../foundation/types").DataProps & {
|
|
37
47
|
onClick?: (() => void) | undefined;
|
|
48
|
+
/** Minutes between the preset options in the dropdown: `15` or `30`. */
|
|
38
49
|
interval?: TimeInterval | undefined;
|
|
50
|
+
/** Time the dropdown options start from: `'now'` or a time string such as `'9:00am'`. Defaults to midnight. */
|
|
39
51
|
startTime?: string | undefined;
|
|
40
52
|
prefix?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
53
|
+
/** When `true` (together with `startTime`), the field acts as the end of a range: each option shows its duration from `startTime`. */
|
|
41
54
|
endField?: boolean | undefined;
|
|
55
|
+
/** Text shown as a suffix inside the field, e.g. the duration of a shift. */
|
|
42
56
|
duration?: string | undefined;
|
|
57
|
+
/** Minutes subtracted from the durations shown in the options, e.g. for unpaid breaks. Only used by the default duration calculation; ignored when `calculateDuration` is set. */
|
|
43
58
|
subtractDuration?: number | undefined;
|
|
59
|
+
/** Custom function to compute the duration label of each option, replacing the default calculation. It receives a `TimeRange` where `start` is the `startTime` prop as given (including the literal `'now'`) and `end` is the option time string. */
|
|
44
60
|
calculateDuration?: ((e: TimeRange) => string) | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Whether times are shown as `'ampm'` (e.g. `9:00 AM`) or `'24h'` (e.g. `09:00`). Defaults to the `timeFormat` set on `SousChefProvider`, which defaults to `'ampm'`.
|
|
63
|
+
* @default SousChefProvider timeFormat ("ampm")
|
|
64
|
+
*/
|
|
45
65
|
timeFormat?: TimeFormat | undefined;
|
|
46
66
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
47
67
|
/**
|
|
48
|
-
* A special field
|
|
68
|
+
* A special field designed for selecting a specific time of the day. Users can choose from a dropdown of preset time intervals, or type directly into the field. When the user leaves the field, the input is automatically formatted into either AM/PM time or 24h time.
|
|
49
69
|
*
|
|
50
70
|
* **You are in charge of validating the value and parsing it back to a value that you can use on your application**.
|
|
71
|
+
*
|
|
72
|
+
* To show durations, set `startTime` and `endField` so each option shows its duration from `startTime`, or pass the text to `duration`. To pick a start and end time with `subtractDuration` (e.g. for unpaid breaks) or a custom `calculateDuration`, use `TimeRangeField`.
|
|
51
73
|
*/
|
|
52
74
|
declare const TimeField: React.ForwardRefExoticComponent<Omit<Props, "prefix" | "subtractDuration" | "calculateDuration" | "suffix"> & React.RefAttributes<HTMLInputElement>>;
|
|
53
75
|
export default TimeField;
|
|
@@ -2,25 +2,38 @@ import React from 'react';
|
|
|
2
2
|
import { StartTime, TimeInterval, TimeRange } from '../../utils/date';
|
|
3
3
|
import { TimeFormat } from '../TimeField/types';
|
|
4
4
|
type Props = {
|
|
5
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass replaces the Formik update, so call `formik.setFieldValue` yourself if you still need it. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
5
6
|
name: string;
|
|
6
7
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
7
8
|
id?: string;
|
|
9
|
+
/** The selected range: `{ start?: string, end?: string }`, with times as strings such as `'9:00am'` or `'17:00'`. */
|
|
8
10
|
value?: TimeRange;
|
|
11
|
+
/** Minutes between the preset options in the dropdowns: `15` or `30`. */
|
|
9
12
|
interval?: TimeInterval;
|
|
13
|
+
/** Time the start dropdown options begin from: `'now'` or a time string such as `'9:00am'`. Defaults to midnight. */
|
|
10
14
|
startTime?: StartTime;
|
|
15
|
+
/** Called with the new `TimeRange` (`{ start?: string, end?: string }`) whenever either time changes. */
|
|
11
16
|
onChange?: (e: TimeRange) => void;
|
|
12
17
|
onBlur?: () => void;
|
|
18
|
+
/** Label shown above the start and end time inputs. */
|
|
13
19
|
label?: React.ReactNode;
|
|
20
|
+
/** Helper text shown below the field. */
|
|
14
21
|
caption?: React.ReactNode;
|
|
22
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
15
23
|
error?: React.ReactNode;
|
|
16
24
|
placeholder?: string;
|
|
17
25
|
disabled?: boolean;
|
|
18
26
|
testId?: string;
|
|
19
|
-
/**
|
|
27
|
+
/** Minutes subtracted from the durations shown, e.g. for unpaid breaks. Only used by the default duration calculation; ignored when `calculateDuration` is set. */
|
|
20
28
|
subtractDuration?: number;
|
|
29
|
+
/** Custom function to compute the duration shown in the end time input and next to each end time option. It receives a `TimeRange` (`{ start?: string, end?: string }`); either value is `undefined` until that time is selected, so handle incomplete ranges. */
|
|
21
30
|
calculateDuration?: (e: TimeRange) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether times are shown as `'ampm'` (e.g. `9:00 AM`) or `'24h'` (e.g. `09:00`). Defaults to the `timeFormat` set on `SousChefProvider`, which defaults to `'ampm'`.
|
|
33
|
+
* @default SousChefProvider timeFormat ("ampm")
|
|
34
|
+
*/
|
|
22
35
|
timeFormat?: TimeFormat;
|
|
23
36
|
};
|
|
24
|
-
/** A special input field for selecting a time range. Comprised of 2 individual time fields, the user selects a start time and an end time individually to. */
|
|
37
|
+
/** A special input field for selecting a time range. Comprised of 2 individual time fields, the user selects a start time and an end time individually to create a time range. The end time field shows the total duration, and each end time option shows its duration from the start time. */
|
|
25
38
|
declare const TimeRangeField: ({ name, id: inputId, value, interval, startTime, onChange, onBlur, label, caption, error, placeholder, disabled, testId, subtractDuration, calculateDuration, timeFormat }: Props) => React.JSX.Element;
|
|
26
39
|
export default TimeRangeField;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { WeekStart } from '../../utils/date';
|
|
3
3
|
import { HighlightGroup } from '../../utils/highlight';
|
|
4
4
|
type Props = {
|
|
5
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass replaces the Formik update, so call `formik.setFieldValue` yourself if you still need it. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
5
6
|
name: string;
|
|
6
7
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
7
8
|
id?: string;
|
|
@@ -16,8 +17,11 @@ type Props = {
|
|
|
16
17
|
initialMonth?: Date;
|
|
17
18
|
onChange?: (e: Date) => void;
|
|
18
19
|
onBlur?: () => void;
|
|
20
|
+
/** Label shown above the field. It is linked to the input, so clicking it focuses the field. */
|
|
19
21
|
label?: React.ReactNode;
|
|
22
|
+
/** Helper text shown below the field. */
|
|
20
23
|
caption?: React.ReactNode;
|
|
24
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
21
25
|
error?: React.ReactNode;
|
|
22
26
|
placeholder?: string;
|
|
23
27
|
disabled?: boolean;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
|
+
/** Field name. Inside a Sous Chef `Form` it binds the field to Formik: the field reads its value and error from the Formik key with this name and writes changes back to it. A `value` you pass overrides the Formik value; an `onChange` you pass is called in addition to the Formik update. Nested paths such as `address.city` or `shifts[0].start` work. Also used to generate the `id` when none is given. */
|
|
3
4
|
name: string;
|
|
4
5
|
id?: string;
|
|
5
6
|
/** The dates to display as pills, in chronological order. Typically 7 days representing a week. */
|
|
6
7
|
days: Date[];
|
|
7
8
|
value?: Date[];
|
|
8
9
|
onChange?: (selected: Date[]) => void;
|
|
10
|
+
/** Label shown above the day pills. */
|
|
9
11
|
label?: React.ReactNode;
|
|
12
|
+
/** Helper text shown below the field. */
|
|
10
13
|
caption?: React.ReactNode;
|
|
14
|
+
/** Error message shown below the field. Inside a Sous Chef `Form`, the Formik error for this field's `name` is shown automatically once the field has been touched; passing `error` overrides it. */
|
|
11
15
|
error?: React.ReactNode;
|
|
12
16
|
disabled?: boolean;
|
|
13
17
|
displayFormat?: 'weekday' | 'month';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
type RadioValue = string | number;
|
|
3
2
|
type FieldControls = {
|
|
4
3
|
error?: React.ReactNode;
|
|
5
4
|
value?: RadioValue;
|
|
6
|
-
onChange?: (
|
|
5
|
+
onChange?: (value: RadioValue) => void;
|
|
7
6
|
};
|
|
8
7
|
type Props = {
|
|
9
8
|
name: string;
|
|
@@ -2,14 +2,14 @@ import type { SelectOption } from '../SelectField/types';
|
|
|
2
2
|
type FieldControls<T> = {
|
|
3
3
|
id: string;
|
|
4
4
|
error?: React.ReactNode;
|
|
5
|
-
value?: SelectOption<T
|
|
5
|
+
value?: SelectOption<T> | null;
|
|
6
6
|
onChange: (e: SelectOption<T>) => void;
|
|
7
7
|
onBlur: (e: SelectOption<T>) => void;
|
|
8
8
|
};
|
|
9
9
|
type Props<T> = {
|
|
10
10
|
name: string;
|
|
11
11
|
id?: string;
|
|
12
|
-
value?: SelectOption<T
|
|
12
|
+
value?: SelectOption<T> | null;
|
|
13
13
|
onChange?: (e: SelectOption<T>) => void;
|
|
14
14
|
onBlur?: (e: SelectOption<T>) => void;
|
|
15
15
|
error?: React.ReactNode;
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -29,7 +29,9 @@ export { Form, FormRow, TextAreaField, TextField, CheckboxField, PillSelectField
|
|
|
29
29
|
export type { PasswordCriteria } from './PasswordField/types';
|
|
30
30
|
export type { SelectOption, SelectOptions, GroupOption, CustomOptionProps, SelectedOptionPrefixProps } from './SelectField/types';
|
|
31
31
|
export type { PillSelectOption } from './PillSelectField/types';
|
|
32
|
+
export type { FormFooterActions } from './FormFooter/types';
|
|
32
33
|
export type { AsyncSelectOptions } from './AsyncSelectField/types';
|
|
34
|
+
export type { DateRange, TimeRange } from '../utils/date';
|
|
33
35
|
export type { FormikType } from './Form/types';
|
|
34
36
|
export type { PhoneFieldCountryCode } from './PhoneField/types';
|
|
35
37
|
export type { HighlightGroup, HighlightShape, HighlightTheme } from '../utils/highlight';
|