@inera/ids-react 6.2.0 → 7.0.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.
Files changed (219) hide show
  1. package/components/accordion/accordion.d.ts +1 -1
  2. package/components/accordion/accordion.js +6 -7
  3. package/components/agent/agent.d.ts +1 -1
  4. package/components/agent/agent.js +2 -2
  5. package/components/alert/alert.d.ts +1 -1
  6. package/components/alert/alert.js +9 -2
  7. package/components/alert-global/alert-global.d.ts +2 -2
  8. package/components/alert-global/alert-global.js +6 -7
  9. package/components/badge/badge.d.ts +4 -3
  10. package/components/badge/badge.js +4 -3
  11. package/components/box-link/box-link.d.ts +11 -3
  12. package/components/box-link/box-link.js +9 -9
  13. package/components/breadcrumbs/breadcrumbs.d.ts +1 -1
  14. package/components/breadcrumbs/breadcrumbs.js +4 -2
  15. package/components/button/button.d.ts +23 -5
  16. package/components/button/button.js +94 -11
  17. package/components/button-group/button-group.d.ts +13 -3
  18. package/components/button-group/button-group.js +10 -9
  19. package/components/card/card.d.ts +4 -3
  20. package/components/card/card.js +16 -8
  21. package/components/carousel/carousel-item.d.ts +10 -0
  22. package/components/carousel/carousel-item.js +24 -0
  23. package/components/carousel/carousel.d.ts +11 -5
  24. package/components/carousel/carousel.js +167 -16
  25. package/components/date-label/date-label.d.ts +2 -2
  26. package/components/date-label/date-label.js +4 -40
  27. package/components/dialog/dialog.d.ts +23 -6
  28. package/components/dialog/dialog.js +75 -13
  29. package/components/dropdown/dropdown-content-link.d.ts +6 -0
  30. package/components/dropdown/dropdown-content-link.js +20 -0
  31. package/components/dropdown/dropdown.d.ts +16 -8
  32. package/components/dropdown/dropdown.js +72 -20
  33. package/components/footer-1177/footer-1177.d.ts +23 -3
  34. package/components/footer-1177/footer-1177.js +64 -9
  35. package/components/footer-1177-admin/footer-1177-admin.d.ts +21 -3
  36. package/components/footer-1177-admin/footer-1177-admin.js +63 -9
  37. package/components/footer-1177-pro/footer-1177-pro.d.ts +17 -3
  38. package/components/footer-1177-pro/footer-1177-pro.js +39 -9
  39. package/components/footer-inera/footer-inera.d.ts +23 -3
  40. package/components/footer-inera/footer-inera.js +64 -9
  41. package/components/footer-inera-admin/footer-inera-admin.d.ts +23 -3
  42. package/components/footer-inera-admin/footer-inera-admin.js +61 -9
  43. package/components/form/check-button/check-button.d.ts +7 -3
  44. package/components/form/check-button/check-button.js +8 -5
  45. package/components/form/checkbox/checkbox-group.d.ts +13 -3
  46. package/components/form/checkbox/checkbox-group.js +51 -9
  47. package/components/form/checkbox/checkbox.d.ts +17 -3
  48. package/components/form/checkbox/checkbox.js +50 -5
  49. package/components/form/error-message/error-message.d.ts +10 -0
  50. package/components/form/error-message/error-message.js +12 -0
  51. package/components/form/form-hooks/useAriaDescribedBy.d.ts +1 -0
  52. package/components/form/form-hooks/useAriaDescribedBy.js +26 -0
  53. package/components/form/form-hooks/useGroupValidity.d.ts +1 -0
  54. package/components/form/form-hooks/useGroupValidity.js +60 -0
  55. package/components/form/form-hooks/useInputValidity.d.ts +1 -0
  56. package/components/form/form-hooks/useInputValidity.js +27 -0
  57. package/components/form/input/input.d.ts +22 -3
  58. package/components/form/input/input.js +51 -9
  59. package/components/form/radio/radio-group.d.ts +13 -3
  60. package/components/form/radio/radio-group.js +28 -5
  61. package/components/form/radio/radio.d.ts +17 -3
  62. package/components/form/radio/radio.js +23 -9
  63. package/components/form/radio-button/radio-button-group.d.ts +9 -0
  64. package/components/form/radio-button/radio-button-group.js +22 -0
  65. package/components/form/radio-button/radio-button.d.ts +9 -0
  66. package/components/form/radio-button/radio-button.js +13 -0
  67. package/components/form/range/range.d.ts +16 -3
  68. package/components/form/range/range.js +29 -9
  69. package/components/form/select/select.d.ts +15 -3
  70. package/components/form/select/select.js +19 -9
  71. package/components/form/select-multiple/select-multiple.d.ts +18 -3
  72. package/components/form/select-multiple/select-multiple.js +60 -9
  73. package/components/form/spinner/spinner.d.ts +9 -3
  74. package/components/form/spinner/spinner.js +9 -9
  75. package/components/form/textarea/textarea.d.ts +18 -3
  76. package/components/form/textarea/textarea.js +26 -9
  77. package/components/form/time/time.d.ts +13 -3
  78. package/components/form/time/time.js +21 -9
  79. package/components/form/toggle/toggle.d.ts +8 -3
  80. package/components/form/toggle/toggle.js +10 -9
  81. package/components/grid/column.d.ts +16 -0
  82. package/components/grid/column.js +13 -0
  83. package/components/grid/container.d.ts +9 -0
  84. package/components/grid/container.js +24 -0
  85. package/components/grid/row.d.ts +9 -0
  86. package/components/grid/row.js +18 -0
  87. package/components/header-1177/header-1177-avatar.d.ts +10 -2
  88. package/components/header-1177/header-1177-avatar.js +30 -8
  89. package/components/header-1177/header-1177-item.d.ts +12 -2
  90. package/components/header-1177/header-1177-item.js +25 -8
  91. package/components/header-1177/header-1177-menu-mobile.d.ts +11 -0
  92. package/components/header-1177/header-1177-menu-mobile.js +42 -0
  93. package/components/header-1177/header-1177-nav-item-mobile.d.ts +11 -2
  94. package/components/header-1177/header-1177-nav-item-mobile.js +24 -8
  95. package/components/header-1177/header-1177-nav-item.d.ts +15 -2
  96. package/components/header-1177/header-1177-nav-item.js +22 -8
  97. package/components/header-1177/header-1177-nav.d.ts +8 -2
  98. package/components/header-1177/header-1177-nav.js +14 -8
  99. package/components/header-1177/header-1177.d.ts +22 -5
  100. package/components/header-1177/header-1177.js +41 -12
  101. package/components/header-1177-admin/header-1177-admin-avatar-mobile.d.ts +9 -2
  102. package/components/header-1177-admin/header-1177-admin-avatar-mobile.js +6 -8
  103. package/components/header-1177-admin/header-1177-admin-avatar.d.ts +10 -2
  104. package/components/header-1177-admin/header-1177-admin-avatar.js +31 -8
  105. package/components/header-1177-admin/header-1177-admin-item.d.ts +12 -2
  106. package/components/header-1177-admin/header-1177-admin-item.js +26 -8
  107. package/components/header-1177-admin/header-1177-admin-nav-item.d.ts +15 -2
  108. package/components/header-1177-admin/header-1177-admin-nav-item.js +24 -8
  109. package/components/header-1177-admin/header-1177-admin-nav.d.ts +7 -2
  110. package/components/header-1177-admin/header-1177-admin-nav.js +12 -8
  111. package/components/header-1177-admin/header-1177-admin.d.ts +22 -3
  112. package/components/header-1177-admin/header-1177-admin.js +26 -9
  113. package/components/header-1177-pro/header-1177-pro-avatar-mobile.d.ts +9 -2
  114. package/components/header-1177-pro/header-1177-pro-avatar-mobile.js +6 -8
  115. package/components/header-1177-pro/header-1177-pro-avatar.d.ts +10 -2
  116. package/components/header-1177-pro/header-1177-pro-avatar.js +31 -8
  117. package/components/header-1177-pro/header-1177-pro-item.d.ts +12 -2
  118. package/components/header-1177-pro/header-1177-pro-item.js +23 -8
  119. package/components/header-1177-pro/header-1177-pro-nav-item.d.ts +15 -2
  120. package/components/header-1177-pro/header-1177-pro-nav-item.js +33 -8
  121. package/components/header-1177-pro/header-1177-pro-nav-menu-mobile.d.ts +11 -5
  122. package/components/header-1177-pro/header-1177-pro-nav-menu-mobile.js +32 -12
  123. package/components/header-1177-pro/header-1177-pro-nav.d.ts +10 -2
  124. package/components/header-1177-pro/header-1177-pro-nav.js +27 -8
  125. package/components/header-1177-pro/header-1177-pro.d.ts +23 -5
  126. package/components/header-1177-pro/header-1177-pro.js +37 -12
  127. package/components/header-inera/header-inera-item.d.ts +13 -2
  128. package/components/header-inera/header-inera-item.js +24 -8
  129. package/components/header-inera/header-inera-nav-item.d.ts +15 -2
  130. package/components/header-inera/header-inera-nav-item.js +54 -8
  131. package/components/header-inera/header-inera-nav-mobile.d.ts +11 -5
  132. package/components/header-inera/header-inera-nav-mobile.js +44 -12
  133. package/components/header-inera/header-inera-nav.d.ts +7 -2
  134. package/components/header-inera/header-inera-nav.js +13 -8
  135. package/components/header-inera/header-inera.d.ts +16 -3
  136. package/components/header-inera/header-inera.js +16 -9
  137. package/components/header-inera-admin/header-inera-admin-avatar-mobile.d.ts +9 -2
  138. package/components/header-inera-admin/header-inera-admin-avatar-mobile.js +11 -8
  139. package/components/header-inera-admin/header-inera-admin-avatar.d.ts +12 -2
  140. package/components/header-inera-admin/header-inera-admin-avatar.js +32 -8
  141. package/components/header-inera-admin/header-inera-admin-item.d.ts +13 -2
  142. package/components/header-inera-admin/header-inera-admin-item.js +24 -8
  143. package/components/header-inera-admin/header-inera-admin-nav-item.d.ts +16 -2
  144. package/components/header-inera-admin/header-inera-admin-nav-item.js +54 -8
  145. package/components/header-inera-admin/header-inera-admin-nav-mobile.d.ts +12 -5
  146. package/components/header-inera-admin/header-inera-admin-nav-mobile.js +32 -12
  147. package/components/header-inera-admin/header-inera-admin-nav.d.ts +8 -2
  148. package/components/header-inera-admin/header-inera-admin-nav.js +13 -8
  149. package/components/header-inera-admin/header-inera-admin.d.ts +15 -3
  150. package/components/header-inera-admin/header-inera-admin.js +24 -9
  151. package/components/header-patient/header-patient.d.ts +13 -0
  152. package/components/header-patient/header-patient.js +21 -0
  153. package/components/link/link.d.ts +17 -3
  154. package/components/link/link.js +42 -9
  155. package/components/mobile/menu/item/mobile-item.d.ts +15 -4
  156. package/components/mobile/menu/item/mobile-item.js +58 -11
  157. package/components/mobile/menu/mobile-menu.d.ts +7 -3
  158. package/components/mobile/menu/mobile-menu.js +9 -9
  159. package/components/navigation/content/navigation-content.d.ts +7 -3
  160. package/components/navigation/content/navigation-content.js +18 -9
  161. package/components/navigation/local/navigation-local.d.ts +7 -3
  162. package/components/navigation/local/navigation-local.js +6 -9
  163. package/components/notification/badge/notification-badge.d.ts +4 -2
  164. package/components/notification/badge/notification-badge.js +4 -3
  165. package/components/pagination/data-pagination/data-pagination.d.ts +24 -3
  166. package/components/pagination/data-pagination/data-pagination.js +14 -9
  167. package/components/pagination/list-pagination/list-pagination.d.ts +19 -7
  168. package/components/pagination/list-pagination/list-pagination.js +51 -14
  169. package/components/popover/popover.d.ts +20 -5
  170. package/components/popover/popover.js +192 -16
  171. package/components/progressbar/progressbar.d.ts +1 -1
  172. package/components/progressbar/progressbar.js +4 -2
  173. package/components/puff-list/puff-list-item/puff-list-item-info.d.ts +7 -0
  174. package/components/puff-list/puff-list-item/puff-list-item-info.js +8 -0
  175. package/components/puff-list/puff-list-item/puff-list-item.d.ts +18 -3
  176. package/components/puff-list/puff-list-item/puff-list-item.js +58 -9
  177. package/components/puff-list/puff-list.d.ts +7 -3
  178. package/components/puff-list/puff-list.js +6 -9
  179. package/components/region-icon/region-icon.d.ts +12 -0
  180. package/components/region-icon/region-icon.js +25 -0
  181. package/components/side-menu/side-menu.d.ts +16 -6
  182. package/components/side-menu/side-menu.js +52 -13
  183. package/components/side-panel/side-panel.d.ts +21 -6
  184. package/components/side-panel/side-panel.js +74 -13
  185. package/components/stepper/step.d.ts +18 -0
  186. package/components/stepper/step.js +41 -0
  187. package/components/stepper/stepper.d.ts +9 -7
  188. package/components/stepper/stepper.js +21 -19
  189. package/components/tabs/tab-panel.d.ts +11 -0
  190. package/components/tabs/tab-panel.js +20 -0
  191. package/components/tabs/tab.d.ts +15 -0
  192. package/components/tabs/tab.js +19 -0
  193. package/components/tabs/tabs.d.ts +14 -9
  194. package/components/tabs/tabs.js +79 -25
  195. package/components/tag/tag.d.ts +5 -6
  196. package/components/tag/tag.js +9 -9
  197. package/components/tooltip/tooltip.d.ts +10 -3
  198. package/components/tooltip/tooltip.js +79 -9
  199. package/components/utils/contexts/HeaderContext.d.ts +9 -0
  200. package/components/utils/contexts/HeaderContext.js +7 -0
  201. package/components/utils/hooks/useElementId.d.ts +5 -0
  202. package/components/utils/hooks/useElementId.js +12 -0
  203. package/components/utils/hooks/useFocusTrap.d.ts +1 -0
  204. package/components/utils/hooks/useFocusTrap.js +44 -0
  205. package/components/utils/utils.d.ts +6 -0
  206. package/components/utils/utils.js +44 -0
  207. package/index.d.ts +15 -5
  208. package/index.js +20 -10
  209. package/package.json +2 -2
  210. package/components/form/errormessage/error-message.d.ts +0 -3
  211. package/components/form/errormessage/error-message.js +0 -12
  212. package/components/grid/grid.d.ts +0 -9
  213. package/components/grid/grid.js +0 -26
  214. package/components/header-1177/header-1177-nav-menu-mobile.d.ts +0 -5
  215. package/components/header-1177/header-1177-nav-menu-mobile.js +0 -15
  216. package/components/icon-region/icon-region.d.ts +0 -3
  217. package/components/icon-region/icon-region.js +0 -12
  218. package/components/puff-list/puff-list-item/puff-list-info/puff-list-item-info.d.ts +0 -3
  219. package/components/puff-list/puff-list-item/puff-list-info/puff-list-item-info.js +0 -12
