@kaizen/components 1.52.1 → 1.53.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.
Files changed (218) hide show
  1. package/dist/cjs/DatePicker/DatePicker.cjs +8 -1
  2. package/dist/cjs/DatePicker/utils/getLocale.cjs +2 -0
  3. package/dist/cjs/DatePicker/utils/validateDate.cjs +28 -2
  4. package/dist/cjs/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.cjs +8 -1
  5. package/dist/cjs/Filter/FilterBar/subcomponents/ClearAllButton/ClearAllButton.cjs +14 -2
  6. package/dist/cjs/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.cjs +1 -0
  7. package/dist/cjs/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.cjs +10 -1
  8. package/dist/cjs/Filter/FilterDatePicker/subcomponents/DateInputField/DateInputField.cjs +8 -1
  9. package/dist/cjs/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.cjs +5 -1
  10. package/dist/cjs/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useEndDateValidation.cjs +1 -0
  11. package/dist/cjs/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useStartDateValidation.cjs +1 -0
  12. package/dist/cjs/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/validateEndDateBeforeStartDate.cjs +16 -1
  13. package/dist/esm/DatePicker/DatePicker.mjs +8 -1
  14. package/dist/esm/DatePicker/utils/getLocale.mjs +3 -1
  15. package/dist/esm/DatePicker/utils/validateDate.mjs +22 -2
  16. package/dist/esm/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.mjs +8 -1
  17. package/dist/esm/Filter/FilterBar/subcomponents/ClearAllButton/ClearAllButton.mjs +14 -2
  18. package/dist/esm/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.mjs +1 -0
  19. package/dist/esm/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.mjs +10 -1
  20. package/dist/esm/Filter/FilterDatePicker/subcomponents/DateInputField/DateInputField.mjs +8 -1
  21. package/dist/esm/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.mjs +5 -1
  22. package/dist/esm/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useEndDateValidation.mjs +1 -0
  23. package/dist/esm/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useStartDateValidation.mjs +1 -0
  24. package/dist/esm/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/validateEndDateBeforeStartDate.mjs +10 -1
  25. package/dist/styles.css +2 -2
  26. package/dist/types/AvatarGroup/_docs/example-data.d.ts +8 -0
  27. package/dist/types/BrandMoment/_docs/ExampleHeaders.d.ts +3 -0
  28. package/dist/types/Calendar/_docs/controls/defaultMonthControls.d.ts +2 -0
  29. package/dist/types/Calendar/_docs/controls/weekStartsOnControls.d.ts +2 -0
  30. package/dist/types/Container/Container.d.ts +1 -1
  31. package/dist/types/Content/Content.d.ts +1 -1
  32. package/dist/types/DateInput/DateInput/DateInput.d.ts +1 -1
  33. package/dist/types/DatePicker/DatePicker.d.ts +1 -1
  34. package/dist/types/DatePicker/_docs/controls/datePickerLocaleControls.d.ts +2 -0
  35. package/dist/types/DatePicker/_docs/controls/disabledDayMatchersControls.d.ts +2 -0
  36. package/dist/types/DatePicker/subcomponents/DateInputField/DateInputField.d.ts +1 -1
  37. package/dist/types/DatePicker/types.d.ts +2 -1
  38. package/dist/types/DatePicker/utils/getLocale.d.ts +1 -1
  39. package/dist/types/Filter/FilterBar/context/types.d.ts +28 -0
  40. package/dist/types/Filter/FilterButton/subcomponents/FilterButtonBase/FilterButtonBase.d.ts +1 -1
  41. package/dist/types/Filter/FilterDatePicker/_docs/controls/disabledDaysControls.d.ts +2 -0
  42. package/dist/types/Filter/FilterDatePicker/_docs/controls/validationControls.d.ts +2 -0
  43. package/dist/types/Filter/FilterDatePicker/subcomponents/DateInputField/DateInputField.d.ts +1 -1
  44. package/dist/types/Filter/FilterDateRangePicker/_docs/controls/disabledDaysControls.d.ts +2 -0
  45. package/dist/types/Filter/FilterDateRangePicker/_docs/controls/validationControls.d.ts +2 -0
  46. package/dist/types/Filter/FilterMultiSelect/_docs/MockData.d.ts +10 -0
  47. package/dist/types/Filter/FilterSelect/_docs/mockData.d.ts +6 -0
  48. package/dist/types/Filter/_docs/controls/renderTriggerControls.d.ts +2 -0
  49. package/dist/types/Menu/_docs/MenuContentExample.d.ts +8 -0
  50. package/dist/types/Menu/_docs/examples.d.ts +11 -0
  51. package/dist/types/Modal/_docs/controls.d.ts +11 -0
  52. package/dist/types/MultiSelect/MultiSelect.d.ts +23 -0
  53. package/dist/types/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.d.ts +13 -0
  54. package/dist/types/Select/Select.d.ts +3 -3
  55. package/dist/types/Workflow/_docs/controls/controls.d.ts +2 -0
  56. package/dist/types/Workflow/_docs/controls/index.d.ts +1 -0
  57. package/dist/types/__future__/Select/Select.d.ts +2 -2
  58. package/dist/types/__future__/Select/_docs/mockData.d.ts +6 -0
  59. package/dist/types/__future__/Select/subcomponents/SelectToggle/SelectToggle.d.ts +2 -2
  60. package/dist/types/__future__/Select/types.d.ts +22 -0
  61. package/dist/types/__future__/Workflow/_docs/controls/controls.d.ts +2 -0
  62. package/dist/types/__future__/Workflow/_docs/controls/index.d.ts +1 -0
  63. package/dist/types/__overlays__/Tooltip/v1/utils/isSemanticElement.d.ts +2 -2
  64. package/dist/types/utils/getNodeText.d.ts +2 -1
  65. package/locales/en.json +40 -0
  66. package/package.json +1 -1
  67. package/src/Avatar/_docs/Avatar.mdx +1 -1
  68. package/src/AvatarGroup/_docs/AvatarGroup.mdx +1 -1
  69. package/src/Badge/_docs/Badge.mdx +1 -1
  70. package/src/Brand/_docs/Brand.mdx +1 -1
  71. package/src/BrandMoment/_docs/BrandMoment.mdx +1 -1
  72. package/src/Button/Button/_docs/Button.mdx +1 -1
  73. package/src/Button/IconButton/_docs/IconButton.mdx +1 -1
  74. package/src/ButtonGroup/_docs/ButtonGroup.mdx +1 -1
  75. package/src/Calendar/CalendarRange/_docs/CalendarRange.mdx +1 -1
  76. package/src/Calendar/CalendarSingle/_docs/CalendarSingle.mdx +1 -1
  77. package/src/Card/_docs/Card.mdx +1 -1
  78. package/src/Checkbox/Checkbox/_docs/Checkbox.mdx +1 -1
  79. package/src/Checkbox/CheckboxField/_docs/CheckboxField.mdx +1 -1
  80. package/src/Checkbox/CheckboxGroup/_docs/CheckboxGroup.mdx +1 -1
  81. package/src/Collapsible/Collapsible/_docs/Collapsible.mdx +1 -1
  82. package/src/Collapsible/CollapsibleGroup/_docs/CollapsibleGroup.mdx +1 -1
  83. package/src/Collapsible/ExpertAdviceCollapsible/_docs/ExpertAdviceCollapsible.mdx +1 -1
  84. package/src/Container/_docs/Container.mdx +1 -1
  85. package/src/Content/_docs/Content.mdx +1 -1
  86. package/src/DateInput/DateInputDescription/DateInputDescription.spec.tsx +26 -18
  87. package/src/DatePicker/DatePicker.spec.tsx +100 -69
  88. package/src/DatePicker/DatePicker.tsx +13 -5
  89. package/src/DatePicker/_docs/DatePicker.mdx +1 -1
  90. package/src/DatePicker/_docs/DatePicker.stickersheet.stories.tsx +57 -21
  91. package/src/DatePicker/_docs/DatePicker.stories.tsx +2 -3
  92. package/src/DatePicker/_docs/controls/datePickerLocaleControls.ts +1 -1
  93. package/src/DatePicker/subcomponents/DateInputField/DateInputField.spec.tsx +49 -36
  94. package/src/DatePicker/types.ts +2 -1
  95. package/src/DatePicker/utils/getLocale.ts +6 -2
  96. package/src/DatePicker/utils/validateDate.spec.ts +40 -16
  97. package/src/DatePicker/utils/{validateDate.ts → validateDate.tsx} +24 -4
  98. package/src/DateRangePicker/_docs/DateRangePicker.mdx +1 -1
  99. package/src/Divider/_docs/Divider.mdx +1 -1
  100. package/src/EmptyState/_docs/EmptyState.mdx +1 -1
  101. package/src/ErrorPage/_docs/ErrorPage.mdx +1 -1
  102. package/src/FieldGroup/_docs/FieldGroup.mdx +1 -1
  103. package/src/FieldMessage/_docs/FieldMessage.mdx +1 -1
  104. package/src/Filter/Filter/_docs/Filter.mdx +1 -1
  105. package/src/Filter/FilterBar/FilterBar.spec.tsx +56 -25
  106. package/src/Filter/FilterBar/_docs/FilterBar.mdx +1 -1
  107. package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.spec.tsx +21 -13
  108. package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.tsx +11 -1
  109. package/src/Filter/FilterBar/subcomponents/ClearAllButton/ClearAllButton.tsx +17 -2
  110. package/src/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.spec.tsx +17 -8
  111. package/src/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.spec.tsx +37 -23
  112. package/src/Filter/FilterBar/subcomponents/FilterBarDateRangePicker/FilterBarDateRangePicker.spec.tsx +35 -23
  113. package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.spec.tsx +42 -26
  114. package/src/Filter/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.spec.tsx +37 -24
  115. package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.spec.tsx +12 -12
  116. package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.tsx +15 -2
  117. package/src/Filter/FilterButton/_docs/filter-buttons.mdx +1 -1
  118. package/src/Filter/FilterDatePicker/FilterDatePicker.spec.tsx +21 -16
  119. package/src/Filter/FilterDatePicker/_docs/FilterDatePicker.mdx +1 -1
  120. package/src/Filter/FilterDatePicker/_docs/FilterDatePicker.stickersheet.stories.tsx +50 -1
  121. package/src/Filter/FilterDatePicker/hooks/useDateInputHandlers.spec.ts +3 -3
  122. package/src/Filter/FilterDatePicker/hooks/{useDateValidation.spec.tsx → useDateValidation.spec.ts} +13 -12
  123. package/src/Filter/FilterDatePicker/subcomponents/DateInputField/DateInputField.tsx +10 -1
  124. package/src/Filter/FilterDatePicker/subcomponents/FilterDatePickerField/FilterDatePickerField.spec.tsx +57 -36
  125. package/src/Filter/FilterDatePicker/utils/validateDate.spec.ts +52 -28
  126. package/src/Filter/FilterDateRangePicker/FilterDateRangePicker.spec.tsx +3 -2
  127. package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.mdx +1 -1
  128. package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.stickersheet.stories.tsx +55 -24
  129. package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeInputField/DateRangeInputField.spec.tsx +43 -28
  130. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.spec.tsx +82 -48
  131. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.tsx +6 -1
  132. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/{useEndDateValidation.spec.tsx → useEndDateValidation.spec.ts} +23 -20
  133. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/{useStartDateValidation.spec.tsx → useStartDateValidation.spec.ts} +13 -11
  134. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/validateEndDateBeforeStartDate.spec.ts +17 -6
  135. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/{validateEndDateBeforeStartDate.ts → validateEndDateBeforeStartDate.tsx} +9 -3
  136. package/src/Filter/FilterMultiSelect/FilterMultiSelect.spec.tsx +10 -14
  137. package/src/Filter/FilterMultiSelect/_docs/FilterMultiSelect.mdx +1 -1
  138. package/src/Filter/FilterMultiSelect/context/SelectionProvider/SelectionProvider.spec.tsx +392 -372
  139. package/src/Filter/FilterMultiSelect/subcomponents/SearchInput/SearchInput.spec.tsx +9 -6
  140. package/src/Filter/FilterSelect/_docs/FilterSelect.mdx +1 -1
  141. package/src/GuidanceBlock/_docs/GuidanceBlock.mdx +1 -1
  142. package/src/Heading/_docs/Heading.mdx +1 -1
  143. package/src/Icon/_docs/Icon.mdx +1 -1
  144. package/src/Illustration/Scene/BrandMomentCaptureIntro/_docs/BrandMomentCaptureIntro.mdx +1 -1
  145. package/src/Illustration/Scene/_docs/Scene.mdx +1 -1
  146. package/src/Illustration/Spot/_docs/Spot.mdx +1 -1
  147. package/src/Input/Input/_docs/Input.mdx +1 -1
  148. package/src/Input/InputRange/_docs/InputRange.mdx +1 -1
  149. package/src/Input/InputSearch/InputSearch.spec.tsx +15 -14
  150. package/src/Input/InputSearch/_docs/InputSearch.mdx +1 -1
  151. package/src/Label/_docs/Label.mdx +1 -1
  152. package/src/LabelledMessage/_docs/LabelledMessage.mdx +1 -1
  153. package/src/LikertScaleLegacy/_docs/LikertScaleLegacy.mdx +1 -1
  154. package/src/Loading/LoadingGraphic/_docs/LoadingGraphic.mdx +1 -1
  155. package/src/Loading/LoadingHeading/_docs/LoadingHeading.mdx +1 -1
  156. package/src/Loading/LoadingInput/_docs/LoadingInput.mdx +1 -1
  157. package/src/Loading/LoadingParagraph/_docs/LoadingParagraph.mdx +1 -1
  158. package/src/Loading/LoadingSpinner/_docs/LoadingSpinner.mdx +1 -1
  159. package/src/Menu/_docs/Menu.mdx +1 -1
  160. package/src/Modal/ConfirmationModal/_docs/ConfirmationModal.mdx +1 -1
  161. package/src/Modal/ContextModal/_docs/ContextModal.mdx +1 -1
  162. package/src/Modal/GenericModal/_docs/GenericModal.mdx +1 -1
  163. package/src/Modal/InputEditModal/_docs/InputEditModal.mdx +1 -1
  164. package/src/MultiSelect/_docs/MultiSelect.mdx +1 -1
  165. package/src/Notification/GlobalNotification/_docs/GlobalNotification.mdx +1 -1
  166. package/src/Notification/InlineNotification/_docs/InlineNotification.mdx +1 -1
  167. package/src/Notification/ToastNotification/_docs/ToastNotification.mdx +1 -1
  168. package/src/Pagination/_docs/Pagination.mdx +1 -1
  169. package/src/Pagination/subcomponents/DirectionalLink/_docs/DirectionalLink.mdx +1 -1
  170. package/src/Pagination/subcomponents/PaginationLink/_docs/PaginationLink.mdx +1 -1
  171. package/src/Popover/_docs/Popover.mdx +1 -1
  172. package/src/ProgressBar/_docs/ProgressBar.mdx +1 -1
  173. package/src/Radio/Radio/_docs/Radio.mdx +1 -1
  174. package/src/Radio/RadioField/_docs/RadioField.mdx +1 -1
  175. package/src/Radio/RadioGroup/_docs/RadioGroup.mdx +1 -1
  176. package/src/RichTextEditor/EditableRichTextContent/_docs/EditableRichTextContent.mdx +1 -1
  177. package/src/RichTextEditor/RichTextContent/_docs/RichTextContent.mdx +1 -1
  178. package/src/RichTextEditor/RichTextEditor/_docs/RichTextEditor.mdx +1 -1
  179. package/src/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/_docs/ToggleIconButton.mdx +1 -1
  180. package/src/RichTextEditor/RichTextEditor/subcomponents/Toolbar/_docs/Toolbar.mdx +1 -1
  181. package/src/SearchField/_docs/SearchField.mdx +1 -1
  182. package/src/Select/_docs/Select.mdx +1 -1
  183. package/src/Skirt/_docs/Skirt.mdx +1 -1
  184. package/src/Slider/_docs/Slider.mdx +1 -1
  185. package/src/SplitButton/SplitButton.spec.tsx +11 -6
  186. package/src/SplitButton/_docs/SplitButton.mdx +1 -1
  187. package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.spec.tsx +15 -10
  188. package/src/Table/_docs/Table.mdx +1 -1
  189. package/src/Tabs/_docs/Tabs.mdx +1 -1
  190. package/src/Tag/_docs/Tag.mdx +1 -1
  191. package/src/Text/_docs/Text.mdx +1 -1
  192. package/src/TextArea/_docs/TextArea.mdx +1 -1
  193. package/src/TextAreaField/_docs/TextAreaField.mdx +1 -1
  194. package/src/TextField/_docs/TextField.mdx +1 -1
  195. package/src/Tile/InformationTile/_docs/InformationTile.mdx +1 -1
  196. package/src/Tile/MultiActionTile/_docs/MultiActionTile.mdx +1 -1
  197. package/src/Tile/TileGrid/_docs/TileGrid.mdx +1 -1
  198. package/src/TimeField/_docs/TimeField.mdx +1 -1
  199. package/src/TitleBlockZen/_docs/TitleBlockZen.mdx +1 -1
  200. package/src/ToggleSwitch/ToggleSwitch/_docs/ToggleSwitch.mdx +1 -1
  201. package/src/ToggleSwitch/ToggleSwitchField/_docs/ToggleSwitchField.mdx +1 -1
  202. package/src/VisuallyHidden/_docs/VisuallyHidden.mdx +1 -1
  203. package/src/Well/_docs/Well.mdx +1 -1
  204. package/src/Workflow/_docs/ProgressStepper.mdx +1 -1
  205. package/src/Workflow/_docs/Workflow.mdx +1 -1
  206. package/src/Workflow/_docs/WorkflowFooter.mdx +1 -1
  207. package/src/Workflow/_docs/WorkflowHeader.mdx +1 -1
  208. package/src/__future__/Select/_docs/Select.mdx +1 -1
  209. package/src/__future__/Tag/Tag/_docs/Tag.mdx +1 -1
  210. package/src/__future__/Workflow/_docs/ProgressStepper.mdx +1 -1
  211. package/src/__future__/Workflow/_docs/Workflow.mdx +1 -1
  212. package/src/__future__/Workflow/_docs/WorkflowFooter.mdx +1 -1
  213. package/src/__future__/Workflow/_docs/WorkflowHeader.mdx +1 -1
  214. package/src/__overlays__/Tooltip/v1/_docs/Tooltip.mdx +1 -1
  215. package/src/__overlays__/Tooltip/v3/_docs/ApiSpecification.mdx +0 -1
  216. package/src/__overlays__/Tooltip/v3/_docs/Tooltip.docs.stories.tsx +52 -0
  217. package/src/__overlays__/Tooltip/v3/_docs/Tooltip.mdx +40 -61
  218. package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_spec.png +0 -0
