@opengovsg/oui 0.0.0-snapshot-20250320092809 → 0.0.0-snapshot-20250326085831

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 (75) hide show
  1. package/dist/cjs/button/button.cjs +1 -1
  2. package/dist/cjs/calendar/agnostic-calendar-state-context.cjs +13 -0
  3. package/dist/cjs/calendar/calendar-bottom-content.cjs +51 -0
  4. package/dist/cjs/calendar/calendar-grid-header.cjs +28 -0
  5. package/dist/cjs/calendar/calendar-header.cjs +74 -0
  6. package/dist/cjs/calendar/calendar-month-day-selector.cjs +86 -0
  7. package/dist/cjs/calendar/calendar-style-context.cjs +0 -25
  8. package/dist/cjs/calendar/calendar.cjs +143 -4
  9. package/dist/cjs/calendar/hooks/index.cjs +11 -0
  10. package/dist/cjs/calendar/hooks/use-calendar-i18n.cjs +33 -0
  11. package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +41 -0
  12. package/dist/cjs/calendar/index.cjs +1 -1
  13. package/dist/cjs/combo-box/combo-box.cjs +1 -1
  14. package/dist/cjs/index.cjs +9 -5
  15. package/dist/cjs/range-calendar/index.cjs +10 -0
  16. package/dist/cjs/range-calendar/range-calendar.cjs +188 -0
  17. package/dist/cjs/select/select.cjs +1 -1
  18. package/dist/cjs/tag-field/tag-field.cjs +2 -2
  19. package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
  20. package/dist/cjs/text-field/text-field.cjs +1 -1
  21. package/dist/esm/button/button.js +1 -1
  22. package/dist/esm/calendar/agnostic-calendar-state-context.js +10 -0
  23. package/dist/esm/calendar/calendar-bottom-content.js +49 -0
  24. package/dist/esm/calendar/calendar-grid-header.js +26 -0
  25. package/dist/esm/calendar/calendar-header.js +72 -0
  26. package/dist/esm/calendar/calendar-month-day-selector.js +84 -0
  27. package/dist/esm/calendar/calendar-style-context.js +1 -25
  28. package/dist/esm/calendar/calendar.js +147 -9
  29. package/dist/esm/calendar/hooks/index.js +3 -0
  30. package/dist/esm/calendar/hooks/use-calendar-i18n.js +30 -0
  31. package/dist/esm/calendar/hooks/use-calendar-selectors.js +39 -0
  32. package/dist/esm/calendar/index.js +2 -2
  33. package/dist/esm/combo-box/combo-box.js +1 -1
  34. package/dist/esm/index.js +5 -4
  35. package/dist/esm/range-calendar/index.js +2 -0
  36. package/dist/esm/range-calendar/range-calendar.js +184 -0
  37. package/dist/esm/select/select.js +1 -1
  38. package/dist/esm/tag-field/tag-field.js +2 -2
  39. package/dist/esm/text-area-field/text-area-field.js +1 -1
  40. package/dist/esm/text-field/text-field.js +1 -1
  41. package/dist/types/calendar/agnostic-calendar-state-context.d.ts +3 -0
  42. package/dist/types/calendar/agnostic-calendar-state-context.d.ts.map +1 -0
  43. package/dist/types/calendar/calendar-bottom-content.d.ts +4 -0
  44. package/dist/types/calendar/calendar-bottom-content.d.ts.map +1 -0
  45. package/dist/types/calendar/calendar-grid-header.d.ts +2 -0
  46. package/dist/types/calendar/calendar-grid-header.d.ts.map +1 -0
  47. package/dist/types/calendar/calendar-header.d.ts +6 -0
  48. package/dist/types/calendar/calendar-header.d.ts.map +1 -0
  49. package/dist/types/calendar/calendar-month-day-selector.d.ts +2 -0
  50. package/dist/types/calendar/calendar-month-day-selector.d.ts.map +1 -0
  51. package/dist/types/calendar/calendar-style-context.d.ts +10 -1030
  52. package/dist/types/calendar/calendar-style-context.d.ts.map +1 -1
  53. package/dist/types/calendar/calendar.d.ts +5 -2
  54. package/dist/types/calendar/calendar.d.ts.map +1 -1
  55. package/dist/types/calendar/hooks/index.d.ts +3 -0
  56. package/dist/types/calendar/hooks/index.d.ts.map +1 -0
  57. package/dist/types/calendar/hooks/use-calendar-i18n.d.ts +4 -0
  58. package/dist/types/calendar/hooks/use-calendar-i18n.d.ts.map +1 -0
  59. package/dist/types/calendar/hooks/use-calendar-selectors.d.ts +13 -0
  60. package/dist/types/calendar/hooks/use-calendar-selectors.d.ts.map +1 -0
  61. package/dist/types/calendar/types.d.ts +5 -4
  62. package/dist/types/calendar/types.d.ts.map +1 -1
  63. package/dist/types/index.d.mts +1 -0
  64. package/dist/types/index.d.ts +1 -0
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/dist/types/range-calendar/index.d.ts +2 -0
  67. package/dist/types/range-calendar/index.d.ts.map +1 -0
  68. package/dist/types/range-calendar/range-calendar.d.ts +69 -0
  69. package/dist/types/range-calendar/range-calendar.d.ts.map +1 -0
  70. package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -1
  71. package/package.json +3 -3
  72. package/dist/cjs/calendar/calendar-base.cjs +0 -347
  73. package/dist/esm/calendar/calendar-base.js +0 -343
  74. package/dist/types/calendar/calendar-base.d.ts +0 -14
  75. package/dist/types/calendar/calendar-base.d.ts.map +0 -1