@@ -0,0 +1,26 @@
1
+ import { useEffect } from 'react';
2
+
3
+ function useAriaDescribedBy(ref, errorMsgId, invalid, hasErrorMsg, hasHint, hintId) {
4
+ useEffect(() => {
5
+ const inputEl = ref.current;
6
+ if (!inputEl)
7
+ return;
8
+ if (hasErrorMsg || hasHint) {
9
+ if (invalid) {
10
+ if (hasErrorMsg) {
11
+ inputEl.setAttribute("aria-describedby", errorMsgId);
12
+ }
13
+ }
14
+ else {
15
+ if (hasHint) {
16
+ inputEl.setAttribute("aria-describedby", hintId);
17
+ }
18
+ else {
19
+ inputEl.removeAttribute("aria-describedby");
20
+ }
21
+ }
22
+ }
23
+ }, [ref, errorMsgId, invalid]);
24
+ }
25
+
26
+ export { useAriaDescribedBy };
@@ -0,0 +1 @@
1
+ export declare function useGroupValidity(ref: React.RefObject<HTMLFieldSetElement>, type: "checkbox" | "radio"): boolean;
@@ -0,0 +1,60 @@
1
+ import { useState, useRef, useEffect } from 'react';
2
+
3
+ function useGroupValidity(ref, type) {
4
+ const [isValid, setIsValid] = useState(true);
5
+ const [hasInteracted, setHasInteracted] = useState(false);
6
+ const initialized = useRef(false);
7
+ useEffect(() => {
8
+ const fieldset = ref.current;
9
+ if (!fieldset)
10
+ return;
11
+ const inputs = fieldset.querySelectorAll(`input[type="${type}"]`);
12
+ if (!inputs.length)
13
+ return;
14
+ const validate = () => {
15
+ if (type === "checkbox") {
16
+ const validStates = Array.from(inputs).map(cb => cb.validity.valid);
17
+ setIsValid(!validStates.some(v => !v));
18
+ }
19
+ else {
20
+ const isAnyChecked = Array.from(inputs).some(radio => radio.checked);
21
+ setIsValid(isAnyChecked);
22
+ if (isAnyChecked) {
23
+ Array.from(inputs).forEach(radio => radio.setAttribute("aria-invalid", "false"));
24
+ }
25
+ }
26
+ };
27
+ if (!initialized.current) {
28
+ validate();
29
+ initialized.current = true;
30
+ }
31
+ const handleInteraction = () => {
32
+ setHasInteracted(true);
33
+ validate();
34
+ };
35
+ const handleChange = () => {
36
+ setHasInteracted(false);
37
+ validate();
38
+ };
39
+ inputs.forEach(cb => {
40
+ cb.addEventListener("invalid", handleInteraction);
41
+ cb.addEventListener("change", handleChange);
42
+ });
43
+ const form = fieldset.closest("form");
44
+ const handleSubmit = () => {
45
+ setHasInteracted(true);
46
+ validate();
47
+ };
48
+ form?.addEventListener("submit", handleSubmit);
49
+ return () => {
50
+ inputs.forEach(cb => {
51
+ cb.removeEventListener("invalid", handleInteraction);
52
+ cb.removeEventListener("change", handleChange);
53
+ });
54
+ form?.removeEventListener("submit", handleSubmit);
55
+ };
56
+ }, [ref]);
57
+ return isValid || !hasInteracted;
58
+ }
59
+
60
+ export { useGroupValidity };
@@ -0,0 +1 @@
1
+ export declare function useInputValidity(ref: React.RefObject<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>): boolean;
@@ -0,0 +1,27 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ function useInputValidity(ref) {
4
+ const [isValid, setIsValid] = useState(true);
5
+ useEffect(() => {
6
+ const inputEl = ref.current;
7
+ if (!inputEl)
8
+ return;
9
+ const updateValidity = () => {
10
+ setIsValid(inputEl.validity.valid);
11
+ };
12
+ const form = inputEl.closest("form");
13
+ form?.addEventListener("submit", updateValidity);
14
+ inputEl.addEventListener("blur", updateValidity);
15
+ inputEl.addEventListener("change", updateValidity);
16
+ inputEl.addEventListener("invalid", updateValidity);
17
+ return () => {
18
+ form?.removeEventListener("submit", updateValidity);
19
+ inputEl.removeEventListener("blur", updateValidity);
20
+ inputEl.removeEventListener("change", updateValidity);
21
+ inputEl.removeEventListener("invalid", updateValidity);
22
+ };
23
+ }, [ref]);
24
+ return isValid;
25
+ }
26
+
27
+ export { useInputValidity };
@@ -1,3 +1,22 @@
1
- import '@inera/ids-core/components/form/input/register.js';
2
- import { IDSInput as Input } from '@inera/ids-core/components/form/input/input-element.js';
3
- export declare const IDSInput: import("@lit-labs/react").ReactWebComponent<Input, {}>;
1
+ import React, { ReactNode, InputHTMLAttributes } from "react";
2
+ interface IDSInputProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ label: string;
4
+ type?: string;
5
+ icon?: string;
6
+ hint?: string | ReactNode;
7
+ showSearchLabel?: boolean;
8
+ errorMsg?: string;
9
+ disabled?: boolean;
10
+ invalid?: boolean;
11
+ required?: boolean;
12
+ noValidation?: boolean;
13
+ autoSize?: boolean;
14
+ block?: boolean;
15
+ light?: boolean;
16
+ readOnly?: boolean;
17
+ tooltip?: ReactNode;
18
+ submitButton?: ReactNode;
19
+ oldIcon?: ReactNode;
20
+ }
21
+ export declare const IDSInput: React.FC<IDSInputProps>;
22
+ export {};
@@ -1,12 +1,54 @@
1
- import * as React from 'react';
2
- import { createComponent } from '@lit-labs/react';
3
- import '@inera/ids-core/components/form/input/register.js';
4
- import { IDSInput as IDSInput$1 } from '@inera/ids-core/components/form/input/input-element.js';
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import React__default, { useRef, useEffect } from 'react';
4
+ import { useElementId } from '../../utils/hooks/useElementId.js';
5
+ import { IDSErrorMessage } from '../error-message/error-message.js';
6
+ import { useInputValidity } from '../form-hooks/useInputValidity.js';
7
+ import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
8
+ import clsx from 'clsx';
5
9
 
