@obosbbl/grunnmuren-react 2.0.0-canary.10 → 2.0.0-canary.12

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, NumberFieldProps as NumberFieldProps$1 } from 'react-aria-components';
1
+ import { CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, ListBoxItemProps, ComboBoxProps, 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';
@@ -133,6 +133,8 @@ declare const _CheckboxGroup: react.ForwardRefExoticComponent<{
133
133
  style?: react.CSSProperties | undefined;
134
134
  } & Omit<CheckboxGroupProps$1, "className" | "style" | "children" | "isDisabled" | "isReadOnly" | "orientation"> & react.RefAttributes<HTMLDivElement>>;
135
135
 
136
+ declare const ListBoxItem: (props: ListBoxItemProps) => react_jsx_runtime.JSX.Element;
137
+
136
138
  type ComboboxProps<T extends object> = {
137
139
  children: React.ReactNode;
138
140
  /** Additional CSS className for the element. */
@@ -153,7 +155,6 @@ type ComboboxProps<T extends object> = {
153
155
  /** Additional style properties for the element. */
154
156
  style?: React.CSSProperties;
155
157
  } & Omit<ComboBoxProps<T>, 'className' | 'isReadOnly' | 'isDisabled' | 'children' | 'style'>;
156
- declare const ComboboxItem: (props: ListBoxItemProps) => react_jsx_runtime.JSX.Element;
157
158
  declare const _Combobox: react.ForwardRefExoticComponent<{
158
159
  children: React.ReactNode;
159
160
  /** Additional CSS className for the element. */
@@ -236,7 +237,6 @@ type SelectProps<T extends object> = {
236
237
  /** Additional style properties for the element. */
237
238
  style?: React.CSSProperties;
238
239
  } & Omit<SelectProps$1<T>, 'className' | 'isReadOnly' | 'isDisabled' | 'children' | 'style'>;
239
- declare const SelectItem: (props: ListBoxItemProps) => react_jsx_runtime.JSX.Element;
240
240
  declare const _Select: react.ForwardRefExoticComponent<{
241
241
  children: React.ReactNode;
242
242
  /** Additional CSS className for the element. */
@@ -394,4 +394,4 @@ declare const _NumberField: react.ForwardRefExoticComponent<{
394
394
  withAddonDivider?: boolean | undefined;
395
395
  } & Omit<NumberFieldProps$1, "className" | "style" | "children" | "isDisabled" | "isReadOnly" | "hideStepper"> & react.RefAttributes<HTMLInputElement>>;
396
396
 
397
- 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 };
397
+ export { _Button as Button, type ButtonProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ListBoxItem as ComboboxItem, type ComboboxProps, _NumberField as NumberField, type NumberFieldProps, _Radio as Radio, _RadioGroup as RadioGroup, type RadioGroupProps, type RadioProps, _Select as Select, ListBoxItem as 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, NumberField as NumberField$1 } from 'react-aria-components';
1
+ import { Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, CheckboxGroup as CheckboxGroup$1, FieldError, ListBoxItem as ListBoxItem$1, ListBox as ListBox$1, ComboBox, Group, Input, Button, 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 } from 'react-aria-components';
2
2
  export { Form, I18nProvider } from 'react-aria-components';
3
3
  export { _ as Button } from './Button-client-XmGlKEk4.js';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -10,7 +10,7 @@ const formField = cx('group flex flex-col gap-2');
10
10
  const formFieldError = cx('w-fit rounded-sm bg-red-light px-2 py-1 text-sm leading-6 text-red');
11
11
  const input = cva({
12
12
  base: [
13
- 'rounded-md px-3 py-2.5 text-sm font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
13
+ 'rounded-md py-2.5 text-sm font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
14
14
  // invalid styles
15
15
  'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red',
16
16
  // Fix invisible ring on safari: https://github.com/tailwindlabs/tailwindcss.com/issues/1135
@@ -23,9 +23,8 @@ const input = cva({
23
23
  visible: 'data-[focus-visible]:ring-2 group-data-[invalid]:data-[focus-visible]:ring'
24
24
  },
25
25
  isGrouped: {
26
- false: '',
27
- //
28
- true: 'flex-1 !ring-0 first:pl-0 last:pr-0'
26
+ false: 'px-3',
27
+ true: 'flex-1 !ring-0'
29
28
  }
30
29
  },
31
30
  defaultVariants: {
@@ -33,7 +32,12 @@ const input = cva({
33
32
  isGrouped: false
34
33
  }
35
34
  });
36
- const inputGroup = cx('inline-flex items-center overflow-hidden rounded-md px-3 ring-1 ring-black focus-within:ring-2 group-data-[invalid]:ring-2 group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring');
35
+ const inputGroup = cx([
36
+ 'inline-flex items-center gap-3 overflow-hidden rounded-md px-3 text-sm ring-1 ring-black focus-within:ring-2',
37
+ 'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring',
38
+ // Make sure icons are the correct size
39
+ '[&_svg]:text-base'
40
+ ]);
37
41
  const dropdown = {
38
42
  popover: cx('min-w-[--trigger-width] overflow-auto rounded-md border border-black bg-white shadow data-[entering]:animate-in data-[exiting]:animate-out data-[entering]:fade-in data-[exiting]:fade-out'),
39
43
  listbox: cx('text-sm outline-none'),
@@ -175,6 +179,39 @@ const _CheckboxGroup = /*#__PURE__*/ forwardRef(CheckboxGroup);
175
179
  });
176
180
  }
177
181
 
182
+ const ListBox = ({ className, ...restProps })=>/*#__PURE__*/ jsx(ListBox$1, {
183
+ ...restProps,
184
+ className: cx(dropdown.listbox, className)
185
+ });
186
+ const ListBoxItem = (props)=>{
187
+ let textValue = props.textValue;
188
+ // When the ListBoxItem child isn't a string we have to set textValue for keyboard completion to work.
189
+ // Since we use a render function (to handle the selected state) the child is never a string.
190
+ // This condition adds back that behaviour
191
+ if (textValue == null && typeof props.children === 'string') {
192
+ textValue = props.children;
193
+ }
194
+ return /*#__PURE__*/ jsx(ListBoxItem$1, {
195
+ ...props,
196
+ className: cx(props.className, 'flex cursor-pointer px-6 py-3 leading-6 outline-none data-[focused]:bg-sky-lightest'),
197
+ textValue: textValue,
198
+ children: ({ isSelected })=>/*#__PURE__*/ jsxs(Fragment, {
199
+ children: [
200
+ isSelected && /*#__PURE__*/ jsx(Check, {
201
+ className: "-ml-6 text-base"
202
+ }),
203
+ props.children
204
+ ]
205
+ })
206
+ });
207
+ };
208
+
209
+ function InputAddonDivider() {
210
+ return /*#__PURE__*/ jsx("span", {
211
+ className: "block h-6 w-px flex-none bg-black"
212
+ });
213
+ }
214
+
178
215
  function Combobox(props, ref) {
179
216
  const { className, children, description, errorMessage, isLoading, label, isInvalid: _isInvalid, ...restProps } = props;
180
217
  const isInvalid = _isInvalid || errorMessage != null;
@@ -218,35 +255,12 @@ function Combobox(props, ref) {
218
255
  className: cx(dropdown.popover, 'min-w-[calc(var(--trigger-width)+26px)]'),
219
256
  crossOffset: -13,
220
257
  children: /*#__PURE__*/ jsx(ListBox, {
221
- className: dropdown.listbox,
222
258
  children: children
223
259
  })
224
260
  })
225
261
  ]
226
262
  });
227
263
  }
