@obosbbl/grunnmuren-react 2.0.0-canary.24 → 2.0.0-canary.25
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 +48 -32
- 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';
|
|
@@ -419,6 +419,17 @@ function Label(props) {
|
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
+
/**
|
|
423
|
+
* This component handles renders a custom error message (if provided), otherwise it falls back to the browser's native validation.
|
|
424
|
+
* In other words, this handles controlled and uncontrolled form errors.
|
|
425
|
+
*/ function ErrorMessageOrFieldError({ errorMessage }) {
|
|
426
|
+
return errorMessage ? /*#__PURE__*/ jsx(ErrorMessage, {
|
|
427
|
+
children: errorMessage
|
|
428
|
+
}) : /*#__PURE__*/ jsx(FieldError, {
|
|
429
|
+
className: formFieldError
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
422
433
|
function CheckboxGroup(props, ref) {
|
|
423
434
|
const { children, className, description, errorMessage, label, isRequired, isInvalid: _isInvalid, ...restProps } = props;
|
|
424
435
|
const isInvalid = _isInvalid || errorMessage != null;
|
|
@@ -436,25 +447,14 @@ function CheckboxGroup(props, ref) {
|
|
|
436
447
|
children: description
|
|
437
448
|
}),
|
|
438
449
|
children,
|
|
439
|
-
|
|
440
|
-
|
|
450
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
451
|
+
errorMessage: errorMessage
|
|
441
452
|
})
|
|
442
453
|
]
|
|
443
454
|
});
|
|
444
455
|
}
|
|
445
456
|
const _CheckboxGroup = /*#__PURE__*/ forwardRef(CheckboxGroup);
|
|
446
457
|
|
|
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
458
|
const ListBox = ({ className, ...restProps })=>/*#__PURE__*/ jsx(ListBox$1, {
|
|
459
459
|
...restProps,
|
|
460
460
|
className: cx(dropdown.listbox, className)
|
|
@@ -556,8 +556,8 @@ function RadioGroup(props, ref) {
|
|
|
556
556
|
children: description
|
|
557
557
|
}),
|
|
558
558
|
children,
|
|
559
|
-
|
|
560
|
-
|
|
559
|
+
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
560
|
+
errorMessage: errorMessage
|
|
561
561
|
})
|
|
562
562
|
]
|
|
563
563
|
});
|
|
@@ -678,17 +678,21 @@ function TextArea(props, ref) {
|
|
|
678
678
|
}
|
|
679
679
|
const _TextArea = /*#__PURE__*/ forwardRef(TextArea);
|
|
680
680
|
|
|
681
|
-
const
|
|
681
|
+
const inputVariants$1 = compose(input, cva({
|
|
682
682
|
base: '',
|
|
683
683
|
variants: {
|
|
684
684
|
textAlign: {
|
|
685
685
|
right: 'text-right',
|
|
686
686
|
left: ''
|
|
687
|
+
},
|
|
688
|
+
autoWidth: {
|
|
689
|
+
true: 'box-content max-w-fit',
|
|
690
|
+
false: ''
|
|
687
691
|
}
|
|
688
692
|
}
|
|
689
693
|
}));
|
|
690
694
|
function TextField(props, ref) {
|
|
691
|
-
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
|
|
695
|
+
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, size, ...restProps } = props;
|
|
692
696
|
const isInvalid = _isInvalid || errorMessage != null;
|
|
693
697
|
return /*#__PURE__*/ jsxs(TextField$1, {
|
|
694
698
|
...restProps,
|
|
@@ -707,20 +711,24 @@ function TextField(props, ref) {
|
|
|
707
711
|
leftAddon,
|
|
708
712
|
withAddonDivider && leftAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
709
713
|
/*#__PURE__*/ jsx(Input, {
|
|
710
|
-
className:
|
|
714
|
+
className: inputVariants$1({
|
|
711
715
|
textAlign,
|
|
712
|
-
isGrouped: true
|
|
716
|
+
isGrouped: true,
|
|
717
|
+
autoWidth: !!size
|
|
713
718
|
}),
|
|
714
|
-
ref: ref
|
|
719
|
+
ref: ref,
|
|
720
|
+
size: size
|
|
715
721
|
}),
|
|
716
722
|
withAddonDivider && rightAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
717
723
|
rightAddon
|
|
718
724
|
]
|
|
719
725
|
}) : /*#__PURE__*/ jsx(Input, {
|
|
720
|
-
className:
|
|
721
|
-
textAlign
|
|
726
|
+
className: inputVariants$1({
|
|
727
|
+
textAlign,
|
|
728
|
+
autoWidth: !!size
|
|
722
729
|
}),
|
|
723
|
-
ref: ref
|
|
730
|
+
ref: ref,
|
|
731
|
+
size: size
|
|
724
732
|
}),
|
|
725
733
|
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
726
734
|
errorMessage: errorMessage
|
|
@@ -731,17 +739,21 @@ function TextField(props, ref) {
|
|
|
731
739
|
const _TextField = /*#__PURE__*/ forwardRef(TextField);
|
|
732
740
|
|
|
733
741
|
// 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
|
|
742
|
+
const inputVariants = compose(input, cva({
|
|
735
743
|
base: '',
|
|
736
744
|
variants: {
|
|
737
745
|
textAlign: {
|
|
738
746
|
right: 'text-right',
|
|
739
747
|
left: ''
|
|
748
|
+
},
|
|
749
|
+
autoWidth: {
|
|
750
|
+
true: 'box-content max-w-fit',
|
|
751
|
+
false: ''
|
|
740
752
|
}
|
|
741
753
|
}
|
|
742
754
|
}));
|
|
743
755
|
function NumberField(props, ref) {
|
|
744
|
-
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
|
|
756
|
+
const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, size, ...restProps } = props;
|
|
745
757
|
const isInvalid = _isInvalid || errorMessage != null;
|
|
746
758
|
return /*#__PURE__*/ jsxs(NumberField$1, {
|
|
747
759
|
...restProps,
|
|
@@ -760,20 +772,24 @@ function NumberField(props, ref) {
|
|
|
760
772
|
leftAddon,
|
|
761
773
|
withAddonDivider && leftAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
762
774
|
/*#__PURE__*/ jsx(Input, {
|
|
763
|
-
className:
|
|
775
|
+
className: inputVariants({
|
|
764
776
|
textAlign,
|
|
765
|
-
isGrouped: true
|
|
777
|
+
isGrouped: true,
|
|
778
|
+
autoWidth: !!size
|
|
766
779
|
}),
|
|
767
|
-
ref: ref
|
|
780
|
+
ref: ref,
|
|
781
|
+
size: size
|
|
768
782
|
}),
|
|
769
783
|
withAddonDivider && rightAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
|
|
770
784
|
rightAddon
|
|
771
785
|
]
|
|
772
786
|
}) : /*#__PURE__*/ jsx(Input, {
|
|
773
|
-
className:
|
|
774
|
-
textAlign
|
|
787
|
+
className: inputVariants({
|
|
788
|
+
textAlign,
|
|
789
|
+
autoWidth: !!size
|
|
775
790
|
}),
|
|
776
|
-
ref: ref
|
|
791
|
+
ref: ref,
|
|
792
|
+
size: size
|
|
777
793
|
}),
|
|
778
794
|
/*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
|
|
779
795
|
errorMessage: errorMessage
|