@norges-domstoler/dds-components 0.0.0-dev-20240226121339 → 0.0.0-dev-20240227092921

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.d.mts CHANGED
@@ -1527,8 +1527,20 @@ declare const BackLink: react.ForwardRefExoticComponent<BackLinkProps & react.Re
1527
1527
  type BreadcrumbProps = HTMLAttributes<HTMLSpanElement> | AnchorHTMLAttributes<HTMLAnchorElement>;
1528
1528
  declare const Breadcrumb: react.ForwardRefExoticComponent<BreadcrumbProps & react.RefAttributes<HTMLElement>>;
1529
1529
 
1530
- type BreadcrumbsProps = BaseComponentPropsWithChildren<HTMLElement>;
1531
- declare const Breadcrumbs: react.ForwardRefExoticComponent<Pick<react.HTMLAttributes<HTMLElement>, "className" | "id"> & object & {
1530
+ type BreadcrumbsProps = BaseComponentPropsWithChildren<HTMLElement, {
1531
+ /**
1532
+ * Om variant for mindre skjerm skal vises.
1533
+ * Trunkerer barn unntatt første og siste; trunkerte barn er tigjengelige ved å trykke på trukeringsknappen.
1534
+ */
1535
+ smallScreen?: boolean;
1536
+ }>;
1537
+ declare const Breadcrumbs: react.ForwardRefExoticComponent<Pick<react.HTMLAttributes<HTMLElement>, "className" | "id"> & {
1538
+ /**
1539
+ * Om variant for mindre skjerm skal vises.
1540
+ * Trunkerer barn unntatt første og siste; trunkerte barn er tigjengelige ved å trykke på trukeringsknappen.
1541
+ */
1542
+ smallScreen?: boolean | undefined;
1543
+ } & {
1532
1544
  children?: react.ReactNode;
1533
1545
  } & {
1534
1546
  htmlProps?: react.HTMLAttributes<HTMLElement> | undefined;
package/dist/index.d.ts CHANGED
@@ -1527,8 +1527,20 @@ declare const BackLink: react.ForwardRefExoticComponent<BackLinkProps & react.Re
1527
1527
  type BreadcrumbProps = HTMLAttributes<HTMLSpanElement> | AnchorHTMLAttributes<HTMLAnchorElement>;
1528
1528
  declare const Breadcrumb: react.ForwardRefExoticComponent<BreadcrumbProps & react.RefAttributes<HTMLElement>>;
1529
1529
 
1530
- type BreadcrumbsProps = BaseComponentPropsWithChildren<HTMLElement>;
1531
- declare const Breadcrumbs: react.ForwardRefExoticComponent<Pick<react.HTMLAttributes<HTMLElement>, "className" | "id"> & object & {
1530
+ type BreadcrumbsProps = BaseComponentPropsWithChildren<HTMLElement, {
1531
+ /**
1532
+ * Om variant for mindre skjerm skal vises.
1533
+ * Trunkerer barn unntatt første og siste; trunkerte barn er tigjengelige ved å trykke på trukeringsknappen.
1534
+ */
1535
+ smallScreen?: boolean;
1536
+ }>;
1537
+ declare const Breadcrumbs: react.ForwardRefExoticComponent<Pick<react.HTMLAttributes<HTMLElement>, "className" | "id"> & {
1538
+ /**
1539
+ * Om variant for mindre skjerm skal vises.
1540
+ * Trunkerer barn unntatt første og siste; trunkerte barn er tigjengelige ved å trykke på trukeringsknappen.
1541
+ */
1542
+ smallScreen?: boolean | undefined;
1543
+ } & {
1532
1544
  children?: react.ReactNode;
1533
1545
  } & {
1534
1546
  htmlProps?: react.HTMLAttributes<HTMLElement> | undefined;
package/dist/index.js CHANGED
@@ -5337,7 +5337,10 @@ var icon2 = {
5337
5337
  color: colors12.DdsColorInteractiveBase
5338
5338
  };
5339
5339
  var listItem = {
5340
- gap: spacing11.SizesDdsSpacingX05
5340
+ gap: spacing11.SizesDdsSpacingX05,
5341
+ notSmallScreen: {
5342
+ padding: `${spacing11.SizesDdsSpacingX0125} 0`
5343
+ }
5341
5344
  };
5342
5345
  var list = {
5343
5346
  gap: spacing11.SizesDdsSpacingX05
@@ -5359,11 +5362,14 @@ var List = import_styled_components26.default.ol`
5359
5362
  gap: ${list2.gap};
5360
5363
  `;
5361
5364
  List.displayName = "List";
5362
- var ListItem = import_styled_components26.default.li`
5365
+ var ListItem = import_styled_components26.default.li.withConfig({
5366
+ shouldForwardProp: (prop) => prop !== "smallScreen"
5367
+ })`
5363
5368
  align-items: center;
5364
5369
  display: flex;
5365
5370
  gap: ${listItem2.gap};
5366
5371
  ${getFontStyling(typographyType2)}
5372
+ padding: ${({ smallScreen }) => smallScreen ? "0" : listItem2.notSmallScreen.padding};
5367
5373
  `;
5368
5374
  ListItem.displayName = "ListItem";
5369
5375
  var StyledIcon = (0, import_styled_components26.default)(Icon)`
@@ -5371,21 +5377,51 @@ var StyledIcon = (0, import_styled_components26.default)(Icon)`
5371
5377
  `;
5372
5378
  var Breadcrumbs = (0, import_react30.forwardRef)(
5373
5379
  (props, ref) => {
5374
- const { children, id, className, htmlProps, ...rest } = props;
5380
+ const { children, smallScreen, id, className, htmlProps, ...rest } = props;
5381
+ const chevronIcon = /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(StyledIcon, { iconSize: "inherit", icon: ChevronRightIcon });
5375
5382
  const childrenArray = import_react30.Children.toArray(children);
5376
5383
  const breadcrumbChildren = childrenArray.map((item, index) => {
5377
- return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(ListItem, { children: [
5378
- index !== 0 && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(StyledIcon, { icon: ChevronRightIcon }),
5384
+ return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(ListItem, { smallScreen, children: [
5385
+ index !== 0 && chevronIcon,
5379
5386
  item
5380
5387
  ] }, `breadcrumb-${index}`);
5381
5388
  });
5389
+ const breadcrumbChildrenTruncated = childrenArray.length > 2 ? childrenArray.slice(1, childrenArray.length - 1).map((item) => {
5390
+ if ((0, import_react30.isValidElement)(item))
5391
+ return {
5392
+ title: item.props.children,
5393
+ href: item.props.href
5394
+ };
5395
+ }).filter((item) => item) : [];
5396
+ const breadcrumbChildrenSmallScreen = /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_jsx_runtime184.Fragment, { children: [
5397
+ /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(ListItem, { smallScreen, children: childrenArray[0] }),
5398
+ breadcrumbChildrenTruncated.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(ListItem, { smallScreen, children: [
5399
+ chevronIcon,
5400
+ /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(OverflowMenuGroup, { children: [
5401
+ /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
5402
+ Button,
5403
+ {
5404
+ size: "tiny",
5405
+ icon: MoreHorizontalIcon,
5406
+ appearance: "borderless",
5407
+ "aria-label": `Vis br\xF8dsmulesti br\xF8dsmule 2 ${breadcrumbChildrenTruncated.length > 1 && `til ${breadcrumbChildren.length - 1}`}`
5408
+ }
5409
+ ),
5410
+ /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(OverflowMenu, { items: breadcrumbChildrenTruncated })
5411
+ ] })
5412
+ ] }),
5413
+ /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(ListItem, { smallScreen, children: [
5414
+ chevronIcon,
5415
+ childrenArray[childrenArray.length - 1]
5416
+ ] })
5417
+ ] });
5382
5418
  return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
5383
5419
  "nav",
5384
5420
  {
5385
5421
  ...getBaseHTMLProps(id, className, htmlProps, rest),
5386
5422
  ref,
5387
5423
  "aria-label": "br\xF8dsmulesti",
5388
- children: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(List, { children: breadcrumbChildren })
5424
+ children: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(List, { children: smallScreen ? breadcrumbChildrenSmallScreen : breadcrumbChildren })
5389
5425
  }
5390
5426
  );
5391
5427
  }