@norges-domstoler/dds-components 22.8.2 → 22.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/dist/index.d.mts CHANGED
@@ -3537,9 +3537,11 @@ type HeadingProps = BaseComponentPropsWithChildren<HTMLHeadingElement, {
3537
3537
  level: HeadingLevel;
3538
3538
  /**Spesifiserer typografistil basert på utvalget for HTML heading elementer. */
3539
3539
  typographyType?: TypographyHeadingType;
3540
+ /**Setter standard spacing for `<Heading>` som er over et inputelement. */
3541
+ withMarginsOverInput?: boolean;
3540
3542
  } & BaseTypographyProps, Omit<HTMLAttributes<HTMLHeadingElement>, 'color'>>;
3541
3543
  declare const Heading: {
3542
- ({ id, className, style, htmlProps, children, typographyType, level, ...rest }: HeadingProps): react_jsx_runtime.JSX.Element;
3544
+ ({ id, className, style, htmlProps, children, typographyType, level, withMargins, withMarginsOverInput, ...rest }: HeadingProps): react_jsx_runtime.JSX.Element;
3543
3545
  displayName: string;
3544
3546
  };
3545
3547
 
@@ -3561,9 +3563,11 @@ declare const Label: {
3561
3563
  type LegendProps = BaseComponentPropsWithChildren<HTMLLegendElement, BaseTypographyProps & {
3562
3564
  /**Typografistil basert på utvalget for HTML heading elementer. */
3563
3565
  typographyType?: TypographyHeadingType;
3566
+ /**Setter standard spacing for `<Legend>` som er over et inputelement. */
3567
+ withMarginsOverInput?: boolean;
3564
3568
  }, Omit<HTMLAttributes<HTMLLegendElement>, 'color'>>;
3565
3569
  declare const Legend: {
3566
- ({ id, className, style, htmlProps, typographyType, ...rest }: LegendProps): react_jsx_runtime.JSX.Element;
3570
+ ({ id, className, style, htmlProps, typographyType, withMarginsOverInput, withMargins, ...rest }: LegendProps): react_jsx_runtime.JSX.Element;
3567
3571
  displayName: string;
3568
3572
  };
3569
3573
 
package/dist/index.d.ts CHANGED
@@ -3537,9 +3537,11 @@ type HeadingProps = BaseComponentPropsWithChildren<HTMLHeadingElement, {
3537
3537
  level: HeadingLevel;
3538
3538
  /**Spesifiserer typografistil basert på utvalget for HTML heading elementer. */
3539
3539
  typographyType?: TypographyHeadingType;
3540
+ /**Setter standard spacing for `<Heading>` som er over et inputelement. */
3541
+ withMarginsOverInput?: boolean;
3540
3542
  } & BaseTypographyProps, Omit<HTMLAttributes<HTMLHeadingElement>, 'color'>>;
3541
3543
  declare const Heading: {
3542
- ({ id, className, style, htmlProps, children, typographyType, level, ...rest }: HeadingProps): react_jsx_runtime.JSX.Element;
3544
+ ({ id, className, style, htmlProps, children, typographyType, level, withMargins, withMarginsOverInput, ...rest }: HeadingProps): react_jsx_runtime.JSX.Element;
3543
3545
  displayName: string;
3544
3546
  };
3545
3547
 
@@ -3561,9 +3563,11 @@ declare const Label: {
3561
3563
  type LegendProps = BaseComponentPropsWithChildren<HTMLLegendElement, BaseTypographyProps & {
3562
3564
  /**Typografistil basert på utvalget for HTML heading elementer. */
3563
3565
  typographyType?: TypographyHeadingType;
3566
+ /**Setter standard spacing for `<Legend>` som er over et inputelement. */
3567
+ withMarginsOverInput?: boolean;
3564
3568
  }, Omit<HTMLAttributes<HTMLLegendElement>, 'color'>>;
3565
3569
  declare const Legend: {
3566
- ({ id, className, style, htmlProps, typographyType, ...rest }: LegendProps): react_jsx_runtime.JSX.Element;
3570
+ ({ id, className, style, htmlProps, typographyType, withMarginsOverInput, withMargins, ...rest }: LegendProps): react_jsx_runtime.JSX.Element;
3567
3571
  displayName: string;
3568
3572
  };
3569
3573
 
package/dist/index.js CHANGED
@@ -469,9 +469,11 @@ var typographyStyles_default = {
469
469
  "heading-xlarge--margins": "typographyStyles_heading-xlarge--margins",
470
470
  "heading-xxlarge": "typographyStyles_heading-xxlarge",
471
471
  "heading-xxlarge--margins": "typographyStyles_heading-xxlarge--margins",
472
+ "heading--margins-over-input": "typographyStyles_heading--margins-over-input",
472
473
  "label-medium": "typographyStyles_label-medium",
473
474
  "label-medium--margins": "typographyStyles_label-medium--margins",
474
475
  legend: "typographyStyles_legend",
476
+ "legend--margins-over-input": "typographyStyles_legend--margins-over-input",
475
477
  caption: "typographyStyles_caption",
476
478
  "caption--withMargins": "typographyStyles_caption--withMargins",
477
479
  bold: "typographyStyles_bold",
@@ -782,6 +784,12 @@ function cn(...classNames) {
782
784
  function convertCamelToHyphen(value) {
783
785
  return value.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([a-z])([0-9])/g, "$1-$2").toLowerCase();
784
786
  }
787
+ function optAttr(value, keepZero) {
788
+ if (keepZero && value === 0) {
789
+ return value;
790
+ }
791
+ return value ? value : void 0;
792
+ }
785
793
 
786
794
  // src/utils/getFocusableElements.ts
787
795
  function getFocusableElements(elementRef) {
@@ -4325,6 +4333,8 @@ var Heading = ({
4325
4333
  children,
4326
4334
  typographyType,
4327
4335
  level,
4336
+ withMargins,
4337
+ withMarginsOverInput,
4328
4338
  ...rest
4329
4339
  }) => {
4330
4340
  const headingElement = getHeadingElement(level);
@@ -4332,9 +4342,19 @@ var Heading = ({
4332
4342
  return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(
4333
4343
  Typography,
4334
4344
  {
4335
- ...getBaseHTMLProps(id, className, style, htmlProps, rest),
4345
+ ...getBaseHTMLProps(
4346
+ id,
4347
+ cn(
4348
+ className,
4349
+ withMarginsOverInput && typographyStyles_default["heading--margins-over-input"]
4350
+ ),
4351
+ style,
4352
+ htmlProps,
4353
+ rest
4354
+ ),
4336
4355
  typographyType: standardTypographyType,
4337
4356
  as: headingElement,
4357
+ withMargins: optAttr(withMargins || withMarginsOverInput),
4338
4358
  children
4339
4359
  }
4340
4360
  );
@@ -4413,14 +4433,26 @@ var Legend = ({
4413
4433
  style,
4414
4434
  htmlProps,
4415
4435
  typographyType = "headingLarge",
4436
+ withMarginsOverInput,
4437
+ withMargins,
4416
4438
  ...rest
4417
4439
  }) => {
4418
4440
  return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(
4419
4441
  Typography,
4420
4442
  {
4421
- ...getBaseHTMLProps(id, className, style, htmlProps, rest),
4443
+ ...getBaseHTMLProps(
4444
+ id,
4445
+ cn(
4446
+ className,
4447
+ withMarginsOverInput && typographyStyles_default["legend--margins-over-input"]
4448
+ ),
4449
+ style,
4450
+ htmlProps,
4451
+ rest
4452
+ ),
4422
4453
  as: "legend",
4423
- typographyType
4454
+ typographyType,
4455
+ withMargins: optAttr(withMargins || withMarginsOverInput)
4424
4456
  }
4425
4457
  );
4426
4458
  };