@danske/sapphire-react-lab 0.80.0 → 0.81.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.
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import { useThemeCheck, Dialog } from '@danske/sapphire-react';
3
+ import { FeedbackMessage } from '../../FeedbackMessage/src/FeedbackMessage.js';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
33
+ const AlertDialog = React.forwardRef(function AlertDialog2(props, ref) {
34
+ useThemeCheck();
35
+ const _a = props, {
36
+ variant = "neutral",
37
+ icon,
38
+ body,
39
+ actionsOrientation = "horizontal",
40
+ actions,
41
+ heading
42
+ } = _a, rest = __objRest(_a, [
43
+ "variant",
44
+ "icon",
45
+ "body",
46
+ "actionsOrientation",
47
+ "actions",
48
+ "heading"
49
+ ]);
50
+ return /* @__PURE__ */ React.createElement(Dialog, __spreadValues({
51
+ ref,
52
+ role: "alertdialog",
53
+ type: "active",
54
+ size: "extra-small",
55
+ header: /* @__PURE__ */ React.createElement(React.Fragment, null),
56
+ content: /* @__PURE__ */ React.createElement(Dialog.Content, null, /* @__PURE__ */ React.createElement(FeedbackMessage, {
57
+ heading: /* @__PURE__ */ React.createElement(Dialog.Header, {
58
+ level: 6,
59
+ heading
60
+ }),
61
+ variant,
62
+ icon,
63
+ body
64
+ })),
65
+ footer: /* @__PURE__ */ React.createElement(Dialog.Footer, {
66
+ stretch: "autoVertical",
67
+ orientation: actionsOrientation
68
+ }, actions)
69
+ }, rest));
70
+ });
71
+
72
+ export { AlertDialog };
73
+ //# sourceMappingURL=AlertDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlertDialog.js","sources":["../../../../src/AlertDialog/src/AlertDialog.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport {\n Dialog,\n DialogProps,\n SapphireStyleProps,\n useThemeCheck,\n} from '@danske/sapphire-react';\nimport {\n FeedbackMessage,\n SapphireFeedbackMessageProps,\n} from '../../FeedbackMessage';\nimport { AriaModalOverlayProps } from '@react-aria/overlays';\nimport { DOMRef } from '@react-types/shared';\n\nexport type SapphireAlertDialogProps = AriaModalOverlayProps &\n SapphireStyleProps &\n Pick<DialogProps, 'isOpen' | 'onClose'> &\n Omit<SapphireFeedbackMessageProps, 'heading' | 'actions'> & {\n /**\n *\n * @default \"horizontal\"\n */\n actionsOrientation?: 'vertical' | 'horizontal';\n /**\n * The elements that will be rendered in the footer of the dialog.\n */\n actions: ReactNode;\n /**\n * The title of the dialog.\n */\n heading: string;\n };\n\nexport const AlertDialog = React.forwardRef(function AlertDialog(\n props: SapphireAlertDialogProps,\n ref: DOMRef<HTMLDivElement>\n) {\n useThemeCheck();\n\n const {\n variant = 'neutral',\n icon,\n body,\n actionsOrientation = 'horizontal',\n actions,\n heading,\n ...rest\n } = props;\n\n return (\n <Dialog\n ref={ref}\n role=\"alertdialog\"\n type=\"active\"\n size=\"extra-small\"\n header={<></>}\n content={\n <Dialog.Content>\n <FeedbackMessage\n heading={<Dialog.Header level={6} heading={heading} />}\n variant={variant}\n icon={icon}\n body={body}\n />\n </Dialog.Content>\n }\n footer={\n <Dialog.Footer stretch=\"autoVertical\" orientation={actionsOrientation}>\n {actions}\n </Dialog.Footer>\n }\n {...rest}\n />\n );\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCO,MAAM,WAAc,GAAA,KAAA,CAAM,UAAW,CAAA,SAAA,YAAA,CAC1C,OACA,GACA,EAAA;AACA,EAAA,aAAA,EAAA,CAAA;AAEA,EAAA,MAQI,EAPF,GAAA,KAAA,EAAA;AAAA,IAAU,OAAA,GAAA,SAAA;AAAA,IACV,IAAA;AAAA,IACA,IAAA;AAAA,IACA,kBAAqB,GAAA,YAAA;AAAA,IACrB,OAAA;AAAA,IACA,OAAA;AAAA,GAEE,GAAA,EAAA,EADC,iBACD,EADC,EAAA;AAAA,IANH,SAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,oBAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAA;AAAA,GAAA,CAAA,CAAA;AAIF,EAAA,2CACG,MAAD,EAAA,cAAA,CAAA;AAAA,IACE,GAAA;AAAA,IACA,IAAK,EAAA,aAAA;AAAA,IACL,IAAK,EAAA,QAAA;AAAA,IACL,IAAK,EAAA,aAAA;AAAA,IACL,MAAQ,kBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,CAAA;AAAA,IACR,yBACG,KAAA,CAAA,aAAA,CAAA,MAAA,CAAO,OAAR,EAAA,IAAA,sCACG,eAAD,EAAA;AAAA,MACE,OAAA,kBAAU,KAAA,CAAA,aAAA,CAAA,MAAA,CAAO,MAAR,EAAA;AAAA,QAAe,KAAO,EAAA,CAAA;AAAA,QAAG,OAAA;AAAA,OAAA,CAAA;AAAA,MAClC,OAAA;AAAA,MACA,IAAA;AAAA,MACA,IAAA;AAAA,KAAA,CAAA,CAAA;AAAA,IAIN,MAAA,kBACG,KAAA,CAAA,aAAA,CAAA,MAAA,CAAO,MAAR,EAAA;AAAA,MAAe,OAAQ,EAAA,cAAA;AAAA,MAAe,WAAa,EAAA,kBAAA;AAAA,KAChD,EAAA,OAAA,CAAA;AAAA,GAGD,EAAA,IAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
@@ -34,6 +34,18 @@ var __objRest = (source, exclude) => {
34
34
  }
