@opengovsg/oui 0.0.47 → 0.0.49

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 (87) hide show
  1. package/dist/cjs/banner/banner.cjs +1 -1
  2. package/dist/cjs/checkbox/checkbox.cjs +34 -26
  3. package/dist/cjs/date-picker/date-picker.cjs +2 -3
  4. package/dist/cjs/date-range-picker/date-range-picker.cjs +1 -1
  5. package/dist/cjs/file-dropzone/file-info.cjs +1 -1
  6. package/dist/cjs/index.cjs +65 -59
  7. package/dist/cjs/infobox/index.cjs +8 -0
  8. package/dist/cjs/infobox/infobox.cjs +39 -0
  9. package/dist/cjs/infobox/use-infobox.cjs +32 -0
  10. package/dist/cjs/modal/modal-content.cjs +1 -1
  11. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/circle-check.cjs +22 -0
  12. package/dist/cjs/number-field/number-field.cjs +1 -1
  13. package/dist/cjs/pagination/index.cjs +5 -5
  14. package/dist/cjs/radio-group/index.cjs +9 -0
  15. package/dist/cjs/radio-group/radio-group-variant-context.cjs +15 -0
  16. package/dist/cjs/radio-group/radio.cjs +99 -0
  17. package/dist/cjs/range-calendar/range-calendar.cjs +1 -1
  18. package/dist/cjs/search-field/search-field.cjs +1 -1
  19. package/dist/cjs/select/select.cjs +1 -1
  20. package/dist/cjs/sidebar/sidebar-list.cjs +1 -1
  21. package/dist/cjs/tabs/index.cjs +1 -0
  22. package/dist/cjs/tabs/tabs.cjs +2 -0
  23. package/dist/cjs/tag-field/tag-field-list.cjs +25 -5
  24. package/dist/cjs/tag-field/use-tag-field.cjs +15 -4
  25. package/dist/cjs/tooltip/tooltip.cjs +7 -9
  26. package/dist/esm/accordion/accordion.js +1 -1
  27. package/dist/esm/badge/use-badge.js +1 -1
  28. package/dist/esm/banner/banner.js +1 -1
  29. package/dist/esm/breadcrumbs/breadcrumbs.js +2 -2
  30. package/dist/esm/calendar/calendar.js +1 -1
  31. package/dist/esm/checkbox/checkbox.js +34 -26
  32. package/dist/esm/combo-box/combo-box-item.js +1 -1
  33. package/dist/esm/combo-box/combo-box.js +1 -1
  34. package/dist/esm/date-picker/date-picker.js +2 -3
  35. package/dist/esm/date-range-picker/date-range-picker.js +1 -1
  36. package/dist/esm/file-dropzone/file-info.js +1 -1
  37. package/dist/esm/index.js +16 -14
  38. package/dist/esm/infobox/index.js +2 -0
  39. package/dist/esm/infobox/infobox.js +37 -0
  40. package/dist/esm/infobox/use-infobox.js +30 -0
  41. package/dist/esm/modal/modal-content.js +1 -1
  42. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/circle-check.js +17 -0
  43. package/dist/esm/number-field/number-field.js +2 -2
  44. package/dist/esm/pagination/use-pagination-item.js +1 -1
  45. package/dist/esm/phone-number-field/phone-number-field.js +4 -4
  46. package/dist/esm/popover/popover.js +1 -1
  47. package/dist/esm/radio-group/index.js +2 -0
  48. package/dist/esm/radio-group/radio-group-variant-context.js +12 -0
  49. package/dist/esm/radio-group/radio.js +96 -0
  50. package/dist/esm/range-calendar/range-calendar.js +1 -1
  51. package/dist/esm/search-field/search-field.js +1 -1
  52. package/dist/esm/select/select.js +1 -1
  53. package/dist/esm/sidebar/sidebar-list.js +1 -1
  54. package/dist/esm/tabs/index.js +1 -1
  55. package/dist/esm/tabs/tabs.js +4 -3
  56. package/dist/esm/tag-field/tag-field-list.js +25 -5
  57. package/dist/esm/tag-field/use-tag-field.js +15 -4
  58. package/dist/esm/tooltip/tooltip.js +5 -7
  59. package/dist/types/checkbox/checkbox.d.ts +3 -3
  60. package/dist/types/checkbox/checkbox.d.ts.map +1 -1
  61. package/dist/types/index.d.mts +2 -0
  62. package/dist/types/index.d.ts +2 -0
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/dist/types/infobox/index.d.ts +2 -0
  65. package/dist/types/infobox/index.d.ts.map +1 -0
  66. package/dist/types/infobox/infobox.d.ts +5 -0
  67. package/dist/types/infobox/infobox.d.ts.map +1 -0
  68. package/dist/types/infobox/use-infobox.d.ts +54 -0
  69. package/dist/types/infobox/use-infobox.d.ts.map +1 -0
  70. package/dist/types/radio-group/index.d.ts +3 -0
  71. package/dist/types/radio-group/index.d.ts.map +1 -0
  72. package/dist/types/radio-group/radio-group-variant-context.d.ts +6 -0
  73. package/dist/types/radio-group/radio-group-variant-context.d.ts.map +1 -0
  74. package/dist/types/radio-group/radio.d.ts +39 -0
  75. package/dist/types/radio-group/radio.d.ts.map +1 -0
  76. package/dist/types/system/react-utils/children.d.ts +1 -1
  77. package/dist/types/system/react-utils/children.d.ts.map +1 -1
  78. package/dist/types/tabs/tabs.d.ts +1 -0
  79. package/dist/types/tabs/tabs.d.ts.map +1 -1
  80. package/dist/types/tag-field/tag-field-list.d.ts +1 -1
  81. package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
  82. package/dist/types/tag-field/types.d.ts +7 -0
  83. package/dist/types/tag-field/types.d.ts.map +1 -1
  84. package/dist/types/tag-field/use-tag-field.d.ts +1 -1
  85. package/dist/types/tag-field/use-tag-field.d.ts.map +1 -1
  86. package/dist/types/tooltip/tooltip.d.ts.map +1 -1
  87. package/package.json +4 -4
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ import { useMemo } from 'react';
3
+ import { useDeepCompareMemo } from 'use-deep-compare';
4
+ import { infoboxStyles } from '@opengovsg/oui-theme';
5
+ import { mapPropsVariants } from '../system/utils.js';
6
+
7
+ function useInfobox(originalProps) {
8
+ const [_props, variantProps] = mapPropsVariants(
9
+ originalProps,
10
+ infoboxStyles.variantKeys
11
+ );
12
+ const { children, as, classNames, icon } = _props;
13
+ const Component = useMemo(() => as || "div", [as]);
14
+ const slots = useDeepCompareMemo(
15
+ () => ({
16
+ ...infoboxStyles({ ...variantProps })
17
+ }),
18
+ [variantProps, infoboxStyles]
19
+ );
20
+ return {
21
+ Component,
22
+ children,
23
+ slots,
24
+ classNames,
25
+ icon,
26
+ variant: variantProps.variant
27
+ };
28
+ }
29
+
30
+ export { useInfobox };
@@ -5,10 +5,10 @@ import { useContext, isValidElement } from 'react';
5
5
  import { useLocalizedStringFormatter } from 'react-aria';
