@helsenorge/designsystem-react 2.4.0 → 2.6.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/Button.js +1 -1
- package/Button.js.map +1 -1
- package/CHANGELOG.md +27 -0
- package/Checkbox.js +1 -1
- package/Checkbox.js.map +1 -1
- package/FormGroup.js +1 -1
- package/FormGroup.js.map +1 -1
- package/HelpBubble.js +1 -1
- package/HelpBubble.js.map +1 -1
- package/Input.js +1 -1
- package/Input.js.map +1 -1
- package/Panel.js +1 -1
- package/Panel.js.map +1 -1
- package/RadioButton.js +1 -1
- package/RadioButton.js.map +1 -1
- package/Select.js +2 -0
- package/Select.js.map +1 -0
- package/Textarea.js +1 -1
- package/Textarea.js.map +1 -1
- package/Tooltip.js +1 -1
- package/Tooltip.js.map +1 -1
- package/TooltipWord.js +2 -0
- package/TooltipWord.js.map +1 -0
- package/__mocks__/uuid.js +1 -1
- package/__mocks__/uuid.js.map +1 -1
- package/components/AnchorLink/index.js +1 -1
- package/components/Avatar/index.js +1 -1
- package/components/Avatar/index.js.map +1 -1
- package/components/Button/index.js +1 -1
- package/components/ButtonWithModal/index.js +1 -1
- package/components/ButtonWithModal/index.js.map +1 -1
- package/components/Checkbox/Checkbox.d.ts +1 -1
- package/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/components/Checkbox/componentdata.json +1 -1
- package/components/Checkbox/index.js +1 -1
- package/components/Close/index.js +1 -1
- package/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/components/Dropdown/index.js +1 -1
- package/components/Dropdown/index.js.map +1 -1
- package/components/Duolist/Duolist.d.ts +6 -4
- package/components/Duolist/Duolist.d.ts.map +1 -1
- package/components/Duolist/componentdata.json +1 -1
- package/components/Duolist/index.js +1 -1
- package/components/Duolist/index.js.map +1 -1
- package/components/Duolist/styles.module.scss +0 -1
- package/components/Expander/index.js +1 -1
- package/components/Expander/index.js.map +1 -1
- package/components/ExpanderList/index.js +1 -1
- package/components/ExpanderList/index.js.map +1 -1
- package/components/FormExample/FormExample.d.ts +2 -1
- package/components/FormExample/FormExample.d.ts.map +1 -1
- package/components/FormExample/componentdata.json +1 -1
- package/components/FormExample/index.js +3 -3
- package/components/FormExample/index.js.map +1 -1
- package/components/FormGroup/FormGroup.d.ts.map +1 -1
- package/components/FormGroup/index.js +1 -1
- package/components/HelpBubble/HelpBubble.d.ts +7 -4
- package/components/HelpBubble/HelpBubble.d.ts.map +1 -1
- package/components/HelpBubble/componentdata.json +1 -1
- package/components/HelpBubble/index.js +1 -1
- package/components/HelpBubble/styles.module.scss +12 -6
- package/components/HelpBubble/styles.module.scss.d.ts +0 -1
- package/components/HelpBubbleExample/componentdata.json +1 -1
- package/components/HelpBubbleExample/index.js +1 -1
- package/components/HelpBubbleExample/index.js.map +1 -1
- package/components/HighlightBox/index.js +1 -1
- package/components/HighlightBox/index.js.map +1 -1
- package/components/HorizontalScroll/index.js +1 -1
- package/components/Icons/AcupunctureBack.js +1 -1
- package/components/Icons/AcupunctureBack.js.map +1 -1
- package/components/Icons/AlarmClock.js +1 -1
- package/components/Icons/AlarmClock.js.map +1 -1
- package/components/Icons/AlertSignFill.js +1 -1
- package/components/Icons/AlertSignFill.js.map +1 -1
- package/components/Icons/AlertSignStroke.js +1 -1
- package/components/Icons/AlertSignStroke.js.map +1 -1
- package/components/Icons/Archive.js +1 -1
- package/components/Icons/Archive.js.map +1 -1
- package/components/Icons/ArrowDown.js +1 -1
- package/components/Icons/ArrowDown.js.map +1 -1
- package/components/Icons/ArrowLeft.js +1 -1
- package/components/Icons/ArrowLeft.js.map +1 -1
- package/components/Icons/ArrowRight.js +1 -1
- package/components/Icons/ArrowRight.js.map +1 -1
- package/components/Icons/ArrowUp.js +1 -1
- package/components/Icons/ArrowUp.js.map +1 -1
- package/components/Icons/ArrowUpRight.js +1 -1
- package/components/Icons/ArrowUpRight.js.map +1 -1
- package/components/Icons/Attachment.js +1 -1
- package/components/Icons/Attachment.js.map +1 -1
- package/components/Icons/Avatar.js +1 -1
- package/components/Icons/Avatar.js.map +1 -1
- package/components/Icons/Bus.js +1 -1
- package/components/Icons/Bus.js.map +1 -1
- package/components/Icons/Calendar.js +1 -1
- package/components/Icons/Calendar.js.map +1 -1
- package/components/Icons/CalendarChange.js +1 -1
- package/components/Icons/CalendarChange.js.map +1 -1
- package/components/Icons/CalendarCheck.js +1 -1
- package/components/Icons/CalendarCheck.js.map +1 -1
- package/components/Icons/CalendarSave.js +1 -1
- package/components/Icons/CalendarSave.js.map +1 -1
- package/components/Icons/Change.js +1 -1
- package/components/Icons/Change.js.map +1 -1
- package/components/Icons/Check.js +1 -1
- package/components/Icons/Check.js.map +1 -1
- package/components/Icons/CheckFill.js +1 -1
- package/components/Icons/CheckFill.js.map +1 -1
- package/components/Icons/ChevronDown.js +1 -1
- package/components/Icons/ChevronDown.js.map +1 -1
- package/components/Icons/ChevronLeft.js +1 -1
- package/components/Icons/ChevronLeft.js.map +1 -1
- package/components/Icons/ChevronRight.js +1 -1
- package/components/Icons/ChevronRight.js.map +1 -1
- package/components/Icons/ChevronUp.js +1 -1
- package/components/Icons/ChevronUp.js.map +1 -1
- package/components/Icons/ChevronsDown.js +1 -1
- package/components/Icons/ChevronsDown.js.map +1 -1
- package/components/Icons/ChevronsUp.js +1 -1
- package/components/Icons/ChevronsUp.js.map +1 -1
- package/components/Icons/Contacts.js +1 -1
- package/components/Icons/Contacts.js.map +1 -1
- package/components/Icons/Copy.js +1 -1
- package/components/Icons/Copy.js.map +1 -1
- package/components/Icons/Download.js +1 -1
- package/components/Icons/Download.js.map +1 -1
- package/components/Icons/EChat.js +1 -1
- package/components/Icons/EChat.js.map +1 -1
- package/components/Icons/EnterFullScreen.js +1 -1
- package/components/Icons/EnterFullScreen.js.map +1 -1
- package/components/Icons/Envelope.js +1 -1
- package/components/Icons/Envelope.js.map +1 -1
- package/components/Icons/Eraser.js +1 -1
- package/components/Icons/Eraser.js.map +1 -1
- package/components/Icons/ErrorSignFill.js +1 -1
- package/components/Icons/ErrorSignFill.js.map +1 -1
- package/components/Icons/ErrorSignStroke.js +1 -1
- package/components/Icons/ErrorSignStroke.js.map +1 -1
- package/components/Icons/ExitFullScreen.js +1 -1
- package/components/Icons/ExitFullScreen.js.map +1 -1
- package/components/Icons/Eye.js +1 -1
- package/components/Icons/Eye.js.map +1 -1
- package/components/Icons/Form.js +1 -1
- package/components/Icons/Form.js.map +1 -1
- package/components/Icons/Forward.js +1 -1
- package/components/Icons/Forward.js.map +1 -1
- package/components/Icons/Gallery.js +1 -1
- package/components/Icons/Gallery.js.map +1 -1
- package/components/Icons/Globe.js +1 -1
- package/components/Icons/Globe.js.map +1 -1
- package/components/Icons/Group.js +1 -1
- package/components/Icons/Group.js.map +1 -1
- package/components/Icons/Heart.js +1 -1
- package/components/Icons/Heart.js.map +1 -1
- package/components/Icons/HelpSign.js +1 -1
- package/components/Icons/HelpSign.js.map +1 -1
- package/components/Icons/History.js +1 -1
- package/components/Icons/History.js.map +1 -1
- package/components/Icons/Home.js +1 -1
- package/components/Icons/Home.js.map +1 -1
- package/components/Icons/Hospital.js +1 -1
- package/components/Icons/Hospital.js.map +1 -1
- package/components/Icons/Hourglass.js +1 -1
- package/components/Icons/Hourglass.js.map +1 -1
- package/components/Icons/Icon.js +1 -1
- package/components/Icons/Icon.js.map +1 -1
- package/components/Icons/InfoSignFill.js +1 -1
- package/components/Icons/InfoSignFill.js.map +1 -1
- package/components/Icons/InfoSignStroke.js +1 -1
- package/components/Icons/InfoSignStroke.js.map +1 -1
- package/components/Icons/Journal.js +1 -1
- package/components/Icons/Journal.js.map +1 -1
- package/components/Icons/List.js +1 -1
- package/components/Icons/List.js.map +1 -1
- package/components/Icons/Location.js +1 -1
- package/components/Icons/Location.js.map +1 -1
- package/components/Icons/Lock.js +1 -1
- package/components/Icons/Lock.js.map +1 -1
- package/components/Icons/Medicine.js +1 -1
- package/components/Icons/Medicine.js.map +1 -1
- package/components/Icons/Menu.js +1 -1
- package/components/Icons/Menu.js.map +1 -1
- package/components/Icons/Minus.js +1 -1
- package/components/Icons/Minus.js.map +1 -1
- package/components/Icons/MobilePhone.js +1 -1
- package/components/Icons/MobilePhone.js.map +1 -1
- package/components/Icons/NoAccess.js +1 -1
- package/components/Icons/NoAccess.js.map +1 -1
- package/components/Icons/NoEye.js +1 -1
- package/components/Icons/NoEye.js.map +1 -1
- package/components/Icons/NoFilter.js +1 -1
- package/components/Icons/NoFilter.js.map +1 -1
- package/components/Icons/PaperPlane.js +1 -1
- package/components/Icons/PaperPlane.js.map +1 -1
- package/components/Icons/Pause.js +1 -1
- package/components/Icons/Pause.js.map +1 -1
- package/components/Icons/Pencil.js +1 -1
- package/components/Icons/Pencil.js.map +1 -1
- package/components/Icons/PersonalPlan.js +1 -1
- package/components/Icons/PersonalPlan.js.map +1 -1
- package/components/Icons/Play.js +1 -1
- package/components/Icons/Play.js.map +1 -1
- package/components/Icons/PlusLarge.js +1 -1
- package/components/Icons/PlusLarge.js.map +1 -1
- package/components/Icons/PlusSmall.js +1 -1
- package/components/Icons/PlusSmall.js.map +1 -1
- package/components/Icons/Printer.js +1 -1
- package/components/Icons/Printer.js.map +1 -1
- package/components/Icons/QrCode.js +1 -1
- package/components/Icons/QrCode.js.map +1 -1
- package/components/Icons/Receptionist.js +1 -1
- package/components/Icons/Receptionist.js.map +1 -1
- package/components/Icons/Referral.js +1 -1
- package/components/Icons/Referral.js.map +1 -1
- package/components/Icons/Refresh.js +1 -1
- package/components/Icons/Refresh.js.map +1 -1
- package/components/Icons/Reply.js +1 -1
- package/components/Icons/Reply.js.map +1 -1
- package/components/Icons/Save.js +1 -1
- package/components/Icons/Save.js.map +1 -1
- package/components/Icons/Search.js +1 -1
- package/components/Icons/Search.js.map +1 -1
- package/components/Icons/SectionSign.js +1 -1
- package/components/Icons/SectionSign.js.map +1 -1
- package/components/Icons/Settings.js +1 -1
- package/components/Icons/Settings.js.map +1 -1
- package/components/Icons/Share.js +1 -1
- package/components/Icons/Share.js.map +1 -1
- package/components/Icons/SpeechBubble.js +1 -1
- package/components/Icons/SpeechBubble.js.map +1 -1
- package/components/Icons/Stopwatch.js +1 -1
- package/components/Icons/Stopwatch.js.map +1 -1
- package/components/Icons/SupportingPerson.js +1 -1
- package/components/Icons/SupportingPerson.js.map +1 -1
- package/components/Icons/Syringe.js +1 -1
- package/components/Icons/Syringe.js.map +1 -1
- package/components/Icons/TimePassing.js +1 -1
- package/components/Icons/TimePassing.js.map +1 -1
- package/components/Icons/Toolbox.js +1 -1
- package/components/Icons/Toolbox.js.map +1 -1
- package/components/Icons/TrashCan.js +1 -1
- package/components/Icons/TrashCan.js.map +1 -1
- package/components/Icons/Undo.js +1 -1
- package/components/Icons/Undo.js.map +1 -1
- package/components/Icons/Upload.js +1 -1
- package/components/Icons/Upload.js.map +1 -1
- package/components/Icons/Vaccine.js +1 -1
- package/components/Icons/Vaccine.js.map +1 -1
- package/components/Icons/VerticalDots.js +1 -1
- package/components/Icons/VerticalDots.js.map +1 -1
- package/components/Icons/VideoCamera.js +1 -1
- package/components/Icons/VideoCamera.js.map +1 -1
- package/components/Icons/VideoChat.js +1 -1
- package/components/Icons/VideoChat.js.map +1 -1
- package/components/Icons/Wallet.js +1 -1
- package/components/Icons/Wallet.js.map +1 -1
- package/components/Icons/Watch.js +1 -1
- package/components/Icons/Watch.js.map +1 -1
- package/components/Icons/X.js +1 -1
- package/components/Icons/X.js.map +1 -1
- package/components/Icons/Zoom.js +1 -1
- package/components/Icons/Zoom.js.map +1 -1
- package/components/Icons/index.js +1 -1
- package/components/Input/Input.d.ts +0 -1
- package/components/Input/Input.d.ts.map +1 -1
- package/components/Input/index.js +1 -1
- package/components/LinkList/index.js +1 -1
- package/components/LinkList/index.js.map +1 -1
- package/components/Loader/index.js +1 -1
- package/components/Loader/index.js.map +1 -1
- package/components/Modal/index.js +1 -1
- package/components/NotificationPanel/index.js +1 -1
- package/components/NotificationPanel/index.js.map +1 -1
- package/components/Panel/index.js +1 -1
- package/components/PanelList/index.js +1 -1
- package/components/PanelList/index.js.map +1 -1
- package/components/Progressbar/index.js +1 -1
- package/components/Progressbar/index.js.map +1 -1
- package/components/RadioButton/RadioButton.d.ts.map +1 -1
- package/components/RadioButton/index.js +1 -1
- package/components/Select/Select.d.ts +30 -0
- package/components/Select/Select.d.ts.map +1 -0
- package/components/Select/componentdata.json +1 -0
- package/components/Select/index.d.ts +4 -0
- package/components/Select/index.d.ts.map +1 -0
- package/components/Select/index.js +2 -0
- package/components/Select/index.js.map +1 -0
- package/components/Select/styles.module.scss +125 -0
- package/components/Select/styles.module.scss.d.ts +21 -0
- package/components/Slider/index.js +1 -1
- package/components/Slider/index.js.map +1 -1
- package/components/StatusDot/index.js +1 -1
- package/components/StatusDot/index.js.map +1 -1
- package/components/Table/TableExpandedRow/index.js +1 -1
- package/components/Table/TableExpanderCell/index.js +1 -1
- package/components/Table/TableHeadCell/index.js +1 -1
- package/components/Table/TableRow/index.js +1 -1
- package/components/Table/index.js +1 -1
- package/components/Table/index.js.map +1 -1
- package/components/Tag/index.js +1 -1
- package/components/Tag/index.js.map +1 -1
- package/components/Textarea/Textarea.d.ts +1 -1
- package/components/Textarea/Textarea.d.ts.map +1 -1
- package/components/Textarea/componentdata.json +1 -1
- package/components/Textarea/index.js +1 -1
- package/components/Tile/index.js +1 -1
- package/components/Tile/index.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +11 -12
- package/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/components/Tooltip/TooltipWord/TooltipWord.d.ts +20 -0
- package/components/Tooltip/TooltipWord/TooltipWord.d.ts.map +1 -0
- package/components/Tooltip/TooltipWord/componentdata.json +1 -0
- package/components/Tooltip/TooltipWord/index.d.ts +4 -0
- package/components/Tooltip/TooltipWord/index.d.ts.map +1 -0
- package/components/Tooltip/TooltipWord/index.js +2 -0
- package/components/Tooltip/TooltipWord/index.js.map +1 -0
- package/components/Tooltip/{styles.module.scss → TooltipWord/styles.module.scss} +3 -6
- package/components/Tooltip/{styles.module.scss.d.ts → TooltipWord/styles.module.scss.d.ts} +0 -0
- package/components/Tooltip/componentdata.json +1 -1
- package/components/Tooltip/index.js +1 -1
- package/components/TooltipExample/TooltipExample.d.ts.map +1 -1
- package/components/TooltipExample/componentdata.json +1 -1
- package/components/TooltipExample/index.js +1 -1
- package/components/TooltipExample/index.js.map +1 -1
- package/components/Validation/index.js +1 -1
- package/constants.d.ts +2 -0
- package/constants.d.ts.map +1 -1
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/hooks/useDelayedState.d.ts +9 -0
- package/hooks/useDelayedState.d.ts.map +1 -0
- package/hooks/useDelayedState.js +2 -0
- package/hooks/useDelayedState.js.map +1 -0
- package/hooks/useElementList.d.ts +9 -0
- package/hooks/useElementList.d.ts.map +1 -0
- package/hooks/useElementList.js +2 -0
- package/hooks/useElementList.js.map +1 -0
- package/hooks/useFocusToggle.d.ts.map +1 -1
- package/hooks/useFocusToggle.js +1 -1
- package/hooks/useFocusToggle.js.map +1 -1
- package/hooks/useFocusTrap.js +1 -1
- package/hooks/useFocusTrap.js.map +1 -1
- package/hooks/useFocusableElements.d.ts.map +1 -1
- package/hooks/useFocusableElements.js +1 -1
- package/hooks/useFocusableElements.js.map +1 -1
- package/hooks/useHover.d.ts +5 -6
- package/hooks/useHover.d.ts.map +1 -1
- package/hooks/useHover.js +1 -1
- package/hooks/useHover.js.map +1 -1
- package/hooks/useKeyboardEvent.d.ts +10 -1
- package/hooks/useKeyboardEvent.d.ts.map +1 -1
- package/hooks/useKeyboardEvent.js +1 -1
- package/hooks/useKeyboardEvent.js.map +1 -1
- package/hooks/useLayoutEvent.js +1 -1
- package/hooks/useLayoutEvent.js.map +1 -1
- package/hooks/useOutsideEvent.d.ts +1 -4
- package/hooks/useOutsideEvent.d.ts.map +1 -1
- package/hooks/useOutsideEvent.js +1 -1
- package/hooks/useOutsideEvent.js.map +1 -1
- package/hooks/useSize.js +1 -1
- package/hooks/useSize.js.map +1 -1
- package/hooks/useSticky.js +1 -1
- package/hooks/useSticky.js.map +1 -1
- package/hooks/useUuid.js +1 -1
- package/hooks/useUuid.js.map +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/utils/accessibility.js +2 -0
- package/utils/accessibility.js.map +1 -0
- package/utils/debounce.js +2 -0
- package/utils/debounce.js.map +1 -0
- package/utils/environment.js +2 -0
- package/utils/environment.js.map +1 -0
- package/{hooks/focus-utils.d.ts → utils/focus.d.ts} +1 -1
- package/utils/focus.d.ts.map +1 -0
- package/{hooks/focus-utils.js → utils/focus.js} +1 -1
- package/utils/focus.js.map +1 -0
- package/utils/loremtext.js +2 -0
- package/utils/loremtext.js.map +1 -0
- package/utils/refs.js +2 -0
- package/utils/refs.js.map +1 -0
- package/utils/uuid.js +2 -0
- package/utils/uuid.js.map +1 -0
- package/utils/viewport.js +2 -0
- package/utils/viewport.js.map +1 -0
- package/uuid.js +1 -1
- package/uuid.js.map +1 -1
- package/accessibility.js +0 -2
- package/accessibility.js.map +0 -1
- package/debounce.js +0 -2
- package/debounce.js.map +0 -1
- package/hooks/focus-utils.d.ts.map +0 -1
- package/hooks/focus-utils.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TooltipWordProps {
|
|
3
|
+
/** Ordet som skal ha en tilhørende tooltip */
|
|
4
|
+
children: string;
|
|
5
|
+
/** Callback når ordet klikkes på */
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
/** Callback når ordet får fokus eller hovres over */
|
|
8
|
+
onFocus: () => void;
|
|
9
|
+
/** Callback når ordet mister fokus eller hover forsvinner */
|
|
10
|
+
onBlur: () => void;
|
|
11
|
+
/** Callback når det skrives på tastaturet */
|
|
12
|
+
onKeyDown: (e: React.KeyboardEvent<HTMLSpanElement>) => void;
|
|
13
|
+
/** ID til element som beskriver ordet */
|
|
14
|
+
ariaDescribedById: string;
|
|
15
|
+
/** Valgfri test-id */
|
|
16
|
+
testId?: string;
|
|
17
|
+
}
|
|
18
|
+
declare const TooltipWord: React.ForwardRefExoticComponent<TooltipWordProps & React.RefAttributes<HTMLSpanElement>>;
|
|
19
|
+
export default TooltipWord;
|
|
20
|
+
//# sourceMappingURL=TooltipWord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipWord.d.ts","sourceRoot":"","sources":["../../../../src/components/Tooltip/TooltipWord/TooltipWord.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qDAAqD;IACrD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,6CAA6C;IAC7C,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAC7D,yCAAyC;IACzC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,WAAW,0FAmBhB,CAAC;AAIF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"props":{"children":{"defaultValue":null,"description":"Ordet som skal ha en tilhørende tooltip","name":"children","parent":{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"},"declarations":[{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"}],"required":true,"type":{"name":"string"}},"onClick":{"defaultValue":null,"description":"Callback når ordet klikkes på","name":"onClick","parent":{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"},"declarations":[{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"}],"required":true,"type":{"name":"() => void"}},"onFocus":{"defaultValue":null,"description":"Callback når ordet får fokus eller hovres over","name":"onFocus","parent":{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"},"declarations":[{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"}],"required":true,"type":{"name":"() => void"}},"onBlur":{"defaultValue":null,"description":"Callback når ordet mister fokus eller hover forsvinner","name":"onBlur","parent":{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"},"declarations":[{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"}],"required":true,"type":{"name":"() => void"}},"onKeyDown":{"defaultValue":null,"description":"Callback når det skrives på tastaturet","name":"onKeyDown","parent":{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"},"declarations":[{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"}],"required":true,"type":{"name":"(e: KeyboardEvent<HTMLSpanElement>) => void"}},"ariaDescribedById":{"defaultValue":null,"description":"ID til element som beskriver ordet","name":"ariaDescribedById","parent":{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"},"declarations":[{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"}],"required":true,"type":{"name":"string"}},"testId":{"defaultValue":null,"description":"Valgfri test-id","name":"testId","parent":{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"},"declarations":[{"fileName":"src/components/Tooltip/TooltipWord/TooltipWord.tsx","name":"TooltipWordProps"}],"required":false,"type":{"name":"string"}}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Tooltip/TooltipWord/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
@import '
|
|
2
|
-
@import '
|
|
1
|
+
@import '../../../scss/_palette.scss';
|
|
2
|
+
@import '../../../scss/_spacers.scss';
|
|
3
3
|
|
|
4
4
|
.word {
|
|
5
5
|
position: relative;
|
|
6
6
|
display: inline-block;
|
|
7
7
|
-webkit-text-decoration: underline dashed $plum400;
|
|
8
8
|
text-decoration: underline 0.15rem dashed $plum400;
|
|
9
|
-
|
|
10
|
-
&:hover {
|
|
11
|
-
cursor: help;
|
|
12
|
-
}
|
|
9
|
+
cursor: help;
|
|
13
10
|
|
|
14
11
|
&:focus-visible {
|
|
15
12
|
box-shadow: 0 0 0 getSpacer(4xs) $black;
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"props":{"children":{"defaultValue":null,"description":"Ordet som skal ha en tilhørende
|
|
1
|
+
{"props":{"children":{"defaultValue":null,"description":"Ordet som skal ha en tilhørende tooltip","name":"children","parent":{"fileName":"src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},"declarations":[{"fileName":"src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"TypeLiteral"}],"required":false,"type":{"name":"string & ReactNode"}},"description":{"defaultValue":null,"description":"Teksten som skal vises i tooltip","name":"description","parent":{"fileName":"src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},"declarations":[{"fileName":"src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"}],"required":true,"type":{"name":"ReactNode"}},"testId":{"defaultValue":null,"description":"Valgfri test-id","name":"testId","parent":{"fileName":"src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},"declarations":[{"fileName":"src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"}],"required":false,"type":{"name":"string"}}}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../Tooltip.js";import{T as
|
|
1
|
+
import"../../Tooltip.js";import{T as H,a as I,T as J}from"../../Tooltip.js";import"react";import"../../hooks/useDelayedState.js";import"../../hooks/useUuid.js";import"../../uuid.js";import"../../utils/environment.js";import"../../HelpBubble.js";import"classnames";import"../../constants.js";import"../../hooks/useInterval.js";import"../../hooks/useIsVisible.js";import"../../hooks/useIntersectionObserver.js";import"../../hooks/useLayoutEvent.js";import"../../utils/debounce.js";import"../../hooks/useSize.js";import"../../utils/refs.js";import"../../AnchorLink.js";import"../Icons/Icon.js";import"../Icons/ArrowUpRight.js";import"../../theme/currys/color.js";import"../../theme/index.js";import"../../theme/palette.js";import"../../theme/spacers.js";import"../../theme/grid.js";import"../../hooks/useHover.js";import"../AnchorLink/styles.module.scss";import"../../Close.js";import"../Icons/X.js";import"../Close/styles.module.scss";import"../../hooks/useBreakpoint.js";import"../HelpBubble/styles.module.scss";import"../../TooltipWord.js";import"./TooltipWord/styles.module.scss";export{H as Tooltip,I as TooltipOpenProvider,J as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipExample.d.ts","sourceRoot":"","sources":["../../../src/components/TooltipExample/TooltipExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAgB,EAAE,YAAY,EAAuB,MAAM,YAAY,CAAC;AAGxE,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"TooltipExample.d.ts","sourceRoot":"","sources":["../../../src/components/TooltipExample/TooltipExample.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAgB,EAAE,YAAY,EAAuB,MAAM,YAAY,CAAC;AAGxE,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAe1C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"props":{"children":{"defaultValue":null,"description":"Ordet som skal ha en tilhørende
|
|
1
|
+
{"props":{"children":{"defaultValue":null,"description":"Ordet som skal ha en tilhørende tooltip","name":"children","parent":{"fileName":"designsystem/src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},"declarations":[{"fileName":"designsystem/src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"TypeLiteral"}],"required":false,"type":{"name":"string & ReactNode"}},"description":{"defaultValue":null,"description":"Teksten som skal vises i tooltip","name":"description","parent":{"fileName":"designsystem/src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},"declarations":[{"fileName":"designsystem/src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"}],"required":true,"type":{"name":"ReactNode"}},"testId":{"defaultValue":null,"description":"Valgfri test-id","name":"testId","parent":{"fileName":"designsystem/src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"},"declarations":[{"fileName":"designsystem/src/components/Tooltip/Tooltip.tsx","name":"TooltipProps"}],"required":false,"type":{"name":"string"}}}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"react";import{a as e,T as o}from"../../Tooltip.js";import{longLoremText as m}from"../../utils/loremtext.js";import"../../hooks/useDelayedState.js";import"../../hooks/useUuid.js";import"../../uuid.js";import"../../utils/environment.js";import"../../HelpBubble.js";import"classnames";import"../../constants.js";import"../../hooks/useInterval.js";import"../../hooks/useIsVisible.js";import"../../hooks/useIntersectionObserver.js";import"../../hooks/useLayoutEvent.js";import"../../utils/debounce.js";import"../../hooks/useSize.js";import"../../utils/refs.js";import"../../AnchorLink.js";import"../Icons/Icon.js";import"../Icons/ArrowUpRight.js";import"../../theme/currys/color.js";import"../../theme/index.js";import"../../theme/palette.js";import"../../theme/spacers.js";import"../../theme/grid.js";import"../../hooks/useHover.js";import"../AnchorLink/styles.module.scss";import"../../Close.js";import"../Icons/X.js";import"../Close/styles.module.scss";import"../../hooks/useBreakpoint.js";import"../HelpBubble/styles.module.scss";import"../../TooltipWord.js";import"../Tooltip/TooltipWord/styles.module.scss";const H=r=>t.createElement(e,null,t.createElement(t.Fragment,null,t.createElement(o,{...r},"Et tooltip her.")," "+m,t.createElement("button",null,"Knapp"),"Dette er ",t.createElement(o,{...r},r.children)," som skal ha n\xE6rmere forklaring.",m,t.createElement(o,{...r},"Enda et tooltip her.")));export{H as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/TooltipExample/TooltipExample.tsx"],"sourcesContent":["import React from 'react';\n\nimport Tooltip, { TooltipProps, TooltipOpenProvider } from '../Tooltip';\nimport longLoremText from '../../utils/loremtext';\n\nconst TooltipExample: React.FC<TooltipProps> = props => {\n return (\n <TooltipOpenProvider>\n <>\n <Tooltip {...props}>{'Et tooltip her.'}</Tooltip>\n {' ' + longLoremText}\n <button>{'Knapp'}</button>\n {'Dette er '}\n <Tooltip {...props}>{props.children}</Tooltip>\n {' som skal ha nærmere forklaring.'}\n {longLoremText}\n <Tooltip {...props}>{'Enda et tooltip her.'}</Tooltip>\n </>\n </TooltipOpenProvider>\n );\n};\n\nexport default TooltipExample;\n"],"names":["TooltipExample","props","React","TooltipOpenProvider","Tooltip","longLoremText"],"mappings":"kmCAKA,MAAMA,EAAkDC,GAEpDC,EAAA,cAACC,EACC,KAAAD,EAAA,cAAAA,EAAA,SAAA,KACGA,EAAA,cAAAE,EAAA,CAAS,GAAGH,CAAQ,EAAA,iBAAkB,EACtC,IAAMI,kBACN,SAAQ,KAAA,OAAQ,EAChB,YACAH,EAAA,cAAAE,EAAA,CAAS,GAAGH,CAAA,EAAQA,EAAM,QAAS,EACnC,sCACAI,EACAH,EAAA,cAAAE,EAAA,CAAS,GAAGH,CAAA,EAAQ,sBAAuB,CAC9C,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../Validation.js";import{V as
|
|
1
|
+
import"../../Validation.js";import{V as J,V as K}from"../../Validation.js";import"react";import"classnames";import"../../FormGroup.js";import"../FormGroup/styles.module.scss";import"../../Checkbox.js";import"../../uuid.js";import"../../utils/environment.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../constants.js";import"../../hooks/useUuid.js";import"../../theme/currys/color.js";import"../../theme/index.js";import"../../theme/palette.js";import"../../theme/spacers.js";import"../../theme/grid.js";import"../Checkbox/styles.module.scss";import"../../RadioButton.js";import"../RadioButton/styles.module.scss";import"../../Input.js";import"../../hooks/useBreakpoint.js";import"../../ErrorWrapper.js";import"../ErrorWrapper/styles.module.scss";import"../Input/styles.module.scss";import"../../Title.js";import"../Title/styles.module.scss";import"../../FormLayout.js";import"../FormLayout/styles.module.scss";import"../../Select.js";import"../Select/styles.module.scss";import"../Icons/ChevronDown.js";import"./styles.module.scss";export{J as Validation,K as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/constants.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare enum ZIndex {
|
|
|
10
10
|
Modal = 1300000,
|
|
11
11
|
ExpanderTrigger = 10000
|
|
12
12
|
}
|
|
13
|
+
export declare const AVERAGE_CHARACTER_WIDTH_PX = 12;
|
|
13
14
|
export interface HTMLButtonProps {
|
|
14
15
|
autoFocus?: boolean;
|
|
15
16
|
disabled?: boolean;
|
|
@@ -77,6 +78,7 @@ export declare enum AnalyticsId {
|
|
|
77
78
|
Portal = "portal",
|
|
78
79
|
Progressbar = "progressbar",
|
|
79
80
|
RadioButton = "radio-button",
|
|
81
|
+
Select = "select",
|
|
80
82
|
Slider = "slider",
|
|
81
83
|
Spacer = "spacer",
|
|
82
84
|
StatusDot = "status-dot",
|
package/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"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"}
|
package/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=(r=>(r[r.XXSmall=24]="XXSmall",r[r.XSmall=38]="XSmall",r[r.Small=48]="Small",r[r.Medium=64]="Medium",r[r.Large=80]="Large",r[r.XLarge=130]="XLarge",r))(o||{}),e=(r=>(r[r.Modal=13e5]="Modal",r[r.ExpanderTrigger=1e4]="ExpanderTrigger",r))(e||{})
|
|
1
|
+
var o=(r=>(r[r.XXSmall=24]="XXSmall",r[r.XSmall=38]="XSmall",r[r.Small=48]="Small",r[r.Medium=64]="Medium",r[r.Large=80]="Large",r[r.XLarge=130]="XLarge",r))(o||{}),e=(r=>(r[r.Modal=13e5]="Modal",r[r.ExpanderTrigger=1e4]="ExpanderTrigger",r))(e||{});const u=12;var a=(r=>(r.onwhite="onwhite",r.ongrey="ongrey",r.onblueberry="onblueberry",r.ondark="ondark",r.oninvalid="oninvalid",r))(a||{}),p=(r=>(r.normal="normal",r.bigform="bigform",r))(p||{}),g=(r=>(r.AnchorLink="anchor-link",r.Avatar="avatar",r.Badge="badge",r.Button="button",r.Checkbox="checkbox",r.Close="close",r.Dropdown="dropdown",r.Duolist="duolist",r.Expander="expander",r.ExpanderList="expander-list",r.ExpanderListExpander="expander-list-expander",r.FormGroup="form-group",r.FormLayout="form-layout",r.HelpBubble="help-bubble",r.HighlightBox="highlight-box",r.Icon="icon",r.Input="input",r.Link="link",r.LinkList="link-list",r.List="list",r.Loader="loader",r.Logo="logo",r.Modal="modal",r.NotificationPanel="notification-panel",r.Panel="panel",r.PanelList="panel-list",r.Portal="portal",r.Progressbar="progressbar",r.RadioButton="radio-button",r.Select="select",r.Slider="slider",r.Spacer="spacer",r.StatusDot="status-dot",r.Table="table",r.Tag="tag",r.TagList="tag-list",r.Textarea="textarea",r.Tile="tile",r.Title="title",r.Tooltip="tooltip",r.Validation="validation",r))(g||{}),l=(r=>(r.Enter="Enter",r.Escape="Escape",r.ArrowDown="ArrowDown",r.ArrowUp="ArrowUp",r.Home="Home",r.End="End",r))(l||{});export{u as AVERAGE_CHARACTER_WIDTH_PX,g as AnalyticsId,a as FormMode,p as FormVariant,o as IconSize,l as KeyboardEventKey,e as ZIndex};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
package/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export enum IconSize {\n XXSmall = 24,\n XSmall = 38,\n Small = 48,\n Medium = 64,\n Large = 80,\n XLarge = 130,\n}\n\nexport enum ZIndex {\n Modal = 1300000,\n ExpanderTrigger = 10000,\n}\n\nexport interface HTMLButtonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n form?: string;\n formAction?: string;\n formEncType?: string;\n formMethod?: string;\n formNoValidate?: boolean;\n formTarget?: string;\n name?: string;\n type?: 'submit' | 'reset' | 'button' | string;\n value?: string | string[] | number;\n id?: string;\n}\n\nexport type AnchorTarget = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface HTMLAnchorProps {\n download?: string;\n href?: string;\n hrefLang?: string;\n media?: string;\n ping?: string;\n rel?: AnchorTarget;\n target?: string;\n referrerPolicy?:\n | ''\n | 'same-origin'\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n}\n\nexport type ButtonVariant = 'secondary' | 'tertiary' | string | undefined | null;\n\nexport enum FormMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n ondark = 'ondark',\n oninvalid = 'oninvalid',\n}\n\nexport enum FormVariant {\n normal = 'normal',\n bigform = 'bigform',\n}\n\nexport enum AnalyticsId {\n AnchorLink = 'anchor-link',\n Avatar = 'avatar',\n Badge = 'badge',\n Button = 'button',\n Checkbox = 'checkbox',\n Close = 'close',\n Dropdown = 'dropdown',\n Duolist = 'duolist',\n Expander = 'expander',\n ExpanderList = 'expander-list',\n ExpanderListExpander = 'expander-list-expander',\n FormGroup = 'form-group',\n FormLayout = 'form-layout',\n HelpBubble = 'help-bubble',\n HighlightBox = 'highlight-box',\n Icon = 'icon',\n Input = 'input',\n Link = 'link',\n LinkList = 'link-list',\n List = 'list',\n Loader = 'loader',\n Logo = 'logo',\n Modal = 'modal',\n NotificationPanel = 'notification-panel',\n Panel = 'panel',\n PanelList = 'panel-list',\n Portal = 'portal',\n Progressbar = 'progressbar',\n RadioButton = 'radio-button',\n Slider = 'slider',\n Spacer = 'spacer',\n StatusDot = 'status-dot',\n Table = 'table',\n Tag = 'tag',\n TagList = 'tag-list',\n Textarea = 'textarea',\n Tile = 'tile',\n Title = 'title',\n Tooltip = 'tooltip',\n Validation = 'validation',\n}\n\nexport enum KeyboardEventKey {\n Enter = 'Enter',\n Escape = 'Escape',\n ArrowDown = 'ArrowDown',\n ArrowUp = 'ArrowUp',\n Home = 'Home',\n End = 'End',\n}\n"],"names":["IconSize","ZIndex","FormMode","FormVariant","AnalyticsId","KeyboardEventKey"],"mappings":"AAAY,IAAAA,GAAAA,IACVA,EAAAA,EAAA,QAAU,IAAV,UACAA,EAAAA,EAAA,OAAS,IAAT,SACAA,EAAAA,EAAA,MAAQ,IAAR,QACAA,EAAAA,EAAA,OAAS,IAAT,SACAA,EAAAA,EAAA,MAAQ,IAAR,QACAA,EAAAA,EAAA,OAAS,KAAT,SANUA,IAAAA,GAAA,CAAA,CAAA,EASAC,GAAAA,IACVA,EAAAA,EAAA,MAAQ,MAAR,QACAA,EAAAA,EAAA,gBAAkB,KAAlB,kBAFUA,IAAAA,GAAA,CAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export enum IconSize {\n XXSmall = 24,\n XSmall = 38,\n Small = 48,\n Medium = 64,\n Large = 80,\n XLarge = 130,\n}\n\nexport enum ZIndex {\n Modal = 1300000,\n ExpanderTrigger = 10000,\n}\n\nexport const AVERAGE_CHARACTER_WIDTH_PX = 12;\n\nexport interface HTMLButtonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n form?: string;\n formAction?: string;\n formEncType?: string;\n formMethod?: string;\n formNoValidate?: boolean;\n formTarget?: string;\n name?: string;\n type?: 'submit' | 'reset' | 'button' | string;\n value?: string | string[] | number;\n id?: string;\n}\n\nexport type AnchorTarget = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface HTMLAnchorProps {\n download?: string;\n href?: string;\n hrefLang?: string;\n media?: string;\n ping?: string;\n rel?: AnchorTarget;\n target?: string;\n referrerPolicy?:\n | ''\n | 'same-origin'\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n}\n\nexport type ButtonVariant = 'secondary' | 'tertiary' | string | undefined | null;\n\nexport enum FormMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n ondark = 'ondark',\n oninvalid = 'oninvalid',\n}\n\nexport enum FormVariant {\n normal = 'normal',\n bigform = 'bigform',\n}\n\nexport enum AnalyticsId {\n AnchorLink = 'anchor-link',\n Avatar = 'avatar',\n Badge = 'badge',\n Button = 'button',\n Checkbox = 'checkbox',\n Close = 'close',\n Dropdown = 'dropdown',\n Duolist = 'duolist',\n Expander = 'expander',\n ExpanderList = 'expander-list',\n ExpanderListExpander = 'expander-list-expander',\n FormGroup = 'form-group',\n FormLayout = 'form-layout',\n HelpBubble = 'help-bubble',\n HighlightBox = 'highlight-box',\n Icon = 'icon',\n Input = 'input',\n Link = 'link',\n LinkList = 'link-list',\n List = 'list',\n Loader = 'loader',\n Logo = 'logo',\n Modal = 'modal',\n NotificationPanel = 'notification-panel',\n Panel = 'panel',\n PanelList = 'panel-list',\n Portal = 'portal',\n Progressbar = 'progressbar',\n RadioButton = 'radio-button',\n Select = 'select',\n Slider = 'slider',\n Spacer = 'spacer',\n StatusDot = 'status-dot',\n Table = 'table',\n Tag = 'tag',\n TagList = 'tag-list',\n Textarea = 'textarea',\n Tile = 'tile',\n Title = 'title',\n Tooltip = 'tooltip',\n Validation = 'validation',\n}\n\nexport enum KeyboardEventKey {\n Enter = 'Enter',\n Escape = 'Escape',\n ArrowDown = 'ArrowDown',\n ArrowUp = 'ArrowUp',\n Home = 'Home',\n End = 'End',\n}\n"],"names":["IconSize","ZIndex","AVERAGE_CHARACTER_WIDTH_PX","FormMode","FormVariant","AnalyticsId","KeyboardEventKey"],"mappings":"AAAY,IAAAA,GAAAA,IACVA,EAAAA,EAAA,QAAU,IAAV,UACAA,EAAAA,EAAA,OAAS,IAAT,SACAA,EAAAA,EAAA,MAAQ,IAAR,QACAA,EAAAA,EAAA,OAAS,IAAT,SACAA,EAAAA,EAAA,MAAQ,IAAR,QACAA,EAAAA,EAAA,OAAS,KAAT,SANUA,IAAAA,GAAA,CAAA,CAAA,EASAC,GAAAA,IACVA,EAAAA,EAAA,MAAQ,MAAR,QACAA,EAAAA,EAAA,gBAAkB,KAAlB,kBAFUA,IAAAA,GAAA,CAAA,CAAA,EAKL,MAAMC,EAA6B,GAyC9B,IAAAC,GAAAA,IACVA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,YAAc,cACdA,EAAA,OAAS,SACTA,EAAA,UAAY,YALFA,IAAAA,GAAA,CAAA,CAAA,EAQAC,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,QAAU,UAFAA,IAAAA,GAAA,CAAA,CAAA,EAKAC,GAAAA,IACVA,EAAA,WAAa,cACbA,EAAA,OAAS,SACTA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,SAAW,WACXA,EAAA,aAAe,gBACfA,EAAA,qBAAuB,yBACvBA,EAAA,UAAY,aACZA,EAAA,WAAa,cACbA,EAAA,WAAa,cACbA,EAAA,aAAe,gBACfA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,KAAO,OACPA,EAAA,SAAW,YACXA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,kBAAoB,qBACpBA,EAAA,MAAQ,QACRA,EAAA,UAAY,aACZA,EAAA,OAAS,SACTA,EAAA,YAAc,cACdA,EAAA,YAAc,eACdA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,UAAY,aACZA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,QAAU,WACVA,EAAA,SAAW,WACXA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,QAAU,UACVA,EAAA,WAAa,aAzCHA,IAAAA,GAAA,CAAA,CAAA,EA4CAC,GAAAA,IACVA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,IAAM,MANIA,IAAAA,GAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* useState, men med mulighet for å oppdatere state etter X millisekunder
|
|
4
|
+
* @param initialState Verdi state skal ha ved første render
|
|
5
|
+
* @param delay Vent X millisekunder før state oppdateres
|
|
6
|
+
* @returns state, callback for å oppdatere state etter delay, og callback for å oppdatere state umiddelbart
|
|
7
|
+
*/
|
|
8
|
+
export declare const useDelayedState: <S>(initialState: S, delay: number) => [S, Dispatch<SetStateAction<S>>, Dispatch<SetStateAction<S>>];
|
|
9
|
+
//# sourceMappingURL=useDelayedState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDelayedState.d.ts","sourceRoot":"","sources":["../../src/hooks/useDelayedState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA+B,MAAM,OAAO,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,eAAe,8BAA+B,MAAM,kEAqBhE,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useState as n,useRef as l,useEffect as m}from"react";const d=(u,c)=>{const[o,r]=n(u),e=l(),s=t=>{clearTimeout(e.current),e.current=window.setTimeout(()=>r(t),c)},a=t=>{clearTimeout(e.current),r(t)};return m(()=>()=>{clearTimeout(e.current)},[]),[o,s,a]};export{d as useDelayedState};
|
|
2
|
+
//# sourceMappingURL=useDelayedState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDelayedState.js","sources":["../../src/hooks/useDelayedState.ts"],"sourcesContent":["import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';\n\n/**\n * useState, men med mulighet for å oppdatere state etter X millisekunder\n * @param initialState Verdi state skal ha ved første render\n * @param delay Vent X millisekunder før state oppdateres\n * @returns state, callback for å oppdatere state etter delay, og callback for å oppdatere state umiddelbart\n */\nexport const useDelayedState = <S>(initialState: S, delay: number): [S, Dispatch<SetStateAction<S>>, Dispatch<SetStateAction<S>>] => {\n const [value, setValue] = useState(initialState);\n const timer = useRef<number>();\n\n const setDelayedValue = (newState: SetStateAction<S>): void => {\n clearTimeout(timer.current);\n timer.current = window.setTimeout(() => setValue(newState), delay);\n };\n\n const setImmediateValue = (newState: SetStateAction<S>): void => {\n clearTimeout(timer.current);\n setValue(newState);\n };\n\n useEffect(() => {\n return () => {\n clearTimeout(timer.current);\n };\n }, []);\n\n return [value, setDelayedValue, setImmediateValue];\n};\n"],"names":["useDelayedState","initialState","delay","value","setValue","useState","timer","useRef","setDelayedValue","newState","setImmediateValue","useEffect"],"mappings":"4DAQa,MAAAA,EAAkB,CAAIC,EAAiBC,IAAiF,CACnI,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAASJ,CAAY,EACzCK,EAAQC,IAERC,EAAmBC,GAAsC,CAC7D,aAAaH,EAAM,OAAO,EAC1BA,EAAM,QAAU,OAAO,WAAW,IAAMF,EAASK,CAAQ,EAAGP,CAAK,CAAA,EAG7DQ,EAAqBD,GAAsC,CAC/D,aAAaH,EAAM,OAAO,EAC1BF,EAASK,CAAQ,CAAA,EAGnB,OAAAE,EAAU,IACD,IAAM,CACX,aAAaL,EAAM,OAAO,CAAA,EAE3B,CAAE,CAAA,EAEE,CAACH,EAAOK,EAAiBE,CAAiB,CACnD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hent ut en liste med HTML-elementer. Bruker MutationObserver-APIet.
|
|
3
|
+
* @param ref Element som skal observeres
|
|
4
|
+
* @param selectors Selektorer som sendes til querySelectorAll for å hente ut liste med elementer
|
|
5
|
+
* @param options MutationObserver-options. Default er å lytte på endringer på child-elementer og deres attributter.
|
|
6
|
+
* @returns Liste med HTML-elementer
|
|
7
|
+
*/
|
|
8
|
+
export declare const useElementList: (ref: React.RefObject<HTMLElement>, selectors: string, options?: MutationObserverInit) => NodeListOf<HTMLElement> | undefined;
|
|
9
|
+
//# sourceMappingURL=useElementList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementList.d.ts","sourceRoot":"","sources":["../../src/hooks/useElementList.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QACpB,MAAM,SAAS,CAAC,WAAW,CAAC,aACtB,MAAM,YACP,oBAAoB,KAC7B,WAAW,WAAW,CAAC,GAAG,SAsB5B,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useState as l,useEffect as a}from"react";const b=(t,e,u)=>{const[o,c]=l();return a(()=>{const n=()=>{var r;const i=(r=t.current)==null?void 0:r.querySelectorAll(e);c(i)},s=new MutationObserver(n);return t!=null&&t.current&&s.observe(t.current,{subtree:!0,childList:!0,attributes:!0,...u}),n(),()=>{s.disconnect()}},[t,e]),o};export{b as useElementList};
|
|
2
|
+
//# sourceMappingURL=useElementList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementList.js","sources":["../../src/hooks/useElementList.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\n/**\n * Hent ut en liste med HTML-elementer. Bruker MutationObserver-APIet.\n * @param ref Element som skal observeres\n * @param selectors Selektorer som sendes til querySelectorAll for å hente ut liste med elementer\n * @param options MutationObserver-options. Default er å lytte på endringer på child-elementer og deres attributter.\n * @returns Liste med HTML-elementer\n */\nexport const useElementList = (\n ref: React.RefObject<HTMLElement>,\n selectors: string,\n options?: MutationObserverInit\n): NodeListOf<HTMLElement> | undefined => {\n const [elementList, setElementList] = useState<NodeListOf<HTMLElement>>();\n\n useEffect(() => {\n const handleMutationChange = () => {\n const elements = ref.current?.querySelectorAll<HTMLElement>(selectors);\n setElementList(elements);\n };\n\n const mutationObserver = new MutationObserver(handleMutationChange);\n if (ref?.current) {\n mutationObserver.observe(ref.current, { subtree: true, childList: true, attributes: true, ...options });\n }\n\n handleMutationChange();\n\n return (): void => {\n mutationObserver.disconnect();\n };\n }, [ref, selectors]);\n\n return elementList;\n};\n"],"names":["useElementList","ref","selectors","options","elementList","setElementList","useState","useEffect","handleMutationChange","elements","_a","mutationObserver"],"mappings":"gDASO,MAAMA,EAAiB,CAC5BC,EACAC,EACAC,IACwC,CACxC,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAkC,EAExE,OAAAC,EAAU,IAAM,CACd,MAAMC,EAAuB,IAAM,OACjC,MAAMC,GAAWC,EAAAT,EAAI,UAAJ,YAAAS,EAAa,iBAA8BR,GAC5DG,EAAeI,CAAQ,CAAA,EAGnBE,EAAmB,IAAI,iBAAiBH,CAAoB,EAClE,OAAIP,GAAA,MAAAA,EAAK,SACPU,EAAiB,QAAQV,EAAI,QAAS,CAAE,QAAS,GAAM,UAAW,GAAM,WAAY,GAAM,GAAGE,CAAS,CAAA,EAGnFK,IAEd,IAAY,CACjBG,EAAiB,WAAW,CAAA,CAC9B,EACC,CAACV,EAAKC,CAAS,CAAC,EAEZE,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusToggle.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusToggle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useFocusToggle.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusToggle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,eAAe,OAAO,KAAG,IA6BxF,CAAC"}
|
package/hooks/useFocusToggle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as T}from"react";import{useElementList as s}from"./useElementList.js";import{FOCUSABLE_SELECTORS as a}from"./useFocusableElements.js";const f=(i,o)=>{const r=s(i,a,{attributes:!1});T(()=>{const e="tabindex",A="data-tabindex";o?r==null||r.forEach(t=>{const E=t.getAttribute(A);E?t.setAttribute(e,E):t.removeAttribute(e)}):r==null||r.forEach(t=>{t.hasAttribute(e)&&t.setAttribute(A,`${t.tabIndex}`),t.tabIndex=-1})},[i,o,r])};export{f as useFocusToggle};
|
|
2
2
|
//# sourceMappingURL=useFocusToggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusToggle.js","sources":["../../src/hooks/useFocusToggle.ts"],"sourcesContent":["import React, { useEffect } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"useFocusToggle.js","sources":["../../src/hooks/useFocusToggle.ts"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useElementList } from './useElementList';\nimport { FOCUSABLE_SELECTORS } from './useFocusableElements';\n\n/**\n * Skru av og på fokus på fokuserbare elementer slik at de kan være en del av DOMen, men samtidig\n * ikke kunne fokuseres/tabbes til med tastaturet.\n * @param ref Alle barn av dette elementet vil sjekkes for om de er fokuserbare\n * @param allowFocus Om elementene skal være fokuserbare eller ikke\n * @returns void\n */\nexport const useFocusToggle = (ref: React.RefObject<HTMLElement>, allowFocus?: boolean): void => {\n // Kan ikke lytte på endringer i attributter, fordi det vil føre til en loop når vi endrer dem etterpå\n const focusableElementList = useElementList(ref, FOCUSABLE_SELECTORS, { attributes: false });\n\n useEffect(() => {\n const TABINDEX_ATTRIBUTE_NAME = 'tabindex';\n const PREVIOUS_TABINDEX_ATTRIBUTE_NAME = 'data-tabindex';\n if (allowFocus) {\n focusableElementList?.forEach(el => {\n // Sett tabIndex tilbake til verdien den hadde før, eller fjern tabIndex\n // slik at elementet kan tabbes til igjen.\n const prevTabIndex = el.getAttribute(PREVIOUS_TABINDEX_ATTRIBUTE_NAME);\n if (prevTabIndex) {\n el.setAttribute(TABINDEX_ATTRIBUTE_NAME, prevTabIndex);\n } else {\n el.removeAttribute(TABINDEX_ATTRIBUTE_NAME);\n }\n });\n } else {\n focusableElementList?.forEach(el => {\n // Hvis elementet allerede har tabIndex, ta vare på den før vi gjør det umulig å\n // tabbe til det.\n if (el.hasAttribute(TABINDEX_ATTRIBUTE_NAME)) {\n el.setAttribute(PREVIOUS_TABINDEX_ATTRIBUTE_NAME, `${el.tabIndex}`);\n }\n el.tabIndex = -1;\n });\n }\n }, [ref, allowFocus, focusableElementList]);\n};\n"],"names":["useFocusToggle","ref","allowFocus","focusableElementList","useElementList","FOCUSABLE_SELECTORS","useEffect","TABINDEX_ATTRIBUTE_NAME","PREVIOUS_TABINDEX_ATTRIBUTE_NAME","el","prevTabIndex"],"mappings":"uJAWa,MAAAA,EAAiB,CAACC,EAAmCC,IAA+B,CAE/F,MAAMC,EAAuBC,EAAeH,EAAKI,EAAqB,CAAE,WAAY,GAAO,EAE3FC,EAAU,IAAM,CACd,MAAMC,EAA0B,WAC1BC,EAAmC,gBACrCN,EACFC,GAAA,MAAAA,EAAsB,QAAcM,GAAA,CAG5B,MAAAC,EAAeD,EAAG,aAAaD,CAAgC,EACjEE,EACCD,EAAA,aAAaF,EAAyBG,CAAY,EAErDD,EAAG,gBAAgBF,CAAuB,CAC5C,GAGFJ,GAAA,MAAAA,EAAsB,QAAcM,GAAA,CAG9BA,EAAG,aAAaF,CAAuB,GACzCE,EAAG,aAAaD,EAAkC,GAAGC,EAAG,UAAU,EAEpEA,EAAG,SAAW,EAAA,EAGjB,EAAA,CAACR,EAAKC,EAAYC,CAAoB,CAAC,CAC5C"}
|
package/hooks/useFocusTrap.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as m}from"react";import{getDocumentActiveElement as u}from"../utils/focus.js";import{useFocusableElements as f}from"./useFocusableElements.js";import"./useElementList.js";const p=(n,o=!0,c=!1)=>{const e=f(n),i=t=>{if(o&&n.current&&(e==null?void 0:e.length)&&t.key==="Tab"){const r=u(n.current),s=e[0],l=e.length===1?s:e[e.length-1];t.shiftKey&&r===s?(l.focus(),t.preventDefault()):!t.shiftKey&&r===l&&(s.focus(),t.preventDefault())}};m(()=>{var t;return c&&o&&(e==null?void 0:e.length)&&e[0].focus(),(t=n.current)==null||t.addEventListener("keydown",i),()=>{var r;(r=n.current)==null||r.removeEventListener("keydown",i)}},[n,o,c,e])};export{p as default,p as useFocusTrap};
|
|
2
2
|
//# sourceMappingURL=useFocusTrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusTrap.js","sources":["../../src/hooks/useFocusTrap.ts"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { getDocumentActiveElement } from '
|
|
1
|
+
{"version":3,"file":"useFocusTrap.js","sources":["../../src/hooks/useFocusTrap.ts"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { getDocumentActiveElement } from '../utils/focus';\nimport { useFocusableElements } from './useFocusableElements';\n\n/**\n * Lås fokus til et bestemt element. Bruker vil bare kunne tabbe mellom fokuserbare elementer innenfor elementet.\n * @param ref Alle barn av dette elementet vil være fokuserbare, elementer utenfor vil ikke det\n * @param trapFocus Om fokus skal \"trappes\" innenfor elementet eller ikke. Default=true.\n * @param autofocus Om fokus automatisk skal settes til første fokuserbare element. Default=false.\n */\nexport const useFocusTrap = (ref: React.RefObject<HTMLElement>, trapFocus: boolean = true, autofocus: boolean = false): void => {\n const focusableElementList = useFocusableElements(ref);\n\n const handleKeyboardEvent = (e: KeyboardEvent): void => {\n if (trapFocus && ref.current && focusableElementList?.length && e.key === 'Tab') {\n const activeElement = getDocumentActiveElement(ref.current);\n const firstElement = focusableElementList[0];\n const lastElement = focusableElementList.length === 1 ? firstElement : focusableElementList[focusableElementList.length - 1];\n\n if (e.shiftKey && activeElement === firstElement) {\n /* shift + tab */\n lastElement.focus();\n e.preventDefault();\n } else if (!e.shiftKey && activeElement === lastElement) {\n /* tab */\n firstElement.focus();\n e.preventDefault();\n }\n }\n };\n\n useEffect(() => {\n if (autofocus && trapFocus && focusableElementList?.length) {\n focusableElementList[0].focus();\n }\n\n ref.current?.addEventListener('keydown', handleKeyboardEvent);\n\n return (): void => {\n ref.current?.removeEventListener('keydown', handleKeyboardEvent);\n };\n }, [ref, trapFocus, autofocus, focusableElementList]); // focusableElementList må være med som dependency for at handleKeyboardEvent skal få oppdatert state\n};\n\nexport default useFocusTrap;\n"],"names":["useFocusTrap","ref","trapFocus","autofocus","focusableElementList","useFocusableElements","handleKeyboardEvent","e","activeElement","getDocumentActiveElement","firstElement","lastElement","useEffect","_a"],"mappings":"4LAUO,MAAMA,EAAe,CAACC,EAAmCC,EAAqB,GAAMC,EAAqB,KAAgB,CACxH,MAAAC,EAAuBC,EAAqBJ,CAAG,EAE/CK,EAAuBC,GAA2B,CACtD,GAAIL,GAAaD,EAAI,UAAWG,GAAA,YAAAA,EAAsB,SAAUG,EAAE,MAAQ,MAAO,CACzE,MAAAC,EAAgBC,EAAyBR,EAAI,OAAO,EACpDS,EAAeN,EAAqB,GACpCO,EAAcP,EAAqB,SAAW,EAAIM,EAAeN,EAAqBA,EAAqB,OAAS,GAEtHG,EAAE,UAAYC,IAAkBE,GAElCC,EAAY,MAAM,EAClBJ,EAAE,eAAe,GACR,CAACA,EAAE,UAAYC,IAAkBG,IAE1CD,EAAa,MAAM,EACnBH,EAAE,eAAe,EAErB,CAAA,EAGFK,EAAU,IAAM,OACV,OAAAT,GAAaD,IAAaE,GAAA,YAAAA,EAAsB,SAClDA,EAAqB,GAAG,SAGtBS,EAAAZ,EAAA,UAAA,MAAAY,EAAS,iBAAiB,UAAWP,GAElC,IAAY,QACbO,EAAAZ,EAAA,UAAA,MAAAY,EAAS,oBAAoB,UAAWP,EAAmB,GAEhE,CAACL,EAAKC,EAAWC,EAAWC,CAAoB,CAAC,CACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusableElements.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusableElements.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,QAarB,CAAC;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,KAAG,WAAW,WAAW,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"useFocusableElements.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusableElements.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,QAarB,CAAC;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,KAAG,WAAW,WAAW,CAAC,GAAG,SACzD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useElementList as n}from"./useElementList.js";import"react";const e=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'].join(","),d=t=>n(t,e);export{e as FOCUSABLE_SELECTORS,d as useFocusableElements};
|
|
2
2
|
//# sourceMappingURL=useFocusableElements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusableElements.js","sources":["../../src/hooks/useFocusableElements.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useFocusableElements.js","sources":["../../src/hooks/useFocusableElements.ts"],"sourcesContent":["import { useElementList } from './useElementList';\n\n// Fra https://github.com/KittyGiraudel/focusable-selectors\nexport const FOCUSABLE_SELECTORS = [\n 'a[href]:not([tabindex^=\"-\"])',\n 'area[href]:not([tabindex^=\"-\"])',\n 'input:not([type=\"hidden\"]):not([type=\"radio\"]):not([disabled]):not([tabindex^=\"-\"])',\n 'input[type=\"radio\"]:not([disabled]):not([tabindex^=\"-\"])',\n 'select:not([disabled]):not([tabindex^=\"-\"])',\n 'textarea:not([disabled]):not([tabindex^=\"-\"])',\n 'button:not([disabled]):not([tabindex^=\"-\"])',\n 'iframe:not([tabindex^=\"-\"])',\n 'audio[controls]:not([tabindex^=\"-\"])',\n 'video[controls]:not([tabindex^=\"-\"])',\n '[contenteditable]:not([tabindex^=\"-\"])',\n '[tabindex]:not([tabindex^=\"-\"])',\n].join(',');\n\n/**\n * Overvåk et element og finn alle fokuserbare elementer inne i elementet. Bruker MutationObserver slik at eventuelle\n * nye elementer som legges til også vil inkluderes i listen.\n * @param ref Element som skal observeres\n * @returns Liste med fokuserbare HTML-elementer\n */\nexport const useFocusableElements = (ref: React.RefObject<HTMLElement>): NodeListOf<HTMLElement> | undefined =>\n useElementList(ref, FOCUSABLE_SELECTORS);\n"],"names":["FOCUSABLE_SELECTORS","useFocusableElements","ref","useElementList"],"mappings":"mEAGO,MAAMA,EAAsB,CACjC,+BACA,kCACA,sFACA,2DACA,8CACA,gDACA,8CACA,8BACA,uCACA,uCACA,yCACA,iCACF,EAAE,KAAK,GAAG,EAQGC,EAAwBC,GACnCC,EAAeD,EAAKF,CAAmB"}
|
package/hooks/useHover.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* includeFocus: If focusing the ref should count as a hover or not. True by default.
|
|
2
|
+
/**
|
|
3
|
+
* Få vite når et element hovres over eller mottar fokus.
|
|
4
|
+
* @param ref Element som skal observeres
|
|
5
|
+
* @returns Objekt med ref og om objekt er hovered/focused
|
|
7
6
|
*/
|
|
8
|
-
export declare const useHover: <T extends HTMLElement | SVGElement>(ref?: RefObject<T> | undefined
|
|
7
|
+
export declare const useHover: <T extends HTMLElement | SVGElement>(ref?: RefObject<T> | undefined) => {
|
|
9
8
|
hoverRef: RefObject<T>;
|
|
10
9
|
isHovered: boolean;
|
|
11
10
|
};
|
package/hooks/useHover.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHover.d.ts","sourceRoot":"","sources":["../../src/hooks/useHover.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/D
|
|
1
|
+
{"version":3,"file":"useHover.d.ts","sourceRoot":"","sources":["../../src/hooks/useHover.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,QAAQ;;eAAkG,OAAO;CAyB7H,CAAC"}
|
package/hooks/useHover.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useRef as
|
|
1
|
+
import{useRef as H,useState as L,useEffect as I}from"react";const M=t=>{const e=t||H(null),[h,n]=L(!1),[F,s]=L(!1);return I(()=>{var v,d,a,i;const r=()=>n(!0),o=()=>n(!1),u=()=>s(!0),c=()=>s(!1);return(v=e.current)==null||v.addEventListener("mouseenter",r),(d=e.current)==null||d.addEventListener("mouseleave",o),(a=e.current)==null||a.addEventListener("focusin",u),(i=e.current)==null||i.addEventListener("focusout",c),()=>{var f,l,m,E;(f=e.current)==null||f.removeEventListener("mouseenter",r),(l=e.current)==null||l.removeEventListener("mouseleave",o),(m=e.current)==null||m.removeEventListener("focusin",u),(E=e.current)==null||E.removeEventListener("focusout",c)}},[e]),{hoverRef:e,isHovered:h||F}};export{M as useHover};
|
|
2
2
|
//# sourceMappingURL=useHover.js.map
|
package/hooks/useHover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHover.js","sources":["../../src/hooks/useHover.ts"],"sourcesContent":["import { useRef, useEffect, useState, RefObject } from 'react';\n\n
|
|
1
|
+
{"version":3,"file":"useHover.js","sources":["../../src/hooks/useHover.ts"],"sourcesContent":["import { useRef, useEffect, useState, RefObject } from 'react';\n\n/**\n * Få vite når et element hovres over eller mottar fokus.\n * @param ref Element som skal observeres\n * @returns Objekt med ref og om objekt er hovered/focused\n */\nexport const useHover = <T extends HTMLElement | SVGElement>(ref?: RefObject<T>): { hoverRef: RefObject<T>; isHovered: boolean } => {\n const hoverRef = ref ? ref : useRef<T>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isFocused, setIsFocused] = useState(false);\n\n useEffect(() => {\n const handleMouseEnter = () => setIsHovered(true);\n const handleMouseLeave = () => setIsHovered(false);\n const handleFocusIn = () => setIsFocused(true);\n const handleFocusOut = () => setIsFocused(false);\n\n hoverRef.current?.addEventListener('mouseenter', handleMouseEnter);\n hoverRef.current?.addEventListener('mouseleave', handleMouseLeave);\n hoverRef.current?.addEventListener('focusin', handleFocusIn);\n hoverRef.current?.addEventListener('focusout', handleFocusOut);\n\n return (): void => {\n hoverRef.current?.removeEventListener('mouseenter', handleMouseEnter);\n hoverRef.current?.removeEventListener('mouseleave', handleMouseLeave);\n hoverRef.current?.removeEventListener('focusin', handleFocusIn);\n hoverRef.current?.removeEventListener('focusout', handleFocusOut);\n };\n }, [hoverRef]);\n\n return { hoverRef, isHovered: isHovered || isFocused };\n};\n"],"names":["useHover","ref","hoverRef","useRef","isHovered","setIsHovered","useState","isFocused","setIsFocused","useEffect","handleMouseEnter","handleMouseLeave","handleFocusIn","handleFocusOut","_a","_b","_c","_d"],"mappings":"4DAOa,MAAAA,EAAgDC,GAAuE,CAClI,MAAMC,EAAWD,GAAYE,EAAU,IAAI,EACrC,CAACC,EAAWC,CAAY,EAAIC,EAAS,EAAK,EAC1C,CAACC,EAAWC,CAAY,EAAIF,EAAS,EAAK,EAEhD,OAAAG,EAAU,IAAM,aACR,MAAAC,EAAmB,IAAML,EAAa,EAAI,EAC1CM,EAAmB,IAAMN,EAAa,EAAK,EAC3CO,EAAgB,IAAMJ,EAAa,EAAI,EACvCK,EAAiB,IAAML,EAAa,EAAK,EAEtC,OAAAM,EAAAZ,EAAA,UAAA,MAAAY,EAAS,iBAAiB,aAAcJ,IACxCK,EAAAb,EAAA,UAAA,MAAAa,EAAS,iBAAiB,aAAcJ,IACxCK,EAAAd,EAAA,UAAA,MAAAc,EAAS,iBAAiB,UAAWJ,IACrCK,EAAAf,EAAA,UAAA,MAAAe,EAAS,iBAAiB,WAAYJ,GAExC,IAAY,cACRC,EAAAZ,EAAA,UAAA,MAAAY,EAAS,oBAAoB,aAAcJ,IAC3CK,EAAAb,EAAA,UAAA,MAAAa,EAAS,oBAAoB,aAAcJ,IAC3CK,EAAAd,EAAA,UAAA,MAAAc,EAAS,oBAAoB,UAAWJ,IACxCK,EAAAf,EAAA,UAAA,MAAAe,EAAS,oBAAoB,WAAYJ,EAAc,CAClE,EACC,CAACX,CAAQ,CAAC,EAEN,CAAE,SAAAA,EAAU,UAAWE,GAAaG,CAAU,CACvD"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
declare type KeyboardEvents = keyof PickByValue<HTMLElementEventMap, KeyboardEvent>;
|
|
2
|
+
/**
|
|
3
|
+
* Kjør en callback når bruker skriver på tastaturet.
|
|
4
|
+
* @param ref Element som skal lyttes på.
|
|
5
|
+
* @param callback Callback som kjøres når det skjer en event.
|
|
6
|
+
* @param key Knapp, eller liste med knapper, som skal trigge callback
|
|
7
|
+
* @param events Liste med keyboard-events som skal trigge callback. Default: "keydown"
|
|
8
|
+
*/
|
|
9
|
+
export declare const useKeyboardEvent: (ref: React.RefObject<HTMLElement>, callback: (event: HTMLElementEventMap[KeyboardEvents]) => void, key: string | string[], events?: KeyboardEvents[]) => void;
|
|
10
|
+
export {};
|
|
2
11
|
//# sourceMappingURL=useKeyboardEvent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyboardEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/useKeyboardEvent.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"useKeyboardEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/useKeyboardEvent.ts"],"names":[],"mappings":"AAEA,aAAK,cAAc,GAAG,MAAM,WAAW,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QACtB,MAAM,SAAS,CAAC,WAAW,CAAC,oBACf,mBAAmB,CAAC,cAAc,CAAC,KAAK,IAAI,OACzD,MAAM,GAAG,MAAM,EAAE,WACd,cAAc,EAAE,SAezB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as a}from"react";const i=(n,d,o,t=["keydown"])=>{a(()=>{const E=r=>{(r.key===o||Array.isArray(o)&&o.includes(r.key))&&d(r)};return t.forEach(r=>{var e;return(e=n.current)==null?void 0:e.addEventListener(r,E)}),()=>{t.forEach(r=>{var e;return(e=n.current)==null?void 0:e.removeEventListener(r,E)})}},[n,d,t,o])};export{i as useKeyboardEvent};
|
|
2
2
|
//# sourceMappingURL=useKeyboardEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyboardEvent.js","sources":["../../src/hooks/useKeyboardEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\
|
|
1
|
+
{"version":3,"file":"useKeyboardEvent.js","sources":["../../src/hooks/useKeyboardEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\ntype KeyboardEvents = keyof PickByValue<HTMLElementEventMap, KeyboardEvent>;\n\n/**\n * Kjør en callback når bruker skriver på tastaturet.\n * @param ref Element som skal lyttes på.\n * @param callback Callback som kjøres når det skjer en event.\n * @param key Knapp, eller liste med knapper, som skal trigge callback\n * @param events Liste med keyboard-events som skal trigge callback. Default: \"keydown\"\n */\nexport const useKeyboardEvent = (\n ref: React.RefObject<HTMLElement>,\n callback: (event: HTMLElementEventMap[KeyboardEvents]) => void,\n key: string | string[],\n events: KeyboardEvents[] = ['keydown']\n) => {\n useEffect(() => {\n const handleKeyboardEvent = (event: HTMLElementEventMap[KeyboardEvents]) => {\n if (event.key === key || (Array.isArray(key) && key.includes(event.key))) {\n callback(event);\n }\n };\n\n events.forEach(eventName => ref.current?.addEventListener(eventName, handleKeyboardEvent));\n\n return () => {\n events.forEach(eventName => ref.current?.removeEventListener(eventName, handleKeyboardEvent));\n };\n }, [ref, callback, events, key]);\n};\n"],"names":["useKeyboardEvent","ref","callback","key","events","useEffect","handleKeyboardEvent","event","eventName","_a"],"mappings":"kCAWa,MAAAA,EAAmB,CAC9BC,EACAC,EACAC,EACAC,EAA2B,CAAC,SAAS,IAClC,CACHC,EAAU,IAAM,CACR,MAAAC,EAAuBC,GAA+C,EACtEA,EAAM,MAAQJ,GAAQ,MAAM,QAAQA,CAAG,GAAKA,EAAI,SAASI,EAAM,GAAG,IACpEL,EAASK,CAAK,CAChB,EAGF,OAAAH,EAAO,QAAqBI,UAAA,OAAAC,EAAAR,EAAI,UAAJ,YAAAQ,EAAa,iBAAiBD,EAAWF,GAAoB,EAElF,IAAM,CACXF,EAAO,QAAqBI,UAAA,OAAAC,EAAAR,EAAI,UAAJ,YAAAQ,EAAa,oBAAoBD,EAAWF,GAAoB,CAAA,GAE7F,CAACL,EAAKC,EAAUE,EAAQD,CAAG,CAAC,CACjC"}
|
package/hooks/useLayoutEvent.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as c}from"react";import{
|
|
1
|
+
import{useEffect as c}from"react";import{debounce as i}from"../utils/debounce.js";const u=(n,t=["layoutchange","resize","orientationchange"],r=10)=>{c(()=>{if(typeof window!="object")return;const[e,a]=i(n,r);return t.forEach(o=>window.addEventListener(o,e)),e(),()=>{a(),t.forEach(o=>window.removeEventListener(o,e))}},[])};export{u as useLayoutEvent};
|
|
2
2
|
//# sourceMappingURL=useLayoutEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutEvent.js","sources":["../../src/hooks/useLayoutEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { debounce } from '../utils/debounce';\n\n/**\n * Lytt på ulike layout-events som har betydning for rendring og størrelse på elementer.\n *\n * @param callback Kalles for hver event\n * @param events Liste med events som skal lyttes på\n * @param debounceMs Begrens kall til callback til x antall ms\n */\nexport const useLayoutEvent = (callback: () => void, events = ['layoutchange', 'resize', 'orientationchange'], debounceMs = 10) => {\n useEffect(() => {\n if (typeof window !== 'object') return;\n const [debouncedCallback, teardown] = debounce(callback, debounceMs);\n\n events.forEach(eventName => window.addEventListener(eventName, debouncedCallback));\n\n debouncedCallback();\n\n return () => {\n teardown();\n events.forEach(eventName => window.removeEventListener(eventName, debouncedCallback));\n };\n }, []);\n};\n"],"names":["useLayoutEvent","callback","events","debounceMs","useEffect","debouncedCallback","teardown","debounce","eventName"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLayoutEvent.js","sources":["../../src/hooks/useLayoutEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { debounce } from '../utils/debounce';\n\n/**\n * Lytt på ulike layout-events som har betydning for rendring og størrelse på elementer.\n *\n * @param callback Kalles for hver event\n * @param events Liste med events som skal lyttes på\n * @param debounceMs Begrens kall til callback til x antall ms\n */\nexport const useLayoutEvent = (callback: () => void, events = ['layoutchange', 'resize', 'orientationchange'], debounceMs = 10) => {\n useEffect(() => {\n if (typeof window !== 'object') return;\n const [debouncedCallback, teardown] = debounce(callback, debounceMs);\n\n events.forEach(eventName => window.addEventListener(eventName, debouncedCallback));\n\n debouncedCallback();\n\n return () => {\n teardown();\n events.forEach(eventName => window.removeEventListener(eventName, debouncedCallback));\n };\n }, []);\n};\n"],"names":["useLayoutEvent","callback","events","debounceMs","useEffect","debouncedCallback","teardown","debounce","eventName"],"mappings":"kFAWa,MAAAA,EAAiB,CAACC,EAAsBC,EAAS,CAAC,eAAgB,SAAU,mBAAmB,EAAGC,EAAa,KAAO,CACjIC,EAAU,IAAM,CACd,GAAI,OAAO,QAAW,SAAU,OAChC,KAAM,CAACC,EAAmBC,CAAQ,EAAIC,EAASN,EAAUE,CAAU,EAEnE,OAAAD,EAAO,QAAqBM,GAAA,OAAO,iBAAiBA,EAAWH,CAAiB,CAAC,EAE/DA,IAEX,IAAM,CACFC,IACTJ,EAAO,QAAqBM,GAAA,OAAO,oBAAoBA,EAAWH,CAAiB,CAAC,CAAA,CAExF,EAAG,CAAE,CAAA,CACP"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
declare type PickByValue<T, V> = Pick<T, {
|
|
2
|
-
[K in keyof T]: T[K] extends V ? K : never;
|
|
3
|
-
}[keyof T]>;
|
|
4
1
|
declare type OutsideEvents = keyof PickByValue<HTMLElementEventMap, MouseEvent | FocusEvent>;
|
|
5
2
|
/**
|
|
6
3
|
* Custom hook for klikk eller fokus utenfor et gitt element
|
|
@@ -8,6 +5,6 @@ declare type OutsideEvents = keyof PickByValue<HTMLElementEventMap, MouseEvent |
|
|
|
8
5
|
* @param handleClick Callback-funksjon ved klikk utenfor elementet
|
|
9
6
|
* @param events Type eventer å lytte på. Default: mousedown
|
|
10
7
|
*/
|
|
11
|
-
export declare const useOutsideEvent: (ref: React.RefObject<HTMLElement>, handleClick: () => void, events?: OutsideEvents[]) => void;
|
|
8
|
+
export declare const useOutsideEvent: (ref: React.RefObject<HTMLElement>, handleClick: (event: HTMLElementEventMap[OutsideEvents]) => void, events?: OutsideEvents[]) => void;
|
|
12
9
|
export {};
|
|
13
10
|
//# sourceMappingURL=useOutsideEvent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOutsideEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/useOutsideEvent.ts"],"names":[],"mappings":"AAEA,aAAK,
|
|
1
|
+
{"version":3,"file":"useOutsideEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/useOutsideEvent.ts"],"names":[],"mappings":"AAEA,aAAK,aAAa,GAAG,MAAM,WAAW,CAAC,mBAAmB,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;AAErF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QACrB,MAAM,SAAS,CAAC,WAAW,CAAC,uBACZ,mBAAmB,CAAC,aAAa,CAAC,KAAK,IAAI,WACxD,aAAa,EAAE,KACtB,IAcF,CAAC"}
|
package/hooks/useOutsideEvent.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as c}from"react";const d=(o,n,e=["mousedown"])=>{const r=t=>{var u;(u=o.current)!=null&&u.contains(t.target)||n(t)};c(()=>(e.forEach(t=>document.addEventListener(t,r)),()=>{e.forEach(t=>document.removeEventListener(t,r))}),[o,n,e])};export{d as useOutsideEvent};
|
|
2
2
|
//# sourceMappingURL=useOutsideEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOutsideEvent.js","sources":["../../src/hooks/useOutsideEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\ntype
|
|
1
|
+
{"version":3,"file":"useOutsideEvent.js","sources":["../../src/hooks/useOutsideEvent.ts"],"sourcesContent":["import { useEffect } from 'react';\n\ntype OutsideEvents = keyof PickByValue<HTMLElementEventMap, MouseEvent | FocusEvent>;\n\n/**\n * Custom hook for klikk eller fokus utenfor et gitt element\n * @param ref Sjekker om det klikkes utenfor dette elementet\n * @param handleClick Callback-funksjon ved klikk utenfor elementet\n * @param events Type eventer å lytte på. Default: mousedown\n */\nexport const useOutsideEvent = (\n ref: React.RefObject<HTMLElement>,\n handleClick: (event: HTMLElementEventMap[OutsideEvents]) => void,\n events: OutsideEvents[] = ['mousedown']\n): void => {\n const handleOutsideEvent = (event: HTMLElementEventMap[OutsideEvents]): void => {\n if (!ref.current?.contains(event.target as Node)) {\n handleClick(event);\n }\n };\n\n useEffect(() => {\n events.forEach(eventName => document.addEventListener(eventName, handleOutsideEvent));\n\n return () => {\n events.forEach(eventName => document.removeEventListener(eventName, handleOutsideEvent));\n };\n }, [ref, handleClick, events]);\n};\n"],"names":["useOutsideEvent","ref","handleClick","events","handleOutsideEvent","event","_a","useEffect","eventName"],"mappings":"kCAUO,MAAMA,EAAkB,CAC7BC,EACAC,EACAC,EAA0B,CAAC,WAAW,IAC7B,CACH,MAAAC,EAAsBC,GAAoD,QACzEC,EAAAL,EAAI,UAAJ,MAAAK,EAAa,SAASD,EAAM,SAC/BH,EAAYG,CAAK,CACnB,EAGFE,EAAU,KACRJ,EAAO,QAAqBK,GAAA,SAAS,iBAAiBA,EAAWJ,CAAkB,CAAC,EAE7E,IAAM,CACXD,EAAO,QAAqBK,GAAA,SAAS,oBAAoBA,EAAWJ,CAAkB,CAAC,CAAA,GAExF,CAACH,EAAKC,EAAaC,CAAM,CAAC,CAC/B"}
|
package/hooks/useSize.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as d,useEffect as r}from"react";import{
|
|
1
|
+
import{useState as d,useEffect as r}from"react";import{debounce as a}from"../utils/debounce.js";const w=e=>{const[i,s]=d();return r(()=>{if(typeof ResizeObserver<"u"){const n=new ResizeObserver(t=>{s(t[0].target.getBoundingClientRect())});return e!=null&&e.current&&n.observe(e==null?void 0:e.current),()=>{e!=null&&e.current?n.unobserve(e.current):n.disconnect()}}else if(typeof window=="object"){const n=()=>{e!=null&&e.current&&s(e.current.getBoundingClientRect())},t=["layoutchange","resize","orientationchange"],[o,u]=a(n,10);return t.forEach(c=>window.addEventListener(c,o)),o(),()=>{u(),t.forEach(c=>window.removeEventListener(c,o))}}},[e==null?void 0:e.current]),i};export{w as useSize};
|
|
2
2
|
//# sourceMappingURL=useSize.js.map
|
package/hooks/useSize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSize.js","sources":["../../src/hooks/useSize.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { debounce } from '../utils/debounce';\n\n/**\n * Lytt på endringer i størrelse på et element\n *\n * @param ref Element som skal observeres.\n * @returns Object med høyde, bredde, x og y til elementet. Merk at objektet bare oppdates når høyde eller bredde endres, ikke når\n * posisjonen (x og y) endres.\n */\nexport const useSize = (ref?: React.RefObject<HTMLElement>) => {\n const [size, setSize] = useState<DOMRect>();\n useEffect(() => {\n if (typeof ResizeObserver !== 'undefined') {\n const resizeObserver = new ResizeObserver(entries => {\n setSize(entries[0].target.getBoundingClientRect());\n });\n if (ref?.current) {\n resizeObserver.observe(ref?.current);\n }\n return (): void => {\n if (ref?.current) {\n resizeObserver.unobserve(ref.current);\n } else {\n resizeObserver.disconnect();\n }\n };\n } else if (typeof window === 'object') {\n // For nettlesere som ikke støtter ResizeObserver (iOS 13 og lavere)\n const handleLayoutEvent = () => {\n ref?.current && setSize(ref.current.getBoundingClientRect());\n };\n\n const events = ['layoutchange', 'resize', 'orientationchange'];\n const debounceMs = 10;\n\n const [debouncedCallback, teardown] = debounce(handleLayoutEvent, debounceMs);\n\n events.forEach(eventName => window.addEventListener(eventName, debouncedCallback));\n\n debouncedCallback();\n\n return () => {\n teardown();\n events.forEach(eventName => window.removeEventListener(eventName, debouncedCallback));\n };\n }\n }, [ref?.current]);\n\n return size;\n};\n"],"names":["useSize","ref","size","setSize","useState","useEffect","resizeObserver","entries","handleLayoutEvent","events","debouncedCallback","teardown","debounce","eventName"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSize.js","sources":["../../src/hooks/useSize.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { debounce } from '../utils/debounce';\n\n/**\n * Lytt på endringer i størrelse på et element\n *\n * @param ref Element som skal observeres.\n * @returns Object med høyde, bredde, x og y til elementet. Merk at objektet bare oppdates når høyde eller bredde endres, ikke når\n * posisjonen (x og y) endres.\n */\nexport const useSize = (ref?: React.RefObject<HTMLElement>) => {\n const [size, setSize] = useState<DOMRect>();\n useEffect(() => {\n if (typeof ResizeObserver !== 'undefined') {\n const resizeObserver = new ResizeObserver(entries => {\n setSize(entries[0].target.getBoundingClientRect());\n });\n if (ref?.current) {\n resizeObserver.observe(ref?.current);\n }\n return (): void => {\n if (ref?.current) {\n resizeObserver.unobserve(ref.current);\n } else {\n resizeObserver.disconnect();\n }\n };\n } else if (typeof window === 'object') {\n // For nettlesere som ikke støtter ResizeObserver (iOS 13 og lavere)\n const handleLayoutEvent = () => {\n ref?.current && setSize(ref.current.getBoundingClientRect());\n };\n\n const events = ['layoutchange', 'resize', 'orientationchange'];\n const debounceMs = 10;\n\n const [debouncedCallback, teardown] = debounce(handleLayoutEvent, debounceMs);\n\n events.forEach(eventName => window.addEventListener(eventName, debouncedCallback));\n\n debouncedCallback();\n\n return () => {\n teardown();\n events.forEach(eventName => window.removeEventListener(eventName, debouncedCallback));\n };\n }\n }, [ref?.current]);\n\n return size;\n};\n"],"names":["useSize","ref","size","setSize","useState","useEffect","resizeObserver","entries","handleLayoutEvent","events","debouncedCallback","teardown","debounce","eventName"],"mappings":"gGAUa,MAAAA,EAAWC,GAAuC,CAC7D,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAkB,EAC1C,OAAAC,EAAU,IAAM,CACV,GAAA,OAAO,eAAmB,IAAa,CACnC,MAAAC,EAAiB,IAAI,eAA0BC,GAAA,CACnDJ,EAAQI,EAAQ,GAAG,OAAO,sBAAuB,CAAA,CAAA,CAClD,EACD,OAAIN,GAAA,MAAAA,EAAK,SACQK,EAAA,QAAQL,GAAA,YAAAA,EAAK,OAAO,EAE9B,IAAY,CACbA,GAAA,MAAAA,EAAK,QACQK,EAAA,UAAUL,EAAI,OAAO,EAEpCK,EAAe,WAAW,CAC5B,CACF,SACS,OAAO,QAAW,SAAU,CAErC,MAAME,EAAoB,IAAM,CAC9BP,GAAA,MAAAA,EAAK,SAAWE,EAAQF,EAAI,QAAQ,uBAAuB,CAAA,EAGvDQ,EAAS,CAAC,eAAgB,SAAU,mBAAmB,EAGvD,CAACC,EAAmBC,CAAQ,EAAIC,EAASJ,EAAmB,EAAU,EAE5E,OAAAC,EAAO,QAAqBI,GAAA,OAAO,iBAAiBA,EAAWH,CAAiB,CAAC,EAE/DA,IAEX,IAAM,CACFC,IACTF,EAAO,QAAqBI,GAAA,OAAO,oBAAoBA,EAAWH,CAAiB,CAAC,CAAA,CAExF,CAAA,EACC,CAACT,GAAA,YAAAA,EAAK,OAAO,CAAC,EAEVC,CACT"}
|
package/hooks/useSticky.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as t}from"react";import{useLayoutEvent as p}from"./useLayoutEvent.js";import"../debounce.js";const L=(s,c)=>{const[d,h]=t(!1),[r,u]=t(!1),[a,f]=t(),[g,l]=t();return p(()=>{var n,o,i;const{top:m=0,width:C=0,bottom:O=0}=((n=s.current)==null?void 0:n.getBoundingClientRect())||{},e=(i=(o=c.current)==null?void 0:o.getBoundingClientRect().height)!=null?i:0;h(m<=0),u(O<=e),l(C),f(e)},["resize","scroll"]),{isOutsideWindow:d,isLeavingWindow:r,offsetHeight:a,contentWidth:g}};export{L as useSticky};
|
|
1
|
+
import{useState as t}from"react";import{useLayoutEvent as p}from"./useLayoutEvent.js";import"../utils/debounce.js";const L=(s,c)=>{const[d,h]=t(!1),[r,u]=t(!1),[a,f]=t(),[g,l]=t();return p(()=>{var n,o,i;const{top:m=0,width:C=0,bottom:O=0}=((n=s.current)==null?void 0:n.getBoundingClientRect())||{},e=(i=(o=c.current)==null?void 0:o.getBoundingClientRect().height)!=null?i:0;h(m<=0),u(O<=e),l(C),f(e)},["resize","scroll"]),{isOutsideWindow:d,isLeavingWindow:r,offsetHeight:a,contentWidth:g}};export{L as useSticky};
|
|
2
2
|
//# sourceMappingURL=useSticky.js.map
|