@navikt/ds-react 6.7.0 → 6.7.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/cjs/chat/Chat.d.ts +2 -1
- package/cjs/chat/Chat.js +2 -1
- package/cjs/chat/Chat.js.map +1 -1
- package/cjs/date/datepicker/parts/DropdownCaption.js +1 -1
- package/cjs/date/datepicker/parts/DropdownCaption.js.map +1 -1
- package/cjs/date/monthpicker/MonthCaption.js +1 -1
- package/cjs/date/utils/labels.d.ts +2 -2
- package/cjs/form/ReadOnlyIcon.d.ts +2 -2
- package/cjs/form/combobox/Combobox.js +7 -22
- package/cjs/form/combobox/Combobox.js.map +1 -1
- package/cjs/form/combobox/ComboboxProvider.js +2 -2
- package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
- package/cjs/form/combobox/ComboboxWrapper.d.ts +1 -2
- package/cjs/form/combobox/ComboboxWrapper.js +4 -2
- package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +13 -15
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/cjs/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
- package/cjs/form/combobox/Input/{inputContext.js → Input.context.js} +22 -22
- package/cjs/form/combobox/Input/Input.context.js.map +1 -0
- package/cjs/form/combobox/Input/Input.js +2 -2
- package/cjs/form/combobox/Input/Input.js.map +1 -1
- package/cjs/form/combobox/Input/InputController.d.ts +3 -0
- package/cjs/form/combobox/Input/InputController.js +70 -0
- package/cjs/form/combobox/Input/InputController.js.map +1 -0
- package/cjs/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
- package/cjs/form/combobox/Input/ToggleListButton.js.map +1 -0
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +7 -13
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/cjs/form/combobox/customOptionsContext.d.ts +4 -4
- package/cjs/form/combobox/customOptionsContext.js +10 -13
- package/cjs/form/combobox/customOptionsContext.js.map +1 -1
- package/cjs/form/combobox/types.d.ts +1 -1
- package/cjs/help-text/HelpTextIcon.d.ts +1 -1
- package/cjs/overlay/dismiss/DismissableLayer.d.ts +70 -0
- package/cjs/overlay/dismiss/DismissableLayer.js +253 -0
- package/cjs/overlay/dismiss/DismissableLayer.js.map +1 -0
- package/cjs/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
- package/cjs/overlay/dismiss/util/dispatchCustomEvent.js +65 -0
- package/cjs/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
- package/cjs/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
- package/cjs/overlay/dismiss/util/useEscapeKeydown.js +19 -0
- package/cjs/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
- package/cjs/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
- package/cjs/overlay/dismiss/util/useFocusOutside.js +42 -0
- package/cjs/overlay/dismiss/util/useFocusOutside.js.map +1 -0
- package/cjs/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
- package/cjs/overlay/dismiss/util/usePointerDownOutside.js +84 -0
- package/cjs/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
- package/cjs/overlays/floating/Floating.d.ts +53 -0
- package/cjs/overlays/floating/Floating.js +215 -0
- package/cjs/overlays/floating/Floating.js.map +1 -0
- package/cjs/overlays/floating/Floating.utils.d.ts +18 -0
- package/cjs/overlays/floating/Floating.utils.js +52 -0
- package/cjs/overlays/floating/Floating.utils.js.map +1 -0
- package/cjs/popover/Popover.js +13 -28
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/progress-bar/ProgressBar.d.ts +20 -8
- package/cjs/progress-bar/ProgressBar.js +19 -9
- package/cjs/progress-bar/ProgressBar.js.map +1 -1
- package/cjs/tabs/Tabs.context.d.ts +7 -3
- package/cjs/tabs/Tabs.context.js +1 -0
- package/cjs/tabs/Tabs.context.js.map +1 -1
- package/cjs/timeline/AxisLabels.d.ts +1 -1
- package/cjs/toggle-group/ToggleGroup.context.d.ts +7 -3
- package/cjs/toggle-group/ToggleGroup.context.js +1 -0
- package/cjs/toggle-group/ToggleGroup.context.js.map +1 -1
- package/cjs/util/hooks/descendants/useDescendant.d.ts +2 -2
- package/cjs/util/hooks/descendants/useDescendant.js +49 -52
- package/cjs/util/hooks/descendants/useDescendant.js.map +1 -1
- package/cjs/util/types/AsChild.d.ts +14 -0
- package/cjs/util/types/AsChild.js +3 -0
- package/cjs/util/types/AsChild.js.map +1 -0
- package/esm/chat/Chat.d.ts +2 -1
- package/esm/chat/Chat.js +1 -0
- package/esm/chat/Chat.js.map +1 -1
- package/esm/date/datepicker/parts/DropdownCaption.js +1 -1
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
- package/esm/date/monthpicker/MonthCaption.js +1 -1
- package/esm/date/utils/labels.d.ts +2 -2
- package/esm/form/ReadOnlyIcon.d.ts +2 -2
- package/esm/form/combobox/Combobox.js +8 -23
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/ComboboxProvider.js +1 -1
- package/esm/form/combobox/ComboboxProvider.js.map +1 -1
- package/esm/form/combobox/ComboboxWrapper.d.ts +1 -2
- package/esm/form/combobox/ComboboxWrapper.js +4 -2
- package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +3 -3
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +15 -16
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
- package/esm/form/combobox/Input/{inputContext.js → Input.context.js} +22 -21
- package/esm/form/combobox/Input/Input.context.js.map +1 -0
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/Input/InputController.d.ts +3 -0
- package/esm/form/combobox/Input/InputController.js +41 -0
- package/esm/form/combobox/Input/InputController.js.map +1 -0
- package/esm/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
- package/esm/form/combobox/Input/ToggleListButton.js.map +1 -0
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +9 -14
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/esm/form/combobox/customOptionsContext.d.ts +4 -4
- package/esm/form/combobox/customOptionsContext.js +10 -12
- package/esm/form/combobox/customOptionsContext.js.map +1 -1
- package/esm/form/combobox/types.d.ts +1 -1
- package/esm/help-text/HelpTextIcon.d.ts +1 -1
- package/esm/overlay/dismiss/DismissableLayer.d.ts +70 -0
- package/esm/overlay/dismiss/DismissableLayer.js +226 -0
- package/esm/overlay/dismiss/DismissableLayer.js.map +1 -0
- package/esm/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
- package/esm/overlay/dismiss/util/dispatchCustomEvent.js +58 -0
- package/esm/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
- package/esm/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
- package/esm/overlay/dismiss/util/useEscapeKeydown.js +15 -0
- package/esm/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
- package/esm/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
- package/esm/overlay/dismiss/util/useFocusOutside.js +38 -0
- package/esm/overlay/dismiss/util/useFocusOutside.js.map +1 -0
- package/esm/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
- package/esm/overlay/dismiss/util/usePointerDownOutside.js +80 -0
- package/esm/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
- package/esm/overlays/floating/Floating.d.ts +53 -0
- package/esm/overlays/floating/Floating.js +188 -0
- package/esm/overlays/floating/Floating.js.map +1 -0
- package/esm/overlays/floating/Floating.utils.d.ts +18 -0
- package/esm/overlays/floating/Floating.utils.js +48 -0
- package/esm/overlays/floating/Floating.utils.js.map +1 -0
- package/esm/popover/Popover.js +16 -31
- package/esm/popover/Popover.js.map +1 -1
- package/esm/progress-bar/ProgressBar.d.ts +20 -8
- package/esm/progress-bar/ProgressBar.js +20 -10
- package/esm/progress-bar/ProgressBar.js.map +1 -1
- package/esm/tabs/Tabs.context.d.ts +7 -3
- package/esm/tabs/Tabs.context.js +1 -0
- package/esm/tabs/Tabs.context.js.map +1 -1
- package/esm/timeline/AxisLabels.d.ts +1 -1
- package/esm/toggle-group/ToggleGroup.context.d.ts +7 -3
- package/esm/toggle-group/ToggleGroup.context.js +1 -0
- package/esm/toggle-group/ToggleGroup.context.js.map +1 -1
- package/esm/util/hooks/descendants/useDescendant.d.ts +2 -2
- package/esm/util/hooks/descendants/useDescendant.js +49 -52
- package/esm/util/hooks/descendants/useDescendant.js.map +1 -1
- package/esm/util/types/AsChild.d.ts +14 -0
- package/esm/util/types/AsChild.js +2 -0
- package/esm/util/types/AsChild.js.map +1 -0
- package/package.json +6 -5
- package/src/chat/Chat.tsx +2 -1
- package/src/date/datepicker/parts/DropdownCaption.tsx +5 -1
- package/src/date/monthpicker/MonthCaption.tsx +1 -1
- package/src/form/combobox/Combobox.tsx +6 -76
- package/src/form/combobox/ComboboxProvider.tsx +1 -1
- package/src/form/combobox/ComboboxWrapper.tsx +4 -3
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +3 -3
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +19 -29
- package/src/form/combobox/Input/{inputContext.tsx → Input.context.tsx} +30 -33
- package/src/form/combobox/Input/Input.tsx +1 -1
- package/src/form/combobox/Input/InputController.tsx +102 -0
- package/src/form/combobox/{ToggleListButton.tsx → Input/ToggleListButton.tsx} +1 -1
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +12 -26
- package/src/form/combobox/{combobox-utils.test.ts → __tests__/combobox-utils.test.ts} +1 -1
- package/src/form/combobox/{combobox.test.tsx → __tests__/combobox.test.tsx} +2 -3
- package/src/form/combobox/customOptionsContext.tsx +14 -18
- package/src/form/combobox/types.ts +3 -1
- package/src/overlay/README.md +5 -0
- package/src/overlay/dismiss/DismissableLayer.tsx +368 -0
- package/src/overlay/dismiss/util/dispatchCustomEvent.ts +77 -0
- package/src/overlay/dismiss/util/useEscapeKeydown.ts +21 -0
- package/src/overlay/dismiss/util/useFocusOutside.ts +52 -0
- package/src/overlay/dismiss/util/usePointerDownOutside.ts +95 -0
- package/src/overlays/floating/Floating.tsx +399 -0
- package/src/overlays/floating/Floating.utils.ts +63 -0
- package/src/popover/Popover.tsx +38 -70
- package/src/progress-bar/ProgressBar.tsx +45 -20
- package/src/tabs/Tabs.context.ts +2 -0
- package/src/toggle-group/ToggleGroup.context.ts +1 -0
- package/src/util/hooks/descendants/useDescendant.tsx +55 -68
- package/src/util/types/AsChild.ts +15 -0
- package/cjs/form/combobox/ClearButton.d.ts +0 -7
- package/cjs/form/combobox/ClearButton.js +0 -28
- package/cjs/form/combobox/ClearButton.js.map +0 -1
- package/cjs/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
- package/cjs/form/combobox/FilteredOptions/CheckIcon.js +0 -12
- package/cjs/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
- package/cjs/form/combobox/Input/inputContext.js.map +0 -1
- package/cjs/form/combobox/ToggleListButton.js.map +0 -1
- package/esm/form/combobox/ClearButton.d.ts +0 -7
- package/esm/form/combobox/ClearButton.js +0 -21
- package/esm/form/combobox/ClearButton.js.map +0 -1
- package/esm/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
- package/esm/form/combobox/FilteredOptions/CheckIcon.js +0 -7
- package/esm/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
- package/esm/form/combobox/Input/inputContext.js.map +0 -1
- package/esm/form/combobox/ToggleListButton.js.map +0 -1
- package/src/form/combobox/ClearButton.tsx +0 -29
- package/src/form/combobox/FilteredOptions/CheckIcon.tsx +0 -23
- /package/cjs/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
- /package/esm/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import cl from "clsx";
|
|
13
|
-
import React, { forwardRef } from "react";
|
|
13
|
+
import React, { forwardRef, useRef } from "react";
|
|
14
14
|
/**
|
|
15
15
|
* ProgressBar
|
|
16
16
|
* A component for visualizing progression in a process.
|
|
@@ -20,26 +20,36 @@ import React, { forwardRef } from "react";
|
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* // For loading content with an approximate duration in sec.
|
|
23
|
-
* <ProgressBar
|
|
23
|
+
* <ProgressBar simulated={{
|
|
24
|
+
* seconds: 30,
|
|
25
|
+
* onTimeout: () => console.log("Oops, this is taking more time than expected!")
|
|
26
|
+
* }}
|
|
27
|
+
* />
|
|
24
28
|
*
|
|
25
29
|
* @example
|
|
26
30
|
* // As a step indicator for forms, questionnaires, etc.
|
|
27
31
|
* <ProgressBar value={2} valueMax={7} />
|
|
28
32
|
*/
|
|
29
33
|
export const ProgressBar = forwardRef((_a, ref) => {
|
|
30
|
-
var { size = "medium", value = 0, valueMax = 100, "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel, className } = _a, rest = __rest(_a, ["size", "value", "valueMax", "aria-labelledby", "aria-label", "className"]);
|
|
34
|
+
var { size = "medium", value = 0, valueMax = 100, "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel, className, simulated } = _a, rest = __rest(_a, ["size", "value", "valueMax", "aria-labelledby", "aria-label", "className", "simulated"]);
|
|
31
35
|
const translate = 100 - (Math.round(value) / valueMax) * 100;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
const onTimeoutRef = useRef();
|
|
37
|
+
onTimeoutRef.current = simulated === null || simulated === void 0 ? void 0 : simulated.onTimeout;
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
if ((simulated === null || simulated === void 0 ? void 0 : simulated.seconds) && onTimeoutRef.current) {
|
|
40
|
+
const timeout = setTimeout(onTimeoutRef.current, simulated.seconds * 1000);
|
|
41
|
+
return () => clearTimeout(timeout);
|
|
42
|
+
}
|
|
43
|
+
}, [simulated === null || simulated === void 0 ? void 0 : simulated.seconds]);
|
|
44
|
+
return (React.createElement("div", Object.assign({ ref: ref, className: cl("navds-progress-bar", `navds-progress-bar--${size}`, className), "aria-valuemax": (simulated === null || simulated === void 0 ? void 0 : simulated.seconds) ? 0 : Math.round(valueMax), "aria-valuenow": (simulated === null || simulated === void 0 ? void 0 : simulated.seconds) ? 0 : Math.round(value), "aria-valuetext": (simulated === null || simulated === void 0 ? void 0 : simulated.seconds)
|
|
45
|
+
? `Fremdrift kan ikke beregnes, antatt tid er: ${simulated === null || simulated === void 0 ? void 0 : simulated.seconds} sekunder`
|
|
35
46
|
: `${Math.round(value)} av ${Math.round(valueMax)}`, role: "progressbar", "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel }, rest),
|
|
36
47
|
React.createElement("div", { className: cl("navds-progress-bar__foreground", {
|
|
37
|
-
"navds-progress-bar__foreground--indeterminate": Number.isInteger(
|
|
48
|
+
"navds-progress-bar__foreground--indeterminate": Number.isInteger(simulated === null || simulated === void 0 ? void 0 : simulated.seconds),
|
|
38
49
|
}), style: {
|
|
39
|
-
"--__ac-progress-bar-
|
|
40
|
-
? `${
|
|
50
|
+
"--__ac-progress-bar-simulated": Number.isInteger(simulated === null || simulated === void 0 ? void 0 : simulated.seconds)
|
|
51
|
+
? `${simulated === null || simulated === void 0 ? void 0 : simulated.seconds}s`
|
|
41
52
|
: undefined,
|
|
42
|
-
"--__ac-progress-bar-delay": `${duration === 0 ? 0 : 4}s`,
|
|
43
53
|
"--__ac-progress-bar-translate": `-${translate}%`,
|
|
44
54
|
} })));
|
|
45
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","sourceRoot":"","sources":["../../src/progress-bar/ProgressBar.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","sourceRoot":"","sources":["../../src/progress-bar/ProgressBar.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAkB,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AA4DlE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CACnC,CACE,EASC,EACD,GAAG,EACH,EAAE;QAXF,EACE,IAAI,GAAG,QAAQ,EACf,KAAK,GAAG,CAAC,EACT,QAAQ,GAAG,GAAG,EACd,iBAAiB,EAAE,cAAc,EACjC,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,SAAS,OAEV,EADI,IAAI,cART,wFASC,CADQ;IAIT,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IAC7D,MAAM,YAAY,GAAG,MAAM,EAAc,CAAC;IAC1C,YAAY,CAAC,OAAO,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,CAAC;IAE5C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,KAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YAC/C,MAAM,OAAO,GAAG,UAAU,CACxB,YAAY,CAAC,OAAO,EACpB,SAAS,CAAC,OAAO,GAAG,IAAI,CACzB,CAAC;YACF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,2CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,oBAAoB,EACpB,uBAAuB,IAAI,EAAE,EAC7B,SAAS,CACV,mBACc,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,mBAC7C,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,oBAEvD,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO;YAChB,CAAC,CAAC,+CAA+C,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,WAAW;YAC9E,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAEvD,IAAI,EAAC,aAAa,qBACD,cAAc,gBACnB,SAAS,IACjB,IAAI;QAER,6BACE,SAAS,EAAE,EAAE,CAAC,gCAAgC,EAAE;gBAC9C,+CAA+C,EAAE,MAAM,CAAC,SAAS,CAC/D,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CACnB;aACF,CAAC,EACF,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM,CAAC,SAAS,CAC/C,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CACnB;oBACC,CAAC,CAAC,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,GAAG;oBAC1B,CAAC,CAAC,SAAS;gBACb,+BAA+B,EAAE,IAAI,SAAS,GAAG;aAClD,GACD,CACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -3,14 +3,18 @@ import { TabsProps } from "./Tabs.types.js";
|
|
|
3
3
|
import { useTabs } from "./useTabs.js";
|
|
4
4
|
export declare const TabsDescendantsProvider: import("react").Provider<import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
5
5
|
value: string;
|
|
6
|
-
}>>, useTabsDescendantsContext: () => import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
6
|
+
}>>, useTabsDescendantsContext: <S extends boolean = true>(strict?: S) => S extends true ? import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
7
7
|
value: string;
|
|
8
|
-
}
|
|
8
|
+
}> : import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
9
|
+
value: string;
|
|
10
|
+
}> | undefined, useTabsDescendants: () => import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
9
11
|
value: string;
|
|
10
12
|
}>, useTabsDescendant: (options?: import("../util/hooks/descendants/descendant.js").DescendantOptions<{
|
|
11
13
|
value: string;
|
|
12
14
|
}> | undefined) => {
|
|
13
|
-
descendants: import("../util/hooks/descendants/descendant.js").DescendantsManager<
|
|
15
|
+
descendants: import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
16
|
+
value: string;
|
|
17
|
+
}>;
|
|
14
18
|
index: number;
|
|
15
19
|
enabledIndex: number;
|
|
16
20
|
register: (instance: HTMLButtonElement | null) => void;
|
package/esm/tabs/Tabs.context.js
CHANGED
|
@@ -6,5 +6,6 @@ export const [TabsProvider, useTabsContext] = createContext({
|
|
|
6
6
|
name: "TabsContext",
|
|
7
7
|
hookName: "useTabsContext",
|
|
8
8
|
providerName: "TabsProvider",
|
|
9
|
+
errorMessage: "Tabs.List, Tabs.Tag and Tabs.Panel needs to be wrapped within <Tabs>",
|
|
9
10
|
});
|
|
10
11
|
//# sourceMappingURL=Tabs.context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.context.js","sourceRoot":"","sources":["../../src/tabs/Tabs.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAIlF,MAAM,CAAC,MAAM,CACX,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EAClB,GAAG,uBAAuB,EAAwC,CAAC;AAQpE,mBAAmB;AACnB,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,GAAG,aAAa,CAAoB;IAC7E,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,gBAAgB;IAC1B,YAAY,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"Tabs.context.js","sourceRoot":"","sources":["../../src/tabs/Tabs.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAIlF,MAAM,CAAC,MAAM,CACX,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EAClB,GAAG,uBAAuB,EAAwC,CAAC;AAQpE,mBAAmB;AACnB,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,GAAG,aAAa,CAAoB;IAC7E,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,gBAAgB;IAC1B,YAAY,EAAE,cAAc;IAC5B,YAAY,EACV,sEAAsE;CACzE,CAAC,CAAC"}
|
|
@@ -4,5 +4,5 @@ export declare const dayLabels: (start: Date, end: Date, totalDays: number, dire
|
|
|
4
4
|
export declare const monthLabels: (start: Date, end: Date, direction: "left" | "right", template?: string) => AxisLabel[];
|
|
5
5
|
export declare const yearLabels: (start: Date, end: Date, direction: "left" | "right", template?: string) => AxisLabel[];
|
|
6
6
|
export declare const AxisLabels: ({ templates, }: {
|
|
7
|
-
templates?: AxisLabelTemplates
|
|
7
|
+
templates?: AxisLabelTemplates;
|
|
8
8
|
}) => React.JSX.Element;
|
|
@@ -7,14 +7,18 @@ interface ToggleContextProps {
|
|
|
7
7
|
export declare const ToggleGroupContext: import("react").Context<ToggleContextProps | null>;
|
|
8
8
|
export declare const ToggleGroupDescendantsProvider: import("react").Provider<import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
9
9
|
value: string;
|
|
10
|
-
}>>, useToggleGroupDescendantsContext: () => import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
10
|
+
}>>, useToggleGroupDescendantsContext: <S extends boolean = true>(strict?: S) => S extends true ? import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
11
11
|
value: string;
|
|
12
|
-
}
|
|
12
|
+
}> : import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
13
|
+
value: string;
|
|
14
|
+
}> | undefined, useToggleGroupDescendants: () => import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
13
15
|
value: string;
|
|
14
16
|
}>, useToggleGroupDescendant: (options?: import("../util/hooks/descendants/descendant.js").DescendantOptions<{
|
|
15
17
|
value: string;
|
|
16
18
|
}> | undefined) => {
|
|
17
|
-
descendants: import("../util/hooks/descendants/descendant.js").DescendantsManager<
|
|
19
|
+
descendants: import("../util/hooks/descendants/descendant.js").DescendantsManager<HTMLButtonElement, {
|
|
20
|
+
value: string;
|
|
21
|
+
}>;
|
|
18
22
|
index: number;
|
|
19
23
|
enabledIndex: number;
|
|
20
24
|
register: (instance: HTMLButtonElement | null) => void;
|
|
@@ -8,5 +8,6 @@ export const [ToggleGroupProvider, useToggleGroupContext] = createContext({
|
|
|
8
8
|
name: "ToggleGroupContext",
|
|
9
9
|
hookName: "useToggleGroupContext",
|
|
10
10
|
providerName: "ToggleGroupProvider",
|
|
11
|
+
errorMessage: "<ToggleGroup.Item> needs to be wrapped within <ToggleGroup>",
|
|
11
12
|
});
|
|
12
13
|
//# sourceMappingURL=ToggleGroup.context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleGroup.context.js","sourceRoot":"","sources":["../../src/toggle-group/ToggleGroup.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAQlF,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAClD,IAAI,CACL,CAAC;AAEF,MAAM,CAAC,MAAM,CACX,8BAA8B,EAC9B,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACzB,GAAG,uBAAuB,EAAwC,CAAC;AAKpE,mBAAmB;AACnB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,GACvD,aAAa,CAA2B;IACtC,IAAI,EAAE,oBAAoB;IAC1B,QAAQ,EAAE,uBAAuB;IACjC,YAAY,EAAE,qBAAqB;
|
|
1
|
+
{"version":3,"file":"ToggleGroup.context.js","sourceRoot":"","sources":["../../src/toggle-group/ToggleGroup.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAQlF,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAClD,IAAI,CACL,CAAC;AAEF,MAAM,CAAC,MAAM,CACX,8BAA8B,EAC9B,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACzB,GAAG,uBAAuB,EAAwC,CAAC;AAKpE,mBAAmB;AACnB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,GACvD,aAAa,CAA2B;IACtC,IAAI,EAAE,oBAAoB;IAC1B,QAAQ,EAAE,uBAAuB;IACjC,YAAY,EAAE,qBAAqB;IACnC,YAAY,EAAE,6DAA6D;CAC5E,CAAC,CAAC"}
|
|
@@ -6,8 +6,8 @@ import { DescendantOptions, DescendantsManager } from "./descendant.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Provides strongly typed versions of the context provider and hooks above.
|
|
8
8
|
*/
|
|
9
|
-
export declare function createDescendantContext<T extends HTMLElement = HTMLElement, K extends Record<string, any> = object>(): readonly [React.Provider<DescendantsManager<T, K>>, () => DescendantsManager<T, K
|
|
10
|
-
descendants: DescendantsManager<
|
|
9
|
+
export declare function createDescendantContext<T extends HTMLElement = HTMLElement, K extends Record<string, any> = object>(): readonly [React.Provider<DescendantsManager<T, K>>, <S extends boolean = true>(strict?: S) => S extends true ? DescendantsManager<T, K> : DescendantsManager<T, K> | undefined, () => DescendantsManager<T, K>, (options?: DescendantOptions<K>) => {
|
|
10
|
+
descendants: DescendantsManager<T, K>;
|
|
11
11
|
index: number;
|
|
12
12
|
enabledIndex: number;
|
|
13
13
|
register: (instance: T | null) => void;
|
|
@@ -7,67 +7,64 @@ import { useClientLayoutEffect } from "../useClientLayoutEffect.js";
|
|
|
7
7
|
import { mergeRefs } from "../useMergeRefs.js";
|
|
8
8
|
import { DescendantsManager } from "./descendant.js";
|
|
9
9
|
import { cast } from "./utils.js";
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
* Initializing DescendantsManager
|
|
13
|
-
*/
|
|
14
|
-
function useDescendants() {
|
|
15
|
-
const descendants = useRef(new DescendantsManager()).current;
|
|
16
|
-
return descendants;
|
|
17
|
-
}
|
|
18
|
-
const [DescendantsContextProvider, useDescendantsContext] = createContext({
|
|
19
|
-
name: "DescendantsProvider",
|
|
20
|
-
errorMessage: "useDescendantsContext must be used within DescendantsProvider",
|
|
21
|
-
});
|
|
22
|
-
/**
|
|
23
|
-
* @internal
|
|
24
|
-
* This hook provides information to descendant component:
|
|
25
|
-
* - Index compared to other descendants
|
|
26
|
-
* - ref callback to register the descendant
|
|
27
|
-
* - Its enabled index compared to other enabled descendants
|
|
28
|
-
*/
|
|
29
|
-
function useDescendant(options) {
|
|
30
|
-
const descendants = useDescendantsContext();
|
|
31
|
-
const [index, setIndex] = useState(-1);
|
|
32
|
-
const ref = useRef(null);
|
|
33
|
-
useClientLayoutEffect(() => {
|
|
34
|
-
return () => {
|
|
35
|
-
if (!ref.current)
|
|
36
|
-
return;
|
|
37
|
-
descendants.unregister(ref.current);
|
|
38
|
-
};
|
|
39
|
-
}, []);
|
|
40
|
-
useClientLayoutEffect(() => {
|
|
41
|
-
if (!ref.current)
|
|
42
|
-
return;
|
|
43
|
-
const dataIndex = Number(ref.current.dataset["index"]);
|
|
44
|
-
if (index != dataIndex && !Number.isNaN(dataIndex)) {
|
|
45
|
-
setIndex(dataIndex);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const refCallback = options
|
|
49
|
-
? cast(descendants.register(options))
|
|
50
|
-
: cast(descendants.register);
|
|
51
|
-
return {
|
|
52
|
-
descendants,
|
|
53
|
-
index,
|
|
54
|
-
enabledIndex: descendants.enabledIndexOf(ref.current),
|
|
55
|
-
register: mergeRefs([refCallback, ref]),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
10
|
/**
|
|
59
11
|
* Provides strongly typed versions of the context provider and hooks above.
|
|
60
12
|
*/
|
|
61
13
|
export function createDescendantContext() {
|
|
14
|
+
const [DescendantsContextProvider, useDescendantsContext] = createContext({
|
|
15
|
+
name: "DescendantsProvider",
|
|
16
|
+
errorMessage: "useDescendantsContext must be used within DescendantsProvider",
|
|
17
|
+
});
|
|
62
18
|
const ContextProvider = cast((props) => (React.createElement(DescendantsContextProvider, Object.assign({}, props.value), props.children)));
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
* This hook provides information to descendant component:
|
|
22
|
+
* - Index compared to other descendants
|
|
23
|
+
* - ref callback to register the descendant
|
|
24
|
+
* - Its enabled index compared to other enabled descendants
|
|
25
|
+
*/
|
|
26
|
+
function _useDescendant(options) {
|
|
27
|
+
const descendants = useDescendantsContext();
|
|
28
|
+
const [index, setIndex] = useState(-1);
|
|
29
|
+
const ref = useRef(null);
|
|
30
|
+
useClientLayoutEffect(() => {
|
|
31
|
+
return () => {
|
|
32
|
+
if (!ref.current)
|
|
33
|
+
return;
|
|
34
|
+
descendants.unregister(ref.current);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
useClientLayoutEffect(() => {
|
|
38
|
+
if (!ref.current)
|
|
39
|
+
return;
|
|
40
|
+
const dataIndex = Number(ref.current.dataset["index"]);
|
|
41
|
+
if (index != dataIndex && !Number.isNaN(dataIndex)) {
|
|
42
|
+
setIndex(dataIndex);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const refCallback = options
|
|
46
|
+
? cast(descendants.register(options))
|
|
47
|
+
: cast(descendants.register);
|
|
48
|
+
return {
|
|
49
|
+
descendants,
|
|
50
|
+
index,
|
|
51
|
+
enabledIndex: descendants.enabledIndexOf(ref.current),
|
|
52
|
+
register: mergeRefs([refCallback, ref]),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* Initializing DescendantsManager
|
|
58
|
+
*/
|
|
59
|
+
function _useDescendants() {
|
|
60
|
+
const descendants = useRef(new DescendantsManager()).current;
|
|
61
|
+
return descendants;
|
|
62
|
+
}
|
|
66
63
|
return [
|
|
67
64
|
// context provider
|
|
68
65
|
ContextProvider,
|
|
69
66
|
// call this when you need to read from context
|
|
70
|
-
|
|
67
|
+
useDescendantsContext,
|
|
71
68
|
// descendants state information, to be called and passed to `ContextProvider`
|
|
72
69
|
_useDescendants,
|
|
73
70
|
// descendant index information
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDescendant.js","sourceRoot":"","sources":["../../../../src/util/hooks/descendants/useDescendant.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAqB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B
|
|
1
|
+
{"version":3,"file":"useDescendant.js","sourceRoot":"","sources":["../../../../src/util/hooks/descendants/useDescendant.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAqB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,uBAAuB;IAIrC,MAAM,CAAC,0BAA0B,EAAE,qBAAqB,CAAC,GAAG,aAAa,CAEvE;QACA,IAAI,EAAE,qBAAqB;QAC3B,YAAY,EACV,+DAA+D;KAClE,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,IAAI,CAC1B,CAAC,KAAK,EAAE,EAAE,CAAC,CACT,oBAAC,0BAA0B,oBAAK,KAAK,CAAC,KAAK,GACxC,KAAK,CAAC,QAAQ,CACY,CAC9B,CACF,CAAC;IAEF;;;;;;OAMG;IACH,SAAS,cAAc,CAAC,OAA8B;QACpD,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;QAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,CAAI,IAAI,CAAC,CAAC;QAE5B,qBAAqB,CAAC,GAAG,EAAE;YACzB,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,OAAO;oBAAE,OAAO;gBACzB,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACtC,CAAC,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,qBAAqB,CAAC,GAAG,EAAE;YACzB,IAAI,CAAC,GAAG,CAAC,OAAO;gBAAE,OAAO;YACzB,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACvD,IAAI,KAAK,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACnD,QAAQ,CAAC,SAAS,CAAC,CAAC;YACtB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,OAAO;YACzB,CAAC,CAAC,IAAI,CAAuB,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC3D,CAAC,CAAC,IAAI,CAAuB,WAAW,CAAC,QAAQ,CAAC,CAAC;QAErD,OAAO;YACL,WAAW;YACX,KAAK;YACL,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;YACrD,QAAQ,EAAE,SAAS,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;SACxC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS,eAAe;QACtB,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,kBAAkB,EAAQ,CAAC,CAAC,OAAO,CAAC;QAEnE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO;QACL,mBAAmB;QACnB,eAAe;QACf,+CAA+C;QAC/C,qBAAqB;QACrB,8EAA8E;QAC9E,eAAe;QACf,+BAA+B;QAC/B,cAAc;KACN,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type AsChild = {
|
|
3
|
+
children: React.ReactElement;
|
|
4
|
+
/**
|
|
5
|
+
* Renders the children as a child of the component. Merges the props of the component with the props of the child.
|
|
6
|
+
*/
|
|
7
|
+
asChild: true;
|
|
8
|
+
} | {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Renders the children as a child of the component. Merges the props of the component with the props of the child.
|
|
12
|
+
*/
|
|
13
|
+
asChild?: false;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsChild.js","sourceRoot":"","sources":["../../../src/util/types/AsChild.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.1",
|
|
4
4
|
"description": "React components from the Norwegian Labour and Welfare Administration.",
|
|
5
5
|
"author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -583,16 +583,17 @@
|
|
|
583
583
|
},
|
|
584
584
|
"dependencies": {
|
|
585
585
|
"@floating-ui/react": "0.25.4",
|
|
586
|
-
"@
|
|
587
|
-
"@navikt/
|
|
586
|
+
"@floating-ui/react-dom": "^2.0.9",
|
|
587
|
+
"@navikt/aksel-icons": "^6.7.1",
|
|
588
|
+
"@navikt/ds-tokens": "^6.7.1",
|
|
588
589
|
"clsx": "^2.1.0",
|
|
589
590
|
"date-fns": "^3.0.0",
|
|
590
591
|
"react-day-picker": "8.10.0"
|
|
591
592
|
},
|
|
592
593
|
"devDependencies": {
|
|
593
|
-
"@testing-library/dom": "
|
|
594
|
+
"@testing-library/dom": "9.3.4",
|
|
594
595
|
"@testing-library/jest-dom": "^5.16.0",
|
|
595
|
-
"@testing-library/react": "^
|
|
596
|
+
"@testing-library/react": "^15.0.7",
|
|
596
597
|
"@testing-library/user-event": "^14.2.0",
|
|
597
598
|
"@types/faker": "5.5.8",
|
|
598
599
|
"concurrently": "7.2.1",
|
package/src/chat/Chat.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import React, { HTMLAttributes, forwardRef } from "react";
|
|
|
3
3
|
import { BodyLong } from "../typography";
|
|
4
4
|
import Bubble from "./Bubble";
|
|
5
5
|
|
|
6
|
+
export const VARIANTS = ["subtle", "info", "neutral"] as const;
|
|
6
7
|
export const POSITIONS = ["left", "right"] as const;
|
|
7
8
|
export const SIZES = ["medium", "small"] as const;
|
|
8
9
|
|
|
@@ -28,7 +29,7 @@ export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
28
29
|
* Avoid using the same background as the surface behind Chat.
|
|
29
30
|
* @default "neutral"
|
|
30
31
|
*/
|
|
31
|
-
variant?:
|
|
32
|
+
variant?: (typeof VARIANTS)[number];
|
|
32
33
|
/**
|
|
33
34
|
* Positions avatar and bubbles.
|
|
34
35
|
* @default "left"
|
|
@@ -37,7 +37,11 @@ export const DropdownCaption = ({ displayMonth, id }: CaptionProps) => {
|
|
|
37
37
|
const handleMonthChange: React.ChangeEventHandler<HTMLSelectElement> = (e) =>
|
|
38
38
|
goToMonth(setMonth(startOfMonth(displayMonth), Number(e.target.value)));
|
|
39
39
|
|
|
40
|
-
const years = getYears(
|
|
40
|
+
const years = getYears(
|
|
41
|
+
fromDate,
|
|
42
|
+
toDate,
|
|
43
|
+
displayMonth.getFullYear(),
|
|
44
|
+
).reverse();
|
|
41
45
|
const months = getMonths(fromDate, toDate, displayMonth);
|
|
42
46
|
|
|
43
47
|
const previousLabel = labelPrevious(previousMonth, { locale });
|
|
@@ -35,7 +35,7 @@ export const MonthCaption = () => {
|
|
|
35
35
|
if (!years.map((x) => x.getFullYear()).includes(year.getFullYear())) {
|
|
36
36
|
years.push(setYear(startOfYear(new Date()), year.getFullYear()));
|
|
37
37
|
}
|
|
38
|
-
years.sort((a, b) =>
|
|
38
|
+
years.sort((a, b) => b.getFullYear() - a.getFullYear());
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const handleYearChange = (e) =>
|
|
@@ -1,57 +1,31 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, { forwardRef
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
3
|
import { BodyShort, ErrorMessage, Label } from "../../typography";
|
|
4
|
-
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
5
|
-
import ClearButton from "./ClearButton";
|
|
6
4
|
import ComboboxWrapper from "./ComboboxWrapper";
|
|
7
5
|
import FilteredOptions from "./FilteredOptions/FilteredOptions";
|
|
8
6
|
import { useFilteredOptionsContext } from "./FilteredOptions/filteredOptionsContext";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import SelectedOptions from "./SelectedOptions/SelectedOptions";
|
|
12
|
-
import { useSelectedOptionsContext } from "./SelectedOptions/selectedOptionsContext";
|
|
13
|
-
import ToggleListButton from "./ToggleListButton";
|
|
7
|
+
import { useInputContext } from "./Input/Input.context";
|
|
8
|
+
import { InputController } from "./Input/InputController";
|
|
14
9
|
import { ComboboxProps } from "./types";
|
|
15
10
|
|
|
16
11
|
export const Combobox = forwardRef<
|
|
17
12
|
HTMLInputElement,
|
|
18
13
|
Omit<ComboboxProps, "onChange" | "options" | "size" | "onClear" | "value">
|
|
19
14
|
>((props, ref) => {
|
|
20
|
-
const {
|
|
21
|
-
className,
|
|
22
|
-
hideLabel = false,
|
|
23
|
-
description,
|
|
24
|
-
label,
|
|
25
|
-
clearButton = true,
|
|
26
|
-
clearButtonLabel,
|
|
27
|
-
toggleListButton = true,
|
|
28
|
-
toggleListButtonLabel,
|
|
29
|
-
inputClassName,
|
|
30
|
-
shouldShowSelectedOptions = true,
|
|
31
|
-
...rest
|
|
32
|
-
} = props;
|
|
33
|
-
|
|
34
|
-
const toggleListButtonRef = useRef<HTMLButtonElement>(null);
|
|
15
|
+
const { className, hideLabel = false, description, label, ...rest } = props;
|
|
35
16
|
|
|
36
|
-
const {
|
|
37
|
-
const { selectedOptions } = useSelectedOptionsContext();
|
|
17
|
+
const { toggleIsListOpen } = useFilteredOptionsContext();
|
|
38
18
|
|
|
39
19
|
const {
|
|
40
|
-
clearInput,
|
|
41
20
|
error,
|
|
42
21
|
errorId,
|
|
43
|
-
focusInput,
|
|
44
22
|
hasError,
|
|
45
23
|
inputDescriptionId,
|
|
46
24
|
inputProps,
|
|
47
|
-
inputRef,
|
|
48
|
-
value,
|
|
49
25
|
showErrorMsg,
|
|
50
26
|
size = "medium",
|
|
51
27
|
} = useInputContext();
|
|
52
28
|
|
|
53
|
-
const mergedInputRef = useMergeRefs(inputRef, ref);
|
|
54
|
-
|
|
55
29
|
return (
|
|
56
30
|
<ComboboxWrapper
|
|
57
31
|
className={className}
|
|
@@ -59,7 +33,6 @@ export const Combobox = forwardRef<
|
|
|
59
33
|
inputProps={inputProps}
|
|
60
34
|
inputSize={size}
|
|
61
35
|
toggleIsListOpen={toggleIsListOpen}
|
|
62
|
-
toggleListButtonRef={toggleListButtonRef}
|
|
63
36
|
>
|
|
64
37
|
<Label
|
|
65
38
|
htmlFor={inputProps.id}
|
|
@@ -83,50 +56,7 @@ export const Combobox = forwardRef<
|
|
|
83
56
|
</BodyShort>
|
|
84
57
|
)}
|
|
85
58
|
<div className="navds-combobox__wrapper">
|
|
86
|
-
{
|
|
87
|
-
<div
|
|
88
|
-
className={cl(
|
|
89
|
-
"navds-combobox__wrapper-inner navds-text-field__input",
|
|
90
|
-
{
|
|
91
|
-
"navds-combobox__wrapper-inner--virtually-unfocused":
|
|
92
|
-
activeDecendantId !== undefined,
|
|
93
|
-
},
|
|
94
|
-
)}
|
|
95
|
-
onClick={focusInput}
|
|
96
|
-
>
|
|
97
|
-
{!shouldShowSelectedOptions ? (
|
|
98
|
-
<Input
|
|
99
|
-
id={inputProps.id}
|
|
100
|
-
ref={mergedInputRef}
|
|
101
|
-
inputClassName={inputClassName}
|
|
102
|
-
{...rest}
|
|
103
|
-
/>
|
|
104
|
-
) : (
|
|
105
|
-
<SelectedOptions selectedOptions={selectedOptions} size={size}>
|
|
106
|
-
<Input
|
|
107
|
-
id={inputProps.id}
|
|
108
|
-
ref={mergedInputRef}
|
|
109
|
-
inputClassName={inputClassName}
|
|
110
|
-
{...rest}
|
|
111
|
-
/>
|
|
112
|
-
</SelectedOptions>
|
|
113
|
-
)}
|
|
114
|
-
<div>
|
|
115
|
-
{value && clearButton && (
|
|
116
|
-
<ClearButton
|
|
117
|
-
handleClear={clearInput}
|
|
118
|
-
clearButtonLabel={clearButtonLabel}
|
|
119
|
-
tabIndex={-1}
|
|
120
|
-
/>
|
|
121
|
-
)}
|
|
122
|
-
{toggleListButton && (
|
|
123
|
-
<ToggleListButton
|
|
124
|
-
toggleListButtonLabel={toggleListButtonLabel}
|
|
125
|
-
ref={toggleListButtonRef}
|
|
126
|
-
/>
|
|
127
|
-
)}
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
59
|
+
<InputController ref={ref} {...rest} />
|
|
130
60
|
<FilteredOptions />
|
|
131
61
|
</div>
|
|
132
62
|
<div
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import Combobox from "./Combobox";
|
|
3
3
|
import { FilteredOptionsProvider } from "./FilteredOptions/filteredOptionsContext";
|
|
4
|
-
import { InputContextProvider } from "./Input/
|
|
4
|
+
import { InputContextProvider } from "./Input/Input.context";
|
|
5
5
|
import { SelectedOptionsProvider } from "./SelectedOptions/selectedOptionsContext";
|
|
6
6
|
import { mapToComboboxOptionArray } from "./combobox-utils";
|
|
7
7
|
import { CustomOptionsProvider } from "./customOptionsContext";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { useRef, useState } from "react";
|
|
3
|
+
import { useInputContext } from "./Input/Input.context";
|
|
3
4
|
|
|
4
5
|
type ComboboxWrapperProps = {
|
|
5
6
|
children: any;
|
|
@@ -10,7 +11,6 @@ type ComboboxWrapperProps = {
|
|
|
10
11
|
};
|
|
11
12
|
inputSize: string;
|
|
12
13
|
toggleIsListOpen: (isListOpen: boolean) => void;
|
|
13
|
-
toggleListButtonRef: React.RefObject<HTMLButtonElement>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const ComboboxWrapper = ({
|
|
@@ -20,15 +20,16 @@ const ComboboxWrapper = ({
|
|
|
20
20
|
inputProps,
|
|
21
21
|
inputSize,
|
|
22
22
|
toggleIsListOpen,
|
|
23
|
-
toggleListButtonRef,
|
|
24
23
|
}: ComboboxWrapperProps) => {
|
|
24
|
+
const { toggleOpenButtonRef } = useInputContext();
|
|
25
|
+
|
|
25
26
|
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
26
27
|
const [hasFocusWithin, setHasFocusWithin] = useState(false);
|
|
27
28
|
|
|
28
29
|
function onFocusInsideWrapper(e) {
|
|
29
30
|
if (
|
|
30
31
|
!wrapperRef.current?.contains(e.relatedTarget) &&
|
|
31
|
-
|
|
32
|
+
toggleOpenButtonRef?.current !== e.target
|
|
32
33
|
) {
|
|
33
34
|
toggleIsListOpen(true);
|
|
34
35
|
setHasFocusWithin(true);
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { CheckmarkIcon, PlusIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { Loader } from "../../../loader";
|
|
5
5
|
import { BodyShort, Label } from "../../../typography";
|
|
6
|
-
import { useInputContext } from "../Input/
|
|
6
|
+
import { useInputContext } from "../Input/Input.context";
|
|
7
7
|
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
8
8
|
import { isInList, toComboboxOption } from "../combobox-utils";
|
|
9
9
|
import { ComboboxOption } from "../types";
|
|
@@ -38,7 +38,7 @@ const FilteredOptions = () => {
|
|
|
38
38
|
const shouldRenderNonSelectables =
|
|
39
39
|
maxSelected?.isLimitReached || // Render maxSelected message
|
|
40
40
|
isLoading || // Render loading message
|
|
41
|
-
(!isLoading && filteredOptions.length === 0); // Render no hits message
|
|
41
|
+
(!isLoading && filteredOptions.length === 0 && !allowNewValues); // Render no hits message
|
|
42
42
|
|
|
43
43
|
const shouldRenderFilteredOptionsList =
|
|
44
44
|
(allowNewValues && isValueNew && !maxSelected?.isLimitReached) || // Render add new option
|
|
@@ -72,7 +72,7 @@ const FilteredOptions = () => {
|
|
|
72
72
|
<Loader title="Søker..." />
|
|
73
73
|
</div>
|
|
74
74
|
)}
|
|
75
|
-
{!isLoading && filteredOptions.length === 0 && (
|
|
75
|
+
{!isLoading && filteredOptions.length === 0 && !allowNewValues && (
|
|
76
76
|
<div
|
|
77
77
|
className="navds-combobox__list-item--no-options"
|
|
78
78
|
id={filteredOptionsUtil.getNoHitsId(id)}
|