@guardian/stand 0.0.46 → 0.0.48

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.
@@ -8,18 +8,26 @@ react = require_runtime.__toESM(react);
8
8
  let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
9
9
  let react_aria_components = require("react-aria-components");
10
10
  //#region src/components/Select/Select.tsx
11
- function Option({ children, theme = {} }) {
11
+ function Option({ children, theme = {}, id, ...props }) {
12
+ const mergedTheme = require_mergeDeep.mergeDeep(require_styles.defaultSelectTheme, theme);
13
+ const resolvedId = id ?? children;
12
14
  return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.ListBoxItem, {
13
- css: require_styles.listBoxItemStyles(require_mergeDeep.mergeDeep(require_styles.defaultSelectTheme, theme)),
15
+ css: require_styles.listBoxItemStyles(mergedTheme),
16
+ id: resolvedId,
17
+ ...props,
14
18
  children
15
19
  });
16
20
  }
17
21
  function ListBox({ children, theme = {} }) {
18
22
  const mergedTheme = require_mergeDeep.mergeDeep(require_styles.defaultSelectTheme, theme);
19
23
  const items = [];
20
- react.default.Children.forEach(children, (child, i) => {
24
+ react.default.Children.forEach(children, (child, index) => {
21
25
  if (!react.default.isValidElement(child)) return;
22
- if (child.type === Option) items.push(react.default.cloneElement(child, { key: `${child.key}-${i}` }));
26
+ if (child.type === Option) {
27
+ const optionChild = child;
28
+ const key = `${optionChild.props.id ?? optionChild.props.children}-${index}`;
29
+ items.push(react.default.cloneElement(optionChild, { key }));
30
+ }
23
31
  });
24
32
  return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.ListBox, {
25
33
  css: require_styles.listBoxStyles(mergedTheme),
@@ -40,7 +48,9 @@ function Select({ isInvalid, theme = {}, children, ...props }) {
40
48
  size: "lg"
41
49
  })]
42
50
  }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Popover, {
43
- css: require_styles.popoverStyles(mergedTheme),
51
+ css: require_styles.popoverStyles(),
52
+ offset: mergedTheme.shared.offset,
53
+ containerPadding: mergedTheme.shared.containerPadding,
44
54
  children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ListBox, { children })
45
55
  })]
46
56
  });
@@ -3,7 +3,9 @@ import { OptionProps, SelectProps } from "./types.cjs";
3
3
  //#region src/components/Select/Select.d.ts
4
4
  declare function Option({
5
5
  children,
6
- theme
6
+ theme,
7
+ id,
8
+ ...props
7
9
  }: OptionProps): import("@emotion/react/jsx-runtime").JSX.Element;
