@opengovsg/oui 0.0.8 → 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 (138) 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 +13 -0
  8. package/dist/cjs/calendar/calendar.cjs +155 -0
  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 +22 -0
  13. package/dist/cjs/calendar/types.cjs +3 -0
  14. package/dist/cjs/calendar/utils.cjs +62 -0
  15. package/dist/cjs/combo-box/combo-box-fuzzy.cjs +3 -3
  16. package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
  17. package/dist/cjs/combo-box/combo-box.cjs +3 -2
  18. package/dist/cjs/index.cjs +53 -20
  19. package/dist/cjs/menu/index.cjs +15 -0
  20. package/dist/cjs/menu/menu.cjs +229 -0
  21. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/{chevrons-up-down.cjs → chevron-left.cjs} +3 -6
  22. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-right.cjs +19 -0
  23. package/dist/cjs/popover/index.cjs +8 -0
  24. package/dist/cjs/popover/popover.cjs +46 -0
  25. package/dist/cjs/range-calendar/index.cjs +10 -0
  26. package/dist/cjs/range-calendar/range-calendar.cjs +188 -0
  27. package/dist/cjs/select/select-item.cjs +11 -24
  28. package/dist/cjs/select/select.cjs +17 -6
  29. package/dist/cjs/system/react-utils/context.cjs +3 -2
  30. package/dist/cjs/system/utils.cjs +9 -6
  31. package/dist/cjs/tag-field/index.cjs +2 -0
  32. package/dist/cjs/tag-field/tag-field-item.cjs +33 -0
  33. package/dist/cjs/tag-field/tag-field-list.cjs +11 -22
  34. package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -2
  35. package/dist/cjs/tag-field/tag-field.cjs +5 -3
  36. package/dist/esm/button/button.js +1 -1
  37. package/dist/esm/calendar/agnostic-calendar-state-context.js +10 -0
  38. package/dist/esm/calendar/calendar-bottom-content.js +49 -0
  39. package/dist/esm/calendar/calendar-grid-header.js +26 -0
  40. package/dist/esm/calendar/calendar-header.js +72 -0
  41. package/dist/esm/calendar/calendar-month-day-selector.js +84 -0
  42. package/dist/esm/calendar/calendar-style-context.js +10 -0
  43. package/dist/esm/calendar/calendar.js +152 -0
  44. package/dist/esm/calendar/hooks/index.js +3 -0
  45. package/dist/esm/calendar/hooks/use-calendar-i18n.js +30 -0
  46. package/dist/esm/calendar/hooks/use-calendar-selectors.js +39 -0
  47. package/dist/esm/calendar/index.js +5 -0
  48. package/dist/esm/calendar/types.js +1 -0
  49. package/dist/esm/calendar/utils.js +57 -0
  50. package/dist/esm/combo-box/combo-box-fuzzy.js +4 -4
  51. package/dist/esm/combo-box/combo-box-item.js +3 -3
  52. package/dist/esm/combo-box/combo-box.js +4 -3
  53. package/dist/esm/index.js +17 -9
  54. package/dist/esm/menu/index.js +2 -0
  55. package/dist/esm/menu/menu.js +220 -0
  56. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-left.js +14 -0
  57. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-right.js +14 -0
  58. package/dist/esm/popover/index.js +2 -0
  59. package/dist/esm/popover/popover.js +44 -0
  60. package/dist/esm/range-calendar/index.js +2 -0
  61. package/dist/esm/range-calendar/range-calendar.js +184 -0
  62. package/dist/esm/select/select-item.js +12 -25
  63. package/dist/esm/select/select.js +19 -8
  64. package/dist/esm/system/react-utils/context.js +3 -2
  65. package/dist/esm/system/utils.js +9 -6
  66. package/dist/esm/tag-field/index.js +1 -0
  67. package/dist/esm/tag-field/tag-field-item.js +31 -0
  68. package/dist/esm/tag-field/tag-field-list.js +12 -22
  69. package/dist/esm/tag-field/tag-field-tag-list.js +3 -2
  70. package/dist/esm/tag-field/tag-field.js +7 -5
  71. package/dist/types/button/button.d.ts +5 -0
  72. package/dist/types/button/button.d.ts.map +1 -1
  73. package/dist/types/calendar/agnostic-calendar-state-context.d.ts +3 -0
  74. package/dist/types/calendar/agnostic-calendar-state-context.d.ts.map +1 -0
  75. package/dist/types/calendar/calendar-bottom-content.d.ts +4 -0
  76. package/dist/types/calendar/calendar-bottom-content.d.ts.map +1 -0
  77. package/dist/types/calendar/calendar-grid-header.d.ts +2 -0
  78. package/dist/types/calendar/calendar-grid-header.d.ts.map +1 -0
  79. package/dist/types/calendar/calendar-header.d.ts +6 -0
  80. package/dist/types/calendar/calendar-header.d.ts.map +1 -0
  81. package/dist/types/calendar/calendar-month-day-selector.d.ts +2 -0
  82. package/dist/types/calendar/calendar-month-day-selector.d.ts.map +1 -0
  83. package/dist/types/calendar/calendar-style-context.d.ts +12 -0
  84. package/dist/types/calendar/calendar-style-context.d.ts.map +1 -0
  85. package/dist/types/calendar/calendar.d.ts +8 -0
  86. package/dist/types/calendar/calendar.d.ts.map +1 -0
  87. package/dist/types/calendar/hooks/index.d.ts +3 -0
  88. package/dist/types/calendar/hooks/index.d.ts.map +1 -0
  89. package/dist/types/calendar/hooks/use-calendar-i18n.d.ts +4 -0
  90. package/dist/types/calendar/hooks/use-calendar-i18n.d.ts.map +1 -0
  91. package/dist/types/calendar/hooks/use-calendar-selectors.d.ts +13 -0
  92. package/dist/types/calendar/hooks/use-calendar-selectors.d.ts.map +1 -0
  93. package/dist/types/calendar/index.d.ts +6 -0
  94. package/dist/types/calendar/index.d.ts.map +1 -0
  95. package/dist/types/calendar/types.d.ts +59 -0
  96. package/dist/types/calendar/types.d.ts.map +1 -0
  97. package/dist/types/calendar/utils.d.ts +13 -0
  98. package/dist/types/calendar/utils.d.ts.map +1 -0
  99. package/dist/types/combo-box/combo-box-fuzzy.d.ts +2 -2
  100. package/dist/types/combo-box/combo-box-fuzzy.d.ts.map +1 -1
  101. package/dist/types/combo-box/combo-box-item.d.ts +3 -3
  102. package/dist/types/combo-box/combo-box-item.d.ts.map +1 -1
  103. package/dist/types/combo-box/combo-box.d.ts.map +1 -1
  104. package/dist/types/index.d.mts +4 -0
  105. package/dist/types/index.d.ts +4 -0
  106. package/dist/types/index.d.ts.map +1 -1
  107. package/dist/types/menu/index.d.ts +2 -0
  108. package/dist/types/menu/index.d.ts.map +1 -0
  109. package/dist/types/menu/menu.d.ts +38 -0
  110. package/dist/types/menu/menu.d.ts.map +1 -0
  111. package/dist/types/popover/index.d.ts +2 -0
  112. package/dist/types/popover/index.d.ts.map +1 -0
  113. package/dist/types/popover/popover.d.ts +21 -0
  114. package/dist/types/popover/popover.d.ts.map +1 -0
  115. package/dist/types/range-calendar/index.d.ts +2 -0
  116. package/dist/types/range-calendar/index.d.ts.map +1 -0
  117. package/dist/types/range-calendar/range-calendar.d.ts +69 -0
  118. package/dist/types/range-calendar/range-calendar.d.ts.map +1 -0
  119. package/dist/types/select/select-item.d.ts.map +1 -1
  120. package/dist/types/select/select.d.ts +4 -3
  121. package/dist/types/select/select.d.ts.map +1 -1
  122. package/dist/types/system/react-utils/context.d.ts +3 -2
  123. package/dist/types/system/react-utils/context.d.ts.map +1 -1
  124. package/dist/types/system/utils.d.ts.map +1 -1
  125. package/dist/types/tag-field/index.d.ts +1 -0
  126. package/dist/types/tag-field/index.d.ts.map +1 -1
  127. package/dist/types/tag-field/tag-field-item.d.ts +7 -0
  128. package/dist/types/tag-field/tag-field-item.d.ts.map +1 -0
  129. package/dist/types/tag-field/tag-field-list.d.ts +2 -6
  130. package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
  131. package/dist/types/tag-field/tag-field-state-context.d.ts +1 -2
  132. package/dist/types/tag-field/tag-field-state-context.d.ts.map +1 -1
  133. package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -1
  134. package/dist/types/tag-field/tag-field.d.ts.map +1 -1
  135. package/dist/types/tag-field/types.d.ts +8 -6
  136. package/dist/types/tag-field/types.d.ts.map +1 -1
  137. package/package.json +8 -7
  138. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js +0 -17
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ "use client";
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';
15
+
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
+ );
144
+ });
145
+ const CalendarStateWrapper = ({
146
+ children
147
+ }) => {
148
+ const state = useContext(CalendarStateContext);
149
+ return /* @__PURE__ */ jsx(Provider, { values: [[AgnosticCalendarStateContext, state]], children });
150
+ };
151
+
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 };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ export { Calendar, CalendarStateWrapper } from './calendar.js';
3
+ export { CalendarStyleContext, useCalendarStyleContext } from './calendar-style-context.js';
4
+ export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './utils.js';
5
+ export { CalendarDate } from '@internationalized/date';
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ import { useMemo } from 'react';
3
+ import { CalendarDate } from '@internationalized/date';
4
+ import { useDateFormatter } from '@react-aria/i18n';
5
+
6
+ function getEraFormat(date) {
7
+ return date?.calendar.identifier === "gregory" && date.era === "BC" ? "short" : void 0;
8
+ }
9
+ function useLocalizedMonthYear(date, timeZone) {
10
+ const era = getEraFormat(date);
11
+ const monthFormatter = useDateFormatter({
12
+ month: "long",
13
+ year: "numeric",
14
+ era,
15
+ calendar: date.calendar.identifier,
16
+ timeZone
17
+ });
18
+ return monthFormatter.format(date.toDate(timeZone));
19
+ }
20
+ function useGenerateLocalizedMonths(timeZone, formatterOptions) {
21
+ const formatter = useDateFormatter({
22
+ month: "long",
23
+ timeZone,
24
+ ...formatterOptions
25
+ });
26
+ return useMemo(() => {
27
+ return Array.from({ length: 12 }, (_, i) => {
28
+ const id = i + 1;
29
+ return {
30
+ id,
31
+ textValue: formatter.format(
32
+ new CalendarDate(2020, id, 1).toDate(timeZone)
33
+ )
34
+ };
35
+ });
36
+ }, [formatter, timeZone]);
37
+ }
38
+ function useGenerateLocalizedYears(yearStart, yearEnd, timeZone, formatterOptions) {
39
+ const formatter = useDateFormatter({
40
+ year: "numeric",
41
+ timeZone,
42
+ ...formatterOptions
43
+ });
44
+ return useMemo(() => {
45
+ return Array.from({ length: yearEnd - yearStart + 1 }, (_, i) => {
46
+ const year = yearStart + i;
47
+ return {
48
+ id: year,
49
+ textValue: formatter.format(
50
+ new CalendarDate(year, 1, 1).toDate(timeZone)
51
+ )
52
+ };
53
+ });
54
+ }, [formatter, yearStart, yearEnd, timeZone]);
55
+ }
56
+
57
+ export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear };
@@ -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",
package/dist/esm/index.js CHANGED
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- export { Input } from './input/input.js';
3
- export { useControllableState } from './hooks/use-controllable-state.js';
4
- export { Button } from './button/button.js';
5
- export { GovtBanner } from './govt-banner/govt-banner.js';
6
2
  export { Ripple } from './ripple/ripple.js';
