@felleslosninger/minid-elements 0.0.140 → 0.1.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 (89) hide show
  1. package/README.md +69 -4
  2. package/dist/components/alert.component.d.ts +6 -4
  3. package/dist/components/alert.component.d.ts.map +1 -1
  4. package/dist/components/alert.js +33 -61
  5. package/dist/components/alert.js.map +1 -1
  6. package/dist/components/button.component.d.ts +1 -1
  7. package/dist/components/checkbox.component.d.ts +1 -2
  8. package/dist/components/checkbox.component.d.ts.map +1 -1
  9. package/dist/components/checkbox.js +25 -55
  10. package/dist/components/checkbox.js.map +1 -1
  11. package/dist/components/code-input-old.component.d.ts +1 -1
  12. package/dist/components/code-input-old.js +1 -1
  13. package/dist/components/code-input.component.d.ts +1 -1
  14. package/dist/components/code-input.component.d.ts.map +1 -1
  15. package/dist/components/code-input.js +232 -94
  16. package/dist/components/code-input.js.map +1 -1
  17. package/dist/components/combobox.component.d.ts +1 -1
  18. package/dist/components/countdown.component.d.ts +1 -1
  19. package/dist/components/dialog.component.d.ts +7 -1
  20. package/dist/components/dialog.component.d.ts.map +1 -1
  21. package/dist/components/dialog.js +19 -2
  22. package/dist/components/dialog.js.map +1 -1
  23. package/dist/components/dropdown.component.d.ts +1 -1
  24. package/dist/components/heading.component.d.ts +1 -1
  25. package/dist/components/heading.component.d.ts.map +1 -1
  26. package/dist/components/heading.js +1 -11
  27. package/dist/components/heading.js.map +1 -1
  28. package/dist/components/helptext.component.d.ts +1 -1
  29. package/dist/components/label.component.d.ts +1 -1
  30. package/dist/components/label.component.d.ts.map +1 -1
  31. package/dist/components/label.js +3 -12
  32. package/dist/components/label.js.map +1 -1
  33. package/dist/components/link.component.d.ts +1 -1
  34. package/dist/components/link.js +1 -1
  35. package/dist/components/link.js.map +1 -1
  36. package/dist/components/menu-item.component.d.ts +1 -1
  37. package/dist/components/menu.component.d.ts +1 -1
  38. package/dist/components/paragraph.component.d.ts +1 -1
  39. package/dist/components/paragraph.component.d.ts.map +1 -1
  40. package/dist/components/paragraph.js +2 -8
  41. package/dist/components/paragraph.js.map +1 -1
  42. package/dist/components/phone-input.component.d.ts +15 -3
  43. package/dist/components/phone-input.component.d.ts.map +1 -1
  44. package/dist/components/phone-input.js +37 -6
  45. package/dist/components/phone-input.js.map +1 -1
  46. package/dist/components/popup.component.d.ts +1 -1
  47. package/dist/components/qr-code.component.d.ts +1 -1
  48. package/dist/components/radio-button.component.d.ts +1 -1
  49. package/dist/components/radio-group.component.d.ts +1 -1
  50. package/dist/components/radio.component.d.ts +1 -1
  51. package/dist/components/radio.component.d.ts.map +1 -1
  52. package/dist/components/radio.js +12 -16
  53. package/dist/components/radio.js.map +1 -1
  54. package/dist/components/search.component.d.ts +11 -4
  55. package/dist/components/search.component.d.ts.map +1 -1
  56. package/dist/components/search.js +75 -31
  57. package/dist/components/search.js.map +1 -1
  58. package/dist/components/spinner.component.d.ts +1 -1
  59. package/dist/components/step-indicator.component.d.ts +1 -1
  60. package/dist/components/textfield.component.d.ts +5 -3
  61. package/dist/components/textfield.component.d.ts.map +1 -1
  62. package/dist/components/textfield.js +76 -84
  63. package/dist/components/textfield.js.map +1 -1
  64. package/dist/components/tooltip.component.d.ts +1 -1
  65. package/dist/components/validation-message.component.d.ts +1 -1
  66. package/dist/controllers/lang.controller.d.ts +14 -0
  67. package/dist/controllers/lang.controller.d.ts.map +1 -0
  68. package/dist/designsystemet-tailwind.css +355 -297
  69. package/dist/index.d.ts +2 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +4 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/lang.controller-P4W-9ipy.js +32 -0
  74. package/dist/lang.controller-P4W-9ipy.js.map +1 -0
  75. package/dist/mixins/validators.d.ts +1 -0
  76. package/dist/mixins/validators.d.ts.map +1 -1
  77. package/dist/mixins/validators.js +18 -1
  78. package/dist/mixins/validators.js.map +1 -1
  79. package/dist/styles.css +5 -0
  80. package/dist/theme.css +1155 -0
  81. package/dist/utilities/lang.d.ts +6 -0
  82. package/dist/utilities/lang.d.ts.map +1 -0
  83. package/dist/utilities/lang.js +18 -0
  84. package/dist/utilities/lang.js.map +1 -0
  85. package/dist/utilities/translations.d.ts +43 -0
  86. package/dist/utilities/translations.d.ts.map +1 -0
  87. package/dist/utilities/translations.js +49 -0
  88. package/dist/utilities/translations.js.map +1 -0
  89. package/package.json +34 -16