@@ -1,14 +1,152 @@
1
1
  "use strict";
2
2
  "use client";
3
- import { jsx } from 'react/jsx-runtime';
4
- import { Provider } from 'react-aria-components';
5
- import { forwardRef } from '../system/utils.js';
6
- import { CalendarBase } from './calendar-base.js';
7
- import { useProvideCalendarStyles, CalendarStyleContext } from './calendar-style-context.js';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { useMemo, useContext } from 'react';
5
+ import { CalendarDate, today, getLocalTimeZone } from '@internationalized/date';
6
+ import { Calendar as Calendar$1, composeRenderProps, Provider, CalendarGrid, CalendarGridBody, CalendarCell, Text, CalendarStateContext } from 'react-aria-components';
7
+ import { useDeepCompareMemo } from 'use-deep-compare';
8
+ import { calendarStyles, dataAttr, cn } from '@opengovsg/oui-theme';
9
+ import { forwardRef, mapPropsVariants } from '../system/utils.js';
10
+ import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
11
+ import { CalendarBottomContent } from './calendar-bottom-content.js';
12
+ import { CalendarGridHeader } from './calendar-grid-header.js';
13
+ import { CalendarHeader } from './calendar-header.js';
14
+ import { CalendarStyleContext } from './calendar-style-context.js';
8
15
 
