@douglasneuroinformatics/libui 2.9.1 → 2.9.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"NumberFieldInput.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CACjF,CAAC;AAEF,eAAO,MAAM,gBAAgB,6EAU1B,qBAAqB,sBA2BvB,CAAC"}
1
+ {"version":3,"file":"NumberFieldInput.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CACjF,CAAC;AAEF,eAAO,MAAM,gBAAgB,6EAU1B,qBAAqB,sBA2BvB,CAAC"}
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
+ import { parseNumber } from '@douglasneuroinformatics/libjs';
2
3
  import { Input } from '../../Input/Input.js';
3
4
  import { Label } from '../../Label/Label.js';
4
5
  import { FieldGroup } from '../FieldGroup/FieldGroup.js';
5
- export const NumberFieldInput = ({ description, error, label, max, min, name, readOnly, setValue, value }) => {
6
+ export const NumberFieldInput = ({ description, error, label, max = Number.MAX_SAFE_INTEGER, min = Number.MIN_SAFE_INTEGER, name, readOnly, setValue, value }) => {
6
7
  const handleChange = (event) => {
7
- const newValue = parseFloat(event.target.value);
8
+ const newValue = parseNumber(event.target.value);
8
9
  if (Number.isNaN(newValue)) {
9
10
  setValue(undefined);
10
11
  }
11
- else if (newValue >= (min ?? -Infinity) && newValue <= (max ?? Infinity)) {
12
+ else if (newValue >= min && newValue <= max) {
12
13
  setValue(newValue);
13
14
  }
14
15
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@douglasneuroinformatics/libui",
3
3
  "type": "module",
4
- "version": "2.9.1",
4
+ "version": "2.9.3",
5
5
  "packageManager": "pnpm@9.3.0",
6
6
  "description": "Generic UI components for DNP projects, built using React and Tailwind CSS",
7
7
  "author": "Joshua Unrau",
@@ -60,11 +60,12 @@
60
60
  },
61
61
  "peerDependencies": {
62
62
  "react": "^18.2.0",
63
- "react-dom": "^18.2.0"
63
+ "react-dom": "^18.2.0",
64
+ "zod": "^3.23.6"
64
65
  },
65
66
  "dependencies": {
66
- "@douglasneuroinformatics/libjs": "^0.3.1",
67
- "@douglasneuroinformatics/libui-form-types": "^0.10.0",
67
+ "@douglasneuroinformatics/libjs": "^0.5.0",
68
+ "@douglasneuroinformatics/libui-form-types": "^0.10.1",
68
69
  "@headlessui/tailwindcss": "^0.2.1",
69
70
  "@heroicons/react": "^2.1.3",
70
71
  "@radix-ui/react-accordion": "^1.1.2",
@@ -107,7 +108,6 @@
107
108
  "ts-pattern": "^5.1.2",
108
109
  "type-fest": "^4.20.0",
109
110
  "vaul": "^0.9.1",
110
- "zod": "^3.23.6",
111
111
  "zustand": "^4.5.2"
112
112
  },
113
113
  "devDependencies": {
@@ -34,7 +34,7 @@ const $ExampleFormData = z.object({
34
34
  stringTextArea: z.string().optional(),
35
35
  stringPassword: z.string().optional(),
36
36
  stringInput: z.string().optional(),
37
- stringRadio: z.enum(['a', 'b', 'c'])
37
+ stringRadio: z.enum(['a', 'b', 'c']).optional()
38
38
  });
39
39
  type ExampleFormSchemaType = typeof $ExampleFormData;
40
40
  type ExampleFormData = z.TypeOf<typeof $ExampleFormData>;
@@ -79,9 +79,7 @@ const numberFields: FormFields<Pick<ExampleFormData, 'numberInput' | 'numberRadi
79
79
  numberInput: {
80
80
  description: 'This is a number field',
81
81
  kind: 'number',
82
- label: 'Input',
83
- max: 10,
84
- min: 0,
82
+ label: 'Number Input',
85
83
  variant: 'input'
86
84
  },
87
85
  numberRadio: {
@@ -109,7 +107,7 @@ const numberFields: FormFields<Pick<ExampleFormData, 'numberInput' | 'numberRadi
109
107
  description: 'This is a number field',
110
108
  kind: 'number',
111
109
  variant: 'select',
112
- label: 'Select',
110
+ label: 'Number Select',
113
111
  options: {
114
112
  1: 'Very Low',
115
113
  2: 'Low',
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
+ import { parseNumber } from '@douglasneuroinformatics/libjs';
3
4
  import type { NumberFormField } from '@douglasneuroinformatics/libui-form-types';
4
5
  import type { Simplify } from 'type-fest';
5
6
 
@@ -17,18 +18,18 @@ export const NumberFieldInput = ({
17
18
  description,
18
19
  error,
19
20
  label,
20
- max,
21
- min,
21
+ max = Number.MAX_SAFE_INTEGER,
22
+ min = Number.MIN_SAFE_INTEGER,
22
23
  name,
23
24
  readOnly,
24
25
  setValue,
25
26
  value
26
27
  }: NumberFieldInputProps) => {
27
28
  const handleChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {
28
- const newValue = parseFloat(event.target.value);
29
+ const newValue = parseNumber(event.target.value);
29
30
  if (Number.isNaN(newValue)) {
30
31
  setValue(undefined);
31
- } else if (newValue >= (min ?? -Infinity) && newValue <= (max ?? Infinity)) {
32
+ } else if (newValue >= min && newValue <= max) {
32
33
  setValue(newValue);
33
34
  }
34
35
  };