@norges-domstoler/dds-components 0.0.0-dev-20260924115410 → 0.0.0-dev-20260929100812
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/index.cjs +104 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +42 -9
- package/dist/index.d.cts +62 -17
- package/dist/index.d.mts +62 -17
- package/dist/index.mjs +104 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1189,7 +1189,7 @@ const BORDER_RADII = [
|
|
|
1189
1189
|
"button",
|
|
1190
1190
|
"input",
|
|
1191
1191
|
"surface",
|
|
1192
|
-
"
|
|
1192
|
+
"tag",
|
|
1193
1193
|
"rounded",
|
|
1194
1194
|
"0"
|
|
1195
1195
|
];
|
|
@@ -1621,7 +1621,7 @@ var Paper_module_default = {
|
|
|
1621
1621
|
var surface_module_default = {
|
|
1622
1622
|
"border-radius--button": "dds-surface-module__border-radius--button",
|
|
1623
1623
|
"border-radius--surface": "dds-surface-module__border-radius--surface",
|
|
1624
|
-
"border-radius--
|
|
1624
|
+
"border-radius--tag": "dds-surface-module__border-radius--tag",
|
|
1625
1625
|
"border-radius--input": "dds-surface-module__border-radius--input",
|
|
1626
1626
|
"border-radius--rounded": "dds-surface-module__border-radius--rounded",
|
|
1627
1627
|
"border-radius--0": "dds-surface-module__border-radius--0"
|
|
@@ -1708,6 +1708,59 @@ var DropdownItem_module_default = {
|
|
|
1708
1708
|
"item--loading": "dds-DropdownItem-module__item--loading"
|
|
1709
1709
|
};
|
|
1710
1710
|
//#endregion
|
|
1711
|
+
//#region src/components/Badge/Badge.module.css
|
|
1712
|
+
var Badge_module_default = {
|
|
1713
|
+
"container": "dds-Badge-module__container",
|
|
1714
|
+
"notification": "dds-Badge-module__notification",
|
|
1715
|
+
"action": "dds-Badge-module__action",
|
|
1716
|
+
"neutral": "dds-Badge-module__neutral",
|
|
1717
|
+
"subtle": "dds-Badge-module__subtle"
|
|
1718
|
+
};
|
|
1719
|
+
const Badge = ({ id, className, style, htmlProps, purpose = "notification", size = "medium", children, max = 9, showZero = false, ...rest }) => {
|
|
1720
|
+
const hasChildren = !!children || showZero && children === 0;
|
|
1721
|
+
const heightVariant = hasChildren ? "withChildren" : "noChildren";
|
|
1722
|
+
const height = {
|
|
1723
|
+
withChildren: {
|
|
1724
|
+
xsmall: "18px",
|
|
1725
|
+
small: "21px",
|
|
1726
|
+
medium: "24px",
|
|
1727
|
+
large: "27px"
|
|
1728
|
+
},
|
|
1729
|
+
noChildren: {
|
|
1730
|
+
xsmall: "x0.5",
|
|
1731
|
+
small: "x0.75",
|
|
1732
|
+
medium: "x1",
|
|
1733
|
+
large: "x1.5"
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
const color = {
|
|
1737
|
+
notification: "text-on-notification",
|
|
1738
|
+
action: "text-on-action",
|
|
1739
|
+
neutral: "text-on-inverse",
|
|
1740
|
+
subtle: "text-default"
|
|
1741
|
+
};
|
|
1742
|
+
const displayValue = hasChildren && max && children > max ? `${max}+` : children;
|
|
1743
|
+
if (!(!showZero && children === 0 ? false : true)) return null;
|
|
1744
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Box, {
|
|
1745
|
+
as: "span",
|
|
1746
|
+
paddingInline: hasChildren ? "x0.25" : void 0,
|
|
1747
|
+
minWidth: height[heightVariant][size],
|
|
1748
|
+
maxWidth: "fit-content",
|
|
1749
|
+
height: height[heightVariant][size],
|
|
1750
|
+
display: "inline-flex",
|
|
1751
|
+
alignItems: "center",
|
|
1752
|
+
justifyContent: "center",
|
|
1753
|
+
...getBaseHTMLProps(id, cn(className, Badge_module_default.container, Badge_module_default[purpose], typographyStyles_module_default[`body-short-${size}`]), style, htmlProps, rest),
|
|
1754
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Typography, {
|
|
1755
|
+
as: "span",
|
|
1756
|
+
typographyType: `body-short-${size}`,
|
|
1757
|
+
color: color[purpose],
|
|
1758
|
+
children: displayValue
|
|
1759
|
+
})
|
|
1760
|
+
});
|
|
1761
|
+
};
|
|
1762
|
+
Badge.displayName = "Badge";
|
|
1763
|
+
//#endregion
|
|
1711
1764
|
//#region src/components/Icon/Icon.tsx
|
|
1712
1765
|
const getSize = (iconSize) => {
|
|
1713
1766
|
switch (iconSize) {
|
|
@@ -1893,7 +1946,7 @@ var focus_module_default = {
|
|
|
1893
1946
|
};
|
|
1894
1947
|
//#endregion
|
|
1895
1948
|
//#region src/components/helpers/Dropdown/DropdownItem.tsx
|
|
1896
|
-
const DropdownItem = ({ icon, className, children: propChildren, purpose = "default", loading, loadingTooltip, ...rest }) => {
|
|
1949
|
+
const DropdownItem = ({ icon, className, children: propChildren, purpose = "default", loading, loadingTooltip, badgeProps, ...rest }) => {
|
|
1897
1950
|
const itemCns = [
|
|
1898
1951
|
DropdownItem_module_default.item,
|
|
1899
1952
|
DropdownItem_module_default[purpose],
|
|
@@ -1931,7 +1984,13 @@ const DropdownItem = ({ icon, className, children: propChildren, purpose = "defa
|
|
|
1931
1984
|
icon,
|
|
1932
1985
|
className: cn(loading && utilStyles_module_default.invisible)
|
|
1933
1986
|
}),
|
|
1934
|
-
children
|
|
1987
|
+
children,
|
|
1988
|
+
badgeProps && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Box, {
|
|
1989
|
+
as: Badge,
|
|
1990
|
+
...badgeProps,
|
|
1991
|
+
size: "small",
|
|
1992
|
+
marginInline: "x0.25 0"
|
|
1993
|
+
})
|
|
1935
1994
|
]
|
|
1936
1995
|
});
|
|
1937
1996
|
};
|
|
@@ -4720,7 +4779,8 @@ var Button_module_default = {
|
|
|
4720
4779
|
"button--primary": "dds-Button-module__button--primary",
|
|
4721
4780
|
"button--secondary": "dds-Button-module__button--secondary",
|
|
4722
4781
|
"button--tertiary": "dds-Button-module__button--tertiary",
|
|
4723
|
-
"button--danger": "dds-Button-module__button--danger"
|
|
4782
|
+
"button--danger": "dds-Button-module__button--danger",
|
|
4783
|
+
"badge": "dds-Button-module__badge"
|
|
4724
4784
|
};
|
|
4725
4785
|
//#endregion
|
|
4726
4786
|
//#region src/components/ButtonGroup/ButtonGroup.context.tsx
|
|
@@ -4728,7 +4788,7 @@ const ButtonGroupContext = (0, react.createContext)({});
|
|
|
4728
4788
|
const useButtonGroupContext = () => (0, react.useContext)(ButtonGroupContext);
|
|
4729
4789
|
//#endregion
|
|
4730
4790
|
//#region src/components/Button/Button.tsx
|
|
4731
|
-
const Button = ({ as: propAs, children, purpose = "primary", size: propSize = "medium", iconPosition = "left", loading, loadingTooltip, fullWidth = false, icon, iconState, onClick, onFocus, onBlur, id, ref, className, style, htmlProps, ...props }) => {
|
|
4791
|
+
const Button = ({ as: propAs, children, purpose = "primary", size: propSize = "medium", iconPosition = "left", loading, loadingTooltip, fullWidth = false, icon, iconState, onClick, onFocus, onBlur, badgeProps, id, ref, className, style, htmlProps, ...props }) => {
|
|
4732
4792
|
const { purpose: groupPurpose, size: groupSize } = useButtonGroupContext();
|
|
4733
4793
|
const { t } = useTranslation();
|
|
4734
4794
|
const spinnerTooltip = loadingTooltip ?? t(texts$28.saving);
|
|
@@ -4771,7 +4831,7 @@ const Button = ({ as: propAs, children, purpose = "primary", size: propSize = "m
|
|
|
4771
4831
|
const isDisabled = (restDisabled ?? htmlDisabled ?? loading) === true;
|
|
4772
4832
|
const as = propAs ? propAs : "button";
|
|
4773
4833
|
const aProps = as === "a" ? { rel: "noopener noreferrer" } : {};
|
|
4774
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
4834
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ElementAs, {
|
|
4775
4835
|
as,
|
|
4776
4836
|
ref,
|
|
4777
4837
|
...getBaseHTMLProps(id, buttonCn, style, htmlProps, restFinal),
|
|
@@ -4780,7 +4840,11 @@ const Button = ({ as: propAs, children, purpose = "primary", size: propSize = "m
|
|
|
4780
4840
|
onBlur,
|
|
4781
4841
|
disabled: isDisabled,
|
|
4782
4842
|
...aProps,
|
|
4783
|
-
children: content
|
|
4843
|
+
children: [content, badgeProps && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Badge, {
|
|
4844
|
+
...badgeProps,
|
|
4845
|
+
size,
|
|
4846
|
+
className: cn(Button_module_default.badge, badgeProps.className)
|
|
4847
|
+
})]
|
|
4784
4848
|
});
|
|
4785
4849
|
};
|
|
4786
4850
|
Button.displayName = "Button";
|
|
@@ -5827,7 +5891,7 @@ const Chip = ({ children, onClose, id, className, style, htmlProps = {}, ...rest
|
|
|
5827
5891
|
maxWidth: "100%",
|
|
5828
5892
|
gap: "x0.125",
|
|
5829
5893
|
padding: "x0.25 0 x0.25 x0.5",
|
|
5830
|
-
borderRadius: "
|
|
5894
|
+
borderRadius: "rounded",
|
|
5831
5895
|
border: "border-subtle",
|
|
5832
5896
|
background: "surface-subtle",
|
|
5833
5897
|
...getBaseHTMLProps(id, cn(className, typographyStyles_module_default["body-short-medium"]), style, restHTMLprops, rest),
|
|
@@ -12762,7 +12826,8 @@ var Tabs_module_default = {
|
|
|
12762
12826
|
"tab--medium--column": "dds-Tabs-module__tab--medium--column",
|
|
12763
12827
|
"tab--small--column": "dds-Tabs-module__tab--small--column",
|
|
12764
12828
|
"tab--row": "dds-Tabs-module__tab--row",
|
|
12765
|
-
"tab--column": "dds-Tabs-module__tab--column"
|
|
12829
|
+
"tab--column": "dds-Tabs-module__tab--column",
|
|
12830
|
+
"tab--column__badge": "dds-Tabs-module__tab--column__badge"
|
|
12766
12831
|
};
|
|
12767
12832
|
//#endregion
|
|
12768
12833
|
//#region src/components/Tabs/TabWidthContext.tsx
|
|
@@ -12849,7 +12914,7 @@ const Tabs = ({ id, activeTab, onChange, tabContentDirection = "row", size = "sm
|
|
|
12849
12914
|
Tabs.displayName = "Tabs";
|
|
12850
12915
|
//#endregion
|
|
12851
12916
|
//#region src/components/Tabs/Tab.tsx
|
|
12852
|
-
const Tab = ({ active = false, icon, children, focus, setFocus, index, onClick, onKeyDown, id, className, htmlProps = {}, style, width = "1fr", ref, ...rest }) => {
|
|
12917
|
+
const Tab = ({ active = false, icon, children, focus, setFocus, index, onClick, onKeyDown, id, className, htmlProps = {}, style, width = "1fr", ref, badgeProps, ...rest }) => {
|
|
12853
12918
|
useSetTabWidth(index, width);
|
|
12854
12919
|
const itemRef = (0, react.useRef)(null);
|
|
12855
12920
|
const combinedRef = useCombinedRef(ref, itemRef);
|
|
@@ -12873,6 +12938,32 @@ const Tab = ({ active = false, icon, children, focus, setFocus, index, onClick,
|
|
|
12873
12938
|
handleSelect();
|
|
12874
12939
|
onKeyDown?.(e);
|
|
12875
12940
|
};
|
|
12941
|
+
const badgeSize = {
|
|
12942
|
+
small: "xsmall",
|
|
12943
|
+
medium: "small"
|
|
12944
|
+
};
|
|
12945
|
+
const hasIcon = !!icon;
|
|
12946
|
+
const hasVerticalBadge = badgeProps && !!badgeProps?.children === false && tabContentDirection === "column" && hasIcon;
|
|
12947
|
+
const hasHorizontalBadge = badgeProps && !hasVerticalBadge;
|
|
12948
|
+
const content = hasHorizontalBadge && tabContentDirection === "row" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Box, {
|
|
12949
|
+
as: Badge,
|
|
12950
|
+
...badgeProps,
|
|
12951
|
+
size: badgeSize[size]
|
|
12952
|
+
})] }) : hasHorizontalBadge && tabContentDirection === "column" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
|
|
12953
|
+
gap: "x0.5",
|
|
12954
|
+
children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Box, {
|
|
12955
|
+
as: Badge,
|
|
12956
|
+
...badgeProps,
|
|
12957
|
+
size: badgeSize[size]
|
|
12958
|
+
})]
|
|
12959
|
+
}) : hasVerticalBadge ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Box, {
|
|
12960
|
+
as: Badge,
|
|
12961
|
+
...badgeProps,
|
|
12962
|
+
size: badgeSize[size],
|
|
12963
|
+
className: cn(Tabs_module_default["tab--column__badge"], badgeProps?.className),
|
|
12964
|
+
top: "x0.125",
|
|
12965
|
+
right: "calc(50% - (var(--dds-size-icon-component) / 2 ))"
|
|
12966
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children });
|
|
12876
12967
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
12877
12968
|
...getBaseHTMLProps(id, cn(className, Tabs_module_default.tab, Tabs_module_default[`tab--${size}--${tabContentDirection}`], active && Tabs_module_default["tab--active"], Tabs_module_default[`tab--${tabContentDirection}`], typographyStyles_module_default[`body-short-${size}`], focus_module_default["focusable--inset"]), style, fixedHtmlProps, rest),
|
|
12878
12969
|
ref: combinedRef,
|
|
@@ -12884,7 +12975,7 @@ const Tab = ({ active = false, icon, children, focus, setFocus, index, onClick,
|
|
|
12884
12975
|
children: [icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
12885
12976
|
icon,
|
|
12886
12977
|
iconSize: "component"
|
|
12887
|
-
}),
|
|
12978
|
+
}), content]
|
|
12888
12979
|
});
|
|
12889
12980
|
};
|
|
12890
12981
|
Tab.displayName = "Tab";
|
|
@@ -13355,6 +13446,7 @@ exports.BORDER_COLORS = BORDER_COLORS;
|
|
|
13355
13446
|
exports.BORDER_RADII = BORDER_RADII;
|
|
13356
13447
|
exports.BackLink = BackLink;
|
|
13357
13448
|
exports.Backdrop = Backdrop;
|
|
13449
|
+
exports.Badge = Badge;
|
|
13358
13450
|
exports.BarChartBoxedIcon = BarChartBoxedIcon;
|
|
13359
13451
|
exports.BarChartIcon = BarChartIcon;
|
|
13360
13452
|
exports.Bleed = Bleed;
|