@douglasneuroinformatics/libui 2.2.0 → 2.2.1

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.
@@ -22,6 +22,6 @@ export const BaseRadioField = ({ description, error, label, name, options, orien
22
22
  React.createElement(FieldGroup.Description, { description: description })),
23
23
  React.createElement(RadioGroup, { className: baseRadioFieldVariants({ orientation: optionsCount > 5 ? 'vertical' : orientation }), name: name, value: value ?? '', onValueChange: (value) => setValue(value) }, Object.keys(options).map((option) => (React.createElement("div", { className: "flex items-center gap-2", key: option },
24
24
  React.createElement(RadioGroup.Item, { id: `${name}-${option}`, value: option }),
25
- React.createElement(Label, { className: "font-normal", htmlFor: `${name}-${option}` }, options[option]))))),
25
+ React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-${option}` }, options[option]))))),
26
26
  React.createElement(FieldGroup.Error, { error: error })));
27
27
  };
@@ -23,9 +23,9 @@ export const BooleanFieldRadio = ({ error, label, name, options, setValue, value
23
23
  React.createElement(RadioGroup, { name: name, value: stringifyBoolean(value), onValueChange: handleValueChange },
24
24
  React.createElement(FieldGroup.Row, null,
25
25
  React.createElement(RadioGroup.Item, { id: `${name}-true`, value: "true" }),
26
- React.createElement(Label, { className: "font-normal", htmlFor: `${name}-true` }, options?.true ?? t('form.radioLabels.true'))),
26
+ React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-true` }, options?.true ?? t('form.radioLabels.true'))),
27
27
  React.createElement(FieldGroup.Row, null,
28
28
  React.createElement(RadioGroup.Item, { id: `${name}-false`, value: "false" }),
29
- React.createElement(Label, { className: "font-normal", htmlFor: `${name}-false` }, options?.false ?? t('form.radioLabels.false')))),
29
+ React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-false` }, options?.false ?? t('form.radioLabels.false')))),
30
30
  React.createElement(FieldGroup.Error, { error: error })));
31
31
  };
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export const FieldGroupRoot = ({ children }) => (React.createElement("div", { className: "flex flex-col gap-2 @container" }, children));
2
+ export const FieldGroupRoot = ({ children }) => (React.createElement("div", { className: "flex flex-col gap-3.5 @container" }, children));
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { FormContent, FormDataType, PartialNullableFormDataType } from '@douglasneuroinformatics/libui-form-types';
3
3
  import { z } from 'zod';
4
- type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.infer<TSchema> = z.infer<TSchema>> = {
4
+ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>> = {
5
5
  [key: `data-${string}`]: unknown;
6
6
  className?: string;
7
7
  content: FormContent<TData>;
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAGZ,2BAA2B,EAC5B,MAAM,2CAA2C,CAAC;AAInD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,KAAK,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI;IAC3G,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,2BAA2B,CAAC,KAAK,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC7C,QAAQ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,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,QAAA,MAAM,IAAI,iPAWP,UAAU,OAAO,EAAE,KAAK,CAAC,sBAgG3B,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC"}
@@ -12,8 +12,8 @@ export const NumberFieldRadio = ({ description, error, label, name, options, set
12
12
  React.createElement(RadioGroup, { className: cn('flex', optionsCount > 5 ? 'flex-col' : 'flex-col @3xl:flex-row @3xl:items-center @3xl:justify-between'), name: name, value: value?.toString() ?? '', onValueChange: (value) => setValue(parseInt(value)) }, Object.keys(options)
13
13
  .map((val) => parseInt(val))
14
14
  .toSorted((a, b) => a - b)
15
- .map((key) => (React.createElement("div", { className: "flex items-center gap-2", key: key },
16
- React.createElement(RadioGroup.Item, { id: `${name}-${key}`, value: key.toString() }),
17
- React.createElement(Label, { className: "font-normal", htmlFor: `${name}-${key}` }, options[key]))))),
15
+ .map((val) => (React.createElement("div", { className: "flex items-center gap-2", key: val },
16
+ React.createElement(RadioGroup.Item, { id: `${name}-${val}`, value: val.toString() }),
17
+ React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-${val}` }, `${val} - ${options[val]}`))))),
18
18
  React.createElement(FieldGroup.Error, { error: error })));