35
35
  return target;
36
36
  };
37
+ const getIconSize = (size) => {
38
+ switch (size) {
39
+ case "medium":
40
+ return "m";
41
+ case "large":
42
+ return "l";
43
+ case "extraLarge":
44
+ return "xl";
45
+ default:
46
+ return "s";
47
+ }
48
+ };
37
49
  const Avatar = (_a) => {
38
50
  var _b = _a, {
39
51
  monogram,
@@ -50,12 +62,13 @@ const Avatar = (_a) => {
50
62
  const { styleProps } = useSapphireStyleProps(props);
51
63
  return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, styleProps), {
52
64
  className: clsx(styleProps.className, styles["sapphire-avatar"], {
65
+ [styles["sapphire-avatar--extra-large"]]: size === "extraLarge",
53
66
  [styles["sapphire-avatar--large"]]: size === "large",
54
67
  [styles["sapphire-avatar--small"]]: size === "small",
55
68
  [styles["sapphire-avatar--extra-small"]]: size === "extraSmall"
56
69
  }, color !== "passive" && styles[`sapphire-avatar--${color}`])
57
70
  }), icon ? /* @__PURE__ */ React.createElement(Icon, {
58
- size: size === "large" ? "l" : size === "medium" ? "m" : "s"
71
+ size: getIconSize(size)
59
72
  }, icon) : monogram);
60
73
  };
