react-science 23.0.0 → 23.1.0

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.
Files changed (32) hide show
  1. package/lib/components/form/components/field_groups/svg_line_style.d.ts +2 -0
  2. package/lib/components/form/components/field_groups/svg_line_style.d.ts.map +1 -1
  3. package/lib/components/form/components/field_groups/svg_text_style.d.ts +2 -0
  4. package/lib/components/form/components/field_groups/svg_text_style.d.ts.map +1 -1
  5. package/lib/components/form/components/input/textarea.d.ts +7 -0
  6. package/lib/components/form/components/input/textarea.d.ts.map +1 -0
  7. package/lib/components/form/components/input/textarea.js +22 -0
  8. package/lib/components/form/components/input/textarea.js.map +1 -0
  9. package/lib/components/form/components/layout/form.d.ts +1 -0
  10. package/lib/components/form/components/layout/form.d.ts.map +1 -1
  11. package/lib/components/form/context/use_ts_form.d.ts +7 -0
  12. package/lib/components/form/context/use_ts_form.d.ts.map +1 -1
  13. package/lib/components/form/context/use_ts_form.js +2 -0
  14. package/lib/components/form/context/use_ts_form.js.map +1 -1
  15. package/lib/components/form/utils/validation/coerce_number_input.d.ts +1 -1
  16. package/lib/components/form/utils/validation/coerce_number_input.d.ts.map +1 -1
  17. package/lib/components/form/utils/validation/coerce_number_input.js +7 -7
  18. package/lib/components/form/utils/validation/coerce_number_input.js.map +1 -1
  19. package/lib/components/utils/index.d.ts +1 -0
  20. package/lib/components/utils/index.d.ts.map +1 -1
  21. package/lib/components/utils/index.js +1 -0
  22. package/lib/components/utils/index.js.map +1 -1
  23. package/lib/components/utils/svg_path_builder.d.ts +67 -0
  24. package/lib/components/utils/svg_path_builder.d.ts.map +1 -0
  25. package/lib/components/utils/svg_path_builder.js +113 -0
  26. package/lib/components/utils/svg_path_builder.js.map +1 -0
  27. package/package.json +1 -1
  28. package/src/components/form/components/input/textarea.tsx +54 -0
  29. package/src/components/form/context/use_ts_form.ts +2 -0
  30. package/src/components/form/utils/validation/coerce_number_input.ts +5 -5
  31. package/src/components/utils/index.ts +1 -0
  32. package/src/components/utils/svg_path_builder.ts +125 -0
@@ -21,6 +21,7 @@ export declare const FieldGroupSVGLineStyleFields: <TFormData, TFields extends i
21
21
  readonly ColorPicker: typeof import("../input/color_picker.tsx").ColorPicker;
22
22
  readonly RadioGroup: typeof import("../input/radio_group.tsx").RadioGroup;
23
23
  readonly DraggableNumericInput: typeof import("../input/draggable_numeric_input.tsx").DraggableNumericInput;
24
+ readonly TextArea: typeof import("../input/textarea.tsx").TextArea;
24
25
  }, {
25
26
  readonly SubmitButton: typeof import("../input/submit_button.tsx").SubmitButton;
26
27
  readonly ResetButton: typeof import("../input/reset_button.tsx").ResetButton;
@@ -34,6 +35,7 @@ export declare const FieldGroupSVGLineStyleFields: <TFormData, TFields extends i
34
35
  readonly ColorPicker: typeof import("../input/color_picker.tsx").ColorPicker;
35
36
  readonly RadioGroup: typeof import("../input/radio_group.tsx").RadioGroup;
36
37
  readonly DraggableNumericInput: typeof import("../input/draggable_numeric_input.tsx").DraggableNumericInput;
38
+ readonly TextArea: typeof import("../input/textarea.tsx").TextArea;
37
39
  }, {
38
40
  readonly SubmitButton: typeof import("../input/submit_button.tsx").SubmitButton;
39
41
  readonly ResetButton: typeof import("../input/reset_button.tsx").ResetButton;
@@ -1 +1 @@
1
- {"version":3,"file":"svg_line_style.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/field_groups/svg_line_style.tsx"],"names":[],"mappings":"AAuBA,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;CACf;AAaD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAqCvC,CAAC"}
1
+ {"version":3,"file":"svg_line_style.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/field_groups/svg_line_style.tsx"],"names":[],"mappings":"AAuBA,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;CACf;AAaD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAqCvC,CAAC"}
@@ -22,6 +22,7 @@ export declare const FieldGroupSVGTextStyleFields: <TFormData, TFields extends i
22
22
  readonly ColorPicker: typeof import("../input/color_picker.tsx").ColorPicker;