@@ -143,9 +143,8 @@ export const Validation: Story = {
143
143
  )
144
144
  const [status, setStatus] = useState<FieldMessageStatus | undefined>()
145
145
  const [response, setResponse] = useState<ValidationResponse | undefined>()
146
- const [validationMessage, setValidationMessage] = useState<
147
- string | undefined
148
- >()
146
+ const [validationMessage, setValidationMessage] =
147
+ useState<ValidationResponse["validationMessage"]>()
149
148
 
150
149
  const handleValidation = (validationResponse: ValidationResponse): void => {
151
150
  setResponse(validationResponse)
@@ -1,6 +1,6 @@
1
1
  import { ArgTypes } from "@storybook/react"
2
2
 
3
- const DATE_PICKER_SUPPORTED_LOCALES = ["en-US", "en-AU"]
3
+ const DATE_PICKER_SUPPORTED_LOCALES = ["en-US", "en-AU", "fr-CA"]
4
4
 
5
5
  export const datePickerLocaleControls: Partial<ArgTypes> = {
6
6
  locale: {
@@ -1,7 +1,8 @@
1
1
  import React, { useRef } from "react"
2
- import { render, screen } from "@testing-library/react"
2
+ import { screen, waitFor } from "@testing-library/react"
3
3
  import userEvent from "@testing-library/user-event"
4
4
  import { enUS } from "date-fns/locale"
5
+ import { renderWithIntl } from "~tests"
5
6
  import { DateInputField, DateInputFieldProps } from "./DateInputField"
6
7
 
7
8
  const user = userEvent.setup()
@@ -9,8 +10,8 @@ const user = userEvent.setup()
9
10
  const defaultProps: DateInputFieldProps = {
10
11
  id: "test__date-input-field",
11
12
  labelText: "Bacon expiry",
12
- onButtonClick: jest.fn<void, []>(),
13
- onKeyDown: jest.fn<void, [React.KeyboardEvent<HTMLInputElement>]>(),
13
+ onButtonClick: jest.fn(),
14
+ onKeyDown: jest.fn(),
14
15
  value: undefined,
15
16
  locale: enUS,
16
17
  }
@@ -21,68 +22,83 @@ const DateInputFieldWrapper = (
21
22
 
22
23
  describe("<DateInputField />", () => {
23
24
  describe("Input", () => {
24
- it("associates the description with the input", () => {
25
- render(<DateInputFieldWrapper />)
26
- expect(
27
- screen.getByRole("textbox", {
28
- name: "Bacon expiry",
29
- description: "Input format : mm/dd/yyyy",
30
- })
31
- ).toBeInTheDocument()
25
+ it("associates the description with the input", async () => {
26
+ renderWithIntl(<DateInputFieldWrapper />)
27
+ await waitFor(() => {
28
+ expect(
29
+ screen.getByRole("textbox", {
30
+ name: "Bacon expiry",
31
+ description: "Input format : mm/dd/yyyy",
32
+ })
33
+ ).toBeInTheDocument()
34
+ })
32
35
  })
33
36
  })
34
37
 
35
38
  describe("Icon button", () => {
36
- it("has helpful label", () => {
37
- render(<DateInputFieldWrapper />)
38
- expect(
39
- screen.getByRole("button", { name: "Choose date" })
40
- ).toBeInTheDocument()
39
+ it("has helpful label", async () => {
40
+ renderWithIntl(<DateInputFieldWrapper />)
41
+ await waitFor(() => {
42
+ expect(
43
+ screen.getByRole("button", { name: "Choose date" })
44
+ ).toBeInTheDocument()
45
+ })
41
46
  })
42
47
 
43
- it("has helpful label showing the current date when one is selected", () => {
44
- render(
48
+ it("has helpful label showing the current date when one is selected", async () => {
49
+ renderWithIntl(
45
50
  <DateInputFieldWrapper
46
51
  value="Mar 1, 2022"
47
52
  onChange={(): void => undefined}
48
53
  />
49
54
  )
50
- expect(
51
- screen.getByRole("button", { name: "Change date, Mar 1, 2022" })
52
- ).toBeInTheDocument()
55
+ await waitFor(() => {
56
+ expect(
57
+ screen.getByRole("button", { name: "Change date, Mar 1, 2022" })
58
+ ).toBeInTheDocument()
59
+ })
53
60
  })
54
61
  })
55
62
 
56
63
  describe("States", () => {
57
- it("disables both input and icon button", () => {
58
- render(<DateInputFieldWrapper disabled />)
64
+ it("disables both input and icon button", async () => {
65
+ renderWithIntl(<DateInputFieldWrapper disabled />)
59
66
  const input = screen.getByRole("textbox", { name: "Bacon expiry" })
60
67
  const calendarButton = screen.getByRole("button", { name: "Choose date" })
61
- expect(input).toBeDisabled()
62
- expect(calendarButton).toBeDisabled()
68
+ await waitFor(() => {
69
+ expect(input).toBeDisabled()
70
+ expect(calendarButton).toBeDisabled()
71
+ })
63
72
  })
64
73
  })
65
74
 
66
75
  describe("Validation", () => {
67
- it("shows validation message", () => {
68
- render(
76
+ it("shows validation message", async () => {
77
+ renderWithIntl(
69
78
  <DateInputFieldWrapper
70
79
  status="error"
71
80
  validationMessage="There is an error"
72
81
  />
73
82
  )
74
83
  const errorMessage = screen.getByText("There is an error")
75
- expect(errorMessage).toBeInTheDocument()
84
+ await waitFor(() => {
85
+ expect(errorMessage).toBeInTheDocument()
86
+ })
76
87
  })
77
88
 
78
- it("does not show validation message when field is disabled", () => {
79
- render(
89
+ it("does not show validation message when field is disabled", async () => {
90
+ renderWithIntl(
80
91
  <DateInputFieldWrapper
81
92
  status="error"
82
93
  validationMessage="There is an error"
83
94
  disabled
84
95
  />
85
96
  )
97
+ await waitFor(() => {
98
+ expect(
99
+ screen.getByRole("textbox", { name: "Bacon expiry" })
100
+ ).toBeVisible()
101
+ })
86
102
  const errorMessage = screen.queryByText("There is an error")
87
103
  expect(errorMessage).not.toBeInTheDocument()
88
104
  })
@@ -90,10 +106,7 @@ describe("<DateInputField />", () => {
90
106
 
91
107
  describe("Refs", () => {
92
108
  it("correctly passes through input and button refs", async () => {
93
- const onButtonClick = jest.fn<
94
- void,
95
- [string | null | undefined, string | null | undefined]
96
- >()
109
+ const onButtonClick = jest.fn()
97
110
 
98
111
  const Wrapper = (): JSX.Element => {
99
112
  const inputRef = useRef<HTMLInputElement>(null)
@@ -122,10 +135,10 @@ describe("<DateInputField />", () => {
122
135
  )
123
136
  }
124
137
 
125
- render(<Wrapper />)
138
+ renderWithIntl(<Wrapper />)
126
139
 
127
140
  await user.click(screen.getByText("Click me"))
128
- expect(onButtonClick).toBeCalledWith(
141
+ expect(onButtonClick).toHaveBeenCalledWith(
129
142
  "test__date-input-field--ref",
130
143
  "Choose date"
131
144
  )
@@ -1,10 +1,11 @@
1
+ import { ReactElement } from "react"
1
2
  import { FieldMessageStatus } from "~components/FieldMessage"
2
3
 
3
4
  export type ValidationResponse = {
4
5
  date: Date | undefined
5
6
  inputValue: string | undefined // Input value upon validation
6
7
  status: FieldMessageStatus | undefined
7
- validationMessage: string | undefined
8
+ validationMessage: string | ReactElement | undefined
8
9
  isDisabled: boolean
9
10
  isInvalid: boolean
10
11
  isEmpty: boolean
@@ -1,9 +1,11 @@
1
1
  import type { Locale } from "date-fns"
2
- import { enAU, enUS } from "date-fns/locale"
2
+ import { enAU, enUS, frCA } from "date-fns/locale"
3
3
  import { StringSuggestions } from "~types/StringSuggestions"
4
4
 
5
5
  // Ensure you update the storybook DATE_PICKER_SUPPORTED_LOCALES arg options when updating DatePickerSupportedLocales.
6
- export type DatePickerSupportedLocales = StringSuggestions<"en-US" | "en-AU">
6
+ export type DatePickerSupportedLocales = StringSuggestions<
7
+ "en-US" | "en-AU" | "fr-CA"
8
+ >
7
9
 
8
10
  export const getLocale = (locale: DatePickerSupportedLocales): Locale => {
9
11
  switch (locale) {
@@ -11,6 +13,8 @@ export const getLocale = (locale: DatePickerSupportedLocales): Locale => {
11
13
  return enAU
12
14
  case "en-US":
13
15
  return enUS
16
+ case "fr-CA":
17
+ return frCA
14
18
  default:
15
19
  return enAU
16
20
  }
@@ -1,3 +1,5 @@
1
+ import { screen, waitFor } from "@testing-library/react"
2
+ import { renderWithIntl } from "~tests"
1
3
  import { validateDate } from "./validateDate"
2
4
 
3
5
  describe("validateDate", () => {
@@ -20,64 +22,79 @@ describe("validateDate", () => {
20
22
  expect(newDate).toBeUndefined()
21
23
  })
22
24
 
23
- it("returns expected response when selected day is invalid and input value is undefined", () => {
25
+ it("returns expected response when selected day is invalid and input value is undefined", async () => {
24
26
  const date = new Date("potato")
25
27
  const inputValue = undefined
26
28
  const { validationResponse, newDate } = validateDate({ date, inputValue })
27
29
 
28
- expect(validationResponse).toStrictEqual({
30
+ const { validationMessage, ...response } = validationResponse
31
+
32
+ expect(response).toStrictEqual({
29
33
  date,
30
34
  inputValue,
31
35
  status: "error",
32
- validationMessage: "Date is invalid",
33
36
  isInvalid: true,
34
37
  isDisabled: false,
35
38
  isEmpty: false,
36
39
  isValidDate: false,
37
40
  })
38
-
39
41
  expect(newDate).toBeUndefined()
42
+
43
+ renderWithIntl(validationMessage)
44
+ await waitFor(() => {
45
+ expect(screen.getByText("Date is invalid")).toBeVisible()
46
+ })
40
47
  })
41
48
 
42
- it("returns expected response when selected day is invalid and input value is empty string", () => {
49
+ it("returns expected response when selected day is invalid and input value is empty string", async () => {
43
50
  const date = new Date("potato")
44
51
  const inputValue = ""
45
52
  const { validationResponse, newDate } = validateDate({ date, inputValue })
46
53
 
47
- expect(validationResponse).toStrictEqual({
54
+ const { validationMessage, ...response } = validationResponse
55
+
56
+ expect(response).toEqual({
48
57
  date,
49
58
  inputValue,
50
59
  status: "error",
51
- validationMessage: "Date is invalid",
52
60
  isInvalid: true,
53
61
  isDisabled: false,
54
62
  isEmpty: false,
55
63
  isValidDate: false,
56
64
  })
57
-
58
65
  expect(newDate).toBeUndefined()
66
+
67
+ renderWithIntl(validationMessage)
68
+ await waitFor(() => {
69
+ expect(screen.getByText("Date is invalid")).toBeVisible()
70
+ })
59
71
  })
60
72
 
61
- it("returns expected response when selected day is invalid and input value is valid string", () => {
73
+ it("returns expected response when selected day is invalid and input value is valid string", async () => {
62
74
  const date = new Date("potato")
63
75
  const inputValue = "potato"
64
76
  const { validationResponse, newDate } = validateDate({ date, inputValue })
65
77
 
66
- expect(validationResponse).toStrictEqual({
78
+ const { validationMessage, ...response } = validationResponse
79
+
80
+ expect(response).toStrictEqual({
67
81
  date,
68
82
  inputValue,
69
83
  status: "error",
70
- validationMessage: "potato is an invalid date",
71
84
  isInvalid: true,
72
85
  isDisabled: false,
73
86
  isEmpty: false,
74
87
  isValidDate: false,
75
88
  })
76
-
77
89
  expect(newDate).toBeUndefined()
90
+
91
+ renderWithIntl(validationMessage)
92
+ await waitFor(() => {
93
+ expect(screen.getByText("potato is an invalid date")).toBeVisible()
94
+ })
78
95
  })
79
96
 
80
- it("returns expected response when selected day is disabled", () => {
97
+ it("returns expected response when selected day is disabled", async () => {
81
98
  const date = new Date("2022-03-01")
82
99
  const inputValue = "03/01/2022"
83
100
  const disabledDays = [new Date("2022-03-01")]
@@ -87,18 +104,25 @@ describe("validateDate", () => {
87
104
  disabledDays,
88
105
  })
89
106
 
90
- expect(validationResponse).toStrictEqual({
107
+ const { validationMessage, ...response } = validationResponse
108
+
109
+ expect(response).toStrictEqual({
91
110
  date,
92
111
  inputValue,
93
112
  status: "error",
94
- validationMessage: "03/01/2022 is not available, try another date",
95
113
  isInvalid: false,
96
114
  isDisabled: true,
97
115
  isEmpty: false,
98
116
  isValidDate: false,
99
117
  })
100
-
101
118
  expect(newDate).toBeUndefined()
119
+
120
+ renderWithIntl(validationMessage)
121
+ await waitFor(() => {
122
+ expect(
123
+ screen.getByText("03/01/2022 is not available, try another date")
124
+ ).toBeVisible()
125
+ })
102
126
  })
103
127
 
104
128
  it("returns expected response when selected day is valid", () => {
@@ -1,3 +1,5 @@
1
+ import React from "react"
2
+ import { FormattedMessage } from "@cultureamp/i18n-react-intl"
1
3
  import {
2
4
  DisabledDays,
3
5
  isDisabledDate,
@@ -47,9 +49,20 @@ export const validateDate = ({
47
49
  validationResponse: {
48
50
  ...baseResponse,
49
51
  status: "error",
50
- validationMessage: inputValue
51
- ? `${inputValue} is an invalid date`
52
- : "Date is invalid",
52
+ validationMessage: inputValue ? (
53
+ <FormattedMessage
54
+ id="date.validation.invalidDateWithValue"
55
+ defaultMessage="{inputValue} is an invalid date"
56
+ description="Error message when the user enters an invalid date and we know their input value"
57
+ values={{ inputValue }}
58
+ />
59
+ ) : (
60
+ <FormattedMessage
61
+ id="date.validation.invalidDate"
62
+ defaultMessage="Date is invalid"
63
+ description="Error message when the user enters an invalid date and we do not know their input value"
64
+ />
65
+ ),
53
66
  isInvalid: true,
54
67
  },
55
68
  newDate: undefined,
@@ -61,7 +74,14 @@ export const validateDate = ({
61
74
  validationResponse: {
62
75
  ...baseResponse,
63
76
  status: "error",
64
- validationMessage: `${inputValue} is not available, try another date`,
77
+ validationMessage: (
78
+ <FormattedMessage
79
+ id="date.validation.unavailableDate"
80
+ defaultMessage="{inputValue} is not available, try another date"
81
+ description="Error message when the user tries to select a date that is unavailable"
82
+ values={{ inputValue }}
83
+ />
84
+ ),
65
85
  isDisabled: true,
66
86
  },
67
87
  newDate: undefined,
@@ -10,7 +10,7 @@ import * as DateRangePickerStories from "./DateRangePicker.stories"
10
10
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/DateRangePicker"
11
11
  figma="https://www.figma.com/file/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-UI-Kit%3A-Heart?type=design&node-id=10458%3A45652&mode=design&t=4Mycc044XjC1WLin-1"
12
12
  designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082094237/Date+Range+Picker"
13
- className="!mb-8"
13
+
14
14
  />
15
15
 
16
16
  <KAIOInstallation exportNames="DateRangePicker" />
@@ -10,7 +10,7 @@ import * as DividerStories from "./Divider.stories"
10
10
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Divider"
11
11
  figma="https://www.figma.com/file/ZRfnoNUXbGZv4eVWLbF4Az/%EF%B8%8F%F0%9F%96%BC%EF%B8%8F-Component-Gallery?node-id=6%3A18248&t=P1w10jr2cpPuaayw-1"
12
12
  designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082061035/Divider"
13
- className="!mb-8"
13
+
14
14
  />
15
15
 
16
16
  <KAIOInstallation exportNames="Divider" />
@@ -10,7 +10,7 @@ import * as EmptyStateStories from "./EmptyState.stories"
10
10
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/EmptyState"
11
11
  figma="https://www.figma.com/file/ZRfnoNUXbGZv4eVWLbF4Az/%F0%9F%96%BC%EF%B8%8F-Component-Gallery?type=design&node-id=6-18405&mode=design&t=zslxM6C2B20CxDxt-0"
12
12
  designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082094098/Empty+State"
13
- className="!mb-8"
13
+
14
14
  />
15
15
 
16
16
  <KAIOInstallation exportNames="EmptyState" />
@@ -8,7 +8,7 @@ import * as ErrorPageStories from "./ErrorPage.stories"
8
8
 
9
9
  <ResourceLinks
10
10
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/master/packages/components/src/ErrorPage"
11
- className="!mb-8"
11
+
12
12
  />
13
13
 
14
14
  <KAIOInstallation exportNames="ErrorPage" />
@@ -9,7 +9,7 @@ import * as FieldGroupStories from "./FieldGroup.stories"
9
9
 
10
10
  <ResourceLinks
11
11
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/FieldGroup"
12
- className="!mb-8"
12
+
13
13
  />
14
14
 
15
15
  <KAIOInstallation exportNames="FieldGroup" />
@@ -10,7 +10,7 @@ import * as FieldMessageStories from "./FieldMessage.stories"
10
10
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/FieldMessage"
11
11
  figma="https://www.figma.com/file/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-UI-Kit%3A-Heart?type=design&node-id=34254%3A91754&mode=design&t=HvwF2tRq9DbfkSuV-1"
12
12
  designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3081928705/Text+Field"
13
- className="!mb-8"
13
+
14
14
  />
15
15
 
16
16
  <KAIOInstallation exportNames="FieldMessage" />
@@ -11,7 +11,7 @@ import * as FilterStories from "./Filter.stories"
11
11
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Filter"
12
12
  figma="https://www.figma.com/file/ZRfnoNUXbGZv4eVWLbF4Az/%F0%9F%96%BC%EF%B8%8F-Component-Gallery?type=design&node-id=6-28579&t=bowQ0LWOQKOd0UYS-0"
13
13
  designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082093959/Filters"
14
- className="!mb-8"
14
+
15
15
  />
16
16
 
17
17
  <KAIOInstallation exportNames={["Filter", "FilterContents"]} />