@douglasneuroinformatics/libui 2.0.5 → 2.0.7
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/components/Form/DynamicField.d.ts +1 -1
- package/dist/components/Form/DynamicField.d.ts.map +1 -1
- package/dist/components/Form/DynamicField.js +7 -2
- package/dist/components/Form/StringField/StringFieldInput.js +2 -2
- package/dist/components/Form/StringField/StringFieldPassword.d.ts.map +1 -1
- package/dist/components/Form/StringField/StringFieldPassword.js +2 -2
- package/dist/components/Form/StringField/StringFieldTextArea.js +2 -2
- package/dist/components/Tooltip/TooltipContent.d.ts +1 -0
- package/dist/components/Tooltip/TooltipContent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Form/DynamicField.tsx +8 -1
- package/src/components/Form/StringField/StringFieldInput.tsx +2 -2
- package/src/components/Form/StringField/StringFieldPassword.tsx +2 -1
- package/src/components/Form/StringField/StringFieldTextArea.tsx +2 -2
- package/src/components/Tooltip/TooltipContent.tsx +1 -0
|
@@ -9,5 +9,5 @@ export type DynamicFieldProps<TData extends FormDataType> = {
|
|
|
9
9
|
setValues: React.Dispatch<React.SetStateAction<PartialFormDataType<TData>>>;
|
|
10
10
|
values: PartialFormDataType<TData>;
|
|
11
11
|
};
|
|
12
|
-
export declare const DynamicField: <TData extends FormDataType>({ field, name, values, ...props }: DynamicFieldProps<TData>) => React.JSX.Element | null;
|
|
12
|
+
export declare const DynamicField: <TData extends FormDataType>({ field, name, setValues, values, ...props }: DynamicFieldProps<TData>) => React.JSX.Element | null;
|
|
13
13
|
//# sourceMappingURL=DynamicField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/DynamicField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,M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AAC,CAAC,CAAC,CAAC;IAC5E,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,YAAY,6EAMtB,kBAAkB,KAAK,CAAC,6BA2B1B,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { pick } from 'lodash-es';
|
|
3
3
|
import { StaticField } from './StaticField.js';
|
|
4
|
-
export const DynamicField = ({ field, name, values, ...props }) => {
|
|
4
|
+
export const DynamicField = ({ field, name, setValues, values, ...props }) => {
|
|
5
5
|
const [dependentValues, setDependentValues] = useState(pick(values, field.deps));
|
|
6
6
|
const staticField = useMemo(() => {
|
|
7
7
|
return field.render(values);
|
|
8
8
|
}, [dependentValues, field.render]);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!staticField) {
|
|
11
|
+
setValues((prevValues) => ({ ...prevValues, [name]: undefined }));
|
|
12
|
+
}
|
|
13
|
+
}, [staticField]);
|
|
9
14
|
useEffect(() => {
|
|
10
15
|
for (const key of field.deps) {
|
|
11
16
|
if (dependentValues[key] !== values[key]) {
|
|
@@ -17,5 +22,5 @@ export const DynamicField = ({ field, name, values, ...props }) => {
|
|
|
17
22
|
if (!staticField) {
|
|
18
23
|
return null;
|
|
19
24
|
}
|
|
20
|
-
return React.createElement(StaticField, { ...props, field: staticField, name: name, values: values });
|
|
25
|
+
return React.createElement(StaticField, { ...props, field: staticField, name: name, setValues: setValues, values: values });
|
|
21
26
|
};
|
|
@@ -5,8 +5,8 @@ import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
|
5
5
|
export const StringFieldInput = ({ description, error, label, name, setValue, value }) => {
|
|
6
6
|
return (React.createElement(FieldGroup, null,
|
|
7
7
|
React.createElement(FieldGroup.Row, null,
|
|
8
|
-
React.createElement(Label,
|
|
8
|
+
React.createElement(Label, { htmlFor: name }, label),
|
|
9
9
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
10
|
-
React.createElement(Input, { name: name, type: "text", value: value ?? '', onChange: (event) => setValue(event.target.value) }),
|
|
10
|
+
React.createElement(Input, { id: name, name: name, type: "text", value: value ?? '', onChange: (event) => setValue(event.target.value) }),
|
|
11
11
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringFieldPassword.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/StringField/StringFieldPassword.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAQjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,wBAAwB,GAAG,uBAAuB,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC;AAEzF,eAAO,MAAM,mBAAmB,yDAA0D,wBAAwB,
|
|
1
|
+
{"version":3,"file":"StringFieldPassword.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/StringField/StringFieldPassword.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAQjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,wBAAwB,GAAG,uBAAuB,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC;AAEzF,eAAO,MAAM,mBAAmB,yDAA0D,wBAAwB,sBA4BjH,CAAC"}
|
|
@@ -8,10 +8,10 @@ export const StringFieldPassword = ({ description, error, label, name, setValue,
|
|
|
8
8
|
const [show, setShow] = useState(false);
|
|
9
9
|
return (React.createElement(FieldGroup, null,
|
|
10
10
|
React.createElement(FieldGroup.Row, null,
|
|
11
|
-
React.createElement(Label,
|
|
11
|
+
React.createElement(Label, { htmlFor: name }, label),
|
|
12
12
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
13
13
|
React.createElement(FieldGroup.Row, null,
|
|
14
|
-
React.createElement(Input, { name: name, type: show ? 'text' : 'password', value: value ?? '', onChange: (event) => setValue(event.target.value) }),
|
|
14
|
+
React.createElement(Input, { id: name, name: name, type: show ? 'text' : 'password', value: value ?? '', onChange: (event) => setValue(event.target.value) }),
|
|
15
15
|
React.createElement("button", { className: "absolute right-0 flex h-full w-8 items-center justify-center text-muted-foreground", type: "button", onClick: () => setShow(!show) },
|
|
16
16
|
React.createElement(EyeIcon, { className: cn('absolute transition-all', show ? '-rotate-90 scale-0' : 'rotate-0 scale-100') }),
|
|
17
17
|
React.createElement(EyeOffIcon, { className: cn('absolute transition-all', !show ? 'rotate-90 scale-0' : 'rotate-0 scale-100') }))),
|
|
@@ -5,8 +5,8 @@ import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
|
5
5
|
export const StringFieldTextArea = ({ description, error, label, name, setValue, value }) => {
|
|
6
6
|
return (React.createElement(FieldGroup, null,
|
|
7
7
|
React.createElement(FieldGroup.Row, null,
|
|
8
|
-
React.createElement(Label,
|
|
8
|
+
React.createElement(Label, { htmlFor: name }, label),
|
|
9
9
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
10
|
-
React.createElement(TextArea, { name: name, rows: 5, value: value ?? '', onChange: (event) => setValue(event.target.value) }),
|
|
10
|
+
React.createElement(TextArea, { id: name, name: name, rows: 5, value: value ?? '', onChange: (event) => setValue(event.target.value) }),
|
|
11
11
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
12
12
|
};
|
|
@@ -8,6 +8,7 @@ export type TooltipContentProps = {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
/** The distance in pixels from the viewport edges where collision detection should occur */
|
|
10
10
|
collisionPadding?: number;
|
|
11
|
+
side?: 'bottom' | 'left' | 'right' | 'top';
|
|
11
12
|
/** The distance in pixels from the trigger */
|
|
12
13
|
sideOffset?: number;
|
|
13
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/TooltipContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,MAAM,mBAAmB,GAAG;IAChC,2FAA2F;IAC3F,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;IACnC,2EAA2E;IAC3E,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,cAAc,4FAe1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/TooltipContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,MAAM,mBAAmB,GAAG;IAChC,2FAA2F;IAC3F,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;IACnC,2EAA2E;IAC3E,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;IAC3C,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,cAAc,4FAe1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ export type DynamicFieldProps<TData extends FormDataType> = {
|
|
|
19
19
|
export const DynamicField = <TData extends FormDataType>({
|
|
20
20
|
field,
|
|
21
21
|
name,
|
|
22
|
+
setValues,
|
|
22
23
|
values,
|
|
23
24
|
...props
|
|
24
25
|
}: DynamicFieldProps<TData>) => {
|
|
@@ -28,6 +29,12 @@ export const DynamicField = <TData extends FormDataType>({
|
|
|
28
29
|
return field.render(values);
|
|
29
30
|
}, [dependentValues, field.render]);
|
|
30
31
|
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!staticField) {
|
|
34
|
+
setValues((prevValues) => ({ ...prevValues, [name]: undefined }));
|
|
35
|
+
}
|
|
36
|
+
}, [staticField]);
|
|
37
|
+
|
|
31
38
|
useEffect(() => {
|
|
32
39
|
for (const key of field.deps) {
|
|
33
40
|
if (dependentValues[key] !== values[key]) {
|
|
@@ -41,5 +48,5 @@ export const DynamicField = <TData extends FormDataType>({
|
|
|
41
48
|
return null;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
return <StaticField {...props} field={staticField} name={name} values={values} />;
|
|
51
|
+
return <StaticField {...props} field={staticField} name={name} setValues={setValues} values={values} />;
|
|
45
52
|
};
|
|
@@ -14,10 +14,10 @@ export const StringFieldInput = ({ description, error, label, name, setValue, va
|
|
|
14
14
|
return (
|
|
15
15
|
<FieldGroup>
|
|
16
16
|
<FieldGroup.Row>
|
|
17
|
-
<Label>{label}</Label>
|
|
17
|
+
<Label htmlFor={name}>{label}</Label>
|
|
18
18
|
<FieldGroup.Description description={description} />
|
|
19
19
|
</FieldGroup.Row>
|
|
20
|
-
<Input name={name} type="text" value={value ?? ''} onChange={(event) => setValue(event.target.value)} />
|
|
20
|
+
<Input id={name} name={name} type="text" value={value ?? ''} onChange={(event) => setValue(event.target.value)} />
|
|
21
21
|
<FieldGroup.Error error={error} />
|
|
22
22
|
</FieldGroup>
|
|
23
23
|
);
|
|
@@ -17,11 +17,12 @@ export const StringFieldPassword = ({ description, error, label, name, setValue,
|
|
|
17
17
|
return (
|
|
18
18
|
<FieldGroup>
|
|
19
19
|
<FieldGroup.Row>
|
|
20
|
-
<Label>{label}</Label>
|
|
20
|
+
<Label htmlFor={name}>{label}</Label>
|
|
21
21
|
<FieldGroup.Description description={description} />
|
|
22
22
|
</FieldGroup.Row>
|
|
23
23
|
<FieldGroup.Row>
|
|
24
24
|
<Input
|
|
25
|
+
id={name}
|
|
25
26
|
name={name}
|
|
26
27
|
type={show ? 'text' : 'password'}
|
|
27
28
|
value={value ?? ''}
|
|
@@ -14,10 +14,10 @@ export const StringFieldTextArea = ({ description, error, label, name, setValue,
|
|
|
14
14
|
return (
|
|
15
15
|
<FieldGroup>
|
|
16
16
|
<FieldGroup.Row>
|
|
17
|
-
<Label>{label}</Label>
|
|
17
|
+
<Label htmlFor={name}>{label}</Label>
|
|
18
18
|
<FieldGroup.Description description={description} />
|
|
19
19
|
</FieldGroup.Row>
|
|
20
|
-
<TextArea name={name} rows={5} value={value ?? ''} onChange={(event) => setValue(event.target.value)} />
|
|
20
|
+
<TextArea id={name} name={name} rows={5} value={value ?? ''} onChange={(event) => setValue(event.target.value)} />
|
|
21
21
|
<FieldGroup.Error error={error} />
|
|
22
22
|
</FieldGroup>
|
|
23
23
|
);
|
|
@@ -13,6 +13,7 @@ export type TooltipContentProps = {
|
|
|
13
13
|
className?: string;
|
|
14
14
|
/** The distance in pixels from the viewport edges where collision detection should occur */
|
|
15
15
|
collisionPadding?: number;
|
|
16
|
+
side?: 'bottom' | 'left' | 'right' | 'top';
|
|
16
17
|
/** The distance in pixels from the trigger */
|
|
17
18
|
sideOffset?: number;
|
|
18
19
|
};
|