@opengovsg/oui 0.0.0-snapshot-20250311073924

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 (215) hide show
  1. package/LICENSE.md +13 -0
  2. package/dist/cjs/banner/banner.cjs +118 -0
  3. package/dist/cjs/banner/index.cjs +8 -0
  4. package/dist/cjs/button/button.cjs +86 -0
  5. package/dist/cjs/button/index.cjs +8 -0
  6. package/dist/cjs/combo-box/combo-box-fuzzy.cjs +107 -0
  7. package/dist/cjs/combo-box/combo-box.cjs +277 -0
  8. package/dist/cjs/combo-box/index.cjs +12 -0
  9. package/dist/cjs/field/field.cjs +63 -0
  10. package/dist/cjs/field/index.cjs +11 -0
  11. package/dist/cjs/govt-banner/govt-banner.cjs +259 -0
  12. package/dist/cjs/govt-banner/index.cjs +8 -0
  13. package/dist/cjs/hooks/index.cjs +8 -0
  14. package/dist/cjs/hooks/use-callback-ref.cjs +17 -0
  15. package/dist/cjs/hooks/use-controllable-state.cjs +37 -0
  16. package/dist/cjs/index.cjs +47 -0
  17. package/dist/cjs/input/index.cjs +8 -0
  18. package/dist/cjs/input/input.cjs +28 -0
  19. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/Icon.cjs +48 -0
  20. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +30 -0
  21. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/defaultAttributes.cjs +24 -0
  22. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs +19 -0
  23. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-up.cjs +19 -0
  24. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/circle-alert.cjs +23 -0
  25. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/external-link.cjs +23 -0
  26. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/info.cjs +23 -0
  27. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/landmark.cjs +26 -0
  28. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/lock.cjs +22 -0
  29. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.cjs +22 -0
  30. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/shared/src/utils.cjs +16 -0
  31. package/dist/cjs/ripple/index.cjs +10 -0
  32. package/dist/cjs/ripple/ripple.cjs +70 -0
  33. package/dist/cjs/ripple/use-ripple.cjs +29 -0
  34. package/dist/cjs/skip-nav-link/index.cjs +8 -0
  35. package/dist/cjs/skip-nav-link/skip-nav-link.cjs +18 -0
  36. package/dist/cjs/spinner/index.cjs +10 -0
  37. package/dist/cjs/spinner/spinner.cjs +17 -0
  38. package/dist/cjs/spinner/use-spinner.cjs +38 -0
  39. package/dist/cjs/system/react-utils/context.cjs +31 -0
  40. package/dist/cjs/system/react-utils/index.cjs +8 -0
  41. package/dist/cjs/system/types.cjs +3 -0
  42. package/dist/cjs/system/utils.cjs +101 -0
  43. package/dist/cjs/tag-field/index.cjs +8 -0
  44. package/dist/cjs/tag-field/tag-field-list.cjs +73 -0
  45. package/dist/cjs/tag-field/tag-field-root.cjs +184 -0
  46. package/dist/cjs/tag-field/tag-field-state-context.cjs +11 -0
  47. package/dist/cjs/tag-field/tag-field-tag-list.cjs +70 -0
  48. package/dist/cjs/tag-field/tag-field-trigger.cjs +27 -0
  49. package/dist/cjs/tag-field/tag-field.cjs +106 -0
  50. package/dist/cjs/tag-field/types.cjs +3 -0
  51. package/dist/cjs/tag-field/use-tag-field-state.cjs +103 -0
  52. package/dist/cjs/tag-field/use-tag-field.cjs +188 -0
  53. package/dist/cjs/text-area/index.cjs +8 -0
  54. package/dist/cjs/text-area/text-area.cjs +28 -0
  55. package/dist/cjs/text-area-field/index.cjs +8 -0
  56. package/dist/cjs/text-area-field/text-area-field.cjs +48 -0
  57. package/dist/cjs/text-field/index.cjs +8 -0
  58. package/dist/cjs/text-field/text-field.cjs +48 -0
  59. package/dist/cjs/toggle/index.cjs +8 -0
  60. package/dist/cjs/toggle/toggle.cjs +48 -0
  61. package/dist/esm/banner/banner.js +116 -0
  62. package/dist/esm/banner/index.js +2 -0
  63. package/dist/esm/button/button.js +84 -0
  64. package/dist/esm/button/index.js +2 -0
  65. package/dist/esm/combo-box/combo-box-fuzzy.js +105 -0
  66. package/dist/esm/combo-box/combo-box.js +273 -0
  67. package/dist/esm/combo-box/index.js +3 -0
  68. package/dist/esm/field/field.js +58 -0
  69. package/dist/esm/field/index.js +2 -0
  70. package/dist/esm/govt-banner/govt-banner.js +257 -0
  71. package/dist/esm/govt-banner/index.js +2 -0
  72. package/dist/esm/hooks/index.js +2 -0
  73. package/dist/esm/hooks/use-callback-ref.js +15 -0
  74. package/dist/esm/hooks/use-controllable-state.js +35 -0
  75. package/dist/esm/index.js +19 -0
  76. package/dist/esm/input/index.js +2 -0
  77. package/dist/esm/input/input.js +26 -0
  78. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/Icon.js +44 -0
  79. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/createLucideIcon.js +26 -0
  80. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/defaultAttributes.js +20 -0
  81. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js +14 -0
  82. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-up.js +14 -0
  83. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/circle-alert.js +18 -0
  84. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/external-link.js +18 -0
  85. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/info.js +18 -0
  86. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/landmark.js +21 -0
  87. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/lock.js +17 -0
  88. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js +17 -0
  89. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/shared/src/utils.js +13 -0
  90. package/dist/esm/ripple/index.js +3 -0
  91. package/dist/esm/ripple/ripple.js +49 -0
  92. package/dist/esm/ripple/use-ripple.js +27 -0
  93. package/dist/esm/skip-nav-link/index.js +2 -0
  94. package/dist/esm/skip-nav-link/skip-nav-link.js +16 -0
  95. package/dist/esm/spinner/index.js +3 -0
  96. package/dist/esm/spinner/spinner.js +15 -0
  97. package/dist/esm/spinner/use-spinner.js +36 -0
  98. package/dist/esm/system/react-utils/context.js +29 -0
  99. package/dist/esm/system/react-utils/index.js +2 -0
  100. package/dist/esm/system/types.js +1 -0
  101. package/dist/esm/system/utils.js +94 -0
  102. package/dist/esm/tag-field/index.js +2 -0
  103. package/dist/esm/tag-field/tag-field-list.js +69 -0
  104. package/dist/esm/tag-field/tag-field-root.js +182 -0
  105. package/dist/esm/tag-field/tag-field-state-context.js +9 -0
  106. package/dist/esm/tag-field/tag-field-tag-list.js +68 -0
  107. package/dist/esm/tag-field/tag-field-trigger.js +24 -0
  108. package/dist/esm/tag-field/tag-field.js +104 -0
  109. package/dist/esm/tag-field/types.js +1 -0
  110. package/dist/esm/tag-field/use-tag-field-state.js +101 -0
  111. package/dist/esm/tag-field/use-tag-field.js +186 -0
  112. package/dist/esm/text-area/index.js +2 -0
  113. package/dist/esm/text-area/text-area.js +26 -0
  114. package/dist/esm/text-area-field/index.js +2 -0
  115. package/dist/esm/text-area-field/text-area-field.js +46 -0
  116. package/dist/esm/text-field/index.js +2 -0
  117. package/dist/esm/text-field/text-field.js +46 -0
  118. package/dist/esm/toggle/index.js +2 -0
  119. package/dist/esm/toggle/toggle.js +46 -0
  120. package/dist/types/banner/banner.d.ts +19 -0
  121. package/dist/types/banner/banner.d.ts.map +1 -0
  122. package/dist/types/banner/index.d.ts +2 -0
  123. package/dist/types/banner/index.d.ts.map +1 -0
  124. package/dist/types/button/button.d.ts +48 -0
  125. package/dist/types/button/button.d.ts.map +1 -0
  126. package/dist/types/button/index.d.ts +2 -0
  127. package/dist/types/button/index.d.ts.map +1 -0
  128. package/dist/types/combo-box/combo-box-fuzzy.d.ts +11 -0
  129. package/dist/types/combo-box/combo-box-fuzzy.d.ts.map +1 -0
  130. package/dist/types/combo-box/combo-box.d.ts +50 -0
  131. package/dist/types/combo-box/combo-box.d.ts.map +1 -0
  132. package/dist/types/combo-box/index.d.ts +3 -0
  133. package/dist/types/combo-box/index.d.ts.map +1 -0
  134. package/dist/types/field/field.d.ts +14 -0
  135. package/dist/types/field/field.d.ts.map +1 -0
  136. package/dist/types/field/index.d.ts +2 -0
  137. package/dist/types/field/index.d.ts.map +1 -0
  138. package/dist/types/govt-banner/govt-banner.d.ts +39 -0
  139. package/dist/types/govt-banner/govt-banner.d.ts.map +1 -0
  140. package/dist/types/govt-banner/index.d.ts +2 -0
  141. package/dist/types/govt-banner/index.d.ts.map +1 -0
  142. package/dist/types/hooks/index.d.ts +2 -0
  143. package/dist/types/hooks/index.d.ts.map +1 -0
  144. package/dist/types/hooks/use-callback-ref.d.ts +6 -0
  145. package/dist/types/hooks/use-callback-ref.d.ts.map +1 -0
  146. package/dist/types/hooks/use-controllable-state.d.ts +11 -0
  147. package/dist/types/hooks/use-controllable-state.d.ts.map +1 -0
  148. package/dist/types/index.d.mts +16 -0
  149. package/dist/types/index.d.ts +16 -0
  150. package/dist/types/index.d.ts.map +1 -0
  151. package/dist/types/input/index.d.ts +2 -0
  152. package/dist/types/input/index.d.ts.map +1 -0
  153. package/dist/types/input/input.d.ts +9 -0
  154. package/dist/types/input/input.d.ts.map +1 -0
  155. package/dist/types/ripple/index.d.ts +3 -0
  156. package/dist/types/ripple/index.d.ts.map +1 -0
  157. package/dist/types/ripple/ripple.d.ts +10 -0
  158. package/dist/types/ripple/ripple.d.ts.map +1 -0
  159. package/dist/types/ripple/use-ripple.d.ts +15 -0
  160. package/dist/types/ripple/use-ripple.d.ts.map +1 -0
  161. package/dist/types/skip-nav-link/index.d.ts +2 -0
  162. package/dist/types/skip-nav-link/index.d.ts.map +1 -0
  163. package/dist/types/skip-nav-link/skip-nav-link.d.ts +11 -0
  164. package/dist/types/skip-nav-link/skip-nav-link.d.ts.map +1 -0
  165. package/dist/types/spinner/index.d.ts +3 -0
  166. package/dist/types/spinner/index.d.ts.map +1 -0
  167. package/dist/types/spinner/spinner.d.ts +4 -0
  168. package/dist/types/spinner/spinner.d.ts.map +1 -0
  169. package/dist/types/spinner/use-spinner.d.ts +66 -0
  170. package/dist/types/spinner/use-spinner.d.ts.map +1 -0
  171. package/dist/types/system/react-utils/context.d.ts +27 -0
  172. package/dist/types/system/react-utils/context.d.ts.map +1 -0
  173. package/dist/types/system/react-utils/index.d.ts +2 -0
  174. package/dist/types/system/react-utils/index.d.ts.map +1 -0
  175. package/dist/types/system/types.d.ts +63 -0
  176. package/dist/types/system/types.d.ts.map +1 -0
  177. package/dist/types/system/utils.d.ts +856 -0
  178. package/dist/types/system/utils.d.ts.map +1 -0
  179. package/dist/types/tag-field/index.d.ts +2 -0
  180. package/dist/types/tag-field/index.d.ts.map +1 -0
  181. package/dist/types/tag-field/tag-field-list.d.ts +22 -0
  182. package/dist/types/tag-field/tag-field-list.d.ts.map +1 -0
  183. package/dist/types/tag-field/tag-field-root.d.ts +14 -0
  184. package/dist/types/tag-field/tag-field-root.d.ts.map +1 -0
  185. package/dist/types/tag-field/tag-field-state-context.d.ts +12 -0
  186. package/dist/types/tag-field/tag-field-state-context.d.ts.map +1 -0
  187. package/dist/types/tag-field/tag-field-tag-list.d.ts +17 -0
  188. package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -0
  189. package/dist/types/tag-field/tag-field-trigger.d.ts +8 -0
  190. package/dist/types/tag-field/tag-field-trigger.d.ts.map +1 -0
  191. package/dist/types/tag-field/tag-field.d.ts +3 -0
  192. package/dist/types/tag-field/tag-field.d.ts.map +1 -0
  193. package/dist/types/tag-field/types.d.ts +71 -0
  194. package/dist/types/tag-field/types.d.ts.map +1 -0
  195. package/dist/types/tag-field/use-tag-field-state.d.ts +35 -0
  196. package/dist/types/tag-field/use-tag-field-state.d.ts.map +1 -0
  197. package/dist/types/tag-field/use-tag-field.d.ts +48 -0
  198. package/dist/types/tag-field/use-tag-field.d.ts.map +1 -0
  199. package/dist/types/text-area/index.d.ts +2 -0
  200. package/dist/types/text-area/index.d.ts.map +1 -0
  201. package/dist/types/text-area/text-area.d.ts +9 -0
  202. package/dist/types/text-area/text-area.d.ts.map +1 -0
  203. package/dist/types/text-area-field/index.d.ts +2 -0
  204. package/dist/types/text-area-field/index.d.ts.map +1 -0
  205. package/dist/types/text-area-field/text-area-field.d.ts +12 -0
  206. package/dist/types/text-area-field/text-area-field.d.ts.map +1 -0
  207. package/dist/types/text-field/index.d.ts +2 -0
  208. package/dist/types/text-field/index.d.ts.map +1 -0
  209. package/dist/types/text-field/text-field.d.ts +12 -0
  210. package/dist/types/text-field/text-field.d.ts.map +1 -0
  211. package/dist/types/toggle/index.d.ts +2 -0
  212. package/dist/types/toggle/index.d.ts.map +1 -0
  213. package/dist/types/toggle/toggle.d.ts +22 -0
  214. package/dist/types/toggle/toggle.d.ts.map +1 -0
  215. package/package.json +93 -0
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ "use client";
3
+ 'use strict';
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+ var ouiTheme = require('@opengovsg/oui-theme');
8
+ var reactAriaComponents = require('react-aria-components');
9
+
10
+ const TextArea = react.forwardRef(
11
+ ({ size, variant, isDisabled, ...props }, ref) => {
12
+ return /* @__PURE__ */ jsxRuntime.jsx(
13
+ reactAriaComponents.TextArea,
14
+ {
15
+ ...props,
16
+ disabled: isDisabled,
17
+ className: ouiTheme.composeRenderProps(
18
+ props.className,
19
+ (className, renderProps) => ouiTheme.textAreaStyles({ ...renderProps, className, size, variant })
20
+ ),
21
+ ref
22
+ }
23
+ );
24
+ }
25
+ );
26
+ TextArea.displayName = "TextArea";
27
+
28
+ exports.TextArea = TextArea;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ 'use strict';
3
+
4
+ var textAreaField = require('./text-area-field.cjs');
5
+
6
+
7
+
8
+ exports.TextAreaField = textAreaField.TextAreaField;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ "use client";
3
+ 'use strict';
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var ouiTheme = require('@opengovsg/oui-theme');
7
+ var reactAriaComponents = require('react-aria-components');
8
+ var textArea = require('../text-area/text-area.cjs');
9
+ var field = require('../field/field.cjs');
10
+
11
+ function TextAreaField({
12
+ label,
13
+ description,
14
+ errorMessage,
15
+ classNames,
16
+ className,
17
+ inputProps,
18
+ size,
19
+ variant,
20
+ ...props
21
+ }) {
22
+ return /* @__PURE__ */ jsxRuntime.jsxs(
23
+ reactAriaComponents.TextField,
24
+ {
25
+ ...props,
26
+ className: ouiTheme.composeTailwindRenderProps(
27
+ className ?? classNames?.base,
28
+ "flex flex-col gap-2"
29
+ ),
30
+ children: [
31
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Label, { size, className: classNames?.label, children: label }),
32
+ /* @__PURE__ */ jsxRuntime.jsx(
33
+ textArea.TextArea,
34
+ {
35
+ size,
36
+ variant,
37
+ className: classNames?.input,
38
+ ...inputProps
39
+ }
40
+ ),
41
+ description && /* @__PURE__ */ jsxRuntime.jsx(field.Description, { size, className: classNames?.description, children: description }),
42
+ /* @__PURE__ */ jsxRuntime.jsx(field.FieldError, { size, className: classNames?.error, children: errorMessage })
43
+ ]
44
+ }
45
+ );
46
+ }
47
+
48
+ exports.TextAreaField = TextAreaField;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ 'use strict';
3
+
4
+ var textField = require('./text-field.cjs');
5
+
6
+
7
+
8
+ exports.TextField = textField.TextField;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ "use client";
3
+ 'use strict';
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var ouiTheme = require('@opengovsg/oui-theme');
7
+ var reactAriaComponents = require('react-aria-components');
8
+ var input = require('../input/input.cjs');
9
+ var field = require('../field/field.cjs');
10
+
11
+ function TextField({
12
+ label,
13
+ description,
14
+ errorMessage,
15
+ classNames,
16
+ className,
17
+ inputProps,
18
+ size,
19
+ variant,
20
+ ...props
21
+ }) {
22
+ return /* @__PURE__ */ jsxRuntime.jsxs(
23
+ reactAriaComponents.TextField,
24
+ {
25
+ ...props,
26
+ className: ouiTheme.composeTailwindRenderProps(
27
+ className ?? classNames?.base,
28
+ "flex flex-col gap-2"
29
+ ),
30
+ children: [
31
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Label, { size, className: classNames?.label, children: label }),
32
+ /* @__PURE__ */ jsxRuntime.jsx(
33
+ input.Input,
34
+ {
35
+ size,
36
+ variant,
37
+ className: classNames?.input,
38
+ ...inputProps
39
+ }
40
+ ),
41
+ description && /* @__PURE__ */ jsxRuntime.jsx(field.Description, { size, className: classNames?.description, children: description }),
42
+ /* @__PURE__ */ jsxRuntime.jsx(field.FieldError, { size, className: classNames?.error, children: errorMessage })
43
+ ]
44
+ }
45
+ );
46
+ }
47
+
48
+ exports.TextField = TextField;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ 'use strict';
3
+
4
+ var toggle = require('./toggle.cjs');
5
+
6
+
7
+
8
+ exports.Toggle = toggle.Toggle;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ "use client";
3
+ 'use strict';
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+ var ouiTheme = require('@opengovsg/oui-theme');
8
+ var reactAria = require('react-aria');
9
+ var reactAriaComponents = require('react-aria-components');
10
+ var utils = require('../system/utils.cjs');
11
+
12
+ const Toggle = ({
13
+ children,
14
+ classNames,
15
+ thumbIcon,
16
+ ...originalProps
17
+ }) => {
18
+ const [props, variantProps] = utils.mapPropsVariants(
19
+ originalProps,
20
+ ouiTheme.toggleStyles.variantKeys
21
+ );
22
+ const slots = ouiTheme.toggleStyles(variantProps);
23
+ const clonedThumbIcon = react.useCallback(
24
+ (renderProps) => {
25
+ const baseProps = {
26
+ className: slots.thumbIcon({ className: classNames?.thumbIcon })
27
+ };
28
+ return typeof thumbIcon === "function" ? thumbIcon(reactAria.mergeProps(baseProps, renderProps)) : thumbIcon && react.cloneElement(thumbIcon, baseProps);
29
+ },
30
+ [classNames?.thumbIcon, slots, thumbIcon]
31
+ );
32
+ return /* @__PURE__ */ jsxRuntime.jsx(
33
+ reactAriaComponents.Switch,
34
+ {
35
+ ...props,
36
+ className: ouiTheme.composeTailwindRenderProps(
37
+ props.className ?? classNames?.base,
38
+ slots.base()
39
+ ),
40
+ children: (renderProps) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
41
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: slots.track({ className: classNames?.track }), children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: slots.thumb({ className: classNames?.thumb }), children: thumbIcon && clonedThumbIcon(renderProps) }) }),
42
+ children
43
+ ] })
44
+ }
45
+ );
46
+ };
47
+
48
+ exports.Toggle = Toggle;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { useMemo, useRef } from 'react';
5
+ import { bannerStyles } from '@opengovsg/oui-theme';
6
+ import { useMessageFormatter, useDisclosure } from 'react-aria';
7
+ import { useDisclosureState } from 'react-stately';
8
+ import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
9
+ import Info from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/info.js';
10
+ import { Button } from '../button/button.js';
11
+ import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js';
12
+
13
+ const i18nStrings = {
14
+ "en-SG": {
15
+ dismiss: "Close banner"
16
+ },
17
+ "zh-SG": {
18
+ dismiss: "\u5173\u95ED\u6A2A\u5E45"
19
+ },
20
+ "ms-SG": {
21
+ dismiss: "Tutup sepanduk"
22
+ },
23
+ "ta-SG": {
24
+ dismiss: "\u0B89\u0B9F\u0BC8\u0B95\u0BB3\u0BC8 \u0BAE\u0BC2\u0B9F\u0BC1\u0B99\u0BCD\u0B95\u0BB3\u0BCD"
25
+ }
26
+ };
27
+ const Banner = ({
28
+ variant = "info",
29
+ size,
30
+ children,
31
+ isDismissable,
32
+ startContent: startContentProp,
33
+ className,
34
+ classNames,
35
+ defaultExpanded = true,
36
+ ...disclosureProps
37
+ }) => {
38
+ const formatMessage = useMessageFormatter(i18nStrings);
39
+ const styles = bannerStyles({ variant, size });
40
+ const startContent = useMemo(() => {
41
+ if (startContentProp) {
42
+ return startContentProp;
43
+ }
44
+ switch (variant) {
45
+ case "info":
46
+ return /* @__PURE__ */ jsx(Info, { className: styles.icon({ className: classNames?.icon }) });
47
+ case "warning":
48
+ case "error":
49
+ return /* @__PURE__ */ jsx(
50
+ CircleAlert,
51
+ {
52
+ className: styles.icon({ className: classNames?.icon })
53
+ }
54
+ );
55
+ }
56
+ }, [classNames?.icon, startContentProp, styles, variant]);
57
+ const bannerRef = useRef(null);
58
+ const state = useDisclosureState({
59
+ defaultExpanded
60
+ });
61
+ const { buttonProps, panelProps: bannerProps } = useDisclosure(
62
+ disclosureProps,
63
+ state,
64
+ bannerRef
65
+ );
66
+ if (!state.isExpanded) {
67
+ return null;
68
+ }
69
+ return /* @__PURE__ */ jsxs(
70
+ "div",
71
+ {
72
+ className: styles.base({ className: className ?? classNames?.base }),
73
+ ref: bannerRef,
74
+ ...isDismissable ? bannerProps : {},
75
+ children: [
76
+ /* @__PURE__ */ jsxs("div", { className: styles.content({ className: classNames?.content }), children: [
77
+ /* @__PURE__ */ jsx(
78
+ "div",
79
+ {
80
+ className: styles.startContentWrapper({
81
+ className: classNames?.startContentWrapper
82
+ }),
83
+ children: startContent
84
+ }
85
+ ),
86
+ /* @__PURE__ */ jsx(
87
+ "div",
88
+ {
89
+ className: styles.childrenWrapper({
90
+ className: classNames?.childrenWrapper
91
+ }),
92
+ children
93
+ }
94
+ )
95
+ ] }),
96
+ isDismissable && /* @__PURE__ */ jsx(
97
+ Button,
98
+ {
99
+ size: "xs",
100
+ variant: "clear",
101
+ color: "neutral",
102
+ isIconOnly: true,
103
+ "aria-label": formatMessage("dismiss"),
104
+ className: styles.dismissButton({
105
+ className: classNames?.dismissButton
106
+ }),
107
+ ...buttonProps,
108
+ children: /* @__PURE__ */ jsx(X, {})
109
+ }
110
+ )
111
+ ]
112
+ }
113
+ );
114
+ };
115
+
116
+ export { Banner };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ export { Banner } from './banner.js';
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { forwardRef, useMemo } from 'react';
5
+ import { buttonStyles } from '@opengovsg/oui-theme';
6
+ import { chain } from '@react-aria/utils';
7
+ import { Button as Button$1, composeRenderProps } from 'react-aria-components';
8
+ import { useRipple } from '../ripple/use-ripple.js';
9
+ import { Spinner } from '../spinner/spinner.js';
10
+ import { Ripple } from '../ripple/ripple.js';
11
+
12
+ const Button = forwardRef(
13
+ ({
14
+ startContent,
15
+ endContent,
16
+ className: classNameProp,
17
+ variant,
18
+ color,
19
+ layout,
20
+ radius,
21
+ size = "md",
22
+ spinnerPlacement = "start",
23
+ loadingText,
24
+ onPress,
25
+ children,
26
+ disableRipple,
27
+ isPending,
28
+ spinner: spinnerProp,
29
+ isIconOnly,
30
+ ...props
31
+ }, ref) => {
32
+ const {
33
+ onPress: onPressRipple,
34
+ onClear: onClearRipple,
35
+ ripples
36
+ } = useRipple();
37
+ const spinner = useMemo(() => {
38
+ if (spinnerProp) {
39
+ return spinnerProp;
40
+ }
41
+ const buttonSpinnerSizeMap = {
42
+ sm: "sm",
43
+ md: "sm",
44
+ lg: "md"
45
+ };
46
+ const spinnerSize = buttonSpinnerSizeMap[size];
47
+ return /* @__PURE__ */ jsx(Spinner, { size: spinnerSize });
48
+ }, [size, spinnerProp]);
49
+ return /* @__PURE__ */ jsxs(
50
+ Button$1,
51
+ {
52
+ ...props,
53
+ className: composeRenderProps(
54
+ classNameProp,
55
+ (className, renderProps) => buttonStyles({
56
+ ...renderProps,
57
+ variant,
58
+ size,
59
+ className,
60
+ layout,
61
+ color,
62
+ radius,
63
+ isIconOnly
64
+ })
65
+ ),
66
+ isPending,
67
+ onPress: chain(onPress, onPressRipple),
68
+ ref,
69
+ children: [
70
+ startContent,
71
+ isPending && spinnerPlacement === "start" ? spinner : null,
72
+ isPending ? null : children,
73
+ isPending && loadingText ? loadingText : null,
74
+ isPending && spinnerPlacement === "end" ? spinner : null,
75
+ endContent,
76
+ !disableRipple && /* @__PURE__ */ jsx(Ripple, { onClear: onClearRipple, ripples })
77
+ ]
78
+ }
79
+ );
80
+ }
81
+ );
82
+ Button.displayName = "Button";
83
+
84
+ export { Button };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ export { Button } from './button.js';
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useDeferredValue, useMemo, useState, useCallback } from 'react';
5
+ import { comboBoxFuzzyHighlightedTextStyles } from '@opengovsg/oui-theme';
6
+ import fuzzysort from 'fuzzysort';
7
+ import { ComboBox, ComboBoxItem } from './combo-box.js';
8
+
9
+ function HighlightedText({
10
+ result,
11
+ originalText,
12
+ isFocused,
13
+ isSelected,
14
+ className
15
+ }) {
16
+ if (!result || result.indexes.length === 0) return originalText;
17
+ return result.highlight((m, i) => /* @__PURE__ */ jsx(
18
+ "mark",
19
+ {
20
+ className: comboBoxFuzzyHighlightedTextStyles({
21
+ className,
22
+ isFocused,
23
+ isSelected
24
+ }),
25
+ children: m
26
+ },
27
+ i
28
+ ));
29
+ }
30
+ function ComboBoxFuzzy({
31
+ items,
32
+ itemClassNames,
33
+ onSelectionChange: onSelectionChangeProp,
34
+ onInputChange: onInputChangeProp,
35
+ ...props
36
+ }) {
37
+ const deferredInputValue = useDeferredValue(props.inputValue);
38
+ const preparedItems = useMemo(() => {
39
+ return items?.map((item) => ({
40
+ ...item,
41
+ prepared: fuzzysort.prepare(item.name)
42
+ })) ?? [];
43
+ }, [items]);
44
+ const [filteredResults, setFilteredResults] = useState({ items, result: {} });
45
+ const onSelectionChange = useCallback(
46
+ (key) => {
47
+ onSelectionChangeProp(key);
48
+ setFilteredResults({ items: preparedItems, result: {} });
49
+ },
50
+ [onSelectionChangeProp, preparedItems]
51
+ );
52
+ const onInputChange = useCallback(
53
+ (value) => {
54
+ onInputChangeProp(value);
55
+ if (!value) {
56
+ setFilteredResults({ items: preparedItems, result: {} });
57
+ return;
58
+ }
59
+ const results = fuzzysort.go(value, preparedItems, {
60
+ key: "prepared"
61
+ }).reduce(
62
+ (acc, result) => {
63
+ acc.items.push(result.obj);
64
+ acc.result[result.obj.name] = result;
65
+ return acc;
66
+ },
67
+ { items: [], result: {} }
68
+ );
69
+ setFilteredResults(results);
70
+ },
71
+ [onInputChangeProp, preparedItems]
72
+ );
73
+ return /* @__PURE__ */ jsx(
74
+ ComboBox,
75
+ {
76
+ ...props,
77
+ items: filteredResults.items,
78
+ dependencies: [deferredInputValue],
79
+ onSelectionChange,
80
+ onInputChange,
81
+ children: (item) => /* @__PURE__ */ jsx(
82
+ ComboBoxItem,
83
+ {
84
+ classNames: itemClassNames,
85
+ label: ({ isSelected, isFocused }) => /* @__PURE__ */ jsx(
86
+ HighlightedText,
87
+ {
88
+ className: itemClassNames?.highlight,
89
+ result: filteredResults.result?.[item.name],
90
+ originalText: item.name,
91
+ isSelected,
92
+ isFocused
93
+ }
94
+ ),
95
+ description: item.description,
96
+ textValue: item.name,
97
+ id: item.value
98
+ },
99
+ item.name
100
+ )
101
+ }
102
+ );
103
+ }
104
+
105
+ export { ComboBoxFuzzy };