@digdir/designsystemet-react 0.59.1-alpha.0 → 0.59.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Accordion/Accordion.js +1 -4
- package/dist/cjs/components/Accordion/AccordionContent/AccordionContent.js +1 -2
- package/dist/cjs/components/Accordion/AccordionHeader/AccordionHeader.js +1 -2
- package/dist/cjs/components/Accordion/AccordionItem/AccordionItem.js +1 -4
- package/dist/cjs/components/Button/Button.js +2 -2
- package/dist/cjs/components/Modal/ModalHeader/ModalHeader.js +1 -1
- package/dist/cjs/components/Modal/ModalHeader/ModalHeader.module.css.js +1 -1
- package/dist/cjs/components/form/Combobox/Combobox.js +33 -43
- package/dist/cjs/components/form/Combobox/Combobox.module.css.js +1 -1
- package/dist/cjs/components/form/Combobox/internal/ComboboxChips.js +7 -12
- package/dist/cjs/components/form/Combobox/internal/ComboboxClearButton.js +3 -6
- package/dist/cjs/components/form/Combobox/internal/ComboboxInput.js +6 -40
- package/dist/cjs/components/form/Combobox/useCombobox.js +48 -60
- package/dist/cjs/components/form/Combobox/useComboboxKeyboard.js +25 -28
- package/dist/cjs/node_modules/clsx/dist/clsx.js +1 -1
- package/dist/cjs/node_modules/clsx/dist/lite.js +9 -0
- package/dist/cjs/react-css-modules.css +2 -136
- package/dist/esm/components/Accordion/Accordion.js +1 -4
- package/dist/esm/components/Accordion/AccordionContent/AccordionContent.js +1 -2
- package/dist/esm/components/Accordion/AccordionHeader/AccordionHeader.js +1 -2
- package/dist/esm/components/Accordion/AccordionItem/AccordionItem.js +1 -4
- package/dist/esm/components/Button/Button.js +2 -2
- package/dist/esm/components/Modal/ModalHeader/ModalHeader.js +1 -1
- package/dist/esm/components/Modal/ModalHeader/ModalHeader.module.css.js +1 -1
- package/dist/esm/components/form/Combobox/Combobox.js +33 -43
- package/dist/esm/components/form/Combobox/Combobox.module.css.js +1 -1
- package/dist/esm/components/form/Combobox/internal/ComboboxChips.js +7 -12
- package/dist/esm/components/form/Combobox/internal/ComboboxClearButton.js +3 -6
- package/dist/esm/components/form/Combobox/internal/ComboboxInput.js +7 -41
- package/dist/esm/components/form/Combobox/useCombobox.js +48 -60
- package/dist/esm/components/form/Combobox/useComboboxKeyboard.js +25 -28
- package/dist/esm/node_modules/clsx/dist/clsx.js +1 -1
- package/dist/esm/node_modules/clsx/dist/lite.js +4 -0
- package/dist/esm/react-css-modules.css +2 -136
- package/dist/types/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/types/components/Accordion/AccordionContent/AccordionContent.d.ts.map +1 -1
- package/dist/types/components/Accordion/AccordionHeader/AccordionHeader.d.ts.map +1 -1
- package/dist/types/components/Accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/dist/types/components/Modal/ModalHeader/ModalHeader.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/Combobox.d.ts +0 -18
- package/dist/types/components/form/Combobox/Combobox.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/ComboboxContext.d.ts +6 -13
- package/dist/types/components/form/Combobox/ComboboxContext.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/internal/ComboboxChips.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/internal/ComboboxClearButton.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts +9 -1
- package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/useCombobox.d.ts +1 -4
- package/dist/types/components/form/Combobox/useCombobox.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts +3 -4
- package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/components/Accordion/Accordion.module.css.js +0 -6
- package/dist/esm/components/Accordion/Accordion.module.css.js +0 -4
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var useDebounce = require('../../../utilities/useDebounce.js');
|
|
5
5
|
var ComboboxIdContext = require('./ComboboxIdContext.js');
|
|
6
6
|
|
|
7
|
-
const useComboboxKeyboard = ({ readOnly, disabled, interactiveChildren, filteredOptions, inputValue, selectedOptions, multiple, open, options, setOpen,
|
|
7
|
+
const useComboboxKeyboard = ({ readOnly, disabled, interactiveChildren, filteredOptions, inputValue, selectedOptions, multiple, open, options, setOpen, handleSelectOption, }) => {
|
|
8
8
|
const { activeIndex } = ComboboxIdContext.useComboboxId();
|
|
9
9
|
// handle keyboard navigation in the list
|
|
10
10
|
const handleKeyDownFunc = (event) => {
|
|
@@ -15,16 +15,16 @@ const useComboboxKeyboard = ({ readOnly, disabled, interactiveChildren, filtered
|
|
|
15
15
|
switch (event.key) {
|
|
16
16
|
case 'ArrowDown':
|
|
17
17
|
event.preventDefault();
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (open)
|
|
19
|
+
break;
|
|
20
|
+
setOpen(true);
|
|
21
21
|
break;
|
|
22
22
|
case 'ArrowUp':
|
|
23
23
|
event.preventDefault();
|
|
24
24
|
/* If we are on the first item, close */
|
|
25
|
-
if (activeIndex
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (activeIndex !== 0)
|
|
26
|
+
break;
|
|
27
|
+
setOpen(false);
|
|
28
28
|
break;
|
|
29
29
|
case 'Enter':
|
|
30
30
|
event.preventDefault();
|
|
@@ -44,30 +44,27 @@ const useComboboxKeyboard = ({ readOnly, disabled, interactiveChildren, filtered
|
|
|
44
44
|
const valueIndex = activeIndex - interactiveChildren.length;
|
|
45
45
|
// eslint-disable-next-line no-case-declarations
|
|
46
46
|
const option = filteredOptions[valueIndex];
|
|
47
|
-
|
|
48
|
-
// check if option is already selected, if so, deselect it
|
|
49
|
-
if (selectedOptions[option]) {
|
|
50
|
-
setSelectedOptions({});
|
|
51
|
-
setInputValue('');
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
handleSelectOption(options[option]);
|
|
47
|
+
handleSelectOption({ option: options[option] });
|
|
56
48
|
break;
|
|
57
49
|
case 'Backspace':
|
|
58
|
-
if
|
|
59
|
-
multiple &&
|
|
60
|
-
Object.keys(selectedOptions).length >= 0) {
|
|
61
|
-
setSelectedOptions((prev) => {
|
|
62
|
-
const updated = { ...prev };
|
|
63
|
-
const keys = Object.keys(updated);
|
|
64
|
-
delete updated[keys[keys.length - 1]];
|
|
65
|
-
return updated;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// if we are in single mode, we need to set activeValue to null
|
|
50
|
+
// if we are in single mode, we need to set selectedOptions to empty
|
|
69
51
|
if (!multiple) {
|
|
70
|
-
|
|
52
|
+
const lastOption = Object.keys(selectedOptions).pop();
|
|
53
|
+
lastOption &&
|
|
54
|
+
handleSelectOption({
|
|
55
|
+
option: selectedOptions[lastOption],
|
|
56
|
+
remove: true,
|
|
57
|
+
});
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (inputValue === '' && multiple) {
|
|
61
|
+
const lastOption = Object.keys(selectedOptions).pop();
|
|
62
|
+
/* Remove last option, and use handleSelectOption */
|
|
63
|
+
lastOption &&
|
|
64
|
+
handleSelectOption({
|
|
65
|
+
option: selectedOptions[lastOption],
|
|
66
|
+
remove: true,
|
|
67
|
+
});
|
|
71
68
|
}
|
|
72
69
|
break;
|
|
73
70
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<
|
|
6
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
7
7
|
|
|
8
8
|
exports.clsx = clsx;
|
|
9
9
|
exports.default = clsx;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
function clsx(){for(var t,r=0,e="",n=arguments.length;r<n;r++)(t=arguments[r])&&"string"==typeof t&&(e+=(e&&" ")+t);return e}
|
|
7
|
+
|
|
8
|
+
exports.clsx = clsx;
|
|
9
|
+
exports.default = clsx;
|
|
@@ -517,140 +517,6 @@
|
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
-
@layer fds.accordion {
|
|
521
|
-
.fds-accordion-accordion-a8137c3d {
|
|
522
|
-
--fds-accordion-border-radius: var(--fds-border_radius-interactive);
|
|
523
|
-
--fds-accordion-border-color: var(--fds-semantic-border-neutral-subtle);
|
|
524
|
-
|
|
525
|
-
border-bottom: 1px solid var(--fds-semantic-border-neutral-subtle);
|
|
526
|
-
box-sizing: border-box;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
.fds-accordion-border-a8137c3d {
|
|
530
|
-
border: 1px solid var(--fds-accordion-border-color);
|
|
531
|
-
border-radius: var(--fds-accordion-border-radius);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
.fds-accordion-expandIcon-a8137c3d {
|
|
535
|
-
border-radius: var(--fds-border_radius-interactive);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
.fds-accordion-content-a8137c3d {
|
|
539
|
-
padding: var(--fds-spacing-5, 1rem);
|
|
540
|
-
overflow: hidden;
|
|
541
|
-
text-overflow: ellipsis;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
.fds-accordion-header-a8137c3d {
|
|
545
|
-
margin: 0;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
.fds-accordion-accordionButton-a8137c3d {
|
|
549
|
-
width: 100%;
|
|
550
|
-
display: flex;
|
|
551
|
-
justify-content: flex-start;
|
|
552
|
-
align-items: center;
|
|
553
|
-
gap: var(--fds-spacing-2);
|
|
554
|
-
margin: 0;
|
|
555
|
-
text-align: left;
|
|
556
|
-
cursor: pointer;
|
|
557
|
-
border: none;
|
|
558
|
-
border-top: 1px solid var(--fds-semantic-border-neutral-subtle);
|
|
559
|
-
padding: var(--fds-spacing-4);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
.fds-accordion-border-a8137c3d .fds-accordion-accordionButton-a8137c3d {
|
|
563
|
-
border-radius: var(--fds-accordion-border-radius);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
.fds-accordion-item-a8137c3d:focus-within {
|
|
567
|
-
position: relative;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
.fds-accordion-item-a8137c3d:where(.fds-accordion-open-a8137c3d) .fds-accordion-accordionButton-a8137c3d:hover + * .fds-accordion-content-a8137c3d {
|
|
571
|
-
border-color: var(--fds-semantic-border-neutral-strong);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
.fds-accordion-item-a8137c3d:where(.fds-accordion-open-a8137c3d) .fds-accordion-expandIcon-a8137c3d {
|
|
575
|
-
transform: rotateZ(180deg);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
.fds-accordion-neutral-a8137c3d,
|
|
579
|
-
.fds-accordion-neutral-a8137c3d .fds-accordion-accordionButton-a8137c3d {
|
|
580
|
-
background-color: var(--fds-semantic-surface-neutral-default);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
.fds-accordion-subtle-a8137c3d,
|
|
584
|
-
.fds-accordion-subtle-a8137c3d .fds-accordion-accordionButton-a8137c3d {
|
|
585
|
-
background-color: var(--fds-semantic-surface-neutral-subtle);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
.fds-accordion-first-a8137c3d,
|
|
589
|
-
.fds-accordion-first-a8137c3d .fds-accordion-accordionButton-a8137c3d {
|
|
590
|
-
--fds-accordion-border-color: var(--fds-semantic-border-first-default);
|
|
591
|
-
|
|
592
|
-
background: var(--fds-semantic-surface-first-light);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
.fds-accordion-second-a8137c3d,
|
|
596
|
-
.fds-accordion-second-a8137c3d .fds-accordion-accordionButton-a8137c3d {
|
|
597
|
-
--fds-accordion-border-color: var(--fds-semantic-border-second-default);
|
|
598
|
-
|
|
599
|
-
background: var(--fds-semantic-surface-second-light);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
.fds-accordion-third-a8137c3d,
|
|
603
|
-
.fds-accordion-third-a8137c3d .fds-accordion-accordionButton-a8137c3d {
|
|
604
|
-
--fds-accordion-border-color: var(--fds-semantic-border-third-default);
|
|
605
|
-
|
|
606
|
-
background: var(--fds-semantic-surface-third-light);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
.fds-accordion-first-a8137c3d .fds-accordion-item-a8137c3d:where(.fds-accordion-open-a8137c3d) .fds-accordion-accordionButton-a8137c3d,
|
|
610
|
-
.fds-accordion-second-a8137c3d .fds-accordion-item-a8137c3d:where(.fds-accordion-open-a8137c3d) .fds-accordion-accordionButton-a8137c3d,
|
|
611
|
-
.fds-accordion-third-a8137c3d .fds-accordion-item-a8137c3d:where(.fds-accordion-open-a8137c3d) .fds-accordion-accordionButton-a8137c3d {
|
|
612
|
-
background-color: rgba(0 0 0 / 0.03);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
.fds-accordion-neutral-a8137c3d .fds-accordion-item-a8137c3d:where(.fds-accordion-open-a8137c3d) .fds-accordion-accordionButton-a8137c3d,
|
|
616
|
-
.fds-accordion-subtle-a8137c3d .fds-accordion-item-a8137c3d:where(.fds-accordion-open-a8137c3d) .fds-accordion-accordionButton-a8137c3d {
|
|
617
|
-
background-color: var(--fds-semantic-surface-action-first-no_fill-hover);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
.fds-accordion-border-a8137c3d .fds-accordion-item-a8137c3d:first-child .fds-accordion-accordionButton-a8137c3d {
|
|
621
|
-
border-top: 0;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
.fds-accordion-first-a8137c3d .fds-accordion-item-a8137c3d:not(:first-child) .fds-accordion-accordionButton-a8137c3d,
|
|
625
|
-
.fds-accordion-second-a8137c3d .fds-accordion-item-a8137c3d:not(:first-child) .fds-accordion-accordionButton-a8137c3d,
|
|
626
|
-
.fds-accordion-third-a8137c3d .fds-accordion-item-a8137c3d:not(:first-child) .fds-accordion-accordionButton-a8137c3d {
|
|
627
|
-
border-top: 1px solid var(--fds-semantic-surface-neutral-default);
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
@media (hover: hover) and (pointer: fine) {
|
|
631
|
-
.fds-accordion-accordionButton-a8137c3d:hover .fds-accordion-expandIcon-a8137c3d {
|
|
632
|
-
background-color: rgba(0 0 0 / 0.1);
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
.fds-accordion-neutral-a8137c3d .fds-accordion-accordionButton-a8137c3d:hover,
|
|
636
|
-
.fds-accordion-subtle-a8137c3d .fds-accordion-accordionButton-a8137c3d:hover {
|
|
637
|
-
background-color: var(--fds-semantic-surface-neutral-subtle-hover);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
.fds-accordion-first-a8137c3d .fds-accordion-accordionButton-a8137c3d:hover {
|
|
641
|
-
background-color: var(--fds-semantic-surface-first-light-hover);
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
.fds-accordion-second-a8137c3d .fds-accordion-accordionButton-a8137c3d:hover {
|
|
645
|
-
background-color: var(--fds-semantic-surface-second-light-hover);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
.fds-accordion-third-a8137c3d .fds-accordion-accordionButton-a8137c3d:hover {
|
|
649
|
-
background-color: var(--fds-semantic-surface-third-light-hover);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
520
|
.fds-animateheight-root-a203211d.fds-animateheight-openingOrClosing-a203211d,
|
|
655
521
|
.fds-animateheight-root-a203211d.fds-animateheight-closed-a203211d {
|
|
656
522
|
overflow: hidden;
|
|
@@ -2170,7 +2036,7 @@
|
|
|
2170
2036
|
color: var(--fds-semantic-text-neutral-default);
|
|
2171
2037
|
}
|
|
2172
2038
|
|
|
2173
|
-
.fds-modalheader-
|
|
2039
|
+
.fds-modalheader-modalHeaderButton-47e4ee5b {
|
|
2174
2040
|
position: absolute;
|
|
2175
2041
|
top: var(--fds-spacing-3);
|
|
2176
2042
|
right: var(--fds-spacing-3);
|
|
@@ -3039,7 +2905,7 @@
|
|
|
3039
2905
|
/**
|
|
3040
2906
|
* Apply a focus outline on an element when it is focused with keyboard
|
|
3041
2907
|
*/
|
|
3042
|
-
.fds-combobox-
|
|
2908
|
+
.fds-combobox-inputWrapper-249a725c:has(input:focus) {
|
|
3043
2909
|
--fds-focus-border-width: 3px;
|
|
3044
2910
|
|
|
3045
2911
|
outline: var(--fds-focus-border-width) solid var(--fds-semantic-border-focus-outline);
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { clsx } from '../../node_modules/clsx/dist/clsx.js';
|
|
5
|
-
import classes from './Accordion.module.css.js';
|
|
6
5
|
|
|
7
|
-
const Accordion = forwardRef(({ border = false, color = 'neutral', className, ...rest }, ref) => (jsx("div", { className: clsx(
|
|
8
|
-
[classes.border]: border,
|
|
9
|
-
}, className), ref: ref, ...rest })));
|
|
6
|
+
const Accordion = forwardRef(({ border = false, color = 'neutral', className, ...rest }, ref) => (jsx("div", { className: clsx('fds-accordion', border && 'fds-accordion--border', color && `fds-accordion--${color}`, className), ref: ref, ...rest })));
|
|
10
7
|
Accordion.displayName = 'Accordion';
|
|
11
8
|
|
|
12
9
|
export { Accordion };
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { clsx } from '../../../node_modules/clsx/dist/clsx.js';
|
|
4
4
|
import { forwardRef, useContext } from 'react';
|
|
5
|
-
import classes from '../Accordion.module.css.js';
|
|
6
5
|
import { AccordionItemContext } from '../AccordionItem/AccordionItem.js';
|
|
7
6
|
import { AnimateHeight } from '../../../utilities/AnimateHeight/AnimateHeight.js';
|
|
8
7
|
import { Paragraph } from '../../Typography/Paragraph/Paragraph.js';
|
|
@@ -13,7 +12,7 @@ const AccordionContent = forwardRef(({ children, className, ...rest }, ref) => {
|
|
|
13
12
|
console.error('<Accordion.Content> has to be used within an <Accordion.Item>');
|
|
14
13
|
return null;
|
|
15
14
|
}
|
|
16
|
-
return (jsx(AnimateHeight, { id: context.contentId, open: context.open, children: jsx(Paragraph, { asChild: true, size: 'small', children: jsx("div", { ref: ref, className: clsx(
|
|
15
|
+
return (jsx(AnimateHeight, { id: context.contentId, open: context.open, children: jsx(Paragraph, { asChild: true, size: 'small', children: jsx("div", { ref: ref, className: clsx('fds-accordion__content', className), ...rest, children: children }) }) }));
|
|
17
16
|
});
|
|
18
17
|
AccordionContent.displayName = 'AccordionContent';
|
|
19
18
|
|
|
@@ -3,7 +3,6 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
3
3
|
import { ChevronDownIcon } from '@navikt/aksel-icons';
|
|
4
4
|
import { clsx } from '../../../node_modules/clsx/dist/clsx.js';
|
|
5
5
|
import { forwardRef, useContext } from 'react';
|
|
6
|
-
import classes from '../Accordion.module.css.js';
|
|
7
6
|
import { AccordionItemContext } from '../AccordionItem/AccordionItem.js';
|
|
8
7
|
import { Heading } from '../../Typography/Heading/Heading.js';
|
|
9
8
|
import { Paragraph } from '../../Typography/Paragraph/Paragraph.js';
|
|
@@ -18,7 +17,7 @@ const AccordionHeader = forwardRef(({ level = 1, children, className, onHeaderCl
|
|
|
18
17
|
context.toggleOpen();
|
|
19
18
|
onHeaderClick && onHeaderClick(e);
|
|
20
19
|
};
|
|
21
|
-
return (jsx(Heading, { ref: ref, size: 'xsmall', level: level, className: clsx(
|
|
20
|
+
return (jsx(Heading, { ref: ref, size: 'xsmall', level: level, className: clsx('fds-accordion__header', className), ...rest, children: jsxs("button", { type: 'button', className: clsx('fds-accordion__button', `fds-focus`), onClick: handleClick, "aria-expanded": context.open, "aria-controls": context.contentId, children: [jsx(ChevronDownIcon, { "aria-hidden": true, className: 'fds-accordion__expand-icon', fontSize: '1.5rem' }), jsx(Paragraph, { asChild: true, size: 'small', children: jsx("span", { children: children }) })] }) }));
|
|
22
21
|
});
|
|
23
22
|
AccordionHeader.displayName = 'AccordionHeader';
|
|
24
23
|
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { clsx } from '../../../node_modules/clsx/dist/clsx.js';
|
|
4
4
|
import { createContext, forwardRef, useState, useId } from 'react';
|
|
5
|
-
import classes from '../Accordion.module.css.js';
|
|
6
5
|
|
|
7
6
|
const AccordionItemContext = createContext(null);
|
|
8
7
|
const AccordionItem = forwardRef(({ children, className, open, defaultOpen = false, ...rest }, ref) => {
|
|
9
8
|
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
10
9
|
const contentId = useId();
|
|
11
|
-
return (jsx("div", { className: clsx(
|
|
12
|
-
[classes.open]: open ?? internalOpen,
|
|
13
|
-
}, className), ref: ref, ...rest, children: jsx(AccordionItemContext.Provider, { value: {
|
|
10
|
+
return (jsx("div", { className: clsx('fds-accordion__item', (open ?? internalOpen) && 'fds-accordion__item--open', className), ref: ref, ...rest, children: jsx(AccordionItemContext.Provider, { value: {
|
|
14
11
|
open: open ?? internalOpen,
|
|
15
12
|
toggleOpen: () => {
|
|
16
13
|
if (open === undefined) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
|
-
import { clsx } from '../../node_modules/clsx/dist/
|
|
4
|
+
import { clsx } from '../../node_modules/clsx/dist/lite.js';
|
|
5
5
|
import { Slot as $5e63c961fc1ce211$export$8c6ed5c666ac1360 } from '../../node_modules/@radix-ui/react-slot/dist/index.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,7 +9,7 @@ import { Slot as $5e63c961fc1ce211$export$8c6ed5c666ac1360 } from '../../node_mo
|
|
|
9
9
|
*/
|
|
10
10
|
const Button = forwardRef(({ children, color = 'first', variant = 'primary', size = 'medium', fullWidth = false, icon = false, type = 'button', className, as = 'button', asChild, ...rest }, ref) => {
|
|
11
11
|
const Component = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : as;
|
|
12
|
-
return (jsx(Component, { ref: ref, type: type, className: clsx('fds-btn', `fds-focus`, `fds-btn--${size}`, `fds-btn--${variant}`, `fds-btn--${color}`,
|
|
12
|
+
return (jsx(Component, { ref: ref, type: type, className: clsx('fds-btn', `fds-focus`, `fds-btn--${size}`, `fds-btn--${variant}`, `fds-btn--${color}`, fullWidth && 'fds-btn--full-width', icon && 'fds-btn--icon-only', className), ...rest, children: children }));
|
|
13
13
|
});
|
|
14
14
|
Button.displayName = 'Button';
|
|
15
15
|
|
|
@@ -13,7 +13,7 @@ import { Heading } from '../../Typography/Heading/Heading.js';
|
|
|
13
13
|
const ModalHeader = forwardRef(({ closeButton = true, children, subtitle, asChild, className, ...rest }, ref) => {
|
|
14
14
|
const Component = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : 'div';
|
|
15
15
|
const context = useContext(ModalContext);
|
|
16
|
-
return (jsxs(Component, { ref: ref, className: clsx(classes.modalHeader, !closeButton && classes.noCloseButton, className), ...rest, children: [subtitle && (jsx(Paragraph, { size: 'small', variant: 'short', children: subtitle })), jsx(Heading, { level: 2, size: 'xsmall', children: children }), closeButton && (jsx(Button, { name: 'close', variant: 'tertiary', color: 'second', size: 'medium', onClick: context?.closeModal, autoFocus: true, icon: true, children: jsx(XMarkIcon, { title: 'close modal', fontSize: '1.5em' }) }))] }));
|
|
16
|
+
return (jsxs(Component, { ref: ref, className: clsx(classes.modalHeader, !closeButton && classes.noCloseButton, className), ...rest, children: [subtitle && (jsx(Paragraph, { size: 'small', variant: 'short', children: subtitle })), jsx(Heading, { level: 2, size: 'xsmall', children: children }), closeButton && (jsx(Button, { name: 'close', variant: 'tertiary', color: 'second', size: 'medium', onClick: context?.closeModal, autoFocus: true, icon: true, className: classes.modalHeaderButton, children: jsx(XMarkIcon, { title: 'close modal', fontSize: '1.5em' }) }))] }));
|
|
17
17
|
});
|
|
18
18
|
ModalHeader.displayName = 'ModalHeader';
|
|
19
19
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var classes = {"modalHeader":"fds-modalheader-modalHeader-47e4ee5b","noCloseButton":"fds-modalheader-noCloseButton-47e4ee5b"};
|
|
2
|
+
var classes = {"modalHeader":"fds-modalheader-modalHeader-47e4ee5b","modalHeaderButton":"fds-modalheader-modalHeaderButton-47e4ee5b","noCloseButton":"fds-modalheader-noCloseButton-47e4ee5b"};
|
|
3
3
|
|
|
4
4
|
export { classes as default };
|
|
@@ -21,14 +21,13 @@ import { Box } from '../../Box/Box.js';
|
|
|
21
21
|
import { Spinner } from '../../Spinner/Spinner.js';
|
|
22
22
|
import { omit } from '../../../utilities/objectUtils.js';
|
|
23
23
|
|
|
24
|
-
const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange, label, hideLabel = false, description, multiple = false, size = 'medium', disabled = false, readOnly = false, hideChips = false,
|
|
24
|
+
const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange, label, hideLabel = false, description, multiple = false, size = 'medium', disabled = false, readOnly = false, hideChips = false, clearButtonLabel = 'Fjern alt', hideClearButton = false, error, errorId, id, name, portal = true, htmlSize = 0, virtual = false, children, style, loading, loadingLabel = 'Laster...', filter, chipSrLabel = (option) => 'Slett ' + option.label, className, ...rest }, forwareddRef) => {
|
|
25
25
|
const inputRef = useRef(null);
|
|
26
26
|
const portalRef = useRef(null);
|
|
27
27
|
const listRef = useRef([]);
|
|
28
28
|
const listId = useId();
|
|
29
29
|
const [inputValue, setInputValue] = useState(rest.inputValue || '');
|
|
30
|
-
|
|
31
|
-
const { selectedOptions, options, restChildren, interactiveChildren, optionValues, customIds, filteredOptionsChildren, filteredOptions, prevSelectedHash, setSelectedOptions, setPrevSelectedHash, } = useCombobox({
|
|
30
|
+
const { selectedOptions, options, restChildren, interactiveChildren, customIds, filteredOptionsChildren, filteredOptions, setSelectedOptions, } = useCombobox({
|
|
32
31
|
children,
|
|
33
32
|
inputValue,
|
|
34
33
|
filter,
|
|
@@ -49,20 +48,11 @@ const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange,
|
|
|
49
48
|
}, 'combobox');
|
|
50
49
|
// if value is set, set input value to the label of the value
|
|
51
50
|
useEffect(() => {
|
|
52
|
-
if (value && value.length
|
|
51
|
+
if (value && value.length > 0 && !multiple) {
|
|
53
52
|
const option = options[value[0]];
|
|
54
53
|
setInputValue(option?.label || '');
|
|
55
54
|
}
|
|
56
55
|
}, [multiple, value, options]);
|
|
57
|
-
// Send new value if option was clicked
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const selectedHash = JSON.stringify(selectedOptions);
|
|
60
|
-
if (prevSelectedHash === selectedHash)
|
|
61
|
-
return;
|
|
62
|
-
const values = Object.keys(selectedOptions);
|
|
63
|
-
onValueChange?.(values);
|
|
64
|
-
setPrevSelectedHash(selectedHash);
|
|
65
|
-
}, [onValueChange, selectedOptions, prevSelectedHash, setPrevSelectedHash]);
|
|
66
56
|
useEffect(() => {
|
|
67
57
|
if (value && Object.keys(options).length >= 0) {
|
|
68
58
|
const updatedSelectedOptions = value.map((option) => {
|
|
@@ -74,38 +64,47 @@ const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange,
|
|
|
74
64
|
return acc;
|
|
75
65
|
}, {}));
|
|
76
66
|
}
|
|
77
|
-
}, [multiple,
|
|
67
|
+
}, [multiple, value, options, setSelectedOptions]);
|
|
78
68
|
// handle click on option, either select or deselect - Handles single or multiple
|
|
79
|
-
const handleSelectOption = (
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
setSelectedOptions(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return updated;
|
|
86
|
-
});
|
|
69
|
+
const handleSelectOption = (args) => {
|
|
70
|
+
const { option, clear, remove } = args;
|
|
71
|
+
if (clear) {
|
|
72
|
+
setSelectedOptions({});
|
|
73
|
+
setInputValue('');
|
|
74
|
+
onValueChange?.([]);
|
|
87
75
|
return;
|
|
88
76
|
}
|
|
77
|
+
if (!option)
|
|
78
|
+
return;
|
|
79
|
+
if (remove) {
|
|
80
|
+
const newSelectedOptions = { ...selectedOptions };
|
|
81
|
+
delete newSelectedOptions[option.value];
|
|
82
|
+
setSelectedOptions(newSelectedOptions);
|
|
83
|
+
onValueChange?.(Object.keys(newSelectedOptions));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const newSelectedOptions = { ...selectedOptions };
|
|
89
87
|
if (multiple) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
88
|
+
if (newSelectedOptions[option.value]) {
|
|
89
|
+
delete newSelectedOptions[option.value];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
newSelectedOptions[option.value] = option;
|
|
93
|
+
}
|
|
96
94
|
setInputValue('');
|
|
97
95
|
inputRef.current?.focus();
|
|
98
96
|
}
|
|
99
97
|
else {
|
|
100
|
-
|
|
101
|
-
[option.value]: option,
|
|
102
|
-
});
|
|
98
|
+
newSelectedOptions[option.value] = option;
|
|
103
99
|
setInputValue(option?.label || '');
|
|
104
100
|
// move cursor to the end of the input
|
|
105
101
|
setTimeout(() => {
|
|
106
102
|
inputRef.current?.setSelectionRange(option?.label?.length || 0, option?.label?.length || 0);
|
|
107
103
|
}, 0);
|
|
108
104
|
}
|
|
105
|
+
setSelectedOptions(newSelectedOptions);
|
|
106
|
+
console.log('calling new value with: ', Object.keys(newSelectedOptions));
|
|
107
|
+
onValueChange?.(Object.keys(newSelectedOptions));
|
|
109
108
|
!multiple && setOpen(false);
|
|
110
109
|
refs.domReference.current?.focus();
|
|
111
110
|
};
|
|
@@ -122,7 +121,6 @@ const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange,
|
|
|
122
121
|
interactiveChildren,
|
|
123
122
|
setOpen,
|
|
124
123
|
setInputValue,
|
|
125
|
-
setSelectedOptions,
|
|
126
124
|
handleSelectOption: debouncedHandleSelectOption,
|
|
127
125
|
});
|
|
128
126
|
const rowVirtualizer = useVirtualizer({
|
|
@@ -145,23 +143,15 @@ const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange,
|
|
|
145
143
|
inputRef,
|
|
146
144
|
refs,
|
|
147
145
|
inputValue,
|
|
148
|
-
error,
|
|
149
146
|
formFieldProps,
|
|
150
|
-
name,
|
|
151
147
|
htmlSize,
|
|
152
|
-
|
|
153
|
-
hideChips,
|
|
154
|
-
clearButtonLabel: cleanButtonLabel || clearButtonLabel,
|
|
155
|
-
hideClearButton,
|
|
156
|
-
listId,
|
|
148
|
+
clearButtonLabel,
|
|
157
149
|
customIds,
|
|
158
150
|
filteredOptions,
|
|
159
151
|
setInputValue,
|
|
160
|
-
handleKeyDown,
|
|
161
152
|
setOpen,
|
|
162
153
|
getReferenceProps,
|
|
163
154
|
getItemProps,
|
|
164
|
-
setSelectedOptions,
|
|
165
155
|
/* Recieves the value of the option, and searches for it in our values lookup */
|
|
166
156
|
onOptionClick: (value) => {
|
|
167
157
|
if (readOnly)
|
|
@@ -169,13 +159,13 @@ const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange,
|
|
|
169
159
|
if (disabled)
|
|
170
160
|
return;
|
|
171
161
|
const option = options[value];
|
|
172
|
-
debouncedHandleSelectOption(option);
|
|
162
|
+
debouncedHandleSelectOption({ option: option });
|
|
173
163
|
},
|
|
174
164
|
handleSelectOption: debouncedHandleSelectOption,
|
|
175
165
|
chipSrLabel,
|
|
176
166
|
listRef,
|
|
177
167
|
forwareddRef,
|
|
178
|
-
}, children: [jsxs(Box, { className: clsx(classes.combobox, disabled && classes.disabled, className), style: style, ref: portalRef, children: [name && (jsx(ComboboxNative, { name: name, selectedOptions: selectedOptions, multiple: multiple })), jsx(ComboboxLabel, { label: label, description: description, size: size, readOnly: readOnly, hideLabel: hideLabel, formFieldProps: formFieldProps }), jsx(ComboboxInput, { ...omit(['inputValue'], rest), "aria-busy": loading }), jsx(ComboboxError, { size: size, error: error, formFieldProps: formFieldProps })] }), open && (jsx(FloatingPortal, { root: portal ? null : portalRef, children: jsx(FloatingFocusManager, { context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: jsxs(Box, { id: listId, shadow: 'medium', borderRadius: 'medium', borderColor: 'default', "aria-labelledby": formFieldProps.inputProps.id, "aria-autocomplete": 'list', tabIndex: -1, ...getFloatingProps({
|
|
168
|
+
}, children: [jsxs(Box, { className: clsx(classes.combobox, disabled && classes.disabled, className), style: style, ref: portalRef, children: [name && (jsx(ComboboxNative, { name: name, selectedOptions: selectedOptions, multiple: multiple })), jsx(ComboboxLabel, { label: label, description: description, size: size, readOnly: readOnly, hideLabel: hideLabel, formFieldProps: formFieldProps }), jsx(ComboboxInput, { ...omit(['inputValue'], rest), hideClearButton: hideClearButton, listId: listId, error: error, hideChips: hideChips, handleKeyDown: handleKeyDown, "aria-busy": loading }), jsx(ComboboxError, { size: size, error: error, formFieldProps: formFieldProps })] }), open && (jsx(FloatingPortal, { root: portal ? null : portalRef, children: jsx(FloatingFocusManager, { context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: jsxs(Box, { id: listId, shadow: 'medium', borderRadius: 'medium', borderColor: 'default', "aria-labelledby": formFieldProps.inputProps.id, "aria-autocomplete": 'list', tabIndex: -1, ...getFloatingProps({
|
|
179
169
|
ref: refs.setFloating,
|
|
180
170
|
style: {
|
|
181
171
|
...floatingStyles,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var classes = {"combobox":"fds-combobox-combobox-249a725c","optionsWrapper":"fds-combobox-optionsWrapper-249a725c","readOnly":"fds-combobox-readOnly-249a725c","inputWrapper":"fds-combobox-inputWrapper-249a725c","small":"fds-combobox-small-249a725c","medium":"fds-combobox-medium-249a725c","large":"fds-combobox-large-249a725c","error":"fds-combobox-error-249a725c","chipAndInput":"fds-combobox-chipAndInput-249a725c","chips":"fds-combobox-chips-249a725c","arrow":"fds-combobox-arrow-249a725c","readonly":"fds-combobox-readonly-249a725c","label":"fds-combobox-label-249a725c","description":"fds-combobox-description-249a725c","clearButton":"fds-combobox-clearButton-249a725c","disabled":"fds-combobox-disabled-249a725c","padlock":"fds-combobox-padlock-249a725c","errorMessage":"fds-combobox-errorMessage-249a725c","loading":"fds-combobox-loading-249a725c","
|
|
2
|
+
var classes = {"combobox":"fds-combobox-combobox-249a725c","optionsWrapper":"fds-combobox-optionsWrapper-249a725c","readOnly":"fds-combobox-readOnly-249a725c","inputWrapper":"fds-combobox-inputWrapper-249a725c","small":"fds-combobox-small-249a725c","medium":"fds-combobox-medium-249a725c","large":"fds-combobox-large-249a725c","error":"fds-combobox-error-249a725c","chipAndInput":"fds-combobox-chipAndInput-249a725c","chips":"fds-combobox-chips-249a725c","arrow":"fds-combobox-arrow-249a725c","readonly":"fds-combobox-readonly-249a725c","label":"fds-combobox-label-249a725c","description":"fds-combobox-description-249a725c","clearButton":"fds-combobox-clearButton-249a725c","disabled":"fds-combobox-disabled-249a725c","padlock":"fds-combobox-padlock-249a725c","errorMessage":"fds-combobox-errorMessage-249a725c","loading":"fds-combobox-loading-249a725c","showChecked":"fds-combobox-showChecked-249a725c"};
|
|
3
3
|
|
|
4
4
|
export { classes as default };
|
|
@@ -10,7 +10,7 @@ const ComboboxChips = () => {
|
|
|
10
10
|
if (!context) {
|
|
11
11
|
throw new Error('ComboboxContext is missing');
|
|
12
12
|
}
|
|
13
|
-
const { size, readOnly, disabled, selectedOptions,
|
|
13
|
+
const { size, readOnly, disabled, selectedOptions, chipSrLabel, handleSelectOption, inputRef, } = context;
|
|
14
14
|
return (jsx(Fragment, { children: Object.keys(selectedOptions).map((value) => {
|
|
15
15
|
return (jsx(RemovableChip, { size: size, disabled: disabled, onKeyDown: (e) => {
|
|
16
16
|
if (readOnly)
|
|
@@ -19,10 +19,9 @@ const ComboboxChips = () => {
|
|
|
19
19
|
return;
|
|
20
20
|
if (e.key === 'Enter') {
|
|
21
21
|
e.stopPropagation();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return rest;
|
|
22
|
+
handleSelectOption({
|
|
23
|
+
option: selectedOptions[value],
|
|
24
|
+
remove: true,
|
|
26
25
|
});
|
|
27
26
|
inputRef.current?.focus();
|
|
28
27
|
}
|
|
@@ -32,14 +31,10 @@ const ComboboxChips = () => {
|
|
|
32
31
|
if (disabled)
|
|
33
32
|
return;
|
|
34
33
|
/* If we click a chip, filter the active values and remove the one we clicked */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return rest;
|
|
34
|
+
handleSelectOption({
|
|
35
|
+
option: selectedOptions[value],
|
|
36
|
+
remove: true,
|
|
39
37
|
});
|
|
40
|
-
}, style: {
|
|
41
|
-
/* We already set the opacity on Combobox */
|
|
42
|
-
opacity: 1,
|
|
43
38
|
}, "aria-label": chipSrLabel(selectedOptions[value]), children: selectedOptions[value].label }, value));
|
|
44
39
|
}) }));
|
|
45
40
|
};
|
|
@@ -11,14 +11,13 @@ const ComboboxClearButton = () => {
|
|
|
11
11
|
if (!context) {
|
|
12
12
|
throw new Error('ComboboxContext is missing');
|
|
13
13
|
}
|
|
14
|
-
const { size, readOnly, disabled, clearButtonLabel,
|
|
14
|
+
const { size, readOnly, disabled, clearButtonLabel, handleSelectOption } = context;
|
|
15
15
|
return (jsx("button", { disabled: disabled, className: clsx(classes.clearButton, classes[size], `fds-focus`), onClick: () => {
|
|
16
16
|
if (readOnly)
|
|
17
17
|
return;
|
|
18
18
|
if (disabled)
|
|
19
19
|
return;
|
|
20
|
-
|
|
21
|
-
setInputValue('');
|
|
20
|
+
handleSelectOption({ option: null, clear: true });
|
|
22
21
|
}, onKeyDown: (e) => {
|
|
23
22
|
if (readOnly)
|
|
24
23
|
return;
|
|
@@ -26,9 +25,7 @@ const ComboboxClearButton = () => {
|
|
|
26
25
|
return;
|
|
27
26
|
if (e.key === 'Enter') {
|
|
28
27
|
e.stopPropagation();
|
|
29
|
-
|
|
30
|
-
setInputValue('');
|
|
31
|
-
inputRef.current?.focus();
|
|
28
|
+
handleSelectOption({ option: null, clear: true });
|
|
32
29
|
}
|
|
33
30
|
}, type: 'button', "aria-label": clearButtonLabel, children: jsx(XMarkIcon, { fontSize: '1.5em', title: 'Clear selection' }) }));
|
|
34
31
|
};
|