@bikdotai/bik-component-library 0.0.868-beta.8 → 0.0.868

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/README.md +0 -3
  2. package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
  3. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
  4. package/dist/cjs/components/bik-copilot/BIKCopilot.js +2 -0
  5. package/dist/cjs/components/bik-copilot/BIKCopilot.js.map +1 -0
  6. package/dist/cjs/components/bik-copilot/ControlledCopilot.js +2 -0
  7. package/dist/cjs/components/bik-copilot/ControlledCopilot.js.map +1 -0
  8. package/dist/cjs/components/bik-copilot/ControlledCopilot.styled.js +27 -0
  9. package/dist/cjs/components/bik-copilot/ControlledCopilot.styled.js.map +1 -0
  10. package/dist/cjs/components/bik-copilot/CopilotBall.js +2 -0
  11. package/dist/cjs/components/bik-copilot/CopilotBall.js.map +1 -0
  12. package/dist/cjs/components/bik-copilot/CopilotBall.styled.js +42 -0
  13. package/dist/cjs/components/bik-copilot/CopilotBall.styled.js.map +1 -0
  14. package/dist/cjs/components/bik-copilot/CopilotFeedbackModal.js +2 -0
  15. package/dist/cjs/components/bik-copilot/CopilotFeedbackModal.js.map +1 -0
  16. package/dist/cjs/components/bik-copilot/CopilotFeedbackModal.styled.js +108 -0
  17. package/dist/cjs/components/bik-copilot/CopilotFeedbackModal.styled.js.map +1 -0
  18. package/dist/cjs/components/bik-copilot/CopilotPanel.js +2 -0
  19. package/dist/cjs/components/bik-copilot/CopilotPanel.js.map +1 -0
  20. package/dist/cjs/components/bik-copilot/CopilotPanel.styled.js +534 -0
  21. package/dist/cjs/components/bik-copilot/CopilotPanel.styled.js.map +1 -0
  22. package/dist/cjs/components/bik-copilot/copilotPlacement.js +2 -0
  23. package/dist/cjs/components/bik-copilot/copilotPlacement.js.map +1 -0
  24. package/dist/cjs/components/bik-copilot/copilotRegenerate.js +2 -0
  25. package/dist/cjs/components/bik-copilot/copilotRegenerate.js.map +1 -0
  26. package/dist/cjs/components/bik-copilot/services/copilotDb.js +2 -0
  27. package/dist/cjs/components/bik-copilot/services/copilotDb.js.map +1 -0
  28. package/dist/cjs/components/bik-copilot/services/copilotFeedbackClient.js +2 -0
  29. package/dist/cjs/components/bik-copilot/services/copilotFeedbackClient.js.map +1 -0
  30. package/dist/cjs/components/bik-copilot/services/copilotIcebreakersClient.js +2 -0
  31. package/dist/cjs/components/bik-copilot/services/copilotIcebreakersClient.js.map +1 -0
  32. package/dist/cjs/components/bik-copilot/services/copilotMessagesClient.js +2 -0
  33. package/dist/cjs/components/bik-copilot/services/copilotMessagesClient.js.map +1 -0
  34. package/dist/cjs/components/bik-copilot/services/copilotPageSession.js +2 -0
  35. package/dist/cjs/components/bik-copilot/services/copilotPageSession.js.map +1 -0
  36. package/dist/cjs/components/bik-copilot/services/copilotSseParser.js +7 -0
  37. package/dist/cjs/components/bik-copilot/services/copilotSseParser.js.map +1 -0
  38. package/dist/cjs/components/bik-copilot/services/copilotStreamClient.js +2 -0
  39. package/dist/cjs/components/bik-copilot/services/copilotStreamClient.js.map +1 -0
  40. package/dist/cjs/components/bik-copilot/useCopilotIcebreakers.js +2 -0
  41. package/dist/cjs/components/bik-copilot/useCopilotIcebreakers.js.map +1 -0
  42. package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js +2 -0
  43. package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js.map +1 -0
  44. package/dist/cjs/components/bik-copilot/useDraggableFloater.js +2 -0
  45. package/dist/cjs/components/bik-copilot/useDraggableFloater.js.map +1 -0
  46. package/dist/cjs/components/bik-copilot/utils/markdown.js +4 -0
  47. package/dist/cjs/components/bik-copilot/utils/markdown.js.map +1 -0
  48. package/dist/cjs/components/bik-copilot/utils/toolCtas.js +2 -0
  49. package/dist/cjs/components/bik-copilot/utils/toolCtas.js.map +1 -0
  50. package/dist/cjs/components/button/themes.js +2 -2
  51. package/dist/cjs/components/button/themes.js.map +1 -1
  52. package/dist/cjs/components/datePicker/DatePickerWrapper.js +1 -1
  53. package/dist/cjs/components/datePicker/DatePickerWrapper.js.map +1 -1
  54. package/dist/cjs/index.js +1 -1
  55. package/dist/esm/components/agent-builder/constants/tools.d.ts +1 -0
  56. package/dist/esm/components/agent-builder/constants/tools.js +18 -18
  57. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  58. package/dist/esm/components/bik-copilot/BIKCopilot.d.ts +31 -0
  59. package/dist/esm/components/bik-copilot/BIKCopilot.js +118 -0
  60. package/dist/esm/components/bik-copilot/BIKCopilot.js.map +1 -0
  61. package/dist/esm/components/bik-copilot/ControlledCopilot.d.ts +14 -0
  62. package/dist/esm/components/bik-copilot/ControlledCopilot.js +174 -0
  63. package/dist/esm/components/bik-copilot/ControlledCopilot.js.map +1 -0
  64. package/dist/esm/components/bik-copilot/ControlledCopilot.styled.d.ts +7 -0
  65. package/dist/esm/components/bik-copilot/ControlledCopilot.styled.js +31 -0
  66. package/dist/esm/components/bik-copilot/ControlledCopilot.styled.js.map +1 -0
  67. package/dist/esm/components/bik-copilot/CopilotBall.d.ts +13 -0
  68. package/dist/esm/components/bik-copilot/CopilotBall.js +50 -0
  69. package/dist/esm/components/bik-copilot/CopilotBall.js.map +1 -0
  70. package/dist/esm/components/bik-copilot/CopilotBall.styled.d.ts +9 -0
  71. package/dist/esm/components/bik-copilot/CopilotBall.styled.js +46 -0
  72. package/dist/esm/components/bik-copilot/CopilotBall.styled.js.map +1 -0
  73. package/dist/esm/components/bik-copilot/CopilotFeedbackModal.d.ts +29 -0
  74. package/dist/esm/components/bik-copilot/CopilotFeedbackModal.js +73 -0
  75. package/dist/esm/components/bik-copilot/CopilotFeedbackModal.js.map +1 -0
  76. package/dist/esm/components/bik-copilot/CopilotFeedbackModal.styled.d.ts +12 -0
  77. package/dist/esm/components/bik-copilot/CopilotFeedbackModal.styled.js +122 -0
  78. package/dist/esm/components/bik-copilot/CopilotFeedbackModal.styled.js.map +1 -0
  79. package/dist/esm/components/bik-copilot/CopilotPanel.d.ts +9 -0
  80. package/dist/esm/components/bik-copilot/CopilotPanel.js +536 -0
  81. package/dist/esm/components/bik-copilot/CopilotPanel.js.map +1 -0
  82. package/dist/esm/components/bik-copilot/CopilotPanel.styled.d.ts +67 -0
  83. package/dist/esm/components/bik-copilot/CopilotPanel.styled.js +573 -0
  84. package/dist/esm/components/bik-copilot/CopilotPanel.styled.js.map +1 -0
  85. package/dist/esm/components/bik-copilot/copilotPlacement.d.ts +24 -0
  86. package/dist/esm/components/bik-copilot/copilotPlacement.js +38 -0
  87. package/dist/esm/components/bik-copilot/copilotPlacement.js.map +1 -0
  88. package/dist/esm/components/bik-copilot/copilotRegenerate.d.ts +22 -0
  89. package/dist/esm/components/bik-copilot/copilotRegenerate.js +6 -0
  90. package/dist/esm/components/bik-copilot/copilotRegenerate.js.map +1 -0
  91. package/dist/esm/components/bik-copilot/index.d.ts +19 -0
  92. package/dist/esm/components/bik-copilot/model.d.ts +804 -0
  93. package/dist/esm/components/bik-copilot/services/copilotDb.d.ts +90 -0
  94. package/dist/esm/components/bik-copilot/services/copilotDb.js +96 -0
  95. package/dist/esm/components/bik-copilot/services/copilotDb.js.map +1 -0
  96. package/dist/esm/components/bik-copilot/services/copilotFeedbackClient.d.ts +15 -0
  97. package/dist/esm/components/bik-copilot/services/copilotFeedbackClient.js +55 -0
  98. package/dist/esm/components/bik-copilot/services/copilotFeedbackClient.js.map +1 -0
  99. package/dist/esm/components/bik-copilot/services/copilotIcebreakersClient.d.ts +11 -0
  100. package/dist/esm/components/bik-copilot/services/copilotIcebreakersClient.js +54 -0
  101. package/dist/esm/components/bik-copilot/services/copilotIcebreakersClient.js.map +1 -0
  102. package/dist/esm/components/bik-copilot/services/copilotMessagesClient.d.ts +23 -0
  103. package/dist/esm/components/bik-copilot/services/copilotMessagesClient.js +78 -0
  104. package/dist/esm/components/bik-copilot/services/copilotMessagesClient.js.map +1 -0
  105. package/dist/esm/components/bik-copilot/services/copilotPageSession.d.ts +37 -0
  106. package/dist/esm/components/bik-copilot/services/copilotPageSession.js +35 -0
  107. package/dist/esm/components/bik-copilot/services/copilotPageSession.js.map +1 -0
  108. package/dist/esm/components/bik-copilot/services/copilotSseParser.d.ts +22 -0
  109. package/dist/esm/components/bik-copilot/services/copilotSseParser.js +52 -0
  110. package/dist/esm/components/bik-copilot/services/copilotSseParser.js.map +1 -0
  111. package/dist/esm/components/bik-copilot/services/copilotStreamClient.d.ts +35 -0
  112. package/dist/esm/components/bik-copilot/services/copilotStreamClient.js +110 -0
  113. package/dist/esm/components/bik-copilot/services/copilotStreamClient.js.map +1 -0
  114. package/dist/esm/components/bik-copilot/useCopilotIcebreakers.d.ts +17 -0
  115. package/dist/esm/components/bik-copilot/useCopilotIcebreakers.js +60 -0
  116. package/dist/esm/components/bik-copilot/useCopilotIcebreakers.js.map +1 -0
  117. package/dist/esm/components/bik-copilot/useCopilotStreamChat.d.ts +20 -0
  118. package/dist/esm/components/bik-copilot/useCopilotStreamChat.js +377 -0
  119. package/dist/esm/components/bik-copilot/useCopilotStreamChat.js.map +1 -0
  120. package/dist/esm/components/bik-copilot/useDraggableFloater.d.ts +9 -0
  121. package/dist/esm/components/bik-copilot/useDraggableFloater.js +118 -0
  122. package/dist/esm/components/bik-copilot/useDraggableFloater.js.map +1 -0
  123. package/dist/esm/components/bik-copilot/utils/markdown.d.ts +1 -0
  124. package/dist/esm/components/bik-copilot/utils/markdown.js +48 -0
  125. package/dist/esm/components/bik-copilot/utils/markdown.js.map +1 -0
  126. package/dist/esm/components/bik-copilot/utils/toolCtas.d.ts +6 -0
  127. package/dist/esm/components/bik-copilot/utils/toolCtas.js +27 -0
  128. package/dist/esm/components/bik-copilot/utils/toolCtas.js.map +1 -0
  129. package/dist/esm/components/button/themes.js +1 -2
  130. package/dist/esm/components/button/themes.js.map +1 -1
  131. package/dist/esm/components/datePicker/DatePickerWrapper.d.ts +0 -7
  132. package/dist/esm/components/datePicker/DatePickerWrapper.js +64 -66
  133. package/dist/esm/components/datePicker/DatePickerWrapper.js.map +1 -1
  134. package/dist/esm/components/datePicker/index.d.ts +0 -1
  135. package/dist/esm/index.d.ts +1 -3
  136. package/dist/esm/index.js +844 -828
  137. package/dist/esm/index.js.map +1 -1
  138. package/package.json +1 -1
  139. package/dist/cjs/components/chip-selector/ChipSelector.js +0 -2
  140. package/dist/cjs/components/chip-selector/ChipSelector.js.map +0 -1
  141. package/dist/cjs/components/chip-selector/ChipSelector.styled.js +0 -36
  142. package/dist/cjs/components/chip-selector/ChipSelector.styled.js.map +0 -1
  143. package/dist/cjs/components/chip-selector/ChipSelectorGroup.js +0 -2
  144. package/dist/cjs/components/chip-selector/ChipSelectorGroup.js.map +0 -1
  145. package/dist/cjs/components/combo-box/ComboBox.js +0 -2
  146. package/dist/cjs/components/combo-box/ComboBox.js.map +0 -1
  147. package/dist/cjs/components/combo-box/ComboBox.styled.js +0 -33
  148. package/dist/cjs/components/combo-box/ComboBox.styled.js.map +0 -1
  149. package/dist/cjs/components/schedule-builder/RefreshSegmentToggle.js +0 -2
  150. package/dist/cjs/components/schedule-builder/RefreshSegmentToggle.js.map +0 -1
  151. package/dist/cjs/components/schedule-builder/ScheduleBuilder.js +0 -2
  152. package/dist/cjs/components/schedule-builder/ScheduleBuilder.js.map +0 -1
  153. package/dist/cjs/components/schedule-builder/ScheduleBuilder.styled.js +0 -138
  154. package/dist/cjs/components/schedule-builder/ScheduleBuilder.styled.js.map +0 -1
  155. package/dist/cjs/components/schedule-builder/ScheduleEndPicker.js +0 -2
  156. package/dist/cjs/components/schedule-builder/ScheduleEndPicker.js.map +0 -1
  157. package/dist/cjs/components/schedule-builder/ScheduleFrequencyPicker.js +0 -2
  158. package/dist/cjs/components/schedule-builder/ScheduleFrequencyPicker.js.map +0 -1
  159. package/dist/cjs/components/schedule-builder/ScheduleHelper.js +0 -2
  160. package/dist/cjs/components/schedule-builder/ScheduleHelper.js.map +0 -1
  161. package/dist/cjs/components/schedule-builder/SendModeSelector.js +0 -2
  162. package/dist/cjs/components/schedule-builder/SendModeSelector.js.map +0 -1
  163. package/dist/cjs/components/schedule-builder/StartDateTimePicker.js +0 -2
  164. package/dist/cjs/components/schedule-builder/StartDateTimePicker.js.map +0 -1
  165. package/dist/cjs/components/schedule-builder/UpcomingRunsPreview.js +0 -2
  166. package/dist/cjs/components/schedule-builder/UpcomingRunsPreview.js.map +0 -1
  167. package/dist/cjs/components/schedule-builder/model.js +0 -2
  168. package/dist/cjs/components/schedule-builder/model.js.map +0 -1
  169. package/dist/esm/components/chip-selector/ChipSelector.d.ts +0 -9
  170. package/dist/esm/components/chip-selector/ChipSelector.js +0 -27
  171. package/dist/esm/components/chip-selector/ChipSelector.js.map +0 -1
  172. package/dist/esm/components/chip-selector/ChipSelector.styled.d.ts +0 -10
  173. package/dist/esm/components/chip-selector/ChipSelector.styled.js +0 -48
  174. package/dist/esm/components/chip-selector/ChipSelector.styled.js.map +0 -1
  175. package/dist/esm/components/chip-selector/ChipSelectorGroup.d.ts +0 -10
  176. package/dist/esm/components/chip-selector/ChipSelectorGroup.js +0 -48
  177. package/dist/esm/components/chip-selector/ChipSelectorGroup.js.map +0 -1
  178. package/dist/esm/components/chip-selector/index.d.ts +0 -4
  179. package/dist/esm/components/chip-selector/model.d.ts +0 -106
  180. package/dist/esm/components/combo-box/ComboBox.d.ts +0 -15
  181. package/dist/esm/components/combo-box/ComboBox.js +0 -118
  182. package/dist/esm/components/combo-box/ComboBox.js.map +0 -1
  183. package/dist/esm/components/combo-box/ComboBox.styled.d.ts +0 -12
  184. package/dist/esm/components/combo-box/ComboBox.styled.js +0 -40
  185. package/dist/esm/components/combo-box/ComboBox.styled.js.map +0 -1
  186. package/dist/esm/components/combo-box/index.d.ts +0 -3
  187. package/dist/esm/components/combo-box/model.d.ts +0 -55
  188. package/dist/esm/components/schedule-builder/RefreshSegmentToggle.d.ts +0 -22
  189. package/dist/esm/components/schedule-builder/RefreshSegmentToggle.js +0 -31
  190. package/dist/esm/components/schedule-builder/RefreshSegmentToggle.js.map +0 -1
  191. package/dist/esm/components/schedule-builder/ScheduleBuilder.d.ts +0 -88
  192. package/dist/esm/components/schedule-builder/ScheduleBuilder.js +0 -105
  193. package/dist/esm/components/schedule-builder/ScheduleBuilder.js.map +0 -1
  194. package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.d.ts +0 -81
  195. package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.js +0 -168
  196. package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.js.map +0 -1
  197. package/dist/esm/components/schedule-builder/ScheduleEndPicker.d.ts +0 -17
  198. package/dist/esm/components/schedule-builder/ScheduleEndPicker.js +0 -105
  199. package/dist/esm/components/schedule-builder/ScheduleEndPicker.js.map +0 -1
  200. package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.d.ts +0 -21
  201. package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.js +0 -136
  202. package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.js.map +0 -1
  203. package/dist/esm/components/schedule-builder/ScheduleHelper.d.ts +0 -110
  204. package/dist/esm/components/schedule-builder/ScheduleHelper.js +0 -196
  205. package/dist/esm/components/schedule-builder/ScheduleHelper.js.map +0 -1
  206. package/dist/esm/components/schedule-builder/SendModeSelector.d.ts +0 -29
  207. package/dist/esm/components/schedule-builder/SendModeSelector.js +0 -41
  208. package/dist/esm/components/schedule-builder/SendModeSelector.js.map +0 -1
  209. package/dist/esm/components/schedule-builder/StartDateTimePicker.d.ts +0 -51
  210. package/dist/esm/components/schedule-builder/StartDateTimePicker.js +0 -120
  211. package/dist/esm/components/schedule-builder/StartDateTimePicker.js.map +0 -1
  212. package/dist/esm/components/schedule-builder/UpcomingRunsPreview.d.ts +0 -19
  213. package/dist/esm/components/schedule-builder/UpcomingRunsPreview.js +0 -44
  214. package/dist/esm/components/schedule-builder/UpcomingRunsPreview.js.map +0 -1
  215. package/dist/esm/components/schedule-builder/index.d.ts +0 -18
  216. package/dist/esm/components/schedule-builder/model.d.ts +0 -69
  217. package/dist/esm/components/schedule-builder/model.js +0 -8
  218. package/dist/esm/components/schedule-builder/model.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScheduleEndPicker.js","sources":["../../../../src/components/schedule-builder/ScheduleEndPicker.tsx"],"sourcesContent":["import React from 'react';\nimport { COLORS } from '../../constants/Theme';\nimport { DatePickerWrapper } from '../datePicker';\nimport { Input } from '../input';\nimport { RadioButton } from '../radioButton';\nimport { BodySecondary } from '../TypographyStyle';\nimport { RECURRENCE_END_MODE, RecurrenceValue } from './model';\nimport {\n\tEndDateWrapper,\n\tEndsRow,\n\tFieldColumn,\n\tFieldLabel,\n\tRow,\n\tRunCountInputWrapper,\n} from './ScheduleBuilder.styled';\nimport { MAX_RECURRENCE_RUNS } from './ScheduleHelper';\n\n/**\n * Radios in this section read brand purple when selected. The library defaults\n * to the positive green, which is not what the design shows.\n */\nconst RADIO_ACTIVE_COLOR = COLORS.background.inverseLight;\n\nexport interface ScheduleEndPickerProps {\n\tvalue: RecurrenceValue;\n\tonChange: (patch: Partial<RecurrenceValue>) => void;\n\t/** Earliest selectable end date — normally the series' own start date. */\n\tminEndDate?: Date;\n\t'data-test'?: string;\n}\n\n/**\n * \"Never / After N runs / On <date>\".\n *\n * The run-count input and the end-date picker stay mounted and go disabled with\n * their mode rather than unmounting, so the row keeps its width and the controls\n * do not jump as the merchant switches between them.\n */\nexport const ScheduleEndPicker: React.FC<ScheduleEndPickerProps> = ({\n\tvalue,\n\tonChange,\n\tminEndDate,\n\t'data-test': dataTest,\n}) => {\n\tconst endMode = value?.endMode ?? RECURRENCE_END_MODE.NEVER;\n\n\treturn (\n\t\t<FieldColumn data-test={dataTest}>\n\t\t\t<FieldLabel>\n\t\t\t\t<BodySecondary color={COLORS.content.primary}>Ends</BodySecondary>\n\t\t\t</FieldLabel>\n\t\t\t<EndsRow>\n\t\t\t\t<RadioButton\n\t\t\t\t\tisActive={endMode === RECURRENCE_END_MODE.NEVER}\n\t\t\t\t\tlabel=\"Never\"\n\t\t\t\t\tvalue={RECURRENCE_END_MODE.NEVER}\n\t\t\t\t\tonValueChange={() => onChange({ endMode: RECURRENCE_END_MODE.NEVER })}\n\t\t\t\t\tactiveColor={RADIO_ACTIVE_COLOR}\n\t\t\t\t\t// Inert only once selected — an end mode is always required, so the\n\t\t\t\t\t// active option cannot be clicked off.\n\t\t\t\t\tskipSelectingOff={endMode === RECURRENCE_END_MODE.NEVER}\n\t\t\t\t/>\n\n\t\t\t\t<Row gap={8}>\n\t\t\t\t\t<RadioButton\n\t\t\t\t\t\tisActive={endMode === RECURRENCE_END_MODE.AFTER_RUNS}\n\t\t\t\t\t\tlabel=\"After\"\n\t\t\t\t\t\tvalue={RECURRENCE_END_MODE.AFTER_RUNS}\n\t\t\t\t\t\tonValueChange={() =>\n\t\t\t\t\t\t\tonChange({ endMode: RECURRENCE_END_MODE.AFTER_RUNS })\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactiveColor={RADIO_ACTIVE_COLOR}\n\t\t\t\t\t\tskipSelectingOff={endMode === RECURRENCE_END_MODE.AFTER_RUNS}\n\t\t\t\t\t/>\n\t\t\t\t\t<RunCountInputWrapper>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\tvariant=\"small\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tplaceholder={String(MAX_RECURRENCE_RUNS)}\n\t\t\t\t\t\t\tvalue={value?.endAfterRuns ? String(value.endAfterRuns) : ''}\n\t\t\t\t\t\t\tstate={\n\t\t\t\t\t\t\t\tendMode === RECURRENCE_END_MODE.AFTER_RUNS ? 'none' : 'disabled'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChangeText={(input: string) => {\n\t\t\t\t\t\t\t\tconst digitsOnly = input.replace(/\\D/g, '');\n\t\t\t\t\t\t\t\tif (!digitsOnly) {\n\t\t\t\t\t\t\t\t\tonChange({ endAfterRuns: undefined });\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\tendAfterRuns: Math.min(\n\t\t\t\t\t\t\t\t\t\tNumber(digitsOnly),\n\t\t\t\t\t\t\t\t\t\tMAX_RECURRENCE_RUNS,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</RunCountInputWrapper>\n\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>runs</BodySecondary>\n\t\t\t\t</Row>\n\n\t\t\t\t<Row gap={8}>\n\t\t\t\t\t<RadioButton\n\t\t\t\t\t\tisActive={endMode === RECURRENCE_END_MODE.ON_DATE}\n\t\t\t\t\t\tlabel=\"On\"\n\t\t\t\t\t\tvalue={RECURRENCE_END_MODE.ON_DATE}\n\t\t\t\t\t\tonValueChange={() =>\n\t\t\t\t\t\t\tonChange({ endMode: RECURRENCE_END_MODE.ON_DATE })\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactiveColor={RADIO_ACTIVE_COLOR}\n\t\t\t\t\t\tskipSelectingOff={endMode === RECURRENCE_END_MODE.ON_DATE}\n\t\t\t\t\t/>\n\t\t\t\t\t<EndDateWrapper>\n\t\t\t\t\t\t<DatePickerWrapper\n\t\t\t\t\t\t\tval={\n\t\t\t\t\t\t\t\tvalue?.endOnDate ? new Date(value.endOnDate * 1000) : undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={endMode !== RECURRENCE_END_MODE.ON_DATE}\n\t\t\t\t\t\t\tonChange={(picked: Date | Date[]) => {\n\t\t\t\t\t\t\t\tconst dateValue = Array.isArray(picked) ? picked[0] : picked;\n\t\t\t\t\t\t\t\tif (!dateValue) return;\n\t\t\t\t\t\t\t\t// End of the chosen day, so a run landing that day still fires.\n\t\t\t\t\t\t\t\tconst endOfDay = new Date(dateValue);\n\t\t\t\t\t\t\t\tendOfDay.setHours(23, 59, 59, 0);\n\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\tendMode: RECURRENCE_END_MODE.ON_DATE,\n\t\t\t\t\t\t\t\t\tendOnDate: Math.floor(endOfDay.getTime() / 1000),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tcalendarProps={{ minDate: minEndDate }}\n\t\t\t\t\t\t\tpickerStyles={{ top: 8, zIndex: 4 }}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</EndDateWrapper>\n\t\t\t\t</Row>\n\t\t\t</EndsRow>\n\t\t</FieldColumn>\n\t);\n};\n"],"names":["RADIO_ACTIVE_COLOR","COLORS","ScheduleEndPicker","value","onChange","minEndDate","dataTest","endMode","RECURRENCE_END_MODE","jsxs","FieldColumn","jsx","FieldLabel","BodySecondary","EndsRow","RadioButton","Row","RunCountInputWrapper","Input","MAX_RECURRENCE_RUNS","input","digitsOnly","EndDateWrapper","DatePickerWrapper","picked","dateValue","endOfDay"],"mappings":";;;;;;;;;AAqBA,MAAMA,IAAqBC,EAAO,WAAW,cAiBhCC,IAAsD,CAAC;AAAA,EACnE,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAaC;AACd,MAAM;AACL,QAAMC,IAAUJ,GAAO,WAAWK,EAAoB;AAEtD,SACC,gBAAAC,EAACC,GAAA,EAAY,aAAWJ,GACvB,UAAA;AAAA,IAAA,gBAAAK,EAACC,GAAA,EACA,4BAACC,GAAA,EAAc,OAAOZ,EAAO,QAAQ,SAAS,kBAAI,EAAA,CACnD;AAAA,sBACCa,GAAA,EACA,UAAA;AAAA,MAAA,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACA,UAAUR,MAAYC,EAAoB;AAAA,UAC1C,OAAM;AAAA,UACN,OAAOA,EAAoB;AAAA,UAC3B,eAAe,MAAMJ,EAAS,EAAE,SAASI,EAAoB,OAAO;AAAA,UACpE,aAAaR;AAAA,UAGb,kBAAkBO,MAAY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D,aAAaR;AAAA,YACb,kBAAkBO,MAAYC,EAAoB;AAAA,UAAA;AAAA,QAAA;AAAA,0BAElDc,GAAA,EACA,UAAA,gBAAAX;AAAA,UAACY;AAAA,UAAA;AAAA,YACA,KACCpB,GAAO,YAAY,IAAI,KAAKA,EAAM,YAAY,GAAI,IAAI;AAAA,YAEvD,UAAUI,MAAYC,EAAoB;AAAA,YAC1C,UAAU,CAACgB,MAA0B;AACpC,oBAAMC,IAAY,MAAM,QAAQD,CAAM,IAAIA,EAAO,CAAC,IAAIA;AACtD,kBAAI,CAACC,EAAW;AAEhB,oBAAMC,IAAW,IAAI,KAAKD,CAAS;AACnC,cAAAC,EAAS,SAAS,IAAI,IAAI,IAAI,CAAC,GAC/BtB,EAAS;AAAA,gBACR,SAASI,EAAoB;AAAA,gBAC7B,WAAW,KAAK,MAAMkB,EAAS,QAAA,IAAY,GAAI;AAAA,cAAA,CAC/C;AAAA,YACF;AAAA,YACA,eAAe,EAAE,SAASrB,EAAA;AAAA,YAC1B,cAAc,EAAE,KAAK,GAAG,QAAQ,EAAA;AAAA,UAAE;AAAA,QAAA,EACnC,CACD;AAAA,MAAA,EAAA,CACD;AAAA,IAAA,EAAA,CACD;AAAA,EAAA,GACD;AAEF;"}