6
6
  import { Dialog } from 'react-aria-components';
7
7
  import { cn } from '@opengovsg/oui-theme';
8
- import { Button } from '../button/button.js';
9
8
  import { i18nStrings } from './i18n.js';
10
9
  import { ModalVariantContext } from './modal-variant-context.js';
11
10
  import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js';
11
+ import { Button } from '../button/button.js';
12
12
 
13
13
  function ModalContent({
14
14
  closeButtonContent: closeButtonContentProp,
@@ -0,0 +1,17 @@
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 = [
12
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
13
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
14
+ ];
15
+ const CircleCheck = createLucideIcon("CircleCheck", __iconNode);
16
+
17
+ export { __iconNode, CircleCheck as default };
@@ -2,13 +2,13 @@
2
2
  "use client";
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
  import { NumberField as NumberField$1 } from 'react-aria-components';
5
- import { numberFieldStyles, composeTailwindRenderProps, dataAttr, fieldBorderStyles, cn } from '@opengovsg/oui-theme';
6
- import { Button } from '../button/button.js';
5
+ import { numberFieldStyles, fieldBorderStyles, cn, composeTailwindRenderProps, dataAttr } from '@opengovsg/oui-theme';
7
6
  import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
8
7
  import { Input } from '../input/input.js';
9
8
  import { mapPropsVariants } from '../system/utils.js';
10
9
  import Minus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/minus.js';
11
10
  import Plus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/plus.js';
11
+ import { Button } from '../button/button.js';
12
12
 
13
13
  function NumberField(originalProps) {
14
14
  const [
@@ -3,7 +3,7 @@
3
3
  import { useMemo } from 'react';
4
4
  import { useFocusRing } from '@react-aria/focus';
5
5
  import { usePress, useHover } from '@react-aria/interactions';
6
- import { useRouter, mergeProps, chain, shouldClientNavigate } from '@react-aria/utils';
6
+ import { useRouter, chain, shouldClientNavigate, mergeProps } from '@react-aria/utils';
7
7
  import { cn, dataAttr } from '@opengovsg/oui-theme';
8
8
  import { useDomRef } from '../system/react-utils/refs.js';
9
9
  import { filterDOMProps } from '../system/react-utils/filter-dom-props.js';
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  "use client";
3
- import { jsxs, jsx } from 'react/jsx-runtime';
4
- import { useMemo, useState, useRef, useCallback } from 'react';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { useMemo, useCallback, useState, useRef } from 'react';
5
5
  import { TextField, Provider } from 'react-aria-components';
6
6
  import BasePhoneInput, { getCountryCallingCode } from 'react-phone-number-input';
7
7
  import flags from 'react-phone-number-input/flags';
8
8
  import NonInternationalBasePhoneInput from 'react-phone-number-input/input';
9
- import { phoneNumberFieldStyles, cn } from '@opengovsg/oui-theme';
9
+ import { cn, phoneNumberFieldStyles } from '@opengovsg/oui-theme';
10
10
  import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
11
11
  import { useControllableState } from '../hooks/use-controllable-state.js';
12
12
  import { Input } from '../input/input.js';
@@ -15,7 +15,7 @@ import { SelectItem } from '../select/select-item.js';
15
15
  import { useLocalizedStringFormatter } from '../system/l10n.js';
16
16
  import { mapPropsVariants } from '../system/utils.js';
17
17
  import { MOBILE_EXAMPLES } from './constants.js';
18
- import { PhoneInputContext, usePhoneInputContext } from './context.js';
18
+ import { usePhoneInputContext, PhoneInputContext } from './context.js';
19
19
  import { i18nStrings } from './i18n.js';
20
20
 
21
21
  const PhoneInput = ({
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  "use client";
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
- import { useSlottedContext, PopoverContext, Popover as Popover$1, composeRenderProps, OverlayArrow } from 'react-aria-components';
4
+ import { useSlottedContext, PopoverContext, Popover as Popover$1, OverlayArrow, composeRenderProps } from 'react-aria-components';
5
5
  import { popoverArrowStyles, popoverStyles } from '@opengovsg/oui-theme';
6
6
 
7
7
  const Popover = ({
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ export { Radio, RadioGroup } from './radio.js';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ import { createContext } from '../system/react-utils/context.js';
3
+
4
+ const [RadioGroupVariantContext, useRadioGroupVariantContext] = createContext({
5
+ name: "RadioGroupVariantContext",
6
+ strict: false,
7
+ defaultValue: {
8
+ size: "md"
9
+ }
10
+ });
11
+
12
+ export { RadioGroupVariantContext, useRadioGroupVariantContext };
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { Radio as Radio$1, composeRenderProps, Provider, RadioGroup as RadioGroup$1 } from 'react-aria-components';
5
+ import { radioStyles, radioGroupStyles } from '@opengovsg/oui-theme';
6
+ import { Description, Label, FieldError } from '../field/field.js';
7
+ import { renderChildren } from '../system/react-utils/children.js';
8
+ import { mapPropsVariants } from '../system/utils.js';
9
+ import { useRadioGroupVariantContext, RadioGroupVariantContext } from './radio-group-variant-context.js';
10
+
11
+ const Radio = ({
12
+ classNames,
13
+ className,
14
+ children,
15
+ description,
16
+ ...originalProps
17
+ }) => {
18
+ const [props, variants] = mapPropsVariants(
19
+ originalProps,
20
+ radioStyles.variantKeys
21
+ );
22
+ const groupContext = useRadioGroupVariantContext();
23
+ const styles = radioStyles({ size: groupContext?.size, ...variants });
24
+ return /* @__PURE__ */ jsx(
25
+ Radio$1,
26
+ {
27
+ ...props,
28
+ isDisabled: variants.isDisabled,
29
+ className: composeRenderProps(
30
+ className ?? classNames?.base,
31
+ (className2, renderProps) => styles.base({ ...renderProps, className: className2 })
32
+ ),
33
+ children: (renderProps) => {
34
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
35
+ /* @__PURE__ */ jsx(
36
+ "span",
37
+ {
38
+ className: styles.circle({
39
+ ...renderProps,
40
+ className: classNames?.circle
41
+ }),
42
+ children: /* @__PURE__ */ jsx(
43
+ "span",
44
+ {
45
+ className: styles.icon({
46
+ ...renderProps,
47
+ className: classNames?.icon
48
+ })
49
+ }
50
+ )
51
+ }
52
+ ),
53
+ /* @__PURE__ */ jsx("span", { className: styles.label({ className: classNames?.label }), children: renderChildren(renderProps, children) }),
54
+ description && /* @__PURE__ */ jsx(
55
+ Description,
56
+ {
57
+ size: groupContext?.size,
58
+ className: styles.description({
59
+ className: classNames?.description
60
+ }),
61
+ children: description
62
+ }
63
+ )
64
+ ] });
65
+ }
66
+ }
67
+ );
68
+ };
69
+ const RadioGroup = ({
70
+ label,
71
+ description,
72
+ errorMessage,
73
+ classNames,
74
+ size,
75
+ ...props
76
+ }) => {
77
+ const context = { size };
78
+ return /* @__PURE__ */ jsx(Provider, { values: [[RadioGroupVariantContext, context]], children: /* @__PURE__ */ jsxs(
79
+ RadioGroup$1,
80
+ {
81
+ ...props,
82
+ className: composeRenderProps(
83
+ props.className ?? classNames?.base,
84
+ (className, renderProps) => radioGroupStyles({ ...renderProps, size, className })
85
+ ),
86
+ children: [
87
+ label && /* @__PURE__ */ jsx(Label, { size, className: classNames?.label, children: label }),
88
+ props.children,
89
+ description && /* @__PURE__ */ jsx(Description, { size, className: classNames?.description, children: description }),
90
+ /* @__PURE__ */ jsx(FieldError, { size, classNames: classNames?.error, children: errorMessage })
91
+ ]
92
+ }
93
+ ) });
94
+ };
95
+
96
+ export { Radio, RadioGroup };
@@ -6,12 +6,12 @@ import { CalendarDate, today, getLocalTimeZone, getDayOfWeek } from '@internatio
6
6
  import { RangeCalendar as RangeCalendar$1, Provider, CalendarGrid, CalendarGridBody, Text, RangeCalendarStateContext, useLocale, CalendarCell } from 'react-aria-components';
7
7
  import { useDeepCompareMemo } from 'use-deep-compare';
8
8
  import { calendarStyles, composeRenderProps, cn, dataAttr } from '@opengovsg/oui-theme';
9
- import { CalendarStyleContext, useCalendarStyleContext } from '../calendar/calendar-style-context.js';
10
9
  import { AgnosticCalendarStateContext } from '../calendar/agnostic-calendar-state-context.js';
11
10
  import { CalendarBottomContent } from '../calendar/calendar-bottom-content.js';
12
11
  import { CalendarGridHeader } from '../calendar/calendar-grid-header.js';
13
12
  import { CalendarHeader } from '../calendar/calendar-header.js';
14
13
  import { forwardRefGeneric, mapPropsVariants } from '../system/utils.js';
14
+ import { CalendarStyleContext, useCalendarStyleContext } from '../calendar/calendar-style-context.js';
15
15
 
16
16
  const RangeCalendar = forwardRefGeneric(function RangeCalendar2(originalProps, ref) {
17
17
  const [props, variantProps] = mapPropsVariants(
@@ -3,13 +3,13 @@ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useLocalizedStringFormatter } from 'react-aria';
4
4
  import { SearchField as SearchField$1 } from 'react-aria-components';
5
5
  import { searchFieldStyles, composeRenderProps } from '@opengovsg/oui-theme';
6
- import { Button } from '../button/button.js';
7
6
  import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
8
7
  import { Input } from '../input/input.js';
9
8
  import { mapPropsVariants } from '../system/utils.js';
10
9
  import { i18nStrings } from './i18n.js';
11
10
  import Search from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/search.js';
12
11
  import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js';
12
+ import { Button } from '../button/button.js';
13
13
 
14
14
  function SearchField(originalProps) {
15
15
  const [
@@ -5,7 +5,6 @@ import { useMemo, isValidElement, cloneElement } from 'react';
5
5
  import { useLocalizedStringFormatter } from 'react-aria';
6
6
  import { useFilter, Virtualizer, ListLayout, ListBox, Provider, Select as Select$1, SelectValue, Autocomplete, SearchField, Input } from 'react-aria-components';
7
7
  import { selectStyles, cn, composeRenderProps } from '@opengovsg/oui-theme';
8
- import { Button } from '../button/button.js';
9
8
  import { Label, Description, FieldError } from '../field/field.js';
10
9
  import { Popover } from '../popover/popover.js';
11
10
  import { useElementWidth } from '../system/react-utils/sizing.js';
@@ -13,6 +12,7 @@ import { mapPropsVariants } from '../system/utils.js';
13
12
  import { i18nStrings } from './i18n.js';
14
13
  import { SelectVariantContext } from './select-variant-context.js';
15
14
  import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
15
+ import { Button } from '../button/button.js';
16
16
 
17
17
  const calculateEstimatedRowHeight = (size) => {
18
18
  switch (size) {
@@ -6,11 +6,11 @@ import { useLocalizedStringFormatter } from 'react-aria';
6
6
  import { Disclosure, DisclosurePanel, Provider, Link, Button as Button$1 } from 'react-aria-components';
7
7
  import { useDisclosureState } from 'react-stately';
8
8
  import { dataAttr } from '@opengovsg/oui-theme';
9
- import { Button } from '../button/button.js';
10
9
  import { forwardRef } from '../system/utils.js';
11
10
  import { useSidebarStyleContext, useSidebarCollapseContext, SidebarNestContext, useSidebarNestContext } from './context.js';
12
11
  import { i18nStrings } from './i18n.js';
13
12
  import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
13
+ import { Button } from '../button/button.js';
14
14
 
15
15
  const SidebarListSection = ({
16
16
  onlyCaretToggle,
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- export { Tab, TabList, TabPanel, Tabs, TabsVariantContext, useTabsVariantContext } from './tabs.js';
2
+ export { Tab, TabList, TabPanel, TabPanels, Tabs, TabsVariantContext, useTabsVariantContext } from './tabs.js';
@@ -2,8 +2,8 @@
2
2
  "use client";
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { forwardRef } from 'react';
5
- import { useContextProps, TabList as TabList$1, composeRenderProps, Tab as Tab$1, Provider, Tabs as Tabs$1, TabPanel as TabPanel$1 } from 'react-aria-components';
6
- import { tabListStyles, tabStyles, tabsStyles, tabPanelStyles } from '@opengovsg/oui-theme';
5
+ import { useContextProps, TabList as TabList$1, composeRenderProps, Tab as Tab$1, TabPanels as TabPanels$1, TabPanel as TabPanel$1, Provider, Tabs as Tabs$1 } from 'react-aria-components';
6
+ import { tabListStyles, tabStyles, tabPanelStyles, tabsStyles } from '@opengovsg/oui-theme';
7
7
  import { forwardRefGeneric, mapPropsVariants } from '../system/utils.js';
8
8
  import { createContext } from '../system/react-utils/context.js';
9
9
 
@@ -86,5 +86,6 @@ function TabPanel(props) {
86
86
  }
87
87
  );
88
88
  }
89
+ const TabPanels = TabPanels$1;
89
90
 
90
- export { Tab, TabList, TabPanel, Tabs, TabsVariantContext, useTabsVariantContext };
91
+ export { Tab, TabList, TabPanel, TabPanels, Tabs, TabsVariantContext, useTabsVariantContext };
@@ -10,18 +10,18 @@ import { TagFieldStateContext } from './tag-field-state-context.js';
10
10
  const TagFieldListContext = createContext(null);
11
11
  const TagFieldListInner = (props, ref) => {
12
12
  [props, ref] = useContextProps(props, ref, TagFieldListContext);
13
- const { items, getItemProps, highlightedIndex } = useContext(TagFieldStateContext);
13
+ const { items, getItemProps, highlightedIndex, itemToKey } = useContext(TagFieldStateContext);
14
14
  const { slot, rowVirtualizer, itemClassNames, ...rest } = props;
15
- return /* @__PURE__ */ jsx("ul", { slot: slot ?? void 0, ref, ...rest, children: props.children !== void 0 && typeof props.children !== "function" ? props.children : /* @__PURE__ */ jsxs(Fragment, { children: [
15
+ return /* @__PURE__ */ jsx("ul", { slot: slot ?? void 0, ref, ...rest, children: props.children !== void 0 && typeof props.children !== "function" ? props.children : rowVirtualizer ? /* @__PURE__ */ jsxs(Fragment, { children: [
16
16
  /* @__PURE__ */ jsx(
17
17
  "li",
18
18
  {
19
19
  "aria-hidden": true,
20
- style: { height: rowVirtualizer?.getTotalSize() }
20
+ style: { height: rowVirtualizer.getTotalSize() }
21
21
  },
22
22
  "total-size"
23
23
  ),
24
- rowVirtualizer?.getVirtualItems().map((virtualRow) => {
24
+ rowVirtualizer.getVirtualItems().map((virtualRow) => {
25
25
  const item = items[virtualRow.index];
26
26
  const itemProps = getItemProps({
27
27
  item,
@@ -53,7 +53,27 @@ const TagFieldListInner = (props, ref) => {
53
53
  }
54
54
  );
55
55
  })
56
- ] }) });
56
+ ] }) : items.map((item, index) => {
57
+ const itemProps = getItemProps({ item, index });
58
+ const key = itemToKey(item);
59
+ const childProps = {
60
+ item,
61
+ isHighlighted: highlightedIndex === index,
62
+ key,
63
+ classNames: itemClassNames
64
+ };
65
+ if (typeof props.children === "function") {
66
+ return props.children({ ...childProps, itemProps });
67
+ }
68
+ return /* @__PURE__ */ createElement(
69
+ TagFieldItem,
70
+ {
71
+ ...childProps,
72
+ ...itemProps,
73
+ key
74
+ }
75
+ );
76
+ }) });
57
77
  };
58
78
  const TagFieldList = forwardRefGeneric(TagFieldListInner);
59
79
 
@@ -6,6 +6,10 @@ import { useMultipleSelection, useCombobox } from 'downshift';
6
6
  import { omit } from 'lodash-es';
7
7
  import { useTextField } from 'react-aria';
8
8
 
9
+ function useOptionalVirtualizer(isVirtualized, options) {
10
+ const virtualizer = useVirtualizer(options);
11
+ return isVirtualized ? virtualizer : null;
12
+ }
9
13
  function useTagField(props, state) {
10
14
  let { buttonRef } = props;
11
15
  const {
@@ -19,7 +23,8 @@ function useTagField(props, state) {
19
23
  itemToKey,
20
24
  itemToText,
21
25
  label,
22
- virtualRowHeight = 40
26
+ virtualRowHeight = 40,
27
+ isVirtualized = true
23
28
  } = props;
24
29
  const backupBtnRef = useRef(null);
25
30
  buttonRef = buttonRef ?? backupBtnRef;
@@ -49,7 +54,7 @@ function useTagField(props, state) {
49
54
  const disabledKeysSet = useMemo(() => {
50
55
  return new Set(disabledKeys);
51
56
  }, [disabledKeys]);
52
- const rowVirtualizer = useVirtualizer({
57
+ const rowVirtualizer = useOptionalVirtualizer(isVirtualized, {
53
58
  count: items.length,
54
59
  getScrollElement: () => listBoxRef.current,
55
60
  estimateSize: () => virtualRowHeight,
@@ -76,11 +81,17 @@ function useTagField(props, state) {
76
81
  },
77
82
  isItemDisabled: (item) => isDisabled || isReadOnly || disabledKeysSet.has(itemToKey(item)),
78
83
  items,
79
- scrollIntoView: () => {
84
+ // Noop for scrollIntoView if virtualized, as we'll handle it in onHighlightedIndexChange
85
+ scrollIntoView: (node) => {
86
+ if (!isVirtualized) {
87
+ node.scrollIntoView({ block: "nearest" });
88
+ }
80
89
  },
81
90
  onHighlightedIndexChange: ({ highlightedIndex: highlightedIndex2, type }) => {
82
91
  if (type !== useCombobox.stateChangeTypes.MenuMouseLeave && highlightedIndex2 >= 0) {
83
- rowVirtualizer.scrollToIndex(highlightedIndex2);
92
+ if (rowVirtualizer) {
93
+ rowVirtualizer.scrollToIndex(highlightedIndex2);
94
+ }
84
95
  }
85
96
  },
86
97
  defaultHighlightedIndex: 0,
@@ -3,6 +3,7 @@
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow } from 'react-aria-components';
5
5
  import { tooltipStyles, composeRenderProps } from '@opengovsg/oui-theme';
6
+ import { renderChildren } from '../system/react-utils/children.js';
6
7
  import { mapPropsVariants } from '../system/utils.js';
7
8
 
8
9
  function Tooltip(originalProps) {
@@ -29,13 +30,10 @@ function Tooltip(originalProps) {
29
30
  width: 8,
30
31
  height: 8,
31
32
  viewBox: "0 0 8 8",
32
- className: composeRenderProps(
33
- classNames?.arrow,
34
- (className, renderProps2) => styles.arrow({
35
- className,
36
- ...renderProps2
37
- })
38
- )(renderProps),
33
+ className: styles.arrow({
34
+ ...renderProps,
35
+ className: renderChildren(renderProps, classNames?.arrow)
36
+ }),
39
37
  children: /* @__PURE__ */ jsx("path", { d: "M0 0 L4 4 L8 0" })
40
38
  }
41
39
  ) }),
@@ -1,8 +1,8 @@
1
- import type { CheckboxGroupProps as AriaCheckboxGroupProps, CheckboxProps as AriaCheckboxProps, ValidationResult } from "react-aria-components";
2
- import type { CheckboxSlots, FieldErrorSlots, SlotsToClasses, VariantProps } from "@opengovsg/oui-theme";
1
+ import type { CheckboxGroupProps as AriaCheckboxGroupProps, CheckboxProps as AriaCheckboxProps, CheckboxRenderProps, ValidationResult } from "react-aria-components";
2
+ import type { CheckboxSlots, FieldErrorSlots, SlotsToClasses, SlotsToClassesWithRenderProps, VariantProps } from "@opengovsg/oui-theme";
3
3
  import { checkboxStyles } from "@opengovsg/oui-theme";
4
4
  export interface CheckboxProps extends AriaCheckboxProps, VariantProps<typeof checkboxStyles> {
5
- classNames?: SlotsToClasses<CheckboxSlots>;
5
+ classNames?: SlotsToClassesWithRenderProps<CheckboxSlots, CheckboxRenderProps>;
6
6
  }
7
7
  export declare const Checkbox: ({ classNames, className, ...originalProps }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
8
8
  export interface CheckboxGroupProps extends Omit<AriaCheckboxGroupProps, "children"> {
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,IAAI,sBAAsB,EAC5C,aAAa,IAAI,iBAAiB,EAClC,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAS9B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAuB,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAS1E,MAAM,WAAW,aACf,SAAQ,iBAAiB,EACvB,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,UAAU,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAA;CAC3C;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CAAA;AACD,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,gBAAgB,KAAK,MAAM,CAAC,CAAA;IAClE,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC,GAAG;QAC9D,KAAK,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAA;KACxC,CAAA;IACD,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC7B;AAED,wBAAgB,aAAa,CAAC,EAC5B,WAAW,EACX,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,kBAAkB,2CA8BpB"}
@@ -39,4 +39,6 @@ export * from "./breadcrumbs";
39
39
  export * from "./sidebar";
40
40
  export * from "./tooltip";
41
41
  export * from "./phone-number-field";
42
+ export * from "./infobox";
43
+ export * from "./radio-group";
42
44
  //# sourceMappingURL=index.d.ts.map
@@ -39,4 +39,6 @@ export * from "./breadcrumbs";
39
39
  export * from "./sidebar";
40
40
  export * from "./tooltip";
41
41
  export * from "./phone-number-field";
42
+ export * from "./infobox";
43
+ export * from "./radio-group";
42
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc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AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "./infobox";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infobox/index.tsx"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { UseInfoboxProps } from "./use-infobox";
2
+ export interface InfoboxProps extends UseInfoboxProps {
3
+ }
4
+ export declare const Infobox: (props: InfoboxProps) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=infobox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infobox.d.ts","sourceRoot":"","sources":["../../../src/infobox/infobox.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,MAAM,WAAW,YAAa,SAAQ,eAAe;CAAG;AAExD,eAAO,MAAM,OAAO,UAAW,YAAY,4CAsC1C,CAAA"}
@@ -0,0 +1,54 @@
1
+ import type { InfoboxSlots, InfoboxVariantProps, SlotsToClasses } from "@opengovsg/oui-theme";
2
+ import type { HtmlUiProps } from "../system/types";
3
+ export interface UseInfoboxProps extends HtmlUiProps, InfoboxVariantProps {
4
+ /**
5
+ * Icon to show on the left of the infobox.
6
+ * If not specified, a default icon will be used according to the infobox variant.
7
+ * Pass `null` to explicitly hide the icon.
8
+ */
9
+ icon?: React.ReactNode | null;
10
+ /**
11
+ * Classname or List of classes to change the classNames of the element.
12
+ * if `className` is passed, it will be added to the base slot.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * <Infobox classNames={{
17
+ * base: "base-classes",
18
+ * icon: "icon-classes",
19
+ * }} />
20
+ * ```
21
+ */
22
+ classNames?: SlotsToClasses<InfoboxSlots>;
23
+ }
24
+ export declare function useInfobox(originalProps: UseInfoboxProps): {
25
+ Component: import("../system/types").As<any>;
26
+ children: import("react").ReactNode;
27
+ slots: {
28
+ base: ((slotProps?: ({
29
+ size?: "md" | "sm" | undefined;
30
+ variant?: "error" | "warning" | "success" | "info" | undefined;
31
+ } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string) & ((slotProps?: ({
32
+ size?: "md" | "sm" | undefined;
33
+ variant?: "error" | "warning" | "success" | "info" | undefined;
34
+ } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string);
35
+ icon: ((slotProps?: ({
36
+ size?: "md" | "sm" | undefined;
37
+ variant?: "error" | "warning" | "success" | "info" | undefined;
38
+ } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string) & ((slotProps?: ({
39
+ size?: "md" | "sm" | undefined;
40
+ variant?: "error" | "warning" | "success" | "info" | undefined;
41
+ } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string);
42
+ wrapper: ((slotProps?: ({
43
+ size?: "md" | "sm" | undefined;
44
+ variant?: "error" | "warning" | "success" | "info" | undefined;
45
+ } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string) & ((slotProps?: ({
46
+ size?: "md" | "sm" | undefined;
47
+ variant?: "error" | "warning" | "success" | "info" | undefined;
48
+ } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string);
49
+ };
50
+ classNames: SlotsToClasses<"base" | "wrapper" | "icon"> | undefined;
51
+ icon: import("react").ReactNode;
52
+ variant: "error" | "warning" | "success" | "info" | undefined;
53
+ };
54
+ //# sourceMappingURL=use-infobox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-infobox.d.ts","sourceRoot":"","sources":["../../../src/infobox/use-infobox.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACf,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD,MAAM,WAAW,eAAgB,SAAQ,WAAW,EAAE,mBAAmB;IACvE;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAA;IAC7B;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;CAC1C;AAED,wBAAgB,UAAU,CAAC,aAAa,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxD"}
@@ -0,0 +1,3 @@
1
+ export { Radio, RadioGroup } from "./radio";
2
+ export type { RadioGroupProps, RadioProps } from "./radio";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/radio-group/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAE3C,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { RadioGroupVariantProps } from "@opengovsg/oui-theme";
2
+ export interface RadioGroupVariantContextValue extends RadioGroupVariantProps {
3
+ size: RadioGroupVariantProps["size"];
4
+ }
5
+ export declare const RadioGroupVariantContext: import("react").Context<RadioGroupVariantContextValue | undefined>, useRadioGroupVariantContext: () => RadioGroupVariantContextValue | undefined;
6
+ //# sourceMappingURL=radio-group-variant-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radio-group-variant-context.d.ts","sourceRoot":"","sources":["../../../src/radio-group/radio-group-variant-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAIlE,MAAM,WAAW,6BAA8B,SAAQ,sBAAsB;IAC3E,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAA;CACrC;AAED,eAAO,MAAO,wBAAwB,sEAAE,2BAA2B,iDAO/D,CAAA"}