6
- const IDSInput = createComponent({
7
- tagName: 'ids-input',
8
- elementClass: IDSInput$1,
9
- react: React,
10
- });
10
+ const IDSInput = ({ label = "", type = "text", icon = "", hint = "", showSearchLabel = false, errorMsg = "", disabled = false, invalid = false, required = false, noValidation = false, autoSize = false, block = false, light = false, readOnly = false, id, tooltip, submitButton, oldIcon, className, ...props }) => {
11
+ const fieldId = useElementId(id);
12
+ const errorMsgId = useElementId();
13
+ const hintId = useElementId();
14
+ const oldIconRef = useRef(null);
15
+ const inputRef = useRef(null);
16
+ const hasValidValue = useInputValidity(inputRef);
17
+ const isInvalid = (invalid || !hasValidValue) && !noValidation;
18
+ useAriaDescribedBy(inputRef, errorMsgId, isInvalid, !!errorMsg && !noValidation, !!hint, hintId);
19
+ useEffect(() => {
20
+ if (oldIconRef.current) {
21
+ oldIconRef.current.setAttribute("size", "s");
22
+ setOldIconColor(oldIconRef.current);
23
+ }
24
+ }, [oldIconRef, isInvalid, disabled]);
25
+ const setOldIconColor = (iconComponent) => {
26
+ let color = "var(--IDS-ICON__COLOR)";
27
+ let color2 = "var(--IDS-ICON__COLOR-2)";
28
+ if (isInvalid) {
29
+ color = "var(--IDS-INPUT--INVALID__ICON-FILL)";
30
+ color2 = "var(--IDS-INPUT--INVALID__ICON-FILL)";
31
+ }
32
+ if (disabled) {
33
+ color = "var(--IDS-INPUT--DISABLED__ICON-FILL)";
34
+ color2 = "var(--IDS-INPUT--DISABLED__ICON-FILL)";
35
+ }
36
+ iconComponent.setAttribute("color", color);
37
+ iconComponent.setAttribute("color2", color2);
38
+ };
39
+ const renderOldIcon = oldIcon && React__default.isValidElement(oldIcon)
40
+ ? React__default.cloneElement(oldIcon, { ref: oldIconRef })
41
+ : oldIcon;
42
+ return (jsxs("div", { className: clsx("ids-input-component", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { className: clsx("ids-label", {
43
+ "ids-label--disabled": disabled || readOnly,
44
+ "ids-hidden": type === "search" && !showSearchLabel
45
+ }), "aria-hidden": "false", htmlFor: fieldId, children: label }), tooltip] }), jsxs("div", { className: "ids-input__wrapper", children: [jsxs("div", { className: clsx("ids-input__inner-wrapper", {
46
+ "ids-input--icon": icon,
47
+ "ids-input__inner-wrapper--search": type === "search"
48
+ }), children: [jsx("input", { ref: inputRef, id: fieldId, type: type, readOnly: readOnly, className: clsx("ids-input", {
49
+ "ids-input--light": light,
50
+ "ids-input--invalid": invalid
51
+ }), "aria-invalid": isInvalid, required: required, "aria-required": required, disabled: disabled, "aria-disabled": disabled, ...props }), type === "search" && jsx("span", { className: "ids-input__search-icon" }), icon && jsx("span", { className: `ids-input__icon ids-icon-${icon}` }), oldIcon && jsx("span", { className: "ids-input__icon", children: renderOldIcon })] }), submitButton] }), hint && (jsx("div", { id: hintId, className: "ids-input__hint", children: hint })), isInvalid && errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
52
+ };
11
53
 
