@gnist/design-system 3.8.4 → 3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/components/actions/chips/ActionChip.cjs +4 -4
  3. package/dist/components/actions/chips/ActionChip.d.ts +1 -1
  4. package/dist/components/actions/chips/ActionChip.d.ts.map +1 -1
  5. package/dist/components/actions/chips/ActionChip.js +4 -4
  6. package/dist/components/actions/chips/FilterChip.cjs +4 -4
  7. package/dist/components/actions/chips/FilterChip.d.ts +1 -1
  8. package/dist/components/actions/chips/FilterChip.d.ts.map +1 -1
  9. package/dist/components/actions/chips/FilterChip.js +4 -4
  10. package/dist/components/actions/chips/TagChip.cjs +4 -4
  11. package/dist/components/actions/chips/TagChip.d.ts +1 -1
  12. package/dist/components/actions/chips/TagChip.d.ts.map +1 -1
  13. package/dist/components/actions/chips/TagChip.js +4 -4
  14. package/dist/components/actions/index.cjs +2 -0
  15. package/dist/components/actions/index.js +2 -0
  16. package/dist/components/actions/selectionControls/Checkbox.cjs +5 -5
  17. package/dist/components/actions/selectionControls/Checkbox.d.ts +5 -2
  18. package/dist/components/actions/selectionControls/Checkbox.d.ts.map +1 -1
  19. package/dist/components/actions/selectionControls/Checkbox.js +5 -5
  20. package/dist/components/actions/selectionControls/RadioButton.cjs +5 -5
  21. package/dist/components/actions/selectionControls/RadioButton.d.ts +5 -2
  22. package/dist/components/actions/selectionControls/RadioButton.d.ts.map +1 -1
  23. package/dist/components/actions/selectionControls/RadioButton.js +5 -5
  24. package/dist/components/actions/selectionControls/Switch.cjs +49 -0
  25. package/dist/components/actions/selectionControls/Switch.d.ts +17 -0
  26. package/dist/components/actions/selectionControls/Switch.d.ts.map +1 -0
  27. package/dist/components/actions/selectionControls/Switch.js +49 -0
  28. package/dist/components/actions/selectionControls/index.cjs +2 -0
  29. package/dist/components/actions/selectionControls/index.d.ts +1 -0
  30. package/dist/components/actions/selectionControls/index.d.ts.map +1 -1
  31. package/dist/components/actions/selectionControls/index.js +3 -1
  32. package/dist/components/actions/selectionControls/switch.css.cjs +165 -0
  33. package/dist/components/actions/selectionControls/switch.css.d.ts +46 -0
  34. package/dist/components/actions/selectionControls/switch.css.d.ts.map +1 -0
  35. package/dist/components/actions/selectionControls/switch.css.js +165 -0
  36. package/dist/components/index.cjs +2 -0
  37. package/dist/components/index.js +2 -0
  38. package/dist/components/inputs/dropdowns/MultiSelect.cjs +3 -4
  39. package/dist/components/inputs/dropdowns/MultiSelect.d.ts +1 -1
  40. package/dist/components/inputs/dropdowns/MultiSelect.d.ts.map +1 -1
  41. package/dist/components/inputs/dropdowns/MultiSelect.js +3 -4
  42. package/dist/components/inputs/dropdowns/SelectBase.cjs +9 -7
  43. package/dist/components/inputs/dropdowns/SelectBase.d.ts +1 -2
  44. package/dist/components/inputs/dropdowns/SelectBase.d.ts.map +1 -1
  45. package/dist/components/inputs/dropdowns/SelectBase.js +9 -7
  46. package/dist/components/inputs/dropdowns/SingleSelect.cjs +3 -4
  47. package/dist/components/inputs/dropdowns/SingleSelect.d.ts +1 -1
  48. package/dist/components/inputs/dropdowns/SingleSelect.d.ts.map +1 -1
  49. package/dist/components/inputs/dropdowns/SingleSelect.js +3 -4
  50. package/dist/components/inputs/pickers/calendar.cjs +9 -7
  51. package/dist/components/inputs/pickers/calendar.d.ts +3 -1
  52. package/dist/components/inputs/pickers/calendar.d.ts.map +1 -1
  53. package/dist/components/inputs/pickers/calendar.js +10 -8
  54. package/dist/components/inputs/textFields/TextArea.cjs +5 -5
  55. package/dist/components/inputs/textFields/TextArea.d.ts +3 -17
  56. package/dist/components/inputs/textFields/TextArea.d.ts.map +1 -1
  57. package/dist/components/inputs/textFields/TextArea.js +5 -5
  58. package/dist/components/inputs/textFields/TextField.cjs +5 -5
  59. package/dist/components/inputs/textFields/TextField.d.ts +5 -3
  60. package/dist/components/inputs/textFields/TextField.d.ts.map +1 -1
  61. package/dist/components/inputs/textFields/TextField.js +5 -5
  62. package/dist/components/surfaces/modal/Modal.cjs +10 -5
  63. package/dist/components/surfaces/modal/Modal.js +10 -5
  64. package/dist/foundation/typography/index.d.ts +2 -4
  65. package/dist/foundation/typography/index.d.ts.map +1 -1
  66. package/dist/index.cjs +2 -0
  67. package/dist/index.js +2 -0
  68. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.9.1](https://github.com/mollerdigital/design-system-design-system/compare/@gnist/design-system@3.9.0...@gnist/design-system@3.9.1) (2025-09-02)
7
+
8
+ **Note:** Version bump only for package @gnist/design-system
9
+
10
+ ## [3.9.0](https://github.com/mollerdigital/design-system-design-system/compare/@gnist/design-system@3.8.4...@gnist/design-system@3.9.0) (2025-08-29)
11
+
12
+ ### Features
13
+
14
+ * add switch component ([76b8479](https://github.com/mollerdigital/design-system-design-system/commit/76b8479b9652d74257b9eae8e9a82fc68ee4ada5))
15
+
6
16
  ## [3.8.4](https://github.com/mollerdigital/design-system-design-system/compare/@gnist/design-system@3.8.3...@gnist/design-system@3.8.4) (2025-08-27)
7
17
 
8
18
  **Note:** Version bump only for package @gnist/design-system
@@ -7,7 +7,7 @@ require("../../../foundation/iconography/IconVariantProvider.cjs");
7
7
  require("../../../foundation/iconography/icons.cjs");
8
8
  const Icon = require("../../../foundation/iconography/Icon.cjs");
9
9
  const index = require("../../../foundation/typography/index.cjs");
10
- const React = require("react");
10
+ require("react");
11
11
  const classNames = require("classnames");
12
12
  require("../../../foundation/logos/Logo.css.cjs");
13
13
  const animations_css = require("../../../styles/animations.css.cjs");
@@ -18,7 +18,7 @@ const styles_css$1 = require("./styles.css.cjs");
18
18
  const styles_css = require("../buttons/styles.css.cjs");
19
19
  const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
20
20
  const classNames__default = /* @__PURE__ */ _interopDefaultCompat(classNames);
21
- const ActionChip = React.forwardRef(function ActionChip2({ label, onClick, selected, icon, loading, density = "default", ...props }, ref) {
21
+ function ActionChip({ label, onClick, selected, icon, loading, density = "default", ...props }) {
22
22
  return jsxRuntime.jsx("button", { type: "button", ...props, title: label, onClick, className: classNames__default.default(styles_css$1.chipRecipe({
23
23
  selected,
24
24
  filterVariant: false,
@@ -28,6 +28,6 @@ const ActionChip = React.forwardRef(function ActionChip2({ label, onClick, selec
28
28
  borderRadius: "full",
29
29
  backgroundColor: "on-background",
30
30
  setFocusState: true
31
- })), ref, children: loading?.isLoading ? jsxRuntime.jsx(Spinner.Spinner, { diameter: density === "compact" ? tokens_css_js.tokens.size.xs : tokens_css_js.tokens.size.s, textDescription: loading.loadingText }) : jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [icon && jsxRuntime.jsx(Icon.Icon, { icon, size: density === "compact" ? "m" : "l" }), jsxRuntime.jsx(index.BodyText, { className: styles_css.actionText, children: label })] }) });
32
- });
31
+ })), children: loading?.isLoading ? jsxRuntime.jsx(Spinner.Spinner, { diameter: density === "compact" ? tokens_css_js.tokens.size.xs : tokens_css_js.tokens.size.s, textDescription: loading.loadingText }) : jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [icon && jsxRuntime.jsx(Icon.Icon, { icon, size: density === "compact" ? "m" : "l" }), jsxRuntime.jsx(index.BodyText, { className: styles_css.actionText, children: label })] }) });
32
+ }
33
33
  exports.ActionChip = ActionChip;