228
- const ComboboxItem = (props)=>{
229
- let textValue = props.textValue;
230
- // When the ListBoxItem child isn't a string we have to set textValue for keyboard completion to work.
231
- // Since we use a render function (to handle the selected state) the child is never a string.
232
- // This condition adds back that behaviour
233
- if (textValue == null && typeof props.children === 'string') {
234
- textValue = props.children;
235
- }
236
- return /*#__PURE__*/ jsx(ListBoxItem, {
237
- ...props,
238
- className: cx(props.className, 'flex cursor-default px-6 py-2 leading-6 outline-none data-[focused]:bg-sky-lightest'),
239
- textValue: textValue,
240
- children: ({ isSelected })=>/*#__PURE__*/ jsxs(Fragment, {
241
- children: [
242
- isSelected && /*#__PURE__*/ jsx(Check, {
243
- className: "-ml-6 text-base"
244
- }),
245
- props.children
246
- ]
247
- })
248
- });
249
- };
250
264
  const _Combobox = /*#__PURE__*/ forwardRef(Combobox);
251
265
 
252
266
  function RadioGroup(props, ref) {
@@ -353,35 +367,12 @@ function Select(props, ref) {
353
367
  /*#__PURE__*/ jsx(Popover, {
354
368
  className: dropdown.popover,
355
369
  children: /*#__PURE__*/ jsx(ListBox, {
356
- className: dropdown.listbox,
357
370
  children: children
358
371
  })
359
372
  })
360
373
  ]
361
374
  });
