@vygruppen/spor-react 12.8.7 → 12.8.9

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.mjs CHANGED
@@ -753,8 +753,15 @@ var Heading = forwardRef(
753
753
  id: externalId,
754
754
  ...rest
755
755
  } = props;
756
- const id = externalId ?? (autoId && typeof rest.children === "string") ? slugify(rest.children) : void 0;
757
- return /* @__PURE__ */ jsx(Text, { as, textStyle: variant, id, ref, ...rest });
756
+ const reactId = useId();
757
+ function getId() {
758
+ if (externalId !== void 0)
759
+ return externalId;
760
+ if (!autoId)
761
+ return;
762
+ return typeof rest.children === "string" ? slugify(rest.children) : reactId;
763
+ }
764
+ return /* @__PURE__ */ jsx(Text, { as, textStyle: variant, id: getId(), ref, ...rest });
758
765
  }
759
766
  );
760
767
  function resolveTextProps({
@@ -1370,6 +1377,7 @@ var Field3 = React27.forwardRef(
1370
1377
  readOnly,
1371
1378
  required,
1372
1379
  direction,
1380
+ id,
1373
1381
  ...rest
1374
1382
  } = props;
1375
1383
  const recipe = useSlotRecipe({ key: "field" });
@@ -1384,10 +1392,17 @@ var Field3 = React27.forwardRef(
1384
1392
  required,
1385
1393
  css: styles.root,
1386
1394
  direction,
1395
+ id,
1387
1396
  children: [
1388
- label && !floatingLabel && /* @__PURE__ */ jsx(Label, { children: label }),
1397
+ label && !floatingLabel && /* @__PURE__ */ jsxs(Label, { children: [
1398
+ label,
1399
+ /* @__PURE__ */ jsx(Field.RequiredIndicator, {})
1400
+ ] }),
1389
1401
  children,
1390
- label && floatingLabel && /* @__PURE__ */ jsx(FloatingLabel, { children: label }),
1402
+ label && floatingLabel && /* @__PURE__ */ jsxs(FloatingLabel, { children: [
1403
+ label,
1404
+ /* @__PURE__ */ jsx(Field.RequiredIndicator, {})
1405
+ ] }),
1391
1406
  errorText && /* @__PURE__ */ jsx(Field.ErrorText, { children: errorText })
1392
1407
  ]
1393
1408
  }
@@ -1953,6 +1968,7 @@ var DatePicker = forwardRef(
1953
1968
  errorText,
1954
1969
  invalid,
1955
1970
  helperText,
1971
+ required: props.required,
1956
1972
  children: /* @__PURE__ */ jsx(PopoverAnchor, { children: /* @__PURE__ */ jsxs(
1957
1973
  StyledField,
1958
1974
  {
@@ -2076,6 +2092,7 @@ function DateRangePicker({
2076
2092
  errorText,
2077
2093
  helperText,
2078
2094
  invalid,
2095
+ required: props.required,
2079
2096
  children: /* @__PURE__ */ jsx(PopoverAnchor, { children: /* @__PURE__ */ jsxs(
2080
2097
  StyledField,
2081
2098
  {
@@ -2785,6 +2802,7 @@ var Input = forwardRef(
2785
2802
  invalid,
2786
2803
  helperText,
2787
2804
  errorText,
2805
+ required,
2788
2806
  ...props
2789
2807
  }, ref) => {
2790
2808
  const recipe = useRecipe({ key: "input" });
@@ -2795,7 +2813,9 @@ var Input = forwardRef(
2795
2813
  {
2796
2814
  invalid,
2797
2815
  helperText,
2816
+ required,
2798
2817
  errorText,
2818
+ id: props.id,
2799
2819
  label: (
2800
2820
  // Render startElement invisibly to align label text with input content when an icon is present
2801
2821
  /* @__PURE__ */ jsxs(Flex, { children: [
@@ -2958,6 +2978,7 @@ var NativeSelect = React27.forwardRef(function NativeSelect2(props, ref) {
2958
2978
  required,
2959
2979
  helperText,
2960
2980
  errorText,
2981
+ id: rest.id,
2961
2982
  floatingLabel: true,
2962
2983
  children: /* @__PURE__ */ jsxs(
2963
2984
  NativeSelect$1.Root,
@@ -3012,7 +3033,7 @@ var NumericStepper = React27__default.forwardRef((props, ref) => {
3012
3033
  var _a5;
3013
3034
  (_a5 = addButtonRef.current) == null ? void 0 : _a5.focus();
3014
3035
  };
3015
- return /* @__PURE__ */ jsxs(Field3, { css: styles.root, width: "auto", ...rest, ref, children: [
3036
+ return /* @__PURE__ */ jsxs(Field3, { css: styles.root, width: "auto", ...rest, id: idProp, ref, children: [
3016
3037
  /* @__PURE__ */ jsx(
3017
3038
  VerySmallButton,
3018
3039
  {
@@ -3467,22 +3488,32 @@ var Select = React27.forwardRef(
3467
3488
  } = props;
3468
3489
  const recipe = useSlotRecipe({ key: "select" });
3469
3490
  const styles = recipe({ variant });
3470
- return /* @__PURE__ */ jsx(Field3, { errorText, invalid, helperText, children: /* @__PURE__ */ jsxs(
3471
- Select$1.Root,
3491
+ return /* @__PURE__ */ jsx(
3492
+ Field3,
3472
3493
  {
3473
- ...rest,
3474
- ref,
3475
- positioning: { sameWidth: true, ...positioning },
3476
- variant,
3477
- css: styles.root,
3478
- position: "relative",
3479
- children: [
3480
- /* @__PURE__ */ jsx(SelectTrigger, { "data-attachable": true, children: /* @__PURE__ */ jsx(SelectValueText, { withPlaceholder: label ? true : false }) }),
3481
- label && /* @__PURE__ */ jsx(SelectLabel, { css: styles.label, children: label }),
3482
- /* @__PURE__ */ jsx(SelectContent, { css: styles.selectContent, children })
3483
- ]
3494
+ errorText,
3495
+ invalid,
3496
+ helperText,
3497
+ required: props.required,
3498
+ id: rest.id,
3499
+ children: /* @__PURE__ */ jsxs(
3500
+ Select$1.Root,
3501
+ {
3502
+ ...rest,
3503
+ ref,
3504
+ positioning: { sameWidth: true, ...positioning },
3505
+ variant,
3506
+ css: styles.root,
3507
+ position: "relative",
3508
+ children: [
3509
+ /* @__PURE__ */ jsx(SelectTrigger, { "data-attachable": true, children: /* @__PURE__ */ jsx(SelectValueText, { withPlaceholder: label ? true : false }) }),
3510
+ label && /* @__PURE__ */ jsx(SelectLabel, { css: styles.label, children: label }),
3511
+ /* @__PURE__ */ jsx(SelectContent, { css: styles.selectContent, children })
3512
+ ]
3513
+ }
3514
+ )
3484
3515
  }
3485
- ) });
3516
+ );
3486
3517
  }
3487
3518
  );
3488
3519
  var SelectLabel = (props) => {
@@ -3589,6 +3620,8 @@ var Switch = forwardRef(
3589
3620
  invalid,
3590
3621
  errorText,
3591
3622
  helperText,
3623
+ required: props.required,
3624
+ id: rest.id,
3592
3625
  children: /* @__PURE__ */ jsxs(
3593
3626
  Switch$1.Root,
3594
3627
  {
@@ -7609,6 +7642,9 @@ var fieldSlotRecipe = defineSlotRecipe({
7609
7642
  marginStart: 1,
7610
7643
  color: "brightRed"
7611
7644
  },
7645
+ label: {
7646
+ display: "flex"
7647
+ },
7612
7648
  helperText: {
7613
7649
  marginTop: 2,
7614
7650
  color: "text.tertiary",