@opengovsg/oui 0.0.0-snapshot-20251216073051 → 0.0.0-snapshot-20260126032728

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 (129) hide show
  1. package/dist/cjs/accordion/accordion.cjs +189 -0
  2. package/dist/cjs/accordion/index.cjs +13 -0
  3. package/dist/cjs/avatar/avatar-context.cjs +12 -0
  4. package/dist/cjs/avatar/avatar-group-context.cjs +88 -0
  5. package/dist/cjs/avatar/avatar-group.cjs +60 -0
  6. package/dist/cjs/avatar/avatar.cjs +132 -0
  7. package/dist/cjs/avatar/hooks/use-img-loading-status.cjs +68 -0
  8. package/dist/cjs/avatar/index.cjs +23 -0
  9. package/dist/cjs/avatar/utils.cjs +9 -0
  10. package/dist/cjs/banner/banner.cjs +1 -1
  11. package/dist/cjs/button/button.cjs +13 -10
  12. package/dist/cjs/calendar/calendar-month-day-selector.cjs +2 -2
  13. package/dist/cjs/checkbox/checkbox.cjs +3 -3
  14. package/dist/cjs/combo-box/combo-box.cjs +2 -2
  15. package/dist/cjs/date-field/date-field.cjs +1 -1
  16. package/dist/cjs/date-picker/date-picker.cjs +5 -4
  17. package/dist/cjs/date-range-picker/date-range-picker.cjs +5 -5
  18. package/dist/cjs/file-dropzone/file-dropzone.cjs +13 -9
  19. package/dist/cjs/file-dropzone/file-info.cjs +3 -2
  20. package/dist/cjs/file-dropzone/utils.cjs +4 -4
  21. package/dist/cjs/index.cjs +33 -12
  22. package/dist/cjs/menu/menu.cjs +1 -1
  23. package/dist/cjs/modal/modal-content.cjs +1 -1
  24. package/dist/cjs/navbar/navbar-menu/menu.cjs +1 -1
  25. package/dist/cjs/navbar/use-navbar.cjs +1 -1
  26. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/user.cjs +22 -0
  27. package/dist/cjs/number-field/number-field.cjs +3 -3
  28. package/dist/cjs/range-calendar/range-calendar.cjs +1 -1
  29. package/dist/cjs/select/select.cjs +89 -17
  30. package/dist/cjs/system/react-utils/children.cjs +7 -0
  31. package/dist/cjs/tag-field/tag-field.cjs +3 -3
  32. package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
  33. package/dist/cjs/text-field/text-field.cjs +1 -1
  34. package/dist/cjs/toast/toast.cjs +1 -1
  35. package/dist/esm/accordion/accordion.js +182 -0
  36. package/dist/esm/accordion/index.js +2 -0
  37. package/dist/esm/avatar/avatar-context.js +9 -0
  38. package/dist/esm/avatar/avatar-group-context.js +84 -0
  39. package/dist/esm/avatar/avatar-group.js +58 -0
  40. package/dist/esm/avatar/avatar.js +128 -0
  41. package/dist/esm/avatar/hooks/use-img-loading-status.js +66 -0
  42. package/dist/esm/avatar/index.js +13 -0
  43. package/dist/esm/avatar/utils.js +7 -0
  44. package/dist/esm/banner/banner.js +1 -1
  45. package/dist/esm/button/button.js +13 -10
  46. package/dist/esm/calendar/calendar-month-day-selector.js +2 -2
  47. package/dist/esm/checkbox/checkbox.js +3 -3
  48. package/dist/esm/combo-box/combo-box.js +2 -2
  49. package/dist/esm/date-field/date-field.js +1 -1
  50. package/dist/esm/date-picker/date-picker.js +5 -4
  51. package/dist/esm/date-range-picker/date-range-picker.js +5 -5
  52. package/dist/esm/file-dropzone/file-dropzone.js +13 -9
  53. package/dist/esm/file-dropzone/file-info.js +3 -2
  54. package/dist/esm/file-dropzone/utils.js +4 -4
  55. package/dist/esm/index.js +9 -3
  56. package/dist/esm/menu/menu.js +1 -1
  57. package/dist/esm/modal/modal-content.js +1 -1
  58. package/dist/esm/navbar/navbar-menu/menu.js +1 -1
  59. package/dist/esm/navbar/use-navbar.js +1 -1
  60. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/user.js +17 -0
  61. package/dist/esm/number-field/number-field.js +3 -3
  62. package/dist/esm/range-calendar/range-calendar.js +1 -1
  63. package/dist/esm/select/select.js +92 -20
  64. package/dist/esm/system/react-utils/children.js +7 -1
  65. package/dist/esm/tag-field/tag-field.js +3 -3
  66. package/dist/esm/text-area-field/text-area-field.js +1 -1
  67. package/dist/esm/text-field/text-field.js +1 -1
  68. package/dist/esm/toast/toast.js +1 -1
  69. package/dist/types/accordion/accordion.d.ts +50 -0
  70. package/dist/types/accordion/accordion.d.ts.map +1 -0
  71. package/dist/types/accordion/index.d.ts +2 -0
  72. package/dist/types/accordion/index.d.ts.map +1 -0
  73. package/dist/types/avatar/avatar-context.d.ts +12 -0
  74. package/dist/types/avatar/avatar-context.d.ts.map +1 -0
  75. package/dist/types/avatar/avatar-group-context.d.ts +70 -0
  76. package/dist/types/avatar/avatar-group-context.d.ts.map +1 -0
  77. package/dist/types/avatar/avatar-group.d.ts +5 -0
  78. package/dist/types/avatar/avatar-group.d.ts.map +1 -0
  79. package/dist/types/avatar/avatar.d.ts +18 -0
  80. package/dist/types/avatar/avatar.d.ts.map +1 -0
  81. package/dist/types/avatar/hooks/use-img-loading-status.d.ts +4 -0
  82. package/dist/types/avatar/hooks/use-img-loading-status.d.ts.map +1 -0
  83. package/dist/types/avatar/index.d.ts +15 -0
  84. package/dist/types/avatar/index.d.ts.map +1 -0
  85. package/dist/types/avatar/utils.d.ts +2 -0
  86. package/dist/types/avatar/utils.d.ts.map +1 -0
  87. package/dist/types/button/button.d.ts +12 -6
  88. package/dist/types/button/button.d.ts.map +1 -1
  89. package/dist/types/calendar/agnostic-calendar-state-context.d.ts +1 -1
  90. package/dist/types/calendar/agnostic-calendar-state-context.d.ts.map +1 -1
  91. package/dist/types/calendar/calendar.d.ts.map +1 -1
  92. package/dist/types/checkbox/checkbox-group-style-context.d.ts +1 -1
  93. package/dist/types/checkbox/checkbox-group-style-context.d.ts.map +1 -1
  94. package/dist/types/date-field/date-field.d.ts.map +1 -1
  95. package/dist/types/file-dropzone/file-dropzone.d.ts +8 -2
  96. package/dist/types/file-dropzone/file-dropzone.d.ts.map +1 -1
  97. package/dist/types/file-dropzone/file-info.d.ts.map +1 -1
  98. package/dist/types/file-dropzone/types.d.ts +1 -0
  99. package/dist/types/file-dropzone/types.d.ts.map +1 -1
  100. package/dist/types/file-dropzone/utils.d.ts +2 -1
  101. package/dist/types/file-dropzone/utils.d.ts.map +1 -1
  102. package/dist/types/index.d.mts +2 -0
  103. package/dist/types/index.d.ts +2 -0
  104. package/dist/types/index.d.ts.map +1 -1
  105. package/dist/types/menu/menu.d.ts +1 -1
  106. package/dist/types/menu/menu.d.ts.map +1 -1
  107. package/dist/types/navbar/navbar-context.d.ts +2 -2
  108. package/dist/types/navbar/use-navbar.d.ts +1 -1
  109. package/dist/types/range-calendar/range-calendar.d.ts.map +1 -1
  110. package/dist/types/select/select-item.d.ts +1 -2
  111. package/dist/types/select/select-item.d.ts.map +1 -1
  112. package/dist/types/select/select.d.ts +14 -0
  113. package/dist/types/select/select.d.ts.map +1 -1
  114. package/dist/types/system/react-utils/children.d.ts +3 -0
  115. package/dist/types/system/react-utils/children.d.ts.map +1 -1
  116. package/dist/types/system/react-utils/context.d.ts +4 -4
  117. package/dist/types/system/react-utils/context.d.ts.map +1 -1
  118. package/dist/types/system/utils.d.ts.map +1 -1
  119. package/dist/types/tabs/tabs.d.ts +1 -1
  120. package/dist/types/tabs/tabs.d.ts.map +1 -1
  121. package/dist/types/tag-field/tag-field-item.d.ts.map +1 -1
  122. package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
  123. package/package.json +20 -20
  124. /package/dist/cjs/node_modules/.pnpm/{@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3 → @react-aria_overlays@3.31.0_react-dom@19.2.3_react@19.2.3__react@19.2.3}/node_modules/@react-aria/overlays/dist/Overlay.cjs +0 -0
  125. /package/dist/cjs/node_modules/.pnpm/{@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3 → @react-aria_overlays@3.31.0_react-dom@19.2.3_react@19.2.3__react@19.2.3}/node_modules/@react-aria/overlays/dist/PortalProvider.cjs +0 -0
  126. /package/dist/cjs/node_modules/.pnpm/{@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3 → @react-aria_overlays@3.31.0_react-dom@19.2.3_react@19.2.3__react@19.2.3}/node_modules/@react-aria/overlays/dist/usePreventScroll.cjs +0 -0
  127. /package/dist/esm/node_modules/.pnpm/{@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3 → @react-aria_overlays@3.31.0_react-dom@19.2.3_react@19.2.3__react@19.2.3}/node_modules/@react-aria/overlays/dist/Overlay.js +0 -0
  128. /package/dist/esm/node_modules/.pnpm/{@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3 → @react-aria_overlays@3.31.0_react-dom@19.2.3_react@19.2.3__react@19.2.3}/node_modules/@react-aria/overlays/dist/PortalProvider.js +0 -0
  129. /package/dist/esm/node_modules/.pnpm/{@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3 → @react-aria_overlays@3.31.0_react-dom@19.2.3_react@19.2.3__react@19.2.3}/node_modules/@react-aria/overlays/dist/usePreventScroll.js +0 -0
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { Disclosure, composeRenderProps, DisclosureGroup, DisclosureStateContext, Heading, Button, DisclosurePanel } from 'react-aria-components';
6
+ import { cn, accordionStyles, composeTailwindRenderProps } from '@opengovsg/oui-theme';
7
+ import { renderChildren } from '../system/react-utils/children.js';
8
+ import { forwardRef, mapPropsVariants } from '../system/utils.js';
9
+ import { createContext } from '../system/react-utils/context.js';
10
+ 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';
11
+
12
+ const [AccordionStyleContext, useAccordionStyleContext] = createContext({
13
+ name: "AccordionStyleContext",
14
+ strict: true
15
+ });
16
+ const AccordionItem = forwardRef(
17
+ ({ classNames, className, children, ...props }, ref) => {
18
+ const { slots } = useContext(AccordionStyleContext);
19
+ return /* @__PURE__ */ jsx(
20
+ Disclosure,
21
+ {
22
+ ...props,
23
+ ref,
24
+ className: composeRenderProps(
25
+ className,
26
+ (className2, renderProps) => slots.item({
27
+ ...renderProps,
28
+ className: cn(classNames?.item, className2)
29
+ })
30
+ ),
31
+ children
32
+ }
33
+ );
34
+ }
35
+ );
36
+ AccordionItem.displayName = "AccordionItem";
37
+ function AccordionHeader({
38
+ children,
39
+ classNames,
40
+ indicator,
41
+ startContent,
42
+ endContent,
43
+ hideIndicator = false
44
+ }) {
45
+ const { slots, classNames: contextClassNames } = useContext(
46
+ AccordionStyleContext
47
+ );
48
+ const { isExpanded } = useContext(DisclosureStateContext);
49
+ return /* @__PURE__ */ jsx(
50
+ Heading,
51
+ {
52
+ className: slots.heading({
53
+ className: cn(contextClassNames?.heading, classNames?.heading)
54
+ }),
55
+ children: /* @__PURE__ */ jsx(
56
+ Button,
57
+ {
58
+ slot: "trigger",
59
+ className: slots.trigger({
60
+ className: cn(contextClassNames?.trigger, classNames?.trigger)
61
+ }),
62
+ children: (buttonRenderProps) => {
63
+ const headerRenderProps = { ...buttonRenderProps, isExpanded };
64
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
65
+ startContent && /* @__PURE__ */ jsx(
66
+ "div",
67
+ {
68
+ className: slots.startContentWrapper({
69
+ className: cn(
70
+ contextClassNames?.startContentWrapper,
71
+ classNames?.startContentWrapper
72
+ )
73
+ }),
74
+ children: renderChildren(headerRenderProps, startContent)
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsx(
78
+ "span",
79
+ {
80
+ className: slots.title({
81
+ className: cn(contextClassNames?.title, classNames?.title)
82
+ }),
83
+ children: renderChildren(headerRenderProps, children)
84
+ }
85
+ ),
86
+ !hideIndicator && /* @__PURE__ */ jsx(
87
+ "span",
88
+ {
89
+ "aria-hidden": true,
90
+ className: slots.indicator({
91
+ isExpanded,
92
+ className: cn(
93
+ contextClassNames?.indicator,
94
+ classNames?.indicator
95
+ )
96
+ }),
97
+ children: renderChildren(
98
+ headerRenderProps,
99
+ indicator ?? /* @__PURE__ */ jsx(ChevronDown, {})
100
+ )
101
+ }
102
+ ),
103
+ endContent && /* @__PURE__ */ jsx(
104
+ "div",
105
+ {
106
+ className: slots.endContentWrapper({
107
+ className: cn(
108
+ contextClassNames?.endContentWrapper,
109
+ classNames?.endContentWrapper
110
+ )
111
+ }),
112
+ children: renderChildren(headerRenderProps, endContent)
113
+ }
114
+ )
115
+ ] });
116
+ }
117
+ }
118
+ )
119
+ }
120
+ );
121
+ }
122
+ function AccordionContent({
123
+ children,
124
+ classNames,
125
+ ...props
126
+ }) {
127
+ const { slots, classNames: contextClassNames } = useContext(
128
+ AccordionStyleContext
129
+ );
130
+ return /* @__PURE__ */ jsx(
131
+ DisclosurePanel,
132
+ {
133
+ ...props,
134
+ className: composeTailwindRenderProps(
135
+ props.className,
136
+ slots.panel({
137
+ className: cn(contextClassNames?.panel, classNames?.panel)
138
+ })
139
+ ),
140
+ children: /* @__PURE__ */ jsx(
141
+ "div",
142
+ {
143
+ className: slots.content({
144
+ className: cn(contextClassNames?.content, classNames?.content)
145
+ }),
146
+ children
147
+ }
148
+ )
149
+ }
150
+ );
151
+ }
152
+ const Accordion = forwardRef(
153
+ (originalProps, ref) => {
154
+ const [
155
+ { classNames, className, ...props },
156
+ { size = "md", ...variantProps }
157
+ ] = mapPropsVariants(originalProps, accordionStyles.variantKeys);
158
+ const slots = accordionStyles({ size, ...variantProps });
159
+ return /* @__PURE__ */ jsx(
160
+ AccordionStyleContext.Provider,
161
+ {
162
+ value: {
163
+ slots,
164
+ classNames
165
+ },
166
+ children: /* @__PURE__ */ jsx(
167
+ DisclosureGroup,
168
+ {
169
+ className: slots.base({
170
+ className: cn(classNames?.base, className)
171
+ }),
172
+ ...props,
173
+ ref
174
+ }
175
+ )
176
+ }
177
+ );
178
+ }
179
+ );
180
+ Accordion.displayName = "Accordion";
181
+
182
+ export { Accordion, AccordionContent, AccordionHeader, AccordionItem, AccordionStyleContext, useAccordionStyleContext };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ export { Accordion, AccordionContent, AccordionHeader, AccordionItem, AccordionStyleContext, useAccordionStyleContext } from './accordion.js';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ import { createContext } from '../system/react-utils/context.js';
3
+
4
+ const [AvatarContext, useAvatarContext] = createContext({
5
+ name: "AvatarContext",
6
+ strict: true
7
+ });
8
+
9
+ export { AvatarContext, useAvatarContext };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ import { useMemo, cloneElement } from 'react';
3
+ import { avatarGroupStyles, cn } from '@opengovsg/oui-theme';
4
+ import { getValidChildren } from '../system/react-utils/children.js';
5
+ import { createContext } from '../system/react-utils/context.js';
6
+ import { useDomRef } from '../system/react-utils/refs.js';
7
+
8
+ const [AvatarGroupProvider, useAvatarGroupContext] = createContext({
9
+ name: "AvatarGroupContext",
10
+ strict: false
11
+ });
12
+ function useAvatarGroup(props = {}) {
13
+ const {
14
+ as,
15
+ ref,
16
+ max = 5,
17
+ total,
18
+ size,
19
+ color,
20
+ prominence,
21
+ radius,
22
+ children,
23
+ renderCount,
24
+ className,
25
+ classNames,
26
+ countProps,
27
+ ...otherProps
28
+ } = props;
29
+ const domRef = useDomRef(ref);
30
+ const Component = as || "div";
31
+ const context = useMemo(
32
+ () => ({
33
+ size,
34
+ color,
35
+ radius,
36
+ prominence
37
+ }),
38
+ [size, color, radius, prominence]
39
+ );
40
+ const slots = useMemo(
41
+ () => avatarGroupStyles({ className: className ?? classNames?.base }),
42
+ [className, classNames?.base]
43
+ );
44
+ const validChildren = getValidChildren(children);
45
+ const childrenWithinMax = max ? validChildren.slice(0, max) : validChildren;
46
+ const remainingCount = total ? total : max != null ? validChildren.length - max : -1;
47
+ const clones = childrenWithinMax.map((child, index) => {
48
+ return cloneElement(child, {
49
+ // @ts-expect-error: CSS variable is not recognized as a valid style property
50
+ style: {
51
+ "--avatar-zindex": childrenWithinMax.length - index
52
+ }
53
+ });
54
+ });
55
+ const getAvatarGroupProps = () => {
56
+ return {
57
+ ref: domRef,
58
+ className: slots.base({
59
+ class: cn(classNames?.base, className)
60
+ }),
61
+ role: "group",
62
+ ...otherProps
63
+ };
64
+ };
65
+ const getAvatarGroupCountProps = () => {
66
+ return {
67
+ className: slots.counter({
68
+ class: classNames?.counter
69
+ }),
70
+ ...countProps
71
+ };
72
+ };
73
+ return {
74
+ Component,
75
+ context,
76
+ remainingCount,
77
+ clones,
78
+ renderCount,
79
+ getAvatarGroupProps,
80
+ getAvatarGroupCountProps
81
+ };
82
+ }
83
+
84
+ export { AvatarGroupProvider, useAvatarGroup, useAvatarGroupContext };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useMemo } from 'react';
4
+ import { forwardRef } from '../system/utils.js';
5
+ import { AvatarRoot, AvatarFallback } from './avatar.js';
6
+ import { useAvatarGroup, AvatarGroupProvider } from './avatar-group-context.js';
7
+
8
+ const AvatarGroup = forwardRef((props, ref) => {
9
+ const {
10
+ Component,
11
+ clones,
12
+ context,
13
+ remainingCount,
14
+ getAvatarGroupCountProps,
15
+ getAvatarGroupProps,
16
+ renderCount
17
+ } = useAvatarGroup({
18
+ ...props,
19
+ ref
20
+ });
21
+ const renderedCount = useMemo(() => {
22
+ if (remainingCount <= 0) return null;
23
+ if (renderCount) {
24
+ return renderCount(remainingCount);
25
+ }
26
+ const countAvatarVariantProps = {
27
+ prominence: "subtle",
28
+ color: "primary"
29
+ };
30
+ if (context.prominence === "subtle") {
31
+ countAvatarVariantProps.color = "white";
32
+ }
33
+ return /* @__PURE__ */ jsx(
34
+ AvatarRoot,
35
+ {
36
+ ...countAvatarVariantProps,
37
+ ...getAvatarGroupCountProps(),
38
+ name: `+${remainingCount}`,
39
+ children: /* @__PURE__ */ jsxs(AvatarFallback, { children: [
40
+ "+",
41
+ remainingCount
42
+ ] })
43
+ }
44
+ );
45
+ }, [
46
+ context.prominence,
47
+ getAvatarGroupCountProps,
48
+ remainingCount,
49
+ renderCount
50
+ ]);
51
+ return /* @__PURE__ */ jsx(Component, { ...getAvatarGroupProps(), children: /* @__PURE__ */ jsxs(AvatarGroupProvider, { value: context, children: [
52
+ clones,
53
+ renderedCount
54
+ ] }) });
55
+ });
56
+ AvatarGroup.displayName = "AvatarGroup";
57
+
58
+ export { AvatarGroup };
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useState, useMemo } from 'react';
5
+ import { useLayoutEffect } from '@react-aria/utils';
6
+ import { avatarStyles, dataAttr } from '@opengovsg/oui-theme';
7
+ import { forwardRef, mapPropsVariants } from '../system/utils.js';
8
+ import { AvatarContext, useAvatarContext } from './avatar-context.js';
9
+ import { useAvatarGroupContext } from './avatar-group-context.js';
10
+ import { useImageLoadingStatus } from './hooks/use-img-loading-status.js';
11
+ import { getInitialsFromText } from './utils.js';
12
+ import { useDomRef } from '../system/react-utils/refs.js';
13
+ import User from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/user.js';
14
+
15
+ const AvatarRoot = forwardRef(
16
+ (originalProps, ref) => {
17
+ const groupContext = useAvatarGroupContext();
18
+ const [
19
+ {
20
+ name,
21
+ getInitials = getInitialsFromText,
22
+ classNames,
23
+ className,
24
+ children,
25
+ as,
26
+ ...props
27
+ },
28
+ {
29
+ color = groupContext?.color,
30
+ prominence = groupContext?.prominence,
31
+ size = groupContext?.size,
32
+ radius = groupContext?.radius,
33
+ ...variantProps
34
+ }
35
+ ] = mapPropsVariants(originalProps, avatarStyles.variantKeys);
36
+ const isInGroup = !!groupContext;
37
+ const domRef = useDomRef(ref);
38
+ const slots = avatarStyles({
39
+ color,
40
+ prominence,
41
+ size,
42
+ radius,
43
+ isInGroup,
44
+ ...variantProps
45
+ });
46
+ const [imageLoadingStatus, setImageLoadingStatus] = useState("idle");
47
+ const Component = as || "span";
48
+ return /* @__PURE__ */ jsx(
49
+ AvatarContext,
50
+ {
51
+ value: {
52
+ imageLoadingStatus,
53
+ setImageLoadingStatus,
54
+ slots,
55
+ classNames,
56
+ getInitials,
57
+ name
58
+ },
59
+ children: /* @__PURE__ */ jsx(
60
+ Component,
61
+ {
62
+ ref: domRef,
63
+ ...props,
64
+ className: slots.base({ className: className ?? classNames?.base }),
65
+ children
66
+ }
67
+ )
68
+ }
69
+ );
70
+ }
71
+ );
72
+ const AvatarImage = forwardRef(
73
+ ({ src, as, ...props }, ref) => {
74
+ const domRef = useDomRef(ref);
75
+ const {
76
+ setImageLoadingStatus,
77
+ imageLoadingStatus,
78
+ slots,
79
+ name,
80
+ classNames
81
+ } = useAvatarContext();
82
+ const currentImageStatus = useImageLoadingStatus(src, props);
83
+ const Component = as || "img";
84
+ useLayoutEffect(() => {
85
+ setImageLoadingStatus(currentImageStatus);
86
+ }, [currentImageStatus, setImageLoadingStatus]);
87
+ return /* @__PURE__ */ jsx(
88
+ Component,
89
+ {
90
+ ref: domRef,
91
+ alt: name,
92
+ "data-loaded": dataAttr(imageLoadingStatus === "loaded"),
93
+ ...props,
94
+ src,
95
+ className: slots.image({ className: classNames?.image })
96
+ }
97
+ );
98
+ }
99
+ );
100
+ const AvatarFallback = forwardRef(
101
+ ({ children, as, ...props }, ref) => {
102
+ const domRef = useDomRef(ref);
103
+ const { slots, classNames, imageLoadingStatus, name, getInitials } = useAvatarContext();
104
+ const childrenToRender = useMemo(() => {
105
+ if (children) return children;
106
+ if (name) {
107
+ return getInitials(name);
108
+ }
109
+ return /* @__PURE__ */ jsx(User, { className: slots.icon({ className: classNames?.icon }) });
110
+ }, [children, classNames?.icon, getInitials, name, slots]);
111
+ const Component = as || "div";
112
+ if (imageLoadingStatus === "loaded") {
113
+ return null;
114
+ }
115
+ return /* @__PURE__ */ jsx(
116
+ Component,
117
+ {
118
+ title: name,
119
+ className: slots.fallback({ className: classNames?.fallback }),
120
+ ref: domRef,
121
+ ...props,
122
+ children: childrenToRender
123
+ }
124
+ );
125
+ }
126
+ );
127
+
128
+ export { AvatarFallback, AvatarImage, AvatarRoot };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ import { useRef, useState, useLayoutEffect, useSyncExternalStore } from 'react';
3
+
4
+ function useIsHydrated() {
5
+ return useSyncExternalStore(
6
+ subscribe,
7
+ () => true,
8
+ () => false
9
+ );
10
+ }
11
+ function subscribe() {
12
+ return () => {
13
+ };
14
+ }
15
+ function resolveLoadingStatus(image, src) {
16
+ if (!image) {
17
+ return "idle";
18
+ }
19
+ if (!src) {
20
+ return "error";
21
+ }
22
+ if (image.src !== src) {
23
+ image.src = src;
24
+ }
25
+ return image.complete && image.naturalWidth > 0 ? "loaded" : "loading";
26
+ }
27
+ function useImageLoadingStatus(src, { referrerPolicy, crossOrigin }) {
28
+ const isHydrated = useIsHydrated();
29
+ const imageRef = useRef(null);
30
+ const image = (() => {
31
+ if (!isHydrated) return null;
32
+ if (!imageRef.current) {
33
+ imageRef.current = new window.Image();
34
+ }
35
+ return imageRef.current;
36
+ })();
37
+ const [loadingStatus, setLoadingStatus] = useState(
38
+ () => resolveLoadingStatus(image, src)
39
+ );
40
+ useLayoutEffect(() => {
41
+ setLoadingStatus(resolveLoadingStatus(image, src));
42
+ }, [image, src]);
43
+ useLayoutEffect(() => {
44
+ const updateStatus = (status) => () => {
45
+ setLoadingStatus(status);
46
+ };
47
+ if (!image) return;
48
+ const handleLoad = updateStatus("loaded");
49
+ const handleError = updateStatus("error");
50
+ image.addEventListener("load", handleLoad);
51
+ image.addEventListener("error", handleError);
52
+ if (referrerPolicy) {
53
+ image.referrerPolicy = referrerPolicy;
54
+ }
55
+ if (typeof crossOrigin === "string") {
56
+ image.crossOrigin = crossOrigin;
57
+ }
58
+ return () => {
59
+ image.removeEventListener("load", handleLoad);
60
+ image.removeEventListener("error", handleError);
61
+ };
62
+ }, [image, crossOrigin, referrerPolicy]);
63
+ return loadingStatus;
64
+ }
65
+
66
+ export { useImageLoadingStatus };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ import { AvatarRoot, AvatarFallback, AvatarImage } from './avatar.js';
3
+ export { AvatarContext, useAvatarContext } from './avatar-context.js';
4
+ export { AvatarGroup } from './avatar-group.js';
5
+ export { AvatarGroupProvider, useAvatarGroup } from './avatar-group-context.js';
6
+
7
+ const Avatar = Object.assign(AvatarRoot, {
8
+ Root: AvatarRoot,
9
+ Image: AvatarImage,
10
+ Fallback: AvatarFallback
11
+ });
12
+
13
+ export { Avatar, AvatarFallback, AvatarImage, AvatarRoot };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ const getInitialsFromText = (text, limit = 2) => {
3
+ const initials = text?.trim().split(/[\s\-_.]+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase()).join("") || "";
4
+ return initials.slice(0, limit);
5
+ };
6
+
7
+ export { getInitialsFromText };
@@ -5,9 +5,9 @@ import { useMemo, useRef } from 'react';
5
5
  import { useMessageFormatter, useDisclosure } from 'react-aria';
