@opengovsg/oui 0.0.9 → 0.0.10

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 (111) 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-fuzzy.cjs +3 -3
  14. package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
  15. package/dist/cjs/combo-box/combo-box.cjs +3 -2
  16. package/dist/cjs/index.cjs +38 -23
  17. package/dist/cjs/menu/index.cjs +15 -0
  18. package/dist/cjs/menu/menu.cjs +229 -0
  19. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.cjs +19 -0
  20. package/dist/cjs/popover/index.cjs +8 -0
  21. package/dist/cjs/popover/popover.cjs +46 -0
  22. package/dist/cjs/range-calendar/index.cjs +10 -0
  23. package/dist/cjs/range-calendar/range-calendar.cjs +188 -0
  24. package/dist/cjs/select/select.cjs +4 -1
  25. package/dist/cjs/system/react-utils/context.cjs +3 -2
  26. package/dist/cjs/tag-field/tag-field-item.cjs +8 -3
  27. package/dist/cjs/tag-field/tag-field.cjs +2 -1
  28. package/dist/esm/button/button.js +1 -1
  29. package/dist/esm/calendar/agnostic-calendar-state-context.js +10 -0
  30. package/dist/esm/calendar/calendar-bottom-content.js +49 -0
  31. package/dist/esm/calendar/calendar-grid-header.js +26 -0
  32. package/dist/esm/calendar/calendar-header.js +72 -0
  33. package/dist/esm/calendar/calendar-month-day-selector.js +84 -0
  34. package/dist/esm/calendar/calendar-style-context.js +1 -25
  35. package/dist/esm/calendar/calendar.js +147 -9
  36. package/dist/esm/calendar/hooks/index.js +3 -0
  37. package/dist/esm/calendar/hooks/use-calendar-i18n.js +30 -0
  38. package/dist/esm/calendar/hooks/use-calendar-selectors.js +39 -0
  39. package/dist/esm/calendar/index.js +2 -2
  40. package/dist/esm/combo-box/combo-box-fuzzy.js +4 -4
  41. package/dist/esm/combo-box/combo-box-item.js +3 -3
  42. package/dist/esm/combo-box/combo-box.js +4 -3
  43. package/dist/esm/index.js +15 -12
  44. package/dist/esm/menu/index.js +2 -0
  45. package/dist/esm/menu/menu.js +220 -0
  46. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.js +14 -0
  47. package/dist/esm/popover/index.js +2 -0
  48. package/dist/esm/popover/popover.js +44 -0
  49. package/dist/esm/range-calendar/index.js +2 -0
  50. package/dist/esm/range-calendar/range-calendar.js +184 -0
  51. package/dist/esm/select/select.js +5 -2
  52. package/dist/esm/system/react-utils/context.js +3 -2
  53. package/dist/esm/tag-field/tag-field-item.js +9 -4
  54. package/dist/esm/tag-field/tag-field.js +3 -2
  55. package/dist/types/calendar/agnostic-calendar-state-context.d.ts +3 -0
  56. package/dist/types/calendar/agnostic-calendar-state-context.d.ts.map +1 -0
  57. package/dist/types/calendar/calendar-bottom-content.d.ts +4 -0
  58. package/dist/types/calendar/calendar-bottom-content.d.ts.map +1 -0
  59. package/dist/types/calendar/calendar-grid-header.d.ts +2 -0
  60. package/dist/types/calendar/calendar-grid-header.d.ts.map +1 -0
  61. package/dist/types/calendar/calendar-header.d.ts +6 -0
  62. package/dist/types/calendar/calendar-header.d.ts.map +1 -0
  63. package/dist/types/calendar/calendar-month-day-selector.d.ts +2 -0
  64. package/dist/types/calendar/calendar-month-day-selector.d.ts.map +1 -0
  65. package/dist/types/calendar/calendar-style-context.d.ts +10 -1030
  66. package/dist/types/calendar/calendar-style-context.d.ts.map +1 -1
  67. package/dist/types/calendar/calendar.d.ts +5 -2
  68. package/dist/types/calendar/calendar.d.ts.map +1 -1
  69. package/dist/types/calendar/hooks/index.d.ts +3 -0
  70. package/dist/types/calendar/hooks/index.d.ts.map +1 -0
  71. package/dist/types/calendar/hooks/use-calendar-i18n.d.ts +4 -0
  72. package/dist/types/calendar/hooks/use-calendar-i18n.d.ts.map +1 -0
  73. package/dist/types/calendar/hooks/use-calendar-selectors.d.ts +13 -0
  74. package/dist/types/calendar/hooks/use-calendar-selectors.d.ts.map +1 -0
  75. package/dist/types/calendar/types.d.ts +5 -4
  76. package/dist/types/calendar/types.d.ts.map +1 -1
  77. package/dist/types/combo-box/combo-box-fuzzy.d.ts +2 -2
  78. package/dist/types/combo-box/combo-box-fuzzy.d.ts.map +1 -1
  79. package/dist/types/combo-box/combo-box-item.d.ts +3 -3
  80. package/dist/types/combo-box/combo-box-item.d.ts.map +1 -1
  81. package/dist/types/combo-box/combo-box.d.ts.map +1 -1
  82. package/dist/types/index.d.mts +3 -0
  83. package/dist/types/index.d.ts +3 -0
  84. package/dist/types/index.d.ts.map +1 -1
  85. package/dist/types/menu/index.d.ts +2 -0
  86. package/dist/types/menu/index.d.ts.map +1 -0
  87. package/dist/types/menu/menu.d.ts +38 -0
  88. package/dist/types/menu/menu.d.ts.map +1 -0
  89. package/dist/types/popover/index.d.ts +2 -0
  90. package/dist/types/popover/index.d.ts.map +1 -0
  91. package/dist/types/popover/popover.d.ts +21 -0
  92. package/dist/types/popover/popover.d.ts.map +1 -0
  93. package/dist/types/range-calendar/index.d.ts +2 -0
  94. package/dist/types/range-calendar/index.d.ts.map +1 -0
  95. package/dist/types/range-calendar/range-calendar.d.ts +69 -0
  96. package/dist/types/range-calendar/range-calendar.d.ts.map +1 -0
  97. package/dist/types/select/select.d.ts +4 -3
  98. package/dist/types/select/select.d.ts.map +1 -1
  99. package/dist/types/system/react-utils/context.d.ts +3 -2
  100. package/dist/types/system/react-utils/context.d.ts.map +1 -1
  101. package/dist/types/tag-field/tag-field-item.d.ts +2 -2
  102. package/dist/types/tag-field/tag-field-item.d.ts.map +1 -1
  103. package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -1
  104. package/dist/types/tag-field/tag-field.d.ts.map +1 -1
  105. package/dist/types/tag-field/types.d.ts +3 -3
  106. package/dist/types/tag-field/types.d.ts.map +1 -1
  107. package/package.json +5 -5
  108. package/dist/cjs/calendar/calendar-base.cjs +0 -347
  109. package/dist/esm/calendar/calendar-base.js +0 -343
  110. package/dist/types/calendar/calendar-base.d.ts +0 -14
  111. package/dist/types/calendar/calendar-base.d.ts.map +0 -1
