tide-design-system 2.5.13 → 2.5.14
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/dist/tide-design-system.d.ts +2742 -0
- package/dist/tide-design-system.js +2 -2
- package/package.json +13 -2
- package/.eslintrc.cjs +0 -119
- package/.github/workflows/publish-release.yml +0 -38
- package/.storybook/main.ts +0 -70
- package/.storybook/preview.ts +0 -256
- package/docs/assets/full-bleed.gif +0 -0
- package/docs/assets/layout-grid-default.webp +0 -0
- package/docs/assets/layout-grid-fluid.webp +0 -0
- package/docs/assets/layout-grid.webp +0 -0
- package/docs/assets/native-input-validation.png +0 -0
- package/docs/configuation.md +0 -47
- package/docs/development.md +0 -163
- package/docs/figma.md +0 -43
- package/docs/forms.md +0 -484
- package/docs/grid-layout.md +0 -83
- package/docs/images.md +0 -50
- package/docs/integration-full.md +0 -84
- package/docs/integration-partial.md +0 -39
- package/docs/migration.md +0 -74
- package/docs/storybook.md +0 -44
- package/docs/style-guide.md +0 -22
- package/docs/toast.md +0 -61
- package/docs/token-cheatsheet.md +0 -63
- package/docs/upgrading.md +0 -188
- package/docs/workflows.md +0 -20
- package/index.html +0 -14
- package/index.ts +0 -201
- package/netlify.toml +0 -3
- package/src/assets/css/fonts.css +0 -36
- package/src/assets/css/grid-layout.css +0 -34
- package/src/assets/css/main.css +0 -5
- package/src/assets/css/realm/aero.css +0 -25
- package/src/assets/css/realm/atv.css +0 -25
- package/src/assets/css/realm/boatmart.css +0 -25
- package/src/assets/css/realm/cycle.css +0 -24
- package/src/assets/css/realm/equipment.css +0 -25
- package/src/assets/css/realm/pwc.css +0 -25
- package/src/assets/css/realm/rv.css +0 -25
- package/src/assets/css/realm/snow.css +0 -25
- package/src/assets/css/realm/truck.css +0 -25
- package/src/assets/css/reset.css +0 -99
- package/src/assets/css/storybook.css +0 -18
- package/src/assets/css/utilities-base.css +0 -574
- package/src/assets/css/utilities-responsive.css +0 -2307
- package/src/assets/css/utilities.css +0 -16
- package/src/assets/css/variables.css +0 -223
- package/src/assets/svg/branding/logo/logo-aero.svg +0 -4
- package/src/assets/svg/branding/logo/logo-atv.svg +0 -6
- package/src/assets/svg/branding/logo/logo-boatmart.svg +0 -4
- package/src/assets/svg/branding/logo/logo-cycle.svg +0 -4
- package/src/assets/svg/branding/logo/logo-equipment.svg +0 -4
- package/src/assets/svg/branding/logo/logo-pwc.svg +0 -4
- package/src/assets/svg/branding/logo/logo-rv.svg +0 -6
- package/src/assets/svg/branding/logo/logo-snow.svg +0 -4
- package/src/assets/svg/branding/logo/logo-truck.svg +0 -5
- package/src/assets/svg/branding/mark/mark-aero.svg +0 -3
- package/src/assets/svg/branding/mark/mark-atv.svg +0 -4
- package/src/assets/svg/branding/mark/mark-boatmart.svg +0 -3
- package/src/assets/svg/branding/mark/mark-cycle.svg +0 -3
- package/src/assets/svg/branding/mark/mark-equipment.svg +0 -3
- package/src/assets/svg/branding/mark/mark-pwc.svg +0 -3
- package/src/assets/svg/branding/mark/mark-rv.svg +0 -4
- package/src/assets/svg/branding/mark/mark-snow.svg +0 -3
- package/src/assets/svg/branding/mark/mark-truck.svg +0 -4
- package/src/assets/svg/icons/IconAccountBalance.svg +0 -5
- package/src/assets/svg/icons/IconAcute.svg +0 -3
- package/src/assets/svg/icons/IconAdd.svg +0 -3
- package/src/assets/svg/icons/IconAiDescription.svg +0 -7
- package/src/assets/svg/icons/IconAlignSpaceEven.svg +0 -3
- package/src/assets/svg/icons/IconApplePay.svg +0 -5
- package/src/assets/svg/icons/IconArrowBack.svg +0 -3
- package/src/assets/svg/icons/IconArrowCycle.svg +0 -5
- package/src/assets/svg/icons/IconArrowForward.svg +0 -3
- package/src/assets/svg/icons/IconArrowRight.svg +0 -3
- package/src/assets/svg/icons/IconArrowUp.svg +0 -3
- package/src/assets/svg/icons/IconAssignment.svg +0 -3
- package/src/assets/svg/icons/IconAttachMoney.svg +0 -4
- package/src/assets/svg/icons/IconAutoRenew.svg +0 -3
- package/src/assets/svg/icons/IconAwardStar.svg +0 -5
- package/src/assets/svg/icons/IconBed.svg +0 -3
- package/src/assets/svg/icons/IconBolt.svg +0 -3
- package/src/assets/svg/icons/IconBookmark.svg +0 -5
- package/src/assets/svg/icons/IconBunkhouse.svg +0 -3
- package/src/assets/svg/icons/IconCalculate.svg +0 -3
- package/src/assets/svg/icons/IconCalendarMonth.svg +0 -5
- package/src/assets/svg/icons/IconCall.svg +0 -5
- package/src/assets/svg/icons/IconCallQuality.svg +0 -3
- package/src/assets/svg/icons/IconCarRental.svg +0 -3
- package/src/assets/svg/icons/IconCheck.svg +0 -3
- package/src/assets/svg/icons/IconChevronLeft.svg +0 -3
- package/src/assets/svg/icons/IconChevronRight.svg +0 -3
- package/src/assets/svg/icons/IconClear.svg +0 -3
- package/src/assets/svg/icons/IconClose.svg +0 -3
- package/src/assets/svg/icons/IconContract.svg +0 -3
- package/src/assets/svg/icons/IconCrash.svg +0 -3
- package/src/assets/svg/icons/IconDashboardCustomize.svg +0 -3
- package/src/assets/svg/icons/IconDelete.svg +0 -5
- package/src/assets/svg/icons/IconDiamond.svg +0 -5
- package/src/assets/svg/icons/IconDirectionsBoat.svg +0 -3
- package/src/assets/svg/icons/IconDomain.svg +0 -3
- package/src/assets/svg/icons/IconDraft.svg +0 -3
- package/src/assets/svg/icons/IconEdit.svg +0 -5
- package/src/assets/svg/icons/IconEngine.svg +0 -3
- package/src/assets/svg/icons/IconEngineering.svg +0 -3
- package/src/assets/svg/icons/IconError.svg +0 -5
- package/src/assets/svg/icons/IconExpandContent.svg +0 -3
- package/src/assets/svg/icons/IconExpandLess.svg +0 -3
- package/src/assets/svg/icons/IconExpandMore.svg +0 -3
- package/src/assets/svg/icons/IconFacebook.svg +0 -3
- package/src/assets/svg/icons/IconFavorite.svg +0 -5
- package/src/assets/svg/icons/IconFavoriteFilled.svg +0 -5
- package/src/assets/svg/icons/IconFlag.svg +0 -3
- package/src/assets/svg/icons/IconFormatBold.svg +0 -5
- package/src/assets/svg/icons/IconFormatItalic.svg +0 -3
- package/src/assets/svg/icons/IconFormatListBulleted.svg +0 -5
- package/src/assets/svg/icons/IconForum.svg +0 -5
- package/src/assets/svg/icons/IconGas.svg +0 -3
- package/src/assets/svg/icons/IconGavel.svg +0 -5
- package/src/assets/svg/icons/IconGears.svg +0 -3
- package/src/assets/svg/icons/IconGlobeLocationPin.svg +0 -3
- package/src/assets/svg/icons/IconGoogle.svg +0 -18
- package/src/assets/svg/icons/IconGooglePay.svg +0 -5
- package/src/assets/svg/icons/IconGrid.svg +0 -3
- package/src/assets/svg/icons/IconHandshake.svg +0 -3
- package/src/assets/svg/icons/IconHandyman.svg +0 -3
- package/src/assets/svg/icons/IconHeight.svg +0 -3
- package/src/assets/svg/icons/IconHelp.svg +0 -5
- package/src/assets/svg/icons/IconInfo.svg +0 -5
- package/src/assets/svg/icons/IconInformation.svg +0 -3
- package/src/assets/svg/icons/IconInsertText.svg +0 -5
- package/src/assets/svg/icons/IconInstagram.svg +0 -3
- package/src/assets/svg/icons/IconIosShare.svg +0 -5
- package/src/assets/svg/icons/IconLayout.svg +0 -3
- package/src/assets/svg/icons/IconLevellingJack.svg +0 -3
- package/src/assets/svg/icons/IconLinkedIn.svg +0 -3
- package/src/assets/svg/icons/IconLocalShipping.svg +0 -5
- package/src/assets/svg/icons/IconLock.svg +0 -5
- package/src/assets/svg/icons/IconMail.svg +0 -5
- package/src/assets/svg/icons/IconMenu.svg +0 -3
- package/src/assets/svg/icons/IconMoneyBag.svg +0 -3
- package/src/assets/svg/icons/IconMoreHoriz.svg +0 -5
- package/src/assets/svg/icons/IconMove.svg +0 -3
- package/src/assets/svg/icons/IconNotifications.svg +0 -5
- package/src/assets/svg/icons/IconOdometer.svg +0 -3
- package/src/assets/svg/icons/IconOpenInNew.svg +0 -5
- package/src/assets/svg/icons/IconPalette.svg +0 -5
- package/src/assets/svg/icons/IconPaypal.svg +0 -5
- package/src/assets/svg/icons/IconPerson.svg +0 -5
- package/src/assets/svg/icons/IconPersonSearch.svg +0 -3
- package/src/assets/svg/icons/IconPhotoCamera.svg +0 -5
- package/src/assets/svg/icons/IconPinterest.svg +0 -5
- package/src/assets/svg/icons/IconPlayArrow.svg +0 -3
- package/src/assets/svg/icons/IconPolicy.svg +0 -3
- package/src/assets/svg/icons/IconPower.svg +0 -3
- package/src/assets/svg/icons/IconPowerOff.svg +0 -3
- package/src/assets/svg/icons/IconPriorityHigh.svg +0 -3
- package/src/assets/svg/icons/IconRemove.svg +0 -3
- package/src/assets/svg/icons/IconRequestQuote.svg +0 -3
- package/src/assets/svg/icons/IconResetWrench.svg +0 -3
- package/src/assets/svg/icons/IconRoad.svg +0 -3
- package/src/assets/svg/icons/IconRoundedCorner.svg +0 -5
- package/src/assets/svg/icons/IconRuler.svg +0 -3
- package/src/assets/svg/icons/IconSailing.svg +0 -3
- package/src/assets/svg/icons/IconSchool.svg +0 -3
- package/src/assets/svg/icons/IconSearch.svg +0 -5
- package/src/assets/svg/icons/IconSeating.svg +0 -3
- package/src/assets/svg/icons/IconSell.svg +0 -5
- package/src/assets/svg/icons/IconSensors.svg +0 -3
- package/src/assets/svg/icons/IconSettings.svg +0 -3
- package/src/assets/svg/icons/IconShare.svg +0 -5
- package/src/assets/svg/icons/IconShieldCheck.svg +0 -3
- package/src/assets/svg/icons/IconShoppingCart.svg +0 -5
- package/src/assets/svg/icons/IconSleeps.svg +0 -3
- package/src/assets/svg/icons/IconSms.svg +0 -5
- package/src/assets/svg/icons/IconSnowflake.svg +0 -3
- package/src/assets/svg/icons/IconStar.svg +0 -5
- package/src/assets/svg/icons/IconStarFilled.svg +0 -3
- package/src/assets/svg/icons/IconStarHalf.svg +0 -3
- package/src/assets/svg/icons/IconSummarize.svg +0 -3
- package/src/assets/svg/icons/IconSwapHoriz.svg +0 -3
- package/src/assets/svg/icons/IconSwapVert.svg +0 -5
- package/src/assets/svg/icons/IconThreeDRotation.svg +0 -18
- package/src/assets/svg/icons/IconThumbUp.svg +0 -3
- package/src/assets/svg/icons/IconTrendingDown.svg +0 -5
- package/src/assets/svg/icons/IconTrophy.svg +0 -5
- package/src/assets/svg/icons/IconTune.svg +0 -5
- package/src/assets/svg/icons/IconTwitter.svg +0 -5
- package/src/assets/svg/icons/IconUmbrella.svg +0 -3
- package/src/assets/svg/icons/IconVerified.svg +0 -4
- package/src/assets/svg/icons/IconVideocam.svg +0 -5
- package/src/assets/svg/icons/IconViewInAr.svg +0 -5
- package/src/assets/svg/icons/IconVisibility.svg +0 -5
- package/src/assets/svg/icons/IconVolumeOff.svg +0 -5
- package/src/assets/svg/icons/IconVolumeOn.svg +0 -5
- package/src/assets/svg/icons/IconWarehouse.svg +0 -3
- package/src/assets/svg/icons/IconWarning.svg +0 -5
- package/src/assets/svg/icons/IconWater.svg +0 -3
- package/src/assets/svg/icons/IconWeight.svg +0 -3
- package/src/assets/svg/icons/IconWidth.svg +0 -3
- package/src/assets/svg/icons/IconWorkspacePremium.svg +0 -3
- package/src/assets/svg/icons/IconWrench.svg +0 -3
- package/src/assets/svg/icons/IconYoutube.svg +0 -5
- package/src/assets/svg/icons/realm/aero/IconAeroFlight.svg +0 -3
- package/src/assets/svg/icons/realm/aero/IconAeroHelicopter.svg +0 -3
- package/src/assets/svg/icons/realm/aero/IconAeroModeFan.svg +0 -3
- package/src/assets/svg/icons/realm/aero/IconAeroPlaneContrails.svg +0 -3
- package/src/assets/svg/icons/realm/atv/IconAtvAtv.svg +0 -3
- package/src/assets/svg/icons/realm/atv/IconAtvDuneBuggy.svg +0 -3
- package/src/assets/svg/icons/realm/atv/IconAtvGoKart.svg +0 -3
- package/src/assets/svg/icons/realm/atv/IconAtvGolfCart.svg +0 -3
- package/src/assets/svg/icons/realm/atv/IconAtvSandRail.svg +0 -3
- package/src/assets/svg/icons/realm/atv/IconAtvSideBySide.svg +0 -3
- package/src/assets/svg/icons/realm/atv/IconAtvTrailer.svg +0 -3
- package/src/assets/svg/icons/realm/boatmart/IconBoatmartPwc.svg +0 -3
- package/src/assets/svg/icons/realm/boatmart/IconBoatmartTrailer.svg +0 -3
- package/src/assets/svg/icons/realm/cycle/IconCycleMotorcycle.svg +0 -4
- package/src/assets/svg/icons/realm/cycle/IconCycleTrailer.svg +0 -3
- package/src/assets/svg/icons/realm/pwc/IconPwcPwc.svg +0 -3
- package/src/assets/svg/icons/realm/pwc/IconPwcSnowmobile.svg +0 -3
- package/src/assets/svg/icons/realm/pwc/IconPwcTrailer.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvClassA.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvClassB.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvClassC.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvDestinationTrailer.svg +0 -5
- package/src/assets/svg/icons/realm/rv/IconRvFifthWheel.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvFishHouse.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvParkModel.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvPopUpCamper.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvTeardropTrailer.svg +0 -4
- package/src/assets/svg/icons/realm/rv/IconRvTravelTrailer.svg +0 -3
- package/src/assets/svg/icons/realm/rv/IconRvTruckCamper.svg +0 -3
- package/src/assets/svg/icons/realm/snow/IconSnowMotorcycle.svg +0 -4
- package/src/assets/svg/icons/realm/snow/IconSnowPwc.svg +0 -3
- package/src/assets/svg/icons/realm/snow/IconSnowSideBySide.svg +0 -3
- package/src/assets/svg/icons/realm/snow/IconSnowSnowmobile.svg +0 -3
- package/src/assets/svg/icons/realm/snow/IconSnowTrailer.svg +0 -3
- package/src/components/InternalBaseLink.vue +0 -11
- package/src/components/TideAccordionItem.vue +0 -120
- package/src/components/TideAlert.vue +0 -186
- package/src/components/TideBadge.vue +0 -64
- package/src/components/TideBadgeTrustedPartner.vue +0 -52
- package/src/components/TideBadgeVerifiedVehicle.vue +0 -46
- package/src/components/TideBreadCrumbs.vue +0 -62
- package/src/components/TideButton.vue +0 -115
- package/src/components/TideButtonIcon.vue +0 -91
- package/src/components/TideButtonPagination.vue +0 -87
- package/src/components/TideButtonSave.vue +0 -109
- package/src/components/TideButtonSegmented.vue +0 -115
- package/src/components/TideCard.vue +0 -107
- package/src/components/TideCarousel.vue +0 -489
- package/src/components/TideChipAction.vue +0 -83
- package/src/components/TideChipFilter.vue +0 -71
- package/src/components/TideChipInput.vue +0 -54
- package/src/components/TideColumns.vue +0 -65
- package/src/components/TideDivider.vue +0 -43
- package/src/components/TideForm.vue +0 -33
- package/src/components/TideIcon.vue +0 -85
- package/src/components/TideImage.vue +0 -126
- package/src/components/TideImageBackground.vue +0 -69
- package/src/components/TideIndicator.vue +0 -63
- package/src/components/TideInputCheckbox.vue +0 -210
- package/src/components/TideInputCheckboxDeprecated.vue +0 -117
- package/src/components/TideInputRadio.vue +0 -115
- package/src/components/TideInputRadioDeprecated.vue +0 -119
- package/src/components/TideInputSelect.vue +0 -331
- package/src/components/TideInputSelectDeprecated.vue +0 -245
- package/src/components/TideInputSupportingText.vue +0 -44
- package/src/components/TideInputText.vue +0 -382
- package/src/components/TideInputTextDeprecated.vue +0 -327
- package/src/components/TideInputTextarea.vue +0 -235
- package/src/components/TideInputTextareaDeprecated.vue +0 -198
- package/src/components/TideLink.vue +0 -95
- package/src/components/TideMenuItem.vue +0 -83
- package/src/components/TideModal.vue +0 -281
- package/src/components/TidePagination.vue +0 -65
- package/src/components/TidePopover.vue +0 -198
- package/src/components/TideRating.vue +0 -109
- package/src/components/TideRealmLogo.vue +0 -154
- package/src/components/TideSeoLinks.vue +0 -59
- package/src/components/TideSheet.vue +0 -209
- package/src/components/TideSwitch.vue +0 -101
- package/src/components/TideTabs.vue +0 -63
- package/src/components/TideToaster.vue +0 -97
- package/src/composables/useTideConfig.ts +0 -23
- package/src/composables/useTideForm.ts +0 -25
- package/src/composables/useTideToaster.ts +0 -63
- package/src/contexts/sandbox/AppSandbox.vue +0 -7
- package/src/contexts/sandbox/app-sandbox.ts +0 -10
- package/src/stories/DemoCssUtilities.stories.ts +0 -154
- package/src/stories/DemoCssUtilitiesByTextInput.stories.ts +0 -61
- package/src/stories/FoundationsBorder.stories.ts +0 -272
- package/src/stories/FoundationsColor.stories.ts +0 -311
- package/src/stories/FoundationsFlexbox.stories.ts +0 -184
- package/src/stories/FoundationsGrid.stories.ts +0 -126
- package/src/stories/FoundationsMargin.stories.ts +0 -155
- package/src/stories/FoundationsPadding.stories.ts +0 -108
- package/src/stories/FoundationsShadow.stories.ts +0 -103
- package/src/stories/FoundationsTransparency.stories.ts +0 -114
- package/src/stories/FoundationsTypography.stories.ts +0 -212
- package/src/stories/Template.stories.ts +0 -73
- package/src/stories/TideAccordionItem.stories.ts +0 -91
- package/src/stories/TideAlert.stories.ts +0 -133
- package/src/stories/TideBadge.stories.ts +0 -90
- package/src/stories/TideBadgeTrustedPartner.stories.ts +0 -34
- package/src/stories/TideBadgeVerifiedVehicle.stories.ts +0 -22
- package/src/stories/TideBreadCrumbs.stories.ts +0 -42
- package/src/stories/TideButton.stories.ts +0 -132
- package/src/stories/TideButtonIcon.stories.ts +0 -109
- package/src/stories/TideButtonPagination.stories.ts +0 -99
- package/src/stories/TideButtonSave.stories.ts +0 -62
- package/src/stories/TideButtonSegmented.stories.ts +0 -110
- package/src/stories/TideCard.stories.ts +0 -102
- package/src/stories/TideCarousel.stories.ts +0 -219
- package/src/stories/TideChipAction.stories.ts +0 -81
- package/src/stories/TideChipFilter.stories.ts +0 -84
- package/src/stories/TideChipInput.stories.ts +0 -56
- package/src/stories/TideColumns.stories.ts +0 -89
- package/src/stories/TideDivider.stories.ts +0 -48
- package/src/stories/TideIcon.stories.ts +0 -31
- package/src/stories/TideImage.stories.ts +0 -124
- package/src/stories/TideImageBackground.stories.ts +0 -114
- package/src/stories/TideIndicator.stories.ts +0 -32
- package/src/stories/TideInputCheckbox.stories.ts +0 -138
- package/src/stories/TideInputRadio.stories.ts +0 -100
- package/src/stories/TideInputSelect.stories.ts +0 -244
- package/src/stories/TideInputText.stories.ts +0 -221
- package/src/stories/TideInputTextarea.stories.ts +0 -156
- package/src/stories/TideLink.stories.ts +0 -127
- package/src/stories/TideMenuItem.stories.ts +0 -117
- package/src/stories/TideModal.stories.ts +0 -219
- package/src/stories/TidePagination.stories.ts +0 -100
- package/src/stories/TidePopover.stories.ts +0 -101
- package/src/stories/TideRating.stories.ts +0 -114
- package/src/stories/TideRealmLogo.stories.ts +0 -93
- package/src/stories/TideSeoLinks.stories.ts +0 -68
- package/src/stories/TideSheet.stories.ts +0 -152
- package/src/stories/TideSwitch.stories.ts +0 -72
- package/src/stories/TideTabs.stories.ts +0 -114
- package/src/stories/TideToaster.stories.ts +0 -117
- package/src/stories/Welcome.mdx +0 -17
- package/src/types/Alert.ts +0 -8
- package/src/types/Badge.ts +0 -76
- package/src/types/BreadCrumb.ts +0 -5
- package/src/types/Breakpoint.ts +0 -18
- package/src/types/Card.ts +0 -7
- package/src/types/Element.ts +0 -13
- package/src/types/FieldDeprecated.ts +0 -92
- package/src/types/Form.ts +0 -1
- package/src/types/FormDeprecated.ts +0 -91
- package/src/types/Formatted.ts +0 -23
- package/src/types/Icon.ts +0 -202
- package/src/types/Image.ts +0 -7
- package/src/types/Link.ts +0 -5
- package/src/types/Orientation.ts +0 -6
- package/src/types/Priority.ts +0 -11
- package/src/types/Realm.ts +0 -14
- package/src/types/RealmLogo.ts +0 -23
- package/src/types/Select.ts +0 -9
- package/src/types/Size.ts +0 -13
- package/src/types/Source.ts +0 -6
- package/src/types/Storybook.ts +0 -253
- package/src/types/Styles.ts +0 -526
- package/src/types/Tab.ts +0 -5
- package/src/types/Target.ts +0 -6
- package/src/types/TextInput.ts +0 -28
- package/src/types/Toast.ts +0 -21
- package/src/types/Type.ts +0 -6
- package/src/types/Validation.ts +0 -33
- package/src/types/ValidationDeprecated.ts +0 -41
- package/src/utilities/event.ts +0 -4
- package/src/utilities/format.ts +0 -184
- package/src/utilities/forms.ts +0 -22
- package/src/utilities/realm.ts +0 -17
- package/src/utilities/storybook.ts +0 -354
- package/src/utilities/validation-deprecated.ts +0 -252
- package/src/utilities/validation.ts +0 -132
- package/src/utilities/viewport.ts +0 -63
- package/tests/InternalBaseLink.spec.ts +0 -61
- package/tests/TideRealmLogo.spec.ts +0 -58
- package/tests/svg-icons.spec.ts +0 -74
- package/tests/utilities-format.spec.ts +0 -470
- package/tests/utilities-storybook.spec.ts +0 -99
- package/tsconfig.app.json +0 -14
- package/tsconfig.config.json +0 -12
- package/tsconfig.json +0 -35
- package/tsconfig.node.json +0 -7
- package/tsconfig.vitest.json +0 -10
- package/vite-env.d.ts +0 -2
- package/vite.config.sandbox.ts +0 -29
- package/vite.config.ts +0 -37
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { priceToNumber } from '@/utilities/format';
|
|
2
|
-
|
|
3
|
-
import type { StringInput } from '@/types/FormDeprecated';
|
|
4
|
-
import type { SelectOption } from '@/types/Select';
|
|
5
|
-
import type { ValidationError, ValidationLength, ValidationResult, Validator } from '@/types/ValidationDeprecated';
|
|
6
|
-
import type { Ref } from 'vue';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated
|
|
10
|
-
*/
|
|
11
|
-
type RangeData = {
|
|
12
|
-
min: number | null;
|
|
13
|
-
max: number | null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated
|
|
18
|
-
*/
|
|
19
|
-
export const errorMessageDefault = 'Please enter a valid value.';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated
|
|
23
|
-
*/
|
|
24
|
-
export const noError = {
|
|
25
|
-
message: '',
|
|
26
|
-
valid: true,
|
|
27
|
-
} as Readonly<ValidationResult>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated
|
|
31
|
-
*/
|
|
32
|
-
export const checkFormat = (format: RegExp) => {
|
|
33
|
-
return (value: string): ValidationResult => {
|
|
34
|
-
let result = noError;
|
|
35
|
-
|
|
36
|
-
if (!value.trim().match(format)) {
|
|
37
|
-
result = {
|
|
38
|
-
message: errorMessageDefault,
|
|
39
|
-
valid: false,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated
|
|
49
|
-
*/
|
|
50
|
-
export const getErrorMessage = (errorFromProps: ValidationError, errorFromRef: ValidationError) => {
|
|
51
|
-
// error in props takes precedence over validation error
|
|
52
|
-
if (typeof errorFromProps === 'string' && errorFromProps.length > 0) return errorFromProps;
|
|
53
|
-
|
|
54
|
-
return typeof errorFromRef === 'string' && errorFromRef.length > 0 ? errorFromRef : errorMessageDefault;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated
|
|
59
|
-
*/
|
|
60
|
-
export const getFieldHasError = (errorFromProps: ValidationError, errorFromRef: ValidationError) =>
|
|
61
|
-
errorFromProps !== false || errorFromRef !== false;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @deprecated
|
|
65
|
-
*/
|
|
66
|
-
export const getFieldLengthIsValid = ({ maxlength, minlength, required, value }: ValidationLength) => {
|
|
67
|
-
const isEmptyAndUnrequired = value.length === 0 && !required;
|
|
68
|
-
const isTooLong = maxlength && value.length > maxlength;
|
|
69
|
-
const isTooShort = !isEmptyAndUnrequired && minlength && value.length < minlength;
|
|
70
|
-
|
|
71
|
-
return !isTooShort && !isTooLong;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated
|
|
76
|
-
*/
|
|
77
|
-
export const getMaxRangeIsValid = ({ min }: Pick<RangeData, 'min'>, type?: 'price') => {
|
|
78
|
-
return (value: string): ValidationResult => {
|
|
79
|
-
let newMax: number | null = type === 'price' ? priceToNumber(value) : Number(value);
|
|
80
|
-
newMax = !isNaN(newMax) ? newMax : null;
|
|
81
|
-
if (min && newMax) {
|
|
82
|
-
if (newMax >= min) {
|
|
83
|
-
return {
|
|
84
|
-
message: '',
|
|
85
|
-
valid: true,
|
|
86
|
-
};
|
|
87
|
-
} else {
|
|
88
|
-
return {
|
|
89
|
-
message: `Must be greater than min`,
|
|
90
|
-
valid: false,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
return noError;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @deprecated
|
|
101
|
-
*/
|
|
102
|
-
export const getMinRangeIsValid = ({ max }: Pick<RangeData, 'max'>, type?: 'price') => {
|
|
103
|
-
return (value: string): ValidationResult => {
|
|
104
|
-
let newMin: number | null = type === 'price' ? priceToNumber(value) : Number(value);
|
|
105
|
-
newMin = !isNaN(newMin) ? newMin : null;
|
|
106
|
-
if (max && newMin) {
|
|
107
|
-
if (newMin <= max) {
|
|
108
|
-
return {
|
|
109
|
-
message: '',
|
|
110
|
-
valid: true,
|
|
111
|
-
};
|
|
112
|
-
} else {
|
|
113
|
-
return {
|
|
114
|
-
message: `Must be less than max`,
|
|
115
|
-
valid: false,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
return noError;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* @deprecated
|
|
126
|
-
*/
|
|
127
|
-
export const getSelectOptionsFromStrings = (strings: string[]) =>
|
|
128
|
-
strings.map(
|
|
129
|
-
(option) =>
|
|
130
|
-
({
|
|
131
|
-
label: option,
|
|
132
|
-
value: option,
|
|
133
|
-
} as SelectOption)
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @deprecated
|
|
138
|
-
*/
|
|
139
|
-
export const handleFieldValidation = ({
|
|
140
|
-
error,
|
|
141
|
-
errorFromProps,
|
|
142
|
-
maxlength,
|
|
143
|
-
minlength,
|
|
144
|
-
required = false,
|
|
145
|
-
validators,
|
|
146
|
-
value,
|
|
147
|
-
}: {
|
|
148
|
-
error: Ref<ValidationError>;
|
|
149
|
-
errorFromProps: ValidationError;
|
|
150
|
-
maxlength?: number;
|
|
151
|
-
minlength?: number;
|
|
152
|
-
required?: boolean;
|
|
153
|
-
validators?: Validator[];
|
|
154
|
-
value?: Ref<string | undefined>;
|
|
155
|
-
}) => {
|
|
156
|
-
// error in props takes precedence over validation error
|
|
157
|
-
|
|
158
|
-
error.value = errorFromProps ? errorFromProps : false;
|
|
159
|
-
|
|
160
|
-
if (!error.value && validators) {
|
|
161
|
-
const validation = validateProperty(value?.value || '', validators);
|
|
162
|
-
|
|
163
|
-
if (!validation.valid) {
|
|
164
|
-
error.value = validation.message;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (!error.value && (maxlength || minlength)) {
|
|
169
|
-
const lengthValidation = validateLength({
|
|
170
|
-
maxlength,
|
|
171
|
-
minlength,
|
|
172
|
-
required,
|
|
173
|
-
value: value?.value || '',
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (!lengthValidation.valid) {
|
|
177
|
-
error.value = lengthValidation.message;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @deprecated
|
|
184
|
-
*/
|
|
185
|
-
export function validateFieldsFromRefs(fields: { [key: string]: Ref<StringInput | null> }) {
|
|
186
|
-
let valid = true;
|
|
187
|
-
|
|
188
|
-
for (const key in fields) {
|
|
189
|
-
if (fields[key].value?.required) {
|
|
190
|
-
const value = fields[key].value?.value;
|
|
191
|
-
valid = valid && !!value && value.trim() !== '';
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const error = fields[key].value?.error;
|
|
195
|
-
valid = valid && !error;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return valid;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* @deprecated
|
|
203
|
-
*/
|
|
204
|
-
export const validateLength = ({
|
|
205
|
-
maxlength,
|
|
206
|
-
minlength,
|
|
207
|
-
required = false,
|
|
208
|
-
value,
|
|
209
|
-
}: ValidationLength): ValidationResult => {
|
|
210
|
-
const response = {
|
|
211
|
-
message: '',
|
|
212
|
-
valid: true,
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
response.valid = getFieldLengthIsValid({
|
|
216
|
-
maxlength,
|
|
217
|
-
minlength,
|
|
218
|
-
required,
|
|
219
|
-
value,
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
if (response.valid) return response;
|
|
223
|
-
|
|
224
|
-
response.message = errorMessageDefault;
|
|
225
|
-
|
|
226
|
-
if (maxlength && minlength) {
|
|
227
|
-
response.message = `Please enter a value between ${minlength} and ${maxlength} characters in length.`;
|
|
228
|
-
} else if (maxlength) {
|
|
229
|
-
response.message = `Please enter a value no more than ${maxlength} characters in length.`;
|
|
230
|
-
} else if (minlength) {
|
|
231
|
-
response.message = `Please enter a value no less than ${minlength} characters in length.`;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return response;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* @deprecated
|
|
239
|
-
*/
|
|
240
|
-
export function validateProperty(value: string, validators: ((value: string) => ValidationResult)[]): ValidationResult {
|
|
241
|
-
for (const validator of validators) {
|
|
242
|
-
const validation = validator(value);
|
|
243
|
-
if (!validation.valid) {
|
|
244
|
-
return validation;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return {
|
|
249
|
-
message: '',
|
|
250
|
-
valid: true,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { formatNumber } from '@/utilities/format';
|
|
2
|
-
|
|
3
|
-
import type { ValidationLength, ValidationResult, Validator } from '@/types/Validation';
|
|
4
|
-
import type { Ref } from 'vue';
|
|
5
|
-
|
|
6
|
-
export const errorMessageDefault = 'Please enter a valid value';
|
|
7
|
-
|
|
8
|
-
export const VALIDATION_RESULT = {
|
|
9
|
-
NO_ERROR: {
|
|
10
|
-
message: '',
|
|
11
|
-
valid: true,
|
|
12
|
-
},
|
|
13
|
-
REQUIRED: {
|
|
14
|
-
message: 'Please fill out this field',
|
|
15
|
-
valid: false,
|
|
16
|
-
},
|
|
17
|
-
} as const;
|
|
18
|
-
|
|
19
|
-
export const checkFormat = (format: RegExp, message?: string) => {
|
|
20
|
-
return (value: string): ValidationResult => {
|
|
21
|
-
let result: ValidationResult = VALIDATION_RESULT.NO_ERROR;
|
|
22
|
-
|
|
23
|
-
if (!value.trim().match(format)) {
|
|
24
|
-
result = {
|
|
25
|
-
message: message ?? errorMessageDefault,
|
|
26
|
-
valid: false,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const getFieldLengthIsValid = ({ maxlength, minlength, required, value }: ValidationLength) => {
|
|
35
|
-
const isEmptyAndUnrequired = value.length === 0 && !required;
|
|
36
|
-
const isTooLong = maxlength && value.length > maxlength;
|
|
37
|
-
const isTooShort = !isEmptyAndUnrequired && minlength && value.length < minlength;
|
|
38
|
-
return !isTooShort && !isTooLong;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const getFieldValidationResult = ({
|
|
42
|
-
errorFromProps,
|
|
43
|
-
maxlength,
|
|
44
|
-
minlength,
|
|
45
|
-
required,
|
|
46
|
-
validators,
|
|
47
|
-
value,
|
|
48
|
-
}: {
|
|
49
|
-
errorFromProps: string;
|
|
50
|
-
maxlength?: number;
|
|
51
|
-
minlength?: number;
|
|
52
|
-
required: boolean;
|
|
53
|
-
validators?: Validator[];
|
|
54
|
-
value: Ref<string>;
|
|
55
|
-
}): ValidationResult => {
|
|
56
|
-
// error in props takes precedence over validation error
|
|
57
|
-
if (errorFromProps !== '')
|
|
58
|
-
return {
|
|
59
|
-
message: errorFromProps,
|
|
60
|
-
valid: false,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// custom validator prop errors from have second highest precedence
|
|
64
|
-
if (validators) {
|
|
65
|
-
const validation = validateProperty(value.value ?? '', validators);
|
|
66
|
-
|
|
67
|
-
if (!validation.valid) {
|
|
68
|
-
return validation;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// all other prop-based errors come last
|
|
73
|
-
if (required && value.value?.trim() === '') {
|
|
74
|
-
return VALIDATION_RESULT.REQUIRED;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (maxlength || minlength) {
|
|
78
|
-
const lengthValidation = validateLength({
|
|
79
|
-
maxlength,
|
|
80
|
-
minlength,
|
|
81
|
-
required,
|
|
82
|
-
value: value.value,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
if (!lengthValidation.valid) {
|
|
86
|
-
return lengthValidation;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return VALIDATION_RESULT.NO_ERROR;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const validateLength = ({ maxlength, minlength, required, value }: ValidationLength): ValidationResult => {
|
|
93
|
-
const response = {
|
|
94
|
-
message: '',
|
|
95
|
-
valid: true,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
response.valid = getFieldLengthIsValid({
|
|
99
|
-
maxlength,
|
|
100
|
-
minlength,
|
|
101
|
-
required,
|
|
102
|
-
value,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
if (response.valid) return response;
|
|
106
|
-
|
|
107
|
-
response.message = errorMessageDefault;
|
|
108
|
-
|
|
109
|
-
if (maxlength && minlength) {
|
|
110
|
-
response.message = `Enter a value between ${formatNumber(minlength)} and ${formatNumber(maxlength)} characters`;
|
|
111
|
-
} else if (maxlength) {
|
|
112
|
-
response.message = `Use ${formatNumber(maxlength)} characters or fewer`;
|
|
113
|
-
} else if (minlength) {
|
|
114
|
-
response.message = `Enter at least ${formatNumber(minlength)} characters`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return response;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export function validateProperty(value: string, validators: ((value: string) => ValidationResult)[]): ValidationResult {
|
|
121
|
-
for (const validator of validators) {
|
|
122
|
-
const validation = validator(value);
|
|
123
|
-
if (!validation.valid) {
|
|
124
|
-
return validation;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
message: '',
|
|
130
|
-
valid: true,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { nextTick } from 'vue';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Directly modifies the `<body>` element to apply or remove scroll lock.
|
|
5
|
-
* When `false` is provided, it only unlocks scroll if there are no open
|
|
6
|
-
* HTML dialog elements.
|
|
7
|
-
*/
|
|
8
|
-
export const setScrollLock = async (isLocked: boolean) => {
|
|
9
|
-
// Cannot be applied to body tag in marketplace repo due to data-css-scope
|
|
10
|
-
// const BODY_LOCK_CLASS = 'body-scroll-lock';
|
|
11
|
-
|
|
12
|
-
const body = document.body;
|
|
13
|
-
|
|
14
|
-
if (isLocked) {
|
|
15
|
-
if (!body.dataset.scrollLockY) {
|
|
16
|
-
const scrollY = window.scrollY;
|
|
17
|
-
|
|
18
|
-
body.dataset.scrollLockY = scrollY.toString();
|
|
19
|
-
body.style.setProperty('--saved-scroll-y', `${scrollY}px`);
|
|
20
|
-
body.style.setProperty('inset', '0');
|
|
21
|
-
body.style.setProperty('margin-top', `calc(0px - var(--saved-scroll-y, 0px))`);
|
|
22
|
-
body.style.setProperty('overflow-y', 'scroll');
|
|
23
|
-
body.style.setProperty('position', 'fixed');
|
|
24
|
-
|
|
25
|
-
// Cannot be applied to body tag in marketplace repo due to data-css-scope
|
|
26
|
-
// body.classList.add(BODY_LOCK_CLASS);
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
await nextTick();
|
|
30
|
-
if (!document.querySelector('dialog[open]')) {
|
|
31
|
-
const savedScrollY = parseInt(body.dataset.scrollLockY || '0');
|
|
32
|
-
|
|
33
|
-
// Cannot be applied to body tag in marketplace repo due to data-css-scope
|
|
34
|
-
// body.classList.remove(BODY_LOCK_CLASS);
|
|
35
|
-
|
|
36
|
-
body.style.removeProperty('inset');
|
|
37
|
-
body.style.removeProperty('margin-top');
|
|
38
|
-
body.style.removeProperty('overflow-y');
|
|
39
|
-
body.style.removeProperty('position');
|
|
40
|
-
body.style.removeProperty('--saved-scroll-y');
|
|
41
|
-
|
|
42
|
-
window.scrollTo({
|
|
43
|
-
behavior: 'auto',
|
|
44
|
-
top: savedScrollY,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
delete body.dataset.scrollLockY;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const TOP_LAYER_ID = 'tide-top-layer';
|
|
53
|
-
|
|
54
|
-
export const initFauxTopLayer = () => {
|
|
55
|
-
let topLayer = document.getElementById(TOP_LAYER_ID);
|
|
56
|
-
if (!topLayer) {
|
|
57
|
-
topLayer = document.createElement('div');
|
|
58
|
-
topLayer.id = TOP_LAYER_ID;
|
|
59
|
-
topLayer.setAttribute('data-css-scope', '');
|
|
60
|
-
document.body.appendChild(topLayer);
|
|
61
|
-
}
|
|
62
|
-
topLayer.style.isolation = 'isolate';
|
|
63
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest/globals" />
|
|
2
|
-
|
|
3
|
-
import { mount } from '@vue/test-utils';
|
|
4
|
-
import { describe, expect, it } from 'vitest';
|
|
5
|
-
import { defineComponent, h, markRaw } from 'vue';
|
|
6
|
-
|
|
7
|
-
import InternalBaseLink from '@/components/InternalBaseLink.vue';
|
|
8
|
-
import { provideTideConfig } from '@/composables/useTideConfig';
|
|
9
|
-
|
|
10
|
-
// @vitest-environment jsdom
|
|
11
|
-
|
|
12
|
-
/* eslint-disable vue/one-component-per-file */
|
|
13
|
-
const TestWrapper = defineComponent({
|
|
14
|
-
props: {
|
|
15
|
-
config: { type: Object, default: () => ({}) },
|
|
16
|
-
},
|
|
17
|
-
setup(props, { slots }) {
|
|
18
|
-
provideTideConfig(props.config);
|
|
19
|
-
return () => h(InternalBaseLink, null, slots);
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
/* eslint-enable vue/one-component-per-file */
|
|
23
|
-
|
|
24
|
-
describe('InternalBaseLink', () => {
|
|
25
|
-
it('renders default <a> when no provider is used', () => {
|
|
26
|
-
const wrapper = mount(InternalBaseLink, {
|
|
27
|
-
slots: { default: 'Hello' },
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(wrapper.element.tagName.toLowerCase()).toBe('a');
|
|
31
|
-
expect(wrapper.text()).toBe('Hello');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('renders a provided custom link component', () => {
|
|
35
|
-
const CustomLink = markRaw(
|
|
36
|
-
/* eslint-disable vue/one-component-per-file */
|
|
37
|
-
defineComponent({
|
|
38
|
-
name: 'CustomLink',
|
|
39
|
-
render() {
|
|
40
|
-
return h('custom-link', {}, this.$slots.default?.());
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
/* eslint-enable vue/one-component-per-file */
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const wrapper = mount(TestWrapper, {
|
|
47
|
-
props: {
|
|
48
|
-
config: {
|
|
49
|
-
linkComponent: CustomLink,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
slots: {
|
|
53
|
-
default: 'Custom Content',
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const btn = wrapper.find('custom-link');
|
|
58
|
-
expect(btn.exists()).toBe(true);
|
|
59
|
-
expect(btn.text()).toBe('Custom Content');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { describe, expect, it } from 'vitest';
|
|
4
|
-
|
|
5
|
-
import { LOGO_WIDTH_LARGE } from '@/types/RealmLogo';
|
|
6
|
-
|
|
7
|
-
const BRANDING_DIR = path.resolve(__dirname, '../src/assets/svg/branding');
|
|
8
|
-
const LOGO_DIR = path.join(BRANDING_DIR, 'logo');
|
|
9
|
-
const MARK_DIR = path.join(BRANDING_DIR, 'mark');
|
|
10
|
-
|
|
11
|
-
function getViewBoxWidth(content: string): number | null {
|
|
12
|
-
const viewBoxMatch = content.match(/viewBox\s*=\s*["']0\s+0\s+(\d+\.?\d*)\s+\d+\.?\d*["']/i);
|
|
13
|
-
return viewBoxMatch ? parseFloat(viewBoxMatch[1]) : null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe('Realm Logo Constant Validation', () => {
|
|
17
|
-
const realms = Object.keys(LOGO_WIDTH_LARGE) as (keyof typeof LOGO_WIDTH_LARGE)[];
|
|
18
|
-
|
|
19
|
-
describe('Full Logos', () => {
|
|
20
|
-
realms.forEach((realm) => {
|
|
21
|
-
const fileName = `logo-${realm.toLowerCase()}.svg`;
|
|
22
|
-
const filePath = path.join(LOGO_DIR, fileName);
|
|
23
|
-
|
|
24
|
-
it(`should match the viewBox width in ${fileName}`, () => {
|
|
25
|
-
if (!fs.existsSync(filePath)) {
|
|
26
|
-
throw new Error(`SVG file missing: ${filePath}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
30
|
-
const vbWidth = getViewBoxWidth(content);
|
|
31
|
-
|
|
32
|
-
expect(vbWidth, `Could not parse viewBox in ${fileName}`).not.toBeNull();
|
|
33
|
-
|
|
34
|
-
expect(LOGO_WIDTH_LARGE[realm], `LOGO_WIDTH_LARGE[${realm}] does not match ${fileName}`).toBe(vbWidth);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('Logo Marks', () => {
|
|
40
|
-
realms.forEach((realm) => {
|
|
41
|
-
const fileName = `mark-${realm.toLowerCase()}.svg`;
|
|
42
|
-
const filePath = path.join(MARK_DIR, fileName);
|
|
43
|
-
|
|
44
|
-
it(`should match the viewBox width in ${fileName}`, () => {
|
|
45
|
-
if (!fs.existsSync(filePath)) {
|
|
46
|
-
throw new Error(`SVG file missing: ${filePath}`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
50
|
-
const vbWidth = getViewBoxWidth(content);
|
|
51
|
-
|
|
52
|
-
expect(vbWidth, `Could not parse viewBox in ${fileName}`).not.toBeNull();
|
|
53
|
-
|
|
54
|
-
expect(vbWidth, `Logo mark width does not match ${fileName}`).toBe(32);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
package/tests/svg-icons.spec.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { describe, expect, it } from 'vitest';
|
|
4
|
-
|
|
5
|
-
const SVG_DIR: string = path.resolve(__dirname, '../src/assets/svg/icons');
|
|
6
|
-
|
|
7
|
-
const numberRegex = /-?\d*\.\d+|-?\d+/g;
|
|
8
|
-
|
|
9
|
-
function findExcessivePrecision(content: string, maxDecimals: number): string[] {
|
|
10
|
-
const matches = content.match(numberRegex);
|
|
11
|
-
if (!matches) return [];
|
|
12
|
-
|
|
13
|
-
return matches.filter((numStr) => {
|
|
14
|
-
if (numStr.includes('.')) {
|
|
15
|
-
const decimals = numStr.split('.')[1].length;
|
|
16
|
-
return decimals > maxDecimals;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe('SVG validation tests', () => {
|
|
23
|
-
const svgFiles: string[] = fs.readdirSync(SVG_DIR).filter((file: string) => file.endsWith('.svg'));
|
|
24
|
-
|
|
25
|
-
it('should have at least one svg file to check', () => {
|
|
26
|
-
expect(svgFiles.length).toBeGreaterThan(0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
svgFiles.forEach((file: string) => {
|
|
30
|
-
describe(`"${file}"`, () => {
|
|
31
|
-
const filePath: string = path.join(SVG_DIR, file);
|
|
32
|
-
const content: string = fs.readFileSync(filePath, 'utf8');
|
|
33
|
-
const match: RegExpMatchArray | null = content.match(/<svg[^>]*>/i);
|
|
34
|
-
|
|
35
|
-
it('should contain an <svg> root element', () => {
|
|
36
|
-
expect(match).not.toBeNull();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
if (match) {
|
|
40
|
-
const svgTag: string = match[0];
|
|
41
|
-
|
|
42
|
-
it("should have viewBox='0 0 24 24'", () => {
|
|
43
|
-
const viewBoxMatch: RegExpMatchArray | null = svgTag.match(/viewBox\s*=\s*["']([^"']+)["']/i);
|
|
44
|
-
expect(viewBoxMatch).not.toBeNull();
|
|
45
|
-
expect(viewBoxMatch![1]).toBe('0 0 24 24');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should not have a fill attribute', () => {
|
|
49
|
-
const hasFill: boolean = /\sfill\s*=\s*["'][^"']*["']/i.test(svgTag);
|
|
50
|
-
expect(hasFill).toBe(false);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should not have width or height attributes', () => {
|
|
54
|
-
const hasWidth: boolean = /\swidth\s*=\s*["'][^"']*["']/i.test(svgTag);
|
|
55
|
-
const hasHeight: boolean = /\sheight\s*=\s*["'][^"']*["']/i.test(svgTag);
|
|
56
|
-
expect(hasWidth).toBe(false);
|
|
57
|
-
expect(hasHeight).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const MAX_PRECISION = 3;
|
|
62
|
-
|
|
63
|
-
it(`should not contain numbers with more than ${MAX_PRECISION} decimal places`, () => {
|
|
64
|
-
const badNumbers = findExcessivePrecision(content, MAX_PRECISION);
|
|
65
|
-
expect(
|
|
66
|
-
badNumbers,
|
|
67
|
-
`Found overly precise numbers: ${badNumbers.join(
|
|
68
|
-
', '
|
|
69
|
-
)}. Use www.svgomg.net to optimize the vector asset before committing it.`
|
|
70
|
-
).toEqual([]);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|