6
6
  import { useDisclosureState } from 'react-stately';
7
7
  import { bannerStyles } from '@opengovsg/oui-theme';
8
+ import { Button } from '../button/button.js';
8
9
  import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
9
10
  import Info from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/info.js';
10
- import { Button } from '../button/button.js';
11
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
12
 
13
13
  const i18nStrings = {
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  "use client";
3
- import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { forwardRef, useMemo } from 'react';
5
5
  import { chain } from '@react-aria/utils';
6
6
  import { Button as Button$1, composeRenderProps } from 'react-aria-components';
7
7
  import { buttonStyles } from '@opengovsg/oui-theme';
8
+ import { Ripple } from '../ripple/ripple.js';
8
9
  import { useRipple } from '../ripple/use-ripple.js';
9
10
  import { Spinner } from '../spinner/spinner.js';
10
- import { Ripple } from '../ripple/ripple.js';
11
+ import { renderChildren } from '../system/react-utils/children.js';
11
12
 
12
13
  const Button = forwardRef(
13
14
  ({
@@ -21,6 +22,7 @@ const Button = forwardRef(
21
22
  size = "md",
22
23
  spinnerPlacement = "start",
23
24
  loadingText,
25
+ pendingElement,
24
26
  onPress,
25
27
  children,
26
28
  disableRipple,
@@ -47,7 +49,7 @@ const Button = forwardRef(
47
49
  const spinnerSize = buttonSpinnerSizeMap[size];
48
50
  return /* @__PURE__ */ jsx(Spinner, { size: spinnerSize });
49
51
  }, [size, spinnerProp]);
50
- return /* @__PURE__ */ jsxs(
52
+ return /* @__PURE__ */ jsx(
51
53
  Button$1,
52
54
  {
53
55
  ...props,
@@ -68,15 +70,16 @@ const Button = forwardRef(
68
70
  isPending,
69
71
  onPress: chain(onPress, onPressRipple),
70
72
  ref,
71
- children: [
72
- startContent,
73
- isPending && spinnerPlacement === "start" ? spinner : null,
74
- isPending ? null : children,
73
+ children: (renderProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
74
+ renderChildren(renderProps, startContent),
75
+ isPending && spinnerPlacement === "start" ? renderChildren(renderProps, spinner) : null,
76
+ isPending ? null : renderChildren(renderProps, children),
75
77
  isPending && loadingText ? loadingText : null,
76
- isPending && spinnerPlacement === "end" ? spinner : null,
77
- endContent,
78
+ isPending && pendingElement ? renderChildren(renderProps, pendingElement) : null,
79
+ isPending && spinnerPlacement === "end" ? renderChildren(renderProps, spinner) : null,
80
+ renderChildren(renderProps, endContent),
78
81
  !disableRipple && /* @__PURE__ */ jsx(Ripple, { onClear: onClearRipple, ripples })
79
- ]
82
+ ] })
80
83
  }
81
84
  );
82
85
  }
@@ -4,11 +4,11 @@ import { jsx } from 'react/jsx-runtime';
4
4
  import { useContext } from 'react';
5
5
  import { CalendarDate } from '@internationalized/date';
6
6
  import { Group } from 'react-aria-components';
7
+ import { Select } from '../select/select.js';
8
+ import { SelectItem } from '../select/select-item.js';
7
9
  import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
8
10
  import { useCalendarStyleContext } from './calendar-style-context.js';
9
11
  import { useCalendarSelectors } from './hooks/use-calendar-selectors.js';
10
- import { Select } from '../select/select.js';
11
- import { SelectItem } from '../select/select-item.js';
12
12
  import { useCalendarI18n } from './hooks/use-calendar-i18n.js';
13
13
 
14
14
  const CalendarMonthDaySelector = () => {
@@ -3,11 +3,11 @@
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { Checkbox as Checkbox$1, composeRenderProps, Provider, CheckboxGroup as CheckboxGroup$1 } from 'react-aria-components';
5
5
  import { checkboxStyles, checkboxGroupStyles } from '@opengovsg/oui-theme';
6
+ import { Label, Description, FieldError } from '../field/field.js';
6
7
  import { mapPropsVariants } from '../system/utils.js';
7
8
  import { useCheckboxGroupStyleContext, CheckboxGroupStyleContext } from './checkbox-group-style-context.js';
8
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';
9
10
  import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/check.js';
10
- import { Label, Description, FieldError } from '../field/field.js';
11
11
 
12
12
  const Checkbox = ({
13
13
  classNames,
@@ -18,8 +18,8 @@ const Checkbox = ({
18
18
  originalProps,
19
19
  checkboxStyles.variantKeys
20
20
  );
21
- const { size } = useCheckboxGroupStyleContext();
22
- const styles = checkboxStyles({ size, ...variants });
21
+ const context = useCheckboxGroupStyleContext();
22
+ const styles = checkboxStyles({ size: context?.size, ...variants });
23
23
  return /* @__PURE__ */ jsx(
24
24
  Checkbox$1,
25
25
  {
@@ -5,13 +5,13 @@ import { useMemo, useCallback } from 'react';
5
5
  import { useMessageFormatter } from 'react-aria';
6
6
  import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Virtualizer, ListBox } from 'react-aria-components';
7
7
  import { listBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
8
+ import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
9
+ import { Popover } from '../popover/popover.js';
8
10
  import { mapPropsVariants } from '../system/utils.js';
9
11
  import { ComboBoxVariantContext } from './combo-box-variant-context.js';
10
- import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
11
12
  import ChevronUp from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-up.js';
12
13
  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
14
  import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js';
14
- import { Popover } from '../popover/popover.js';
15
15
 
16
16
  const calculateEstimatedRowHeight = (size) => {
17
17
  switch (size) {