@@ -27,5 +27,5 @@ export interface ActionChipProps extends ComponentPropsWithRef<"button"> {
27
27
 
28
28
  Documentation: [ActionChip](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-chips-actionchip--docs)
29
29
  **/
30
- export declare const ActionChip: import("react").ForwardRefExoticComponent<Omit<ActionChipProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
30
+ export declare function ActionChip({ label, onClick, selected, icon, loading, density, ...props }: ActionChipProps): import("react/jsx-runtime").JSX.Element;
31
31
  //# sourceMappingURL=ActionChip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionChip.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/chips/ActionChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAGf,qCAAiD;AAQlD,OAAO,EACH,qBAAqB,EAGrB,iBAAiB,EACpB,MAAM,OAAO,CAAC;AAKf,MAAM,WAAW,eAAgB,SAAQ,qBAAqB,CAAC,QAAQ,CAAC;IACpE,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,oBAAoB;IACpB,OAAO,CAAC,EAAE;QACN,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,2BAA2B;IAC3B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;;;;IASI;AACJ,eAAO,MAAM,UAAU,4HAuDrB,CAAC"}
1
+ {"version":3,"file":"ActionChip.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/chips/ActionChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAGf,qCAAiD;AAQlD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKjE,MAAM,WAAW,eAAgB,SAAQ,qBAAqB,CAAC,QAAQ,CAAC;IACpE,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,oBAAoB;IACpB,OAAO,CAAC,EAAE;QACN,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,2BAA2B;IAC3B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;;;;IASI;AACJ,wBAAgB,UAAU,CAAC,EACvB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,OAAmB,EACnB,GAAG,KAAK,EACX,EAAE,eAAe,2CA2CjB"}
@@ -5,7 +5,7 @@ import "../../../foundation/iconography/IconVariantProvider.js";
5
5
  import "../../../foundation/iconography/icons.js";
6
6
  import { Icon } from "../../../foundation/iconography/Icon.js";
7
7
  import { BodyText } from "../../../foundation/typography/index.js";
8
- import { forwardRef } from "react";
8
+ import "react";
9
9
  import classNames from "classnames";
10
10
  import "../../../foundation/logos/Logo.css.js";
11
11
  import { clickAnimation } from "../../../styles/animations.css.js";
@@ -14,7 +14,7 @@ import { tokens } from "@gnist/themes/tokens.css.js";
14
14
  import { Spinner } from "../../progress/Spinner.js";
15
15
  import { chipRecipe } from "./styles.css.js";
16
16
  import { actionText } from "../buttons/styles.css.js";
17
- const ActionChip = forwardRef(function ActionChip2({ label, onClick, selected, icon, loading, density = "default", ...props }, ref) {
17
+ function ActionChip({ label, onClick, selected, icon, loading, density = "default", ...props }) {
18
18
  return jsx("button", { type: "button", ...props, title: label, onClick, className: classNames(chipRecipe({
19
19
  selected,
20
20
  filterVariant: false,
@@ -24,8 +24,8 @@ const ActionChip = forwardRef(function ActionChip2({ label, onClick, selected, i
24
24
  borderRadius: "full",
25
25
  backgroundColor: "on-background",
26
26
  setFocusState: true
27
- })), ref, children: loading?.isLoading ? jsx(Spinner, { diameter: density === "compact" ? tokens.size.xs : tokens.size.s, textDescription: loading.loadingText }) : jsxs(Fragment, { children: [icon && jsx(Icon, { icon, size: density === "compact" ? "m" : "l" }), jsx(BodyText, { className: actionText, children: label })] }) });
28
- });
27
+ })), children: loading?.isLoading ? jsx(Spinner, { diameter: density === "compact" ? tokens.size.xs : tokens.size.s, textDescription: loading.loadingText }) : jsxs(Fragment, { children: [icon && jsx(Icon, { icon, size: density === "compact" ? "m" : "l" }), jsx(BodyText, { className: actionText, children: label })] }) });
28
+ }
29
29
  export {
30
30
  ActionChip
31
31
  };
