@arkyn/components 3.0.1-beta.154 → 3.0.1-beta.156
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/index.js +4694 -75
- package/dist/modules/components/alert/alertContainer/index.js +22 -0
- package/dist/modules/components/alert/alertContent/index.js +9 -0
- package/dist/modules/components/alert/alertDescription/index.js +9 -0
- package/dist/modules/components/alert/alertIcon/index.js +20 -0
- package/dist/modules/components/alert/alertTitle/index.js +9 -0
- package/dist/modules/components/audioPlayer/index.js +76 -0
- package/dist/modules/components/audioUpload/hasFileContent/index.js +63 -0
- package/dist/modules/components/audioUpload/index.js +80 -0
- package/dist/modules/components/audioUpload/noFileContent/index.js +46 -0
- package/dist/modules/components/badge/index.js +23 -0
- package/dist/modules/components/button/index.js +33 -0
- package/dist/modules/components/calendar/_calendarProvider.js +65 -0
- package/dist/modules/components/calendar/_viewService.js +141 -0
- package/dist/modules/components/calendar/calendarContainer/index.js +8 -0
- package/dist/modules/components/calendar/calendarHeader/index.js +73 -0
- package/dist/modules/components/calendar/calendarTableBody/index.js +11 -0
- package/dist/modules/components/calendar/calendarTableContainer/index.js +8 -0
- package/dist/modules/components/calendar/calendarTableHeader/index.js +11 -0
- package/dist/modules/components/calendar/calendarTableTd/index.js +24 -0
- package/dist/modules/components/calendar/index.js +50 -0
- package/dist/modules/components/cardTab/cardTabButton/index.js +30 -0
- package/dist/modules/components/cardTab/cardTabContainer/index.js +29 -0
- package/dist/modules/components/cardTab/cardTabContext.js +13 -0
- package/dist/modules/components/checkbox/index.js +65 -0
- package/dist/modules/components/clientOnly.js +9 -0
- package/dist/modules/components/currencyInput/index.js +140 -0
- package/dist/modules/components/divider/index.js +13 -0
- package/dist/modules/components/drawer/drawerContainer/index.js +44 -0
- package/dist/modules/components/drawer/drawerContext.js +13 -0
- package/dist/modules/components/drawer/drawerHeader/index.js +28 -0
- package/dist/modules/components/facebookPixel/facebookPixel.client.js +19 -0
- package/dist/modules/components/facebookPixel/index.js +9 -0
- package/dist/modules/components/facebookPixel/pixel.js +53 -0
- package/dist/modules/components/fieldError/index.js +9 -0
- package/dist/modules/components/fieldLabel/index.js +13 -0
- package/dist/modules/components/fieldWrapper/index.js +14 -0
- package/dist/modules/components/fileUpload/hasFileContent/index.js +68 -0
- package/dist/modules/components/fileUpload/index.js +73 -0
- package/dist/modules/components/fileUpload/noFileContent/index.js +46 -0
- package/dist/modules/components/fullCalendar/_fullCalendarProvider.js +48 -0
- package/dist/modules/components/fullCalendar/_viewService.js +106 -0
- package/dist/modules/components/fullCalendar/dayCalendar/dayCalendarContainer/index.js +8 -0
- package/dist/modules/components/fullCalendar/dayCalendar/dayCalendarEvent/index.js +79 -0
- package/dist/modules/components/fullCalendar/dayCalendar/dayCalendarRow/index.js +34 -0
- package/dist/modules/components/fullCalendar/dayCalendar/index.js +11 -0
- package/dist/modules/components/fullCalendar/fullCalendarContainer/index.js +8 -0
- package/dist/modules/components/fullCalendar/fullCalendarHeader/index.js +72 -0
- package/dist/modules/components/fullCalendar/index.js +31 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/index.js +13 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarEvent/index.js +37 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableBody/index.js +11 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableContainer/index.js +10 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableHeader/index.js +11 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableTd/index.js +37 -0
- package/dist/modules/components/fullCalendar/weekCalendar/index.js +13 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarEvent/index.js +79 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableBody/index.js +21 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableContainer/index.js +10 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableHeader/index.js +20 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableTd/index.js +40 -0
- package/dist/modules/components/googleAnalytics/googleAnalytics.client.js +8 -0
- package/dist/modules/components/googleAnalytics/googleAnalytics.js +18 -0
- package/dist/modules/components/googleAnalytics/index.js +10 -0
- package/dist/modules/components/googleAnalytics/snippets/generateGAElements.js +16 -0
- package/dist/modules/components/googleTagManager/googleTagManager.client.js +8 -0
- package/dist/modules/components/googleTagManager/googleTagManager.js +49 -0
- package/dist/modules/components/googleTagManager/index.js +28 -0
- package/dist/modules/components/googleTagManager/snippets/appendToDataLayer.js +9 -0
- package/dist/modules/components/googleTagManager/snippets/generateGTMElements.js +24 -0
- package/dist/modules/components/iconButton/index.js +30 -0
- package/dist/modules/components/imageUpload/hasFileContent/index.js +64 -0
- package/dist/modules/components/imageUpload/index.js +83 -0
- package/dist/modules/components/imageUpload/noFileContent/index.js +46 -0
- package/dist/modules/components/input/index.js +121 -0
- package/dist/modules/components/mapView/index.js +33 -0
- package/dist/modules/components/mapView/mapView.client.js +52 -0
- package/dist/modules/components/maskedInput/index.js +113 -0
- package/dist/modules/components/modal/modalContainer/index.js +43 -0
- package/dist/modules/components/modal/modalContext.js +13 -0
- package/dist/modules/components/modal/modalFooter/index.js +9 -0
- package/dist/modules/components/modal/modalHeader/index.js +28 -0
- package/dist/modules/components/multiSelect/index.js +155 -0
- package/dist/modules/components/multiSelect/multiSelectChevron/index.js +22 -0
- package/dist/modules/components/multiSelect/multiSelectContainer/index.js +30 -0
- package/dist/modules/components/multiSelect/multiSelectContent/index.js +9 -0
- package/dist/modules/components/multiSelect/multiSelectMark/index.js +23 -0
- package/dist/modules/components/multiSelect/multiSelectOption/index.js +14 -0
- package/dist/modules/components/multiSelect/multiSelectOptionsContainer/index.js +46 -0
- package/dist/modules/components/multiSelect/multiSelectOverlay/index.js +9 -0
- package/dist/modules/components/multiSelect/multiSelectSpinner/index.js +17 -0
- package/dist/modules/components/pagination/chevronButton/index.js +18 -0
- package/dist/modules/components/pagination/currentButton/index.js +8 -0
- package/dist/modules/components/pagination/index.js +84 -0
- package/dist/modules/components/pagination/pageButton/index.js +9 -0
- package/dist/modules/components/pagination/paginationService.js +49 -0
- package/dist/modules/components/pagination/spread/index.js +9 -0
- package/dist/modules/components/phoneInput/index.js +152 -0
- package/dist/modules/components/phoneInput/phoneInputContainer/index.js +20 -0
- package/dist/modules/components/phoneInput/phoneInputCountriesOverlay/index.js +9 -0
- package/dist/modules/components/phoneInput/phoneInputCountryOption/index.js +16 -0
- package/dist/modules/components/phoneInput/phoneInputCountryOptionsContainer/index.js +44 -0
- package/dist/modules/components/phoneInput/phoneInputCountrySelector/index.js +22 -0
- package/dist/modules/components/phoneInput/phoneInputMask/index.js +62 -0
- package/dist/modules/components/popover/index.js +37 -0
- package/dist/modules/components/radio/radioBox/index.js +43 -0
- package/dist/modules/components/radio/radioContext.js +20 -0
- package/dist/modules/components/radio/radioGroup/index.js +65 -0
- package/dist/modules/components/richText/blockButton/index.js +24 -0
- package/dist/modules/components/richText/element/index.js +59 -0
- package/dist/modules/components/richText/index.js +136 -0
- package/dist/modules/components/richText/insertImage/index.js +106 -0
- package/dist/modules/components/richText/insertVideo/index.js +98 -0
- package/dist/modules/components/richText/leaf/index.js +7 -0
- package/dist/modules/components/richText/markButton/index.js +23 -0
- package/dist/modules/components/richText/toolbar/index.js +8 -0
- package/dist/modules/components/searchPlaces.js +67 -0
- package/dist/modules/components/select/index.js +145 -0
- package/dist/modules/components/select/selectChevron/index.js +22 -0
- package/dist/modules/components/select/selectContainer/index.js +30 -0
- package/dist/modules/components/select/selectContent/index.js +9 -0
- package/dist/modules/components/select/selectOption/index.js +14 -0
- package/dist/modules/components/select/selectOptionsContainer/index.js +46 -0
- package/dist/modules/components/select/selectOverlay/index.js +9 -0
- package/dist/modules/components/select/selectSpinner/index.js +10 -0
- package/dist/modules/components/slider/index.js +42 -0
- package/dist/modules/components/switch/index.js +63 -0
- package/dist/modules/components/tab/tabButton/index.js +30 -0
- package/dist/modules/components/tab/tabContainer/index.js +29 -0
- package/dist/modules/components/tab/tabContext.js +13 -0
- package/dist/modules/components/table/tableBody/index.js +15 -0
- package/dist/modules/components/table/tableCaption/index.js +9 -0
- package/dist/modules/components/table/tableContainer/index.js +9 -0
- package/dist/modules/components/table/tableFooter/index.js +12 -0
- package/dist/modules/components/table/tableHeader/index.js +12 -0
- package/dist/modules/components/textarea/index.js +70 -0
- package/dist/modules/components/tooltip/index.js +46 -0
- package/dist/modules/hooks/useAutomation.js +28 -0
- package/dist/modules/hooks/useDrawer.js +20 -0
- package/dist/modules/hooks/useForm.js +8 -0
- package/dist/modules/hooks/useHydrated.js +15 -0
- package/dist/modules/hooks/useModal.js +20 -0
- package/dist/modules/hooks/useScopedParams.js +18 -0
- package/dist/modules/hooks/useScrollLock.js +21 -0
- package/dist/modules/hooks/useSearchAutomation.js +15 -0
- package/dist/modules/hooks/useSlider.js +14 -0
- package/dist/modules/hooks/useToast.js +11 -0
- package/dist/modules/index.js +144 -0
- package/dist/modules/providers/drawerProvider.js +31 -0
- package/dist/modules/providers/formProvider.js +18 -0
- package/dist/modules/providers/modalProvider.js +34 -0
- package/dist/modules/providers/placesProvider.js +18 -0
- package/dist/modules/providers/toastProvider.js +52 -0
- package/dist/modules/services/extractTextFromNode.js +7 -0
- package/dist/modules/services/fieldTemplate.js +24 -0
- package/dist/modules/services/iconRenderer.js +8 -0
- package/dist/modules/services/isBlockActive.js +15 -0
- package/dist/modules/services/isMarkActive.js +8 -0
- package/dist/modules/services/maskCurrencyValues.js +14 -0
- package/dist/modules/services/toHtml.js +7 -0
- package/dist/modules/services/toRichTextValue.js +9 -0
- package/dist/modules/services/toggleBlock.js +20 -0
- package/dist/modules/services/toggleMark.js +8 -0
- package/dist/modules/style.css +1 -0
- package/dist/modules/templates/badResponses.js +14 -0
- package/dist/modules/templates/richTextTemplates.js +14 -0
- package/dist/modules/templates/successResponses.js +4 -0
- package/dist/modules/utils/phoneInputUtilities.js +32 -0
- package/dist/modules/utils/richTextUtilities.js +77 -0
- package/package.json +208 -208
- package/dist/components/alert/alertContainer/index.js +0 -71
- package/dist/components/alert/alertContent/index.js +0 -26
- package/dist/components/alert/alertDescription/index.js +0 -25
- package/dist/components/alert/alertIcon/index.js +0 -43
- package/dist/components/alert/alertTitle/index.js +0 -27
- package/dist/components/audioPlayer/index.js +0 -112
- package/dist/components/audioUpload/hasFileContent/index.js +0 -26
- package/dist/components/audioUpload/index.js +0 -95
- package/dist/components/audioUpload/noFileContent/index.js +0 -29
- package/dist/components/badge/index.js +0 -41
- package/dist/components/button/index.js +0 -51
- package/dist/components/calendar/_calendarProvider.js +0 -58
- package/dist/components/calendar/_viewService.js +0 -179
- package/dist/components/calendar/calendarContainer/index.js +0 -6
- package/dist/components/calendar/calendarHeader/index.js +0 -13
- package/dist/components/calendar/calendarTableBody/index.js +0 -9
- package/dist/components/calendar/calendarTableContainer/index.js +0 -6
- package/dist/components/calendar/calendarTableHeader/index.js +0 -9
- package/dist/components/calendar/calendarTableTd/index.js +0 -15
- package/dist/components/calendar/index.js +0 -54
- package/dist/components/cardTab/cardTabButton/index.js +0 -40
- package/dist/components/cardTab/cardTabContainer/index.js +0 -42
- package/dist/components/cardTab/cardTabContext.js +0 -10
- package/dist/components/checkbox/index.js +0 -71
- package/dist/components/clientOnly.js +0 -31
- package/dist/components/currencyInput/index.js +0 -126
- package/dist/components/divider/index.js +0 -28
- package/dist/components/drawer/drawerContainer/index.js +0 -38
- package/dist/components/drawer/drawerContext.js +0 -10
- package/dist/components/drawer/drawerHeader/index.js +0 -33
- package/dist/components/facebookPixel/facebookPixel.client.js +0 -23
- package/dist/components/facebookPixel/index.js +0 -45
- package/dist/components/facebookPixel/pixel.js +0 -111
- package/dist/components/fieldError/index.js +0 -26
- package/dist/components/fieldLabel/index.js +0 -23
- package/dist/components/fieldWrapper/index.js +0 -27
- package/dist/components/fileUpload/hasFileContent/index.js +0 -34
- package/dist/components/fileUpload/index.js +0 -89
- package/dist/components/fileUpload/noFileContent/index.js +0 -29
- package/dist/components/fullCalendar/_fullCalendarProvider.js +0 -36
- package/dist/components/fullCalendar/_viewService.js +0 -144
- package/dist/components/fullCalendar/dayCalendar/dayCalendarContainer/index.js +0 -6
- package/dist/components/fullCalendar/dayCalendar/dayCalendarEvent/index.js +0 -105
- package/dist/components/fullCalendar/dayCalendar/dayCalendarRow/index.js +0 -24
- package/dist/components/fullCalendar/dayCalendar/index.js +0 -9
- package/dist/components/fullCalendar/fullCalendarContainer/index.js +0 -6
- package/dist/components/fullCalendar/fullCalendarHeader/index.js +0 -37
- package/dist/components/fullCalendar/index.js +0 -52
- package/dist/components/fullCalendar/monthlyCalendar/index.js +0 -8
- package/dist/components/fullCalendar/monthlyCalendar/monthlyCalendarEvent/index.js +0 -29
- package/dist/components/fullCalendar/monthlyCalendar/monthlyCalendarTableBody/index.js +0 -9
- package/dist/components/fullCalendar/monthlyCalendar/monthlyCalendarTableContainer/index.js +0 -6
- package/dist/components/fullCalendar/monthlyCalendar/monthlyCalendarTableHeader/index.js +0 -9
- package/dist/components/fullCalendar/monthlyCalendar/monthlyCalendarTableTd/index.js +0 -30
- package/dist/components/fullCalendar/weekCalendar/index.js +0 -8
- package/dist/components/fullCalendar/weekCalendar/weekCalendarEvent/index.js +0 -102
- package/dist/components/fullCalendar/weekCalendar/weekCalendarTableBody/index.js +0 -11
- package/dist/components/fullCalendar/weekCalendar/weekCalendarTableContainer/index.js +0 -6
- package/dist/components/fullCalendar/weekCalendar/weekCalendarTableHeader/index.js +0 -10
- package/dist/components/fullCalendar/weekCalendar/weekCalendarTableTd/index.js +0 -25
- package/dist/components/googleAnalytics/googleAnalytics.client.js +0 -8
- package/dist/components/googleAnalytics/googleAnalytics.js +0 -23
- package/dist/components/googleAnalytics/index.js +0 -31
- package/dist/components/googleAnalytics/snippets/generateGAElements.js +0 -16
- package/dist/components/googleTagManager/googleTagManager.client.js +0 -8
- package/dist/components/googleTagManager/googleTagManager.js +0 -52
- package/dist/components/googleTagManager/index.js +0 -47
- package/dist/components/googleTagManager/snippets/appendToDataLayer.js +0 -7
- package/dist/components/googleTagManager/snippets/generateGTMElements.js +0 -25
- package/dist/components/iconButton/index.js +0 -38
- package/dist/components/imageUpload/hasFileContent/index.js +0 -24
- package/dist/components/imageUpload/index.js +0 -101
- package/dist/components/imageUpload/noFileContent/index.js +0 -29
- package/dist/components/input/index.js +0 -94
- package/dist/components/mapView/index.js +0 -53
- package/dist/components/mapView/mapView.client.js +0 -51
- package/dist/components/maskedInput/index.js +0 -108
- package/dist/components/modal/modalContainer/index.js +0 -40
- package/dist/components/modal/modalContext.js +0 -10
- package/dist/components/modal/modalFooter/index.js +0 -32
- package/dist/components/modal/modalHeader/index.js +0 -34
- package/dist/components/multiSelect/index.js +0 -135
- package/dist/components/multiSelect/multiSelectChevron/index.js +0 -18
- package/dist/components/multiSelect/multiSelectContainer/index.js +0 -11
- package/dist/components/multiSelect/multiSelectContent/index.js +0 -8
- package/dist/components/multiSelect/multiSelectMark/index.js +0 -11
- package/dist/components/multiSelect/multiSelectOption/index.js +0 -10
- package/dist/components/multiSelect/multiSelectOptionsContainer/index.js +0 -44
- package/dist/components/multiSelect/multiSelectOverlay/index.js +0 -9
- package/dist/components/multiSelect/multiSelectSpinner/index.js +0 -10
- package/dist/components/pagination/chevronButton/index.js +0 -9
- package/dist/components/pagination/currentButton/index.js +0 -6
- package/dist/components/pagination/index.js +0 -46
- package/dist/components/pagination/pageButton/index.js +0 -7
- package/dist/components/pagination/paginationService.js +0 -62
- package/dist/components/pagination/spread/index.js +0 -7
- package/dist/components/phoneInput/index.js +0 -127
- package/dist/components/phoneInput/phoneInputContainer/index.js +0 -11
- package/dist/components/phoneInput/phoneInputCountriesOverlay/index.js +0 -9
- package/dist/components/phoneInput/phoneInputCountryOption/index.js +0 -10
- package/dist/components/phoneInput/phoneInputCountryOptionsContainer/index.js +0 -40
- package/dist/components/phoneInput/phoneInputCountrySelector/index.js +0 -9
- package/dist/components/phoneInput/phoneInputMask/index.js +0 -37
- package/dist/components/popover/index.js +0 -62
- package/dist/components/radio/radioBox/index.js +0 -48
- package/dist/components/radio/radioContext.js +0 -11
- package/dist/components/radio/radioGroup/index.js +0 -58
- package/dist/components/richText/blockButton/index.js +0 -18
- package/dist/components/richText/element/index.js +0 -26
- package/dist/components/richText/index.js +0 -136
- package/dist/components/richText/insertImage/index.js +0 -33
- package/dist/components/richText/insertVideo/index.js +0 -51
- package/dist/components/richText/leaf/index.js +0 -13
- package/dist/components/richText/markButton/index.js +0 -16
- package/dist/components/richText/toolbar/index.js +0 -6
- package/dist/components/searchPlaces.js +0 -99
- package/dist/components/select/index.js +0 -134
- package/dist/components/select/selectChevron/index.js +0 -18
- package/dist/components/select/selectContainer/index.js +0 -11
- package/dist/components/select/selectContent/index.js +0 -8
- package/dist/components/select/selectOption/index.js +0 -10
- package/dist/components/select/selectOptionsContainer/index.js +0 -44
- package/dist/components/select/selectOverlay/index.js +0 -9
- package/dist/components/select/selectSpinner/index.js +0 -10
- package/dist/components/slider/index.js +0 -79
- package/dist/components/switch/index.js +0 -66
- package/dist/components/tab/tabButton/index.js +0 -40
- package/dist/components/tab/tabContainer/index.js +0 -42
- package/dist/components/tab/tabContext.js +0 -10
- package/dist/components/table/tableBody/index.js +0 -34
- package/dist/components/table/tableCaption/index.js +0 -24
- package/dist/components/table/tableContainer/index.js +0 -37
- package/dist/components/table/tableFooter/index.js +0 -23
- package/dist/components/table/tableHeader/index.js +0 -25
- package/dist/components/textarea/index.js +0 -80
- package/dist/components/tooltip/index.js +0 -96
- package/dist/hooks/useAutomation.js +0 -74
- package/dist/hooks/useDrawer.js +0 -20
- package/dist/hooks/useForm.js +0 -35
- package/dist/hooks/useHydrated.js +0 -26
- package/dist/hooks/useModal.js +0 -20
- package/dist/hooks/useScopedParams.js +0 -55
- package/dist/hooks/useScrollLock.js +0 -46
- package/dist/hooks/useSearchAutomation.js +0 -64
- package/dist/hooks/useSlider.js +0 -35
- package/dist/hooks/useToast.js +0 -28
- package/dist/providers/drawerProvider.js +0 -54
- package/dist/providers/formProvider.js +0 -34
- package/dist/providers/modalProvider.js +0 -58
- package/dist/providers/placesProvider.js +0 -40
- package/dist/providers/toastProvider.js +0 -62
- package/dist/services/extractTextFromNode.js +0 -5
- package/dist/services/fieldTemplate.js +0 -11
- package/dist/services/iconRenderer.js +0 -13
- package/dist/services/isBlockActive.js +0 -14
- package/dist/services/isMarkActive.js +0 -6
- package/dist/services/maskCurrencyValues.js +0 -23
- package/dist/services/toHtml.js +0 -22
- package/dist/services/toRichTextValue.js +0 -34
- package/dist/services/toggleBlock.js +0 -32
- package/dist/services/toggleMark.js +0 -10
- package/dist/templates/badResponses.js +0 -12
- package/dist/templates/richTextTemplates.js +0 -12
- package/dist/templates/successResponses.js +0 -2
- package/dist/types/richTextTypes.js +0 -1
- package/dist/utils/phoneInputUtilities.js +0 -37
- package/dist/utils/richTextUtilities.js +0 -89
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
function getScrollbarWidth() {
|
|
3
|
-
if (typeof window === "undefined")
|
|
4
|
-
return 0;
|
|
5
|
-
return window.innerWidth - document.documentElement.clientWidth;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* useScrollLock — locks `document.body` scroll while an overlay is open.
|
|
9
|
-
*
|
|
10
|
-
* Compensates for the scrollbar width by adding equivalent `paddingRight`,
|
|
11
|
-
* preventing layout shift when the scrollbar disappears.
|
|
12
|
-
* Restores the original `overflow` and `paddingRight` when `isLocked` becomes `false`.
|
|
13
|
-
*
|
|
14
|
-
* Used internally by `Modal` and `Drawer` — you usually don't need this directly
|
|
15
|
-
* unless building a custom overlay.
|
|
16
|
-
*
|
|
17
|
-
* @param isLocked - When `true`, body scroll is disabled.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* function CustomOverlay({ isOpen }) {
|
|
22
|
-
* useScrollLock(isOpen);
|
|
23
|
-
* return isOpen ? <div className="overlay">...</div> : null;
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
function useScrollLock(isLocked) {
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (isLocked) {
|
|
30
|
-
const originalOverflow = document.body.style.overflow;
|
|
31
|
-
const originalPaddingRight = document.body.style.paddingRight;
|
|
32
|
-
const scrollbarWidth = getScrollbarWidth();
|
|
33
|
-
if (scrollbarWidth > 0) {
|
|
34
|
-
const computedStyle = window.getComputedStyle(document.body);
|
|
35
|
-
const existingPaddingRight = parseInt(computedStyle.paddingRight) || 0;
|
|
36
|
-
document.body.style.paddingRight = `${existingPaddingRight + scrollbarWidth}px`;
|
|
37
|
-
}
|
|
38
|
-
document.body.style.overflow = "hidden";
|
|
39
|
-
return () => {
|
|
40
|
-
document.body.style.overflow = originalOverflow;
|
|
41
|
-
document.body.style.paddingRight = originalPaddingRight;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}, [isLocked]);
|
|
45
|
-
}
|
|
46
|
-
export { useScrollLock };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { useModal } from "./useModal";
|
|
3
|
-
import { useToast } from "./useToast";
|
|
4
|
-
import { badResponses } from "../templates/badResponses";
|
|
5
|
-
import { successResponses } from "../templates/successResponses";
|
|
6
|
-
import { useScopedParams } from "./useScopedParams";
|
|
7
|
-
/**
|
|
8
|
-
* useSearchAutomation — URL-driven version of `useAutomation`. Reads automation params from a
|
|
9
|
-
* URL search string and executes the same side-effects (close modals, toast) on every change.
|
|
10
|
-
*
|
|
11
|
-
* Reads the following params (optionally prefixed by `scope:`):
|
|
12
|
-
* - `closeModal=true` — closes all open modals.
|
|
13
|
-
* - `message` — text for the toast notification.
|
|
14
|
-
* - `type` — `"success"` or `"danger"` toast style.
|
|
15
|
-
* - `name` — response identifier matched against `successResponses`/`badResponses` lists.
|
|
16
|
-
*
|
|
17
|
-
* @param searchString - Raw URL search string (e.g. `location.search`).
|
|
18
|
-
* @param scope - Optional prefix for all params. Default: `""` (no prefix).
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* // Remix / Next.js Server Action that redirects with search params
|
|
23
|
-
* // redirect("?closeModal=true&message=Saved!&type=success")
|
|
24
|
-
* const [searchParams] = useSearchParams();
|
|
25
|
-
* useSearchAutomation(searchParams.toString());
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```tsx
|
|
30
|
-
* // Scoped params — avoids collisions when multiple features share the URL
|
|
31
|
-
* // redirect("?filters:closeModal=true&filters:message=Applied!&filters:type=success")
|
|
32
|
-
* useSearchAutomation(location.search, "filters");
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
function useSearchAutomation(searchString, scope = "") {
|
|
36
|
-
const { closeAll } = useModal();
|
|
37
|
-
const { showToast } = useToast();
|
|
38
|
-
const { getParam } = useScopedParams(searchString, scope);
|
|
39
|
-
const closeModal = getParam("closeModal") === "true";
|
|
40
|
-
const message = getParam("message");
|
|
41
|
-
const name = getParam("name");
|
|
42
|
-
const type = getParam("type");
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (closeModal)
|
|
45
|
-
closeAll();
|
|
46
|
-
if (message) {
|
|
47
|
-
if (type === "success")
|
|
48
|
-
showToast({ message, type: "success" });
|
|
49
|
-
if (type === "danger")
|
|
50
|
-
showToast({ message, type: "danger" });
|
|
51
|
-
if (name &&
|
|
52
|
-
badResponses.includes(name) &&
|
|
53
|
-
!badResponses.includes(message)) {
|
|
54
|
-
showToast({ message, type: "danger" });
|
|
55
|
-
}
|
|
56
|
-
if (name &&
|
|
57
|
-
successResponses.includes(name) &&
|
|
58
|
-
!successResponses.includes(message)) {
|
|
59
|
-
showToast({ message, type: "success" });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, [closeModal, message, name, type]);
|
|
63
|
-
}
|
|
64
|
-
export { useSearchAutomation };
|
package/dist/hooks/useSlider.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* useSlider — state manager for the `Slider` component. Clamps values to `[0, 100]`.
|
|
4
|
-
*
|
|
5
|
-
* @param defaultValue - Initial percentage value (0–100). Default: 0
|
|
6
|
-
*
|
|
7
|
-
* @returns `[value, setValue]` — current percentage and a setter that clamps at the boundaries.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* const [volume, setVolume] = useSlider(50);
|
|
12
|
-
* return <Slider value={volume} onChange={setVolume} />;
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
function useSlider(defaultValue) {
|
|
16
|
-
function getDefaultValue() {
|
|
17
|
-
if (!defaultValue)
|
|
18
|
-
return 0;
|
|
19
|
-
if (defaultValue <= 0)
|
|
20
|
-
return 0;
|
|
21
|
-
if (defaultValue >= 100)
|
|
22
|
-
return 100;
|
|
23
|
-
return defaultValue;
|
|
24
|
-
}
|
|
25
|
-
const [sliderValue, setSliderValue] = useState(getDefaultValue());
|
|
26
|
-
function changeSliderValue(value) {
|
|
27
|
-
if (value <= 0)
|
|
28
|
-
return setSliderValue(0);
|
|
29
|
-
if (value >= 100)
|
|
30
|
-
return setSliderValue(100);
|
|
31
|
-
return setSliderValue(value);
|
|
32
|
-
}
|
|
33
|
-
return [sliderValue, changeSliderValue];
|
|
34
|
-
}
|
|
35
|
-
export { useSlider };
|
package/dist/hooks/useToast.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { toastContext } from "../providers/toastProvider";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* useToast — reads `ToastProvider` context to display toast notifications.
|
|
5
|
-
*
|
|
6
|
-
* @returns Context containing `showToast(options)`.
|
|
7
|
-
*
|
|
8
|
-
* @throws If called outside a `ToastProvider`.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* const { showToast } = useToast();
|
|
13
|
-
*
|
|
14
|
-
* // After a successful save
|
|
15
|
-
* showToast({ message: "Changes saved!", type: "success" });
|
|
16
|
-
*
|
|
17
|
-
* // After a failed request
|
|
18
|
-
* showToast({ message: "Failed to save changes.", type: "danger" });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
function useToast() {
|
|
22
|
-
const contextData = useContext(toastContext);
|
|
23
|
-
if (Object.entries(contextData).length === 0) {
|
|
24
|
-
throw new Error("useToast must be used within a Provider");
|
|
25
|
-
}
|
|
26
|
-
return contextData;
|
|
27
|
-
}
|
|
28
|
-
export { useToast };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useState } from "react";
|
|
3
|
-
const drawerContext = createContext({});
|
|
4
|
-
/**
|
|
5
|
-
* DrawerProvider — context provider that manages open/close state and data for named drawers.
|
|
6
|
-
*
|
|
7
|
-
* Wrap your app (or a subtree) with this once. Any component in the tree can then call
|
|
8
|
-
* `useDrawer(key)` to open, close, or read data for a specific drawer.
|
|
9
|
-
*
|
|
10
|
-
* @param props.children - Components that will have access to drawer context.
|
|
11
|
-
*
|
|
12
|
-
* @returns DrawerProvider JSX element.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* // In your root layout
|
|
17
|
-
* <DrawerProvider>
|
|
18
|
-
* <App />
|
|
19
|
-
* </DrawerProvider>
|
|
20
|
-
*
|
|
21
|
-
* // Opening a drawer from anywhere in the tree
|
|
22
|
-
* const { openDrawer } = useDrawer();
|
|
23
|
-
* openDrawer('filters', { category: 'electronics' });
|
|
24
|
-
*
|
|
25
|
-
* // Consuming in the drawer component
|
|
26
|
-
* const { drawerIsOpen, drawerData, closeDrawer } = useDrawer<{ category: string }>('filters');
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
function DrawerProvider(args) {
|
|
30
|
-
const { children = false } = args;
|
|
31
|
-
const [openedDrawers, setOpenedDrawers] = useState([]);
|
|
32
|
-
function drawerIsOpen(key) {
|
|
33
|
-
return !!openedDrawers.some((drawer) => drawer.key === key);
|
|
34
|
-
}
|
|
35
|
-
function drawerData(key) {
|
|
36
|
-
return openedDrawers.find((drawer) => drawer.key === key)?.data;
|
|
37
|
-
}
|
|
38
|
-
function openDrawer(key, data) {
|
|
39
|
-
const alreadyExist = drawerIsOpen(key);
|
|
40
|
-
if (alreadyExist) {
|
|
41
|
-
setOpenedDrawers((old) => {
|
|
42
|
-
const filtered = old.filter((drawer) => drawer.key !== key);
|
|
43
|
-
return [...filtered, { key, data }];
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
else
|
|
47
|
-
setOpenedDrawers([...openedDrawers, { key, data }]);
|
|
48
|
-
}
|
|
49
|
-
function closeDrawer(key) {
|
|
50
|
-
setOpenedDrawers(openedDrawers.filter((drawer) => drawer.key !== key));
|
|
51
|
-
}
|
|
52
|
-
return (_jsx(drawerContext.Provider, { value: { drawerIsOpen, drawerData, openDrawer, closeDrawer }, children: children }));
|
|
53
|
-
}
|
|
54
|
-
export { drawerContext, DrawerProvider };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, cloneElement } from "react";
|
|
3
|
-
const formContext = createContext({});
|
|
4
|
-
/**
|
|
5
|
-
* FormProvider — distributes field-level validation errors to all form input components in its subtree.
|
|
6
|
-
*
|
|
7
|
-
* All inputs (`Input`, `Select`, `Checkbox`, etc.) read `fieldErrors[name]` automatically,
|
|
8
|
-
* so you don't need to pass errors manually to each field. Use the `form` prop to also wrap
|
|
9
|
-
* children in a `<form>` element (e.g. for Remix `<Form />`).
|
|
10
|
-
*
|
|
11
|
-
* @param props.children - Form fields and other components.
|
|
12
|
-
* @param props.fieldErrors - Map of field name → error message (e.g. from Zod / server validation).
|
|
13
|
-
* @param props.form - Optional `<form>` element to wrap children in (cloned with `children`).
|
|
14
|
-
*
|
|
15
|
-
* @returns FormProvider JSX element.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* // With Remix action errors
|
|
20
|
-
* const actionData = useActionData<typeof action>();
|
|
21
|
-
*
|
|
22
|
-
* <FormProvider fieldErrors={actionData?.fieldErrors}>
|
|
23
|
-
* <Input name="email" label="Email" />
|
|
24
|
-
* <Input name="password" label="Password" type="password" />
|
|
25
|
-
* <Button type="submit">Login</Button>
|
|
26
|
-
* </FormProvider>
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
function FormProvider(props) {
|
|
30
|
-
const { children, fieldErrors, form } = props;
|
|
31
|
-
return (_jsxs(formContext.Provider, { value: { fieldErrors }, children: [!form && children, form &&
|
|
32
|
-
cloneElement(form, form.props, children)] }));
|
|
33
|
-
}
|
|
34
|
-
export { formContext, FormProvider };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useState } from "react";
|
|
3
|
-
const modalContext = createContext({});
|
|
4
|
-
/**
|
|
5
|
-
* ModalProvider — context provider that manages open/close state and data for named modals.
|
|
6
|
-
*
|
|
7
|
-
* Wrap your app (or a subtree) with this once. Any component in the tree can then call
|
|
8
|
-
* `useModal(key)` to open, close, or read data for a specific modal. `closeAll()` is also
|
|
9
|
-
* available (used by `useAutomation` to close all modals after a successful form action).
|
|
10
|
-
*
|
|
11
|
-
* @param props.children - Components that will have access to modal context.
|
|
12
|
-
*
|
|
13
|
-
* @returns ModalProvider JSX element.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* // In your root layout
|
|
18
|
-
* <ModalProvider>
|
|
19
|
-
* <App />
|
|
20
|
-
* </ModalProvider>
|
|
21
|
-
*
|
|
22
|
-
* // Opening a modal from anywhere in the tree
|
|
23
|
-
* const { openModal } = useModal();
|
|
24
|
-
* openModal('confirm-delete', { id: user.id });
|
|
25
|
-
*
|
|
26
|
-
* // Consuming in the modal component
|
|
27
|
-
* const { modalIsOpen, modalData, closeModal } = useModal<{ id: number }>('confirm-delete');
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
function ModalProvider(args) {
|
|
31
|
-
const { children = false } = args;
|
|
32
|
-
const [openedModals, setOpenedModals] = useState([]);
|
|
33
|
-
function modalIsOpen(key) {
|
|
34
|
-
return !!openedModals.some((modal) => modal.key === key);
|
|
35
|
-
}
|
|
36
|
-
function modalData(key) {
|
|
37
|
-
return openedModals.find((modal) => modal.key === key)?.data;
|
|
38
|
-
}
|
|
39
|
-
function openModal(key, data) {
|
|
40
|
-
const alreadyExist = modalIsOpen(key);
|
|
41
|
-
if (alreadyExist) {
|
|
42
|
-
setOpenedModals((old) => {
|
|
43
|
-
const filtered = old.filter((modal) => modal.key !== key);
|
|
44
|
-
return [...filtered, { key, data }];
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
setOpenedModals([...openedModals, { key, data }]);
|
|
49
|
-
}
|
|
50
|
-
function closeModal(key) {
|
|
51
|
-
setOpenedModals(openedModals.filter((modal) => modal.key !== key));
|
|
52
|
-
}
|
|
53
|
-
function closeAll() {
|
|
54
|
-
setOpenedModals([]);
|
|
55
|
-
}
|
|
56
|
-
return (_jsx(modalContext.Provider, { value: { modalIsOpen, modalData, openModal, closeModal, closeAll }, children: children }));
|
|
57
|
-
}
|
|
58
|
-
export { modalContext, ModalProvider };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useLoadScript } from "@react-google-maps/api";
|
|
3
|
-
const libraries = [
|
|
4
|
-
"places",
|
|
5
|
-
"marker",
|
|
6
|
-
"maps",
|
|
7
|
-
];
|
|
8
|
-
/**
|
|
9
|
-
* PlacesProvider — loads the Google Maps JS API with `places`, `marker`, and `maps` libraries.
|
|
10
|
-
*
|
|
11
|
-
* Uses a render-prop pattern: `children` receives `isLoaded` so you can defer rendering
|
|
12
|
-
* `SearchPlaces` or `MapView` until the script is ready.
|
|
13
|
-
*
|
|
14
|
-
* @param props.apiKey - Google Maps API key. Required.
|
|
15
|
-
* @param props.children - Render function: `(isLoaded: boolean) => ReactNode`.
|
|
16
|
-
* @param props.preventFontsLoading - Prevents Google Fonts from being injected by the Maps SDK. @default true
|
|
17
|
-
*
|
|
18
|
-
* @returns The result of calling `children(isLoaded)`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* <PlacesProvider apiKey={env.GOOGLE_MAPS_KEY}>
|
|
23
|
-
* {(isLoaded) => (
|
|
24
|
-
* isLoaded
|
|
25
|
-
* ? <SearchPlaces apiKey={env.GOOGLE_MAPS_KEY} onSelect={setAddress} />
|
|
26
|
-
* : <Skeleton />
|
|
27
|
-
* )}
|
|
28
|
-
* </PlacesProvider>
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
function PlacesProvider(props) {
|
|
32
|
-
const { apiKey, children, preventFontsLoading = true } = props;
|
|
33
|
-
const { isLoaded } = useLoadScript({
|
|
34
|
-
googleMapsApiKey: apiKey,
|
|
35
|
-
libraries,
|
|
36
|
-
preventGoogleFontsLoading: preventFontsLoading,
|
|
37
|
-
});
|
|
38
|
-
return _jsx(_Fragment, { children: children(isLoaded) });
|
|
39
|
-
}
|
|
40
|
-
export { PlacesProvider };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createContext } from "react";
|
|
3
|
-
import toast, { Toaster } from "react-hot-toast";
|
|
4
|
-
const toastContext = createContext({});
|
|
5
|
-
/**
|
|
6
|
-
* ToastProvider — mounts a `react-hot-toast` `<Toaster>` and exposes `showToast` via context.
|
|
7
|
-
*
|
|
8
|
-
* Wrap your app once. Then call `useToast()` anywhere in the tree to show notifications.
|
|
9
|
-
* Supports two types: `"success"` (green) and `"danger"` (red).
|
|
10
|
-
*
|
|
11
|
-
* @param props.children - App subtree that will have access to `useToast`.
|
|
12
|
-
*
|
|
13
|
-
* @returns ToastProvider JSX element.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* // In your root layout
|
|
18
|
-
* <ToastProvider>
|
|
19
|
-
* <App />
|
|
20
|
-
* </ToastProvider>
|
|
21
|
-
*
|
|
22
|
-
* // Anywhere in the tree
|
|
23
|
-
* const { showToast } = useToast();
|
|
24
|
-
* showToast({ message: "Order placed!", type: "success" });
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
function ToastProvider({ children }) {
|
|
28
|
-
function showToast(props) {
|
|
29
|
-
switch (props.type) {
|
|
30
|
-
case "success":
|
|
31
|
-
return toast.success(props.message, {
|
|
32
|
-
style: {
|
|
33
|
-
background: "#10B981",
|
|
34
|
-
color: "#ffffff",
|
|
35
|
-
padding: "12px 16px",
|
|
36
|
-
fontSize: "14px",
|
|
37
|
-
fontWeight: 600,
|
|
38
|
-
},
|
|
39
|
-
iconTheme: {
|
|
40
|
-
primary: "#059669",
|
|
41
|
-
secondary: "#ffffff",
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
case "danger":
|
|
45
|
-
return toast.error(props.message, {
|
|
46
|
-
style: {
|
|
47
|
-
background: "#E11D48",
|
|
48
|
-
color: "#ffffff",
|
|
49
|
-
padding: "12px 16px",
|
|
50
|
-
fontSize: "14px",
|
|
51
|
-
fontWeight: 600,
|
|
52
|
-
},
|
|
53
|
-
iconTheme: {
|
|
54
|
-
primary: "#BE123C",
|
|
55
|
-
secondary: "#ffffff",
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return (_jsxs(toastContext.Provider, { value: { showToast }, children: [_jsx(Toaster, { position: "top-right", containerStyle: { zIndex: 999999999999999 } }), children] }));
|
|
61
|
-
}
|
|
62
|
-
export { toastContext, ToastProvider };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { FieldError } from "../components/fieldError";
|
|
3
|
-
import { FieldLabel } from "../components/fieldLabel";
|
|
4
|
-
import { FieldWrapper } from "../components/fieldWrapper";
|
|
5
|
-
function FieldTemplate(props) {
|
|
6
|
-
const { name, label, showAsterisk, className, unShowFieldTemplate, errorMessage, children, orientation, } = props;
|
|
7
|
-
if (unShowFieldTemplate)
|
|
8
|
-
return children;
|
|
9
|
-
return (_jsxs(FieldWrapper, { id: name, className: className, orientation: orientation, children: [label && _jsx(FieldLabel, { showAsterisk: showAsterisk, children: label }), children, errorMessage && _jsx(FieldError, { children: errorMessage })] }));
|
|
10
|
-
}
|
|
11
|
-
export { FieldTemplate };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
function IconRenderer(props) {
|
|
3
|
-
const { iconSize, icon: Icon, className, show = true } = props;
|
|
4
|
-
if (!show)
|
|
5
|
-
return _jsx(_Fragment, {});
|
|
6
|
-
if (!Icon)
|
|
7
|
-
return _jsx(_Fragment, {});
|
|
8
|
-
if (typeof Icon === "string") {
|
|
9
|
-
return _jsx("p", { className: className, children: Icon });
|
|
10
|
-
}
|
|
11
|
-
return _jsx(Icon, { size: iconSize, strokeWidth: 2.5, className: className });
|
|
12
|
-
}
|
|
13
|
-
export { IconRenderer };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Editor, Element as SlateElement } from "slate";
|
|
2
|
-
function isBlockActive(editor, format, blockType = "type") {
|
|
3
|
-
const { selection } = editor;
|
|
4
|
-
if (!selection)
|
|
5
|
-
return false;
|
|
6
|
-
const [match] = Array.from(Editor.nodes(editor, {
|
|
7
|
-
at: Editor.unhangRange(editor, selection),
|
|
8
|
-
match: (n) => !Editor.isEditor(n) &&
|
|
9
|
-
SlateElement.isElement(n) &&
|
|
10
|
-
n[blockType] === format,
|
|
11
|
-
}));
|
|
12
|
-
return !!match;
|
|
13
|
-
}
|
|
14
|
-
export { isBlockActive };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { formatToCurrency, removeNonNumeric } from "@arkyn/shared";
|
|
2
|
-
function normalizeValue(number) {
|
|
3
|
-
let safeNumber = number;
|
|
4
|
-
if (typeof number === "string") {
|
|
5
|
-
safeNumber = +removeNonNumeric(number);
|
|
6
|
-
if (safeNumber % 1 !== 0)
|
|
7
|
-
safeNumber = safeNumber.toFixed(2);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
safeNumber = Number.isInteger(number)
|
|
11
|
-
? Number(number) * 10 ** 2
|
|
12
|
-
: number.toFixed(2);
|
|
13
|
-
}
|
|
14
|
-
return +removeNonNumeric(String(safeNumber)) / 10 ** 2;
|
|
15
|
-
}
|
|
16
|
-
function maskCurrencyValues(inputFieldValue, locale) {
|
|
17
|
-
if (!inputFieldValue)
|
|
18
|
-
return [0, formatToCurrency(0, locale)];
|
|
19
|
-
const value = normalizeValue(inputFieldValue);
|
|
20
|
-
const maskedValue = formatToCurrency(value, locale);
|
|
21
|
-
return [value, maskedValue];
|
|
22
|
-
}
|
|
23
|
-
export { maskCurrencyValues, normalizeValue };
|
package/dist/services/toHtml.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { serialize } from "../utils/richTextUtilities";
|
|
2
|
-
/**
|
|
3
|
-
* toHtml — converts a `RichTextValue` (Slate.js Descendant array) to an HTML string.
|
|
4
|
-
*
|
|
5
|
-
* Use this to persist or display the editor's content as plain HTML.
|
|
6
|
-
*
|
|
7
|
-
* @param richTextValue - The value from a `RichText` component's `onChange` callback.
|
|
8
|
-
* @returns HTML string representation of the rich text content.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* const [content, setContent] = useState<RichTextValue>([]);
|
|
13
|
-
*
|
|
14
|
-
* // On form submit, convert to HTML for storage
|
|
15
|
-
* const html = toHtml(content);
|
|
16
|
-
* // e.g. "<p><strong>Hello world</strong></p>"
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
function toHtml(richTextValue) {
|
|
20
|
-
return richTextValue.map((node) => serialize(node)).join("");
|
|
21
|
-
}
|
|
22
|
-
export { toHtml };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import parse from "html-react-parser";
|
|
2
|
-
import { deserialize } from "../utils/richTextUtilities";
|
|
3
|
-
/**
|
|
4
|
-
* toRichTextValue — converts an HTML string to a `RichTextValue` (Slate.js Descendant array).
|
|
5
|
-
*
|
|
6
|
-
* Use this to populate a `RichText` editor with content previously stored as HTML
|
|
7
|
-
* (e.g. loaded from a database).
|
|
8
|
-
*
|
|
9
|
-
* @param html - HTML string to convert.
|
|
10
|
-
* @returns Slate.js Descendant array ready to pass to `RichText`'s `defaultValue` prop.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* // Load stored HTML into the editor
|
|
15
|
-
* const defaultValue = toRichTextValue(product.description);
|
|
16
|
-
* // e.g. [{ type: 'paragraph', children: [{ text: 'Hello', bold: true }] }]
|
|
17
|
-
*
|
|
18
|
-
* <RichText name="description" defaultValue={defaultValue} />
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
function toRichTextValue(html) {
|
|
22
|
-
const parsed = parse(html);
|
|
23
|
-
if (Array.isArray(parsed)) {
|
|
24
|
-
return parsed.map((node) => {
|
|
25
|
-
if (typeof node === "string")
|
|
26
|
-
return { text: node };
|
|
27
|
-
return deserialize(node);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (typeof parsed === "string")
|
|
31
|
-
return [{ text: parsed }];
|
|
32
|
-
return [deserialize(parsed)];
|
|
33
|
-
}
|
|
34
|
-
export { toRichTextValue };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Editor, Element as SlateElement, Transforms } from "slate";
|
|
2
|
-
import { listTypes, textAlignTypes } from "../templates/richTextTemplates";
|
|
3
|
-
import { isBlockActive } from "./isBlockActive";
|
|
4
|
-
function toggleBlock(editor, format) {
|
|
5
|
-
const blockType = textAlignTypes.includes(format) ? "align" : "type";
|
|
6
|
-
const isActive = isBlockActive(editor, format, blockType);
|
|
7
|
-
const isList = listTypes.includes(format);
|
|
8
|
-
Transforms.unwrapNodes(editor, {
|
|
9
|
-
match: (n) => !Editor.isEditor(n) &&
|
|
10
|
-
SlateElement.isElement(n) &&
|
|
11
|
-
listTypes.includes(n.type) &&
|
|
12
|
-
!textAlignTypes.includes(format),
|
|
13
|
-
split: true,
|
|
14
|
-
});
|
|
15
|
-
let newProperties;
|
|
16
|
-
if (textAlignTypes.includes(format)) {
|
|
17
|
-
const formatType = format;
|
|
18
|
-
newProperties = { align: isActive ? undefined : formatType };
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
const formatType = format;
|
|
22
|
-
newProperties = {
|
|
23
|
-
type: isActive ? "paragraph" : isList ? "listItem" : formatType,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
Transforms.setNodes(editor, newProperties);
|
|
27
|
-
if (!isActive && isList) {
|
|
28
|
-
const block = { type: format, children: [] };
|
|
29
|
-
Transforms.wrapNodes(editor, block);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export { toggleBlock };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Editor } from "slate";
|
|
2
|
-
import { isMarkActive } from "./isMarkActive";
|
|
3
|
-
function toggleMark(editor, format) {
|
|
4
|
-
const isActive = isMarkActive(editor, format);
|
|
5
|
-
if (isActive)
|
|
6
|
-
Editor.removeMark(editor, format);
|
|
7
|
-
else
|
|
8
|
-
Editor.addMark(editor, format, true);
|
|
9
|
-
}
|
|
10
|
-
export { toggleMark };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const hotKeys = {
|
|
2
|
-
"mod+b": "bold",
|
|
3
|
-
"mod+i": "italic",
|
|
4
|
-
"mod+u": "underline",
|
|
5
|
-
"mod+`": "code",
|
|
6
|
-
};
|
|
7
|
-
const initialValue = [
|
|
8
|
-
{ type: "paragraph", children: [{ text: "" }] },
|
|
9
|
-
];
|
|
10
|
-
const listTypes = ["listItem", "numberedList"];
|
|
11
|
-
const textAlignTypes = ["left", "center", "right", "justify"];
|
|
12
|
-
export { hotKeys, initialValue, listTypes, textAlignTypes };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|