Skip to content

Commit 32f9f7d

Browse files
committed
docs: new github callouts, design choices
1 parent 6c3736d commit 32f9f7d

File tree

6 files changed

+394
-19
lines changed

6 files changed

+394
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dist-ssr
1818
# Editor directories and files
1919
.vscode/*
2020
!.vscode/extensions.json
21+
!.vscode/settings.json
2122
.idea
2223
.DS_Store
2324
*.suo

.vscode/extensions.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
{}
1+
{
2+
"recommendations": [
3+
"stylelint.vscode-stylelint",
4+
"dbaeumer.vscode-eslint",
5+
"runem.lit-plugin",
6+
"esbenp.prettier-vscode"
7+
]
8+
}

.vscode/settings.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"cssVariables.lookupFiles": [
3+
"**/*.css",
4+
"**/*.scss",
5+
"**/*.sass",
6+
"**/*.less",
7+
"packages/shoelace/node_modules/@shoelace-style/shoelace/dist/themes/dark.css",
8+
// "packages/shoelace/node_modules/@shoelace-style/shoelace/dist/themes/light.css",
9+
10+
"packages/spectrum/node_modules/@spectrum-web-components/styles/spectrum-scale-large.css",
11+
"packages/spectrum/node_modules/@spectrum-web-components/styles/spectrum-theme-dark.css",
12+
"packages/spectrum/node_modules/@spectrum-web-components/styles/typography.css",
13+
"packages/spectrum/node_modules/@spectrum-web-components/styles/core-global.css",
14+
"packages/spectrum/node_modules/@spectrum-web-components/styles/spectrum-core-global.css"
15+
],
16+
"markdown.extension.toc.levels": "2..6",
17+
18+
// Unused
19+
"html.customData": ["./vscode.html-custom-data.json"],
20+
"css.customData": ["./vscode.css-custom-data.json"]
21+
}

README.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# 📝  JSON Schema Form Element
22

33
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/@jsfe/form)
4-
[![ISC License](https://img.shields.io/npm/l/@jsfe/form)](./LICENSE)
4+
[![ISC License](https://img.shields.io/npm/l/@jsfe/form)](./LICENSE)
5+
![Downloads](https://img.shields.io/npm/dt/@jsfe/form)
56
[![GitHub](https://img.shields.io/badge/Repository-222222?logo=github)](https://github.com/json-schema-form-element/jsfe)
67
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](https://makeapullrequest.com)
78
[![TypeScript](https://img.shields.io/badge/TypeScript-333333?logo=typescript)](http://www.typescriptlang.org/)
@@ -50,7 +51,7 @@ Comes with Shoelace 2 and Google Material 3 web components libraries or barebone
5051
5152
Swap built-in components with your own, or add custom widget thanks to [UI schema](#schema) definitions. -->
5253

53-
> **Warning**
54+
> [!CAUTION]
5455
> Not for production.
5556
> Expect the doc. to be not in sync. with the actual released code.
5657
@@ -133,7 +134,7 @@ Jump to [**UI libraries**](#component-libraries):
133134
- [Usage](#usage)
134135
- [Installation](#installation)
135136
- [UI Libraries](#ui-libraries)
136-
- [Implementation](#implementation)
137+
- [Implementations](#implementations)
137138
- [All examples](#all-examples)
138139
- [Pure HTML with CDN](#pure-html-with-cdn)
139140
- [TypeScript (no framework)](#typescript-no-framework)
@@ -149,6 +150,7 @@ Jump to [**UI libraries**](#component-libraries):
149150
- [Component libraries](#component-libraries)
150151
- [Shoelace](#shoelace)
151152
- [Custom widgets](#custom-widgets)
153+
- [Design choices](#design-choices)
152154
- [Validation](#validation)
153155
- [Schema massaging](#schema-massaging)
154156
- [Custom Elements Manifests](#custom-elements-manifests)
@@ -560,6 +562,8 @@ items:
560562
561563
### Installation
562564
565+
**This is for the bare package**. You'll have to bring all the widgets yourself.
566+
563567
```sh
564568
npm i @jsfe/form
565569
# or
@@ -572,7 +576,7 @@ yarn add @jsfe/form
572576

573577
See [examples/src/pages/flavored.astro](https://github.com/json-schema-form-element/examples/blob/main/src/pages/flavored.astro)
574578

575-
Alternatively:
579+
_Alternatively_:
576580

577581
```
578582
npm install @jsfe/shoelace
@@ -601,9 +605,9 @@ import '@shoelace-style/shoelace/dist/themes/dark.css';
601605

602606
See also the [CSS section](#CSS).
603607

604-
### Implementation
608+
### Implementations
605609

606-
> **Warning**
610+
> [!CAUTION]
607611
> This project is new, API is subject to changes
608612
609613
#### All examples
@@ -855,15 +859,15 @@ Please file an issue if an info is wrong or missing.
855859
Each implementation examples are trying to show off the most type-safe way to use JSFE, with the least trade-offs.
856860

857861
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
859863
when your callbacks are getting too beefy, you'll better extract them from templates.
860864

861865
Generally, imperative usage get perfect TypeScript support (you just handle the class), whereas declaratively, you'll have
862866
to deal with various template languages limitations (this is an universal problem).
863867

864868
## Component libraries
865869

866-
> **Warning**
870+
> [!IMPORTANT]
867871
> Before you dive in, here is some context about Web Components libraries support with JSFE.
868872
869873
Whereas you are starting from scratch or you want to integrate declarative forms in
@@ -880,10 +884,10 @@ Why so?
880884
- Keep an eye on converging practices across vendors.
881885
- Ensure that _JSFE_ remains not to tied with _Shoelace_ way of things (which is already quite thin, relatively).
882886
- 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.
884888

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!
887891
888892
But I will do my best to provide all the hooks you need, thanks to an _agnostic_ and _type-safe_ API,
889893
smoothening some peculiarities.
@@ -938,6 +942,20 @@ That's why it's the very first library implemented in _JSFE_.
938942

939943
### Custom widgets
940944

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+
941959
🚧……🚧
942960

943961
<!-- OLD -->
@@ -962,7 +980,7 @@ Mapping between schema and “real” fields happens at the `HTMLElement` level,
962980

963981
## Validation
964982

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.
966984
HTML native validation is already quite powerful, but you might want to do
967985
your own wizardry.
968986
Note that client-validation is more for user experience,
@@ -977,8 +995,8 @@ JSFE doesn't bundle, dereference, nor it is fetching remote
977995
schemas.
978996
Doing so would add a huge payload to the library, and you might certainly have already those tools at hand somewhere in your stack.
979997
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).
9821000

9831001
## Custom Elements Manifests
9841002

@@ -1003,15 +1021,17 @@ With internal dependencies included, minus peer dependencies (UI libs.):
10031021
</div>
10041022

10051023
`@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.
10071025
If you just want to override _some_ of the flavored components, `@jsfe/<theme>` packages are handy starters.
10081026

10091027
`@jsfe/types` contains everything for assisting your own widgets authoring.
10101028
It's re-exported from every package so you don't need to install it on your own.
10111029

10121030
### _Next_ versions
10131031

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:
1034+
> `npm i @jsfe/<package>@next`.
10151035
10161036
## Experimental features
10171037

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"eslint-plugin-tsdoc": "^0.2.17",
4545
"lerna": "^8.0.0",
4646
"prettier": "^3.1.0",
47+
"remark": "^15.0.1",
4748
"sort-package-json": "^2.6.0",
4849
"stylelint": "^15.11.0",
4950
"stylelint-config-prettier": "^9.0.5",

0 commit comments

Comments
 (0)