@obosbbl/grunnmuren-react 2.0.0-canary.7 → 2.0.0-canary.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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, ComboBoxProps, ListBoxItemProps, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps as SelectProps$1, TextFieldProps as TextFieldProps$1 } from 'react-aria-components';
1
+ import { CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, ComboBoxProps, ListBoxItemProps, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps as SelectProps$1, TextFieldProps as TextFieldProps$1, NumberFieldProps as NumberFieldProps$1 } from 'react-aria-components';
2
2
  export { ListBoxItemProps as ComboboxItemProps, Form, I18nProvider, ListBoxItemProps as SelectItemProps } from 'react-aria-components';
3
3
  import * as react from 'react';
4
4
  import { VariantProps } from 'cva';
@@ -226,4 +226,31 @@ type TextFieldProps = {
226
226
  } & Omit<TextFieldProps$1, 'className' | 'isReadOnly' | 'isDisabled' | 'children' | 'style'>;
227
227
  declare const _TextField: react.ForwardRefExoticComponent<Omit<TextFieldProps, "ref"> & react.RefAttributes<HTMLInputElement>>;
228
228
 
229
- export { _Button as Button, type ButtonProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ComboboxItem, type ComboboxProps, _Radio as Radio, _RadioGroup as RadioGroup, type RadioGroupProps, type RadioProps, _Select as Select, SelectItem, type SelectProps, _TextArea as TextArea, type TextAreaProps, _TextField as TextField, type TextFieldProps };
229
+ type NumberFieldProps = {
230
+ /** Additional CSS className for the element. */
231
+ className?: string;
232
+ /** Help text for the form control. */
233
+ description?: React.ReactNode;
234
+ /** Error message for the form control. Automatically sets `isInvalid` to true */
235
+ errorMessage?: React.ReactNode;
236
+ /** Element to be rendered in the left side of the input. */
237
+ leftAddon?: React.ReactNode;
238
+ /** Label for the form control. */
239
+ label?: React.ReactNode;
240
+ /** Element to be rendered in the right side of the input. */
241
+ rightAddon?: React.ReactNode;
242
+ /** Placeholder text. Only visible when the input value is empty. */
243
+ placeholder?: string;
244
+ /**
245
+ * Text alignment of the input
246
+ * @default left
247
+ */
248
+ textAlign?: 'left' | 'right';
249
+ /** Additional style properties for the element. */
250
+ style?: React.CSSProperties;
251
+ /** Add a divider between the left/right addons and the input */
252
+ withAddonDivider?: boolean;
253
+ } & Omit<NumberFieldProps$1, 'className' | 'isReadOnly' | 'isDisabled' | 'children' | 'style' | 'hideStepper'>;
254
+ declare const _NumberField: react.ForwardRefExoticComponent<Omit<NumberFieldProps, "ref"> & react.RefAttributes<HTMLInputElement>>;
255
+
256
+ export { _Button as Button, type ButtonProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ComboboxItem, type ComboboxProps, _NumberField as NumberField, type NumberFieldProps, _Radio as Radio, _RadioGroup as RadioGroup, type RadioGroupProps, type RadioProps, _Select as Select, SelectItem, type SelectProps, _TextArea as TextArea, type TextAreaProps, _TextField as TextField, type TextFieldProps };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, CheckboxGroup as CheckboxGroup$1, FieldError, ListBoxItem, ComboBox, Group, Input, Button, Popover, ListBox, RadioGroup as RadioGroup$1, Radio as Radio$1, Select as Select$1, SelectValue, TextField as TextField$1, TextArea as TextArea$1 } from 'react-aria-components';
1
+ import { Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, CheckboxGroup as CheckboxGroup$1, FieldError, ListBoxItem, ComboBox, Group, Input, Button, Popover, ListBox, 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 } from 'react-aria-components';
2
2
  export { Form, I18nProvider } from 'react-aria-components';