12
54
  export { IDSInput };
@@ -1,3 +1,13 @@
1
- import '@inera/ids-core/components/form/radio/register.js';
2
- import { IDSRadioGroup as IDSComponent } from '@inera/ids-core/components/form/radio/radio-group-element.js';
3
- export declare const IDSRadioGroup: import("@lit-labs/react").ReactWebComponent<IDSComponent, {}>;
1
+ import React, { ReactNode } from "react";
2
+ interface IDSRadioGroupProps extends React.FieldsetHTMLAttributes<HTMLFieldSetElement> {
3
+ name: string;
4
+ legend?: string;
5
+ errorMsg?: string | ReactNode;
6
+ compact?: boolean;
7
+ required?: boolean;
8
+ tooltip?: ReactNode;
9
+ children?: ReactNode;
10
+ onRadioChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
11
+ }
12
+ export declare const IDSRadioGroup: React.FC<IDSRadioGroupProps>;
13
+ export {};
@@ -1,8 +1,31 @@
1
- import * as React from 'react';
2
- import { createComponent } from '@lit-labs/react';
3
- import '@inera/ids-core/components/form/radio/register.js';
4
- import { IDSRadioGroup as IDSRadioGroup$1 } from '@inera/ids-core/components/form/radio/radio-group-element.js';
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import React__default, { useRef } from 'react';
4
+ import { IDSErrorMessage } from '../error-message/error-message.js';
5
+ import { useElementId } from '../../utils/hooks/useElementId.js';
6
+ import { useGroupValidity } from '../form-hooks/useGroupValidity.js';
7
+ import clsx from 'clsx';
5
8
 