7
3
  export { useRipple } from './ripple/use-ripple.js';
8
4
  export { Spinner } from './spinner/spinner.js';
@@ -10,16 +6,28 @@ export { useSpinner } from './spinner/use-spinner.js';
10
6
  export { Toggle } from './toggle/toggle.js';
11
7
  export { SkipNavLink } from './skip-nav-link/skip-nav-link.js';
12
8
  export { TextField } from './text-field/text-field.js';
13
- export { Description, FieldError, FieldGroup, Label } from './field/field.js';
14
9
  export { TextArea } from './text-area/text-area.js';
15
10
  export { TextAreaField } from './text-area-field/text-area-field.js';
11
+ export { TagField } from './tag-field/tag-field.js';
12
+ export { TagFieldItem } from './tag-field/tag-field-item.js';
13
+ export { Select } from './select/select.js';
14
+ export { SelectItem } from './select/select-item.js';
15
+ export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
16
+ export { useControllableState } from './hooks/use-controllable-state.js';
17
+ export { Button } from './button/button.js';
18
+ export { GovtBanner } from './govt-banner/govt-banner.js';
19
+ export { Input } from './input/input.js';
20
+ export { Description, FieldError, FieldGroup, Label } from './field/field.js';
16
21
  export { ComboBox, ComboBoxEmptyState } from './combo-box/combo-box.js';
