@navikt/ds-react 7.8.1 → 7.9.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/cjs/accordion/AccordionContent.js +2 -2
- package/cjs/accordion/AccordionContent.js.map +1 -1
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/accordion/AccordionHeader.js.map +1 -1
- package/cjs/button/Button.js +9 -25
- package/cjs/button/Button.js.map +1 -1
- package/cjs/date/datepicker/parts/WeekNumber.js +2 -2
- package/cjs/date/datepicker/parts/WeekNumber.js.map +1 -1
- package/cjs/date/parts/DateInput.js +1 -1
- package/cjs/date/parts/DateInput.js.map +1 -1
- package/cjs/form/combobox/Combobox.d.ts +1 -1
- package/cjs/form/combobox/Combobox.js +1 -1
- package/cjs/form/combobox/Combobox.js.map +1 -1
- package/cjs/form/combobox/Input/InputController.d.ts +1 -1
- package/cjs/form/confirmation-panel/ConfirmationPanel.js +1 -1
- package/cjs/form/confirmation-panel/ConfirmationPanel.js.map +1 -1
- package/cjs/form/fieldset/Fieldset.js +1 -1
- package/cjs/form/fieldset/Fieldset.js.map +1 -1
- package/cjs/form/file-upload/parts/dropzone/Dropzone.js +1 -1
- package/cjs/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
- package/cjs/form/search/Search.js +3 -3
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/form/select/Select.js +1 -1
- package/cjs/form/select/Select.js.map +1 -1
- package/cjs/form/switch/Switch.js +1 -7
- package/cjs/form/switch/Switch.js.map +1 -1
- package/cjs/form/textarea/Textarea.js +1 -1
- package/cjs/form/textarea/Textarea.js.map +1 -1
- package/cjs/form/textfield/TextField.js +1 -1
- package/cjs/form/textfield/TextField.js.map +1 -1
- package/cjs/guide-panel/GuidePanel.js +2 -2
- package/cjs/guide-panel/GuidePanel.js.map +1 -1
- package/cjs/help-text/HelpText.js +2 -2
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/internal-header/InternalHeader.js +3 -3
- package/cjs/internal-header/InternalHeader.js.map +1 -1
- package/cjs/layout/base/BasePrimitive.js +2 -2
- package/cjs/layout/base/BasePrimitive.js.map +1 -1
- package/cjs/layout/bleed/Bleed.js +2 -2
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.js +2 -2
- package/cjs/layout/box/Box.js.map +1 -1
- package/cjs/layout/grid/HGrid.js +2 -2
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.js +2 -2
- package/cjs/layout/page/Page.js.map +1 -1
- package/cjs/layout/stack/Stack.js +2 -2
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js +2 -2
- package/cjs/overlays/action-menu/ActionMenu.js.map +1 -1
- package/cjs/pagination/PaginationItem.js +2 -2
- package/cjs/pagination/PaginationItem.js.map +1 -1
- package/cjs/popover/Popover.js +2 -2
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/portal/Portal.js +12 -0
- package/cjs/portal/Portal.js.map +1 -1
- package/cjs/provider/index.d.ts +0 -1
- package/cjs/provider/index.js +1 -4
- package/cjs/provider/index.js.map +1 -1
- package/cjs/read-more/ReadMore.js +1 -3
- package/cjs/read-more/ReadMore.js.map +1 -1
- package/cjs/tabs/Tabs.context.d.ts +1 -1
- package/cjs/tabs/parts/tablist/useScrollButtons.d.ts +1 -1
- package/cjs/theme/Theme.d.ts +16 -0
- package/cjs/{provider/theme/AkselTheme.js → theme/Theme.js} +17 -18
- package/cjs/theme/Theme.js.map +1 -0
- package/cjs/theme/index.d.ts +1 -0
- package/cjs/theme/index.js +7 -0
- package/cjs/theme/index.js.map +1 -0
- package/cjs/timeline/Pin.js +2 -2
- package/cjs/timeline/Pin.js.map +1 -1
- package/cjs/timeline/period/ClickablePeriod.js +2 -2
- package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
- package/cjs/toggle-group/parts/ToggleItem.js +1 -1
- package/cjs/toggle-group/parts/ToggleItem.js.map +1 -1
- package/cjs/tooltip/Tooltip.js +2 -2
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/typography/ErrorMessage.d.ts +4 -0
- package/cjs/typography/ErrorMessage.js +6 -2
- package/cjs/typography/ErrorMessage.js.map +1 -1
- package/cjs/util/TextareaAutoSize.js +1 -1
- package/cjs/util/TextareaAutoSize.js.map +1 -1
- package/cjs/util/debounce.d.ts +2 -2
- package/cjs/util/debounce.js +5 -1
- package/cjs/util/debounce.js.map +1 -1
- package/esm/accordion/AccordionContent.js +2 -2
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +2 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/button/Button.js +10 -26
- package/esm/button/Button.js.map +1 -1
- package/esm/date/datepicker/parts/WeekNumber.js +2 -2
- package/esm/date/datepicker/parts/WeekNumber.js.map +1 -1
- package/esm/date/parts/DateInput.js +1 -1
- package/esm/date/parts/DateInput.js.map +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +1 -1
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/Input/InputController.d.ts +1 -1
- package/esm/form/confirmation-panel/ConfirmationPanel.js +1 -1
- package/esm/form/confirmation-panel/ConfirmationPanel.js.map +1 -1
- package/esm/form/fieldset/Fieldset.js +1 -1
- package/esm/form/fieldset/Fieldset.js.map +1 -1
- package/esm/form/file-upload/parts/dropzone/Dropzone.js +1 -1
- package/esm/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
- package/esm/form/search/Search.js +3 -3
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/select/Select.js +1 -1
- package/esm/form/select/Select.js.map +1 -1
- package/esm/form/switch/Switch.js +1 -7
- package/esm/form/switch/Switch.js.map +1 -1
- package/esm/form/textarea/Textarea.js +1 -1
- package/esm/form/textarea/Textarea.js.map +1 -1
- package/esm/form/textfield/TextField.js +1 -1
- package/esm/form/textfield/TextField.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +2 -2
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/help-text/HelpText.js +2 -2
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/internal-header/InternalHeader.js +3 -3
- package/esm/internal-header/InternalHeader.js.map +1 -1
- package/esm/layout/base/BasePrimitive.js +2 -2
- package/esm/layout/base/BasePrimitive.js.map +1 -1
- package/esm/layout/bleed/Bleed.js +2 -2
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.js +2 -2
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/grid/HGrid.js +2 -2
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.js +2 -2
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/stack/Stack.js +2 -2
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/overlays/action-menu/ActionMenu.js +2 -2
- package/esm/overlays/action-menu/ActionMenu.js.map +1 -1
- package/esm/pagination/PaginationItem.js +2 -2
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/popover/Popover.js +2 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/portal/Portal.js +12 -0
- package/esm/portal/Portal.js.map +1 -1
- package/esm/provider/index.d.ts +0 -1
- package/esm/provider/index.js +0 -1
- package/esm/provider/index.js.map +1 -1
- package/esm/read-more/ReadMore.js +1 -3
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/tabs/Tabs.context.d.ts +1 -1
- package/esm/tabs/parts/tablist/useScrollButtons.d.ts +1 -1
- package/esm/theme/Theme.d.ts +16 -0
- package/esm/theme/Theme.js +21 -0
- package/esm/theme/Theme.js.map +1 -0
- package/esm/theme/index.d.ts +1 -0
- package/esm/theme/index.js +3 -0
- package/esm/theme/index.js.map +1 -0
- package/esm/timeline/Pin.js +2 -2
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.js +2 -2
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/toggle-group/parts/ToggleItem.js +1 -1
- package/esm/toggle-group/parts/ToggleItem.js.map +1 -1
- package/esm/tooltip/Tooltip.js +2 -2
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/ErrorMessage.d.ts +4 -0
- package/esm/typography/ErrorMessage.js +6 -2
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/util/TextareaAutoSize.js +1 -1
- package/esm/util/TextareaAutoSize.js.map +1 -1
- package/esm/util/debounce.d.ts +2 -2
- package/esm/util/debounce.js +5 -1
- package/esm/util/debounce.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/AccordionContent.tsx +2 -2
- package/src/accordion/AccordionHeader.tsx +2 -2
- package/src/button/Button.tsx +20 -50
- package/src/date/datepicker/parts/WeekNumber.tsx +2 -2
- package/src/date/parts/DateInput.tsx +5 -1
- package/src/form/combobox/Combobox.tsx +5 -1
- package/src/form/confirmation-panel/ConfirmationPanel.tsx +5 -1
- package/src/form/fieldset/Fieldset.tsx +3 -1
- package/src/form/file-upload/parts/dropzone/Dropzone.tsx +1 -1
- package/src/form/search/Search.tsx +5 -3
- package/src/form/select/Select.tsx +3 -1
- package/src/form/switch/Switch.tsx +1 -10
- package/src/form/textarea/Textarea.tsx +3 -1
- package/src/form/textfield/TextField.tsx +3 -1
- package/src/guide-panel/GuidePanel.tsx +2 -2
- package/src/help-text/HelpText.tsx +2 -2
- package/src/internal-header/InternalHeader.tsx +4 -4
- package/src/layout/base/BasePrimitive.tsx +2 -2
- package/src/layout/bleed/Bleed.tsx +2 -2
- package/src/layout/box/Box.tsx +2 -2
- package/src/layout/grid/HGrid.tsx +2 -2
- package/src/layout/page/Page.tsx +2 -2
- package/src/layout/stack/Stack.tsx +2 -2
- package/src/overlays/action-menu/ActionMenu.tsx +2 -2
- package/src/pagination/PaginationItem.tsx +2 -2
- package/src/popover/Popover.tsx +2 -2
- package/src/portal/Portal.tsx +17 -0
- package/src/provider/index.ts +0 -4
- package/src/read-more/ReadMore.tsx +1 -4
- package/src/theme/Theme.tsx +60 -0
- package/src/theme/index.ts +2 -0
- package/src/timeline/Pin.tsx +2 -2
- package/src/timeline/period/ClickablePeriod.tsx +2 -2
- package/src/toggle-group/parts/ToggleItem.tsx +1 -0
- package/src/tooltip/Tooltip.tsx +2 -2
- package/src/typography/ErrorMessage.tsx +36 -2
- package/src/util/TextareaAutoSize.tsx +15 -11
- package/src/util/debounce.ts +11 -3
- package/cjs/provider/theme/AkselTheme.d.ts +0 -22
- package/cjs/provider/theme/AkselTheme.js.map +0 -1
- package/esm/provider/theme/AkselTheme.d.ts +0 -22
- package/esm/provider/theme/AkselTheme.js +0 -22
- package/esm/provider/theme/AkselTheme.js.map +0 -1
- package/src/provider/theme/AkselTheme.tsx +0 -70
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { Slot } from "../slot/Slot";
|
|
4
|
+
import { createContext } from "../util/create-context";
|
|
5
|
+
import { AsChildProps } from "../util/types";
|
|
6
|
+
|
|
7
|
+
type ThemeContext = {
|
|
8
|
+
/**
|
|
9
|
+
* Color theme
|
|
10
|
+
* @default "light"
|
|
11
|
+
*/
|
|
12
|
+
theme: "light" | "dark";
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const [ThemeProvider, useThemeInternal] = createContext<ThemeContext>({
|
|
16
|
+
hookName: "useTheme",
|
|
17
|
+
name: "ThemeProvider",
|
|
18
|
+
providerName: "ThemeProvider",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type ThemeProps = {
|
|
22
|
+
className?: string;
|
|
23
|
+
hasBackground?: boolean;
|
|
24
|
+
} & ThemeContext &
|
|
25
|
+
AsChildProps;
|
|
26
|
+
|
|
27
|
+
const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
28
|
+
(props: ThemeProps, ref) => {
|
|
29
|
+
const context = useThemeInternal(false);
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
asChild = false,
|
|
35
|
+
theme = context?.theme ?? "light",
|
|
36
|
+
hasBackground: hasBackgroundProp = true,
|
|
37
|
+
} = props;
|
|
38
|
+
|
|
39
|
+
const isRoot = context === undefined;
|
|
40
|
+
|
|
41
|
+
const hasBackground =
|
|
42
|
+
hasBackgroundProp ?? (isRoot && props.theme !== undefined);
|
|
43
|
+
|
|
44
|
+
const SlotElement = asChild ? Slot : "div";
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<ThemeProvider theme={theme}>
|
|
48
|
+
<SlotElement
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cl("navds-theme", className, theme)}
|
|
51
|
+
data-background={hasBackground}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</SlotElement>
|
|
55
|
+
</ThemeProvider>
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export { Theme, useThemeInternal };
|
package/src/timeline/Pin.tsx
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "@floating-ui/react";
|
|
16
16
|
import { format } from "date-fns";
|
|
17
17
|
import React, { forwardRef, useRef, useState } from "react";
|
|
18
|
-
import {
|
|
18
|
+
import { useThemeInternal } from "../theme/Theme";
|
|
19
19
|
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
20
20
|
import { useI18n } from "../util/i18n/i18n.context";
|
|
21
21
|
import { useTimelineContext } from "./hooks/useTimelineContext";
|
|
@@ -48,7 +48,7 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
|
|
|
48
48
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
49
49
|
const translate = useI18n("Timeline");
|
|
50
50
|
|
|
51
|
-
const themeContext =
|
|
51
|
+
const themeContext = useThemeInternal(false);
|
|
52
52
|
const showArrow = !themeContext;
|
|
53
53
|
|
|
54
54
|
const {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "@floating-ui/react";
|
|
16
16
|
import cl from "clsx";
|
|
17
17
|
import React, { useRef, useState } from "react";
|
|
18
|
-
import {
|
|
18
|
+
import { useThemeInternal } from "../../theme/Theme";
|
|
19
19
|
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
20
20
|
import { useI18n } from "../../util/i18n/i18n.context";
|
|
21
21
|
import { usePeriodContext } from "../hooks/usePeriodContext";
|
|
@@ -56,7 +56,7 @@ const ClickablePeriod = React.memo(
|
|
|
56
56
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
57
57
|
const translate = useI18n("Timeline");
|
|
58
58
|
|
|
59
|
-
const themeContext =
|
|
59
|
+
const themeContext = useThemeInternal(false);
|
|
60
60
|
const showArrow = !themeContext;
|
|
61
61
|
|
|
62
62
|
const {
|
|
@@ -76,6 +76,7 @@ const ToggleItem = forwardRef<HTMLButtonElement, ToggleGroupItemProps>(
|
|
|
76
76
|
type="button"
|
|
77
77
|
role="radio"
|
|
78
78
|
aria-checked={itemCtx.isSelected}
|
|
79
|
+
data-selected={itemCtx.isSelected}
|
|
79
80
|
tabIndex={itemCtx.isFocused ? 0 : -1}
|
|
80
81
|
onClick={itemCtx.onClick}
|
|
81
82
|
onFocus={itemCtx.onFocus}
|
package/src/tooltip/Tooltip.tsx
CHANGED
|
@@ -15,8 +15,8 @@ import cl from "clsx";
|
|
|
15
15
|
import React, { HTMLAttributes, forwardRef, useRef } from "react";
|
|
16
16
|
import { useModalContext } from "../modal/Modal.context";
|
|
17
17
|
import { Portal } from "../portal";
|
|
18
|
-
import { UNSAFE_useAkselTheme } from "../provider";
|
|
19
18
|
import { Slot } from "../slot/Slot";
|
|
19
|
+
import { useThemeInternal } from "../theme/Theme";
|
|
20
20
|
import { Detail } from "../typography";
|
|
21
21
|
import { useId } from "../util/hooks";
|
|
22
22
|
import { useControllableState } from "../util/hooks/useControllableState";
|
|
@@ -124,7 +124,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
124
124
|
},
|
|
125
125
|
ref,
|
|
126
126
|
) => {
|
|
127
|
-
const themeContext =
|
|
127
|
+
const themeContext = useThemeInternal(false);
|
|
128
128
|
const showArrow = _arrow && !themeContext;
|
|
129
129
|
|
|
130
130
|
const [_open, _setOpen] = useControllableState({
|
|
@@ -16,6 +16,10 @@ export interface ErrorMessageProps
|
|
|
16
16
|
* Error text.
|
|
17
17
|
*/
|
|
18
18
|
children: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Render a triangular warning icon.
|
|
21
|
+
*/
|
|
22
|
+
showIcon?: boolean;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/**
|
|
@@ -36,7 +40,18 @@ export const ErrorMessage: OverridableComponent<
|
|
|
36
40
|
ErrorMessageProps,
|
|
37
41
|
HTMLParagraphElement
|
|
38
42
|
> = forwardRef(
|
|
39
|
-
(
|
|
43
|
+
(
|
|
44
|
+
{
|
|
45
|
+
children,
|
|
46
|
+
className,
|
|
47
|
+
size,
|
|
48
|
+
spacing,
|
|
49
|
+
as: Component = "p",
|
|
50
|
+
showIcon = false,
|
|
51
|
+
...rest
|
|
52
|
+
},
|
|
53
|
+
ref,
|
|
54
|
+
) => (
|
|
40
55
|
<Component
|
|
41
56
|
{...rest}
|
|
42
57
|
ref={ref}
|
|
@@ -49,9 +64,28 @@ export const ErrorMessage: OverridableComponent<
|
|
|
49
64
|
}),
|
|
50
65
|
{
|
|
51
66
|
"navds-label--small": size === "small",
|
|
67
|
+
"navds-error-message--show-icon": showIcon,
|
|
52
68
|
},
|
|
53
69
|
)}
|
|
54
|
-
|
|
70
|
+
>
|
|
71
|
+
{showIcon && (
|
|
72
|
+
<svg
|
|
73
|
+
viewBox="0 0 17 16"
|
|
74
|
+
fill="none"
|
|
75
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
76
|
+
focusable={false}
|
|
77
|
+
aria-hidden
|
|
78
|
+
>
|
|
79
|
+
<path
|
|
80
|
+
fillRule="evenodd"
|
|
81
|
+
clipRule="evenodd"
|
|
82
|
+
d="M3.49209 11.534L8.11398 2.7594C8.48895 2.04752 9.50833 2.04743 9.88343 2.75924L14.5073 11.5339C14.8582 12.1998 14.3753 13 13.6226 13H4.37685C3.6242 13 3.14132 12.1999 3.49209 11.534ZM9.74855 10.495C9.74855 10.9092 9.41276 11.245 8.99855 11.245C8.58433 11.245 8.24855 10.9092 8.24855 10.495C8.24855 10.0808 8.58433 9.74497 8.99855 9.74497C9.41276 9.74497 9.74855 10.0808 9.74855 10.495ZM9.49988 5.49997C9.49988 5.22383 9.27602 4.99997 8.99988 4.99997C8.72373 4.99997 8.49988 5.22383 8.49988 5.49997V7.99997C8.49988 8.27611 8.72373 8.49997 8.99988 8.49997C9.27602 8.49997 9.49988 8.27611 9.49988 7.99997V5.49997Z"
|
|
83
|
+
fill="currentColor"
|
|
84
|
+
/>
|
|
85
|
+
</svg>
|
|
86
|
+
)}
|
|
87
|
+
{children}
|
|
88
|
+
</Component>
|
|
55
89
|
),
|
|
56
90
|
);
|
|
57
91
|
|
|
@@ -167,19 +167,23 @@ const TextareaAutosize = forwardRef<HTMLTextAreaElement, TextareaAutosizeProps>(
|
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
const handleResize = debounce(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
const handleResize = debounce(
|
|
171
|
+
() => {
|
|
172
|
+
renders.current = 0;
|
|
173
|
+
|
|
174
|
+
if (inputRef.current?.style.height || inputRef.current?.style.width) {
|
|
175
|
+
// User has resized manually
|
|
176
|
+
if (inputRef.current?.style.overflow === "hidden") {
|
|
177
|
+
setState((oldState) => ({ ...oldState, overflow: false })); // The state update isn't important, we just need to trigger a rerender
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
177
180
|
}
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
181
|
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
syncHeightWithFlushSync();
|
|
183
|
+
},
|
|
184
|
+
166,
|
|
185
|
+
true,
|
|
186
|
+
);
|
|
183
187
|
|
|
184
188
|
const input = inputRef.current!;
|
|
185
189
|
const containerWindow = ownerWindow(input);
|
package/src/util/debounce.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
// https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/debounce.js
|
|
3
|
-
export default function debounce
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default function debounce<T extends unknown[]>(
|
|
4
|
+
func: (...args: T) => void,
|
|
5
|
+
wait = 166,
|
|
6
|
+
leading = false,
|
|
7
|
+
) {
|
|
8
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
9
|
+
function debounced(this: any, ...args: T) {
|
|
6
10
|
const later = () => {
|
|
11
|
+
timeout = undefined;
|
|
7
12
|
func.apply(this, args);
|
|
8
13
|
};
|
|
14
|
+
if (!timeout && leading) {
|
|
15
|
+
later();
|
|
16
|
+
}
|
|
9
17
|
clearTimeout(timeout);
|
|
10
18
|
timeout = setTimeout(later, wait);
|
|
11
19
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
type AkselThemeContext = {
|
|
3
|
-
/**
|
|
4
|
-
* Color theme
|
|
5
|
-
* @default "light"
|
|
6
|
-
*/
|
|
7
|
-
theme?: "light" | "dark";
|
|
8
|
-
/**
|
|
9
|
-
* Brand volume
|
|
10
|
-
* @default "low"
|
|
11
|
-
* This is experimental and subject to changes
|
|
12
|
-
*/
|
|
13
|
-
volume?: "high" | "low";
|
|
14
|
-
};
|
|
15
|
-
declare const useAkselTheme: <S extends boolean = true>(strict?: S) => S extends true ? AkselThemeContext : AkselThemeContext | undefined;
|
|
16
|
-
declare const AkselTheme: React.ForwardRefExoticComponent<{
|
|
17
|
-
children: React.ReactNode;
|
|
18
|
-
className?: string;
|
|
19
|
-
hasBackground?: boolean;
|
|
20
|
-
asChild?: boolean;
|
|
21
|
-
} & AkselThemeContext & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
export { AkselTheme, useAkselTheme };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AkselTheme.js","sourceRoot":"","sources":["../../../src/provider/theme/AkselTheme.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAsB;AACtB,+CAA0C;AAC1C,0CAAuC;AACvC,8DAA0D;AAgB1D,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,GAAG,IAAA,8BAAa,EAAoB;IACtE,YAAY,EAAE,sDAAsD;IACpE,QAAQ,EAAE,eAAe;IACzB,IAAI,EAAE,oBAAoB;IAC1B,YAAY,EAAE,oBAAoB;CACnC,CAAC,CAAC;AA6CkB,sCAAa;AAnClC,MAAM,UAAU,GAAG,IAAA,kBAAU,EAC3B,CAAC,KAAsB,EAAE,GAAG,EAAE,EAAE;;IAC9B,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAErC,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,KAAK,EACf,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,OAAO,EACjC,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,KAAK,EACjC,aAAa,EAAE,iBAAiB,GAAG,IAAI,GACxC,GAAG,KAAK,CAAC;IAEV,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC;IAErC,MAAM,aAAa,GACjB,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAE7D,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,WAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAE3C,OAAO,CACL,8BAAC,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;QACzC,8BAAC,WAAW,IACV,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,cAAE,EAAC,aAAa,EAAE,SAAS,EAAE,KAAK,CAAC,qBAC7B,aAAa,iBACjB,MAAM,IAElB,QAAQ,CACG,CACA,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEO,gCAAU"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
type AkselThemeContext = {
|
|
3
|
-
/**
|
|
4
|
-
* Color theme
|
|
5
|
-
* @default "light"
|
|
6
|
-
*/
|
|
7
|
-
theme?: "light" | "dark";
|
|
8
|
-
/**
|
|
9
|
-
* Brand volume
|
|
10
|
-
* @default "low"
|
|
11
|
-
* This is experimental and subject to changes
|
|
12
|
-
*/
|
|
13
|
-
volume?: "high" | "low";
|
|
14
|
-
};
|
|
15
|
-
declare const useAkselTheme: <S extends boolean = true>(strict?: S) => S extends true ? AkselThemeContext : AkselThemeContext | undefined;
|
|
16
|
-
declare const AkselTheme: React.ForwardRefExoticComponent<{
|
|
17
|
-
children: React.ReactNode;
|
|
18
|
-
className?: string;
|
|
19
|
-
hasBackground?: boolean;
|
|
20
|
-
asChild?: boolean;
|
|
21
|
-
} & AkselThemeContext & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
export { AkselTheme, useAkselTheme };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import cl from "clsx";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import { Slot } from "../../slot/Slot.js";
|
|
4
|
-
import { createContext } from "../../util/create-context.js";
|
|
5
|
-
const [ThemeProvider, useAkselTheme] = createContext({
|
|
6
|
-
errorMessage: "useAkselTheme must be used within AkselThemeProvider",
|
|
7
|
-
hookName: "useAkselTheme",
|
|
8
|
-
name: "AkselThemeProvider",
|
|
9
|
-
providerName: "AkselThemeProvider",
|
|
10
|
-
});
|
|
11
|
-
const AkselTheme = forwardRef((props, ref) => {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
const context = useAkselTheme(false);
|
|
14
|
-
const { children, className, asChild = false, theme = (_a = context === null || context === void 0 ? void 0 : context.theme) !== null && _a !== void 0 ? _a : "light", volume = (_b = context === null || context === void 0 ? void 0 : context.volume) !== null && _b !== void 0 ? _b : "low", hasBackground: hasBackgroundProp = true, } = props;
|
|
15
|
-
const isRoot = context === undefined;
|
|
16
|
-
const hasBackground = hasBackgroundProp !== null && hasBackgroundProp !== void 0 ? hasBackgroundProp : (isRoot || props.theme !== undefined);
|
|
17
|
-
const SlotElement = asChild ? Slot : "div";
|
|
18
|
-
return (React.createElement(ThemeProvider, { theme: theme, volume: volume },
|
|
19
|
-
React.createElement(SlotElement, { ref: ref, className: cl("navds-theme", className, theme), "data-background": hasBackground, "data-volume": volume }, children)));
|
|
20
|
-
});
|
|
21
|
-
export { AkselTheme, useAkselTheme };
|
|
22
|
-
//# sourceMappingURL=AkselTheme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AkselTheme.js","sourceRoot":"","sources":["../../../src/provider/theme/AkselTheme.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAgB1D,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,GAAG,aAAa,CAAoB;IACtE,YAAY,EAAE,sDAAsD;IACpE,QAAQ,EAAE,eAAe;IACzB,IAAI,EAAE,oBAAoB;IAC1B,YAAY,EAAE,oBAAoB;CACnC,CAAC,CAAC;AAUH,MAAM,UAAU,GAAG,UAAU,CAC3B,CAAC,KAAsB,EAAE,GAAG,EAAE,EAAE;;IAC9B,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAErC,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,KAAK,EACf,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,OAAO,EACjC,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,KAAK,EACjC,aAAa,EAAE,iBAAiB,GAAG,IAAI,GACxC,GAAG,KAAK,CAAC;IAEV,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC;IAErC,MAAM,aAAa,GACjB,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAE7D,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAE3C,OAAO,CACL,oBAAC,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;QACzC,oBAAC,WAAW,IACV,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,CAAC,qBAC7B,aAAa,iBACjB,MAAM,IAElB,QAAQ,CACG,CACA,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import cl from "clsx";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import { Slot } from "../../slot/Slot";
|
|
4
|
-
import { createContext } from "../../util/create-context";
|
|
5
|
-
|
|
6
|
-
type AkselThemeContext = {
|
|
7
|
-
/**
|
|
8
|
-
* Color theme
|
|
9
|
-
* @default "light"
|
|
10
|
-
*/
|
|
11
|
-
theme?: "light" | "dark";
|
|
12
|
-
/**
|
|
13
|
-
* Brand volume
|
|
14
|
-
* @default "low"
|
|
15
|
-
* This is experimental and subject to changes
|
|
16
|
-
*/
|
|
17
|
-
volume?: "high" | "low";
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const [ThemeProvider, useAkselTheme] = createContext<AkselThemeContext>({
|
|
21
|
-
errorMessage: "useAkselTheme must be used within AkselThemeProvider",
|
|
22
|
-
hookName: "useAkselTheme",
|
|
23
|
-
name: "AkselThemeProvider",
|
|
24
|
-
providerName: "AkselThemeProvider",
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
type AkselThemeProps = {
|
|
28
|
-
children: React.ReactNode;
|
|
29
|
-
className?: string;
|
|
30
|
-
hasBackground?: boolean;
|
|
31
|
-
/* TODO: Handle this correctly with types */
|
|
32
|
-
asChild?: boolean;
|
|
33
|
-
} & AkselThemeContext;
|
|
34
|
-
|
|
35
|
-
const AkselTheme = forwardRef<HTMLDivElement, AkselThemeProps>(
|
|
36
|
-
(props: AkselThemeProps, ref) => {
|
|
37
|
-
const context = useAkselTheme(false);
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
children,
|
|
41
|
-
className,
|
|
42
|
-
asChild = false,
|
|
43
|
-
theme = context?.theme ?? "light",
|
|
44
|
-
volume = context?.volume ?? "low",
|
|
45
|
-
hasBackground: hasBackgroundProp = true,
|
|
46
|
-
} = props;
|
|
47
|
-
|
|
48
|
-
const isRoot = context === undefined;
|
|
49
|
-
|
|
50
|
-
const hasBackground =
|
|
51
|
-
hasBackgroundProp ?? (isRoot || props.theme !== undefined);
|
|
52
|
-
|
|
53
|
-
const SlotElement = asChild ? Slot : "div";
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<ThemeProvider theme={theme} volume={volume}>
|
|
57
|
-
<SlotElement
|
|
58
|
-
ref={ref}
|
|
59
|
-
className={cl("navds-theme", className, theme)}
|
|
60
|
-
data-background={hasBackground}
|
|
61
|
-
data-volume={volume}
|
|
62
|
-
>
|
|
63
|
-
{children}
|
|
64
|
-
</SlotElement>
|
|
65
|
-
</ThemeProvider>
|
|
66
|
-
);
|
|
67
|
-
},
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
export { AkselTheme, useAkselTheme };
|