origam 2.38.0 → 2.38.2
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/CHANGELOG.md +34 -0
- package/dist/src/assets/locales/en.json +1 -1
- package/dist/src/assets/locales/fr.json +2 -2
- package/dist/src/components/Alert/OrigamAlert.vue +739 -165
- package/dist/src/components/App/OrigamApp.vue +95 -19
- package/dist/src/components/App/OrigamAppBar.vue +751 -158
- package/dist/src/components/Audio/OrigamAudio.vue +1288 -346
- package/dist/src/components/Audio/OrigamAudioWaveform.vue +63 -7
- package/dist/src/components/Avatar/OrigamAvatar.vue +678 -126
- package/dist/src/components/Avatar/OrigamAvatarGroup.vue +700 -153
- package/dist/src/components/Badge/OrigamBadge.vue +548 -135
- package/dist/src/components/Blockquote/OrigamBlockquote.vue +698 -140
- package/dist/src/components/BottomNav/OrigamBottomNav.vue +864 -156
- package/dist/src/components/Bracket/OrigamBracket.vue +1013 -380
- package/dist/src/components/Bracket/OrigamBracketCompetitor.vue +674 -154
- package/dist/src/components/Bracket/OrigamBracketMatch.vue +663 -163
- package/dist/src/components/Bracket/OrigamBracketRound.vue +116 -34
- package/dist/src/components/Breadcrumb/OrigamBreadcrumb.vue +654 -119
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbDivider.vue +292 -54
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbItem.vue +657 -126
- package/dist/src/components/Btn/OrigamBtn.vue +928 -249
- package/dist/src/components/Btn/OrigamBtnGroup.vue +658 -141
- package/dist/src/components/Btn/OrigamBtnToggle.vue +578 -91
- package/dist/src/components/Calendar/OrigamCalendar.vue +1142 -484
- package/dist/src/components/Card/OrigamCard.vue +938 -194
- package/dist/src/components/Card/OrigamCardHeader.vue +593 -104
- package/dist/src/components/Card/OrigamCardText.vue +536 -84
- package/dist/src/components/Carousel/OrigamCarousel.vue +778 -202
- package/dist/src/components/Carousel/OrigamCarouselItem.vue +660 -109
- package/dist/src/components/Chart/OrigamChart.vue +942 -452
- package/dist/src/components/Chart/OrigamChartAxis.vue +111 -19
- package/dist/src/components/Chart/OrigamChartBoxPlot.vue +713 -297
- package/dist/src/components/Chart/OrigamChartBullet.vue +701 -286
- package/dist/src/components/Chart/OrigamChartCandlestick.vue +663 -243
- package/dist/src/components/Chart/OrigamChartCartesian.vue +1055 -487
- package/dist/src/components/Chart/OrigamChartGauge.vue +563 -164
- package/dist/src/components/Chart/OrigamChartHeatmap.vue +677 -251
- package/dist/src/components/Chart/OrigamChartHoneycomb.vue +700 -288
- package/dist/src/components/Chart/OrigamChartLegend.vue +108 -16
- package/dist/src/components/Chart/OrigamChartMap.vue +723 -299
- package/dist/src/components/Chart/OrigamChartPareto.vue +721 -276
- package/dist/src/components/Chart/OrigamChartPictorial.vue +777 -355
- package/dist/src/components/Chart/OrigamChartPolar.vue +603 -210
- package/dist/src/components/Chart/OrigamChartPolarBar.vue +674 -271
- package/dist/src/components/Chart/OrigamChartPyramid.vue +685 -250
- package/dist/src/components/Chart/OrigamChartRadar.vue +515 -165
- package/dist/src/components/Chart/OrigamChartRangeSelector.vue +50 -25
- package/dist/src/components/Chart/OrigamChartSankey.vue +913 -467
- package/dist/src/components/Chart/OrigamChartSparkline.vue +711 -268
- package/dist/src/components/Chart/OrigamChartStreamgraph.vue +810 -368
- package/dist/src/components/Chart/OrigamChartSunburst.vue +779 -368
- package/dist/src/components/Chart/OrigamChartTooltip.vue +78 -19
- package/dist/src/components/Chart/OrigamChartTreemap.vue +750 -288
- package/dist/src/components/Chart/OrigamChartVariwide.vue +679 -251
- package/dist/src/components/Chart/OrigamChartWordCloud.vue +674 -265
- package/dist/src/components/Checkbox/OrigamCheckbox.vue +781 -136
- package/dist/src/components/Checkbox/OrigamCheckboxBtn.vue +465 -81
- package/dist/src/components/Checkbox/OrigamCheckboxGroup.vue +824 -137
- package/dist/src/components/Chip/OrigamChip.vue +867 -202
- package/dist/src/components/Chip/OrigamChipGroup.vue +633 -121
- package/dist/src/components/ClientOnly/OrigamClientOnly.vue +30 -4
- package/dist/src/components/Clipboard/OrigamClipboard.vue +624 -105
- package/dist/src/components/Code/OrigamCode.vue +844 -206
- package/dist/src/components/CodeGroup/OrigamCodeGroup.vue +494 -83
- package/dist/src/components/ColorPicker/OrigamColorPicker.vue +777 -159
- package/dist/src/components/ColorPicker/OrigamColorPickerCanvas.vue +295 -181
- package/dist/src/components/ColorPicker/OrigamColorPickerEdit.vue +108 -45
- package/dist/src/components/ColorPicker/OrigamColorPickerPreview.vue +131 -46
- package/dist/src/components/ColorPicker/OrigamColorPickerSwatches.vue +128 -39
- package/dist/src/components/ColorPickerField/OrigamColorPickerField.vue +1123 -258
- package/dist/src/components/CommandPalette/OrigamCommandPalette.vue +415 -162
- package/dist/src/components/ConfirmWrapper/OrigamConfirmWrapper.vue +389 -145
- package/dist/src/components/ContextualMenu/OrigamContextualMenu.vue +852 -147
- package/dist/src/components/Counter/OrigamCounter.vue +588 -96
- package/dist/src/components/DataList/OrigamDataList.vue +619 -113
- package/dist/src/components/DataList/OrigamDataText.vue +295 -65
- package/dist/src/components/DataList/OrigamDataTitle.vue +295 -65
- package/dist/src/components/DataTable/OrigamDataTable.vue +934 -222
- package/dist/src/components/DataTable/OrigamDataTableColumnCell.vue +196 -51
- package/dist/src/components/DataTable/OrigamDataTableFooter.vue +319 -78
- package/dist/src/components/DataTable/OrigamDataTableGroupHeaderRow.vue +124 -44
- package/dist/src/components/DataTable/OrigamDataTableHeaderCell.vue +181 -70
- package/dist/src/components/DataTable/OrigamDataTableHeaders.vue +155 -46
- package/dist/src/components/DataTable/OrigamDataTableHeadersCell.vue +145 -27
- package/dist/src/components/DataTable/OrigamDataTableHeadersCellMobile.vue +126 -43
- package/dist/src/components/DataTable/OrigamDataTableRow.vue +151 -73
- package/dist/src/components/DataTable/OrigamDataTableRows.vue +261 -106
- package/dist/src/components/DatePicker/OrigamDatePicker.vue +1048 -261
- package/dist/src/components/DatePicker/OrigamDatePickerControls.vue +155 -51
- package/dist/src/components/DatePicker/OrigamDatePickerHeader.vue +147 -46
- package/dist/src/components/DatePicker/OrigamDatePickerMonth.vue +312 -134
- package/dist/src/components/DatePicker/OrigamDatePickerMonths.vue +151 -61
- package/dist/src/components/DatePicker/OrigamDatePickerYears.vue +154 -67
- package/dist/src/components/DatePickerField/OrigamDatePickerField.vue +1147 -306
- package/dist/src/components/DefaultsProvider/OrigamDefaultsProvider.vue +74 -14
- package/dist/src/components/Dialog/OrigamDialog.vue +953 -196
- package/dist/src/components/Dialog/OrigamDialogConfirmation.vue +886 -148
- package/dist/src/components/Divider/OrigamDivider.vue +210 -50
- package/dist/src/components/Drawer/OrigamDrawer.vue +909 -207
- package/dist/src/components/EmptyState/OrigamEmptyState.vue +146 -35
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanel.vue +746 -159
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelContent.vue +591 -95
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelHeader.vue +663 -143
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanels.vue +675 -134
- package/dist/src/components/Field/OrigamField.vue +1118 -306
- package/dist/src/components/FileField/OrigamFileField.vue +1188 -311
- package/dist/src/components/FileField/OrigamFileFieldDragNDropItem.vue +155 -36
- package/dist/src/components/FileField/OrigamFileFieldListItem.vue +155 -36
- package/dist/src/components/Form/OrigamForm.vue +197 -74
- package/dist/src/components/Grid/OrigamGrid.vue +707 -147
- package/dist/src/components/Grid/OrigamGridItem.vue +110 -37
- package/dist/src/components/Grids/OrigamCol.vue +593 -110
- package/dist/src/components/Grids/OrigamContainer.vue +461 -80
- package/dist/src/components/Grids/OrigamRow.vue +573 -112
- package/dist/src/components/Grids/OrigamSpacer.vue +54 -17
- package/dist/src/components/Icon/OrigamClassIcon.vue +573 -98
- package/dist/src/components/Icon/OrigamComponentIcon.vue +561 -101
- package/dist/src/components/Icon/OrigamIcon.vue +561 -98
- package/dist/src/components/Icon/OrigamLigatureIcon.vue +558 -98
- package/dist/src/components/Icon/OrigamSvgIcon.vue +593 -100
- package/dist/src/components/Img/OrigamImg.vue +869 -228
- package/dist/src/components/InfiniteScroll/OrigamInfiniteScroll.vue +319 -111
- package/dist/src/components/InfiniteScroll/OrigamInfiniteScrollIntersect.vue +80 -17
- package/dist/src/components/InlineEdit/OrigamInlineEdit.vue +476 -140
- package/dist/src/components/Input/OrigamInput.vue +747 -180
- package/dist/src/components/ItemGroup/OrigamItemGroup.vue +112 -36
- package/dist/src/components/ItemGroup/OrigamItemGroupItem.vue +80 -29
- package/dist/src/components/Kbd/OrigamKbd.vue +450 -75
- package/dist/src/components/Label/OrigamLabel.vue +584 -95
- package/dist/src/components/Layout/OrigamLayout.vue +563 -94
- package/dist/src/components/Lazy/OrigamLazy.vue +131 -34
- package/dist/src/components/List/OrigamList.vue +755 -170
- package/dist/src/components/List/OrigamListChildren.vue +59 -19
- package/dist/src/components/List/OrigamListGroup.vue +631 -134
- package/dist/src/components/List/OrigamListGroupActivator.vue +45 -17
- package/dist/src/components/List/OrigamListItem.vue +890 -224
- package/dist/src/components/List/OrigamListItemWrapper.vue +20 -10
- package/dist/src/components/List/OrigamListSubheader.vue +542 -93
- package/dist/src/components/Loader/OrigamLoader.vue +110 -25
- package/dist/src/components/Main/OrigamMain.vue +565 -96
- package/dist/src/components/Masonry/OrigamMasonry.vue +799 -187
- package/dist/src/components/Media/OrigamMediaController.vue +465 -182
- package/dist/src/components/Media/OrigamMediaScrubber.vue +389 -152
- package/dist/src/components/Media/OrigamMediaVolumeControl.vue +174 -44
- package/dist/src/components/Menu/OrigamMenu.vue +1079 -255
- package/dist/src/components/Messages/OrigamMessages.vue +606 -97
- package/dist/src/components/NumberField/OrigamNumberField.vue +1208 -333
- package/dist/src/components/NumberFormat/OrigamNumberFormat.vue +177 -57
- package/dist/src/components/OtpInputField/OrigamOtpInputField.vue +1016 -272
- package/dist/src/components/Overlay/OrigamOverlay.vue +446 -158
- package/dist/src/components/Overlay/OrigamOverlayScrim.vue +122 -30
- package/dist/src/components/Pagination/OrigamPagination.vue +982 -313
- package/dist/src/components/Parallax/OrigamParallax.vue +800 -259
- package/dist/src/components/Parallax/OrigamParallaxElement.vue +694 -178
- package/dist/src/components/Parallax/OrigamParallaxLayer.vue +132 -47
- package/dist/src/components/PasswordField/OrigamPasswordField.vue +1098 -265
- package/dist/src/components/Picker/OrigamPicker.vue +655 -108
- package/dist/src/components/Picker/OrigamPickerTitle.vue +108 -26
- package/dist/src/components/Progress/OrigamProgress.vue +436 -70
- package/dist/src/components/Progress/OrigamProgressCircular.vue +399 -82
- package/dist/src/components/Progress/OrigamProgressLinear.vue +468 -115
- package/dist/src/components/QrCode/OrigamQrCode.vue +642 -126
- package/dist/src/components/Radio/OrigamRadio.vue +772 -132
- package/dist/src/components/Radio/OrigamRadioBtn.vue +446 -71
- package/dist/src/components/Radio/OrigamRadioGroup.vue +808 -135
- package/dist/src/components/RatingField/OrigamRatingField.vue +963 -194
- package/dist/src/components/RatingField/OrigamRatingFieldItem.vue +657 -106
- package/dist/src/components/Responsive/OrigamResponsive.vue +548 -91
- package/dist/src/components/Select/OrigamSelect.vue +1639 -567
- package/dist/src/components/SelectionControl/OrigamSelectionControl.vue +564 -151
- package/dist/src/components/SelectionControl/OrigamSelectionControlGroup.vue +178 -62
- package/dist/src/components/Sheet/OrigamSheet.vue +773 -199
- package/dist/src/components/Skeleton/OrigamSkeleton.vue +249 -46
- package/dist/src/components/Skeleton/OrigamSkeletonGroup.vue +66 -11
- package/dist/src/components/Slide/OrigamSlideGroup.vue +772 -257
- package/dist/src/components/SliderField/OrigamSliderField.vue +1157 -335
- package/dist/src/components/SliderField/OrigamSliderFieldTrack.vue +236 -112
- package/dist/src/components/Snackbar/OrigamSnackbar.vue +871 -214
- package/dist/src/components/Snackbar/OrigamSnackbarGroup.vue +218 -51
- package/dist/src/components/Snackbar/OrigamSnackbarItem.vue +175 -43
- package/dist/src/components/Stepper/OrigamStepper.vue +618 -126
- package/dist/src/components/Stepper/OrigamStepperItem.vue +98 -37
- package/dist/src/components/Switch/OrigamSwitch.vue +879 -156
- package/dist/src/components/Switch/OrigamSwitchTrack.vue +431 -78
- package/dist/src/components/SystemBar/OrigamSystemBar.vue +517 -87
- package/dist/src/components/Table/OrigamTable.vue +585 -124
- package/dist/src/components/Tabs/OrigamTab.vue +239 -73
- package/dist/src/components/Tabs/OrigamTabPanel.vue +125 -39
- package/dist/src/components/Tabs/OrigamTabPanels.vue +148 -57
- package/dist/src/components/Tabs/OrigamTabs.vue +381 -109
- package/dist/src/components/TextField/OrigamTextField.vue +1077 -258
- package/dist/src/components/TextMask/OrigamTextMask.vue +150 -43
- package/dist/src/components/TextareaField/OrigamTextareaField.vue +1162 -310
- package/dist/src/components/TextareaField/OrigamTextareaFieldRichToolbar.vue +77 -79
- package/dist/src/components/ThemeProvider/OrigamThemeProvider.vue +44 -9
- package/dist/src/components/Timeline/OrigamTimeline.vue +113 -43
- package/dist/src/components/Timeline/OrigamTimelineItem.vue +163 -76
- package/dist/src/components/Title/OrigamTitle.vue +505 -82
- package/dist/src/components/Toolbar/OrigamToolbar.vue +679 -142
- package/dist/src/components/Tooltip/OrigamTooltip.vue +288 -72
- package/dist/src/components/Transition/OrigamExpandX.vue +219 -106
- package/dist/src/components/Transition/OrigamExpandY.vue +219 -106
- package/dist/src/components/Transition/OrigamFade.vue +47 -9
- package/dist/src/components/Transition/OrigamReverseTranslatePicker.vue +52 -10
- package/dist/src/components/Transition/OrigamScaleRotate.vue +52 -10
- package/dist/src/components/Transition/OrigamSlideX.vue +52 -10
- package/dist/src/components/Transition/OrigamSlideY.vue +52 -10
- package/dist/src/components/Transition/OrigamSnack.vue +52 -10
- package/dist/src/components/Transition/OrigamTransition.vue +40 -12
- package/dist/src/components/Transition/OrigamTranslateBottom.vue +52 -10
- package/dist/src/components/Transition/OrigamTranslatePicker.vue +52 -10
- package/dist/src/components/Transition/OrigamTranslateScale.vue +209 -97
- package/dist/src/components/Transition/OrigamWindowXReverseTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowXTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowYReverseTranslate.vue +40 -7
- package/dist/src/components/Transition/OrigamWindowYTranslate.vue +40 -7
- package/dist/src/components/Treeview/OrigamTreeview.vue +258 -118
- package/dist/src/components/Treeview/OrigamTreeviewNode.vue +126 -88
- package/dist/src/components/Video/OrigamVideo.vue +1178 -331
- package/dist/src/components/VirtualScroll/OrigamVirtualScroll.vue +147 -55
- package/dist/src/components/VirtualScroll/OrigamVirtualScrollItem.vue +94 -19
- package/dist/src/components/Watermark/OrigamWatermark.vue +224 -124
- package/dist/src/components/Window/OrigamWindow.vue +745 -175
- package/dist/src/components/Window/OrigamWindowItem.vue +162 -69
- package/dist/src/composables/Commons/display.composable.cjs +2 -0
- package/dist/src/composables/Commons/display.composable.js +1 -1
- package/dist/src/interfaces/Pagination/pagination.interface.d.ts +1 -1
- package/package.json +8 -8
|
@@ -84,18 +84,7 @@
|
|
|
84
84
|
</template>
|
|
85
85
|
|
|
86
86
|
<script lang="ts" setup>
|
|
87
|
-
import {
|
|
88
|
-
computed,
|
|
89
|
-
nextTick,
|
|
90
|
-
onBeforeMount,
|
|
91
|
-
onBeforeUnmount,
|
|
92
|
-
ref,
|
|
93
|
-
shallowRef,
|
|
94
|
-
StyleValue,
|
|
95
|
-
toRef,
|
|
96
|
-
useSlots,
|
|
97
|
-
watch
|
|
98
|
-
} from "vue";
|
|
87
|
+
import { computed, nextTick, onBeforeMount, onBeforeUnmount, ref, shallowRef, StyleValue, toRef, useSlots, watch } from "vue";
|
|
99
88
|
import OrigamResponsive from "../Responsive/OrigamResponsive.vue";
|
|
100
89
|
import OrigamTransition from "../Transition/OrigamTransition.vue";
|
|
101
90
|
import { useBorder } from "../../composables/Commons/border.composable";
|
|
@@ -110,92 +99,597 @@ import vIntersect from "../../directives/Intersect/intersect.directive";
|
|
|
110
99
|
import { IMG_STATE } from "../../enums/Img/img.enum";
|
|
111
100
|
import { convertToUnit, pick } from "../../utils/Commons/commons.util";
|
|
112
101
|
import { getCurrentInstance } from "../../utils/Commons/getCurrentInstance.util";
|
|
102
|
+
/*********************************************************
|
|
103
|
+
* Global
|
|
104
|
+
*
|
|
105
|
+
* @description
|
|
106
|
+
* Props, emits, composables, and image load lifecycle setup.
|
|
107
|
+
********************************************************/
|
|
113
108
|
const props = defineProps({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
109
|
+
alt: {
|
|
110
|
+
type: String,
|
|
111
|
+
required: false
|
|
112
|
+
},
|
|
113
|
+
cover: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
required: false
|
|
116
|
+
},
|
|
117
|
+
draggable: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
required: false
|
|
120
|
+
},
|
|
121
|
+
gradient: {
|
|
122
|
+
type: String,
|
|
123
|
+
required: false
|
|
124
|
+
},
|
|
125
|
+
lazySrc: {
|
|
126
|
+
type: String,
|
|
127
|
+
required: false
|
|
128
|
+
},
|
|
129
|
+
options: {
|
|
130
|
+
type: Object,
|
|
131
|
+
required: false
|
|
132
|
+
},
|
|
133
|
+
sizes: {
|
|
134
|
+
type: String,
|
|
135
|
+
required: false
|
|
136
|
+
},
|
|
137
|
+
src: {
|
|
138
|
+
type: [String, Object],
|
|
139
|
+
required: false
|
|
140
|
+
},
|
|
141
|
+
crossorigin: {
|
|
142
|
+
type: null,
|
|
143
|
+
required: false
|
|
144
|
+
},
|
|
145
|
+
referrerpolicy: {
|
|
146
|
+
type: null,
|
|
147
|
+
required: false
|
|
148
|
+
},
|
|
149
|
+
srcset: {
|
|
150
|
+
type: String,
|
|
151
|
+
required: false
|
|
152
|
+
},
|
|
153
|
+
position: {
|
|
154
|
+
type: String,
|
|
155
|
+
required: false
|
|
156
|
+
},
|
|
157
|
+
color: {
|
|
158
|
+
type: [
|
|
159
|
+
String,
|
|
160
|
+
Object,
|
|
161
|
+
Boolean,
|
|
162
|
+
null
|
|
163
|
+
],
|
|
164
|
+
required: false,
|
|
165
|
+
skipCheck: true
|
|
166
|
+
},
|
|
167
|
+
bgColor: {
|
|
168
|
+
type: [
|
|
169
|
+
String,
|
|
170
|
+
Object,
|
|
171
|
+
Boolean,
|
|
172
|
+
null
|
|
173
|
+
],
|
|
174
|
+
required: false,
|
|
175
|
+
skipCheck: true
|
|
176
|
+
},
|
|
177
|
+
aspectRatio: {
|
|
178
|
+
type: [String, Number],
|
|
179
|
+
required: false
|
|
180
|
+
},
|
|
181
|
+
contentClass: {
|
|
182
|
+
type: String,
|
|
183
|
+
required: false
|
|
184
|
+
},
|
|
185
|
+
height: {
|
|
186
|
+
type: [Number, String],
|
|
187
|
+
required: false
|
|
188
|
+
},
|
|
189
|
+
maxHeight: {
|
|
190
|
+
type: [Number, String],
|
|
191
|
+
required: false
|
|
192
|
+
},
|
|
193
|
+
maxWidth: {
|
|
194
|
+
type: [Number, String],
|
|
195
|
+
required: false
|
|
196
|
+
},
|
|
197
|
+
minHeight: {
|
|
198
|
+
type: [Number, String],
|
|
199
|
+
required: false
|
|
200
|
+
},
|
|
201
|
+
minWidth: {
|
|
202
|
+
type: [Number, String],
|
|
203
|
+
required: false
|
|
204
|
+
},
|
|
205
|
+
width: {
|
|
206
|
+
type: [Number, String],
|
|
207
|
+
required: false
|
|
208
|
+
},
|
|
209
|
+
id: {
|
|
210
|
+
type: String,
|
|
211
|
+
required: false
|
|
212
|
+
},
|
|
213
|
+
class: {
|
|
214
|
+
type: [
|
|
215
|
+
String,
|
|
216
|
+
Array,
|
|
217
|
+
Object
|
|
218
|
+
],
|
|
219
|
+
required: false
|
|
220
|
+
},
|
|
221
|
+
style: {
|
|
222
|
+
type: [
|
|
223
|
+
String,
|
|
224
|
+
Array,
|
|
225
|
+
Object,
|
|
226
|
+
Boolean,
|
|
227
|
+
null
|
|
228
|
+
],
|
|
229
|
+
required: false,
|
|
230
|
+
skipCheck: true
|
|
231
|
+
},
|
|
232
|
+
tag: {
|
|
233
|
+
type: String,
|
|
234
|
+
required: false,
|
|
235
|
+
default: "div"
|
|
236
|
+
},
|
|
237
|
+
padding: {
|
|
238
|
+
type: [
|
|
239
|
+
Boolean,
|
|
240
|
+
Number,
|
|
241
|
+
String
|
|
242
|
+
],
|
|
243
|
+
required: false
|
|
244
|
+
},
|
|
245
|
+
paddingTop: {
|
|
246
|
+
type: [
|
|
247
|
+
Boolean,
|
|
248
|
+
Number,
|
|
249
|
+
String
|
|
250
|
+
],
|
|
251
|
+
required: false
|
|
252
|
+
},
|
|
253
|
+
paddingLeft: {
|
|
254
|
+
type: [
|
|
255
|
+
Boolean,
|
|
256
|
+
Number,
|
|
257
|
+
String
|
|
258
|
+
],
|
|
259
|
+
required: false
|
|
260
|
+
},
|
|
261
|
+
paddingBottom: {
|
|
262
|
+
type: [
|
|
263
|
+
Boolean,
|
|
264
|
+
Number,
|
|
265
|
+
String
|
|
266
|
+
],
|
|
267
|
+
required: false
|
|
268
|
+
},
|
|
269
|
+
paddingRight: {
|
|
270
|
+
type: [
|
|
271
|
+
Boolean,
|
|
272
|
+
Number,
|
|
273
|
+
String
|
|
274
|
+
],
|
|
275
|
+
required: false
|
|
276
|
+
},
|
|
277
|
+
paddingBlock: {
|
|
278
|
+
type: [
|
|
279
|
+
Boolean,
|
|
280
|
+
Number,
|
|
281
|
+
String
|
|
282
|
+
],
|
|
283
|
+
required: false
|
|
284
|
+
},
|
|
285
|
+
paddingInline: {
|
|
286
|
+
type: [
|
|
287
|
+
Boolean,
|
|
288
|
+
Number,
|
|
289
|
+
String
|
|
290
|
+
],
|
|
291
|
+
required: false
|
|
292
|
+
},
|
|
293
|
+
paddingInlineStart: {
|
|
294
|
+
type: [
|
|
295
|
+
Boolean,
|
|
296
|
+
Number,
|
|
297
|
+
String
|
|
298
|
+
],
|
|
299
|
+
required: false
|
|
300
|
+
},
|
|
301
|
+
paddingInlineEnd: {
|
|
302
|
+
type: [
|
|
303
|
+
Boolean,
|
|
304
|
+
Number,
|
|
305
|
+
String
|
|
306
|
+
],
|
|
307
|
+
required: false
|
|
308
|
+
},
|
|
309
|
+
paddingBlockStart: {
|
|
310
|
+
type: [
|
|
311
|
+
Boolean,
|
|
312
|
+
Number,
|
|
313
|
+
String
|
|
314
|
+
],
|
|
315
|
+
required: false
|
|
316
|
+
},
|
|
317
|
+
paddingBlockEnd: {
|
|
318
|
+
type: [
|
|
319
|
+
Boolean,
|
|
320
|
+
Number,
|
|
321
|
+
String
|
|
322
|
+
],
|
|
323
|
+
required: false
|
|
324
|
+
},
|
|
325
|
+
margin: {
|
|
326
|
+
type: [
|
|
327
|
+
Boolean,
|
|
328
|
+
Number,
|
|
329
|
+
String
|
|
330
|
+
],
|
|
331
|
+
required: false
|
|
332
|
+
},
|
|
333
|
+
marginTop: {
|
|
334
|
+
type: [
|
|
335
|
+
Boolean,
|
|
336
|
+
Number,
|
|
337
|
+
String
|
|
338
|
+
],
|
|
339
|
+
required: false
|
|
340
|
+
},
|
|
341
|
+
marginLeft: {
|
|
342
|
+
type: [
|
|
343
|
+
Boolean,
|
|
344
|
+
Number,
|
|
345
|
+
String
|
|
346
|
+
],
|
|
347
|
+
required: false
|
|
348
|
+
},
|
|
349
|
+
marginBottom: {
|
|
350
|
+
type: [
|
|
351
|
+
Boolean,
|
|
352
|
+
Number,
|
|
353
|
+
String
|
|
354
|
+
],
|
|
355
|
+
required: false
|
|
356
|
+
},
|
|
357
|
+
marginRight: {
|
|
358
|
+
type: [
|
|
359
|
+
Boolean,
|
|
360
|
+
Number,
|
|
361
|
+
String
|
|
362
|
+
],
|
|
363
|
+
required: false
|
|
364
|
+
},
|
|
365
|
+
marginBlock: {
|
|
366
|
+
type: [
|
|
367
|
+
Boolean,
|
|
368
|
+
Number,
|
|
369
|
+
String
|
|
370
|
+
],
|
|
371
|
+
required: false
|
|
372
|
+
},
|
|
373
|
+
marginInline: {
|
|
374
|
+
type: [
|
|
375
|
+
Boolean,
|
|
376
|
+
Number,
|
|
377
|
+
String
|
|
378
|
+
],
|
|
379
|
+
required: false
|
|
380
|
+
},
|
|
381
|
+
marginInlineStart: {
|
|
382
|
+
type: [
|
|
383
|
+
Boolean,
|
|
384
|
+
Number,
|
|
385
|
+
String
|
|
386
|
+
],
|
|
387
|
+
required: false
|
|
388
|
+
},
|
|
389
|
+
marginInlineEnd: {
|
|
390
|
+
type: [
|
|
391
|
+
Boolean,
|
|
392
|
+
Number,
|
|
393
|
+
String
|
|
394
|
+
],
|
|
395
|
+
required: false
|
|
396
|
+
},
|
|
397
|
+
marginBlockStart: {
|
|
398
|
+
type: [
|
|
399
|
+
Boolean,
|
|
400
|
+
Number,
|
|
401
|
+
String
|
|
402
|
+
],
|
|
403
|
+
required: false
|
|
404
|
+
},
|
|
405
|
+
marginBlockEnd: {
|
|
406
|
+
type: [
|
|
407
|
+
Boolean,
|
|
408
|
+
Number,
|
|
409
|
+
String
|
|
410
|
+
],
|
|
411
|
+
required: false
|
|
412
|
+
},
|
|
413
|
+
border: {
|
|
414
|
+
type: [
|
|
415
|
+
Boolean,
|
|
416
|
+
Number,
|
|
417
|
+
String,
|
|
418
|
+
Array
|
|
419
|
+
],
|
|
420
|
+
required: false,
|
|
421
|
+
skipCheck: true
|
|
422
|
+
},
|
|
423
|
+
borderTop: {
|
|
424
|
+
type: [
|
|
425
|
+
Boolean,
|
|
426
|
+
Number,
|
|
427
|
+
String
|
|
428
|
+
],
|
|
429
|
+
required: false
|
|
430
|
+
},
|
|
431
|
+
borderLeft: {
|
|
432
|
+
type: [
|
|
433
|
+
Boolean,
|
|
434
|
+
Number,
|
|
435
|
+
String
|
|
436
|
+
],
|
|
437
|
+
required: false
|
|
438
|
+
},
|
|
439
|
+
borderBottom: {
|
|
440
|
+
type: [
|
|
441
|
+
Boolean,
|
|
442
|
+
Number,
|
|
443
|
+
String
|
|
444
|
+
],
|
|
445
|
+
required: false
|
|
446
|
+
},
|
|
447
|
+
borderRight: {
|
|
448
|
+
type: [
|
|
449
|
+
Boolean,
|
|
450
|
+
Number,
|
|
451
|
+
String
|
|
452
|
+
],
|
|
453
|
+
required: false
|
|
454
|
+
},
|
|
455
|
+
borderBlock: {
|
|
456
|
+
type: [
|
|
457
|
+
Boolean,
|
|
458
|
+
Number,
|
|
459
|
+
String
|
|
460
|
+
],
|
|
461
|
+
required: false
|
|
462
|
+
},
|
|
463
|
+
borderInline: {
|
|
464
|
+
type: [
|
|
465
|
+
Boolean,
|
|
466
|
+
Number,
|
|
467
|
+
String
|
|
468
|
+
],
|
|
469
|
+
required: false
|
|
470
|
+
},
|
|
471
|
+
borderInlineStart: {
|
|
472
|
+
type: [
|
|
473
|
+
Boolean,
|
|
474
|
+
Number,
|
|
475
|
+
String
|
|
476
|
+
],
|
|
477
|
+
required: false
|
|
478
|
+
},
|
|
479
|
+
borderInlineEnd: {
|
|
480
|
+
type: [
|
|
481
|
+
Boolean,
|
|
482
|
+
Number,
|
|
483
|
+
String
|
|
484
|
+
],
|
|
485
|
+
required: false
|
|
486
|
+
},
|
|
487
|
+
borderBlockStart: {
|
|
488
|
+
type: [
|
|
489
|
+
Boolean,
|
|
490
|
+
Number,
|
|
491
|
+
String
|
|
492
|
+
],
|
|
493
|
+
required: false
|
|
494
|
+
},
|
|
495
|
+
borderBlockEnd: {
|
|
496
|
+
type: [
|
|
497
|
+
Boolean,
|
|
498
|
+
Number,
|
|
499
|
+
String
|
|
500
|
+
],
|
|
501
|
+
required: false
|
|
502
|
+
},
|
|
503
|
+
borderColor: {
|
|
504
|
+
type: String,
|
|
505
|
+
required: false
|
|
506
|
+
},
|
|
507
|
+
borderStyle: {
|
|
508
|
+
type: String,
|
|
509
|
+
required: false
|
|
510
|
+
},
|
|
511
|
+
borderTopColor: {
|
|
512
|
+
type: [
|
|
513
|
+
String,
|
|
514
|
+
Object,
|
|
515
|
+
Boolean,
|
|
516
|
+
null
|
|
517
|
+
],
|
|
518
|
+
required: false,
|
|
519
|
+
skipCheck: true
|
|
520
|
+
},
|
|
521
|
+
borderRightColor: {
|
|
522
|
+
type: [
|
|
523
|
+
String,
|
|
524
|
+
Object,
|
|
525
|
+
Boolean,
|
|
526
|
+
null
|
|
527
|
+
],
|
|
528
|
+
required: false,
|
|
529
|
+
skipCheck: true
|
|
530
|
+
},
|
|
531
|
+
borderBottomColor: {
|
|
532
|
+
type: [
|
|
533
|
+
String,
|
|
534
|
+
Object,
|
|
535
|
+
Boolean,
|
|
536
|
+
null
|
|
537
|
+
],
|
|
538
|
+
required: false,
|
|
539
|
+
skipCheck: true
|
|
540
|
+
},
|
|
541
|
+
borderLeftColor: {
|
|
542
|
+
type: [
|
|
543
|
+
String,
|
|
544
|
+
Object,
|
|
545
|
+
Boolean,
|
|
546
|
+
null
|
|
547
|
+
],
|
|
548
|
+
required: false,
|
|
549
|
+
skipCheck: true
|
|
550
|
+
},
|
|
551
|
+
borderInlineStartColor: {
|
|
552
|
+
type: [
|
|
553
|
+
String,
|
|
554
|
+
Object,
|
|
555
|
+
Boolean,
|
|
556
|
+
null
|
|
557
|
+
],
|
|
558
|
+
required: false,
|
|
559
|
+
skipCheck: true
|
|
560
|
+
},
|
|
561
|
+
borderInlineEndColor: {
|
|
562
|
+
type: [
|
|
563
|
+
String,
|
|
564
|
+
Object,
|
|
565
|
+
Boolean,
|
|
566
|
+
null
|
|
567
|
+
],
|
|
568
|
+
required: false,
|
|
569
|
+
skipCheck: true
|
|
570
|
+
},
|
|
571
|
+
borderBlockStartColor: {
|
|
572
|
+
type: [
|
|
573
|
+
String,
|
|
574
|
+
Object,
|
|
575
|
+
Boolean,
|
|
576
|
+
null
|
|
577
|
+
],
|
|
578
|
+
required: false,
|
|
579
|
+
skipCheck: true
|
|
580
|
+
},
|
|
581
|
+
borderBlockEndColor: {
|
|
582
|
+
type: [
|
|
583
|
+
String,
|
|
584
|
+
Object,
|
|
585
|
+
Boolean,
|
|
586
|
+
null
|
|
587
|
+
],
|
|
588
|
+
required: false,
|
|
589
|
+
skipCheck: true
|
|
590
|
+
},
|
|
591
|
+
rounded: {
|
|
592
|
+
type: [
|
|
593
|
+
Boolean,
|
|
594
|
+
Number,
|
|
595
|
+
String,
|
|
596
|
+
null
|
|
597
|
+
],
|
|
598
|
+
required: false,
|
|
599
|
+
skipCheck: true
|
|
600
|
+
},
|
|
601
|
+
roundedTopRight: {
|
|
602
|
+
type: [
|
|
603
|
+
Boolean,
|
|
604
|
+
Number,
|
|
605
|
+
String
|
|
606
|
+
],
|
|
607
|
+
required: false
|
|
608
|
+
},
|
|
609
|
+
roundedTopLeft: {
|
|
610
|
+
type: [
|
|
611
|
+
Boolean,
|
|
612
|
+
Number,
|
|
613
|
+
String
|
|
614
|
+
],
|
|
615
|
+
required: false
|
|
616
|
+
},
|
|
617
|
+
roundedBottomLeft: {
|
|
618
|
+
type: [
|
|
619
|
+
Boolean,
|
|
620
|
+
Number,
|
|
621
|
+
String
|
|
622
|
+
],
|
|
623
|
+
required: false
|
|
624
|
+
},
|
|
625
|
+
roundedBottomRight: {
|
|
626
|
+
type: [
|
|
627
|
+
Boolean,
|
|
628
|
+
Number,
|
|
629
|
+
String
|
|
630
|
+
],
|
|
631
|
+
required: false
|
|
632
|
+
},
|
|
633
|
+
roundedStartStart: {
|
|
634
|
+
type: [
|
|
635
|
+
Boolean,
|
|
636
|
+
Number,
|
|
637
|
+
String
|
|
638
|
+
],
|
|
639
|
+
required: false
|
|
640
|
+
},
|
|
641
|
+
roundedStartEnd: {
|
|
642
|
+
type: [
|
|
643
|
+
Boolean,
|
|
644
|
+
Number,
|
|
645
|
+
String
|
|
646
|
+
],
|
|
647
|
+
required: false
|
|
648
|
+
},
|
|
649
|
+
roundedEndStart: {
|
|
650
|
+
type: [
|
|
651
|
+
Boolean,
|
|
652
|
+
Number,
|
|
653
|
+
String
|
|
654
|
+
],
|
|
655
|
+
required: false
|
|
656
|
+
},
|
|
657
|
+
roundedEndEnd: {
|
|
658
|
+
type: [
|
|
659
|
+
Boolean,
|
|
660
|
+
Number,
|
|
661
|
+
String
|
|
662
|
+
],
|
|
663
|
+
required: false
|
|
664
|
+
},
|
|
665
|
+
transition: {
|
|
666
|
+
type: [
|
|
667
|
+
Boolean,
|
|
668
|
+
String,
|
|
669
|
+
Object
|
|
670
|
+
],
|
|
671
|
+
required: false
|
|
672
|
+
},
|
|
673
|
+
eager: {
|
|
674
|
+
type: Boolean,
|
|
675
|
+
required: false
|
|
676
|
+
}
|
|
194
677
|
});
|
|
195
|
-
const emits = defineEmits([
|
|
678
|
+
const emits = defineEmits([
|
|
679
|
+
"loadstart",
|
|
680
|
+
"load",
|
|
681
|
+
"error"
|
|
682
|
+
]);
|
|
196
683
|
defineSlots();
|
|
197
684
|
const { filterProps } = useProps(props);
|
|
685
|
+
// Phase 3 (Vague D) — class-first companion alongside inline styles.
|
|
686
|
+
/*********************************************************
|
|
687
|
+
* Color
|
|
688
|
+
********************************************************/
|
|
198
689
|
const { colorClasses, colorStyles } = useBothColor(toRef(props, "bgColor"), toRef(props, "color"));
|
|
690
|
+
/*********************************************************
|
|
691
|
+
* Composables
|
|
692
|
+
********************************************************/
|
|
199
693
|
const { roundedClasses, roundedStyles } = useRounded(props);
|
|
200
694
|
const { borderClasses, borderStyles } = useBorder(props);
|
|
201
695
|
const { paddingClasses, paddingStyles } = usePadding(props);
|
|
@@ -204,202 +698,349 @@ const slots = useSlots();
|
|
|
204
698
|
const vm = getCurrentInstance("OrigamImg");
|
|
205
699
|
const currentSrc = shallowRef("");
|
|
206
700
|
const image = ref();
|
|
701
|
+
/*********************************************************
|
|
702
|
+
* state — ADR-005, no eager read of `props.eager` (#653 family)
|
|
703
|
+
*
|
|
704
|
+
* @description
|
|
705
|
+
* The seed used to be `shallowRef(props.eager ? LOADING : IDLE)` —
|
|
706
|
+
* an eager read of `props.eager` in the body of `setup()`, taken
|
|
707
|
+
* BEFORE the theme-props-resolver's `beforeCreate` hook patches
|
|
708
|
+
* `instance.props`. Always seeding `IDLE` is behaviour-preserving:
|
|
709
|
+
* `init()` (called from `onBeforeMount`, which runs AFTER
|
|
710
|
+
* `beforeCreate`) unconditionally overwrites `state` to `LOADING`
|
|
711
|
+
* whenever the resolved `props.eager` is true — the only path
|
|
712
|
+
* where the seed's value would otherwise have mattered.
|
|
713
|
+
********************************************************/
|
|
207
714
|
const state = shallowRef(IMG_STATE.IDLE);
|
|
208
715
|
const naturalWidth = shallowRef();
|
|
209
716
|
const naturalHeight = shallowRef();
|
|
210
717
|
const normalisedSrc = computed(() => {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
718
|
+
return props.src && typeof props.src === "object" ? {
|
|
719
|
+
src: props.src.src,
|
|
720
|
+
srcset: props.srcset || props.src.srcset,
|
|
721
|
+
lazySrc: props.lazySrc || props.src.lazySrc,
|
|
722
|
+
aspectRatio: Number(props.aspectRatio || props.src.aspectRatio || 0)
|
|
723
|
+
} : {
|
|
724
|
+
src: props.src,
|
|
725
|
+
srcset: props.srcset,
|
|
726
|
+
lazySrc: props.lazySrc,
|
|
727
|
+
aspectRatio: Number(props.aspectRatio || 0)
|
|
728
|
+
};
|
|
222
729
|
});
|
|
223
730
|
const aspectRatio = computed(() => {
|
|
224
|
-
|
|
731
|
+
return normalisedSrc.value.aspectRatio || naturalWidth.value / naturalHeight.value || 0;
|
|
225
732
|
});
|
|
226
|
-
|
|
733
|
+
/*********************************************************
|
|
734
|
+
* responsiveProps — computed instead of a setup-time pick() (#684)
|
|
735
|
+
*
|
|
736
|
+
* @description
|
|
737
|
+
* Was a plain `pick(props, [...])` call in the body of `setup()`,
|
|
738
|
+
* evaluated ONCE and frozen forever: `v-bind="responsiveProps"`
|
|
739
|
+
* (template) then diffused that stale snapshot for the component's
|
|
740
|
+
* whole lifetime — none of the 10 listed props (aspectRatio,
|
|
741
|
+
* contentClass, height, maxHeight, maxWidth, minHeight, minWidth,
|
|
742
|
+
* width, class, style) ever reacted to a post-mount change.
|
|
743
|
+
* @description
|
|
744
|
+
* Wrapped in `computed()` so every read happens at access time, the
|
|
745
|
+
* same fix shape as `intersect` below (ADR-005) — the initial render
|
|
746
|
+
* was already correct, which is what made this a C3 (works once,
|
|
747
|
+
* freezes at usage) rather than a C1.
|
|
748
|
+
********************************************************/
|
|
749
|
+
const responsiveProps = computed(() => pick(props, [
|
|
750
|
+
"tag",
|
|
751
|
+
"aspectRatio",
|
|
752
|
+
"contentClass",
|
|
753
|
+
"height",
|
|
754
|
+
"maxHeight",
|
|
755
|
+
"maxWidth",
|
|
756
|
+
"minHeight",
|
|
757
|
+
"minWidth",
|
|
758
|
+
"width",
|
|
759
|
+
"class",
|
|
760
|
+
"style"
|
|
761
|
+
]));
|
|
227
762
|
watch(() => props.src, () => {
|
|
228
|
-
|
|
763
|
+
init(state.value !== IMG_STATE.IDLE);
|
|
229
764
|
});
|
|
230
765
|
watch(aspectRatio, (val, oldVal) => {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
766
|
+
if (!val && oldVal && image.value) {
|
|
767
|
+
pollForSize(image.value);
|
|
768
|
+
}
|
|
234
769
|
});
|
|
235
770
|
onBeforeMount(() => init());
|
|
236
771
|
const init = (isIntersecting) => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
772
|
+
if (props.eager && isIntersecting) return;
|
|
773
|
+
if (SUPPORTS_INTERSECTION && !isIntersecting && !props.eager) return;
|
|
774
|
+
state.value = IMG_STATE.LOADING;
|
|
775
|
+
if (normalisedSrc.value.lazySrc) {
|
|
776
|
+
const lazyImg = new Image();
|
|
777
|
+
lazyImg.src = normalisedSrc.value.lazySrc;
|
|
778
|
+
pollForSize(lazyImg, null);
|
|
779
|
+
}
|
|
780
|
+
if (!normalisedSrc.value.src) return;
|
|
781
|
+
nextTick(() => {
|
|
782
|
+
emits("loadstart", { src: image.value?.currentSrc || normalisedSrc.value.src || "" });
|
|
783
|
+
setTimeout(() => {
|
|
784
|
+
if (vm.isUnmounted) return;
|
|
785
|
+
if (image.value?.complete) {
|
|
786
|
+
if (!image.value.naturalWidth) {
|
|
787
|
+
onError();
|
|
788
|
+
}
|
|
789
|
+
if (state.value === IMG_STATE.ERROR) return;
|
|
790
|
+
if (!aspectRatio.value) pollForSize(image.value, null);
|
|
791
|
+
if (state.value === IMG_STATE.LOADING) onLoad();
|
|
792
|
+
} else {
|
|
793
|
+
if (!aspectRatio.value) pollForSize(image.value);
|
|
794
|
+
getSrc();
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
});
|
|
263
798
|
};
|
|
264
799
|
const onLoad = () => {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
800
|
+
if (vm.isUnmounted) return;
|
|
801
|
+
getSrc();
|
|
802
|
+
pollForSize(image.value);
|
|
803
|
+
state.value = "loaded";
|
|
804
|
+
emits("load", { src: image.value?.currentSrc || normalisedSrc.value.src || "" });
|
|
270
805
|
};
|
|
806
|
+
/*********************************************************
|
|
807
|
+
* Event handlers
|
|
808
|
+
********************************************************/
|
|
271
809
|
const handleLoad = () => {
|
|
272
|
-
|
|
810
|
+
onLoad();
|
|
273
811
|
};
|
|
274
812
|
const onError = () => {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
813
|
+
if (vm.isUnmounted) return;
|
|
814
|
+
state.value = "error";
|
|
815
|
+
emits("error", { src: image.value?.currentSrc || normalisedSrc.value.src || "" });
|
|
278
816
|
};
|
|
279
817
|
const handleError = () => {
|
|
280
|
-
|
|
818
|
+
onError();
|
|
281
819
|
};
|
|
282
820
|
const getSrc = () => {
|
|
283
|
-
|
|
284
|
-
|
|
821
|
+
const img = image.value;
|
|
822
|
+
if (img) currentSrc.value = img.currentSrc || img.src;
|
|
285
823
|
};
|
|
286
824
|
let timer = -1;
|
|
287
|
-
|
|
825
|
+
/*********************************************************
|
|
826
|
+
* bootFrames — les deux rAF imbriques de `markBooted` (#779)
|
|
827
|
+
*
|
|
828
|
+
* @description
|
|
829
|
+
* Le `clearTimeout(timer)` ci-dessous couvre `pollForSize`, et lui
|
|
830
|
+
* seul. Les deux `requestAnimationFrame` de `markBooted` n'ont jamais
|
|
831
|
+
* capture leur handle : c'est exactement le site qu'une heuristique
|
|
832
|
+
* PAR FICHIER blanchit, puisque le fichier porte bien un
|
|
833
|
+
* `onBeforeUnmount` — pose pour autre chose.
|
|
834
|
+
*
|
|
835
|
+
* @description
|
|
836
|
+
* Les deux rungs sont suivis, pas seulement le dernier : le rung
|
|
837
|
+
* externe arme le rung interne, donc annuler un seul handle laisse
|
|
838
|
+
* l'autre en vol selon l'instant du demontage.
|
|
839
|
+
********************************************************/
|
|
840
|
+
const bootFrames = new Set();
|
|
288
841
|
onBeforeUnmount(() => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
842
|
+
clearTimeout(timer);
|
|
843
|
+
for (const id of bootFrames) cancelAnimationFrame(id);
|
|
844
|
+
bootFrames.clear();
|
|
292
845
|
});
|
|
293
846
|
const pollForSize = (img, timeout = 100) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
847
|
+
const poll = () => {
|
|
848
|
+
clearTimeout(timer);
|
|
849
|
+
if (vm.isUnmounted) return;
|
|
850
|
+
const { naturalHeight: imgHeight, naturalWidth: imgWidth } = img;
|
|
851
|
+
if (imgHeight || imgWidth) {
|
|
852
|
+
naturalWidth.value = imgWidth;
|
|
853
|
+
naturalHeight.value = imgHeight;
|
|
854
|
+
} else if (!img.complete && state.value === IMG_STATE.LOADING && timeout != null) {
|
|
855
|
+
timer = window.setTimeout(poll, timeout);
|
|
856
|
+
} else if (img.currentSrc.endsWith(".svg") || img.currentSrc.startsWith("data:image/svg+xml")) {
|
|
857
|
+
naturalWidth.value = 1;
|
|
858
|
+
naturalHeight.value = 1;
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
poll();
|
|
309
862
|
};
|
|
310
863
|
const isBooted = shallowRef(false);
|
|
864
|
+
// When the consumer already passes an explicit `aspect-ratio` (e.g.
|
|
865
|
+
// OrigamAvatar binds `aspectRatio: 1`), the computed starts truthy
|
|
866
|
+
// on mount. Vue's default watch semantic (fire-on-change only)
|
|
867
|
+
// missed the initial value → isBooted stayed false forever →
|
|
868
|
+
// `origam-img--booting` class kept the image hidden behind its
|
|
869
|
+
// placeholder.
|
|
870
|
+
//
|
|
871
|
+
// We can't simply pass `{ immediate: true }` because the watcher
|
|
872
|
+
// body calls `stop()` — referenced via the same `const`, which
|
|
873
|
+
// triggers a TDZ error when `immediate` fires the watcher before
|
|
874
|
+
// the assignment completes. Wrap stop() in a guard instead.
|
|
311
875
|
let stop = null;
|
|
312
876
|
const markBooted = (val) => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
877
|
+
if (val) {
|
|
878
|
+
// `requestAnimationFrame` is browser-only. When `aspectRatio` is
|
|
879
|
+
// already truthy at setup (consumer passed an explicit
|
|
880
|
+
// `aspect-ratio`, e.g. a fixed logo), this runs during SSR and
|
|
881
|
+
// crashes Node with "requestAnimationFrame is not defined". Guard
|
|
882
|
+
// it: on the server `isBooted` stays false (the `--booting` class
|
|
883
|
+
// is rendered), which matches the client's initial hydration
|
|
884
|
+
// render — the rAF then flips it post-hydration with no mismatch.
|
|
885
|
+
if (IN_BROWSER) {
|
|
886
|
+
// Doesn't work with nextTick, idk why
|
|
887
|
+
const outer = requestAnimationFrame(() => {
|
|
888
|
+
bootFrames.delete(outer);
|
|
889
|
+
const inner = requestAnimationFrame(() => {
|
|
890
|
+
bootFrames.delete(inner);
|
|
891
|
+
isBooted.value = true;
|
|
892
|
+
});
|
|
893
|
+
bootFrames.add(inner);
|
|
894
|
+
});
|
|
895
|
+
bootFrames.add(outer);
|
|
896
|
+
}
|
|
897
|
+
stop?.();
|
|
898
|
+
}
|
|
327
899
|
};
|
|
328
900
|
stop = watch(aspectRatio, markBooted);
|
|
901
|
+
// Cover the case where aspectRatio is ALREADY truthy on mount.
|
|
329
902
|
markBooted(aspectRatio.value);
|
|
903
|
+
/*********************************************************
|
|
904
|
+
* intersect — ADR-005, computed instead of a setup-time ref
|
|
905
|
+
*
|
|
906
|
+
* @description
|
|
907
|
+
* A plain `ref([{ handler, options: props.options }, ...])` reads
|
|
908
|
+
* `props.options` once, eagerly, in the body of `setup()` — a
|
|
909
|
+
* theme naming `options` on `origam-img` never reached the
|
|
910
|
+
* directive. `computed` defers the read to access time (render),
|
|
911
|
+
* comfortably after the theme-props-resolver's `beforeCreate`.
|
|
912
|
+
*
|
|
913
|
+
* @description
|
|
914
|
+
* #1192 — the directive's binding VALUE is `{ handler, options }` and
|
|
915
|
+
* `once` is a MODIFIER (`v-intersect.once`). This used to bind the
|
|
916
|
+
* `withDirectives` tuple `[{ handler, options }, null, ['once']]` as the
|
|
917
|
+
* value: the directive read `.handler` / `.options` off an array, got
|
|
918
|
+
* `undefined`, and `init` was never called by an intersection. A visible
|
|
919
|
+
* image only worked through the native `load` event; a `display:none`
|
|
920
|
+
* (client-mounted, fading in) one never started.
|
|
921
|
+
********************************************************/
|
|
330
922
|
const intersect = computed(() => ({
|
|
331
|
-
|
|
332
|
-
|
|
923
|
+
handler: init,
|
|
924
|
+
options: props.options
|
|
333
925
|
}));
|
|
926
|
+
/*********************************************************
|
|
927
|
+
* nativeLoading — native `loading` attribute (CSS/HTML-first)
|
|
928
|
+
*
|
|
929
|
+
* @description
|
|
930
|
+
* Complements the custom `IntersectionObserver`-driven state
|
|
931
|
+
* machine (which also feeds the placeholder/error slots and the
|
|
932
|
+
* `load`/`error` emits) with the browser's own lazy-loading
|
|
933
|
+
* primitive. Read lazily via a computed, so a theme-provided
|
|
934
|
+
* `eager` reaches it (ADR-005).
|
|
935
|
+
*
|
|
936
|
+
* @description
|
|
937
|
+
* #1192 — `lazy` only while `IDLE`. A client-mounted image is
|
|
938
|
+
* `display:none` (`v-show`) until its `load`; Chromium never loads a
|
|
939
|
+
* `loading="lazy"` image that has no box, so that image waited for a
|
|
940
|
+
* load that nothing would start. Once the IntersectionObserver has
|
|
941
|
+
* fired (`state` left `IDLE`) the component has itself decided the
|
|
942
|
+
* image is due, so the native attribute must not veto it. A hydrated
|
|
943
|
+
* image is unaffected: it starts `IDLE` (`lazy`, as served) and is
|
|
944
|
+
* visible, so native lazy keeps gating it.
|
|
945
|
+
********************************************************/
|
|
334
946
|
const nativeLoading = computed(() => props.eager || state.value !== IMG_STATE.IDLE ? "eager" : "lazy");
|
|
947
|
+
/*********************************************************
|
|
948
|
+
* State
|
|
949
|
+
*
|
|
950
|
+
* @description
|
|
951
|
+
* Computed booleans derived from the image load state machine.
|
|
952
|
+
********************************************************/
|
|
335
953
|
const isLoaded = computed(() => {
|
|
336
|
-
|
|
954
|
+
return state.value === IMG_STATE.LOADED;
|
|
337
955
|
});
|
|
338
956
|
const isLoading = computed(() => {
|
|
339
|
-
|
|
957
|
+
return state.value === IMG_STATE.LOADING;
|
|
340
958
|
});
|
|
341
959
|
const isError = computed(() => {
|
|
342
|
-
|
|
960
|
+
return state.value === IMG_STATE.ERROR;
|
|
343
961
|
});
|
|
962
|
+
/*********************************************************
|
|
963
|
+
* fadesIn — client-mounted vs server-rendered (#1182)
|
|
964
|
+
*
|
|
965
|
+
* @description
|
|
966
|
+
* An image hydrated from server HTML must paint at once and never
|
|
967
|
+
* flash: it is shown unless it errored, and its transition does not
|
|
968
|
+
* `appear` (an `appear` transition applies its enter-from classes
|
|
969
|
+
* during hydration). An image mounted on the client (SPA navigation,
|
|
970
|
+
* dynamic list, `v-if` after hydration) keeps the former behaviour:
|
|
971
|
+
* hidden until the native `load`, then faded in by `transition`.
|
|
972
|
+
*
|
|
973
|
+
* @description
|
|
974
|
+
* During hydration Vue sets `vnode.el` to the existing server node
|
|
975
|
+
* BEFORE `setup()` runs; on a fresh client mount it is still null. On
|
|
976
|
+
* the server `IN_BROWSER` is false, so the `<img>` is always served
|
|
977
|
+
* visible. Read once, at setup, on purpose: it describes how this
|
|
978
|
+
* instance came to exist, and never changes.
|
|
979
|
+
********************************************************/
|
|
344
980
|
const fadesIn = IN_BROWSER && !vm.vnode.el;
|
|
345
981
|
const isPictureShown = computed(() => {
|
|
346
|
-
|
|
982
|
+
return fadesIn ? isLoaded.value : !isError.value;
|
|
347
983
|
});
|
|
348
984
|
const hasContent = computed(() => {
|
|
349
|
-
|
|
985
|
+
return slots.default;
|
|
350
986
|
});
|
|
987
|
+
/*********************************************************
|
|
988
|
+
* Class & Style
|
|
989
|
+
*
|
|
990
|
+
* @description
|
|
991
|
+
* Composable-driven class and style composition.
|
|
992
|
+
********************************************************/
|
|
351
993
|
const imgStyles = computed(() => {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
994
|
+
return [
|
|
995
|
+
{ "width": convertToUnit(props.width === "auto" ? naturalWidth.value : props.width) },
|
|
996
|
+
colorStyles.value,
|
|
997
|
+
roundedStyles.value,
|
|
998
|
+
borderStyles.value,
|
|
999
|
+
paddingStyles.value,
|
|
1000
|
+
marginStyles.value,
|
|
1001
|
+
props.style
|
|
1002
|
+
];
|
|
361
1003
|
});
|
|
362
1004
|
const imgClasses = computed(() => {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
1005
|
+
return [
|
|
1006
|
+
"origam-img",
|
|
1007
|
+
{ "origam-img--booting": !isBooted.value },
|
|
1008
|
+
colorClasses.value,
|
|
1009
|
+
roundedClasses.value,
|
|
1010
|
+
borderClasses.value,
|
|
1011
|
+
paddingClasses.value,
|
|
1012
|
+
marginClasses.value,
|
|
1013
|
+
props.class
|
|
1014
|
+
];
|
|
373
1015
|
});
|
|
374
1016
|
const imgPictureClasses = computed(() => {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
"origam-img__picture--preload": normalisedSrc.value.lazySrc && !isLoaded.value
|
|
381
|
-
}
|
|
382
|
-
];
|
|
1017
|
+
return ["origam-img__picture", {
|
|
1018
|
+
"origam-img__picture--cover": props.cover,
|
|
1019
|
+
"origam-img__picture--contain": !props.cover,
|
|
1020
|
+
"origam-img__picture--preload": normalisedSrc.value.lazySrc && !isLoaded.value
|
|
1021
|
+
}];
|
|
383
1022
|
});
|
|
384
1023
|
const imgContentStyles = computed(() => {
|
|
385
|
-
|
|
386
|
-
{ objectPosition: props.position }
|
|
387
|
-
];
|
|
1024
|
+
return [{ objectPosition: props.position }];
|
|
388
1025
|
});
|
|
389
1026
|
const imgGradientStyles = computed(() => {
|
|
390
|
-
|
|
391
|
-
`backgroundImage: linear-gradient(${props.gradient})`
|
|
392
|
-
];
|
|
1027
|
+
return [`backgroundImage: linear-gradient(${props.gradient})`];
|
|
393
1028
|
});
|
|
394
1029
|
const { id, css, load, isLoaded: styleIsLoaded, unload } = useStyle(imgStyles, () => props.id);
|
|
1030
|
+
/*********************************************************
|
|
1031
|
+
* Expose
|
|
1032
|
+
*
|
|
1033
|
+
* @description
|
|
1034
|
+
* Forwards filterProps to parent components.
|
|
1035
|
+
********************************************************/
|
|
395
1036
|
defineExpose({
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
1037
|
+
filterProps,
|
|
1038
|
+
css,
|
|
1039
|
+
id,
|
|
1040
|
+
load,
|
|
1041
|
+
unload,
|
|
1042
|
+
isLoaded,
|
|
1043
|
+
styleIsLoaded
|
|
403
1044
|
});
|
|
404
1045
|
</script>
|
|
405
1046
|
|