@@ -7,7 +7,7 @@ require("../../../foundation/iconography/IconVariantProvider.cjs");
7
7
  require("../../../foundation/iconography/icons.cjs");
8
8
  const Icon = require("../../../foundation/iconography/Icon.cjs");
9
9
  const index = require("../../../foundation/typography/index.cjs");
10
- const React = require("react");
10
+ require("react");
11
11
  const classNames = require("classnames");
12
12
  require("../../../foundation/logos/Logo.css.cjs");
13
13
  const animations_css = require("../../../styles/animations.css.cjs");
@@ -18,7 +18,7 @@ const styles_css$1 = require("./styles.css.cjs");
18
18
  const styles_css = require("../buttons/styles.css.cjs");
19
19
  const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
20
20
  const classNames__default = /* @__PURE__ */ _interopDefaultCompat(classNames);
21
- const FilterChip = React.forwardRef(function FilterChip2({ label, onClick, selected, loading, density = "default", icon, ...props }, ref) {
21
+ function FilterChip({ label, onClick, selected, loading, density = "default", icon, ...props }) {
22
22
  return jsxRuntime.jsxs("button", { type: "button", ...props, title: label, onClick, className: classNames__default.default(styles_css$1.chipRecipe({
23
23
  selected,
24
24
  filterVariant: true,
@@ -28,6 +28,6 @@ const FilterChip = React.forwardRef(function FilterChip2({ label, onClick, selec
28
28
  borderRadius: "full",
29
29
  backgroundColor: "on-background",
30
30
  setFocusState: true
31
- })), ref, children: [(icon || selected) && !loading?.isLoading && jsxRuntime.jsx(Icon.Icon, { icon: selected ? "check" : icon }), loading?.isLoading ? jsxRuntime.jsx(Spinner.Spinner, { diameter: density === "compact" ? tokens_css_js.tokens.size.xs : tokens_css_js.tokens.size.s, textDescription: loading.loadingText }) : jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(index.BodyText, { className: styles_css.actionText, children: label }) })] });
32
- });
31
+ })), children: [(icon || selected) && !loading?.isLoading && jsxRuntime.jsx(Icon.Icon, { icon: selected ? "check" : icon }), loading?.isLoading ? jsxRuntime.jsx(Spinner.Spinner, { diameter: density === "compact" ? tokens_css_js.tokens.size.xs : tokens_css_js.tokens.size.s, textDescription: loading.loadingText }) : jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(index.BodyText, { className: styles_css.actionText, children: label }) })] });
32
+ }
33
33
  exports.FilterChip = FilterChip;
@@ -24,6 +24,6 @@ interface FilterChipProps extends ComponentPropsWithRef<"button"> {
24
24
 
25
25
  Documentation: [FilterChip](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-chips-filterchip--docs)
26
26
  **/
27
- export declare const FilterChip: import("react").ForwardRefExoticComponent<Omit<FilterChipProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
27
+ export declare function FilterChip({ label, onClick, selected, loading, density, icon, ...props }: FilterChipProps): import("react/jsx-runtime").JSX.Element;
28
28
  export {};
29
29
  //# sourceMappingURL=FilterChip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterChip.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/chips/FilterChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAGf,qCAAiD;AAQlD,OAAO,EAAE,qBAAqB,EAA4B,MAAM,OAAO,CAAC;AAKxE,UAAU,eAAgB,SAAQ,qBAAqB,CAAC,QAAQ,CAAC;IAC7D,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB;IACpB,OAAO,CAAC,EAAE;QACN,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,8BAA8B;IAC9B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,sCAAsC;IACtC,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;IAMI;AAEJ,eAAO,MAAM,UAAU,4HA0DrB,CAAC"}
1
+ {"version":3,"file":"FilterChip.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/chips/FilterChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAGf,qCAAiD;AAQlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAK9C,UAAU,eAAgB,SAAQ,qBAAqB,CAAC,QAAQ,CAAC;IAC7D,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB;IACpB,OAAO,CAAC,EAAE;QACN,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,8BAA8B;IAC9B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,sCAAsC;IACtC,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;IAMI;AAEJ,wBAAgB,UAAU,CAAC,EACvB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAmB,EACnB,IAAI,EACJ,GAAG,KAAK,EACX,EAAE,eAAe,2CA8CjB"}
@@ -5,7 +5,7 @@ import "../../../foundation/iconography/IconVariantProvider.js";
5
5
  import "../../../foundation/iconography/icons.js";
6
6
  import { Icon } from "../../../foundation/iconography/Icon.js";
7
7
  import { BodyText } from "../../../foundation/typography/index.js";
8
- import { forwardRef } from "react";
8
+ import "react";
9
9
  import classNames from "classnames";
10
10
  import "../../../foundation/logos/Logo.css.js";
11
11
  import { clickAnimation } from "../../../styles/animations.css.js";
@@ -14,7 +14,7 @@ import { tokens } from "@gnist/themes/tokens.css.js";
14
14
  import { Spinner } from "../../progress/Spinner.js";
15
15
  import { chipRecipe } from "./styles.css.js";
16
16
  import { actionText } from "../buttons/styles.css.js";
17
- const FilterChip = forwardRef(function FilterChip2({ label, onClick, selected, loading, density = "default", icon, ...props }, ref) {
17
+ function FilterChip({ label, onClick, selected, loading, density = "default", icon, ...props }) {
18
18
  return jsxs("button", { type: "button", ...props, title: label, onClick, className: classNames(chipRecipe({
19
19
  selected,
20
20
  filterVariant: true,
@@ -24,8 +24,8 @@ const FilterChip = forwardRef(function FilterChip2({ label, onClick, selected, l
24
24
  borderRadius: "full",
25
25
  backgroundColor: "on-background",
26
26
  setFocusState: true
27
- })), ref, children: [(icon || selected) && !loading?.isLoading && jsx(Icon, { icon: selected ? "check" : icon }), loading?.isLoading ? jsx(Spinner, { diameter: density === "compact" ? tokens.size.xs : tokens.size.s, textDescription: loading.loadingText }) : jsx(Fragment, { children: jsx(BodyText, { className: actionText, children: label }) })] });
28
- });
27
+ })), children: [(icon || selected) && !loading?.isLoading && jsx(Icon, { icon: selected ? "check" : icon }), loading?.isLoading ? jsx(Spinner, { diameter: density === "compact" ? tokens.size.xs : tokens.size.s, textDescription: loading.loadingText }) : jsx(Fragment, { children: jsx(BodyText, { className: actionText, children: label }) })] });
28
+ }
29
29
  export {
30
30
  FilterChip
31
31
  };