17
22
  export { ComboBoxFuzzy } from './combo-box/combo-box-fuzzy.js';
18
23
  export { ComboBoxItem } from './combo-box/combo-box-item.js';
19
24
  export { ComboBoxVariantContext, useComboBoxVariantContext } from './combo-box/combo-box-variant-context.js';
20
25
  export { Banner } from './banner/banner.js';
21
- export { TagField } from './tag-field/tag-field.js';
22
- export { Select } from './select/select.js';
23
- export { SelectItem } from './select/select-item.js';
24
- export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
25
26
  export { Badge } from './badge/badge.js';
27
+ export { CalendarDate } from '@internationalized/date';
28
+ export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
29
+ export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
30
+ export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
31
+ export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
32
+ export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
33
+ export { Popover } from './popover/popover.js';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu.js';
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { forwardRef, useMemo, useCallback } from 'react';
5
+ import { useContextProps, MenuItem as MenuItem$1, composeRenderProps, Provider, Menu as Menu$1, MenuSection as MenuSection$1, Header, Collection, MenuTrigger as MenuTrigger$1, SubmenuTrigger as SubmenuTrigger$1, Separator } from 'react-aria-components';
6
+ import { listBoxItemStyles, menuItemStyles, menuStyles, menuSectionStyles, menuDividerStyles } from '@opengovsg/oui-theme';
7
+ import { forwardRefGeneric, mapPropsVariants } from '../system/utils.js';
8
+ import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.js';
9
+ 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';
10
+ import { createContext } from '../system/react-utils/context.js';
11
+ import { Popover } from '../popover/popover.js';
12
+
13
+ const [MenuVariantContext, useMenuVariantContext] = createContext({
14
+ name: "MenuVariantContext",
15
+ strict: false
16
+ });
17
+ function MenuInner(originalProps, ref) {
18
+ [originalProps, ref] = useContextProps(
19
+ originalProps,
20
+ ref,
21
+ MenuVariantContext
22
+ );
23
+ const [props, variantProps] = mapPropsVariants(
24
+ originalProps,
25
+ menuStyles.variantKeys
26
+ );
27
+ const { className, classNames, placement, ...rest } = props;
28
+ const styles = menuStyles(variantProps);
29
+ return /* @__PURE__ */ jsx(Provider, { values: [[MenuVariantContext, variantProps]], children: /* @__PURE__ */ jsx(
30
+ Popover,
31
+ {
32
+ placement,
33
+ className: styles.popover({ className: classNames?.popover }),
34
+ children: /* @__PURE__ */ jsx(
35
+ Menu$1,
36
+ {
37
+ ...rest,
38
+ ref,
39
+ className: composeRenderProps(
40
+ className ?? classNames?.base,
41
+ (className2, renderProps) => styles.base({
42
+ className: className2,
43
+ ...renderProps
44
+ })
45
+ )
46
+ }
47
+ )
48
+ }
49
+ ) });
50
+ }
51
+ const Menu = forwardRefGeneric(MenuInner);
52
+ const MenuItem = forwardRef(function MenuItem2(originalProps, ref) {
53
+ [originalProps, ref] = useContextProps(
54
+ originalProps,
55
+ ref,
56
+ MenuVariantContext
57
+ );
58
+ const [
59
+ {
60
+ classNames,
61
+ className,
62
+ multipleSelectionIcon: multipleSelectionIconProp,
63
+ singleSelectionIcon: singleSelectionIconProp,
64
+ startContent,
65
+ endContent,
66
+ ...props
67
+ },
68
+ variantProps
69
+ ] = mapPropsVariants(originalProps, listBoxItemStyles.variantKeys);
70
+ const styles = menuItemStyles(variantProps);
71
+ const multipleSelectionIcon = useMemo(() => {
72
+ if (multipleSelectionIconProp !== void 0) {
73
+ return multipleSelectionIconProp;
74
+ }
75
+ return /* @__PURE__ */ jsx(
76
+ Check,
77
+ {
78
+ "aria-hidden": true,
79
+ className: styles.icon({ className: classNames?.icon })
80
+ }
81
+ );
82
+ }, [classNames?.icon, multipleSelectionIconProp, styles]);
83
+ const singleSelectionIcon = useMemo(() => {
84
+ if (singleSelectionIconProp !== void 0) {
85
+ return singleSelectionIconProp;
86
+ }
87
+ return /* @__PURE__ */ jsx(
88
+ Check,
89
+ {
90
+ "aria-hidden": true,
91
+ className: styles.icon({ className: classNames?.icon })
92
+ }
93
+ );
94
+ }, [classNames?.icon, singleSelectionIconProp, styles]);
95
+ const showIconContainer = useCallback(
96
+ (selectionMode) => {
97
+ switch (selectionMode) {
98
+ case "none":
99
+ return false;
100
+ case "multiple":
101
+ return !!multipleSelectionIcon;
102
+ case "single":
103
+ return !!singleSelectionIcon;
104
+ }
105
+ },
106
+ [multipleSelectionIcon, singleSelectionIcon]
107
+ );
108
+ const defaultTextValue = useMemo(() => {
109
+ if (props.textValue) {
110
+ return props.textValue;
111
+ }
112
+ if (typeof props.children === "string") {
113
+ return props.children;
114
+ }
115
+ return void 0;
116
+ }, [props.children, props.textValue]);
117
+ return /* @__PURE__ */ jsx(
118
+ MenuItem$1,
119
+ {
120
+ ref,
121
+ textValue: defaultTextValue,
122
+ ...props,
123
+ isDisabled: variantProps.isDisabled,
124
+ className: composeRenderProps(
125
+ className ?? classNames?.container,
126
+ (className2, renderProps) => styles.container({
127
+ className: className2,
128
+ ...renderProps
129
+ })
130
+ ),
131
+ children: composeRenderProps(
132
+ props.children,
133
+ (children, { selectionMode, isSelected, hasSubmenu }) => /* @__PURE__ */ jsxs(Fragment, { children: [
134
+ startContent,
135
+ /* @__PURE__ */ jsx(
136
+ "span",
137
+ {
138
+ className: styles.label({
139
+ className: classNames?.label
140
+ }),
141
+ children
142
+ }
143
+ ),
144
+ showIconContainer(selectionMode) && /* @__PURE__ */ jsxs(
145
+ "span",
146
+ {
147
+ className: styles.iconContainer({
148
+ className: classNames?.iconContainer
149
+ }),
150
+ children: [
151
+ isSelected && selectionMode === "multiple" && multipleSelectionIcon,
152
+ isSelected && selectionMode === "single" && singleSelectionIcon
153
+ ]
154
+ }
155
+ ),
156
+ endContent,
157
+ hasSubmenu && /* @__PURE__ */ jsx(
158
+ ChevronRight,
159
+ {
160
+ "aria-hidden": true,
161
+ className: styles.icon({
162
+ className: classNames?.icon
163
+ })
164
+ }
165
+ )
166
+ ] })
167
+ )
168
+ }
169
+ );
170
+ });
171
+ function MenuSeparator(props) {
172
+ return /* @__PURE__ */ jsx(
173
+ Separator,
174
+ {
175
+ ...props,
176
+ className: menuDividerStyles({
177
+ className: props.className
178
+ })
179
+ }
180
+ );
181
+ }
182
+ function MenuSectionInner(originalProps, ref) {
183
+ [originalProps, ref] = useContextProps(
184
+ originalProps,
185
+ ref,
186
+ MenuVariantContext
187
+ );
188
+ const [{ title, classNames, ...props }, variantProps] = mapPropsVariants(
189
+ originalProps,
190
+ menuSectionStyles.variantKeys
191
+ );
192
+ const styles = menuSectionStyles(variantProps);
193
+ return /* @__PURE__ */ jsxs(
194
+ MenuSection$1,
195
+ {
196
+ ref,
197
+ className: styles.base({
198
+ className: props.className ?? classNames?.base
199
+ }),
200
+ ...props,
201
+ children: [
202
+ title && /* @__PURE__ */ jsx(
203
+ Header,
204
+ {
205
+ className: styles.header({
206
+ className: classNames?.header
207
+ }),
208
+ children: title
209
+ }
210
+ ),
211
+ /* @__PURE__ */ jsx(Collection, { items: props.items, children: props.children })
212
+ ]
213
+ }
214
+ );
215
+ }
216
+ const MenuSection = forwardRefGeneric(MenuSectionInner);
217
+ const MenuTrigger = MenuTrigger$1;
218
+ const SubmenuTrigger = SubmenuTrigger$1;
219
+
220
+ export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext };
@@ -0,0 +1,14 @@
1
+ import createLucideIcon from '../createLucideIcon.js';
2
+
3
+ /**
4
+ * @license lucide-react v0.475.0 - ISC
5
+ *
6
+ * This source code is licensed under the ISC license.
7
+ * See the LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ const __iconNode = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
12
+ const ChevronLeft = createLucideIcon("ChevronLeft", __iconNode);
13
+
14
+ export { __iconNode, ChevronLeft as default };
@@ -0,0 +1,14 @@
1
+ import createLucideIcon from '../createLucideIcon.js';
2
+
3
+ /**
4
+ * @license lucide-react v0.475.0 - ISC
5
+ *
6
+ * This source code is licensed under the ISC license.
7
+ * See the LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ const __iconNode = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
12
+ const ChevronRight = createLucideIcon("ChevronRight", __iconNode);
13
+
14
+ export { __iconNode, ChevronRight as default };