61
74
 
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sources":["../../../../src/Avatar/src/Avatar.tsx"],"sourcesContent":["import {\n Icon,\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n} from '@danske/sapphire-react';\nimport React, { ReactNode } from 'react';\nimport styles from '@danske/sapphire-css/components/avatar/avatar.module.css';\nimport clsx from 'clsx';\n\nexport type SapphireAvatarProps = SapphireStyleProps & {\n /**\n * @default 'medium'\n */\n size?: 'large' | 'medium' | 'small' | 'extraSmall';\n\n /**\n * The background color of the avatar.\n * Can either be semantic or one of the named decorative colors.\n *\n * @default 'informative'\n */\n\n color?:\n | 'positive'\n | 'negative'\n | 'warning'\n | 'informative'\n | 'passive'\n | 'aqua'\n | 'copper'\n | 'electro'\n | 'indigo'\n | 'lime'\n | 'pink'\n | 'violet'\n | 'gold'\n | 'beige'\n | 'orchid'\n | 'gray'\n | 'cobalt'\n | 'forestGreen'\n | 'teal'\n | 'orange';\n} & (\n | {\n monogram: ReactNode;\n icon?: never;\n }\n | {\n monogram?: never;\n icon: ReactNode;\n }\n );\n\nexport const Avatar = ({\n monogram,\n icon,\n color = 'informative',\n size = 'medium',\n ...props\n}: SapphireAvatarProps): React.ReactElement => {\n useThemeCheck();\n const { styleProps } = useSapphireStyleProps(props);\n\n return (\n <div\n {...styleProps}\n className={clsx(\n styleProps.className,\n styles['sapphire-avatar'],\n {\n [styles['sapphire-avatar--large']]: size === 'large',\n [styles['sapphire-avatar--small']]: size === 'small',\n [styles['sapphire-avatar--extra-small']]: size === 'extraSmall',\n },\n color !== 'passive' && styles[`sapphire-avatar--${color}`]\n )}\n >\n {icon ? (\n <Icon size={size === 'large' ? 'l' : size === 'medium' ? 'm' : 's'}>\n {icon}\n </Icon>\n ) : (\n monogram\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDa,MAAA,MAAA,GAAS,CAAC,EAMwB,KAAA;AANxB,EACrB,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAQ,GAAA,aAAA;AAAA,IACR,IAAO,GAAA,QAAA;AAAA,GAJc,GAAA,EAAA,EAKlB,kBALkB,EAKlB,EAAA;AAAA,IAJH,UAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,GAAA,CAAA,CAAA;AAGA,EAAA,aAAA,EAAA,CAAA;AACA,EAAM,MAAA,EAAE,eAAe,qBAAsB,CAAA,KAAA,CAAA,CAAA;AAE7C,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,UADN,CAAA,EAAA;AAAA,IAEE,SAAW,EAAA,IAAA,CACT,UAAW,CAAA,SAAA,EACX,OAAO,iBACP,CAAA,EAAA;AAAA,MACG,CAAA,MAAA,CAAO,4BAA4B,IAAS,KAAA,OAAA;AAAA,MAC5C,CAAA,MAAA,CAAO,4BAA4B,IAAS,KAAA,OAAA;AAAA,MAC5C,CAAA,MAAA,CAAO,kCAAkC,IAAS,KAAA,YAAA;AAAA,KAErD,EAAA,KAAA,KAAU,SAAa,IAAA,MAAA,CAAO,CAAoB,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA,CAAA;AAAA,GAGnD,CAAA,EAAA,IAAA,uCACE,IAAD,EAAA;AAAA,IAAM,MAAM,IAAS,KAAA,OAAA,GAAU,GAAM,GAAA,IAAA,KAAS,WAAW,GAAM,GAAA,GAAA;AAAA,GAAA,EAC5D,IAGH,CAAA,GAAA,QAAA,CAAA,CAAA;AAAA;;;;"}
1
+ {"version":3,"file":"Avatar.js","sources":["../../../../src/Avatar/src/Avatar.tsx"],"sourcesContent":["import {\n Icon,\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n} from '@danske/sapphire-react';\nimport React, { ReactNode } from 'react';\nimport styles from '@danske/sapphire-css/components/avatar/avatar.module.css';\nimport clsx from 'clsx';\n\nconst getIconSize = (\n size?: 'extraLarge' | 'large' | 'medium' | 'small' | 'extraSmall'\n) => {\n switch (size) {\n case 'medium':\n return 'm';\n case 'large':\n return 'l';\n case 'extraLarge':\n return 'xl';\n default:\n return 's';\n }\n};\n\nexport type SapphireAvatarProps = SapphireStyleProps & {\n /**\n * @default 'medium'\n */\n size?: 'extraLarge' | 'large' | 'medium' | 'small' | 'extraSmall';\n\n /**\n * The background color of the avatar.\n * Can either be semantic or one of the named decorative colors.\n *\n * @default 'informative'\n */\n\n color?:\n | 'positive'\n | 'negative'\n | 'warning'\n | 'informative'\n | 'passive'\n | 'aqua'\n | 'copper'\n | 'electro'\n | 'indigo'\n | 'lime'\n | 'pink'\n | 'violet'\n | 'gold'\n | 'beige'\n | 'orchid'\n | 'gray'\n | 'cobalt'\n | 'forestGreen'\n | 'teal'\n | 'orange';\n} & (\n | {\n monogram: ReactNode;\n icon?: never;\n }\n | {\n monogram?: never;\n icon: ReactNode;\n }\n );\n\nexport const Avatar = ({\n monogram,\n icon,\n color = 'informative',\n size = 'medium',\n ...props\n}: SapphireAvatarProps): React.ReactElement => {\n useThemeCheck();\n const { styleProps } = useSapphireStyleProps(props);\n\n return (\n <div\n {...styleProps}\n className={clsx(\n styleProps.className,\n styles['sapphire-avatar'],\n {\n [styles['sapphire-avatar--extra-large']]: size === 'extraLarge',\n [styles['sapphire-avatar--large']]: size === 'large',\n [styles['sapphire-avatar--small']]: size === 'small',\n [styles['sapphire-avatar--extra-small']]: size === 'extraSmall',\n },\n color !== 'passive' && styles[`sapphire-avatar--${color}`]\n )}\n >\n {icon ? <Icon size={getIconSize(size)}>{icon}</Icon> : monogram}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,WAAA,GAAc,CAClB,IACG,KAAA;AACH,EAAQ,QAAA,IAAA;AAAA,IACD,KAAA,QAAA;AACH,MAAO,OAAA,GAAA,CAAA;AAAA,IACJ,KAAA,OAAA;AACH,MAAO,OAAA,GAAA,CAAA;AAAA,IACJ,KAAA,YAAA;AACH,MAAO,OAAA,IAAA,CAAA;AAAA,IAAA;AAEP,MAAO,OAAA,GAAA,CAAA;AAAA,GAAA;AAAA,CAAA,CAAA;AAiDA,MAAA,MAAA,GAAS,CAAC,EAMwB,KAAA;AANxB,EACrB,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAQ,GAAA,aAAA;AAAA,IACR,IAAO,GAAA,QAAA;AAAA,GAJc,GAAA,EAAA,EAKlB,kBALkB,EAKlB,EAAA;AAAA,IAJH,UAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,GAAA,CAAA,CAAA;AAGA,EAAA,aAAA,EAAA,CAAA;AACA,EAAM,MAAA,EAAE,eAAe,qBAAsB,CAAA,KAAA,CAAA,CAAA;AAE7C,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,UADN,CAAA,EAAA;AAAA,IAEE,SAAW,EAAA,IAAA,CACT,UAAW,CAAA,SAAA,EACX,OAAO,iBACP,CAAA,EAAA;AAAA,MACG,CAAA,MAAA,CAAO,kCAAkC,IAAS,KAAA,YAAA;AAAA,MAClD,CAAA,MAAA,CAAO,4BAA4B,IAAS,KAAA,OAAA;AAAA,MAC5C,CAAA,MAAA,CAAO,4BAA4B,IAAS,KAAA,OAAA;AAAA,MAC5C,CAAA,MAAA,CAAO,kCAAkC,IAAS,KAAA,YAAA;AAAA,KAErD,EAAA,KAAA,KAAU,SAAa,IAAA,MAAA,CAAO,CAAoB,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA,CAAA;AAAA,GAGnD,CAAA,EAAA,IAAA,uCAAQ,IAAD,EAAA;AAAA,IAAM,MAAM,WAAY,CAAA,IAAA,CAAA;AAAA,GAAA,EAAQ,IAAe,CAAA,GAAA,QAAA,CAAA,CAAA;AAAA;;;;"}
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import clsx from 'clsx';
3
- import { CheckMarkCircle, AlertCircle } from '@danske/sapphire-icons/react';
4
- import { useThemeCheck, useSapphireStyleProps, Icon, Heading } from '@danske/sapphire-react';
3
+ import { Bell, AlertTriangle, AlertCircle, CheckMarkCircle } from '@danske/sapphire-icons/react';
4
+ import { useThemeCheck, useSapphireStyleProps, Heading } from '@danske/sapphire-react';
5
5
  import styles from '@danske/sapphire-css/components/feedbackMessage/feedbackMessage.module.css';
6
+ import { Avatar } from '../../Avatar/src/Avatar.js';
6
7
 
7
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
@@ -19,17 +20,48 @@ var __objRest = (source, exclude) => {
19
20
  }
20
21
  return target;
21
22
  };
23
+ const getColor = (variant) => {
24
+ switch (variant) {
25
+ case "success":
26
+ return "positive";
27
+ case "error":
28
+ return "negative";
29
+ case "neutral":
30
+ return "passive";
31
+ default:
32
+ return variant;
33
+ }
34
+ };
35
+ const getIcon = (variant, icon) => {
36
+ if (icon) {
37
+ return icon;
38
+ }
39
+ switch (variant) {
40
+ case "success":
41
+ return /* @__PURE__ */ React.createElement(CheckMarkCircle, null);
42
+ case "error":
43
+ return /* @__PURE__ */ React.createElement(AlertCircle, null);
44
+ case "warning":
45
+ return /* @__PURE__ */ React.createElement(AlertTriangle, null);
46
+ case "informative":
47
+ return /* @__PURE__ */ React.createElement(Bell, null);
48
+ default:
49
+ return null;
50
+ }
51
+ };
22
52
  const FeedbackMessage = (_a) => {
23
53
  var _b = _a, {
24
54
  heading,
25
55
  body,
26
56
  actions,
27
- type = "neutral"
57
+ variant = "neutral",
58
+ icon
28
59
  } = _b, otherProps = __objRest(_b, [
29
60
  "heading",
30
61
  "body",
31
62
  "actions",
32
- "type"
63
+ "variant",
64
+ "icon"
33
65
  ]);
34
66
  useThemeCheck();
35
67
  const {
@@ -38,15 +70,15 @@ const FeedbackMessage = (_a) => {
38
70
  return /* @__PURE__ */ React.createElement("div", {
39
71
  className: clsx(styles["sapphire-feedback-message"], className),
40
72
  style
41
- }, type !== "neutral" && /* @__PURE__ */ React.createElement("div", {
42
- className: clsx(styles["sapphire-feedback-message__icon"], styles[`sapphire-feedback-message__icon--${type}`])
43
- }, /* @__PURE__ */ React.createElement(Icon, {
44
- size: "xl"
45
- }, type === "success" ? /* @__PURE__ */ React.createElement(CheckMarkCircle, null) : /* @__PURE__ */ React.createElement(AlertCircle, null))), /* @__PURE__ */ React.createElement("div", {
73
+ }, variant !== "neutral" && /* @__PURE__ */ React.createElement(Avatar, {
74
+ color: getColor(variant),
75
+ size: "extraLarge",
76
+ icon: getIcon(variant, icon)
77
+ }), /* @__PURE__ */ React.createElement("div", {
46
78
  className: styles["sapphire-feedback-message__content"]
47
- }, /* @__PURE__ */ React.createElement(Heading, {
79
+ }, typeof heading === "string" ? /* @__PURE__ */ React.createElement(Heading, {
48
80
  level: 3
49
- }, heading), /* @__PURE__ */ React.createElement("section", {
81
+ }, heading) : heading, /* @__PURE__ */ React.createElement("section", {
50
82
  className: styles["sapphire-feedback-message__body"]
51
83
  }, body)), actions);
52
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FeedbackMessage.js","sources":["../../../../src/FeedbackMessage/src/FeedbackMessage.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\nimport { AlertCircle, CheckMarkCircle } from '@danske/sapphire-icons/react';\nimport {\n Heading,\n Icon,\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n} from '@danske/sapphire-react';\nimport styles from '@danske/sapphire-css/components/feedbackMessage/feedbackMessage.module.css';\n\nexport interface SapphireFeedbackMessageProps extends SapphireStyleProps {\n /**\n * Heading content, rendered in a sapphire Heading component.\n */\n heading: React.ReactNode;\n /**\n * The type of message.\n * The 'error' and 'success' are meant to attract more attention.\n *\n * @default 'neutral'\n */\n type?: 'error' | 'success' | 'neutral';\n /**\n * Optional description, rendered as a section below heading.\n */\n body?: React.ReactNode;\n /**\n * Optional actions, rendered at the bottom. Use {@link ButtonGroup}\n * for the content.\n */\n actions?: React.ReactNode;\n}\n\n/**\n * Implements layout and style of a feedback message.\n */\nexport const FeedbackMessage = ({\n heading,\n body,\n actions,\n type = 'neutral',\n ...otherProps\n}: SapphireFeedbackMessageProps): JSX.Element => {\n useThemeCheck();\n const {\n styleProps: { style, className },\n } = useSapphireStyleProps(otherProps);\n\n return (\n <div\n className={clsx(styles['sapphire-feedback-message'], className)}\n style={style}\n >\n {type !== 'neutral' && (\n <div\n className={clsx(\n styles['sapphire-feedback-message__icon'],\n styles[`sapphire-feedback-message__icon--${type}`]\n )}\n >\n <Icon size=\"xl\">\n {type === 'success' ? <CheckMarkCircle /> : <AlertCircle />}\n </Icon>\n </div>\n )}\n <div className={styles['sapphire-feedback-message__content']}>\n <Heading level={3}>{heading}</Heading>\n <section className={styles['sapphire-feedback-message__body']}>\n {body}\n </section>\n </div>\n {actions}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCa,MAAA,eAAA,GAAkB,CAAC,EAMiB,KAAA;AANjB,EAC9B,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAO,GAAA,SAAA;AAAA,GAJuB,GAAA,EAAA,EAK3B,uBAL2B,EAK3B,EAAA;AAAA,IAJH,SAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,GAAA,CAAA,CAAA;AAGA,EAAA,aAAA,EAAA,CAAA;AACA,EAAM,MAAA;AAAA,IACJ,UAAA,EAAY,EAAE,KAAO,EAAA,SAAA,EAAA;AAAA,GAAA,GACnB,qBAAsB,CAAA,UAAA,CAAA,CAAA;AAE1B,EAAA,2CACG,KAAD,EAAA;AAAA,IACE,SAAA,EAAW,IAAK,CAAA,MAAA,CAAO,2BAA8B,CAAA,EAAA,SAAA,CAAA;AAAA,IACrD,KAAA;AAAA,GAEC,EAAA,IAAA,KAAS,SACR,oBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA;AAAA,IACE,SAAW,EAAA,IAAA,CACT,MAAO,CAAA,iCAAA,CAAA,EACP,OAAO,CAAoC,iCAAA,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA;AAAA,GAAA,sCAG5C,IAAD,EAAA;AAAA,IAAM,IAAK,EAAA,IAAA;AAAA,GACR,EAAA,IAAA,KAAS,4BAAa,KAAA,CAAA,aAAA,CAAA,eAAA,EAAD,wBAAuB,KAAA,CAAA,aAAA,CAAA,WAAA,EAAD,IAIlD,CAAA,CAAA,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA;AAAA,IAAK,WAAW,MAAO,CAAA,oCAAA,CAAA;AAAA,GAAA,sCACpB,OAAD,EAAA;AAAA,IAAS,KAAO,EAAA,CAAA;AAAA,GAAI,EAAA,OAAA,CAAA,sCACnB,SAAD,EAAA;AAAA,IAAS,WAAW,MAAO,CAAA,iCAAA,CAAA;AAAA,GAAA,EACxB,IAGJ,CAAA,CAAA,EAAA,OAAA,CAAA,CAAA;AAAA;;;;"}
1
+ {"version":3,"file":"FeedbackMessage.js","sources":["../../../../src/FeedbackMessage/src/FeedbackMessage.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\nimport {\n AlertCircle,\n AlertTriangle,\n Bell,\n CheckMarkCircle,\n} from '@danske/sapphire-icons/react';\nimport {\n Heading,\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n} from '@danske/sapphire-react';\nimport styles from '@danske/sapphire-css/components/feedbackMessage/feedbackMessage.module.css';\nimport { Avatar } from '../../Avatar';\n\nexport type FeedbackMessageVariant =\n | 'success'\n | 'error'\n | 'warning'\n | 'informative'\n | 'neutral';\n\nexport interface SapphireFeedbackMessageProps extends SapphireStyleProps {\n /**\n * Heading content, rendered in a sapphire Heading component.\n */\n heading: React.ReactNode | string;\n /**\n * The type of message.\n * The 'error' and 'success' are meant to attract more attention.\n *\n * @default 'neutral'\n */\n variant?: FeedbackMessageVariant;\n /**\n * Optional icon to override the default icon for the message type.\n */\n icon?: React.ReactNode;\n /**\n * Optional description, rendered as a section below heading.\n */\n body?: React.ReactNode;\n /**\n * Optional actions, rendered at the bottom. Use {@link ButtonGroup}\n * for the content.\n */\n actions?: React.ReactNode;\n}\n\nconst getColor = (variant: FeedbackMessageVariant) => {\n switch (variant) {\n case 'success':\n return 'positive';\n case 'error':\n return 'negative';\n case 'neutral':\n return 'passive';\n default:\n return variant;\n }\n};\n\nconst getIcon = (variant: FeedbackMessageVariant, icon?: React.ReactNode) => {\n if (icon) {\n return icon;\n }\n\n switch (variant) {\n case 'success':\n return <CheckMarkCircle />;\n case 'error':\n return <AlertCircle />;\n case 'warning':\n return <AlertTriangle />;\n case 'informative':\n return <Bell />;\n default:\n return null;\n }\n};\n\n/**\n * Implements layout and style of a feedback message.\n */\nexport const FeedbackMessage = ({\n heading,\n body,\n actions,\n variant = 'neutral',\n icon,\n ...otherProps\n}: SapphireFeedbackMessageProps): JSX.Element => {\n useThemeCheck();\n const {\n styleProps: { style, className },\n } = useSapphireStyleProps(otherProps);\n\n return (\n <div\n className={clsx(styles['sapphire-feedback-message'], className)}\n style={style}\n >\n {variant !== 'neutral' && (\n <Avatar\n color={getColor(variant)}\n size=\"extraLarge\"\n icon={getIcon(variant, icon)}\n />\n )}\n <div className={styles['sapphire-feedback-message__content']}>\n {typeof heading === 'string' ? (\n <Heading level={3}>{heading}</Heading>\n ) : (\n heading\n )}\n <section className={styles['sapphire-feedback-message__body']}>\n {body}\n </section>\n </div>\n {actions}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,QAAA,GAAW,CAAC,OAAoC,KAAA;AACpD,EAAQ,QAAA,OAAA;AAAA,IACD,KAAA,SAAA;AACH,MAAO,OAAA,UAAA,CAAA;AAAA,IACJ,KAAA,OAAA;AACH,MAAO,OAAA,UAAA,CAAA;AAAA,IACJ,KAAA,SAAA;AACH,MAAO,OAAA,SAAA,CAAA;AAAA,IAAA;AAEP,MAAO,OAAA,OAAA,CAAA;AAAA,GAAA;AAAA,CAAA,CAAA;AAIb,MAAM,OAAA,GAAU,CAAC,OAAA,EAAiC,IAA2B,KAAA;AAC3E,EAAA,IAAI,IAAM,EAAA;AACR,IAAO,OAAA,IAAA,CAAA;AAAA,GAAA;AAGT,EAAQ,QAAA,OAAA;AAAA,IACD,KAAA,SAAA;AACH,MAAA,2CAAQ,eAAD,EAAA,IAAA,CAAA,CAAA;AAAA,IACJ,KAAA,OAAA;AACH,MAAA,2CAAQ,WAAD,EAAA,IAAA,CAAA,CAAA;AAAA,IACJ,KAAA,SAAA;AACH,MAAA,2CAAQ,aAAD,EAAA,IAAA,CAAA,CAAA;AAAA,IACJ,KAAA,aAAA;AACH,MAAA,2CAAQ,IAAD,EAAA,IAAA,CAAA,CAAA;AAAA,IAAA;AAEP,MAAO,OAAA,IAAA,CAAA;AAAA,GAAA;AAAA,CAAA,CAAA;AAOA,MAAA,eAAA,GAAkB,CAAC,EAOiB,KAAA;AAPjB,EAC9B,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAU,GAAA,SAAA;AAAA,IACV,IAAA;AAAA,GAL8B,GAAA,EAAA,EAM3B,uBAN2B,EAM3B,EAAA;AAAA,IALH,SAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,GAAA,CAAA,CAAA;AAGA,EAAA,aAAA,EAAA,CAAA;AACA,EAAM,MAAA;AAAA,IACJ,UAAA,EAAY,EAAE,KAAO,EAAA,SAAA,EAAA;AAAA,GAAA,GACnB,qBAAsB,CAAA,UAAA,CAAA,CAAA;AAE1B,EAAA,2CACG,KAAD,EAAA;AAAA,IACE,SAAA,EAAW,IAAK,CAAA,MAAA,CAAO,2BAA8B,CAAA,EAAA,SAAA,CAAA;AAAA,IACrD,KAAA;AAAA,GAEC,EAAA,OAAA,KAAY,SACX,oBAAA,KAAA,CAAA,aAAA,CAAC,MAAD,EAAA;AAAA,IACE,OAAO,QAAS,CAAA,OAAA,CAAA;AAAA,IAChB,IAAK,EAAA,YAAA;AAAA,IACL,IAAA,EAAM,QAAQ,OAAS,EAAA,IAAA,CAAA;AAAA,GAAA,CAAA,sCAG1B,KAAD,EAAA;AAAA,IAAK,WAAW,MAAO,CAAA,oCAAA,CAAA;AAAA,GAAA,EACpB,OAAO,OAAA,KAAY,QAClB,mBAAA,KAAA,CAAA,aAAA,CAAC,OAAD,EAAA;AAAA,IAAS,KAAO,EAAA,CAAA;AAAA,GAAI,EAAA,OAAA,CAAA,GAEpB,OAEF,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAD,EAAA;AAAA,IAAS,WAAW,MAAO,CAAA,iCAAA,CAAA;AAAA,GAAA,EACxB,IAGJ,CAAA,CAAA,EAAA,OAAA,CAAA,CAAA;AAAA;;;;"}
@@ -17,6 +17,7 @@ export { Accordion } from './Accordion/index.js';
17
17
  export { Typography } from './Typography/index.js';
18
18
  export { Fieldset } from './Fieldset/src/Fieldset.js';
19
19
  export { Avatar } from './Avatar/src/Avatar.js';
20
+ export { AlertDialog } from './AlertDialog/src/AlertDialog.js';
20
21
  export { NumberField } from './NumberField/src/NumberField.js';
21
22
  export { useLocale } from '@react-aria/i18n';
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
package/build/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { PressEvents, Validation, RangeValue, HelpTextProps, LabelableProps, Col
3
3
  import * as React from 'react';
4
4
  import React__default, { ReactNode, ComponentType, RefObject } from 'react';
5
5
  import { AriaToggleButtonProps } from '@react-aria/button';
6
- import { SapphireStyleProps, PopoverTriggerProps, HeadingProps, TextStyleProps } from '@danske/sapphire-react';
6
+ import { SapphireStyleProps, PopoverTriggerProps, HeadingProps, TextStyleProps, DialogProps } from '@danske/sapphire-react';
7
7
  import { DateValue } from '@internationalized/date';
8
8
  import { AriaCalendarProps, AriaRangeCalendarProps } from '@react-aria/calendar';
9
9
  import { RangeCalendarStateOptions as RangeCalendarStateOptions$1 } from '@react-stately/calendar';
@@ -13,6 +13,7 @@ import { ComboBoxProps } from '@react-types/combobox';
13
13
  import { AriaSearchFieldProps } from '@react-aria/searchfield';
14
14
  import { AriaToastRegionProps } from '@react-aria/toast';
15
15
  import { ToastState } from '@react-stately/toast';
16
+ import { AriaModalOverlayProps } from '@react-aria/overlays';
16
17
  import { AriaNumberFieldProps } from '@react-aria/numberfield';
17
18
  export { useLocale } from '@react-aria/i18n';
18
19
 
@@ -480,18 +481,23 @@ declare const DateRangeField: <T extends DateValue$1, P extends string>(props: O
480
481
  declare const isEndDateBeforeStartDate: (dateRange?: RangeValue<DateValue$1> | null) => boolean | null | undefined;
481
482
  declare const isDateOutsideValidRange: (value?: DateValue$1 | null, minValue?: DateValue$1 | null, maxValue?: DateValue$1 | null) => "after" | "before" | undefined;
482
483
 
484
+ declare type FeedbackMessageVariant = 'success' | 'error' | 'warning' | 'informative' | 'neutral';
483
485
  interface SapphireFeedbackMessageProps extends SapphireStyleProps {
484
486
  /**
485
487
  * Heading content, rendered in a sapphire Heading component.
486
488
  */
487
- heading: React__default.ReactNode;
489
+ heading: React__default.ReactNode | string;
488
490
  /**
489
491
  * The type of message.
490
492
  * The 'error' and 'success' are meant to attract more attention.
491
493
  *
492
494
  * @default 'neutral'
493
495
  */
494
- type?: 'error' | 'success' | 'neutral';
496
+ variant?: FeedbackMessageVariant;
497
+ /**
498
+ * Optional icon to override the default icon for the message type.
499
+ */
500
+ icon?: React__default.ReactNode;
495
501
  /**
496
502
  * Optional description, rendered as a section below heading.
497
503
  */
@@ -505,7 +511,7 @@ interface SapphireFeedbackMessageProps extends SapphireStyleProps {
505
511
  /**
506
512
  * Implements layout and style of a feedback message.
507
513
  */
508
- declare const FeedbackMessage: ({ heading, body, actions, type, ...otherProps }: SapphireFeedbackMessageProps) => JSX.Element;
514
+ declare const FeedbackMessage: ({ heading, body, actions, variant, icon, ...otherProps }: SapphireFeedbackMessageProps) => JSX.Element;
509
515
 
510
516
  declare type SapphireSearchFieldProps<T extends object> = SapphireStyleProps & Omit<AriaSearchFieldProps, keyof HelpTextProps | keyof Validation<unknown> | keyof LabelableProps> & AutocompleteProps<T> & {
511
517
  /**
@@ -757,7 +763,7 @@ declare type SapphireAvatarProps = SapphireStyleProps & {
757
763
  /**
758
764
  * @default 'medium'
759
765
  */
760
- size?: 'large' | 'medium' | 'small' | 'extraSmall';
766
+ size?: 'extraLarge' | 'large' | 'medium' | 'small' | 'extraSmall';
761
767
  /**
762
768
  * The background color of the avatar.
763
769
  * Can either be semantic or one of the named decorative colors.
@@ -774,6 +780,37 @@ declare type SapphireAvatarProps = SapphireStyleProps & {
774
780
  });
775
781
  declare const Avatar: ({ monogram, icon, color, size, ...props }: SapphireAvatarProps) => React__default.ReactElement;
776
782
 
783
+ declare type SapphireAlertDialogProps = AriaModalOverlayProps & SapphireStyleProps & Pick<DialogProps, 'isOpen' | 'onClose'> & Omit<SapphireFeedbackMessageProps, 'heading' | 'actions'> & {
784
+ /**
785
+ *
786
+ * @default "horizontal"
787
+ */
788
+ actionsOrientation?: 'vertical' | 'horizontal';
789
+ /**
790
+ * The elements that will be rendered in the footer of the dialog.
791
+ */
792
+ actions: ReactNode;
793
+ /**
794
+ * The title of the dialog.
795
+ */
796
+ heading: string;
797
+ };
798
+ declare const AlertDialog: React__default.ForwardRefExoticComponent<AriaModalOverlayProps & SapphireStyleProps & Pick<DialogProps, "isOpen" | "onClose"> & Omit<SapphireFeedbackMessageProps, "heading" | "actions"> & {
799
+ /**
800
+ *
801
+ * @default "horizontal"
802
+ */
803
+ actionsOrientation?: "horizontal" | "vertical" | undefined;
804
+ /**
805
+ * The elements that will be rendered in the footer of the dialog.
806
+ */
807
+ actions: ReactNode;
808
+ /**
809
+ * The title of the dialog.
810
+ */
811
+ heading: string;
812
+ } & React__default.RefAttributes<_react_types_shared.DOMRefValue<HTMLDivElement>>>;
813
+
777
814
  interface SapphireNumberFieldProps
778
815
  /**
779
816
  * Reasons to omit the below properties:
@@ -836,4 +873,4 @@ interface NumberFieldProps extends SapphireNumberFieldProps, PressEvents, Sapphi
836
873
  }
837
874
  declare const NumberField: React__default.ForwardRefExoticComponent<NumberFieldProps & React__default.RefAttributes<NumberFieldRef>>;
838
875
 
839
- export { _Accordion as Accordion, Avatar, Calendar, CalendarView, DateField, DateFieldProps, DateRangeField, DateRangeFieldProps, FeedbackMessage, Fieldset, FieldsetProps, FilterDropdown, NotificationBadge, NotificationBadgeProps, NumberField, NumberFieldProps, NumberFieldRef, PredefinedDateRange, RangeCalendar, SapphireAccordionHeadingProps, SapphireAccordionItemProps, SapphireAccordionProps, SapphireAvatarProps, SapphireCalendarProps, SapphireFeedbackMessageProps, SapphireFilterDropdownProps, SapphireRangeCalendarProps, SapphireSearchFieldProps, SapphireToggleButtonProps, SearchField, ShowToastFn, ShowToastOptions, Spinner, SpinnerProps, ToastProvider, ToastProviderProps, ToggleButton, Typography, TypographyBodyProps, TypographyCaptionProps, TypographyHeadingProps, TypographySubheadingProps, isDateOutsideValidRange, isEndDateBeforeStartDate, useShowToast };
876
+ export { _Accordion as Accordion, AlertDialog, Avatar, Calendar, CalendarView, DateField, DateFieldProps, DateRangeField, DateRangeFieldProps, FeedbackMessage, Fieldset, FieldsetProps, FilterDropdown, NotificationBadge, NotificationBadgeProps, NumberField, NumberFieldProps, NumberFieldRef, PredefinedDateRange, RangeCalendar, SapphireAccordionHeadingProps, SapphireAccordionItemProps, SapphireAccordionProps, SapphireAlertDialogProps, SapphireAvatarProps, SapphireCalendarProps, SapphireFeedbackMessageProps, SapphireFilterDropdownProps, SapphireRangeCalendarProps, SapphireSearchFieldProps, SapphireToggleButtonProps, SearchField, ShowToastFn, ShowToastOptions, Spinner, SpinnerProps, ToastProvider, ToastProviderProps, ToggleButton, Typography, TypographyBodyProps, TypographyCaptionProps, TypographyHeadingProps, TypographySubheadingProps, isDateOutsideValidRange, isEndDateBeforeStartDate, useShowToast };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danske/sapphire-react-lab",
3
- "version": "0.80.0",
3
+ "version": "0.81.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "Experimental React components of the Sapphire Design System from Danske Bank A/S",
6
6
  "exports": {
@@ -36,7 +36,7 @@
36
36
  "cross-env": "^7.0.3"
37
37
  },
38
38
  "dependencies": {
39
- "@danske/sapphire-css": "^27.0.0",
39
+ "@danske/sapphire-css": "^27.1.0",
40
40
  "@internationalized/date": "^3.5.2",
41
41
  "@internationalized/string": "^3.2.1",
42
42
  "@react-aria/accordion": "^3.0.0-alpha.27",
@@ -71,5 +71,5 @@
71
71
  "clsx": "^1.1.1",
72
72
  "react-transition-group": "^4.4.5"
73
73
  },
74
- "gitHead": "e207779162338643e012a71b68cbd4d2ad5def7d"
74
+ "gitHead": "b32c314ce39dda19db3c38304864b4e63c0f9470"
75
75
  }