@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,2 @@
1
+ "use strict";
2
+ export { Popover } from './popover.js';
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { useSlottedContext, PopoverContext, Popover as Popover$1, composeRenderProps, OverlayArrow } from 'react-aria-components';
5
+ import { popoverArrowStyles, popoverStyles } from '@opengovsg/oui-theme';
6
+
7
+ const Popover = ({
8
+ children,
9
+ showArrow,
10
+ className,
11
+ classNames,
12
+ ...props
13
+ }) => {
14
+ const popoverContext = useSlottedContext(PopoverContext);
15
+ const isSubmenu = popoverContext?.trigger === "SubmenuTrigger";
16
+ let offset = showArrow ? 12 : 8;
17
+ offset = isSubmenu ? offset - 6 : offset;
18
+ return /* @__PURE__ */ jsxs(
19
+ Popover$1,
20
+ {
21
+ offset,
22
+ ...props,
23
+ className: composeRenderProps(
24
+ className ?? classNames?.base,
25
+ (className2, renderProps) => popoverStyles({ ...renderProps, className: className2 })
26
+ ),
27
+ children: [
28
+ showArrow && /* @__PURE__ */ jsx(OverlayArrow, { className: "group", children: /* @__PURE__ */ jsx(
29
+ "svg",
30
+ {
31
+ width: 12,
32
+ height: 12,
33
+ viewBox: "0 0 12 12",
34
+ className: popoverArrowStyles({ className: classNames?.arrow }),
35
+ children: /* @__PURE__ */ jsx("path", { d: "M0 0 L6 6 L12 0" })
36
+ }
37
+ ) }),
38
+ children
39
+ ]
40
+ }
41
+ );
42
+ };
43
+
44
+ export { Popover };
@@ -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 };
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  "use client";
3
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { jsx } from 'react/jsx-runtime';
4
4
  import { useContextProps, ListBoxItem } from 'react-aria-components';
5
5
  import { selectItemStyles, composeRenderProps } from '@opengovsg/oui-theme';
6
6
  import { forwardRef, mapPropsVariants } from '../system/utils.js';
7
7
  import { SelectVariantContext } from './select-variant-context.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
8
 