@@ -10,15 +10,20 @@ var tagFieldStateContext = require('./tag-field-state-context.cjs');
10
10
 
11
11
  const TagFieldItemInner = ({ item, isHighlighted, classNames, ...itemProps }, ref) => {
12
12
  const { itemToText, size } = react.useContext(tagFieldStateContext.TagFieldStateContext);
13
- const styles = ouiTheme.tagFieldItemStyles({ size });
13
+ const styles = ouiTheme.listBoxItemStyles({ size });
14
14
  return /* @__PURE__ */ jsxRuntime.jsx(
15
15
  "li",
16
16
  {
17
17
  ref,
18
18
  ...itemProps,
19
- className: styles.container({ className: classNames?.container }),
19
+ className: styles.container({
20
+ className: classNames?.container,
21
+ isFocused: isHighlighted,
22
+ isDisabled: itemProps["aria-disabled"]
23
+ }),
20
24
  "data-rac": true,
21
- "data-hovered": ouiTheme.dataAttr(isHighlighted),
25
+ "data-focused": ouiTheme.dataAttr(isHighlighted),
26
+ "data-disabled": ouiTheme.dataAttr(itemProps["aria-disabled"]),
22
27
  children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.label({ className: classNames?.label }), children: itemToText(item) })
23
28
  }
