@prismicio/vue 5.2.1 → 5.3.0-canary.5d9ea4c
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/README.md +3 -15
- package/dist/PrismicEmbed.vue.d.cts +25 -0
- package/dist/PrismicEmbed.vue.d.cts.map +1 -0
- package/dist/PrismicImage.vue.d.cts +301 -0
- package/dist/PrismicImage.vue.d.cts.map +1 -0
- package/dist/PrismicLink.vue.d.cts +282 -0
- package/dist/PrismicLink.vue.d.cts.map +1 -0
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts +102 -0
- package/dist/PrismicRichText/PrismicRichText.vue.d.cts.map +1 -0
- package/dist/PrismicRichText/getRichTextComponentProps.d.cts +54 -0
- package/dist/PrismicRichText/getRichTextComponentProps.d.cts.map +1 -0
- package/dist/PrismicRichText/types.d.cts +27 -0
- package/dist/PrismicRichText/types.d.cts.map +1 -0
- package/dist/PrismicTable/PrismicTable.vue.d.cts +38 -0
- package/dist/PrismicTable/PrismicTable.vue.d.cts.map +1 -0
- package/dist/PrismicTable/getTableComponentProps.d.cts +136 -0
- package/dist/PrismicTable/getTableComponentProps.d.cts.map +1 -0
- package/dist/PrismicTable/types.d.cts +35 -0
- package/dist/PrismicTable/types.d.cts.map +1 -0
- package/dist/PrismicText.vue.d.cts +37 -0
- package/dist/PrismicText.vue.d.cts.map +1 -0
- package/dist/SliceZone/SliceZone.vue.d.cts +48 -0
- package/dist/SliceZone/SliceZone.vue.d.cts.map +1 -0
- package/dist/SliceZone/TODOSliceComponent.d.cts +15 -0
- package/dist/SliceZone/TODOSliceComponent.d.cts.map +1 -0
- package/dist/SliceZone/defineSliceZoneComponents.d.cts +42 -0
- package/dist/SliceZone/defineSliceZoneComponents.d.cts.map +1 -0
- package/dist/SliceZone/getSliceComponentProps.d.cts +71 -0
- package/dist/SliceZone/getSliceComponentProps.d.cts.map +1 -0
- package/dist/SliceZone/types.d.cts +100 -0
- package/dist/SliceZone/types.d.cts.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +19 -0
- package/dist/_virtual/rolldown_runtime.js +18 -0
- package/dist/createPrismic.d.cts +29 -0
- package/dist/createPrismic.d.cts.map +1 -0
- package/dist/index.cjs +35 -32
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +21 -23
- package/dist/index.js +16 -32
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/src/PrismicEmbed.cjs +8 -0
- package/dist/src/PrismicEmbed.cjs.map +1 -0
- package/dist/src/PrismicEmbed.js +8 -0
- package/dist/src/PrismicEmbed.js.map +1 -0
- package/dist/src/PrismicEmbed.vue.d.ts +25 -0
- package/dist/src/PrismicEmbed.vue.d.ts.map +1 -0
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.cjs +42 -0
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/src/PrismicEmbed.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicImage.cjs +8 -0
- package/dist/src/PrismicImage.cjs.map +1 -0
- package/dist/src/PrismicImage.js +8 -0
- package/dist/src/PrismicImage.js.map +1 -0
- package/dist/src/PrismicImage.vue.d.ts +301 -0
- package/dist/src/PrismicImage.vue.d.ts.map +1 -0
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.cjs +117 -0
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.js +117 -0
- package/dist/src/PrismicImage.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicLink.cjs +8 -0
- package/dist/src/PrismicLink.cjs.map +1 -0
- package/dist/src/PrismicLink.js +8 -0
- package/dist/src/PrismicLink.js.map +1 -0
- package/dist/src/PrismicLink.vue.d.ts +282 -0
- package/dist/src/PrismicLink.vue.d.ts.map +1 -0
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs +86 -0
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.js +86 -0
- package/dist/src/PrismicLink.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.cjs +8 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.cjs.map +1 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.js +8 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.js.map +1 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.cjs +92 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/src/PrismicRichText/DeprecatedPrismicRichText.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichText.cjs +8 -0
- package/dist/src/PrismicRichText/PrismicRichText.cjs.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichText.js +8 -0
- package/dist/src/PrismicRichText/PrismicRichText.js.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts +102 -0
- package/dist/src/PrismicRichText/PrismicRichText.vue.d.ts.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs +88 -0
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js +88 -0
- package/dist/src/PrismicRichText/PrismicRichText.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.cjs +8 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.cjs.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.js +8 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.js.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs +103 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/src/PrismicRichText/PrismicRichTextDefaultComponent.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.cjs +8 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.cjs.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.js +8 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.js.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs +60 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/src/PrismicRichText/PrismicRichTextSerialize.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicRichText/getRichTextComponentProps.cjs +40 -0
- package/dist/src/PrismicRichText/getRichTextComponentProps.cjs.map +1 -0
- package/dist/{PrismicRichText → src/PrismicRichText}/getRichTextComponentProps.d.ts +15 -10
- package/dist/src/PrismicRichText/getRichTextComponentProps.d.ts.map +1 -0
- package/dist/src/PrismicRichText/getRichTextComponentProps.js +39 -0
- package/dist/src/PrismicRichText/getRichTextComponentProps.js.map +1 -0
- package/dist/src/PrismicRichText/index.d.ts +2 -0
- package/dist/{PrismicRichText → src/PrismicRichText}/types.d.ts +11 -6
- package/dist/src/PrismicRichText/types.d.ts.map +1 -0
- package/dist/src/PrismicTable/PrismicTable.cjs +8 -0
- package/dist/src/PrismicTable/PrismicTable.cjs.map +1 -0
- package/dist/src/PrismicTable/PrismicTable.js +8 -0
- package/dist/src/PrismicTable/PrismicTable.js.map +1 -0
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts +39 -0
- package/dist/src/PrismicTable/PrismicTable.vue.d.ts.map +1 -0
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs +65 -0
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js +65 -0
- package/dist/src/PrismicTable/PrismicTable.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs +46 -0
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.cjs.map +1 -0
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.js +46 -0
- package/dist/src/PrismicTable/PrismicTableDefaultComponents.js.map +1 -0
- package/dist/src/PrismicTable/PrismicTableRow.cjs +8 -0
- package/dist/src/PrismicTable/PrismicTableRow.cjs.map +1 -0
- package/dist/src/PrismicTable/PrismicTableRow.js +8 -0
- package/dist/src/PrismicTable/PrismicTableRow.js.map +1 -0
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.cjs +51 -0
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/src/PrismicTable/PrismicTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/PrismicTable/getTableComponentProps.cjs +140 -0
- package/dist/src/PrismicTable/getTableComponentProps.cjs.map +1 -0
- package/dist/{PrismicTable → src/PrismicTable}/getTableComponentProps.d.ts +40 -32
- package/dist/src/PrismicTable/getTableComponentProps.d.ts.map +1 -0
- package/dist/src/PrismicTable/getTableComponentProps.js +129 -0
- package/dist/src/PrismicTable/getTableComponentProps.js.map +1 -0
- package/dist/src/PrismicTable/index.d.ts +1 -0
- package/dist/src/PrismicTable/types.d.ts +35 -0
- package/dist/src/PrismicTable/types.d.ts.map +1 -0
- package/dist/src/PrismicText.cjs +8 -0
- package/dist/src/PrismicText.cjs.map +1 -0
- package/dist/src/PrismicText.js +8 -0
- package/dist/src/PrismicText.js.map +1 -0
- package/dist/src/PrismicText.vue.d.ts +37 -0
- package/dist/src/PrismicText.vue.d.ts.map +1 -0
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.cjs +48 -0
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/src/PrismicText.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/SliceZone/SliceZone.cjs +8 -0
- package/dist/src/SliceZone/SliceZone.cjs.map +1 -0
- package/dist/src/SliceZone/SliceZone.js +8 -0
- package/dist/src/SliceZone/SliceZone.js.map +1 -0
- package/dist/src/SliceZone/SliceZone.vue.d.ts +48 -0
- package/dist/src/SliceZone/SliceZone.vue.d.ts.map +1 -0
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.cjs +82 -0
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.js +82 -0
- package/dist/src/SliceZone/SliceZone.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/SliceZone/TODOSliceComponent.cjs +36 -0
- package/dist/src/SliceZone/TODOSliceComponent.cjs.map +1 -0
- package/dist/src/SliceZone/TODOSliceComponent.d.ts +15 -0
- package/dist/src/SliceZone/TODOSliceComponent.d.ts.map +1 -0
- package/dist/src/SliceZone/TODOSliceComponent.js +36 -0
- package/dist/src/SliceZone/TODOSliceComponent.js.map +1 -0
- package/dist/src/SliceZone/defineSliceZoneComponents.cjs +50 -0
- package/dist/src/SliceZone/defineSliceZoneComponents.cjs.map +1 -0
- package/dist/{SliceZone → src/SliceZone}/defineSliceZoneComponents.d.ts +8 -2
- package/dist/src/SliceZone/defineSliceZoneComponents.d.ts.map +1 -0
- package/dist/src/SliceZone/defineSliceZoneComponents.js +50 -0
- package/dist/src/SliceZone/defineSliceZoneComponents.js.map +1 -0
- package/dist/src/SliceZone/getSliceComponentProps.cjs +60 -0
- package/dist/src/SliceZone/getSliceComponentProps.cjs.map +1 -0
- package/dist/{SliceZone → src/SliceZone}/getSliceComponentProps.d.ts +25 -20
- package/dist/src/SliceZone/getSliceComponentProps.d.ts.map +1 -0
- package/dist/src/SliceZone/getSliceComponentProps.js +59 -0
- package/dist/src/SliceZone/getSliceComponentProps.js.map +1 -0
- package/dist/src/SliceZone/index.d.ts +4 -0
- package/dist/{SliceZone → src/SliceZone}/types.d.ts +40 -37
- package/dist/src/SliceZone/types.d.ts.map +1 -0
- package/dist/src/createPrismic.cjs +85 -0
- package/dist/src/createPrismic.cjs.map +1 -0
- package/dist/src/createPrismic.d.ts +29 -0
- package/dist/src/createPrismic.d.ts.map +1 -0
- package/dist/src/createPrismic.js +85 -0
- package/dist/src/createPrismic.js.map +1 -0
- package/dist/src/lib/Wrapper.cjs +8 -0
- package/dist/src/lib/Wrapper.cjs.map +1 -0
- package/dist/src/lib/Wrapper.js +8 -0
- package/dist/src/lib/Wrapper.js.map +1 -0
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.cjs +22 -0
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.js +22 -0
- package/dist/src/lib/Wrapper.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/src/lib/devMsg.cjs +25 -0
- package/dist/src/lib/devMsg.cjs.map +1 -0
- package/dist/src/lib/devMsg.js +25 -0
- package/dist/src/lib/devMsg.js.map +1 -0
- package/dist/src/lib/isInternalURL.cjs +24 -0
- package/dist/src/lib/isInternalURL.cjs.map +1 -0
- package/dist/src/lib/isInternalURL.js +23 -0
- package/dist/src/lib/isInternalURL.js.map +1 -0
- package/dist/src/types.d.ts +357 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/usePrismic.cjs +38 -0
- package/dist/src/usePrismic.cjs.map +1 -0
- package/dist/{usePrismic.d.ts → src/usePrismic.d.ts} +10 -4
- package/dist/src/usePrismic.d.ts.map +1 -0
- package/dist/src/usePrismic.js +37 -0
- package/dist/src/usePrismic.js.map +1 -0
- package/dist/types.d.cts +357 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/usePrismic.d.cts +36 -0
- package/dist/usePrismic.d.cts.map +1 -0
- package/package.json +29 -53
- package/src/PrismicImage.vue +54 -1
- package/src/SliceZone/TODOSliceComponent.ts +2 -1
- package/src/index.ts +7 -17
- package/dist/PrismicEmbed.vue.cjs +0 -25
- package/dist/PrismicEmbed.vue.cjs.map +0 -1
- package/dist/PrismicEmbed.vue.d.ts +0 -19
- package/dist/PrismicEmbed.vue.js +0 -26
- package/dist/PrismicEmbed.vue.js.map +0 -1
- package/dist/PrismicEmbed.vue2.cjs +0 -4
- package/dist/PrismicEmbed.vue2.cjs.map +0 -1
- package/dist/PrismicEmbed.vue2.js +0 -5
- package/dist/PrismicEmbed.vue2.js.map +0 -1
- package/dist/PrismicImage.vue.cjs +0 -84
- package/dist/PrismicImage.vue.cjs.map +0 -1
- package/dist/PrismicImage.vue.d.ts +0 -224
- package/dist/PrismicImage.vue.js +0 -85
- package/dist/PrismicImage.vue.js.map +0 -1
- package/dist/PrismicImage.vue2.cjs +0 -4
- package/dist/PrismicImage.vue2.cjs.map +0 -1
- package/dist/PrismicImage.vue2.js +0 -5
- package/dist/PrismicImage.vue2.js.map +0 -1
- package/dist/PrismicLink.vue.cjs +0 -64
- package/dist/PrismicLink.vue.cjs.map +0 -1
- package/dist/PrismicLink.vue.d.ts +0 -279
- package/dist/PrismicLink.vue.js +0 -65
- package/dist/PrismicLink.vue.js.map +0 -1
- package/dist/PrismicLink.vue2.cjs +0 -4
- package/dist/PrismicLink.vue2.cjs.map +0 -1
- package/dist/PrismicLink.vue2.js +0 -5
- package/dist/PrismicLink.vue2.js.map +0 -1
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs +0 -100
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.cjs.map +0 -1
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.d.ts +0 -38
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js +0 -101
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue.js.map +0 -1
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.cjs +0 -4
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.cjs.map +0 -1
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.js +0 -5
- package/dist/PrismicRichText/DeprecatedPrismicRichText.vue2.js.map +0 -1
- package/dist/PrismicRichText/PrismicRichText.vue.cjs +0 -97
- package/dist/PrismicRichText/PrismicRichText.vue.cjs.map +0 -1
- package/dist/PrismicRichText/PrismicRichText.vue.d.ts +0 -96
- package/dist/PrismicRichText/PrismicRichText.vue.js +0 -98
- package/dist/PrismicRichText/PrismicRichText.vue.js.map +0 -1
- package/dist/PrismicRichText/PrismicRichText.vue2.cjs +0 -4
- package/dist/PrismicRichText/PrismicRichText.vue2.cjs.map +0 -1
- package/dist/PrismicRichText/PrismicRichText.vue2.js +0 -5
- package/dist/PrismicRichText/PrismicRichText.vue2.js.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.cjs +0 -133
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.cjs.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.d.ts +0 -37
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.js +0 -134
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue.js.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.cjs +0 -4
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.cjs.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.js +0 -5
- package/dist/PrismicRichText/PrismicRichTextDefaultComponent.vue2.js.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.cjs +0 -47
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.cjs.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.d.ts +0 -10
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.js +0 -48
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue.js.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.cjs +0 -4
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.cjs.map +0 -1
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.js +0 -5
- package/dist/PrismicRichText/PrismicRichTextSerialize.vue2.js.map +0 -1
- package/dist/PrismicRichText/getRichTextComponentProps.cjs +0 -10
- package/dist/PrismicRichText/getRichTextComponentProps.cjs.map +0 -1
- package/dist/PrismicRichText/getRichTextComponentProps.js +0 -10
- package/dist/PrismicRichText/getRichTextComponentProps.js.map +0 -1
- package/dist/PrismicRichText/index.d.ts +0 -2
- package/dist/PrismicTable/PrismicTable.vue.cjs +0 -62
- package/dist/PrismicTable/PrismicTable.vue.cjs.map +0 -1
- package/dist/PrismicTable/PrismicTable.vue.d.ts +0 -32
- package/dist/PrismicTable/PrismicTable.vue.js +0 -63
- package/dist/PrismicTable/PrismicTable.vue.js.map +0 -1
- package/dist/PrismicTable/PrismicTable.vue2.cjs +0 -4
- package/dist/PrismicTable/PrismicTable.vue2.cjs.map +0 -1
- package/dist/PrismicTable/PrismicTable.vue2.js +0 -5
- package/dist/PrismicTable/PrismicTable.vue2.js.map +0 -1
- package/dist/PrismicTable/PrismicTableDefaultComponents.cjs +0 -44
- package/dist/PrismicTable/PrismicTableDefaultComponents.cjs.map +0 -1
- package/dist/PrismicTable/PrismicTableDefaultComponents.d.ts +0 -2
- package/dist/PrismicTable/PrismicTableDefaultComponents.js +0 -44
- package/dist/PrismicTable/PrismicTableDefaultComponents.js.map +0 -1
- package/dist/PrismicTable/PrismicTableRow.vue.cjs +0 -52
- package/dist/PrismicTable/PrismicTableRow.vue.cjs.map +0 -1
- package/dist/PrismicTable/PrismicTableRow.vue.d.ts +0 -26
- package/dist/PrismicTable/PrismicTableRow.vue.js +0 -53
- package/dist/PrismicTable/PrismicTableRow.vue.js.map +0 -1
- package/dist/PrismicTable/PrismicTableRow.vue2.cjs +0 -4
- package/dist/PrismicTable/PrismicTableRow.vue2.cjs.map +0 -1
- package/dist/PrismicTable/PrismicTableRow.vue2.js +0 -5
- package/dist/PrismicTable/PrismicTableRow.vue2.js.map +0 -1
- package/dist/PrismicTable/getTableComponentProps.cjs +0 -30
- package/dist/PrismicTable/getTableComponentProps.cjs.map +0 -1
- package/dist/PrismicTable/getTableComponentProps.js +0 -30
- package/dist/PrismicTable/getTableComponentProps.js.map +0 -1
- package/dist/PrismicTable/index.d.ts +0 -1
- package/dist/PrismicTable/types.d.ts +0 -30
- package/dist/PrismicText.vue.cjs +0 -43
- package/dist/PrismicText.vue.cjs.map +0 -1
- package/dist/PrismicText.vue.d.ts +0 -31
- package/dist/PrismicText.vue.js +0 -44
- package/dist/PrismicText.vue.js.map +0 -1
- package/dist/PrismicText.vue2.cjs +0 -4
- package/dist/PrismicText.vue2.cjs.map +0 -1
- package/dist/PrismicText.vue2.js +0 -5
- package/dist/PrismicText.vue2.js.map +0 -1
- package/dist/SliceZone/SliceZone.vue.cjs +0 -63
- package/dist/SliceZone/SliceZone.vue.cjs.map +0 -1
- package/dist/SliceZone/SliceZone.vue.d.ts +0 -41
- package/dist/SliceZone/SliceZone.vue.js +0 -64
- package/dist/SliceZone/SliceZone.vue.js.map +0 -1
- package/dist/SliceZone/SliceZone.vue2.cjs +0 -4
- package/dist/SliceZone/SliceZone.vue2.cjs.map +0 -1
- package/dist/SliceZone/SliceZone.vue2.js +0 -5
- package/dist/SliceZone/SliceZone.vue2.js.map +0 -1
- package/dist/SliceZone/TODOSliceComponent.cjs +0 -29
- package/dist/SliceZone/TODOSliceComponent.cjs.map +0 -1
- package/dist/SliceZone/TODOSliceComponent.d.ts +0 -9
- package/dist/SliceZone/TODOSliceComponent.js +0 -29
- package/dist/SliceZone/TODOSliceComponent.js.map +0 -1
- package/dist/SliceZone/defineSliceZoneComponents.cjs +0 -14
- package/dist/SliceZone/defineSliceZoneComponents.cjs.map +0 -1
- package/dist/SliceZone/defineSliceZoneComponents.js +0 -14
- package/dist/SliceZone/defineSliceZoneComponents.js.map +0 -1
- package/dist/SliceZone/getSliceComponentProps.cjs +0 -22
- package/dist/SliceZone/getSliceComponentProps.cjs.map +0 -1
- package/dist/SliceZone/getSliceComponentProps.js +0 -22
- package/dist/SliceZone/getSliceComponentProps.js.map +0 -1
- package/dist/SliceZone/index.d.ts +0 -4
- package/dist/createPrismic.cjs +0 -81
- package/dist/createPrismic.cjs.map +0 -1
- package/dist/createPrismic.d.ts +0 -22
- package/dist/createPrismic.js +0 -81
- package/dist/createPrismic.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/Wrapper.vue.cjs +0 -20
- package/dist/lib/Wrapper.vue.cjs.map +0 -1
- package/dist/lib/Wrapper.vue.d.ts +0 -28
- package/dist/lib/Wrapper.vue.js +0 -21
- package/dist/lib/Wrapper.vue.js.map +0 -1
- package/dist/lib/Wrapper.vue2.cjs +0 -4
- package/dist/lib/Wrapper.vue2.cjs.map +0 -1
- package/dist/lib/Wrapper.vue2.js +0 -5
- package/dist/lib/Wrapper.vue2.js.map +0 -1
- package/dist/lib/devMsg.cjs +0 -8
- package/dist/lib/devMsg.cjs.map +0 -1
- package/dist/lib/devMsg.d.ts +0 -16
- package/dist/lib/devMsg.js +0 -8
- package/dist/lib/devMsg.js.map +0 -1
- package/dist/lib/isInternalURL.cjs +0 -9
- package/dist/lib/isInternalURL.cjs.map +0 -1
- package/dist/lib/isInternalURL.d.ts +0 -8
- package/dist/lib/isInternalURL.js +0 -9
- package/dist/lib/isInternalURL.js.map +0 -1
- package/dist/package.json.cjs +0 -5
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -5
- package/dist/package.json.js.map +0 -1
- package/dist/types.d.ts +0 -369
- package/dist/usePrismic.cjs +0 -10
- package/dist/usePrismic.cjs.map +0 -1
- package/dist/usePrismic.js +0 -10
- package/dist/usePrismic.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.js","names":[],"sources":["../../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import * as vue11 from "vue";
|
|
2
|
+
import { ImageField, asImagePixelDensitySrcSet, asImageSrc, asImageWidthSrcSet } from "@prismicio/client";
|
|
3
|
+
|
|
4
|
+
//#region src/PrismicImage.vue.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for `<PrismicImage />`.
|
|
8
|
+
*/
|
|
9
|
+
type PrismicImageProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The Prismic image field or thumbnail to render.
|
|
12
|
+
*/
|
|
13
|
+
field: ImageField | ImageField<string>;
|
|
14
|
+
/**
|
|
15
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
16
|
+
*
|
|
17
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
18
|
+
*/
|
|
19
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
20
|
+
/**
|
|
21
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
22
|
+
*
|
|
23
|
+
* See:
|
|
24
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
25
|
+
*/
|
|
26
|
+
alt?: "";
|
|
27
|
+
/**
|
|
28
|
+
* Declare an image as decorative only if the image field does not have
|
|
29
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
30
|
+
*
|
|
31
|
+
* See:
|
|
32
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
33
|
+
*/
|
|
34
|
+
fallbackAlt?: "";
|
|
35
|
+
/**
|
|
36
|
+
* The width attribute of the image element.
|
|
37
|
+
*
|
|
38
|
+
* See:
|
|
39
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
|
|
40
|
+
*/
|
|
41
|
+
width?: number | string;
|
|
42
|
+
/**
|
|
43
|
+
* The height attribute of the image element.
|
|
44
|
+
*
|
|
45
|
+
* See:
|
|
46
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
|
|
47
|
+
*/
|
|
48
|
+
height?: number | string;
|
|
49
|
+
} & ({
|
|
50
|
+
/**
|
|
51
|
+
* Widths used to build a `srcset` value for the image field.
|
|
52
|
+
*
|
|
53
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
54
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
|
|
55
|
+
* 3840.
|
|
56
|
+
*
|
|
57
|
+
* If the image field contains responsive views, each responsive view can
|
|
58
|
+
* be used as a width in the resulting `srcset` by passing `"thumbnails"`
|
|
59
|
+
* as the `widths` prop.
|
|
60
|
+
*/
|
|
61
|
+
widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults";
|
|
62
|
+
/**
|
|
63
|
+
* Not used when the `widths` prop is used.
|
|
64
|
+
*/
|
|
65
|
+
pixelDensities?: never;
|
|
66
|
+
} | {
|
|
67
|
+
/**
|
|
68
|
+
* Not used when the `widths` prop is used.
|
|
69
|
+
*/
|
|
70
|
+
widths?: never;
|
|
71
|
+
/**
|
|
72
|
+
* Pixel densities used to build a `srcset` value for the image field.
|
|
73
|
+
*
|
|
74
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following pixel
|
|
75
|
+
* densities will be used: 1, 2, 3.
|
|
76
|
+
*/
|
|
77
|
+
pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
78
|
+
});
|
|
79
|
+
declare const __VLS_export: vue11.DefineComponent<({
|
|
80
|
+
/**
|
|
81
|
+
* The Prismic image field or thumbnail to render.
|
|
82
|
+
*/
|
|
83
|
+
field: ImageField | ImageField<string>;
|
|
84
|
+
/**
|
|
85
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
86
|
+
*
|
|
87
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
88
|
+
*/
|
|
89
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
90
|
+
/**
|
|
91
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
92
|
+
*
|
|
93
|
+
* See:
|
|
94
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
95
|
+
*/
|
|
96
|
+
alt?: "";
|
|
97
|
+
/**
|
|
98
|
+
* Declare an image as decorative only if the image field does not have
|
|
99
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
100
|
+
*
|
|
101
|
+
* See:
|
|
102
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
103
|
+
*/
|
|
104
|
+
fallbackAlt?: "";
|
|
105
|
+
/**
|
|
106
|
+
* The width attribute of the image element.
|
|
107
|
+
*
|
|
108
|
+
* See:
|
|
109
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
|
|
110
|
+
*/
|
|
111
|
+
width?: number | string;
|
|
112
|
+
/**
|
|
113
|
+
* The height attribute of the image element.
|
|
114
|
+
*
|
|
115
|
+
* See:
|
|
116
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
|
|
117
|
+
*/
|
|
118
|
+
height?: number | string;
|
|
119
|
+
} & {
|
|
120
|
+
/**
|
|
121
|
+
* Widths used to build a `srcset` value for the image field.
|
|
122
|
+
*
|
|
123
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
124
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
|
|
125
|
+
* 3840.
|
|
126
|
+
*
|
|
127
|
+
* If the image field contains responsive views, each responsive view can
|
|
128
|
+
* be used as a width in the resulting `srcset` by passing `"thumbnails"`
|
|
129
|
+
* as the `widths` prop.
|
|
130
|
+
*/
|
|
131
|
+
widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults";
|
|
132
|
+
/**
|
|
133
|
+
* Not used when the `widths` prop is used.
|
|
134
|
+
*/
|
|
135
|
+
pixelDensities?: never;
|
|
136
|
+
}) | ({
|
|
137
|
+
/**
|
|
138
|
+
* The Prismic image field or thumbnail to render.
|
|
139
|
+
*/
|
|
140
|
+
field: ImageField | ImageField<string>;
|
|
141
|
+
/**
|
|
142
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
143
|
+
*
|
|
144
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
145
|
+
*/
|
|
146
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
147
|
+
/**
|
|
148
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
149
|
+
*
|
|
150
|
+
* See:
|
|
151
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
152
|
+
*/
|
|
153
|
+
alt?: "";
|
|
154
|
+
/**
|
|
155
|
+
* Declare an image as decorative only if the image field does not have
|
|
156
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
157
|
+
*
|
|
158
|
+
* See:
|
|
159
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
160
|
+
*/
|
|
161
|
+
fallbackAlt?: "";
|
|
162
|
+
/**
|
|
163
|
+
* The width attribute of the image element.
|
|
164
|
+
*
|
|
165
|
+
* See:
|
|
166
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
|
|
167
|
+
*/
|
|
168
|
+
width?: number | string;
|
|
169
|
+
/**
|
|
170
|
+
* The height attribute of the image element.
|
|
171
|
+
*
|
|
172
|
+
* See:
|
|
173
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
|
|
174
|
+
*/
|
|
175
|
+
height?: number | string;
|
|
176
|
+
} & {
|
|
177
|
+
/**
|
|
178
|
+
* Not used when the `widths` prop is used.
|
|
179
|
+
*/
|
|
180
|
+
widths?: never;
|
|
181
|
+
/**
|
|
182
|
+
* Pixel densities used to build a `srcset` value for the image field.
|
|
183
|
+
*
|
|
184
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following pixel
|
|
185
|
+
* densities will be used: 1, 2, 3.
|
|
186
|
+
*/
|
|
187
|
+
pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
188
|
+
}), {}, {}, {}, {}, vue11.ComponentOptionsMixin, vue11.ComponentOptionsMixin, {}, string, vue11.PublicProps, Readonly<({
|
|
189
|
+
/**
|
|
190
|
+
* The Prismic image field or thumbnail to render.
|
|
191
|
+
*/
|
|
192
|
+
field: ImageField | ImageField<string>;
|
|
193
|
+
/**
|
|
194
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
195
|
+
*
|
|
196
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
197
|
+
*/
|
|
198
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
199
|
+
/**
|
|
200
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
201
|
+
*
|
|
202
|
+
* See:
|
|
203
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
204
|
+
*/
|
|
205
|
+
alt?: "";
|
|
206
|
+
/**
|
|
207
|
+
* Declare an image as decorative only if the image field does not have
|
|
208
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
209
|
+
*
|
|
210
|
+
* See:
|
|
211
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
212
|
+
*/
|
|
213
|
+
fallbackAlt?: "";
|
|
214
|
+
/**
|
|
215
|
+
* The width attribute of the image element.
|
|
216
|
+
*
|
|
217
|
+
* See:
|
|
218
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
|
|
219
|
+
*/
|
|
220
|
+
width?: number | string;
|
|
221
|
+
/**
|
|
222
|
+
* The height attribute of the image element.
|
|
223
|
+
*
|
|
224
|
+
* See:
|
|
225
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
|
|
226
|
+
*/
|
|
227
|
+
height?: number | string;
|
|
228
|
+
} & {
|
|
229
|
+
/**
|
|
230
|
+
* Widths used to build a `srcset` value for the image field.
|
|
231
|
+
*
|
|
232
|
+
* If a `widths` prop is not given or `"defaults"` is passed, the
|
|
233
|
+
* following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
|
|
234
|
+
* 3840.
|
|
235
|
+
*
|
|
236
|
+
* If the image field contains responsive views, each responsive view can
|
|
237
|
+
* be used as a width in the resulting `srcset` by passing `"thumbnails"`
|
|
238
|
+
* as the `widths` prop.
|
|
239
|
+
*/
|
|
240
|
+
widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "thumbnails" | "defaults";
|
|
241
|
+
/**
|
|
242
|
+
* Not used when the `widths` prop is used.
|
|
243
|
+
*/
|
|
244
|
+
pixelDensities?: never;
|
|
245
|
+
}) | ({
|
|
246
|
+
/**
|
|
247
|
+
* The Prismic image field or thumbnail to render.
|
|
248
|
+
*/
|
|
249
|
+
field: ImageField | ImageField<string>;
|
|
250
|
+
/**
|
|
251
|
+
* An object of Imgix URL API parameters to transform the image.
|
|
252
|
+
*
|
|
253
|
+
* See: https://docs.imgix.com/apis/rendering
|
|
254
|
+
*/
|
|
255
|
+
imgixParams?: Parameters<typeof asImageSrc>[1];
|
|
256
|
+
/**
|
|
257
|
+
* Declare an image as decorative by providing `alt=""`.
|
|
258
|
+
*
|
|
259
|
+
* See:
|
|
260
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
261
|
+
*/
|
|
262
|
+
alt?: "";
|
|
263
|
+
/**
|
|
264
|
+
* Declare an image as decorative only if the image field does not have
|
|
265
|
+
* alternative text by providing `fallbackAlt=""`.
|
|
266
|
+
*
|
|
267
|
+
* See:
|
|
268
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
|
|
269
|
+
*/
|
|
270
|
+
fallbackAlt?: "";
|
|
271
|
+
/**
|
|
272
|
+
* The width attribute of the image element.
|
|
273
|
+
*
|
|
274
|
+
* See:
|
|
275
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width
|
|
276
|
+
*/
|
|
277
|
+
width?: number | string;
|
|
278
|
+
/**
|
|
279
|
+
* The height attribute of the image element.
|
|
280
|
+
*
|
|
281
|
+
* See:
|
|
282
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height
|
|
283
|
+
*/
|
|
284
|
+
height?: number | string;
|
|
285
|
+
} & {
|
|
286
|
+
/**
|
|
287
|
+
* Not used when the `widths` prop is used.
|
|
288
|
+
*/
|
|
289
|
+
widths?: never;
|
|
290
|
+
/**
|
|
291
|
+
* Pixel densities used to build a `srcset` value for the image field.
|
|
292
|
+
*
|
|
293
|
+
* If a `pixelDensities` prop is passed `"defaults"`, the following pixel
|
|
294
|
+
* densities will be used: 1, 2, 3.
|
|
295
|
+
*/
|
|
296
|
+
pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
|
|
297
|
+
})> & Readonly<{}>, {}, {}, {}, {}, string, vue11.ComponentProvideOptions, false, {}, any>;
|
|
298
|
+
declare const _default: typeof __VLS_export;
|
|
299
|
+
//#endregion
|
|
300
|
+
export { PrismicImageProps, _default };
|
|
301
|
+
//# sourceMappingURL=PrismicImage.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue.d.ts","names":[],"sources":["../../src/PrismicImage.vue"],"sourcesContent":[],"mappings":";;;;;;;AAuOA;AAIQ,KAJI,iBAAA,GAIJ;EAAa;;;EAuDe,KAAA,EAvD5B,UAuD4B,GAvDf,UAuDe,CAAA,MAAA,CAAA;EAAlB;;;;;EAoBD,WAAA,CAAA,EApEF,UAoEE,CAAA,OApEgB,UAoEhB,CAAA,CAAA,CAAA,CAAA;EAwIX;;;;;;EA5JY,GAAA,CAAA,EAAA,EAAA;EAAZ;;;;;;;EAoBA,WAAA,CAAA,EAAA,EAAA;EAAW;;;;;;EApEF,KAAA,CAAA,EAAA,MAAA,GAAA,MAAA;EAgDqB;;;;;;EAhDrB,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA;CAqES,GAAA,CAAA;EAAlB;;;;;;;AAuIY;;;;WA5JZ,YAAY,kBAAkB;;;;;;;;;;;;;;;;kBAoB9B,YACA,kBAAkB;;cAuIlB,oBAAY;;;;SAnNV,aAAa;;;;;;gBAON,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgD3B,YAAY,kBAAkB;;;;;;;;;SAvD5B,aAAa;;;;;;gBAON,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAoE3B,YACA,kBAAkB;oBADP,KAAA,CAAA,qBAAA;;;;SA3ET,aAAa;;;;;;gBAON,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgD3B,YAAY,kBAAkB;;;;;;;;;SAvD5B,aAAa;;;;;;gBAON,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAoE3B,YACA,kBAAkB;;cAuIN,iBAGU"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const require_usePrismic = require('./usePrismic.cjs');
|
|
2
|
+
const require_devMsg = require('./lib/devMsg.cjs');
|
|
3
|
+
let vue = require("vue");
|
|
4
|
+
let __prismicio_client = require("@prismicio/client");
|
|
5
|
+
let esm_env = require("esm-env");
|
|
6
|
+
|
|
7
|
+
//#region src/PrismicImage.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
const _hoisted_1 = [
|
|
9
|
+
"src",
|
|
10
|
+
"srcset",
|
|
11
|
+
"alt",
|
|
12
|
+
"width",
|
|
13
|
+
"height"
|
|
14
|
+
];
|
|
15
|
+
var PrismicImage_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
16
|
+
name: "PrismicImage",
|
|
17
|
+
__name: "PrismicImage",
|
|
18
|
+
props: {
|
|
19
|
+
field: {
|
|
20
|
+
type: null,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
imgixParams: {
|
|
24
|
+
type: null,
|
|
25
|
+
required: false
|
|
26
|
+
},
|
|
27
|
+
alt: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: false
|
|
30
|
+
},
|
|
31
|
+
fallbackAlt: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false
|
|
34
|
+
},
|
|
35
|
+
width: {
|
|
36
|
+
type: [Number, String],
|
|
37
|
+
required: false
|
|
38
|
+
},
|
|
39
|
+
height: {
|
|
40
|
+
type: [Number, String],
|
|
41
|
+
required: false
|
|
42
|
+
},
|
|
43
|
+
widths: {
|
|
44
|
+
type: null,
|
|
45
|
+
required: false
|
|
46
|
+
},
|
|
47
|
+
pixelDensities: {
|
|
48
|
+
type: null,
|
|
49
|
+
required: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
setup(__props) {
|
|
53
|
+
const props = __props;
|
|
54
|
+
const { options } = require_usePrismic.usePrismic();
|
|
55
|
+
if (esm_env.DEV) (0, vue.watchEffect)(() => {
|
|
56
|
+
if (typeof props.alt === "string" && props.alt !== "") console.warn(`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
|
|
57
|
+
if (typeof props.fallbackAlt === "string" && props.fallbackAlt !== "") console.warn(`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${require_devMsg.devMsg("alt-must-be-an-empty-string")}`);
|
|
58
|
+
if (props.widths && props.pixelDensities) console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
|
|
59
|
+
});
|
|
60
|
+
const castInt = (input) => {
|
|
61
|
+
if (typeof input === "number" || typeof input === "undefined") return input;
|
|
62
|
+
else {
|
|
63
|
+
const parsed = Number.parseInt(input);
|
|
64
|
+
if (Number.isNaN(parsed)) return;
|
|
65
|
+
else return parsed;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const image = (0, vue.computed)(() => {
|
|
69
|
+
if (!__prismicio_client.isFilled.imageThumbnail(props.field)) return;
|
|
70
|
+
let src;
|
|
71
|
+
let srcSet;
|
|
72
|
+
if (props.widths || !props.pixelDensities) {
|
|
73
|
+
const res = (0, __prismicio_client.asImageWidthSrcSet)(props.field, {
|
|
74
|
+
...props.imgixParams,
|
|
75
|
+
widths: props.widths === "defaults" ? options.components?.imageWidthSrcSetDefaults : props.widths
|
|
76
|
+
});
|
|
77
|
+
src = res.src;
|
|
78
|
+
srcSet = res.srcset;
|
|
79
|
+
} else if (props.pixelDensities) {
|
|
80
|
+
const res = (0, __prismicio_client.asImagePixelDensitySrcSet)(props.field, {
|
|
81
|
+
...props.imgixParams,
|
|
82
|
+
pixelDensities: props.pixelDensities === "defaults" ? options.components?.imagePixelDensitySrcSetDefaults : props.pixelDensities
|
|
83
|
+
});
|
|
84
|
+
src = res.src;
|
|
85
|
+
srcSet = res.srcset;
|
|
86
|
+
}
|
|
87
|
+
const ar = props.field.dimensions.width / props.field.dimensions.height;
|
|
88
|
+
const castedWidth = castInt(props.width);
|
|
89
|
+
const castedHeight = castInt(props.height);
|
|
90
|
+
let resolvedWidth = castedWidth ?? props.field.dimensions.width;
|
|
91
|
+
let resolvedHeight = castedHeight ?? props.field.dimensions.height;
|
|
92
|
+
if (castedWidth != null && castedHeight == null) resolvedHeight = castedWidth / ar;
|
|
93
|
+
else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
|
|
94
|
+
return {
|
|
95
|
+
src,
|
|
96
|
+
srcSet,
|
|
97
|
+
alt: props.alt ?? (props.field.alt || props.fallbackAlt),
|
|
98
|
+
width: Math.round(resolvedWidth),
|
|
99
|
+
height: Math.round(resolvedHeight)
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
return (_ctx, _cache) => {
|
|
103
|
+
return image.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("img", {
|
|
104
|
+
key: 0,
|
|
105
|
+
src: image.value.src,
|
|
106
|
+
srcset: image.value.srcSet,
|
|
107
|
+
alt: image.value.alt,
|
|
108
|
+
width: image.value.width,
|
|
109
|
+
height: image.value.height
|
|
110
|
+
}, null, 8, _hoisted_1)) : (0, vue.createCommentVNode)("v-if", true);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
exports.default = PrismicImage_vue_vue_type_script_setup_true_lang_default;
|
|
117
|
+
//# sourceMappingURL=PrismicImage.vue_vue_type_script_setup_true_lang.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue_vue_type_script_setup_true_lang.cjs","names":[],"sources":["../../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuGA,MAAM,QAAQ;EAGd,MAAM,EAAE,YAAY,+BAAW;AAE/B,MAAI,YACH,4BAAkB;AACjB,OAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,GAClD,SAAQ,KACP,qQAAqQ,sBACpQ,8BACA,GACF;AAGD,OAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,GAClE,SAAQ,KACP,qSAAqS,sBACpS,8BACA,GACF;AAGD,OAAI,MAAM,UAAU,MAAM,eACzB,SAAQ,KACP,4MACD;IAED;EAGF,MAAM,WAAW,UAA2D;AAC3E,OAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YACjD,QAAO;QACD;IACN,MAAM,SAAS,OAAO,SAAS,MAAK;AAEpC,QAAI,OAAO,MAAM,OAAO,CACvB;QAEA,QAAO;;;EAKV,MAAM,gCAAuB;AAC5B,OAAI,CAAC,4BAAS,eAAe,MAAM,MAAM,CACxC;GAGD,IAAI;GACJ,IAAI;AACJ,OAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;IAC1C,MAAM,iDAAyB,MAAM,OAAO;KAC3C,GAAG,MAAM;KACT,QACC,MAAM,WAAW,aACd,QAAQ,YAAY,2BACpB,MAAM;KACV,CAAA;AAED,UAAM,IAAI;AACV,aAAS,IAAI;cACH,MAAM,gBAAgB;IAChC,MAAM,wDAAgC,MAAM,OAAO;KAClD,GAAG,MAAM;KACT,gBACC,MAAM,mBAAmB,aACtB,QAAQ,YAAY,kCACpB,MAAM;KACV,CAAA;AAED,UAAM,IAAI;AACV,aAAS,IAAI;;GAGd,MAAM,KAAK,MAAM,MAAM,WAAW,QAAQ,MAAM,MAAM,WAAW;GAEjE,MAAM,cAAc,QAAQ,MAAM,MAAK;GACvC,MAAM,eAAe,QAAQ,MAAM,OAAM;GAEzC,IAAI,gBAAgB,eAAe,MAAM,MAAM,WAAW;GAC1D,IAAI,iBAAiB,gBAAgB,MAAM,MAAM,WAAW;AAE5D,OAAI,eAAe,QAAQ,gBAAgB,KAC1C,kBAAiB,cAAc;YACrB,eAAe,QAAQ,gBAAgB,KACjD,iBAAgB,eAAe;AAGhC,UAAO;IACN;IACA;IACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;IAC5C,OAAO,KAAK,MAAM,cAAc;IAChC,QAAQ,KAAK,MAAM,eAAe;IACnC;IACA;;UAKO,MAAA,2DAML,OAAA;;IALA,KAAK,MAAA,MAAM;IACX,QAAQ,MAAA,MAAM;IACd,KAAK,MAAA,MAAM;IACX,OAAO,MAAA,MAAM;IACb,QAAQ,MAAA,MAAM"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { usePrismic } from "./usePrismic.js";
|
|
2
|
+
import { devMsg } from "./lib/devMsg.js";
|
|
3
|
+
import { computed, createCommentVNode, createElementBlock, defineComponent, openBlock, watchEffect } from "vue";
|
|
4
|
+
import { asImagePixelDensitySrcSet, asImageWidthSrcSet, isFilled } from "@prismicio/client";
|
|
5
|
+
import { DEV } from "esm-env";
|
|
6
|
+
|
|
7
|
+
//#region src/PrismicImage.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
const _hoisted_1 = [
|
|
9
|
+
"src",
|
|
10
|
+
"srcset",
|
|
11
|
+
"alt",
|
|
12
|
+
"width",
|
|
13
|
+
"height"
|
|
14
|
+
];
|
|
15
|
+
var PrismicImage_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
16
|
+
name: "PrismicImage",
|
|
17
|
+
__name: "PrismicImage",
|
|
18
|
+
props: {
|
|
19
|
+
field: {
|
|
20
|
+
type: null,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
imgixParams: {
|
|
24
|
+
type: null,
|
|
25
|
+
required: false
|
|
26
|
+
},
|
|
27
|
+
alt: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: false
|
|
30
|
+
},
|
|
31
|
+
fallbackAlt: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false
|
|
34
|
+
},
|
|
35
|
+
width: {
|
|
36
|
+
type: [Number, String],
|
|
37
|
+
required: false
|
|
38
|
+
},
|
|
39
|
+
height: {
|
|
40
|
+
type: [Number, String],
|
|
41
|
+
required: false
|
|
42
|
+
},
|
|
43
|
+
widths: {
|
|
44
|
+
type: null,
|
|
45
|
+
required: false
|
|
46
|
+
},
|
|
47
|
+
pixelDensities: {
|
|
48
|
+
type: null,
|
|
49
|
+
required: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
setup(__props) {
|
|
53
|
+
const props = __props;
|
|
54
|
+
const { options } = usePrismic();
|
|
55
|
+
if (DEV) watchEffect(() => {
|
|
56
|
+
if (typeof props.alt === "string" && props.alt !== "") console.warn(`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
|
|
57
|
+
if (typeof props.fallbackAlt === "string" && props.fallbackAlt !== "") console.warn(`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
|
|
58
|
+
if (props.widths && props.pixelDensities) console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
|
|
59
|
+
});
|
|
60
|
+
const castInt = (input) => {
|
|
61
|
+
if (typeof input === "number" || typeof input === "undefined") return input;
|
|
62
|
+
else {
|
|
63
|
+
const parsed = Number.parseInt(input);
|
|
64
|
+
if (Number.isNaN(parsed)) return;
|
|
65
|
+
else return parsed;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const image = computed(() => {
|
|
69
|
+
if (!isFilled.imageThumbnail(props.field)) return;
|
|
70
|
+
let src;
|
|
71
|
+
let srcSet;
|
|
72
|
+
if (props.widths || !props.pixelDensities) {
|
|
73
|
+
const res = asImageWidthSrcSet(props.field, {
|
|
74
|
+
...props.imgixParams,
|
|
75
|
+
widths: props.widths === "defaults" ? options.components?.imageWidthSrcSetDefaults : props.widths
|
|
76
|
+
});
|
|
77
|
+
src = res.src;
|
|
78
|
+
srcSet = res.srcset;
|
|
79
|
+
} else if (props.pixelDensities) {
|
|
80
|
+
const res = asImagePixelDensitySrcSet(props.field, {
|
|
81
|
+
...props.imgixParams,
|
|
82
|
+
pixelDensities: props.pixelDensities === "defaults" ? options.components?.imagePixelDensitySrcSetDefaults : props.pixelDensities
|
|
83
|
+
});
|
|
84
|
+
src = res.src;
|
|
85
|
+
srcSet = res.srcset;
|
|
86
|
+
}
|
|
87
|
+
const ar = props.field.dimensions.width / props.field.dimensions.height;
|
|
88
|
+
const castedWidth = castInt(props.width);
|
|
89
|
+
const castedHeight = castInt(props.height);
|
|
90
|
+
let resolvedWidth = castedWidth ?? props.field.dimensions.width;
|
|
91
|
+
let resolvedHeight = castedHeight ?? props.field.dimensions.height;
|
|
92
|
+
if (castedWidth != null && castedHeight == null) resolvedHeight = castedWidth / ar;
|
|
93
|
+
else if (castedWidth == null && castedHeight != null) resolvedWidth = castedHeight * ar;
|
|
94
|
+
return {
|
|
95
|
+
src,
|
|
96
|
+
srcSet,
|
|
97
|
+
alt: props.alt ?? (props.field.alt || props.fallbackAlt),
|
|
98
|
+
width: Math.round(resolvedWidth),
|
|
99
|
+
height: Math.round(resolvedHeight)
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
return (_ctx, _cache) => {
|
|
103
|
+
return image.value ? (openBlock(), createElementBlock("img", {
|
|
104
|
+
key: 0,
|
|
105
|
+
src: image.value.src,
|
|
106
|
+
srcset: image.value.srcSet,
|
|
107
|
+
alt: image.value.alt,
|
|
108
|
+
width: image.value.width,
|
|
109
|
+
height: image.value.height
|
|
110
|
+
}, null, 8, _hoisted_1)) : createCommentVNode("v-if", true);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { PrismicImage_vue_vue_type_script_setup_true_lang_default as default };
|
|
117
|
+
//# sourceMappingURL=PrismicImage.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicImage.vue_vue_type_script_setup_true_lang.js","names":[],"sources":["../../src/PrismicImage.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ImageField, asImageSrc } from \"@prismicio/client\"\nimport {\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\"\nimport { DEV } from \"esm-env\"\nimport { computed, watchEffect } from \"vue\"\n\nimport { devMsg } from \"./lib/devMsg\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * Props for `<PrismicImage />`.\n */\nexport type PrismicImageProps = {\n\t/**\n\t * The Prismic image field or thumbnail to render.\n\t */\n\tfield: ImageField | ImageField<string>\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: Parameters<typeof asImageSrc>[1]\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\"\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\"\n\n\t/**\n\t * The width attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/width\n\t */\n\twidth?: number | string\n\n\t/**\n\t * The height attribute of the image element.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/height\n\t */\n\theight?: number | string\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Widths used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `widths` prop is not given or `\"defaults\"` is passed, the\n\t\t\t * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,\n\t\t\t * 3840.\n\t\t\t *\n\t\t\t * If the image field contains responsive views, each responsive view can\n\t\t\t * be used as a width in the resulting `srcset` by passing `\"thumbnails\"`\n\t\t\t * as the `widths` prop.\n\t\t\t */\n\t\t\twidths?:\n\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t| \"thumbnails\"\n\t\t\t\t| \"defaults\"\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\tpixelDensities?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Not used when the `widths` prop is used.\n\t\t\t */\n\t\t\twidths?: never\n\t\t\t/**\n\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t *\n\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following pixel\n\t\t\t * densities will be used: 1, 2, 3.\n\t\t\t */\n\t\t\tpixelDensities:\n\t\t\t\t| NonNullable<\n\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t| \"defaults\"\n\t }\n)\n\nconst props = defineProps<PrismicImageProps>()\ndefineOptions({ name: \"PrismicImage\" })\n\nconst { options } = usePrismic()\n\nif (DEV) {\n\twatchEffect(() => {\n\t\tif (typeof props.alt === \"string\" && props.alt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (typeof props.fallbackAlt === \"string\" && props.fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t)\n\t\t}\n\n\t\tif (props.widths && props.pixelDensities) {\n\t\t\tconsole.warn(\n\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input\n\t} else {\n\t\tconst parsed = Number.parseInt(input)\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined\n\t\t} else {\n\t\t\treturn parsed\n\t\t}\n\t}\n}\n\nconst image = computed(() => {\n\tif (!isFilled.imageThumbnail(props.field)) {\n\t\treturn\n\t}\n\n\tlet src: string | undefined\n\tlet srcSet: string | undefined\n\tif (props.widths || !props.pixelDensities) {\n\t\tconst res = asImageWidthSrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\twidths:\n\t\t\t\tprops.widths === \"defaults\"\n\t\t\t\t\t? options.components?.imageWidthSrcSetDefaults\n\t\t\t\t\t: props.widths,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t} else if (props.pixelDensities) {\n\t\tconst res = asImagePixelDensitySrcSet(props.field, {\n\t\t\t...props.imgixParams,\n\t\t\tpixelDensities:\n\t\t\t\tprops.pixelDensities === \"defaults\"\n\t\t\t\t\t? options.components?.imagePixelDensitySrcSetDefaults\n\t\t\t\t\t: props.pixelDensities,\n\t\t})\n\n\t\tsrc = res.src\n\t\tsrcSet = res.srcset\n\t}\n\n\tconst ar = props.field.dimensions.width / props.field.dimensions.height\n\n\tconst castedWidth = castInt(props.width)\n\tconst castedHeight = castInt(props.height)\n\n\tlet resolvedWidth = castedWidth ?? props.field.dimensions.width\n\tlet resolvedHeight = castedHeight ?? props.field.dimensions.height\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar\n\t}\n\n\treturn {\n\t\tsrc,\n\t\tsrcSet,\n\t\talt: props.alt ?? (props.field.alt || props.fallbackAlt),\n\t\twidth: Math.round(resolvedWidth),\n\t\theight: Math.round(resolvedHeight),\n\t}\n})\n</script>\n\n<template>\n\t<img\n\t\tv-if=\"image\"\n\t\t:src=\"image.src\"\n\t\t:srcset=\"image.srcSet\"\n\t\t:alt=\"image.alt\"\n\t\t:width=\"image.width\"\n\t\t:height=\"image.height\"\n\t/>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuGA,MAAM,QAAQ;EAGd,MAAM,EAAE,YAAY,YAAW;AAE/B,MAAI,IACH,mBAAkB;AACjB,OAAI,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,GAClD,SAAQ,KACP,qQAAqQ,OACpQ,8BACA,GACF;AAGD,OAAI,OAAO,MAAM,gBAAgB,YAAY,MAAM,gBAAgB,GAClE,SAAQ,KACP,qSAAqS,OACpS,8BACA,GACF;AAGD,OAAI,MAAM,UAAU,MAAM,eACzB,SAAQ,KACP,4MACD;IAED;EAGF,MAAM,WAAW,UAA2D;AAC3E,OAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YACjD,QAAO;QACD;IACN,MAAM,SAAS,OAAO,SAAS,MAAK;AAEpC,QAAI,OAAO,MAAM,OAAO,CACvB;QAEA,QAAO;;;EAKV,MAAM,QAAQ,eAAe;AAC5B,OAAI,CAAC,SAAS,eAAe,MAAM,MAAM,CACxC;GAGD,IAAI;GACJ,IAAI;AACJ,OAAI,MAAM,UAAU,CAAC,MAAM,gBAAgB;IAC1C,MAAM,MAAM,mBAAmB,MAAM,OAAO;KAC3C,GAAG,MAAM;KACT,QACC,MAAM,WAAW,aACd,QAAQ,YAAY,2BACpB,MAAM;KACV,CAAA;AAED,UAAM,IAAI;AACV,aAAS,IAAI;cACH,MAAM,gBAAgB;IAChC,MAAM,MAAM,0BAA0B,MAAM,OAAO;KAClD,GAAG,MAAM;KACT,gBACC,MAAM,mBAAmB,aACtB,QAAQ,YAAY,kCACpB,MAAM;KACV,CAAA;AAED,UAAM,IAAI;AACV,aAAS,IAAI;;GAGd,MAAM,KAAK,MAAM,MAAM,WAAW,QAAQ,MAAM,MAAM,WAAW;GAEjE,MAAM,cAAc,QAAQ,MAAM,MAAK;GACvC,MAAM,eAAe,QAAQ,MAAM,OAAM;GAEzC,IAAI,gBAAgB,eAAe,MAAM,MAAM,WAAW;GAC1D,IAAI,iBAAiB,gBAAgB,MAAM,MAAM,WAAW;AAE5D,OAAI,eAAe,QAAQ,gBAAgB,KAC1C,kBAAiB,cAAc;YACrB,eAAe,QAAQ,gBAAgB,KACjD,iBAAgB,eAAe;AAGhC,UAAO;IACN;IACA;IACA,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,MAAM;IAC5C,OAAO,KAAK,MAAM,cAAc;IAChC,QAAQ,KAAK,MAAM,eAAe;IACnC;IACA;;UAKO,MAAA,sBADP,mBAOE,OAAA;;IALA,KAAK,MAAA,MAAM;IACX,QAAQ,MAAA,MAAM;IACd,KAAK,MAAA,MAAM;IACX,OAAO,MAAA,MAAM;IACb,QAAQ,MAAA,MAAM"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_PrismicLink_vue_vue_type_script_setup_true_lang = require('./PrismicLink.vue_vue_type_script_setup_true_lang.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/PrismicLink.vue
|
|
4
|
+
var PrismicLink_default = require_PrismicLink_vue_vue_type_script_setup_true_lang.default;
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.default = PrismicLink_default;
|
|
8
|
+
//# sourceMappingURL=PrismicLink.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicLink.cjs","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\"\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\"\n\n/**\n * The default rel attribute rendered for external URLs.\n */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * An HTML tag name or a component used to render internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * An HTML tag name or a component used to render external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic link field to render.\n\t\t\t */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic document to render as a link.\n\t\t\t */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { options } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || options.linkResolver,\n\t\trel(args) {\n\t\t\tconst maybeRel = props.rel || options.components?.linkRel\n\t\t\tif (maybeRel) {\n\t\t\t\treturn typeof maybeRel === \"function\" ? maybeRel(args) : maybeRel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent ||\n\t\t\t\toptions.components?.linkInternalComponent ||\n\t\t\t\tdefaultInternalComponent\n\t\t: props.externalComponent ||\n\t\t\t\toptions.components?.linkExternalComponent ||\n\t\t\t\tdefaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import PrismicLink_vue_vue_type_script_setup_true_lang_default from "./PrismicLink.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
|
|
3
|
+
//#region src/PrismicLink.vue
|
|
4
|
+
var PrismicLink_default = PrismicLink_vue_vue_type_script_setup_true_lang_default;
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { PrismicLink_default as default };
|
|
8
|
+
//# sourceMappingURL=PrismicLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismicLink.js","names":[],"sources":["../../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\"\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\"\n\n/**\n * The default rel attribute rendered for external URLs.\n */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * An HTML tag name or a component used to render internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * An HTML tag name or a component used to render external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic link field to render.\n\t\t\t */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic document to render as a link.\n\t\t\t */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { options } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || options.linkResolver,\n\t\trel(args) {\n\t\t\tconst maybeRel = props.rel || options.components?.linkRel\n\t\t\tif (maybeRel) {\n\t\t\t\treturn typeof maybeRel === \"function\" ? maybeRel(args) : maybeRel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent ||\n\t\t\t\toptions.components?.linkInternalComponent ||\n\t\t\t\tdefaultInternalComponent\n\t\t: props.externalComponent ||\n\t\t\t\toptions.components?.linkExternalComponent ||\n\t\t\t\tdefaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"mappings":""}
|