@cyclone-ui/state 0.0.12 → 0.0.13
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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/base/atoms/atom-with-broadcast.cjs +45 -1
- package/dist/base/atoms/atom-with-broadcast.mjs +45 -1
- package/dist/base/atoms/atom-with-broadcast.mjs.map +1 -1
- package/dist/base/atoms/atom-with-compare.cjs +12 -1
- package/dist/base/atoms/atom-with-compare.mjs +12 -1
- package/dist/base/atoms/atom-with-compare.mjs.map +1 -1
- package/dist/base/atoms/atom-with-debounce.cjs +52 -1
- package/dist/base/atoms/atom-with-debounce.mjs +52 -1
- package/dist/base/atoms/atom-with-debounce.mjs.map +1 -1
- package/dist/base/atoms/atom-with-effect.cjs +123 -1
- package/dist/base/atoms/atom-with-effect.mjs +120 -1
- package/dist/base/atoms/atom-with-effect.mjs.map +1 -1
- package/dist/base/atoms/atom-with-listeners.cjs +36 -1
- package/dist/base/atoms/atom-with-listeners.mjs +36 -1
- package/dist/base/atoms/atom-with-listeners.mjs.map +1 -1
- package/dist/base/atoms/atom-with-pending.cjs +14 -1
- package/dist/base/atoms/atom-with-pending.mjs +14 -1
- package/dist/base/atoms/atom-with-pending.mjs.map +1 -1
- package/dist/base/atoms/atom-with-refresh-and-default.cjs +19 -1
- package/dist/base/atoms/atom-with-refresh-and-default.mjs +19 -1
- package/dist/base/atoms/atom-with-refresh-and-default.mjs.map +1 -1
- package/dist/base/atoms/atom-with-refresh.cjs +13 -1
- package/dist/base/atoms/atom-with-refresh.mjs +13 -1
- package/dist/base/atoms/atom-with-refresh.mjs.map +1 -1
- package/dist/base/atoms/atom-with-toggle.cjs +13 -1
- package/dist/base/atoms/atom-with-toggle.mjs +13 -1
- package/dist/base/atoms/atom-with-toggle.mjs.map +1 -1
- package/dist/base/atoms/atom-with-web-storage.cjs +48 -1
- package/dist/base/atoms/atom-with-web-storage.mjs +47 -1
- package/dist/base/atoms/atom-with-web-storage.mjs.map +1 -1
- package/dist/base/atoms/atom-with-wrapper.cjs +25 -1
- package/dist/base/atoms/atom-with-wrapper.mjs +25 -1
- package/dist/base/atoms/atom-with-wrapper.mjs.map +1 -1
- package/dist/base/atoms/base-atom.cjs +25 -1
- package/dist/base/atoms/base-atom.mjs +25 -1
- package/dist/base/atoms/base-atom.mjs.map +1 -1
- package/dist/base/atoms/index.cjs +24 -1
- package/dist/base/atoms/index.mjs +13 -1
- package/dist/base/hooks/index.cjs +9 -1
- package/dist/base/hooks/index.mjs +6 -1
- package/dist/base/hooks/use-atom-effect.cjs +17 -1
- package/dist/base/hooks/use-atom-effect.mjs +17 -1
- package/dist/base/hooks/use-atom-effect.mjs.map +1 -1
- package/dist/base/hooks/use-hydrate-molecule.cjs +17 -1
- package/dist/base/hooks/use-hydrate-molecule.mjs +17 -1
- package/dist/base/hooks/use-hydrate-molecule.mjs.map +1 -1
- package/dist/base/hooks/use-prepare-atoms.cjs +20 -1
- package/dist/base/hooks/use-prepare-atoms.mjs +20 -1
- package/dist/base/hooks/use-prepare-atoms.mjs.map +1 -1
- package/dist/base/hooks/use-sync-molecule.cjs +37 -1
- package/dist/base/hooks/use-sync-molecule.mjs +37 -1
- package/dist/base/hooks/use-sync-molecule.mjs.map +1 -1
- package/dist/base/index.cjs +47 -1
- package/dist/base/index.mjs +24 -1
- package/dist/base/utilities/create-molecule.cjs +105 -4
- package/dist/base/utilities/create-molecule.d.cts.map +1 -1
- package/dist/base/utilities/create-molecule.mjs +102 -4
- package/dist/base/utilities/create-molecule.mjs.map +1 -1
- package/dist/base/utilities/create-web-storage.cjs +55 -1
- package/dist/base/utilities/create-web-storage.mjs +55 -1
- package/dist/base/utilities/create-web-storage.mjs.map +1 -1
- package/dist/base/utilities/debounce.cjs +52 -1
- package/dist/base/utilities/debounce.mjs +52 -1
- package/dist/base/utilities/debounce.mjs.map +1 -1
- package/dist/base/utilities/index.cjs +13 -1
- package/dist/base/utilities/index.mjs +6 -1
- package/dist/base/utilities/is-atom.cjs +48 -1
- package/dist/base/utilities/is-atom.mjs +46 -1
- package/dist/base/utilities/is-atom.mjs.map +1 -1
- package/dist/base/utilities/set-atom-debug.cjs +24 -1
- package/dist/base/utilities/set-atom-debug.mjs +23 -1
- package/dist/base/utilities/set-atom-debug.mjs.map +1 -1
- package/dist/client/index.cjs +16 -1
- package/dist/client/index.mjs +8 -1
- package/dist/form/atoms/atom-with-field.cjs +23 -1
- package/dist/form/atoms/atom-with-field.mjs +23 -1
- package/dist/form/atoms/atom-with-field.mjs.map +1 -1
- package/dist/form/atoms/atom-with-messages.cjs +85 -1
- package/dist/form/atoms/atom-with-messages.mjs +78 -1
- package/dist/form/atoms/atom-with-messages.mjs.map +1 -1
- package/dist/form/hooks/index.cjs +7 -1
- package/dist/form/hooks/index.mjs +5 -1
- package/dist/form/hooks/use-field-actions.cjs +92 -1
- package/dist/form/hooks/use-field-actions.mjs +92 -1
- package/dist/form/hooks/use-field-actions.mjs.map +1 -1
- package/dist/form/hooks/use-field-ref.cjs +16 -1
- package/dist/form/hooks/use-field-ref.mjs +16 -1
- package/dist/form/hooks/use-field-ref.mjs.map +1 -1
- package/dist/form/hooks/use-form-actions.cjs +69 -1
- package/dist/form/hooks/use-form-actions.mjs +69 -1
- package/dist/form/hooks/use-form-actions.mjs.map +1 -1
- package/dist/form/index.cjs +30 -1
- package/dist/form/index.mjs +17 -1
- package/dist/form/molecules/field-molecule.cjs +154 -1
- package/dist/form/molecules/field-molecule.mjs +153 -1
- package/dist/form/molecules/field-molecule.mjs.map +1 -1
- package/dist/form/molecules/form-molecule.cjs +180 -1
- package/dist/form/molecules/form-molecule.mjs +179 -1
- package/dist/form/molecules/form-molecule.mjs.map +1 -1
- package/dist/form/molecules/index.cjs +7 -1
- package/dist/form/molecules/index.mjs +4 -1
- package/dist/form/providers/FieldProvider.cjs +103 -4
- package/dist/form/providers/FieldProvider.mjs +103 -4
- package/dist/form/providers/FieldProvider.mjs.map +1 -1
- package/dist/form/providers/FormProvider.cjs +66 -4
- package/dist/form/providers/FormProvider.d.cts.map +1 -1
- package/dist/form/providers/FormProvider.mjs +66 -4
- package/dist/form/providers/FormProvider.mjs.map +1 -1
- package/dist/form/providers/index.cjs +5 -1
- package/dist/form/providers/index.mjs +4 -1
- package/dist/form/types.cjs +13 -1
- package/dist/form/types.mjs +13 -1
- package/dist/form/types.mjs.map +1 -1
- package/dist/form/utilities/abort-error.cjs +15 -1
- package/dist/form/utilities/abort-error.mjs +15 -1
- package/dist/form/utilities/abort-error.mjs.map +1 -1
- package/dist/form/utilities/index.cjs +7 -1
- package/dist/form/utilities/index.mjs +5 -1
- package/dist/form/utilities/is-validation-results.cjs +9 -1
- package/dist/form/utilities/is-validation-results.mjs +9 -1
- package/dist/form/utilities/is-validation-results.mjs.map +1 -1
- package/dist/form/utilities/validators.cjs +8 -1
- package/dist/form/utilities/validators.mjs +8 -1
- package/dist/form/utilities/validators.mjs.map +1 -1
- package/dist/index.cjs +71 -1
- package/dist/index.mjs +34 -1
- package/dist/message/components/MessageViewport.cjs +21 -6
- package/dist/message/components/MessageViewport.mjs +21 -6
- package/dist/message/components/MessageViewport.mjs.map +1 -1
- package/dist/message/components/index.cjs +3 -1
- package/dist/message/components/index.mjs +3 -1
- package/dist/message/hooks/index.cjs +3 -1
- package/dist/message/hooks/index.mjs +3 -1
- package/dist/message/hooks/use-message-actions.cjs +63 -1
- package/dist/message/hooks/use-message-actions.mjs +63 -1
- package/dist/message/hooks/use-message-actions.mjs.map +1 -1
- package/dist/message/index.cjs +23 -1
- package/dist/message/index.mjs +8 -1
- package/dist/message/providers/MessageProvider.cjs +16 -1
- package/dist/message/providers/MessageProvider.mjs +16 -1
- package/dist/message/providers/MessageProvider.mjs.map +1 -1
- package/dist/theme/hooks/index.cjs +7 -1
- package/dist/theme/hooks/index.mjs +4 -1
- package/dist/theme/hooks/use-theme-actions.cjs +21 -1
- package/dist/theme/hooks/use-theme-actions.mjs +21 -1
- package/dist/theme/hooks/use-theme-actions.mjs.map +1 -1
- package/dist/theme/hooks/use-theme-store.cjs +61 -1
- package/dist/theme/hooks/use-theme-store.d.cts +2 -2
- package/dist/theme/hooks/use-theme-store.d.mts +2 -2
- package/dist/theme/hooks/use-theme-store.mjs +59 -1
- package/dist/theme/hooks/use-theme-store.mjs.map +1 -1
- package/dist/theme/index.cjs +17 -1
- package/dist/theme/index.mjs +9 -1
- package/dist/theme/molecules/index.cjs +3 -1
- package/dist/theme/molecules/index.mjs +3 -1
- package/dist/theme/molecules/theme-molecule.cjs +14 -1
- package/dist/theme/molecules/theme-molecule.mjs +14 -1
- package/dist/theme/molecules/theme-molecule.mjs.map +1 -1
- package/dist/theme/providers/ThemeProvider.cjs +30 -5
- package/dist/theme/providers/ThemeProvider.mjs +30 -5
- package/dist/theme/providers/ThemeProvider.mjs.map +1 -1
- package/dist/theme/utilities/theme-helpers.cjs +71 -1
- package/dist/theme/utilities/theme-helpers.mjs +70 -1
- package/dist/theme/utilities/theme-helpers.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1,2 +1,154 @@
|
|
|
1
|
-
import{createMoleculeApi
|
|
1
|
+
import { createMoleculeApi, use } from "../../base/utilities/create-molecule.mjs";
|
|
2
|
+
import "../../base/index.mjs";
|
|
3
|
+
import { atomWithFieldItems } from "../atoms/atom-with-field.mjs";
|
|
4
|
+
import { atomWithFieldsMessageList, atomWithFieldsMessageTypes, atomWithMessages, atomWithTheme } from "../atoms/atom-with-messages.mjs";
|
|
5
|
+
import { requiredValidator } from "../utilities/validators.mjs";
|
|
6
|
+
import { FormApi } from "./form-molecule.mjs";
|
|
7
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
8
|
+
import { RESET, atomWithDefault, splitAtom } from "jotai/utils";
|
|
9
|
+
import { isEqual } from "@stryke/helpers/is-equal";
|
|
10
|
+
import { atom } from "jotai";
|
|
11
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
12
|
+
import { deepMerge } from "@stryke/helpers/deep-merge";
|
|
13
|
+
import { getField } from "@stryke/helpers/get-field";
|
|
14
|
+
import { toPath } from "@stryke/helpers/to-path";
|
|
15
|
+
import { isSet } from "@stryke/type-checks/is-set";
|
|
16
|
+
import { focusAtom } from "jotai-optics";
|
|
17
|
+
|
|
18
|
+
//#region src/form/molecules/field-molecule.ts
|
|
19
|
+
const DEFAULT_FIELD_OPTIONS = {
|
|
20
|
+
theme: "base",
|
|
21
|
+
size: "md",
|
|
22
|
+
debounceMs: 100,
|
|
23
|
+
isEqual,
|
|
24
|
+
required: false,
|
|
25
|
+
disabled: false,
|
|
26
|
+
clearable: false,
|
|
27
|
+
initialValue: null
|
|
28
|
+
};
|
|
29
|
+
const FieldApi = createMoleculeApi((scope) => {
|
|
30
|
+
const formScope = use(FormApi.Scope);
|
|
31
|
+
const formScopeAtom = atom(() => formScope);
|
|
32
|
+
const form = use(FormApi.Molecule);
|
|
33
|
+
const optionsBaseAtom = atom(DEFAULT_FIELD_OPTIONS);
|
|
34
|
+
const optionsAtom = atom((get) => {
|
|
35
|
+
const formOptions = get(form.options);
|
|
36
|
+
const options = get(optionsBaseAtom);
|
|
37
|
+
const result = deepMerge(formOptions.defaultFieldOptions, options);
|
|
38
|
+
return deepMerge({ validate: { onBlur: result.required ? [requiredValidator] : [] } }, result);
|
|
39
|
+
}, (get, set, update) => {
|
|
40
|
+
let nextValue = {};
|
|
41
|
+
if (isFunction(update)) nextValue = update(get(optionsBaseAtom));
|
|
42
|
+
else if (update === RESET) nextValue = {};
|
|
43
|
+
else nextValue = update;
|
|
44
|
+
set(optionsBaseAtom, deepMerge(DEFAULT_FIELD_OPTIONS, nextValue));
|
|
45
|
+
});
|
|
46
|
+
const formPrefix = `${formScope}-`;
|
|
47
|
+
const path = toPath(scope.startsWith(formPrefix) ? scope.slice(formPrefix.length) : scope.includes("-") ? scope.slice(scope.indexOf("-") + 1) : scope);
|
|
48
|
+
const pathAtom = atom(() => path);
|
|
49
|
+
const nameAtom = atom((get) => get(pathAtom).slice(-1)[0]);
|
|
50
|
+
const focusedAtom = focusAtom(form.focusedFields, (optic) => optic.path(...path));
|
|
51
|
+
const requiredStateAtom = focusAtom(form.requiredFields, (optic) => optic.path(...path));
|
|
52
|
+
const disabledStateAtom = focusAtom(form.disabledFields, (optic) => optic.path(...path));
|
|
53
|
+
const requiredAtom = atom((get) => get(requiredStateAtom) ?? get(optionsAtom).required, (_get, set, update) => {
|
|
54
|
+
set(requiredStateAtom, update);
|
|
55
|
+
});
|
|
56
|
+
const disabledAtom = atom((get) => get(disabledStateAtom) ?? get(optionsAtom).disabled, (_get, set, update) => {
|
|
57
|
+
set(disabledStateAtom, update);
|
|
58
|
+
});
|
|
59
|
+
const clearableAtom = atom((get) => get(optionsAtom).clearable);
|
|
60
|
+
const touchedAtom = focusAtom(form.touchedFields, (optic) => optic.path(...path));
|
|
61
|
+
const blurredAtom = focusAtom(form.blurredFields, (optic) => optic.path(...path));
|
|
62
|
+
const validatingAtom = focusAtom(form.validatingFields, (optic) => optic.path(...path));
|
|
63
|
+
const validationResultsAtom = focusAtom(form.validationResultsFields, (optic) => optic.path(...path));
|
|
64
|
+
const tabIndexAtom = focusAtom(form.tabIndexes, (optic) => optic.path(...path));
|
|
65
|
+
const refAtom = focusAtom(form.refs, (optic) => optic.path(...path));
|
|
66
|
+
const initialValueAtom = focusAtom(form.initialValues, (optic) => optic.path(...path));
|
|
67
|
+
const valueAtom = focusAtom(form.values, (optic) => optic.path(...path));
|
|
68
|
+
const dirtyAtom = atom((get) => {
|
|
69
|
+
return get(optionsAtom).isEqual(get(valueAtom), get(initialValueAtom));
|
|
70
|
+
});
|
|
71
|
+
const errorsAtom = atomWithFieldsMessageTypes(validationResultsAtom, "danger");
|
|
72
|
+
const warningsAtom = atomWithFieldsMessageTypes(validationResultsAtom, "warning");
|
|
73
|
+
const infoAtom = atomWithFieldsMessageTypes(validationResultsAtom, "info");
|
|
74
|
+
const discoveryAtom = atomWithFieldsMessageTypes(validationResultsAtom, "discovery");
|
|
75
|
+
const successesAtom = atomWithFieldsMessageTypes(validationResultsAtom, "success");
|
|
76
|
+
const positivesAtom = atomWithFieldsMessageTypes(validationResultsAtom, "positive");
|
|
77
|
+
const negativesAtom = atomWithFieldsMessageTypes(validationResultsAtom, "negative");
|
|
78
|
+
const errorMessagesAtom = atomWithFieldsMessageList(validationResultsAtom, "danger");
|
|
79
|
+
const warningMessagesAtom = atomWithFieldsMessageList(validationResultsAtom, "warning");
|
|
80
|
+
const infoMessagesAtom = atomWithFieldsMessageList(validationResultsAtom, "info");
|
|
81
|
+
const discoveryMessagesAtom = atomWithFieldsMessageList(validationResultsAtom, "discovery");
|
|
82
|
+
const successMessagesAtom = atomWithFieldsMessageList(validationResultsAtom, "success");
|
|
83
|
+
const positiveMessagesAtom = atomWithFieldsMessageList(validationResultsAtom, "positive");
|
|
84
|
+
const negativeMessagesAtom = atomWithFieldsMessageList(validationResultsAtom, "negative");
|
|
85
|
+
const invalidAtom = atom((get) => {
|
|
86
|
+
return get(errorMessagesAtom).length > 0;
|
|
87
|
+
});
|
|
88
|
+
const validAtom = atom((get) => !get(invalidAtom));
|
|
89
|
+
const formattedValueAtom = atom((get) => {
|
|
90
|
+
const options = get(optionsAtom);
|
|
91
|
+
const value = get(valueAtom);
|
|
92
|
+
let formattedValue;
|
|
93
|
+
if (options?.format) formattedValue = options.format(value);
|
|
94
|
+
else formattedValue = value;
|
|
95
|
+
if (!isSet(formattedValue)) return "";
|
|
96
|
+
else if (isString(formattedValue)) return formattedValue;
|
|
97
|
+
return String(formattedValue);
|
|
98
|
+
});
|
|
99
|
+
const itemsAtom = atomWithFieldItems(optionsAtom, valueAtom, disabledAtom);
|
|
100
|
+
const itemsAtomsAtom = splitAtom(itemsAtom);
|
|
101
|
+
const sizeAtom = atomWithDefault((get) => {
|
|
102
|
+
return get(optionsAtom).size ?? "md";
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
options: optionsAtom,
|
|
106
|
+
form: formScopeAtom,
|
|
107
|
+
name: nameAtom,
|
|
108
|
+
path: pathAtom,
|
|
109
|
+
initialValue: initialValueAtom,
|
|
110
|
+
previousValue: atom((get) => {
|
|
111
|
+
const previousValues = get(form.previousValues);
|
|
112
|
+
return getField(previousValues, get(pathAtom).join(".")) ?? null;
|
|
113
|
+
}),
|
|
114
|
+
value: valueAtom,
|
|
115
|
+
formattedValue: formattedValueAtom,
|
|
116
|
+
focused: focusedAtom,
|
|
117
|
+
required: requiredAtom,
|
|
118
|
+
disabled: disabledAtom,
|
|
119
|
+
clearable: clearableAtom,
|
|
120
|
+
touched: touchedAtom,
|
|
121
|
+
blurred: blurredAtom,
|
|
122
|
+
validating: validatingAtom,
|
|
123
|
+
validationResults: validationResultsAtom,
|
|
124
|
+
tabIndex: tabIndexAtom,
|
|
125
|
+
ref: refAtom,
|
|
126
|
+
pristine: atom((get) => !get(dirtyAtom)),
|
|
127
|
+
dirty: dirtyAtom,
|
|
128
|
+
items: itemsAtom,
|
|
129
|
+
itemsAtoms: itemsAtomsAtom,
|
|
130
|
+
size: sizeAtom,
|
|
131
|
+
errors: errorsAtom,
|
|
132
|
+
warnings: warningsAtom,
|
|
133
|
+
info: infoAtom,
|
|
134
|
+
discovery: discoveryAtom,
|
|
135
|
+
success: successesAtom,
|
|
136
|
+
positive: positivesAtom,
|
|
137
|
+
negative: negativesAtom,
|
|
138
|
+
dangerMessages: errorMessagesAtom,
|
|
139
|
+
warningMessages: warningMessagesAtom,
|
|
140
|
+
infoMessages: infoMessagesAtom,
|
|
141
|
+
discoveryMessages: discoveryMessagesAtom,
|
|
142
|
+
successMessages: successMessagesAtom,
|
|
143
|
+
positiveMessages: positiveMessagesAtom,
|
|
144
|
+
negativeMessages: negativeMessagesAtom,
|
|
145
|
+
theme: atomWithTheme(optionsAtom, errorMessagesAtom, warningMessagesAtom, infoMessagesAtom, discoveryMessagesAtom, successMessagesAtom, positiveMessagesAtom, negativeMessagesAtom),
|
|
146
|
+
messages: atomWithMessages(errorMessagesAtom, warningMessagesAtom, infoMessagesAtom, discoveryMessagesAtom, successMessagesAtom, positiveMessagesAtom, negativeMessagesAtom),
|
|
147
|
+
invalid: invalidAtom,
|
|
148
|
+
valid: validAtom
|
|
149
|
+
};
|
|
150
|
+
}, { type: "field" });
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
export { DEFAULT_FIELD_OPTIONS, FieldApi };
|
|
2
154
|
//# sourceMappingURL=field-molecule.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-molecule.mjs","names":[
|
|
1
|
+
{"version":3,"file":"field-molecule.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1 +1,180 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_create_molecule = require("../../base/utilities/create-molecule.cjs");
|
|
2
|
+
const require_atom_with_messages = require("../atoms/atom-with-messages.cjs");
|
|
3
|
+
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
4
|
+
let jotai_utils = require("jotai/utils");
|
|
5
|
+
let _stryke_helpers_is_equal = require("@stryke/helpers/is-equal");
|
|
6
|
+
let jotai = require("jotai");
|
|
7
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
8
|
+
let _stryke_helpers_deep_merge = require("@stryke/helpers/deep-merge");
|
|
9
|
+
let _stryke_helpers_flatten_object = require("@stryke/helpers/flatten-object");
|
|
10
|
+
let _stryke_helpers_set_field = require("@stryke/helpers/set-field");
|
|
11
|
+
let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
12
|
+
|
|
13
|
+
//#region src/form/molecules/form-molecule.ts
|
|
14
|
+
const DEFAULT_FORM_OPTIONS = {
|
|
15
|
+
theme: "base",
|
|
16
|
+
debounceMs: 100,
|
|
17
|
+
isEqual: _stryke_helpers_is_equal.isEqual,
|
|
18
|
+
disabled: false,
|
|
19
|
+
initialValues: {},
|
|
20
|
+
defaultFieldOptions: {}
|
|
21
|
+
};
|
|
22
|
+
const FormApi = require_create_molecule.createMoleculeApi((scope) => {
|
|
23
|
+
const optionsBaseAtom = (0, jotai_utils.atomWithReset)(DEFAULT_FORM_OPTIONS);
|
|
24
|
+
const optionsAtom = (0, jotai.atom)((get) => get(optionsBaseAtom), (get, set, update) => {
|
|
25
|
+
let nextValue = {};
|
|
26
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(update)) nextValue = update(get(optionsBaseAtom));
|
|
27
|
+
else if (update === jotai_utils.RESET) nextValue = {};
|
|
28
|
+
else nextValue = update;
|
|
29
|
+
set(optionsBaseAtom, (0, _stryke_helpers_deep_merge.deepMerge)(DEFAULT_FORM_OPTIONS, nextValue));
|
|
30
|
+
});
|
|
31
|
+
const nameAtom = (0, jotai.atom)(scope);
|
|
32
|
+
const disabledAtom = (0, jotai_utils.atomWithDefault)((get) => Boolean(get(optionsAtom).disabled));
|
|
33
|
+
const formValidatingAtom = (0, jotai_utils.atomWithReset)(false);
|
|
34
|
+
const previousValuesBaseAtom = (0, jotai_utils.atomWithReset)({});
|
|
35
|
+
const previousValuesAtom = (0, jotai.atom)((get) => get(previousValuesBaseAtom), (_get, _set, _update) => {});
|
|
36
|
+
const initialValuesAtom = (0, jotai_utils.atomWithDefault)((get) => get(optionsAtom).initialValues);
|
|
37
|
+
const valuesBaseAtom = (0, jotai_utils.atomWithDefault)((get) => get(optionsAtom).initialValues);
|
|
38
|
+
const valuesAtom = (0, jotai.atom)((get) => get(valuesBaseAtom), (get, set, update) => {
|
|
39
|
+
let nextValue = {};
|
|
40
|
+
if (update) {
|
|
41
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(update)) nextValue = update(get(valuesBaseAtom));
|
|
42
|
+
else nextValue = update;
|
|
43
|
+
}
|
|
44
|
+
set(previousValuesBaseAtom, get(valuesBaseAtom));
|
|
45
|
+
set(valuesBaseAtom, nextValue);
|
|
46
|
+
});
|
|
47
|
+
const validationResultsAtom = (0, jotai_utils.atomWithReset)({
|
|
48
|
+
initialize: [],
|
|
49
|
+
change: [],
|
|
50
|
+
blur: [],
|
|
51
|
+
submit: [],
|
|
52
|
+
server: []
|
|
53
|
+
});
|
|
54
|
+
const submittingAtom = (0, jotai_utils.atomWithReset)(false);
|
|
55
|
+
const submittedAtom = (0, jotai_utils.atomWithReset)(false);
|
|
56
|
+
const submitAttemptsAtom = (0, jotai_utils.atomWithReset)(0);
|
|
57
|
+
const focusedFieldsAtom = (0, jotai_utils.atomWithReset)({});
|
|
58
|
+
const requiredFieldsAtom = (0, jotai_utils.atomWithReset)({});
|
|
59
|
+
const disabledFieldsAtom = (0, jotai_utils.atomWithReset)({});
|
|
60
|
+
const touchedFieldsAtom = (0, jotai_utils.atomWithReset)({});
|
|
61
|
+
const blurredFieldsAtom = (0, jotai_utils.atomWithReset)({});
|
|
62
|
+
const validatingFieldsAtom = (0, jotai_utils.atomWithReset)({});
|
|
63
|
+
const validationResultsFieldsAtom = (0, jotai_utils.atomWithReset)({});
|
|
64
|
+
const refsAtom = (0, jotai_utils.atomWithReset)({});
|
|
65
|
+
const tabIndexesBaseAtom = (0, jotai_utils.atomWithReset)({});
|
|
66
|
+
const tabIndexesAtom = (0, jotai.atom)((get) => get(tabIndexesBaseAtom), (get, set, update) => {
|
|
67
|
+
let nextValue = {};
|
|
68
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(update)) nextValue = update(get(tabIndexesBaseAtom));
|
|
69
|
+
else if (update === jotai_utils.RESET) nextValue = {};
|
|
70
|
+
else {
|
|
71
|
+
const tabIndexes = get(tabIndexesBaseAtom);
|
|
72
|
+
if ("field" in update && update.field && (0, _stryke_type_checks_is_string.isString)(update.field)) {
|
|
73
|
+
let tabIndex = update.tabIndex;
|
|
74
|
+
if (!(0, _stryke_type_checks_is_number.isNumber)(tabIndex) || tabIndex > -1) {
|
|
75
|
+
const flat = (0, _stryke_helpers_flatten_object.flattenObject)(tabIndexes);
|
|
76
|
+
let lastIndex = -1;
|
|
77
|
+
for (const key in flat) if ((0, _stryke_type_checks_is_number.isNumber)(flat[key]) && flat[key] > lastIndex) lastIndex = flat[key];
|
|
78
|
+
tabIndex = lastIndex + 1;
|
|
79
|
+
}
|
|
80
|
+
nextValue = (0, _stryke_helpers_set_field.setField)(tabIndexes, update.field, tabIndex);
|
|
81
|
+
} else nextValue = update;
|
|
82
|
+
}
|
|
83
|
+
set(tabIndexesBaseAtom, nextValue);
|
|
84
|
+
});
|
|
85
|
+
const dirtyAtom = (0, jotai.atom)((get) => {
|
|
86
|
+
return get(optionsAtom).isEqual(get(valuesAtom), get(initialValuesAtom));
|
|
87
|
+
});
|
|
88
|
+
const pristineAtom = (0, jotai.atom)((get) => !get(dirtyAtom));
|
|
89
|
+
const blurredAtom = (0, jotai.atom)((get) => {
|
|
90
|
+
const blurredFields = (0, _stryke_helpers_flatten_object.flattenObject)(get(blurredFieldsAtom));
|
|
91
|
+
return Object.keys(blurredFields).some((key) => blurredFields[key]);
|
|
92
|
+
});
|
|
93
|
+
const touchedAtom = (0, jotai.atom)((get) => {
|
|
94
|
+
const touchedFields = (0, _stryke_helpers_flatten_object.flattenObject)(get(touchedFieldsAtom));
|
|
95
|
+
return Object.keys(touchedFields).some((key) => touchedFields[key]);
|
|
96
|
+
});
|
|
97
|
+
const validatingAtom = (0, jotai.atom)((get) => {
|
|
98
|
+
if (get(formValidatingAtom)) return true;
|
|
99
|
+
const validatingFields = (0, _stryke_helpers_flatten_object.flattenObject)(get(validatingFieldsAtom));
|
|
100
|
+
return Object.keys(validatingFields).some((key) => validatingFields[key]);
|
|
101
|
+
});
|
|
102
|
+
const formErrorsAtom = require_atom_with_messages.atomWithMessageTypes(validationResultsAtom, "danger");
|
|
103
|
+
const formWarningsAtom = require_atom_with_messages.atomWithMessageTypes(validationResultsAtom, "warning");
|
|
104
|
+
const formInfoAtom = require_atom_with_messages.atomWithMessageTypes(validationResultsAtom, "info");
|
|
105
|
+
const formHelpAtom = require_atom_with_messages.atomWithMessageTypes(validationResultsAtom, "discovery");
|
|
106
|
+
const formSuccessesAtom = require_atom_with_messages.atomWithMessageTypes(validationResultsAtom, "success");
|
|
107
|
+
const formPositivesAtom = require_atom_with_messages.atomWithMessageTypes(validationResultsAtom, "positive");
|
|
108
|
+
const formNegativesAtom = require_atom_with_messages.atomWithMessageTypes(validationResultsAtom, "negative");
|
|
109
|
+
const isFormInvalidAtom = (0, jotai.atom)((get) => {
|
|
110
|
+
return get(formErrorsAtom).length > 0;
|
|
111
|
+
});
|
|
112
|
+
const errorFieldsAtom = require_atom_with_messages.atomWithFieldsMessageTypes(validationResultsFieldsAtom, "danger");
|
|
113
|
+
const warningFieldsAtom = require_atom_with_messages.atomWithFieldsMessageTypes(validationResultsFieldsAtom, "warning");
|
|
114
|
+
const infoFieldsAtom = require_atom_with_messages.atomWithFieldsMessageTypes(validationResultsFieldsAtom, "info");
|
|
115
|
+
const helpFieldsAtom = require_atom_with_messages.atomWithFieldsMessageTypes(validationResultsFieldsAtom, "discovery");
|
|
116
|
+
const successFieldsAtom = require_atom_with_messages.atomWithFieldsMessageTypes(validationResultsFieldsAtom, "success");
|
|
117
|
+
const fieldErrorMessagesAtom = require_atom_with_messages.atomWithFieldsMessageList(validationResultsFieldsAtom, "danger");
|
|
118
|
+
const fieldWarningMessagesAtom = require_atom_with_messages.atomWithFieldsMessageList(validationResultsFieldsAtom, "warning");
|
|
119
|
+
const fieldInfoMessagesAtom = require_atom_with_messages.atomWithFieldsMessageList(validationResultsFieldsAtom, "info");
|
|
120
|
+
const fieldHelpMessagesAtom = require_atom_with_messages.atomWithFieldsMessageList(validationResultsFieldsAtom, "discovery");
|
|
121
|
+
const fieldsSuccessMessagesAtom = require_atom_with_messages.atomWithFieldsMessageList(validationResultsFieldsAtom, "success");
|
|
122
|
+
const invalidAtom = (0, jotai.atom)((get) => {
|
|
123
|
+
return get(fieldErrorMessagesAtom).length > 0 || get(isFormInvalidAtom);
|
|
124
|
+
});
|
|
125
|
+
const validAtom = (0, jotai.atom)((get) => !get(invalidAtom));
|
|
126
|
+
const canSubmitAtom = (0, jotai.atom)((get) => get(validAtom) && !get(validatingAtom) && !get(submittingAtom) && !get(disabledAtom));
|
|
127
|
+
return {
|
|
128
|
+
options: optionsAtom,
|
|
129
|
+
name: nameAtom,
|
|
130
|
+
disabled: disabledAtom,
|
|
131
|
+
formValidating: formValidatingAtom,
|
|
132
|
+
validationResults: validationResultsAtom,
|
|
133
|
+
submitting: submittingAtom,
|
|
134
|
+
submitted: submittedAtom,
|
|
135
|
+
submitAttempts: submitAttemptsAtom,
|
|
136
|
+
focusedFields: focusedFieldsAtom,
|
|
137
|
+
requiredFields: requiredFieldsAtom,
|
|
138
|
+
disabledFields: disabledFieldsAtom,
|
|
139
|
+
touchedFields: touchedFieldsAtom,
|
|
140
|
+
blurredFields: blurredFieldsAtom,
|
|
141
|
+
validatingFields: validatingFieldsAtom,
|
|
142
|
+
validationResultsFields: validationResultsFieldsAtom,
|
|
143
|
+
tabIndexes: tabIndexesAtom,
|
|
144
|
+
refs: refsAtom,
|
|
145
|
+
dirty: dirtyAtom,
|
|
146
|
+
pristine: pristineAtom,
|
|
147
|
+
blurred: blurredAtom,
|
|
148
|
+
touched: touchedAtom,
|
|
149
|
+
validating: validatingAtom,
|
|
150
|
+
previousValues: previousValuesAtom,
|
|
151
|
+
initialValues: initialValuesAtom,
|
|
152
|
+
values: valuesAtom,
|
|
153
|
+
dangerMessages: formErrorsAtom,
|
|
154
|
+
warningMessages: formWarningsAtom,
|
|
155
|
+
infoMessages: formInfoAtom,
|
|
156
|
+
discoveryMessages: formHelpAtom,
|
|
157
|
+
successMessages: formSuccessesAtom,
|
|
158
|
+
positiveMessages: formPositivesAtom,
|
|
159
|
+
negativeMessages: formNegativesAtom,
|
|
160
|
+
messages: require_atom_with_messages.atomWithMessages(formErrorsAtom, formWarningsAtom, formInfoAtom, formHelpAtom, formSuccessesAtom, formPositivesAtom, formNegativesAtom),
|
|
161
|
+
dangerFields: errorFieldsAtom,
|
|
162
|
+
warningFields: warningFieldsAtom,
|
|
163
|
+
infoFields: infoFieldsAtom,
|
|
164
|
+
discoveryFields: helpFieldsAtom,
|
|
165
|
+
successFields: successFieldsAtom,
|
|
166
|
+
fieldDangerMessages: fieldErrorMessagesAtom,
|
|
167
|
+
fieldWarningMessages: fieldWarningMessagesAtom,
|
|
168
|
+
fieldInfoMessages: fieldInfoMessagesAtom,
|
|
169
|
+
fieldHelpMessages: fieldHelpMessagesAtom,
|
|
170
|
+
fieldsSuccessMessages: fieldsSuccessMessagesAtom,
|
|
171
|
+
valid: validAtom,
|
|
172
|
+
invalid: invalidAtom,
|
|
173
|
+
theme: require_atom_with_messages.atomWithTheme(optionsAtom, formErrorsAtom, formWarningsAtom, formInfoAtom, formHelpAtom, formSuccessesAtom, formPositivesAtom, formNegativesAtom),
|
|
174
|
+
canSubmit: canSubmitAtom
|
|
175
|
+
};
|
|
176
|
+
}, { type: "form" });
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
exports.DEFAULT_FORM_OPTIONS = DEFAULT_FORM_OPTIONS;
|
|
180
|
+
exports.FormApi = FormApi;
|
|
@@ -1,2 +1,180 @@
|
|
|
1
|
-
import{createMoleculeApi
|
|
1
|
+
import { createMoleculeApi } from "../../base/utilities/create-molecule.mjs";
|
|
2
|
+
import { atomWithFieldsMessageList, atomWithFieldsMessageTypes, atomWithMessageTypes, atomWithMessages, atomWithTheme } from "../atoms/atom-with-messages.mjs";
|
|
3
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
4
|
+
import { RESET, atomWithDefault, atomWithReset } from "jotai/utils";
|
|
5
|
+
import { isEqual } from "@stryke/helpers/is-equal";
|
|
6
|
+
import { atom } from "jotai";
|
|
7
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
8
|
+
import { deepMerge } from "@stryke/helpers/deep-merge";
|
|
9
|
+
import { flattenObject } from "@stryke/helpers/flatten-object";
|
|
10
|
+
import { setField } from "@stryke/helpers/set-field";
|
|
11
|
+
import { isNumber } from "@stryke/type-checks/is-number";
|
|
12
|
+
|
|
13
|
+
//#region src/form/molecules/form-molecule.ts
|
|
14
|
+
const DEFAULT_FORM_OPTIONS = {
|
|
15
|
+
theme: "base",
|
|
16
|
+
debounceMs: 100,
|
|
17
|
+
isEqual,
|
|
18
|
+
disabled: false,
|
|
19
|
+
initialValues: {},
|
|
20
|
+
defaultFieldOptions: {}
|
|
21
|
+
};
|
|
22
|
+
const FormApi = createMoleculeApi((scope) => {
|
|
23
|
+
const optionsBaseAtom = atomWithReset(DEFAULT_FORM_OPTIONS);
|
|
24
|
+
const optionsAtom = atom((get) => get(optionsBaseAtom), (get, set, update) => {
|
|
25
|
+
let nextValue = {};
|
|
26
|
+
if (isFunction(update)) nextValue = update(get(optionsBaseAtom));
|
|
27
|
+
else if (update === RESET) nextValue = {};
|
|
28
|
+
else nextValue = update;
|
|
29
|
+
set(optionsBaseAtom, deepMerge(DEFAULT_FORM_OPTIONS, nextValue));
|
|
30
|
+
});
|
|
31
|
+
const nameAtom = atom(scope);
|
|
32
|
+
const disabledAtom = atomWithDefault((get) => Boolean(get(optionsAtom).disabled));
|
|
33
|
+
const formValidatingAtom = atomWithReset(false);
|
|
34
|
+
const previousValuesBaseAtom = atomWithReset({});
|
|
35
|
+
const previousValuesAtom = atom((get) => get(previousValuesBaseAtom), (_get, _set, _update) => {});
|
|
36
|
+
const initialValuesAtom = atomWithDefault((get) => get(optionsAtom).initialValues);
|
|
37
|
+
const valuesBaseAtom = atomWithDefault((get) => get(optionsAtom).initialValues);
|
|
38
|
+
const valuesAtom = atom((get) => get(valuesBaseAtom), (get, set, update) => {
|
|
39
|
+
let nextValue = {};
|
|
40
|
+
if (update) {
|
|
41
|
+
if (isFunction(update)) nextValue = update(get(valuesBaseAtom));
|
|
42
|
+
else nextValue = update;
|
|
43
|
+
}
|
|
44
|
+
set(previousValuesBaseAtom, get(valuesBaseAtom));
|
|
45
|
+
set(valuesBaseAtom, nextValue);
|
|
46
|
+
});
|
|
47
|
+
const validationResultsAtom = atomWithReset({
|
|
48
|
+
initialize: [],
|
|
49
|
+
change: [],
|
|
50
|
+
blur: [],
|
|
51
|
+
submit: [],
|
|
52
|
+
server: []
|
|
53
|
+
});
|
|
54
|
+
const submittingAtom = atomWithReset(false);
|
|
55
|
+
const submittedAtom = atomWithReset(false);
|
|
56
|
+
const submitAttemptsAtom = atomWithReset(0);
|
|
57
|
+
const focusedFieldsAtom = atomWithReset({});
|
|
58
|
+
const requiredFieldsAtom = atomWithReset({});
|
|
59
|
+
const disabledFieldsAtom = atomWithReset({});
|
|
60
|
+
const touchedFieldsAtom = atomWithReset({});
|
|
61
|
+
const blurredFieldsAtom = atomWithReset({});
|
|
62
|
+
const validatingFieldsAtom = atomWithReset({});
|
|
63
|
+
const validationResultsFieldsAtom = atomWithReset({});
|
|
64
|
+
const refsAtom = atomWithReset({});
|
|
65
|
+
const tabIndexesBaseAtom = atomWithReset({});
|
|
66
|
+
const tabIndexesAtom = atom((get) => get(tabIndexesBaseAtom), (get, set, update) => {
|
|
67
|
+
let nextValue = {};
|
|
68
|
+
if (isFunction(update)) nextValue = update(get(tabIndexesBaseAtom));
|
|
69
|
+
else if (update === RESET) nextValue = {};
|
|
70
|
+
else {
|
|
71
|
+
const tabIndexes = get(tabIndexesBaseAtom);
|
|
72
|
+
if ("field" in update && update.field && isString(update.field)) {
|
|
73
|
+
let tabIndex = update.tabIndex;
|
|
74
|
+
if (!isNumber(tabIndex) || tabIndex > -1) {
|
|
75
|
+
const flat = flattenObject(tabIndexes);
|
|
76
|
+
let lastIndex = -1;
|
|
77
|
+
for (const key in flat) if (isNumber(flat[key]) && flat[key] > lastIndex) lastIndex = flat[key];
|
|
78
|
+
tabIndex = lastIndex + 1;
|
|
79
|
+
}
|
|
80
|
+
nextValue = setField(tabIndexes, update.field, tabIndex);
|
|
81
|
+
} else nextValue = update;
|
|
82
|
+
}
|
|
83
|
+
set(tabIndexesBaseAtom, nextValue);
|
|
84
|
+
});
|
|
85
|
+
const dirtyAtom = atom((get) => {
|
|
86
|
+
return get(optionsAtom).isEqual(get(valuesAtom), get(initialValuesAtom));
|
|
87
|
+
});
|
|
88
|
+
const pristineAtom = atom((get) => !get(dirtyAtom));
|
|
89
|
+
const blurredAtom = atom((get) => {
|
|
90
|
+
const blurredFields = flattenObject(get(blurredFieldsAtom));
|
|
91
|
+
return Object.keys(blurredFields).some((key) => blurredFields[key]);
|
|
92
|
+
});
|
|
93
|
+
const touchedAtom = atom((get) => {
|
|
94
|
+
const touchedFields = flattenObject(get(touchedFieldsAtom));
|
|
95
|
+
return Object.keys(touchedFields).some((key) => touchedFields[key]);
|
|
96
|
+
});
|
|
97
|
+
const validatingAtom = atom((get) => {
|
|
98
|
+
if (get(formValidatingAtom)) return true;
|
|
99
|
+
const validatingFields = flattenObject(get(validatingFieldsAtom));
|
|
100
|
+
return Object.keys(validatingFields).some((key) => validatingFields[key]);
|
|
101
|
+
});
|
|
102
|
+
const formErrorsAtom = atomWithMessageTypes(validationResultsAtom, "danger");
|
|
103
|
+
const formWarningsAtom = atomWithMessageTypes(validationResultsAtom, "warning");
|
|
104
|
+
const formInfoAtom = atomWithMessageTypes(validationResultsAtom, "info");
|
|
105
|
+
const formHelpAtom = atomWithMessageTypes(validationResultsAtom, "discovery");
|
|
106
|
+
const formSuccessesAtom = atomWithMessageTypes(validationResultsAtom, "success");
|
|
107
|
+
const formPositivesAtom = atomWithMessageTypes(validationResultsAtom, "positive");
|
|
108
|
+
const formNegativesAtom = atomWithMessageTypes(validationResultsAtom, "negative");
|
|
109
|
+
const isFormInvalidAtom = atom((get) => {
|
|
110
|
+
return get(formErrorsAtom).length > 0;
|
|
111
|
+
});
|
|
112
|
+
const errorFieldsAtom = atomWithFieldsMessageTypes(validationResultsFieldsAtom, "danger");
|
|
113
|
+
const warningFieldsAtom = atomWithFieldsMessageTypes(validationResultsFieldsAtom, "warning");
|
|
114
|
+
const infoFieldsAtom = atomWithFieldsMessageTypes(validationResultsFieldsAtom, "info");
|
|
115
|
+
const helpFieldsAtom = atomWithFieldsMessageTypes(validationResultsFieldsAtom, "discovery");
|
|
116
|
+
const successFieldsAtom = atomWithFieldsMessageTypes(validationResultsFieldsAtom, "success");
|
|
117
|
+
const fieldErrorMessagesAtom = atomWithFieldsMessageList(validationResultsFieldsAtom, "danger");
|
|
118
|
+
const fieldWarningMessagesAtom = atomWithFieldsMessageList(validationResultsFieldsAtom, "warning");
|
|
119
|
+
const fieldInfoMessagesAtom = atomWithFieldsMessageList(validationResultsFieldsAtom, "info");
|
|
120
|
+
const fieldHelpMessagesAtom = atomWithFieldsMessageList(validationResultsFieldsAtom, "discovery");
|
|
121
|
+
const fieldsSuccessMessagesAtom = atomWithFieldsMessageList(validationResultsFieldsAtom, "success");
|
|
122
|
+
const invalidAtom = atom((get) => {
|
|
123
|
+
return get(fieldErrorMessagesAtom).length > 0 || get(isFormInvalidAtom);
|
|
124
|
+
});
|
|
125
|
+
const validAtom = atom((get) => !get(invalidAtom));
|
|
126
|
+
const canSubmitAtom = atom((get) => get(validAtom) && !get(validatingAtom) && !get(submittingAtom) && !get(disabledAtom));
|
|
127
|
+
return {
|
|
128
|
+
options: optionsAtom,
|
|
129
|
+
name: nameAtom,
|
|
130
|
+
disabled: disabledAtom,
|
|
131
|
+
formValidating: formValidatingAtom,
|
|
132
|
+
validationResults: validationResultsAtom,
|
|
133
|
+
submitting: submittingAtom,
|
|
134
|
+
submitted: submittedAtom,
|
|
135
|
+
submitAttempts: submitAttemptsAtom,
|
|
136
|
+
focusedFields: focusedFieldsAtom,
|
|
137
|
+
requiredFields: requiredFieldsAtom,
|
|
138
|
+
disabledFields: disabledFieldsAtom,
|
|
139
|
+
touchedFields: touchedFieldsAtom,
|
|
140
|
+
blurredFields: blurredFieldsAtom,
|
|
141
|
+
validatingFields: validatingFieldsAtom,
|
|
142
|
+
validationResultsFields: validationResultsFieldsAtom,
|
|
143
|
+
tabIndexes: tabIndexesAtom,
|
|
144
|
+
refs: refsAtom,
|
|
145
|
+
dirty: dirtyAtom,
|
|
146
|
+
pristine: pristineAtom,
|
|
147
|
+
blurred: blurredAtom,
|
|
148
|
+
touched: touchedAtom,
|
|
149
|
+
validating: validatingAtom,
|
|
150
|
+
previousValues: previousValuesAtom,
|
|
151
|
+
initialValues: initialValuesAtom,
|
|
152
|
+
values: valuesAtom,
|
|
153
|
+
dangerMessages: formErrorsAtom,
|
|
154
|
+
warningMessages: formWarningsAtom,
|
|
155
|
+
infoMessages: formInfoAtom,
|
|
156
|
+
discoveryMessages: formHelpAtom,
|
|
157
|
+
successMessages: formSuccessesAtom,
|
|
158
|
+
positiveMessages: formPositivesAtom,
|
|
159
|
+
negativeMessages: formNegativesAtom,
|
|
160
|
+
messages: atomWithMessages(formErrorsAtom, formWarningsAtom, formInfoAtom, formHelpAtom, formSuccessesAtom, formPositivesAtom, formNegativesAtom),
|
|
161
|
+
dangerFields: errorFieldsAtom,
|
|
162
|
+
warningFields: warningFieldsAtom,
|
|
163
|
+
infoFields: infoFieldsAtom,
|
|
164
|
+
discoveryFields: helpFieldsAtom,
|
|
165
|
+
successFields: successFieldsAtom,
|
|
166
|
+
fieldDangerMessages: fieldErrorMessagesAtom,
|
|
167
|
+
fieldWarningMessages: fieldWarningMessagesAtom,
|
|
168
|
+
fieldInfoMessages: fieldInfoMessagesAtom,
|
|
169
|
+
fieldHelpMessages: fieldHelpMessagesAtom,
|
|
170
|
+
fieldsSuccessMessages: fieldsSuccessMessagesAtom,
|
|
171
|
+
valid: validAtom,
|
|
172
|
+
invalid: invalidAtom,
|
|
173
|
+
theme: atomWithTheme(optionsAtom, formErrorsAtom, formWarningsAtom, formInfoAtom, formHelpAtom, formSuccessesAtom, formPositivesAtom, formNegativesAtom),
|
|
174
|
+
canSubmit: canSubmitAtom
|
|
175
|
+
};
|
|
176
|
+
}, { type: "form" });
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
export { DEFAULT_FORM_OPTIONS, FormApi };
|
|
2
180
|
//# sourceMappingURL=form-molecule.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-molecule.mjs","names":[
|
|
1
|
+
{"version":3,"file":"form-molecule.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_form_molecule = require("./form-molecule.cjs");
|
|
2
|
+
const require_field_molecule = require("./field-molecule.cjs");
|
|
3
|
+
|
|
4
|
+
exports.DEFAULT_FIELD_OPTIONS = require_field_molecule.DEFAULT_FIELD_OPTIONS;
|
|
5
|
+
exports.DEFAULT_FORM_OPTIONS = require_form_molecule.DEFAULT_FORM_OPTIONS;
|
|
6
|
+
exports.FieldApi = require_field_molecule.FieldApi;
|
|
7
|
+
exports.FormApi = require_form_molecule.FormApi;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{DEFAULT_FORM_OPTIONS
|
|
1
|
+
import { DEFAULT_FORM_OPTIONS, FormApi } from "./form-molecule.mjs";
|
|
2
|
+
import { DEFAULT_FIELD_OPTIONS, FieldApi } from "./field-molecule.mjs";
|
|
3
|
+
|
|
4
|
+
export { DEFAULT_FIELD_OPTIONS, DEFAULT_FORM_OPTIONS, FieldApi, FormApi };
|