@navikt/ds-react 3.3.0 → 3.4.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/cjs/tag/Tag.js CHANGED
@@ -43,7 +43,6 @@ const clsx_1 = __importDefault(require("clsx"));
43
43
  const __1 = require("..");
44
44
  exports.Tag = (0, react_1.forwardRef)((_a, ref) => {
45
45
  var { className, variant, size = "medium" } = _a, rest = __rest(_a, ["className", "variant", "size"]);
46
- const Component = size === "medium" ? __1.BodyShort : __1.Detail;
47
- return (react_1.default.createElement(Component, Object.assign({}, rest, { ref: ref, as: "span", size: size === "medium" ? "medium" : "small", className: (0, clsx_1.default)("navds-tag", className, `navds-tag--${variant}`, `navds-tag--${size}`) })));
46
+ return (react_1.default.createElement(__1.BodyShort, Object.assign({}, rest, { ref: ref, as: "span", size: size === "medium" ? "medium" : "small", className: (0, clsx_1.default)("navds-tag", className, `navds-tag--${variant}`, `navds-tag--${size}`) })));
48
47
  });
49
48
  exports.default = exports.Tag;
package/cjs/util/copy.js CHANGED
@@ -1,73 +1,28 @@
1
1
  "use strict";
2
- // https://github.com/sudodoki/copy-to-clipboard/blob/main/index.js
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
3
11
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const defaultMessage = "Kopier til utklippstavle: #{key}, Enter";
5
- function format(message) {
6
- const copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
7
- return message.replace(/#{\s*key\s*}/g, copyKey);
8
- }
9
12
  function copy(text) {
10
- let debug, message, range, selection, mark, success = false;
11
- debug = process.env.NODE_ENV !== "production";
12
- try {
13
- range = document.createRange();
14
- selection = document.getSelection();
15
- mark = document.createElement("span");
16
- mark.textContent = text;
17
- // avoid screen readers from reading out loud the text
18
- mark.ariaHidden = "true";
19
- // reset user styles for span element
20
- mark.style.all = "unset";
21
- // prevents scrolling to the end of the page
22
- mark.style.position = "fixed";
23
- mark.style.top = 0;
24
- mark.style.clip = "rect(0, 0, 0, 0)";
25
- // used to preserve spaces and line breaks
26
- mark.style.whiteSpace = "pre";
27
- // do not inherit user-select (it may be `none`)
28
- mark.style.webkitUserSelect = "text";
29
- mark.style.MozUserSelect = "text";
30
- mark.style.msUserSelect = "text";
31
- mark.style.userSelect = "text";
32
- mark.addEventListener("copy", function (e) {
33
- e.stopPropagation();
34
- });
35
- document.body.appendChild(mark);
36
- range.selectNodeContents(mark);
37
- selection.addRange(range);
38
- const successful = document.execCommand("copy");
39
- if (!successful) {
40
- throw new Error("copy command was unsuccessful");
41
- }
42
- success = true;
43
- }
44
- catch (err) {
45
- debug && console.error("unable to copy using execCommand: ", err);
46
- debug && console.warn("trying IE specific stuff");
13
+ return __awaiter(this, void 0, void 0, function* () {
47
14
  try {
48
- window.clipboardData.setData("text", text);
49
- success = true;
15
+ yield navigator.clipboard.writeText(text);
50
16
  }
51
17
  catch (err) {
52
- debug && console.error("unable to copy using clipboardData: ", err);
53
- debug && console.error("falling back to prompt");
54
- message = format(defaultMessage);
55
- window.prompt(message, text);
56
- }
57
- }
58
- finally {
59
- if (selection) {
60
- if (typeof selection.removeRange == "function") {
61
- selection.removeRange(range);
18
+ if (process.env.NODE_ENV !== "production") {
19
+ console.error("Unable to copy using Clipboard API", err);
62
20
  }
63
- else {
64
- selection.removeAllRanges();
65
- }
66
- }
67
- if (mark) {
68
- document.body.removeChild(mark);
21
+ // Fallback for browsers that do not support the Clipboard API.
22
+ const copyKey = /mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl";
23
+ const message = `Kopier til utklippstavle: ${copyKey}+C, Enter`;
24
+ window.prompt(message, text);
69
25
  }
70
- }
71
- return success;
26
+ });
72
27
  }
73
28
  exports.default = copy;
@@ -18,4 +18,4 @@ export declare const SharedMonthProvider: ({ children, dropdownCaption, disabled
18
18
  onSelect: any;
19
19
  year: any;
20
20
  onYearChange: any;
21
- }) => JSX.Element;
21
+ }) => React.JSX.Element;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { DayProps } from "react-day-picker";
3
- export declare const DayButton: (props: DayProps) => JSX.Element;
3
+ export declare const DayButton: (props: DayProps) => React.JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  /** Render the table head. */
3
2
  export declare function TableHead(): JSX.Element;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { CaptionProps } from "react-day-picker";