package/dist/index.d.ts CHANGED
@@ -26,4 +26,6 @@ export { MinidTooltip } from './components/tooltip.component.ts';
26
26
  export { MinidValidationMessage } from './components/validation-message.component.ts';
27
27
  export * from './events/events.ts';
28
28
  export * from './utilities/countries.ts';
29
+ export { setTranslations } from './utilities/translations.ts';
30
+ export type { ComponentTranslations } from './utilities/translations.ts';
29
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,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components/alert.js";
2
3
  import { MinidButton } from "./components/button.js";
3
4
  import { MinidCheckbox } from "./components/checkbox.js";
@@ -27,6 +28,7 @@ import { MinidValidationMessage } from "./components/validation-message.js";
27
28
  import { countryLabelsEn } from "./utilities/country-labels-en.js";
28
29
  import { countryLabelsNo } from "./utilities/country-labels-no.js";
29
30
  import { getCountries } from "libphonenumber-js";
31
+ import { setTranslations } from "./utilities/translations.js";
30
32
  export {
31
33
  MinidAlert,
32
34
  MinidButton,
@@ -56,6 +58,7 @@ export {
56
58
  MinidValidationMessage,
57
59
  countryLabelsEn,
58
60
  countryLabelsNo,
59
- getCountries
61
+ getCountries,
62
+ setTranslations
60
63
  };
61
64
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,32 @@
1
+ import { getLang } from "./utilities/lang.js";
2
+ class LangController {
3
+ constructor(host) {
4
+ this.managed = false;
5
+ (this.host = host).addController(this);
6
+ this.observer = new MutationObserver(() => this.handleDocumentLangChange());
7
+ }
8
+ hostConnected() {
9
+ if (!this.host.hasAttribute("lang")) {
10
+ this.host.setAttribute("lang", getLang(this.host));
11
+ this.managed = true;
12
+ }
13
+ this.observer.observe(document.documentElement, {
14
+ attributes: true,
15
+ attributeFilter: ["lang"]
16
+ });
17
+ }
18
+ hostDisconnected() {
19
+ this.observer.disconnect();
20
+ }
21
+ handleDocumentLangChange() {
22
+ if (this.managed) {
23
+ this.host.removeAttribute("lang");
24
+ this.host.setAttribute("lang", getLang(this.host));
25
+ }
26
+ this.host.requestUpdate();
27
+ }
28
+ }
29
+ export {
30
+ LangController as L
31
+ };
32
+ //# sourceMappingURL=lang.controller-P4W-9ipy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lang.controller-P4W-9ipy.js","sources":["../src/controllers/lang.controller.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport { getLang } from '../utilities/lang.js';\n\n/**\n * Reactive controller that keeps a component in sync with the active language.\n */\nexport class LangController implements ReactiveController {\n private readonly host: ReactiveControllerHost & HTMLElement;\n private readonly observer: MutationObserver;\n private managed = false;\n\n constructor(host: ReactiveControllerHost & HTMLElement) {\n (this.host = host).addController(this);\n this.observer = new MutationObserver(() => this.handleDocumentLangChange());\n }\n\n hostConnected() {\n if (!this.host.hasAttribute('lang')) {\n this.host.setAttribute('lang', getLang(this.host));\n this.managed = true;\n }\n\n this.observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['lang'],\n });\n }\n\n hostDisconnected() {\n this.observer.disconnect();\n }\n\n private handleDocumentLangChange() {\n if (this.managed) {\n this.host.removeAttribute('lang');\n this.host.setAttribute('lang', getLang(this.host));\n }\n this.host.requestUpdate();\n }\n}\n"],"names":[],"mappings":";AAMO,MAAM,eAA6C;AAAA,EAKxD,YAAY,MAA4C;AAFxD,SAAQ,UAAU;AAGhB,KAAC,KAAK,OAAO,MAAM,cAAc,IAAI;AACrC,SAAK,WAAW,IAAI,iBAAiB,MAAM,KAAK,0BAA0B;AAAA,EAC5E;AAAA,EAEA,gBAAgB;AACd,QAAI,CAAC,KAAK,KAAK,aAAa,MAAM,GAAG;AACnC,WAAK,KAAK,aAAa,QAAQ,QAAQ,KAAK,IAAI,CAAC;AACjD,WAAK,UAAU;AAAA,IACjB;AAEA,SAAK,SAAS,QAAQ,SAAS,iBAAiB;AAAA,MAC9C,YAAY;AAAA,MACZ,iBAAiB,CAAC,MAAM;AAAA,IAAA,CACzB;AAAA,EACH;AAAA,EAEA,mBAAmB;AACjB,SAAK,SAAS,WAAA;AAAA,EAChB;AAAA,EAEQ,2BAA2B;AACjC,QAAI,KAAK,SAAS;AAChB,WAAK,KAAK,gBAAgB,MAAM;AAChC,WAAK,KAAK,aAAa,QAAQ,QAAQ,KAAK,IAAI,CAAC;AAAA,IACnD;AACA,SAAK,KAAK,cAAA;AAAA,EACZ;AACF;"}
@@ -3,4 +3,5 @@ export declare const requiredValidator: Validator;
3
3
  export declare const minLengthValidator: Validator;
4
4
  export declare const maxLengthValidator: Validator;
5
5
  export declare const patternValidator: Validator;
6
+ export declare const typeMismatchValidator: Validator;
6
7
  //# sourceMappingURL=validators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/mixins/validators.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,eAAO,MAAM,iBAAiB,EAAE,SAgB/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAyBhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAyBhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAa9B,CAAC"}
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/mixins/validators.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,eAAO,MAAM,iBAAiB,EAAE,SAgB/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAyBhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAyBhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAa9B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,SAyBnC,CAAC"}
@@ -56,10 +56,27 @@ const patternValidator = {
56
56
  return !!regExp.exec(value);
57
57
  }
58
58
  };