@@ -7,7 +7,7 @@ require("../../../foundation/iconography/IconVariantProvider.cjs");
7
7
  require("../../../foundation/iconography/icons.cjs");
8
8
  const Icon = require("../../../foundation/iconography/Icon.cjs");
9
9
  const index = require("../../../foundation/typography/index.cjs");
10
- const React = require("react");
10
+ require("react");
11
11
  const classNames = require("classnames");
12
12
  require("../../../foundation/logos/Logo.css.cjs");
13
13
  const animations_css = require("../../../styles/animations.css.cjs");
@@ -16,12 +16,12 @@ const styles_css$1 = require("./styles.css.cjs");
16
16
  const styles_css = require("../buttons/styles.css.cjs");
17
17
  const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
18
18
  const classNames__default = /* @__PURE__ */ _interopDefaultCompat(classNames);
19
- const TagChip = React.forwardRef(function TagChip2({ label, onClick, icon, density = "default", ...props }, ref) {
19
+ function TagChip({ label, onClick, icon, density = "default", ...props }) {
20
20
  return jsxRuntime.jsxs("button", { type: "button", ...props, title: label, onClick, className: classNames__default.default(styles_css$1.chipRecipe(), animations_css.clickAnimation, states_css.focusStyle, states_css.stateLayers({
21
21
  borderSize: "medium",
22
22
  borderRadius: "full",
23
23
  backgroundColor: "on-background",
24
24
  setFocusState: true
25
- })), ref, children: [icon && jsxRuntime.jsx(Icon.Icon, { icon, size: density === "compact" ? "m" : "l" }), jsxRuntime.jsx(index.BodyText, { className: styles_css.actionText, children: label }), jsxRuntime.jsx(Icon.Icon, { icon: "clear", size: density === "compact" ? "m" : "l" })] });
26
- });
25
+ })), children: [icon && jsxRuntime.jsx(Icon.Icon, { icon, size: density === "compact" ? "m" : "l" }), jsxRuntime.jsx(index.BodyText, { className: styles_css.actionText, children: label }), jsxRuntime.jsx(Icon.Icon, { icon: "clear", size: density === "compact" ? "m" : "l" })] });
26
+ }
27
27
  exports.TagChip = TagChip;
@@ -17,6 +17,6 @@ interface TagChipProps extends ComponentPropsWithRef<"button"> {
17
17
 
18
18
  Documentation: [TagChip](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-chips-tagchip--docs)
19
19
  **/
20
- export declare const TagChip: import("react").ForwardRefExoticComponent<Omit<TagChipProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
20
+ export declare function TagChip({ label, onClick, icon, density, ...props }: TagChipProps): import("react/jsx-runtime").JSX.Element;
21
21
  export {};
22
22
  //# sourceMappingURL=TagChip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TagChip.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/chips/TagChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAGf,qCAAiD;AAOlD,OAAO,EACH,qBAAqB,EAGrB,iBAAiB,EACpB,MAAM,OAAO,CAAC;AAIf,UAAU,YAAa,SAAQ,qBAAqB,CAAC,QAAQ,CAAC;IAC1D,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C,sCAAsC;IACtC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;IAMI;AAEJ,eAAO,MAAM,OAAO,yHA8BlB,CAAC"}
1
+ {"version":3,"file":"TagChip.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/chips/TagChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAGf,qCAAiD;AAOlD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAIjE,UAAU,YAAa,SAAQ,qBAAqB,CAAC,QAAQ,CAAC;IAC1D,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C,sCAAsC;IACtC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;IAMI;AAEJ,wBAAgB,OAAO,CAAC,EACpB,KAAK,EACL,OAAO,EACP,IAAI,EACJ,OAAmB,EACnB,GAAG,KAAK,EACX,EAAE,YAAY,2CA0Bd"}
@@ -5,21 +5,21 @@ import "../../../foundation/iconography/IconVariantProvider.js";
5
5
  import "../../../foundation/iconography/icons.js";
6
6
  import { Icon } from "../../../foundation/iconography/Icon.js";
7
7
  import { BodyText } from "../../../foundation/typography/index.js";
8
- import { forwardRef } from "react";
8
+ import "react";
9
9
  import classNames from "classnames";
10
10
  import "../../../foundation/logos/Logo.css.js";
11
11
  import { clickAnimation } from "../../../styles/animations.css.js";
12
12
  import { focusStyle, stateLayers } from "../../../styles/states.css.js";
13
13
  import { chipRecipe } from "./styles.css.js";
14
14
  import { actionText } from "../buttons/styles.css.js";
15
- const TagChip = forwardRef(function TagChip2({ label, onClick, icon, density = "default", ...props }, ref) {
15
+ function TagChip({ label, onClick, icon, density = "default", ...props }) {
16
16
  return jsxs("button", { type: "button", ...props, title: label, onClick, className: classNames(chipRecipe(), clickAnimation, focusStyle, stateLayers({
17
17
  borderSize: "medium",
18
18
  borderRadius: "full",
19
19
  backgroundColor: "on-background",
20
20
  setFocusState: true
21
- })), ref, children: [icon && jsx(Icon, { icon, size: density === "compact" ? "m" : "l" }), jsx(BodyText, { className: actionText, children: label }), jsx(Icon, { icon: "clear", size: density === "compact" ? "m" : "l" })] });
22
- });
21
+ })), children: [icon && jsx(Icon, { icon, size: density === "compact" ? "m" : "l" }), jsx(BodyText, { className: actionText, children: label }), jsx(Icon, { icon: "clear", size: density === "compact" ? "m" : "l" })] });
22
+ }
23
23
  export {
24
24
  TagChip
25
25
  };