9
- const Calendar = forwardRef(function Calendar2(props, ref) {
10
- const { calendarProps, context } = useProvideCalendarStyles(props);
11
- return /* @__PURE__ */ jsx(Provider, { values: [[CalendarStyleContext, context]], children: /* @__PURE__ */ jsx(CalendarBase, { calendarRef: ref, ...calendarProps }) });
16
+ const Calendar = forwardRef(function Calendar2(originalProps, ref) {
17
+ const [props, variantProps] = mapPropsVariants(
18
+ originalProps,
19
+ calendarStyles.variantKeys
20
+ );
21
+ const {
22
+ className,
23
+ classNames,
24
+ weekdayStyle = "narrow",
25
+ minValue = new CalendarDate(1900, 0, 1),
26
+ maxValue = new CalendarDate(2100, 12, 31),
27
+ bottomContent,
28
+ showTodayButton = true,
29
+ errorMessage,
30
+ ...restProps
31
+ } = props;
32
+ const slots = useDeepCompareMemo(
33
+ () => calendarStyles(variantProps),
34
+ [variantProps]
35
+ );
36
+ const context = useMemo(
37
+ () => ({
38
+ slots,
39
+ classNames,
40
+ className,
41
+ size: variantProps.size ?? calendarStyles.defaultVariants.size
42
+ }),
43
+ [className, classNames, slots, variantProps.size]
44
+ );
45
+ const numberOfVisibleMonths = props.visibleDuration?.months ?? 1;
46
+ const dateToHighlight = useMemo(() => {
47
+ if (props.defaultFocusedValue !== void 0) {
48
+ return props.defaultFocusedValue;
49
+ }
50
+ return today(getLocalTimeZone());
51
+ }, [props.defaultFocusedValue]);
52
+ return /* @__PURE__ */ jsxs(
53
+ Calendar$1,
54
+ {
55
+ pageBehavior: "single",
56
+ ...restProps,
57
+ ref,
58
+ minValue,
59
+ maxValue,
60
+ className: composeRenderProps(
61
+ className,
62
+ (className2, renderProps) => slots.base({
63
+ className: cn(classNames?.base, className2),
64
+ ...renderProps
65
+ })
66
+ ),
67
+ children: [
68
+ /* @__PURE__ */ jsx(CalendarStateWrapper, { children: /* @__PURE__ */ jsxs(Provider, { values: [[CalendarStyleContext, context]], children: [
69
+ /* @__PURE__ */ jsx(
70
+ "div",
71
+ {
72
+ className: slots.gridWrapper({
73
+ className: classNames?.gridWrapper
74
+ }),
75
+ children: Array.from({ length: numberOfVisibleMonths }).map((_, index) => /* @__PURE__ */ jsxs(
76
+ "div",
77
+ {
78
+ className: slots.calendar({ className: classNames?.calendar }),
79
+ children: [
80
+ /* @__PURE__ */ jsx(CalendarHeader, { offsetMonths: index }),
81
+ /* @__PURE__ */ jsxs(
82
+ CalendarGrid,
83
+ {
84
+ className: slots.grid({ className: classNames?.grid }),
85
+ weekdayStyle,
86
+ offset: { months: index },
87
+ children: [
88
+ /* @__PURE__ */ jsx(CalendarGridHeader, {}),
89
+ /* @__PURE__ */ jsx(
90
+ CalendarGridBody,
91
+ {
92
+ className: slots.gridBody({
93
+ className: classNames?.gridBody
94
+ }),
95
+ children: (date) => /* @__PURE__ */ jsx(
96
+ CalendarCell,
97
+ {
98
+ className: composeRenderProps(
99
+ classNames?.cell,
100
+ (className2, renderProps) => slots.cell({
101
+ className: className2,
102
+ isMultipleMonths: numberOfVisibleMonths >= 2,
103
+ ...renderProps
104
+ })
105
+ ),
106
+ "data-highlighted": dataAttr(
107
+ dateToHighlight ? date.compare(dateToHighlight) === 0 : false
108
+ ),
109
+ date
110
+ }
111
+ )
112
+ }
113
+ )
114
+ ]
115
+ }
116
+ )
117
+ ]
118
+ },
119
+ index
120
+ ))
121
+ }
122
+ ),
123
+ /* @__PURE__ */ jsx(
124
+ CalendarBottomContent,
125
+ {
126
+ bottomContent,
127
+ showTodayButton
128
+ }
129
+ )
130
+ ] }) }),
131
+ errorMessage && /* @__PURE__ */ jsx(
132
+ Text,
133
+ {
134
+ className: slots.errorMessage({
135
+ className: classNames?.errorMessage
136
+ }),
137
+ slot: "errorMessage",
138
+ children: errorMessage
139
+ }
140
+ )
141
+ ]
142
+ }
143
+ );
12
144
  });
145
+ const CalendarStateWrapper = ({
146
+ children
147
+ }) => {
148
+ const state = useContext(CalendarStateContext);
149
+ return /* @__PURE__ */ jsx(Provider, { values: [[AgnosticCalendarStateContext, state]], children });
150
+ };
13
151
 
14
- export { Calendar };
152
+ export { Calendar, CalendarStateWrapper };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ export { i18nStrings, useCalendarI18n } from './use-calendar-i18n.js';
3
+ export { useCalendarSelectors } from './use-calendar-selectors.js';
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ import { useMessageFormatter } from 'react-aria';
3
+
4
+ const i18nStrings = {
5
+ "en-SG": {
6
+ selectMonth: "Select month",
7
+ selectYear: "Select year",
8
+ today: "Today"
9
+ },
10
+ "zh-SG": {
11
+ selectMonth: "\u9009\u62E9\u6708\u4EFD",
12
+ selectYear: "\u9009\u62E9\u5E74\u4EFD",
13
+ today: "\u4ECA\u5929"
14
+ },
15
+ "ms-SG": {
16
+ selectMonth: "Pilih bulan",
17
+ selectYear: "Pilih tahun",
18
+ today: "Hari ini"
19
+ },
20
+ "ta-SG": {
21
+ selectMonth: "\u0BAE\u0BBE\u0BA4\u0BA4\u0BCD\u0BA4\u0BC8 \u0BA4\u0BC7\u0BB0\u0BCD\u0BA8\u0BCD\u0BA4\u0BC6\u0B9F\u0BC1\u0B95\u0BCD\u0B95\u0BB5\u0BC1\u0BAE\u0BCD",
22
+ selectYear: "\u0B86\u0BA3\u0BCD\u0B9F\u0BC8 \u0BA4\u0BC7\u0BB0\u0BCD\u0BA8\u0BCD\u0BA4\u0BC6\u0B9F\u0BC1\u0B95\u0BCD\u0B95\u0BB5\u0BC1\u0BAE\u0BCD",
23
+ today: "\u0B87\u0BA9\u0BCD\u0BB1\u0BC1"
24
+ }
25
+ };
26
+ const useCalendarI18n = () => {
27
+ return useMessageFormatter(i18nStrings);
28
+ };
29
+
30
+ export { i18nStrings, useCalendarI18n };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ "use client";
3
+ import { useMemo } from 'react';
4
+ import { useDateFormatter } from 'react-aria';
5
+ import { useGenerateLocalizedMonths, useGenerateLocalizedYears } from '../utils.js';
6
+
7
+ const useCalendarSelectors = (state) => {
8
+ const yearRange = useMemo(() => {
9
+ const start = state.minValue.year ?? 1900;
10
+ const end = state.maxValue.year ?? 2100;
11
+ return { start, end };
12
+ }, [state.maxValue, state.minValue]);
13
+ const dateFormatter = useDateFormatter(state);
14
+ const datePartOrder = useMemo(() => {
15
+ const parts = dateFormatter.formatToParts(
16
+ state.visibleRange.start.toDate(state.timeZone)
17
+ );
18
+ const filteredParts = parts.filter(
19
+ (part) => ["year", "month"].includes(part.type)
20
+ );
21
+ const filteredPartNames = filteredParts.map((part) => part.type);
22
+ return filteredPartNames;
23
+ }, [dateFormatter, state.timeZone, state.visibleRange.start]);
24
+ const months = useGenerateLocalizedMonths(state.timeZone);
25
+ const years = useGenerateLocalizedYears(
26
+ yearRange.start,
27
+ yearRange.end,
28
+ state.timeZone
29
+ );
30
+ return useMemo(() => {
31
+ return {
32
+ months,
33
+ years,
34
+ datePartOrder
35
+ };
36
+ }, [datePartOrder, months, years]);
37
+ };
38
+
39
+ export { useCalendarSelectors };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- export { Calendar } from './calendar.js';
3
- export { CalendarStyleContext, useCalendarStyleContext, useProvideCalendarStyles } from './calendar-style-context.js';
2
+ export { Calendar, CalendarStateWrapper } from './calendar.js';
3
+ export { CalendarStyleContext, useCalendarStyleContext } from './calendar-style-context.js';
4
4
  export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './utils.js';
5
5
  export { CalendarDate } from '@internationalized/date';
@@ -5,9 +5,9 @@ import { useMemo, useCallback } from 'react';
5
5
  import { useMessageFormatter } from 'react-aria';
6
6
  import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Popover, Virtualizer, ListBox } from 'react-aria-components';
7
7
  import { comboBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
8
+ import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
8
9
  import { mapPropsVariants } from '../system/utils.js';
9
10
  import { ComboBoxVariantContext } from './combo-box-variant-context.js';
10
- import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
11
11
  import ChevronUp from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-up.js';
12
12
  import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
13
13
  import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  export { useControllableState } from './hooks/use-controllable-state.js';
3
- export { Button } from './button/button.js';
4
3
  export { GovtBanner } from './govt-banner/govt-banner.js';
5
4
  export { Ripple } from './ripple/ripple.js';
6
5
  export { useRipple } from './ripple/use-ripple.js';
@@ -17,14 +16,16 @@ export { ComboBox, ComboBoxEmptyState } from './combo-box/combo-box.js';
17
16
  export { ComboBoxFuzzy } from './combo-box/combo-box-fuzzy.js';
18
17
  export { ComboBoxItem } from './combo-box/combo-box-item.js';
19
18
  export { ComboBoxVariantContext, useComboBoxVariantContext } from './combo-box/combo-box-variant-context.js';
20
- export { Banner } from './banner/banner.js';
21
19
  export { TagField } from './tag-field/tag-field.js';
22
20
  export { TagFieldItem } from './tag-field/tag-field-item.js';
23
21
  export { Select } from './select/select.js';
24
22
  export { SelectItem } from './select/select-item.js';
25
23
  export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
24
+ export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
25
+ export { Button } from './button/button.js';
26
+ export { Banner } from './banner/banner.js';
26
27
  export { Badge } from './badge/badge.js';
27
28
  export { CalendarDate } from '@internationalized/date';
28
- export { Calendar } from './calendar/calendar.js';
29
- export { CalendarStyleContext, useCalendarStyleContext, useProvideCalendarStyles } from './calendar/calendar-style-context.js';
29
+ export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
30
+ export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
30
31
  export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar.js';
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { forwardRef, useMemo, useContext } from 'react';
5
+ import { CalendarDate, today, getLocalTimeZone, getDayOfWeek } from '@internationalized/date';
6
+ import { RangeCalendar as RangeCalendar$1, Provider, CalendarGrid, CalendarGridBody, Text, RangeCalendarStateContext, useLocale, CalendarCell } from 'react-aria-components';
7
+ import { useDeepCompareMemo } from 'use-deep-compare';
8
+ import { calendarStyles, composeRenderProps, cn, dataAttr } from '@opengovsg/oui-theme';
9
+ import { AgnosticCalendarStateContext } from '../calendar/agnostic-calendar-state-context.js';
10
+ import { CalendarBottomContent } from '../calendar/calendar-bottom-content.js';
11
+ import { CalendarGridHeader } from '../calendar/calendar-grid-header.js';
12
+ import { CalendarHeader } from '../calendar/calendar-header.js';
13
+ import { mapPropsVariants } from '../system/utils.js';
14
+ import { CalendarStyleContext, useCalendarStyleContext } from '../calendar/calendar-style-context.js';
15
+
16
+ const RangeCalendar = forwardRef(function RangeCalendar2(originalProps, ref) {
17
+ const [props, variantProps] = mapPropsVariants(
18
+ originalProps,
19
+ calendarStyles.variantKeys
20
+ );
21
+ const {
22
+ className,
23
+ classNames,
24
+ weekdayStyle = "narrow",
25
+ minValue = new CalendarDate(1900, 0, 1),
26
+ maxValue = new CalendarDate(2100, 12, 31),
27
+ bottomContent,
28
+ showTodayButton = true,
29
+ errorMessage,
30
+ ...restProps
31
+ } = props;
32
+ const slots = useDeepCompareMemo(
33
+ () => calendarStyles({ ...variantProps, isRange: true }),
34
+ [variantProps]
35
+ );
36
+ const context = useMemo(
37
+ () => ({
38
+ slots,
39
+ classNames,
40
+ className,
41
+ size: variantProps.size ?? calendarStyles.defaultVariants.size
42
+ }),
43
+ [className, classNames, slots, variantProps.size]
44
+ );
45
+ const numberOfVisibleMonths = props.visibleDuration?.months ?? 1;
46
+ const dateToHighlight = useMemo(() => {
47
+ if (props.defaultFocusedValue !== void 0) {
48
+ return props.defaultFocusedValue;
49
+ }
50
+ return today(getLocalTimeZone());
51
+ }, [props.defaultFocusedValue]);
52
+ return /* @__PURE__ */ jsxs(
53
+ RangeCalendar$1,
54
+ {
55
+ ...restProps,
56
+ ref,
57
+ minValue,
58
+ maxValue,
59
+ className: composeRenderProps(
60
+ className,
61
+ (className2, renderProps) => slots.base({
62
+ className: cn(classNames?.base, className2),
63
+ ...renderProps
64
+ })
65
+ ),
66
+ children: [
67
+ /* @__PURE__ */ jsx(Provider, { values: [[CalendarStyleContext, context]], children: /* @__PURE__ */ jsxs(RangeCalendarStateWrapper, { children: [
68
+ /* @__PURE__ */ jsx(
69
+ "div",
70
+ {
71
+ className: slots.gridWrapper({
72
+ className: classNames?.gridWrapper
73
+ }),
74
+ children: Array.from({ length: numberOfVisibleMonths }).map((_, index) => /* @__PURE__ */ jsxs(
75
+ "div",
76
+ {
77
+ className: slots.calendar({ className: classNames?.calendar }),
78
+ children: [
79
+ /* @__PURE__ */ jsx(CalendarHeader, { offsetMonths: index }),
80
+ /* @__PURE__ */ jsxs(
81
+ CalendarGrid,
82
+ {
83
+ className: slots.grid({ className: classNames?.grid }),
84
+ weekdayStyle,
85
+ offset: { months: index },
86
+ children: [
87
+ /* @__PURE__ */ jsx(CalendarGridHeader, {}),
88
+ /* @__PURE__ */ jsx(
89
+ CalendarGridBody,
90
+ {
91
+ className: slots.gridBody({
92
+ className: classNames?.gridBody
93
+ }),
94
+ children: (date) => /* @__PURE__ */ jsx(
95
+ RangeCalendarCell,
96
+ {
97
+ firstDayOfWeek: props.firstDayOfWeek,
98
+ dateToHighlight,
99
+ date,
100
+ isMultipleMonths: numberOfVisibleMonths >= 2
101
+ }
102
+ )
103
+ }
104
+ )
105
+ ]
106
+ }
107
+ )
108
+ ]
109
+ },
110
+ index
111
+ ))
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsx(
115
+ CalendarBottomContent,
116
+ {
117
+ bottomContent,
118
+ showTodayButton
119
+ }
120
+ )
121
+ ] }) }),
122
+ errorMessage && /* @__PURE__ */ jsx(
123
+ Text,
124
+ {
125
+ className: slots.errorMessage({
126
+ className: classNames?.errorMessage
127
+ }),
128
+ slot: "errorMessage",
129
+ children: errorMessage
130
+ }
131
+ )
132
+ ]
133
+ }
134
+ );
135
+ });
136
+ const RangeCalendarStateWrapper = ({
137
+ children
138
+ }) => {
139
+ const state = useContext(RangeCalendarStateContext);
140
+ return /* @__PURE__ */ jsx(Provider, { values: [[AgnosticCalendarStateContext, state]], children });
141
+ };
142
+ const RangeCalendarCell = ({
143
+ date,
144
+ isMultipleMonths,
145
+ dateToHighlight,
146
+ firstDayOfWeek
147
+ }) => {
148
+ const { classNames, slots } = useCalendarStyleContext();
149
+ const state = useContext(AgnosticCalendarStateContext);
150
+ const { locale } = useLocale();
151
+ const dataAttributes = useMemo(() => {
152
+ const isDateHighlighted = dateToHighlight ? date.compare(dateToHighlight) === 0 : false;
153
+ const isSelected = state.isSelected(date);
154
+ const isDisabled = state.isCellDisabled(date);
155
+ const isInvalid = state.isInvalid(date);
156
+ const isFirstSelectedAfterDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(date.subtract({ days: 1 }));
157
+ const isLastSelectedBeforeDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(date.add({ days: 1 }));
158
+ const dayOfWeek = getDayOfWeek(date, locale, firstDayOfWeek);
159
+ const isRangeStart = isSelected && (isFirstSelectedAfterDisabled || dayOfWeek === 0 || date.day === 1);
160
+ const isRangeEnd = isSelected && (isLastSelectedBeforeDisabled || dayOfWeek === 6 || date.day === date.calendar.getDaysInMonth(date));
161
+ return {
162
+ "data-highlighted": dataAttr(isDateHighlighted),
163
+ "data-range-end": dataAttr(isRangeEnd),
164
+ "data-range-start": dataAttr(isRangeStart)
165
+ };
166
+ }, [date, dateToHighlight, firstDayOfWeek, locale, state]);
167
+ return /* @__PURE__ */ jsx(
168
+ CalendarCell,
169
+ {
170
+ className: composeRenderProps(
171
+ classNames?.cell,
172
+ (className, renderProps) => slots.cell({
173
+ className,
174
+ isMultipleMonths,
175
+ ...renderProps
176
+ })
177
+ ),
178
+ ...dataAttributes,
179
+ date
180
+ }
181
+ );
182
+ };
183
+
184
+ export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper };
@@ -4,9 +4,9 @@ import { jsx, jsxs } from 'react/jsx-runtime';
4
4
  import { useMemo } from 'react';
5
5
  import { Provider, Select as Select$1, SelectValue, Popover, Virtualizer, ListLayout, ListBox } from 'react-aria-components';
6
6
  import { selectStyles, composeRenderProps } from '@opengovsg/oui-theme';
7
+ import { Label, Description } from '../field/field.js';
7
8
  import { mapPropsVariants } from '../system/utils.js';
8
9
  import { SelectVariantContext } from './select-variant-context.js';
9
- import { Label, Description } from '../field/field.js';
10
10
  import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
11
11
  import { Button } from '../button/button.js';
12
12
 
@@ -4,14 +4,14 @@ import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { createElement } from 'react';
5
5
  import { composeRenderProps, Popover } from 'react-aria-components';
6
6
  import { tagFieldStyles } from '@opengovsg/oui-theme';
7
+ import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
8
+ import { Input } from '../input/input.js';
7
9
  import { TagFieldItem } from './tag-field-item.js';
8
10
  import { TagFieldList } from './tag-field-list.js';
9
11
  import { TagFieldRoot } from './tag-field-root.js';
10
12
  import { TagFieldTagList } from './tag-field-tag-list.js';
11
13
  import { TagFieldTrigger } from './tag-field-trigger.js';
12
14
  import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
13
- import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
14
- import { Input } from '../input/input.js';
15
15
 
16
16
  function TagField({
17
17
  classNames,
@@ -3,8 +3,8 @@
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { TextField } from 'react-aria-components';
5
5
  import { composeTailwindRenderProps } from '@opengovsg/oui-theme';
6
- import { TextArea } from '../text-area/text-area.js';
7
6
  import { Label, Description, FieldError } from '../field/field.js';
7
+ import { TextArea } from '../text-area/text-area.js';
8
8
 
9
9
  function TextAreaField({
10
10
  label,
@@ -3,8 +3,8 @@
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { TextField as TextField$1 } from 'react-aria-components';
5
5
  import { composeTailwindRenderProps } from '@opengovsg/oui-theme';
6
- import { Input } from '../input/input.js';
7
6
  import { Label, Description, FieldError } from '../field/field.js';
7
+ import { Input } from '../input/input.js';
8
8
 
9
9
  function TextField({
10
10
  label,
@@ -0,0 +1,3 @@
1
+ import type { CalendarState, RangeCalendarState } from "react-stately";
2
+ export declare const AgnosticCalendarStateContext: import("react").Context<CalendarState | RangeCalendarState>, useAgnosticCalendarStateContext: () => CalendarState | RangeCalendarState;
3
+ //# sourceMappingURL=agnostic-calendar-state-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agnostic-calendar-state-context.d.ts","sourceRoot":"","sources":["../../../src/calendar/agnostic-calendar-state-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAItE,eAAO,MAAO,4BAA4B,+DAAE,+BAA+B,0CAIvE,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { CalendarDate } from "@internationalized/date";
2
+ import type { CalendarProps } from "./types";
3
+ export declare const CalendarBottomContent: <T extends CalendarDate>({ bottomContent, showTodayButton, }: Pick<CalendarProps<T>, "bottomContent" | "showTodayButton">) => string | number | bigint | true | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=calendar-bottom-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-bottom-content.d.ts","sourceRoot":"","sources":["../../../src/calendar/calendar-bottom-content.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAI3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,YAAY,uCAGzD,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,eAAe,GAAG,iBAAiB,CAAC,6VAkC7D,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function CalendarGridHeader(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=calendar-grid-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-grid-header.d.ts","sourceRoot":"","sources":["../../../src/calendar/calendar-grid-header.tsx"],"names":[],"mappings":"AASA,wBAAgB,kBAAkB,4CAiBjC"}
@@ -0,0 +1,6 @@
1
+ interface CalendarHeaderProps {
2
+ offsetMonths?: number;
3
+ }
4
+ export declare function CalendarHeader({ offsetMonths }: CalendarHeaderProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
6
+ //# sourceMappingURL=calendar-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-header.d.ts","sourceRoot":"","sources":["../../../src/calendar/calendar-header.tsx"],"names":[],"mappings":"AAYA,UAAU,mBAAmB;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,cAAc,CAAC,EAAE,YAAgB,EAAE,EAAE,mBAAmB,2CA8DvE"}
@@ -0,0 +1,2 @@
1
+ export declare const CalendarMonthDaySelector: () => import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=calendar-month-day-selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-month-day-selector.d.ts","sourceRoot":"","sources":["../../../src/calendar/calendar-month-day-selector.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,wBAAwB,+CA2EpC,CAAA"}