braid-design-system 34.6.0 → 34.6.2
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/CHANGELOG.md +14 -0
- package/README.md +4 -2
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/lib/components/Autosuggest/Autosuggest.cjs +18 -24
- package/dist/lib/components/Autosuggest/Autosuggest.mjs +19 -25
- package/dist/lib/components/Autosuggest/useScrollIntoView.cjs +14 -0
- package/dist/lib/components/Autosuggest/useScrollIntoView.mjs +14 -0
- package/dist/lib/components/BraidProvider/BraidProvider.cjs +3 -2
- package/dist/lib/components/BraidProvider/BraidProvider.mjs +3 -2
- package/dist/lib/components/Button/ButtonLoader.css.mjs +2 -1
- package/dist/lib/components/ButtonLink/ButtonLink.playroom.cjs +2 -1
- package/dist/lib/components/ButtonLink/ButtonLink.playroom.mjs +2 -1
- package/dist/lib/components/FieldMessage/FieldMessage.playroom.cjs +2 -1
- package/dist/lib/components/FieldMessage/FieldMessage.playroom.mjs +2 -1
- package/dist/lib/components/Link/Link.cjs +2 -1
- package/dist/lib/components/Link/Link.mjs +2 -1
- package/dist/lib/components/Loader/Loader.css.cjs +6 -5
- package/dist/lib/components/Loader/Loader.css.mjs +11 -9
- package/dist/lib/components/PageBlock/PageBlock.cjs +2 -1
- package/dist/lib/components/PageBlock/PageBlock.mjs +2 -1
- package/dist/lib/components/Stepper/Stepper.css.cjs +1 -1
- package/dist/lib/components/Stepper/Stepper.css.mjs +1 -1
- package/dist/lib/components/Table/TableBody.cjs +2 -1
- package/dist/lib/components/Table/TableBody.mjs +2 -1
- package/dist/lib/components/Table/TableCell.cjs +2 -1
- package/dist/lib/components/Table/TableCell.mjs +2 -1
- package/dist/lib/components/Table/TableFooter.cjs +2 -1
- package/dist/lib/components/Table/TableFooter.mjs +2 -1
- package/dist/lib/components/Table/TableHeader.cjs +2 -1
- package/dist/lib/components/Table/TableHeader.mjs +2 -1
- package/dist/lib/components/Tabs/Tab.cjs +14 -12
- package/dist/lib/components/Tabs/Tab.mjs +14 -12
- package/dist/lib/components/TextLink/TextLink.mjs +2 -1
- package/dist/lib/components/Textarea/formatRanges.cjs +3 -2
- package/dist/lib/components/Textarea/formatRanges.mjs +3 -2
- package/dist/lib/components/TooltipRenderer/TooltipRenderer.cjs +2 -1
- package/dist/lib/components/TooltipRenderer/TooltipRenderer.mjs +2 -1
- package/dist/lib/components/private/Announcement/Announcement.cjs +1 -0
- package/dist/lib/components/private/Announcement/Announcement.mjs +1 -0
- package/dist/lib/components/private/Modal/Modal.cjs +2 -1
- package/dist/lib/components/private/Modal/Modal.mjs +2 -1
- package/dist/lib/components/private/Popover/Popover.cjs +11 -9
- package/dist/lib/components/private/Popover/Popover.css.mjs +5 -4
- package/dist/lib/components/private/Popover/Popover.mjs +11 -9
- package/dist/lib/components/useToast/Toast.cjs +7 -6
- package/dist/lib/components/useToast/Toast.mjs +7 -6
- package/dist/lib/components/useToast/useFlipList.cjs +24 -24
- package/dist/lib/components/useToast/useFlipList.mjs +24 -24
- package/dist/lib/css/atoms/sprinkles.css.d.cts +1 -1
- package/dist/lib/css/atoms/sprinkles.css.d.mts +1 -1
- package/dist/lib/hooks/useIcon/icon.css.cjs +4 -7
- package/dist/lib/hooks/useIcon/icon.css.mjs +4 -7
- package/dist/lib/playroom/FrameComponent.cjs +2 -1
- package/dist/lib/playroom/FrameComponent.mjs +2 -1
- package/dist/lib/utils/isLight/index.cjs +1 -1
- package/dist/lib/utils/isLight/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# braid-design-system
|
|
2
2
|
|
|
3
|
+
## 34.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Autosuggest:** Add `translate="no"` to the suggestion list and the ARIA live announcement region to prevent browser translations from wrapping text nodes in `<font>` elements, which breaks React DOM updates. Also key suggestion rows by index instead of `index + text`, so locale changes to suggestion labels no longer remount the list, and numeric text can no longer collide keys via string concatenation. ([#2117](https://github.com/seek-oss/braid-design-system/pull/2117))
|
|
8
|
+
|
|
9
|
+
- **Autosuggest:** Allow the suggestions list to flip above the field when there is insufficient space below, and keep keyboard highlight scrolling inside the menu so it no longer jumps the page ([#2113](https://github.com/seek-oss/braid-design-system/pull/2113))
|
|
10
|
+
|
|
11
|
+
## 34.6.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Fix Dialog/Drawer crashing under Jest (CJS) when resolving `react-focus-lock` ([#2108](https://github.com/seek-oss/braid-design-system/pull/2108))
|
|
16
|
+
|
|
3
17
|
## 34.6.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<div align="center" >
|
|
2
|
-
<
|
|
3
|
-
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/seek-oss/braid-design-system/HEAD/logo-inverted.png" />
|
|
4
|
+
<img src="https://raw.githubusercontent.com/seek-oss/braid-design-system/HEAD/logo.png" alt="BRAID" title="BRAID" width="186px" />
|
|
5
|
+
</picture>
|
|
4
6
|
<br/>
|
|
5
7
|
<br/>
|
|
6
8
|
Themeable design system for the SEEK Group.
|
|
@@ -24,7 +24,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
24
|
}
|
|
25
25
|
return to;
|
|
26
26
|
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
28
28
|
value: mod,
|
|
29
29
|
enumerable: true
|
|
30
30
|
}) : target, mod));
|
|
@@ -20,6 +20,7 @@ const require_normalizeKey = require("../private/normalizeKey.cjs");
|
|
|
20
20
|
const require_smoothScroll = require("../private/smoothScroll.cjs");
|
|
21
21
|
const require_createAccessibilityProps = require("./createAccessibilityProps.cjs");
|
|
22
22
|
const require_reverseMatches = require("./reverseMatches.cjs");
|
|
23
|
+
const require_useScrollIntoView = require("./useScrollIntoView.cjs");
|
|
23
24
|
const require_Autosuggest_css = require("./Autosuggest.css.cjs");
|
|
24
25
|
let dedent = require("dedent");
|
|
25
26
|
dedent = require_runtime.__toESM(dedent, 1);
|
|
@@ -43,7 +44,8 @@ const SUGGESTION_MOUSE_ENTER = 8;
|
|
|
43
44
|
const HAS_SUGGESTIONS_CHANGED = 9;
|
|
44
45
|
function SuggestionItem({ suggestion, highlighted, selected, onHover, id, ...restProps }) {
|
|
45
46
|
const { highlights = [], onClear, clearLabel, data } = suggestion;
|
|
46
|
-
const
|
|
47
|
+
const label = suggestion.label ?? suggestion.text;
|
|
48
|
+
const suggestionParts = (0, autosuggest_highlight_parse_index_js.default)(label, highlights.map(({ start, end }) => [start, end]));
|
|
47
49
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
48
50
|
component: "li",
|
|
49
51
|
cursor: "pointer",
|
|
@@ -256,24 +258,15 @@ const Autosuggest = (0, react.forwardRef)(function({ id, value = fallbackValue,
|
|
|
256
258
|
isFocused: false
|
|
257
259
|
});
|
|
258
260
|
const isOpen = showSuggestionsIfAvailable && hasItems;
|
|
259
|
-
|
|
260
|
-
(0, react.
|
|
261
|
+
const highlightedItem = typeof highlightedIndex === "number" ? document.getElementById(require_createAccessibilityProps.getItemId(resolvedId, highlightedIndex)) : null;
|
|
262
|
+
(0, react.useLayoutEffect)(() => {
|
|
261
263
|
dispatch({ type: HAS_SUGGESTIONS_CHANGED });
|
|
262
264
|
}, [hasSuggestions]);
|
|
263
265
|
const isMobile = require_useResponsiveValue.useResponsiveValue()({
|
|
264
266
|
mobile: true,
|
|
265
267
|
tablet: false
|
|
266
268
|
});
|
|
267
|
-
(
|
|
268
|
-
if (menuRef.current && isOpen && !isMobile) {
|
|
269
|
-
const { bottom: menuBottom } = menuRef.current.getBoundingClientRect();
|
|
270
|
-
if (menuBottom > document.documentElement.clientHeight) menuRef.current.scrollIntoView(false);
|
|
271
|
-
}
|
|
272
|
-
}, [
|
|
273
|
-
isOpen,
|
|
274
|
-
isMobile,
|
|
275
|
-
suggestionCount
|
|
276
|
-
]);
|
|
269
|
+
require_useScrollIntoView.useScrollIntoView(highlightedItem, menuRef);
|
|
277
270
|
const inputProps = {
|
|
278
271
|
value: previewValue ? previewValue.text : value.text,
|
|
279
272
|
type: type === "search" ? type : "text",
|
|
@@ -336,14 +329,16 @@ const Autosuggest = (0, react.forwardRef)(function({ id, value = fallbackValue,
|
|
|
336
329
|
const clearable = Boolean(typeof onClear !== "undefined" && !restProps.disabled && typeof value !== "undefined" && value.text.length > 0);
|
|
337
330
|
const announcements = [];
|
|
338
331
|
const hasAutomaticSelection = automaticSelection && previewValue === null && highlightedIndex === 0;
|
|
339
|
-
if (isFocused && isOpen && (highlightedIndex === null || hasAutomaticSelection))
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (noSuggestionsMessage
|
|
345
|
-
|
|
346
|
-
|
|
332
|
+
if (isFocused && isOpen && (highlightedIndex === null || hasAutomaticSelection)) {
|
|
333
|
+
if (hasSuggestions) {
|
|
334
|
+
announcements.push(translations.suggestionsAvailableAnnouncement(suggestionCount));
|
|
335
|
+
if (hasAutomaticSelection) announcements.push(translations.suggestionAutoSelectedAnnouncement(normalisedSuggestions[0].text));
|
|
336
|
+
announcements.push(translations.suggestionInstructions);
|
|
337
|
+
} else if (noSuggestionsMessage) {
|
|
338
|
+
if (noSuggestionsMessage.title) announcements.push(noSuggestionsMessage.title);
|
|
339
|
+
announcements.push(noSuggestionsMessage.description);
|
|
340
|
+
} else announcements.push(translations.noSuggestionsAvailableAnnouncement);
|
|
341
|
+
}
|
|
347
342
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [showMobileBackdrop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
348
343
|
position: "fixed",
|
|
349
344
|
zIndex: "dropdownBackdrop",
|
|
@@ -396,7 +391,6 @@ const Autosuggest = (0, react.forwardRef)(function({ id, value = fallbackValue,
|
|
|
396
391
|
triggerRef: fieldRef,
|
|
397
392
|
open: isOpen,
|
|
398
393
|
width: "full",
|
|
399
|
-
lockPlacement: true,
|
|
400
394
|
offsetSpace: "xxsmall",
|
|
401
395
|
modal: false,
|
|
402
396
|
role: false,
|
|
@@ -407,6 +401,7 @@ const Autosuggest = (0, react.forwardRef)(function({ id, value = fallbackValue,
|
|
|
407
401
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Box.Box, {
|
|
408
402
|
textAlign: "left",
|
|
409
403
|
component: "ul",
|
|
404
|
+
translate: "no",
|
|
410
405
|
background: !hasSuggestions && noSuggestionsMessage ? {
|
|
411
406
|
lightMode: "neutralSoft",
|
|
412
407
|
darkMode: "neutral"
|
|
@@ -432,7 +427,6 @@ const Autosuggest = (0, react.forwardRef)(function({ id, value = fallbackValue,
|
|
|
432
427
|
children: noSuggestionsMessage.description
|
|
433
428
|
})]
|
|
434
429
|
}) : null, hasSuggestions ? normalisedSuggestions.map((suggestion, index) => {
|
|
435
|
-
const { text } = suggestion;
|
|
436
430
|
const groupHeading = groupHeadingIndexes.get(index);
|
|
437
431
|
const highlights = suggestionHighlight ? highlightSuggestions(suggestion.text, value.text, suggestionHighlight) : suggestion.highlights;
|
|
438
432
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [groupHeading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupHeading, { children: groupHeading }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuggestionItem, {
|
|
@@ -458,7 +452,7 @@ const Autosuggest = (0, react.forwardRef)(function({ id, value = fallbackValue,
|
|
|
458
452
|
description: suggestion.description,
|
|
459
453
|
groupHeading: groupHeadingForSuggestion.get(suggestion)
|
|
460
454
|
})
|
|
461
|
-
})] }, index
|
|
455
|
+
})] }, index);
|
|
462
456
|
}) : null]
|
|
463
457
|
})
|
|
464
458
|
})
|
|
@@ -19,9 +19,10 @@ import { normalizeKey } from "../private/normalizeKey.mjs";
|
|
|
19
19
|
import { smoothScroll } from "../private/smoothScroll.mjs";
|
|
20
20
|
import { createAccessibilityProps, getItemId } from "./createAccessibilityProps.mjs";
|
|
21
21
|
import { reverseMatches } from "./reverseMatches.mjs";
|
|
22
|
+
import { useScrollIntoView } from "./useScrollIntoView.mjs";
|
|
22
23
|
import { backdrop, backdropVisible, menu } from "./Autosuggest.css.mjs";
|
|
23
24
|
import dedent from "dedent";
|
|
24
|
-
import { Fragment, forwardRef, useCallback,
|
|
25
|
+
import { Fragment, forwardRef, useCallback, useLayoutEffect, useReducer, useRef } from "react";
|
|
25
26
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
26
27
|
import matchHighlights from "autosuggest-highlight/match/index.js";
|
|
27
28
|
import parseHighlights from "autosuggest-highlight/parse/index.js";
|
|
@@ -39,7 +40,8 @@ const SUGGESTION_MOUSE_ENTER = 8;
|
|
|
39
40
|
const HAS_SUGGESTIONS_CHANGED = 9;
|
|
40
41
|
function SuggestionItem({ suggestion, highlighted, selected, onHover, id, ...restProps }) {
|
|
41
42
|
const { highlights = [], onClear, clearLabel, data } = suggestion;
|
|
42
|
-
const
|
|
43
|
+
const label = suggestion.label ?? suggestion.text;
|
|
44
|
+
const suggestionParts = parseHighlights(label, highlights.map(({ start, end }) => [start, end]));
|
|
43
45
|
return /* @__PURE__ */ jsx(Box, {
|
|
44
46
|
component: "li",
|
|
45
47
|
cursor: "pointer",
|
|
@@ -252,24 +254,15 @@ const Autosuggest = forwardRef(function({ id, value = fallbackValue, suggestions
|
|
|
252
254
|
isFocused: false
|
|
253
255
|
});
|
|
254
256
|
const isOpen = showSuggestionsIfAvailable && hasItems;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
const highlightedItem = typeof highlightedIndex === "number" ? document.getElementById(getItemId(resolvedId, highlightedIndex)) : null;
|
|
258
|
+
useLayoutEffect(() => {
|
|
257
259
|
dispatch({ type: HAS_SUGGESTIONS_CHANGED });
|
|
258
260
|
}, [hasSuggestions]);
|
|
259
261
|
const isMobile = useResponsiveValue()({
|
|
260
262
|
mobile: true,
|
|
261
263
|
tablet: false
|
|
262
264
|
});
|
|
263
|
-
|
|
264
|
-
if (menuRef.current && isOpen && !isMobile) {
|
|
265
|
-
const { bottom: menuBottom } = menuRef.current.getBoundingClientRect();
|
|
266
|
-
if (menuBottom > document.documentElement.clientHeight) menuRef.current.scrollIntoView(false);
|
|
267
|
-
}
|
|
268
|
-
}, [
|
|
269
|
-
isOpen,
|
|
270
|
-
isMobile,
|
|
271
|
-
suggestionCount
|
|
272
|
-
]);
|
|
265
|
+
useScrollIntoView(highlightedItem, menuRef);
|
|
273
266
|
const inputProps = {
|
|
274
267
|
value: previewValue ? previewValue.text : value.text,
|
|
275
268
|
type: type === "search" ? type : "text",
|
|
@@ -332,14 +325,16 @@ const Autosuggest = forwardRef(function({ id, value = fallbackValue, suggestions
|
|
|
332
325
|
const clearable = Boolean(typeof onClear !== "undefined" && !restProps.disabled && typeof value !== "undefined" && value.text.length > 0);
|
|
333
326
|
const announcements = [];
|
|
334
327
|
const hasAutomaticSelection = automaticSelection && previewValue === null && highlightedIndex === 0;
|
|
335
|
-
if (isFocused && isOpen && (highlightedIndex === null || hasAutomaticSelection))
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (noSuggestionsMessage
|
|
341
|
-
|
|
342
|
-
|
|
328
|
+
if (isFocused && isOpen && (highlightedIndex === null || hasAutomaticSelection)) {
|
|
329
|
+
if (hasSuggestions) {
|
|
330
|
+
announcements.push(translations.suggestionsAvailableAnnouncement(suggestionCount));
|
|
331
|
+
if (hasAutomaticSelection) announcements.push(translations.suggestionAutoSelectedAnnouncement(normalisedSuggestions[0].text));
|
|
332
|
+
announcements.push(translations.suggestionInstructions);
|
|
333
|
+
} else if (noSuggestionsMessage) {
|
|
334
|
+
if (noSuggestionsMessage.title) announcements.push(noSuggestionsMessage.title);
|
|
335
|
+
announcements.push(noSuggestionsMessage.description);
|
|
336
|
+
} else announcements.push(translations.noSuggestionsAvailableAnnouncement);
|
|
337
|
+
}
|
|
343
338
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [showMobileBackdrop ? /* @__PURE__ */ jsx(Box, {
|
|
344
339
|
position: "fixed",
|
|
345
340
|
zIndex: "dropdownBackdrop",
|
|
@@ -392,7 +387,6 @@ const Autosuggest = forwardRef(function({ id, value = fallbackValue, suggestions
|
|
|
392
387
|
triggerRef: fieldRef,
|
|
393
388
|
open: isOpen,
|
|
394
389
|
width: "full",
|
|
395
|
-
lockPlacement: true,
|
|
396
390
|
offsetSpace: "xxsmall",
|
|
397
391
|
modal: false,
|
|
398
392
|
role: false,
|
|
@@ -403,6 +397,7 @@ const Autosuggest = forwardRef(function({ id, value = fallbackValue, suggestions
|
|
|
403
397
|
children: /* @__PURE__ */ jsxs(Box, {
|
|
404
398
|
textAlign: "left",
|
|
405
399
|
component: "ul",
|
|
400
|
+
translate: "no",
|
|
406
401
|
background: !hasSuggestions && noSuggestionsMessage ? {
|
|
407
402
|
lightMode: "neutralSoft",
|
|
408
403
|
darkMode: "neutral"
|
|
@@ -428,7 +423,6 @@ const Autosuggest = forwardRef(function({ id, value = fallbackValue, suggestions
|
|
|
428
423
|
children: noSuggestionsMessage.description
|
|
429
424
|
})]
|
|
430
425
|
}) : null, hasSuggestions ? normalisedSuggestions.map((suggestion, index) => {
|
|
431
|
-
const { text } = suggestion;
|
|
432
426
|
const groupHeading = groupHeadingIndexes.get(index);
|
|
433
427
|
const highlights = suggestionHighlight ? highlightSuggestions(suggestion.text, value.text, suggestionHighlight) : suggestion.highlights;
|
|
434
428
|
return /* @__PURE__ */ jsxs(Fragment, { children: [groupHeading ? /* @__PURE__ */ jsx(GroupHeading, { children: groupHeading }) : null, /* @__PURE__ */ jsx(SuggestionItem, {
|
|
@@ -454,7 +448,7 @@ const Autosuggest = forwardRef(function({ id, value = fallbackValue, suggestions
|
|
|
454
448
|
description: suggestion.description,
|
|
455
449
|
groupHeading: groupHeadingForSuggestion.get(suggestion)
|
|
456
450
|
})
|
|
457
|
-
})] }, index
|
|
451
|
+
})] }, index);
|
|
458
452
|
}) : null]
|
|
459
453
|
})
|
|
460
454
|
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
let react = require("react");
|
|
2
|
+
//#region src/lib/components/Autosuggest/useScrollIntoView.ts
|
|
3
|
+
function useScrollIntoView(element, scrollContainerRef) {
|
|
4
|
+
(0, react.useEffect)(() => {
|
|
5
|
+
const scrollContainer = scrollContainerRef.current;
|
|
6
|
+
if (!scrollContainer || !element) return;
|
|
7
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
8
|
+
const elementRect = element.getBoundingClientRect();
|
|
9
|
+
if (elementRect.top < containerRect.top) scrollContainer.scrollTop -= containerRect.top - elementRect.top;
|
|
10
|
+
else if (elementRect.bottom > containerRect.bottom) scrollContainer.scrollTop += elementRect.bottom - containerRect.bottom;
|
|
11
|
+
}, [scrollContainerRef, element]);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.useScrollIntoView = useScrollIntoView;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
//#region src/lib/components/Autosuggest/useScrollIntoView.ts
|
|
3
|
+
function useScrollIntoView(element, scrollContainerRef) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const scrollContainer = scrollContainerRef.current;
|
|
6
|
+
if (!scrollContainer || !element) return;
|
|
7
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
8
|
+
const elementRect = element.getBoundingClientRect();
|
|
9
|
+
if (elementRect.top < containerRect.top) scrollContainer.scrollTop -= containerRect.top - elementRect.top;
|
|
10
|
+
else if (elementRect.bottom > containerRect.bottom) scrollContainer.scrollTop += elementRect.bottom - containerRect.bottom;
|
|
11
|
+
}, [scrollContainerRef, element]);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useScrollIntoView };
|
|
@@ -14,10 +14,11 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
14
14
|
//#region src/lib/components/BraidProvider/BraidProvider.tsx
|
|
15
15
|
if (process.env.NODE_ENV === "development") require_resetTracker.ensureResetImported();
|
|
16
16
|
const makeLinkComponent = (render) => ({ __forwardRef__: (0, react.forwardRef)(render) });
|
|
17
|
-
const
|
|
17
|
+
const DefaultLinkComponent = makeLinkComponent((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
18
18
|
ref,
|
|
19
19
|
...props
|
|
20
|
-
}))
|
|
20
|
+
}));
|
|
21
|
+
const LinkComponentContext = (0, react.createContext)(DefaultLinkComponent);
|
|
21
22
|
const useLinkComponent = (ref) => {
|
|
22
23
|
const linkComponent = (0, react.useContext)(LinkComponentContext);
|
|
23
24
|
(0, assert.default)(!ref || "__forwardRef__" in linkComponent, dedent.default`
|
|
@@ -11,10 +11,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
//#region src/lib/components/BraidProvider/BraidProvider.tsx
|
|
12
12
|
if (process.env.NODE_ENV === "development") ensureResetImported();
|
|
13
13
|
const makeLinkComponent = (render) => ({ __forwardRef__: forwardRef(render) });
|
|
14
|
-
const
|
|
14
|
+
const DefaultLinkComponent = makeLinkComponent((props, ref) => /* @__PURE__ */ jsx("a", {
|
|
15
15
|
ref,
|
|
16
16
|
...props
|
|
17
|
-
}))
|
|
17
|
+
}));
|
|
18
|
+
const LinkComponentContext = createContext(DefaultLinkComponent);
|
|
18
19
|
const useLinkComponent = (ref) => {
|
|
19
20
|
const linkComponent = useContext(LinkComponentContext);
|
|
20
21
|
assert(!ref || "__forwardRef__" in linkComponent, dedent`
|
|
@@ -2,7 +2,8 @@ import { endFileScope, setFileScope } from "@vanilla-extract/css/fileScope";
|
|
|
2
2
|
import { keyframes, style } from "@vanilla-extract/css";
|
|
3
3
|
//#region src/lib/components/Button/ButtonLoader.css.ts
|
|
4
4
|
setFileScope("src/lib/components/Button/ButtonLoader.css.ts", "braid-design-system");
|
|
5
|
-
const
|
|
5
|
+
const spin = keyframes({ to: { transform: "rotate(360deg)" } }, "spin");
|
|
6
|
+
const loading = style({ animation: `${spin} 0.7s linear infinite` }, "loading");
|
|
6
7
|
endFileScope();
|
|
7
8
|
//#endregion
|
|
8
9
|
export { loading };
|
|
@@ -4,9 +4,10 @@ let react = require("react");
|
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
//#region src/lib/components/ButtonLink/ButtonLink.playroom.tsx
|
|
6
6
|
const ButtonLink = (0, react.forwardRef)(({ variant, ...restProps }, ref) => {
|
|
7
|
+
const isValidVariant = variant && require_Button.buttonVariants.indexOf(variant) > -1;
|
|
7
8
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ButtonLink.ButtonLink, {
|
|
8
9
|
ref,
|
|
9
|
-
variant:
|
|
10
|
+
variant: isValidVariant ? variant : void 0,
|
|
10
11
|
...restProps
|
|
11
12
|
});
|
|
12
13
|
});
|
|
@@ -4,9 +4,10 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/lib/components/ButtonLink/ButtonLink.playroom.tsx
|
|
6
6
|
const ButtonLink = forwardRef(({ variant, ...restProps }, ref) => {
|
|
7
|
+
const isValidVariant = variant && buttonVariants.indexOf(variant) > -1;
|
|
7
8
|
return /* @__PURE__ */ jsx(ButtonLink$1, {
|
|
8
9
|
ref,
|
|
9
|
-
variant:
|
|
10
|
+
variant: isValidVariant ? variant : void 0,
|
|
10
11
|
...restProps
|
|
11
12
|
});
|
|
12
13
|
});
|
|
@@ -3,8 +3,9 @@ const require_FieldMessage = require("./FieldMessage.cjs");
|
|
|
3
3
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
4
|
//#region src/lib/components/FieldMessage/FieldMessage.playroom.tsx
|
|
5
5
|
const FieldMessage = ({ id, tone, ...restProps }) => {
|
|
6
|
+
const resolvedId = require_useFallbackId.useFallbackId(id);
|
|
6
7
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldMessage.FieldMessage, {
|
|
7
|
-
id:
|
|
8
|
+
id: resolvedId,
|
|
8
9
|
tone: tone && require_FieldMessage.tones.indexOf(tone) > -1 ? tone : void 0,
|
|
9
10
|
...restProps
|
|
10
11
|
});
|
|
@@ -3,8 +3,9 @@ import { FieldMessage as FieldMessage$1, tones } from "./FieldMessage.mjs";
|
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/lib/components/FieldMessage/FieldMessage.playroom.tsx
|
|
5
5
|
const FieldMessage = ({ id, tone, ...restProps }) => {
|
|
6
|
+
const resolvedId = useFallbackId(id);
|
|
6
7
|
return /* @__PURE__ */ jsx(FieldMessage$1, {
|
|
7
|
-
id:
|
|
8
|
+
id: resolvedId,
|
|
8
9
|
tone: tone && tones.indexOf(tone) > -1 ? tone : void 0,
|
|
9
10
|
...restProps
|
|
10
11
|
});
|
|
@@ -8,7 +8,8 @@ let clsx = require("clsx");
|
|
|
8
8
|
clsx = require_runtime.__toESM(clsx, 1);
|
|
9
9
|
//#region src/lib/components/Link/Link.tsx
|
|
10
10
|
const Link = (0, react.forwardRef)(({ href, className, data, ...restProps }, ref) => {
|
|
11
|
-
|
|
11
|
+
const LinkComponent = require_BraidProvider.useLinkComponent(ref);
|
|
12
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LinkComponent, {
|
|
12
13
|
ref,
|
|
13
14
|
href,
|
|
14
15
|
className: (0, clsx.default)(require_atoms.atoms({ reset: "a" }), className),
|
|
@@ -6,7 +6,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
//#region src/lib/components/Link/Link.tsx
|
|
8
8
|
const Link = forwardRef(({ href, className, data, ...restProps }, ref) => {
|
|
9
|
-
|
|
9
|
+
const LinkComponent = useLinkComponent(ref);
|
|
10
|
+
return /* @__PURE__ */ jsx(LinkComponent, {
|
|
10
11
|
ref,
|
|
11
12
|
href,
|
|
12
13
|
className: clsx(atoms({ reset: "a" }), className),
|
|
@@ -13,11 +13,12 @@ const size = (0, _vanilla_extract_css.styleVariants)(require_vars_css.vars.textS
|
|
|
13
13
|
tablet: { height: tablet.fontSize }
|
|
14
14
|
}), "size");
|
|
15
15
|
const currentColor = (0, _vanilla_extract_css.style)({ fill: "currentcolor" }, "currentColor");
|
|
16
|
+
const bounce = (0, _vanilla_extract_css.keyframes)({
|
|
17
|
+
"33%": { transform: `translateY(-1.4em)` },
|
|
18
|
+
"66%": { transform: `translateY(1.4em)` }
|
|
19
|
+
}, "bounce");
|
|
16
20
|
const bounceAnimation = (0, _vanilla_extract_css.style)({
|
|
17
|
-
animationName:
|
|
18
|
-
"33%": { transform: `translateY(-1.4em)` },
|
|
19
|
-
"66%": { transform: `translateY(1.4em)` }
|
|
20
|
-
}, "bounce"),
|
|
21
|
+
animationName: bounce,
|
|
21
22
|
animationFillMode: "both",
|
|
22
23
|
animationIterationCount: "infinite",
|
|
23
24
|
animationTimingFunction: "ease-in-out",
|
|
@@ -27,7 +28,7 @@ const animationDelayInMs = 70;
|
|
|
27
28
|
const circle = (0, _vanilla_extract_css.style)([bounceAnimation, (0, _vanilla_extract_css.style)({
|
|
28
29
|
transform: `translateY(1.4em)`,
|
|
29
30
|
selectors: {
|
|
30
|
-
[`&:nth-child(1)`]: { animationDelay:
|
|
31
|
+
[`&:nth-child(1)`]: { animationDelay: `140ms` },
|
|
31
32
|
[`&:nth-child(2)`]: { animationDelay: `${animationDelayInMs}ms` }
|
|
32
33
|
}
|
|
33
34
|
}, "circle")], "circle");
|
|
@@ -13,11 +13,12 @@ const size = styleVariants(vars.textSize, ({ mobile, tablet }) => responsiveStyl
|
|
|
13
13
|
tablet: { height: tablet.fontSize }
|
|
14
14
|
}), "size");
|
|
15
15
|
const currentColor = style({ fill: "currentcolor" }, "currentColor");
|
|
16
|
+
const bounce = keyframes({
|
|
17
|
+
"33%": { transform: `translateY(-1.4em)` },
|
|
18
|
+
"66%": { transform: `translateY(1.4em)` }
|
|
19
|
+
}, "bounce");
|
|
16
20
|
const bounceAnimation = style({
|
|
17
|
-
animationName:
|
|
18
|
-
"33%": { transform: `translateY(-1.4em)` },
|
|
19
|
-
"66%": { transform: `translateY(1.4em)` }
|
|
20
|
-
}, "bounce"),
|
|
21
|
+
animationName: bounce,
|
|
21
22
|
animationFillMode: "both",
|
|
22
23
|
animationIterationCount: "infinite",
|
|
23
24
|
animationTimingFunction: "ease-in-out",
|
|
@@ -27,16 +28,17 @@ const animationDelayInMs = 70;
|
|
|
27
28
|
const circle = style([bounceAnimation, style({
|
|
28
29
|
transform: `translateY(1.4em)`,
|
|
29
30
|
selectors: {
|
|
30
|
-
[`&:nth-child(1)`]: { animationDelay:
|
|
31
|
+
[`&:nth-child(1)`]: { animationDelay: `140ms` },
|
|
31
32
|
[`&:nth-child(2)`]: { animationDelay: `${animationDelayInMs}ms` }
|
|
32
33
|
}
|
|
33
34
|
}, "circle")], "circle");
|
|
35
|
+
const fade = keyframes({
|
|
36
|
+
from: { opacity: 0 },
|
|
37
|
+
to: { opacity: 1 }
|
|
38
|
+
}, "fade");
|
|
34
39
|
const delay = style({
|
|
35
40
|
opacity: 0,
|
|
36
|
-
animationName:
|
|
37
|
-
from: { opacity: 0 },
|
|
38
|
-
to: { opacity: 1 }
|
|
39
|
-
}, "fade"),
|
|
41
|
+
animationName: fade,
|
|
40
42
|
animationIterationCount: "1",
|
|
41
43
|
animationFillMode: "forwards",
|
|
42
44
|
animationTimingFunction: "ease-in",
|
|
@@ -13,9 +13,10 @@ const validPageBlockComponents = [
|
|
|
13
13
|
"nav"
|
|
14
14
|
];
|
|
15
15
|
const PageBlock = ({ children, width = "large", component: componentProp, data, ...restProps }) => {
|
|
16
|
+
const component = componentProp && validPageBlockComponents.includes(componentProp) ? componentProp : "div";
|
|
16
17
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
17
18
|
width: "full",
|
|
18
|
-
component
|
|
19
|
+
component,
|
|
19
20
|
paddingX: require_pageBlockGutters.pageBlockGutters,
|
|
20
21
|
...require_buildDataAttributes.default({
|
|
21
22
|
data,
|
|
@@ -13,9 +13,10 @@ const validPageBlockComponents = [
|
|
|
13
13
|
"nav"
|
|
14
14
|
];
|
|
15
15
|
const PageBlock = ({ children, width = "large", component: componentProp, data, ...restProps }) => {
|
|
16
|
+
const component = componentProp && validPageBlockComponents.includes(componentProp) ? componentProp : "div";
|
|
16
17
|
return /* @__PURE__ */ jsx(Box, {
|
|
17
18
|
width: "full",
|
|
18
|
-
component
|
|
19
|
+
component,
|
|
19
20
|
paddingX: pageBlockGutters,
|
|
20
21
|
...buildDataAttributes_default({
|
|
21
22
|
data,
|
|
@@ -76,7 +76,7 @@ const tick = (0, _vanilla_extract_css.style)([
|
|
|
76
76
|
const progressBarGap = "xxsmall";
|
|
77
77
|
const dotSize = 2;
|
|
78
78
|
const progressTrack = (0, _vanilla_extract_css.style)({
|
|
79
|
-
background: `repeating-linear-gradient(90deg, ${baseColourVar}, ${baseColourVar} ${dotSize}px, transparent ${dotSize}px, transparent
|
|
79
|
+
background: `repeating-linear-gradient(90deg, ${baseColourVar}, ${baseColourVar} ${dotSize}px, transparent ${dotSize}px, transparent 4px)`,
|
|
80
80
|
height: require_vars_css.vars.borderWidth.large,
|
|
81
81
|
width: `${(0, _vanilla_extract_css_utils.calc)("100%").subtract(stepIndicatorSize).subtract((0, _vanilla_extract_css_utils.calc)(require_vars_css.vars.space[progressBarGap]).multiply(2))}`,
|
|
82
82
|
top: `${(0, _vanilla_extract_css_utils.calc)(stepIndicatorSize).subtract(require_vars_css.vars.borderWidth.large).divide(2)}`,
|
|
@@ -76,7 +76,7 @@ const tick = style([
|
|
|
76
76
|
const progressBarGap = "xxsmall";
|
|
77
77
|
const dotSize = 2;
|
|
78
78
|
const progressTrack = style({
|
|
79
|
-
background: `repeating-linear-gradient(90deg, ${baseColourVar}, ${baseColourVar} ${dotSize}px, transparent ${dotSize}px, transparent
|
|
79
|
+
background: `repeating-linear-gradient(90deg, ${baseColourVar}, ${baseColourVar} ${dotSize}px, transparent ${dotSize}px, transparent 4px)`,
|
|
80
80
|
height: vars.borderWidth.large,
|
|
81
81
|
width: `${calc("100%").subtract(stepIndicatorSize).subtract(calc(vars.space[progressBarGap]).multiply(2))}`,
|
|
82
82
|
top: `${calc(stepIndicatorSize).subtract(vars.borderWidth.large).divide(2)}`,
|
|
@@ -9,7 +9,8 @@ let react = require("react");
|
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
//#region src/lib/components/Table/TableBody.tsx
|
|
11
11
|
const TableBody = (0, react.forwardRef)(({ children, data, ...restProps }, ref) => {
|
|
12
|
-
|
|
12
|
+
const tableContext = (0, react.useContext)(require_TableContext.TableContext);
|
|
13
|
+
(0, assert.default)(tableContext, "TableBody must be used within a Table component");
|
|
13
14
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TableContext.TableBodyContext.Provider, {
|
|
14
15
|
value: true,
|
|
15
16
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
@@ -7,7 +7,8 @@ import { forwardRef, useContext } from "react";
|
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/lib/components/Table/TableBody.tsx
|
|
9
9
|
const TableBody = forwardRef(({ children, data, ...restProps }, ref) => {
|
|
10
|
-
|
|
10
|
+
const tableContext = useContext(TableContext);
|
|
11
|
+
assert(tableContext, "TableBody must be used within a Table component");
|
|
11
12
|
return /* @__PURE__ */ jsx(TableBodyContext.Provider, {
|
|
12
13
|
value: true,
|
|
13
14
|
children: /* @__PURE__ */ jsx(Box, {
|
|
@@ -93,7 +93,8 @@ const TableCell = (0, react.forwardRef)((props, ref) => {
|
|
|
93
93
|
});
|
|
94
94
|
const TableHeaderCell = (0, react.forwardRef)((props, ref) => {
|
|
95
95
|
const tableHeaderContext = (0, react.useContext)(require_TableContext.TableHeaderContext);
|
|
96
|
-
|
|
96
|
+
const tableRowContext = (0, react.useContext)(require_TableContext.TableRowContext);
|
|
97
|
+
(0, assert.default)(tableRowContext, "TableHeaderCell cannot be used outside a TableRow component");
|
|
97
98
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Cell, {
|
|
98
99
|
...props,
|
|
99
100
|
header: true,
|
|
@@ -91,7 +91,8 @@ const TableCell = forwardRef((props, ref) => {
|
|
|
91
91
|
});
|
|
92
92
|
const TableHeaderCell = forwardRef((props, ref) => {
|
|
93
93
|
const tableHeaderContext = useContext(TableHeaderContext);
|
|
94
|
-
|
|
94
|
+
const tableRowContext = useContext(TableRowContext);
|
|
95
|
+
assert(tableRowContext, "TableHeaderCell cannot be used outside a TableRow component");
|
|
95
96
|
return /* @__PURE__ */ jsx(Cell, {
|
|
96
97
|
...props,
|
|
97
98
|
header: true,
|
|
@@ -9,7 +9,8 @@ let react = require("react");
|
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
//#region src/lib/components/Table/TableFooter.tsx
|
|
11
11
|
const TableFooter = (0, react.forwardRef)(({ children, data, ...restProps }, ref) => {
|
|
12
|
-
|
|
12
|
+
const tableContext = (0, react.useContext)(require_TableContext.TableContext);
|
|
13
|
+
(0, assert.default)(tableContext, "TableFooter must be used within a Table component");
|
|
13
14
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TableContext.TableFooterContext.Provider, {
|
|
14
15
|
value: true,
|
|
15
16
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
@@ -7,7 +7,8 @@ import { forwardRef, useContext } from "react";
|
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/lib/components/Table/TableFooter.tsx
|
|
9
9
|
const TableFooter = forwardRef(({ children, data, ...restProps }, ref) => {
|
|
10
|
-
|
|
10
|
+
const tableContext = useContext(TableContext);
|
|
11
|
+
assert(tableContext, "TableFooter must be used within a Table component");
|
|
11
12
|
return /* @__PURE__ */ jsx(TableFooterContext.Provider, {
|
|
12
13
|
value: true,
|
|
13
14
|
children: /* @__PURE__ */ jsx(Box, {
|
|
@@ -9,7 +9,8 @@ let react = require("react");
|
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
//#region src/lib/components/Table/TableHeader.tsx
|
|
11
11
|
const TableHeader = (0, react.forwardRef)(({ children, data, ...restProps }, ref) => {
|
|
12
|
-
|
|
12
|
+
const tableContext = (0, react.useContext)(require_TableContext.TableContext);
|
|
13
|
+
(0, assert.default)(tableContext, "TableHeader must be used within a Table component");
|
|
13
14
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TableContext.TableHeaderContext.Provider, {
|
|
14
15
|
value: true,
|
|
15
16
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
@@ -7,7 +7,8 @@ import { forwardRef, useContext } from "react";
|
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/lib/components/Table/TableHeader.tsx
|
|
9
9
|
const TableHeader = forwardRef(({ children, data, ...restProps }, ref) => {
|
|
10
|
-
|
|
10
|
+
const tableContext = useContext(TableContext);
|
|
11
|
+
assert(tableContext, "TableHeader must be used within a Table component");
|
|
11
12
|
return /* @__PURE__ */ jsx(TableHeaderContext.Provider, {
|
|
12
13
|
value: true,
|
|
13
14
|
children: /* @__PURE__ */ jsx(Box, {
|