10
9
  const SelectItem = forwardRef(function SelectItem2({ classNames, ...originalProps }, ref) {
11
10
  [originalProps, ref] = useContextProps(
@@ -21,6 +20,7 @@ const SelectItem = forwardRef(function SelectItem2({ classNames, ...originalProp
21
20
  return /* @__PURE__ */ jsx(
22
21
  ListBoxItem,
23
22
  {
23
+ textValue: typeof props.children === "string" ? props.children : void 0,
24
24
  ...props,
25
25
  ref,
26
26
  className: composeRenderProps(
@@ -31,29 +31,16 @@ const SelectItem = forwardRef(function SelectItem2({ classNames, ...originalProp
31
31
  if (typeof props.children === "function") {
32
32
  return props.children(renderProps);
33
33
  }
34
- return /* @__PURE__ */ jsxs(Fragment, { children: [
35
- /* @__PURE__ */ jsx(
36
- "span",
37
- {
38
- className: styles.text({
39
- className: classNames?.text,
40
- ...renderProps
41
- }),
42
- children: props.children
43
- }
44
- ),
45
- renderProps.isSelected && /* @__PURE__ */ jsx(
46
- "span",
47
- {
48
- "aria-hidden": true,
49
- className: styles.icon({
50
- className: classNames?.icon,
51
- ...renderProps
52
- }),
53
- children: /* @__PURE__ */ jsx(Check, {})
54
- }
55
- )
56
- ] });
34
+ return /* @__PURE__ */ jsx(
35
+ "span",
36
+ {
37
+ className: styles.text({
38
+ className: classNames?.text,
39
+ ...renderProps
40
+ }),
41
+ children: props.children
42
+ }
43
+ );
57
44
  }
58
45
  }
59
46
  );
@@ -2,12 +2,13 @@
2
2
  "use client";
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
4
  import { useMemo } from 'react';
5
- import { ListLayout, Provider, Select as Select$1, SelectValue, Popover, Virtualizer, ListBox } from 'react-aria-components';
5
+ import { Provider, Select as Select$1, SelectValue, Virtualizer, ListLayout, ListBox } from 'react-aria-components';
6
6
  import { selectStyles, composeRenderProps } from '@opengovsg/oui-theme';
7
7
  import { mapPropsVariants } from '../system/utils.js';
8
8
  import { SelectVariantContext } from './select-variant-context.js';
9
- import ChevronsUpDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js';
10
- import { Label, Description } from '../field/field.js';
9
+ import { Label, Description, FieldError } from '../field/field.js';
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
+ import { Popover } from '../popover/popover.js';
11
12
  import { Button } from '../button/button.js';
12
13
 
13
14
  const calculateEstimatedRowHeight = (size) => {
@@ -24,6 +25,7 @@ function Select({
24
25
  label,
25
26
  description,
26
27
  classNames,
28
+ errorMessage,
27
29
  ...originalProps
28
30
  }) {
29
31
  const [_props, variantProps] = mapPropsVariants(
@@ -32,13 +34,13 @@ function Select({
32
34
  );
33
35
  const { items, children, listLayoutOptions, ...props } = _props;
34
36
  const styles = selectStyles(variantProps);
35
- const layout = useMemo(() => {
36
- return new ListLayout({
37
+ const layoutOptions = useMemo(() => {
38
+ return {
37
39
  estimatedRowHeight: calculateEstimatedRowHeight(
38
40
  variantProps.size ?? "md"
39
41
  ),
40
42
  ...listLayoutOptions
41
- });
43
+ };
42
44
  }, [listLayoutOptions, variantProps.size]);
43
45
  return /* @__PURE__ */ jsx(Provider, { values: [[SelectVariantContext, variantProps]], children: /* @__PURE__ */ jsxs(
44
46
  Select$1,
@@ -69,7 +71,14 @@ function Select({
69
71
  })
70
72
  }
71
73
  ),
72
- /* @__PURE__ */ jsx(ChevronsUpDown, { className: "h-4 w-4" })
74
+ /* @__PURE__ */ jsx(
75
+ ChevronDown,
76
+ {
77
+ className: styles.icon({
78
+ className: classNames?.icon
79
+ })
80
+ }
81
+ )
73
82
  ]
74
83
  }
75
84
  ),
@@ -81,9 +90,11 @@ function Select({
81
90
  children: description
82
91
  }
83
92
  ),
84
- /* @__PURE__ */ jsx(Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsx(Virtualizer, { layout, children: /* @__PURE__ */ jsx(
93
+ /* @__PURE__ */ jsx(FieldError, { size: variantProps.size, className: classNames?.error, children: errorMessage }),
94
+ /* @__PURE__ */ jsx(Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsx(Virtualizer, { layout: ListLayout, layoutOptions, children: /* @__PURE__ */ jsx(
85
95
  ListBox,
86
96
  {
97
+ autoFocus: true,
87
98
  items,
88
99
  shouldFocusWrap: true,
89
100
  className: composeRenderProps(
@@ -5,9 +5,10 @@ function createContext(options = {}) {
5
5
  const {
6
6
  strict = true,
7
7
  errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider",
8
- name
8
+ name,
9
+ defaultValue
9
10
  } = options;
10
- const Context = createContext$1(void 0);
11
+ const Context = createContext$1(defaultValue);
11
12
  Context.displayName = name;
12
13
  function useContext$1() {
13
14
  const context = useContext(Context);
@@ -11,12 +11,15 @@ const mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
11
11
  if (!variantKeys) {
12
12
  return [props, {}];
13
13
  }
14
- const picked = variantKeys.reduce((acc, key) => {
15
- if (key in props) {
16
- return { ...acc, [key]: props[key] };
17
- }
18
- return acc;
19
- }, {});
14
+ const picked = variantKeys.reduce(
15
+ (acc, key) => {
16
+ if (key in props) {
17
+ return { ...acc, [key]: props[key] };
18
+ }
19
+ return acc;
20
+ },
21
+ {}
22
+ );
20
23
  if (removeVariantProps) {
21
24
  const omitted = Object.keys(props).filter((key) => !variantKeys.includes(key)).reduce((acc, key) => ({ ...acc, [key]: props[key] }), {});
22
25
  return [omitted, picked];
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  export { TagField } from './tag-field.js';
3
+ export { TagFieldItem } from './tag-field-item.js';
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { listBoxItemStyles, dataAttr } from '@opengovsg/oui-theme';
6
+ import { forwardRefGeneric } from '../system/utils.js';
7
+ import { TagFieldStateContext } from './tag-field-state-context.js';
8
+
9
+ const TagFieldItemInner = ({ item, isHighlighted, classNames, ...itemProps }, ref) => {
10
+ const { itemToText, size } = useContext(TagFieldStateContext);
11
+ const styles = listBoxItemStyles({ size });
12
+ return /* @__PURE__ */ jsx(
13
+ "li",
14
+ {
15
+ ref,
16
+ ...itemProps,
17
+ className: styles.container({
18
+ className: classNames?.container,
19
+ isFocused: isHighlighted,
20
+ isDisabled: itemProps["aria-disabled"]
21
+ }),
22
+ "data-rac": true,
23
+ "data-focused": dataAttr(isHighlighted),
24
+ "data-disabled": dataAttr(itemProps["aria-disabled"]),
25
+ children: /* @__PURE__ */ jsx("span", { className: styles.label({ className: classNames?.label }), children: itemToText(item) })
26
+ }
27
+ );
28
+ };
29
+ const TagFieldItem = forwardRefGeneric(TagFieldItemInner);
30
+
31
+ export { TagFieldItem };
@@ -3,27 +3,11 @@
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { createContext, useContext, createElement } from 'react';
5
5
  import { useContextProps } from 'react-aria-components';
6
- import { tagFieldItemStyles, dataAttr } from '@opengovsg/oui-theme';
7
6
  import { forwardRefGeneric } from '../system/utils.js';
7
+ import { TagFieldItem } from './tag-field-item.js';
8
8
  import { TagFieldStateContext } from './tag-field-state-context.js';
9
9
 
10
10
  const TagFieldListContext = createContext(null);
11
- const TagFieldListItemInner = ({ item, isHighlighted, classNames, ...itemProps }, ref) => {
12
- const { itemToText, size } = useContext(TagFieldStateContext);
13
- const styles = tagFieldItemStyles({ size });
14
- return /* @__PURE__ */ jsx(
15
- "li",
16
- {
17
- ref,
18
- ...itemProps,
19
- className: styles.container({ className: classNames?.container }),
20
- "data-rac": true,
21
- "data-hovered": dataAttr(isHighlighted),
22
- children: /* @__PURE__ */ jsx("span", { className: styles.label({ className: classNames?.label }), children: itemToText(item) })
23
- }
24
- );
25
- };
26
- const TagFieldListItem = forwardRefGeneric(TagFieldListItemInner);
27
11
  const TagFieldListInner = (props, ref) => {
28
12
  [props, ref] = useContextProps(props, ref, TagFieldListContext);
29
13
  const { items, getItemProps, highlightedIndex } = useContext(TagFieldStateContext);
@@ -55,16 +39,22 @@ const TagFieldListInner = (props, ref) => {
55
39
  item,
56
40
  isHighlighted: highlightedIndex === virtualRow.index,
57
41
  key: virtualRow.key,
58
- itemClassNames,
59
- ...itemProps
42
+ classNames: itemClassNames
60
43
  };
61
44
  if (typeof props.children === "function") {
62
- return props.children(childProps);
45
+ return props.children({ ...childProps, itemProps });
63
46
  }
64
- return /* @__PURE__ */ createElement(TagFieldListItem, { ...childProps, key: childProps.key });
47
+ return /* @__PURE__ */ createElement(
48
+ TagFieldItem,
49
+ {
50
+ ...childProps,
51
+ ...itemProps,
52
+ key: childProps.key
53
+ }
54
+ );
65
55
  })
66
56
  ] }) });
67
57
  };
68
58
  const TagFieldList = forwardRefGeneric(TagFieldListInner);
69
59
 
70
- export { TagFieldList, TagFieldListContext, TagFieldListItem };
60
+ export { TagFieldList, TagFieldListContext };
@@ -13,7 +13,8 @@ const TagFieldTagList = ({
13
13
  getSelectedItemProps,
14
14
  removeSelectedItem,
15
15
  isDisabled,
16
- isReadOnly
16
+ isReadOnly,
17
+ itemToText
17
18
  } = useContext(TagFieldStateContext);
18
19
  const handleRemoveSelectedItem = useCallback(
19
20
  (item) => () => {
@@ -47,7 +48,7 @@ const TagFieldTagList = ({
47
48
  className: classNames?.tag,
48
49
  ...itemProps,
49
50
  children: [
50
- /* @__PURE__ */ jsx("span", { className: classNames?.tagText, children: selectedItem.textValue }),
51
+ /* @__PURE__ */ jsx("span", { className: classNames?.tagText, children: itemToText(selectedItem) }),
51
52
  /* @__PURE__ */ jsx(
52
53
  X,
53
54
  {
@@ -2,15 +2,17 @@
2
2
  "use client";
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { createElement } from 'react';
5
- import { composeRenderProps, Popover } from 'react-aria-components';
5
+ import { composeRenderProps } from 'react-aria-components';
6
6
  import { tagFieldStyles } from '@opengovsg/oui-theme';
7
- import { Input } from '../input/input.js';
8
- import { TagFieldList, TagFieldListItem } from './tag-field-list.js';
7
+ import { TagFieldItem } from './tag-field-item.js';
8
+ import { TagFieldList } from './tag-field-list.js';
9
9
  import { TagFieldRoot } from './tag-field-root.js';
10
10
  import { TagFieldTagList } from './tag-field-tag-list.js';
11
11
  import { TagFieldTrigger } from './tag-field-trigger.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 { Label, FieldGroup, Description, FieldError } from '../field/field.js';
14
+ import { Input } from '../input/input.js';
15
+ import { Popover } from '../popover/popover.js';
14
16
 
15
17
  function TagField({
16
18
  classNames,
@@ -90,12 +92,12 @@ function TagField({
90
92
  }
91
93
  )
92
94
  ] }),
93
- /* @__PURE__ */ jsx(Popover, { children: /* @__PURE__ */ jsx(
95
+ /* @__PURE__ */ jsx(Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsx(
94
96
  TagFieldList,
95
97
  {
96
98
  className: styles.list({ className: classNames?.list }),
97
99
  itemClassNames: props.itemClassNames,
98
- children: ({ key, ...props2 }) => children ? children({ key, ...props2 }) : /* @__PURE__ */ createElement(TagFieldListItem, { ...props2, key })
100
+ children: ({ key, itemProps, ...props2 }) => children ? children({ key, itemProps, ...props2 }) : /* @__PURE__ */ createElement(TagFieldItem, { ...props2, ...itemProps, key })
99
101
  }
100
102
  ) })
101
103
  ] });
@@ -30,6 +30,11 @@ export interface ButtonProps extends Omit<AriaButtonProps, "children">, ButtonVa
30
30
  * @defaultValue "start"
31
31
  */
32
32
  spinnerPlacement?: "start" | "end";
33
+ /**
34
+ * Whether the button only contains an icon.
35
+ * If true, you must provide an `aria-label` for accessibility.
36
+ */
37
+ isIconOnly?: boolean;
33
38
  }
34
39
  /**
35
40
  * You probably do not want to use this component if you are rendering a link.
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/button/button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAK3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAO9D,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,EACvC,kBAAkB;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;CACnC;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,2GAwElB,CAAA"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/button/button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAK3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAO9D,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,EACvC,kBAAkB;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC9B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IAElC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,2GAwElB,CAAA"}
@@ -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"}
@@ -0,0 +1,12 @@
1
+ import type { CalendarDate } from "@internationalized/date";
2
+ import type { RangeCalendarProps } from "react-aria-components";
3
+ import type { calendarStyles } from "@opengovsg/oui-theme";
4
+ import type { CalendarProps } from "./types";
5
+ export interface UseProvideCalendarStylesReturn<T extends CalendarDate> {
6
+ slots: ReturnType<typeof calendarStyles>;
7
+ classNames: CalendarProps<T>["classNames"];
8
+ className: CalendarProps<T>["className"] | RangeCalendarProps<T>["className"];
9
+ size: CalendarProps<T>["size"];
10
+ }
11
+ export declare const CalendarStyleContext: import("react").Context<UseProvideCalendarStylesReturn<CalendarDate>>, useCalendarStyleContext: () => UseProvideCalendarStylesReturn<CalendarDate>;
12
+ //# sourceMappingURL=calendar-style-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-style-context.d.ts","sourceRoot":"","sources":["../../../src/calendar/calendar-style-context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C,MAAM,WAAW,8BAA8B,CAAC,CAAC,SAAS,YAAY;IACpE,KAAK,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;IACxC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;IAC1C,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IAC7E,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;CAC/B;AAED,eAAO,MAAO,oBAAoB,yEAAE,uBAAuB,oDAKzD,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from "react";
2
+ import { CalendarDate } from "@internationalized/date";
3
+ import type { CalendarProps } from "./types";
4
+ export declare const Calendar: <T extends CalendarDate>(props: CalendarProps<T>) => ReactElement;
5
+ export declare const CalendarStateWrapper: ({ children, }: {
6
+ children: React.ReactNode;
7
+ }) => import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/calendar/calendar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,OAAO,CAAA;AAEvD,OAAO,EAAE,YAAY,EAA2B,MAAM,yBAAyB,CAAA;AAe/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAQ5C,eAAO,MAAM,QAAQ,EA8Hf,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,YAAY,CAAA;AAEvE,eAAO,MAAM,oBAAoB,kBAE9B;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,4CAQA,CAAA"}