@resumekit/react 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +74 -2
- package/dist/PagedSheet.d.ts +63 -0
- package/dist/PagedSheet.d.ts.map +1 -0
- package/dist/PagedSheet.js +584 -0
- package/dist/TemplateDocument.d.ts +33 -0
- package/dist/TemplateDocument.d.ts.map +1 -0
- package/dist/TemplateDocument.js +33 -0
- package/dist/autosave-context.d.ts +37 -0
- package/dist/autosave-context.d.ts.map +1 -0
- package/dist/autosave-context.js +24 -0
- package/dist/collections/AuthoredItems.d.ts +9 -0
- package/dist/collections/AuthoredItems.d.ts.map +1 -0
- package/dist/collections/AuthoredItems.js +116 -0
- package/dist/collections/Collection.d.ts +48 -0
- package/dist/collections/Collection.d.ts.map +1 -0
- package/dist/collections/Collection.js +24 -0
- package/dist/collections/CollectionItems.d.ts +94 -0
- package/dist/collections/CollectionItems.d.ts.map +1 -0
- package/dist/collections/CollectionItems.js +91 -0
- package/dist/collections/EntryOverlay.d.ts +38 -0
- package/dist/collections/EntryOverlay.d.ts.map +1 -0
- package/dist/collections/EntryOverlay.js +51 -0
- package/dist/collections/SortableItems.d.ts +52 -0
- package/dist/collections/SortableItems.d.ts.map +1 -0
- package/dist/collections/SortableItems.js +80 -0
- package/dist/collections/authoring-context.d.ts +69 -0
- package/dist/collections/authoring-context.d.ts.map +1 -0
- package/dist/collections/authoring-context.js +36 -0
- package/dist/collections/collection.css +462 -0
- package/dist/collections/entry-text.d.ts +23 -0
- package/dist/collections/entry-text.d.ts.map +1 -0
- package/dist/collections/entry-text.js +35 -0
- package/dist/collections/icons.d.ts +53 -0
- package/dist/collections/icons.d.ts.map +1 -0
- package/dist/collections/icons.js +56 -0
- package/dist/collections/library/LibraryAction.d.ts +24 -0
- package/dist/collections/library/LibraryAction.d.ts.map +1 -0
- package/dist/collections/library/LibraryAction.js +122 -0
- package/dist/collections/library/LibraryPicker.d.ts +42 -0
- package/dist/collections/library/LibraryPicker.d.ts.map +1 -0
- package/dist/collections/library/LibraryPicker.js +94 -0
- package/dist/collections/library/library.css +435 -0
- package/dist/collections/overlay-context.d.ts +34 -0
- package/dist/collections/overlay-context.d.ts.map +1 -0
- package/dist/collections/overlay-context.js +13 -0
- package/dist/collections/preload.d.ts +19 -0
- package/dist/collections/preload.d.ts.map +1 -0
- package/dist/collections/preload.js +23 -0
- package/dist/collections/selection-context.d.ts +25 -0
- package/dist/collections/selection-context.d.ts.map +1 -0
- package/dist/collections/selection-context.js +49 -0
- package/dist/collections/useCollection.d.ts +58 -0
- package/dist/collections/useCollection.d.ts.map +1 -0
- package/dist/collections/useCollection.js +90 -0
- package/dist/collections/useCustomEntries.d.ts +18 -0
- package/dist/collections/useCustomEntries.d.ts.map +1 -0
- package/dist/collections/useCustomEntries.js +56 -0
- package/dist/collections/useSectionCollection.d.ts +48 -0
- package/dist/collections/useSectionCollection.d.ts.map +1 -0
- package/dist/collections/useSectionCollection.js +169 -0
- package/dist/document.css +185 -0
- package/dist/export-bundle/bundle.css +2 -0
- package/dist/export-bundle/bundle.js +67 -0
- package/dist/fields/date-issues-context.d.ts +20 -0
- package/dist/fields/date-issues-context.d.ts.map +1 -0
- package/dist/fields/date-issues-context.js +68 -0
- package/dist/fields/field-registry.d.ts +163 -0
- package/dist/fields/field-registry.d.ts.map +1 -0
- package/dist/fields/field-registry.js +175 -0
- package/dist/fonts/README.md +207 -0
- package/dist/fonts/arimo-400.woff2 +0 -0
- package/dist/fonts/arimo-400i.woff2 +0 -0
- package/dist/fonts/arimo-700.woff2 +0 -0
- package/dist/fonts/arimo-700i.woff2 +0 -0
- package/dist/fonts/bitter-400.woff2 +0 -0
- package/dist/fonts/bitter-400i.woff2 +0 -0
- package/dist/fonts/bitter-700.woff2 +0 -0
- package/dist/fonts/bitter-700i.woff2 +0 -0
- package/dist/fonts/cabin-700.woff2 +0 -0
- package/dist/fonts/carlito-400.woff2 +0 -0
- package/dist/fonts/carlito-400i.woff2 +0 -0
- package/dist/fonts/carlito-700.woff2 +0 -0
- package/dist/fonts/carlito-700i.woff2 +0 -0
- package/dist/fonts/clearsans-400.woff2 +0 -0
- package/dist/fonts/clearsans-400i.woff2 +0 -0
- package/dist/fonts/cochineal-400.woff2 +0 -0
- package/dist/fonts/cochineal-400i.woff2 +0 -0
- package/dist/fonts/cochineal-700.woff2 +0 -0
- package/dist/fonts/ebgaramond-400.woff2 +0 -0
- package/dist/fonts/ebgaramond-400i.woff2 +0 -0
- package/dist/fonts/ebgaramond-700.woff2 +0 -0
- package/dist/fonts/ebgaramond-700i.woff2 +0 -0
- package/dist/fonts/fonts.css +622 -0
- package/dist/fonts/gelasio-400.woff2 +0 -0
- package/dist/fonts/gelasio-400i.woff2 +0 -0
- package/dist/fonts/gelasio-700.woff2 +0 -0
- package/dist/fonts/gelasio-700i.woff2 +0 -0
- package/dist/fonts/heros-400.woff2 +0 -0
- package/dist/fonts/heros-400i.woff2 +0 -0
- package/dist/fonts/heros-700.woff2 +0 -0
- package/dist/fonts/heros-700i.woff2 +0 -0
- package/dist/fonts/inconsolata-400.woff2 +0 -0
- package/dist/fonts/lato-100.woff2 +0 -0
- package/dist/fonts/lato-300.woff2 +0 -0
- package/dist/fonts/lato-300i.woff2 +0 -0
- package/dist/fonts/lato-400.woff2 +0 -0
- package/dist/fonts/lato-400i.woff2 +0 -0
- package/dist/fonts/lato-700.woff2 +0 -0
- package/dist/fonts/lato-700i.woff2 +0 -0
- package/dist/fonts/licenses/arimo-OFL.txt +93 -0
- package/dist/fonts/licenses/bitter-OFL.txt +94 -0
- package/dist/fonts/licenses/cabin-OFL.txt +93 -0
- package/dist/fonts/licenses/carlito-OFL.txt +94 -0
- package/dist/fonts/licenses/clearsans-APACHE-2.0.txt +205 -0
- package/dist/fonts/licenses/cochineal-OFL.txt +96 -0
- package/dist/fonts/licenses/ebgaramond-OFL.txt +93 -0
- package/dist/fonts/licenses/gelasio-OFL.txt +93 -0
- package/dist/fonts/licenses/heros-GUST-FONT-LICENSE.txt +30 -0
- package/dist/fonts/licenses/inconsolata-OFL.txt +93 -0
- package/dist/fonts/licenses/latinmodern-GUST-FONT-LICENSE.txt +35 -0
- package/dist/fonts/licenses/lato-OFL.txt +93 -0
- package/dist/fonts/licenses/ptserif-OFL.txt +93 -0
- package/dist/fonts/licenses/raleway-OFL.txt +93 -0
- package/dist/fonts/licenses/roboto-OFL.txt +93 -0
- package/dist/fonts/licenses/robotocondensed-OFL.txt +93 -0
- package/dist/fonts/licenses/robotoslab-APACHE-2.0.txt +205 -0
- package/dist/fonts/licenses/sourcesans3-OFL.txt +93 -0
- package/dist/fonts/licenses/tinos-OFL.txt +93 -0
- package/dist/fonts/lmmono-400.woff2 +0 -0
- package/dist/fonts/lmroman-400.woff2 +0 -0
- package/dist/fonts/lmroman-400i.woff2 +0 -0
- package/dist/fonts/lmroman-700.woff2 +0 -0
- package/dist/fonts/lmroman-700i.woff2 +0 -0
- package/dist/fonts/lmromancaps-400.woff2 +0 -0
- package/dist/fonts/ptserif-400.woff2 +0 -0
- package/dist/fonts/ptserif-400i.woff2 +0 -0
- package/dist/fonts/ptserif-700.woff2 +0 -0
- package/dist/fonts/ptserif-700i.woff2 +0 -0
- package/dist/fonts/raleway-300.woff2 +0 -0
- package/dist/fonts/raleway-400.woff2 +0 -0
- package/dist/fonts/raleway-400i.woff2 +0 -0
- package/dist/fonts/raleway-500.woff2 +0 -0
- package/dist/fonts/raleway-700.woff2 +0 -0
- package/dist/fonts/roboto-100.woff2 +0 -0
- package/dist/fonts/roboto-300.woff2 +0 -0
- package/dist/fonts/roboto-300i.woff2 +0 -0
- package/dist/fonts/roboto-400.woff2 +0 -0
- package/dist/fonts/roboto-400i.woff2 +0 -0
- package/dist/fonts/roboto-700.woff2 +0 -0
- package/dist/fonts/robotocondensed-400.woff2 +0 -0
- package/dist/fonts/robotocondensed-400i.woff2 +0 -0
- package/dist/fonts/robotocondensed-700.woff2 +0 -0
- package/dist/fonts/robotocondensed-700i.woff2 +0 -0
- package/dist/fonts/robotoslab-700.woff2 +0 -0
- package/dist/fonts/sourcesans3-300.woff2 +0 -0
- package/dist/fonts/sourcesans3-300i.woff2 +0 -0
- package/dist/fonts/sourcesans3-400.woff2 +0 -0
- package/dist/fonts/sourcesans3-400i.woff2 +0 -0
- package/dist/fonts/sourcesans3-700.woff2 +0 -0
- package/dist/fonts/tinos-400.woff2 +0 -0
- package/dist/fonts/tinos-400i.woff2 +0 -0
- package/dist/fonts/tinos-700.woff2 +0 -0
- package/dist/fonts/tinos-700i.woff2 +0 -0
- package/dist/i18n/README.md +52 -0
- package/dist/i18n/catalog.d.ts +39 -0
- package/dist/i18n/catalog.d.ts.map +1 -0
- package/dist/i18n/catalog.js +43 -0
- package/dist/i18n/format.d.ts +14 -0
- package/dist/i18n/format.d.ts.map +1 -0
- package/dist/i18n/format.js +38 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/locale-context.d.ts +43 -0
- package/dist/i18n/locale-context.d.ts.map +1 -0
- package/dist/i18n/locale-context.js +74 -0
- package/dist/i18n/locales/en.json +337 -0
- package/dist/i18n/locales/es.json +337 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +99 -0
- package/dist/kit/BulletSkillGroup.d.ts +20 -0
- package/dist/kit/BulletSkillGroup.d.ts.map +1 -0
- package/dist/kit/BulletSkillGroup.js +25 -0
- package/dist/kit/DescribedEntries.d.ts +41 -0
- package/dist/kit/DescribedEntries.d.ts.map +1 -0
- package/dist/kit/DescribedEntries.js +57 -0
- package/dist/kit/DocumentSection.d.ts +58 -0
- package/dist/kit/DocumentSection.d.ts.map +1 -0
- package/dist/kit/DocumentSection.js +38 -0
- package/dist/kit/GridSkillGroup.d.ts +12 -0
- package/dist/kit/GridSkillGroup.d.ts.map +1 -0
- package/dist/kit/GridSkillGroup.js +14 -0
- package/dist/kit/Heading.d.ts +11 -0
- package/dist/kit/Heading.d.ts.map +1 -0
- package/dist/kit/Heading.js +10 -0
- package/dist/kit/InitialsAvatar.d.ts +17 -0
- package/dist/kit/InitialsAvatar.d.ts.map +1 -0
- package/dist/kit/InitialsAvatar.js +18 -0
- package/dist/kit/InitialsChip.d.ts +16 -0
- package/dist/kit/InitialsChip.d.ts.map +1 -0
- package/dist/kit/InitialsChip.js +16 -0
- package/dist/kit/InlineSkillGroup.d.ts +22 -0
- package/dist/kit/InlineSkillGroup.d.ts.map +1 -0
- package/dist/kit/InlineSkillGroup.js +16 -0
- package/dist/kit/LabelledSkillGroup.d.ts +24 -0
- package/dist/kit/LabelledSkillGroup.d.ts.map +1 -0
- package/dist/kit/LabelledSkillGroup.js +20 -0
- package/dist/kit/LanguageList.d.ts +28 -0
- package/dist/kit/LanguageList.d.ts.map +1 -0
- package/dist/kit/LanguageList.js +56 -0
- package/dist/kit/Separator.d.ts +20 -0
- package/dist/kit/Separator.d.ts.map +1 -0
- package/dist/kit/Separator.js +21 -0
- package/dist/kit/TagSkillGroup.d.ts +8 -0
- package/dist/kit/TagSkillGroup.d.ts.map +1 -0
- package/dist/kit/TagSkillGroup.js +10 -0
- package/dist/kit/avatar.css +42 -0
- package/dist/kit/contact-icons.css +70 -0
- package/dist/kit/contact.d.ts +16 -0
- package/dist/kit/contact.d.ts.map +1 -0
- package/dist/kit/contact.js +18 -0
- package/dist/kit/described.css +114 -0
- package/dist/kit/documentStyle.d.ts +12 -0
- package/dist/kit/documentStyle.d.ts.map +1 -0
- package/dist/kit/documentStyle.js +24 -0
- package/dist/kit/heading.css +17 -0
- package/dist/kit/keywords.css +127 -0
- package/dist/kit/language.css +104 -0
- package/dist/kit/layout.css +16 -0
- package/dist/kit/monogram.d.ts +6 -0
- package/dist/kit/monogram.d.ts.map +1 -0
- package/dist/kit/monogram.js +12 -0
- package/dist/kit/panel.css +26 -0
- package/dist/kit/skill-grid.css +93 -0
- package/dist/kit/skill-tags.css +36 -0
- package/dist/kit/textShapes.d.ts +24 -0
- package/dist/kit/textShapes.d.ts.map +1 -0
- package/dist/kit/textShapes.js +32 -0
- package/dist/letter/LetterDocument.d.ts +13 -0
- package/dist/letter/LetterDocument.d.ts.map +1 -0
- package/dist/letter/LetterDocument.js +12 -0
- package/dist/letter/letter.css +75 -0
- package/dist/nodes/AuthoredBullets.d.ts +22 -0
- package/dist/nodes/AuthoredBullets.d.ts.map +1 -0
- package/dist/nodes/AuthoredBullets.js +101 -0
- package/dist/nodes/CustomSections.d.ts +42 -0
- package/dist/nodes/CustomSections.d.ts.map +1 -0
- package/dist/nodes/CustomSections.js +27 -0
- package/dist/nodes/EditableBulletList.d.ts +15 -0
- package/dist/nodes/EditableBulletList.d.ts.map +1 -0
- package/dist/nodes/EditableBulletList.js +98 -0
- package/dist/nodes/EditableInlineList.d.ts +27 -0
- package/dist/nodes/EditableInlineList.d.ts.map +1 -0
- package/dist/nodes/EditableInlineList.js +50 -0
- package/dist/nodes/EditableText.d.ts +79 -0
- package/dist/nodes/EditableText.d.ts.map +1 -0
- package/dist/nodes/EditableText.js +113 -0
- package/dist/nodes/LinkField.d.ts +103 -0
- package/dist/nodes/LinkField.d.ts.map +1 -0
- package/dist/nodes/LinkField.js +277 -0
- package/dist/nodes/PlainTextField.d.ts +38 -0
- package/dist/nodes/PlainTextField.d.ts.map +1 -0
- package/dist/nodes/PlainTextField.js +72 -0
- package/dist/nodes/formatting.d.ts +34 -0
- package/dist/nodes/formatting.d.ts.map +1 -0
- package/dist/nodes/formatting.js +24 -0
- package/dist/nodes/link-field.css +200 -0
- package/dist/nodes/locked.d.ts +38 -0
- package/dist/nodes/locked.d.ts.map +1 -0
- package/dist/nodes/locked.js +65 -0
- package/dist/nodes/template-node.css +720 -0
- package/dist/paged.css +265 -0
- package/dist/pagination.d.ts +93 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +167 -0
- package/dist/picture-context.d.ts +6 -0
- package/dist/picture-context.d.ts.map +1 -0
- package/dist/picture-context.js +14 -0
- package/dist/presentation-context.d.ts +45 -0
- package/dist/presentation-context.d.ts.map +1 -0
- package/dist/presentation-context.js +44 -0
- package/dist/presented.d.ts +16 -0
- package/dist/presented.d.ts.map +1 -0
- package/dist/presented.js +22 -0
- package/dist/rail/ContainerRail.d.ts +29 -0
- package/dist/rail/ContainerRail.d.ts.map +1 -0
- package/dist/rail/ContainerRail.js +50 -0
- package/dist/rail/EntryActions.d.ts +19 -0
- package/dist/rail/EntryActions.d.ts.map +1 -0
- package/dist/rail/EntryActions.js +17 -0
- package/dist/rail/rail-store.d.ts +42 -0
- package/dist/rail/rail-store.d.ts.map +1 -0
- package/dist/rail/rail-store.js +107 -0
- package/dist/rail/rail.css +188 -0
- package/dist/rail/useSpaceDrag.d.ts +30 -0
- package/dist/rail/useSpaceDrag.d.ts.map +1 -0
- package/dist/rail/useSpaceDrag.js +154 -0
- package/dist/registry.d.ts +35 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +74 -0
- package/dist/spacing/spacing-context.d.ts +53 -0
- package/dist/spacing/spacing-context.d.ts.map +1 -0
- package/dist/spacing/spacing-context.js +36 -0
- package/dist/spacing/spacing.css +159 -0
- package/dist/spacing/useSpaceSlot.d.ts +52 -0
- package/dist/spacing/useSpaceSlot.d.ts.map +1 -0
- package/dist/spacing/useSpaceSlot.js +38 -0
- package/dist/static/api.d.ts +13 -0
- package/dist/static/api.d.ts.map +1 -0
- package/dist/static/api.js +1 -0
- package/dist/static/static.mjs +33779 -0
- package/dist/static/templates/academic.css +1 -0
- package/dist/static/templates/alta.css +1 -0
- package/dist/static/templates/classic.css +1 -0
- package/dist/static/templates/cobalt.css +1 -0
- package/dist/static/templates/compact.css +1 -0
- package/dist/static/templates/contemporary.css +1 -0
- package/dist/static/templates/creative.css +1 -0
- package/dist/static/templates/crimson.css +1 -0
- package/dist/static/templates/curve.css +1 -0
- package/dist/static/templates/double-column-logos.css +1 -0
- package/dist/static/templates/double-column.css +1 -0
- package/dist/static/templates/elegant-logos.css +1 -0
- package/dist/static/templates/elegant.css +1 -0
- package/dist/static/templates/engineer.css +1 -0
- package/dist/static/templates/executive.css +1 -0
- package/dist/static/templates/harvard.css +1 -0
- package/dist/static/templates/hipster.css +1 -0
- package/dist/static/templates/ivy.css +1 -0
- package/dist/static/templates/meridian.css +1 -0
- package/dist/static/templates/modern.css +1 -0
- package/dist/static/templates/polished.css +1 -0
- package/dist/static/templates/portrait.css +1 -0
- package/dist/static/templates/prism.css +1 -0
- package/dist/static/templates/scholar.css +1 -0
- package/dist/static/templates/split.css +1 -0
- package/dist/static/templates/stylish.css +1 -0
- package/dist/static/templates/timeline.css +1 -0
- package/dist/static/templates.css +1 -0
- package/dist/templates/academic/AcademicDocument.d.ts +6 -0
- package/dist/templates/academic/AcademicDocument.d.ts.map +1 -0
- package/dist/templates/academic/AcademicDocument.js +29 -0
- package/dist/templates/academic/academic.css +284 -0
- package/dist/templates/academic/entries.d.ts +22 -0
- package/dist/templates/academic/entries.d.ts.map +1 -0
- package/dist/templates/academic/entries.js +17 -0
- package/dist/templates/alta/AltaDocument.d.ts +6 -0
- package/dist/templates/alta/AltaDocument.d.ts.map +1 -0
- package/dist/templates/alta/AltaDocument.js +29 -0
- package/dist/templates/alta/alta.css +413 -0
- package/dist/templates/alta/entries.d.ts +22 -0
- package/dist/templates/alta/entries.d.ts.map +1 -0
- package/dist/templates/alta/entries.js +17 -0
- package/dist/templates/classic/ClassicDocument.d.ts +6 -0
- package/dist/templates/classic/ClassicDocument.d.ts.map +1 -0
- package/dist/templates/classic/ClassicDocument.js +26 -0
- package/dist/templates/classic/classic.css +251 -0
- package/dist/templates/classic/entries.d.ts +22 -0
- package/dist/templates/classic/entries.d.ts.map +1 -0
- package/dist/templates/classic/entries.js +17 -0
- package/dist/templates/cobalt/CobaltDocument.d.ts +6 -0
- package/dist/templates/cobalt/CobaltDocument.d.ts.map +1 -0
- package/dist/templates/cobalt/CobaltDocument.js +28 -0
- package/dist/templates/cobalt/cobalt.css +478 -0
- package/dist/templates/cobalt/crest.d.ts +6 -0
- package/dist/templates/cobalt/crest.d.ts.map +1 -0
- package/dist/templates/cobalt/crest.js +8 -0
- package/dist/templates/cobalt/entries.d.ts +22 -0
- package/dist/templates/cobalt/entries.d.ts.map +1 -0
- package/dist/templates/cobalt/entries.js +17 -0
- package/dist/templates/compact/CompactDocument.d.ts +6 -0
- package/dist/templates/compact/CompactDocument.d.ts.map +1 -0
- package/dist/templates/compact/CompactDocument.js +28 -0
- package/dist/templates/compact/compact.css +240 -0
- package/dist/templates/compact/entries.d.ts +22 -0
- package/dist/templates/compact/entries.d.ts.map +1 -0
- package/dist/templates/compact/entries.js +17 -0
- package/dist/templates/contemporary/ContemporaryDocument.d.ts +6 -0
- package/dist/templates/contemporary/ContemporaryDocument.d.ts.map +1 -0
- package/dist/templates/contemporary/ContemporaryDocument.js +29 -0
- package/dist/templates/contemporary/contemporary.css +411 -0
- package/dist/templates/contemporary/entries.d.ts +22 -0
- package/dist/templates/contemporary/entries.d.ts.map +1 -0
- package/dist/templates/contemporary/entries.js +17 -0
- package/dist/templates/creative/CreativeDocument.d.ts +6 -0
- package/dist/templates/creative/CreativeDocument.d.ts.map +1 -0
- package/dist/templates/creative/CreativeDocument.js +29 -0
- package/dist/templates/creative/creative.css +326 -0
- package/dist/templates/creative/entries.d.ts +22 -0
- package/dist/templates/creative/entries.d.ts.map +1 -0
- package/dist/templates/creative/entries.js +17 -0
- package/dist/templates/crimson/CrimsonDocument.d.ts +6 -0
- package/dist/templates/crimson/CrimsonDocument.d.ts.map +1 -0
- package/dist/templates/crimson/CrimsonDocument.js +30 -0
- package/dist/templates/crimson/crimson.css +301 -0
- package/dist/templates/crimson/entries.d.ts +22 -0
- package/dist/templates/crimson/entries.d.ts.map +1 -0
- package/dist/templates/crimson/entries.js +17 -0
- package/dist/templates/curve/CurveDocument.d.ts +6 -0
- package/dist/templates/curve/CurveDocument.d.ts.map +1 -0
- package/dist/templates/curve/CurveDocument.js +29 -0
- package/dist/templates/curve/curve.css +330 -0
- package/dist/templates/curve/entries.d.ts +22 -0
- package/dist/templates/curve/entries.d.ts.map +1 -0
- package/dist/templates/curve/entries.js +17 -0
- package/dist/templates/double-column/DoubleColumnDocument.d.ts +6 -0
- package/dist/templates/double-column/DoubleColumnDocument.d.ts.map +1 -0
- package/dist/templates/double-column/DoubleColumnDocument.js +29 -0
- package/dist/templates/double-column/double-column.css +331 -0
- package/dist/templates/double-column/entries.d.ts +22 -0
- package/dist/templates/double-column/entries.d.ts.map +1 -0
- package/dist/templates/double-column/entries.js +17 -0
- package/dist/templates/double-column-logos/DoubleColumnLogosDocument.d.ts +6 -0
- package/dist/templates/double-column-logos/DoubleColumnLogosDocument.d.ts.map +1 -0
- package/dist/templates/double-column-logos/DoubleColumnLogosDocument.js +28 -0
- package/dist/templates/double-column-logos/double-column-logos.css +333 -0
- package/dist/templates/double-column-logos/entries.d.ts +22 -0
- package/dist/templates/double-column-logos/entries.d.ts.map +1 -0
- package/dist/templates/double-column-logos/entries.js +18 -0
- package/dist/templates/elegant/ElegantDocument.d.ts +6 -0
- package/dist/templates/elegant/ElegantDocument.d.ts.map +1 -0
- package/dist/templates/elegant/ElegantDocument.js +31 -0
- package/dist/templates/elegant/elegant.css +358 -0
- package/dist/templates/elegant/entries.d.ts +22 -0
- package/dist/templates/elegant/entries.d.ts.map +1 -0
- package/dist/templates/elegant/entries.js +17 -0
- package/dist/templates/elegant-logos/ElegantLogosDocument.d.ts +6 -0
- package/dist/templates/elegant-logos/ElegantLogosDocument.d.ts.map +1 -0
- package/dist/templates/elegant-logos/ElegantLogosDocument.js +30 -0
- package/dist/templates/elegant-logos/elegant-logos.css +370 -0
- package/dist/templates/elegant-logos/entries.d.ts +22 -0
- package/dist/templates/elegant-logos/entries.d.ts.map +1 -0
- package/dist/templates/elegant-logos/entries.js +18 -0
- package/dist/templates/engineer/EngineerDocument.d.ts +6 -0
- package/dist/templates/engineer/EngineerDocument.d.ts.map +1 -0
- package/dist/templates/engineer/EngineerDocument.js +26 -0
- package/dist/templates/engineer/engineer.css +261 -0
- package/dist/templates/engineer/entries.d.ts +22 -0
- package/dist/templates/engineer/entries.d.ts.map +1 -0
- package/dist/templates/engineer/entries.js +17 -0
- package/dist/templates/executive/ExecutiveDocument.d.ts +6 -0
- package/dist/templates/executive/ExecutiveDocument.d.ts.map +1 -0
- package/dist/templates/executive/ExecutiveDocument.js +29 -0
- package/dist/templates/executive/entries.d.ts +22 -0
- package/dist/templates/executive/entries.d.ts.map +1 -0
- package/dist/templates/executive/entries.js +17 -0
- package/dist/templates/executive/executive.css +394 -0
- package/dist/templates/harvard/HarvardDocument.d.ts +6 -0
- package/dist/templates/harvard/HarvardDocument.d.ts.map +1 -0
- package/dist/templates/harvard/HarvardDocument.js +25 -0
- package/dist/templates/harvard/entries.d.ts +28 -0
- package/dist/templates/harvard/entries.d.ts.map +1 -0
- package/dist/templates/harvard/entries.js +22 -0
- package/dist/templates/harvard/harvard.css +436 -0
- package/dist/templates/hipster/HipsterDocument.d.ts +6 -0
- package/dist/templates/hipster/HipsterDocument.d.ts.map +1 -0
- package/dist/templates/hipster/HipsterDocument.js +30 -0
- package/dist/templates/hipster/entries.d.ts +22 -0
- package/dist/templates/hipster/entries.d.ts.map +1 -0
- package/dist/templates/hipster/entries.js +17 -0
- package/dist/templates/hipster/hipster.css +442 -0
- package/dist/templates/ivy/IvyDocument.d.ts +6 -0
- package/dist/templates/ivy/IvyDocument.d.ts.map +1 -0
- package/dist/templates/ivy/IvyDocument.js +26 -0
- package/dist/templates/ivy/entries.d.ts +22 -0
- package/dist/templates/ivy/entries.d.ts.map +1 -0
- package/dist/templates/ivy/entries.js +17 -0
- package/dist/templates/ivy/ivy.css +292 -0
- package/dist/templates/meridian/MeridianDocument.d.ts +6 -0
- package/dist/templates/meridian/MeridianDocument.d.ts.map +1 -0
- package/dist/templates/meridian/MeridianDocument.js +28 -0
- package/dist/templates/meridian/entries.d.ts +22 -0
- package/dist/templates/meridian/entries.d.ts.map +1 -0
- package/dist/templates/meridian/entries.js +17 -0
- package/dist/templates/meridian/meridian.css +431 -0
- package/dist/templates/modern/ModernDocument.d.ts +6 -0
- package/dist/templates/modern/ModernDocument.d.ts.map +1 -0
- package/dist/templates/modern/ModernDocument.js +29 -0
- package/dist/templates/modern/entries.d.ts +22 -0
- package/dist/templates/modern/entries.d.ts.map +1 -0
- package/dist/templates/modern/entries.js +17 -0
- package/dist/templates/modern/modern.css +309 -0
- package/dist/templates/polished/PolishedDocument.d.ts +6 -0
- package/dist/templates/polished/PolishedDocument.d.ts.map +1 -0
- package/dist/templates/polished/PolishedDocument.js +28 -0
- package/dist/templates/polished/entries.d.ts +22 -0
- package/dist/templates/polished/entries.d.ts.map +1 -0
- package/dist/templates/polished/entries.js +17 -0
- package/dist/templates/polished/polished.css +327 -0
- package/dist/templates/portrait/PortraitDocument.d.ts +6 -0
- package/dist/templates/portrait/PortraitDocument.d.ts.map +1 -0
- package/dist/templates/portrait/PortraitDocument.js +30 -0
- package/dist/templates/portrait/entries.d.ts +22 -0
- package/dist/templates/portrait/entries.d.ts.map +1 -0
- package/dist/templates/portrait/entries.js +17 -0
- package/dist/templates/portrait/portrait.css +427 -0
- package/dist/templates/prism/PrismDocument.d.ts +6 -0
- package/dist/templates/prism/PrismDocument.d.ts.map +1 -0
- package/dist/templates/prism/PrismDocument.js +35 -0
- package/dist/templates/prism/entries.d.ts +22 -0
- package/dist/templates/prism/entries.d.ts.map +1 -0
- package/dist/templates/prism/entries.js +17 -0
- package/dist/templates/prism/prism.css +314 -0
- package/dist/templates/scholar/ScholarDocument.d.ts +6 -0
- package/dist/templates/scholar/ScholarDocument.d.ts.map +1 -0
- package/dist/templates/scholar/ScholarDocument.js +27 -0
- package/dist/templates/scholar/entries.d.ts +22 -0
- package/dist/templates/scholar/entries.d.ts.map +1 -0
- package/dist/templates/scholar/entries.js +17 -0
- package/dist/templates/scholar/scholar.css +279 -0
- package/dist/templates/skills.d.ts +19 -0
- package/dist/templates/skills.d.ts.map +1 -0
- package/dist/templates/skills.js +19 -0
- package/dist/templates/split/SplitDocument.d.ts +6 -0
- package/dist/templates/split/SplitDocument.d.ts.map +1 -0
- package/dist/templates/split/SplitDocument.js +29 -0
- package/dist/templates/split/entries.d.ts +22 -0
- package/dist/templates/split/entries.d.ts.map +1 -0
- package/dist/templates/split/entries.js +17 -0
- package/dist/templates/split/split.css +337 -0
- package/dist/templates/stylish/StylishDocument.d.ts +6 -0
- package/dist/templates/stylish/StylishDocument.d.ts.map +1 -0
- package/dist/templates/stylish/StylishDocument.js +29 -0
- package/dist/templates/stylish/entries.d.ts +22 -0
- package/dist/templates/stylish/entries.d.ts.map +1 -0
- package/dist/templates/stylish/entries.js +17 -0
- package/dist/templates/stylish/stylish.css +340 -0
- package/dist/templates/timeline/TimelineDocument.d.ts +6 -0
- package/dist/templates/timeline/TimelineDocument.d.ts.map +1 -0
- package/dist/templates/timeline/TimelineDocument.js +27 -0
- package/dist/templates/timeline/entries.d.ts +22 -0
- package/dist/templates/timeline/entries.d.ts.map +1 -0
- package/dist/templates/timeline/entries.js +17 -0
- package/dist/templates/timeline/timeline.css +295 -0
- package/dist/useFitZoom.d.ts +99 -0
- package/dist/useFitZoom.d.ts.map +1 -0
- package/dist/useFitZoom.js +171 -0
- package/package.json +81 -3
- package/src/PagedSheet.tsx +792 -0
- package/src/TemplateDocument.tsx +112 -0
- package/src/autosave-context.tsx +67 -0
- package/src/collections/AuthoredItems.tsx +199 -0
- package/src/collections/Collection.tsx +73 -0
- package/src/collections/CollectionItems.tsx +318 -0
- package/src/collections/EntryOverlay.tsx +162 -0
- package/src/collections/SortableItems.tsx +167 -0
- package/src/collections/authoring-context.tsx +140 -0
- package/src/collections/entry-text.ts +41 -0
- package/src/collections/icons.tsx +83 -0
- package/src/collections/library/LibraryAction.tsx +200 -0
- package/src/collections/library/LibraryPicker.tsx +325 -0
- package/src/collections/overlay-context.tsx +49 -0
- package/src/collections/preload.ts +23 -0
- package/src/collections/selection-context.tsx +88 -0
- package/src/collections/useCollection.ts +133 -0
- package/src/collections/useCustomEntries.ts +84 -0
- package/src/collections/useSectionCollection.ts +268 -0
- package/src/compiler/emit.ts +736 -0
- package/src/compiler/schema.ts +689 -0
- package/src/export/entry.tsx +177 -0
- package/src/fields/date-issues-context.tsx +105 -0
- package/src/fields/field-registry.tsx +358 -0
- package/src/i18n/catalog.ts +81 -0
- package/src/i18n/format.ts +50 -0
- package/src/i18n/index.ts +21 -0
- package/src/i18n/locale-context.tsx +135 -0
- package/src/index.ts +156 -0
- package/src/kit/BulletSkillGroup.tsx +37 -0
- package/src/kit/DescribedEntries.tsx +132 -0
- package/src/kit/DocumentSection.tsx +97 -0
- package/src/kit/GridSkillGroup.tsx +17 -0
- package/src/kit/Heading.tsx +17 -0
- package/src/kit/InitialsAvatar.tsx +31 -0
- package/src/kit/InitialsChip.tsx +29 -0
- package/src/kit/InlineSkillGroup.tsx +41 -0
- package/src/kit/LabelledSkillGroup.tsx +68 -0
- package/src/kit/LanguageList.tsx +148 -0
- package/src/kit/Separator.tsx +30 -0
- package/src/kit/TagSkillGroup.tsx +19 -0
- package/src/kit/contact.ts +34 -0
- package/src/kit/documentStyle.ts +33 -0
- package/src/kit/monogram.ts +11 -0
- package/src/kit/textShapes.tsx +61 -0
- package/src/letter/LetterDocument.tsx +33 -0
- package/src/nodes/AuthoredBullets.tsx +253 -0
- package/src/nodes/CustomSections.tsx +138 -0
- package/src/nodes/EditableBulletList.tsx +186 -0
- package/src/nodes/EditableInlineList.tsx +109 -0
- package/src/nodes/EditableText.tsx +261 -0
- package/src/nodes/LinkField.tsx +438 -0
- package/src/nodes/PlainTextField.tsx +132 -0
- package/src/nodes/formatting.ts +58 -0
- package/src/nodes/locked.ts +67 -0
- package/src/pagination.ts +238 -0
- package/src/picture-context.tsx +18 -0
- package/src/presentation-context.tsx +87 -0
- package/src/presented.ts +29 -0
- package/src/rail/ContainerRail.tsx +145 -0
- package/src/rail/EntryActions.tsx +104 -0
- package/src/rail/rail-store.tsx +126 -0
- package/src/rail/useSpaceDrag.ts +177 -0
- package/src/registry.ts +101 -0
- package/src/spacing/spacing-context.tsx +100 -0
- package/src/spacing/useSpaceSlot.tsx +97 -0
- package/src/static/api.ts +19 -0
- package/src/static/fixtures.ts +80 -0
- package/src/static/render.tsx +24 -0
- package/src/templates/academic/AcademicDocument.tsx +255 -0
- package/src/templates/academic/entries.tsx +176 -0
- package/src/templates/alta/AltaDocument.tsx +265 -0
- package/src/templates/alta/entries.tsx +167 -0
- package/src/templates/classic/ClassicDocument.tsx +248 -0
- package/src/templates/classic/entries.tsx +175 -0
- package/src/templates/cobalt/CobaltDocument.tsx +302 -0
- package/src/templates/cobalt/crest.tsx +31 -0
- package/src/templates/cobalt/entries.tsx +136 -0
- package/src/templates/compact/CompactDocument.tsx +256 -0
- package/src/templates/compact/entries.tsx +167 -0
- package/src/templates/contemporary/ContemporaryDocument.tsx +287 -0
- package/src/templates/contemporary/entries.tsx +167 -0
- package/src/templates/creative/CreativeDocument.tsx +269 -0
- package/src/templates/creative/entries.tsx +167 -0
- package/src/templates/crimson/CrimsonDocument.tsx +283 -0
- package/src/templates/crimson/entries.tsx +169 -0
- package/src/templates/curve/CurveDocument.tsx +259 -0
- package/src/templates/curve/entries.tsx +168 -0
- package/src/templates/double-column/DoubleColumnDocument.tsx +269 -0
- package/src/templates/double-column/entries.tsx +169 -0
- package/src/templates/double-column-logos/DoubleColumnLogosDocument.tsx +262 -0
- package/src/templates/double-column-logos/entries.tsx +172 -0
- package/src/templates/elegant/ElegantDocument.tsx +297 -0
- package/src/templates/elegant/entries.tsx +167 -0
- package/src/templates/elegant-logos/ElegantLogosDocument.tsx +291 -0
- package/src/templates/elegant-logos/entries.tsx +170 -0
- package/src/templates/engineer/EngineerDocument.tsx +248 -0
- package/src/templates/engineer/entries.tsx +170 -0
- package/src/templates/executive/ExecutiveDocument.tsx +312 -0
- package/src/templates/executive/entries.tsx +146 -0
- package/src/templates/harvard/HarvardDocument.tsx +248 -0
- package/src/templates/harvard/entries.tsx +205 -0
- package/src/templates/hipster/HipsterDocument.tsx +289 -0
- package/src/templates/hipster/entries.tsx +175 -0
- package/src/templates/ivy/IvyDocument.tsx +248 -0
- package/src/templates/ivy/entries.tsx +167 -0
- package/src/templates/meridian/MeridianDocument.tsx +304 -0
- package/src/templates/meridian/entries.tsx +140 -0
- package/src/templates/modern/ModernDocument.tsx +265 -0
- package/src/templates/modern/entries.tsx +167 -0
- package/src/templates/polished/PolishedDocument.tsx +262 -0
- package/src/templates/polished/entries.tsx +167 -0
- package/src/templates/portrait/PortraitDocument.tsx +278 -0
- package/src/templates/portrait/entries.tsx +173 -0
- package/src/templates/prism/PrismDocument.tsx +307 -0
- package/src/templates/prism/entries.tsx +175 -0
- package/src/templates/scholar/ScholarDocument.tsx +266 -0
- package/src/templates/scholar/entries.tsx +169 -0
- package/src/templates/skills.ts +21 -0
- package/src/templates/split/SplitDocument.tsx +293 -0
- package/src/templates/split/entries.tsx +164 -0
- package/src/templates/stylish/StylishDocument.tsx +265 -0
- package/src/templates/stylish/entries.tsx +167 -0
- package/src/templates/timeline/TimelineDocument.tsx +251 -0
- package/src/templates/timeline/entries.tsx +173 -0
- package/src/useFitZoom.ts +185 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The export bundle: the document, drawn in the renderer's browser.
|
|
3
|
+
*
|
|
4
|
+
* ## Why a browser bundle rather than server-rendered HTML
|
|
5
|
+
*
|
|
6
|
+
* Not because the components cannot be server-rendered — they can.
|
|
7
|
+
* `renderToStaticMarkup` of `TemplateDocument` produces the whole document, text
|
|
8
|
+
* and all. The reason is narrower, and it is **pagination**.
|
|
9
|
+
*
|
|
10
|
+
* `PagedSheet` decides where a page ends by MEASURING the laid-out document:
|
|
11
|
+
* `getBoundingClientRect` on every block, a settle loop, and a correction pass
|
|
12
|
+
* for margins that collapsed. `pagination.ts` states the constraint plainly —
|
|
13
|
+
* reading the layout is a browser question, and every measurement outside a
|
|
14
|
+
* browser is zero. Server-rendered markup therefore arrives unpaginated: no
|
|
15
|
+
* pushed margins, one sheet reported however long the résumé is, and the page
|
|
16
|
+
* breaks left to whatever Chromium's own `break-*` rules decide. That is exactly
|
|
17
|
+
* the screen/paper divergence this change exists to eliminate.
|
|
18
|
+
*
|
|
19
|
+
* Paginating server-rendered markup would mean reimplementing the measuring half
|
|
20
|
+
* of `PagedSheet` as a standalone script — a second implementation of the one
|
|
21
|
+
* piece of code the guarantee rests on. So the export ships the real thing and
|
|
22
|
+
* lets the renderer's Chromium run it. The paginator is **executed, not
|
|
23
|
+
* reimplemented**, and the only difference from the editor's rendering is
|
|
24
|
+
* `sheetGap`, which is zero because paper has no gap between its pages.
|
|
25
|
+
*
|
|
26
|
+
* The cost is an inlined bundle of a few hundred KB. Against a render that is
|
|
27
|
+
* already starting a browser, that is not the expensive part.
|
|
28
|
+
*/
|
|
29
|
+
import { createRoot } from 'react-dom/client';
|
|
30
|
+
import { TemplateDocument } from '../TemplateDocument.js';
|
|
31
|
+
import { LetterDocument } from '../letter/LetterDocument.js';
|
|
32
|
+
import {
|
|
33
|
+
EXPORT_PAGES_GLOBAL,
|
|
34
|
+
EXPORT_PAYLOAD_GLOBAL,
|
|
35
|
+
EXPORT_STATE_GLOBAL,
|
|
36
|
+
PRINT_SHEET_GAP,
|
|
37
|
+
isLetterPayload,
|
|
38
|
+
type ExportPayload,
|
|
39
|
+
type ExportState,
|
|
40
|
+
} from '@resumekit/schema';
|
|
41
|
+
|
|
42
|
+
/** How many consecutive identical frames count as "the layout has stopped". */
|
|
43
|
+
const STABLE_FRAMES = 3;
|
|
44
|
+
/** Frames to wait before giving up on the layout ever settling. */
|
|
45
|
+
const MAX_FRAMES = 240;
|
|
46
|
+
|
|
47
|
+
declare global {
|
|
48
|
+
interface Window {
|
|
49
|
+
[EXPORT_PAYLOAD_GLOBAL]?: ExportPayload;
|
|
50
|
+
[EXPORT_STATE_GLOBAL]?: ExportState;
|
|
51
|
+
[EXPORT_PAGES_GLOBAL]?: number;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function setState(state: ExportState): void {
|
|
56
|
+
window[EXPORT_STATE_GLOBAL] = state;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const frame = () =>
|
|
60
|
+
new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A fingerprint of everything that decides where the pages fall.
|
|
64
|
+
*
|
|
65
|
+
* The page count alone is not enough: a document can reach its final count while
|
|
66
|
+
* a block is still being nudged by the correction pass, and printing then would
|
|
67
|
+
* capture the intermediate position. The pushed margins are therefore part of
|
|
68
|
+
* the fingerprint, so "settled" means every block has stopped moving.
|
|
69
|
+
*/
|
|
70
|
+
function layoutFingerprint(): string {
|
|
71
|
+
const pages = document.querySelector<HTMLElement>('.tpl-pages');
|
|
72
|
+
if (!pages) return '';
|
|
73
|
+
const blocks = Array.from(
|
|
74
|
+
pages.querySelectorAll<HTMLElement>('.tpl-pages__flow *'),
|
|
75
|
+
)
|
|
76
|
+
.map((el) => el.style.marginTop)
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join('|');
|
|
79
|
+
return `${pages.style.getPropertyValue('--pages')}#${Math.round(
|
|
80
|
+
pages.getBoundingClientRect().height,
|
|
81
|
+
)}#${blocks}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Wait until the document has stopped moving.
|
|
86
|
+
*
|
|
87
|
+
* Fonts first, because a face that loads late re-flows every line and would
|
|
88
|
+
* otherwise settle the layout twice — the second time after the renderer had
|
|
89
|
+
* already been told the page was ready. `document.fonts.ready` is the browser's
|
|
90
|
+
* own answer to "are the metrics final", so nothing here has to guess at a delay.
|
|
91
|
+
*/
|
|
92
|
+
async function settle(): Promise<void> {
|
|
93
|
+
await document.fonts.ready;
|
|
94
|
+
|
|
95
|
+
let previous = '';
|
|
96
|
+
let stable = 0;
|
|
97
|
+
for (let i = 0; i < MAX_FRAMES; i++) {
|
|
98
|
+
await frame();
|
|
99
|
+
const current = layoutFingerprint();
|
|
100
|
+
if (current !== '' && current === previous) {
|
|
101
|
+
if (++stable >= STABLE_FRAMES) return;
|
|
102
|
+
} else {
|
|
103
|
+
stable = 0;
|
|
104
|
+
}
|
|
105
|
+
previous = current;
|
|
106
|
+
}
|
|
107
|
+
throw new Error('layout did not settle');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function main(): Promise<void> {
|
|
111
|
+
const payload = window[EXPORT_PAYLOAD_GLOBAL];
|
|
112
|
+
if (!payload) throw new Error('no export payload');
|
|
113
|
+
|
|
114
|
+
const host = document.getElementById('cvgs-export-root');
|
|
115
|
+
if (!host) throw new Error('no export root');
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Deliberately NOT under StrictMode.
|
|
119
|
+
*
|
|
120
|
+
* StrictMode exists to surface effect bugs during development by running
|
|
121
|
+
* effects twice. This is a print job: there is no developer to warn, and the
|
|
122
|
+
* doubling costs a second full pagination pass of a document whose whole job
|
|
123
|
+
* is to be measured. The app mounts the same tree under StrictMode, so
|
|
124
|
+
* anything it would catch is already caught where it can be acted on.
|
|
125
|
+
*
|
|
126
|
+
* A letter is one flowing column the browser breaks by itself — it has no
|
|
127
|
+
* paginator to wait for, only its fonts.
|
|
128
|
+
*/
|
|
129
|
+
if (isLetterPayload(payload)) {
|
|
130
|
+
createRoot(host).render(
|
|
131
|
+
<LetterDocument letter={payload.letter} date={payload.date} />,
|
|
132
|
+
);
|
|
133
|
+
await document.fonts.ready;
|
|
134
|
+
await frame();
|
|
135
|
+
window[EXPORT_PAGES_GLOBAL] = 1;
|
|
136
|
+
setState('ready');
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
createRoot(host).render(
|
|
141
|
+
<TemplateDocument
|
|
142
|
+
resume={payload.resume}
|
|
143
|
+
presentation={payload.presentation}
|
|
144
|
+
sheetGap={PRINT_SHEET_GAP}
|
|
145
|
+
/>,
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
await settle();
|
|
149
|
+
|
|
150
|
+
const pages = document.querySelector<HTMLElement>('.tpl-pages');
|
|
151
|
+
window[EXPORT_PAGES_GLOBAL] = Number(
|
|
152
|
+
pages?.style.getPropertyValue('--pages') ?? 1,
|
|
153
|
+
);
|
|
154
|
+
setState('ready');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setState('pending');
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* Any failure ends the wait immediately and says so.
|
|
161
|
+
*
|
|
162
|
+
* Without this a broken document would hold the renderer for its whole timeout
|
|
163
|
+
* and then report only that it expired — the least useful of the available
|
|
164
|
+
* facts. The renderer additionally fails on console exceptions, so an error
|
|
165
|
+
* thrown outside this promise is caught too.
|
|
166
|
+
*/
|
|
167
|
+
window.addEventListener('error', () => setState('failed'));
|
|
168
|
+
window.addEventListener('unhandledrejection', () => setState('failed'));
|
|
169
|
+
|
|
170
|
+
main().catch((error: unknown) => {
|
|
171
|
+
setState('failed');
|
|
172
|
+
// The template id and the failure — never the document. See the PII rule.
|
|
173
|
+
console.error(
|
|
174
|
+
'[export] render failed:',
|
|
175
|
+
error instanceof Error ? error.message : 'unknown error',
|
|
176
|
+
);
|
|
177
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useMemo,
|
|
5
|
+
useSyncExternalStore,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import {
|
|
9
|
+
additionPaths,
|
|
10
|
+
collectionOrder,
|
|
11
|
+
dateIssuesInDrawnOrder,
|
|
12
|
+
type AppendableSection,
|
|
13
|
+
type DateIssueKind,
|
|
14
|
+
} from '@resumekit/schema';
|
|
15
|
+
import { useFieldRegistry } from './field-registry.js';
|
|
16
|
+
import { useDocumentOverlay } from '../collections/overlay-context.js';
|
|
17
|
+
|
|
18
|
+
/** The sections whose entries carry a start and an end to compare. */
|
|
19
|
+
const DATED: AppendableSection[] = ['experience', 'education'];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Which fields disagree with the résumé's chronological order, by PATH.
|
|
23
|
+
*
|
|
24
|
+
* Keyed by path because that is the address a field already knows itself by, so
|
|
25
|
+
* `EditableText` can ask "is there anything about me?" without knowing the
|
|
26
|
+
* résumé's shape. That is what lets every template carry this without being
|
|
27
|
+
* edited, and a template added later get it for free.
|
|
28
|
+
*
|
|
29
|
+
* Absent by default, and that is the whole of how this stays out of the export:
|
|
30
|
+
* only the editor mounts the provider, so the read-only preview and the render
|
|
31
|
+
* container see an empty map and draw exactly what they drew before.
|
|
32
|
+
*/
|
|
33
|
+
const DateIssuesContext = createContext<ReadonlyMap<string, DateIssueKind>>(
|
|
34
|
+
new Map(),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export interface DateIssuesProviderProps {
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const noSubscribe = () => () => undefined;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Computes the issues once per change and hands them to the fields.
|
|
45
|
+
*
|
|
46
|
+
* Reads the registry's LIVE values, the same way `EditsReporter` does: the
|
|
47
|
+
* revision is the signal and the values are the input. The mounted résumé would
|
|
48
|
+
* be the wrong source — a warning that stayed on a date the candidate had
|
|
49
|
+
* already corrected is worse than no warning at all.
|
|
50
|
+
*
|
|
51
|
+
* One computation per change rather than one per field: the check is cheap, but
|
|
52
|
+
* there is one of it and dozens of fields asking.
|
|
53
|
+
*/
|
|
54
|
+
export function DateIssuesProvider({ children }: DateIssuesProviderProps) {
|
|
55
|
+
const registry = useFieldRegistry();
|
|
56
|
+
const { base, edits } = useDocumentOverlay();
|
|
57
|
+
const revision = useSyncExternalStore(
|
|
58
|
+
registry?.revision.subscribe ?? noSubscribe,
|
|
59
|
+
() => registry?.revision.get() ?? 0,
|
|
60
|
+
() => 0,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const issues = useMemo(() => {
|
|
64
|
+
/* Read on the revision, which is the whole reason it is a dependency —
|
|
65
|
+
the values live in a ref and are mutated in place. */
|
|
66
|
+
void revision;
|
|
67
|
+
if (!registry || !base) return new Map<string, DateIssueKind>();
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* The order the document is DRAWN in, from the same `collectionOrder` the
|
|
71
|
+
* document lays itself out with — never the order the paths are numbered
|
|
72
|
+
* in. A path follows the job: a reordered résumé renders `experience.2`
|
|
73
|
+
* first and its fields keep saying `experience.2.*`, so the index says
|
|
74
|
+
* where an entry STARTED and the check is about where it is NOW. Deriving
|
|
75
|
+
* the order here from the same source is what stops the check and the page
|
|
76
|
+
* disagreeing about which entry is above which.
|
|
77
|
+
*/
|
|
78
|
+
const overlay = edits ?? [];
|
|
79
|
+
const additions = additionPaths(base, overlay);
|
|
80
|
+
const sections = DATED.map((section) =>
|
|
81
|
+
collectionOrder(base, overlay, section)
|
|
82
|
+
.map((slot) =>
|
|
83
|
+
'base' in slot ? `${section}.${slot.base}` : additions.get(slot.ref),
|
|
84
|
+
)
|
|
85
|
+
.filter((path): path is string => path !== undefined),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const values = registry.values.current;
|
|
89
|
+
return dateIssuesInDrawnOrder(sections, (path) => {
|
|
90
|
+
const value = values.get(path);
|
|
91
|
+
return typeof value === 'string' ? value : undefined;
|
|
92
|
+
});
|
|
93
|
+
}, [registry, revision, base, edits]);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<DateIssuesContext.Provider value={issues}>
|
|
97
|
+
{children}
|
|
98
|
+
</DateIssuesContext.Provider>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** What was noticed about this field's date, if anything. */
|
|
103
|
+
export function useDateIssue(path: string): DateIssueKind | undefined {
|
|
104
|
+
return useContext(DateIssuesContext).get(path);
|
|
105
|
+
}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
useSyncExternalStore,
|
|
10
|
+
type MutableRefObject,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import type { EditValue } from '@resumekit/schema';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The editor's own field model, keyed by the résumé's own paths.
|
|
17
|
+
*
|
|
18
|
+
* This is what replaced Craft.js (`retire-craftjs`, #69). Craft is a
|
|
19
|
+
* page-builder library and this is deliberately the opposite of one — the design
|
|
20
|
+
* that introduced it said its whole job was "to take what Craft.js gives (node
|
|
21
|
+
* tree, per-node props, selection state, serialization) and refuse what it also
|
|
22
|
+
* gives (drag, drop, layout manipulation, style props)". What was actually
|
|
23
|
+
* consumed was a ref connector, a selected flag, a prop writer, an enabled flag,
|
|
24
|
+
* and a walk of the node map to save. All of it is below, in one file.
|
|
25
|
+
*
|
|
26
|
+
* The tree went with it and nothing was lost: a template's structure is plain
|
|
27
|
+
* JSX and has never been addressable, so Craft was modelling a tree the product
|
|
28
|
+
* refuses to let anyone edit. And every use of a node id here immediately
|
|
29
|
+
* translated it back to a résumé path — `valuesFromNodes` looked for nodes
|
|
30
|
+
* carrying `path`; `LinkField` scanned for the node whose `path` it already
|
|
31
|
+
* knew. **The path was always the identity.** So the path is the key.
|
|
32
|
+
*
|
|
33
|
+
* Two consequences, both of which were bugs before:
|
|
34
|
+
*
|
|
35
|
+
* - A field's props are ordinary props again. Craft froze them at mount, which
|
|
36
|
+
* is why an address typed into a link's popover left the document pointing
|
|
37
|
+
* at the old URL, and why presentation had to travel by context.
|
|
38
|
+
* - There is nothing to configure into a page builder. `LOCKED_RULES` refused
|
|
39
|
+
* four movement predicates; a refusal is configuration, and configuration is
|
|
40
|
+
* one upgrade away from meaning something else. There is now no capability
|
|
41
|
+
* to refuse.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Selection, as the smallest external store that does the job.
|
|
46
|
+
*
|
|
47
|
+
* Deliberately not React state. In context, one selection change is a new
|
|
48
|
+
* context value and therefore a re-render of every field in the document —
|
|
49
|
+
* hundreds, on every click. With a store a field subscribes to the one question
|
|
50
|
+
* it cares about, `am I selected?`, and re-renders only when that answer
|
|
51
|
+
* changes. `useSyncExternalStore` is React's own way to do this and needs no
|
|
52
|
+
* library.
|
|
53
|
+
*/
|
|
54
|
+
export interface SelectionStore {
|
|
55
|
+
get: () => string | null;
|
|
56
|
+
set: (path: string | null) => void;
|
|
57
|
+
subscribe: (listener: () => void) => () => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* "Something changed", as a number.
|
|
62
|
+
*
|
|
63
|
+
* The values are a ref, so nothing re-renders when one is written — which is
|
|
64
|
+
* the point, and also means the things that watch the DOCUMENT rather than a
|
|
65
|
+
* field need a signal of their own. The overlay reporter and the paginator both
|
|
66
|
+
* subscribe here: one rebuilds the overlay, the other re-measures, and neither
|
|
67
|
+
* should run because a pointer crossed a field.
|
|
68
|
+
*
|
|
69
|
+
* A counter rather than the map itself, because the map is mutated in place —
|
|
70
|
+
* its identity never changes, so it cannot be a dependency.
|
|
71
|
+
*/
|
|
72
|
+
export interface RevisionStore {
|
|
73
|
+
get: () => number;
|
|
74
|
+
bump: () => void;
|
|
75
|
+
subscribe: (listener: () => void) => () => void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function createRevisionStore(): RevisionStore {
|
|
79
|
+
let revision = 0;
|
|
80
|
+
const listeners = new Set<() => void>();
|
|
81
|
+
return {
|
|
82
|
+
get: () => revision,
|
|
83
|
+
bump: () => {
|
|
84
|
+
revision += 1;
|
|
85
|
+
for (const listener of listeners) listener();
|
|
86
|
+
},
|
|
87
|
+
subscribe: (listener) => {
|
|
88
|
+
listeners.add(listener);
|
|
89
|
+
return () => {
|
|
90
|
+
listeners.delete(listener);
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function createSelectionStore(): SelectionStore {
|
|
97
|
+
let selected: string | null = null;
|
|
98
|
+
const listeners = new Set<() => void>();
|
|
99
|
+
return {
|
|
100
|
+
get: () => selected,
|
|
101
|
+
set: (path) => {
|
|
102
|
+
if (path === selected) return;
|
|
103
|
+
selected = path;
|
|
104
|
+
for (const listener of listeners) listener();
|
|
105
|
+
},
|
|
106
|
+
subscribe: (listener) => {
|
|
107
|
+
listeners.add(listener);
|
|
108
|
+
return () => {
|
|
109
|
+
listeners.delete(listener);
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** What every field needs, and what the save reads. */
|
|
116
|
+
export interface FieldRegistry {
|
|
117
|
+
/** Whether this document is being edited, or only displayed. */
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* The live values, by path. A REF rather than state: it is read when the
|
|
121
|
+
* document saves and written on every keystroke, and a re-render of every
|
|
122
|
+
* field per character is the cost this shape avoids.
|
|
123
|
+
*/
|
|
124
|
+
values: MutableRefObject<Map<string, EditValue>>;
|
|
125
|
+
/** Each mounted field's setter, keyed by path. Read through {@link write}. */
|
|
126
|
+
setters: MutableRefObject<Map<string, (next: EditValue) => void>>;
|
|
127
|
+
/**
|
|
128
|
+
* What a field holds because the TEMPLATE supplied it, by path.
|
|
129
|
+
*
|
|
130
|
+
* Only a field that HAS such a value registers one — today, a section
|
|
131
|
+
* heading, which prints "Experience" on a résumé nobody has renamed. The save
|
|
132
|
+
* hands this to `presentationEdits`, which refuses to record a value equal to
|
|
133
|
+
* its default, so opening a document does not look like nine edits and
|
|
134
|
+
* renaming a section back to its own name leaves no trace.
|
|
135
|
+
*/
|
|
136
|
+
defaults: MutableRefObject<Map<string, string>>;
|
|
137
|
+
selection: SelectionStore;
|
|
138
|
+
/** Bumped whenever any value changes — see {@link RevisionStore}. */
|
|
139
|
+
revision: RevisionStore;
|
|
140
|
+
/**
|
|
141
|
+
* Set a field's value from OUTSIDE it, by path.
|
|
142
|
+
*
|
|
143
|
+
* One caller: a link's popover, which edits a field the candidate is not
|
|
144
|
+
* typing into. It replaces `setProp(nodeId, …)`, and the difference is the
|
|
145
|
+
* whole point of this change — a path is something a component already knows,
|
|
146
|
+
* where a node id had to be found by scanning the tree for the node carrying
|
|
147
|
+
* the path it wanted.
|
|
148
|
+
*
|
|
149
|
+
* Writes through the field's own setter rather than into the map, so the
|
|
150
|
+
* field re-renders. A write to the map alone would save correctly and show
|
|
151
|
+
* nothing, which is the worse of the two failures.
|
|
152
|
+
*/
|
|
153
|
+
write: (path: string, next: EditValue) => void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const FieldRegistryContext = createContext<FieldRegistry | null>(null);
|
|
157
|
+
|
|
158
|
+
export interface FieldRegistryProviderProps {
|
|
159
|
+
/** `false` for the preview and the export renderer — see `TemplateDocument`. */
|
|
160
|
+
enabled?: boolean;
|
|
161
|
+
children: ReactNode;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function FieldRegistryProvider({
|
|
165
|
+
enabled = false,
|
|
166
|
+
children,
|
|
167
|
+
}: FieldRegistryProviderProps) {
|
|
168
|
+
const values = useRef(new Map<string, EditValue>());
|
|
169
|
+
const [selection] = useState(createSelectionStore);
|
|
170
|
+
const [revision] = useState(createRevisionStore);
|
|
171
|
+
/* Each mounted field's setter, so one field can be written by another. */
|
|
172
|
+
const setters = useRef(new Map<string, (next: EditValue) => void>());
|
|
173
|
+
const defaults = useRef(new Map<string, string>());
|
|
174
|
+
const write = useCallback((path: string, next: EditValue) => {
|
|
175
|
+
setters.current.get(path)?.(next);
|
|
176
|
+
}, []);
|
|
177
|
+
|
|
178
|
+
/* Stable, so a document being typed into never re-renders because its
|
|
179
|
+
registry object is new. `values` is a ref and the store a fixed reference;
|
|
180
|
+
only `enabled` can change it, and it does not change. */
|
|
181
|
+
const registry = useMemo<FieldRegistry>(
|
|
182
|
+
() => ({ enabled, values, setters, defaults, selection, revision, write }),
|
|
183
|
+
[enabled, selection, revision, write],
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<FieldRegistryContext.Provider value={registry}>
|
|
188
|
+
{children}
|
|
189
|
+
</FieldRegistryContext.Provider>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The registry, for what acts on the document as a whole — reading every value
|
|
195
|
+
* to save it, or clearing the selection before printing.
|
|
196
|
+
*
|
|
197
|
+
* `null` outside a provider, which is a document being READ: the saved-résumé
|
|
198
|
+
* view and the export renderer mount none, so every field renders as text and
|
|
199
|
+
* neither has to remember to turn anything off.
|
|
200
|
+
*/
|
|
201
|
+
export const useFieldRegistry = (): FieldRegistry | null =>
|
|
202
|
+
useContext(FieldRegistryContext);
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Everything one field needs.
|
|
206
|
+
*
|
|
207
|
+
* Generic over what the field HOLDS, because `EditValue` is a union — a line of
|
|
208
|
+
* text or a list of them — and a field is only ever one of the two. Without it
|
|
209
|
+
* every caller would narrow a union it already knew the answer to, at each of
|
|
210
|
+
* the four places it reads the value.
|
|
211
|
+
*/
|
|
212
|
+
export interface Field<T extends EditValue> {
|
|
213
|
+
/** The value now — local state, so a keystroke re-renders this field alone. */
|
|
214
|
+
value: T;
|
|
215
|
+
/** Whether this document can be edited at all. */
|
|
216
|
+
editing: boolean;
|
|
217
|
+
/** Whether THIS field is the one being edited. */
|
|
218
|
+
selected: boolean;
|
|
219
|
+
select: () => void;
|
|
220
|
+
set: (next: T) => void;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Register a field at `path`, and read its state back.
|
|
225
|
+
*
|
|
226
|
+
* `initial` seeds the value and is adopted when it changes UPSTREAM — a template
|
|
227
|
+
* switch, a reload, an entry inserted above this one. That is what ordinary
|
|
228
|
+
* props give and Craft's frozen node props did not.
|
|
229
|
+
*/
|
|
230
|
+
export function useField<T extends EditValue>(
|
|
231
|
+
path: string,
|
|
232
|
+
initial: T,
|
|
233
|
+
/**
|
|
234
|
+
* What this field holds when the candidate has written nothing — the
|
|
235
|
+
* template's own word, not a placeholder. See `FieldRegistry.defaults`.
|
|
236
|
+
*/
|
|
237
|
+
templateDefault?: string,
|
|
238
|
+
): Field<T> {
|
|
239
|
+
const registry = useFieldRegistry();
|
|
240
|
+
const [value, setValue] = useState<T>(initial);
|
|
241
|
+
|
|
242
|
+
/*
|
|
243
|
+
* Adopt an upstream change, and only an upstream change.
|
|
244
|
+
*
|
|
245
|
+
* `seen` is what makes it safe: a render carrying an `initial` we have not
|
|
246
|
+
* seen is the document moving underneath us and is adopted; a render that
|
|
247
|
+
* merely repeats what we already knew leaves the candidate's typing alone.
|
|
248
|
+
* The same guard `SpaceHandle` keeps, for the same reason — a value travels a
|
|
249
|
+
* long way round and comes back late.
|
|
250
|
+
*/
|
|
251
|
+
const seen = useRef(initial);
|
|
252
|
+
if (initial !== seen.current) {
|
|
253
|
+
seen.current = initial;
|
|
254
|
+
if (initial !== value) setValue(initial);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const map = registry?.values;
|
|
258
|
+
const revision = registry?.revision;
|
|
259
|
+
|
|
260
|
+
/* Published for as long as the field is mounted, and withdrawn with it, so a
|
|
261
|
+
default cannot outlive the template that supplied it. */
|
|
262
|
+
const defaults = registry?.defaults;
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (!defaults || templateDefault === undefined) return;
|
|
265
|
+
defaults.current.set(path, templateDefault);
|
|
266
|
+
return () => {
|
|
267
|
+
defaults.current.delete(path);
|
|
268
|
+
};
|
|
269
|
+
}, [defaults, path, templateDefault]);
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
if (!map) return;
|
|
272
|
+
map.current.set(path, value);
|
|
273
|
+
revision?.bump();
|
|
274
|
+
return () => {
|
|
275
|
+
map.current.delete(path);
|
|
276
|
+
/* A removed entry's fields must leave the overlay, so their going is a
|
|
277
|
+
change like any other. */
|
|
278
|
+
revision?.bump();
|
|
279
|
+
};
|
|
280
|
+
}, [map, revision, path, value]);
|
|
281
|
+
|
|
282
|
+
const selection = registry?.selection;
|
|
283
|
+
const subscribe = useCallback(
|
|
284
|
+
(listener: () => void) =>
|
|
285
|
+
selection?.subscribe(listener) ?? (() => undefined),
|
|
286
|
+
[selection],
|
|
287
|
+
);
|
|
288
|
+
const isSelected = useSyncExternalStore(
|
|
289
|
+
subscribe,
|
|
290
|
+
() => selection?.get() === path,
|
|
291
|
+
() => false,
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const set = useCallback(
|
|
295
|
+
(next: T) => {
|
|
296
|
+
setValue(next);
|
|
297
|
+
/* Written to the map synchronously as well as through state: the save
|
|
298
|
+
reads the map, and a save racing a render must not read the previous
|
|
299
|
+
character. */
|
|
300
|
+
map?.current.set(path, next);
|
|
301
|
+
revision?.bump();
|
|
302
|
+
},
|
|
303
|
+
[map, revision, path],
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const select = useCallback(() => selection?.set(path), [selection, path]);
|
|
307
|
+
|
|
308
|
+
/*
|
|
309
|
+
* Publish this field's setter so another component can write it by path — see
|
|
310
|
+
* `FieldRegistry.write`. Registered for as long as the field is mounted, and
|
|
311
|
+
* withdrawn with it, so a write to a field that has gone is a no-op rather
|
|
312
|
+
* than a state update on an unmounted component.
|
|
313
|
+
*/
|
|
314
|
+
const setters = registry?.setters;
|
|
315
|
+
useEffect(() => {
|
|
316
|
+
if (!setters) return;
|
|
317
|
+
setters.current.set(path, set as (next: EditValue) => void);
|
|
318
|
+
return () => {
|
|
319
|
+
setters.current.delete(path);
|
|
320
|
+
};
|
|
321
|
+
}, [setters, path, set]);
|
|
322
|
+
|
|
323
|
+
return {
|
|
324
|
+
value,
|
|
325
|
+
editing: registry?.enabled ?? false,
|
|
326
|
+
selected: Boolean(registry?.enabled) && isSelected,
|
|
327
|
+
select,
|
|
328
|
+
set,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* WATCH a field somebody else owns.
|
|
334
|
+
*
|
|
335
|
+
* `useField` REGISTERS a field: it holds the value in local state and publishes
|
|
336
|
+
* a setter. Calling it twice for one path is therefore two fields wearing one
|
|
337
|
+
* name — two pieces of state, one setter overwriting the other, and a write
|
|
338
|
+
* that updates a copy nobody renders. That is a real bug this hook exists to
|
|
339
|
+
* make unavailable: a link's popover edits the text its own document renders,
|
|
340
|
+
* so it must not be a second owner of it.
|
|
341
|
+
*
|
|
342
|
+
* So: read through the registry's map, re-render on the revision, and write
|
|
343
|
+
* through {@link FieldRegistry.write}, which reaches the field that does own it.
|
|
344
|
+
*/
|
|
345
|
+
export function useFieldValue(path: string): EditValue | undefined {
|
|
346
|
+
const registry = useFieldRegistry();
|
|
347
|
+
const revision = registry?.revision;
|
|
348
|
+
const subscribe = useCallback(
|
|
349
|
+
(listener: () => void) =>
|
|
350
|
+
revision?.subscribe(listener) ?? (() => undefined),
|
|
351
|
+
[revision],
|
|
352
|
+
);
|
|
353
|
+
return useSyncExternalStore(
|
|
354
|
+
subscribe,
|
|
355
|
+
() => registry?.values.current.get(path),
|
|
356
|
+
() => undefined,
|
|
357
|
+
);
|
|
358
|
+
}
|