@opengovsg/oui 0.0.0-snapshot-20250813090518 → 0.0.0-snapshot-20250813172831

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 (142) hide show
  1. package/dist/cjs/badge/badge.cjs +4 -4
  2. package/dist/cjs/badge/use-badge.cjs +6 -6
  3. package/dist/cjs/banner/banner.cjs +4 -4
  4. package/dist/cjs/button/button.cjs +4 -4
  5. package/dist/cjs/calendar/calendar-bottom-content.cjs +2 -2
  6. package/dist/cjs/calendar/calendar-header.cjs +2 -2
  7. package/dist/cjs/calendar/calendar-month-day-selector.cjs +4 -4
  8. package/dist/cjs/calendar/calendar.cjs +4 -4
  9. package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +4 -4
  10. package/dist/cjs/calendar/utils.cjs +3 -3
  11. package/dist/cjs/checkbox/checkbox.cjs +1 -1
  12. package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
  13. package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
  14. package/dist/cjs/combo-box/combo-box.cjs +5 -5
  15. package/dist/cjs/date-field/date-field.cjs +4 -4
  16. package/dist/cjs/date-picker/date-picker.cjs +6 -7
  17. package/dist/cjs/date-range-picker/date-range-picker.cjs +8 -8
  18. package/dist/cjs/govt-banner/govt-banner.cjs +3 -3
  19. package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
  20. package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
  21. package/dist/cjs/index.cjs +20 -9
  22. package/dist/cjs/input/input.cjs +2 -2
  23. package/dist/cjs/menu/menu.cjs +7 -7
  24. package/dist/cjs/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.cjs +45 -0
  25. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.cjs +21 -0
  26. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.cjs +72 -0
  27. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.cjs +60 -0
  28. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.cjs +210 -0
  29. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.cjs +100 -0
  30. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.cjs +152 -0
  31. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.cjs +676 -0
  32. package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.cjs +160 -0
  33. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs +9 -0
  34. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs +9 -0
  35. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs +16 -0
  36. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs +9 -0
  37. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.cjs +11 -0
  38. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.cjs +10 -0
  39. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.cjs +12 -0
  40. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/Icon.cjs +4 -4
  41. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +3 -3
  42. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-right.cjs +22 -0
  43. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/ellipsis.cjs +23 -0
  44. package/dist/cjs/pagination/hooks/use-pagination.cjs +117 -0
  45. package/dist/cjs/pagination/index.cjs +17 -0
  46. package/dist/cjs/pagination/pagination-cursor.cjs +18 -0
  47. package/dist/cjs/pagination/pagination-item.cjs +18 -0
  48. package/dist/cjs/pagination/pagination.cjs +263 -0
  49. package/dist/cjs/pagination/use-pagination-item.cjs +87 -0
  50. package/dist/cjs/pagination/use-pagination.cjs +251 -0
  51. package/dist/cjs/range-calendar/range-calendar.cjs +7 -7
  52. package/dist/cjs/ripple/use-ripple.cjs +4 -4
  53. package/dist/cjs/select/select.cjs +5 -5
  54. package/dist/cjs/spinner/use-spinner.cjs +3 -3
  55. package/dist/cjs/system/react-utils/context.cjs +3 -3
  56. package/dist/cjs/system/react-utils/dom-props.cjs +186 -0
  57. package/dist/cjs/system/react-utils/filter-dom-props.cjs +46 -0
  58. package/dist/cjs/system/react-utils/index.cjs +2 -0
  59. package/dist/cjs/system/react-utils/refs.cjs +3 -3
  60. package/dist/cjs/system/utils.cjs +3 -3
  61. package/dist/cjs/tabs/tabs.cjs +2 -2
  62. package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
  63. package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
  64. package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
  65. package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
  66. package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
  67. package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
  68. package/dist/cjs/tag-field/tag-field.cjs +5 -5
  69. package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
  70. package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
  71. package/dist/cjs/text-area/text-area.cjs +2 -2
  72. package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
  73. package/dist/cjs/text-field/text-field.cjs +1 -1
  74. package/dist/cjs/toggle/toggle.cjs +3 -3
  75. package/dist/esm/banner/banner.js +1 -1
  76. package/dist/esm/button/button.js +1 -1
  77. package/dist/esm/calendar/calendar-month-day-selector.js +2 -2
  78. package/dist/esm/checkbox/checkbox.js +1 -1
  79. package/dist/esm/combo-box/combo-box.js +2 -2
  80. package/dist/esm/date-field/date-field.js +1 -1
  81. package/dist/esm/date-picker/date-picker.js +4 -5
  82. package/dist/esm/date-range-picker/date-range-picker.js +5 -5
  83. package/dist/esm/index.js +8 -3
  84. package/dist/esm/menu/menu.js +1 -1
  85. package/dist/esm/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.js +43 -0
  86. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.js +19 -0
  87. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.js +69 -0
  88. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.js +58 -0
  89. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.js +205 -0
  90. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.js +98 -0
  91. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.js +150 -0
  92. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.js +674 -0
  93. package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.js +155 -0
  94. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +7 -0
  95. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js +7 -0
  96. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js +14 -0
  97. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js +7 -0
  98. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.js +9 -0
  99. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.js +8 -0
  100. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.js +10 -0
  101. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-right.js +17 -0
  102. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/ellipsis.js +18 -0
  103. package/dist/esm/pagination/hooks/use-pagination.js +114 -0
  104. package/dist/esm/pagination/index.js +6 -0
  105. package/dist/esm/pagination/pagination-cursor.js +16 -0
  106. package/dist/esm/pagination/pagination-item.js +16 -0
  107. package/dist/esm/pagination/pagination.js +261 -0
  108. package/dist/esm/pagination/use-pagination-item.js +85 -0
  109. package/dist/esm/pagination/use-pagination.js +248 -0
  110. package/dist/esm/range-calendar/range-calendar.js +1 -1
  111. package/dist/esm/select/select.js +3 -3
  112. package/dist/esm/system/react-utils/dom-props.js +183 -0
  113. package/dist/esm/system/react-utils/filter-dom-props.js +44 -0
  114. package/dist/esm/system/react-utils/index.js +1 -0
  115. package/dist/esm/tag-field/tag-field.js +3 -3
  116. package/dist/esm/text-area-field/text-area-field.js +1 -1
  117. package/dist/esm/text-field/text-field.js +1 -1
  118. package/dist/types/index.d.mts +1 -0
  119. package/dist/types/index.d.ts +1 -0
  120. package/dist/types/index.d.ts.map +1 -1
  121. package/dist/types/pagination/hooks/use-pagination.d.ts +51 -0
  122. package/dist/types/pagination/hooks/use-pagination.d.ts.map +1 -0
  123. package/dist/types/pagination/index.d.ts +7 -0
  124. package/dist/types/pagination/index.d.ts.map +1 -0
  125. package/dist/types/pagination/pagination-cursor.d.ts +9 -0
  126. package/dist/types/pagination/pagination-cursor.d.ts.map +1 -0
  127. package/dist/types/pagination/pagination-item.d.ts +5 -0
  128. package/dist/types/pagination/pagination-item.d.ts.map +1 -0
  129. package/dist/types/pagination/pagination.d.ts +5 -0
  130. package/dist/types/pagination/pagination.d.ts.map +1 -0
  131. package/dist/types/pagination/use-pagination-item.d.ts +51 -0
  132. package/dist/types/pagination/use-pagination-item.d.ts.map +1 -0
  133. package/dist/types/pagination/use-pagination.d.ts +353 -0
  134. package/dist/types/pagination/use-pagination.d.ts.map +1 -0
  135. package/dist/types/system/react-utils/context.d.ts.map +1 -1
  136. package/dist/types/system/react-utils/dom-props.d.ts +3 -0
  137. package/dist/types/system/react-utils/dom-props.d.ts.map +1 -0
  138. package/dist/types/system/react-utils/filter-dom-props.d.ts +39 -0
  139. package/dist/types/system/react-utils/filter-dom-props.d.ts.map +1 -0
  140. package/dist/types/system/react-utils/index.d.ts +1 -0
  141. package/dist/types/system/react-utils/index.d.ts.map +1 -1
  142. package/package.json +6 -4