3
3
  export { _ as Button } from './Button-client-wuoyidfi.js';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -411,7 +411,7 @@ function TextArea(props, ref) {
411
411
  }
412
412
  const _TextArea = /*#__PURE__*/ forwardRef(TextArea);
413
413
 
414
- const inputWithAlignment = compose(input, cva({
414
+ const inputWithAlignment$1 = compose(input, cva({
415
415
  base: '',
416
416
  variants: {
417
417
  textAlign: {
@@ -424,6 +424,68 @@ function TextField(props, ref) {
424
424
  const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
425
425
  const isInvalid = _isInvalid || errorMessage != null;
426
426
  return /*#__PURE__*/ jsxs(TextField$1, {
427
+ ...restProps,
428
+ className: cx(className, formField),
429
+ isInvalid: isInvalid,
430
+ children: [
431
+ label && /*#__PURE__*/ jsx(Label, {
432
+ children: label
433
+ }),
434
+ description && /*#__PURE__*/ jsx(Description, {
435
+ children: description
436
+ }),
437
+ leftAddon || rightAddon ? /*#__PURE__*/ jsxs(Group, {
438
+ className: inputGroup,
439
+ children: [
440
+ leftAddon,
441
+ withAddonDivider && leftAddon && /*#__PURE__*/ jsx(Divider$1, {
442
+ className: "ml-3"
443
+ }),
444
+ /*#__PURE__*/ jsx(Input, {
445
+ className: inputWithAlignment$1({
446
+ textAlign,
447
+ isGrouped: true
448
+ }),
449
+ ref: ref
450
+ }),
451
+ withAddonDivider && rightAddon && /*#__PURE__*/ jsx(Divider$1, {
452
+ className: "mr-3"
453
+ }),
454
+ rightAddon
455
+ ]
456
+ }) : /*#__PURE__*/ jsx(Input, {
457
+ className: inputWithAlignment$1({
458
+ textAlign
459
+ }),
460
+ ref: ref
461
+ }),
462
+ /*#__PURE__*/ jsx(ErrorMessageOrFieldError, {
463
+ errorMessage: errorMessage
464
+ })
465
+ ]
466
+ });
467
+ }
468
+ function Divider$1({ className }) {
469
+ return /*#__PURE__*/ jsx("span", {
470
+ className: cx(className, 'block h-6 w-px flex-none bg-black')
471
+ });
472
+ }
473
+ const _TextField = /*#__PURE__*/ forwardRef(TextField);
474
+
475
+ // This component is based on a copy of ../textfield/TextField, refactoring is TBD: https://github.com/code-obos/grunnmuren/pull/722#issuecomment-1931478786
476
+ const inputWithAlignment = compose(input, cva({
477
+ base: '',
478
+ variants: {
479
+ textAlign: {
480
+ right: 'text-right',
481
+ left: ''
482
+ }
483
+ }
484
+ }));
485
+ function NumberField(props, ref) {
486
+ const { className, description, errorMessage, label, leftAddon, isInvalid: _isInvalid, textAlign, rightAddon, withAddonDivider, ...restProps } = props;
487
+ const isInvalid = _isInvalid || errorMessage != null;
488
+ return /*#__PURE__*/ jsxs(NumberField$1, {
427
489
  ...restProps,
428
490
  className: cx(className, formField),
429
491
  isInvalid: isInvalid,
@@ -470,6 +532,6 @@ function Divider({ className }) {
470
532
  className: cx(className, 'block h-6 w-px flex-none bg-black')
471
533
  });
472
534
  }
473
- const _TextField = /*#__PURE__*/ forwardRef(TextField);
535
+ const _NumberField = /*#__PURE__*/ forwardRef(NumberField);
474
536
 
475
- export { _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ComboboxItem, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, SelectItem, _TextArea as TextArea, _TextField as TextField };
537
+ export { _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ComboboxItem, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, SelectItem, _TextArea as TextArea, _TextField as TextField };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "2.0.0-canary.7",
3
+ "version": "2.0.0-canary.9",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"