You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-16Lines changed: 36 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,8 @@
1
1
# 📝 JSON Schema Form Element
2
2
3
3
[](https://www.webcomponents.org/element/@jsfe/form)
@@ -855,15 +859,15 @@ Please file an issue if an info is wrong or missing.
855
859
Each implementation examples are trying to show off the most type-safe way to use JSFE, with the least trade-offs.
856
860
857
861
Using it more **declaratively** or **imperatively** is up to you, your framework ability and you coding style.
858
-
Bot usages are valid and can be mixed. Typically when you want to use the schema elsewhere in your app., or
862
+
Both usages are valid and can be mixed. Typically when you want to use the schema elsewhere in your app., or
859
863
when your callbacks are getting too beefy, you'll better extract them from templates.
860
864
861
865
Generally, imperative usage get perfect TypeScript support (you just handle the class), whereas declaratively, you'll have
862
866
to deal with various template languages limitations (this is an universal problem).
863
867
864
868
## Component libraries
865
869
866
-
> **Warning**
870
+
> [!IMPORTANT]
867
871
> Before you dive in, here is some context about Web Components libraries support with JSFE.
868
872
869
873
Whereas you are starting from scratch or you want to integrate declarative forms in
@@ -880,10 +884,10 @@ Why so?
880
884
- Keep an eye on converging practices across vendors.
881
885
- Ensure that _JSFE_ remains not to tied with _Shoelace_ way of things (which is already quite thin, relatively).
882
886
- Be able to swap out built-ins for custom widgets on a pinch, when needed.
883
-
- Borrow valuable ideas from others libraries and re-implement them in Shoelace when lacking.
887
+
- Borrow valuable ideas from others libraries and re-implement them with Shoelace bits when lacking.
884
888
885
-
> **Warning**
886
-
> I will not maintain the full spectrum of _JSFE_ widgets, accross all libraries!
889
+
> [!WARNING]
890
+
> I will not maintain the **full spectrum** of _JSFE_ widgets, accross all libraries!
887
891
888
892
But I will do my best to provide all the hooks you need, thanks to an _agnostic_ and _type-safe_ API,
889
893
smoothening some peculiarities.
@@ -938,6 +942,20 @@ That's why it's the very first library implemented in _JSFE_.
938
942
939
943
### Custom widgets
940
944
945
+
#### Design choices
946
+
947
+
You might have noticed that _JSFE_ is not using Custom Elements as a medium for injecting widgets.
948
+
First prototypes were using them, but I've had troubles regarding the parent form element awareness about its children.
949
+
E.g. with Shoelace, inputs weren't responding well with form validation, the <kbd>ENTER</kbd> key for submit, etc.
950
+
I'm sure there are ways to circumvent those hassles (forwarding events…). I tried, but for now it's not a priority, as that might affect various UI libs in different ways.
951
+
952
+
Moreover, Web Components users are eager to see [Custom Registries](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry) becoming maintream.
953
+
That will make the process of overriding widgets much more flexible.
954
+
955
+
For now, using Lit's `TemplateResult` (from a function returning a `html` literal) is straight-forward, however there are some trade-offs; it's a state-less function, no CSS scoping, lit-tied, etc.
956
+
957
+
Ultimately, goal is to make JSFE fully modular and agnostic, by using well-defined Custom Elements, for each individual form control.
958
+
941
959
🚧……🚧
942
960
943
961
<!-- OLD -->
@@ -962,7 +980,7 @@ Mapping between schema and “real” fields happens at the `HTMLElement` level,
962
980
963
981
## Validation
964
982
965
-
You're responsible to hook-up additional / more advanced validation with, e.g, AJV.
983
+
You're responsible to hook-up additional / more advanced validation with, e.g, AJV.
966
984
HTML native validation is already quite powerful, but you might want to do
967
985
your own wizardry.
968
986
Note that client-validation is more for user experience,
@@ -977,8 +995,8 @@ JSFE doesn't bundle, dereference, nor it is fetching remote
977
995
schemas.
978
996
Doing so would add a huge payload to the library, and you might certainly have already those tools at hand somewhere in your stack.
979
997
Only thing it does is resolving [JSON references](https://datatracker.ietf.org/doc/html/draft-pbryan-zyp-json-ref-03), pointing to **local definitions** only.
980
-
Implementation is quite simple, and because this is a much needed feature for DRY-ness, recursivity…
981
-
Hopefully it's easy to bring in an advanced parser along, like the [`json-schema-ref-parser`](https://github.com/APIDevTools/json-schema-ref-parser).
998
+
This is because implementation is relatively trivial, without much code, and that's a much needed feature for DRY-ness, recursivity…
999
+
Hopefully it's easy to bring in an full-featured parser / resolver along, like the [`json-schema-ref-parser`](https://github.com/APIDevTools/json-schema-ref-parser).
982
1000
983
1001
## Custom Elements Manifests
984
1002
@@ -1003,15 +1021,17 @@ With internal dependencies included, minus peer dependencies (UI libs.):
1003
1021
</div>
1004
1022
1005
1023
`@jsfe/form` contains the base class from which all other packages extends themselves from.
1006
-
You don't need to install it, unless you want to provide widgets and styles from scratch.
1024
+
**You don't need to install it**, unless you want to provide widgets and styles from scratch.
1007
1025
If you just want to override _some_ of the flavored components, `@jsfe/<theme>` packages are handy starters.
1008
1026
1009
1027
`@jsfe/types` contains everything for assisting your own widgets authoring.
1010
1028
It's re-exported from every package so you don't need to install it on your own.
1011
1029
1012
1030
### _Next_ versions
1013
1031
1014
-
You can try nightly builds from the `next` branch like this: `npm i @jsfe/<package>@next`.
1032
+
> [!TIP]
1033
+
> You can try the upcoming release from the [`next` branch](https://github.com/json-schema-form-element/jsfe/tree/next) like this:
0 commit comments