8
10
  declare function Select({
9
11
  isInvalid,
@@ -3,7 +3,9 @@ import { OptionProps, SelectProps } from "./types.js";
3
3
  //#region src/components/Select/Select.d.ts
4
4
  declare function Option({
5
5
  children,
6
- theme
6
+ theme,
7
+ id,
8
+ ...props
7
9
  }: OptionProps): import("@emotion/react/jsx-runtime").JSX.Element;
8
10
  declare function Select({
9
11
  isInvalid,
@@ -6,18 +6,26 @@ import React from "react";
6
6
  import { jsx, jsxs } from "@emotion/react/jsx-runtime";
7
7
  import { Button, ListBox, ListBoxItem, Popover, Select, SelectValue } from "react-aria-components";
8
8
  //#region src/components/Select/Select.tsx
9
- function Option({ children, theme = {} }) {
9
+ function Option({ children, theme = {}, id, ...props }) {
10
+ const mergedTheme = mergeDeep(defaultSelectTheme, theme);
11
+ const resolvedId = id ?? children;
10
12
  return /* @__PURE__ */ jsx(ListBoxItem, {
11
- css: listBoxItemStyles(mergeDeep(defaultSelectTheme, theme)),
13
+ css: listBoxItemStyles(mergedTheme),
14
+ id: resolvedId,
15
+ ...props,
12
16
  children
13
17
  });
14
18
  }
15
19
  function ListBox$1({ children, theme = {} }) {
16
20
  const mergedTheme = mergeDeep(defaultSelectTheme, theme);
17
21
  const items = [];
18
- React.Children.forEach(children, (child, i) => {
22
+ React.Children.forEach(children, (child, index) => {
19
23
  if (!React.isValidElement(child)) return;
20
- if (child.type === Option) items.push(React.cloneElement(child, { key: `${child.key}-${i}` }));
24
+ if (child.type === Option) {
25
+ const optionChild = child;
26
+ const key = `${optionChild.props.id ?? optionChild.props.children}-${index}`;
27
+ items.push(React.cloneElement(optionChild, { key }));
28
+ }
21
29
  });
22
30
  return /* @__PURE__ */ jsx(ListBox, {
23
31
  css: listBoxStyles(mergedTheme),
@@ -38,7 +46,9 @@ function Select$1({ isInvalid, theme = {}, children, ...props }) {
38
46
  size: "lg"
39
47
  })]
40
48
  }), /* @__PURE__ */ jsx(Popover, {
41
- css: popoverStyles(mergedTheme),
49
+ css: popoverStyles(),
50
+ offset: mergedTheme.shared.offset,
51
+ containerPadding: mergedTheme.shared.containerPadding,
42
52
  children: /* @__PURE__ */ jsx(ListBox$1, { children })
43
53
  })]
44
54
  });
@@ -3,9 +3,10 @@ const require_select = require("../../styleD/build/typescript/component/select.c
3
3
  let _emotion_react = require("@emotion/react");
4
4
  //#region src/components/Select/styles.ts
5
5
  const defaultSelectTheme = require_select.componentSelect;
6
- const popoverStyles = (theme) => {
6
+ const popoverStyles = () => {
7
7
  return _emotion_react.css`
8
- width: ${theme.shared.width};
8
+ /* width must be determined by the react-aria popover --trigger-width variable */
9
+ width: var(--trigger-width);
9
10
  `;
10
11
  };
11
12
  const listBoxItemStyles = (theme) => {
@@ -3,9 +3,10 @@ import { componentSelect } from "../../styleD/build/typescript/component/select.
3
3
  import { css } from "@emotion/react";
4
4
  //#region src/components/Select/styles.ts
5
5
  const defaultSelectTheme = componentSelect;
6
- const popoverStyles = (theme) => {
6
+ const popoverStyles = () => {
7
7
  return css`
8
- width: ${theme.shared.width};
8
+ /* width must be determined by the react-aria popover --trigger-width variable */
9
+ width: var(--trigger-width);
9
10
  `;
10
11
  };
11
12
  const listBoxItemStyles = (theme) => {
@@ -4,7 +4,7 @@ import { SelectTheme } from "./styles.cjs";
4
4
  import { ListBoxItemProps, SelectProps } from "react-aria-components";
5
5
 
6
6
  //#region src/components/Select/types.d.ts
7
- interface OptionProps extends DefaultPropsWithChildren<SelectTheme, ListBoxItemProps['className']>, Omit<ListBoxItemProps, 'children'> {}
7
+ interface OptionProps extends DefaultPropsWithChildren<SelectTheme, ListBoxItemProps['className'], string>, Omit<ListBoxItemProps, 'children'> {}
8
8
  type SelectProps$1 = FormInputContainerDefaultProps<SelectProps<object, 'single' | 'multiple'>, SelectTheme>;
9
9
  //#endregion
10
10
  export { OptionProps, SelectProps$1 as SelectProps };
@@ -4,7 +4,7 @@ import { SelectTheme } from "./styles.js";
4
4
  import { ListBoxItemProps, SelectProps } from "react-aria-components";
5
5
 
6
6
  //#region src/components/Select/types.d.ts
7
- interface OptionProps extends DefaultPropsWithChildren<SelectTheme, ListBoxItemProps['className']>, Omit<ListBoxItemProps, 'children'> {}
7
+ interface OptionProps extends DefaultPropsWithChildren<SelectTheme, ListBoxItemProps['className'], string>, Omit<ListBoxItemProps, 'children'> {}
8
8
  type SelectProps$1 = FormInputContainerDefaultProps<SelectProps<object, 'single' | 'multiple'>, SelectTheme>;
9
9
  //#endregion
10
10
  export { OptionProps, SelectProps$1 as SelectProps };
@@ -4,6 +4,8 @@
4
4
 
5
5
  :root {
6
6
  --component-select-shared-width: 100%;
7
+ --component-select-shared-offset: 8;
8
+ --component-select-shared-container-padding: 0;
7
9
  --component-select-shared-hover-background-color: #f6f6f6;
8
10
  --component-select-shared-hover-outline: none; /** Override outline focus styles on hover */
9
11
  --component-select-shared-pressed-background-color: #ededed;
@@ -4,6 +4,8 @@
4
4
  */
5
5
  const componentSelect = { shared: {
6
6
  width: "100%",
7
+ offset: 8,
8
+ containerPadding: 0,
7
9
  hover: {
8
10
  backgroundColor: "#f6f6f6",
9
11
  outline: "none"
@@ -5,6 +5,8 @@
5
5
  declare const componentSelect: {
6
6
  shared: {
7
7
  width: string;
8
+ offset: number;
9
+ containerPadding: number;
8
10
  hover: {
9
11
  backgroundColor: string;
10
12
  outline: string;
@@ -5,6 +5,8 @@
5
5
  declare const componentSelect: {
6
6
  shared: {
7
7
  width: string;
8
+ offset: number;
9
+ containerPadding: number;
8
10
  hover: {
9
11
  backgroundColor: string;
10
12
  outline: string;
@@ -4,6 +4,8 @@
4
4
  */
5
5
  const componentSelect = { shared: {
6
6
  width: "100%",
7
+ offset: 8,
8
+ containerPadding: 0,
7
9
  hover: {
8
10
  backgroundColor: "#f6f6f6",
9
11
  outline: "none"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/stand",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "repository": {
5
5
  "url": "https://github.com/guardian/stand"
6
6
  },
@@ -503,14 +503,14 @@
503
503
  },
504
504
  "peerDependencies": {
505
505
  "@emotion/react": ">=11.11.4 <=11.14.0",
506
- "@guardian/prosemirror-invisibles": "3.1.1",
506
+ "@guardian/prosemirror-invisibles": "^3.1.1",
507
507
  "@internationalized/date": "^3.12.1",
508
- "prosemirror-dropcursor": "1.8.2",
509
- "prosemirror-history": "1.4.1",
510
- "prosemirror-keymap": "1.2.2",
511
- "prosemirror-model": "1.25.0",
512
- "prosemirror-state": "1.4.3",
513
- "prosemirror-view": "1.37.2",
508
+ "prosemirror-dropcursor": "^1.8.2",
509
+ "prosemirror-history": "^1.4.1",
510
+ "prosemirror-keymap": "^1.2.2",
511
+ "prosemirror-model": "^1.25.0",
512
+ "prosemirror-state": "^1.4.3",
513
+ "prosemirror-view": "^1.37.2",
514
514
  "react": "^17.0.2 || ^18.0.0 || ^19.0.0",
515
515
  "react-aria-components": ">= 1.13.0 <= 1.18.0",
516
516
  "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0",