@@ -10,6 +10,7 @@ const TextButton = require("./buttons/TextButton.cjs");
10
10
  const IconButton = require("./buttons/IconButton.cjs");
11
11
  const Checkbox = require("./selectionControls/Checkbox.cjs");
12
12
  const RadioButton = require("./selectionControls/RadioButton.cjs");
13
+ const Switch = require("./selectionControls/Switch.cjs");
13
14
  const ActionChip = require("./chips/ActionChip.cjs");
14
15
  const FilterChip = require("./chips/FilterChip.cjs");
15
16
  const TagChip = require("./chips/TagChip.cjs");
@@ -22,6 +23,7 @@ exports.TextButton = TextButton.TextButton;
22
23
  exports.IconButton = IconButton.IconButton;
23
24
  exports.Checkbox = Checkbox.Checkbox;
24
25
  exports.RadioButton = RadioButton.RadioButton;
26
+ exports.Switch = Switch.Switch;
25
27
  exports.ActionChip = ActionChip.ActionChip;
26
28
  exports.FilterChip = FilterChip.FilterChip;
27
29
  exports.TagChip = TagChip.TagChip;
@@ -8,6 +8,7 @@ import { TextButton } from "./buttons/TextButton.js";
8
8
  import { IconButton } from "./buttons/IconButton.js";
9
9
  import { Checkbox } from "./selectionControls/Checkbox.js";
10
10
  import { RadioButton } from "./selectionControls/RadioButton.js";
11
+ import { Switch } from "./selectionControls/Switch.js";
11
12
  import { ActionChip } from "./chips/ActionChip.js";
12
13
  import { FilterChip } from "./chips/FilterChip.js";
13
14
  import { TagChip } from "./chips/TagChip.js";
@@ -22,6 +23,7 @@ export {
22
23
  RadioButton,
23
24
  SecondaryButton,
24
25
  SuccessButton,
26
+ Switch,
25
27
  TagChip,
26
28
  TextButton
27
29
  };
@@ -6,7 +6,6 @@ const InputHelperText = require("../../../building-blocks/inputs/InputHelperText
6
6
  const ScreenReaderOnly = require("../../../utilities/accessibility/ScreenReaderOnly.cjs");
7
7
  require("../../../utilities/accessibility/visuallyHidden.css.cjs");
8
8
  const index = require("../../../utilities/html/index.cjs");
9
- const React = require("react");
10
9
  require("../../../foundation/iconography/ExtraIconsProvider.cjs");
11
10
  require("../../../foundation/iconography/IconVariantProvider.cjs");
12
11
  require("../../../foundation/iconography/icons.cjs");
@@ -21,7 +20,7 @@ const CustomCheckbox = ({ value, disabled }) => {
21
20
  return jsxRuntime.jsx("span", { className: ` ${checkbox_css.checkbox({ disabled })}`, "aria-hidden": true, children: value !== "indeterminate" ? jsxRuntime.jsx(Icon.Icon, { icon: "check", size: "s" }) : jsxRuntime.jsx(Icon.Icon, { icon: "remove", size: "s" }) });
22
21
  };
23
22
  const defaultRender = (checkbox2, description) => jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [checkbox2, jsxRuntime.jsx("div", { className: shared_css.indentedDescriptionStyle, children: description })] });
24
- const Checkbox = React.forwardRef(function Checkbox2({
23
+ function Checkbox({
25
24
  label,
26
25
  description,
27
26
  value,
@@ -35,8 +34,9 @@ const Checkbox = React.forwardRef(function Checkbox2({
35
34
  render = defaultRender,
36
35
  // Input element props
37
36
  onBlur,
37
+ ref,
38
38
  ...rest
39
- }, ref) {
39
+ }) {
40
40
  const inputId = id;
41
41
  const labelId = `${id}-label`;
42
42
  const helperId = `${id}-helper`;
@@ -51,6 +51,6 @@ const Checkbox = React.forwardRef(function Checkbox2({
51
51
  disabled,
52
52
  validity: validity?.type === "error" ? "error" : void 0
53
53
  }), children: jsxRuntime.jsx(CustomCheckbox, { value, disabled }) }), hideLabel ? jsxRuntime.jsx(ScreenReaderOnly.ScreenReaderOnly, { children: label }) : jsxRuntime.jsx("span", { className: shared_css.LabelStyle, children: label })] }) });
54
- return jsxRuntime.jsx(shared.HelperTextWrapper, { ...helperTextProps, children: render(checkboxElement, descriptionElement) });
55
- });
54
+ return jsxRuntime.jsx(shared.HelperTextWrapper, { ...helperTextProps, children: render && render(checkboxElement, descriptionElement) });
55
+ }
56
56
  exports.Checkbox = Checkbox;
@@ -1,5 +1,8 @@
1
+ import { Ref } from "react";
1
2
  import { SelectionControlProps } from "./shared.js";
2
- export type CheckboxProps = SelectionControlProps<boolean | "indeterminate">;
3
+ export type CheckboxProps = SelectionControlProps<boolean | "indeterminate"> & {
4
+ ref?: Ref<HTMLSpanElement>;
5
+ };
3
6
  /**
4
7
  *
5
8
  * Checkboxes allow users to select one or more items from a list. They may also be used as a way to have the users indicate they agree to terms and services.
@@ -8,5 +11,5 @@ export type CheckboxProps = SelectionControlProps<boolean | "indeterminate">;
8
11
 
9
12
  Documentation: [Checkbox](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-selectioncontrols-checkbox--docs)
10
13
  */