362
375
  }
363
- const SelectItem = (props)=>{
364
- let textValue = props.textValue;
365
- // When the ListBoxItem child isn't a string we have to set textValue for keyboard completion to work.
366
- // Since we use a render function (to handle the selected state) the child is never a string.
367
- // This condition adds back that behaviour
368
- if (textValue == null && typeof props.children === 'string') {
369
- textValue = props.children;
370
- }
371
- return /*#__PURE__*/ jsx(ListBoxItem, {
372
- ...props,
373
- className: cx(props.className, 'flex cursor-default px-6 py-2 leading-6 outline-none data-[focused]:bg-sky-lightest'),
374
- textValue: textValue,
375
- children: ({ isSelected })=>/*#__PURE__*/ jsxs(Fragment, {
376
- children: [
377
- isSelected && /*#__PURE__*/ jsx(Check, {
378
- className: "-ml-6 text-base"
379
- }),
380
- props.children
381
- ]
382
- })
383
- });
384
- };
385
376
  const _Select = /*#__PURE__*/ forwardRef(Select);
386
377
 
387
378
  function TextArea(props, ref) {
@@ -438,9 +429,7 @@ function TextField(props, ref) {
438
429
  className: inputGroup,
439
430
  children: [
440
431
  leftAddon,
441
- withAddonDivider && leftAddon && /*#__PURE__*/ jsx(Divider$1, {
442
- className: "ml-3"
443
- }),
432
+ withAddonDivider && leftAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
444
433
  /*#__PURE__*/ jsx(Input, {
445
434
  className: inputWithAlignment$1({
446
435
  textAlign,
@@ -448,9 +437,7 @@ function TextField(props, ref) {
448
437
  }),
449
438
  ref: ref
450
439
  }),
451
- withAddonDivider && rightAddon && /*#__PURE__*/ jsx(Divider$1, {
452
- className: "mr-3"
453
- }),
440
+ withAddonDivider && rightAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
454
441
  rightAddon
455
442
  ]
456
443
  }) : /*#__PURE__*/ jsx(Input, {
@@ -465,11 +452,6 @@ function TextField(props, ref) {
465
452
  ]
466
453
  });
467
454
  }
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
455
  const _TextField = /*#__PURE__*/ forwardRef(TextField);
474
456
 
475
457
  // This component is based on a copy of ../textfield/TextField, refactoring is TBD: https://github.com/code-obos/grunnmuren/pull/722#issuecomment-1931478786
@@ -500,9 +482,7 @@ function NumberField(props, ref) {
500
482
  className: inputGroup,
501
483
  children: [
502
484
  leftAddon,
503
- withAddonDivider && leftAddon && /*#__PURE__*/ jsx(Divider, {
504
- className: "ml-3"
505
- }),
485
+ withAddonDivider && leftAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
506
486
  /*#__PURE__*/ jsx(Input, {
507
487
  className: inputWithAlignment({
508
488
  textAlign,
@@ -510,9 +490,7 @@ function NumberField(props, ref) {
510
490
  }),
511
491
  ref: ref
512
492
  }),
513
- withAddonDivider && rightAddon && /*#__PURE__*/ jsx(Divider, {
514
- className: "mr-3"
515
- }),
493
+ withAddonDivider && rightAddon && /*#__PURE__*/ jsx(InputAddonDivider, {}),
516
494
  rightAddon
517
495
  ]
518
496
  }) : /*#__PURE__*/ jsx(Input, {
@@ -527,11 +505,6 @@ function NumberField(props, ref) {
527
505
  ]
528
506
  });
529
507
  }
530
- function Divider({ className }) {
531
- return /*#__PURE__*/ jsx("span", {
532
- className: cx(className, 'block h-6 w-px flex-none bg-black')
533
- });
534
- }
535
508
  const _NumberField = /*#__PURE__*/ forwardRef(NumberField);
536
509
 
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 };
510
+ export { _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ListBoxItem as ComboboxItem, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, ListBoxItem as 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.10",
3
+ "version": "2.0.0-canary.12",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"