23
23
  readonly RadioGroup: typeof import("../input/radio_group.tsx").RadioGroup;
24
24
  readonly DraggableNumericInput: typeof import("../input/draggable_numeric_input.tsx").DraggableNumericInput;
25
+ readonly TextArea: typeof import("../input/textarea.tsx").TextArea;
25
26
  }, {
26
27
  readonly SubmitButton: typeof import("../input/submit_button.tsx").SubmitButton;
27
28
  readonly ResetButton: typeof import("../input/reset_button.tsx").ResetButton;
@@ -35,6 +36,7 @@ export declare const FieldGroupSVGTextStyleFields: <TFormData, TFields extends i
35
36
  readonly ColorPicker: typeof import("../input/color_picker.tsx").ColorPicker;
36
37
  readonly RadioGroup: typeof import("../input/radio_group.tsx").RadioGroup;
37
38
  readonly DraggableNumericInput: typeof import("../input/draggable_numeric_input.tsx").DraggableNumericInput;
39
+ readonly TextArea: typeof import("../input/textarea.tsx").TextArea;
38
40
  }, {
39
41
  readonly SubmitButton: typeof import("../input/submit_button.tsx").SubmitButton;
40
42
  readonly ResetButton: typeof import("../input/reset_button.tsx").ResetButton;
@@ -1 +1 @@
1
- {"version":3,"file":"svg_text_style.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/field_groups/svg_text_style.tsx"],"names":[],"mappings":"AAyBA,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDA4DvC,CAAC"}
1
+ {"version":3,"file":"svg_text_style.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/field_groups/svg_text_style.tsx"],"names":[],"mappings":"AAyBA,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDA4DvC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { TextAreaProps as BPTextAreaProps } from '@blueprintjs/core';
2
+ import type { FormGroupInputProps } from '../input_groups/index.ts';
3
+ interface TextAreaProps extends FormGroupInputProps, BPTextAreaProps {
4
+ }
5
+ export declare function TextArea(props: TextAreaProps): import("react").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/input/textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAM1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,UAAU,aAAc,SAAQ,mBAAmB,EAAE,eAAe;CAAG;AAOvE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,+BAqC5C"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TextArea as BPTextArea } from '@blueprintjs/core';
3
+ import styled from '@emotion/styled';
4
+ import { useFieldContext } from "../../context/use_ts_form.js";
5
+ import { FormGroup } from "../input_groups/index.js";
6
+ const ResizeableTextArea = styled(BPTextArea) `
7
+ resize: both;
8
+ max-width: 100%;
9
+ `;
10
+ export function TextArea(props) {
11
+ const { label, required, helpText, layout, fullWidth, ...otherProps } = props;
12
+ const field = useFieldContext();
13
+ const error = field
14
+ .getMeta()
15
+ .errors.map((e) => e.message)
16
+ .at(0);
17
+ function onChange(event) {
18
+ return field.handleChange(event.target.value);
19
+ }
20
+ return (_jsx(FormGroup, { name: field.name, label: label, intent: error ? 'danger' : 'none', required: required, error: error, helpText: helpText, layout: layout, fullWidth: fullWidth, contentFullWidth: true, children: _jsx(ResizeableTextArea, { ...otherProps, id: field.name, name: field.name, onChange: onChange, onBlur: field.handleBlur, intent: error ? 'danger' : 'none', value: field.state.value, required: required }) }));
21
+ }
22
+ //# sourceMappingURL=textarea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../../../src/components/form/components/input/textarea.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAIrD,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;;;CAG5C,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAE9E,MAAM,KAAK,GAAG,eAAe,EAAU,CAAC;IACxC,MAAM,KAAK,GAAG,KAAK;SAChB,OAAO,EAAE;SACT,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;SAC5B,EAAE,CAAC,CAAC,CAAC,CAAC;IAET,SAAS,QAAQ,CAAC,KAAuC;QACvD,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,CACL,KAAC,SAAS,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EACjC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,gBAAgB,kBAEhB,KAAC,kBAAkB,OACb,UAAU,EACd,EAAE,EAAE,KAAK,CAAC,IAAI,EACd,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,KAAK,CAAC,UAAU,EACxB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EACjC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EACxB,QAAQ,EAAE,QAAQ,GAClB,GACQ,CACb,CAAC;AACJ,CAAC"}
@@ -31,6 +31,7 @@ export declare const AppForm: MinimalFunctionComponent<MinimalProps<import("reac
31
31
  readonly ColorPicker: typeof import("../input/color_picker.tsx").ColorPicker;
32
32
  readonly RadioGroup: typeof import("../input/radio_group.tsx").RadioGroup;
33
33
  readonly DraggableNumericInput: typeof import("../input/draggable_numeric_input.tsx").DraggableNumericInput;
34
+ readonly TextArea: typeof import("../input/textarea.tsx").TextArea;
34
35
  }, {
35
36
  readonly SubmitButton: typeof import("../input/submit_button.tsx").SubmitButton;
36
37
  readonly ResetButton: typeof import("../input/reset_button.tsx").ResetButton;
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/layout/form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,KAAK,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGzE,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC;IACpE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;OAOG;IAGH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,eAAe,EAAE,WAAW,CAAC,KAAK,GAAG,CAAC;IAE5E;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAWD;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;IAuCnB,CAAC;AAEF,KAAK,YAAY,CAAC,KAAK,SAAS;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG;IACzE;;OAEG;IACH,IAAI,EAAE,IAAI,CACR,KAAK,CAAC,MAAM,CAAC,EAKb,gBAAgB,GAAG,kBAAkB,GAAG,mBAAmB,CAC5D,CAAC;CACH,CAAC;AACF,KAAK,wBAAwB,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC"}
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/layout/form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,KAAK,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGzE,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC;IACpE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;OAOG;IAGH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,eAAe,EAAE,WAAW,CAAC,KAAK,GAAG,CAAC;IAE5E;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAWD;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;IAuCnB,CAAC;AAEF,KAAK,YAAY,CAAC,KAAK,SAAS;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG;IACzE;;OAEG;IACH,IAAI,EAAE,IAAI,CACR,KAAK,CAAC,MAAM,CAAC,EAKb,gBAAgB,GAAG,kBAAkB,GAAG,mBAAmB,CAC5D,CAAC;CACH,CAAC;AACF,KAAK,wBAAwB,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC"}
@@ -8,6 +8,7 @@ import { ResetButton } from '../components/input/reset_button.js';
8
8
  import { Select } from '../components/input/select.js';
9
9
  import { SubmitButton } from '../components/input/submit_button.js';
10
10
  import { Switch } from '../components/input/switch.js';
11
+ import { TextArea } from '../components/input/textarea.tsx';
11
12
  import { Section } from '../components/layout/Section.js';
12
13
  declare const useFormContext: () => import("@tanstack/react-form").ReactFormExtendedApi<Record<string, never>, any, any, any, any, any, any, any, any, any, any, any>, useFieldContext: <TData>() => import("@tanstack/react-form").FieldApi<any, string, TData, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
13
14
  declare const withForm: <TFormData, TOnMount extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChange extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TSubmitMeta, TRenderProps extends object = {}>({ render, props, }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
@@ -19,6 +20,7 @@ declare const withForm: <TFormData, TOnMount extends import("@tanstack/react-for
19
20
  readonly ColorPicker: typeof ColorPicker;
20
21
  readonly RadioGroup: typeof RadioGroup;
21
22
  readonly DraggableNumericInput: typeof DraggableNumericInput;
23
+ readonly TextArea: typeof TextArea;
22
24
  }, {
23
25
  readonly SubmitButton: typeof SubmitButton;
24
26
  readonly ResetButton: typeof ResetButton;
@@ -33,6 +35,7 @@ declare const withForm: <TFormData, TOnMount extends import("@tanstack/react-for
33
35
  readonly ColorPicker: typeof ColorPicker;
34
36
  readonly RadioGroup: typeof RadioGroup;
35
37
  readonly DraggableNumericInput: typeof DraggableNumericInput;
38
+ readonly TextArea: typeof TextArea;
36
39
  }, {
37
40
  readonly SubmitButton: typeof SubmitButton;
38
41
  readonly ResetButton: typeof ResetButton;
@@ -47,6 +50,7 @@ declare const withForm: <TFormData, TOnMount extends import("@tanstack/react-for
47
50
  readonly ColorPicker: typeof ColorPicker;
48
51
  readonly RadioGroup: typeof RadioGroup;
49
52
  readonly DraggableNumericInput: typeof DraggableNumericInput;
53
+ readonly TextArea: typeof TextArea;
50
54
  }, {
51
55
  readonly SubmitButton: typeof SubmitButton;
52
56
  readonly ResetButton: typeof ResetButton;
@@ -61,6 +65,7 @@ declare const withForm: <TFormData, TOnMount extends import("@tanstack/react-for
61
65
  readonly ColorPicker: typeof ColorPicker;
62
66
  readonly RadioGroup: typeof RadioGroup;
63
67
  readonly DraggableNumericInput: typeof DraggableNumericInput;
68
+ readonly TextArea: typeof TextArea;
64
69
  }, {
65
70
  readonly SubmitButton: typeof SubmitButton;
66
71
  readonly ResetButton: typeof ResetButton;
@@ -74,6 +79,7 @@ declare const withForm: <TFormData, TOnMount extends import("@tanstack/react-for
74
79
  readonly ColorPicker: typeof ColorPicker;
75
80
  readonly RadioGroup: typeof RadioGroup;
76
81
  readonly DraggableNumericInput: typeof DraggableNumericInput;
82
+ readonly TextArea: typeof TextArea;
77
83
  }, {
78
84
  readonly SubmitButton: typeof SubmitButton;
79
85
  readonly ResetButton: typeof ResetButton;
@@ -90,6 +96,7 @@ export declare const useForm: <TFormData, TOnMount extends import("@tanstack/rea
90
96
  readonly ColorPicker: typeof ColorPicker;
91
97
  readonly RadioGroup: typeof RadioGroup;
92
98
  readonly DraggableNumericInput: typeof DraggableNumericInput;
99
+ readonly TextArea: typeof TextArea;
93
100
  }, {
94
101
  readonly SubmitButton: typeof SubmitButton;
95
102
  readonly ResetButton: typeof ResetButton;
@@ -1 +1 @@
1
- {"version":3,"file":"use_ts_form.d.ts","sourceRoot":"","sources":["../../../../src/components/form/context/use_ts_form.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE1D,QAAA,MAAQ,cAAc,2IAAE,eAAe,8KACb,CAAC;AAS3B,QAAA,MAAoB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAkB1C,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;EAAa,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"use_ts_form.d.ts","sourceRoot":"","sources":["../../../../src/components/form/context/use_ts_form.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE1D,QAAA,MAAQ,cAAc,2IAAE,eAAe,8KACb,CAAC;AAS3B,QAAA,MAAoB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAmB1C,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;EAAa,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC"}
@@ -9,6 +9,7 @@ import { ResetButton } from '../components/input/reset_button.js';
9
9
  import { Select } from '../components/input/select.js';
10
10
  import { SubmitButton } from '../components/input/submit_button.js';
11
11
  import { Switch } from '../components/input/switch.js';
12
+ import { TextArea } from "../components/input/textarea.js";
12
13
  import { Section } from '../components/layout/Section.js';
13
14
  const { useFormContext, useFieldContext, formContext, fieldContext } = createFormHookContexts();
14
15
  /*
@@ -35,6 +36,7 @@ const { useAppForm, withForm, withFieldGroup } = createFormHook({
35
36
  ColorPicker,
36
37
  RadioGroup,
37
38
  DraggableNumericInput,
39
+ TextArea,
38
40
  },
39
41
  });
40
42
  export const useForm = useAppForm;
@@ -1 +1 @@
1
- {"version":3,"file":"use_ts_form.js","sourceRoot":"","sources":["../../../../src/components/form/context/use_ts_form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAsC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE1D,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,GAClE,sBAAsB,EAAE,CAAC;AAE3B;;;;;;GAMG;AACH,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC;IAC9D,YAAY;IACZ,WAAW;IACX,cAAc,EAAE;QACd,YAAY;QACZ,WAAW;QACX,OAAO;KACR;IACD,eAAe,EAAE;QACf,KAAK;QACL,YAAY;QACZ,QAAQ;QACR,MAAM;QACN,MAAM;QACN,WAAW;QACX,UAAU;QACV,qBAAqB;KACtB;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"use_ts_form.js","sourceRoot":"","sources":["../../../../src/components/form/context/use_ts_form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAsC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAkC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE1D,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,GAClE,sBAAsB,EAAE,CAAC;AAE3B;;;;;;GAMG;AACH,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC;IAC9D,YAAY;IACZ,WAAW;IACX,cAAc,EAAE;QACd,YAAY;QACZ,WAAW;QACX,OAAO;KACR;IACD,eAAe,EAAE;QACf,KAAK;QACL,YAAY;QACZ,QAAQ;QACR,MAAM;QACN,MAAM;QACN,WAAW;QACX,UAAU;QACV,qBAAqB;QACrB,QAAQ;KACT;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { z } from 'zod';
2
- export declare function coerceNumberInput(schema?: z.ZodNumber): z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
2
+ export declare function coerceNumberInput(schema?: z.ZodNumber): z.ZodCodec<z.ZodString, z.ZodNumber>;
3
3
  //# sourceMappingURL=coerce_number_input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coerce_number_input.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/utils/validation/coerce_number_input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAgB,iBAAiB,CAAC,MAAM,cAAa,kFAQpD"}
1
+ {"version":3,"file":"coerce_number_input.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/utils/validation/coerce_number_input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAgB,iBAAiB,CAAC,MAAM,cAAa,wCAQpD"}
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  export function coerceNumberInput(schema = z.number()) {
3
- return z
4
- .string()
5
- .transform((value) => {
6
- const number = Number(value);
7
- return Number.isNaN(number) ? 0 : number;
8
- })
9
- .pipe(schema);
3
+ return z.codec(z.string(), schema, {
4
+ decode: (value) => {
5
+ const number = Number(value);
6
+ return Number.isNaN(number) ? 0 : number;
7
+ },
8
+ encode: String,
9
+ });
10
10
  }
11
11
  //# sourceMappingURL=coerce_number_input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coerce_number_input.js","sourceRoot":"","sources":["../../../../../src/components/form/utils/validation/coerce_number_input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE;IACnD,OAAO,CAAC;SACL,MAAM,EAAE;SACR,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"coerce_number_input.js","sourceRoot":"","sources":["../../../../../src/components/form/utils/validation/coerce_number_input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE;IACnD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE;QACjC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC3C,CAAC;QACD,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;AACL,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './debounce.js';
2
2
  export * from './throttle.js';
3
3
  export * from './svg.js';
4
+ export * from './svg_path_builder.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './debounce.js';
2
2
  export * from './throttle.js';
3
3
  export * from './svg.js';
4
+ export * from './svg_path_builder.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * A basic svg path line command builder.
3
+ * It supports the following commands:
4
+ * - moveTo (absolute coordinates)
5
+ * - lineTo (absolute coordinates)
6
+ * - closePath
7
+ *
8
+ * Coordinates are clamped in the [-clampValue; clampValue] interval.
9
+ * `clampValue` is the first argument given to the constructor.
10
+ * `clampValue` is a public property.
11
+ *
12
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorials/SVG_from_scratch/Paths#line_commands
13
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d
14
+ */
15
+ export declare class SVGPathBuilder {
16
+ #private;
17
+ clampValue: number | null;
18
+ /**
19
+ * @param clampValue - All `x` and `y` values passed to moveTo and lineTo commands
20
+ * will be clamped to this value. `x < -clampValue` set `x` to `-clampValue`
21
+ * `x > clampValue` set `x` to `clampValue`.
22
+ * Set null to disable this behavior.
23
+ * defaults to `1e5`
24
+ */
25
+ constructor(clampValue?: number | null);
26
+ /**
27
+ * Get a shallow copy of internal the buffer.
28
+ *
29
+ * @param sliceArgs
30
+ */
31
+ getBufferSlice(...sliceArgs: [start?: number, end?: number]): string[];
32
+ /**
33
+ * Absolute move to
34
+ *
35
+ * @param x
36
+ * @param y
37
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#moveto_path_commands
38
+ */
39
+ moveTo(x: number, y: number): this;
40
+ /**
41
+ * Absolute line to
42
+ *
43
+ * @param x
44
+ * @param y
45
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#lineto_path_commands
46
+ */
47
+ lineTo(x: number, y: number): this;
48
+ /**
49
+ * Close the path, no-op if buffer is empty.
50
+ *
51
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#closepath
52
+ */
53
+ closePath(): this;
54
+ /**
55
+ * Serialize the buffer into paths commands.
56
+ *
57
+ * @param separator - default value is debug friendly (new-line + two spaces).
58
+ */
59
+ toString(separator?: string): string;
60
+ /**
61
+ * Merge many path builders into a new single one.
62
+ *
63
+ * @param builders
64
+ */
65
+ static concat(...builders: SVGPathBuilder[]): SVGPathBuilder;
66
+ }
67
+ //# sourceMappingURL=svg_path_builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg_path_builder.d.ts","sourceRoot":"","sources":["../../../src/components/utils/svg_path_builder.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc;;IAEzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;;;;;OAMG;gBACS,UAAU,GAAE,MAAM,GAAG,IAA0B;IAqB3D;;;;OAIG;IACH,cAAc,CAAC,GAAG,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAI3D;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAQlC;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAQlC;;;;OAIG;IACH,SAAS,IAAI,IAAI;IAOjB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,SAAoB,GAAG,MAAM;IAI/C;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc;CAS7D"}
@@ -0,0 +1,113 @@
1
+ /** Better dom readability */
2
+ const DEFAULT_SEPARATOR = '\n ';
3
+ const DEFAULT_CLAMP_VALUE = 1e5;
4
+ /**
5
+ * A basic svg path line command builder.
6
+ * It supports the following commands:
7
+ * - moveTo (absolute coordinates)
8
+ * - lineTo (absolute coordinates)
9
+ * - closePath
10
+ *
11
+ * Coordinates are clamped in the [-clampValue; clampValue] interval.
12
+ * `clampValue` is the first argument given to the constructor.
13
+ * `clampValue` is a public property.
14
+ *
15
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorials/SVG_from_scratch/Paths#line_commands
16
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d
17
+ */
18
+ export class SVGPathBuilder {
19
+ #buffer = [];
20
+ clampValue;
21
+ /**
22
+ * @param clampValue - All `x` and `y` values passed to moveTo and lineTo commands
23
+ * will be clamped to this value. `x < -clampValue` set `x` to `-clampValue`
24
+ * `x > clampValue` set `x` to `clampValue`.
25
+ * Set null to disable this behavior.
26
+ * defaults to `1e5`
27
+ */
28
+ constructor(clampValue = DEFAULT_CLAMP_VALUE) {
29
+ this.clampValue = clampValue;
30
+ }
31
+ #appendPath(segment) {
32
+ this.#buffer.push(segment);
33
+ }
34
+ /**
35
+ * Clamp values to avoid rendering issues of the SVG.
36
+ * This assumes that the viewport has pixel coordinates
37
+ * (so the max values are outside of the visible area)
38
+ */
39
+ #clamp(value) {
40
+ const cv = this.clampValue;
41
+ if (cv === null)
42
+ return value;
43
+ if (value < -cv)
44
+ return -cv;
45
+ if (value > cv)
46
+ return cv;
47
+ return value;
48
+ }
49
+ /**
50
+ * Get a shallow copy of internal the buffer.
51
+ *
52
+ * @param sliceArgs
53
+ */
54
+ getBufferSlice(...sliceArgs) {
55
+ return this.#buffer.slice(...sliceArgs);
56
+ }
57
+ /**
58
+ * Absolute move to
59
+ *
60
+ * @param x
61
+ * @param y
62
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#moveto_path_commands
63
+ */
64
+ moveTo(x, y) {
65
+ x = this.#clamp(x);
66
+ y = this.#clamp(y);
67
+ this.#appendPath(`M ${x} ${y}`);
68
+ return this;
69
+ }
70
+ /**
71
+ * Absolute line to
72
+ *
73
+ * @param x
74
+ * @param y
75
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#lineto_path_commands
76
+ */
77
+ lineTo(x, y) {
78
+ x = this.#clamp(x);
79
+ y = this.#clamp(y);
80
+ this.#appendPath(`L ${x} ${y}`);
81
+ return this;
82
+ }
83
+ /**
84
+ * Close the path, no-op if buffer is empty.
85
+ *
86
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#closepath
87
+ */
88
+ closePath() {
89
+ if (this.#buffer.length === 0)
90
+ return this;
91
+ this.#appendPath('Z');
92
+ return this;
93
+ }
94
+ /**
95
+ * Serialize the buffer into paths commands.
96
+ *
97
+ * @param separator - default value is debug friendly (new-line + two spaces).
98
+ */
99
+ toString(separator = DEFAULT_SEPARATOR) {
100
+ return this.#buffer.join(separator);
101
+ }
102
+ /**
103
+ * Merge many path builders into a new single one.
104
+ *
105
+ * @param builders
106
+ */
107
+ static concat(...builders) {
108
+ const builder = new SVGPathBuilder();
109
+ builder.#buffer = builder.#buffer.concat(builders.flatMap((path) => path.getBufferSlice()));
110
+ return builder;
111
+ }
112
+ }
113
+ //# sourceMappingURL=svg_path_builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg_path_builder.js","sourceRoot":"","sources":["../../../src/components/utils/svg_path_builder.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAAc;IACzB,OAAO,GAAa,EAAE,CAAC;IACvB,UAAU,CAAgB;IAE1B;;;;;;OAMG;IACH,YAAY,aAA4B,mBAAmB;QACzD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,WAAW,CAAC,OAAe;QACzB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAa;QAClB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;QAC3B,IAAI,EAAE,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,KAAK,GAAG,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,CAAC;QAC5B,IAAI,KAAK,GAAG,EAAE;YAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,GAAG,SAAyC;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC3C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,SAAS,GAAG,iBAAiB;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,QAA0B;QACzC,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QAErC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CACtC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAClD,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-science",
3
- "version": "23.0.0",
3
+ "version": "23.1.0",
4
4
  "description": "React components to build scientific applications UI",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,54 @@
1
+ import type { TextAreaProps as BPTextAreaProps } from '@blueprintjs/core';
2
+ import { TextArea as BPTextArea } from '@blueprintjs/core';
3
+ import styled from '@emotion/styled';
4
+ import type { ChangeEvent } from 'react';
5
+
6
+ import { useFieldContext } from '../../context/use_ts_form.ts';
7
+ import type { FormGroupInputProps } from '../input_groups/index.ts';
8
+ import { FormGroup } from '../input_groups/index.ts';
9
+
10
+ interface TextAreaProps extends FormGroupInputProps, BPTextAreaProps {}
11
+
12
+ const ResizeableTextArea = styled(BPTextArea)`
13
+ resize: both;
14
+ max-width: 100%;
15
+ `;
16
+
17
+ export function TextArea(props: TextAreaProps) {
18
+ const { label, required, helpText, layout, fullWidth, ...otherProps } = props;
19
+
20
+ const field = useFieldContext<string>();
21
+ const error = field
22
+ .getMeta()
23
+ .errors.map((e) => e.message)
24
+ .at(0);
25
+
26
+ function onChange(event: ChangeEvent<HTMLTextAreaElement>) {
27
+ return field.handleChange(event.target.value);
28
+ }
29
+
30
+ return (
31
+ <FormGroup
32
+ name={field.name}
33
+ label={label}
34
+ intent={error ? 'danger' : 'none'}
35
+ required={required}
36
+ error={error}
37
+ helpText={helpText}
38
+ layout={layout}
39
+ fullWidth={fullWidth}
40
+ contentFullWidth
41
+ >
42
+ <ResizeableTextArea
43
+ {...otherProps}
44
+ id={field.name}
45
+ name={field.name}
46
+ onChange={onChange}
47
+ onBlur={field.handleBlur}
48
+ intent={error ? 'danger' : 'none'}
49
+ value={field.state.value}
50
+ required={required}
51
+ />
52
+ </FormGroup>
53
+ );
54
+ }
@@ -10,6 +10,7 @@ import { ResetButton } from '../components/input/reset_button.js';
10
10
  import { Select } from '../components/input/select.js';
11
11
  import { SubmitButton } from '../components/input/submit_button.js';
12
12
  import { Switch } from '../components/input/switch.js';
13
+ import { TextArea } from '../components/input/textarea.tsx';
13
14
  import { Section } from '../components/layout/Section.js';
14
15
 
15
16
  const { useFormContext, useFieldContext, formContext, fieldContext } =
@@ -39,6 +40,7 @@ const { useAppForm, withForm, withFieldGroup } = createFormHook({
39
40
  ColorPicker,
40
41
  RadioGroup,
41
42
  DraggableNumericInput,
43
+ TextArea,
42
44
  },
43
45
  });
44
46
 
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  export function coerceNumberInput(schema = z.number()) {
4
- return z
5
- .string()
6
- .transform((value) => {
4
+ return z.codec(z.string(), schema, {
5
+ decode: (value) => {
7
6
  const number = Number(value);
8
7
  return Number.isNaN(number) ? 0 : number;
9
- })
10
- .pipe(schema);
8
+ },
9
+ encode: String,
10
+ });
11
11
  }
@@ -1,3 +1,4 @@
1
1
  export * from './debounce.js';
2
2
  export * from './throttle.js';
3
3
  export * from './svg.js';
4
+ export * from './svg_path_builder.js';
@@ -0,0 +1,125 @@
1
+ /** Better dom readability */
2
+ const DEFAULT_SEPARATOR = '\n ';
3
+ const DEFAULT_CLAMP_VALUE = 1e5;
4
+
5
+ /**
6
+ * A basic svg path line command builder.
7
+ * It supports the following commands:
8
+ * - moveTo (absolute coordinates)
9
+ * - lineTo (absolute coordinates)
10
+ * - closePath
11
+ *
12
+ * Coordinates are clamped in the [-clampValue; clampValue] interval.
13
+ * `clampValue` is the first argument given to the constructor.
14
+ * `clampValue` is a public property.
15
+ *
16
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorials/SVG_from_scratch/Paths#line_commands
17
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d
18
+ */
19
+ export class SVGPathBuilder {
20
+ #buffer: string[] = [];
21
+ clampValue: number | null;
22
+
23
+ /**
24
+ * @param clampValue - All `x` and `y` values passed to moveTo and lineTo commands
25
+ * will be clamped to this value. `x < -clampValue` set `x` to `-clampValue`
26
+ * `x > clampValue` set `x` to `clampValue`.
27
+ * Set null to disable this behavior.
28
+ * defaults to `1e5`
29
+ */
30
+ constructor(clampValue: number | null = DEFAULT_CLAMP_VALUE) {
31
+ this.clampValue = clampValue;
32
+ }
33
+
34
+ #appendPath(segment: string) {
35
+ this.#buffer.push(segment);
36
+ }
37
+
38
+ /**
39
+ * Clamp values to avoid rendering issues of the SVG.
40
+ * This assumes that the viewport has pixel coordinates
41
+ * (so the max values are outside of the visible area)
42
+ */
43
+ #clamp(value: number) {
44
+ const cv = this.clampValue;
45
+ if (cv === null) return value;
46
+ if (value < -cv) return -cv;
47
+ if (value > cv) return cv;
48
+ return value;
49
+ }
50
+
51
+ /**
52
+ * Get a shallow copy of internal the buffer.
53
+ *
54
+ * @param sliceArgs
55
+ */
56
+ getBufferSlice(...sliceArgs: [start?: number, end?: number]) {
57
+ return this.#buffer.slice(...sliceArgs);
58
+ }
59
+
60
+ /**
61
+ * Absolute move to
62
+ *
63
+ * @param x
64
+ * @param y
65
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#moveto_path_commands
66
+ */
67
+ moveTo(x: number, y: number): this {
68
+ x = this.#clamp(x);
69
+ y = this.#clamp(y);
70
+ this.#appendPath(`M ${x} ${y}`);
71
+
72
+ return this;
73
+ }
74
+
75
+ /**
76
+ * Absolute line to
77
+ *
78
+ * @param x
79
+ * @param y
80
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#lineto_path_commands
81
+ */
82
+ lineTo(x: number, y: number): this {
83
+ x = this.#clamp(x);
84
+ y = this.#clamp(y);
85
+ this.#appendPath(`L ${x} ${y}`);
86
+
87
+ return this;
88
+ }
89
+
90
+ /**
91
+ * Close the path, no-op if buffer is empty.
92
+ *
93
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/d#closepath
94
+ */
95
+ closePath(): this {
96
+ if (this.#buffer.length === 0) return this;
97
+ this.#appendPath('Z');
98
+
99
+ return this;
100
+ }
101
+
102
+ /**
103
+ * Serialize the buffer into paths commands.
104
+ *
105
+ * @param separator - default value is debug friendly (new-line + two spaces).
106
+ */
107
+ toString(separator = DEFAULT_SEPARATOR): string {
108
+ return this.#buffer.join(separator);
109
+ }
110
+
111
+ /**
112
+ * Merge many path builders into a new single one.
113
+ *
114
+ * @param builders
115
+ */
116
+ static concat(...builders: SVGPathBuilder[]): SVGPathBuilder {
117
+ const builder = new SVGPathBuilder();
118
+
119
+ builder.#buffer = builder.#buffer.concat(
120
+ builders.flatMap((path) => path.getBufferSlice()),
121
+ );
122
+
123
+ return builder;
124
+ }
125
+ }