11
- export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLSpanElement>>;
14
+ export declare function Checkbox({ label, description, value, onChange, disabled, validity, id, hideLabel, canShowErrorMessage, className, render, onBlur, ref, ...rest }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
12
15
  //# sourceMappingURL=Checkbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/Checkbox.tsx"],"names":[],"mappings":"AAcA,OAAO,EAEH,qBAAqB,EAExB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG,qBAAqB,CAAC,OAAO,GAAG,eAAe,CAAC,CAAC;AA+B7E;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,yBAAyB,CAClD,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,CA6EtD,CAAC"}
1
+ {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/Checkbox.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAU5B,OAAO,EAEH,qBAAqB,EAExB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG,qBAAqB,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG;IAC3E,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;CAC9B,CAAC;AA+BF;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,EACrB,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,EAA6B,EAC7B,SAAiB,EACjB,mBAA2B,EAC3B,SAAS,EACT,MAAsB,EAEtB,MAAM,EACN,GAAG,EACH,GAAG,IAAI,EACV,EAAE,aAAa,2CA0Df"}
@@ -4,7 +4,6 @@ import { useInputHelperText } from "../../../building-blocks/inputs/InputHelperT
4
4
  import { ScreenReaderOnly } from "../../../utilities/accessibility/ScreenReaderOnly.js";
5
5
  import "../../../utilities/accessibility/visuallyHidden.css.js";
6
6
  import { createValidHtmlId } from "../../../utilities/html/index.js";
7
- import { forwardRef } from "react";
8
7
  import "../../../foundation/iconography/ExtraIconsProvider.js";
9
8
  import "../../../foundation/iconography/IconVariantProvider.js";
10
9
  import "../../../foundation/iconography/icons.js";
@@ -19,7 +18,7 @@ const CustomCheckbox = ({ value, disabled }) => {
19
18
  return jsx("span", { className: ` ${checkbox({ disabled })}`, "aria-hidden": true, children: value !== "indeterminate" ? jsx(Icon, { icon: "check", size: "s" }) : jsx(Icon, { icon: "remove", size: "s" }) });
20
19
  };
21
20
  const defaultRender = (checkbox2, description) => jsxs(Fragment, { children: [checkbox2, jsx("div", { className: indentedDescriptionStyle, children: description })] });
22
- const Checkbox = forwardRef(function Checkbox2({
21
+ function Checkbox({
23
22
  label,
24
23
  description,
25
24
  value,
@@ -33,8 +32,9 @@ const Checkbox = forwardRef(function Checkbox2({
33
32
  render = defaultRender,
34
33
  // Input element props
35
34
  onBlur,
35
+ ref,
36
36
  ...rest
37
- }, ref) {
37
+ }) {
38
38
  const inputId = id;
39
39
  const labelId = `${id}-label`;
40
40
  const helperId = `${id}-helper`;
@@ -49,8 +49,8 @@ const Checkbox = forwardRef(function Checkbox2({
49
49
  disabled,
50
50
  validity: validity?.type === "error" ? "error" : void 0
51
51
  }), children: jsx(CustomCheckbox, { value, disabled }) }), hideLabel ? jsx(ScreenReaderOnly, { children: label }) : jsx("span", { className: LabelStyle, children: label })] }) });
52
- return jsx(HelperTextWrapper, { ...helperTextProps, children: render(checkboxElement, descriptionElement) });
53
- });
52
+ return jsx(HelperTextWrapper, { ...helperTextProps, children: render && render(checkboxElement, descriptionElement) });
53
+ }
54
54
  export {
55
55
  Checkbox
56
56
  };
@@ -7,7 +7,6 @@ const ScreenReaderOnly = require("../../../utilities/accessibility/ScreenReaderO
7
7
  require("../../../utilities/accessibility/visuallyHidden.css.cjs");
8
8
  const index = require("../../../utilities/html/index.cjs");
9
9
  const classNames = require("classnames");
10
- const React = require("react");
11
10
  const radiobutton_css = require("./radiobutton.css.cjs");
12
11
  const shared_css = require("./shared.css.cjs");
13
12
  const shared = require("./shared.cjs");
@@ -24,7 +23,7 @@ const CustomRadioButton = ({ value, disabled, validity }) => {
24
23
  }) }) });
25
24
  };
26
25
  const defaultRender = (radio, description) => jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [radio, jsxRuntime.jsx("div", { className: shared_css.indentedDescriptionStyle, children: description })] });
27
- const RadioButton = React.forwardRef(function RadioButton2({
26
+ function RadioButton({
28
27
  value,
29
28
  onChange,
30
29
  disabled,
@@ -36,9 +35,10 @@ const RadioButton = React.forwardRef(function RadioButton2({
36
35
  canShowErrorMessage = false,
37
36
  className,
38
37
  render = defaultRender,
38
+ ref,
39
39
  // Input element props
40
40
  ...rest
41
- }, ref) {
41
+ }) {
42
42
  const inputId = id;
43
43
  const labelId = `${id}-label`;
44
44
  const helperId = `${id}-helper`;
@@ -49,6 +49,6 @@ const RadioButton = React.forwardRef(function RadioButton2({
49
49
  });
50
50
  const radioButtonElement = jsxRuntime.jsx("span", { className: classNames__default.default(shared_css.InputWrapper, className), ref, children: jsxRuntime.jsxs("label", { htmlFor: inputId, className: shared_css.LabelRecipe({ disabled }), id: labelId, children: [jsxRuntime.jsx("input", { type: "radio", id: inputId, disabled, onChange, checked: value === true, className: shared_css.InputStyleRecipe({ disabled }), tabIndex: 0, ...inputAriaProps, ...rest }), jsxRuntime.jsx(CustomRadioButton, { value, disabled, validity }), hideLabel ? jsxRuntime.jsx(ScreenReaderOnly.ScreenReaderOnly, { children: label }) : jsxRuntime.jsx("span", { className: shared_css.LabelStyle, children: label })] }) });
51
51
  const descriptionElement = description ? jsxRuntime.jsx(shared.SelectionDescription, { disabled, children: description }) : void 0;
52
- return jsxRuntime.jsx(shared.HelperTextWrapper, { ...helperTextProps, children: render(radioButtonElement, descriptionElement) });
53
- });
52
+ return jsxRuntime.jsx(shared.HelperTextWrapper, { ...helperTextProps, children: render && render(radioButtonElement, descriptionElement) });
53
+ }
54
54
  exports.RadioButton = RadioButton;
@@ -1,5 +1,8 @@
1
+ import { Ref } from "react";
1
2
  import { SelectionControlProps } from "./shared.js";
2
- export type RadioButtonProps = SelectionControlProps<boolean>;
3
+ export type RadioButtonProps = SelectionControlProps<boolean> & {
4
+ ref?: Ref<HTMLSpanElement>;
5
+ };
3
6
  /**
4
7
  * Radio buttons allow users to select one option from a list. Use radio buttons when the user needs to see all available options. If available options can be collapsed, consider using a dropdown menu because it uses less space.
5
8
  *
@@ -7,5 +10,5 @@ export type RadioButtonProps = SelectionControlProps<boolean>;
7
10
 
8
11
  Documentation: [RadioButton](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-selectioncontrols-radiobutton--docs)
9
12
  **/
10
- export declare const RadioButton: React.ForwardRefExoticComponent<Omit<RadioButtonProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
13
+ export declare function RadioButton({ value, onChange, disabled, validity, label, description, id, hideLabel, canShowErrorMessage, className, render, ref, ...rest }: RadioButtonProps): import("react/jsx-runtime").JSX.Element;
11
14
  //# sourceMappingURL=RadioButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/RadioButton.tsx"],"names":[],"mappings":"AAcA,OAAO,EAEH,qBAAqB,EAExB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAqC9D;;;;;;GAMG;AAEH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,yBAAyB,CACrD,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,CAuEtE,CAAC"}
1
+ {"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/RadioButton.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAS5B,OAAO,EAEH,qBAAqB,EAExB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,OAAO,CAAC,GAAG;IAC5D,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;CAC9B,CAAC;AAqCF;;;;;;GAMG;AAEH,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,WAAW,EACX,EAA6B,EAC7B,SAAiB,EACjB,mBAA2B,EAC3B,SAAS,EACT,MAAsB,EACtB,GAAG,EAEH,GAAG,IAAI,EACV,EAAE,gBAAgB,2CAqDlB"}
@@ -5,7 +5,6 @@ import { ScreenReaderOnly } from "../../../utilities/accessibility/ScreenReaderO
5
5
  import "../../../utilities/accessibility/visuallyHidden.css.js";
6
6
  import { createValidHtmlId } from "../../../utilities/html/index.js";
7
7
  import classNames from "classnames";
8
- import { forwardRef } from "react";
9
8
  import { RadioButtonRecipe, CheckedCircleRecipe } from "./radiobutton.css.js";
10
9
  import { LabelRecipe, InputStyleRecipe, LabelStyle, InputWrapper, indentedDescriptionStyle } from "./shared.css.js";
11
10
  import { SelectionDescription, HelperTextWrapper } from "./shared.js";
@@ -20,7 +19,7 @@ const CustomRadioButton = ({ value, disabled, validity }) => {
20
19
  }) }) });
