@resumekit/react 0.0.0-stage → 0.2.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 +186 -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 +20 -0
- package/dist/kit/documentStyle.d.ts.map +1 -0
- package/dist/kit/documentStyle.js +64 -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/kit/typography.css +86 -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 +38 -0
- package/dist/nodes/formatting.d.ts.map +1 -0
- package/dist/nodes/formatting.js +27 -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 +68 -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 +33930 -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 +80 -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 +70 -0
- package/src/nodes/locked.ts +70 -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 +259 -0
- package/src/templates/academic/entries.tsx +176 -0
- package/src/templates/alta/AltaDocument.tsx +269 -0
- package/src/templates/alta/entries.tsx +167 -0
- package/src/templates/classic/ClassicDocument.tsx +252 -0
- package/src/templates/classic/entries.tsx +175 -0
- package/src/templates/cobalt/CobaltDocument.tsx +306 -0
- package/src/templates/cobalt/crest.tsx +31 -0
- package/src/templates/cobalt/entries.tsx +136 -0
- package/src/templates/compact/CompactDocument.tsx +260 -0
- package/src/templates/compact/entries.tsx +167 -0
- package/src/templates/contemporary/ContemporaryDocument.tsx +291 -0
- package/src/templates/contemporary/entries.tsx +167 -0
- package/src/templates/creative/CreativeDocument.tsx +273 -0
- package/src/templates/creative/entries.tsx +167 -0
- package/src/templates/crimson/CrimsonDocument.tsx +287 -0
- package/src/templates/crimson/entries.tsx +169 -0
- package/src/templates/curve/CurveDocument.tsx +263 -0
- package/src/templates/curve/entries.tsx +168 -0
- package/src/templates/double-column/DoubleColumnDocument.tsx +273 -0
- package/src/templates/double-column/entries.tsx +169 -0
- package/src/templates/double-column-logos/DoubleColumnLogosDocument.tsx +266 -0
- package/src/templates/double-column-logos/entries.tsx +172 -0
- package/src/templates/elegant/ElegantDocument.tsx +301 -0
- package/src/templates/elegant/entries.tsx +167 -0
- package/src/templates/elegant-logos/ElegantLogosDocument.tsx +295 -0
- package/src/templates/elegant-logos/entries.tsx +170 -0
- package/src/templates/engineer/EngineerDocument.tsx +252 -0
- package/src/templates/engineer/entries.tsx +170 -0
- package/src/templates/executive/ExecutiveDocument.tsx +316 -0
- package/src/templates/executive/entries.tsx +146 -0
- package/src/templates/harvard/HarvardDocument.tsx +252 -0
- package/src/templates/harvard/entries.tsx +205 -0
- package/src/templates/hipster/HipsterDocument.tsx +293 -0
- package/src/templates/hipster/entries.tsx +175 -0
- package/src/templates/ivy/IvyDocument.tsx +252 -0
- package/src/templates/ivy/entries.tsx +167 -0
- package/src/templates/meridian/MeridianDocument.tsx +308 -0
- package/src/templates/meridian/entries.tsx +140 -0
- package/src/templates/modern/ModernDocument.tsx +269 -0
- package/src/templates/modern/entries.tsx +167 -0
- package/src/templates/polished/PolishedDocument.tsx +266 -0
- package/src/templates/polished/entries.tsx +167 -0
- package/src/templates/portrait/PortraitDocument.tsx +282 -0
- package/src/templates/portrait/entries.tsx +173 -0
- package/src/templates/prism/PrismDocument.tsx +311 -0
- package/src/templates/prism/entries.tsx +175 -0
- package/src/templates/scholar/ScholarDocument.tsx +270 -0
- package/src/templates/scholar/entries.tsx +169 -0
- package/src/templates/skills.ts +21 -0
- package/src/templates/split/SplitDocument.tsx +297 -0
- package/src/templates/split/entries.tsx +164 -0
- package/src/templates/stylish/StylishDocument.tsx +269 -0
- package/src/templates/stylish/entries.tsx +167 -0
- package/src/templates/timeline/TimelineDocument.tsx +255 -0
- package/src/templates/timeline/entries.tsx +173 -0
- package/src/useFitZoom.ts +185 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a template's editable fields may and may not carry.
|
|
3
|
+
*
|
|
4
|
+
* This file used to open with `LOCKED_RULES` — four movement predicates every
|
|
5
|
+
* node answered `false`, because Craft.js is a page-builder library and this is
|
|
6
|
+
* deliberately the opposite of one. `retire-craftjs` removed the library, and
|
|
7
|
+
* with it the capability those predicates existed to refuse. The file's own
|
|
8
|
+
* argument is why they went rather than being kept for safety: "rules are
|
|
9
|
+
* configuration, and configuration is one API change away from meaning
|
|
10
|
+
* something else". A capability that does not exist cannot be re-enabled by
|
|
11
|
+
* accident, and `nodes.spec.tsx` now asserts the absence directly.
|
|
12
|
+
*
|
|
13
|
+
* What remains is the rule that was never about Craft at all.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Prop names a template node may never accept.
|
|
18
|
+
*
|
|
19
|
+
* The rule is **no arbitrary presentation**, not "no presentation". A node may
|
|
20
|
+
* take a bounded formatting value from the catalog — a boolean emphasis, a named
|
|
21
|
+
* `align`, a named `ink` — because those can only express what the domain has
|
|
22
|
+
* vetted, and what they MEAN is still decided by the template's stylesheet.
|
|
23
|
+
* What it may never take is a value through which a caller could express
|
|
24
|
+
* anything at all: a style object, a class name, a raw colour, a dimension.
|
|
25
|
+
*
|
|
26
|
+
* That is the distinction that was actually load-bearing in #29, and the one
|
|
27
|
+
* `resume-document-formatting` (#30) preserves while making formatting possible.
|
|
28
|
+
*
|
|
29
|
+
* Enforced by test rather than by types alone, because a component's prop
|
|
30
|
+
* surface is easy to widen and hard to notice widening.
|
|
31
|
+
*/
|
|
32
|
+
export const FORBIDDEN_NODE_PROPS: readonly string[] = [
|
|
33
|
+
'style',
|
|
34
|
+
'className',
|
|
35
|
+
'class',
|
|
36
|
+
'background',
|
|
37
|
+
'font',
|
|
38
|
+
'fontFamily',
|
|
39
|
+
'fontSize',
|
|
40
|
+
'size',
|
|
41
|
+
'width',
|
|
42
|
+
'height',
|
|
43
|
+
'margin',
|
|
44
|
+
'padding',
|
|
45
|
+
'layout',
|
|
46
|
+
'variant',
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Formatting props a node MAY accept, each paired with the catalog type its
|
|
51
|
+
* values must come from. Asserted by test, so adding a free-string formatting
|
|
52
|
+
* prop fails the suite rather than quietly reopening the design surface.
|
|
53
|
+
*/
|
|
54
|
+
export const BOUNDED_NODE_PROPS: Readonly<Record<string, string>> = {
|
|
55
|
+
bold: 'boolean',
|
|
56
|
+
italic: 'boolean',
|
|
57
|
+
underline: 'boolean',
|
|
58
|
+
step: 'FieldStepId',
|
|
59
|
+
align: 'FieldAlign',
|
|
60
|
+
ink: 'InkId',
|
|
61
|
+
/*
|
|
62
|
+
* CONTENT, admitted under the same rule as the rest: a bounded value from the
|
|
63
|
+
* domain, never a free string. `LinkTargetSchema` parses the URL and accepts
|
|
64
|
+
* only `http`/`https`, so this cannot express "anything at all" — which is
|
|
65
|
+
* what `FORBIDDEN_NODE_PROPS` exists to keep out. A URL is not a style, a
|
|
66
|
+
* class, a colour or a dimension; it is a fact about where a word points, of
|
|
67
|
+
* the same kind as the `links` array the résumé schema already carries.
|
|
68
|
+
*/
|
|
69
|
+
href: 'LinkTarget',
|
|
70
|
+
};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the pages break — as arithmetic, with no DOM in it.
|
|
3
|
+
*
|
|
4
|
+
* Separated from `PagedSheet` because the two halves fail for different reasons
|
|
5
|
+
* and are checked by different means. Reading the layout is a browser question
|
|
6
|
+
* that jsdom cannot answer (every measurement there is zero). Deciding where a
|
|
7
|
+
* sheet ends is a model, and a model can be handed measurements and held to its
|
|
8
|
+
* answer — which is what `pagination.spec.ts` does, and what no test could do
|
|
9
|
+
* while this lived inside a `useCallback` closed over a ref.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Letter at 96dpi, and the document's own vertical margin, both in CSS pixels. */
|
|
13
|
+
export const PAGE_HEIGHT = 11 * 96;
|
|
14
|
+
/** Letter's other dimension, which is what a view zoom has to fit into. */
|
|
15
|
+
export const PAGE_WIDTH = 8.5 * 96;
|
|
16
|
+
export const PAGE_MARGIN = 0.5 * 96;
|
|
17
|
+
/**
|
|
18
|
+
* The gap drawn between sheets on screen. Presentation only — never printed.
|
|
19
|
+
*
|
|
20
|
+
* It is the DEFAULT rather than the law, because the export renders the same
|
|
21
|
+
* document onto real paper, where sheets are contiguous. That is the single
|
|
22
|
+
* parameter separating the two renderings: pass `0` and the pitch becomes the
|
|
23
|
+
* page height, so sheet `k` starts exactly where printed page `k` starts.
|
|
24
|
+
*/
|
|
25
|
+
export const SHEET_GAP = 28;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* One block as the browser reported it, tagged with the column it flows down.
|
|
29
|
+
*
|
|
30
|
+
* `flow` is opaque here on purpose: the model only ever compares flows for
|
|
31
|
+
* identity, so it does not need to know they are elements, and a test can label
|
|
32
|
+
* them `'main'` and `'aside'`.
|
|
33
|
+
*/
|
|
34
|
+
export interface MeasuredBlock<TFlow> {
|
|
35
|
+
flow: TFlow;
|
|
36
|
+
/** Natural position in flow coordinates, before any push. */
|
|
37
|
+
top: number;
|
|
38
|
+
height: number;
|
|
39
|
+
/** A heading, which must not be the last thing on a sheet. */
|
|
40
|
+
keepWithNext: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Space the candidate recorded above this block. Absent means none.
|
|
43
|
+
*
|
|
44
|
+
* When the block is moved to a new sheet it keeps only the part of this
|
|
45
|
+
* space that was NOT needed to move it there. The space that fitted on the
|
|
46
|
+
* sheet it came from is spent. So a block starts its new sheet on the first
|
|
47
|
+
* line, and each further step moves it down from there.
|
|
48
|
+
*
|
|
49
|
+
* Without it a moved block was placed with its top edge on the sheet's first
|
|
50
|
+
* line, whatever gap it carried: the push is measured from the block's
|
|
51
|
+
* natural position, which already includes that gap, so every extra step of
|
|
52
|
+
* space shortened the push by exactly as much. The spacer's number rose and
|
|
53
|
+
* nothing on the page moved.
|
|
54
|
+
*
|
|
55
|
+
* Only the RECORDED space. The template's own rhythm above a block is space
|
|
56
|
+
* between two things, and at the top of a sheet there is nothing above it.
|
|
57
|
+
*/
|
|
58
|
+
lead?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PaginationPlan {
|
|
62
|
+
/** Block index → how far down it must be pushed. Absent means "not pushed". */
|
|
63
|
+
pushes: Map<number, number>;
|
|
64
|
+
/** Block index → where a pushed block is SUPPOSED to start. */
|
|
65
|
+
targets: Map<number, number>;
|
|
66
|
+
/**
|
|
67
|
+
* Block index → the recorded space a pushed block keeps above it on its new
|
|
68
|
+
* sheet, after capping. Absent means none. Printing needs it on its own,
|
|
69
|
+
* because it places the block with a page break rather than by position.
|
|
70
|
+
*/
|
|
71
|
+
leads: Map<number, number>;
|
|
72
|
+
/** How many sheets the document occupies. Never below one. */
|
|
73
|
+
pages: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Sheet `k` occupies `[pitch*k, pitch*k + PAGE_HEIGHT)`, where the pitch is the
|
|
78
|
+
* page plus whatever gap is drawn between sheets.
|
|
79
|
+
*
|
|
80
|
+
* Derived per call rather than fixed at module scope: the editor draws a gap and
|
|
81
|
+
* the printed document does not, and those are the same document paginated with
|
|
82
|
+
* one number changed. Holding the screen's gap in a constant here is what would
|
|
83
|
+
* make the file and the screen break in different places.
|
|
84
|
+
*/
|
|
85
|
+
function geometry(gap: number) {
|
|
86
|
+
const pitch = PAGE_HEIGHT + gap;
|
|
87
|
+
return {
|
|
88
|
+
pitch,
|
|
89
|
+
textTop: (k: number) => pitch * k + PAGE_MARGIN,
|
|
90
|
+
textBottom: (k: number) => pitch * k + PAGE_HEIGHT - PAGE_MARGIN,
|
|
91
|
+
/** Independent of the gap: a sheet holds what a sheet holds. */
|
|
92
|
+
usable: PAGE_HEIGHT - PAGE_MARGIN * 2,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Plan the breaks: which blocks move down, how far, and how many sheets result.
|
|
98
|
+
*
|
|
99
|
+
* Every push is derived arithmetically from ONE reading of the natural layout,
|
|
100
|
+
* rather than by measuring, pushing, and measuring again — that costs a reflow
|
|
101
|
+
* per block on every keystroke. Pushing a block down by `p` shifts everything
|
|
102
|
+
* after it **in the same flow** by exactly `p`, so a running offset per flow is
|
|
103
|
+
* all the later blocks need.
|
|
104
|
+
*
|
|
105
|
+
* **Per flow**, and that is the load-bearing word. A template that sets regions
|
|
106
|
+
* side by side has more than one column, and a push in one of them does not move
|
|
107
|
+
* the other. Carrying a single running offset across both — which is what this
|
|
108
|
+
* did while every template was one column — would measure every block of the
|
|
109
|
+
* second column against a position it never occupied, and the sidebar would walk
|
|
110
|
+
* off the sheet on the first break.
|
|
111
|
+
*
|
|
112
|
+
* A document with no declared flow puts every block in the same one, so the maps
|
|
113
|
+
* below hold a single entry and the arithmetic is the single running offset it
|
|
114
|
+
* replaced. Single-column templates are not paginated by a new code path.
|
|
115
|
+
*/
|
|
116
|
+
export function planPagination<TFlow>(
|
|
117
|
+
blocks: readonly MeasuredBlock<TFlow>[],
|
|
118
|
+
sheetGap: number = SHEET_GAP,
|
|
119
|
+
): PaginationPlan {
|
|
120
|
+
const { pitch, textTop, textBottom, usable } = geometry(sheetGap);
|
|
121
|
+
const pushes = new Map<number, number>();
|
|
122
|
+
const targets = new Map<number, number>();
|
|
123
|
+
const leads = new Map<number, number>();
|
|
124
|
+
if (blocks.length === 0) return { pushes, targets, leads, pages: 1 };
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* The next block in the SAME flow, for `keepWithNext`.
|
|
128
|
+
*
|
|
129
|
+
* Resolved in one backward pass rather than by searching forward per block: a
|
|
130
|
+
* heading is kept with what follows it *in its own column*, and the block that
|
|
131
|
+
* happens to come next in the document can be the top of the other one.
|
|
132
|
+
*/
|
|
133
|
+
const nextInFlow = new Array<number>(blocks.length).fill(-1);
|
|
134
|
+
const lastSeen = new Map<TFlow, number>();
|
|
135
|
+
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
136
|
+
nextInFlow[i] = lastSeen.get(blocks[i].flow) ?? -1;
|
|
137
|
+
lastSeen.set(blocks[i].flow, i);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Per flow: how far its content has been pushed, and the sheet it is on. */
|
|
141
|
+
const shifts = new Map<TFlow, number>();
|
|
142
|
+
const sheets = new Map<TFlow, number>();
|
|
143
|
+
/** How far down the document reaches once every push is applied. */
|
|
144
|
+
let bottom = 0;
|
|
145
|
+
|
|
146
|
+
for (const [index, block] of blocks.entries()) {
|
|
147
|
+
const shift = shifts.get(block.flow) ?? 0;
|
|
148
|
+
let sheet = sheets.get(block.flow) ?? 0;
|
|
149
|
+
let top = block.top + shift;
|
|
150
|
+
|
|
151
|
+
// A block taller than a whole sheet cannot be rescued by pushing it; let it
|
|
152
|
+
// run, and count the sheets it spans.
|
|
153
|
+
if (block.height > usable) {
|
|
154
|
+
sheets.set(
|
|
155
|
+
block.flow,
|
|
156
|
+
Math.max(sheet, Math.floor((top + block.height) / pitch)),
|
|
157
|
+
);
|
|
158
|
+
bottom = Math.max(bottom, top + block.height);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/*
|
|
163
|
+
* A section heading must not be the last thing on a sheet. It is measured
|
|
164
|
+
* together with whatever follows it — the same intent as the stylesheet's
|
|
165
|
+
* `break-after: avoid`, which the printer applies to this very document.
|
|
166
|
+
*
|
|
167
|
+
* UNLESS what follows cannot fit on a sheet by itself. Holding a heading
|
|
168
|
+
* against a block that overflows wherever it starts buys nothing and costs a
|
|
169
|
+
* page: the heading is pushed to a fresh sheet, the block still overruns,
|
|
170
|
+
* and the sheet the heading came from is left empty. That is exactly how a
|
|
171
|
+
* 56-item keyword rail emptied its own first page — the list is one block,
|
|
172
|
+
* taller than the paper, so its heading was moved every single time.
|
|
173
|
+
*/
|
|
174
|
+
const next = nextInFlow[index];
|
|
175
|
+
const nextHeight = next === -1 ? 0 : blocks[next].height;
|
|
176
|
+
const withNext =
|
|
177
|
+
block.keepWithNext && nextHeight <= usable ? nextHeight : 0;
|
|
178
|
+
|
|
179
|
+
if (top + block.height + withNext > textBottom(sheet)) {
|
|
180
|
+
sheet += 1;
|
|
181
|
+
/*
|
|
182
|
+
* How much of the recorded space carries over to the new sheet.
|
|
183
|
+
*
|
|
184
|
+
* `room` is the space the block could have had and still stayed on the
|
|
185
|
+
* sheet it came from. That much is spent there, so only the remainder
|
|
186
|
+
* goes above the block on its new sheet. A block that crosses because of
|
|
187
|
+
* its space therefore lands on the first line and moves down one step at
|
|
188
|
+
* a time from there, rather than arriving with the whole gap again.
|
|
189
|
+
*
|
|
190
|
+
* A block that would not have fitted even with no space spent none of
|
|
191
|
+
* it, so it keeps all of it.
|
|
192
|
+
*
|
|
193
|
+
* Capped so the block, and whatever it is kept with, still fits on its
|
|
194
|
+
* new sheet. A gap taller than that would only push it off again.
|
|
195
|
+
*/
|
|
196
|
+
const recorded = Math.max(0, block.lead ?? 0);
|
|
197
|
+
const room = Math.max(
|
|
198
|
+
0,
|
|
199
|
+
textBottom(sheet - 1) - (top - recorded) - block.height - withNext,
|
|
200
|
+
);
|
|
201
|
+
const lead = Math.min(
|
|
202
|
+
Math.max(0, recorded - room),
|
|
203
|
+
Math.max(0, usable - block.height - withNext),
|
|
204
|
+
);
|
|
205
|
+
const target = textTop(sheet) + lead;
|
|
206
|
+
const push = target - top;
|
|
207
|
+
pushes.set(index, push);
|
|
208
|
+
targets.set(index, target);
|
|
209
|
+
if (lead > 0) leads.set(index, lead);
|
|
210
|
+
shifts.set(block.flow, shift + push);
|
|
211
|
+
sheets.set(block.flow, sheet);
|
|
212
|
+
top = target;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Accumulated as the loop goes, with the offset that was in force for THIS
|
|
216
|
+
// block — a flow's final offset belongs to its last block, not to every
|
|
217
|
+
// block that preceded the pushes making it up.
|
|
218
|
+
bottom = Math.max(bottom, top + block.height);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/*
|
|
222
|
+
* The deepest sheet ANY flow reaches decides the count.
|
|
223
|
+
*
|
|
224
|
+
* Per flow rather than "the last block in the document", because the last
|
|
225
|
+
* block of a two-column page is the foot of the sidebar, which is routinely
|
|
226
|
+
* the shorter column — trusting it would drop the sheet the main column is
|
|
227
|
+
* still running onto.
|
|
228
|
+
*/
|
|
229
|
+
let deepest = 0;
|
|
230
|
+
for (const sheet of sheets.values()) deepest = Math.max(deepest, sheet);
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
pushes,
|
|
234
|
+
targets,
|
|
235
|
+
leads,
|
|
236
|
+
pages: Math.max(deepest + 1, Math.ceil(bottom / pitch) || 1),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A document drawn as a picture of itself: links are text, headings are not
|
|
5
|
+
* part of the host page's outline, and nothing an editor reads is emitted.
|
|
6
|
+
* For previews embedded in another page, never for the document itself.
|
|
7
|
+
*/
|
|
8
|
+
const PictureContext = createContext(false);
|
|
9
|
+
|
|
10
|
+
export function PictureProvider({ children }: { children: ReactNode }) {
|
|
11
|
+
return (
|
|
12
|
+
<PictureContext.Provider value={true}>{children}</PictureContext.Provider>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function usePicture(): boolean {
|
|
17
|
+
return useContext(PictureContext);
|
|
18
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
formatFor,
|
|
5
|
+
type DocumentStyle,
|
|
6
|
+
type FieldFormat,
|
|
7
|
+
type ResumeFormats,
|
|
8
|
+
} from '@resumekit/schema';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How the document is presented, delivered by context rather than by props.
|
|
12
|
+
*
|
|
13
|
+
* This is not a style preference — it is the only thing that works. `<Frame>`
|
|
14
|
+
* children are Craft.js's INITIAL node tree: props are read off that JSX once,
|
|
15
|
+
* when the nodes are created, and thereafter live in Craft's own store. Passing
|
|
16
|
+
* `style` and `formats` down through `<Element>` therefore froze them at mount,
|
|
17
|
+
* and every formatting change stayed invisible until something forced a remount.
|
|
18
|
+
*
|
|
19
|
+
* Context sidesteps the node store entirely: a change re-renders the components
|
|
20
|
+
* that read it, immediately, without touching Craft's state at all. Which is
|
|
21
|
+
* also the correct model — formatting is presentation OVER the document, not
|
|
22
|
+
* part of it. The document is the text, and only the text is Craft's to hold.
|
|
23
|
+
*/
|
|
24
|
+
export interface DocumentPresentation {
|
|
25
|
+
style?: DocumentStyle;
|
|
26
|
+
formats?: ResumeFormats;
|
|
27
|
+
/** The document's language, which its printed words follow. Absent is English. */
|
|
28
|
+
language?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const PresentationContext = createContext<DocumentPresentation>({});
|
|
32
|
+
|
|
33
|
+
export function DocumentPresentationProvider({
|
|
34
|
+
style,
|
|
35
|
+
formats,
|
|
36
|
+
language,
|
|
37
|
+
children,
|
|
38
|
+
}: DocumentPresentation & { children: ReactNode }) {
|
|
39
|
+
// Keyed on the values themselves, so a parent re-render that changed neither
|
|
40
|
+
// does not cascade a new context object through the whole document.
|
|
41
|
+
const value = useMemo(
|
|
42
|
+
() => ({ style, formats, language }),
|
|
43
|
+
[style, formats, language],
|
|
44
|
+
);
|
|
45
|
+
return (
|
|
46
|
+
<PresentationContext.Provider value={value}>
|
|
47
|
+
{children}
|
|
48
|
+
</PresentationContext.Provider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The document's style, or undefined for the template's own typography. */
|
|
53
|
+
export function useDocumentStyle(): DocumentStyle | undefined {
|
|
54
|
+
return useContext(PresentationContext).style;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Every field's formatting, for the one reader that needs the whole list.
|
|
59
|
+
*
|
|
60
|
+
* `useFieldFormat` answers for a path and is what a node should ask; this is
|
|
61
|
+
* for `useSpace`, which reaches the same record for a different question and
|
|
62
|
+
* would otherwise need a second copy of the formats threaded to it.
|
|
63
|
+
*/
|
|
64
|
+
export function useDocumentLanguage(): string | undefined {
|
|
65
|
+
return useContext(PresentationContext).language;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function useDocumentFormats(): ResumeFormats | undefined {
|
|
69
|
+
return useContext(PresentationContext).formats;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The formatting for one field, as bounded values a node may accept.
|
|
74
|
+
*
|
|
75
|
+
* Returns the format WITHOUT its path: a node already knows which field it is,
|
|
76
|
+
* and passing the path back in would invite a node to read a different field's
|
|
77
|
+
* formatting than its own.
|
|
78
|
+
*/
|
|
79
|
+
export function useFieldFormat(path: string): Omit<FieldFormat, 'path'> {
|
|
80
|
+
const { formats } = useContext(PresentationContext);
|
|
81
|
+
return useMemo(() => {
|
|
82
|
+
const found = formatFor(formats, path);
|
|
83
|
+
if (!found) return {};
|
|
84
|
+
const { path: _unused, ...rest } = found;
|
|
85
|
+
return rest;
|
|
86
|
+
}, [formats, path]);
|
|
87
|
+
}
|
package/src/presented.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyPresentation,
|
|
3
|
+
type ResumeEdits,
|
|
4
|
+
type ResumeObject,
|
|
5
|
+
} from '@resumekit/schema';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The resume as it should be drawn: the writer's output with the candidate's
|
|
9
|
+
* corrections applied.
|
|
10
|
+
*
|
|
11
|
+
* Lives with the DOCUMENT rather than with the editor, because it answers "what
|
|
12
|
+
* is on the page" — the question every surface that draws a résumé has to
|
|
13
|
+
* answer, including the server-side renderer that never loads an editor.
|
|
14
|
+
*
|
|
15
|
+
* Falls back to the writer's own resume if the overlay cannot be applied. An
|
|
16
|
+
* overlay is data at rest that can outlive the schema it was written against,
|
|
17
|
+
* and a resume that will not open is a worse failure than an edit that does not
|
|
18
|
+
* show — so the document always renders.
|
|
19
|
+
*/
|
|
20
|
+
export function presentedResume(
|
|
21
|
+
base: ResumeObject,
|
|
22
|
+
edits: ResumeEdits,
|
|
23
|
+
): ResumeObject {
|
|
24
|
+
try {
|
|
25
|
+
return applyPresentation(base, edits);
|
|
26
|
+
} catch {
|
|
27
|
+
return base;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useCallback, useState, type ReactNode } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import type { SpaceTarget } from '../spacing/spacing-context.js';
|
|
4
|
+
import { useRailLevel } from './rail-store.js';
|
|
5
|
+
import { useSpaceDrag } from './useSpaceDrag.js';
|
|
6
|
+
import './rail.css';
|
|
7
|
+
import { useEditorText } from '../i18n/index.js';
|
|
8
|
+
|
|
9
|
+
/** Up-and-down through a bar: the space above can be opened or closed. */
|
|
10
|
+
const SpaceIcon = () => (
|
|
11
|
+
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
12
|
+
<path d="M8 1.75v4M5.75 3.75 8 1.5l2.25 2.25M8 14.25v-4M5.75 12.25 8 14.5l2.25-2.25M3 8h10" />
|
|
13
|
+
</svg>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The space control: a slider in the rail, and — while it is pointed at or
|
|
18
|
+
* dragged — the gap it acts on, tinted, with its value. The gap is drawn in
|
|
19
|
+
* the CONTAINER (portalled), because that is where the space is; the rail is
|
|
20
|
+
* only where the hand is.
|
|
21
|
+
*/
|
|
22
|
+
function SpaceControl({
|
|
23
|
+
target,
|
|
24
|
+
label,
|
|
25
|
+
railKey,
|
|
26
|
+
host,
|
|
27
|
+
}: {
|
|
28
|
+
target: SpaceTarget;
|
|
29
|
+
label: string;
|
|
30
|
+
railKey: string;
|
|
31
|
+
host: HTMLElement | null;
|
|
32
|
+
}) {
|
|
33
|
+
const { adjustable, shown, dragging, sliderProps } = useSpaceDrag(
|
|
34
|
+
target,
|
|
35
|
+
label,
|
|
36
|
+
railKey,
|
|
37
|
+
);
|
|
38
|
+
const [looking, setLooking] = useState(false);
|
|
39
|
+
const { t, locale } = useEditorText();
|
|
40
|
+
if (!adjustable) return null;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<span
|
|
45
|
+
className="tpl-rail__btn tpl-rail__space"
|
|
46
|
+
data-dragging={dragging ? '' : undefined}
|
|
47
|
+
onPointerEnter={() => setLooking(true)}
|
|
48
|
+
onPointerLeave={() => setLooking(false)}
|
|
49
|
+
onFocus={() => setLooking(true)}
|
|
50
|
+
onBlur={() => setLooking(false)}
|
|
51
|
+
{...sliderProps}
|
|
52
|
+
>
|
|
53
|
+
<SpaceIcon />
|
|
54
|
+
</span>
|
|
55
|
+
{host &&
|
|
56
|
+
(looking || dragging) &&
|
|
57
|
+
createPortal(
|
|
58
|
+
<span
|
|
59
|
+
className="tpl-rail-gap"
|
|
60
|
+
data-chrome
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
data-open={shown > 0 ? '' : undefined}
|
|
63
|
+
/* An attribute the stylesheet draws, never a text node: a word in
|
|
64
|
+
here would be a word in the résumé's own text. */
|
|
65
|
+
data-readout={
|
|
66
|
+
shown > 0
|
|
67
|
+
? `+${shown.toLocaleString(locale, {
|
|
68
|
+
minimumFractionDigits: 1,
|
|
69
|
+
maximumFractionDigits: 1,
|
|
70
|
+
})}`
|
|
71
|
+
: t.space.dragToAdd
|
|
72
|
+
}
|
|
73
|
+
/>,
|
|
74
|
+
host,
|
|
75
|
+
)}
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ContainerRailProps {
|
|
81
|
+
/** The container's `data-rail-key`. */
|
|
82
|
+
railKey: string;
|
|
83
|
+
/** Names the toolbar for assistive technology. */
|
|
84
|
+
toolbarLabel: string;
|
|
85
|
+
/** Selected containers keep a solid rail wherever the pointer is. */
|
|
86
|
+
selected?: boolean;
|
|
87
|
+
/** The gap above this container, when it can be adjusted. */
|
|
88
|
+
space?: { target: SpaceTarget; label: string } | null;
|
|
89
|
+
/** The container's own actions, below the space control. */
|
|
90
|
+
children?: ReactNode;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* One container's controls, as a single vertical pill beside the sheet,
|
|
95
|
+
* centred on the container.
|
|
96
|
+
*
|
|
97
|
+
* It exists only while the container is pointed at, focused, selected or being
|
|
98
|
+
* adjusted — a document at rest carries no control at all — and it is faint
|
|
99
|
+
* until the candidate commits to the container by selecting, focusing or
|
|
100
|
+
* reaching for it. Chrome: absolutely positioned, never printed, and moving
|
|
101
|
+
* nothing in the document by appearing.
|
|
102
|
+
*/
|
|
103
|
+
export function ContainerRail({
|
|
104
|
+
railKey,
|
|
105
|
+
toolbarLabel,
|
|
106
|
+
selected = false,
|
|
107
|
+
space,
|
|
108
|
+
children,
|
|
109
|
+
}: ContainerRailProps) {
|
|
110
|
+
const level = useRailLevel(railKey);
|
|
111
|
+
const [host, setHost] = useState<HTMLElement | null>(null);
|
|
112
|
+
/* Stable, or every render would detach and re-attach it — two state updates
|
|
113
|
+
per render, and a loop. */
|
|
114
|
+
const attach = useCallback(
|
|
115
|
+
(node: HTMLSpanElement | null) => setHost(node?.parentElement ?? null),
|
|
116
|
+
[],
|
|
117
|
+
);
|
|
118
|
+
if (level === 0 && !selected) return null;
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<span
|
|
122
|
+
ref={attach}
|
|
123
|
+
className="tpl-rail"
|
|
124
|
+
data-chrome
|
|
125
|
+
contentEditable={false}
|
|
126
|
+
role="toolbar"
|
|
127
|
+
aria-orientation="vertical"
|
|
128
|
+
aria-label={toolbarLabel}
|
|
129
|
+
data-strong={level === 2 || selected ? '' : undefined}
|
|
130
|
+
>
|
|
131
|
+
{space && (
|
|
132
|
+
<SpaceControl
|
|
133
|
+
target={space.target}
|
|
134
|
+
label={space.label}
|
|
135
|
+
railKey={railKey}
|
|
136
|
+
host={host}
|
|
137
|
+
/>
|
|
138
|
+
)}
|
|
139
|
+
{space && children && (
|
|
140
|
+
<span className="tpl-rail__divider" aria-hidden="true" />
|
|
141
|
+
)}
|
|
142
|
+
{children}
|
|
143
|
+
</span>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowDownIcon,
|
|
3
|
+
ArrowUpIcon,
|
|
4
|
+
GripIcon,
|
|
5
|
+
PlusIcon,
|
|
6
|
+
TrashIcon,
|
|
7
|
+
} from '../collections/icons.js';
|
|
8
|
+
import type { CollectionHandle } from '../collections/useCollection.js';
|
|
9
|
+
import type { ItemOrigin } from '../collections/EntryOverlay.js';
|
|
10
|
+
import { useEntryText } from '../collections/entry-text.js';
|
|
11
|
+
import { LibraryAction } from '../collections/library/LibraryAction.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* An entry's own actions in its rail — the same operations, names and rules as
|
|
15
|
+
* the compact toolbar, laid out vertically. Every one is a button in the tab
|
|
16
|
+
* order; the reorder grip is the one drag, and "move up/down" is the same
|
|
17
|
+
* operation for anyone not dragging.
|
|
18
|
+
*/
|
|
19
|
+
export function EntryActions<T>({
|
|
20
|
+
collection,
|
|
21
|
+
index,
|
|
22
|
+
noun,
|
|
23
|
+
path,
|
|
24
|
+
handleProps,
|
|
25
|
+
}: {
|
|
26
|
+
collection: CollectionHandle<T> & { originOf?: (i: number) => ItemOrigin };
|
|
27
|
+
index: number;
|
|
28
|
+
noun: string;
|
|
29
|
+
/** The entry's field path, for actions that write into it. */
|
|
30
|
+
path?: string;
|
|
31
|
+
handleProps?: Record<string, unknown>;
|
|
32
|
+
}) {
|
|
33
|
+
const origin = collection.originOf?.(index) ?? 'added';
|
|
34
|
+
const refusal = collection.removeReason(index);
|
|
35
|
+
const last = collection.items.length - 1;
|
|
36
|
+
const text = useEntryText(noun, index, origin);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
{handleProps && (
|
|
41
|
+
<span
|
|
42
|
+
className="tpl-rail__btn tpl-rail__grip"
|
|
43
|
+
title={text.drag}
|
|
44
|
+
{...handleProps}
|
|
45
|
+
>
|
|
46
|
+
<GripIcon />
|
|
47
|
+
</span>
|
|
48
|
+
)}
|
|
49
|
+
{collection.canMove && (
|
|
50
|
+
<>
|
|
51
|
+
<button
|
|
52
|
+
type="button"
|
|
53
|
+
className="tpl-rail__btn"
|
|
54
|
+
title={text.moveUp}
|
|
55
|
+
aria-label={text.moveUpLabel}
|
|
56
|
+
disabled={index === 0}
|
|
57
|
+
onClick={() => collection.move(index, index - 1)}
|
|
58
|
+
>
|
|
59
|
+
<ArrowUpIcon />
|
|
60
|
+
</button>
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
className="tpl-rail__btn"
|
|
64
|
+
title={text.moveDown}
|
|
65
|
+
aria-label={text.moveDownLabel}
|
|
66
|
+
disabled={index === last}
|
|
67
|
+
onClick={() => collection.move(index, index + 1)}
|
|
68
|
+
>
|
|
69
|
+
<ArrowDownIcon />
|
|
70
|
+
</button>
|
|
71
|
+
</>
|
|
72
|
+
)}
|
|
73
|
+
{collection.canAdd && (
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
className="tpl-rail__btn"
|
|
77
|
+
title={text.addBelow}
|
|
78
|
+
aria-label={text.addAfterLabel}
|
|
79
|
+
onClick={() => collection.add(index)}
|
|
80
|
+
>
|
|
81
|
+
<PlusIcon />
|
|
82
|
+
</button>
|
|
83
|
+
)}
|
|
84
|
+
<LibraryAction
|
|
85
|
+
collection={collection}
|
|
86
|
+
index={index}
|
|
87
|
+
path={path}
|
|
88
|
+
noun={noun}
|
|
89
|
+
className="tpl-rail__btn"
|
|
90
|
+
/>
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
className="tpl-rail__btn"
|
|
94
|
+
data-tone="danger"
|
|
95
|
+
disabled={refusal !== undefined}
|
|
96
|
+
title={refusal ?? text.remove}
|
|
97
|
+
aria-label={text.removeLabel}
|
|
98
|
+
onClick={() => collection.remove(index)}
|
|
99
|
+
>
|
|
100
|
+
<TrashIcon />
|
|
101
|
+
</button>
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
}
|