@strictly/react-form 0.0.10 → 0.0.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.
Files changed (54) hide show
  1. package/.out/core/mobx/field_adapter_builder.js +18 -6
  2. package/.out/core/mobx/{form_presenter.d.ts → form_model.d.ts} +15 -21
  3. package/.out/core/mobx/form_model.js +513 -0
  4. package/.out/core/mobx/hooks.d.ts +6 -25
  5. package/.out/core/mobx/hooks.js +14 -50
  6. package/.out/core/mobx/merge_field_adapters_with_validators.js +1 -5
  7. package/.out/core/mobx/specs/fixtures.js +2 -1
  8. package/.out/core/mobx/specs/{form_presenter.tests.js → form_model.tests.js} +52 -43
  9. package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +2 -1
  10. package/.out/core/mobx/types.d.ts +4 -4
  11. package/.out/field_converters/integer_to_string_converter.js +12 -4
  12. package/.out/field_converters/maybe_identity_converter.js +12 -4
  13. package/.out/field_converters/nullable_to_boolean_converter.js +24 -7
  14. package/.out/field_converters/select_value_type_converter.js +36 -12
  15. package/.out/index.d.ts +1 -1
  16. package/.out/index.js +1 -1
  17. package/.out/mantine/create_checkbox.js +8 -4
  18. package/.out/mantine/create_fields_view.js +7 -4
  19. package/.out/mantine/create_form.js +1 -1
  20. package/.out/mantine/create_radio_group.js +8 -4
  21. package/.out/mantine/create_text_input.js +8 -4
  22. package/.out/mantine/create_value_input.js +8 -4
  23. package/.out/mantine/hooks.js +218 -92
  24. package/.out/mantine/specs/checkbox_hooks.stories.js +13 -1
  25. package/.out/mantine/specs/checkbox_hooks.tests.js +22 -9
  26. package/.out/mantine/specs/fields_view_hooks.stories.js +15 -2
  27. package/.out/mantine/specs/fields_view_hooks.tests.js +12 -3
  28. package/.out/mantine/specs/radio_group_hooks.stories.js +13 -1
  29. package/.out/mantine/specs/radio_group_hooks.tests.js +23 -10
  30. package/.out/mantine/specs/select_hooks.stories.js +13 -1
  31. package/.out/mantine/specs/text_input_hooks.stories.js +13 -1
  32. package/.out/mantine/specs/text_input_hooks.tests.js +18 -7
  33. package/.out/mantine/specs/value_input_hooks.stories.js +14 -2
  34. package/.out/tsconfig.tsbuildinfo +1 -1
  35. package/.out/tsup.config.js +2 -9
  36. package/.out/types/merge_validators.js +1 -4
  37. package/.out/util/partial.js +5 -5
  38. package/.out/vitest.workspace.js +2 -10
  39. package/.turbo/turbo-build.log +9 -9
  40. package/.turbo/turbo-check-types.log +1 -1
  41. package/.turbo/turbo-release$colon$exports.log +1 -1
  42. package/core/mobx/{form_presenter.ts → form_model.ts} +287 -329
  43. package/core/mobx/hooks.tsx +26 -123
  44. package/core/mobx/specs/{form_presenter.tests.ts → form_model.tests.ts} +101 -94
  45. package/core/mobx/types.ts +12 -12
  46. package/dist/index.cjs +639 -600
  47. package/dist/index.d.cts +51 -73
  48. package/dist/index.d.ts +51 -73
  49. package/dist/index.js +644 -601
  50. package/index.ts +1 -1
  51. package/mantine/hooks.tsx +2 -0
  52. package/package.json +1 -1
  53. package/.out/core/mobx/form_presenter.js +0 -422
  54. /package/.out/core/mobx/specs/{form_presenter.tests.d.ts → form_model.tests.d.ts} +0 -0
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { jsx as _jsx } from "react/jsx-runtime";
2
11
  import { composeStories } from '@storybook/react';
3
12
  import { toArray } from '@strictly/base';
