@obosbbl/grunnmuren-react 2.0.0-canary.24 → 2.0.0-canary.26
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 +18 -2
- package/dist/index.mjs +58 -36
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -350,8 +350,10 @@ type TextFieldProps = {
|
|
|
350
350
|
textAlign?: 'left' | 'right';
|
|
351
351
|
/** Additional style properties for the element. */
|
|
352
352
|
style?: React.CSSProperties;
|
|
353
|
-
/** Add a divider between the left/right addons and the input */
|
|
353
|
+
/** Add a divider between the left/right addons and the input, a value of 0 will be ignored */
|
|
354
354
|
withAddonDivider?: boolean;
|
|
355
|
+
/** Defines the number of characters and determines the width of the input element */
|
|
356
|
+
size?: number;
|
|
355
357
|
} & Omit<TextFieldProps$1, 'className' | 'isReadOnly' | 'isDisabled' | 'children' | 'style'>;
|
|
356
358
|
declare const _TextField: react.ForwardRefExoticComponent<{
|
|
357
359
|
/** Additional CSS className for the element. */
|
|
@@ -375,8 +377,10 @@ declare const _TextField: react.ForwardRefExoticComponent<{
|
|
|
375
377
|
textAlign?: "left" | "right" | undefined;
|
|
376
378
|
/** Additional style properties for the element. */
|
|
377
379
|
style?: react.CSSProperties | undefined;
|
|
378
|
-
/** Add a divider between the left/right addons and the input */
|
|
380
|
+
/** Add a divider between the left/right addons and the input, a value of 0 will be ignored */
|
|
379
381
|
withAddonDivider?: boolean | undefined;
|
|
382
|
+
/** Defines the number of characters and determines the width of the input element */
|
|
383
|
+
size?: number | undefined;
|
|
380
384
|
} & Omit<TextFieldProps$1, "children" | "className" | "style" | "isDisabled" | "isReadOnly"> & react.RefAttributes<HTMLInputElement>>;
|
|
381
385
|
|
|
382
386
|
type NumberFieldProps = {
|
|
@@ -403,6 +407,12 @@ type NumberFieldProps = {
|
|
|
403
407
|
style?: React.CSSProperties;
|
|
404
408
|
/** Add a divider between the left/right addons and the input */
|
|
405
409
|
withAddonDivider?: boolean;
|
|
410
|
+
/** Defines the number of characters and determines the width of the input element, a value of 0 will be ignored */
|
|
411
|
+
size?: number;
|
|
412
|
+
/** Defines the maximum numeric value */
|
|
413
|
+
maxValue?: number;
|
|
414
|
+
/** Defines the minimum numeric value */
|
|
415
|
+
minValue?: number;
|
|
406
416
|
} & Omit<NumberFieldProps$1, 'className' | 'isReadOnly' | 'isDisabled' | 'children' | 'style' | 'hideStepper'>;
|
|
407
417
|
declare const _NumberField: react.ForwardRefExoticComponent<{
|
|
408
418
|
/** Additional CSS className for the element. */
|
|
@@ -428,6 +438,12 @@ declare const _NumberField: react.ForwardRefExoticComponent<{
|
|
|
428
438
|
style?: react.CSSProperties | undefined;
|
|
429
439
|
/** Add a divider between the left/right addons and the input */
|
|
430
440
|
withAddonDivider?: boolean | undefined;
|
|
441
|
+
/** Defines the number of characters and determines the width of the input element, a value of 0 will be ignored */
|
|
442
|
+
size?: number | undefined;
|
|
443
|
+
/** Defines the maximum numeric value */
|
|
444
|
+
maxValue?: number | undefined;
|
|
445
|
+
/** Defines the minimum numeric value */
|
|
446
|
+
minValue?: number | undefined;
|
|
431
447
|
} & Omit<NumberFieldProps$1, "children" | "className" | "style" | "isDisabled" | "isReadOnly" | "hideStepper"> & react.RefAttributes<HTMLInputElement>>;
|
|
432
448
|
|
|
433
449
|
declare const alertVariants: (props?: ({
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { I18nProvider, RouterProvider, useContextProps, Provider, Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, CheckboxGroup as CheckboxGroup$1,
|
|
2
|
+
import { I18nProvider, RouterProvider, useContextProps, Provider, Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, FieldError, CheckboxGroup as CheckboxGroup$1, ListBoxItem as ListBoxItem$1, ListBox as ListBox$1, ComboBox, Group, Input, Button as Button$1, Popover, RadioGroup as RadioGroup$1, Radio as Radio$1, Select as Select$1, SelectValue, TextField as TextField$1, TextArea as TextArea$1, NumberField as NumberField$1, useLocale, Breadcrumbs as Breadcrumbs$1, Breadcrumb as Breadcrumb$1, Link } from 'react-aria-components';
|
|
3
3
|
export { Form } from 'react-aria-components';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { useLayoutEffect, createContext, forwardRef, Children, useId, useState, useRef } from 'react';
|
|
@@ -396,8 +396,10 @@ function Checkbox(props, ref) {
|
|
|
396
396
|
}),
|
|
397
397
|
description && /*#__PURE__*/ jsx(Description, {
|
|
398
398
|
className: "block",
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
400
|
+
id: descriptionId,
|
|
401
|
+
children: description
|
|
402
|
+
})
|
|
401
403
|
}),
|
|
402
404
|
errorMessage && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
403
405
|
className: "mt-2 block",
|
|
@@ -419,6 +421,17 @@ function Label(props) {
|
|
|
419
421
|
});
|
|
420
422
|
}
|
|
421
423
|
|
|
424
|
+
/**
|
|
425
|
+
* This component handles renders a custom error message (if provided), otherwise it falls back to the browser's native validation.
|
|
426
|
+
* In other words, this handles controlled and uncontrolled form errors.
|
|
427
|
+
*/ function ErrorMessageOrFieldError({ errorMessage }) {
|
|
428
|
+
return errorMessage ? /*#__PURE__*/ jsx(ErrorMessage, {
|
|
429
|
+
children: errorMessage
|
|
430
|
+
}) : /*#__PURE__*/ jsx(FieldError, {
|
|
431
|
+
className: formFieldError
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
422
435
|
function CheckboxGroup(props, ref) {
|
|
423
436
|
const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
|
|
424
437
|
const isInvalid = _isInvalid || errorMessage != null;
|
|
@@ -436,25 +449,14 @@ function CheckboxGroup(props, ref) {
|
|
|
436
449
|
children: description
|
|
437
450
|
}),
|
|
438
451
|
children,
|
|
439
|
-
|
|
440
|
-
|
|
452
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
453
|
+
errorMessage: errorMessage
|
|
441
454
|
})
|
|
442
455
|
]
|
|
443
456
|
});
|
|
444
457
|
}
|
|
445
458
|
const _CheckboxGroup = /*#__PURE__*/ forwardRef(CheckboxGroup);
|
|
446
459
|
|
|
447
|
-
/**
|
|
448
|
-
* This component handles renders a custom error message (if provided), otherwise it falls back to the browser's native validation.
|
|
449
|
-
* In other words, this handles controlled and uncontrolled form errors.
|
|
450
|
-
*/ function ErrorMessageOrFieldError({ errorMessage }) {
|
|
451
|
-
return errorMessage ? /*#__PURE__*/ jsx(ErrorMessage, {
|
|
452
|
-
children: errorMessage
|
|
453
|
-
}) : /*#__PURE__*/ jsx(FieldError, {
|
|
454
|
-
className: formFieldError
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
|
|
458
460
|
const ListBox = ({ className, ...restProps })=>/*#__PURE__*/ jsx(ListBox$1, {
|
|
459
461
|
...restProps,
|
|
460
462
|
className: cx(dropdown.listbox, className)
|
|
@@ -556,8 +558,8 @@ function RadioGroup(props, ref) {
|
|
|
556
558
|
children: description
|
|
557
559
|
}),
|
|
558
560
|
children,
|
|
559
|
-
|
|
560
|
-
|
|
561
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
562
|
+
errorMessage: errorMessage
|
|
561
563
|
})
|
|
562
564
|
]
|
|
563
565
|
});
|
|
@@ -678,17 +680,21 @@ function TextArea(props, ref) {
|
|
|
678
680
|
}
|
|
679
681
|
const _TextArea = /*#__PURE__*/ forwardRef(TextArea);
|
|
680
682
|
|
|
681
|
-
const
|
|
683
|
+
const inputVariants$1 = compose(input, cva({
|
|
682
684
|
base: '',
|
|
683
685
|
variants: {
|
|
684
686
|
textAlign: {
|
|
685
687
|
right: 'text-right',
|
|
686
688
|
left: ''
|
|
689
|
+
},
|
|
690
|
+
autoWidth: {
|
|
691
|
+
true: 'box-content max-w-fit',
|
|
692
|
+
false: ''
|
|
687
693
|
}
|
|
688
694
|
}
|
|
689
695
|
}));
|
|
690
696
|
function TextField(props, ref) {
|
|
691
|
-
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
|
|
697
|
+
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, size, ...restProps } = props;
|
|
692
698
|
const isInvalid = _isInvalid || errorMessage != null;
|
|
693
699
|
return /*#__PURE__*/ jsxs(TextField$1, {
|
|
694
700
|
...restProps,
|
|
@@ -702,25 +708,31 @@ function TextField(props, ref) {
|
|
|
702
708
|
children: description
|
|
703
709
|
}),
|
|
704
710
|
leftAddon || rightAddon ? /*#__PURE__*/ jsxs(Group, {
|
|
705
|
-
className: inputGroup,
|
|
711
|
+
className: cx(inputGroup, {
|
|
712
|
+
'w-fit': !!size
|
|
713
|
+
}),
|
|
706
714
|
children: [
|
|
707
715
|
leftAddon,
|
|
708
716
|
withAddonDivider && leftAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
709
717
|
/*#__PURE__*/ jsx(Input, {
|
|
710
|
-
className:
|
|
718
|
+
className: inputVariants$1({
|
|
711
719
|
textAlign,
|
|
712
|
-
isGrouped: true
|
|
720
|
+
isGrouped: true,
|
|
721
|
+
autoWidth: !!size
|
|
713
722
|
}),
|
|
714
|
-
ref: ref
|
|
723
|
+
ref: ref,
|
|
724
|
+
size: size
|
|
715
725
|
}),
|
|
716
726
|
withAddonDivider && rightAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
717
727
|
rightAddon
|
|
718
728
|
]
|
|
719
729
|
}) : /*#__PURE__*/ jsx(Input, {
|
|
720
|
-
className:
|
|
721
|
-
textAlign
|
|
730
|
+
className: inputVariants$1({
|
|
731
|
+
textAlign,
|
|
732
|
+
autoWidth: !!size
|
|
722
733
|
}),
|
|
723
|
-
ref: ref
|
|
734
|
+
ref: ref,
|
|
735
|
+
size: size
|
|
724
736
|
}),
|
|
725
737
|
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
726
738
|
errorMessage: errorMessage
|
|
@@ -731,17 +743,21 @@ function TextField(props, ref) {
|
|
|
731
743
|
const _TextField = /*#__PURE__*/ forwardRef(TextField);
|
|
732
744
|
|
|
733
745
|
// This component is based on a copy of ../textfield/TextField, refactoring is TBD: https://github.com/code-obos/grunnmuren/pull/722#issuecomment-1931478786
|
|
734
|
-
const
|
|
746
|
+
const inputVariants = compose(input, cva({
|
|
735
747
|
base: '',
|
|
736
748
|
variants: {
|
|
737
749
|
textAlign: {
|
|
738
750
|
right: 'text-right',
|
|
739
751
|
left: ''
|
|
752
|
+
},
|
|
753
|
+
autoWidth: {
|
|
754
|
+
true: 'box-content max-w-fit',
|
|
755
|
+
false: ''
|
|
740
756
|
}
|
|
741
757
|
}
|
|
742
758
|
}));
|
|
743
759
|
function NumberField(props, ref) {
|
|
744
|
-
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
|
|
760
|
+
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, size, ...restProps } = props;
|
|
745
761
|
const isInvalid = _isInvalid || errorMessage != null;
|
|
746
762
|
return /*#__PURE__*/ jsxs(NumberField$1, {
|
|
747
763
|
...restProps,
|
|
@@ -755,25 +771,31 @@ function NumberField(props, ref) {
|
|
|
755
771
|
children: description
|
|
756
772
|
}),
|
|
757
773
|
leftAddon || rightAddon ? /*#__PURE__*/ jsxs(Group, {
|
|
758
|
-
className: inputGroup,
|
|
774
|
+
className: cx(inputGroup, {
|
|
775
|
+
'w-fit': !!size
|
|
776
|
+
}),
|
|
759
777
|
children: [
|
|
760
778
|
leftAddon,
|
|
761
779
|
withAddonDivider && leftAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
762
780
|
/*#__PURE__*/ jsx(Input, {
|
|
763
|
-
className:
|
|
781
|
+
className: inputVariants({
|
|
764
782
|
textAlign,
|
|
765
|
-
isGrouped: true
|
|
783
|
+
isGrouped: true,
|
|
784
|
+
autoWidth: !!size
|
|
766
785
|
}),
|
|
767
|
-
ref: ref
|
|
786
|
+
ref: ref,
|
|
787
|
+
size: size
|
|
768
788
|
}),
|
|
769
789
|
withAddonDivider && rightAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
770
790
|
rightAddon
|
|
771
791
|
]
|
|
772
792
|
}) : /*#__PURE__*/ jsx(Input, {
|
|
773
|
-
className:
|
|
774
|
-
textAlign
|
|
793
|
+
className: inputVariants({
|
|
794
|
+
textAlign,
|
|
795
|
+
autoWidth: !!size
|
|
775
796
|
}),
|
|
776
|
-
ref: ref
|
|
797
|
+
ref: ref,
|
|
798
|
+
size: size
|
|
777
799
|
}),
|
|
778
800
|
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
779
801
|
errorMessage: errorMessage
|