6
- const IDSRadioGroup = createComponent(React, 'ids-radio-group', IDSRadioGroup$1);
9
+ const IDSRadioGroup = ({ name = "options", legend = "", errorMsg = "", compact = false, required = false, onRadioChange, tooltip, className, children }) => {
10
+ const groupRef = useRef(null);
11
+ const isValid = useGroupValidity(groupRef, "radio");
12
+ const errorMsgId = useElementId();
13
+ const clonedChildren = React__default.Children.map(children, child => {
14
+ if (React__default.isValidElement(child) && child.type.displayName === "IDSRadio") {
15
+ return React__default.cloneElement(child, {
16
+ key: child.props.id,
17
+ name,
18
+ required,
19
+ groupErrorMsgId: errorMsg && errorMsgId,
20
+ groupInvalid: !isValid,
21
+ onChange: onRadioChange
22
+ });
23
+ }
24
+ return child;
25
+ });
26
+ return (jsxs("fieldset", { ref: groupRef, "aria-required": required, className: clsx("ids-form-group__fieldset", {
27
+ "ids-form-group__fieldset--compact": compact
28
+ }, className), children: [jsxs("legend", { children: [legend, tooltip] }), clonedChildren, !isValid && !!errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
29
+ };
7
30
 
8
31
  export { IDSRadioGroup };
@@ -1,3 +1,17 @@
1
- import '@inera/ids-core/components/form/radio/register.js';
2
- import { IDSRadio as Radio } from '@inera/ids-core/components/form/radio/radio-element.js';
3
- export declare const IDSRadio: import("@lit-labs/react").ReactWebComponent<Radio, {}>;
1
+ import React, { ReactNode, ChangeEvent, InputHTMLAttributes } from "react";
2
+ export interface IDSRadioProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ name?: string;
4
+ id?: string;
5
+ groupErrorMsgId?: string;
6
+ invalid?: boolean;
7
+ groupInvalid?: boolean;
8
+ disabled?: boolean;
9
+ noLabel?: boolean;
10
+ noValidation?: boolean;
11
+ light?: boolean;
12
+ compact?: boolean;
13
+ tooltip?: ReactNode;
14
+ children?: ReactNode;
15
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
16
+ }
17
+ export declare const IDSRadio: React.FC<IDSRadioProps>;
@@ -1,12 +1,26 @@
1
- import * as React from 'react';
2
- import { createComponent } from '@lit-labs/react';
3
- import '@inera/ids-core/components/form/radio/register.js';
4
- import { IDSRadio as IDSRadio$1 } from '@inera/ids-core/components/form/radio/radio-element.js';
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useRef } from 'react';
4
+ import { useElementId } from '../../utils/hooks/useElementId.js';
5
+ import { useInputValidity } from '../form-hooks/useInputValidity.js';
6
+ import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
7
+ import clsx from 'clsx';
5
8
 
6
- const IDSRadio = createComponent({
7
- tagName: 'ids-radio',
8
- elementClass: IDSRadio$1,
9
- react: React,
10
- });
9
+ const IDSRadio = ({ name = "", groupErrorMsgId = "", invalid = false, groupInvalid = false, disabled = false, noValidation = false, light = false, compact = false, tooltip, id, children, className, onChange, ...props }) => {
10
+ const fieldId = useElementId(id);
11
+ const radioRef = useRef(null);
12
+ const hasValidValue = useInputValidity(radioRef);
13
+ const isInvalid = (invalid || groupInvalid || !hasValidValue) && !noValidation;
14
+ useAriaDescribedBy(radioRef, groupErrorMsgId, isInvalid, !!groupErrorMsgId);
15
+ return (jsxs("div", { className: clsx("ids-radio", {
16
+ "ids-radio--compact": compact
17
+ }, className), children: [jsx("input", { id: fieldId, ref: radioRef, type: "radio", className: clsx({
18
+ "ids-input--light": light
19
+ }), disabled: disabled, "aria-disabled": disabled, "aria-invalid": isInvalid, name: name, onChange: onChange, ...props }), jsxs("div", { className: clsx("ids-label-tooltip-wrapper", {
20
+ "ids-label-tooltip-wrapper--inline": tooltip
21
+ }), children: [jsx("label", { htmlFor: fieldId, className: clsx("ids-radio__label ids-label", {
22
+ "ids-input--clickable": !disabled
23
+ }), children: children }), tooltip] })] }));
24
+ };
11
25
 
12
26
  export { IDSRadio };
@@ -0,0 +1,9 @@
1
+ import React, { ReactNode, InputHTMLAttributes } from "react";
2
+ interface IDSRadioButtonGroupProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ name: string;
4
+ legend?: string;
5
+ children?: ReactNode;
6
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
7
+ }
8
+ export declare const IDSRadioButtonGroup: React.FC<IDSRadioButtonGroupProps>;
9
+ export {};
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import React__default, { useRef } from 'react';
4
+ import clsx from 'clsx';
5
+
6
+ const IDSRadioButtonGroup = ({ name = "options", legend = "", onChange, className, children }) => {
7
+ const groupRef = useRef(null);
8
+ const clonedChildren = React__default.Children.map(children, child => {
9
+ if (React__default.isValidElement(child) && child.type.displayName === "IDSRadioButton") {
10
+ return React__default.cloneElement(child, {
11
+ key: child.props.id,
12
+ icon: child.props.icon,
13
+ name,
14
+ onChange
15
+ });
16
+ }
17
+ return child;
18
+ });
19
+ return (jsxs("fieldset", { ref: groupRef, className: clsx("ids-form-group__fieldset", className), children: [jsx("legend", { children: legend && legend }), clonedChildren] }));
20
+ };
21
+
22
+ export { IDSRadioButtonGroup };
@@ -0,0 +1,9 @@
1
+ import React, { ReactNode, InputHTMLAttributes } from "react";
2
+ export interface IDSRadioButtonProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ name?: string;
4
+ id?: string;
5
+ icon: string;
6
+ children?: ReactNode;
7
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => {};
8
+ }
9
+ export declare const IDSRadioButton: React.FC<IDSRadioButtonProps>;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useRef } from 'react';
4
+ import { useElementId } from '../../utils/hooks/useElementId.js';
5
+ import clsx from 'clsx';
6
+
7
+ const IDSRadioButton = ({ name = "", icon = "user", id, children, onChange, className, ...props }) => {
8
+ const fieldId = useElementId(id);
9
+ const radioRef = useRef(null);
10
+ return (jsxs("div", { className: clsx("ids-radio-button", className), children: [jsx("input", { id: fieldId, ref: radioRef, type: "radio", className: "ids-radio-button__input", name: name, onChange: onChange, ...props }), jsx("label", { htmlFor: fieldId, className: `ids-radio-button__label ids-icon-${icon}`, children: children })] }));
11
+ };
12
+
13
+ export { IDSRadioButton };
@@ -1,3 +1,16 @@
1
- import '@inera/ids-core/components/form/range/register.js';
2
- import { IDSRange as Range } from '@inera/ids-core/components/form/range/range-element.js';
3
- export declare const IDSRange: import("@lit-labs/react").ReactWebComponent<Range, {}>;
1
+ import React, { ReactNode, InputHTMLAttributes, ChangeEvent } from "react";
2
+ import "@inera/ids-design/components/form/range/range.css";
3
+ interface IDSRangeProps extends InputHTMLAttributes<HTMLInputElement> {
4
+ label?: string;
5
+ value?: number;
6
+ showTicks?: boolean;
7
+ interval?: number;
8
+ min?: number;
9
+ max?: number;
10
+ step?: number;
11
+ disabled?: boolean;
12
+ tooltip?: ReactNode;
13
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
14
+ }
15
+ export declare const IDSRange: React.FC<IDSRangeProps>;
16
+ export {};
@@ -1,12 +1,32 @@
1
- import * as React from 'react';
2
- import { createComponent } from '@lit-labs/react';
3
- import '@inera/ids-core/components/form/range/register.js';
4
- import { IDSRange as IDSRange$1 } from '@inera/ids-core/components/form/range/range-element.js';
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState, useRef, useEffect } from 'react';
4
+ import { useElementId } from '../../utils/hooks/useElementId.js';
5
+ import '@inera/ids-design/components/form/range/range.css';
6
+ import clsx from 'clsx';
5
7
 
