@uniformdev/csk-components 6.1.57 → 6.1.64-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -81
- package/dist/ThemeSwitcher-EUDUX3QI.mjs +1 -0
- package/dist/accordion-item-7IKL6Z6Q.mjs +1 -0
- package/dist/accordion-item-MORC2F2Q.mjs +1 -0
- package/dist/banner-WOYK426U.mjs +1 -0
- package/dist/carousel-ALNEGOPM.mjs +1 -0
- package/dist/carousel-HKYR3ZBB.mjs +1 -0
- package/dist/chunk-27WJUZYR.mjs +1 -0
- package/dist/chunk-3JU2XCD2.mjs +1 -0
- package/dist/chunk-47YB4P2Q.mjs +1 -0
- package/dist/chunk-6CKVLOIH.mjs +1 -0
- package/dist/chunk-7GVG4HLE.mjs +1 -0
- package/dist/chunk-AOFJCDRO.mjs +1 -0
- package/dist/chunk-AWTML4I7.mjs +1 -0
- package/dist/chunk-CZ4X5ZBK.mjs +1 -0
- package/dist/chunk-D673IM2U.mjs +1 -0
- package/dist/chunk-I6SUO5WR.mjs +1 -0
- package/dist/chunk-JT77BVIX.mjs +1 -0
- package/dist/chunk-LPAOEOU4.mjs +1 -0
- package/dist/chunk-MKOFM4XK.mjs +1 -0
- package/dist/chunk-NKINOJY6.mjs +1 -0
- package/dist/chunk-OKUDTS22.mjs +1 -0
- package/dist/chunk-OL6JBPZ4.mjs +1 -0
- package/dist/chunk-OY6ZJNCE.mjs +1 -0
- package/dist/chunk-PLKWUEFW.mjs +1 -0
- package/dist/chunk-QPQGRQKI.mjs +1 -0
- package/dist/chunk-VWWXSA5H.mjs +1 -0
- package/dist/chunk-WAW7PQYM.mjs +1 -0
- package/dist/chunk-XKCRANRQ.mjs +1 -0
- package/dist/chunk-XYU3TGOU.mjs +1 -0
- package/dist/chunk-Y337A266.mjs +7 -0
- package/dist/chunk-YQYDZJ65.mjs +1 -0
- package/dist/chunk-ZAHWFLY4.mjs +1 -0
- package/dist/{chunk-V4EBWEG4.mjs → chunk-ZWDCDE5W.mjs} +1 -1
- package/dist/components/canvas/emptyPlaceholders.d.mts +5 -4
- package/dist/components/canvas/emptyPlaceholders.mjs +1 -1
- package/dist/components/canvas/index.d.mts +4 -664
- package/dist/components/canvas/index.mjs +1 -2
- package/dist/components/canvas/serverClient.d.mts +694 -0
- package/dist/components/canvas/serverClient.mjs +1 -0
- package/dist/components/canvas/serverOnly.d.mts +41 -0
- package/dist/components/canvas/serverOnly.mjs +1 -0
- package/dist/components/ui/index.d.mts +81 -54
- package/dist/components/ui/index.mjs +1 -1
- package/dist/content/components/canvas/Accordion/accordion.tsx +12 -17
- package/dist/content/components/canvas/Accordion/index.tsx +2 -2
- package/dist/content/components/canvas/AccordionItem/accordion-item.tsx +28 -39
- package/dist/content/components/canvas/AccordionItem/index.tsx +4 -6
- package/dist/content/components/canvas/Badge/badge.tsx +12 -5
- package/dist/content/components/canvas/Badge/index.tsx +2 -3
- package/dist/content/components/canvas/Badge/style-utils.ts +6 -6
- package/dist/content/components/canvas/Banner/banner.tsx +24 -36
- package/dist/content/components/canvas/Banner/index.tsx +7 -11
- package/dist/content/components/canvas/Breadcrumbs/breadcrumbs.tsx +21 -22
- package/dist/content/components/canvas/Breadcrumbs/index.tsx +4 -7
- package/dist/content/components/canvas/Button/button.tsx +19 -11
- package/dist/content/components/canvas/Button/index.tsx +4 -7
- package/dist/content/components/canvas/Card/card.tsx +10 -12
- package/dist/content/components/canvas/Card/index.tsx +3 -3
- package/dist/content/components/canvas/Carousel/carousel.tsx +10 -10
- package/dist/content/components/canvas/Carousel/index.tsx +4 -4
- package/dist/content/components/canvas/Container/container.tsx +7 -10
- package/dist/content/components/canvas/Container/index.tsx +3 -3
- package/dist/content/components/canvas/Container/parameters.ts +0 -4
- package/dist/content/components/canvas/CookieConsent/cookie-consent.tsx +126 -0
- package/dist/content/components/canvas/CookieConsent/empty-placeholder.tsx +12 -0
- package/dist/content/components/canvas/CookieConsent/index.tsx +26 -0
- package/dist/content/components/canvas/Countdown/countdown.tsx +9 -7
- package/dist/content/components/canvas/Countdown/index.tsx +2 -3
- package/dist/content/components/canvas/DemoHero/atoms.tsx +59 -35
- package/dist/content/components/canvas/DemoHero/columns-variant.tsx +5 -11
- package/dist/content/components/canvas/DemoHero/default-variant.tsx +5 -12
- package/dist/content/components/canvas/DemoHero/demo-hero.tsx +43 -22
- package/dist/content/components/canvas/DemoHero/fixed-hero.tsx +63 -65
- package/dist/content/components/canvas/DemoHero/flexible-hero.tsx +8 -2
- package/dist/content/components/canvas/DemoHero/index.tsx +6 -18
- package/dist/content/components/canvas/DemoHero/utils.ts +14 -0
- package/dist/content/components/canvas/Divider/divider.tsx +5 -2
- package/dist/content/components/canvas/Divider/index.tsx +2 -2
- package/dist/content/components/canvas/Flex/flex.tsx +11 -10
- package/dist/content/components/canvas/Flex/index.tsx +6 -6
- package/dist/content/components/canvas/FlexItem/flex-item.tsx +7 -4
- package/dist/content/components/canvas/FlexItem/index.tsx +4 -5
- package/dist/content/components/canvas/Footer/footer.tsx +9 -8
- package/dist/content/components/canvas/Footer/index.tsx +2 -3
- package/dist/content/components/canvas/Grid/grid.tsx +9 -9
- package/dist/content/components/canvas/Grid/index.tsx +5 -5
- package/dist/content/components/canvas/GridItem/grid-item.tsx +10 -8
- package/dist/content/components/canvas/GridItem/index.tsx +5 -5
- package/dist/content/components/canvas/Header/header.tsx +10 -7
- package/dist/content/components/canvas/Header/index.tsx +2 -3
- package/dist/content/components/canvas/IconLabel/icon-label.tsx +16 -8
- package/dist/content/components/canvas/IconLabel/index.tsx +4 -5
- package/dist/content/components/canvas/Image/image.tsx +25 -8
- package/dist/content/components/canvas/Image/index.tsx +2 -3
- package/dist/content/components/canvas/ImageGallery/empty-placeholder.tsx +1 -1
- package/dist/content/components/canvas/ImageGallery/gallery-inner.tsx +6 -6
- package/dist/content/components/canvas/ImageGallery/image-gallery.tsx +21 -36
- package/dist/content/components/canvas/ImageGallery/index.tsx +11 -12
- package/dist/content/components/canvas/Link/index.tsx +2 -3
- package/dist/content/components/canvas/Link/link.tsx +7 -4
- package/dist/content/components/canvas/Modal/index.tsx +2 -2
- package/dist/content/components/canvas/Modal/modal.tsx +16 -74
- package/dist/content/components/canvas/NavigationFlyout/desktop.tsx +9 -13
- package/dist/content/components/canvas/NavigationFlyout/index.tsx +21 -3
- package/dist/content/components/canvas/NavigationFlyout/mobile.tsx +10 -13
- package/dist/content/components/canvas/NavigationFlyout/{navigation-flyout.tsx → navigation-flyout-client.tsx} +26 -20
- package/dist/content/components/canvas/NavigationGroup/desktop.tsx +7 -10
- package/dist/content/components/canvas/NavigationGroup/index.tsx +20 -3
- package/dist/content/components/canvas/NavigationGroup/mobile.tsx +9 -8
- package/dist/content/components/canvas/NavigationGroup/{navigation-group.tsx → navigation-group-client.tsx} +21 -18
- package/dist/content/components/canvas/NavigationLink/index.tsx +2 -4
- package/dist/content/components/canvas/NavigationLink/navigation-link.tsx +12 -9
- package/dist/content/components/canvas/Page/index.tsx +7 -7
- package/dist/content/components/canvas/Page/page.tsx +9 -18
- package/dist/content/components/canvas/Review/default-variant.tsx +3 -5
- package/dist/content/components/canvas/Review/empty-placeholder.tsx +6 -3
- package/dist/content/components/canvas/Review/index.tsx +6 -6
- package/dist/content/components/canvas/Review/multi-column-variant.tsx +3 -5
- package/dist/content/components/canvas/Review/review.tsx +11 -11
- package/dist/content/components/canvas/RichText/index.tsx +7 -6
- package/dist/content/components/canvas/RichText/rich-text.tsx +23 -6
- package/dist/content/components/canvas/Section/columns-variant.tsx +5 -11
- package/dist/content/components/canvas/Section/default-variant.tsx +7 -16
- package/dist/content/components/canvas/Section/empty-placeholder.tsx +5 -2
- package/dist/content/components/canvas/Section/index.tsx +2 -2
- package/dist/content/components/canvas/Section/section.tsx +11 -16
- package/dist/content/components/canvas/SimpleFooter/index.tsx +16 -0
- package/dist/content/components/canvas/SimpleFooter/simple-footer.tsx +85 -0
- package/dist/content/components/canvas/SimpleHeader/index.tsx +22 -0
- package/dist/content/components/canvas/SimpleHeader/simple-header.tsx +63 -0
- package/dist/content/components/canvas/Spacer/index.tsx +2 -2
- package/dist/content/components/canvas/Spacer/spacer.tsx +5 -2
- package/dist/content/components/canvas/Tab/index.tsx +2 -3
- package/dist/content/components/canvas/Tab/tab.tsx +6 -5
- package/dist/content/components/canvas/Table/index.tsx +2 -2
- package/dist/content/components/canvas/Table/table.tsx +9 -13
- package/dist/content/components/canvas/TableCustomCell/index.tsx +2 -2
- package/dist/content/components/canvas/TableCustomCell/table-custom-cell.tsx +7 -4
- package/dist/content/components/canvas/TableDataCell/index.tsx +2 -2
- package/dist/content/components/canvas/TableDataCell/table-data-cell.tsx +7 -4
- package/dist/content/components/canvas/TableHeaderCell/index.tsx +2 -2
- package/dist/content/components/canvas/TableHeaderCell/table-header-cell.tsx +7 -4
- package/dist/content/components/canvas/TableRow/index.tsx +5 -3
- package/dist/content/components/canvas/TableRow/table-row.tsx +6 -3
- package/dist/content/components/canvas/Tabs/index.tsx +7 -7
- package/dist/content/components/canvas/Tabs/style-utils.ts +12 -11
- package/dist/content/components/canvas/Tabs/tabs.tsx +45 -48
- package/dist/content/components/canvas/Testimonial/default-variant.tsx +9 -11
- package/dist/content/components/canvas/Testimonial/index.tsx +2 -2
- package/dist/content/components/canvas/Testimonial/testimonial.tsx +11 -17
- package/dist/content/components/canvas/Testimonial/with-large-avatar-variant.tsx +9 -11
- package/dist/content/components/canvas/Testimonial/with-overlapping-image-variant.tsx +9 -11
- package/dist/content/components/canvas/Text/index.tsx +2 -3
- package/dist/content/components/canvas/Text/text.tsx +21 -15
- package/dist/content/components/canvas/ThemeSwitcher/index.tsx +2 -2
- package/dist/content/components/canvas/ThemeSwitcher/theme-switcher.tsx +6 -3
- package/dist/content/components/canvas/Video/index.tsx +2 -5
- package/dist/content/components/canvas/Video/placeholder.tsx +1 -1
- package/dist/content/components/canvas/Video/video.tsx +9 -7
- package/dist/content/components/ui/Accordion/accordion.tsx +23 -0
- package/dist/content/components/ui/Accordion/index.tsx +9 -0
- package/dist/content/components/ui/AccordionItem/accordion-item.tsx +41 -0
- package/dist/content/components/ui/AccordionItem/index.tsx +16 -0
- package/dist/content/components/ui/Banner/banner.tsx +47 -0
- package/dist/content/components/ui/Banner/index.tsx +29 -0
- package/dist/content/components/{canvas → ui}/Banner/style-utils.ts +1 -2
- package/dist/content/components/ui/Button/index.ts +2 -5
- package/dist/content/components/ui/Carousel/carousel.tsx +2 -2
- package/dist/content/components/ui/Carousel/index.ts +3 -3
- package/dist/content/components/ui/ComponentEmptyPlaceholder/component-empty-placeholder.tsx +13 -0
- package/dist/content/components/ui/ComponentEmptyPlaceholder/index.ts +6 -0
- package/dist/content/components/ui/Container/container.tsx +2 -7
- package/dist/content/components/ui/Container/index.ts +0 -6
- package/dist/content/components/ui/Flex/flex.tsx +21 -27
- package/dist/content/components/ui/Flex/index.ts +3 -5
- package/dist/content/components/ui/FlexItem/index.ts +1 -1
- package/dist/content/components/ui/Footer/index.ts +5 -4
- package/dist/content/components/ui/Grid/grid.tsx +21 -25
- package/dist/content/components/ui/Grid/index.ts +6 -15
- package/dist/content/components/ui/GridItem/grid-item.tsx +10 -1
- package/dist/content/components/ui/GridItem/index.ts +6 -9
- package/dist/content/components/ui/Header/index.ts +1 -1
- package/dist/content/components/ui/IconLabel/icon-label.tsx +2 -0
- package/dist/content/components/ui/IconLabel/index.ts +1 -0
- package/dist/content/components/ui/InlineSVG/index.ts +15 -0
- package/dist/content/components/ui/InlineSVG/inline-svg.tsx +70 -0
- package/dist/content/components/ui/InlineSVG/utils.ts +132 -0
- package/dist/content/components/ui/Modal/index.tsx +22 -0
- package/dist/content/components/ui/Modal/modal.tsx +89 -0
- package/dist/content/components/{canvas → ui}/Modal/style-utils.ts +4 -4
- package/dist/content/components/ui/Rating/index.tsx +1 -1
- package/dist/content/components/ui/Rating/rating.tsx +1 -1
- package/dist/content/components/ui/Text/index.ts +3 -6
- package/dist/content/types/cskTypes.ts +32 -9
- package/dist/content/utils/assets.ts +3 -18
- package/dist/content/utils/createComponentResolver.ts +7 -6
- package/dist/content/utils/createEmptyPlaceholderResolver.tsx +4 -8
- package/dist/content/utils/getSlotComponents.ts +15 -0
- package/dist/content/utils/routing.ts +60 -15
- package/dist/content/utils/useCookiesConsent.ts +17 -0
- package/dist/content/utils/withFlattenParameters.tsx +17 -0
- package/dist/content/utils/withSlotsDataValue.tsx +34 -0
- package/dist/cookie-consent-5QJUCW2K.mjs +1 -0
- package/dist/countdown-FRQZMVKW.mjs +1 -0
- package/dist/image-gallery-HWCMTJL3.mjs +1 -0
- package/dist/index-CrBZatTs.d.mts +18 -0
- package/dist/index-vyIO0XN2.d.mts +90 -0
- package/dist/index.mjs +3 -3
- package/dist/mobile-KBYNJEBM.mjs +1 -0
- package/dist/modal-4TVVGHWS.mjs +1 -0
- package/dist/modal-E5RMA4EO.mjs +1 -0
- package/dist/navigation-flyout-client-WUN4A34X.mjs +1 -0
- package/dist/navigation-group-client-Y72BOPIH.mjs +1 -0
- package/dist/parameters-B8w5Q6Pp.d.mts +29 -0
- package/dist/tabs-VMFTATOP.mjs +1 -0
- package/dist/theme-switcher-QTX46Z7E.mjs +1 -0
- package/dist/theme-switcher-RGY4D3KL.mjs +1 -0
- package/dist/types/cskTypes.d.mts +27 -9
- package/dist/utils/assets.d.mts +8 -17
- package/dist/utils/assets.mjs +1 -1
- package/dist/utils/createComponentResolver.d.mts +3 -9
- package/dist/utils/createComponentResolver.mjs +1 -1
- package/dist/utils/createEmptyPlaceholderResolver.d.mts +4 -2
- package/dist/utils/createEmptyPlaceholderResolver.mjs +1 -1
- package/dist/utils/getSlotComponents.d.mts +11 -0
- package/dist/utils/getSlotComponents.mjs +1 -0
- package/dist/utils/routing.d.mts +21 -8
- package/dist/utils/routing.mjs +1 -1
- package/dist/utils/sitemap.d.mts +21 -0
- package/dist/utils/sitemap.mjs +1 -0
- package/dist/utils/styling.d.mts +4 -1
- package/dist/utils/styling.mjs +1 -1
- package/dist/utils/withFlattenParameters.d.mts +10 -0
- package/dist/utils/withFlattenParameters.mjs +1 -0
- package/dist/utils/withSlotsDataValue.d.mts +12 -0
- package/dist/utils/withSlotsDataValue.mjs +1 -0
- package/dist/video-VG6ZQCKN.mjs +1 -0
- package/package.json +48 -15
- package/dist/ThemeSwitcher-6Q7LCO4Q.mjs +0 -1
- package/dist/accordion-item-G5CNMERW.mjs +0 -1
- package/dist/banner-2B4K5R4N.mjs +0 -1
- package/dist/carousel-BBEW5P4Y.mjs +0 -1
- package/dist/carousel-ERCHOWUS.mjs +0 -1
- package/dist/chunk-2SEOCBRK.mjs +0 -1
- package/dist/chunk-2UV7TQNF.mjs +0 -1
- package/dist/chunk-2YTACEBA.mjs +0 -1
- package/dist/chunk-3PDY7RJC.mjs +0 -7
- package/dist/chunk-4LWAGTFW.mjs +0 -1
- package/dist/chunk-56OQGKRM.mjs +0 -1
- package/dist/chunk-5VM2Y55L.mjs +0 -1
- package/dist/chunk-AKRWCDDG.mjs +0 -1
- package/dist/chunk-FPOIJMYT.mjs +0 -1
- package/dist/chunk-LA36HQWS.mjs +0 -1
- package/dist/chunk-M3BGP5VE.mjs +0 -1
- package/dist/chunk-MSXDLSXH.mjs +0 -1
- package/dist/chunk-QHIWJPL6.mjs +0 -1
- package/dist/chunk-RX4IAAQQ.mjs +0 -1
- package/dist/chunk-TIRCISSU.mjs +0 -1
- package/dist/chunk-TM7Q5NMH.mjs +0 -1
- package/dist/chunk-YEKQJ4YC.mjs +0 -1
- package/dist/chunk-YUCUJWBO.mjs +0 -1
- package/dist/chunk-Z7JSWSPD.mjs +0 -1
- package/dist/content/components/canvas/Banner/types.ts +0 -21
- package/dist/content/components/canvas/Image/placeholder.tsx +0 -20
- package/dist/content/components/ui/Container/utils.ts +0 -18
- package/dist/countdown-LYDXJLEE.mjs +0 -1
- package/dist/image-gallery-F6JLG7XW.mjs +0 -1
- package/dist/index-B9eeSbLG.d.mts +0 -71
- package/dist/mobile-UAUHHXPH.mjs +0 -1
- package/dist/modal-HKMQGV4B.mjs +0 -1
- package/dist/navigation-flyout-MXIJA6PC.mjs +0 -1
- package/dist/navigation-group-DEN3D2BO.mjs +0 -1
- package/dist/tabs-AQFKYC6M.mjs +0 -1
- package/dist/theme-switcher-76F2V343.mjs +0 -1
- package/dist/theme-switcher-WO5JIV2W.mjs +0 -1
- package/dist/video-RC2QHJS2.mjs +0 -1
- /package/dist/content/components/{canvas → ui}/AccordionItem/icon-arrow-down.tsx +0 -0
- /package/dist/content/components/{canvas → ui}/AccordionItem/icon-arrow-up.tsx +0 -0
- /package/dist/content/components/{canvas → ui}/Banner/close-button.tsx +0 -0
- /package/dist/content/components/{canvas → ui}/Modal/close-icon.tsx +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import BaseContainer
|
|
2
|
+
import BaseContainer from '@/components/ui/Container';
|
|
3
3
|
import { cn, resolveViewPort } from '@/utils/styling';
|
|
4
4
|
import { GridProps } from '.';
|
|
5
5
|
|
|
@@ -12,29 +12,25 @@ export const Grid: FC<GridProps> = ({
|
|
|
12
12
|
spacing,
|
|
13
13
|
border,
|
|
14
14
|
fluidContent,
|
|
15
|
-
fullHeight,
|
|
16
|
-
fitHeight,
|
|
17
15
|
height,
|
|
18
16
|
children,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'grid',
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
40
|
-
};
|
|
17
|
+
alignItems,
|
|
18
|
+
}) => (
|
|
19
|
+
<BaseContainer {...{ backgroundColor, spacing, border, fluidContent, height }}>
|
|
20
|
+
<div
|
|
21
|
+
className={cn(
|
|
22
|
+
'grid',
|
|
23
|
+
{
|
|
24
|
+
[resolveViewPort(columnsCount, 'grid-cols-{value}')]: columnsCount,
|
|
25
|
+
[resolveViewPort(gapX, 'gap-x-{value}')]: gapX,
|
|
26
|
+
[resolveViewPort(gapY, 'gap-y-{value}')]: gapY,
|
|
27
|
+
[resolveViewPort(height, 'h-{value}')]: height,
|
|
28
|
+
[resolveViewPort(alignItems, 'items-{value}')]: alignItems,
|
|
29
|
+
},
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
</BaseContainer>
|
|
36
|
+
);
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import { DefaultTheme } from 'tailwindcss/types/generated/default-theme';
|
|
2
1
|
import { ContainerProps as BaseContainerProps } from '@/components/ui/Container';
|
|
3
2
|
import { ViewPort } from '@/types/cskTypes';
|
|
4
3
|
|
|
5
|
-
type
|
|
6
|
-
type AvailableGap = keyof DefaultTheme['spacing'];
|
|
4
|
+
type Align = 'start' | 'end' | 'center' | 'baseline' | 'stretch';
|
|
7
5
|
|
|
8
6
|
export type GridProps = Pick<
|
|
9
7
|
BaseContainerProps,
|
|
10
|
-
| '
|
|
11
|
-
| 'backgroundColor'
|
|
12
|
-
| 'spacing'
|
|
13
|
-
| 'border'
|
|
14
|
-
| 'fluidContent'
|
|
15
|
-
| 'fullHeight'
|
|
16
|
-
| 'fitHeight'
|
|
17
|
-
| 'children'
|
|
18
|
-
| 'height'
|
|
8
|
+
'title' | 'backgroundColor' | 'spacing' | 'border' | 'fluidContent' | 'children' | 'height'
|
|
19
9
|
> & {
|
|
20
|
-
columnsCount?:
|
|
21
|
-
gapY?:
|
|
22
|
-
gapX?:
|
|
10
|
+
columnsCount?: string | ViewPort<string>;
|
|
11
|
+
gapY?: string | ViewPort<string>;
|
|
12
|
+
gapX?: string | ViewPort<string>;
|
|
13
|
+
alignItems?: Align | ViewPort<Align>;
|
|
23
14
|
className?: string;
|
|
24
15
|
};
|
|
25
16
|
|
|
@@ -2,7 +2,15 @@ import { FC } from 'react';
|
|
|
2
2
|
import { cn, resolveViewPort } from '@/utils/styling';
|
|
3
3
|
import { GridItemProps } from '.';
|
|
4
4
|
|
|
5
|
-
export const GridItem: FC<GridItemProps> = ({
|
|
5
|
+
export const GridItem: FC<GridItemProps> = ({
|
|
6
|
+
className,
|
|
7
|
+
columnStart,
|
|
8
|
+
columnSpan,
|
|
9
|
+
rowStart,
|
|
10
|
+
rowSpan,
|
|
11
|
+
children,
|
|
12
|
+
alignSelf,
|
|
13
|
+
}) => (
|
|
6
14
|
<div
|
|
7
15
|
className={cn(
|
|
8
16
|
{
|
|
@@ -10,6 +18,7 @@ export const GridItem: FC<GridItemProps> = ({ className, columnStart, columnSpan
|
|
|
10
18
|
[resolveViewPort(columnSpan, 'col-{value}')]: columnSpan,
|
|
11
19
|
[resolveViewPort(rowStart, 'row-start-{value}')]: rowStart,
|
|
12
20
|
[resolveViewPort(rowSpan, 'row-{value}')]: rowSpan,
|
|
21
|
+
[resolveViewPort(alignSelf, 'self-{value}')]: alignSelf,
|
|
13
22
|
},
|
|
14
23
|
className
|
|
15
24
|
)}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
|
-
import { DefaultTheme } from 'tailwindcss/types/generated/default-theme';
|
|
3
2
|
import { ViewPort } from '@/types/cskTypes';
|
|
4
3
|
|
|
5
|
-
type
|
|
6
|
-
type AvailableColumnSpan = keyof DefaultTheme['gridColumn'];
|
|
7
|
-
type AvailableGridRowStart = keyof DefaultTheme['gridRowStart'];
|
|
8
|
-
type AvailableGridRowSpan = keyof DefaultTheme['gridRow'];
|
|
4
|
+
type Align = 'start' | 'end' | 'center' | 'baseline' | 'stretch';
|
|
9
5
|
|
|
10
6
|
export type GridItemProps = HTMLAttributes<HTMLDivElement> & {
|
|
11
|
-
columnStart?:
|
|
12
|
-
columnSpan?:
|
|
13
|
-
rowStart?:
|
|
14
|
-
rowSpan?:
|
|
7
|
+
columnStart?: string | ViewPort<string>;
|
|
8
|
+
columnSpan?: string | ViewPort<string>;
|
|
9
|
+
rowStart?: string | ViewPort<string>;
|
|
10
|
+
rowSpan?: string | ViewPort<string>;
|
|
15
11
|
className?: string;
|
|
12
|
+
alignSelf?: Align | ViewPort<Align>;
|
|
16
13
|
};
|
|
17
14
|
|
|
18
15
|
export { GridItem as default } from './grid-item';
|
|
@@ -2,7 +2,7 @@ import { PropsWithChildren, ReactNode } from 'react';
|
|
|
2
2
|
import { ContainerProps as BaseContainerProps } from '@/components/ui/Container';
|
|
3
3
|
|
|
4
4
|
export type HeaderProps = PropsWithChildren &
|
|
5
|
-
Omit<BaseContainerProps, 'fluidContent' | '
|
|
5
|
+
Omit<BaseContainerProps, 'fluidContent' | 'height'> & {
|
|
6
6
|
leftSection?: ReactNode;
|
|
7
7
|
rightSection?: ReactNode;
|
|
8
8
|
color?: string;
|
|
@@ -18,6 +18,7 @@ export const IconLabel: FC<IconLabelProps> = ({
|
|
|
18
18
|
textClassName,
|
|
19
19
|
iconClassName,
|
|
20
20
|
className,
|
|
21
|
+
iconPosition,
|
|
21
22
|
}) => (
|
|
22
23
|
<div
|
|
23
24
|
className={cn(
|
|
@@ -25,6 +26,7 @@ export const IconLabel: FC<IconLabelProps> = ({
|
|
|
25
26
|
{
|
|
26
27
|
[`text-${size}`]: !!size,
|
|
27
28
|
[`text-${color}`]: !!color,
|
|
29
|
+
'flex-row-reverse': icon && iconPosition === 'right',
|
|
28
30
|
},
|
|
29
31
|
className
|
|
30
32
|
)}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type InlineSVGProps = {
|
|
4
|
+
src: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
fill?: boolean;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
sanitize?: boolean;
|
|
10
|
+
fallback?: ReactNode;
|
|
11
|
+
useCurrentColor?: boolean;
|
|
12
|
+
alt?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { InlineSVG as default } from './inline-svg';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/error-boundaries */
|
|
2
|
+
import { FC, SVGProps } from 'react';
|
|
3
|
+
import { cn } from '@/utils/styling';
|
|
4
|
+
import { InlineSVGProps } from '.';
|
|
5
|
+
import {
|
|
6
|
+
fetchSvg,
|
|
7
|
+
sanitizeSvg,
|
|
8
|
+
applyCurrentColor,
|
|
9
|
+
getSvgAttributes,
|
|
10
|
+
getSvgInnerContent,
|
|
11
|
+
convertSvgAttributesToReactProps,
|
|
12
|
+
} from './utils';
|
|
13
|
+
|
|
14
|
+
export const InlineSVG: FC<InlineSVGProps> = async ({
|
|
15
|
+
src,
|
|
16
|
+
className = '',
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
fill,
|
|
20
|
+
sanitize = true,
|
|
21
|
+
useCurrentColor = true,
|
|
22
|
+
fallback,
|
|
23
|
+
alt,
|
|
24
|
+
}) => {
|
|
25
|
+
if (!src) return fallback ?? null;
|
|
26
|
+
|
|
27
|
+
const transformSvg = (svg: string): string => {
|
|
28
|
+
const transformers: Array<(input: string) => string> = [];
|
|
29
|
+
|
|
30
|
+
if (sanitize) transformers.push(sanitizeSvg);
|
|
31
|
+
if (useCurrentColor) transformers.push(applyCurrentColor);
|
|
32
|
+
|
|
33
|
+
return transformers.reduce((result, fn) => fn(result), svg);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const raw = await fetchSvg(src);
|
|
38
|
+
const cleaned = transformSvg(raw);
|
|
39
|
+
const attrs = getSvgAttributes(cleaned);
|
|
40
|
+
const content = getSvgInnerContent(cleaned);
|
|
41
|
+
|
|
42
|
+
const reactProps = convertSvgAttributesToReactProps(attrs);
|
|
43
|
+
|
|
44
|
+
const svgProps: SVGProps<SVGSVGElement> = {
|
|
45
|
+
...reactProps,
|
|
46
|
+
role: 'img',
|
|
47
|
+
'aria-label': alt,
|
|
48
|
+
focusable: false,
|
|
49
|
+
width: fill ? '100%' : width,
|
|
50
|
+
height: fill ? '100%' : height,
|
|
51
|
+
className: cn(reactProps.className, className, {
|
|
52
|
+
'absolute inset-0': fill,
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className="relative size-full">
|
|
58
|
+
<svg {...svgProps} dangerouslySetInnerHTML={{ __html: content }} />
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
} catch {
|
|
62
|
+
return (
|
|
63
|
+
fallback ?? (
|
|
64
|
+
<div className={cn(className)} style={{ width, height }}>
|
|
65
|
+
<div className="rounded border border-red-200 bg-red-50 p-2 text-sm text-red-500">Failed to load SVG</div>
|
|
66
|
+
</div>
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { SVGProps } from 'react';
|
|
2
|
+
|
|
3
|
+
type SVGAttributes = Record<string, string | number | boolean>;
|
|
4
|
+
type ReactSVGProps = SVGProps<SVGSVGElement>;
|
|
5
|
+
const PRESERVE_AS_STRING = ['id', 'class', 'viewBox', 'preserveAspectRatio'];
|
|
6
|
+
|
|
7
|
+
const ATTRIBUTE_MAP: Record<string, string> = {
|
|
8
|
+
class: 'className',
|
|
9
|
+
'stroke-width': 'strokeWidth',
|
|
10
|
+
'stroke-linecap': 'strokeLinecap',
|
|
11
|
+
'stroke-linejoin': 'strokeLinejoin',
|
|
12
|
+
'stroke-miterlimit': 'strokeMiterlimit',
|
|
13
|
+
'stroke-dasharray': 'strokeDasharray',
|
|
14
|
+
'stroke-dashoffset': 'strokeDashoffset',
|
|
15
|
+
'stroke-opacity': 'strokeOpacity',
|
|
16
|
+
'fill-opacity': 'fillOpacity',
|
|
17
|
+
'fill-rule': 'fillRule',
|
|
18
|
+
'clip-rule': 'clipRule',
|
|
19
|
+
'clip-path': 'clipPath',
|
|
20
|
+
'font-family': 'fontFamily',
|
|
21
|
+
'font-size': 'fontSize',
|
|
22
|
+
'font-weight': 'fontWeight',
|
|
23
|
+
'text-anchor': 'textAnchor',
|
|
24
|
+
'pointer-events': 'pointerEvents',
|
|
25
|
+
'vector-effect': 'vectorEffect',
|
|
26
|
+
'color-interpolation': 'colorInterpolation',
|
|
27
|
+
'dominant-baseline': 'dominantBaseline',
|
|
28
|
+
'text-rendering': 'textRendering',
|
|
29
|
+
'shape-rendering': 'shapeRendering',
|
|
30
|
+
'color-rendering': 'colorRendering',
|
|
31
|
+
'image-rendering': 'imageRendering',
|
|
32
|
+
'xml:space': 'xmlSpace',
|
|
33
|
+
'xmlns:xlink': 'xmlnsXlink',
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sanitizes SVG by removing potentially dangerous or unwanted content.
|
|
38
|
+
*/
|
|
39
|
+
export const sanitizeSvg = (svg: string): string =>
|
|
40
|
+
svg
|
|
41
|
+
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '')
|
|
42
|
+
.replace(/\son\w+="[^"]*"/gi, '')
|
|
43
|
+
.replace(/\son\w+='[^']*'/gi, '')
|
|
44
|
+
.replace(/javascript:/gi, '');
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Replaces color attributes (fill, stroke, color) with `currentColor`
|
|
48
|
+
* except for 'none' and 'transparent'.
|
|
49
|
+
*/
|
|
50
|
+
export const applyCurrentColor = (svg: string): string =>
|
|
51
|
+
svg
|
|
52
|
+
.replace(/fill=(['"])(?!none|transparent)[^'"]*\1/gi, 'fill="currentColor"')
|
|
53
|
+
.replace(/stroke=(['"])(?!none|transparent)[^'"]*\1/gi, 'stroke="currentColor"')
|
|
54
|
+
.replace(/color=(['"])[^'"]*\1/gi, 'color="currentColor"');
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Extracts attributes from the <svg> tag as key-value pairs.
|
|
58
|
+
*/
|
|
59
|
+
export const getSvgAttributes = (svgContent: string): SVGAttributes => {
|
|
60
|
+
const svgTagMatch = svgContent.match(/<svg([^>]*)>/i);
|
|
61
|
+
if (!svgTagMatch) return {};
|
|
62
|
+
|
|
63
|
+
const attributesString = svgTagMatch[1];
|
|
64
|
+
const attributes: SVGAttributes = {};
|
|
65
|
+
|
|
66
|
+
const attrRegex = /(\w+(?:[-:]\w+)*)\s*=\s*["']([^"']*)["']/g;
|
|
67
|
+
let match;
|
|
68
|
+
|
|
69
|
+
while ((match = attrRegex.exec(attributesString ?? '')) !== null) {
|
|
70
|
+
const [, key, value] = match;
|
|
71
|
+
|
|
72
|
+
if (!key || !value) continue;
|
|
73
|
+
|
|
74
|
+
if (value === 'true' || value === 'false') {
|
|
75
|
+
attributes[key] = value === 'true';
|
|
76
|
+
} else if (!isNaN(Number(value)) && value !== '' && !PRESERVE_AS_STRING.includes(key)) {
|
|
77
|
+
attributes[key] = Number(value);
|
|
78
|
+
} else {
|
|
79
|
+
attributes[key] = value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return attributes;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Extracts inner content from an SVG string (everything inside <svg>...</svg>).
|
|
87
|
+
*/
|
|
88
|
+
export const getSvgInnerContent = (svg: string): string => {
|
|
89
|
+
const match = svg.match(/<svg[^>]*>([\s\S]*?)<\/svg>/i);
|
|
90
|
+
return match?.[1] ?? '';
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Converts SVG attributes to React props.
|
|
95
|
+
*/
|
|
96
|
+
export const convertSvgAttributesToReactProps = (attributes: SVGAttributes): Partial<ReactSVGProps> => {
|
|
97
|
+
const reactProps: Record<string, string | number | boolean> = {};
|
|
98
|
+
|
|
99
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
100
|
+
const reactPropName = ATTRIBUTE_MAP[key] || key;
|
|
101
|
+
reactProps[reactPropName] = value;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return reactProps;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Fetches raw SVG content from a remote URL.
|
|
109
|
+
*/
|
|
110
|
+
export const fetchSvg = async (url: string): Promise<string> => {
|
|
111
|
+
try {
|
|
112
|
+
const response = await fetch(url, {
|
|
113
|
+
headers: {
|
|
114
|
+
Accept: 'image/svg+xml, text/plain, */*',
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
if (!response.ok) {
|
|
119
|
+
throw new Error(`Failed to fetch SVG: ${response.status} ${response.statusText}`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const content = await response.text();
|
|
123
|
+
if (!content.trim().includes('<svg')) {
|
|
124
|
+
throw new Error('Response is not valid SVG');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return content;
|
|
128
|
+
} catch (err) {
|
|
129
|
+
console.error('Error fetching SVG:', err);
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import dynamic from 'next/dynamic';
|
|
3
|
+
|
|
4
|
+
export const MaxWidthMap = {
|
|
5
|
+
small: 'max-w-xl',
|
|
6
|
+
medium: 'max-w-2xl',
|
|
7
|
+
large: 'max-w-4xl',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ModalProps = {
|
|
11
|
+
maxWidth?: 'small' | 'medium' | 'large';
|
|
12
|
+
className?: string;
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
closeIconColor?: string;
|
|
15
|
+
disableCloseModalOnClickOutside?: boolean;
|
|
16
|
+
trigger: ReactNode;
|
|
17
|
+
content: ReactNode;
|
|
18
|
+
actions?: ReactNode;
|
|
19
|
+
onChangeModalState?: (state: boolean) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default dynamic(() => import('./modal').then(mod => mod.Modal));
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { FC, useCallback, useState, MouseEvent, useRef, useEffect } from 'react';
|
|
4
|
+
import { cn } from '@/utils/styling';
|
|
5
|
+
import { ModalProps } from '.';
|
|
6
|
+
import { CloseIcon } from './close-icon';
|
|
7
|
+
import { getCloseButtonClasses, getDialogClasses, getFormClasses } from './style-utils';
|
|
8
|
+
|
|
9
|
+
export const Modal: FC<ModalProps> = ({
|
|
10
|
+
trigger,
|
|
11
|
+
content,
|
|
12
|
+
actions,
|
|
13
|
+
maxWidth,
|
|
14
|
+
backgroundColor,
|
|
15
|
+
closeIconColor,
|
|
16
|
+
disableCloseModalOnClickOutside,
|
|
17
|
+
onChangeModalState,
|
|
18
|
+
className,
|
|
19
|
+
}) => {
|
|
20
|
+
const modalActionsRef = useRef<HTMLDivElement>(null);
|
|
21
|
+
const [showModal, setShowModal] = useState(false);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (onChangeModalState) {
|
|
25
|
+
onChangeModalState(showModal);
|
|
26
|
+
}
|
|
27
|
+
}, [showModal, onChangeModalState]);
|
|
28
|
+
|
|
29
|
+
const handleClickOutside = useCallback(() => {
|
|
30
|
+
if (!disableCloseModalOnClickOutside) setShowModal(false);
|
|
31
|
+
}, [disableCloseModalOnClickOutside]);
|
|
32
|
+
|
|
33
|
+
const toggleModal = useCallback(() => {
|
|
34
|
+
setShowModal(prev => !prev);
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const handleClickContent = useCallback((e: MouseEvent<HTMLFormElement>) => {
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!modalActionsRef.current) return;
|
|
43
|
+
const currentActions = modalActionsRef.current.querySelectorAll('button, a');
|
|
44
|
+
const handleClickButton = () => setShowModal(false);
|
|
45
|
+
|
|
46
|
+
currentActions.forEach(button => {
|
|
47
|
+
button.addEventListener('click', handleClickButton);
|
|
48
|
+
});
|
|
49
|
+
return () =>
|
|
50
|
+
currentActions.forEach(button => {
|
|
51
|
+
button.removeEventListener('click', handleClickButton);
|
|
52
|
+
});
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div>
|
|
57
|
+
<div onClick={toggleModal}>{trigger}</div>
|
|
58
|
+
<div className={getDialogClasses({ showModal })}>
|
|
59
|
+
<dialog
|
|
60
|
+
open={showModal}
|
|
61
|
+
onClick={handleClickOutside}
|
|
62
|
+
aria-label="Close modal"
|
|
63
|
+
aria-modal="true"
|
|
64
|
+
className="flex size-full items-center justify-center bg-black/50 px-4"
|
|
65
|
+
>
|
|
66
|
+
<form
|
|
67
|
+
method="dialog"
|
|
68
|
+
className={cn(getFormClasses({ maxWidth, backgroundColor }), className)}
|
|
69
|
+
onClick={handleClickContent}
|
|
70
|
+
>
|
|
71
|
+
<button onClick={toggleModal} className={getCloseButtonClasses({ disableCloseModalOnClickOutside })}>
|
|
72
|
+
<CloseIcon
|
|
73
|
+
className={cn({
|
|
74
|
+
[`fill-${closeIconColor}`]: closeIconColor,
|
|
75
|
+
})}
|
|
76
|
+
/>
|
|
77
|
+
</button>
|
|
78
|
+
<div className="p-6 md:p-8">{content}</div>
|
|
79
|
+
{actions && (
|
|
80
|
+
<div ref={modalActionsRef} className="border-t p-6 md:p-8">
|
|
81
|
+
{actions}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
</form>
|
|
85
|
+
</dialog>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cn } from '@/utils/styling';
|
|
2
|
-
import { MaxWidthMap,
|
|
2
|
+
import { MaxWidthMap, ModalProps } from '.';
|
|
3
3
|
|
|
4
4
|
type DialogClassesProps = {
|
|
5
5
|
showModal?: boolean;
|
|
@@ -11,8 +11,8 @@ export const getDialogClasses = ({ showModal }: DialogClassesProps) =>
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
type FormClassesProps = {
|
|
14
|
-
maxWidth?:
|
|
15
|
-
backgroundColor?:
|
|
14
|
+
maxWidth?: ModalProps['maxWidth'];
|
|
15
|
+
backgroundColor?: ModalProps['backgroundColor'];
|
|
16
16
|
};
|
|
17
17
|
export const getFormClasses = ({ maxWidth, backgroundColor }: FormClassesProps) =>
|
|
18
18
|
cn('rounded-lg shadow-lg relative', MaxWidthMap[maxWidth || 'small'], {
|
|
@@ -20,7 +20,7 @@ export const getFormClasses = ({ maxWidth, backgroundColor }: FormClassesProps)
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
type CloseButtonClassesProps = {
|
|
23
|
-
disableCloseModalOnClickOutside?:
|
|
23
|
+
disableCloseModalOnClickOutside?: ModalProps['disableCloseModalOnClickOutside'];
|
|
24
24
|
};
|
|
25
25
|
export const getCloseButtonClasses = ({ disableCloseModalOnClickOutside }: CloseButtonClassesProps) =>
|
|
26
26
|
cn('group absolute right-4 top-4 opacity-40 hover:opacity-100', {
|
|
@@ -5,7 +5,7 @@ import { RatingProps } from '.';
|
|
|
5
5
|
export const Rating: FC<RatingProps> = ({ rating, showReviewLabel, starsColor, activeStarsColor }) => (
|
|
6
6
|
<div className="flex items-center space-x-1">
|
|
7
7
|
{Array.from({ length: 5 }, (_, starIndex) => {
|
|
8
|
-
const selectedRating = rating >= starIndex + 1;
|
|
8
|
+
const selectedRating = rating && rating >= starIndex + 1;
|
|
9
9
|
return (
|
|
10
10
|
<svg
|
|
11
11
|
key={starIndex}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { DefaultTheme } from 'tailwindcss/types/generated/default-theme';
|
|
3
2
|
import { ViewPort } from '@/types/cskTypes';
|
|
4
3
|
|
|
5
|
-
type TextSize = keyof DefaultTheme['fontSize'];
|
|
6
|
-
|
|
7
4
|
export type TextProps = {
|
|
8
5
|
className?: string;
|
|
9
|
-
size?:
|
|
6
|
+
size?: string | ViewPort<string>;
|
|
10
7
|
color?: string;
|
|
11
|
-
weight?:
|
|
8
|
+
weight?: string;
|
|
12
9
|
font?: string;
|
|
13
10
|
transform?: 'uppercase' | 'lowercase' | 'capitalize' | 'normal-case';
|
|
14
11
|
decoration?: 'underline' | 'overline' | 'line-through' | 'no-underline';
|
|
15
|
-
letterSpacing?:
|
|
12
|
+
letterSpacing?: string;
|
|
16
13
|
children: ReactElement | string;
|
|
17
14
|
alignment?: 'left' | 'center' | 'right';
|
|
18
15
|
lineCountRestrictions?: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { HTMLAttributes, ComponentProps as ReactComponentProps } from 'react';
|
|
2
|
+
import { AssetParamValueItem } from '@uniformdev/canvas';
|
|
3
|
+
import { UniformComposition } from '@uniformdev/next-app-router';
|
|
4
|
+
import { ComponentParameter } from '@uniformdev/next-app-router-shared';
|
|
5
|
+
|
|
6
|
+
type ResolveEmptyPlaceholderFunction = NonNullable<
|
|
7
|
+
ReactComponentProps<typeof UniformComposition>['resolveEmptyPlaceholder']
|
|
8
|
+
>;
|
|
9
|
+
export type ResolveEmptyPlaceholderOptions = Parameters<ResolveEmptyPlaceholderFunction>[0];
|
|
10
10
|
|
|
11
11
|
export type ViewPort<T> = {
|
|
12
12
|
desktop?: T;
|
|
@@ -25,3 +25,26 @@ export type SpaceType = Pick<
|
|
|
25
25
|
| 'paddingRight'
|
|
26
26
|
| 'paddingBottom'
|
|
27
27
|
>;
|
|
28
|
+
|
|
29
|
+
type ToComponentParameters<T> = {
|
|
30
|
+
[K in keyof T]: ComponentParameter<T[K]>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ComponentProps<
|
|
34
|
+
T,
|
|
35
|
+
S extends string = string,
|
|
36
|
+
> = import('@uniformdev/next-app-router/component').ComponentProps<ToComponentParameters<T>, S>;
|
|
37
|
+
|
|
38
|
+
type ValueOfField<F> = F extends { value: infer V } ? V : never;
|
|
39
|
+
type FlattenFields<T extends AssetParamValueItem> = {
|
|
40
|
+
[K in keyof T['fields']]: ValueOfField<T['fields'][K]>;
|
|
41
|
+
};
|
|
42
|
+
type RenameKey<T, K extends keyof T, NewName extends PropertyKey> = Omit<T, K> & { [P in NewName]: T[K] };
|
|
43
|
+
|
|
44
|
+
export type ResolvedAssetFromItem<T extends AssetParamValueItem> = RenameKey<FlattenFields<T>, 'id', 'file'> & {
|
|
45
|
+
id: T['_id'];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type ReplaceFieldsWithAssets<T, K extends keyof T> = Omit<T, K> & {
|
|
49
|
+
[P in K]?: ResolvedAssetFromItem<AssetParamValueItem>[];
|
|
50
|
+
};
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
import { AssetParamValue } from '@uniformdev/assets';
|
|
1
|
+
import { AssetParamValue, AssetParamValueItem } from '@uniformdev/assets';
|
|
2
2
|
import { flattenValues } from '@uniformdev/canvas';
|
|
3
|
-
|
|
4
|
-
type ResolvedAsset = {
|
|
5
|
-
id?: string;
|
|
6
|
-
url: string;
|
|
7
|
-
file?: string;
|
|
8
|
-
size?: number;
|
|
9
|
-
title?: string;
|
|
10
|
-
width?: number;
|
|
11
|
-
height?: number;
|
|
12
|
-
mediaType?: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
focalPoint?: {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
3
|
+
import { ResolvedAssetFromItem } from '@/types/cskTypes';
|
|
19
4
|
|
|
20
5
|
/**
|
|
21
6
|
* Resolves a list of assets, filtering out any entries without a valid URL.
|
|
@@ -23,5 +8,5 @@ type ResolvedAsset = {
|
|
|
23
8
|
* @param {AssetParamValue | undefined} image - The list of assets to resolve.
|
|
24
9
|
* @returns {ResolvedAsset[]} - An array of resolved assets with valid URLs.
|
|
25
10
|
*/
|
|
26
|
-
export const resolveAsset = (image?: AssetParamValue):
|
|
11
|
+
export const resolveAsset = (image?: AssetParamValue): ResolvedAssetFromItem<AssetParamValueItem>[] =>
|
|
27
12
|
(flattenValues(image as never) || []).filter(({ url }) => Boolean(url));
|