3
- export declare const DatePickerCaption: ({ displayMonth, id }: CaptionProps) => JSX.Element;
3
+ export declare const DatePickerCaption: ({ displayMonth, id }: CaptionProps) => React.JSX.Element;
4
4
  export default DatePickerCaption;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { CaptionProps } from "react-day-picker";
3
- export declare const DropdownCaption: ({ displayMonth, id }: CaptionProps) => JSX.Element | null;
3
+ export declare const DropdownCaption: ({ displayMonth, id }: CaptionProps) => React.JSX.Element | null;
4
4
  export default DropdownCaption;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  interface MonthType {
3
3
  month: Date;
4
4
  months: Date[];
@@ -7,5 +7,5 @@ interface MonthType {
7
7
  tabRoot?: Date;
8
8
  setTabRoot: Function;
9
9
  }
10
- export declare const MonthButton: ({ month, months, focus, setFocus, tabRoot, setTabRoot, }: MonthType) => JSX.Element;
10
+ export declare const MonthButton: ({ month, months, focus, setFocus, tabRoot, setTabRoot, }: MonthType) => React.JSX.Element;
11
11
  export default MonthButton;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- export declare const MonthCaption: () => JSX.Element;
1
+ import React from "react";
2
+ export declare const MonthCaption: () => React.JSX.Element;
3
3
  export default MonthCaption;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- export declare const MonthSelector: () => JSX.Element;
1
+ import React from "react";
2
+ export declare const MonthSelector: () => React.JSX.Element;
3
3
  export default MonthSelector;
@@ -54,5 +54,5 @@ export declare const Counter: ({ maxLength, currentLength, size, i18n }: {
54
54
  currentLength: any;
55
55
  size: any;
56
56
  i18n: any;
57
- }) => JSX.Element;
57
+ }) => React.JSX.Element;
58
58
  export default Textarea;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  export declare const HelpTextIcon: ({ title, filled, }: {
3
3
  title: string;
4
4
  filled?: boolean | undefined;
5
- }) => JSX.Element;
5
+ }) => React.JSX.Element;
@@ -16,5 +16,5 @@ export interface ProviderProps {
16
16
  appElement?: HTMLElement;
17
17
  }
18
18
  export declare const useProvider: () => ProviderContextType | undefined;
19
- export declare const Provider: ({ children, ...rest }: ProviderProps) => JSX.Element;
19
+ export declare const Provider: ({ children, ...rest }: ProviderProps) => React.JSX.Element;
20
20
  export default Provider;
package/esm/tag/Tag.d.ts CHANGED
@@ -4,7 +4,7 @@ export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
4
4
  /**
5
5
  * Changes visual profile of tag
6
6
  */
7
- variant: "warning" | "warning-filled" | "error" | "error-filled" | "info" | "info-filled" | "success" | "success-filled" | "neutral" | "neutral-filled" | "alt1" | "alt1-filled" | "alt2" | "alt2-filled" | "alt3" | "alt3-filled";
7
+ variant: "warning" | "warning-filled" | "warning-moderate" | "error" | "error-filled" | "error-moderate" | "info" | "info-filled" | "info-moderate" | "success" | "success-filled" | "success-moderate" | "neutral" | "neutral-filled" | "neutral-moderate" | "alt1" | "alt1-filled" | "alt1-moderate" | "alt2" | "alt2-filled" | "alt2-moderate" | "alt3" | "alt3-filled" | "alt3-moderate";
8
8
  /**
9
9
  * @default "medium"
10
10
  */
