@opengovsg/oui 0.0.28 → 0.0.30
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.
- package/dist/cjs/badge/badge.cjs +4 -4
- package/dist/cjs/badge/use-badge.cjs +6 -6
- package/dist/cjs/banner/banner.cjs +4 -4
- package/dist/cjs/button/button.cjs +4 -4
- package/dist/cjs/calendar/calendar-bottom-content.cjs +3 -3
- package/dist/cjs/calendar/calendar-header.cjs +2 -2
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +4 -4
- package/dist/cjs/calendar/calendar.cjs +4 -4
- package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +4 -4
- package/dist/cjs/calendar/utils.cjs +3 -3
- package/dist/cjs/checkbox/checkbox.cjs +1 -1
- package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
- package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
- package/dist/cjs/combo-box/combo-box.cjs +5 -5
- package/dist/cjs/date-field/date-field.cjs +4 -4
- package/dist/cjs/date-picker/date-picker.cjs +7 -6
- package/dist/cjs/date-range-picker/date-range-picker.cjs +8 -8
- package/dist/cjs/field/field.cjs +2 -2
- package/dist/cjs/file-dropzone/file-dropzone.cjs +23 -19
- package/dist/cjs/file-dropzone/file-info.cjs +6 -5
- package/dist/cjs/file-dropzone/utils.cjs +4 -4
- package/dist/cjs/govt-banner/govt-banner.cjs +3 -3
- package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
- package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
- package/dist/cjs/hooks/use-draggable.cjs +8 -8
- package/dist/cjs/hooks/use-scroll-position.cjs +53 -0
- package/dist/cjs/index.cjs +38 -19
- package/dist/cjs/input/input.cjs +2 -2
- package/dist/cjs/menu/menu.cjs +8 -8
- package/dist/cjs/modal/modal-body.cjs +2 -2
- package/dist/cjs/modal/modal-content.cjs +4 -4
- package/dist/cjs/modal/modal-footer.cjs +2 -2
- package/dist/cjs/modal/modal-header.cjs +2 -2
- package/dist/cjs/modal/modal.cjs +3 -3
- package/dist/cjs/navbar/index.cjs +25 -0
- package/dist/cjs/navbar/navbar-brand.cjs +28 -0
- package/dist/cjs/navbar/navbar-content.cjs +33 -0
- package/dist/cjs/navbar/navbar-context.cjs +14 -0
- package/dist/cjs/navbar/navbar-item.cjs +29 -0
- package/dist/cjs/navbar/navbar-menu/i18n.cjs +23 -0
- package/dist/cjs/navbar/navbar-menu/item.cjs +44 -0
- package/dist/cjs/navbar/navbar-menu/menu.cjs +62 -0
- package/dist/cjs/navbar/navbar-menu/toggle.cjs +95 -0
- package/dist/cjs/navbar/navbar.cjs +50 -0
- package/dist/cjs/navbar/use-navbar.cjs +126 -0
- 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/node_modules/@react-aria/overlays/dist/Overlay.cjs +55 -0
- 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/node_modules/@react-aria/overlays/dist/PortalProvider.cjs +23 -0
- 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/node_modules/@react-aria/overlays/dist/usePreventScroll.cjs +208 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_ssr@3.9.10_react@19.2.3/node_modules/@react-aria/ssr/dist/SSRProvider.cjs +104 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/Icon.cjs +4 -4
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +3 -3
- package/dist/cjs/number-field/number-field.cjs +2 -2
- package/dist/cjs/pagination/hooks/use-pagination.cjs +7 -7
- package/dist/cjs/pagination/pagination.cjs +6 -6
- package/dist/cjs/pagination/use-pagination-item.cjs +3 -3
- package/dist/cjs/pagination/use-pagination.cjs +8 -8
- package/dist/cjs/range-calendar/range-calendar.cjs +7 -7
- package/dist/cjs/ripple/use-ripple.cjs +4 -4
- package/dist/cjs/select/select.cjs +5 -5
- package/dist/cjs/spinner/use-spinner.cjs +3 -3
- package/dist/cjs/system/react-utils/children.cjs +26 -0
- package/dist/cjs/system/react-utils/context.cjs +3 -3
- package/dist/cjs/system/react-utils/refs.cjs +3 -3
- package/dist/cjs/system/utils.cjs +2 -2
- package/dist/cjs/tabs/tabs.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
- package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
- package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
- package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
- package/dist/cjs/tag-field/tag-field.cjs +4 -4
- package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
- package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
- package/dist/cjs/text-area/text-area.cjs +2 -2
- package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
- package/dist/cjs/text-field/text-field.cjs +1 -1
- package/dist/cjs/toast/toast.cjs +1 -1
- package/dist/cjs/toggle/toggle.cjs +3 -3
- package/dist/esm/banner/banner.js +1 -1
- package/dist/esm/button/button.js +1 -1
- package/dist/esm/calendar/calendar-month-day-selector.js +2 -2
- package/dist/esm/checkbox/checkbox.js +1 -1
- package/dist/esm/combo-box/combo-box.js +2 -2
- package/dist/esm/date-field/date-field.js +1 -1
- package/dist/esm/date-picker/date-picker.js +5 -4
- package/dist/esm/date-range-picker/date-range-picker.js +5 -5
- package/dist/esm/file-dropzone/file-dropzone.js +13 -9
- package/dist/esm/file-dropzone/file-info.js +3 -2
- package/dist/esm/file-dropzone/utils.js +4 -4
- package/dist/esm/hooks/use-scroll-position.js +51 -0
- package/dist/esm/index.js +17 -8
- package/dist/esm/menu/menu.js +2 -2
- package/dist/esm/modal/modal-content.js +1 -1
- package/dist/esm/navbar/index.js +10 -0
- package/dist/esm/navbar/navbar-brand.js +26 -0
- package/dist/esm/navbar/navbar-content.js +31 -0
- package/dist/esm/navbar/navbar-context.js +11 -0
- package/dist/esm/navbar/navbar-item.js +27 -0
- package/dist/esm/navbar/navbar-menu/i18n.js +21 -0
- package/dist/esm/navbar/navbar-menu/item.js +42 -0
- package/dist/esm/navbar/navbar-menu/menu.js +60 -0
- package/dist/esm/navbar/navbar-menu/toggle.js +93 -0
- package/dist/esm/navbar/navbar.js +48 -0
- package/dist/esm/navbar/use-navbar.js +124 -0
- 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/node_modules/@react-aria/overlays/dist/Overlay.js +52 -0
- 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/node_modules/@react-aria/overlays/dist/PortalProvider.js +20 -0
- 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/node_modules/@react-aria/overlays/dist/usePreventScroll.js +206 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_ssr@3.9.10_react@19.2.3/node_modules/@react-aria/ssr/dist/SSRProvider.js +102 -0
- package/dist/esm/number-field/number-field.js +2 -2
- package/dist/esm/pagination/use-pagination-item.js +1 -1
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/select/select.js +3 -3
- package/dist/esm/system/react-utils/children.js +23 -0
- package/dist/esm/tag-field/tag-field.js +2 -2
- package/dist/esm/text-area-field/text-area-field.js +1 -1
- package/dist/esm/text-field/text-field.js +1 -1
- package/dist/esm/toast/toast.js +1 -1
- package/dist/types/calendar/calendar.d.ts.map +1 -1
- package/dist/types/date-field/date-field.d.ts.map +1 -1
- package/dist/types/file-dropzone/file-dropzone.d.ts +8 -2
- package/dist/types/file-dropzone/file-dropzone.d.ts.map +1 -1
- package/dist/types/file-dropzone/file-info.d.ts.map +1 -1
- package/dist/types/file-dropzone/types.d.ts +1 -0
- package/dist/types/file-dropzone/types.d.ts.map +1 -1
- package/dist/types/file-dropzone/utils.d.ts +2 -1
- package/dist/types/file-dropzone/utils.d.ts.map +1 -1
- package/dist/types/hooks/use-scroll-position.d.ts +29 -0
- package/dist/types/hooks/use-scroll-position.d.ts.map +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/menu/menu.d.ts.map +1 -1
- package/dist/types/navbar/index.d.ts +17 -0
- package/dist/types/navbar/index.d.ts.map +1 -0
- package/dist/types/navbar/navbar-brand.d.ts +6 -0
- package/dist/types/navbar/navbar-brand.d.ts.map +1 -0
- package/dist/types/navbar/navbar-content.d.ts +14 -0
- package/dist/types/navbar/navbar-content.d.ts.map +1 -0
- package/dist/types/navbar/navbar-context.d.ts +182 -0
- package/dist/types/navbar/navbar-context.d.ts.map +1 -0
- package/dist/types/navbar/navbar-item.d.ts +11 -0
- package/dist/types/navbar/navbar-item.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/i18n.d.ts +3 -0
- package/dist/types/navbar/navbar-menu/i18n.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/item.d.ts +16 -0
- package/dist/types/navbar/navbar-menu/item.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/menu.d.ts +11 -0
- package/dist/types/navbar/navbar-menu/menu.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/toggle.d.ts +12 -0
- package/dist/types/navbar/navbar-menu/toggle.d.ts.map +1 -0
- package/dist/types/navbar/navbar.d.ts +6 -0
- package/dist/types/navbar/navbar.d.ts.map +1 -0
- package/dist/types/navbar/use-navbar.d.ts +163 -0
- package/dist/types/navbar/use-navbar.d.ts.map +1 -0
- package/dist/types/range-calendar/range-calendar.d.ts.map +1 -1
- package/dist/types/system/react-utils/children.d.ts +10 -0
- package/dist/types/system/react-utils/children.d.ts.map +1 -0
- package/dist/types/system/react-utils/index.d.ts +5 -3
- package/dist/types/system/react-utils/index.d.ts.map +1 -1
- package/dist/types/system/utils.d.ts.map +1 -1
- package/dist/types/tabs/tabs.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-item.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('@react-aria/utils');
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
const $49c51c25361d4cd2$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
17
|
+
// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
18
|
+
let $49c51c25361d4cd2$var$preventScrollCount = 0;
|
|
19
|
+
let $49c51c25361d4cd2$var$restore;
|
|
20
|
+
function $49c51c25361d4cd2$export$ee0f7cc6afcd1c18(options = {}) {
|
|
21
|
+
let { isDisabled: isDisabled } = options;
|
|
22
|
+
(utils.useLayoutEffect)(()=>{
|
|
23
|
+
if (isDisabled) return;
|
|
24
|
+
$49c51c25361d4cd2$var$preventScrollCount++;
|
|
25
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 1) {
|
|
26
|
+
if ((utils.isIOS)()) $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollMobileSafari();
|
|
27
|
+
else $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollStandard();
|
|
28
|
+
}
|
|
29
|
+
return ()=>{
|
|
30
|
+
$49c51c25361d4cd2$var$preventScrollCount--;
|
|
31
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 0) $49c51c25361d4cd2$var$restore();
|
|
32
|
+
};
|
|
33
|
+
}, [
|
|
34
|
+
isDisabled
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
// For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
38
|
+
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
39
|
+
function $49c51c25361d4cd2$var$preventScrollStandard() {
|
|
40
|
+
let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
41
|
+
return (utils.chain)(scrollbarWidth > 0 && // Use scrollbar-gutter when supported because it also works for fixed positioned elements.
|
|
42
|
+
('scrollbarGutter' in document.documentElement.style ? $49c51c25361d4cd2$var$setStyle(document.documentElement, 'scrollbarGutter', 'stable') : $49c51c25361d4cd2$var$setStyle(document.documentElement, 'paddingRight', `${scrollbarWidth}px`)), $49c51c25361d4cd2$var$setStyle(document.documentElement, 'overflow', 'hidden'));
|
|
43
|
+
}
|
|
44
|
+
// Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
45
|
+
// it still scrolls the page in many situations:
|
|
46
|
+
//
|
|
47
|
+
// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
|
|
48
|
+
// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
|
|
49
|
+
// it, so it becomes scrollable.
|
|
50
|
+
// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
|
|
51
|
+
// This may cause even fixed position elements to scroll off the screen.
|
|
52
|
+
// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
|
|
53
|
+
// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
|
|
54
|
+
//
|
|
55
|
+
// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
|
|
56
|
+
//
|
|
57
|
+
// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
|
|
58
|
+
// on the window.
|
|
59
|
+
// 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at
|
|
60
|
+
// the top or bottom. Work around a bug where this does not work when the element does not actually overflow
|
|
61
|
+
// by preventing default in a `touchmove` event. This is best effort: we can't prevent default when pinch
|
|
62
|
+
// zooming or when an element contains text selection, which may allow scrolling in some cases.
|
|
63
|
+
// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
|
|
64
|
+
// 4. When focus moves to an input, create an off screen input and focus that temporarily. This prevents
|
|
65
|
+
// Safari from scrolling the page. After a small delay, focus the real input and scroll it into view
|
|
66
|
+
// ourselves, without scrolling the whole page.
|
|
67
|
+
function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
68
|
+
let scrollable;
|
|
69
|
+
let allowTouchMove = false;
|
|
70
|
+
let onTouchStart = (e)=>{
|
|
71
|
+
// Store the nearest scrollable parent element from the element that the user touched.
|
|
72
|
+
let target = e.target;
|
|
73
|
+
scrollable = (utils.isScrollable)(target) ? target : (utils.getScrollParent)(target, true);
|
|
74
|
+
allowTouchMove = false;
|
|
75
|
+
// If the target is selected, don't preventDefault in touchmove to allow user to adjust selection.
|
|
76
|
+
let selection = target.ownerDocument.defaultView.getSelection();
|
|
77
|
+
if (selection && !selection.isCollapsed && selection.containsNode(target, true)) allowTouchMove = true;
|
|
78
|
+
// If this is a focused input element with a selected range, allow user to drag the selection handles.
|
|
79
|
+
if ('selectionStart' in target && 'selectionEnd' in target && target.selectionStart < target.selectionEnd && target.ownerDocument.activeElement === target) allowTouchMove = true;
|
|
80
|
+
};
|
|
81
|
+
// Prevent scrolling up when at the top and scrolling down when at the bottom
|
|
82
|
+
// of a nested scrollable area, otherwise mobile Safari will start scrolling
|
|
83
|
+
// the window instead.
|
|
84
|
+
// This must be applied before the touchstart event as of iOS 26, so inject it as a <style> element.
|
|
85
|
+
let style = document.createElement('style');
|
|
86
|
+
style.textContent = `
|
|
87
|
+
@layer {
|
|
88
|
+
* {
|
|
89
|
+
overscroll-behavior: contain;
|
|
90
|
+
}
|
|
91
|
+
}`.trim();
|
|
92
|
+
document.head.prepend(style);
|
|
93
|
+
let onTouchMove = (e)=>{
|
|
94
|
+
// Allow pinch-zooming.
|
|
95
|
+
if (e.touches.length === 2 || allowTouchMove) return;
|
|
96
|
+
// Prevent scrolling the window.
|
|
97
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// overscroll-behavior should prevent scroll chaining, but currently does not
|
|
102
|
+
// if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452
|
|
103
|
+
// This checks that both the width and height do not overflow, otherwise we might
|
|
104
|
+
// block horizontal scrolling too. In that case, adding `touch-action: pan-x` to
|
|
105
|
+
// the element will prevent vertical page scrolling. We can't add that automatically
|
|
106
|
+
// because it must be set before the touchstart event.
|
|
107
|
+
if (scrollable.scrollHeight === scrollable.clientHeight && scrollable.scrollWidth === scrollable.clientWidth) e.preventDefault();
|
|
108
|
+
};
|
|
109
|
+
let onBlur = (e)=>{
|
|
110
|
+
let target = e.target;
|
|
111
|
+
let relatedTarget = e.relatedTarget;
|
|
112
|
+
if (relatedTarget && (utils.willOpenKeyboard)(relatedTarget)) {
|
|
113
|
+
// Focus without scrolling the whole page, and then scroll into view manually.
|
|
114
|
+
relatedTarget.focus({
|
|
115
|
+
preventScroll: true
|
|
116
|
+
});
|
|
117
|
+
$49c51c25361d4cd2$var$scrollIntoViewWhenReady(relatedTarget, (utils.willOpenKeyboard)(target));
|
|
118
|
+
} else if (!relatedTarget) {
|
|
119
|
+
var _target_parentElement;
|
|
120
|
+
// When tapping the Done button on the keyboard, focus moves to the body.
|
|
121
|
+
// FocusScope will then restore focus back to the input. Later when tapping
|
|
122
|
+
// the same input again, it is already focused, so no blur event will fire,
|
|
123
|
+
// resulting in the flow above never running and Safari's native scrolling occurring.
|
|
124
|
+
// Instead, move focus to the parent focusable element (e.g. the dialog).
|
|
125
|
+
let focusable = (_target_parentElement = target.parentElement) === null || _target_parentElement === void 0 ? void 0 : _target_parentElement.closest('[tabindex]');
|
|
126
|
+
focusable === null || focusable === void 0 ? void 0 : focusable.focus({
|
|
127
|
+
preventScroll: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
// Override programmatic focus to scroll into view without scrolling the whole page.
|
|
132
|
+
let focus = HTMLElement.prototype.focus;
|
|
133
|
+
HTMLElement.prototype.focus = function(opts) {
|
|
134
|
+
// Track whether the keyboard was already visible before.
|
|
135
|
+
let wasKeyboardVisible = document.activeElement != null && (utils.willOpenKeyboard)(document.activeElement);
|
|
136
|
+
// Focus the element without scrolling the page.
|
|
137
|
+
focus.call(this, {
|
|
138
|
+
...opts,
|
|
139
|
+
preventScroll: true
|
|
140
|
+
});
|
|
141
|
+
if (!opts || !opts.preventScroll) $49c51c25361d4cd2$var$scrollIntoViewWhenReady(this, wasKeyboardVisible);
|
|
142
|
+
};
|
|
143
|
+
let removeEvents = (utils.chain)($49c51c25361d4cd2$var$addEvent(document, 'touchstart', onTouchStart, {
|
|
144
|
+
passive: false,
|
|
145
|
+
capture: true
|
|
146
|
+
}), $49c51c25361d4cd2$var$addEvent(document, 'touchmove', onTouchMove, {
|
|
147
|
+
passive: false,
|
|
148
|
+
capture: true
|
|
149
|
+
}), $49c51c25361d4cd2$var$addEvent(document, 'blur', onBlur, true));
|
|
150
|
+
return ()=>{
|
|
151
|
+
removeEvents();
|
|
152
|
+
style.remove();
|
|
153
|
+
HTMLElement.prototype.focus = focus;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Sets a CSS property on an element, and returns a function to revert it to the previous value.
|
|
157
|
+
function $49c51c25361d4cd2$var$setStyle(element, style, value) {
|
|
158
|
+
let cur = element.style[style];
|
|
159
|
+
element.style[style] = value;
|
|
160
|
+
return ()=>{
|
|
161
|
+
element.style[style] = cur;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Adds an event listener to an element, and returns a function to remove it.
|
|
165
|
+
function $49c51c25361d4cd2$var$addEvent(target, event, handler, options) {
|
|
166
|
+
// internal function, so it's ok to ignore the difficult to fix type error
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
target.addEventListener(event, handler, options);
|
|
169
|
+
return ()=>{
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
target.removeEventListener(event, handler, options);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function $49c51c25361d4cd2$var$scrollIntoViewWhenReady(target, wasKeyboardVisible) {
|
|
175
|
+
if (wasKeyboardVisible || !$49c51c25361d4cd2$var$visualViewport) // If the keyboard was already visible, scroll the target into view immediately.
|
|
176
|
+
$49c51c25361d4cd2$var$scrollIntoView(target);
|
|
177
|
+
else // Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
178
|
+
// measure the correct position to scroll to.
|
|
179
|
+
$49c51c25361d4cd2$var$visualViewport.addEventListener('resize', ()=>$49c51c25361d4cd2$var$scrollIntoView(target), {
|
|
180
|
+
once: true
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function $49c51c25361d4cd2$var$scrollIntoView(target) {
|
|
184
|
+
let root = document.scrollingElement || document.documentElement;
|
|
185
|
+
let nextTarget = target;
|
|
186
|
+
while(nextTarget && nextTarget !== root){
|
|
187
|
+
// Find the parent scrollable element and adjust the scroll position if the target is not already in view.
|
|
188
|
+
let scrollable = (utils.getScrollParent)(nextTarget);
|
|
189
|
+
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== nextTarget) {
|
|
190
|
+
let scrollableRect = scrollable.getBoundingClientRect();
|
|
191
|
+
let targetRect = nextTarget.getBoundingClientRect();
|
|
192
|
+
if (targetRect.top < scrollableRect.top || targetRect.bottom > scrollableRect.top + nextTarget.clientHeight) {
|
|
193
|
+
let bottom = scrollableRect.bottom;
|
|
194
|
+
if ($49c51c25361d4cd2$var$visualViewport) bottom = Math.min(bottom, $49c51c25361d4cd2$var$visualViewport.offsetTop + $49c51c25361d4cd2$var$visualViewport.height);
|
|
195
|
+
// Center within the viewport.
|
|
196
|
+
let adjustment = targetRect.top - scrollableRect.top - ((bottom - scrollableRect.top) / 2 - targetRect.height / 2);
|
|
197
|
+
scrollable.scrollTo({
|
|
198
|
+
// Clamp to the valid range to prevent over-scrolling.
|
|
199
|
+
top: Math.max(0, Math.min(scrollable.scrollHeight - scrollable.clientHeight, scrollable.scrollTop + adjustment)),
|
|
200
|
+
behavior: 'smooth'
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
nextTarget = scrollable.parentElement;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
exports.usePreventScroll = $49c51c25361d4cd2$export$ee0f7cc6afcd1c18;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var $670gB$react = require('react');
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/ // We must avoid a circular dependency with @react-aria/utils, and this useLayoutEffect is
|
|
16
|
+
// guarded by a check that it only runs on the client side.
|
|
17
|
+
// eslint-disable-next-line rulesdir/useLayoutEffectRule
|
|
18
|
+
|
|
19
|
+
// Default context value to use in case there is no SSRProvider. This is fine for
|
|
20
|
+
// client-only apps. In order to support multiple copies of React Aria potentially
|
|
21
|
+
// being on the page at once, the prefix is set to a random number. SSRProvider
|
|
22
|
+
// will reset this to zero for consistency between server and client, so in the
|
|
23
|
+
// SSR case multiple copies of React Aria is not supported.
|
|
24
|
+
const $b5e257d569688ac6$var$defaultContext = {
|
|
25
|
+
prefix: String(Math.round(Math.random() * 10000000000)),
|
|
26
|
+
current: 0
|
|
27
|
+
};
|
|
28
|
+
const $b5e257d569688ac6$var$SSRContext = /*#__PURE__*/ ($670gB$react).createContext($b5e257d569688ac6$var$defaultContext);
|
|
29
|
+
const $b5e257d569688ac6$var$IsSSRContext = /*#__PURE__*/ ($670gB$react).createContext(false);
|
|
30
|
+
let $b5e257d569688ac6$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
31
|
+
let $b5e257d569688ac6$var$componentIds = new WeakMap();
|
|
32
|
+
function $b5e257d569688ac6$var$useCounter(isDisabled = false) {
|
|
33
|
+
let ctx = ($670gB$react.useContext)($b5e257d569688ac6$var$SSRContext);
|
|
34
|
+
let ref = ($670gB$react.useRef)(null);
|
|
35
|
+
// eslint-disable-next-line rulesdir/pure-render
|
|
36
|
+
if (ref.current === null && !isDisabled) {
|
|
37
|
+
var _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner, _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
38
|
+
// In strict mode, React renders components twice, and the ref will be reset to null on the second render.
|
|
39
|
+
// This means our id counter will be incremented twice instead of once. This is a problem because on the
|
|
40
|
+
// server, components are only rendered once and so ids generated on the server won't match the client.
|
|
41
|
+
// In React 18, useId was introduced to solve this, but it is not available in older versions. So to solve this
|
|
42
|
+
// we need to use some React internals to access the underlying Fiber instance, which is stable between renders.
|
|
43
|
+
// This is exposed as ReactCurrentOwner in development, which is all we need since StrictMode only runs in development.
|
|
44
|
+
// To ensure that we only increment the global counter once, we store the starting id for this component in
|
|
45
|
+
// a weak map associated with the Fiber. On the second render, we reset the global counter to this value.
|
|
46
|
+
// Since React runs the second render immediately after the first, this is safe.
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
let currentOwner = (_React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ($670gB$react).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === void 0 ? void 0 : (_React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner = _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner) === null || _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner === void 0 ? void 0 : _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner.current;
|
|
49
|
+
if (currentOwner) {
|
|
50
|
+
let prevComponentValue = $b5e257d569688ac6$var$componentIds.get(currentOwner);
|
|
51
|
+
if (prevComponentValue == null) // On the first render, and first call to useId, store the id and state in our weak map.
|
|
52
|
+
$b5e257d569688ac6$var$componentIds.set(currentOwner, {
|
|
53
|
+
id: ctx.current,
|
|
54
|
+
state: currentOwner.memoizedState
|
|
55
|
+
});
|
|
56
|
+
else if (currentOwner.memoizedState !== prevComponentValue.state) {
|
|
57
|
+
// On the second render, the memoizedState gets reset by React.
|
|
58
|
+
// Reset the counter, and remove from the weak map so we don't
|
|
59
|
+
// do this for subsequent useId calls.
|
|
60
|
+
ctx.current = prevComponentValue.id;
|
|
61
|
+
$b5e257d569688ac6$var$componentIds.delete(currentOwner);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line rulesdir/pure-render
|
|
65
|
+
ref.current = ++ctx.current;
|
|
66
|
+
}
|
|
67
|
+
// eslint-disable-next-line rulesdir/pure-render
|
|
68
|
+
return ref.current;
|
|
69
|
+
}
|
|
70
|
+
function $b5e257d569688ac6$var$useLegacySSRSafeId(defaultId) {
|
|
71
|
+
let ctx = ($670gB$react.useContext)($b5e257d569688ac6$var$SSRContext);
|
|
72
|
+
// If we are rendering in a non-DOM environment, and there's no SSRProvider,
|
|
73
|
+
// provide a warning to hint to the developer to add one.
|
|
74
|
+
if (ctx === $b5e257d569688ac6$var$defaultContext && !$b5e257d569688ac6$var$canUseDOM && process.env.NODE_ENV !== 'production') console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
|
|
75
|
+
let counter = $b5e257d569688ac6$var$useCounter(!!defaultId);
|
|
76
|
+
let prefix = ctx === $b5e257d569688ac6$var$defaultContext && process.env.NODE_ENV === 'test' ? 'react-aria' : `react-aria${ctx.prefix}`;
|
|
77
|
+
return defaultId || `${prefix}-${counter}`;
|
|
78
|
+
}
|
|
79
|
+
function $b5e257d569688ac6$var$useModernSSRSafeId(defaultId) {
|
|
80
|
+
let id = ($670gB$react).useId();
|
|
81
|
+
let [didSSR] = ($670gB$react.useState)($b5e257d569688ac6$export$535bd6ca7f90a273());
|
|
82
|
+
let prefix = didSSR || process.env.NODE_ENV === 'test' ? 'react-aria' : `react-aria${$b5e257d569688ac6$var$defaultContext.prefix}`;
|
|
83
|
+
return defaultId || `${prefix}-${id}`;
|
|
84
|
+
}
|
|
85
|
+
typeof ($670gB$react)['useId'] === 'function' ? $b5e257d569688ac6$var$useModernSSRSafeId : $b5e257d569688ac6$var$useLegacySSRSafeId;
|
|
86
|
+
function $b5e257d569688ac6$var$getSnapshot() {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
function $b5e257d569688ac6$var$getServerSnapshot() {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
93
|
+
function $b5e257d569688ac6$var$subscribe(onStoreChange) {
|
|
94
|
+
// noop
|
|
95
|
+
return ()=>{};
|
|
96
|
+
}
|
|
97
|
+
function $b5e257d569688ac6$export$535bd6ca7f90a273() {
|
|
98
|
+
// In React 18, we can use useSyncExternalStore to detect if we're server rendering or hydrating.
|
|
99
|
+
if (typeof ($670gB$react)['useSyncExternalStore'] === 'function') return ($670gB$react)['useSyncExternalStore']($b5e257d569688ac6$var$subscribe, $b5e257d569688ac6$var$getSnapshot, $b5e257d569688ac6$var$getServerSnapshot);
|
|
100
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
101
|
+
return ($670gB$react.useContext)($b5e257d569688ac6$var$IsSSRContext);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.useIsSSR = $b5e257d569688ac6$export$535bd6ca7f90a273;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var react = require('react');
|
|
5
|
+
var $670gB$react = require('react');
|
|
6
6
|
var defaultAttributes = require('./defaultAttributes.cjs');
|
|
7
7
|
var utils = require('./shared/src/utils.cjs');
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ var utils = require('./shared/src/utils.cjs');
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
const Icon = react.forwardRef(
|
|
17
|
+
const Icon = $670gB$react.forwardRef(
|
|
18
18
|
({
|
|
19
19
|
color = "currentColor",
|
|
20
20
|
size = 24,
|
|
@@ -25,7 +25,7 @@ const Icon = react.forwardRef(
|
|
|
25
25
|
iconNode,
|
|
26
26
|
...rest
|
|
27
27
|
}, ref) => {
|
|
28
|
-
return react.createElement(
|
|
28
|
+
return $670gB$react.createElement(
|
|
29
29
|
"svg",
|
|
30
30
|
{
|
|
31
31
|
ref,
|
|
@@ -38,7 +38,7 @@ const Icon = react.forwardRef(
|
|
|
38
38
|
...rest
|
|
39
39
|
},
|
|
40
40
|
[
|
|
41
|
-
...iconNode.map(([tag, attrs]) => react.createElement(tag, attrs)),
|
|
41
|
+
...iconNode.map(([tag, attrs]) => $670gB$react.createElement(tag, attrs)),
|
|
42
42
|
...Array.isArray(children) ? children : [children]
|
|
43
43
|
]
|
|
44
44
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var react = require('react');
|
|
5
|
+
var $670gB$react = require('react');
|
|
6
6
|
var utils = require('./shared/src/utils.cjs');
|
|
7
7
|
var Icon = require('./Icon.cjs');
|
|
8
8
|
|
|
@@ -15,8 +15,8 @@ var Icon = require('./Icon.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
const createLucideIcon = (iconName, iconNode) => {
|
|
18
|
-
const Component = react.forwardRef(
|
|
19
|
-
({ className, ...props }, ref) => react.createElement(Icon.default, {
|
|
18
|
+
const Component = $670gB$react.forwardRef(
|
|
19
|
+
({ className, ...props }, ref) => $670gB$react.createElement(Icon.default, {
|
|
20
20
|
ref,
|
|
21
21
|
iconNode,
|
|
22
22
|
className: utils.mergeClasses(`lucide-${utils.toKebabCase(iconName)}`, className),
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
+
var button = require('../button/button.cjs');
|
|
9
|
+
var field = require('../field/field.cjs');
|
|
8
10
|
var input = require('../input/input.cjs');
|
|
9
11
|
var utils = require('../system/utils.cjs');
|
|
10
12
|
var minus = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/minus.cjs');
|
|
11
13
|
var plus = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/plus.cjs');
|
|
12
|
-
var field = require('../field/field.cjs');
|
|
13
|
-
var button = require('../button/button.cjs');
|
|
14
14
|
|
|
15
15
|
function NumberField(originalProps) {
|
|
16
16
|
const [
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var react = require('react');
|
|
5
|
+
var $670gB$react = require('react');
|
|
6
6
|
var i18n = require('@react-aria/i18n');
|
|
7
7
|
|
|
8
8
|
var PaginationItemType = /* @__PURE__ */ ((PaginationItemType2) => {
|
|
@@ -25,22 +25,22 @@ function usePagination(props) {
|
|
|
25
25
|
showControls = false,
|
|
26
26
|
onChange
|
|
27
27
|
} = props;
|
|
28
|
-
const [activePage, setActivePage] = react.useState(page || initialPage);
|
|
28
|
+
const [activePage, setActivePage] = $670gB$react.useState(page || initialPage);
|
|
29
29
|
const { direction } = i18n.useLocale();
|
|
30
30
|
const isRTL = direction === "rtl";
|
|
31
|
-
const onChangeActivePage = react.useCallback(
|
|
31
|
+
const onChangeActivePage = $670gB$react.useCallback(
|
|
32
32
|
(newPage) => {
|
|
33
33
|
setActivePage(newPage);
|
|
34
34
|
onChange?.(newPage);
|
|
35
35
|
},
|
|
36
36
|
[onChange]
|
|
37
37
|
);
|
|
38
|
-
react.useEffect(() => {
|
|
38
|
+
$670gB$react.useEffect(() => {
|
|
39
39
|
if (page && page !== activePage) {
|
|
40
40
|
setActivePage(page);
|
|
41
41
|
}
|
|
42
42
|
}, [activePage, page]);
|
|
43
|
-
const setPage = react.useCallback(
|
|
43
|
+
const setPage = $670gB$react.useCallback(
|
|
44
44
|
(pageNumber) => {
|
|
45
45
|
if (pageNumber <= 0) {
|
|
46
46
|
onChangeActivePage(1);
|
|
@@ -56,7 +56,7 @@ function usePagination(props) {
|
|
|
56
56
|
const previous = () => setPage(activePage - 1);
|
|
57
57
|
const first = () => setPage(1);
|
|
58
58
|
const last = () => setPage(total);
|
|
59
|
-
const formatRange = react.useCallback(
|
|
59
|
+
const formatRange = $670gB$react.useCallback(
|
|
60
60
|
(range2) => {
|
|
61
61
|
if (showControls) {
|
|
62
62
|
return ["prev" /* PREV */, ...range2, "next" /* NEXT */];
|
|
@@ -66,7 +66,7 @@ function usePagination(props) {
|
|
|
66
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
67
|
[isRTL, showControls]
|
|
68
68
|
);
|
|
69
|
-
const paginationRange = react.useMemo(() => {
|
|
69
|
+
const paginationRange = $670gB$react.useMemo(() => {
|
|
70
70
|
const totalPageNumbers = siblings * 2 + 3 + boundaries * 2;
|
|
71
71
|
if (totalPageNumbers >= total) {
|
|
72
72
|
return formatRange(range(1, total));
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var react = require('react');
|
|
6
|
+
var $670gB$react = require('react');
|
|
7
7
|
var i18n = require('@react-aria/i18n');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
9
|
var utils = require('../system/utils.cjs');
|
|
@@ -40,7 +40,7 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
40
40
|
} = usePagination.usePagination({ ...props, ref });
|
|
41
41
|
const { direction } = i18n.useLocale();
|
|
42
42
|
const isRTL = direction === "rtl";
|
|
43
|
-
const renderChevronIcon = react.useCallback(
|
|
43
|
+
const renderChevronIcon = $670gB$react.useCallback(
|
|
44
44
|
(key) => {
|
|
45
45
|
if (key === usePagination$1.PaginationItemType.PREV && !isRTL || key === usePagination$1.PaginationItemType.NEXT && isRTL) {
|
|
46
46
|
return /* @__PURE__ */ jsxRuntime.jsx(chevronLeft.default, {});
|
|
@@ -56,7 +56,7 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
56
56
|
},
|
|
57
57
|
[isRTL, slots, classNames?.chevronNext]
|
|
58
58
|
);
|
|
59
|
-
const renderPrevItem = react.useCallback(() => {
|
|
59
|
+
const renderPrevItem = $670gB$react.useCallback(() => {
|
|
60
60
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
61
61
|
paginationItem.PaginationItem,
|
|
62
62
|
{
|
|
@@ -82,7 +82,7 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
82
82
|
onPrevious,
|
|
83
83
|
renderChevronIcon
|
|
84
84
|
]);
|
|
85
|
-
const renderNextItem = react.useCallback(() => {
|
|
85
|
+
const renderNextItem = $670gB$react.useCallback(() => {
|
|
86
86
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
87
|
paginationItem.PaginationItem,
|
|
88
88
|
{
|
|
@@ -109,7 +109,7 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
109
109
|
onNext,
|
|
110
110
|
renderChevronIcon
|
|
111
111
|
]);
|
|
112
|
-
const renderItem = react.useCallback(
|
|
112
|
+
const renderItem = $670gB$react.useCallback(
|
|
113
113
|
(value, index) => {
|
|
114
114
|
const isBefore = index < range.indexOf(activePage);
|
|
115
115
|
if (renderItemProp && typeof renderItemProp === "function") {
|
|
@@ -209,7 +209,7 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
209
209
|
usePagination$1.PaginationItemType.DOTS + isBefore
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
|
-
return /* @__PURE__ */ react.createElement(
|
|
212
|
+
return /* @__PURE__ */ $670gB$react.createElement(
|
|
213
213
|
paginationItem.PaginationItem,
|
|
214
214
|
{
|
|
215
215
|
...getItemProps({ value }),
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var react = require('react');
|
|
5
|
+
var $670gB$react = require('react');
|
|
6
6
|
var focus = require('@react-aria/focus');
|
|
7
7
|
var interactions = require('@react-aria/interactions');
|
|
8
8
|
var utils = require('@react-aria/utils');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
|
-
var filterDomProps = require('../system/react-utils/filter-dom-props.cjs');
|
|
11
10
|
var refs = require('../system/react-utils/refs.cjs');
|
|
11
|
+
var filterDomProps = require('../system/react-utils/filter-dom-props.cjs');
|
|
12
12
|
|
|
13
13
|
function usePaginationItem(props) {
|
|
14
14
|
const {
|
|
@@ -29,7 +29,7 @@ function usePaginationItem(props) {
|
|
|
29
29
|
const shouldFilterDOMProps = typeof Component === "string";
|
|
30
30
|
const domRef = refs.useDomRef(ref);
|
|
31
31
|
const router = utils.useRouter();
|
|
32
|
-
const ariaLabel = react.useMemo(
|
|
32
|
+
const ariaLabel = $670gB$react.useMemo(
|
|
33
33
|
() => isActive ? `${getAriaLabel?.(value)} active` : getAriaLabel?.(value),
|
|
34
34
|
[isActive, getAriaLabel, value]
|
|
35
35
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var react = require('react');
|
|
5
|
+
var $670gB$react = require('react');
|
|
6
6
|
var scrollIntoView = require('scroll-into-view-if-needed');
|
|
7
7
|
var useDeepCompare = require('use-deep-compare');
|
|
8
8
|
var usehooksTs = require('usehooks-ts');
|
|
@@ -37,9 +37,9 @@ function usePagination(originalProps) {
|
|
|
37
37
|
} = props;
|
|
38
38
|
const Component = as || "nav";
|
|
39
39
|
const domRef = refs.useDomRef(ref);
|
|
40
|
-
const cursorRef = react.useRef(null);
|
|
41
|
-
const itemsRef = react.useRef(null);
|
|
42
|
-
const cursorTimer = react.useRef(null);
|
|
40
|
+
const cursorRef = $670gB$react.useRef(null);
|
|
41
|
+
const itemsRef = $670gB$react.useRef(null);
|
|
42
|
+
const cursorTimer = $670gB$react.useRef(null);
|
|
43
43
|
const disableAnimation = originalProps?.disableAnimation ?? false;
|
|
44
44
|
const disableCursorAnimation = originalProps?.disableCursorAnimation ?? disableAnimation ?? false;
|
|
45
45
|
function getItemsRefMap() {
|
|
@@ -56,7 +56,7 @@ function usePagination(originalProps) {
|
|
|
56
56
|
map.delete(value);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
const scrollTo = react.useCallback(
|
|
59
|
+
const scrollTo = $670gB$react.useCallback(
|
|
60
60
|
(value, skipAnimation) => {
|
|
61
61
|
const map = getItemsRefMap();
|
|
62
62
|
const node = map.get(value);
|
|
@@ -103,13 +103,13 @@ function usePagination(originalProps) {
|
|
|
103
103
|
onChange
|
|
104
104
|
});
|
|
105
105
|
const [setRef, isVisible] = usehooksTs.useIntersectionObserver();
|
|
106
|
-
react.useEffect(() => {
|
|
106
|
+
$670gB$react.useEffect(() => {
|
|
107
107
|
if (domRef.current) {
|
|
108
108
|
setRef(domRef.current);
|
|
109
109
|
}
|
|
110
110
|
}, [domRef, setRef]);
|
|
111
|
-
const activePageRef = react.useRef(activePage);
|
|
112
|
-
react.useEffect(() => {
|
|
111
|
+
const activePageRef = $670gB$react.useRef(activePage);
|
|
112
|
+
$670gB$react.useEffect(() => {
|
|
113
113
|
if (activePage && !disableAnimation && isVisible) {
|
|
114
114
|
scrollTo(activePage, activePage === activePageRef.current);
|
|
115
115
|
}
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var react = require('react');
|
|
6
|
+
var $670gB$react = require('react');
|
|
7
7
|
var date = require('@internationalized/date');
|
|
8
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
9
|
var useDeepCompare = require('use-deep-compare');
|
|
10
10
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
11
|
+
var calendarStyleContext = require('../calendar/calendar-style-context.cjs');
|
|
11
12
|
var agnosticCalendarStateContext = require('../calendar/agnostic-calendar-state-context.cjs');
|
|
12
13
|
var calendarBottomContent = require('../calendar/calendar-bottom-content.cjs');
|
|
13
14
|
var calendarGridHeader = require('../calendar/calendar-grid-header.cjs');
|
|
14
15
|
var calendarHeader = require('../calendar/calendar-header.cjs');
|
|
15
16
|
var utils = require('../system/utils.cjs');
|
|
16
|
-
var calendarStyleContext = require('../calendar/calendar-style-context.cjs');
|
|
17
17
|
|
|
18
18
|
const RangeCalendar = utils.forwardRefGeneric(function RangeCalendar2(originalProps, ref) {
|
|
19
19
|
const [props, variantProps] = utils.mapPropsVariants(
|
|
@@ -36,7 +36,7 @@ const RangeCalendar = utils.forwardRefGeneric(function RangeCalendar2(originalPr
|
|
|
36
36
|
() => ouiTheme.calendarStyles({ ...variantProps, isRange: true }),
|
|
37
37
|
[variantProps]
|
|
38
38
|
);
|
|
39
|
-
const context = react.useMemo(
|
|
39
|
+
const context = $670gB$react.useMemo(
|
|
40
40
|
() => ({
|
|
41
41
|
slots,
|
|
42
42
|
classNames,
|
|
@@ -46,7 +46,7 @@ const RangeCalendar = utils.forwardRefGeneric(function RangeCalendar2(originalPr
|
|
|
46
46
|
[className, classNames, slots, variantProps.size]
|
|
47
47
|
);
|
|
48
48
|
const numberOfVisibleMonths = props.visibleDuration?.months ?? 1;
|
|
49
|
-
const dateToHighlight = react.useMemo(() => {
|
|
49
|
+
const dateToHighlight = $670gB$react.useMemo(() => {
|
|
50
50
|
if (props.defaultFocusedValue !== void 0) {
|
|
51
51
|
return props.defaultFocusedValue;
|
|
52
52
|
}
|
|
@@ -140,7 +140,7 @@ const RangeCalendar = utils.forwardRefGeneric(function RangeCalendar2(originalPr
|
|
|
140
140
|
const RangeCalendarStateWrapper = ({
|
|
141
141
|
children
|
|
142
142
|
}) => {
|
|
143
|
-
const state = react.useContext(reactAriaComponents.RangeCalendarStateContext);
|
|
143
|
+
const state = $670gB$react.useContext(reactAriaComponents.RangeCalendarStateContext);
|
|
144
144
|
return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Provider, { values: [[agnosticCalendarStateContext.AgnosticCalendarStateContext, state]], children });
|
|
145
145
|
};
|
|
146
146
|
const RangeCalendarCell = ({
|
|
@@ -150,9 +150,9 @@ const RangeCalendarCell = ({
|
|
|
150
150
|
firstDayOfWeek
|
|
151
151
|
}) => {
|
|
152
152
|
const { classNames, slots } = calendarStyleContext.useCalendarStyleContext();
|
|
153
|
-
const state = react.useContext(agnosticCalendarStateContext.AgnosticCalendarStateContext);
|
|
153
|
+
const state = $670gB$react.useContext(agnosticCalendarStateContext.AgnosticCalendarStateContext);
|
|
154
154
|
const { locale } = reactAriaComponents.useLocale();
|
|
155
|
-
const dataAttributes = react.useMemo(() => {
|
|
155
|
+
const dataAttributes = $670gB$react.useMemo(() => {
|
|
156
156
|
const isDateHighlighted = dateToHighlight ? date$1.compare(dateToHighlight) === 0 : false;
|
|
157
157
|
const isSelected = state.isSelected(date$1);
|
|
158
158
|
const isDisabled = state.isCellDisabled(date$1);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var react = require('react');
|
|
5
|
+
var $670gB$react = require('react');
|
|
6
6
|
var nanoid = require('nanoid');
|
|
7
7
|
|
|
8
8
|
const useRipple = () => {
|
|
9
|
-
const [ripples, setRipples] = react.useState([]);
|
|
10
|
-
const onPress = react.useCallback((event) => {
|
|
9
|
+
const [ripples, setRipples] = $670gB$react.useState([]);
|
|
10
|
+
const onPress = $670gB$react.useCallback((event) => {
|
|
11
11
|
const trigger = event.target;
|
|
12
12
|
const size = Math.max(trigger.clientWidth, trigger.clientHeight);
|
|
13
13
|
setRipples((prevRipples) => [
|
|
@@ -20,7 +20,7 @@ const useRipple = () => {
|
|
|
20
20
|
}
|
|
21
21
|
]);
|
|
22
22
|
}, []);
|
|
23
|
-
const onClear = react.useCallback((key) => {
|
|
23
|
+
const onClear = $670gB$react.useCallback((key) => {
|
|
24
24
|
setRipples((prevState) => prevState.filter((ripple) => ripple.key !== key));
|
|
25
25
|
}, []);
|
|
26
26
|
return { ripples, onPress, onClear };
|