@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,261 @@
|
|
|
1
|
+
import { isSafeLinkTarget } from '@resumekit/schema';
|
|
2
|
+
import { useField } from '../fields/field-registry.js';
|
|
3
|
+
import { formatClass, formatInk, inkAttr } from './formatting.js';
|
|
4
|
+
import { useFieldFormat } from '../presentation-context.js';
|
|
5
|
+
import { PlainTextField } from './PlainTextField.js';
|
|
6
|
+
import { useAutosave } from '../autosave-context.js';
|
|
7
|
+
import { useDateIssue } from '../fields/date-issues-context.js';
|
|
8
|
+
import { useEditorText } from '../i18n/index.js';
|
|
9
|
+
import { usePicture } from '../picture-context.js';
|
|
10
|
+
import type { TextShape } from '../kit/textShapes.js';
|
|
11
|
+
|
|
12
|
+
export interface EditableTextProps {
|
|
13
|
+
/** Where this text lives in the `ResumeObject` — e.g. `experience.0.title`. */
|
|
14
|
+
path: string;
|
|
15
|
+
value: string;
|
|
16
|
+
/** Shown when the writer had nothing for this field. Never saved. */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the text wraps. A content property, not a style one: the summary is
|
|
20
|
+
* a paragraph and a job title is a line, and that is true in every template.
|
|
21
|
+
*/
|
|
22
|
+
multiline?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Where this text points, supplied by the DOCUMENT rather than by the
|
|
25
|
+
* candidate's formatting.
|
|
26
|
+
*
|
|
27
|
+
* The résumé already carries `links[]` — a label and a URL — and the templates
|
|
28
|
+
* rendered the label as dead text, so "GitHub" reached an employer as a word
|
|
29
|
+
* they had to retype. This is that URL, and it is now the only way a link is
|
|
30
|
+
* MADE: the rail's per-field `href` control is gone, because a link is content
|
|
31
|
+
* and two homes for one fact is what the ranking below exists to paper over.
|
|
32
|
+
* A stored `format.href` is still read, for a document formatted while that
|
|
33
|
+
* control existed.
|
|
34
|
+
*/
|
|
35
|
+
href?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether this text is typed into HERE.
|
|
38
|
+
*
|
|
39
|
+
* `false` — the default — is every ordinary field: pressing it places a caret
|
|
40
|
+
* in it. `true` registers the field and draws its text exactly as before, and
|
|
41
|
+
* refuses the caret, because the value is set by a control of its own.
|
|
42
|
+
*
|
|
43
|
+
* One caller: a link. A link is a text and an address, and only one of the
|
|
44
|
+
* two is on the page — so typing into the visible half would let a candidate
|
|
45
|
+
* write a label with no way to see or reach what it points at. The document
|
|
46
|
+
* still needs the text to BE a field, though: it is what the save collects
|
|
47
|
+
* and what carries the anchor, and a span outside the registry is neither.
|
|
48
|
+
*
|
|
49
|
+
* So it is not "an input that is disabled". It is the document's own text,
|
|
50
|
+
* which happens to be edited somewhere else — and pressing it is how a
|
|
51
|
+
* candidate gets to that somewhere else, which is the wrapper's business and
|
|
52
|
+
* not this component's.
|
|
53
|
+
*/
|
|
54
|
+
readOnly?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* What this text says when the candidate has written nothing — the
|
|
57
|
+
* template's own word, not guidance.
|
|
58
|
+
*
|
|
59
|
+
* Distinct from `placeholder`, and the difference is the whole point: a
|
|
60
|
+
* placeholder is never stored, never exported and never extractable, while
|
|
61
|
+
* this PRINTS. A section heading is the case — "Experience" is on the page of
|
|
62
|
+
* a résumé nobody has renamed — and declaring it keeps merely opening the
|
|
63
|
+
* document from reading as an edit. See `FieldRegistry.defaults`.
|
|
64
|
+
*/
|
|
65
|
+
defaultValue?: string;
|
|
66
|
+
/**
|
|
67
|
+
* How the printed text is divided into spans a stylesheet can set apart — a
|
|
68
|
+
* surname in bold, a heading's first letters in the accent (`kit/textShapes`).
|
|
69
|
+
*
|
|
70
|
+
* Applied wherever the text is drawn, so the editor and the page agree; not
|
|
71
|
+
* while the field is being typed into, where it is one plain run in the
|
|
72
|
+
* field's own style. The characters never change.
|
|
73
|
+
*/
|
|
74
|
+
shape?: TextShape;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* One editable string in a template.
|
|
79
|
+
*
|
|
80
|
+
* Unselected it is ordinary document text — semantic, selectable, copyable, and
|
|
81
|
+
* exactly what prints. Selected it becomes a borderless field **in the same
|
|
82
|
+
* box**: `font`, `line-height`, `padding` and `border` are all inherited or
|
|
83
|
+
* zeroed, so nothing on the page moves when the candidate clicks into it.
|
|
84
|
+
*
|
|
85
|
+
* The wrapping variant grows with its content through the grid + `::after`
|
|
86
|
+
* mirror in `template-node.css` rather than through measured `scrollHeight`,
|
|
87
|
+
* which means the field cannot be one pixel off from the text it replaced.
|
|
88
|
+
*/
|
|
89
|
+
export function EditableText({
|
|
90
|
+
path,
|
|
91
|
+
value: given,
|
|
92
|
+
placeholder,
|
|
93
|
+
multiline,
|
|
94
|
+
href,
|
|
95
|
+
readOnly = false,
|
|
96
|
+
defaultValue,
|
|
97
|
+
shape,
|
|
98
|
+
}: EditableTextProps) {
|
|
99
|
+
// Read live, so a formatting change shows the instant it is made — a field's
|
|
100
|
+
// value is the text, and only the text.
|
|
101
|
+
const format = useFieldFormat(path);
|
|
102
|
+
const picture = usePicture();
|
|
103
|
+
/*
|
|
104
|
+
* The field, by its path in the résumé.
|
|
105
|
+
*
|
|
106
|
+
* `editing` decides what a click on a link means. In the editor a click must
|
|
107
|
+
* select the field — following the link would navigate away from the document
|
|
108
|
+
* the candidate is working on. In a read-only preview there is nothing to
|
|
109
|
+
* select, so the link behaves like a link. The anchor is in the DOM either
|
|
110
|
+
* way, which is what matters for the export: printing emits a Link annotation
|
|
111
|
+
* from the markup, not from the click handler.
|
|
112
|
+
*/
|
|
113
|
+
const { value, editing, selected, select, set } = useField(
|
|
114
|
+
path,
|
|
115
|
+
given,
|
|
116
|
+
defaultValue,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
/*
|
|
120
|
+
* Typing, so the DEFERRED request: this fires per character, and a field that
|
|
121
|
+
* stored itself on every keystroke would send one write per letter of a job
|
|
122
|
+
* title. `saveSoon` coalesces the burst into the one write the candidate
|
|
123
|
+
* actually meant — the sentence they finished.
|
|
124
|
+
*/
|
|
125
|
+
const { saveSoon } = useAutosave();
|
|
126
|
+
|
|
127
|
+
/*
|
|
128
|
+
* Whether this field's date disagrees with the résumé's chronological order.
|
|
129
|
+
*
|
|
130
|
+
* Asked BY PATH, which is the address the field already knows itself by — so
|
|
131
|
+
* no template passes anything, and a template added later is covered without
|
|
132
|
+
* being told. Undefined everywhere the provider is not mounted, which is the
|
|
133
|
+
* read-only preview and the export renderer: the marker is editor chrome and
|
|
134
|
+
* must never print.
|
|
135
|
+
*/
|
|
136
|
+
const dateIssue = useDateIssue(path);
|
|
137
|
+
const { t } = useEditorText();
|
|
138
|
+
const dateWarning = dateIssue ? t.dateIssues[dateIssue] : undefined;
|
|
139
|
+
|
|
140
|
+
const change = (next: string) => {
|
|
141
|
+
// A line stays a line. Pasting three lines of a signature block into a job
|
|
142
|
+
// title should give a job title, not a résumé with a hole in it.
|
|
143
|
+
set(multiline ? next : next.replace(/\s*\n\s*/g, ' '));
|
|
144
|
+
saveSoon();
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
* A press selects the field. Craft's `connect` used to attach this; without
|
|
149
|
+
* it the element is ordinary markup and has to say so itself.
|
|
150
|
+
*
|
|
151
|
+
* `mousedown` rather than `click`, and NOT prevented: the browser places the
|
|
152
|
+
* caret where the candidate pressed, and this puts the field in the state
|
|
153
|
+
* where that caret is inside a real editable box.
|
|
154
|
+
*/
|
|
155
|
+
const onMouseDown = editing && !readOnly ? () => select() : undefined;
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
* A read-only field never enters the typing state, even if something else
|
|
159
|
+
* selected it. Checked here rather than trusted to the handler above: the
|
|
160
|
+
* selection is document-wide and settable by any caller, and "this text is
|
|
161
|
+
* not typed into" is a property of the field rather than of one press.
|
|
162
|
+
*/
|
|
163
|
+
if (!selected || readOnly) {
|
|
164
|
+
/*
|
|
165
|
+
* The value, and ONLY the value.
|
|
166
|
+
*
|
|
167
|
+
* The placeholder used to stand in here when the field was empty, and it
|
|
168
|
+
* was a real text node — so "Degree", "Field of study" and "YYYY-MM" were
|
|
169
|
+
* painted into the exported PDF and extracted by anything reading it. A
|
|
170
|
+
* résumé that tells a screening system the candidate's degree is "Degree"
|
|
171
|
+
* is worse than one that omits the line.
|
|
172
|
+
*
|
|
173
|
+
* It is drawn by CSS now instead: guidance for a candidate looking at an
|
|
174
|
+
* editor, switched off for the read-only document and for paper, and never
|
|
175
|
+
* part of the text at all.
|
|
176
|
+
*/
|
|
177
|
+
const text = shape && value.length > 0 ? shape(value) : value;
|
|
178
|
+
/*
|
|
179
|
+
* The résumé's own link wins over a candidate-applied one: a `links[]` entry
|
|
180
|
+
* IS the address for that field, and a format that disagreed with it would
|
|
181
|
+
* be two answers to one question.
|
|
182
|
+
*/
|
|
183
|
+
const raw = href ?? format?.href;
|
|
184
|
+
const target = raw && isSafeLinkTarget(raw) ? raw : undefined;
|
|
185
|
+
return (
|
|
186
|
+
<span
|
|
187
|
+
onMouseDown={onMouseDown}
|
|
188
|
+
className={formatClass(format, 'tpl-text')}
|
|
189
|
+
style={formatInk(format)}
|
|
190
|
+
data-ink={inkAttr(format)}
|
|
191
|
+
data-empty={value.length === 0 || undefined}
|
|
192
|
+
data-placeholder={picture ? undefined : placeholder}
|
|
193
|
+
data-path={picture ? undefined : path}
|
|
194
|
+
/*
|
|
195
|
+
* What was noticed about this date, as an attribute the stylesheet
|
|
196
|
+
* draws and a reader can hear. Never a text node: a message painted
|
|
197
|
+
* into the document would print into the PDF and be read by a parser as
|
|
198
|
+
* the candidate's own words — the mistake `data-placeholder` exists to
|
|
199
|
+
* avoid, made a second time.
|
|
200
|
+
*/
|
|
201
|
+
data-issue={dateIssue}
|
|
202
|
+
title={dateWarning}
|
|
203
|
+
aria-description={dateWarning}
|
|
204
|
+
>
|
|
205
|
+
{/*
|
|
206
|
+
* An ANCHOR when the field points somewhere.
|
|
207
|
+
*
|
|
208
|
+
* Rendered in the unselected state, which is the state that prints —
|
|
209
|
+
* the editor clears selection before `beforeprint` precisely so the
|
|
210
|
+
* document on paper is plain semantic markup. That is what makes the
|
|
211
|
+
* link followable in the exported PDF: browsers emit a Link annotation
|
|
212
|
+
* for an `<a href>` when printing, so the export path needs no PDF
|
|
213
|
+
* library and no second rendering.
|
|
214
|
+
*
|
|
215
|
+
* `rel` is set because the exported document is opened in readers this
|
|
216
|
+
* product does not control. The target is validated in `@resumekit/schema`, so
|
|
217
|
+
* a `javascript:` URL never reaches this element.
|
|
218
|
+
*/}
|
|
219
|
+
{target && picture ? (
|
|
220
|
+
<span className="tpl-text__link">{text}</span>
|
|
221
|
+
) : target ? (
|
|
222
|
+
<a
|
|
223
|
+
className="tpl-text__link"
|
|
224
|
+
href={target}
|
|
225
|
+
rel="noopener noreferrer"
|
|
226
|
+
onClick={(e) => {
|
|
227
|
+
if (editing) e.preventDefault();
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
{text}
|
|
231
|
+
</a>
|
|
232
|
+
) : (
|
|
233
|
+
text
|
|
234
|
+
)}
|
|
235
|
+
</span>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<span
|
|
241
|
+
onMouseDown={onMouseDown}
|
|
242
|
+
/*
|
|
243
|
+
* A plain inline box, and nothing more. The field inside it flows and
|
|
244
|
+
* wraps on its own now, so there is no mirror to measure it and no grid
|
|
245
|
+
* to hold the two of them in the same cell.
|
|
246
|
+
*/
|
|
247
|
+
className={formatClass(format, 'tpl-text')}
|
|
248
|
+
style={formatInk(format)}
|
|
249
|
+
data-ink={inkAttr(format)}
|
|
250
|
+
data-path={path}
|
|
251
|
+
>
|
|
252
|
+
<PlainTextField
|
|
253
|
+
value={value}
|
|
254
|
+
placeholder={placeholder}
|
|
255
|
+
multiline={multiline}
|
|
256
|
+
label={path}
|
|
257
|
+
onChange={change}
|
|
258
|
+
/>
|
|
259
|
+
</span>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import type { Link } from '@resumekit/schema';
|
|
4
|
+
import { useEditorText } from '../i18n/index.js';
|
|
5
|
+
import { useAutosave } from '../autosave-context.js';
|
|
6
|
+
import { useFieldRegistry, useFieldValue } from '../fields/field-registry.js';
|
|
7
|
+
import { EditableText } from './EditableText.js';
|
|
8
|
+
import './link-field.css';
|
|
9
|
+
|
|
10
|
+
export interface LinkFieldProps {
|
|
11
|
+
/** The entry this field renders — its text and its address. */
|
|
12
|
+
item: Link;
|
|
13
|
+
/** Where the entry lives, e.g. `links.0`. Its fields hang off this. */
|
|
14
|
+
path: string;
|
|
15
|
+
/**
|
|
16
|
+
* What the field says while the link is blank.
|
|
17
|
+
*
|
|
18
|
+
* Defaulted from the domain's own guidance rather than required of each
|
|
19
|
+
* template, because a template that passed none rendered an empty inline
|
|
20
|
+
* span: no text, no width, and nothing on the page to say a link belonged
|
|
21
|
+
* there. Three of the four did exactly that.
|
|
22
|
+
*/
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the candidate has just added this link, in this session.
|
|
26
|
+
*
|
|
27
|
+
* The only thing that opens the panel on its own. It used to open for any
|
|
28
|
+
* link with no text and no address — a property of the CONTENTS rather than
|
|
29
|
+
* an act — on the reasoning that only `collection.add()` produces a blank
|
|
30
|
+
* pair. That reasoning held for one press and not for a document: a résumé
|
|
31
|
+
* that had somehow acquired a hundred blank links drew a hundred panels
|
|
32
|
+
* stacked over the page, one per link, every time it was rendered.
|
|
33
|
+
*
|
|
34
|
+
* The act is what the popover actually wants, and the collection is the only
|
|
35
|
+
* thing that knows it — see `SectionCollectionHandle.justAdded`.
|
|
36
|
+
*/
|
|
37
|
+
justAdded?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Both halves of a link, while they are being typed and before they are set. */
|
|
41
|
+
interface LinkDraft {
|
|
42
|
+
label: string;
|
|
43
|
+
url: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* One of a résumé's links, in every template.
|
|
48
|
+
*
|
|
49
|
+
* The four templates each had their own answer and three of them amounted to
|
|
50
|
+
* none: Harvard rendered a `Collection` of `label ?? url` inline in the contact
|
|
51
|
+
* line, while Cobalt, Executive and Meridian rendered a bare `.map` of the URL
|
|
52
|
+
* as the visible text behind `{links.length > 0 && …}` — no collection, so a
|
|
53
|
+
* résumé whose writer produced no links had nothing to press, and one moved
|
|
54
|
+
* between templates lost its labels.
|
|
55
|
+
*
|
|
56
|
+
* What is shared is what a link IS: the text the document shows and the address
|
|
57
|
+
* behind it. Where it SITS is still the template's decision — this renders the
|
|
58
|
+
* field and nothing around it, so Harvard keeps its contact line and the others
|
|
59
|
+
* keep their websites list.
|
|
60
|
+
*
|
|
61
|
+
* ## The field on the page is a way IN, not a place to type
|
|
62
|
+
*
|
|
63
|
+
* A link is one thing with two parts, and only one of them is on the page. So
|
|
64
|
+
* the visible text is a **read-only** field: it registers at `links.N.label`,
|
|
65
|
+
* draws that text in the document's own typography, and shows the collection's
|
|
66
|
+
* guidance while it is blank — an ordinary-looking field the candidate can see
|
|
67
|
+
* belongs there — but it refuses the caret. Pressing it opens the popover, and
|
|
68
|
+
* the popover is where both halves are typed.
|
|
69
|
+
*
|
|
70
|
+
* The alternative was tried and is what this replaced. With the text editable
|
|
71
|
+
* in place, one press did two things: `EditableText`'s own `mousedown` selected
|
|
72
|
+
* the field and turned it into a `contenteditable`, and this component's opened
|
|
73
|
+
* a popover over it. Two live editors for one value, fighting over the
|
|
74
|
+
* keyboard, and a candidate could still type a label with no way to see what it
|
|
75
|
+
* pointed at.
|
|
76
|
+
*
|
|
77
|
+
* ## Typed into a draft, set by Ok
|
|
78
|
+
*
|
|
79
|
+
* The popover's inputs hold a DRAFT — a copy of both halves — and nothing
|
|
80
|
+
* reaches the document until Ok. That is what makes an address a decision
|
|
81
|
+
* rather than a side effect of typing: a half-written `https://li` is not a
|
|
82
|
+
* link, and every keystroke of it used to land in the résumé and, at the end of
|
|
83
|
+
* the debounce, in storage. Escape and a press outside discard the draft, so
|
|
84
|
+
* backing out of a link leaves the document exactly as it was.
|
|
85
|
+
*
|
|
86
|
+
* Ok writes both fields through the registry, by path — see
|
|
87
|
+
* `FieldRegistry.write`. That is the only route that survives: the save rebuilds
|
|
88
|
+
* the overlay from the fields that carry a path, so a value written any other
|
|
89
|
+
* way would show on screen and be dropped by the next save. Two fields cannot
|
|
90
|
+
* share one path either, so each half has exactly one field and the popover
|
|
91
|
+
* writes to them rather than being a second owner of either.
|
|
92
|
+
*
|
|
93
|
+
* ## Adding and removing belong to the COLLECTION, not here
|
|
94
|
+
*
|
|
95
|
+
* This renders one link. It does not render a control to make another, and it
|
|
96
|
+
* did: a `+` sat past the end of every link, on the reasoning that a collection
|
|
97
|
+
* inside a line has nowhere else to put one. That reasoning was true only
|
|
98
|
+
* because a link could not be selected — the press was swallowed before it
|
|
99
|
+
* reached the item root, so the entry toolbar every other collection uses for
|
|
100
|
+
* add, remove and reorder never appeared on a link. With the press let through,
|
|
101
|
+
* links get the same controls as a role or a qualification, and a second, link-
|
|
102
|
+
* shaped way to add is one the candidate has to learn separately.
|
|
103
|
+
*
|
|
104
|
+
* ## The chrome costs the document nothing
|
|
105
|
+
*
|
|
106
|
+
* The trigger and the popover are `position: absolute`,
|
|
107
|
+
* `contentEditable={false}`, `data-chrome`, and hidden in print — the contract
|
|
108
|
+
* `SpaceHandle` and `EntryOverlay` already meet. The address field is mounted
|
|
109
|
+
* whether or not the popover is open, because a field outside the tree is not
|
|
110
|
+
* collected when the document saves; it is the store, and the popover is the
|
|
111
|
+
* control.
|
|
112
|
+
*
|
|
113
|
+
* The wrapper renders in BOTH states. An element the editor adds and the preview
|
|
114
|
+
* does not is an element the two documents differ by — `position: relative` with
|
|
115
|
+
* no offsets moves nothing, the same argument `[data-gap]` already makes.
|
|
116
|
+
*/
|
|
117
|
+
export function LinkField({
|
|
118
|
+
item,
|
|
119
|
+
path,
|
|
120
|
+
placeholder: givenPlaceholder,
|
|
121
|
+
justAdded = false,
|
|
122
|
+
}: LinkFieldProps) {
|
|
123
|
+
const { t, format } = useEditorText();
|
|
124
|
+
const placeholder = givenPlaceholder ?? t.placeholders.label;
|
|
125
|
+
const labelPath = `${path}.label`;
|
|
126
|
+
const urlPath = `${path}.url`;
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Both halves of the link, read from the fields that hold them.
|
|
130
|
+
*
|
|
131
|
+
* `useFieldValue` on a path this component does not RENDER is how it reads
|
|
132
|
+
* the address: the address's own field is mounted below, hidden, and this is
|
|
133
|
+
* the same value. It replaces a scan of Craft's node map for the node
|
|
134
|
+
* carrying this path — the indirection `retire-craftjs` removed, since the
|
|
135
|
+
* path was always the identity.
|
|
136
|
+
*/
|
|
137
|
+
const registry = useFieldRegistry();
|
|
138
|
+
const label = String(
|
|
139
|
+
useFieldValue(labelPath) ?? item.label ?? item.url ?? '',
|
|
140
|
+
);
|
|
141
|
+
const address = String(useFieldValue(urlPath) ?? item.url ?? '');
|
|
142
|
+
const editing = registry?.enabled ?? false;
|
|
143
|
+
|
|
144
|
+
/* What the document shows: the text, falling back to the address so a link
|
|
145
|
+
with no label reads as something rather than as a gap. */
|
|
146
|
+
const shown = label || address;
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
* Setting a link is a discrete act with nothing still coming after it, so
|
|
150
|
+
* `saveNow` rather than the deferred request typing makes. The draft below is
|
|
151
|
+
* why: the popover writes once, on Ok, and not once per character.
|
|
152
|
+
*/
|
|
153
|
+
const { saveNow } = useAutosave();
|
|
154
|
+
|
|
155
|
+
/*
|
|
156
|
+
* The draft IS the open state: a popover is open exactly while there is
|
|
157
|
+
* something being typed in it. Two flags for one fact is how they come apart.
|
|
158
|
+
*
|
|
159
|
+
* A link the candidate JUST ADDED opens straight away, because the address
|
|
160
|
+
* has nowhere else to be typed. Only that — never "this link is blank". The
|
|
161
|
+
* blank test reads as equivalent and is not: it is true of every empty link
|
|
162
|
+
* in the document at every render, so a résumé carrying a few of them opened
|
|
163
|
+
* a panel for each, stacked over the page.
|
|
164
|
+
*/
|
|
165
|
+
const [draft, setDraft] = useState<LinkDraft | null>(() =>
|
|
166
|
+
editing && justAdded ? { label: '', url: '' } : null,
|
|
167
|
+
);
|
|
168
|
+
const open = draft !== null;
|
|
169
|
+
|
|
170
|
+
const root = useRef<HTMLSpanElement>(null);
|
|
171
|
+
const pop = useRef<HTMLFormElement>(null);
|
|
172
|
+
const firstInput = useRef<HTMLInputElement>(null);
|
|
173
|
+
const [at, setAt] = useState<{ top: number; left: number } | null>(null);
|
|
174
|
+
|
|
175
|
+
const openWith = () => setDraft({ label, url: address });
|
|
176
|
+
const discard = () => setDraft(null);
|
|
177
|
+
|
|
178
|
+
/*
|
|
179
|
+
* Ok, which is the only thing that writes.
|
|
180
|
+
*
|
|
181
|
+
* Trimmed, because an address is pasted far more often than it is typed and a
|
|
182
|
+
* leading space is enough to make `isSafeLinkTarget` refuse a perfectly good
|
|
183
|
+
* URL — a link that silently stops being followable in the export.
|
|
184
|
+
*/
|
|
185
|
+
const set = () => {
|
|
186
|
+
if (!draft) return;
|
|
187
|
+
registry?.write(labelPath, draft.label.trim());
|
|
188
|
+
registry?.write(urlPath, draft.url.trim());
|
|
189
|
+
setDraft(null);
|
|
190
|
+
saveNow();
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/* Nothing to set while both halves are blank, and a button that does nothing
|
|
194
|
+
should say so rather than pretend. */
|
|
195
|
+
const settable = Boolean(draft && (draft.label.trim() || draft.url.trim()));
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
* Close on an outside press or Escape. Written here rather than imported
|
|
199
|
+
* from a UI library the document would otherwise not need: ten lines is the
|
|
200
|
+
* cheaper of the two prices.
|
|
201
|
+
*/
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (!open) return;
|
|
204
|
+
const onDown = (e: MouseEvent) => {
|
|
205
|
+
/* The panel is portalled out of the link, so "outside" is outside BOTH. */
|
|
206
|
+
const target = e.target as Node;
|
|
207
|
+
if (root.current?.contains(target) || pop.current?.contains(target)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
setDraft(null);
|
|
211
|
+
};
|
|
212
|
+
const onKey = (e: KeyboardEvent) => {
|
|
213
|
+
if (e.key === 'Escape') setDraft(null);
|
|
214
|
+
};
|
|
215
|
+
document.addEventListener('mousedown', onDown);
|
|
216
|
+
document.addEventListener('keydown', onKey);
|
|
217
|
+
return () => {
|
|
218
|
+
document.removeEventListener('mousedown', onDown);
|
|
219
|
+
document.removeEventListener('keydown', onKey);
|
|
220
|
+
};
|
|
221
|
+
}, [open]);
|
|
222
|
+
|
|
223
|
+
/*
|
|
224
|
+
* The text, in flow, in the document's own typography — and read-only, so the
|
|
225
|
+
* press that opens the popover cannot also put a caret in it. See the note on
|
|
226
|
+
* `EditableText`'s `readOnly`.
|
|
227
|
+
*
|
|
228
|
+
* `undefined` rather than `''` for the address — `href ?? format?.href` falls
|
|
229
|
+
* back only on nullish, so an empty string used to SHADOW an address set
|
|
230
|
+
* elsewhere and the link printed dead.
|
|
231
|
+
*/
|
|
232
|
+
const text = (
|
|
233
|
+
<EditableText
|
|
234
|
+
path={labelPath}
|
|
235
|
+
value={item.label ?? item.url ?? ''}
|
|
236
|
+
placeholder={placeholder}
|
|
237
|
+
href={address || undefined}
|
|
238
|
+
readOnly={editing}
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
/*
|
|
243
|
+
* The whole link opens the popover, and the handler is on the WRAPPER rather
|
|
244
|
+
* than on an element drawn over the text.
|
|
245
|
+
*
|
|
246
|
+
* The overlay this replaces was `position: absolute; inset: 0` inside an
|
|
247
|
+
* inline `<span>`. That asks the browser to resolve a containing block from
|
|
248
|
+
* the bounding box of an inline's fragments, which is exactly the kind of
|
|
249
|
+
* geometry jsdom cannot model — so the suite proved the handler ran while
|
|
250
|
+
* saying nothing about whether a pointer could ever reach it. A handler is
|
|
251
|
+
* not an element: it has no box to get wrong, and it costs the document
|
|
252
|
+
* nothing, which is the same guarantee by a shorter route.
|
|
253
|
+
*
|
|
254
|
+
* `mousedown` is where the caret is refused, not `click`. By click time the
|
|
255
|
+
* browser has already placed one in the text, so it has to be cancelled
|
|
256
|
+
* before the selection it would make.
|
|
257
|
+
*
|
|
258
|
+
* The press is NOT stopped from bubbling, and that is the fix for a control
|
|
259
|
+
* nobody could reach. An item's root carries `onClick: select(id)` — it is
|
|
260
|
+
* how every collection reveals the entry's own toolbar, and the toolbar is
|
|
261
|
+
* where remove and reorder live. Swallowing the press here meant a link was
|
|
262
|
+
* the one entry in the document that could never be selected, so a link the
|
|
263
|
+
* candidate did not want could not be got rid of. Selecting the entry and
|
|
264
|
+
* opening the panel are not rivals: the panel edits the link, the toolbar
|
|
265
|
+
* acts on the entry, which is the same division `AuthoredItem` already
|
|
266
|
+
* describes for a job title.
|
|
267
|
+
*/
|
|
268
|
+
const refuseCaret = (e: { preventDefault: () => void }) => e.preventDefault();
|
|
269
|
+
|
|
270
|
+
/*
|
|
271
|
+
* Where the popover is drawn, measured when it opens.
|
|
272
|
+
*
|
|
273
|
+
* It is rendered into `document.body` through a portal and positioned
|
|
274
|
+
* `fixed`, and both halves of that are load-bearing.
|
|
275
|
+
*
|
|
276
|
+
* `position: absolute` inside `.tpl-link` is what it did before, and that
|
|
277
|
+
* asked the browser to resolve a containing block from the bounding box of an
|
|
278
|
+
* INLINE span's fragments — the same fragile geometry that made the old
|
|
279
|
+
* overlay trigger unreachable. A popover positioned against a degenerate box
|
|
280
|
+
* lands somewhere nobody can see, which looks exactly like a popover that
|
|
281
|
+
* never opened.
|
|
282
|
+
*
|
|
283
|
+
* And an ancestor clips it. `paged.css` masks `.tpl-pages__flow` on a
|
|
284
|
+
* multi-page document to hide the gutter between sheets, and a mask clips
|
|
285
|
+
* everything inside it: a panel hanging below a link would be cut off at the
|
|
286
|
+
* page edge, or vanish entirely in the gap between two.
|
|
287
|
+
*
|
|
288
|
+
* A portal has neither problem — nothing above it in the DOM can clip it, and
|
|
289
|
+
* nothing about an inline box decides where it goes. The React tree is
|
|
290
|
+
* unchanged by a portal, so the address's field stays registered and the
|
|
291
|
+
* document still saves it.
|
|
292
|
+
*/
|
|
293
|
+
useLayoutEffect(() => {
|
|
294
|
+
if (!open) {
|
|
295
|
+
setAt(null);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const box = root.current?.getBoundingClientRect();
|
|
299
|
+
if (box) setAt({ top: box.bottom + 4, left: box.left });
|
|
300
|
+
}, [open]);
|
|
301
|
+
|
|
302
|
+
/*
|
|
303
|
+
* The caret belongs in the panel that just appeared, not left behind in the
|
|
304
|
+
* document: the field on the page refuses it, so a press with no follow-up
|
|
305
|
+
* would leave the keyboard pointing at nothing.
|
|
306
|
+
*
|
|
307
|
+
* A second effect rather than a line in the one above, because the panel does
|
|
308
|
+
* not exist yet when that one runs — it renders on `draft && at`, and `at` is
|
|
309
|
+
* what that effect is measuring. Focusing there would reach for an input that
|
|
310
|
+
* mounts a render later, find `null`, and silently do nothing.
|
|
311
|
+
*/
|
|
312
|
+
useEffect(() => {
|
|
313
|
+
if (open && at) firstInput.current?.focus({ preventScroll: true });
|
|
314
|
+
}, [open, at]);
|
|
315
|
+
|
|
316
|
+
const stop = (e: { stopPropagation: () => void }) => e.stopPropagation();
|
|
317
|
+
|
|
318
|
+
return (
|
|
319
|
+
<span
|
|
320
|
+
className="tpl-link"
|
|
321
|
+
ref={root}
|
|
322
|
+
{...(editing
|
|
323
|
+
? {
|
|
324
|
+
onMouseDown: refuseCaret,
|
|
325
|
+
onClick: (e: { preventDefault: () => void }) => {
|
|
326
|
+
refuseCaret(e);
|
|
327
|
+
if (open) discard();
|
|
328
|
+
else openWith();
|
|
329
|
+
},
|
|
330
|
+
}
|
|
331
|
+
: {})}
|
|
332
|
+
>
|
|
333
|
+
{text}
|
|
334
|
+
{editing && (
|
|
335
|
+
<>
|
|
336
|
+
{/*
|
|
337
|
+
* The keyboard's way in, and the accessible name for what the pointer
|
|
338
|
+
* already does. Visually hidden rather than drawn: the affordance a
|
|
339
|
+
* mouse uses is the link itself, so a second visible control would be
|
|
340
|
+
* furniture — but a span with a click handler is reachable by nothing
|
|
341
|
+
* without this.
|
|
342
|
+
*/}
|
|
343
|
+
<button
|
|
344
|
+
type="button"
|
|
345
|
+
className="tpl-link__trigger"
|
|
346
|
+
data-chrome
|
|
347
|
+
contentEditable={false}
|
|
348
|
+
aria-haspopup="dialog"
|
|
349
|
+
aria-expanded={open}
|
|
350
|
+
aria-label={
|
|
351
|
+
shown ? format(t.link.edit, { name: shown }) : t.link.editThis
|
|
352
|
+
}
|
|
353
|
+
title={t.link.editThis}
|
|
354
|
+
onClick={(e) => {
|
|
355
|
+
e.stopPropagation();
|
|
356
|
+
if (open) discard();
|
|
357
|
+
else openWith();
|
|
358
|
+
}}
|
|
359
|
+
/>
|
|
360
|
+
|
|
361
|
+
{/*
|
|
362
|
+
* The address's field — the store the popover writes to, and the only
|
|
363
|
+
* reason the address survives a save.
|
|
364
|
+
*
|
|
365
|
+
* It stays HERE, in the document's own tree, rather than travelling
|
|
366
|
+
* to the portal with the panel: it is mounted whether or not the
|
|
367
|
+
* popover is open, because a field outside the React tree is not
|
|
368
|
+
* collected. Hidden, marked chrome, and taking no space.
|
|
369
|
+
*/}
|
|
370
|
+
<span className="tpl-link__store" data-chrome hidden>
|
|
371
|
+
<EditableText path={urlPath} value={item.url} readOnly />
|
|
372
|
+
</span>
|
|
373
|
+
|
|
374
|
+
{draft && at
|
|
375
|
+
? createPortal(
|
|
376
|
+
/*
|
|
377
|
+
* A FORM, so Enter sets the link the way it does in every other
|
|
378
|
+
* two-field panel, and Ok is the submit button rather than a
|
|
379
|
+
* button that happens to be pressed last. Portalled to the
|
|
380
|
+
* body, so it nests inside nothing.
|
|
381
|
+
*/
|
|
382
|
+
<form
|
|
383
|
+
className="tpl-link__pop"
|
|
384
|
+
ref={pop}
|
|
385
|
+
data-chrome
|
|
386
|
+
role="dialog"
|
|
387
|
+
aria-label={t.link.dialog}
|
|
388
|
+
style={{ top: at.top, left: at.left }}
|
|
389
|
+
onMouseDown={stop}
|
|
390
|
+
onClick={stop}
|
|
391
|
+
onSubmit={(e) => {
|
|
392
|
+
e.preventDefault();
|
|
393
|
+
set();
|
|
394
|
+
}}
|
|
395
|
+
>
|
|
396
|
+
<label className="tpl-link__row">
|
|
397
|
+
<span className="tpl-link__label">{t.link.text}</span>
|
|
398
|
+
<input
|
|
399
|
+
ref={firstInput}
|
|
400
|
+
className="tpl-link__input"
|
|
401
|
+
type="text"
|
|
402
|
+
value={draft.label}
|
|
403
|
+
placeholder={placeholder}
|
|
404
|
+
onChange={(e) =>
|
|
405
|
+
setDraft({ ...draft, label: e.target.value })
|
|
406
|
+
}
|
|
407
|
+
/>
|
|
408
|
+
</label>
|
|
409
|
+
<label className="tpl-link__row">
|
|
410
|
+
<span className="tpl-link__label">{t.link.url}</span>
|
|
411
|
+
<input
|
|
412
|
+
className="tpl-link__input"
|
|
413
|
+
type="url"
|
|
414
|
+
value={draft.url}
|
|
415
|
+
placeholder={t.placeholders.url}
|
|
416
|
+
onChange={(e) =>
|
|
417
|
+
setDraft({ ...draft, url: e.target.value })
|
|
418
|
+
}
|
|
419
|
+
/>
|
|
420
|
+
</label>
|
|
421
|
+
<div className="tpl-link__actions">
|
|
422
|
+
<button
|
|
423
|
+
type="submit"
|
|
424
|
+
className="tpl-link__ok"
|
|
425
|
+
disabled={!settable}
|
|
426
|
+
>
|
|
427
|
+
{t.link.ok}
|
|
428
|
+
</button>
|
|
429
|
+
</div>
|
|
430
|
+
</form>,
|
|
431
|
+
document.body,
|
|
432
|
+
)
|
|
433
|
+
: null}
|
|
434
|
+
</>
|
|
435
|
+
)}
|
|
436
|
+
</span>
|
|
437
|
+
);
|
|
438
|
+
}
|