package/esm/tag/Tag.js CHANGED
@@ -11,11 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React, { forwardRef } from "react";
13
13
  import cl from "clsx";
14
- import { BodyShort, Detail } from "..";
14
+ import { BodyShort } from "..";
15
15
  export const Tag = forwardRef((_a, ref) => {
16
16
  var { className, variant, size = "medium" } = _a, rest = __rest(_a, ["className", "variant", "size"]);
17
- const Component = size === "medium" ? BodyShort : Detail;
18
- return (React.createElement(Component, Object.assign({}, rest, { ref: ref, as: "span", size: size === "medium" ? "medium" : "small", className: cl("navds-tag", className, `navds-tag--${variant}`, `navds-tag--${size}`) })));
17
+ return (React.createElement(BodyShort, Object.assign({}, rest, { ref: ref, as: "span", size: size === "medium" ? "medium" : "small", className: cl("navds-tag", className, `navds-tag--${variant}`, `navds-tag--${size}`) })));
19
18
  });
20
19
  export default Tag;
21
20
  //# sourceMappingURL=Tag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../src/tag/Tag.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AA8BvC,MAAM,CAAC,MAAM,GAAG,GAAG,UAAU,CAC3B,CAAC,EAAgD,EAAE,GAAG,EAAE,EAAE;QAAzD,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,GAAG,QAAQ,OAAW,EAAN,IAAI,cAA9C,gCAAgD,CAAF;IAC7C,MAAM,SAAS,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IAEzD,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,EAAE,EAAC,MAAM,EACT,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAC5C,SAAS,EAAE,EAAE,CACX,WAAW,EACX,SAAS,EACT,cAAc,OAAO,EAAE,EACvB,cAAc,IAAI,EAAE,CACrB,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../src/tag/Tag.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAsC/B,MAAM,CAAC,MAAM,GAAG,GAAG,UAAU,CAC3B,CAAC,EAAgD,EAAE,GAAG,EAAE,EAAE;QAAzD,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,GAAG,QAAQ,OAAW,EAAN,IAAI,cAA9C,gCAAgD,CAAF;IAAY,OAAA,CACzD,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,EAAE,EAAC,MAAM,EACT,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAC5C,SAAS,EAAE,EAAE,CACX,WAAW,EACX,SAAS,EACT,cAAc,OAAO,EAAE,EACvB,cAAc,IAAI,EAAE,CACrB,IACD,CACH,CAAA;CAAA,CACF,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -1 +1 @@