59
+ const typeMismatchValidator = {
60
+ attribute: "type",
61
+ key: "typeMismatch",
62
+ message(instance) {
63
+ return instance.input?.validationMessage || "Please enter a valid value";
64
+ },
65
+ isValid(instance, value) {
66
+ if (!value || typeof value !== "string" || instance.type !== "email" && instance.type !== "url" || typeof document === "undefined") {
67
+ return true;
68
+ }
69
+ const input = document.createElement("input");
70
+ input.type = instance.type;
71
+ input.value = value;
72
+ return !input.validity.typeMismatch;
73
+ }
74
+ };
59
75
  export {
60
76
  maxLengthValidator,
61
77
  minLengthValidator,
62
78
  patternValidator,
63
- requiredValidator
79
+ requiredValidator,
80
+ typeMismatchValidator
64
81
  };
65
82
  //# sourceMappingURL=validators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validators.js","sources":["../../src/mixins/validators.ts"],"sourcesContent":["import type { FormControlInterface } from '../types/form-control';\nimport type { FormValue } from '../types/form-value';\nimport type { Validator } from '../types/validator.type';\n\nexport const requiredValidator: Validator = {\n attribute: 'required',\n key: 'valueMissing',\n message: 'Please fill out this field',\n isValid(\n instance: HTMLElement & { required: boolean },\n value: FormValue\n ): boolean {\n let valid = true;\n\n if ((instance.hasAttribute('required') || instance.required) && !value) {\n valid = false;\n }\n\n return valid;\n },\n};\n\nexport const minLengthValidator: Validator = {\n attribute: 'minlength',\n key: 'tooShort',\n message(\n instance: FormControlInterface & { minlength: number },\n value: FormValue\n ): string {\n const _value = (value as string) || '';\n return `Please use at least ${instance.minlength} characters (you are currently using ${_value.length} characters).`;\n },\n isValid(\n instance: HTMLElement & { minlength: number },\n value: string\n ): boolean {\n /** If no value is provided, this validator should return true */\n if (!value) {\n return true;\n }\n\n if (!!value && instance.minlength > value.length) {\n return false;\n }\n\n return true;\n },\n};\n\nexport const maxLengthValidator: Validator = {\n attribute: 'maxlength',\n key: 'tooLong',\n message(\n instance: FormControlInterface & { maxLength: number },\n value: FormValue\n ): string {\n const _value = (value as string) || '';\n return `Please use no more than ${instance.maxLength} characters (you are currently using ${_value.length} characters).`;\n },\n isValid(\n instance: HTMLElement & { maxLength: number },\n value: string\n ): boolean {\n /** If maxLength isn't set, this is valid */\n if (!instance.maxLength) {\n return true;\n }\n\n if (!!value && instance.maxLength < value.length) {\n return false;\n }\n\n return true;\n },\n};\n\nexport const patternValidator: Validator = {\n attribute: 'pattern',\n key: 'patternMismatch',\n message: 'Please match the requested format',\n isValid(instance: HTMLElement & { pattern: string }, value: string): boolean {\n /** If no value is provided, this validator should return true */\n if (!value || !instance.pattern) {\n return true;\n }\n\n const regExp = new RegExp(instance.pattern);\n return !!regExp.exec(value);\n },\n};\n"],"names":[],"mappings":"AAIO,MAAM,oBAA+B;AAAA,EAC1C,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,QACE,UACA,OACS;AACT,QAAI,QAAQ;AAEZ,SAAK,SAAS,aAAa,UAAU,KAAK,SAAS,aAAa,CAAC,OAAO;AACtE,cAAQ;AAAA,IACV;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,qBAAgC;AAAA,EAC3C,WAAW;AAAA,EACX,KAAK;AAAA,EACL,QACE,UACA,OACQ;AACR,UAAM,SAAU,SAAoB;AACpC,WAAO,uBAAuB,SAAS,SAAS,wCAAwC,OAAO,MAAM;AAAA,EACvG;AAAA,EACA,QACE,UACA,OACS;AAET,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,CAAC,SAAS,SAAS,YAAY,MAAM,QAAQ;AAChD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,qBAAgC;AAAA,EAC3C,WAAW;AAAA,EACX,KAAK;AAAA,EACL,QACE,UACA,OACQ;AACR,UAAM,SAAU,SAAoB;AACpC,WAAO,2BAA2B,SAAS,SAAS,wCAAwC,OAAO,MAAM;AAAA,EAC3G;AAAA,EACA,QACE,UACA,OACS;AAET,QAAI,CAAC,SAAS,WAAW;AACvB,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,CAAC,SAAS,SAAS,YAAY,MAAM,QAAQ;AAChD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,mBAA8B;AAAA,EACzC,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,QAAQ,UAA6C,OAAwB;AAE3E,QAAI,CAAC,SAAS,CAAC,SAAS,SAAS;AAC/B,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,IAAI,OAAO,SAAS,OAAO;AAC1C,WAAO,CAAC,CAAC,OAAO,KAAK,KAAK;AAAA,EAC5B;AACF;"}
