@bikdotai/bik-component-library 0.0.867 → 0.0.868-beta.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 (91) hide show
  1. package/dist/cjs/components/chip-selector/ChipSelector.js +2 -0
  2. package/dist/cjs/components/chip-selector/ChipSelector.js.map +1 -0
  3. package/dist/cjs/components/chip-selector/ChipSelector.styled.js +36 -0
  4. package/dist/cjs/components/chip-selector/ChipSelector.styled.js.map +1 -0
  5. package/dist/cjs/components/chip-selector/ChipSelectorGroup.js +2 -0
  6. package/dist/cjs/components/chip-selector/ChipSelectorGroup.js.map +1 -0
  7. package/dist/cjs/components/combo-box/ComboBox.js +2 -0
  8. package/dist/cjs/components/combo-box/ComboBox.js.map +1 -0
  9. package/dist/cjs/components/combo-box/ComboBox.styled.js +33 -0
  10. package/dist/cjs/components/combo-box/ComboBox.styled.js.map +1 -0
  11. package/dist/cjs/components/datePicker/DatePickerWrapper.js +1 -1
  12. package/dist/cjs/components/datePicker/DatePickerWrapper.js.map +1 -1
  13. package/dist/cjs/components/schedule-builder/RefreshSegmentToggle.js +2 -0
  14. package/dist/cjs/components/schedule-builder/RefreshSegmentToggle.js.map +1 -0
  15. package/dist/cjs/components/schedule-builder/ScheduleBuilder.js +2 -0
  16. package/dist/cjs/components/schedule-builder/ScheduleBuilder.js.map +1 -0
  17. package/dist/cjs/components/schedule-builder/ScheduleBuilder.styled.js +138 -0
  18. package/dist/cjs/components/schedule-builder/ScheduleBuilder.styled.js.map +1 -0
  19. package/dist/cjs/components/schedule-builder/ScheduleEndPicker.js +2 -0
  20. package/dist/cjs/components/schedule-builder/ScheduleEndPicker.js.map +1 -0
  21. package/dist/cjs/components/schedule-builder/ScheduleFrequencyPicker.js +2 -0
  22. package/dist/cjs/components/schedule-builder/ScheduleFrequencyPicker.js.map +1 -0
  23. package/dist/cjs/components/schedule-builder/ScheduleHelper.js +2 -0
  24. package/dist/cjs/components/schedule-builder/ScheduleHelper.js.map +1 -0
  25. package/dist/cjs/components/schedule-builder/SendModeSelector.js +2 -0
  26. package/dist/cjs/components/schedule-builder/SendModeSelector.js.map +1 -0
  27. package/dist/cjs/components/schedule-builder/StartDateTimePicker.js +2 -0
  28. package/dist/cjs/components/schedule-builder/StartDateTimePicker.js.map +1 -0
  29. package/dist/cjs/components/schedule-builder/UpcomingRunsPreview.js +2 -0
  30. package/dist/cjs/components/schedule-builder/UpcomingRunsPreview.js.map +1 -0
  31. package/dist/cjs/components/schedule-builder/model.js +2 -0
  32. package/dist/cjs/components/schedule-builder/model.js.map +1 -0
  33. package/dist/cjs/index.js +1 -1
  34. package/dist/esm/components/chip-selector/ChipSelector.d.ts +9 -0
  35. package/dist/esm/components/chip-selector/ChipSelector.js +27 -0
  36. package/dist/esm/components/chip-selector/ChipSelector.js.map +1 -0
  37. package/dist/esm/components/chip-selector/ChipSelector.styled.d.ts +10 -0
  38. package/dist/esm/components/chip-selector/ChipSelector.styled.js +48 -0
  39. package/dist/esm/components/chip-selector/ChipSelector.styled.js.map +1 -0
  40. package/dist/esm/components/chip-selector/ChipSelectorGroup.d.ts +10 -0
  41. package/dist/esm/components/chip-selector/ChipSelectorGroup.js +48 -0
  42. package/dist/esm/components/chip-selector/ChipSelectorGroup.js.map +1 -0
  43. package/dist/esm/components/chip-selector/index.d.ts +4 -0
  44. package/dist/esm/components/chip-selector/model.d.ts +106 -0
  45. package/dist/esm/components/combo-box/ComboBox.d.ts +15 -0
  46. package/dist/esm/components/combo-box/ComboBox.js +118 -0
  47. package/dist/esm/components/combo-box/ComboBox.js.map +1 -0
  48. package/dist/esm/components/combo-box/ComboBox.styled.d.ts +12 -0
  49. package/dist/esm/components/combo-box/ComboBox.styled.js +40 -0
  50. package/dist/esm/components/combo-box/ComboBox.styled.js.map +1 -0
  51. package/dist/esm/components/combo-box/index.d.ts +3 -0
  52. package/dist/esm/components/combo-box/model.d.ts +55 -0
  53. package/dist/esm/components/datePicker/DatePickerWrapper.d.ts +7 -0
  54. package/dist/esm/components/datePicker/DatePickerWrapper.js +66 -64
  55. package/dist/esm/components/datePicker/DatePickerWrapper.js.map +1 -1
  56. package/dist/esm/components/datePicker/index.d.ts +1 -0
  57. package/dist/esm/components/schedule-builder/RefreshSegmentToggle.d.ts +22 -0
  58. package/dist/esm/components/schedule-builder/RefreshSegmentToggle.js +31 -0
  59. package/dist/esm/components/schedule-builder/RefreshSegmentToggle.js.map +1 -0
  60. package/dist/esm/components/schedule-builder/ScheduleBuilder.d.ts +88 -0
  61. package/dist/esm/components/schedule-builder/ScheduleBuilder.js +105 -0
  62. package/dist/esm/components/schedule-builder/ScheduleBuilder.js.map +1 -0
  63. package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.d.ts +81 -0
  64. package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.js +168 -0
  65. package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.js.map +1 -0
  66. package/dist/esm/components/schedule-builder/ScheduleEndPicker.d.ts +17 -0
  67. package/dist/esm/components/schedule-builder/ScheduleEndPicker.js +105 -0
  68. package/dist/esm/components/schedule-builder/ScheduleEndPicker.js.map +1 -0
  69. package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.d.ts +21 -0
  70. package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.js +136 -0
  71. package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.js.map +1 -0
  72. package/dist/esm/components/schedule-builder/ScheduleHelper.d.ts +110 -0
  73. package/dist/esm/components/schedule-builder/ScheduleHelper.js +196 -0
  74. package/dist/esm/components/schedule-builder/ScheduleHelper.js.map +1 -0
  75. package/dist/esm/components/schedule-builder/SendModeSelector.d.ts +29 -0
  76. package/dist/esm/components/schedule-builder/SendModeSelector.js +41 -0
  77. package/dist/esm/components/schedule-builder/SendModeSelector.js.map +1 -0
  78. package/dist/esm/components/schedule-builder/StartDateTimePicker.d.ts +44 -0
  79. package/dist/esm/components/schedule-builder/StartDateTimePicker.js +119 -0
  80. package/dist/esm/components/schedule-builder/StartDateTimePicker.js.map +1 -0
  81. package/dist/esm/components/schedule-builder/UpcomingRunsPreview.d.ts +19 -0
  82. package/dist/esm/components/schedule-builder/UpcomingRunsPreview.js +44 -0
  83. package/dist/esm/components/schedule-builder/UpcomingRunsPreview.js.map +1 -0
  84. package/dist/esm/components/schedule-builder/index.d.ts +17 -0
  85. package/dist/esm/components/schedule-builder/model.d.ts +69 -0
  86. package/dist/esm/components/schedule-builder/model.js +8 -0
  87. package/dist/esm/components/schedule-builder/model.js.map +1 -0
  88. package/dist/esm/index.d.ts +3 -0
  89. package/dist/esm/index.js +716 -675
  90. package/dist/esm/index.js.map +1 -1
  91. package/package.json +1 -1
