braid-design-system 32.23.1 → 32.24.0

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 CHANGED
@@ -1,5 +1,35 @@
1
1
  # braid-design-system
2
2
 
3
+ ## 32.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **Autosuggest**: Optimise automatic scrolling to selected suggestion by using native browser methods. ([#1571](https://github.com/seek-oss/braid-design-system/pull/1571))
8
+
9
+ ### Patch Changes
10
+
11
+ - **Stack, Tiles:** Deprecate `dividers` prop ([#1574](https://github.com/seek-oss/braid-design-system/pull/1574))
12
+
13
+ In preparation for migrating Braid layout components to use [CSS gap], the `dividers` prop has been deprecated on `Stack` and `Tiles`.
14
+
15
+ Consumers are encouraged to migrate now in advance of its removal in v33.
16
+
17
+ #### Migration Guide
18
+
19
+ See [the migration guide] for details on how to migrate off the `dividers` prop.
20
+
21
+ [CSS gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/gap
22
+ [migration guide]: https://github.com/seek-oss/braid-design-system/blob/master/docs/Removing%20dividers%20support%20from%20layout%20components.md
23
+
24
+ - **Autosuggest**: Improve handling of `suggestionHighlight` prop when set to `remaining` ([#1572](https://github.com/seek-oss/braid-design-system/pull/1572))
25
+
26
+ Fixes a bug in `Autosuggest` when using `suggestionHighlight` prop set to `remaining`.
27
+ If the input contained multiple words, the highlighted portion would be appended to the end of matching suggestions.
28
+
29
+ - **Divider:** Ensure full width in flex container ([#1574](https://github.com/seek-oss/braid-design-system/pull/1574))
30
+
31
+ Ensures the `Divider` component remains full width when used as a flex child inside a flex container.
32
+
3
33
  ## 32.23.1
4
34
 
5
35
  ### Patch Changes
@@ -17,11 +17,11 @@ const lib_components_private_getNextIndex_cjs = require("../private/getNextIndex
17
17
  const lib_components_private_normalizeKey_cjs = require("../private/normalizeKey.cjs");
18
18
  const lib_components_private_Field_ClearField_cjs = require("../private/Field/ClearField.cjs");
19
19
  const lib_components_private_smoothScroll_cjs = require("../private/smoothScroll.cjs");
20
- const lib_components_Autosuggest_useScrollIntoView_cjs = require("./useScrollIntoView.cjs");
21
20
  const lib_components_useResponsiveValue_useResponsiveValue_cjs = require("../useResponsiveValue/useResponsiveValue.cjs");
22
21
  const reactRemoveScroll = require("react-remove-scroll");
23
22
  const lib_components_Autosuggest_createAccessibilityProps_cjs = require("./createAccessibilityProps.cjs");
24
23
  const lib_translations_en_cjs = require("../../translations/en.cjs");
24
+ const lib_components_Autosuggest_reverseMatches_cjs = require("./reverseMatches.cjs");
25
25
  const lib_components_Autosuggest_Autosuggest_css_cjs = require("./Autosuggest.css.cjs");
26
26
  const lib_components_icons_IconClear_IconClear_cjs = require("../icons/IconClear/IconClear.cjs");
27
27
  const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
@@ -187,9 +187,9 @@ function normaliseNoSuggestionMessage(noSuggestionsMessage, suggestionProp) {
187
187
  }
188
188
  }
189
189
  function highlightSuggestions(suggestion, value, variant = "matching") {
190
- const matches = matchHighlights__default.default(suggestion, value);
191
- const formattedMatches = variant === "remaining" ? matches.map(([_, end]) => ({ start: end, end: suggestion.length })) : matches.map(([start, end]) => ({ start, end }));
192
- return formattedMatches;
190
+ const matchedHighlights = matchHighlights__default.default(suggestion, value);
191
+ const matches = variant === "matching" ? matchedHighlights : lib_components_Autosuggest_reverseMatches_cjs.reverseMatches(suggestion, matchedHighlights);
192
+ return matches.map(([start, end]) => ({ start, end }));
193
193
  }
194
194
  const Autosuggest = React.forwardRef(function({
195
195
  id,
@@ -370,7 +370,7 @@ const Autosuggest = React.forwardRef(function({
370
370
  });
371
371
  const isOpen = showSuggestionsIfAvailable && hasItems;
372
372
  const highlightedItem = typeof highlightedIndex === "number" ? document.getElementById(lib_components_Autosuggest_createAccessibilityProps_cjs.getItemId(id, highlightedIndex)) : null;
373
- lib_components_Autosuggest_useScrollIntoView_cjs.useScrollIntoView(highlightedItem, menuRef.current);
373
+ highlightedItem == null ? void 0 : highlightedItem.scrollIntoView({ block: "nearest" });
374
374
  React.useEffect(() => {
375
375
  dispatch({
376
376
  type: HAS_SUGGESTIONS_CHANGED
@@ -16,11 +16,11 @@ import { getNextIndex } from "../private/getNextIndex.mjs";
16
16
  import { normalizeKey } from "../private/normalizeKey.mjs";
17
17
  import { ClearField } from "../private/Field/ClearField.mjs";
18
18
  import { smoothScroll } from "../private/smoothScroll.mjs";
19
- import { useScrollIntoView } from "./useScrollIntoView.mjs";
20
19
  import { useResponsiveValue } from "../useResponsiveValue/useResponsiveValue.mjs";
21
20
  import { RemoveScroll } from "react-remove-scroll";
22
21
  import { getItemId, createAccessibilityProps } from "./createAccessibilityProps.mjs";
23
22
  import { autosuggest } from "../../translations/en.mjs";
23
+ import { reverseMatches } from "./reverseMatches.mjs";
24
24
  import { backdrop, backdropVisible, menu, groupHeading } from "./Autosuggest.css.mjs";
25
25
  import { IconClear } from "../icons/IconClear/IconClear.mjs";
26
26
  const INPUT_FOCUS = 0;
@@ -182,9 +182,9 @@ function normaliseNoSuggestionMessage(noSuggestionsMessage, suggestionProp) {
182
182
  }
183
183
  }
184
184
  function highlightSuggestions(suggestion, value, variant = "matching") {
185
- const matches = matchHighlights(suggestion, value);
186
- const formattedMatches = variant === "remaining" ? matches.map(([_, end]) => ({ start: end, end: suggestion.length })) : matches.map(([start, end]) => ({ start, end }));
187
- return formattedMatches;
185
+ const matchedHighlights = matchHighlights(suggestion, value);
186
+ const matches = variant === "matching" ? matchedHighlights : reverseMatches(suggestion, matchedHighlights);
187
+ return matches.map(([start, end]) => ({ start, end }));
188
188
  }
189
189
  const Autosuggest = forwardRef(function({
190
190
  id,
@@ -365,7 +365,7 @@ const Autosuggest = forwardRef(function({
365
365
  });
366
366
  const isOpen = showSuggestionsIfAvailable && hasItems;
367
367
  const highlightedItem = typeof highlightedIndex === "number" ? document.getElementById(getItemId(id, highlightedIndex)) : null;
368
- useScrollIntoView(highlightedItem, menuRef.current);
368
+ highlightedItem == null ? void 0 : highlightedItem.scrollIntoView({ block: "nearest" });
369
369
  useEffect(() => {
370
370
  dispatch({
371
371
  type: HAS_SUGGESTIONS_CHANGED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ function reverseMatches(suggestion, matches) {
3
+ const suggestionLength = suggestion.length;
4
+ const reversedMatches = [];
5
+ let currentStart = 0;
6
+ for (const [start, end] of matches) {
7
+ if (currentStart < start) {
8
+ reversedMatches.push([currentStart, start]);
9
+ }
10
+ currentStart = end;
11
+ }
12
+ if (currentStart < suggestionLength) {
13
+ reversedMatches.push([currentStart, suggestionLength]);
14
+ }
15
+ return reversedMatches;
16
+ }
17
+ exports.reverseMatches = reverseMatches;
@@ -0,0 +1,18 @@
1
+ function reverseMatches(suggestion, matches) {
2
+ const suggestionLength = suggestion.length;
3
+ const reversedMatches = [];
4
+ let currentStart = 0;
5
+ for (const [start, end] of matches) {
6
+ if (currentStart < start) {
7
+ reversedMatches.push([currentStart, start]);
8
+ }
9
+ currentStart = end;
10
+ }
11
+ if (currentStart < suggestionLength) {
12
+ reversedMatches.push([currentStart, suggestionLength]);
13
+ }
14
+ return reversedMatches;
15
+ }
16
+ export {
17
+ reverseMatches
18
+ };
@@ -5,12 +5,13 @@ const lib_components_Box_Box_cjs = require("../Box/Box.cjs");
5
5
  const lib_components_Divider_Divider_css_cjs = require("./Divider.css.cjs");
6
6
  const Divider = ({ weight = "regular" }) => {
7
7
  const lightness = lib_components_Box_BackgroundContext_cjs.useBackgroundLightness();
8
- return /* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { component: "span", display: "block", position: "relative", children: /* @__PURE__ */ jsxRuntime.jsx(
8
+ return /* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { component: "span", display: "block", position: "relative", width: "full", children: /* @__PURE__ */ jsxRuntime.jsx(
9
9
  lib_components_Box_Box_cjs.Box,
10
10
  {
11
11
  component: "span",
12
12
  position: "absolute",
13
- width: "full",
13
+ left: 0,
14
+ right: 0,
14
15
  className: [
15
16
  lib_components_Divider_Divider_css_cjs.base,
16
17
  weight === "strong" ? lib_components_Divider_Divider_css_cjs.strong : lib_components_Divider_Divider_css_cjs.regular,
@@ -4,12 +4,13 @@ import { Box } from "../Box/Box.mjs";
4
4
  import { base, strong, regular, lightModeWeight, darkModeWeight } from "./Divider.css.mjs";
5
5
  const Divider = ({ weight = "regular" }) => {
6
6
  const lightness = useBackgroundLightness();
7
- return /* @__PURE__ */ jsx(Box, { component: "span", display: "block", position: "relative", children: /* @__PURE__ */ jsx(
7
+ return /* @__PURE__ */ jsx(Box, { component: "span", display: "block", position: "relative", width: "full", children: /* @__PURE__ */ jsx(
8
8
  Box,
9
9
  {
10
10
  component: "span",
11
11
  position: "absolute",
12
- width: "full",
12
+ left: 0,
13
+ right: 0,
13
14
  className: [
14
15
  base,
15
16
  weight === "strong" ? strong : regular,
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
+ const dedent = require("dedent");
3
4
  const React = require("react");
4
5
  const lib_utils_flattenChildren_cjs = require("../../utils/flattenChildren.cjs");
5
6
  const assert = require("assert");
@@ -14,6 +15,7 @@ const lib_css_negativeMargin_negativeMargin_cjs = require("../../css/negativeMar
14
15
  const lib_css_atoms_sprinkles_css_cjs = require("../../css/atoms/sprinkles.css.cjs");
15
16
  const lib_components_private_buildDataAttributes_cjs = require("../private/buildDataAttributes.cjs");
16
17
  const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
18
+ const dedent__default = /* @__PURE__ */ _interopDefaultCompat(dedent);
17
19
  const assert__default = /* @__PURE__ */ _interopDefaultCompat(assert);
18
20
  const alignToDisplay = {
19
21
  left: "block",
@@ -62,7 +64,7 @@ const Stack = ({
62
64
  children,
63
65
  space = "none",
64
66
  align = "left",
65
- dividers = false,
67
+ dividers,
66
68
  data,
67
69
  ...restProps
68
70
  }) => {
@@ -70,6 +72,32 @@ const Stack = ({
70
72
  validStackComponents.includes(component),
71
73
  `Invalid Stack component: '${component}'. Should be one of [${validStackComponents.map((c) => `'${c}'`).join(", ")}]`
72
74
  );
75
+ if (process.env.NODE_ENV !== "production") {
76
+ if (typeof dividers !== "undefined") {
77
+ console.warn(
78
+ dedent__default.default`
79
+ The "dividers" prop is deprecated and will be removed in v33 to enable CSS gap in layout components.
80
+ Update your usage now to make upgrading easier by manually inserting "Divider" components as required:
81
+ %c- <Stack space="..." dividers>
82
+ %c+ <Stack space="...">
83
+ %c <Component>{item}</Component>
84
+ %c+ <Divider />
85
+ %c <Component>{item}</Component>****
86
+ %c+ <Divider />
87
+ %c <Component>{item}</Component>
88
+ </Stack>
89
+ See migration guide for details: https://github.com/seek-oss/braid-design-system/blob/master/docs/Removing%20dividers%20support%20from%20layout%20components.md
90
+ `,
91
+ "color: red",
92
+ "color: green",
93
+ "color: inherit",
94
+ "color: green",
95
+ "color: inherit",
96
+ "color: green",
97
+ "color: inherit"
98
+ );
99
+ }
100
+ }
73
101
  const stackItemProps = useStackItem({ space, align, component });
74
102
  const stackItems = lib_utils_flattenChildren_cjs.flattenChildren(children);
75
103
  const isList = component === "ol" || component === "ul";
@@ -1,4 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import dedent from "dedent";
2
3
  import { Children } from "react";
3
4
  import { flattenChildren } from "../../utils/flattenChildren.mjs";
4
5
  import assert from "assert";
@@ -59,7 +60,7 @@ const Stack = ({
59
60
  children,
60
61
  space = "none",
61
62
  align = "left",
62
- dividers = false,
63
+ dividers,
63
64
  data,
64
65
  ...restProps
65
66
  }) => {
@@ -67,6 +68,32 @@ const Stack = ({
67
68
  validStackComponents.includes(component),
68
69
  `Invalid Stack component: '${component}'. Should be one of [${validStackComponents.map((c) => `'${c}'`).join(", ")}]`
69
70
  );
71
+ if (process.env.NODE_ENV !== "production") {
72
+ if (typeof dividers !== "undefined") {
73
+ console.warn(
74
+ dedent`
75
+ The "dividers" prop is deprecated and will be removed in v33 to enable CSS gap in layout components.
76
+ Update your usage now to make upgrading easier by manually inserting "Divider" components as required:
77
+ %c- <Stack space="..." dividers>
78
+ %c+ <Stack space="...">
79
+ %c <Component>{item}</Component>
80
+ %c+ <Divider />
81
+ %c <Component>{item}</Component>****
82
+ %c+ <Divider />
83
+ %c <Component>{item}</Component>
84
+ </Stack>
85
+ See migration guide for details: https://github.com/seek-oss/braid-design-system/blob/master/docs/Removing%20dividers%20support%20from%20layout%20components.md
86
+ `,
87
+ "color: red",
88
+ "color: green",
89
+ "color: inherit",
90
+ "color: green",
91
+ "color: inherit",
92
+ "color: green",
93
+ "color: inherit"
94
+ );
95
+ }
96
+ }
70
97
  const stackItemProps = useStackItem({ space, align, component });
71
98
  const stackItems = flattenChildren(children);
72
99
  const isList = component === "ol" || component === "ul";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
+ const dedent = require("dedent");
3
4
  const React = require("react");
4
5
  const lib_utils_flattenChildren_cjs = require("../../utils/flattenChildren.cjs");
5
6
  const lib_components_Box_Box_cjs = require("../Box/Box.cjs");
@@ -9,61 +10,97 @@ const lib_utils_resolveResponsiveProp_cjs = require("../../utils/resolveResponsi
9
10
  const lib_components_Tiles_Tiles_css_cjs = require("./Tiles.css.cjs");
10
11
  const lib_css_atoms_sprinkles_css_cjs = require("../../css/atoms/sprinkles.css.cjs");
11
12
  const lib_components_private_buildDataAttributes_cjs = require("../private/buildDataAttributes.cjs");
13
+ const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
14
+ const dedent__default = /* @__PURE__ */ _interopDefaultCompat(dedent);
12
15
  const Tiles = ({
13
16
  children,
14
17
  space = "none",
15
18
  columns = 1,
16
- dividers = false,
19
+ dividers,
17
20
  data,
18
21
  ...restProps
19
- }) => /* @__PURE__ */ jsxRuntime.jsx(
20
- lib_components_Box_Box_cjs.Box,
21
- {
22
- className: lib_css_negativeMargin_negativeMargin_cjs.negativeMargin("top", space),
23
- ...lib_components_private_buildDataAttributes_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
24
- children: /* @__PURE__ */ jsxRuntime.jsx(
25
- lib_components_Box_Box_cjs.Box,
26
- {
27
- display: "flex",
28
- flexWrap: "wrap",
29
- className: lib_css_negativeMargin_negativeMargin_cjs.negativeMargin("left", space),
30
- children: React.Children.map(lib_utils_flattenChildren_cjs.flattenChildren(children), (child, i) => /* @__PURE__ */ jsxRuntime.jsx(
31
- lib_components_Box_Box_cjs.Box,
32
- {
33
- minWidth: 0,
34
- className: lib_utils_resolveResponsiveProp_cjs.resolveResponsiveProp(
35
- columns,
36
- lib_components_Tiles_Tiles_css_cjs.columnsMobile,
37
- lib_components_Tiles_Tiles_css_cjs.columnsTablet,
38
- lib_components_Tiles_Tiles_css_cjs.columnsDesktop,
39
- lib_components_Tiles_Tiles_css_cjs.columnsWide
40
- ),
41
- children: /* @__PURE__ */ jsxRuntime.jsxs(
42
- lib_components_Box_Box_cjs.Box,
43
- {
44
- height: "full",
45
- paddingTop: space,
46
- paddingLeft: space,
47
- children: [
48
- dividers && i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
49
- lib_components_Box_Box_cjs.Box,
50
- {
51
- paddingBottom: space,
52
- display: lib_css_atoms_sprinkles_css_cjs.mapResponsiveValue(
53
- columns,
54
- (column) => column === 1 ? "block" : "none"
55
- ),
56
- children: typeof dividers === "string" ? /* @__PURE__ */ jsxRuntime.jsx(lib_components_Divider_Divider_cjs.Divider, { weight: dividers }) : /* @__PURE__ */ jsxRuntime.jsx(lib_components_Divider_Divider_cjs.Divider, {})
57
- }
58
- ) : null,
59
- child
60
- ]
61
- }
62
- )
63
- }
64
- ))
65
- }
66
- )
22
+ }) => {
23
+ if (process.env.NODE_ENV !== "production") {
24
+ if (typeof dividers !== "undefined") {
25
+ console.warn(
26
+ dedent__default.default`
27
+ The "dividers" prop is deprecated and will be removed in v33 to enable CSS gap in layout components.
28
+ Update your usage now to make upgrading easier by manually inserting "Divider" components as required:
29
+ %c- <Tiles space="..." dividers>
30
+ %c+ <Tiles space="...">
31
+ %c <Component>{item}</Component>
32
+ %c+ <Stack space="...">
33
+ + <Hidden above="mobile"><Divider /></Hidden>
34
+ %c <Component>{item}</Component>
35
+ %c+ </Stack>
36
+ + <Stack space="...">
37
+ + <Hidden above="mobile"><Divider /></Hidden>
38
+ %c <Component>{item}</Component>
39
+ %c+ </Stack>
40
+ %c </Tiles>
41
+ See migration guide for details: https://github.com/seek-oss/braid-design-system/blob/master/docs/Removing%20dividers%20support%20from%20layout%20components.md
42
+ `,
43
+ "color: red",
44
+ "color: green",
45
+ "color: inherit",
46
+ "color: green",
47
+ "color: inherit",
48
+ "color: green",
49
+ "color: inherit",
50
+ "color: green",
51
+ "color: inherit"
52
+ );
53
+ }
67
54
  }
68
- );
55
+ return /* @__PURE__ */ jsxRuntime.jsx(
56
+ lib_components_Box_Box_cjs.Box,
57
+ {
58
+ className: lib_css_negativeMargin_negativeMargin_cjs.negativeMargin("top", space),
59
+ ...lib_components_private_buildDataAttributes_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
60
+ children: /* @__PURE__ */ jsxRuntime.jsx(
61
+ lib_components_Box_Box_cjs.Box,
62
+ {
63
+ display: "flex",
64
+ flexWrap: "wrap",
65
+ className: lib_css_negativeMargin_negativeMargin_cjs.negativeMargin("left", space),
66
+ children: React.Children.map(lib_utils_flattenChildren_cjs.flattenChildren(children), (child, i) => /* @__PURE__ */ jsxRuntime.jsx(
67
+ lib_components_Box_Box_cjs.Box,
68
+ {
69
+ minWidth: 0,
70
+ className: lib_utils_resolveResponsiveProp_cjs.resolveResponsiveProp(
71
+ columns,
72
+ lib_components_Tiles_Tiles_css_cjs.columnsMobile,
73
+ lib_components_Tiles_Tiles_css_cjs.columnsTablet,
74
+ lib_components_Tiles_Tiles_css_cjs.columnsDesktop,
75
+ lib_components_Tiles_Tiles_css_cjs.columnsWide
76
+ ),
77
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
78
+ lib_components_Box_Box_cjs.Box,
79
+ {
80
+ height: "full",
81
+ paddingTop: space,
82
+ paddingLeft: space,
83
+ children: [
84
+ dividers && i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
85
+ lib_components_Box_Box_cjs.Box,
86
+ {
87
+ paddingBottom: space,
88
+ display: lib_css_atoms_sprinkles_css_cjs.mapResponsiveValue(
89
+ columns,
90
+ (column) => column === 1 ? "block" : "none"
91
+ ),
92
+ children: typeof dividers === "string" ? /* @__PURE__ */ jsxRuntime.jsx(lib_components_Divider_Divider_cjs.Divider, { weight: dividers }) : /* @__PURE__ */ jsxRuntime.jsx(lib_components_Divider_Divider_cjs.Divider, {})
93
+ }
94
+ ) : null,
95
+ child
96
+ ]
97
+ }
98
+ )
99
+ }
100
+ ))
101
+ }
102
+ )
103
+ }
104
+ );
105
+ };
69
106
  exports.Tiles = Tiles;
@@ -1,4 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import dedent from "dedent";
2
3
  import { Children } from "react";
3
4
  import { flattenChildren } from "../../utils/flattenChildren.mjs";
4
5
  import { Box } from "../Box/Box.mjs";
@@ -12,59 +13,93 @@ const Tiles = ({
12
13
  children,
13
14
  space = "none",
14
15
  columns = 1,
15
- dividers = false,
16
+ dividers,
16
17
  data,
17
18
  ...restProps
18
- }) => /* @__PURE__ */ jsx(
19
- Box,
20
- {
21
- className: negativeMargin("top", space),
22
- ...buildDataAttributes({ data, validateRestProps: restProps }),
23
- children: /* @__PURE__ */ jsx(
24
- Box,
25
- {
26
- display: "flex",
27
- flexWrap: "wrap",
28
- className: negativeMargin("left", space),
29
- children: Children.map(flattenChildren(children), (child, i) => /* @__PURE__ */ jsx(
30
- Box,
31
- {
32
- minWidth: 0,
33
- className: resolveResponsiveProp(
34
- columns,
35
- columnsMobile,
36
- columnsTablet,
37
- columnsDesktop,
38
- columnsWide
39
- ),
40
- children: /* @__PURE__ */ jsxs(
41
- Box,
42
- {
43
- height: "full",
44
- paddingTop: space,
45
- paddingLeft: space,
46
- children: [
47
- dividers && i > 0 ? /* @__PURE__ */ jsx(
48
- Box,
49
- {
50
- paddingBottom: space,
51
- display: mapResponsiveValue(
52
- columns,
53
- (column) => column === 1 ? "block" : "none"
54
- ),
55
- children: typeof dividers === "string" ? /* @__PURE__ */ jsx(Divider, { weight: dividers }) : /* @__PURE__ */ jsx(Divider, {})
56
- }
57
- ) : null,
58
- child
59
- ]
60
- }
61
- )
62
- }
63
- ))
64
- }
65
- )
19
+ }) => {
20
+ if (process.env.NODE_ENV !== "production") {
21
+ if (typeof dividers !== "undefined") {
22
+ console.warn(
23
+ dedent`
24
+ The "dividers" prop is deprecated and will be removed in v33 to enable CSS gap in layout components.
25
+ Update your usage now to make upgrading easier by manually inserting "Divider" components as required:
26
+ %c- <Tiles space="..." dividers>
27
+ %c+ <Tiles space="...">
28
+ %c <Component>{item}</Component>
29
+ %c+ <Stack space="...">
30
+ + <Hidden above="mobile"><Divider /></Hidden>
31
+ %c <Component>{item}</Component>
32
+ %c+ </Stack>
33
+ + <Stack space="...">
34
+ + <Hidden above="mobile"><Divider /></Hidden>
35
+ %c <Component>{item}</Component>
36
+ %c+ </Stack>
37
+ %c </Tiles>
38
+ See migration guide for details: https://github.com/seek-oss/braid-design-system/blob/master/docs/Removing%20dividers%20support%20from%20layout%20components.md
39
+ `,
40
+ "color: red",
41
+ "color: green",
42
+ "color: inherit",
43
+ "color: green",
44
+ "color: inherit",
45
+ "color: green",
46
+ "color: inherit",
47
+ "color: green",
48
+ "color: inherit"
49
+ );
50
+ }
66
51
  }
67
- );
52
+ return /* @__PURE__ */ jsx(
53
+ Box,
54
+ {
55
+ className: negativeMargin("top", space),
56
+ ...buildDataAttributes({ data, validateRestProps: restProps }),
57
+ children: /* @__PURE__ */ jsx(
58
+ Box,
59
+ {
60
+ display: "flex",
61
+ flexWrap: "wrap",
62
+ className: negativeMargin("left", space),
63
+ children: Children.map(flattenChildren(children), (child, i) => /* @__PURE__ */ jsx(
64
+ Box,
65
+ {
66
+ minWidth: 0,
67
+ className: resolveResponsiveProp(
68
+ columns,
69
+ columnsMobile,
70
+ columnsTablet,
71
+ columnsDesktop,
72
+ columnsWide
73
+ ),
74
+ children: /* @__PURE__ */ jsxs(
75
+ Box,
76
+ {
77
+ height: "full",
78
+ paddingTop: space,
79
+ paddingLeft: space,
80
+ children: [
81
+ dividers && i > 0 ? /* @__PURE__ */ jsx(
82
+ Box,
83
+ {
84
+ paddingBottom: space,
85
+ display: mapResponsiveValue(
86
+ columns,
87
+ (column) => column === 1 ? "block" : "none"
88
+ ),
89
+ children: typeof dividers === "string" ? /* @__PURE__ */ jsx(Divider, { weight: dividers }) : /* @__PURE__ */ jsx(Divider, {})
90
+ }
91
+ ) : null,
92
+ child
93
+ ]
94
+ }
95
+ )
96
+ }
97
+ ))
98
+ }
99
+ )
100
+ }
101
+ );
102
+ };
68
103
  export {
69
104
  Tiles
70
105
  };
@@ -3313,6 +3313,14 @@ interface StackProps {
3313
3313
  children: ReactNodeNoStrings;
3314
3314
  space: ResponsiveSpace;
3315
3315
  align?: OptionalResponsiveValue<Align>;
3316
+ /**
3317
+ * @deprecated Will be removed in v33 to enable [CSS gap] in layout components.
3318
+ *
3319
+ * See [migration guide] for details.
3320
+ *
3321
+ * [CSS gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/gap
3322
+ * [migration guide]: https://github.com/seek-oss/braid-design-system/blob/master/docs/Removing%20dividers%20support%20from%20layout%20components.md
3323
+ * */
3316
3324
  dividers?: boolean | DividerProps['weight'];
3317
3325
  data?: DataAttributeMap;
3318
3326
  }
@@ -3918,6 +3926,14 @@ interface TilesProps {
3918
3926
  children: ReactNodeNoStrings;
3919
3927
  space: RequiredResponsiveValue$1<Space>;
3920
3928
  columns: RequiredResponsiveValue$1<1 | 2 | 3 | 4 | 5 | 6>;
3929
+ /**
3930
+ * @deprecated Will be removed in v33 to enable [CSS gap] in layout components.
3931
+ *
3932
+ * See [migration guide] for details.
3933
+ *
3934
+ * [CSS gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/gap
3935
+ * [migration guide]: https://github.com/seek-oss/braid-design-system/blob/master/docs/Removing%20dividers%20support%20from%20layout%20components.md
3936
+ * */
3921
3937
  dividers?: boolean | DividerProps['weight'];
3922
3938
  data?: DataAttributeMap;
3923
3939
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-design-system",
3
- "version": "32.23.1",
3
+ "version": "32.24.0",
4
4
  "description": "Themeable design system for the SEEK Group",
5
5
  "homepage": "https://seek-oss.github.io/braid-design-system/",
6
6
  "bugs": {
@@ -220,13 +220,13 @@
220
220
  "fast-glob": "^3.2.12",
221
221
  "fs-extra": "^10.1.0",
222
222
  "html-validate": "^7.1.1",
223
- "playroom": "0.38.0",
223
+ "playroom": "0.38.1",
224
224
  "prettier": "^2.8.8",
225
225
  "react": "^18.3.1",
226
226
  "react-dom": "^18.3.1",
227
227
  "react-router-dom": "^6.3.0",
228
228
  "sanitize-html": "^2.12.1",
229
- "sku": "13.1.0",
229
+ "sku": "13.1.2",
230
230
  "storybook": "7.6.20",
231
231
  "svgo": "^2.8.0",
232
232
  "title-case": "^3.0.3",
@@ -1,19 +0,0 @@
1
- "use strict";
2
- const React = require("react");
3
- function useScrollIntoView(element, scrollContainer) {
4
- React.useEffect(() => {
5
- if (scrollContainer && element) {
6
- const itemOffsetRelativeToContainer = element.offsetParent === scrollContainer ? element.offsetTop : element.offsetTop - scrollContainer.offsetTop;
7
- let { scrollTop } = scrollContainer;
8
- if (itemOffsetRelativeToContainer < scrollTop) {
9
- scrollTop = itemOffsetRelativeToContainer;
10
- } else if (itemOffsetRelativeToContainer + element.offsetHeight > scrollTop + scrollContainer.offsetHeight) {
11
- scrollTop = itemOffsetRelativeToContainer + element.offsetHeight - scrollContainer.offsetHeight;
12
- }
13
- if (scrollTop !== scrollContainer.scrollTop) {
14
- scrollContainer.scrollTop = scrollTop;
15
- }
16
- }
17
- }, [scrollContainer, element]);
18
- }
19
- exports.useScrollIntoView = useScrollIntoView;
@@ -1,20 +0,0 @@
1
- import { useEffect } from "react";
2
- function useScrollIntoView(element, scrollContainer) {
3
- useEffect(() => {
4
- if (scrollContainer && element) {
5
- const itemOffsetRelativeToContainer = element.offsetParent === scrollContainer ? element.offsetTop : element.offsetTop - scrollContainer.offsetTop;
6
- let { scrollTop } = scrollContainer;
7
- if (itemOffsetRelativeToContainer < scrollTop) {
8
- scrollTop = itemOffsetRelativeToContainer;
9
- } else if (itemOffsetRelativeToContainer + element.offsetHeight > scrollTop + scrollContainer.offsetHeight) {
10
- scrollTop = itemOffsetRelativeToContainer + element.offsetHeight - scrollContainer.offsetHeight;
11
- }
12
- if (scrollTop !== scrollContainer.scrollTop) {
13
- scrollContainer.scrollTop = scrollTop;
14
- }
15
- }
16
- }, [scrollContainer, element]);
17
- }
18
- export {
19
- useScrollIntoView
20
- };