6
- const IDSRange = createComponent({
7
- tagName: 'ids-range',
8
- elementClass: IDSRange$1,
9
- react: React,
10
- });
8
+ const IDSRange = ({ label = "", value = 0, showTicks = false, interval = 0, min = 0, max = 0, step = 0, disabled = false, tooltip, id, onChange, className, ...props }) => {
9
+ const [internalValue, setInternalValue] = useState(value);
10
+ const [ticks, setTicks] = useState([]);
11
+ const fieldId = useElementId(id);
12
+ const rangeRef = useRef(null);
13
+ useEffect(() => {
14
+ if (step > 0) {
15
+ const steps = [];
16
+ const increment = interval > 0 ? interval : step;
17
+ for (let i = min; i <= max; i += increment) {
18
+ steps.push(Math.floor(i));
19
+ }
20
+ setTicks(steps);
21
+ }
22
+ }, [min, max, step, interval, showTicks]);
23
+ const handleOnChange = (ev) => {
24
+ setInternalValue(+ev.target.value);
25
+ if (onChange) {
26
+ onChange(ev);
27
+ }
28
+ };
29
+ return (jsxs("div", { className: clsx("ids-range", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { htmlFor: fieldId, className: `ids-label ${disabled ? "ids-label--disabled" : ""}`, children: label }), tooltip] }), jsx("input", { id: fieldId, ref: rangeRef, type: "range", className: "ids-range__input", min: min, "aria-valuemin": min, max: max, "aria-valuemax": max, step: step, value: internalValue, "aria-valuenow": internalValue, disabled: disabled, style: { backgroundSize: ((internalValue - min) * 100) / (max - min) + "% 100%" }, onChange: handleOnChange, ...props }), showTicks && (jsx("div", { className: `ids-range-ticks ${disabled ? "ids-range-ticks--disabled" : ""}`, children: ticks.map(tick => (jsx("div", { className: "ids-range-tick", children: tick }, tick))) }))] }));
30
+ };
11
31
 