1
- export default function copy(text: any): boolean;
1
+ export default function copy(text: string): Promise<void>;
package/esm/util/copy.js CHANGED
@@ -1,71 +1,26 @@
1
- // https://github.com/sudodoki/copy-to-clipboard/blob/main/index.js
2
- const defaultMessage = "Kopier til utklippstavle: #{key}, Enter";
3
- function format(message) {
4
- const copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
5
- return message.replace(/#{\s*key\s*}/g, copyKey);
6
- }
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
7
10
  export default function copy(text) {
8
- let debug, message, range, selection, mark, success = false;
9
- debug = process.env.NODE_ENV !== "production";
10
- try {
11
- range = document.createRange();
12
- selection = document.getSelection();
13
- mark = document.createElement("span");
14
- mark.textContent = text;
15
- // avoid screen readers from reading out loud the text
16
- mark.ariaHidden = "true";
17
- // reset user styles for span element
18
- mark.style.all = "unset";
19
- // prevents scrolling to the end of the page
20
- mark.style.position = "fixed";
21
- mark.style.top = 0;
22
- mark.style.clip = "rect(0, 0, 0, 0)";
23
- // used to preserve spaces and line breaks
24
- mark.style.whiteSpace = "pre";
25
- // do not inherit user-select (it may be `none`)
26
- mark.style.webkitUserSelect = "text";
27
- mark.style.MozUserSelect = "text";
28
- mark.style.msUserSelect = "text";
29
- mark.style.userSelect = "text";
30
- mark.addEventListener("copy", function (e) {
31
- e.stopPropagation();
32
- });
33
- document.body.appendChild(mark);
34
- range.selectNodeContents(mark);
35
- selection.addRange(range);
36
- const successful = document.execCommand("copy");
37
- if (!successful) {
38
- throw new Error("copy command was unsuccessful");
39
- }
40
- success = true;
41
- }
42
- catch (err) {
43
- debug && console.error("unable to copy using execCommand: ", err);
44
- debug && console.warn("trying IE specific stuff");
11
+ return __awaiter(this, void 0, void 0, function* () {
45
12
  try {
46
- window.clipboardData.setData("text", text);
47
- success = true;
13
+ yield navigator.clipboard.writeText(text);
48
14
  }
49
15
  catch (err) {
50
- debug && console.error("unable to copy using clipboardData: ", err);
51
- debug && console.error("falling back to prompt");
52
- message = format(defaultMessage);
53
- window.prompt(message, text);
54
- }
55
- }
56
- finally {
57
- if (selection) {
58
- if (typeof selection.removeRange == "function") {
59
- selection.removeRange(range);
16
+ if (process.env.NODE_ENV !== "production") {
17
+ console.error("Unable to copy using Clipboard API", err);
60
18
  }
61
- else {
62
- selection.removeAllRanges();
63
- }
64
- }
65
- if (mark) {
66
- document.body.removeChild(mark);
19
+ // Fallback for browsers that do not support the Clipboard API.
20
+ const copyKey = /mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl";
21
+ const message = `Kopier til utklippstavle: ${copyKey}+C, Enter`;
22
+ window.prompt(message, text);
67
23
  }
68
- }
69
- return success;
24
+ });
70
25
  }
71
26
  //# sourceMappingURL=copy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/util/copy.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,MAAM,cAAc,GAAG,yCAAyC,CAAC;AAEjE,SAAS,MAAM,CAAC,OAAO;IACrB,MAAM,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC9E,OAAO,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,IAAI;IAC/B,IAAI,KAAK,EACP,OAAO,EACP,KAAK,EACL,SAAS,EACT,IAAI,EACJ,OAAO,GAAG,KAAK,CAAC;IAClB,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAC9C,IAAI;QACF,KAAK,GA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zC,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;aAC1D;YAED,+DAA+D;YAC/D,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;YACrE,MAAM,OAAO,GAAG,6BAA6B,OAAO,WAAW,CAAC;YAChE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SAC9B;IACH,CAAC;CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Aksel react-components for NAV designsystem",
5
5
  "author": "Aksel | NAV designsystem team",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@floating-ui/react": "0.24.1",
41
- "@navikt/aksel-icons": "^3.3.0",
41
+ "@navikt/aksel-icons": "^3.4.0",
42
42
  "@radix-ui/react-tabs": "1.0.0",
43
43
  "@radix-ui/react-toggle-group": "1.0.0",
44
44
  "clsx": "^1.2.1",
@@ -123,7 +123,7 @@ export const Link = () => (
123
123
 
124
124
  export const Loading = {
125
125
  render: () => (
126
- <div className="colgap">
126
+ <div className="colgap chromatic-ignore">
127
127
  <div className="rowgap">
128
128
  {variants.map((variant) => (
129
129
  <Button key={variant} variant={variant} loading>
@@ -153,7 +153,7 @@ export const Loading = {
153
153
  };
154
154
 
155
155
  export const Icon = () => (
156
- <div className="colgap">
156
+ <div className="colgap ">
157
157
  <div className="rowgap">
158
158
  {variants.map((variant) => (
159
159
  <Button
@@ -250,7 +250,7 @@ export const Disabled = () => (
250
250
 
251
251
  export const LoadingWithAs = {
252
252
  render: () => (
253
- <div className="colgap">
253
+ <div className="colgap chromatic-ignore">
254
254
  <div className="rowgap">
255
255
  {variants.map((variant) => (
256
256
  <Button key={variant} variant={variant} loading size="small">
package/src/tag/Tag.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, HTMLAttributes } from "react";
2
2
  import cl from "clsx";
3
- import { BodyShort, Detail } from "..";
3
+ import { BodyShort } from "..";
4
4
 
5
5
  export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
6
6
  children: React.ReactNode;
@@ -10,20 +10,28 @@ export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
10
10
  variant:
11
11
  | "warning"
12
12
  | "warning-filled"
13
+ | "warning-moderate"
13
14
  | "error"
14
15
  | "error-filled"
16
+ | "error-moderate"
15
17
  | "info"
16
18
  | "info-filled"
19
+ | "info-moderate"
17
20
  | "success"
18
21
  | "success-filled"
22
+ | "success-moderate"
19
23
  | "neutral"
20
24
  | "neutral-filled"
25
+ | "neutral-moderate"
21
26
  | "alt1"
22
27
  | "alt1-filled"
28
+ | "alt1-moderate"
23
29
  | "alt2"
24
30
  | "alt2-filled"
31
+ | "alt2-moderate"
25
32
  | "alt3"
26
- | "alt3-filled";
33
+ | "alt3-filled"
34
+ | "alt3-moderate";
27
35
  /**
28
36
  * @default "medium"
29
37
  */
@@ -31,24 +39,20 @@ export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
31
39
  }
32
40
 
33
41
  export const Tag = forwardRef<HTMLSpanElement, TagProps>(
34
- ({ className, variant, size = "medium", ...rest }, ref) => {
35
- const Component = size === "medium" ? BodyShort : Detail;
36
-
37
- return (
38
- <Component
39
- {...rest}
40
- ref={ref}
41
- as="span"
42
- size={size === "medium" ? "medium" : "small"}
43
- className={cl(
44
- "navds-tag",
45
- className,
46
- `navds-tag--${variant}`,
47
- `navds-tag--${size}`
48
- )}
49
- />
50
- );
51
- }
42
+ ({ className, variant, size = "medium", ...rest }, ref) => (
43
+ <BodyShort
44
+ {...rest}
45
+ ref={ref}
46
+ as="span"
47
+ size={size === "medium" ? "medium" : "small"}
48
+ className={cl(
49
+ "navds-tag",
50
+ className,
51
+ `navds-tag--${variant}`,
52
+ `navds-tag--${size}`
53
+ )}
54
+ />
55
+ )
52
56
  );
53
57
 
54
58
  export default Tag;
@@ -1,62 +1,8 @@
1
1
  import React from "react";
2
- import { Tag } from ".";
2
+ import type { Meta } from "@storybook/react";
3
+ import { Tag, TagProps } from ".";
3
4
 
4
- export default {
5
- title: "ds-react/Tag",
6
- component: Tag,
7
- argTypes: {
8
- variant: {
9
- defaultValue: "info",
10
- control: {
11
- type: "radio",
12
- options: [
13
- "warning",
14
- "error",
15
- "info",
16
- "success",
17
- "neutral",
18
- "alt1",
19
- "alt2",
20
- "alt3",
21
- "warning-filled",
22
- "error-filled",
23
- "info-filled",
24
- "success-filled",
25
- "neutral-filled",
26
- "alt1-filled",
27
- "alt2-filled",
28
- "alt3-filled",
29
- ],
30
- },
31
- },
32
- size: {
33
- defaultValue: "medium",
34
- control: {
35
- type: "radio",
36
- options: ["xsmall", "small", "medium"],
37
- },
38
- },
39
- },
40
- };
41
-
42
- const variants: Array<
43
- | "warning"
44
- | "warning-filled"
45
- | "error"
46
- | "error-filled"
47
- | "info"
48
- | "info-filled"
49
- | "success"
50
- | "success-filled"
51
- | "neutral"
52
- | "neutral-filled"
53
- | "alt1"
54
- | "alt1-filled"
55
- | "alt2"
56
- | "alt2-filled"
57
- | "alt3"
58
- | "alt3-filled"
59
- > = [
5
+ const variants: TagProps["variant"][] = [
60
6
  "warning",
61
7
  "error",
62
8
  "info",
@@ -73,8 +19,37 @@ const variants: Array<
73
19
  "alt1-filled",
74
20
  "alt2-filled",
75
21
  "alt3-filled",
22
+ "warning-moderate",
23
+ "error-moderate",
24
+ "info-moderate",
25
+ "success-moderate",
26
+ "neutral-moderate",
27
+ "alt1-moderate",
28
+ "alt2-moderate",
29
+ "alt3-moderate",
76
30
  ];
77
31
 
32
+ export default {
33
+ title: "ds-react/Tag",
34
+ component: Tag,
35
+ argTypes: {
36
+ variant: {
37
+ defaultValue: "info",
38
+ control: {
39
+ type: "radio",
40
+ },
41
+ options: variants,
42
+ },
43
+ size: {
44
+ defaultValue: "medium",
45
+ control: {
46
+ type: "radio",
47
+ },
48
+ options: ["xsmall", "small", "medium"],
49
+ },
50
+ },
51
+ } satisfies Meta<typeof Tag>;
52
+
78
53
  export const Default = {
79
54
  render: (props) => (
80
55
  <Tag variant={props.variant} size={props.size}>
package/src/util/copy.ts CHANGED
@@ -1,81 +1,14 @@
1
- // https://github.com/sudodoki/copy-to-clipboard/blob/main/index.js
2
-
3
- const defaultMessage = "Kopier til utklippstavle: #{key}, Enter";
4
-
5
- function format(message) {
6
- const copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
7
- return message.replace(/#{\s*key\s*}/g, copyKey);
8
- }
9
-
10
- export default function copy(text) {
11
- let debug,
12
- message,
13
- range,
14
- selection,
15
- mark,
16
- success = false;
17
- debug = process.env.NODE_ENV !== "production";
1
+ export default async function copy(text: string): Promise<void> {
18
2
  try {
19
- range = document.createRange();
20
- selection = document.getSelection();
21
-
22
- mark = document.createElement("span");
23
- mark.textContent = text;
24
- // avoid screen readers from reading out loud the text
25
- mark.ariaHidden = "true";
26
- // reset user styles for span element
27
- mark.style.all = "unset";
28
- // prevents scrolling to the end of the page
29
- mark.style.position = "fixed";
30
- mark.style.top = 0;
31
- mark.style.clip = "rect(0, 0, 0, 0)";
32
- // used to preserve spaces and line breaks
33
- mark.style.whiteSpace = "pre";
34
- // do not inherit user-select (it may be `none`)
35
- mark.style.webkitUserSelect = "text";
36
- mark.style.MozUserSelect = "text";
37
- mark.style.msUserSelect = "text";
38
- mark.style.userSelect = "text";
39
- mark.addEventListener("copy", function (e) {
40
- e.stopPropagation();
41
- });
42
-
43
- document.body.appendChild(mark);
44
-
45
- range.selectNodeContents(mark);
46
- selection.addRange(range);
47
-
48
- const successful = document.execCommand("copy");
49
- if (!successful) {
50
- throw new Error("copy command was unsuccessful");
51
- }
52
- success = true;
3
+ await navigator.clipboard.writeText(text);
53
4
  } catch (err) {
54
- debug && console.error("unable to copy using execCommand: ", err);
55
- debug && console.warn("trying IE specific stuff");
56
- try {
57
- (window as any).clipboardData.setData("text", text);
58
-
59
- success = true;
60
- } catch (err) {
61
- debug && console.error("unable to copy using clipboardData: ", err);
62
- debug && console.error("falling back to prompt");
63
- message = format(defaultMessage);
64
- window.prompt(message, text);
65
- }
66
- } finally {
67
- if (selection) {
68
- if (typeof selection.removeRange == "function") {
69
- selection.removeRange(range);
70
- } else {
71
- selection.removeAllRanges();
72
- }
5
+ if (process.env.NODE_ENV !== "production") {
6
+ console.error("Unable to copy using Clipboard API", err);
73
7
  }
74
8
 
75
- if (mark) {
76
- document.body.removeChild(mark);
77
- }
9
+ // Fallback for browsers that do not support the Clipboard API.
10
+ const copyKey = /mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl";
11
+ const message = `Kopier til utklippstavle: ${copyKey}+C, Enter`;
12
+ window.prompt(message, text);
78
13
  }
79
-
80
- return success;
81
14
  }