19
19
  };
@@ -11,6 +11,6 @@ export const NumberFieldSelect = ({ description, error, label, name, options, se
11
11
  React.createElement(Select, { name: name, value: value?.toString() ?? '', onValueChange: (value) => setValue(parseFloat(value)) },
12
12
  React.createElement(Select.Trigger, { "data-cy": `${name}-select-trigger`, "data-testid": `${name}-select-trigger` },
13
13
  React.createElement(Select.Value, null)),
14
- React.createElement(Select.Content, { "data-cy": `${name}-select-content`, "data-testid": `${name}-select-content` }, Object.keys(options).map((option) => (React.createElement(Select.Item, { key: option, value: option }, options[option]))))),
14
+ React.createElement(Select.Content, { "data-cy": `${name}-select-content`, "data-testid": `${name}-select-content` }, Object.keys(options).map((option) => (React.createElement(Select.Item, { key: option, value: option }, `${option} - ${options[option]}`))))),
15
15
  React.createElement(FieldGroup.Error, { error: error })));
16
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SetFieldListbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/SetField/SetFieldListbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAErB,eAAO,MAAM,eAAe,oGAQzB,qBAAqB,CAAC,CAAC,sBAwBzB,CAAC"}
1
+ {"version":3,"file":"SetFieldListbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/SetField/SetFieldListbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAErB,eAAO,MAAM,eAAe,oGAQzB,qBAAqB,CAAC,CAAC,sBA0BzB,CAAC"}
@@ -7,10 +7,10 @@ export const SetFieldListbox = ({ description, error, label, name, onCheckedChan
7
7
  React.createElement(FieldGroup.Row, null,
8
8
  React.createElement(Label, null, label),
9
9
  React.createElement(FieldGroup.Description, { description: description })),
10
- Object.keys(options).map((option) => (React.createElement("div", { className: "flex items-center gap-2", key: option },
10
+ React.createElement("div", { className: "grid gap-2" }, Object.keys(options).map((option) => (React.createElement(FieldGroup.Row, { key: option },
11
11
  React.createElement(Checkbox, { checked: value?.has(option) ?? false, id: `${name}-${option}`, onCheckedChange: (checked) => {
12
12
  onCheckedChange(option, !checked);
13
13
  } }),
14
- React.createElement(Label, { className: "font-normal", htmlFor: `${name}-${option}` }, options[option])))),
14
+ React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-${option}` }, options[option]))))),
15
15
  React.createElement(FieldGroup.Error, { error: error })));
16
16
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@douglasneuroinformatics/libui",
3
3
  "type": "module",
4
- "version": "2.2.0",
4
+ "version": "2.2.1",
5
5
  "packageManager": "pnpm@8.15.3",
6
6
  "description": "Generic UI components for DNP projects, built using React and TailwindCSS",
7
7
  "author": {
@@ -56,7 +56,7 @@ export const BaseRadioField = <T extends string>({
56
56
  {Object.keys(options).map((option) => (
57
57
  <div className="flex items-center gap-2" key={option}>
58
58
  <RadioGroup.Item id={`${name}-${option}`} value={option} />
59
- <Label className="font-normal" htmlFor={`${name}-${option}`}>
59
+ <Label className="font-normal text-muted-foreground" htmlFor={`${name}-${option}`}>
60
60
  {options[option as T]}
61
61
  </Label>
62
62
  </div>
@@ -42,13 +42,13 @@ export const BooleanFieldRadio = ({ error, label, name, options, setValue, value
42
42
  <RadioGroup name={name} value={stringifyBoolean(value)} onValueChange={handleValueChange}>
43
43
  <FieldGroup.Row>
44
44
  <RadioGroup.Item id={`${name}-true`} value="true" />
45
- <Label className="font-normal" htmlFor={`${name}-true`}>
45
+ <Label className="font-normal text-muted-foreground" htmlFor={`${name}-true`}>
46
46
  {options?.true ?? t('form.radioLabels.true')}
47
47
  </Label>
48
48
  </FieldGroup.Row>
49
49
  <FieldGroup.Row>
50
50
  <RadioGroup.Item id={`${name}-false`} value="false" />
51
- <Label className="font-normal" htmlFor={`${name}-false`}>
51
+ <Label className="font-normal text-muted-foreground" htmlFor={`${name}-false`}>
52
52
  {options?.false ?? t('form.radioLabels.false')}
53
53
  </Label>
54
54
  </FieldGroup.Row>
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
 
3
3
  export const FieldGroupRoot: React.FC<{ children: React.ReactNode }> = ({ children }) => (
4
- <div className="flex flex-col gap-2 @container">{children}</div>
4
+ <div className="flex flex-col gap-3.5 @container">{children}</div>
5
5
  );
@@ -20,7 +20,7 @@ import { getInitialValues } from './utils.js';
20
20
 
21
21
  import type { FormErrors } from './types.js';
22
22
 
23
- type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.infer<TSchema> = z.infer<TSchema>> = {
23
+ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>> = {
24
24
  [key: `data-${string}`]: unknown;
25
25
  className?: string;
26
26
  content: FormContent<TData>;
@@ -33,7 +33,7 @@ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.infer<TS
33
33
  validationSchema: z.ZodType<TData>;
34
34
  };
35
35
 
36
- const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.infer<TSchema> = z.infer<TSchema>>({
36
+ const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>>({
37
37
  className,
38
38
  content,
39
39
  id,
@@ -43,11 +43,11 @@ export const NumberFieldRadio = ({
43
43
  {Object.keys(options)
44
44
  .map((val) => parseInt(val))
45
45
  .toSorted((a, b) => a - b)
46
- .map((key) => (
47
- <div className="flex items-center gap-2" key={key}>
48
- <RadioGroup.Item id={`${name}-${key}`} value={key.toString()} />
49
- <Label className="font-normal" htmlFor={`${name}-${key}`}>
50
- {options[key]}
46
+ .map((val) => (
47
+ <div className="flex items-center gap-2" key={val}>
48
+ <RadioGroup.Item id={`${name}-${val}`} value={val.toString()} />
49
+ <Label className="font-normal text-muted-foreground" htmlFor={`${name}-${val}`}>
50
+ {`${val} - ${options[val]}`}
51
51
  </Label>
52
52
  </div>
53
53
  ))}
@@ -35,7 +35,7 @@ export const NumberFieldSelect = <T extends number = number>({
35
35
  {Object.keys(options).map((option) => (
36
36
  <Select.Item key={option} value={option}>
37
37
  {/** option needs to be type number, but no sense converting it when it is coerced right back anyways */}
38
- {options[option as any as T]}
38
+ {`${option} - ${options[option as any as T]}`}
39
39
  </Select.Item>
40
40
  ))}
41
41
  </Select.Content>
@@ -25,20 +25,22 @@ export const SetFieldListbox = <T extends string = string>({
25
25
  <Label>{label}</Label>
26
26
  <FieldGroup.Description description={description} />
27
27
  </FieldGroup.Row>
28
- {Object.keys(options).map((option) => (
29
- <div className="flex items-center gap-2" key={option}>
30
- <Checkbox
31
- checked={value?.has(option as T) ?? false}
32
- id={`${name}-${option}`}
33
- onCheckedChange={(checked) => {
34
- onCheckedChange(option as T, !checked);
35
- }}
36
- />
37
- <Label className="font-normal" htmlFor={`${name}-${option}`}>
38
- {options[option as T]}
39
- </Label>
40
- </div>
41
- ))}
28
+ <div className="grid gap-2">
29
+ {Object.keys(options).map((option) => (
30
+ <FieldGroup.Row key={option}>
31
+ <Checkbox
32
+ checked={value?.has(option as T) ?? false}
33
+ id={`${name}-${option}`}
34
+ onCheckedChange={(checked) => {
35
+ onCheckedChange(option as T, !checked);
36
+ }}
37
+ />
38
+ <Label className="font-normal text-muted-foreground" htmlFor={`${name}-${option}`}>
39
+ {options[option as T]}
40
+ </Label>
41
+ </FieldGroup.Row>
42
+ ))}
43
+ </div>
42
44
  <FieldGroup.Error error={error} />
43
45
  </FieldGroup>
44
46
  );