@@ -1,21 +0,0 @@
1
- import { default as React } from 'react';
2
- import { RecurrenceValue } from './model';
3
- export interface ScheduleFrequencyPickerProps {
4
- value: RecurrenceValue;
5
- onChange: (patch: Partial<RecurrenceValue>) => void;
6
- /**
7
- * Width of the frequency menu. Defaults to matching its button — pass a
8
- * measured width when the button sits in a narrow column and the menu should
9
- * still be readable.
10
- */
11
- frequencyMenuWidth?: string;
12
- 'data-test'?: string;
13
- }
14
- /**
15
- * Frequency, plus whichever "Repeat on" picker that frequency needs.
16
- *
17
- * Daily needs no picker, weekly needs day chips, monthly needs a preset dropdown
18
- * and — for Custom — the 1-31 date grid. All three live here so a caller does not
19
- * have to know which control belongs to which frequency.
20
- */
21
- export declare const ScheduleFrequencyPicker: React.FC<ScheduleFrequencyPickerProps>;
@@ -1,136 +0,0 @@
1
- import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
- import { COLORS as o } from "../../constants/Theme.js";
3
- import y from "../../icons/Informational/General/Info.js";
4
- import { ChipSelectorGroup as O } from "../chip-selector/ChipSelectorGroup.js";
5
- import { BodySecondary as a, BodyCaption as u } from "../TypographyStyle.js";
6
- import { RECURRENCE_FREQUENCY as c, MONTHLY_REPEAT_OPTION as h } from "./model.js";
7
- import { Column as g, FieldsRow as A, DateFieldColumn as C, FieldLabel as s, FrequencyDropdownSlot as M, FieldColumn as b, CaptionWithIcon as m, Row as W, MonthDateGridSlot as N } from "./ScheduleBuilder.styled.js";
8
- import { ScheduleHelper as P, getSkippedMonthCaption as Y, LAST_DAY_CHIP_VALUE as R, DAY_CHIP_OPTIONS as k, CHIP_WIDTH as v, DATE_CHIP_OPTIONS as w } from "./ScheduleHelper.js";
9
- import { Dropdown as T } from "../dropdown/Dropdown.js";
10
- const E = [
11
- { label: "Daily", value: c.DAILY },
12
- { label: "Weekly", value: c.WEEKLY },
13
- { label: "Monthly", value: c.MONTHLY }
14
- ], H = [
15
- { label: "First", value: h.FIRST },
16
- { label: "Last", value: h.LAST },
17
- { label: "Custom", value: h.CUSTOM }
18
- ], Q = ({ value: l, onChange: d, frequencyMenuWidth: L, "data-test": D }) => {
19
- const i = new P(l), f = i.frequency === c.WEEKLY, p = i.frequency === c.MONTHLY, I = p && l?.monthlyRepeatOption === h.CUSTOM, S = Y(l?.datesOfMonth), _ = [
20
- ...l?.datesOfMonth ?? [],
21
- ...l?.lastDaySelected ? [R] : []
22
- ];
23
- return /* @__PURE__ */ n(g, { gap: 12, "data-test": D, children: [
24
- /* @__PURE__ */ n(A, { children: [
25
- /* @__PURE__ */ n(C, { children: [
26
- /* @__PURE__ */ e(s, { children: /* @__PURE__ */ e(a, { color: o.content.primary, children: "Select frequency" }) }),
27
- /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(
28
- T,
29
- {
30
- size: "default",
31
- isSearchable: !1,
32
- isMultiSelect: !1,
33
- options: E,
34
- buttonWidth: "100%",
35
- width: L || "100%",
36
- placeHolderHeight: "48px",
37
- placeHolder: "Select frequency",
38
- value: E.find(
39
- (t) => t.value === i.frequency
40
- )?.label,
41
- onSelect: (t) => {
42
- const r = Array.isArray(t) ? t[0] : t;
43
- r?.value && d({
44
- frequency: r.value
45
- });
46
- }
47
- }
48
- ) })
49
- ] }),
50
- !f && !p && /* @__PURE__ */ e(C, { "aria-hidden": !0 }),
51
- f && /* @__PURE__ */ n(b, { children: [
52
- /* @__PURE__ */ e(s, { children: /* @__PURE__ */ e(a, { color: o.content.primary, children: "Repeat on" }) }),
53
- /* @__PURE__ */ e(
54
- O,
55
- {
56
- "data-test": "recurrence-days-of-week",
57
- ariaLabel: "Repeat on",
58
- chipWidth: v,
59
- options: k,
60
- value: l?.daysOfWeek ?? [],
61
- onChange: (t) => d({
62
- daysOfWeek: t.filter(
63
- (r) => typeof r == "number"
64
- )
65
- })
66
- }
67
- ),
68
- i.isMissingWeeklyDays && /* @__PURE__ */ n(m, { children: [
69
- /* @__PURE__ */ e(y, { size: 16, color: o.content.negative }),
70
- /* @__PURE__ */ e(u, { color: o.content.negative, children: "Select day(s) above to send this weekly recurring" })
71
- ] })
72
- ] }),
73
- p && /* @__PURE__ */ n(b, { children: [
74
- /* @__PURE__ */ e(s, { children: /* @__PURE__ */ e(a, { color: o.content.primary, children: "Repeat every" }) }),
75
- /* @__PURE__ */ n(W, { gap: 8, children: [
76
- /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(
77
- T,
78
- {
79
- size: "default",
80
- isSearchable: !1,
81
- isMultiSelect: !1,
82
- options: H,
83
- buttonWidth: "100%",
84
- width: "220px",
85
- placeHolderHeight: "48px",
86
- placeHolder: "Select",
87
- value: H.find(
88
- (t) => t.value === l?.monthlyRepeatOption
89
- )?.label,
90
- onSelect: (t) => {
91
- const r = Array.isArray(t) ? t[0] : t;
92
- r?.value && d({
93
- monthlyRepeatOption: r.value
94
- });
95
- }
96
- }
97
- ) }),
98
- /* @__PURE__ */ e(a, { color: o.content.primary, children: "day of the month" })
99
- ] })
100
- ] })
101
- ] }),
102
- I && /* @__PURE__ */ n(N, { children: [
103
- /* @__PURE__ */ e(s, { children: /* @__PURE__ */ e(a, { color: o.content.primary, children: "Repeat on" }) }),
104
- /* @__PURE__ */ e(
105
- O,
106
- {
107
- "data-test": "recurrence-dates-of-month",
108
- ariaLabel: "Repeat on dates",
109
- chipWidth: v,
110
- options: w,
111
- size: "small",
112
- wrap: !0,
113
- value: _,
114
- onChange: (t) => d({
115
- datesOfMonth: t.filter(
116
- (r) => typeof r == "number"
117
- ),
118
- lastDaySelected: t.includes(R)
119
- })
120
- }
121
- ),
122
- !!S && /* @__PURE__ */ n(m, { children: [
123
- /* @__PURE__ */ e(y, { size: 16, color: o.content.secondary }),
124
- /* @__PURE__ */ e(u, { color: o.content.secondary, children: S })
125
- ] }),
126
- i.isMissingMonthlyDates && /* @__PURE__ */ n(m, { children: [
127
- /* @__PURE__ */ e(y, { size: 16, color: o.content.negative }),
128
- /* @__PURE__ */ e(u, { color: o.content.negative, children: "Select day(s) above to send this monthly recurring" })
129
- ] })
130
- ] })
131
- ] });
132
- };
133
- export {
134
- Q as ScheduleFrequencyPicker
135
- };
136
- //# sourceMappingURL=ScheduleFrequencyPicker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScheduleFrequencyPicker.js","sources":["../../../../src/components/schedule-builder/ScheduleFrequencyPicker.tsx"],"sourcesContent":["import React from 'react';\nimport { COLORS } from '../../constants/Theme';\nimport Info from '../../icons/Informational/General/Info';\nimport { ChipSelectorGroup } from '../chip-selector';\nimport { Dropdown, DropdownOption, SingleOption } from '../dropdown';\nimport { BodyCaption, BodySecondary } from '../TypographyStyle';\nimport {\n\tMONTHLY_REPEAT_OPTION,\n\tRECURRENCE_FREQUENCY,\n\tRecurrenceValue,\n} from './model';\nimport {\n\tCaptionWithIcon,\n\tColumn,\n\tDateFieldColumn,\n\tFieldColumn,\n\tFieldLabel,\n\tFieldsRow,\n\tFrequencyDropdownSlot,\n\tMonthDateGridSlot,\n\tRow,\n} from './ScheduleBuilder.styled';\nimport {\n\tCHIP_WIDTH,\n\tDATE_CHIP_OPTIONS,\n\tDAY_CHIP_OPTIONS,\n\tgetSkippedMonthCaption,\n\tLAST_DAY_CHIP_VALUE,\n\tScheduleHelper,\n} from './ScheduleHelper';\n\nconst FREQUENCY_OPTIONS: SingleOption[] = [\n\t{ label: 'Daily', value: RECURRENCE_FREQUENCY.DAILY },\n\t{ label: 'Weekly', value: RECURRENCE_FREQUENCY.WEEKLY },\n\t{ label: 'Monthly', value: RECURRENCE_FREQUENCY.MONTHLY },\n];\n\n/** \"Repeat every\" presets for a monthly recurrence. */\nconst MONTHLY_REPEAT_OPTIONS: SingleOption[] = [\n\t{ label: 'First', value: MONTHLY_REPEAT_OPTION.FIRST },\n\t{ label: 'Last', value: MONTHLY_REPEAT_OPTION.LAST },\n\t{ label: 'Custom', value: MONTHLY_REPEAT_OPTION.CUSTOM },\n];\n\nexport interface ScheduleFrequencyPickerProps {\n\tvalue: RecurrenceValue;\n\tonChange: (patch: Partial<RecurrenceValue>) => void;\n\t/**\n\t * Width of the frequency menu. Defaults to matching its button — pass a\n\t * measured width when the button sits in a narrow column and the menu should\n\t * still be readable.\n\t */\n\tfrequencyMenuWidth?: string;\n\t'data-test'?: string;\n}\n\n/**\n * Frequency, plus whichever \"Repeat on\" picker that frequency needs.\n *\n * Daily needs no picker, weekly needs day chips, monthly needs a preset dropdown\n * and — for Custom — the 1-31 date grid. All three live here so a caller does not\n * have to know which control belongs to which frequency.\n */\nexport const ScheduleFrequencyPicker: React.FC<\n\tScheduleFrequencyPickerProps\n> = ({ value, onChange, frequencyMenuWidth, 'data-test': dataTest }) => {\n\tconst helper = new ScheduleHelper(value);\n\tconst isWeekly = helper.frequency === RECURRENCE_FREQUENCY.WEEKLY;\n\tconst isMonthly = helper.frequency === RECURRENCE_FREQUENCY.MONTHLY;\n\tconst isCustomMonthly =\n\t\tisMonthly && value?.monthlyRepeatOption === MONTHLY_REPEAT_OPTION.CUSTOM;\n\n\tconst skippedMonthCaption = getSkippedMonthCaption(value?.datesOfMonth);\n\n\t/** The last-day sentinel rides alongside the numeric dates in one chip group. */\n\tconst monthlyChipValue: (string | number)[] = [\n\t\t...(value?.datesOfMonth ?? []),\n\t\t...(value?.lastDaySelected ? [LAST_DAY_CHIP_VALUE] : []),\n\t];\n\n\treturn (\n\t\t<Column gap={12} data-test={dataTest}>\n\t\t\t<FieldsRow>\n\t\t\t\t{/*\n Same flex share as the Start date column above it, per the design\n where both fields are 337px halves of the 690px row.\n */}\n\t\t\t\t<DateFieldColumn>\n\t\t\t\t\t<FieldLabel>\n\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\tSelect frequency\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</FieldLabel>\n\t\t\t\t\t<FrequencyDropdownSlot>\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tsize=\"default\"\n\t\t\t\t\t\t\tisSearchable={false}\n\t\t\t\t\t\t\tisMultiSelect={false}\n\t\t\t\t\t\t\toptions={FREQUENCY_OPTIONS}\n\t\t\t\t\t\t\tbuttonWidth=\"100%\"\n\t\t\t\t\t\t\twidth={frequencyMenuWidth || '100%'}\n\t\t\t\t\t\t\tplaceHolderHeight=\"48px\"\n\t\t\t\t\t\t\tplaceHolder=\"Select frequency\"\n\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\tFREQUENCY_OPTIONS.find(\n\t\t\t\t\t\t\t\t\t(option) => option.value === helper.frequency,\n\t\t\t\t\t\t\t\t)?.label\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonSelect={(\n\t\t\t\t\t\t\t\tselected: DropdownOption | DropdownOption[] | null,\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tconst normalized = (\n\t\t\t\t\t\t\t\t\tArray.isArray(selected) ? selected[0] : selected\n\t\t\t\t\t\t\t\t) as SingleOption | null;\n\t\t\t\t\t\t\t\tif (!normalized?.value) return;\n\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\tfrequency: normalized.value as RECURRENCE_FREQUENCY,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FrequencyDropdownSlot>\n\t\t\t\t</DateFieldColumn>\n\t\t\t\t{/*\n Holds the other half of the row when no picker follows, so the\n frequency field stays the same width as Start date instead of\n stretching across the whole row.\n */}\n\t\t\t\t{!isWeekly && !isMonthly && <DateFieldColumn aria-hidden />}\n\t\t\t\t{isWeekly && (\n\t\t\t\t\t<FieldColumn>\n\t\t\t\t\t\t<FieldLabel>\n\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tRepeat on\n\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t</FieldLabel>\n\t\t\t\t\t\t<ChipSelectorGroup\n\t\t\t\t\t\t\tdata-test=\"recurrence-days-of-week\"\n\t\t\t\t\t\t\tariaLabel=\"Repeat on\"\n\t\t\t\t\t\t\tchipWidth={CHIP_WIDTH}\n\t\t\t\t\t\t\toptions={DAY_CHIP_OPTIONS}\n\t\t\t\t\t\t\tvalue={value?.daysOfWeek ?? []}\n\t\t\t\t\t\t\tonChange={(days) =>\n\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\tdaysOfWeek: days.filter(\n\t\t\t\t\t\t\t\t\t\t(day): day is number => typeof day === 'number',\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{helper.isMissingWeeklyDays && (\n\t\t\t\t\t\t\t<CaptionWithIcon>\n\t\t\t\t\t\t\t\t<Info size={16} color={COLORS.content.negative} />\n\t\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.negative}>\n\t\t\t\t\t\t\t\t\tSelect day(s) above to send this weekly recurring\n\t\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t</CaptionWithIcon>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</FieldColumn>\n\t\t\t\t)}\n\t\t\t\t{isMonthly && (\n\t\t\t\t\t<FieldColumn>\n\t\t\t\t\t\t<FieldLabel>\n\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tRepeat every\n\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t</FieldLabel>\n\t\t\t\t\t\t<Row gap={8}>\n\t\t\t\t\t\t\t<FrequencyDropdownSlot>\n\t\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\t\tsize=\"default\"\n\t\t\t\t\t\t\t\t\tisSearchable={false}\n\t\t\t\t\t\t\t\t\tisMultiSelect={false}\n\t\t\t\t\t\t\t\t\toptions={MONTHLY_REPEAT_OPTIONS}\n\t\t\t\t\t\t\t\t\tbuttonWidth=\"100%\"\n\t\t\t\t\t\t\t\t\twidth=\"220px\"\n\t\t\t\t\t\t\t\t\tplaceHolderHeight=\"48px\"\n\t\t\t\t\t\t\t\t\tplaceHolder=\"Select\"\n\t\t\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\t\t\tMONTHLY_REPEAT_OPTIONS.find(\n\t\t\t\t\t\t\t\t\t\t\t(option) => option.value === value?.monthlyRepeatOption,\n\t\t\t\t\t\t\t\t\t\t)?.label\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonSelect={(\n\t\t\t\t\t\t\t\t\t\tselected: DropdownOption | DropdownOption[] | null,\n\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\tconst normalized = (\n\t\t\t\t\t\t\t\t\t\t\tArray.isArray(selected) ? selected[0] : selected\n\t\t\t\t\t\t\t\t\t\t) as SingleOption | null;\n\t\t\t\t\t\t\t\t\t\tif (!normalized?.value) return;\n\t\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t\tmonthlyRepeatOption:\n\t\t\t\t\t\t\t\t\t\t\t\tnormalized.value as MONTHLY_REPEAT_OPTION,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FrequencyDropdownSlot>\n\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tday of the month\n\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t</Row>\n\t\t\t\t\t</FieldColumn>\n\t\t\t\t)}\n\t\t\t</FieldsRow>\n\n\t\t\t{isCustomMonthly && (\n\t\t\t\t<MonthDateGridSlot>\n\t\t\t\t\t<FieldLabel>\n\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\tRepeat on\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</FieldLabel>\n\t\t\t\t\t<ChipSelectorGroup\n\t\t\t\t\t\tdata-test=\"recurrence-dates-of-month\"\n\t\t\t\t\t\tariaLabel=\"Repeat on dates\"\n\t\t\t\t\t\tchipWidth={CHIP_WIDTH}\n\t\t\t\t\t\toptions={DATE_CHIP_OPTIONS}\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\twrap\n\t\t\t\t\t\tvalue={monthlyChipValue}\n\t\t\t\t\t\tonChange={(selected) =>\n\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\tdatesOfMonth: selected.filter(\n\t\t\t\t\t\t\t\t\t(item): item is number => typeof item === 'number',\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tlastDaySelected: selected.includes(LAST_DAY_CHIP_VALUE),\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t{!!skippedMonthCaption && (\n\t\t\t\t\t\t<CaptionWithIcon>\n\t\t\t\t\t\t\t<Info size={16} color={COLORS.content.secondary} />\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t{skippedMonthCaption}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t</CaptionWithIcon>\n\t\t\t\t\t)}\n\t\t\t\t\t{helper.isMissingMonthlyDates && (\n\t\t\t\t\t\t<CaptionWithIcon>\n\t\t\t\t\t\t\t<Info size={16} color={COLORS.content.negative} />\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.negative}>\n\t\t\t\t\t\t\t\tSelect day(s) above to send this monthly recurring\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t</CaptionWithIcon>\n\t\t\t\t\t)}\n\t\t\t\t</MonthDateGridSlot>\n\t\t\t)}\n\t\t</Column>\n\t);\n};\n"],"names":["FREQUENCY_OPTIONS","RECURRENCE_FREQUENCY","MONTHLY_REPEAT_OPTIONS","MONTHLY_REPEAT_OPTION","ScheduleFrequencyPicker","value","onChange","frequencyMenuWidth","dataTest","helper","ScheduleHelper","isWeekly","isMonthly","isCustomMonthly","skippedMonthCaption","getSkippedMonthCaption","monthlyChipValue","LAST_DAY_CHIP_VALUE","jsxs","Column","FieldsRow","DateFieldColumn","jsx","FieldLabel","BodySecondary","COLORS","FrequencyDropdownSlot","Dropdown","option","selected","normalized","FieldColumn","ChipSelectorGroup","CHIP_WIDTH","DAY_CHIP_OPTIONS","days","day","CaptionWithIcon","Info","BodyCaption","Row","MonthDateGridSlot","DATE_CHIP_OPTIONS","item"],"mappings":";;;;;;;;;AA+BA,MAAMA,IAAoC;AAAA,EACzC,EAAE,OAAO,SAAS,OAAOC,EAAqB,MAAA;AAAA,EAC9C,EAAE,OAAO,UAAU,OAAOA,EAAqB,OAAA;AAAA,EAC/C,EAAE,OAAO,WAAW,OAAOA,EAAqB,QAAA;AACjD,GAGMC,IAAyC;AA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UAAAX,EAAA,CACF;AAAA,MAAA,GACD;AAAA,MAEAL,EAAO,yBACP,gBAAAS,EAACmB,GAAA,EACA,UAAA;AAAA,QAAA,gBAAAf,EAACgB,KAAK,MAAM,IAAI,OAAOb,EAAO,QAAQ,UAAU;AAAA,0BAC/Cc,GAAA,EAAY,OAAOd,EAAO,QAAQ,UAAU,UAAA,qDAAA,CAE7C;AAAA,MAAA,EAAA,CACD;AAAA,IAAA,EAAA,CAEF;AAAA,EAAA,GAEF;AAEF;"}
@@ -1,110 +0,0 @@
1
- import { ChipOption } from '../chip-selector';
2
- import { RECURRENCE_END_MODE, RECURRENCE_FREQUENCY, RecurrenceSummary, RecurrenceValue } from './model';
3
- /** How many upcoming runs the preview shows by default. */
4
- export declare const UPCOMING_RUNS_PREVIEW_COUNT = 3;
5
- /** Upper bound on `endAfterRuns`, matching the 3-digit input in the design. */
6
- export declare const MAX_RECURRENCE_RUNS = 999;
7
- /**
8
- * Width of a single chip in the "Repeat on" pickers.
9
- *
10
- * Shared by the weekly day chips and the monthly date chips: both grids are
11
- * drawn to the same 44px square in the design, and the monthly grid's 337px
12
- * width assumes it, so the two cannot be sized independently.
13
- */
14
- export declare const CHIP_WIDTH = 44;
15
- /** Highest date the monthly grid offers. */
16
- export declare const MAX_DATE_OF_MONTH = 31;
17
- /** Sentinel chip value for "Last day of the month", which is not a date. */
18
- export declare const LAST_DAY_CHIP_VALUE = "LAST_DAY";
19
- /** Short day labels, indexed by JS day number (0 = Sunday). */
20
- export declare const DAY_LABELS: string[];
21
- /** Selecting all seven days is stored as DAILY rather than a full weekly set. */
22
- export declare const DAYS_IN_WEEK = 7;
23
- /**
24
- * Chips for the weekly "Repeat on" picker. Only the first letter is shown, so
25
- * each chip carries the full day name for screen readers — S, T and S repeat.
26
- */
27
- export declare const DAY_CHIP_OPTIONS: ChipOption[];
28
- /**
29
- * Chips for the monthly "Repeat on" grid — 1 to 31, then "Last day of the
30
- * month" as an independent option rather than an alias for the 31st.
31
- */
32
- export declare const DATE_CHIP_OPTIONS: ChipOption[];
33
- /**
34
- * "1st", "22nd", "13th" — the 11/12/13 exception is why this is not a plain
35
- * lookup on the last digit.
36
- */
37
- export declare const ordinal: (value: number) => string;
38
- /**
39
- * "Mon", "Mon and Tue", "Mon, Tue and Thu" — no Oxford comma, and always "and"
40
- * rather than "&". Shared by the weekly day names and the monthly ordinals.
41
- */
42
- export declare const joinList: (items: string[]) => string;
43
- /** Caption warning that a chosen date does not exist in every month. */
44
- export declare const getSkippedMonthCaption: (datesOfMonth: number[] | undefined) => string | null;
45
- /**
46
- * Works out when a recurring campaign actually runs.
47
- *
48
- * Kept free of React so the schedule preview and the eventual publish payload
49
- * can both read run dates from one place.
50
- */
51
- export declare class ScheduleHelper {
52
- private readonly recurrence;
53
- constructor(recurrence: RecurrenceValue | undefined);
54
- get frequency(): RECURRENCE_FREQUENCY;
55
- get endMode(): RECURRENCE_END_MODE;
56
- /** Days a weekly recurrence repeats on, as JS day indices. */
57
- get daysOfWeek(): number[];
58
- /** Dates a monthly recurrence repeats on (1–31). */
59
- get datesOfMonth(): number[];
60
- /** Whether a monthly recurrence also runs on the last day of every month. */
61
- get lastDaySelected(): boolean;
62
- /** A weekly recurrence cannot run until at least one day is picked. */
63
- get isMissingWeeklyDays(): boolean;
64
- /** A monthly recurrence needs at least one date, or the last-day option. */
65
- get isMissingMonthlyDates(): boolean;
66
- /** True when the current selection cannot produce any run dates. */
67
- get isMissingRunDays(): boolean;
68
- /**
69
- * Advances a date by one day.
70
- *
71
- * Every frequency walks day by day so `isRunDay` decides what counts. Monthly
72
- * cannot use `setMonth`: it rolls a 31st into the following month for shorter
73
- * months (31 Jan -> 3 Mar), whereas a missing date must skip that month
74
- * outright.
75
- */
76
- private addInterval;
77
- /** Last calendar date of the month the given date falls in. */
78
- private static lastDateOfMonth;
79
- /** Whether a candidate date is one the campaign actually runs on. */
80
- private isRunDay;
81
- /**
82
- * Next `limit` run dates from `startDate`, respecting the end rule.
83
- *
84
- * Returns fewer than `limit` when the recurrence ends first, which is what
85
- * lets the preview stop honestly instead of inventing runs.
86
- */
87
- computeUpcomingRuns(startDate: Date | null | undefined, limit?: number): Date[];
88
- /**
89
- * The days a weekly recurrence runs on, in Monday-first display order rather
90
- * than the Sunday-first order the chip values are indexed by.
91
- *
92
- * Mon–Fri exactly collapses to "weekday", Sat+Sun to "weekend". All seven is
93
- * not handled here — that is normalised to DAILY when the day is selected.
94
- */
95
- private get weeklyDayPhrase();
96
- private get monthlyDatePhrase();
97
- /**
98
- * The semibold phrase after "Repeats". Weekly and monthly name the days they
99
- * run on; daily is a plain adverb.
100
- */
101
- private get frequencyLabel();
102
- /** The text following the time, which differs per end mode. */
103
- private get endClause();
104
- /**
105
- * Summary shown under the upcoming runs, split so the frequency and time can
106
- * be rendered in semibold as the design shows:
107
- * "Repeats **daily** at **10:00 AM** with no end date, you can cancel anytime."
108
- */
109
- buildSummary(runs: Date[]): RecurrenceSummary | null;
110
- }
@@ -1,196 +0,0 @@
1
- import { format as d } from "date-fns";
2
- import { RECURRENCE_FREQUENCY as a, RECURRENCE_END_MODE as u, MONTHLY_REPEAT_OPTION as D } from "./model.js";
3
- const E = 3, m = 999, L = 44, g = 31, M = "LAST_DAY", O = 1600, y = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], C = 7, I = y.map(
4
- (t, e) => ({
5
- value: e,
6
- label: t.charAt(0),
7
- ariaLabel: t
8
- })
9
- ), Y = [
10
- ...Array.from({ length: g }, (t, e) => ({
11
- value: e + 1,
12
- label: String(e + 1)
13
- })),
14
- {
15
- value: M,
16
- label: "Last day of the month",
17
- fitContent: !0
18
- }
19
- ], _ = [1, 2, 3, 4, 5], N = [0, 6], R = [1, 2, 3, 4, 5, 6, 0], S = {
20
- 29: "Skipped most Februaries.",
21
- 30: "Skipped in February.",
22
- 31: "Skipped in months without a 31st (Apr, Jun, Sep, Nov)."
23
- }, A = (t) => {
24
- if ([11, 12, 13].includes(t % 100)) return `${t}th`;
25
- switch (t % 10) {
26
- case 1:
27
- return `${t}st`;
28
- case 2:
29
- return `${t}nd`;
30
- case 3:
31
- return `${t}rd`;
32
- default:
33
- return `${t}th`;
34
- }
35
- }, h = (t) => t.length <= 1 ? t[0] ?? "" : t.length === 2 ? `${t[0]} and ${t[1]}` : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`, k = (t) => {
36
- const e = (t ?? []).map((n) => S[n]).filter(Boolean);
37
- return e.length ? e.join(" ") : null;
38
- };
39
- class f {
40
- recurrence;
41
- constructor(e) {
42
- this.recurrence = e ?? {};
43
- }
44
- get frequency() {
45
- return this.recurrence.frequency ?? a.DAILY;
46
- }
47
- get endMode() {
48
- return this.recurrence.endMode ?? u.NEVER;
49
- }
50
- /** Days a weekly recurrence repeats on, as JS day indices. */
51
- get daysOfWeek() {
52
- return this.recurrence.daysOfWeek ?? [];
53
- }
54
- /** Dates a monthly recurrence repeats on (1–31). */
55
- get datesOfMonth() {
56
- return this.recurrence.datesOfMonth ?? [];
57
- }
58
- /** Whether a monthly recurrence also runs on the last day of every month. */
59
- get lastDaySelected() {
60
- return !!this.recurrence.lastDaySelected;
61
- }
62
- /** A weekly recurrence cannot run until at least one day is picked. */
63
- get isMissingWeeklyDays() {
64
- return this.frequency === a.WEEKLY && !this.daysOfWeek.length;
65
- }
66
- /** A monthly recurrence needs at least one date, or the last-day option. */
67
- get isMissingMonthlyDates() {
68
- return this.frequency === a.MONTHLY && !this.datesOfMonth.length && !this.lastDaySelected;
69
- }
70
- /** True when the current selection cannot produce any run dates. */
71
- get isMissingRunDays() {
72
- return this.isMissingWeeklyDays || this.isMissingMonthlyDates;
73
- }
74
- /**
75
- * Advances a date by one day.
76
- *
77
- * Every frequency walks day by day so `isRunDay` decides what counts. Monthly
78
- * cannot use `setMonth`: it rolls a 31st into the following month for shorter
79
- * months (31 Jan -> 3 Mar), whereas a missing date must skip that month
80
- * outright.
81
- */
82
- addInterval(e) {
83
- const n = new Date(e);
84
- return n.setDate(n.getDate() + 1), n;
85
- }
86
- /** Last calendar date of the month the given date falls in. */
87
- static lastDateOfMonth(e) {
88
- return new Date(e.getFullYear(), e.getMonth() + 1, 0).getDate();
89
- }
90
- /** Whether a candidate date is one the campaign actually runs on. */
91
- isRunDay(e) {
92
- if (this.frequency === a.WEEKLY)
93
- return this.daysOfWeek.includes(e.getDay());
94
- if (this.frequency === a.MONTHLY) {
95
- const n = e.getDate();
96
- return this.datesOfMonth.includes(n) ? !0 : this.lastDaySelected && n === f.lastDateOfMonth(e);
97
- }
98
- return !0;
99
- }
100
- /**
101
- * Next `limit` run dates from `startDate`, respecting the end rule.
102
- *
103
- * Returns fewer than `limit` when the recurrence ends first, which is what
104
- * lets the preview stop honestly instead of inventing runs.
105
- */
106
- computeUpcomingRuns(e, n = E) {
107
- if (!e || Number.isNaN(e.getTime())) return [];
108
- if (this.isMissingRunDays) return [];
109
- const s = [], { endAfterRuns: r } = this.recurrence, c = this.endMode === u.AFTER_RUNS && typeof r == "number" && r > 0 ? Math.min(r, n) : n, o = this.endMode === u.ON_DATE && this.recurrence.endOnDate ? this.recurrence.endOnDate * 1e3 : null;
110
- let i = new Date(e), l = 0;
111
- for (; s.length < c && l <= O && !(o !== null && i.getTime() > o); )
112
- this.isRunDay(i) && s.push(new Date(i)), i = this.addInterval(i), l += 1;
113
- return s;
114
- }
115
- /**
116
- * The days a weekly recurrence runs on, in Monday-first display order rather
117
- * than the Sunday-first order the chip values are indexed by.
118
- *
119
- * Mon–Fri exactly collapses to "weekday", Sat+Sun to "weekend". All seven is
120
- * not handled here — that is normalised to DAILY when the day is selected.
121
- */
122
- get weeklyDayPhrase() {
123
- const e = this.daysOfWeek;
124
- if (!e.length) return "";
125
- const n = (r) => e.length === r.length && r.every((c) => e.includes(c));
126
- if (n(_)) return "weekday";
127
- if (n(N)) return "weekend";
128
- const s = R.filter((r) => e.includes(r)).map(
129
- (r) => y[r]
130
- );
131
- return h(s);
132
- }
133
- get monthlyDatePhrase() {
134
- if (this.recurrence?.monthlyRepeatOption === D.FIRST)
135
- return "on the first day";
136
- const e = [...this.datesOfMonth].sort((n, s) => n - s).map(A);
137
- return this.lastDaySelected ? e.length ? `on the ${h([...e, "the last day"])}` : "on the last day" : e.length ? `on the ${h(e)}` : "";
138
- }
139
- /**
140
- * The semibold phrase after "Repeats". Weekly and monthly name the days they
141
- * run on; daily is a plain adverb.
142
- */
143
- get frequencyLabel() {
144
- switch (this.frequency) {
145
- case a.WEEKLY: {
146
- const e = this.weeklyDayPhrase;
147
- return e ? `every ${e}` : "weekly";
148
- }
149
- case a.MONTHLY: {
150
- const e = this.monthlyDatePhrase;
151
- return e ? `${e} of every month` : "monthly";
152
- }
153
- default:
154
- return "daily";
155
- }
156
- }
157
- /** The text following the time, which differs per end mode. */
158
- get endClause() {
159
- if (this.endMode === u.AFTER_RUNS) {
160
- const e = this.recurrence.endAfterRuns;
161
- return e ? ` and ends after ${e} ${e === 1 ? "run" : "runs"}.` : ".";
162
- }
163
- return this.endMode === u.ON_DATE ? this.recurrence.endOnDate ? ` and ends on ${d(
164
- new Date(this.recurrence.endOnDate * 1e3),
165
- "d MMM yyyy"
166
- )}.` : "." : " with no end date, you can cancel anytime.";
167
- }
168
- /**
169
- * Summary shown under the upcoming runs, split so the frequency and time can
170
- * be rendered in semibold as the design shows:
171
- * "Repeats **daily** at **10:00 AM** with no end date, you can cancel anytime."
172
- */
173
- buildSummary(e) {
174
- return e.length ? {
175
- frequencyLabel: this.frequencyLabel,
176
- timeLabel: d(e[0], "h:mm a"),
177
- tail: this.endClause
178
- } : null;
179
- }
180
- }
181
- export {
182
- L as CHIP_WIDTH,
183
- Y as DATE_CHIP_OPTIONS,
184
- C as DAYS_IN_WEEK,
185
- I as DAY_CHIP_OPTIONS,
186
- y as DAY_LABELS,
187
- M as LAST_DAY_CHIP_VALUE,
188
- g as MAX_DATE_OF_MONTH,
189
- m as MAX_RECURRENCE_RUNS,
190
- f as ScheduleHelper,
191
- E as UPCOMING_RUNS_PREVIEW_COUNT,
192
- k as getSkippedMonthCaption,
193
- h as joinList,
194
- A as ordinal
195
- };
196
- //# sourceMappingURL=ScheduleHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScheduleHelper.js","sources":["../../../../src/components/schedule-builder/ScheduleHelper.ts"],"sourcesContent":["import { format as formatDate } from 'date-fns';\nimport { ChipOption } from '../chip-selector';\nimport {\n\tMONTHLY_REPEAT_OPTION,\n\tRECURRENCE_END_MODE,\n\tRECURRENCE_FREQUENCY,\n\tRecurrenceSummary,\n\tRecurrenceValue,\n} from './model';\n\n/** How many upcoming runs the preview shows by default. */\nexport const UPCOMING_RUNS_PREVIEW_COUNT = 3;\n\n/** Upper bound on `endAfterRuns`, matching the 3-digit input in the design. */\nexport const MAX_RECURRENCE_RUNS = 999;\n\n/**\n * Width of a single chip in the \"Repeat on\" pickers.\n *\n * Shared by the weekly day chips and the monthly date chips: both grids are\n * drawn to the same 44px square in the design, and the monthly grid's 337px\n * width assumes it, so the two cannot be sized independently.\n */\nexport const CHIP_WIDTH = 44;\n\n/** Highest date the monthly grid offers. */\nexport const MAX_DATE_OF_MONTH = 31;\n\n/** Sentinel chip value for \"Last day of the month\", which is not a date. */\nexport const LAST_DAY_CHIP_VALUE = 'LAST_DAY';\n\n/**\n * Safety bound for the day-by-day walk.\n *\n * Sized for the worst realistic case rather than the common one: three runs on\n * the 29th starting just after February in a non-leap year waits out three\n * Februaries, so roughly four years of scanning. Weekly needs at most 7 days\n * per run.\n */\nconst MAX_DAYS_SCANNED = 1600;\n\n/** Short day labels, indexed by JS day number (0 = Sunday). */\nexport const DAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\n\n/** Selecting all seven days is stored as DAILY rather than a full weekly set. */\nexport const DAYS_IN_WEEK = 7;\n\n/**\n * Chips for the weekly \"Repeat on\" picker. Only the first letter is shown, so\n * each chip carries the full day name for screen readers — S, T and S repeat.\n */\nexport const DAY_CHIP_OPTIONS: ChipOption[] = DAY_LABELS.map(\n\t(label, dayIndex) => ({\n\t\tvalue: dayIndex,\n\t\tlabel: label.charAt(0),\n\t\tariaLabel: label,\n\t}),\n);\n\n/**\n * Chips for the monthly \"Repeat on\" grid — 1 to 31, then \"Last day of the\n * month\" as an independent option rather than an alias for the 31st.\n */\nexport const DATE_CHIP_OPTIONS: ChipOption[] = [\n\t...Array.from({ length: MAX_DATE_OF_MONTH }, (_, index) => ({\n\t\tvalue: index + 1,\n\t\tlabel: String(index + 1),\n\t})),\n\t{\n\t\tvalue: LAST_DAY_CHIP_VALUE,\n\t\tlabel: 'Last day of the month',\n\t\tfitContent: true,\n\t},\n];\n\n/** Mon–Fri, used to collapse a full working week into \"every weekday\". */\nconst WEEKDAY_INDICES = [1, 2, 3, 4, 5];\n\n/** Sat–Sun, collapsed into \"every weekend\". */\nconst WEEKEND_INDICES = [0, 6];\n\n/**\n * Weekly day order for the summary. Monday-first by design, which is not the\n * JS `getDay()` order the chips are indexed by (Sunday-first).\n */\nconst SUMMARY_DAY_ORDER = [1, 2, 3, 4, 5, 6, 0];\n\n/** Dates that do not exist in every month, with the months that skip them. */\nconst SKIPPED_MONTH_CAPTIONS: Record<number, string> = {\n\t29: 'Skipped most Februaries.',\n\t30: 'Skipped in February.',\n\t31: 'Skipped in months without a 31st (Apr, Jun, Sep, Nov).',\n};\n\n/**\n * \"1st\", \"22nd\", \"13th\" — the 11/12/13 exception is why this is not a plain\n * lookup on the last digit.\n */\nexport const ordinal = (value: number): string => {\n\tif ([11, 12, 13].includes(value % 100)) return `${value}th`;\n\n\tswitch (value % 10) {\n\t\tcase 1:\n\t\t\treturn `${value}st`;\n\t\tcase 2:\n\t\t\treturn `${value}nd`;\n\t\tcase 3:\n\t\t\treturn `${value}rd`;\n\t\tdefault:\n\t\t\treturn `${value}th`;\n\t}\n};\n\n/**\n * \"Mon\", \"Mon and Tue\", \"Mon, Tue and Thu\" — no Oxford comma, and always \"and\"\n * rather than \"&\". Shared by the weekly day names and the monthly ordinals.\n */\nexport const joinList = (items: string[]): string => {\n\tif (items.length <= 1) return items[0] ?? '';\n\tif (items.length === 2) return `${items[0]} and ${items[1]}`;\n\treturn `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`;\n};\n\n/** Caption warning that a chosen date does not exist in every month. */\nexport const getSkippedMonthCaption = (\n\tdatesOfMonth: number[] | undefined,\n): string | null => {\n\tconst captions = (datesOfMonth ?? [])\n\t\t.map((date) => SKIPPED_MONTH_CAPTIONS[date])\n\t\t.filter(Boolean);\n\treturn captions.length ? captions.join(' ') : null;\n};\n\n/**\n * Works out when a recurring campaign actually runs.\n *\n * Kept free of React so the schedule preview and the eventual publish payload\n * can both read run dates from one place.\n */\nexport class ScheduleHelper {\n\tprivate readonly recurrence: RecurrenceValue;\n\n\tconstructor(recurrence: RecurrenceValue | undefined) {\n\t\tthis.recurrence = recurrence ?? {};\n\t}\n\n\tget frequency(): RECURRENCE_FREQUENCY {\n\t\treturn this.recurrence.frequency ?? RECURRENCE_FREQUENCY.DAILY;\n\t}\n\n\tget endMode(): RECURRENCE_END_MODE {\n\t\treturn this.recurrence.endMode ?? RECURRENCE_END_MODE.NEVER;\n\t}\n\n\t/** Days a weekly recurrence repeats on, as JS day indices. */\n\tget daysOfWeek(): number[] {\n\t\treturn this.recurrence.daysOfWeek ?? [];\n\t}\n\n\t/** Dates a monthly recurrence repeats on (1–31). */\n\tget datesOfMonth(): number[] {\n\t\treturn this.recurrence.datesOfMonth ?? [];\n\t}\n\n\t/** Whether a monthly recurrence also runs on the last day of every month. */\n\tget lastDaySelected(): boolean {\n\t\treturn !!this.recurrence.lastDaySelected;\n\t}\n\n\t/** A weekly recurrence cannot run until at least one day is picked. */\n\tget isMissingWeeklyDays(): boolean {\n\t\treturn (\n\t\t\tthis.frequency === RECURRENCE_FREQUENCY.WEEKLY && !this.daysOfWeek.length\n\t\t);\n\t}\n\n\t/** A monthly recurrence needs at least one date, or the last-day option. */\n\tget isMissingMonthlyDates(): boolean {\n\t\treturn (\n\t\t\tthis.frequency === RECURRENCE_FREQUENCY.MONTHLY &&\n\t\t\t!this.datesOfMonth.length &&\n\t\t\t!this.lastDaySelected\n\t\t);\n\t}\n\n\t/** True when the current selection cannot produce any run dates. */\n\tget isMissingRunDays(): boolean {\n\t\treturn this.isMissingWeeklyDays || this.isMissingMonthlyDates;\n\t}\n\n\t/**\n\t * Advances a date by one day.\n\t *\n\t * Every frequency walks day by day so `isRunDay` decides what counts. Monthly\n\t * cannot use `setMonth`: it rolls a 31st into the following month for shorter\n\t * months (31 Jan -> 3 Mar), whereas a missing date must skip that month\n\t * outright.\n\t */\n\tprivate addInterval(date: Date): Date {\n\t\tconst next = new Date(date);\n\t\tnext.setDate(next.getDate() + 1);\n\t\treturn next;\n\t}\n\n\t/** Last calendar date of the month the given date falls in. */\n\tprivate static lastDateOfMonth(date: Date): number {\n\t\treturn new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();\n\t}\n\n\t/** Whether a candidate date is one the campaign actually runs on. */\n\tprivate isRunDay(date: Date): boolean {\n\t\tif (this.frequency === RECURRENCE_FREQUENCY.WEEKLY) {\n\t\t\treturn this.daysOfWeek.includes(date.getDay());\n\t\t}\n\n\t\tif (this.frequency === RECURRENCE_FREQUENCY.MONTHLY) {\n\t\t\tconst dayOfMonth = date.getDate();\n\t\t\tif (this.datesOfMonth.includes(dayOfMonth)) return true;\n\t\t\treturn (\n\t\t\t\tthis.lastDaySelected &&\n\t\t\t\tdayOfMonth === ScheduleHelper.lastDateOfMonth(date)\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Next `limit` run dates from `startDate`, respecting the end rule.\n\t *\n\t * Returns fewer than `limit` when the recurrence ends first, which is what\n\t * lets the preview stop honestly instead of inventing runs.\n\t */\n\tcomputeUpcomingRuns(\n\t\tstartDate: Date | null | undefined,\n\t\tlimit: number = UPCOMING_RUNS_PREVIEW_COUNT,\n\t): Date[] {\n\t\tif (!startDate || Number.isNaN(startDate.getTime())) return [];\n\t\t// Weekly with no day picked, or monthly with no date, has no run dates yet.\n\t\tif (this.isMissingRunDays) return [];\n\n\t\tconst runs: Date[] = [];\n\n\t\t// AFTER_RUNS counts the start date as run 1, so the cap includes it.\n\t\tconst { endAfterRuns } = this.recurrence;\n\t\tconst maxRuns =\n\t\t\tthis.endMode === RECURRENCE_END_MODE.AFTER_RUNS &&\n\t\t\ttypeof endAfterRuns === 'number' &&\n\t\t\tendAfterRuns > 0\n\t\t\t\t? Math.min(endAfterRuns, limit)\n\t\t\t\t: limit;\n\n\t\tconst endDateMs =\n\t\t\tthis.endMode === RECURRENCE_END_MODE.ON_DATE && this.recurrence.endOnDate\n\t\t\t\t? this.recurrence.endOnDate * 1000\n\t\t\t\t: null;\n\n\t\tlet cursor = new Date(startDate);\n\t\t// Weekly walks a day at a time and skips days that are not selected, so\n\t\t// bound the walk rather than trusting it to land on `maxRuns` matches.\n\t\tlet daysScanned = 0;\n\n\t\twhile (runs.length < maxRuns && daysScanned <= MAX_DAYS_SCANNED) {\n\t\t\tif (endDateMs !== null && cursor.getTime() > endDateMs) break;\n\t\t\tif (this.isRunDay(cursor)) runs.push(new Date(cursor));\n\t\t\tcursor = this.addInterval(cursor);\n\t\t\tdaysScanned += 1;\n\t\t}\n\n\t\treturn runs;\n\t}\n\n\t/**\n\t * The days a weekly recurrence runs on, in Monday-first display order rather\n\t * than the Sunday-first order the chip values are indexed by.\n\t *\n\t * Mon–Fri exactly collapses to \"weekday\", Sat+Sun to \"weekend\". All seven is\n\t * not handled here — that is normalised to DAILY when the day is selected.\n\t */\n\tprivate get weeklyDayPhrase(): string {\n\t\tconst days = this.daysOfWeek;\n\t\tif (!days.length) return '';\n\n\t\tconst matchesExactly = (indices: number[]) =>\n\t\t\tdays.length === indices.length &&\n\t\t\tindices.every((day) => days.includes(day));\n\n\t\tif (matchesExactly(WEEKDAY_INDICES)) return 'weekday';\n\t\tif (matchesExactly(WEEKEND_INDICES)) return 'weekend';\n\n\t\tconst labels = SUMMARY_DAY_ORDER.filter((day) => days.includes(day)).map(\n\t\t\t(day) => DAY_LABELS[day],\n\t\t);\n\t\treturn joinList(labels);\n\t}\n\n\tprivate get monthlyDatePhrase(): string {\n\t\tif (this.recurrence?.monthlyRepeatOption === MONTHLY_REPEAT_OPTION.FIRST) {\n\t\t\treturn 'on the first day';\n\t\t}\n\n\t\tconst ordinals = [...this.datesOfMonth]\n\t\t\t.sort((left, right) => left - right)\n\t\t\t.map(ordinal);\n\n\t\tif (!this.lastDaySelected) {\n\t\t\treturn ordinals.length ? `on the ${joinList(ordinals)}` : '';\n\t\t}\n\n\t\tif (!ordinals.length) return 'on the last day';\n\t\treturn `on the ${joinList([...ordinals, 'the last day'])}`;\n\t}\n\n\t/**\n\t * The semibold phrase after \"Repeats\". Weekly and monthly name the days they\n\t * run on; daily is a plain adverb.\n\t */\n\tprivate get frequencyLabel(): string {\n\t\tswitch (this.frequency) {\n\t\t\tcase RECURRENCE_FREQUENCY.WEEKLY: {\n\t\t\t\tconst phrase = this.weeklyDayPhrase;\n\t\t\t\treturn phrase ? `every ${phrase}` : 'weekly';\n\t\t\t}\n\t\t\tcase RECURRENCE_FREQUENCY.MONTHLY: {\n\t\t\t\tconst phrase = this.monthlyDatePhrase;\n\t\t\t\treturn phrase ? `${phrase} of every month` : 'monthly';\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn 'daily';\n\t\t}\n\t}\n\n\t/** The text following the time, which differs per end mode. */\n\tprivate get endClause(): string {\n\t\tif (this.endMode === RECURRENCE_END_MODE.AFTER_RUNS) {\n\t\t\tconst totalRuns = this.recurrence.endAfterRuns;\n\t\t\tif (!totalRuns) return '.';\n\t\t\treturn ` and ends after ${totalRuns} ${\n\t\t\t\ttotalRuns === 1 ? 'run' : 'runs'\n\t\t\t}.`;\n\t\t}\n\n\t\tif (this.endMode === RECURRENCE_END_MODE.ON_DATE) {\n\t\t\tif (!this.recurrence.endOnDate) return '.';\n\t\t\tconst endLabel = formatDate(\n\t\t\t\tnew Date(this.recurrence.endOnDate * 1000),\n\t\t\t\t'd MMM yyyy',\n\t\t\t);\n\t\t\treturn ` and ends on ${endLabel}.`;\n\t\t}\n\n\t\treturn ' with no end date, you can cancel anytime.';\n\t}\n\n\t/**\n\t * Summary shown under the upcoming runs, split so the frequency and time can\n\t * be rendered in semibold as the design shows:\n\t * \"Repeats **daily** at **10:00 AM** with no end date, you can cancel anytime.\"\n\t */\n\tbuildSummary(runs: Date[]): RecurrenceSummary | null {\n\t\tif (!runs.length) return null;\n\n\t\treturn {\n\t\t\tfrequencyLabel: this.frequencyLabel,\n\t\t\ttimeLabel: formatDate(runs[0], 'h:mm a'),\n\t\t\ttail: this.endClause,\n\t\t};\n\t}\n}\n"],"names":["UPCOMING_RUNS_PREVIEW_COUNT","MAX_RECURRENCE_RUNS","CHIP_WIDTH","MAX_DATE_OF_MONTH","LAST_DAY_CHIP_VALUE","MAX_DAYS_SCANNED","DAY_LABELS","DAYS_IN_WEEK","DAY_CHIP_OPTIONS","label","dayIndex","DATE_CHIP_OPTIONS","_","index","WEEKDAY_INDICES","WEEKEND_INDICES","SUMMARY_DAY_ORDER","SKIPPED_MONTH_CAPTIONS","ordinal","value","joinList","items","getSkippedMonthCaption","datesOfMonth","captions","date","ScheduleHelper","recurrence","RECURRENCE_FREQUENCY","RECURRENCE_END_MODE","next","dayOfMonth","startDate","limit","runs","endAfterRuns","maxRuns","endDateMs","cursor","daysScanned","days","matchesExactly","indices","day","labels","MONTHLY_REPEAT_OPTION","ordinals","left","right","phrase","totalRuns","formatDate"],"mappings":";;AAWO,MAAMA,IAA8B,GAG9BC,IAAsB,KAStBC,IAAa,IAGbC,IAAoB,IAGpBC,IAAsB,YAU7BC,IAAmB,MAGZC,IAAa,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,GAG7DC,IAAe,GAMfC,IAAiCF,EAAW;AAAA,EACxD,CAACG,GAAOC,OAAc;AAAA,IACrB,OAAOA;AAAA,IACP,OAAOD,EAA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A,MACzC;AAAA,IAAA,CAE8B,MALQ,MAQjC;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAajB,GAAwC;AACpD,WAAKA,EAAK,SAEH;AAAA,MACN,gBAAgB,KAAK;AAAA,MACrB,WAAWiB,EAAWjB,EAAK,CAAC,GAAG,QAAQ;AAAA,MACvC,MAAM,KAAK;AAAA,IAAA,IALa;AAAA,EAO1B;AACD;"}
@@ -1,29 +0,0 @@
1
- export interface SendModeItem<T extends string = string> {
2
- value: T;
3
- label: string;
4
- /**
5
- * Greys out this mode while leaving the others usable.
6
- *
7
- * Disabled rather than removed so the mode still reads as something the
8
- * product offers — a merchant who cannot use it here should see that it
9
- * exists, not wonder where it went.
10
- */
11
- disabled?: boolean;
12
- }
13
- export interface SendModeSelectorProps<T extends string = string> {
14
- options: SendModeItem<T>[];
15
- value?: T;
16
- onChange: (value: T) => void;
17
- disabled?: boolean;
18
- 'data-test'?: string;
19
- }
20
- /**
21
- * The row of "Send now / Schedule / Set as recurring" cards.
22
- *
23
- * The whole card is the hit target, not just the radio — the radio's own
24
- * `onValueChange` fires too, so both routes land on the same handler.
25
- *
26
- * Options are passed in rather than hardcoded: the modes a screen offers are its
27
- * own business, and a caller with only two of them should not get a dead third.
28
- */
29
- export declare const SendModeSelector: <T extends string = string>({ options, value, onChange, disabled, "data-test": dataTest, }: SendModeSelectorProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,41 +0,0 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { COLORS as u } from "../../constants/Theme.js";
3
- import { SendModeRow as i, SendModeOption as c } from "./ScheduleBuilder.styled.js";
4
- import { RadioButton as v } from "../radioButton/RadioButton.js";
5
- const m = u.background.inverseLight, n = ({
6
- options: t,
7
- value: d,
8
- onChange: r,
9
- disabled: a = !1,
10
- "data-test": s
11
- }) => /* @__PURE__ */ l(i, { "data-test": s, children: t.map((e) => /* @__PURE__ */ l(
12
- c,
13
- {
14
- active: d === e.value,
15
- disabled: a || !!e.disabled,
16
- "data-test": `send-mode-${e.value}`,
17
- onClick: () => {
18
- a || e.disabled || r(e.value);
19
- },
20
- children: /* @__PURE__ */ l(
21
- v,
22
- {
23
- isActive: d === e.value,
24
- isDisabled: a || !!e.disabled,
25
- label: e.label,
26
- value: e.value,
27
- onValueChange: () => {
28
- a || e.disabled || r(e.value);
29
- },
30
- alwaysBold: !0,
31
- activeColor: m,
32
- skipSelectingOff: !0
33
- }
34
- )
35
- },
36
- e.value
37
- )) });
38
- export {
39
- n as SendModeSelector
40
- };
41
- //# sourceMappingURL=SendModeSelector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SendModeSelector.js","sources":["../../../../src/components/schedule-builder/SendModeSelector.tsx"],"sourcesContent":["import { COLORS } from '../../constants/Theme';\nimport { RadioButton } from '../radioButton';\nimport { SendModeOption, SendModeRow } from './ScheduleBuilder.styled';\n\n/** The purple of the selected radio, which is not the default brand colour. */\nconst RADIO_ACTIVE_COLOR = COLORS.background.inverseLight;\n\nexport interface SendModeItem<T extends string = string> {\n\tvalue: T;\n\tlabel: string;\n\t/**\n\t * Greys out this mode while leaving the others usable.\n\t *\n\t * Disabled rather than removed so the mode still reads as something the\n\t * product offers — a merchant who cannot use it here should see that it\n\t * exists, not wonder where it went.\n\t */\n\tdisabled?: boolean;\n}\n\nexport interface SendModeSelectorProps<T extends string = string> {\n\toptions: SendModeItem<T>[];\n\tvalue?: T;\n\tonChange: (value: T) => void;\n\tdisabled?: boolean;\n\t'data-test'?: string;\n}\n\n/**\n * The row of \"Send now / Schedule / Set as recurring\" cards.\n *\n * The whole card is the hit target, not just the radio — the radio's own\n * `onValueChange` fires too, so both routes land on the same handler.\n *\n * Options are passed in rather than hardcoded: the modes a screen offers are its\n * own business, and a caller with only two of them should not get a dead third.\n */\nexport const SendModeSelector = <T extends string = string>({\n\toptions,\n\tvalue,\n\tonChange,\n\tdisabled = false,\n\t'data-test': dataTest,\n}: SendModeSelectorProps<T>) => (\n\t<SendModeRow data-test={dataTest}>\n\t\t{options.map((option) => (\n\t\t\t<SendModeOption\n\t\t\t\tkey={option.value}\n\t\t\t\tactive={value === option.value}\n\t\t\t\tdisabled={disabled || !!option.disabled}\n\t\t\t\tdata-test={`send-mode-${option.value}`}\n\t\t\t\tonClick={() => {\n\t\t\t\t\tif (disabled || option.disabled) return;\n\t\t\t\t\tonChange(option.value);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<RadioButton\n\t\t\t\t\tisActive={value === option.value}\n\t\t\t\t\tisDisabled={disabled || !!option.disabled}\n\t\t\t\t\tlabel={option.label}\n\t\t\t\t\tvalue={option.value}\n\t\t\t\t\tonValueChange={() => {\n\t\t\t\t\t\tif (disabled || option.disabled) return;\n\t\t\t\t\t\tonChange(option.value);\n\t\t\t\t\t}}\n\t\t\t\t\talwaysBold\n\t\t\t\t\tactiveColor={RADIO_ACTIVE_COLOR}\n\t\t\t\t\tskipSelectingOff\n\t\t\t\t/>\n\t\t\t</SendModeOption>\n\t\t))}\n\t</SendModeRow>\n);\n"],"names":["RADIO_ACTIVE_COLOR","COLORS","SendModeSelector","options","value","onChange","disabled","dataTest","SendModeRow","option","jsx","SendModeOption","RadioButton"],"mappings":";;;;AAKA,MAAMA,IAAqBC,EAAO,WAAW,cAgChCC,IAAmB,CAA4B;AAAA,EAC3D,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,aAAaC;AACd,wBACEC,GAAA,EAAY,aAAWD,GACtB,UAAAJ,EAAQ,IAAI,CAACM,MACb,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IAEA,QAAQP,MAAUK,EAAO;AAAA,IACzB,UAAUH,KAAY,CAAC,CAACG,EAAO;AAAA,IAC/B,aAAW,aAAaA,EAAO,KAAK;AAAA,IACpC,SAAS,MAAM;AACd,MAAIH,KAAYG,EAAO,YACvBJ,EAASI,EAAO,KAAK;AAAA,IACtB;AAAA,IAEA,UAAA,gBAAAC;AAAA,MAACE;AAAA,MAAA;AAAA,QACA,UAAUR,MAAUK,EAAO;AAAA,QAC3B,YAAYH,KAAY,CAAC,CAACG,EAAO;AAAA,QACjC,OAAOA,EAAO;AAAA,QACd,OAAOA,EAAO;AAAA,QACd,eAAe,MAAM;AACpB,UAAIH,KAAYG,EAAO,YACvBJ,EAASI,EAAO,KAAK;AAAA,QACtB;AAAA,QACA,YAAU;AAAA,QACV,aAAaT;AAAA,QACb,kBAAgB;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB;AAAA,EArBKS,EAAO;AAsBb,CACA,EAAA,CACF;"}