@@ -0,0 +1,155 @@
1
+ import { isFocusable, getOwnerWindow, focusWithoutScrolling, useLayoutEffect, useEffectEvent } from '@react-aria/utils';
2
+ import { useRef, useCallback } from 'react';
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $8a9cb279dc87e130$export$525bc4921d56d4a(nativeEvent) {
17
+ let event = nativeEvent;
18
+ event.nativeEvent = nativeEvent;
19
+ event.isDefaultPrevented = ()=>event.defaultPrevented;
20
+ // cancelBubble is technically deprecated in the spec, but still supported in all browsers.
21
+ event.isPropagationStopped = ()=>event.cancelBubble;
22
+ event.persist = ()=>{};
23
+ return event;
24
+ }
25
+ function $8a9cb279dc87e130$export$c2b7abe5d61ec696(event, target) {
26
+ Object.defineProperty(event, 'target', {
27
+ value: target
28
+ });
29
+ Object.defineProperty(event, 'currentTarget', {
30
+ value: target
31
+ });
32
+ }
33
+ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
34
+ let stateRef = (useRef)({
35
+ isFocused: false,
36
+ observer: null
37
+ });
38
+ // Clean up MutationObserver on unmount. See below.
39
+ (useLayoutEffect)(()=>{
40
+ const state = stateRef.current;
41
+ return ()=>{
42
+ if (state.observer) {
43
+ state.observer.disconnect();
44
+ state.observer = null;
45
+ }
46
+ };
47
+ }, []);
48
+ let dispatchBlur = (useEffectEvent)((e)=>{
49
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
50
+ });
51
+ // This function is called during a React onFocus event.
52
+ return (useCallback)((e)=>{
53
+ // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
54
+ // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
55
+ // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
56
+ // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
57
+ if (e.target instanceof HTMLButtonElement || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement) {
58
+ stateRef.current.isFocused = true;
59
+ let target = e.target;
60
+ let onBlurHandler = (e)=>{
61
+ stateRef.current.isFocused = false;
62
+ if (target.disabled) {
63
+ // For backward compatibility, dispatch a (fake) React synthetic event.
64
+ let event = $8a9cb279dc87e130$export$525bc4921d56d4a(e);
65
+ dispatchBlur(event);
66
+ }
67
+ // We no longer need the MutationObserver once the target is blurred.
68
+ if (stateRef.current.observer) {
69
+ stateRef.current.observer.disconnect();
70
+ stateRef.current.observer = null;
71
+ }
72
+ };
73
+ target.addEventListener('focusout', onBlurHandler, {
74
+ once: true
75
+ });
76
+ stateRef.current.observer = new MutationObserver(()=>{
77
+ if (stateRef.current.isFocused && target.disabled) {
78
+ var _stateRef_current_observer;
79
+ (_stateRef_current_observer = stateRef.current.observer) === null || _stateRef_current_observer === void 0 ? void 0 : _stateRef_current_observer.disconnect();
80
+ let relatedTargetEl = target === document.activeElement ? null : document.activeElement;
81
+ target.dispatchEvent(new FocusEvent('blur', {
82
+ relatedTarget: relatedTargetEl
83
+ }));
84
+ target.dispatchEvent(new FocusEvent('focusout', {
85
+ bubbles: true,
86
+ relatedTarget: relatedTargetEl
87
+ }));
88
+ }
89
+ });
90
+ stateRef.current.observer.observe(target, {
91
+ attributes: true,
92
+ attributeFilter: [
93
+ 'disabled'
94
+ ]
95
+ });
96
+ }
97
+ }, [
98
+ dispatchBlur
99
+ ]);
100
+ }
101
+ let $8a9cb279dc87e130$export$fda7da73ab5d4c48 = false;
102
+ function $8a9cb279dc87e130$export$cabe61c495ee3649(target) {
103
+ // The browser will focus the nearest focusable ancestor of our target.
104
+ while(target && !(isFocusable)(target))target = target.parentElement;
105
+ let window = (getOwnerWindow)(target);
106
+ let activeElement = window.document.activeElement;
107
+ if (!activeElement || activeElement === target) return;
108
+ $8a9cb279dc87e130$export$fda7da73ab5d4c48 = true;
109
+ let isRefocusing = false;
110
+ let onBlur = (e)=>{
111
+ if (e.target === activeElement || isRefocusing) e.stopImmediatePropagation();
112
+ };
113
+ let onFocusOut = (e)=>{
114
+ if (e.target === activeElement || isRefocusing) {
115
+ e.stopImmediatePropagation();
116
+ // If there was no focusable ancestor, we don't expect a focus event.
117
+ // Re-focus the original active element here.
118
+ if (!target && !isRefocusing) {
119
+ isRefocusing = true;
120
+ (focusWithoutScrolling)(activeElement);
121
+ cleanup();
122
+ }
123
+ }
124
+ };
125
+ let onFocus = (e)=>{
126
+ if (e.target === target || isRefocusing) e.stopImmediatePropagation();
127
+ };
128
+ let onFocusIn = (e)=>{
129
+ if (e.target === target || isRefocusing) {
130
+ e.stopImmediatePropagation();
131
+ if (!isRefocusing) {
132
+ isRefocusing = true;
133
+ (focusWithoutScrolling)(activeElement);
134
+ cleanup();
135
+ }
136
+ }
137
+ };
138
+ window.addEventListener('blur', onBlur, true);
139
+ window.addEventListener('focusout', onFocusOut, true);
140
+ window.addEventListener('focusin', onFocusIn, true);
141
+ window.addEventListener('focus', onFocus, true);
142
+ let cleanup = ()=>{
143
+ cancelAnimationFrame(raf);
144
+ window.removeEventListener('blur', onBlur, true);
145
+ window.removeEventListener('focusout', onFocusOut, true);
146
+ window.removeEventListener('focusin', onFocusIn, true);
147
+ window.removeEventListener('focus', onFocus, true);
148
+ $8a9cb279dc87e130$export$fda7da73ab5d4c48 = false;
149
+ isRefocusing = false;
150
+ };
151
+ let raf = requestAnimationFrame(cleanup);
152
+ return cleanup;
153
+ }
154
+
155
+ export { $8a9cb279dc87e130$export$525bc4921d56d4a as createSyntheticEvent, $8a9cb279dc87e130$export$fda7da73ab5d4c48 as ignoreFocusEvent, $8a9cb279dc87e130$export$cabe61c495ee3649 as preventFocus, $8a9cb279dc87e130$export$c2b7abe5d61ec696 as setEventTarget, $8a9cb279dc87e130$export$715c682d09d639cc as useSyntheticBlurEvent };
@@ -0,0 +1,7 @@
1
+ function _check_private_redeclaration(obj, privateCollection) {
2
+ if (privateCollection.has(obj)) {
3
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
4
+ }
5
+ }
6
+
7
+ export { _check_private_redeclaration as _ };
@@ -0,0 +1,7 @@
1
+ function _class_apply_descriptor_get(receiver, descriptor) {
2
+ if (descriptor.get) return descriptor.get.call(receiver);
3
+
4
+ return descriptor.value;
5
+ }
6
+
7
+ export { _class_apply_descriptor_get as _ };
@@ -0,0 +1,14 @@
1
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
2
+ if (descriptor.set) descriptor.set.call(receiver, value);
3
+ else {
4
+ if (!descriptor.writable) {
5
+ // This should only throw in strict mode, but class bodies are
6
+ // always strict and private fields can only be used inside
7
+ // class bodies.
8
+ throw new TypeError("attempted to set read only private field");
9
+ }
10
+ descriptor.value = value;
11
+ }
12
+ }
13
+
14
+ export { _class_apply_descriptor_set as _ };
@@ -0,0 +1,7 @@
1
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
2
+ if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
3
+
4
+ return privateMap.get(receiver);
5
+ }
6
+
7
+ export { _class_extract_field_descriptor as _ };
@@ -0,0 +1,9 @@
1
+ import { _ as _class_apply_descriptor_get } from './_class_apply_descriptor_get.js';
2
+ import { _ as _class_extract_field_descriptor } from './_class_extract_field_descriptor.js';
3
+
4
+ function _class_private_field_get(receiver, privateMap) {
5
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
6
+ return _class_apply_descriptor_get(receiver, descriptor);
7
+ }
8
+
9
+ export { _class_private_field_get as _ };
@@ -0,0 +1,8 @@
1
+ import { _ as _check_private_redeclaration } from './_check_private_redeclaration.js';
2
+
3
+ function _class_private_field_init(obj, privateMap, value) {
4
+ _check_private_redeclaration(obj, privateMap);
5
+ privateMap.set(obj, value);
6
+ }
7
+
8
+ export { _class_private_field_init as _ };
@@ -0,0 +1,10 @@
1
+ import { _ as _class_apply_descriptor_set } from './_class_apply_descriptor_set.js';
2
+ import { _ as _class_extract_field_descriptor } from './_class_extract_field_descriptor.js';
3
+
4
+ function _class_private_field_set(receiver, privateMap, value) {
5
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
6
+ _class_apply_descriptor_set(receiver, descriptor, value);
7
+ return value;
8
+ }
9
+
10
+ export { _class_private_field_set as _ };
@@ -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
+ ["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
13
+ ["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
14
+ ];
15
+ const ChevronsRight = createLucideIcon("ChevronsRight", __iconNode);
16
+
17
+ export { __iconNode, ChevronsRight as default };
@@ -0,0 +1,18 @@
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: "1", key: "41hilf" }],
13
+ ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
14
+ ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
15
+ ];
16
+ const Ellipsis = createLucideIcon("Ellipsis", __iconNode);
17
+
18
+ export { __iconNode, Ellipsis as default };
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ "use client";
3
+ import { useState, useCallback, useEffect, useMemo } from 'react';
4
+ import { useLocale } from '@react-aria/i18n';
5
+
6
+ var PaginationItemType = /* @__PURE__ */ ((PaginationItemType2) => {
7
+ PaginationItemType2["DOTS"] = "dots";
8
+ PaginationItemType2["PREV"] = "prev";
9
+ PaginationItemType2["NEXT"] = "next";
10
+ return PaginationItemType2;
11
+ })(PaginationItemType || {});
12
+ function range(start, end) {
13
+ const length = end - start + 1;
14
+ return Array.from({ length }, (_, index) => index + start);
15
+ }
16
+ function usePagination(props) {
17
+ const {
18
+ page,
19
+ total,
20
+ siblings = 1,
21
+ boundaries = 1,
22
+ initialPage = 1,
23
+ showControls = false,
24
+ onChange
25
+ } = props;
26
+ const [activePage, setActivePage] = useState(page || initialPage);
27
+ const { direction } = useLocale();
28
+ const isRTL = direction === "rtl";
29
+ const onChangeActivePage = useCallback(
30
+ (newPage) => {
31
+ setActivePage(newPage);
32
+ onChange?.(newPage);
33
+ },
34
+ [onChange]
35
+ );
36
+ useEffect(() => {
37
+ if (page && page !== activePage) {
38
+ setActivePage(page);
39
+ }
40
+ }, [activePage, page]);
41
+ const setPage = useCallback(
42
+ (pageNumber) => {
43
+ if (pageNumber <= 0) {
44
+ onChangeActivePage(1);
45
+ } else if (pageNumber > total) {
46
+ onChangeActivePage(total);
47
+ } else {
48
+ onChangeActivePage(pageNumber);
49
+ }
50
+ },
51
+ [total, onChangeActivePage]
52
+ );
53
+ const next = () => setPage(activePage + 1);
54
+ const previous = () => setPage(activePage - 1);
55
+ const first = () => setPage(1);
56
+ const last = () => setPage(total);
57
+ const formatRange = useCallback(
58
+ (range2) => {
59
+ if (showControls) {
60
+ return ["prev" /* PREV */, ...range2, "next" /* NEXT */];
61
+ }
62
+ return range2;
63
+ },
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
65
+ [isRTL, showControls]
66
+ );
67
+ const paginationRange = useMemo(() => {
68
+ const totalPageNumbers = siblings * 2 + 3 + boundaries * 2;
69
+ if (totalPageNumbers >= total) {
70
+ return formatRange(range(1, total));
71
+ }
72
+ const leftSiblingIndex = Math.max(activePage - siblings, boundaries);
73
+ const rightSiblingIndex = Math.min(
74
+ activePage + siblings,
75
+ total - boundaries
76
+ );
77
+ const shouldShowLeftDots = leftSiblingIndex > boundaries + 2;
78
+ const shouldShowRightDots = rightSiblingIndex < total - (boundaries + 1);
79
+ if (!shouldShowLeftDots && shouldShowRightDots) {
80
+ const leftItemCount = siblings * 2 + boundaries + 2;
81
+ return formatRange([
82
+ ...range(1, leftItemCount),
83
+ "dots" /* DOTS */,
84
+ ...range(total - (boundaries - 1), total)
85
+ ]);
86
+ }
87
+ if (shouldShowLeftDots && !shouldShowRightDots) {
88
+ const rightItemCount = boundaries + 1 + 2 * siblings;
89
+ return formatRange([
90
+ ...range(1, boundaries),
91
+ "dots" /* DOTS */,
92
+ ...range(total - rightItemCount, total)
93
+ ]);
94
+ }
95
+ return formatRange([
96
+ ...range(1, boundaries),
97
+ "dots" /* DOTS */,
98
+ ...range(leftSiblingIndex, rightSiblingIndex),
99
+ "dots" /* DOTS */,
100
+ ...range(total - boundaries + 1, total)
101
+ ]);
102
+ }, [total, activePage, siblings, boundaries, formatRange]);
103
+ return {
104
+ range: paginationRange,
105
+ activePage,
106
+ setPage,
107
+ next,
108
+ previous,
109
+ first,
110
+ last
111
+ };
112
+ }
113
+
114
+ export { PaginationItemType, usePagination };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ export { Pagination } from './pagination.js';
3
+ export { PaginationCursor } from './pagination-cursor.js';
4
+ export { PaginationItem } from './pagination-item.js';
5
+ export { PaginationItemType } from './hooks/use-pagination.js';
6
+ export { CURSOR_TRANSITION_TIMEOUT, usePagination } from './use-pagination.js';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { forwardRef } from '../system/utils.js';
5
+ import { useDomRef } from '../system/react-utils/refs.js';
6
+
7
+ const PaginationCursor = forwardRef(
8
+ (props, ref) => {
9
+ const { as, activePage, ...otherProps } = props;
10
+ const Component = as || "span";
11
+ const domRef = useDomRef(ref);
12
+ return /* @__PURE__ */ jsx(Component, { ref: domRef, "aria-hidden": true, ...otherProps, children: activePage });
13
+ }
14
+ );
15
+
16
+ export { PaginationCursor };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { forwardRef } from '../system/utils.js';
4
+ import { usePaginationItem } from './use-pagination-item.js';
5
+
6
+ const PaginationItem = forwardRef(
7
+ (props, ref) => {
8
+ const { Component, children, getItemProps } = usePaginationItem({
9
+ ...props,
10
+ ref
11
+ });
12
+ return /* @__PURE__ */ jsx(Component, { ...getItemProps(), children });
13
+ }
14
+ );
15
+
16
+ export { PaginationItem };
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { useCallback, createElement } from 'react';
5
+ import { useLocale } from '@react-aria/i18n';
6
+ import { cn, dataAttr } from '@opengovsg/oui-theme';
7
+ import { forwardRef } from '../system/utils.js';
8
+ import { PaginationItemType } from './hooks/use-pagination.js';
9
+ import { PaginationCursor } from './pagination-cursor.js';
10
+ import { PaginationItem } from './pagination-item.js';
11
+ import { usePagination } from './use-pagination.js';
12
+ import ChevronLeft from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-left.js';
13
+ import Ellipsis from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/ellipsis.js';
14
+ import ChevronsRight from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-right.js';
15
+
16
+ const Pagination = forwardRef((props, ref) => {
17
+ const {
18
+ Component,
19
+ dotsJump,
20
+ slots,
21
+ classNames,
22
+ total,
23
+ range,
24
+ loop,
25
+ activePage,
26
+ disableCursorAnimation,
27
+ disableAnimation,
28
+ renderItem: renderItemProp,
29
+ onNext,
30
+ onPrevious,
31
+ setPage,
32
+ getItemAriaLabel,
33
+ getItemRef,
34
+ getBaseProps,
35
+ getWrapperProps,
36
+ getItemProps,
37
+ getCursorProps
38
+ } = usePagination({ ...props, ref });
39
+ const { direction } = useLocale();
40
+ const isRTL = direction === "rtl";
41
+ const renderChevronIcon = useCallback(
42
+ (key) => {
43
+ if (key === PaginationItemType.PREV && !isRTL || key === PaginationItemType.NEXT && isRTL) {
44
+ return /* @__PURE__ */ jsx(ChevronLeft, {});
45
+ }
46
+ return /* @__PURE__ */ jsx(
47
+ ChevronLeft,
48
+ {
49
+ className: slots.chevronNext({
50
+ class: classNames?.chevronNext
51
+ })
52
+ }
53
+ );
54
+ },
55
+ [isRTL, slots, classNames?.chevronNext]
56
+ );
57
+ const renderPrevItem = useCallback(() => {
58
+ return /* @__PURE__ */ jsx(
59
+ PaginationItem,
60
+ {
61
+ className: slots.prev({
62
+ class: classNames?.prev
63
+ }),
64
+ "data-slot": "prev",
65
+ getAriaLabel: getItemAriaLabel,
66
+ isDisabled: props.isDisabled || !loop && activePage === 1,
67
+ value: PaginationItemType.PREV,
68
+ onPress: onPrevious,
69
+ children: renderChevronIcon(PaginationItemType.PREV)
70
+ },
71
+ PaginationItemType.PREV
72
+ );
73
+ }, [
74
+ slots,
75
+ classNames?.prev,
76
+ getItemAriaLabel,
77
+ props.isDisabled,
78
+ loop,
79
+ activePage,
80
+ onPrevious,
81
+ renderChevronIcon
82
+ ]);
83
+ const renderNextItem = useCallback(() => {
84
+ return /* @__PURE__ */ jsx(
85
+ PaginationItem,
86
+ {
87
+ className: slots.next({
88
+ class: cn(classNames?.next)
89
+ }),
90
+ "data-slot": "next",
91
+ getAriaLabel: getItemAriaLabel,
92
+ isDisabled: props.isDisabled || !loop && activePage === total,
93
+ value: PaginationItemType.NEXT,
94
+ onPress: onNext,
95
+ children: renderChevronIcon(PaginationItemType.NEXT)
96
+ },
97
+ PaginationItemType.NEXT
98
+ );
99
+ }, [
100
+ slots,
101
+ classNames?.next,
102
+ getItemAriaLabel,
103
+ props.isDisabled,
104
+ loop,
105
+ activePage,
106
+ total,
107
+ onNext,
108
+ renderChevronIcon
109
+ ]);
110
+ const renderItem = useCallback(
111
+ (value, index) => {
112
+ const isBefore = index < range.indexOf(activePage);
113
+ if (renderItemProp && typeof renderItemProp === "function") {
114
+ let page = typeof value == "number" ? value : index;
115
+ if (value === PaginationItemType.NEXT) {
116
+ page = activePage + 1;
117
+ }
118
+ if (value === PaginationItemType.PREV) {
119
+ page = activePage - 1;
120
+ }
121
+ if (value === PaginationItemType.DOTS) {
122
+ page = isBefore ? activePage - dotsJump >= 1 ? activePage - dotsJump : 1 : activePage + dotsJump <= total ? activePage + dotsJump : total;
123
+ }
124
+ const itemChildren = {
125
+ [PaginationItemType.PREV]: renderChevronIcon(PaginationItemType.PREV),
126
+ [PaginationItemType.NEXT]: renderChevronIcon(PaginationItemType.NEXT),
127
+ [PaginationItemType.DOTS]: /* @__PURE__ */ jsxs(Fragment, { children: [
128
+ /* @__PURE__ */ jsx(
129
+ Ellipsis,
130
+ {
131
+ className: slots?.ellipsis({ class: classNames?.ellipsis })
132
+ }
133
+ ),
134
+ /* @__PURE__ */ jsx(
135
+ ChevronsRight,
136
+ {
137
+ className: slots?.forwardIcon({
138
+ class: classNames?.forwardIcon
139
+ }),
140
+ "data-before": dataAttr(isBefore)
141
+ }
142
+ )
143
+ ] })
144
+ };
145
+ return renderItemProp({
146
+ value,
147
+ index,
148
+ key: `${value}-${index}`,
149
+ page,
150
+ total,
151
+ children: typeof value === "number" ? value : itemChildren[value],
152
+ activePage,
153
+ dotsJump,
154
+ isBefore,
155
+ isActive: value === activePage,
156
+ isPrevious: value === activePage - 1,
157
+ isNext: value === activePage + 1,
158
+ isFirst: value === 1,
159
+ isLast: value === total,
160
+ onNext,
161
+ onPrevious,
162
+ setPage,
163
+ onPress: () => setPage(page),
164
+ ref: typeof value === "number" ? (node) => getItemRef(node, value) : void 0,
165
+ className: slots.item({ class: classNames?.item }),
166
+ getAriaLabel: getItemAriaLabel
167
+ });
168
+ }
169
+ if (value === PaginationItemType.PREV) {
170
+ return renderPrevItem();
171
+ }
172
+ if (value === PaginationItemType.NEXT) {
173
+ return renderNextItem();
174
+ }
175
+ if (value === PaginationItemType.DOTS) {
176
+ return /* @__PURE__ */ jsxs(
177
+ PaginationItem,
178
+ {
179
+ className: slots.item({
180
+ class: cn(classNames?.item, "group")
181
+ }),
182
+ isDisabled: props.isDisabled,
183
+ "data-slot": "item",
184
+ getAriaLabel: getItemAriaLabel,
185
+ value,
186
+ onPress: () => isBefore ? setPage(
187
+ activePage - dotsJump >= 1 ? activePage - dotsJump : 1
188
+ ) : setPage(
189
+ activePage + dotsJump <= total ? activePage + dotsJump : total
190
+ ),
191
+ children: [
192
+ /* @__PURE__ */ jsx(
193
+ Ellipsis,
194
+ {
195
+ className: slots?.ellipsis({ class: classNames?.ellipsis })
196
+ }
197
+ ),
198
+ /* @__PURE__ */ jsx(
199
+ ChevronsRight,
200
+ {
201
+ className: slots?.forwardIcon({ class: classNames?.forwardIcon }),
202
+ "data-before": dataAttr(isRTL ? !isBefore : isBefore)
203
+ }
204
+ )
205
+ ]
206
+ },
207
+ PaginationItemType.DOTS + isBefore
208
+ );
209
+ }
210
+ return /* @__PURE__ */ createElement(
211
+ PaginationItem,
212
+ {
213
+ ...getItemProps({ value }),
214
+ key: value,
215
+ getAriaLabel: getItemAriaLabel
216
+ },
217
+ value
218
+ );
219
+ },
220
+ [
221
+ range,
222
+ activePage,
223
+ renderItemProp,
224
+ getItemProps,
225
+ getItemAriaLabel,
226
+ renderChevronIcon,
227
+ slots,
228
+ classNames?.ellipsis,
229
+ classNames?.forwardIcon,
230
+ classNames?.item,
231
+ total,
232
+ dotsJump,
233
+ onNext,
234
+ onPrevious,
235
+ setPage,
236
+ getItemRef,
237
+ renderPrevItem,
238
+ renderNextItem,
239
+ props.isDisabled,
240
+ isRTL
241
+ ]
242
+ );
243
+ if (props.isCompact) {
244
+ return /* @__PURE__ */ jsx(Component, { ...getBaseProps(), children: /* @__PURE__ */ jsxs("ul", { ...getWrapperProps(), children: [
245
+ renderPrevItem(),
246
+ /* @__PURE__ */ jsxs("li", { className: slots.item({ class: classNames?.item }), children: [
247
+ "Page ",
248
+ activePage,
249
+ " of ",
250
+ total
251
+ ] }),
252
+ renderNextItem()
253
+ ] }) });
254
+ }
255
+ return /* @__PURE__ */ jsx(Component, { ...getBaseProps(), children: /* @__PURE__ */ jsxs("ul", { ...getWrapperProps(), children: [
256
+ !disableCursorAnimation && !disableAnimation && /* @__PURE__ */ jsx(PaginationCursor, { ...getCursorProps() }),
257
+ range.map(renderItem)
258
+ ] }) });
259
+ });
260
+
261
+ export { Pagination };