@obosbbl/grunnmuren-react 2.0.0-canary.27 → 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.
- package/dist/index.mjs +38 -27
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -286,7 +286,7 @@ const formField = cx('group flex flex-col gap-2');
|
|
|
286
286
|
const formFieldError = cx('w-fit rounded-sm bg-red-light px-2 py-1 text-sm leading-6 text-red');
|
|
287
287
|
const input = cva({
|
|
288
288
|
base: [
|
|
289
|
-
'rounded-md py-2.5 text-
|
|
289
|
+
'rounded-md py-2.5 text-base font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
|
|
290
290
|
// invalid styles
|
|
291
291
|
'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red',
|
|
292
292
|
// Fix invisible ring on safari: https://github.com/tailwindlabs/tailwindcss.com/issues/1135
|
|
@@ -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
|
},
|
|
@@ -309,14 +309,12 @@ const input = cva({
|
|
|
309
309
|
}
|
|
310
310
|
});
|
|
311
311
|
const inputGroup = cx([
|
|
312
|
-
'inline-flex items-center gap-3 overflow-hidden rounded-md bg-white px-3 text-
|
|
313
|
-
'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring'
|
|
314
|
-
// Make sure icons are the correct size
|
|
315
|
-
'[&_svg]:text-base'
|
|
312
|
+
'inline-flex items-center gap-3 overflow-hidden rounded-md bg-white px-3 text-base ring-1 ring-black focus-within:ring-2',
|
|
313
|
+
'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring'
|
|
316
314
|
]);
|
|
317
315
|
const dropdown = {
|
|
318
|
-
popover: cx('min-w-[--trigger-width]
|
|
319
|
-
listbox: cx('text-sm outline-none'),
|
|
316
|
+
popover: cx('min-w-[--trigger-width] rounded-md bg-white shadow data-[entering]:animate-in data-[exiting]:animate-out data-[entering]:fade-in data-[exiting]:fade-out'),
|
|
317
|
+
listbox: cx('max-h-[25rem] overflow-y-scroll rounded-md border border-black text-sm outline-none'),
|
|
320
318
|
chevronIcon: cx('text-base transition-transform duration-150 group-data-[open]:rotate-180 motion-reduce:transition-none')
|
|
321
319
|
};
|
|
322
320
|
|
|
@@ -330,16 +328,6 @@ function ErrorMessage(props) {
|
|
|
330
328
|
});
|
|
331
329
|
}
|
|
332
330
|
|
|
333
|
-
const descriptionClasses = 'text-sm font-light leading-6';
|
|
334
|
-
function Description(props) {
|
|
335
|
-
const { className, ...restProps } = props;
|
|
336
|
-
return /*#__PURE__*/ jsx(Text, {
|
|
337
|
-
...restProps,
|
|
338
|
-
className: cx(className, descriptionClasses),
|
|
339
|
-
slot: "description"
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
331
|
const defaultClasses$1 = cx([
|
|
344
332
|
'group relative left-0 inline-flex max-w-fit cursor-pointer items-start gap-4 py-2 leading-7'
|
|
345
333
|
]);
|
|
@@ -374,7 +362,7 @@ function Checkbox(props, ref) {
|
|
|
374
362
|
const id = useId();
|
|
375
363
|
const descriptionId = 'desc' + id;
|
|
376
364
|
const errorMessageId = 'error' + id;
|
|
377
|
-
const isInvalid =
|
|
365
|
+
const isInvalid = errorMessage != null || _isInvalid;
|
|
378
366
|
return /*#__PURE__*/ jsx("div", {
|
|
379
367
|
children: /*#__PURE__*/ jsxs(CheckboxContext.Provider, {
|
|
380
368
|
value: {
|
|
@@ -399,7 +387,7 @@ function Checkbox(props, ref) {
|
|
|
399
387
|
/*#__PURE__*/ jsx("div", {
|
|
400
388
|
id: descriptionId,
|
|
401
389
|
slot: "description",
|
|
402
|
-
className:
|
|
390
|
+
className: "description block",
|
|
403
391
|
children: description
|
|
404
392
|
}),
|
|
405
393
|
errorMessage && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
@@ -422,6 +410,15 @@ function Label(props) {
|
|
|
422
410
|
});
|
|
423
411
|
}
|
|
424
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
|
+
|
|
425
422
|
/**
|
|
426
423
|
* This component handles renders a custom error message (if provided), otherwise it falls back to the browser's native validation.
|
|
427
424
|
* In other words, this handles controlled and uncontrolled form errors.
|
|
@@ -435,7 +432,9 @@ function Label(props) {
|
|
|
435
432
|
|
|
436
433
|
function CheckboxGroup(props, ref) {
|
|
437
434
|
const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
|
|
438
|
-
|
|
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;
|
|
439
438
|
return /*#__PURE__*/ jsxs(CheckboxGroup$1, {
|
|
440
439
|
...restProps,
|
|
441
440
|
className: cx(className, 'flex flex-col gap-2'),
|
|
@@ -493,7 +492,9 @@ function InputAddonDivider() {
|
|
|
493
492
|
|
|
494
493
|
function Combobox(props, ref) {
|
|
495
494
|
const { className, children, description, errorMessage, isLoading, label, isInvalid: _isInvalid, ...restProps } = props;
|
|
496
|
-
|
|
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;
|
|
497
498
|
return /*#__PURE__*/ jsxs(ComboBox, {
|
|
498
499
|
...restProps,
|
|
499
500
|
className: cx(className, formField),
|
|
@@ -534,6 +535,7 @@ function Combobox(props, ref) {
|
|
|
534
535
|
className: cx(dropdown.popover, 'min-w-[calc(var(--trigger-width)+26px)]'),
|
|
535
536
|
crossOffset: -13,
|
|
536
537
|
children: /*#__PURE__*/ jsx(ListBox, {
|
|
538
|
+
className: dropdown.listbox,
|
|
537
539
|
children: children
|
|
538
540
|
})
|
|
539
541
|
})
|
|
@@ -544,7 +546,9 @@ const _Combobox = /*#__PURE__*/ forwardRef(Combobox);
|
|
|
544
546
|
|
|
545
547
|
function RadioGroup(props, ref) {
|
|
546
548
|
const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
|
|
547
|
-
|
|
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;
|
|
548
552
|
return /*#__PURE__*/ jsxs(RadioGroup$1, {
|
|
549
553
|
...restProps,
|
|
550
554
|
className: cx(className, 'flex flex-col gap-2'),
|
|
@@ -612,7 +616,9 @@ const _Radio = /*#__PURE__*/ forwardRef(Radio);
|
|
|
612
616
|
|
|
613
617
|
function Select(props, ref) {
|
|
614
618
|
const { className, children, description, errorMessage, label, isInvalid: _isInvalid, ...restProps } = props;
|
|
615
|
-
|
|
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;
|
|
616
622
|
return /*#__PURE__*/ jsxs(Select$1, {
|
|
617
623
|
...restProps,
|
|
618
624
|
className: cx(className, formField),
|
|
@@ -646,6 +652,7 @@ function Select(props, ref) {
|
|
|
646
652
|
/*#__PURE__*/ jsx(Popover, {
|
|
647
653
|
className: dropdown.popover,
|
|
648
654
|
children: /*#__PURE__*/ jsx(ListBox, {
|
|
655
|
+
className: dropdown.listbox,
|
|
649
656
|
children: children
|
|
650
657
|
})
|
|
651
658
|
})
|
|
@@ -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 =
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
25
|
+
"react-aria-components": "^1.2.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^18"
|