-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added Form Annotation support #2845
base: master
Are you sure you want to change the base?
feat: added Form Annotation support #2845
Conversation
|
packages/primitives/src/index.js
Outdated
export const Form = 'FORM'; | ||
export const FormField = 'FORM_FIELD'; | ||
export const TextInput = 'TEXT_INPUT'; | ||
export const FormPushButton = 'FORM_PUSH_BUTTON'; | ||
export const Picker = 'PICKER'; | ||
export const FormList = 'FORM_LIST'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of keeping the initial names of these components to keep them aligned with the form annotation methods of PDFKit
?
formText( name, x, y, width, height, options)
formPushButton( name, x, y, width, height, name, options)
formCombo( name, x, y, width, height, options)
formList( name, x, y, width, height, options)
(src)
Right now, push buttons don't have any purpose. They are only there to exist. They cannot hold any value. There should be an option for the user to specify an |
Hi @diegomura, what do you think about this feature request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this. Thanks so much for putting this together. I'd like to get this merged soon.
Left a small comment about primitive naming.
Also I think we should add docs in the site (https://github.com/diegomura/react-pdf-site) after this lands. Can you take care of them? 🙏🏻 Not a blocker to merge this once we settle on namings
@@ -8,6 +8,11 @@ export const Note = 'NOTE'; | |||
export const Path = 'PATH'; | |||
export const Rect = 'RECT'; | |||
export const Line = 'LINE'; | |||
export const FormField = 'FORM_FIELD'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a strong opinion, but would Form
be more semantic? For Field
I imagine like an input, but this is actually a form wrapper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @diegomura,
thanks for your response. Let's see what I suggested here in the past: #2845 (comment). 🤔
My initial thought was to align the names with the ones used in pdfkit
(here). So TextInput
becomes FormText
, Picker
becomes FormPicker
, and so on. But you made a valid point back in 2022 suggesting we should stick to the native web primitives. I got used to the current names while preparing the PR.
Regarding FormField
: I chose the same name as pdfkit
mainly to align our (react-pdf) and their (pdfkit) docs and keep them similar. I don't know if that's practical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like FormGroup
? Form rather sounds like the single and complete set of inputs, but they rather are a subsection. E.g., you could separate billing address and shipping address into two groups
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @PhilippBloss,
your suggestion makes sense to me, considering what pdfkit states in their docs as well:
Using the formField method you might create a shipping field that is added to the root of the document, an address field that refers to the shipping field as it's parent, and a street Form Annotation that would refer to the address field as it's parent.
What do you think of fieldset
(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset):
The
<fieldset>
HTML element is used to group several controls as well as labels (<label>
) within a web form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good as well. Would give the decision to @diegomura
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would take over the docs, except @natterstefan has already started with those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would take over the docs, except @natterstefan has already started with those
Hi @PhilippBloss, I haven't taken care of the docs yet. You can take over the docs if you want to or we can share the task. It's fine for me.
Also thanks for the review. I will try to apply your suggestions tomorrow or at least in the next few days.
Thanks for the ping @diegomura.
Would love to see this get merged! I'd love to contribute as well if there's a blocker |
@PhilippBloss thanks for the review here. Would love to take this to the finish line. Are you still open to take care of the docs? 🙏🏻 |
Initially I wanted to wait for a decision on the component names, but I made a todo: diegomura/react-pdf-site#145 |
# By Diego Muracciole (31) and others # Via GitHub * upstream/master: (60 commits) feat: allow units for page size (diegomura#2773) chore: bump jay-peg chore: release packages (diegomura#2981) fix(textkit): make indentation only affect first line. (diegomura#2975) fix: conditional rendering (diegomura#2983) fix(reconciler): missing dependencies (diegomura#2980) chore: release packages (diegomura#2959) feat: rem border widths (diegomura#2960) fix: add scheduler dependency (diegomura#2958) chore: update README chore: release packages (diegomura#2953) feat: support rem units (diegomura#2955) feat: add image stress test example (diegomura#2954) feat: support multiple line-height units (diegomura#2952) chore: release packages (diegomura#2946) fix: note rendering (diegomura#2951) feat: accept commas between transformations (diegomura#2950) fix: document metadata setters (diegomura#2949) fix: stroke dash array computation (diegomura#2948) feat: remove cross-fetch (diegomura#2947) ... # Conflicts: # packages/renderer/index.d.ts
Hi @diegomura, I just made the branch compatible with 4.x and took care of @PhilippBloss' feedback. The only that is left now is deciding which names we choose for the components: Option 1 - align with pdfkit
Option 2 - web standards
I favour Option 1 more as there is a connect to the used library used for forms. What do you think? (previous discussion: #2845 (comment), and #2845 (comment)) |
Hey @diegomura, Hey @PhilippBloss, can you take a look at my last thoughts please? Thank you! |
Tasks
Related PR
Notes
initForm
fix by @kjossendal, see feat: add Form Annotation support #2013 (comment)Docs
Example PDF
Example 2.0.pdf