12
32
  export { IDSRange };
@@ -1,3 +1,15 @@
1
- import '@inera/ids-core/components/form/select/register.js';
2
- import { IDSSelect as Select } from '@inera/ids-core/components/form/select/select-element.js';
3
- export declare const IDSSelect: import("@lit-labs/react").ReactWebComponent<Select, {}>;
1
+ import React, { ReactNode } from "react";
2
+ interface IDSSelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
3
+ label?: string;
4
+ srOf?: string;
5
+ errorMsg?: string;
6
+ disabled?: boolean;
7
+ required?: boolean;
8
+ invalid?: boolean;
9
+ light?: boolean;
10
+ noValidation?: boolean;
11
+ tooltip?: ReactNode;
12
+ children?: ReactNode;
13
+ }
14
+ export declare const IDSSelect: React.FC<IDSSelectProps>;
15
+ export {};
@@ -1,12 +1,22 @@
1
- import * as React from 'react';
2
- import { createComponent } from '@lit-labs/react';
3
- import '@inera/ids-core/components/form/select/register.js';
4
- import { IDSSelect as IDSSelect$1 } from '@inera/ids-core/components/form/select/select-element.js';
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useRef } from 'react';
4
+ import { useElementId } from '../../utils/hooks/useElementId.js';
5
+ import { IDSErrorMessage } from '../error-message/error-message.js';
6
+ import { useInputValidity } from '../form-hooks/useInputValidity.js';
7
+ import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
8
+ import clsx from 'clsx';
5
9
 
6
- const IDSSelect = createComponent({
7
- tagName: 'ids-select',
8
- elementClass: IDSSelect$1,
9
- react: React,
10
- });
10
+ const IDSSelect = ({ label = "", srOf = "av", errorMsg = "", disabled = false, required = false, invalid = false, light = false, noValidation = false, tooltip, id, children, className, ...props }) => {
11
+ const fieldId = useElementId(id);
12
+ const errorMsgId = useElementId();
13
+ const selectRef = useRef(null);
14
+ const hasValidValue = useInputValidity(selectRef);
15
+ const isInvalid = (invalid || !hasValidValue) && !noValidation;
16
+ useAriaDescribedBy(selectRef, errorMsgId, isInvalid, !!errorMsg);
17
+ return (jsxs("div", { className: clsx("ids-select-component", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { htmlFor: fieldId, className: "ids-label", children: label }), tooltip] }), jsx("div", { className: "ids-select-wrapper", children: jsx("select", { id: fieldId, ref: selectRef, className: clsx("ids-select", {
18
+ "ids-input--light": light
19
+ }), "aria-invalid": isInvalid, required: required, disabled: disabled, ...props, children: children }) }), isInvalid && errorMsg && (jsx(IDSErrorMessage, { id: errorMsgId, show: true, children: errorMsg }))] }));
20
+ };
11
21
 
12
22
  export { IDSSelect };