24
29
  );
@@ -14,6 +14,7 @@ var tagFieldTrigger = require('./tag-field-trigger.cjs');
14
14
  var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs');
15
15
  var field = require('../field/field.cjs');
16
16
  var input = require('../input/input.cjs');
17
+ var popover = require('../popover/popover.cjs');
17
18
 
18
19
  function TagField({
19
20
  classNames,
@@ -93,7 +94,7 @@ function TagField({
93
94
  }
94
95
  )
95
96
  ] }),
96
- /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Popover, { children: /* @__PURE__ */ jsxRuntime.jsx(
97
+ /* @__PURE__ */ jsxRuntime.jsx(popover.Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsxRuntime.jsx(
97
98
  tagFieldList.TagFieldList,
98
99
  {
99
100
  className: styles.list({ className: classNames?.list }),
@@ -5,9 +5,9 @@ import { forwardRef, useMemo } from 'react';
5
5
  import { chain } from '@react-aria/utils';
6
6
  import { Button as Button$1, composeRenderProps } from 'react-aria-components';
7
7
  import { buttonStyles } from '@opengovsg/oui-theme';
8
+ import { Ripple } from '../ripple/ripple.js';
8
9
  import { useRipple } from '../ripple/use-ripple.js';
9
10
  import { Spinner } from '../spinner/spinner.js';
10
- import { Ripple } from '../ripple/ripple.js';
11
11
 
12
12
  const Button = forwardRef(
13
13
  ({
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ "use client";
3
+ import { createContext } from '../system/react-utils/context.js';
4
+
5
+ const [AgnosticCalendarStateContext, useAgnosticCalendarStateContext] = createContext({
6
+ name: "AgnosticCalendarStateContext",
7
+ strict: true
8
+ });
9
+
10
+ export { AgnosticCalendarStateContext, useAgnosticCalendarStateContext };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { today, getLocalTimeZone } from '@internationalized/date';
6
+ import { Button } from '../button/button.js';
7
+ import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
8
+ import { useCalendarStyleContext } from './calendar-style-context.js';
9
+ import { useCalendarI18n } from './hooks/use-calendar-i18n.js';
10
+
11
+ const CalendarBottomContent = ({
12
+ bottomContent,
13
+ showTodayButton
14
+ }) => {
15
+ const state = useContext(AgnosticCalendarStateContext);
16
+ const { slots, classNames, size } = useCalendarStyleContext();
17
+ const formatMessage = useCalendarI18n();
18
+ if (bottomContent) {
19
+ return bottomContent;
20
+ }
21
+ if (!showTodayButton) {
22
+ return null;
23
+ }
24
+ return /* @__PURE__ */ jsx(
25
+ "div",
26
+ {
27
+ className: slots.bottomContentWrapper({
28
+ className: classNames?.bottomContentWrapper
29
+ }),
30
+ children: /* @__PURE__ */ jsx(
31
+ Button,
32
+ {
33
+ isDisabled: state.isDisabled,
34
+ variant: "clear",
35
+ color: "sub",
36
+ size,
37
+ slot: null,
38
+ className: slots.todayButton({ className: classNames?.todayButton }),
39
+ onPress: () => {
40
+ state.setFocusedDate(today(getLocalTimeZone()));
41
+ },
42
+ children: formatMessage("today")
43
+ }
44
+ )
45
+ }
46
+ );
47
+ };
48
+
49
+ export { CalendarBottomContent };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { CalendarGridHeader as CalendarGridHeader$1, CalendarHeaderCell } from 'react-aria-components';
5
+ import { useCalendarStyleContext } from './calendar-style-context.js';
6
+
7
+ function CalendarGridHeader() {
8
+ const { slots, classNames } = useCalendarStyleContext();
9
+ return /* @__PURE__ */ jsx(
10
+ CalendarGridHeader$1,
11
+ {
12
+ className: slots.gridHeader({ className: classNames?.gridHeader }),
13
+ children: (day) => /* @__PURE__ */ jsx(
14
+ CalendarHeaderCell,
15
+ {
16
+ className: slots.gridHeaderCell({
17
+ className: classNames?.gridHeaderCell
18
+ }),
19
+ children: day
20
+ }
21
+ )
22
+ }
23
+ );
24
+ }
25
+
26
+ export { CalendarGridHeader };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { useLocale, Group, Heading } from 'react-aria-components';
6
+ import { Button } from '../button/button.js';
7
+ import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
8
+ import { CalendarMonthDaySelector } from './calendar-month-day-selector.js';
9
+ import { useCalendarStyleContext } from './calendar-style-context.js';
10
+ import { useLocalizedMonthYear } from './utils.js';
11
+ import ChevronRight from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-right.js';
12
+ import ChevronLeft from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-left.js';
13
+
14
+ function CalendarHeader({ offsetMonths = 0 }) {
15
+ const { direction } = useLocale();
16
+ const { slots, classNames, size } = useCalendarStyleContext();
17
+ const state = useContext(AgnosticCalendarStateContext);
18
+ const monthYearTitle = useLocalizedMonthYear(
19
+ state.visibleRange.start.add({ months: offsetMonths }),
20
+ state.timeZone
21
+ );
22
+ if (offsetMonths === 0) {
23
+ return /* @__PURE__ */ jsxs("div", { className: slots.header({ className: classNames?.header }), children: [
24
+ /* @__PURE__ */ jsx(CalendarMonthDaySelector, {}),
25
+ /* @__PURE__ */ jsxs(
26
+ Group,
27
+ {
28
+ className: slots.buttonGroup({ className: classNames?.buttonGroup }),
29
+ children: [
30
+ /* @__PURE__ */ jsx(
31
+ Button,
32
+ {
33
+ size,
34
+ isIconOnly: true,
35
+ variant: "clear",
36
+ color: "sub",
37
+ slot: "previous",
38
+ className: slots.prevButton({ className: classNames?.prevButton }),
39
+ children: direction === "rtl" ? /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true }) : /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": true })
40
+ }
41
+ ),
42
+ /* @__PURE__ */ jsx(
43
+ Button,
44
+ {
45
+ size,
46
+ variant: "clear",
47
+ color: "sub",
48
+ isIconOnly: true,
49
+ slot: "next",
50
+ className: slots.nextButton({
51
+ className: classNames?.nextButton
52
+ }),
53
+ children: direction === "rtl" ? /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": true }) : /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true })
54
+ }
55
+ )
56
+ ]
57
+ }
58
+ )
59
+ ] });
60
+ }
61
+ return /* @__PURE__ */ jsx(
62
+ Heading,
63
+ {
64
+ className: slots.header({ className: classNames?.header }),
65
+ "aria-hidden": true,
66
+ level: 2,
67
+ children: monthYearTitle
68
+ }
69
+ );
70
+ }
71
+
72
+ export { CalendarHeader };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { CalendarDate } from '@internationalized/date';
6
+ import { Group } from 'react-aria-components';
7
+ import { Select } from '../select/select.js';
8
+ import { SelectItem } from '../select/select-item.js';
9
+ import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
10
+ import { useCalendarStyleContext } from './calendar-style-context.js';
11
+ import { useCalendarSelectors } from './hooks/use-calendar-selectors.js';
12
+ import { useCalendarI18n } from './hooks/use-calendar-i18n.js';
13
+
14
+ const CalendarMonthDaySelector = () => {
15
+ const { slots, size, classNames } = useCalendarStyleContext();
16
+ const state = useContext(AgnosticCalendarStateContext);
17
+ const { months, years, datePartOrder } = useCalendarSelectors(state);
18
+ const formatMessage = useCalendarI18n();
19
+ return /* @__PURE__ */ jsx(Group, { className: slots.selectors({ className: classNames?.selectors }), children: datePartOrder.map((part) => {
20
+ if (part === "month") {
21
+ return /* @__PURE__ */ jsx(
22
+ Select,
23
+ {
24
+ isDisabled: state.isDisabled,
25
+ size,
26
+ items: months,
27
+ variant: "clear",
28
+ classNames: {
29
+ trigger: slots.monthSelector({
30
+ className: classNames?.monthSelector
31
+ }),
32
+ list: slots.monthList({ className: classNames?.monthList }),
33
+ selectedText: slots.selectorText({
34
+ className: classNames?.selectorText
35
+ }),
36
+ popover: "min-w-[12ch]"
37
+ },
38
+ selectedKey: state.visibleRange.start.month,
39
+ "aria-label": formatMessage("selectMonth"),
40
+ onSelectionChange: (month) => {
41
+ state.setFocusedDate(
42
+ new CalendarDate(state.focusedDate.year, Number(month), 1)
43
+ );
44
+ },
45
+ children: (month) => /* @__PURE__ */ jsx(SelectItem, { children: month.textValue })
46
+ },
47
+ part
48
+ );
49
+ }
50
+ return /* @__PURE__ */ jsx(
51
+ Select,
52
+ {
53
+ isDisabled: state.isDisabled,
54
+ size,
55
+ variant: "clear",
56
+ items: years,
57
+ classNames: {
58
+ trigger: slots.yearSelector({
59
+ className: classNames?.yearSelector
60
+ }),
61
+ list: slots.yearList({ className: classNames?.yearList }),
62
+ selectedText: slots.selectorText({
63
+ className: classNames?.selectorText
64
+ })
65
+ },
66
+ selectedKey: state.visibleRange.start.year,
67
+ "aria-label": formatMessage("selectYear"),
68
+ onSelectionChange: (year) => {
69
+ state.setFocusedDate(
70
+ new CalendarDate(
71
+ Number(year),
72
+ state.focusedDate.month,
73
+ state.focusedDate.day
74
+ )
75
+ );
76
+ },
77
+ children: (year) => /* @__PURE__ */ jsx(SelectItem, { children: year.textValue })
78
+ },
79
+ part
80
+ );
81
+ }) });
82
+ };
83
+
84
+ export { CalendarMonthDaySelector };
@@ -1,34 +1,10 @@
1
1
  "use strict";
2
2
  "use client";
3
- import { useDeepCompareMemo } from 'use-deep-compare';
4
- import { calendarStyles } from '@opengovsg/oui-theme';
5
- import { mapPropsVariants } from '../system/utils.js';
6
3
  import { createContext } from '../system/react-utils/context.js';
7
4
 
8
- function useProvideCalendarStyles(originalProps) {
9
- const [props, variantProps] = mapPropsVariants(
10
- originalProps,
11
- calendarStyles.variantKeys
12
- );
13
- const { errorMessage, className, classNames, ...restProps } = props;
14
- const slots = useDeepCompareMemo(
15
- () => calendarStyles(variantProps),
16
- [variantProps]
17
- );
18
- return {
19
- context: {
20
- slots,
21
- classNames,
22
- className,
23
- size: variantProps.size ?? calendarStyles.defaultVariants.size,
24
- errorMessage
25
- },
26
- calendarProps: { ...restProps, onChange: restProps.onChange }
27
- };
28
- }
29
5
  const [CalendarStyleContext, useCalendarStyleContext] = createContext({
30
6
  name: "CalendarStyleContext",
31
7
  strict: true
32
8
  });
33
9
 
34
- export { CalendarStyleContext, useCalendarStyleContext, useProvideCalendarStyles };
10
+ export { CalendarStyleContext, useCalendarStyleContext };
@@ -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';
@@ -4,7 +4,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useDeferredValue, useMemo, useState, useCallback } from 'react';
5
5
  import fuzzysort from 'fuzzysort';
6
6
  import { Text } from 'react-aria-components';
7
- import { comboBoxStyles, comboBoxItemStyles, comboBoxFuzzyHighlightedTextStyles } from '@opengovsg/oui-theme';
7
+ import { comboBoxStyles, listBoxItemStyles, comboBoxFuzzyHighlightedTextStyles } from '@opengovsg/oui-theme';
8
8
  import { mapPropsVariants } from '../system/utils.js';
9
9
  import { ComboBox } from './combo-box.js';
10
10
  import { ComboBoxItem } from './combo-box-item.js';
@@ -79,7 +79,7 @@ function ComboBoxFuzzy(originalProps) {
79
79
  },
80
80
  [onInputChangeProp, preparedItems]
81
81
  );
82
- const comboboxItemStyles = comboBoxItemStyles(variantProps);
82
+ const itemStyles = listBoxItemStyles(variantProps);
83
83
  return /* @__PURE__ */ jsx(
84
84
  ComboBox,
85
85
  {
@@ -93,7 +93,7 @@ function ComboBoxFuzzy(originalProps) {
93
93
  /* @__PURE__ */ jsx(
94
94
  Text,
95
95
  {
96
- className: comboboxItemStyles.label({
96
+ className: itemStyles.label({
97
97
  className: itemClassNames?.label
98
98
  }),
99
99
  slot: "label",
@@ -112,7 +112,7 @@ function ComboBoxFuzzy(originalProps) {
112
112
  item.description && /* @__PURE__ */ jsx(
113
113
  Text,
114
114
  {
115
- className: comboboxItemStyles.description({
115
+ className: itemStyles.description({
116
116
  className: itemClassNames?.description
117
117
  }),
118
118
  slot: "description",
@@ -3,7 +3,7 @@
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useMemo } from 'react';
5
5
  import { useContextProps, ListBoxItem, composeRenderProps, Text } from 'react-aria-components';
6
- import { comboBoxItemStyles } from '@opengovsg/oui-theme';
6
+ import { listBoxItemStyles } from '@opengovsg/oui-theme';
7
7
  import { forwardRef, mapPropsVariants } from '../system/utils.js';
8
8
  import { ComboBoxVariantContext } from './combo-box-variant-context.js';
9
9
 
@@ -16,8 +16,8 @@ const ComboBoxItem = forwardRef(function ComboBoxItem2(originalProps, ref) {
16
16
  const [
17
17
  { className, description, children, classNames, ...props },
18
18
  variantProps
19
- ] = mapPropsVariants(originalProps, comboBoxItemStyles.variantKeys);
20
- const styles = comboBoxItemStyles(variantProps);
19
+ ] = mapPropsVariants(originalProps, listBoxItemStyles.variantKeys);
20
+ const styles = listBoxItemStyles(variantProps);
21
21
  const defaultTextValue = useMemo(() => {
22
22
  if (props.textValue) {
23
23
  return props.textValue;
@@ -3,14 +3,15 @@
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useMemo, useCallback } from 'react';
5
5
  import { useMessageFormatter } from 'react-aria';
6
- import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Popover, Virtualizer, ListBox } from 'react-aria-components';
7
- import { comboBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
6
+ import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Virtualizer, ListBox } from 'react-aria-components';
7
+ import { listBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
8
8
  import { mapPropsVariants } from '../system/utils.js';
9
9
  import { ComboBoxVariantContext } from './combo-box-variant-context.js';
10
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';
14
+ import { Popover } from '../popover/popover.js';
14
15
 
15
16
  const calculateEstimatedRowHeight = (size) => {
16
17
  switch (size) {
@@ -44,7 +45,7 @@ function ComboBoxEmptyState({
44
45
  size,
45
46
  className
46
47
  }) {
47
- const styles = comboBoxItemStyles({ size });
48
+ const styles = listBoxItemStyles({ size });
48
49
  const formatMessage = useMessageFormatter(i18nStrings);
49
50
  return /* @__PURE__ */ jsx(
50
51
  "span",