21
20
  };
22
21
  const defaultRender = (radio, description) => jsxs(Fragment, { children: [radio, jsx("div", { className: indentedDescriptionStyle, children: description })] });
23
- const RadioButton = forwardRef(function RadioButton2({
22
+ function RadioButton({
24
23
  value,
25
24
  onChange,
26
25
  disabled,
@@ -32,9 +31,10 @@ const RadioButton = forwardRef(function RadioButton2({
32
31
  canShowErrorMessage = false,
33
32
  className,
34
33
  render = defaultRender,
34
+ ref,
35
35
  // Input element props
36
36
  ...rest
37
- }, ref) {
37
+ }) {
38
38
  const inputId = id;
39
39
  const labelId = `${id}-label`;
40
40
  const helperId = `${id}-helper`;
@@ -45,8 +45,8 @@ const RadioButton = forwardRef(function RadioButton2({
45
45
  });
46
46
  const radioButtonElement = jsx("span", { className: classNames(InputWrapper, className), ref, children: jsxs("label", { htmlFor: inputId, className: LabelRecipe({ disabled }), id: labelId, children: [jsx("input", { type: "radio", id: inputId, disabled, onChange, checked: value === true, className: InputStyleRecipe({ disabled }), tabIndex: 0, ...inputAriaProps, ...rest }), jsx(CustomRadioButton, { value, disabled, validity }), hideLabel ? jsx(ScreenReaderOnly, { children: label }) : jsx("span", { className: LabelStyle, children: label })] }) });
47
47
  const descriptionElement = description ? jsx(SelectionDescription, { disabled, children: description }) : void 0;
48
- return jsx(HelperTextWrapper, { ...helperTextProps, children: render(radioButtonElement, descriptionElement) });
49
- });
48
+ return jsx(HelperTextWrapper, { ...helperTextProps, children: render && render(radioButtonElement, descriptionElement) });
49
+ }
50
50
  export {
51
51
  RadioButton
52
52
  };
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const jsxRuntime = require("react/jsx-runtime");
5
+ const InputHelperText = require("../../../building-blocks/inputs/InputHelperText.cjs");
6
+ const ScreenReaderOnly = require("../../../utilities/accessibility/ScreenReaderOnly.cjs");
7
+ require("../../../utilities/accessibility/visuallyHidden.css.cjs");
8
+ const index = require("../../../utilities/html/index.cjs");
9
+ const React = require("react");
10
+ const switch_css = require("./switch.css.cjs");
11
+ const shared_css = require("./shared.css.cjs");
12
+ const shared = require("./shared.cjs");
13
+ const defaultRender = (switchElement, description) => jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [switchElement, jsxRuntime.jsx("div", { className: switch_css.switchDescription, children: description })] });
14
+ const Switch = React.forwardRef(function Switch2({ offLabel, onLabel, description, value = false, onChange, disabled, validity, id = index.createValidHtmlId(offLabel || onLabel || "toggle"), hideLabel = false, canShowErrorMessage = false, className, ...rest }, ref) {
15
+ const inputId = id;
16
+ const labelId = `${id}-label`;
17
+ const helperId = `${id}-helper`;
18
+ const { helperTextProps, inputAriaProps } = InputHelperText.useInputHelperText({
19
+ id: helperId,
20
+ validity,
21
+ reserveSpaceForMessage: canShowErrorMessage
22
+ });
23
+ const descriptionElement = description ? jsxRuntime.jsx(shared.SelectionDescription, { disabled, children: description }) : void 0;
24
+ const switchElement = jsxRuntime.jsx("span", { className: `${shared_css.InputWrapper} ${className}`, ref, children: jsxRuntime.jsxs("div", { className: switch_css.switchContainerStyle, children: [offLabel && !hideLabel && jsxRuntime.jsx("span", { className: switch_css.SwitchLabelRecipe({
25
+ disabled,
26
+ side: "left"
27
+ }), children: offLabel }), jsxRuntime.jsxs("label", { htmlFor: inputId, className: switch_css.SwitchRecipe({
28
+ selected: value,
29
+ disabled,
30
+ validity: validity?.type === "error" ? "error" : void 0
31
+ }), id: labelId, children: [jsxRuntime.jsx("input", { type: "checkbox", id: inputId, disabled, onChange, checked: value === true, className: shared_css.InputStyleRecipe({ disabled }), style: {
32
+ position: "absolute",
33
+ opacity: 0,
34
+ width: "100%",
35
+ height: "100%",
36
+ margin: 0,
37
+ cursor: disabled ? "not-allowed" : "pointer"
38
+ }, ...inputAriaProps, ...rest }), jsxRuntime.jsx("span", { className: switch_css.SwitchThumbRecipe({
39
+ selected: value ?? false,
40
+ disabled
41
+ }) }), onLabel && hideLabel && jsxRuntime.jsx(ScreenReaderOnly.ScreenReaderOnly, { children: onLabel })] }), onLabel && !hideLabel && jsxRuntime.jsx("span", { className: switch_css.SwitchLabelRecipe({
42
+ disabled,
43
+ side: "right"
44
+ }), children: onLabel }), onLabel && !hideLabel && !offLabel && !onLabel && jsxRuntime.jsx("span", { className: switch_css.SwitchLabelRecipe({
45
+ disabled
46
+ }), children: onLabel })] }) });
47
+ return jsxRuntime.jsx(shared.HelperTextWrapper, { ...helperTextProps, children: defaultRender(switchElement, descriptionElement) });
48
+ });
49
+ exports.Switch = Switch;
@@ -0,0 +1,17 @@
1
+ import { SelectionControlProps } from "./shared.js";
2
+ export interface SwitchProps extends Omit<SelectionControlProps<boolean>, "render"> {
3
+ /** The left side label of the switch. */
4
+ offLabel?: string;
5
+ /** The right side label of the switch. */
6
+ onLabel: string;
7
+ }
8
+ /**
9
+ * Use switches to:
10
+ * - Turn an option on or off
11
+ * - Switch between two mutually exclusive options
12
+ * - Enable or disable a feature or setting
13
+ *
14
+ * Documentation: [Switch](https://gnist.moller.no/developers/components/latest/?path=/docs/components-actions-selectioncontrols-switch--docs)
15
+ */
16
+ export declare const Switch: import("react").ForwardRefExoticComponent<SwitchProps & import("react").RefAttributes<HTMLSpanElement>>;
17
+ //# sourceMappingURL=Switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../../src/components/actions/selectionControls/Switch.tsx"],"names":[],"mappings":"AAYA,OAAO,EAEH,qBAAqB,EAExB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,WACb,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IACtD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;CACnB;AAYD;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,yGAkHjB,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import { useInputHelperText } from "../../../building-blocks/inputs/InputHelperText.js";
4
+ import { ScreenReaderOnly } from "../../../utilities/accessibility/ScreenReaderOnly.js";
5
+ import "../../../utilities/accessibility/visuallyHidden.css.js";
6
+ import { createValidHtmlId } from "../../../utilities/html/index.js";
7
+ import { forwardRef } from "react";
8
+ import { switchContainerStyle, SwitchLabelRecipe, SwitchRecipe, SwitchThumbRecipe, switchDescription } from "./switch.css.js";
9
+ import { InputWrapper, InputStyleRecipe } from "./shared.css.js";
10
+ import { SelectionDescription, HelperTextWrapper } from "./shared.js";
11
+ const defaultRender = (switchElement, description) => jsxs(Fragment, { children: [switchElement, jsx("div", { className: switchDescription, children: description })] });
12
+ const Switch = forwardRef(function Switch2({ offLabel, onLabel, description, value = false, onChange, disabled, validity, id = createValidHtmlId(offLabel || onLabel || "toggle"), hideLabel = false, canShowErrorMessage = false, className, ...rest }, ref) {
13
+ const inputId = id;
14
+ const labelId = `${id}-label`;
15
+ const helperId = `${id}-helper`;
16
+ const { helperTextProps, inputAriaProps } = useInputHelperText({
17
+ id: helperId,
18
+ validity,
19
+ reserveSpaceForMessage: canShowErrorMessage
20
+ });
21
+ const descriptionElement = description ? jsx(SelectionDescription, { disabled, children: description }) : void 0;
22
+ const switchElement = jsx("span", { className: `${InputWrapper} ${className}`, ref, children: jsxs("div", { className: switchContainerStyle, children: [offLabel && !hideLabel && jsx("span", { className: SwitchLabelRecipe({
23
+ disabled,
24
+ side: "left"
25
+ }), children: offLabel }), jsxs("label", { htmlFor: inputId, className: SwitchRecipe({
26
+ selected: value,
27
+ disabled,
28
+ validity: validity?.type === "error" ? "error" : void 0
29
+ }), id: labelId, children: [jsx("input", { type: "checkbox", id: inputId, disabled, onChange, checked: value === true, className: InputStyleRecipe({ disabled }), style: {
30
+ position: "absolute",
31
+ opacity: 0,
32
+ width: "100%",
33
+ height: "100%",
34
+ margin: 0,
35
+ cursor: disabled ? "not-allowed" : "pointer"
36
+ }, ...inputAriaProps, ...rest }), jsx("span", { className: SwitchThumbRecipe({
37
+ selected: value ?? false,
38
+ disabled
39
+ }) }), onLabel && hideLabel && jsx(ScreenReaderOnly, { children: onLabel })] }), onLabel && !hideLabel && jsx("span", { className: SwitchLabelRecipe({
40
+ disabled,
41
+ side: "right"
42
+ }), children: onLabel }), onLabel && !hideLabel && !offLabel && !onLabel && jsx("span", { className: SwitchLabelRecipe({
43
+ disabled
44
+ }), children: onLabel })] }) });
45
+ return jsx(HelperTextWrapper, { ...helperTextProps, children: defaultRender(switchElement, descriptionElement) });
46
+ });
47
+ export {
48
+ Switch
49
+ };
@@ -3,5 +3,7 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const Checkbox = require("./Checkbox.cjs");
5
5
  const RadioButton = require("./RadioButton.cjs");
6
+ const Switch = require("./Switch.cjs");
6
7
  exports.Checkbox = Checkbox.Checkbox;
7
8
  exports.RadioButton = RadioButton.RadioButton;
9
+ exports.Switch = Switch.Switch;