@@ -18,19 +27,23 @@ describe('mantine radio group hooks', function () {
18
27
  let onFieldBlur;
19
28
  let wrapper;
20
29
  let radioGroup;
21
- beforeEach(async function () {
22
- onFieldValueChange = vi.fn();
23
- onFieldFocus = vi.fn();
24
- onFieldBlur = vi.fn();
25
- wrapper = render((_jsx(Empty, { onFieldBlur: onFieldBlur, onFieldFocus: onFieldFocus, onFieldValueChange: onFieldValueChange })));
26
- radioGroup = await wrapper.findByLabelText(RADIO_GROUP_LABEL);
30
+ beforeEach(function () {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ onFieldValueChange = vi.fn();
33
+ onFieldFocus = vi.fn();
34
+ onFieldBlur = vi.fn();
35
+ wrapper = render((_jsx(Empty, { onFieldBlur: onFieldBlur, onFieldFocus: onFieldFocus, onFieldValueChange: onFieldValueChange })));
36
+ radioGroup = yield wrapper.findByLabelText(RADIO_GROUP_LABEL);
37
+ });
27
38
  });
28
39
  describe.each(RADIO_VALUES)('selects %s', function (value) {
29
40
  let radio;
30
- beforeEach(async function () {
31
- const label = RADIO_LABELS[value];
32
- radio = await wrapper.findByLabelText(label);
33
- fireEvent.click(radio);
41
+ beforeEach(function () {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const label = RADIO_LABELS[value];
44
+ radio = yield wrapper.findByLabelText(label);
45
+ fireEvent.click(radio);
46
+ });
34
47
  });
35
48
  it('fires onFieldValueChange', function () {
36
49
  expect(onFieldValueChange).toHaveBeenCalledOnce();
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
13
  import { action } from '@storybook/addon-actions';
3
14
  import { useMantineFormFields } from 'mantine/hooks';
@@ -5,7 +16,8 @@ import { SELECT_LABEL } from './select_hooks_constant';
5
16
  function ErrorRenderer({ error }) {
6
17
  return `Error ${error}`;
7
18
  }
8
- function Component({ ...props }) {
19
+ function Component(_a) {
20
+ var props = __rest(_a, []);
9
21
  const form = useMantineFormFields(props);
10
22
  const SelectComponent = form.select('$');
11
23
  return (_jsx(SelectComponent, { ErrorRenderer: ErrorRenderer, data: [
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
13
  import { PillsInputField, Textarea, } from '@mantine/core';
3
14
  import { action } from '@storybook/addon-actions';
@@ -6,7 +17,8 @@ import { TEXT_INPUT_LABEL } from './text_input_constants';
6
17
  function ErrorRenderer({ error }) {
7
18
  return `error ${error}`;
8
19
  }
9
- function Component({ TextInput, ...props }) {
20
+ function Component(_a) {
21
+ var { TextInput } = _a, props = __rest(_a, ["TextInput"]);
10
22
  const form = useMantineFormFields(props);
11
23
  const TextInputComponent = form.textInput('$', TextInput);
12
24
  return (_jsx(TextInputComponent, { ErrorRenderer: ErrorRenderer, label: TEXT_INPUT_LABEL }));
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { jsx as _jsx } from "react/jsx-runtime";
2
11
  import { composeStories } from '@storybook/react';
3
12
  import { toArray } from '@strictly/base';
@@ -19,13 +28,15 @@ describe('mantine checkbox hooks', function () {
19
28
  let onFieldSubmit;
20
29
  let wrapper;
21
30
  let textInput;
22
- beforeEach(async function () {
23
- onFieldValueChange = vi.fn();
24
- onFieldFocus = vi.fn();
25
- onFieldBlur = vi.fn();
26
- onFieldSubmit = vi.fn();
27
- wrapper = render((_jsx(Populated, { onFieldBlur: onFieldBlur, onFieldFocus: onFieldFocus, onFieldSubmit: onFieldSubmit, onFieldValueChange: onFieldValueChange })));
28
- textInput = await wrapper.findByLabelText(TEXT_INPUT_LABEL);
31
+ beforeEach(function () {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ onFieldValueChange = vi.fn();
34
+ onFieldFocus = vi.fn();
35
+ onFieldBlur = vi.fn();
36
+ onFieldSubmit = vi.fn();
37
+ wrapper = render((_jsx(Populated, { onFieldBlur: onFieldBlur, onFieldFocus: onFieldFocus, onFieldSubmit: onFieldSubmit, onFieldValueChange: onFieldValueChange })));
38
+ textInput = yield wrapper.findByLabelText(TEXT_INPUT_LABEL);
39
+ });
29
40
  });
30
41
  it('fires change event', function () {
31
42
  const value = 'new value';
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
13
  import { JsonInput, NumberInput, Rating, Slider, } from '@mantine/core';
3
14
  import { action } from '@storybook/addon-actions';
@@ -6,10 +17,11 @@ import { NUMBER_INPUT_LABEL, SLIDER_LABEL, } from './value_input_constants';
6
17
  function ErrorRenderer({ error }) {
7
18
  return `error ${error}`;
8
19
  }
9
- function Component({ ValueInput, inputProps, ...props }) {
20
+ function Component(_a) {
21
+ var { ValueInput, inputProps } = _a, props = __rest(_a, ["ValueInput", "inputProps"]);
10
22
  const form = useMantineFormFields(props);
11
23
  const ValueInputComponent = form.valueInput('$', ValueInput);
12
- return (_jsx(ValueInputComponent, { ...inputProps, ErrorRenderer: ErrorRenderer }));
24
+ return (_jsx(ValueInputComponent, Object.assign({}, inputProps, { ErrorRenderer: ErrorRenderer })));
13
25
  }
14
26
  const meta = {
15
27
  component: Component,