@flipdish/ui-library 0.56.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/atoms/AppStoreButton/index.cjs +23 -40
- package/dist/components/atoms/AppStoreButton/index.cjs.map +1 -1
- package/dist/components/atoms/AppStoreButton/index.d.ts +30 -28
- package/dist/components/atoms/AppStoreButton/index.d.ts.map +1 -1
- package/dist/components/atoms/AppStoreButton/index.js +20 -37
- package/dist/components/atoms/AppStoreButton/index.js.map +1 -1
- package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/AppStoreBadgeLink.cjs +1 -1
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreBadgeLink.cjs.map +1 -0
- package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/AppStoreBadgeLink.d.ts +1 -1
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreBadgeLink.d.ts.map +1 -0
- package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/AppStoreBadgeLink.js +1 -1
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreBadgeLink.js.map +1 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButton.cjs +44 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButton.cjs.map +1 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButton.d.ts +42 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButton.d.ts.map +1 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButton.js +38 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButton.js.map +1 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButtonsOutline.cjs.map +1 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButtonsOutline.d.ts.map +1 -0
- package/dist/components/atoms/BrandButtons/AppStoreButton/AppStoreButtonsOutline.js.map +1 -0
- package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/GooglePlayPaths.cjs +1 -1
- package/dist/components/atoms/BrandButtons/AppStoreButton/GooglePlayPaths.cjs.map +1 -0
- package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/GooglePlayPaths.d.ts +1 -1
- package/dist/components/atoms/BrandButtons/AppStoreButton/GooglePlayPaths.d.ts.map +1 -0
- package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/GooglePlayPaths.js +1 -1
- package/dist/components/atoms/BrandButtons/AppStoreButton/GooglePlayPaths.js.map +1 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.cjs +108 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.cjs.map +1 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.d.ts +66 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.d.ts.map +1 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.js +105 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.js.map +1 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialLogos.cjs.map +1 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialLogos.d.ts.map +1 -0
- package/dist/components/atoms/BrandButtons/SocialButton/SocialLogos.js.map +1 -0
- package/dist/components/atoms/BrandButtons/index.cjs +19 -0
- package/dist/components/atoms/BrandButtons/index.cjs.map +1 -0
- package/dist/components/atoms/BrandButtons/index.d.ts +14 -0
- package/dist/components/atoms/BrandButtons/index.d.ts.map +1 -0
- package/dist/components/atoms/BrandButtons/index.js +4 -0
- package/dist/components/atoms/BrandButtons/index.js.map +1 -0
- package/dist/components/atoms/SocialButton/index.cjs +6 -100
- package/dist/components/atoms/SocialButton/index.cjs.map +1 -1
- package/dist/components/atoms/SocialButton/index.d.ts +6 -31
- package/dist/components/atoms/SocialButton/index.d.ts.map +1 -1
- package/dist/components/atoms/SocialButton/index.js +6 -100
- package/dist/components/atoms/SocialButton/index.js.map +1 -1
- package/dist/components/atoms/UtilityButton/index.cjs +5 -2
- package/dist/components/atoms/UtilityButton/index.cjs.map +1 -1
- package/dist/components/atoms/UtilityButton/index.d.ts.map +1 -1
- package/dist/components/atoms/UtilityButton/index.js +5 -2
- package/dist/components/atoms/UtilityButton/index.js.map +1 -1
- package/dist/components/forms/fields/FormDatePicker/index.cjs +2 -2
- package/dist/components/forms/fields/FormDatePicker/index.d.ts +1 -1
- package/dist/components/forms/fields/FormDatePicker/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormDatePicker/index.js +1 -1
- package/dist/components/molecules/ActivityFeed/index.cjs +32 -0
- package/dist/components/molecules/ActivityFeed/index.cjs.map +1 -0
- package/dist/components/molecules/ActivityFeed/index.d.ts +54 -0
- package/dist/components/molecules/ActivityFeed/index.d.ts.map +1 -0
- package/dist/components/molecules/ActivityFeed/index.js +30 -0
- package/dist/components/molecules/ActivityFeed/index.js.map +1 -0
- package/dist/components/molecules/Carousel/index.cjs +5 -140
- package/dist/components/molecules/Carousel/index.cjs.map +1 -1
- package/dist/components/molecules/Carousel/index.d.ts +5 -122
- package/dist/components/molecules/Carousel/index.d.ts.map +1 -1
- package/dist/components/molecules/Carousel/index.js +5 -140
- package/dist/components/molecules/Carousel/index.js.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.cjs +5 -106
- package/dist/components/molecules/CodeSnippet/index.cjs.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.d.ts +13 -73
- package/dist/components/molecules/CodeSnippet/index.d.ts.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.js +5 -106
- package/dist/components/molecules/CodeSnippet/index.js.map +1 -1
- package/dist/components/molecules/Messaging/components/MessageItemActions.cjs +11 -0
- package/dist/components/molecules/Messaging/components/MessageItemActions.cjs.map +1 -0
- package/dist/components/{organisms → molecules}/Messaging/components/MessageItemActions.d.ts +1 -1
- package/dist/components/molecules/Messaging/components/MessageItemActions.d.ts.map +1 -0
- package/dist/components/molecules/Messaging/components/MessageItemActions.js +9 -0
- package/dist/components/molecules/Messaging/components/MessageItemActions.js.map +1 -0
- package/dist/components/molecules/Messaging/index.cjs +56 -0
- package/dist/components/molecules/Messaging/index.cjs.map +1 -0
- package/dist/components/molecules/Messaging/index.d.ts +70 -0
- package/dist/components/molecules/Messaging/index.d.ts.map +1 -0
- package/dist/components/molecules/Messaging/index.js +53 -0
- package/dist/components/molecules/Messaging/index.js.map +1 -0
- package/dist/components/{organisms/Messaging → molecules/Messaging/utilities}/messageItem.utils.cjs +4 -2
- package/dist/components/molecules/Messaging/utilities/messageItem.utils.cjs.map +1 -0
- package/dist/components/molecules/Messaging/utilities/messageItem.utils.d.ts.map +1 -0
- package/dist/components/{organisms/Messaging → molecules/Messaging/utilities}/messageItem.utils.js +4 -2
- package/dist/components/molecules/Messaging/utilities/messageItem.utils.js.map +1 -0
- package/dist/components/molecules/Notification/index.cjs +7 -43
- package/dist/components/molecules/Notification/index.cjs.map +1 -1
- package/dist/components/molecules/Notification/index.d.ts +9 -90
- package/dist/components/molecules/Notification/index.d.ts.map +1 -1
- package/dist/components/molecules/Notification/index.js +7 -43
- package/dist/components/molecules/Notification/index.js.map +1 -1
- package/dist/components/molecules/Notifications/AvatarNotification/AvatarNotification.cjs +21 -0
- package/dist/components/molecules/Notifications/AvatarNotification/AvatarNotification.cjs.map +1 -0
- package/dist/components/molecules/Notifications/AvatarNotification/AvatarNotification.d.ts +46 -0
- package/dist/components/molecules/Notifications/AvatarNotification/AvatarNotification.d.ts.map +1 -0
- package/dist/components/molecules/Notifications/AvatarNotification/AvatarNotification.js +19 -0
- package/dist/components/molecules/Notifications/AvatarNotification/AvatarNotification.js.map +1 -0
- package/dist/components/molecules/Notifications/IconNotification/IconNotification.cjs +26 -0
- package/dist/components/molecules/Notifications/IconNotification/IconNotification.cjs.map +1 -0
- package/dist/components/molecules/Notifications/IconNotification/IconNotification.d.ts +39 -0
- package/dist/components/molecules/Notifications/IconNotification/IconNotification.d.ts.map +1 -0
- package/dist/components/molecules/Notifications/IconNotification/IconNotification.js +24 -0
- package/dist/components/molecules/Notifications/IconNotification/IconNotification.js.map +1 -0
- package/dist/components/molecules/Notifications/ImageNotification/ImageNotification.cjs +22 -0
- package/dist/components/molecules/Notifications/ImageNotification/ImageNotification.cjs.map +1 -0
- package/dist/components/molecules/Notifications/ImageNotification/ImageNotification.d.ts +33 -0
- package/dist/components/molecules/Notifications/ImageNotification/ImageNotification.d.ts.map +1 -0
- package/dist/components/molecules/Notifications/ImageNotification/ImageNotification.js +20 -0
- package/dist/components/molecules/Notifications/ImageNotification/ImageNotification.js.map +1 -0
- package/dist/components/molecules/Notifications/index.cjs +12 -0
- package/dist/components/molecules/Notifications/index.cjs.map +1 -0
- package/dist/components/molecules/Notifications/index.d.ts +16 -0
- package/dist/components/molecules/Notifications/index.d.ts.map +1 -0
- package/dist/components/molecules/Notifications/index.js +4 -0
- package/dist/components/molecules/Notifications/index.js.map +1 -0
- package/dist/components/organisms/ActivityFeed/index.cjs +3 -26
- package/dist/components/organisms/ActivityFeed/index.cjs.map +1 -1
- package/dist/components/organisms/ActivityFeed/index.d.ts +7 -52
- package/dist/components/organisms/ActivityFeed/index.d.ts.map +1 -1
- package/dist/components/organisms/ActivityFeed/index.js +3 -26
- package/dist/components/organisms/ActivityFeed/index.js.map +1 -1
- package/dist/components/organisms/Calendar/components/CalendarDayView.cjs +1 -1
- package/dist/components/organisms/Calendar/components/CalendarDayView.js +1 -1
- package/dist/components/{molecules → organisms}/Carousel/hooks/useCarouselScroll.cjs +4 -1
- package/dist/components/organisms/Carousel/hooks/useCarouselScroll.cjs.map +1 -0
- package/dist/components/{molecules → organisms}/Carousel/hooks/useCarouselScroll.d.ts +3 -3
- package/dist/components/{molecules → organisms}/Carousel/hooks/useCarouselScroll.d.ts.map +1 -1
- package/dist/components/{molecules → organisms}/Carousel/hooks/useCarouselScroll.js +4 -1
- package/dist/components/organisms/Carousel/hooks/useCarouselScroll.js.map +1 -0
- package/dist/components/organisms/Carousel/index.cjs +155 -0
- package/dist/components/organisms/Carousel/index.cjs.map +1 -0
- package/dist/components/organisms/Carousel/index.d.ts +133 -0
- package/dist/components/organisms/Carousel/index.d.ts.map +1 -0
- package/dist/components/organisms/Carousel/index.js +152 -0
- package/dist/components/organisms/Carousel/index.js.map +1 -0
- package/dist/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.cjs +39 -0
- package/dist/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.cjs.map +1 -0
- package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetCollapse.d.ts +7 -3
- package/dist/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.d.ts.map +1 -0
- package/dist/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.js +37 -0
- package/dist/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.js.map +1 -0
- package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.cjs.map +1 -1
- package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.d.ts.map +1 -1
- package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.js.map +1 -1
- package/dist/components/organisms/CodeSnippet/index.cjs +126 -0
- package/dist/components/organisms/CodeSnippet/index.cjs.map +1 -0
- package/dist/components/organisms/CodeSnippet/index.d.ts +69 -0
- package/dist/components/organisms/CodeSnippet/index.d.ts.map +1 -0
- package/dist/components/organisms/CodeSnippet/index.js +123 -0
- package/dist/components/organisms/CodeSnippet/index.js.map +1 -0
- package/dist/components/organisms/CodeSnippet/utilities/codeSnippet.utils.cjs.map +1 -0
- package/dist/components/organisms/CodeSnippet/utilities/codeSnippet.utils.d.ts.map +1 -0
- package/dist/components/organisms/CodeSnippet/utilities/codeSnippet.utils.js.map +1 -0
- package/dist/components/organisms/DatePicker/index.cjs +9 -57
- package/dist/components/organisms/DatePicker/index.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/index.d.ts +15 -29
- package/dist/components/organisms/DatePicker/index.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/index.js +8 -56
- package/dist/components/organisms/DatePicker/index.js.map +1 -1
- package/dist/components/organisms/{DatePicker/components → DatePickers/DatePicker}/Calendar.cjs +2 -2
- package/dist/components/organisms/DatePickers/DatePicker/Calendar.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/DatePicker/Calendar.d.ts.map +1 -0
- package/dist/components/organisms/{DatePicker/components → DatePickers/DatePicker}/Calendar.js +2 -2
- package/dist/components/organisms/DatePickers/DatePicker/Calendar.js.map +1 -0
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs +55 -0
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.d.ts +31 -0
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js +53 -0
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js.map +1 -0
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs +73 -0
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs.map +1 -0
- package/dist/components/organisms/{DatePicker/components → DatePickers/DateRangePicker}/DateRangePicker.d.ts +4 -2
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js +71 -0
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js.map +1 -0
- package/dist/components/organisms/{DatePicker/components → DatePickers/RangeCalendar}/RangeCalendar.cjs +2 -2
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.d.ts.map +1 -0
- package/dist/components/organisms/{DatePicker/components → DatePickers/RangeCalendar}/RangeCalendar.js +2 -2
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js.map +1 -0
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/components/CalendarOverlay.js.map +1 -0
- package/dist/components/organisms/{DatePicker → DatePickers}/components/Cell.cjs +1 -1
- package/dist/components/organisms/DatePickers/components/Cell.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/components/Cell.d.ts.map +1 -0
- package/dist/components/organisms/{DatePicker → DatePickers}/components/Cell.js +1 -1
- package/dist/components/organisms/DatePickers/components/Cell.js.map +1 -0
- package/dist/components/organisms/DatePickers/components/InputDate.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/components/InputDate.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/components/InputDate.js.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useDatePickerDraft.cjs +27 -0
- package/dist/components/organisms/DatePickers/hooks/useDatePickerDraft.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useDatePickerDraft.d.ts +18 -0
- package/dist/components/organisms/DatePickers/hooks/useDatePickerDraft.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useDatePickerDraft.js +25 -0
- package/dist/components/organisms/DatePickers/hooks/useDatePickerDraft.js.map +1 -0
- package/dist/components/organisms/DatePickers/index.cjs +12 -0
- package/dist/components/organisms/DatePickers/index.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/index.d.ts +16 -0
- package/dist/components/organisms/DatePickers/index.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/index.js +4 -0
- package/dist/components/organisms/DatePickers/index.js.map +1 -0
- package/dist/components/organisms/DatePickers/utilities/calendarCell.utils.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/utilities/calendarCell.utils.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/utilities/calendarCell.utils.js.map +1 -0
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.cjs +47 -0
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.d.ts +74 -0
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.js +45 -0
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.js.map +1 -0
- package/dist/components/organisms/Messaging/index.cjs +5 -49
- package/dist/components/organisms/Messaging/index.cjs.map +1 -1
- package/dist/components/organisms/Messaging/index.d.ts +9 -68
- package/dist/components/organisms/Messaging/index.d.ts.map +1 -1
- package/dist/components/organisms/Messaging/index.js +5 -49
- package/dist/components/organisms/Messaging/index.js.map +1 -1
- package/dist/native/components/atoms/BrandButtons/index.d.ts +12 -0
- package/dist/native/components/molecules/ActivityFeed/index.d.ts +12 -0
- package/dist/native/components/molecules/Messaging/index.d.ts +12 -0
- package/dist/native/components/molecules/Notifications/index.d.ts +12 -0
- package/dist/native/components/organisms/Carousel/index.d.ts +12 -0
- package/dist/native/components/organisms/CodeSnippet/index.d.ts +12 -0
- package/dist/native/components/organisms/DatePickers/index.d.ts +12 -0
- package/package.json +1 -1
- package/dist/components/atoms/AppStoreButton/components/AppStoreBadgeLink.cjs.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/AppStoreBadgeLink.d.ts.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/AppStoreBadgeLink.js.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/AppStoreButtonsOutline.cjs.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/AppStoreButtonsOutline.d.ts.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/AppStoreButtonsOutline.js.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/GooglePlayPaths.cjs.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/GooglePlayPaths.d.ts.map +0 -1
- package/dist/components/atoms/AppStoreButton/components/GooglePlayPaths.js.map +0 -1
- package/dist/components/atoms/SocialButton/components/SocialLogos.cjs.map +0 -1
- package/dist/components/atoms/SocialButton/components/SocialLogos.d.ts.map +0 -1
- package/dist/components/atoms/SocialButton/components/SocialLogos.js.map +0 -1
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.cjs.map +0 -1
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.js.map +0 -1
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.cjs.map +0 -1
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.d.ts.map +0 -1
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.js.map +0 -1
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.cjs +0 -29
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.cjs.map +0 -1
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.d.ts.map +0 -1
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.js +0 -27
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.js.map +0 -1
- package/dist/components/organisms/DatePicker/calendarCell.utils.cjs.map +0 -1
- package/dist/components/organisms/DatePicker/calendarCell.utils.d.ts.map +0 -1
- package/dist/components/organisms/DatePicker/calendarCell.utils.js.map +0 -1
- package/dist/components/organisms/DatePicker/components/Calendar.cjs.map +0 -1
- package/dist/components/organisms/DatePicker/components/Calendar.d.ts.map +0 -1
- package/dist/components/organisms/DatePicker/components/Calendar.js.map +0 -1
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.cjs.map +0 -1
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.d.ts.map +0 -1
- package/dist/components/organisms/DatePicker/components/CalendarOverlay.js.map +0 -1
- package/dist/components/organisms/DatePicker/components/Cell.cjs.map +0 -1
- package/dist/components/organisms/DatePicker/components/Cell.d.ts.map +0 -1
- package/dist/components/organisms/DatePicker/components/Cell.js.map +0 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs +0 -108
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs.map +0 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts.map +0 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js +0 -106
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js.map +0 -1
- package/dist/components/organisms/DatePicker/components/InputDate.cjs.map +0 -1
- package/dist/components/organisms/DatePicker/components/InputDate.d.ts.map +0 -1
- package/dist/components/organisms/DatePicker/components/InputDate.js.map +0 -1
- package/dist/components/organisms/DatePicker/components/RangeCalendar.cjs.map +0 -1
- package/dist/components/organisms/DatePicker/components/RangeCalendar.d.ts.map +0 -1
- package/dist/components/organisms/DatePicker/components/RangeCalendar.js.map +0 -1
- package/dist/components/organisms/Messaging/components/MessageItemActions.cjs +0 -13
- package/dist/components/organisms/Messaging/components/MessageItemActions.cjs.map +0 -1
- package/dist/components/organisms/Messaging/components/MessageItemActions.d.ts.map +0 -1
- package/dist/components/organisms/Messaging/components/MessageItemActions.js +0 -11
- package/dist/components/organisms/Messaging/components/MessageItemActions.js.map +0 -1
- package/dist/components/organisms/Messaging/messageItem.utils.cjs.map +0 -1
- package/dist/components/organisms/Messaging/messageItem.utils.d.ts.map +0 -1
- package/dist/components/organisms/Messaging/messageItem.utils.js.map +0 -1
- /package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/AppStoreButtonsOutline.cjs +0 -0
- /package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/AppStoreButtonsOutline.d.ts +0 -0
- /package/dist/components/atoms/{AppStoreButton/components → BrandButtons/AppStoreButton}/AppStoreButtonsOutline.js +0 -0
- /package/dist/components/atoms/{SocialButton/components → BrandButtons/SocialButton}/SocialLogos.cjs +0 -0
- /package/dist/components/atoms/{SocialButton/components → BrandButtons/SocialButton}/SocialLogos.d.ts +0 -0
- /package/dist/components/atoms/{SocialButton/components → BrandButtons/SocialButton}/SocialLogos.js +0 -0
- /package/dist/components/{organisms/Messaging → molecules/Messaging/utilities}/messageItem.utils.d.ts +0 -0
- /package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.cjs +0 -0
- /package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.d.ts +0 -0
- /package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.js +0 -0
- /package/dist/components/{molecules/CodeSnippet → organisms/CodeSnippet/utilities}/codeSnippet.utils.cjs +0 -0
- /package/dist/components/{molecules/CodeSnippet → organisms/CodeSnippet/utilities}/codeSnippet.utils.d.ts +0 -0
- /package/dist/components/{molecules/CodeSnippet → organisms/CodeSnippet/utilities}/codeSnippet.utils.js +0 -0
- /package/dist/components/organisms/{DatePicker/components → DatePickers/DatePicker}/Calendar.d.ts +0 -0
- /package/dist/components/organisms/{DatePicker/components → DatePickers/RangeCalendar}/RangeCalendar.d.ts +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers}/components/CalendarOverlay.cjs +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers}/components/CalendarOverlay.d.ts +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers}/components/CalendarOverlay.js +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers}/components/Cell.d.ts +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers}/components/InputDate.cjs +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers}/components/InputDate.d.ts +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers}/components/InputDate.js +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers/utilities}/calendarCell.utils.cjs +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers/utilities}/calendarCell.utils.d.ts +0 -0
- /package/dist/components/organisms/{DatePicker → DatePickers/utilities}/calendarCell.utils.js +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Dot } from '@flipdish/ui-library/components/atoms/Dot';
|
|
3
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
|
+
import { useTestIdPrefix, joinTestId, useResolvedTestId, TestIdProvider } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
|
+
import { createContext, isValidElement, cloneElement, useContext } from 'react';
|
|
6
|
+
import { useCarouselScroll } from './hooks/useCarouselScroll.js';
|
|
7
|
+
|
|
8
|
+
const CarouselContext = createContext(null);
|
|
9
|
+
/**
|
|
10
|
+
* Reads the nearest `Carousel.Root`, for building a custom control inside it. It throws when called
|
|
11
|
+
* outside `Carousel.Root`.
|
|
12
|
+
*
|
|
13
|
+
* @returns The carousel's options and Embla API, the previous and next actions with whether each can scroll, the selected snap index and every snap position.
|
|
14
|
+
*/
|
|
15
|
+
const useCarousel = () => {
|
|
16
|
+
const context = useContext(CarouselContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw new Error('The `useCarousel` hook must be used within a <Carousel />');
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
22
|
+
const CarouselRoot = ({ orientation = 'horizontal', opts, setApi, plugins, className, children, 'data-testid': dataTestId, ...props }) => {
|
|
23
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'carousel', rootName: 'carousel' });
|
|
24
|
+
const { carouselRef, api, scrollPrev, scrollNext, canScrollPrev, canScrollNext, selectedIndex, scrollSnaps, onKeyDownCapture } = useCarouselScroll({
|
|
25
|
+
orientation,
|
|
26
|
+
opts,
|
|
27
|
+
plugins,
|
|
28
|
+
setApi,
|
|
29
|
+
});
|
|
30
|
+
// A `region` landmark needs a name, and `aria-roledescription` does not supply one.
|
|
31
|
+
const isNamed = Boolean(props['aria-label'] || props['aria-labelledby']);
|
|
32
|
+
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(CarouselContext.Provider, { value: {
|
|
33
|
+
carouselRef,
|
|
34
|
+
api: api,
|
|
35
|
+
opts,
|
|
36
|
+
orientation,
|
|
37
|
+
scrollPrev,
|
|
38
|
+
scrollNext,
|
|
39
|
+
canScrollPrev,
|
|
40
|
+
canScrollNext,
|
|
41
|
+
selectedIndex,
|
|
42
|
+
scrollSnaps,
|
|
43
|
+
}, children: jsx("div", { onKeyDownCapture: onKeyDownCapture, className: cx('relative', className), role: isNamed ? 'region' : 'group', "aria-roledescription": "carousel", ...props, "data-testid": rootTestId, children: children }) }) }));
|
|
44
|
+
};
|
|
45
|
+
const CarouselContent = ({ className, overflowHidden = true, ...props }) => {
|
|
46
|
+
const { carouselRef, orientation } = useCarousel();
|
|
47
|
+
return (jsx("div", { ref: carouselRef, className: cx('h-full w-full', overflowHidden && 'overflow-hidden'), children: jsx("div", { className: cx('flex max-h-full', orientation === 'horizontal' ? '' : 'flex-col', className), ...props }) }));
|
|
48
|
+
};
|
|
49
|
+
const CarouselItem = ({ className, index, 'data-testid': dataTestId, ...props }) => {
|
|
50
|
+
const prefix = useTestIdPrefix();
|
|
51
|
+
const itemTestId = dataTestId ?? (prefix && index !== undefined ? joinTestId(prefix, `item-${index}`) : undefined);
|
|
52
|
+
return (
|
|
53
|
+
// biome-ignore lint/a11y/useSemanticElements: This is a custom component and we need to use a div to wrap the children
|
|
54
|
+
jsx("div", { role: "group", "aria-roledescription": "slide", className: cx('min-w-0 shrink-0 grow-0 basis-full', className), ...props, "data-testid": itemTestId }));
|
|
55
|
+
};
|
|
56
|
+
const Trigger = ({ className, children, asChild, direction, style, 'data-testid': dataTestId, ...props }) => {
|
|
57
|
+
const { scrollPrev, canScrollNext, scrollNext, canScrollPrev } = useCarousel();
|
|
58
|
+
const prefix = useTestIdPrefix();
|
|
59
|
+
const triggerTestId = dataTestId ?? (prefix ? joinTestId(prefix, direction) : undefined);
|
|
60
|
+
const isDisabled = direction === 'prev' ? !canScrollPrev : !canScrollNext;
|
|
61
|
+
const handleClick = () => {
|
|
62
|
+
if (isDisabled)
|
|
63
|
+
return;
|
|
64
|
+
direction === 'prev' ? scrollPrev() : scrollNext();
|
|
65
|
+
};
|
|
66
|
+
const computedClassName = typeof className === 'function' ? className({ isDisabled }) : className;
|
|
67
|
+
const defaultAriaLabel = direction === 'prev' ? 'Previous slide' : 'Next slide';
|
|
68
|
+
// If the children is a render prop, we need to pass the necessary props to the render prop.
|
|
69
|
+
if (typeof children === 'function') {
|
|
70
|
+
return jsx(Fragment, { children: children({ isDisabled, onClick: handleClick, 'data-testid': triggerTestId }) });
|
|
71
|
+
}
|
|
72
|
+
// If the children is a valid element, we need to clone it and pass the necessary props to the cloned element.
|
|
73
|
+
if (asChild && isValidElement(children)) {
|
|
74
|
+
const childProps = children.props;
|
|
75
|
+
return cloneElement(children, {
|
|
76
|
+
onClick: handleClick,
|
|
77
|
+
disabled: isDisabled,
|
|
78
|
+
'aria-label': childProps['aria-label'] ?? defaultAriaLabel,
|
|
79
|
+
'data-testid': triggerTestId,
|
|
80
|
+
style: { ...childProps.style, ...style },
|
|
81
|
+
className: [computedClassName, childProps.className].filter(Boolean).join(' ') || undefined,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return (jsx("button", { type: "button", "aria-label": defaultAriaLabel, disabled: isDisabled, className: computedClassName, style: style, onClick: handleClick, ...props, "data-testid": triggerTestId, children: children }));
|
|
85
|
+
};
|
|
86
|
+
const CarouselPrevTrigger = (props) => jsx(Trigger, { ...props, direction: "prev" });
|
|
87
|
+
const CarouselNextTrigger = (props) => jsx(Trigger, { ...props, direction: "next" });
|
|
88
|
+
const CarouselIndicator = ({ index, isSelected = false, children, asChild, className, style, 'data-testid': dataTestId }) => {
|
|
89
|
+
const { api, selectedIndex } = useCarousel();
|
|
90
|
+
const prefix = useTestIdPrefix();
|
|
91
|
+
const indicatorTestId = dataTestId ?? (prefix ? joinTestId(prefix, `indicator-${index}`) : undefined);
|
|
92
|
+
isSelected = isSelected || selectedIndex === index;
|
|
93
|
+
const handleClick = () => {
|
|
94
|
+
api?.scrollTo(index);
|
|
95
|
+
};
|
|
96
|
+
const computedClassName = typeof className === 'function' ? className({ isSelected }) : className;
|
|
97
|
+
const defaultAriaLabel = `Go to slide ${index + 1}`;
|
|
98
|
+
// If the children is a render prop, we need to pass the necessary props to the render prop.
|
|
99
|
+
if (typeof children === 'function') {
|
|
100
|
+
return jsx(Fragment, { children: children({ isSelected, onClick: handleClick, 'data-testid': indicatorTestId }) });
|
|
101
|
+
}
|
|
102
|
+
// If the children is a valid element, we need to clone it and pass the necessary props to the cloned element.
|
|
103
|
+
if (asChild && isValidElement(children)) {
|
|
104
|
+
const childProps = children.props;
|
|
105
|
+
return cloneElement(children, {
|
|
106
|
+
onClick: handleClick,
|
|
107
|
+
'aria-label': childProps['aria-label'] ?? defaultAriaLabel,
|
|
108
|
+
'aria-current': isSelected ? 'true' : undefined,
|
|
109
|
+
'data-testid': indicatorTestId,
|
|
110
|
+
style: { ...childProps.style, ...style },
|
|
111
|
+
className: [computedClassName, childProps.className].filter(Boolean).join(' ') || undefined,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return (jsx("button", { type: "button", "aria-label": defaultAriaLabel, "aria-current": isSelected ? 'true' : undefined, className: computedClassName, style: style, onClick: handleClick, "data-testid": indicatorTestId, children: children }));
|
|
115
|
+
};
|
|
116
|
+
const CarouselIndicatorGroup = ({ children, ...props }) => {
|
|
117
|
+
const { scrollSnaps } = useCarousel();
|
|
118
|
+
// If the children is a render prop, we need to pass the index to the render prop.
|
|
119
|
+
if (typeof children === 'function') {
|
|
120
|
+
return jsx("nav", { ...props, children: scrollSnaps.map((_, index) => children({ index })) });
|
|
121
|
+
}
|
|
122
|
+
return jsx("nav", { ...props, children: children });
|
|
123
|
+
};
|
|
124
|
+
const CarouselIndicatorBar = ({ framed, className }) => {
|
|
125
|
+
const { scrollSnaps, selectedIndex, api } = useCarousel();
|
|
126
|
+
const prefix = useTestIdPrefix();
|
|
127
|
+
return (jsx("nav", { className: cx('flex items-center gap-1.5', framed && 'rounded-full bg-primary/90 px-2.5 py-2 shadow-md backdrop-blur-xs', className), children: scrollSnaps.map((_, index) => (jsx("button", { type: "button", "aria-label": `Go to slide ${index + 1}`, "aria-current": selectedIndex === index ? 'true' : undefined, onClick: () => api?.scrollTo(index), "data-testid": prefix ? joinTestId(prefix, `indicator-${index}`) : undefined, children: jsx(Dot, { size: "sm", color: selectedIndex === index ? 'brand-solid' : 'fg-quaternary' }) }, index))) }));
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Scrollable sequence of slides with previous/next navigation and optional dot
|
|
131
|
+
* indicators.
|
|
132
|
+
Compose `Carousel.Root`, `Carousel.Content`, `Carousel.Item`,
|
|
133
|
+
* `Carousel.PrevTrigger`,
|
|
134
|
+
`Carousel.NextTrigger`, `Carousel.IndicatorGroup`, and
|
|
135
|
+
* `Carousel.Indicator` to build
|
|
136
|
+
fully custom carousel layouts.
|
|
137
|
+
*
|
|
138
|
+
* @summary slides with navigation controls and indicators
|
|
139
|
+
*/
|
|
140
|
+
const Carousel = {
|
|
141
|
+
Root: CarouselRoot,
|
|
142
|
+
Content: CarouselContent,
|
|
143
|
+
Item: CarouselItem,
|
|
144
|
+
PrevTrigger: CarouselPrevTrigger,
|
|
145
|
+
NextTrigger: CarouselNextTrigger,
|
|
146
|
+
IndicatorGroup: CarouselIndicatorGroup,
|
|
147
|
+
Indicator: CarouselIndicator,
|
|
148
|
+
IndicatorBar: CarouselIndicatorBar,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export { Carousel, useCarousel };
|
|
152
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/organisms/Carousel/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAyCA,MAAM,eAAe,GAAG,aAAa,CAA8B,IAAI,CAAC;AAExE;;;;;AAKG;AACI,MAAM,WAAW,GAAG,MAAK;AAC9B,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC;IAE3C,IAAI,CAAC,O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KAAK,CAQH,CACV,CAAC,EAAA,CACE;AAEV,CAAC;AAED;;;;;;;;;;AAUG;AACI,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;AACxB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,WAAW,EAAE,mBAAmB;AAChC,IAAA,WAAW,EAAE,mBAAmB;AAChC,IAAA,cAAc,EAAE,sBAAsB;AACtC,IAAA,SAAS,EAAE,iBAAiB;AAC5B,IAAA,YAAY,EAAE,oBAAoB;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Measures the code block against `maxHeight` and tracks whether the reader has expanded it.
|
|
7
|
+
* The comparison subtracts 10px, so a block that only barely overflows does not show the toggle.
|
|
8
|
+
* The block is measured as it rests, without the class the caller adds while it overflows, so one
|
|
9
|
+
* that later shrinks to fit stops overflowing whatever its layout is by then.
|
|
10
|
+
*
|
|
11
|
+
* @param options The height cap, the content whose scroll height is measured, and the caller's overflow class.
|
|
12
|
+
* @returns The content ref, whether it overflows, whether it is expanded, and a toggle.
|
|
13
|
+
*/
|
|
14
|
+
const useCodeSnippetCollapse = ({ maxHeight, nodes, children, overflowClassName, }) => {
|
|
15
|
+
const contentRef = React.useRef(null);
|
|
16
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
17
|
+
const [exceedsMaxHeight, setExceedsMaxHeight] = React.useState(false);
|
|
18
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: nodes and children change the measured scrollHeight without being read
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
const content = contentRef.current;
|
|
21
|
+
if (!maxHeight || !content)
|
|
22
|
+
return;
|
|
23
|
+
// Lifted and put back before the browser paints: no stored baseline can go stale when the layout changes.
|
|
24
|
+
const hasOverflowClass = Boolean(overflowClassName) && content.classList.contains(overflowClassName);
|
|
25
|
+
if (hasOverflowClass)
|
|
26
|
+
content.classList.remove(overflowClassName);
|
|
27
|
+
const restingHeight = content.scrollHeight;
|
|
28
|
+
if (hasOverflowClass)
|
|
29
|
+
content.classList.add(overflowClassName);
|
|
30
|
+
setExceedsMaxHeight(restingHeight > maxHeight - 10);
|
|
31
|
+
}, [maxHeight, nodes, children, overflowClassName]);
|
|
32
|
+
const toggleExpanded = () => {
|
|
33
|
+
setExpanded(!expanded);
|
|
34
|
+
};
|
|
35
|
+
return { contentRef, exceedsMaxHeight, expanded, toggleExpanded };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.useCodeSnippetCollapse = useCodeSnippetCollapse;
|
|
39
|
+
//# sourceMappingURL=useCodeSnippetCollapse.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCodeSnippetCollapse.cjs","sources":["../../../../../src/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.ts"],"sourcesContent":[null],"names":["useRef","useState","useEffect"],"mappings":";;;;AA0BA;;;;;;;;AAQG;AACI,MAAM,sBAAsB,GAAG,CAAC,EACrC,SAAS,EACT,KAAK,EACL,QAAQ,EACR,iBAAiB,GACa,KAAkC;AAChE,IAAA,MAAM,UAAU,GAAGA,YAAM,CAAiB,IAAI,CAAC;IAC/C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;IAC/C,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;;IAG/DC,eAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO;AAClC,QAAA,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO;YAAE;;AAE5B,QAAA,MAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,iBAAuB,CAAC;AAC1G,QAAA,IAAI,gBAAgB;YAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAuB,CAAC;AACvE,QAAA,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY;AAC1C,QAAA,IAAI,gBAAgB;YAAE,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAuB,CAAC;AACpE,QAAA,mBAAmB,CAAC,aAAa,GAAG,SAAS,GAAG,EAAE,CAAC;IACrD,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAEnD,MAAM,cAAc,GAAG,MAAK;AAC1B,QAAA,WAAW,CAAC,CAAC,QAAQ,CAAC;AACxB,IAAA,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE;AACnE;;"}
|
package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetCollapse.d.ts
RENAMED
|
@@ -6,11 +6,13 @@ interface UseCodeSnippetCollapseOptions {
|
|
|
6
6
|
nodes: ReactNode;
|
|
7
7
|
/** Pre-highlighted children. A new value can change the measured height. */
|
|
8
8
|
children?: ReactNode;
|
|
9
|
+
/** Class the caller puts on the content while it overflows. It is lifted for the measurement, so its padding is not counted as content. */
|
|
10
|
+
overflowClassName?: string;
|
|
9
11
|
}
|
|
10
12
|
interface UseCodeSnippetCollapseResult {
|
|
11
13
|
/** Ref for the element whose `scrollHeight` is compared with `maxHeight`. */
|
|
12
14
|
contentRef: RefObject<HTMLDivElement | null>;
|
|
13
|
-
/** True once the content is taller than `maxHeight` minus a 10px inset
|
|
15
|
+
/** True once the content is taller than `maxHeight` minus a 10px inset, measured without `overflowClassName`. */
|
|
14
16
|
exceedsMaxHeight: boolean;
|
|
15
17
|
/** True after the reader expands a block that overflows. */
|
|
16
18
|
expanded: boolean;
|
|
@@ -20,10 +22,12 @@ interface UseCodeSnippetCollapseResult {
|
|
|
20
22
|
/**
|
|
21
23
|
* Measures the code block against `maxHeight` and tracks whether the reader has expanded it.
|
|
22
24
|
* The comparison subtracts 10px, so a block that only barely overflows does not show the toggle.
|
|
25
|
+
* The block is measured as it rests, without the class the caller adds while it overflows, so one
|
|
26
|
+
* that later shrinks to fit stops overflowing whatever its layout is by then.
|
|
23
27
|
*
|
|
24
|
-
* @param options The height cap
|
|
28
|
+
* @param options The height cap, the content whose scroll height is measured, and the caller's overflow class.
|
|
25
29
|
* @returns The content ref, whether it overflows, whether it is expanded, and a toggle.
|
|
26
30
|
*/
|
|
27
|
-
export declare const useCodeSnippetCollapse: ({ maxHeight, nodes, children }: UseCodeSnippetCollapseOptions) => UseCodeSnippetCollapseResult;
|
|
31
|
+
export declare const useCodeSnippetCollapse: ({ maxHeight, nodes, children, overflowClassName, }: UseCodeSnippetCollapseOptions) => UseCodeSnippetCollapseResult;
|
|
28
32
|
export {};
|
|
29
33
|
//# sourceMappingURL=useCodeSnippetCollapse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCodeSnippetCollapse.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEpF,UAAU,6BAA6B;IACrC,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,KAAK,EAAE,SAAS,CAAC;IACjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,2IAA2I;IAC3I,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,UAAU,4BAA4B;IACpC,6EAA6E;IAC7E,UAAU,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC7C,iHAAiH;IACjH,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;IAClB,wBAAwB;IACxB,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAAI,oDAKpC,6BAA6B,KAAG,4BAsBlC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Measures the code block against `maxHeight` and tracks whether the reader has expanded it.
|
|
5
|
+
* The comparison subtracts 10px, so a block that only barely overflows does not show the toggle.
|
|
6
|
+
* The block is measured as it rests, without the class the caller adds while it overflows, so one
|
|
7
|
+
* that later shrinks to fit stops overflowing whatever its layout is by then.
|
|
8
|
+
*
|
|
9
|
+
* @param options The height cap, the content whose scroll height is measured, and the caller's overflow class.
|
|
10
|
+
* @returns The content ref, whether it overflows, whether it is expanded, and a toggle.
|
|
11
|
+
*/
|
|
12
|
+
const useCodeSnippetCollapse = ({ maxHeight, nodes, children, overflowClassName, }) => {
|
|
13
|
+
const contentRef = useRef(null);
|
|
14
|
+
const [expanded, setExpanded] = useState(false);
|
|
15
|
+
const [exceedsMaxHeight, setExceedsMaxHeight] = useState(false);
|
|
16
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: nodes and children change the measured scrollHeight without being read
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const content = contentRef.current;
|
|
19
|
+
if (!maxHeight || !content)
|
|
20
|
+
return;
|
|
21
|
+
// Lifted and put back before the browser paints: no stored baseline can go stale when the layout changes.
|
|
22
|
+
const hasOverflowClass = Boolean(overflowClassName) && content.classList.contains(overflowClassName);
|
|
23
|
+
if (hasOverflowClass)
|
|
24
|
+
content.classList.remove(overflowClassName);
|
|
25
|
+
const restingHeight = content.scrollHeight;
|
|
26
|
+
if (hasOverflowClass)
|
|
27
|
+
content.classList.add(overflowClassName);
|
|
28
|
+
setExceedsMaxHeight(restingHeight > maxHeight - 10);
|
|
29
|
+
}, [maxHeight, nodes, children, overflowClassName]);
|
|
30
|
+
const toggleExpanded = () => {
|
|
31
|
+
setExpanded(!expanded);
|
|
32
|
+
};
|
|
33
|
+
return { contentRef, exceedsMaxHeight, expanded, toggleExpanded };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { useCodeSnippetCollapse };
|
|
37
|
+
//# sourceMappingURL=useCodeSnippetCollapse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCodeSnippetCollapse.js","sources":["../../../../../src/components/organisms/CodeSnippet/hooks/useCodeSnippetCollapse.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA0BA;;;;;;;;AAQG;AACI,MAAM,sBAAsB,GAAG,CAAC,EACrC,SAAS,EACT,KAAK,EACL,QAAQ,EACR,iBAAiB,GACa,KAAkC;AAChE,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC;IAC/C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC/C,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;;IAG/D,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO;AAClC,QAAA,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO;YAAE;;AAE5B,QAAA,MAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,iBAAuB,CAAC;AAC1G,QAAA,IAAI,gBAAgB;YAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAuB,CAAC;AACvE,QAAA,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY;AAC1C,QAAA,IAAI,gBAAgB;YAAE,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAuB,CAAC;AACpE,QAAA,mBAAmB,CAAC,aAAa,GAAG,SAAS,GAAG,EAAE,CAAC;IACrD,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAEnD,MAAM,cAAc,GAAG,MAAK;AAC1B,QAAA,WAAW,CAAC,CAAC,QAAQ,CAAC;AACxB,IAAA,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE;AACnE;;"}
|
package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.cjs.map
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCodeSnippetHighlight.cjs","sources":["../../../../../src/components/
|
|
1
|
+
{"version":3,"file":"useCodeSnippetHighlight.cjs","sources":["../../../../../src/components/organisms/CodeSnippet/hooks/useCodeSnippetHighlight.ts"],"sourcesContent":[null],"names":["useState","useRef","useLayoutEffect","isProductionBuild"],"mappings":";;;;;AAgBA;;;;;;;AAOG;AACI,MAAM,uBAAuB,GAAG,CAA0B,EAC/D,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,aAAa,GAC4B,KAAe;IACxD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,QAAQ,CAAC;;AAE5C,IAAA,MAAM,WAAW,GAAGC,YAAM,CAAC,QAAQ,CAAC;IACpCC,qBAAe,CAAC,MAAK;AACnB,QAAA,WAAW,CAAC,OAAO,GAAG,QAAQ;AAChC,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEdA,qBAAe,CAAC,MAAK;AACnB,QAAA,IAAI,CAAC,IAAI;YAAE;;QAEX,IAAI,KAAK,GAAG,KAAK;QACjB,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,IAAI,CAChC,CAAC,WAAW,KAAI;AACd,YAAA,IAAI,CAAC,KAAK;gBAAE,QAAQ,CAAC,WAAW,CAAC;AACnC,QAAA,CAAC,EACD,CAAC,KAAc,KAAI;;AAEjB,YAAA,IAAI,KAAK;gBAAE;AACX,YAAA,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC;YAC7B,IAAI,CAACC,6BAAiB,EAAE;AAAE,gBAAA,OAAO,CAAC,IAAI,CAAC,uDAAuD,EAAE,KAAK,CAAC;AACxG,QAAA,CAAC,CACF;AACD,QAAA,OAAO,MAAK;YACV,KAAK,GAAG,IAAI;AACd,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEnC,IAAA,OAAO,KAAK;AACd;;"}
|
package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.d.ts.map
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCodeSnippetHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/components/
|
|
1
|
+
{"version":3,"file":"useCodeSnippetHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/CodeSnippet/hooks/useCodeSnippetHighlight.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,OAAO,CAAC;AAE1E,UAAU,8BAA8B,CAAC,QAAQ,SAAS,MAAM;IAC9D,mGAAmG;IACnG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,QAAQ,EAAE,QAAQ,CAAC;IACnB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,0EAA0E;IAC1E,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;CACzE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,SAAS,MAAM,EAAE,8CAK9D,8BAA8B,CAAC,QAAQ,CAAC,KAAG,SA6B7C,CAAC"}
|
package/dist/components/{molecules → organisms}/CodeSnippet/hooks/useCodeSnippetHighlight.js.map
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCodeSnippetHighlight.js","sources":["../../../../../src/components/
|
|
1
|
+
{"version":3,"file":"useCodeSnippetHighlight.js","sources":["../../../../../src/components/organisms/CodeSnippet/hooks/useCodeSnippetHighlight.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAgBA;;;;;;;AAOG;AACI,MAAM,uBAAuB,GAAG,CAA0B,EAC/D,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,aAAa,GAC4B,KAAe;IACxD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC;;AAE5C,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC;IACpC,eAAe,CAAC,MAAK;AACnB,QAAA,WAAW,CAAC,OAAO,GAAG,QAAQ;AAChC,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEd,eAAe,CAAC,MAAK;AACnB,QAAA,IAAI,CAAC,IAAI;YAAE;;QAEX,IAAI,KAAK,GAAG,KAAK;QACjB,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,IAAI,CAChC,CAAC,WAAW,KAAI;AACd,YAAA,IAAI,CAAC,KAAK;gBAAE,QAAQ,CAAC,WAAW,CAAC;AACnC,QAAA,CAAC,EACD,CAAC,KAAc,KAAI;;AAEjB,YAAA,IAAI,KAAK;gBAAE;AACX,YAAA,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC;YAC7B,IAAI,CAAC,iBAAiB,EAAE;AAAE,gBAAA,OAAO,CAAC,IAAI,CAAC,uDAAuD,EAAE,KAAK,CAAC;AACxG,QAAA,CAAC,CACF;AACD,QAAA,OAAO,MAAK;YACV,KAAK,GAAG,IAAI;AACd,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEnC,IAAA,OAAO,KAAK;AACd;;"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
6
|
+
var UtilityButton = require('@flipdish/ui-library/components/atoms/UtilityButton');
|
|
7
|
+
var useClipboard = require('@flipdish/ui-library/hooks/useClipboard');
|
|
8
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
9
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
10
|
+
var hastUtilToJsxRuntime = require('hast-util-to-jsx-runtime');
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var reactAriaComponents = require('react-aria-components');
|
|
13
|
+
var useCodeSnippetCollapse = require('./hooks/useCodeSnippetCollapse.cjs');
|
|
14
|
+
var useCodeSnippetHighlight = require('./hooks/useCodeSnippetHighlight.cjs');
|
|
15
|
+
var codeSnippet_utils = require('./utilities/codeSnippet.utils.cjs');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Highlights source into React nodes with the snippet's themes, loading the grammar on first use.
|
|
19
|
+
* @param code The source to highlight.
|
|
20
|
+
* @param lang The language id; one Shiki does not know renders as plain text.
|
|
21
|
+
* @returns The highlighted `<pre>` tree, ready to render in place of the fallback.
|
|
22
|
+
*/
|
|
23
|
+
const highlight = async (code, lang) => {
|
|
24
|
+
const out = await codeSnippet_utils.highlightToHast(code, lang);
|
|
25
|
+
return hastUtilToJsxRuntime.toJsxRuntime(out, {
|
|
26
|
+
Fragment: React.Fragment,
|
|
27
|
+
jsx: jsxRuntime.jsx,
|
|
28
|
+
jsxs: jsxRuntime.jsxs,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Tabs context – shares a root ref so the header copy button can find the
|
|
33
|
+
* active panel's code text without fragile global DOM queries.
|
|
34
|
+
*/
|
|
35
|
+
// Bottom padding that keeps the last lines clear of the "Show more" overlay; the collapse hook measures without it.
|
|
36
|
+
const OVERFLOW_PADDING_CLASS = 'pb-12';
|
|
37
|
+
const TabsRefContext = React.createContext(null);
|
|
38
|
+
/**
|
|
39
|
+
* Gradient CSS custom properties for the "Show more" overlay.
|
|
40
|
+
*/
|
|
41
|
+
const gradientStyles = {
|
|
42
|
+
'--gradient-light': 'rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.02) 4.7%, rgba(255, 255, 255, 0.04) 8.9%, rgba(255, 255, 255, 0.07) 12.8%, rgba(255, 255, 255, 0.10) 16.56%, rgba(255, 255, 255, 0.14) 20.37%, rgba(255, 255, 255, 0.18) 24.4%, rgba(255, 255, 255, 0.23) 28.83%, rgba(255, 255, 255, 0.29) 33.84%, rgba(255, 255, 255, 0.35) 39.6%, rgba(255, 255, 255, 0.43) 46.3%, rgba(255, 255, 255, 0.52) 54.1%, rgba(255, 255, 255, 0.62) 63.2%, rgba(255, 255, 255, 0.73) 73.76%, rgba(255, 255, 255, 0.86) 85.97%, #FFFFFF 100%',
|
|
43
|
+
'--gradient-dark': 'rgba(12, 14, 18, 0) 0%, rgba(12, 14, 18, 0.02) 4.7%, rgba(12, 14, 18, 0.04) 8.9%, rgba(12, 14, 18, 0.07) 12.8%, rgba(12, 14, 18, 0.10) 16.56%, rgba(12, 14, 18, 0.14) 20.37%, rgba(12, 14, 18, 0.18) 24.4%, rgba(12, 14, 18, 0.23) 28.83%, rgba(12, 14, 18, 0.29) 33.84%, rgba(12, 14, 18, 0.35) 39.6%, rgba(12, 14, 18, 0.43) 46.3%, rgba(12, 14, 18, 0.52) 54.1%, rgba(12, 14, 18, 0.62) 63.2%, rgba(12, 14, 18, 0.73) 73.76%, rgba(12, 14, 18, 0.86) 85.97%, rgb(12, 14, 18) 100%',
|
|
44
|
+
};
|
|
45
|
+
const CodeSnippetComponent = ({ children, code, language, showLineNumbers = true, maxHeight, onExpand, className, modern = true, 'data-testid': dataTestId, ...otherProps }) => {
|
|
46
|
+
const nodes = useCodeSnippetHighlight.useCodeSnippetHighlight({ code, language, fallback: children, highlightCode: highlight });
|
|
47
|
+
const { copy, copied } = useClipboard.useClipboard();
|
|
48
|
+
const { contentRef, expanded, exceedsMaxHeight, toggleExpanded } = useCodeSnippetCollapse.useCodeSnippetCollapse({
|
|
49
|
+
maxHeight,
|
|
50
|
+
nodes,
|
|
51
|
+
children,
|
|
52
|
+
overflowClassName: OVERFLOW_PADDING_CLASS,
|
|
53
|
+
});
|
|
54
|
+
const isInsideTabs = React.useContext(TabsRefContext) !== null;
|
|
55
|
+
const codeSnippetTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'code-snippet', rootName: 'code-snippet' });
|
|
56
|
+
const canCopy = Boolean(code || children);
|
|
57
|
+
// A pre-highlighted snippet has no `code`, so its text is read from what rendered, whitespace included.
|
|
58
|
+
const copyCode = () => {
|
|
59
|
+
const text = code || contentRef.current?.textContent;
|
|
60
|
+
if (text)
|
|
61
|
+
copy(text);
|
|
62
|
+
};
|
|
63
|
+
const isCollapsible = maxHeight != null && exceedsMaxHeight;
|
|
64
|
+
const isModern = isInsideTabs || modern;
|
|
65
|
+
const codeBlock = (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: codeSnippetTestId, children: jsxRuntime.jsxs("div", { ...otherProps, "data-testid": codeSnippetTestId, className: cx.cx('group/code-snippet relative max-w-full overflow-clip rounded-xl bg-primary ring-1', isModern ? 'shadow-lg ring-secondary_alt' : 'ring-secondary', className), children: [jsxRuntime.jsx("div", { ref: contentRef, className: cx.cx('[&>.shiki]:overflow-x-auto [&>code]:w-full', 'font-mono text-sm leading-[22px] whitespace-pre', showLineNumbers ? 'line-numbers' : 'p-4', !expanded && isCollapsible && 'overflow-y-hidden', isCollapsible && OVERFLOW_PADDING_CLASS), style: {
|
|
66
|
+
maxHeight: expanded || !maxHeight ? 'none' : maxHeight,
|
|
67
|
+
}, children: nodes ?? code ?? jsxRuntime.jsx("p", { children: "Loading..." }) }), isCollapsible && (jsxRuntime.jsx("div", { style: gradientStyles, className: cx.cx('inset-x-0 bottom-0 flex items-end justify-center bg-linear-(--gradient-light) pb-6 dark:bg-linear-(--gradient-dark)', expanded ? 'sticky h-17' : 'absolute h-47'), children: jsxRuntime.jsx(Button.Button, { color: "secondary", size: "sm", onClick: toggleExpanded, children: expanded ? 'Show less' : 'Show more' }) })), (canCopy || onExpand) && (jsxRuntime.jsxs("div", { className: "absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 transition duration-100 ease-linear group-hover/code-snippet:opacity-100 focus-within:opacity-100", children: [onExpand && (jsxRuntime.jsx(UtilityButton.ButtonUtility, { size: "xs", color: "tertiary", icon: uiIcons.Expand06, tooltip: "Expand", onClick: onExpand, "data-testid": testIdUtils.joinTestId(codeSnippetTestId, 'expand') })), canCopy && (jsxRuntime.jsx(UtilityButton.ButtonUtility, { size: "xs", color: "tertiary", icon: copied ? uiIcons.Check : uiIcons.Copy01, tooltip: "Copy", onClick: copyCode, "data-testid": testIdUtils.joinTestId(codeSnippetTestId, 'copy') }))] }))] }) }));
|
|
68
|
+
// Inside tabs: tabs component already provides the outer wrapper
|
|
69
|
+
if (isInsideTabs)
|
|
70
|
+
return codeBlock;
|
|
71
|
+
// Modern: wrap in the shadow frame
|
|
72
|
+
if (isModern) {
|
|
73
|
+
return jsxRuntime.jsx("div", { className: "rounded-[20px] bg-secondary_alt p-2 ring-1 ring-secondary ring-inset", children: codeBlock });
|
|
74
|
+
}
|
|
75
|
+
// Flat: the code block with its plain border
|
|
76
|
+
return codeBlock;
|
|
77
|
+
};
|
|
78
|
+
const CodeSnippetTabs = ({ children, className, 'data-testid': dataTestId, ...otherProps }) => {
|
|
79
|
+
const rootRef = React.useRef(null);
|
|
80
|
+
const tabsTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'tabs', rootName: 'code-snippet' });
|
|
81
|
+
return (jsxRuntime.jsx(TabsRefContext, { value: rootRef, children: jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: tabsTestId, children: jsxRuntime.jsx(reactAriaComponents.Tabs, { ref: rootRef, keyboardActivation: "manual", ...otherProps, "data-testid": tabsTestId, className: (values) => cx.cx('group/code-tabs rounded-t-xl rounded-b-[20px] bg-secondary_alt shadow-xs ring-1 ring-secondary ring-inset', typeof className === 'function' ? className(values) : className), children: children }) }) }));
|
|
82
|
+
};
|
|
83
|
+
const CodeSnippetTabList = ({ children, className, ...otherProps }) => {
|
|
84
|
+
const { copy, copied } = useClipboard.useClipboard();
|
|
85
|
+
const tabsRef = React.useContext(TabsRefContext);
|
|
86
|
+
const handleCopy = () => {
|
|
87
|
+
const text = codeSnippet_utils.getActiveTabPanelText(tabsRef?.current ?? null);
|
|
88
|
+
if (text)
|
|
89
|
+
copy(text);
|
|
90
|
+
};
|
|
91
|
+
return (jsxRuntime.jsxs("div", { className: "relative flex items-start", children: [jsxRuntime.jsx(reactAriaComponents.TabList, { ...otherProps, className: (values) => cx.cx('flex flex-1 items-center overflow-auto px-3 pt-2 pb-2', typeof className === 'function' ? className(values) : className), children: children }), jsxRuntime.jsx("div", { className: "flex shrink-0 items-center pt-2 pr-2", children: jsxRuntime.jsx(UtilityButton.ButtonUtility, { size: "xs", color: "tertiary", icon: copied ? uiIcons.Check : uiIcons.Copy01, tooltip: "Copy", onClick: handleCopy }) })] }));
|
|
92
|
+
};
|
|
93
|
+
const CodeSnippetTab = ({ children, className, ...otherProps }) => {
|
|
94
|
+
const prefix = testIdUtils.useTestIdPrefix();
|
|
95
|
+
const resolveIdPart = () => {
|
|
96
|
+
if (otherProps.id !== undefined)
|
|
97
|
+
return testIdUtils.slugifyTestId(String(otherProps.id));
|
|
98
|
+
if (typeof children === 'string')
|
|
99
|
+
return testIdUtils.slugifyTestId(children);
|
|
100
|
+
return 'item';
|
|
101
|
+
};
|
|
102
|
+
const idPart = resolveIdPart();
|
|
103
|
+
const tabTestId = prefix ? testIdUtils.joinTestId(prefix, `tab-${idPart}`) : undefined;
|
|
104
|
+
return (jsxRuntime.jsx(reactAriaComponents.Tab, { ...otherProps, "data-testid": tabTestId, className: (state) => cx.cx('z-10 flex cursor-pointer items-center justify-center gap-2 rounded-md px-2 py-1 text-sm font-semibold whitespace-nowrap text-quaternary outline-0 outline-offset-2 outline-focus-ring transition duration-100 ease-linear', (state.isSelected || state.isHovered) && 'text-primary', state.isFocusVisible && 'outline-2', typeof className === 'function' ? className(state) : className), children: children }));
|
|
105
|
+
};
|
|
106
|
+
const CodeSnippetTabPanel = ({ children, className, ...otherProps }) => {
|
|
107
|
+
const prefix = testIdUtils.useTestIdPrefix();
|
|
108
|
+
const idPart = otherProps.id !== undefined ? testIdUtils.slugifyTestId(String(otherProps.id)) : 'panel';
|
|
109
|
+
const panelTestId = prefix ? testIdUtils.joinTestId(prefix, `panel-${idPart}`) : undefined;
|
|
110
|
+
return (jsxRuntime.jsx(reactAriaComponents.TabPanel, { ...otherProps, "data-testid": panelTestId, className: (state) => cx.cx('px-2 pb-2', typeof className === 'function' ? className(state) : className), children: children }));
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Shows a block of code with syntax highlighting, a copy button and optional tabs. Use for install
|
|
114
|
+
* commands and API examples.
|
|
115
|
+
*
|
|
116
|
+
* @summary displays formatted, copyable code blocks with optional tabs
|
|
117
|
+
*/
|
|
118
|
+
const CodeSnippet = CodeSnippetComponent;
|
|
119
|
+
CodeSnippet.Tabs = CodeSnippetTabs;
|
|
120
|
+
CodeSnippet.TabList = CodeSnippetTabList;
|
|
121
|
+
CodeSnippet.Tab = CodeSnippetTab;
|
|
122
|
+
CodeSnippet.TabPanel = CodeSnippetTabPanel;
|
|
123
|
+
|
|
124
|
+
exports.CodeSnippet = CodeSnippet;
|
|
125
|
+
exports.highlight = highlight;
|
|
126
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/organisms/CodeSnippet/index.tsx"],"sourcesContent":[null],"names":["highlightToHast","toJsxRuntime","Fragment","jsx","jsxs","createContext","useCodeSnippetHighlight","useClipboard","useCodeSnippetCollapse","useContext","useResolvedTestId","_jsx","TestIdProvider","_jsxs","cx","Button","ButtonUtility","Expand06","joinTestId","Check","Copy01","useRef","AriaTabs","getActiveTabPanelText","AriaTabList","useTestIdPrefix","slugifyTestId","AriaTab","AriaTabPanel"],"mappings":";;;;;;;;;;;;;;;;AAmBA;;;;;AAKG;AACI,MAAM,SAAS,GAAG,OAAO,IAAY,EAAE,IAAe,KAAI;IAC/D,MAAM,GAAG,GAAG,MAAMA,iCAAe,CAAC,IAAI,EAAE,IAAI,CAAC;IAE7C,OAAOC,iCAAY,CAAC,GAAG,EAAE;kBACvBC,cAAQ;aACRC,cAAG;cACHC,eAAI;AACL,KAAA,CAAC;AACJ;AAEA;;;AAGG;AACH;AACA,MAAM,sBAAsB,GAAG,OAAO;AAEtC,MAAM,cAAc,GAAGC,mBAAa,CAA0C,IAAI,CAAC;AAEnF;;AAEG;AACH,MAAM,cAAc,GAAG;AACrB,IAAA,kBAAkB,EAChB,2fAA2f;AAC7f,IAAA,iBAAiB,EACf,sdAAsd;CACxc;AA4ClB,MAAM,oBAAoB,GAAG,CAAC,EAC5B,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,eAAe,GAAG,IAAI,EACtB,SAAS,EACT,QAAQ,EACR,SAAS,EACT,MAAM,GAAG,IAAI,EACb,aAAa,EAAE,UAAU,EACzB,GAAG,UAAU,EACI,KAAI;AACrB,IAAA,MAAM,KAAK,GAAGC,+CAAuB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;IACvG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAGC,yBAAY,EAAE;IACvC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAAGC,6CAAsB,CAAC;QACxF,SAAS;QACT,KAAK;QACL,QAAQ;AACR,QAAA,iBAAiB,EAAE,sBAAsB;AAC1C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Ac,EACvD,KAAK,CAAC,cAAc,IAAI,WAAW,EACnC,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAC/D,EAAA,QAAA,EAGF,QAAQ,EAAA,CACD;AAEd,CAAC;AAED,MAAM,mBAAmB,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,UAAU,EAAiB,KAAI;AACpF,IAAA,MAAM,MAAM,GAAGW,2BAAe,EAAE;IAChC,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,KAAK,SAAS,GAAGC,yBAAa,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO;AAC3F,IAAA,MAAM,WAAW,GAAG,MAAM,GAAGR,sBAAU,CAAC,MAAM,EAAE,CAAA,MAAA,EAAS,MAAM,CAAA,CAAE,CAAC,GAAG,SAAS;AAE9E,IAAA,QACEP,cAAA,CAACiB,4BAAY,EAAA,EAAA,GACP,UAAU,iBACD,WAAW,EACxB,SAAS,EAAE,CAAC,KAAK,KAAKd,KAAE,CAAC,WAAW,EAAE,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,YAEpG,QAAQ,EAAA,CACI;AAEnB,CAAC;AAED;;;;;AAKG;AACI,MAAM,WAAW,GAAG;AAO3B,WAAW,CAAC,IAAI,GAAG,eAAe;AAClC,WAAW,CAAC,OAAO,GAAG,kBAAkB;AACxC,WAAW,CAAC,GAAG,GAAG,cAAc;AAChC,WAAW,CAAC,QAAQ,GAAG,mBAAmB;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import type { TabListProps, TabPanelProps, TabProps, TabsProps } from 'react-aria-components';
|
|
3
|
+
import { type Languages } from './utilities/codeSnippet.utils';
|
|
4
|
+
export type { Languages } from './utilities/codeSnippet.utils';
|
|
5
|
+
/**
|
|
6
|
+
* Highlights source into React nodes with the snippet's themes, loading the grammar on first use.
|
|
7
|
+
* @param code The source to highlight.
|
|
8
|
+
* @param lang The language id; one Shiki does not know renders as plain text.
|
|
9
|
+
* @returns The highlighted `<pre>` tree, ready to render in place of the fallback.
|
|
10
|
+
*/
|
|
11
|
+
export declare const highlight: (code: string, lang: Languages) => Promise<JSX.Element>;
|
|
12
|
+
export interface CodeSnippetProps extends HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
/**
|
|
14
|
+
* The code to be syntax highlighted. Can be provided in two ways:
|
|
15
|
+
* 1. As a string via this prop for client-side highlighting
|
|
16
|
+
* 2. As pre-highlighted nodes via children prop for server-side highlighting
|
|
17
|
+
*/
|
|
18
|
+
code?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The programming language of the code snippet.
|
|
21
|
+
* Determines syntax highlighting rules.
|
|
22
|
+
*/
|
|
23
|
+
language: Languages;
|
|
24
|
+
/** Shows a numbered gutter beside the code; without it the code gets even padding instead. */
|
|
25
|
+
showLineNumbers?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum height (in px) before the "Show more" overlay appears.
|
|
28
|
+
* When omitted, the code block displays at full height.
|
|
29
|
+
*/
|
|
30
|
+
maxHeight?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Callback fired when the expand button is clicked.
|
|
33
|
+
* The expand button is only rendered when this prop is provided.
|
|
34
|
+
*/
|
|
35
|
+
onExpand?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Pre-highlighted code nodes that were generated on the server.
|
|
38
|
+
* Alternative to passing raw code string via the `code` prop.
|
|
39
|
+
*/
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
/** Wraps the snippet in the raised shadow frame; turn it off for a flat block with a plain border. Inside `CodeSnippet.Tabs` the tabs supply the frame. */
|
|
42
|
+
modern?: boolean;
|
|
43
|
+
/** Overrides the derived `data-testid` (defaults to `fd-code-snippet`). */
|
|
44
|
+
'data-testid'?: string;
|
|
45
|
+
}
|
|
46
|
+
declare const CodeSnippetComponent: ({ children, code, language, showLineNumbers, maxHeight, onExpand, className, modern, "data-testid": dataTestId, ...otherProps }: CodeSnippetProps) => import("react").JSX.Element;
|
|
47
|
+
declare const CodeSnippetTabs: ({ children, className, "data-testid": dataTestId, ...otherProps }: TabsProps & {
|
|
48
|
+
"data-testid"?: string;
|
|
49
|
+
}) => import("react").JSX.Element;
|
|
50
|
+
declare const CodeSnippetTabList: <T extends object>({ children, className, ...otherProps }: TabListProps<T>) => import("react").JSX.Element;
|
|
51
|
+
export interface CodeSnippetTabProps extends TabProps {
|
|
52
|
+
/** Tab label; a string label also derives the tab's `data-testid` when no `id` is set. */
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
declare const CodeSnippetTab: ({ children, className, ...otherProps }: CodeSnippetTabProps) => import("react").JSX.Element;
|
|
56
|
+
declare const CodeSnippetTabPanel: ({ children, className, ...otherProps }: TabPanelProps) => import("react").JSX.Element;
|
|
57
|
+
/**
|
|
58
|
+
* Shows a block of code with syntax highlighting, a copy button and optional tabs. Use for install
|
|
59
|
+
* commands and API examples.
|
|
60
|
+
*
|
|
61
|
+
* @summary displays formatted, copyable code blocks with optional tabs
|
|
62
|
+
*/
|
|
63
|
+
export declare const CodeSnippet: typeof CodeSnippetComponent & {
|
|
64
|
+
Tabs: typeof CodeSnippetTabs;
|
|
65
|
+
TabList: typeof CodeSnippetTabList;
|
|
66
|
+
Tab: typeof CodeSnippetTab;
|
|
67
|
+
TabPanel: typeof CodeSnippetTabPanel;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/CodeSnippet/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAA+C,KAAK,cAAc,EAAE,KAAK,SAAS,EAAsC,MAAM,OAAO,CAAC;AAE7I,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,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