@@ -0,0 +1,105 @@
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
+ import { COLORS as s } from "../../constants/Theme.js";
3
+ import { BodySecondary as R } from "../TypographyStyle.js";
4
+ import { RECURRENCE_END_MODE as e } from "./model.js";
5
+ import { FieldColumn as u, FieldLabel as N, EndsRow as O, Row as p, RunCountInputWrapper as D, EndDateWrapper as _ } from "./ScheduleBuilder.styled.js";
6
+ import { MAX_RECURRENCE_RUNS as m } from "./ScheduleHelper.js";
7
+ import { RadioButton as l } from "../radioButton/RadioButton.js";
8
+ import { Input as S } from "../input/Input.js";
9
+ import { DatePickerWrapper as h } from "../datePicker/DatePickerWrapper.js";
10
+ const c = s.background.inverseLight, F = ({
11
+ value: o,
12
+ onChange: t,
13
+ minEndDate: f,
14
+ "data-test": A
15
+ }) => {
16
+ const n = o?.endMode ?? e.NEVER;
17
+ return /* @__PURE__ */ a(u, { "data-test": A, children: [
18
+ /* @__PURE__ */ r(N, { children: /* @__PURE__ */ r(R, { color: s.content.primary, children: "Ends" }) }),
19
+ /* @__PURE__ */ a(O, { children: [
20
+ /* @__PURE__ */ r(
21
+ l,
22
+ {
23
+ isActive: n === e.NEVER,
24
+ label: "Never",
25
+ value: e.NEVER,
26
+ onValueChange: () => t({ endMode: e.NEVER }),
27
+ activeColor: c,
28
+ skipSelectingOff: n === e.NEVER
29
+ }
30
+ ),
31
+ /* @__PURE__ */ a(p, { gap: 8, children: [
32
+ /* @__PURE__ */ r(
33
+ l,
34
+ {
35
+ isActive: n === e.AFTER_RUNS,
36
+ label: "After",
37
+ value: e.AFTER_RUNS,
38
+ onValueChange: () => t({ endMode: e.AFTER_RUNS }),
39
+ activeColor: c,
40
+ skipSelectingOff: n === e.AFTER_RUNS
41
+ }
42
+ ),
43
+ /* @__PURE__ */ r(D, { children: /* @__PURE__ */ r(
44
+ S,
45
+ {
46
+ variant: "small",
47
+ type: "number",
48
+ placeholder: String(m),
49
+ value: o?.endAfterRuns ? String(o.endAfterRuns) : "",
50
+ state: n === e.AFTER_RUNS ? "none" : "disabled",
51
+ onChangeText: (i) => {
52
+ const d = i.replace(/\D/g, "");
53
+ if (!d) {
54
+ t({ endAfterRuns: void 0 });
55
+ return;
56
+ }
57
+ t({
58
+ endAfterRuns: Math.min(
59
+ Number(d),
60
+ m
61
+ )
62
+ });
63
+ }
64
+ }
65
+ ) }),
66
+ /* @__PURE__ */ r(R, { color: s.content.primary, children: "runs" })
67
+ ] }),
68
+ /* @__PURE__ */ a(p, { gap: 8, children: [
69
+ /* @__PURE__ */ r(
70
+ l,
71
+ {
72
+ isActive: n === e.ON_DATE,
73
+ label: "On",
74
+ value: e.ON_DATE,
75
+ onValueChange: () => t({ endMode: e.ON_DATE }),
76
+ activeColor: c,
77
+ skipSelectingOff: n === e.ON_DATE
78
+ }
79
+ ),
80
+ /* @__PURE__ */ r(_, { children: /* @__PURE__ */ r(
81
+ h,
82
+ {
83
+ val: o?.endOnDate ? new Date(o.endOnDate * 1e3) : void 0,
84
+ disabled: n !== e.ON_DATE,
85
+ onChange: (i) => {
86
+ const d = Array.isArray(i) ? i[0] : i;
87
+ if (!d) return;
88
+ const E = new Date(d);
89
+ E.setHours(23, 59, 59, 0), t({
90
+ endMode: e.ON_DATE,
91
+ endOnDate: Math.floor(E.getTime() / 1e3)
92
+ });
93
+ },
94
+ calendarProps: { minDate: f },
95
+ pickerStyles: { top: 8, zIndex: 4 }
96
+ }
97
+ ) })
98
+ ] })
99
+ ] })
100
+ ] });
101
+ };
102
+ export {
103
+ F as ScheduleEndPicker
104
+ };
105
+ //# sourceMappingURL=ScheduleEndPicker.js.map
@@ -0,0 +1 @@
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;AA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1C,OAAM;AAAA,YACN,OAAOA,EAAoB;AAAA,YAC3B,eAAe,MACdJ,EAAS,EAAE,SAASI,EAAoB,SAAS;AAAA,YAElD,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;"}
@@ -0,0 +1,21 @@
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>;
@@ -0,0 +1,136 @@
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
@@ -0,0 +1 @@
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_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A,KAAS;AAAA,YAAA;AAAA,YAE3C,iBAAiBd,EAAS,SAASZ,CAAmB;AAAA,UAAA,CACtD;AAAA,QAAA;AAAA,MAAA;AAAA,MAGF,CAAC,CAACH,KACF,gBAAAI,EAACmB,GAAA,EACA,UAAA;AAAA,QAAA,gBAAAf,EAACgB,KAAK,MAAM,IAAI,OAAOb,EAAO,QAAQ,WAAW;AAAA,0BAChDc,GAAA,EAAY,OAAOd,EAAO,QAAQ,WACjC,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;"}
@@ -0,0 +1,110 @@
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
+ }
@@ -0,0 +1,196 @@
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