1
+ {"version":3,"file":"validators.js","sources":["../../src/mixins/validators.ts"],"sourcesContent":["import type { FormControlInterface } from '../types/form-control';\nimport type { FormValue } from '../types/form-value';\nimport type { Validator } from '../types/validator.type';\n\nexport const requiredValidator: Validator = {\n attribute: 'required',\n key: 'valueMissing',\n message: 'Please fill out this field',\n isValid(\n instance: HTMLElement & { required: boolean },\n value: FormValue\n ): boolean {\n let valid = true;\n\n if ((instance.hasAttribute('required') || instance.required) && !value) {\n valid = false;\n }\n\n return valid;\n },\n};\n\nexport const minLengthValidator: Validator = {\n attribute: 'minlength',\n key: 'tooShort',\n message(\n instance: FormControlInterface & { minlength: number },\n value: FormValue\n ): string {\n const _value = (value as string) || '';\n return `Please use at least ${instance.minlength} characters (you are currently using ${_value.length} characters).`;\n },\n isValid(\n instance: HTMLElement & { minlength: number },\n value: string\n ): boolean {\n /** If no value is provided, this validator should return true */\n if (!value) {\n return true;\n }\n\n if (!!value && instance.minlength > value.length) {\n return false;\n }\n\n return true;\n },\n};\n\nexport const maxLengthValidator: Validator = {\n attribute: 'maxlength',\n key: 'tooLong',\n message(\n instance: FormControlInterface & { maxLength: number },\n value: FormValue\n ): string {\n const _value = (value as string) || '';\n return `Please use no more than ${instance.maxLength} characters (you are currently using ${_value.length} characters).`;\n },\n isValid(\n instance: HTMLElement & { maxLength: number },\n value: string\n ): boolean {\n /** If maxLength isn't set, this is valid */\n if (!instance.maxLength) {\n return true;\n }\n\n if (!!value && instance.maxLength < value.length) {\n return false;\n }\n\n return true;\n },\n};\n\nexport const patternValidator: Validator = {\n attribute: 'pattern',\n key: 'patternMismatch',\n message: 'Please match the requested format',\n isValid(instance: HTMLElement & { pattern: string }, value: string): boolean {\n /** If no value is provided, this validator should return true */\n if (!value || !instance.pattern) {\n return true;\n }\n\n const regExp = new RegExp(instance.pattern);\n return !!regExp.exec(value);\n },\n};\n\nexport const typeMismatchValidator: Validator = {\n attribute: 'type',\n key: 'typeMismatch',\n message(instance: HTMLElement & { input?: HTMLInputElement }): string {\n return instance.input?.validationMessage || 'Please enter a valid value';\n },\n isValid(\n instance: HTMLElement & { type?: HTMLInputElement['type'] },\n value: FormValue\n ): boolean {\n if (\n !value ||\n typeof value !== 'string' ||\n (instance.type !== 'email' && instance.type !== 'url') ||\n typeof document === 'undefined'\n ) {\n return true;\n }\n\n const input = document.createElement('input');\n input.type = instance.type;\n input.value = value;\n\n return !input.validity.typeMismatch;\n },\n};\n"],"names":[],"mappings":"AAIO,MAAM,oBAA+B;AAAA,EAC1C,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,QACE,UACA,OACS;AACT,QAAI,QAAQ;AAEZ,SAAK,SAAS,aAAa,UAAU,KAAK,SAAS,aAAa,CAAC,OAAO;AACtE,cAAQ;AAAA,IACV;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,qBAAgC;AAAA,EAC3C,WAAW;AAAA,EACX,KAAK;AAAA,EACL,QACE,UACA,OACQ;AACR,UAAM,SAAU,SAAoB;AACpC,WAAO,uBAAuB,SAAS,SAAS,wCAAwC,OAAO,MAAM;AAAA,EACvG;AAAA,EACA,QACE,UACA,OACS;AAET,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,CAAC,SAAS,SAAS,YAAY,MAAM,QAAQ;AAChD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,qBAAgC;AAAA,EAC3C,WAAW;AAAA,EACX,KAAK;AAAA,EACL,QACE,UACA,OACQ;AACR,UAAM,SAAU,SAAoB;AACpC,WAAO,2BAA2B,SAAS,SAAS,wCAAwC,OAAO,MAAM;AAAA,EAC3G;AAAA,EACA,QACE,UACA,OACS;AAET,QAAI,CAAC,SAAS,WAAW;AACvB,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,CAAC,SAAS,SAAS,YAAY,MAAM,QAAQ;AAChD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,mBAA8B;AAAA,EACzC,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,QAAQ,UAA6C,OAAwB;AAE3E,QAAI,CAAC,SAAS,CAAC,SAAS,SAAS;AAC/B,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,IAAI,OAAO,SAAS,OAAO;AAC1C,WAAO,CAAC,CAAC,OAAO,KAAK,KAAK;AAAA,EAC5B;AACF;AAEO,MAAM,wBAAmC;AAAA,EAC9C,WAAW;AAAA,EACX,KAAK;AAAA,EACL,QAAQ,UAA8D;AACpE,WAAO,SAAS,OAAO,qBAAqB;AAAA,EAC9C;AAAA,EACA,QACE,UACA,OACS;AACT,QACE,CAAC,SACD,OAAO,UAAU,YAChB,SAAS,SAAS,WAAW,SAAS,SAAS,SAChD,OAAO,aAAa,aACpB;AACA,aAAO;AAAA,IACT;AAEA,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,OAAO,SAAS;AACtB,UAAM,QAAQ;AAEd,WAAO,CAAC,MAAM,SAAS;AAAA,EACzB;AACF;"}
@@ -0,0 +1,5 @@
1
+ @layer theme, base, ds.theme, ds.base, ds.components, components, utilities;
2
+ @import './theme.css' layer(ds.theme);
3
+ @import '@digdir/designsystemet-css';
4
+ @import './designsystemet-tailwind.css';
5
+ @import './index.css' layer(ds.base);