@@ -1,3 +1,18 @@
1
- import '@inera/ids-core/components/form/select-multiple/register.js';
2
- import { IDSSelectMultiple as SelectMultiple } from '@inera/ids-core/components/form/select-multiple/select-multiple-element.js';
3
- export declare const IDSSelectMultiple: import("@lit-labs/react").ReactWebComponent<SelectMultiple, {}>;
1
+ import React, { ReactNode } from "react";
2
+ import "@inera/ids-design/components/form/select-multiple/select-multiple.css";
3
+ interface IDSSelectMultipleProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
+ label?: string;
5
+ selectedLabel?: string;
6
+ selectedLabelPlural?: string;
7
+ placeholder?: string;
8
+ maxHeight?: string;
9
+ expanded?: boolean;
10
+ errorMsg?: string;
11
+ invalid?: boolean;
12
+ light?: boolean;
13
+ noValidation?: boolean;
14
+ tooltip?: ReactNode;
15
+ children?: ReactNode;
16
+ }
17
+ export declare const IDSSelectMultiple: React.FC<IDSSelectMultipleProps>;
18
+ export {};
@@ -1,12 +1,63 @@
1
- import * as React from 'react';
2
- import { createComponent } from '@lit-labs/react';
3
- import '@inera/ids-core/components/form/select-multiple/register.js';
4
- import { IDSSelectMultiple as IDSSelectMultiple$1 } from '@inera/ids-core/components/form/select-multiple/select-multiple-element.js';
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState, useRef, useEffect } from 'react';
4
+ import { useElementId } from '../../utils/hooks/useElementId.js';
5
+ import { IDSCheckboxGroup } from '../checkbox/checkbox-group.js';
6
+ import { useAriaDescribedBy } from '../form-hooks/useAriaDescribedBy.js';
7
+ import '@inera/ids-design/components/form/select-multiple/select-multiple.css';
8
+ import clsx from 'clsx';
5
9
 
6
- const IDSSelectMultiple = createComponent({
7
- tagName: 'ids-select-multiple',
8
- elementClass: IDSSelectMultiple$1,
9
- react: React,
10
- });
10
+ const IDSSelectMultiple = ({ label = "", selectedLabel = "vald", selectedLabelPlural = "valda", placeholder = "", maxHeight = "", expanded = false, errorMsg = "", invalid = false, light = false, noValidation = false, tooltip, id, children, className, ...props }) => {
11
+ const [checkboxListInvalid, setCheckboxListInvalid] = useState(false);
12
+ const [checkedBoxesCount, setCheckedBoxesCount] = useState(0);
13
+ const [value, setValue] = useState(placeholder);
14
+ const [isExpanded, setIsExpanded] = useState(expanded);
15
+ const labelId = useElementId("label-" + id);
16
+ const inputId = useElementId("input-" + id);
17
+ const errorMsgId = useElementId();
18
+ const selectMultipleRef = useRef(null);
19
+ useAriaDescribedBy(selectMultipleRef, errorMsgId, checkboxListInvalid, !!errorMsg);
20
+ useEffect(() => {
21
+ let inputValue = placeholder;
22
+ if (checkedBoxesCount === 1) {
23
+ inputValue = `${checkedBoxesCount} ${selectedLabel}`;
24
+ }
25
+ if (checkedBoxesCount > 1) {
26
+ inputValue = `${checkedBoxesCount} ${selectedLabelPlural}`;
27
+ }
28
+ setValue(inputValue);
29
+ }, [checkedBoxesCount]);
30
+ useEffect(() => {
31
+ const handleInteractionOutside = (event) => {
32
+ const target = event.target;
33
+ if (selectMultipleRef.current) {
34
+ const root = selectMultipleRef.current.closest(".ids-select-multiple-component");
35
+ if (root && !root.contains(target)) {
36
+ setIsExpanded(false);
37
+ }
38
+ }
39
+ };
40
+ const handleKeyDown = (event) => {
41
+ if (event.key === "Escape" && isExpanded) {
42
+ setIsExpanded(false);
43
+ }
44
+ };
45
+ document.addEventListener("click", handleInteractionOutside);
46
+ document.addEventListener("focusin", handleInteractionOutside);
47
+ document.addEventListener("keydown", handleKeyDown);
48
+ return () => {
49
+ document.removeEventListener("click", handleInteractionOutside);
50
+ document.removeEventListener("focusin", handleInteractionOutside);
51
+ document.removeEventListener("keydown", handleKeyDown);
52
+ };
53
+ }, [isExpanded]);
54
+ return (jsxs("div", { className: clsx("ids-select-multiple-component", className), children: [jsxs("div", { className: "ids-label-tooltip-wrapper", children: [jsx("label", { id: labelId, htmlFor: inputId, className: "ids-label", children: label }), tooltip] }), jsx("div", { className: "ids-select-multiple-wrapper", children: jsx("input", { id: inputId, "aria-labelledby": labelId, ref: selectMultipleRef, type: "button", className: clsx("ids-select-multiple__select", {
55
+ "ids-input--light": light
56
+ }), "aria-expanded": isExpanded, "aria-invalid": invalid || checkboxListInvalid, placeholder: placeholder, value: value, onClick: () => setIsExpanded(!isExpanded), ...props }) }), jsx("div", { className: "ids-select-multiple__dropdown__wrapper", children: jsx("div", { className: clsx("ids-select-multiple__dropdown", {
57
+ "ids-select-multiple__dropdown--show": isExpanded
58
+ }), children: jsx("div", { className: "ids-select-multiple__dropdown__inner", style: { maxHeight: maxHeight }, children: jsx(IDSCheckboxGroup, { block: true, errorMsg: errorMsg, setCheckedBoxesCount: setCheckedBoxesCount, onValidityChange: (isValid) => {
59
+ setCheckboxListInvalid(!isValid);
60
+ }, children: children }) }) }) })] }));
61
+ };
11
62
 
12
63
  export { IDSSelectMultiple };
@@ -1,3 +1,9 @@
1
- import '@inera/ids-core/components/form/spinner/register.js';
2
- import { IDSSpinner as Spinner } from '@inera/ids-core/components/form/spinner/spinner-element.js';
3
- export declare const IDSSpinner: import("@lit-labs/react").ReactWebComponent<Spinner, {}>;
1
+ import React from "react";
2
+ import "@inera/ids-design/components/form/spinner/spinner.css";
3
+ interface IDSSpinnerProps extends React.HTMLAttributes<HTMLElement> {
4
+ light?: boolean;
5
+ live?: "polite" | "assertive" | "off";
6
+ srText?: string;
7
+ }
8
+ export declare const IDSSpinner: React.FC<IDSSpinnerProps>;
9
+ export {};