@obosbbl/grunnmuren-react 2.0.0-canary.28 → 2.0.0-canary.29

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.
Files changed (2) hide show
  1. package/dist/index.mjs +31 -20
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -299,7 +299,7 @@ const input = cva({
299
299
  visible: 'data-[focus-visible]:ring-2 group-data-[invalid]:data-[focus-visible]:ring'
300
300
  },
301
301
  isGrouped: {
302
- false: 'px-3',
302
+ false: 'bg-white px-3',
303
303
  true: 'flex-1 !ring-0'
304
304
  }
305
305
  },
@@ -328,16 +328,6 @@ function ErrorMessage(props) {
328
328
  });
329
329
  }
330
330
 
331
- const descriptionClasses = 'text-sm font-light leading-6';
332
- function Description(props) {
333
- const { className, ...restProps } = props;
334
- return /*#__PURE__*/ jsx(Text, {
335
- ...restProps,
336
- className: cx(className, descriptionClasses),
337
- slot: "description"
338
- });
339
- }
340
-
341
331
  const defaultClasses$1 = cx([
342
332
  'group relative left-0 inline-flex max-w-fit cursor-pointer items-start gap-4 py-2 leading-7'
343
333
  ]);
@@ -372,7 +362,7 @@ function Checkbox(props, ref) {
372
362
  const id = useId();
373
363
  const descriptionId = 'desc' + id;
374
364
  const errorMessageId = 'error' + id;
375
- const isInvalid = _isInvalid || errorMessage != null;
365
+ const isInvalid = errorMessage != null || _isInvalid;
376
366
  return /*#__PURE__*/ jsx("div", {
377
367
  children: /*#__PURE__*/ jsxs(CheckboxContext.Provider, {
378
368
  value: {
@@ -397,7 +387,7 @@ function Checkbox(props, ref) {
397
387
  /*#__PURE__*/ jsx("div", {
398
388
  id: descriptionId,
399
389
  slot: "description",
400
- className: cx('block', descriptionClasses),
390
+ className: "description block",
401
391
  children: description
402
392
  }),
403
393
  errorMessage && /*#__PURE__*/ jsx(ErrorMessage, {
@@ -420,6 +410,15 @@ function Label(props) {
420
410
  });
421
411
  }
422
412
 
413
+ function Description(props) {
414
+ const { className, ...restProps } = props;
415
+ return /*#__PURE__*/ jsx(Text, {
416
+ ...restProps,
417
+ className: cx(className, 'description'),
418
+ slot: "description"
419
+ });
420
+ }
421
+
423
422
  /**
424
423
  * This component handles renders a custom error message (if provided), otherwise it falls back to the browser's native validation.
425
424
  * In other words, this handles controlled and uncontrolled form errors.
@@ -433,7 +432,9 @@ function Label(props) {
433
432
 
434
433
  function CheckboxGroup(props, ref) {
435
434
  const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
436
- const isInvalid = _isInvalid || errorMessage != null;
435
+ // the order of the conditions matter here, because providing a value for isInvalid makes the validation state "controlled",
436
+ // which will override any built in validation
437
+ const isInvalid = errorMessage != null || _isInvalid;
437
438
  return /*#__PURE__*/ jsxs(CheckboxGroup$1, {
438
439
  ...restProps,
439
440
  className: cx(className, 'flex flex-col gap-2'),
@@ -491,7 +492,9 @@ function InputAddonDivider() {
491
492
 
492
493
  function Combobox(props, ref) {
493
494
  const { className, children, description, errorMessage, isLoading, label, isInvalid: _isInvalid, ...restProps } = props;
494
- const isInvalid = _isInvalid || errorMessage != null;
495
+ // the order of the conditions matter here, because providing a value for isInvalid makes the validation state "controlled",
496
+ // which will override any built in validation
497
+ const isInvalid = errorMessage != null || _isInvalid;
495
498
  return /*#__PURE__*/ jsxs(ComboBox, {
496
499
  ...restProps,
497
500
  className: cx(className, formField),
@@ -543,7 +546,9 @@ const _Combobox = /*#__PURE__*/ forwardRef(Combobox);
543
546
 
544
547
  function RadioGroup(props, ref) {
545
548
  const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
546
- const isInvalid = _isInvalid || errorMessage != null;
549
+ // the order of the conditions matter here, because providing a value for isInvalid makes the validation state "controlled",
550
+ // which will override any built in validation
551
+ const isInvalid = errorMessage != null || _isInvalid;
547
552
  return /*#__PURE__*/ jsxs(RadioGroup$1, {
548
553
  ...restProps,
549
554
  className: cx(className, 'flex flex-col gap-2'),
@@ -611,7 +616,9 @@ const _Radio = /*#__PURE__*/ forwardRef(Radio);
611
616
 
612
617
  function Select(props, ref) {
613
618
  const { className, children, description, errorMessage, label, isInvalid: _isInvalid, ...restProps } = props;
614
- const isInvalid = _isInvalid || errorMessage != null;
619
+ // the order of the conditions matter here, because providing a value for isInvalid makes the validation state "controlled",
620
+ // which will override any built in validation
621
+ const isInvalid = errorMessage != null || _isInvalid;
615
622
  return /*#__PURE__*/ jsxs(Select$1, {
616
623
  ...restProps,
617
624
  className: cx(className, formField),
@@ -656,7 +663,7 @@ const _Select = /*#__PURE__*/ forwardRef(Select);
656
663
 
657
664
  function TextArea(props, ref) {
658
665
  const { className, description, errorMessage, label, isInvalid: _isInvalid, rows, ...restProps } = props;
659
- const isInvalid = _isInvalid || errorMessage != null;
666
+ const isInvalid = errorMessage != null || _isInvalid;
660
667
  return /*#__PURE__*/ jsxs(TextField$1, {
661
668
  ...restProps,
662
669
  className: cx(className, formField),
@@ -696,7 +703,9 @@ const inputVariants$1 = compose(input, cva({
696
703
  }));
697
704
  function TextField(props, ref) {
698
705
  const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, size, ...restProps } = props;
699
- const isInvalid = _isInvalid || errorMessage != null;
706
+ // the order of the conditions matter here, because providing a value for isInvalid makes the validation state "controlled",
707
+ // which will override any built in validation
708
+ const isInvalid = errorMessage != null || _isInvalid;
700
709
  return /*#__PURE__*/ jsxs(TextField$1, {
701
710
  ...restProps,
702
711
  className: cx(className, formField),
@@ -759,7 +768,9 @@ const inputVariants = compose(input, cva({
759
768
  }));
760
769
  function NumberField(props, ref) {
761
770
  const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, size, ...restProps } = props;
762
- const isInvalid = _isInvalid || errorMessage != null;
771
+ // the order of the conditions matter here, because providing a value for isInvalid makes the validation state "controlled",
772
+ // which will override any built in validation
773
+ const isInvalid = errorMessage != null || _isInvalid;
763
774
  return /*#__PURE__*/ jsxs(NumberField$1, {
764
775
  ...restProps,
765
776
  className: cx(className, formField),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "2.0.0-canary.28",
3
+ "version": "2.0.0-canary.29",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"
@@ -19,10 +19,10 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.1",
22
- "@react-aria/utils": "^3.24.0",
22
+ "@react-aria/utils": "^3.24.1",
23
23
  "@types/node": "^20.11.19",
24
24
  "cva": "1.0.0-beta.1",
25
- "react-aria-components": "^1.2.0"
25
+ "react-aria-components": "^1.2.1"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "^18"