@arkyn/components 3.0.1-beta.154 → 3.0.1-beta.155
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/calendar/_viewService.d.ts +1 -1
- package/dist/components/fullCalendar/_viewService.d.ts +2 -2
- package/dist/components.css +2 -0
- package/dist/hooks/useScopedParams.d.ts +1 -1
- package/dist/index.js +4358 -75
- package/dist/modules/components/alert/alertContainer/index.js +27 -0
- package/dist/modules/components/alert/alertContent/index.js +12 -0
- package/dist/modules/components/alert/alertDescription/index.js +12 -0
- package/dist/modules/components/alert/alertIcon/index.js +28 -0
- package/dist/modules/components/alert/alertTitle/index.js +12 -0
- package/dist/modules/components/audioPlayer/index.js +75 -0
- package/dist/modules/components/audioUpload/hasFileContent/index.js +55 -0
- package/dist/modules/components/audioUpload/index.js +72 -0
- package/dist/modules/components/audioUpload/noFileContent/index.js +36 -0
- package/dist/modules/components/badge/index.js +27 -0
- package/dist/modules/components/button/index.js +40 -0
- package/dist/modules/components/calendar/_calendarProvider.js +40 -0
- package/dist/modules/components/calendar/_viewService.js +133 -0
- package/dist/modules/components/calendar/calendarContainer/index.js +11 -0
- package/dist/modules/components/calendar/calendarHeader/index.js +52 -0
- package/dist/modules/components/calendar/calendarTableBody/index.js +13 -0
- package/dist/modules/components/calendar/calendarTableContainer/index.js +11 -0
- package/dist/modules/components/calendar/calendarTableHeader/index.js +14 -0
- package/dist/modules/components/calendar/calendarTableTd/index.js +21 -0
- package/dist/modules/components/calendar/index.js +32 -0
- package/dist/modules/components/cardTab/cardTabButton/index.js +20 -0
- package/dist/modules/components/cardTab/cardTabContainer/index.js +23 -0
- package/dist/modules/components/cardTab/cardTabContext.js +15 -0
- package/dist/modules/components/checkbox/index.js +38 -0
- package/dist/modules/components/clientOnly.js +9 -0
- package/dist/modules/components/currencyInput/index.js +112 -0
- package/dist/modules/components/divider/index.js +12 -0
- package/dist/modules/components/drawer/drawerContainer/index.js +41 -0
- package/dist/modules/components/drawer/drawerContext.js +15 -0
- package/dist/modules/components/drawer/drawerHeader/index.js +21 -0
- package/dist/modules/components/facebookPixel/facebookPixel.client.js +9 -0
- package/dist/modules/components/facebookPixel/index.js +9 -0
- package/dist/modules/components/facebookPixel/pixel.js +48 -0
- package/dist/modules/components/fieldError/index.js +13 -0
- package/dist/modules/components/fieldLabel/index.js +12 -0
- package/dist/modules/components/fieldWrapper/index.js +13 -0
- package/dist/modules/components/fileUpload/hasFileContent/index.js +60 -0
- package/dist/modules/components/fileUpload/index.js +66 -0
- package/dist/modules/components/fileUpload/noFileContent/index.js +36 -0
- package/dist/modules/components/fullCalendar/_fullCalendarProvider.js +35 -0
- package/dist/modules/components/fullCalendar/_viewService.js +101 -0
- package/dist/modules/components/fullCalendar/dayCalendar/dayCalendarContainer/index.js +11 -0
- package/dist/modules/components/fullCalendar/dayCalendar/dayCalendarEvent/index.js +71 -0
- package/dist/modules/components/fullCalendar/dayCalendar/dayCalendarRow/index.js +29 -0
- package/dist/modules/components/fullCalendar/dayCalendar/index.js +14 -0
- package/dist/modules/components/fullCalendar/fullCalendarContainer/index.js +11 -0
- package/dist/modules/components/fullCalendar/fullCalendarHeader/index.js +69 -0
- package/dist/modules/components/fullCalendar/index.js +31 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/index.js +10 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarEvent/index.js +29 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableBody/index.js +13 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableContainer/index.js +11 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableHeader/index.js +14 -0
- package/dist/modules/components/fullCalendar/monthlyCalendar/monthlyCalendarTableTd/index.js +36 -0
- package/dist/modules/components/fullCalendar/weekCalendar/index.js +10 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarEvent/index.js +71 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableBody/index.js +18 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableContainer/index.js +11 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableHeader/index.js +17 -0
- package/dist/modules/components/fullCalendar/weekCalendar/weekCalendarTableTd/index.js +35 -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 +14 -0
- package/dist/modules/components/googleTagManager/googleTagManager.client.js +8 -0
- package/dist/modules/components/googleTagManager/googleTagManager.js +45 -0
- package/dist/modules/components/googleTagManager/index.js +17 -0
- package/dist/modules/components/googleTagManager/snippets/appendToDataLayer.js +9 -0
- package/dist/modules/components/googleTagManager/snippets/generateGTMElements.js +23 -0
- package/dist/modules/components/iconButton/index.js +32 -0
- package/dist/modules/components/imageUpload/hasFileContent/index.js +47 -0
- package/dist/modules/components/imageUpload/index.js +66 -0
- package/dist/modules/components/imageUpload/noFileContent/index.js +36 -0
- package/dist/modules/components/input/index.js +93 -0
- package/dist/modules/components/mapView/index.js +29 -0
- package/dist/modules/components/mapView/mapView.client.js +50 -0
- package/dist/modules/components/maskedInput/index.js +102 -0
- package/dist/modules/components/modal/modalContainer/index.js +50 -0
- package/dist/modules/components/modal/modalContext.js +15 -0
- package/dist/modules/components/modal/modalFooter/index.js +12 -0
- package/dist/modules/components/modal/modalHeader/index.js +21 -0
- package/dist/modules/components/multiSelect/index.js +116 -0
- package/dist/modules/components/multiSelect/multiSelectChevron/index.js +19 -0
- package/dist/modules/components/multiSelect/multiSelectContainer/index.js +14 -0
- package/dist/modules/components/multiSelect/multiSelectContent/index.js +12 -0
- package/dist/modules/components/multiSelect/multiSelectMark/index.js +20 -0
- package/dist/modules/components/multiSelect/multiSelectOption/index.js +18 -0
- package/dist/modules/components/multiSelect/multiSelectOptionsContainer/index.js +36 -0
- package/dist/modules/components/multiSelect/multiSelectOverlay/index.js +12 -0
- package/dist/modules/components/multiSelect/multiSelectSpinner/index.js +14 -0
- package/dist/modules/components/pagination/chevronButton/index.js +18 -0
- package/dist/modules/components/pagination/currentButton/index.js +12 -0
- package/dist/modules/components/pagination/index.js +52 -0
- package/dist/modules/components/pagination/pageButton/index.js +13 -0
- package/dist/modules/components/pagination/paginationService.js +34 -0
- package/dist/modules/components/pagination/spread/index.js +12 -0
- package/dist/modules/components/phoneInput/index.js +104 -0
- package/dist/modules/components/phoneInput/phoneInputContainer/index.js +13 -0
- package/dist/modules/components/phoneInput/phoneInputCountriesOverlay/index.js +12 -0
- package/dist/modules/components/phoneInput/phoneInputCountryOption/index.js +24 -0
- package/dist/modules/components/phoneInput/phoneInputCountryOptionsContainer/index.js +34 -0
- package/dist/modules/components/phoneInput/phoneInputCountrySelector/index.js +26 -0
- package/dist/modules/components/phoneInput/phoneInputMask/index.js +46 -0
- package/dist/modules/components/popover/index.js +38 -0
- package/dist/modules/components/radio/radioBox/index.js +25 -0
- package/dist/modules/components/radio/radioContext.js +22 -0
- package/dist/modules/components/radio/radioGroup/index.js +42 -0
- package/dist/modules/components/richText/blockButton/index.js +21 -0
- package/dist/modules/components/richText/element/index.js +73 -0
- package/dist/modules/components/richText/index.js +144 -0
- package/dist/modules/components/richText/insertImage/index.js +95 -0
- package/dist/modules/components/richText/insertVideo/index.js +86 -0
- package/dist/modules/components/richText/leaf/index.js +10 -0
- package/dist/modules/components/richText/markButton/index.js +20 -0
- package/dist/modules/components/richText/toolbar/index.js +11 -0
- package/dist/modules/components/searchPlaces.js +58 -0
- package/dist/modules/components/select/index.js +113 -0
- package/dist/modules/components/select/selectChevron/index.js +19 -0
- package/dist/modules/components/select/selectContainer/index.js +14 -0
- package/dist/modules/components/select/selectContent/index.js +12 -0
- package/dist/modules/components/select/selectOption/index.js +18 -0
- package/dist/modules/components/select/selectOptionsContainer/index.js +36 -0
- package/dist/modules/components/select/selectOverlay/index.js +12 -0
- package/dist/modules/components/select/selectSpinner/index.js +14 -0
- package/dist/modules/components/slider/index.js +35 -0
- package/dist/modules/components/switch/index.js +36 -0
- package/dist/modules/components/tab/tabButton/index.js +20 -0
- package/dist/modules/components/tab/tabContainer/index.js +23 -0
- package/dist/modules/components/tab/tabContext.js +15 -0
- package/dist/modules/components/table/tableBody/index.js +20 -0
- package/dist/modules/components/table/tableCaption/index.js +16 -0
- package/dist/modules/components/table/tableContainer/index.js +13 -0
- package/dist/modules/components/table/tableFooter/index.js +19 -0
- package/dist/modules/components/table/tableHeader/index.js +13 -0
- package/dist/modules/components/textarea/index.js +52 -0
- package/dist/modules/components/tooltip/index.js +35 -0
- package/dist/modules/components.css +2 -0
- package/dist/modules/hooks/useAutomation.js +36 -0
- package/dist/modules/hooks/useDrawer.js +18 -0
- package/dist/modules/hooks/useForm.js +8 -0
- package/dist/modules/hooks/useHydrated.js +10 -0
- package/dist/modules/hooks/useModal.js +18 -0
- package/dist/modules/hooks/useScopedParams.js +18 -0
- package/dist/modules/hooks/useScrollLock.js +21 -0
- package/dist/modules/hooks/useSearchAutomation.js +32 -0
- package/dist/modules/hooks/useSlider.js +14 -0
- package/dist/modules/hooks/useToast.js +10 -0
- package/dist/modules/index.js +72 -0
- package/dist/modules/providers/drawerProvider.js +36 -0
- package/dist/modules/providers/formProvider.js +13 -0
- package/dist/modules/providers/modalProvider.js +40 -0
- package/dist/modules/providers/placesProvider.js +18 -0
- package/dist/modules/providers/toastProvider.js +46 -0
- package/dist/modules/services/extractTextFromNode.js +7 -0
- package/dist/modules/services/fieldTemplate.js +23 -0
- package/dist/modules/services/iconRenderer.js +15 -0
- package/dist/modules/services/isBlockActive.js +13 -0
- package/dist/modules/services/isMarkActive.js +8 -0
- package/dist/modules/services/maskCurrencyValues.js +13 -0
- package/dist/modules/services/toHtml.js +7 -0
- package/dist/modules/services/toRichTextValue.js +9 -0
- package/dist/modules/services/toggleBlock.js +21 -0
- package/dist/modules/services/toggleMark.js +8 -0
- package/dist/modules/templates/badResponses.js +14 -0
- package/dist/modules/templates/richTextTemplates.js +17 -0
- package/dist/modules/templates/successResponses.js +9 -0
- package/dist/modules/utils/phoneInputUtilities.js +22 -0
- package/dist/modules/utils/richTextUtilities.js +90 -0
- package/dist/services/fieldTemplate.d.ts +1 -1
- package/dist/services/fieldTemplate.d.ts.map +1 -1
- package/package.json +144 -144
- 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/style.css +0 -1
- 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,179 +0,0 @@
|
|
|
1
|
-
import { formatToCapitalizeFirstWordLetter } from "@arkyn/shared";
|
|
2
|
-
class ViewService {
|
|
3
|
-
currentDay(viewDate) {
|
|
4
|
-
return String(viewDate.getDate()).padStart(2, "0");
|
|
5
|
-
}
|
|
6
|
-
currentMonth(viewDate) {
|
|
7
|
-
return String(viewDate.getMonth() + 1).padStart(2, "0");
|
|
8
|
-
}
|
|
9
|
-
currentYear(viewDate) {
|
|
10
|
-
return String(viewDate.getFullYear());
|
|
11
|
-
}
|
|
12
|
-
capitalize(text) {
|
|
13
|
-
return formatToCapitalizeFirstWordLetter(text);
|
|
14
|
-
}
|
|
15
|
-
parseDayType(day, month, year, valueDate) {
|
|
16
|
-
const firstDateDay = valueDate[0].getDate();
|
|
17
|
-
const firstDateMonth = valueDate[0].getMonth();
|
|
18
|
-
const firstDateYear = valueDate[0].getFullYear();
|
|
19
|
-
const secondDateDay = valueDate[1].getDate();
|
|
20
|
-
const secondDateMonth = valueDate[1].getMonth();
|
|
21
|
-
const secondDateYear = valueDate[1].getFullYear();
|
|
22
|
-
const firstDate = new Date(firstDateYear, firstDateMonth, firstDateDay);
|
|
23
|
-
const secondDate = new Date(secondDateYear, secondDateMonth, secondDateDay);
|
|
24
|
-
const currentDate = new Date(year, month, day);
|
|
25
|
-
if (firstDate.getTime() === currentDate.getTime())
|
|
26
|
-
return "checkedDay";
|
|
27
|
-
if (secondDate.getTime() === currentDate.getTime())
|
|
28
|
-
return "checkedDay";
|
|
29
|
-
if (currentDate > firstDate && currentDate < secondDate)
|
|
30
|
-
return "middleDay";
|
|
31
|
-
return "uncheckedDay";
|
|
32
|
-
}
|
|
33
|
-
listWeek(language) {
|
|
34
|
-
const weekDays = [];
|
|
35
|
-
const firstSundayUtc = new Date(Date.UTC(2023, 0, 1));
|
|
36
|
-
for (let i = 0; i < 7; i++) {
|
|
37
|
-
const day = new Date(firstSundayUtc);
|
|
38
|
-
day.setUTCDate(firstSundayUtc.getUTCDate() + i);
|
|
39
|
-
const dayName = day.toLocaleDateString(language, {
|
|
40
|
-
weekday: "short",
|
|
41
|
-
timeZone: "UTC",
|
|
42
|
-
});
|
|
43
|
-
weekDays.push(dayName);
|
|
44
|
-
}
|
|
45
|
-
return weekDays;
|
|
46
|
-
}
|
|
47
|
-
listMonths(viewDate, language) {
|
|
48
|
-
const monthsByNavigatorLanguage = new Intl.DateTimeFormat(language, {
|
|
49
|
-
month: "long",
|
|
50
|
-
});
|
|
51
|
-
return Array.from({ length: 12 }, (_, i) => {
|
|
52
|
-
const date = new Date(viewDate.getFullYear(), i, 1);
|
|
53
|
-
const label = monthsByNavigatorLanguage.format(date);
|
|
54
|
-
return {
|
|
55
|
-
label: this.capitalize(label),
|
|
56
|
-
value: String(i).padStart(2, "0"),
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
listYears(lastYears) {
|
|
61
|
-
const currentYear = new Date().getFullYear();
|
|
62
|
-
return Array.from({ length: lastYears + 1 }, (_, i) => {
|
|
63
|
-
const year = currentYear - lastYears + i;
|
|
64
|
-
return { label: String(year), value: String(year) };
|
|
65
|
-
}).reverse();
|
|
66
|
-
}
|
|
67
|
-
listMatrix(viewDate, valueDate) {
|
|
68
|
-
const year = viewDate.getFullYear();
|
|
69
|
-
const monthIndex = viewDate.getMonth();
|
|
70
|
-
const firstDayOfMonth = new Date(year, monthIndex, 1);
|
|
71
|
-
const firstWeekday = firstDayOfMonth.getDay();
|
|
72
|
-
const daysInCurrentMonth = new Date(year, monthIndex + 1, 0).getDate();
|
|
73
|
-
const daysInPreviousMonth = new Date(year, monthIndex, 0).getDate();
|
|
74
|
-
const totalCells = Math.ceil((firstWeekday + daysInCurrentMonth) / 7) * 7;
|
|
75
|
-
const weeks = [];
|
|
76
|
-
let currentMonthDay = 1;
|
|
77
|
-
let nextMonthDay = 1;
|
|
78
|
-
for (let i = 0; i < totalCells; i++) {
|
|
79
|
-
const weekIndex = Math.floor(i / 7);
|
|
80
|
-
if (!weeks[weekIndex])
|
|
81
|
-
weeks[weekIndex] = [];
|
|
82
|
-
if (i < firstWeekday) {
|
|
83
|
-
const day = daysInPreviousMonth - (firstWeekday - i - 1);
|
|
84
|
-
const month = monthIndex === 0 ? 11 : monthIndex - 1;
|
|
85
|
-
const cellYear = monthIndex === 0 ? year - 1 : year;
|
|
86
|
-
weeks[weekIndex].push({
|
|
87
|
-
day,
|
|
88
|
-
month,
|
|
89
|
-
year: cellYear,
|
|
90
|
-
dayOwner: "previous",
|
|
91
|
-
dayType: this.parseDayType(day, month, cellYear, valueDate),
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else if (currentMonthDay <= daysInCurrentMonth) {
|
|
95
|
-
weeks[weekIndex].push({
|
|
96
|
-
day: currentMonthDay,
|
|
97
|
-
month: monthIndex,
|
|
98
|
-
year: year,
|
|
99
|
-
dayOwner: "current",
|
|
100
|
-
dayType: this.parseDayType(currentMonthDay, monthIndex, year, valueDate),
|
|
101
|
-
});
|
|
102
|
-
currentMonthDay++;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const month = monthIndex === 11 ? 0 : monthIndex + 1;
|
|
106
|
-
const cellYear = monthIndex === 11 ? year + 1 : year;
|
|
107
|
-
weeks[weekIndex].push({
|
|
108
|
-
day: nextMonthDay,
|
|
109
|
-
month,
|
|
110
|
-
year: cellYear,
|
|
111
|
-
dayOwner: "next",
|
|
112
|
-
dayType: this.parseDayType(nextMonthDay, month, cellYear, valueDate),
|
|
113
|
-
});
|
|
114
|
-
nextMonthDay++;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return weeks;
|
|
118
|
-
}
|
|
119
|
-
changeDay(day, month, year, calendarType, valueDate, setValueDate, setViewDate) {
|
|
120
|
-
const normalizeDate = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
121
|
-
const newDate = normalizeDate(new Date(year, month, day));
|
|
122
|
-
setViewDate(newDate);
|
|
123
|
-
if (calendarType === "single") {
|
|
124
|
-
setValueDate([newDate, newDate]);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
let startDate = normalizeDate(valueDate[0]);
|
|
128
|
-
let endDate = normalizeDate(valueDate[1]);
|
|
129
|
-
const newDateTime = newDate.getTime();
|
|
130
|
-
const startDateTime = startDate.getTime();
|
|
131
|
-
const endDateTime = endDate.getTime();
|
|
132
|
-
if (newDateTime === startDateTime) {
|
|
133
|
-
setValueDate([newDate, newDate]);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (newDateTime === endDateTime) {
|
|
137
|
-
setValueDate([newDate, newDate]);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (newDate < startDate) {
|
|
141
|
-
setValueDate([newDate, endDate]);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (newDate > endDate) {
|
|
145
|
-
setValueDate([startDate, newDate]);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const distanceToStart = Math.abs(newDateTime - startDateTime);
|
|
149
|
-
const distanceToEnd = Math.abs(endDateTime - newDateTime);
|
|
150
|
-
if (distanceToStart <= distanceToEnd) {
|
|
151
|
-
setValueDate([newDate, endDate]);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
setValueDate([startDate, newDate]);
|
|
155
|
-
}
|
|
156
|
-
changeMonth(month, viewDate, setViewDate) {
|
|
157
|
-
const nextViewDate = new Date(viewDate);
|
|
158
|
-
nextViewDate.setMonth(month);
|
|
159
|
-
setViewDate(nextViewDate);
|
|
160
|
-
}
|
|
161
|
-
changeYear(year, viewDate, setViewDate) {
|
|
162
|
-
const nextViewDate = new Date(viewDate);
|
|
163
|
-
nextViewDate.setFullYear(year);
|
|
164
|
-
setViewDate(nextViewDate);
|
|
165
|
-
}
|
|
166
|
-
nextMonth(viewDate, setViewDate) {
|
|
167
|
-
const nextViewDate = new Date(viewDate);
|
|
168
|
-
nextViewDate.setDate(1);
|
|
169
|
-
nextViewDate.setMonth(nextViewDate.getMonth() + 1);
|
|
170
|
-
setViewDate(nextViewDate);
|
|
171
|
-
}
|
|
172
|
-
previousMonth(viewDate, setViewDate) {
|
|
173
|
-
const nextViewDate = new Date(viewDate);
|
|
174
|
-
nextViewDate.setDate(1);
|
|
175
|
-
nextViewDate.setMonth(nextViewDate.getMonth() - 1);
|
|
176
|
-
setViewDate(nextViewDate);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
export { ViewService };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
3
|
-
import { Select } from "../../select";
|
|
4
|
-
import { useCalendar } from "../_calendarProvider";
|
|
5
|
-
import "./styles.css";
|
|
6
|
-
function CalendarHeader({ basicMode }) {
|
|
7
|
-
const calendar = useCalendar();
|
|
8
|
-
if (basicMode) {
|
|
9
|
-
return (_jsxs("div", { className: `arkynCalendarHeader`, children: [_jsx("button", { className: "arkynCalendarButton", onClick: () => calendar.previousMonth(), children: _jsx(ChevronLeft, {}) }), _jsx("p", { children: calendar.currentDate }), _jsx("button", { className: "arkynCalendarButton", onClick: () => calendar.nextMonth(), children: _jsx(ChevronRight, {}) })] }));
|
|
10
|
-
}
|
|
11
|
-
return (_jsxs("div", { className: `arkynCalendarHeader`, children: [_jsxs("div", { children: [_jsx("button", { className: "arkynCalendarButton", onClick: () => calendar.previousMonth(), children: _jsx(ChevronLeft, {}) }), _jsx("button", { className: "arkynCalendarButton", onClick: () => calendar.nextMonth(), children: _jsx(ChevronRight, {}) })] }), _jsxs("div", { children: [_jsx(Select, { name: "calendarMonth", variant: "underline", className: "calendarMonthSelect", value: calendar.currentMonth, options: calendar.listMonths, onChange: (value) => calendar.changeMonth(+value) }), _jsx(Select, { name: "calendarYear", variant: "underline", className: "calendarYearSelect", value: calendar.currentYear, options: calendar.listYears, onChange: (value) => calendar.changeYear(+value) })] })] }));
|
|
12
|
-
}
|
|
13
|
-
export { CalendarHeader };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCalendar } from "../_calendarProvider";
|
|
3
|
-
import { CalendarTableTd } from "../calendarTableTd";
|
|
4
|
-
import "./styles.css";
|
|
5
|
-
function CalendarTableBody() {
|
|
6
|
-
const calendar = useCalendar();
|
|
7
|
-
return (_jsx("tbody", { className: "arkynCalendarTableBody", children: calendar.listMatrix.map((week, weekIndex) => (_jsx("tr", { children: week.map((props, dayIndex) => (_jsx(CalendarTableTd, { ...props }, dayIndex))) }, weekIndex))) }));
|
|
8
|
-
}
|
|
9
|
-
export { CalendarTableBody };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { formatToCapitalizeFirstWordLetter } from "@arkyn/shared";
|
|
3
|
-
import { useCalendar } from "../_calendarProvider";
|
|
4
|
-
import "./styles.css";
|
|
5
|
-
function CalendarTableHeader() {
|
|
6
|
-
const { listWeek } = useCalendar();
|
|
7
|
-
return (_jsx("thead", { className: "arkynCalendarTableHeader", children: _jsx("tr", { children: listWeek.map((day, index) => (_jsx("th", { children: formatToCapitalizeFirstWordLetter(day) }, index))) }) }));
|
|
8
|
-
}
|
|
9
|
-
export { CalendarTableHeader };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCalendar } from "../_calendarProvider";
|
|
3
|
-
import "./styles.css";
|
|
4
|
-
function CalendarTableTd(props) {
|
|
5
|
-
const { day, month, year, dayOwner, dayType } = props;
|
|
6
|
-
const { changeDay } = useCalendar();
|
|
7
|
-
function isToday() {
|
|
8
|
-
const today = new Date();
|
|
9
|
-
return (day === today.getDate() &&
|
|
10
|
-
month === today.getMonth() &&
|
|
11
|
-
year === today.getFullYear());
|
|
12
|
-
}
|
|
13
|
-
return (_jsx("td", { onClick: () => changeDay(day, month, year), className: `arkynCalendarTableTd ${dayOwner} ${dayType} ${isToday() ? "today" : ""}`, children: _jsxs("div", { className: "textGroup", children: [_jsx("span", {}), _jsx("p", { children: day })] }) }));
|
|
14
|
-
}
|
|
15
|
-
export { CalendarTableTd };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CalendarProvider } from "./_calendarProvider";
|
|
3
|
-
import { CalendarContainer } from "./calendarContainer";
|
|
4
|
-
import { CalendarHeader } from "./calendarHeader";
|
|
5
|
-
import { CalendarTableBody } from "./calendarTableBody";
|
|
6
|
-
import { CalendarTableContainer } from "./calendarTableContainer";
|
|
7
|
-
import { CalendarTableHeader } from "./calendarTableHeader";
|
|
8
|
-
/**
|
|
9
|
-
* Reusable calendar component with support for two selection modes:
|
|
10
|
-
* single date (`single`) and range (`range`).
|
|
11
|
-
*
|
|
12
|
-
* The component encapsulates calendar state and navigation rules through
|
|
13
|
-
* `CalendarProvider`, exposing a simple API for forms, filters,
|
|
14
|
-
* and scheduling flows.
|
|
15
|
-
*
|
|
16
|
-
* @param props Calendar properties (`single` or `range` mode).
|
|
17
|
-
* @returns Calendar UI structure with header and date grid.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // Single-date selection
|
|
21
|
-
* <Calendar
|
|
22
|
-
* type="single"
|
|
23
|
-
* variant="complete"
|
|
24
|
-
* defaultValue={new Date()}
|
|
25
|
-
* onChange={(date) => {
|
|
26
|
-
* console.log("Selected date:", date);
|
|
27
|
-
* }}
|
|
28
|
-
* onChangeView={(viewDate) => {
|
|
29
|
-
* console.log("Current view:", viewDate);
|
|
30
|
-
* }}
|
|
31
|
-
* />
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* // Range selection
|
|
35
|
-
* <Calendar
|
|
36
|
-
* type="range"
|
|
37
|
-
* variant="basic"
|
|
38
|
-
* defaultValue={[new Date(2026, 5, 1), new Date(2026, 5, 15)]}
|
|
39
|
-
* onChange={([start, end]) => {
|
|
40
|
-
* console.log("Range:", start, end);
|
|
41
|
-
* }}
|
|
42
|
-
* onChangeView={(viewDate) => {
|
|
43
|
-
* console.log("Focused month:", viewDate);
|
|
44
|
-
* }}
|
|
45
|
-
* />
|
|
46
|
-
*/
|
|
47
|
-
function Calendar(props) {
|
|
48
|
-
const variant = props.variant || "complete";
|
|
49
|
-
if (props.type === "range") {
|
|
50
|
-
return (_jsx(CalendarProvider, { value: props.value, viewValue: props.viewValue, defaultViewValue: props.defaultViewValue, defaultValue: props.defaultValue, calendarType: "range", onChange: props.onChange, onChangeView: props.onChangeView, children: _jsxs(CalendarContainer, { children: [_jsx(CalendarHeader, { basicMode: variant.includes("basic") }), _jsxs(CalendarTableContainer, { children: [_jsx(CalendarTableHeader, {}), _jsx(CalendarTableBody, {})] })] }) }));
|
|
51
|
-
}
|
|
52
|
-
return (_jsx(CalendarProvider, { value: props.value, viewValue: props.viewValue, defaultViewValue: props.defaultViewValue, defaultValue: props.defaultValue, calendarType: "single", onChange: props.onChange, onChangeView: props.onChangeView, children: _jsxs(CalendarContainer, { children: [_jsx(CalendarHeader, { basicMode: variant.includes("basic") }), _jsxs(CalendarTableContainer, { children: [_jsx(CalendarTableHeader, {}), _jsx(CalendarTableBody, {})] })] }) }));
|
|
53
|
-
}
|
|
54
|
-
export { Calendar };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCardTab } from "../cardTabContext";
|
|
3
|
-
import "./styles.css";
|
|
4
|
-
/**
|
|
5
|
-
* CardTabButton — individual tab button inside a `CardTabContainer`.
|
|
6
|
-
*
|
|
7
|
-
* Reads active state and disabled state from `CardTabContainer` context.
|
|
8
|
-
* The button's own `disabled` prop is ORed with the container's `disabled`.
|
|
9
|
-
*
|
|
10
|
-
* @param props.children - Tab label content. Required.
|
|
11
|
-
* @param props.value - Tab identifier. Required.
|
|
12
|
-
* @param props.disabled - Disables this tab individually (container can also disable all tabs).
|
|
13
|
-
*
|
|
14
|
-
* **...Other valid HTML `<button>` properties except `type`**
|
|
15
|
-
*
|
|
16
|
-
* @returns CardTabButton JSX element.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* <CardTabContainer defaultValue="details" onChange={setTab}>
|
|
21
|
-
* <CardTabButton value="details">Details</CardTabButton>
|
|
22
|
-
* <CardTabButton value="history">History</CardTabButton>
|
|
23
|
-
* <CardTabButton value="settings" disabled>Settings</CardTabButton>
|
|
24
|
-
* </CardTabContainer>
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
function CardTabButton(props) {
|
|
28
|
-
const { children, disabled: rawDisabled = false, className: baseClassName = "", onClick, value, ...rest } = props;
|
|
29
|
-
const { disabled, currentTab, changeCurrentTab } = useCardTab();
|
|
30
|
-
const isDisabled = disabled || rawDisabled;
|
|
31
|
-
const disabledClass = isDisabled ? "isDisabled" : "";
|
|
32
|
-
const activeClass = currentTab === value && value ? "isActive" : "";
|
|
33
|
-
const className = `arkynCardTabButton ${disabledClass} ${activeClass} ${baseClassName}`;
|
|
34
|
-
function handleClick(event) {
|
|
35
|
-
changeCurrentTab(value);
|
|
36
|
-
onClick && onClick(event);
|
|
37
|
-
}
|
|
38
|
-
return (_jsx("button", { onClick: handleClick, className: className.trim(), ...rest, disabled: isDisabled, type: "button", children: children }));
|
|
39
|
-
}
|
|
40
|
-
export { CardTabButton };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { CardTabProvider } from "../cardTabContext";
|
|
4
|
-
import "./styles.css";
|
|
5
|
-
/**
|
|
6
|
-
* CardTabContainer — wrapper that manages active state for a group of `CardTabButton` components.
|
|
7
|
-
*
|
|
8
|
-
* Renders as a `<nav>` element. Provides context consumed by each `CardTabButton`.
|
|
9
|
-
*
|
|
10
|
-
* @param props.children - `CardTabButton` elements. Required.
|
|
11
|
-
* @param props.defaultValue - Initially selected tab value.
|
|
12
|
-
* @param props.disabled - Disables all buttons. Default: false
|
|
13
|
-
* @param props.onChange - Called with the new value whenever the active tab changes.
|
|
14
|
-
*
|
|
15
|
-
* **...Other valid HTML `<nav>` properties**
|
|
16
|
-
*
|
|
17
|
-
* @returns CardTabContainer JSX element.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* <CardTabContainer defaultValue="overview" onChange={setActiveTab}>
|
|
22
|
-
* <CardTabButton value="overview">Overview</CardTabButton>
|
|
23
|
-
* <CardTabButton value="analytics">Analytics</CardTabButton>
|
|
24
|
-
* <CardTabButton value="settings">Settings</CardTabButton>
|
|
25
|
-
* </CardTabContainer>
|
|
26
|
-
*
|
|
27
|
-
* {activeTab === 'overview' && <OverviewPanel />}
|
|
28
|
-
* {activeTab === 'analytics' && <AnalyticsPanel />}
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
function CardTabContainer(props) {
|
|
32
|
-
const { children, onChange, defaultValue, disabled = false, className: baseClassName, ...rest } = props;
|
|
33
|
-
const [currentTab, setCurrentTab] = useState(defaultValue || "");
|
|
34
|
-
const className = `arkynCardTabContainer ${baseClassName || ""}`;
|
|
35
|
-
function changeCurrentTab(value) {
|
|
36
|
-
setCurrentTab(value);
|
|
37
|
-
if (onChange)
|
|
38
|
-
onChange(value);
|
|
39
|
-
}
|
|
40
|
-
return (_jsx(CardTabProvider, { disabled: disabled, currentTab: currentTab, changeCurrentTab: changeCurrentTab, children: _jsx("nav", { className: className.trim(), ...rest, children: children }) }));
|
|
41
|
-
}
|
|
42
|
-
export { CardTabContainer };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
const CardTabContext = createContext({});
|
|
4
|
-
function useCardTab() {
|
|
5
|
-
return useContext(CardTabContext);
|
|
6
|
-
}
|
|
7
|
-
function CardTabProvider(props) {
|
|
8
|
-
return (_jsx(CardTabContext.Provider, { value: props, children: props.children }));
|
|
9
|
-
}
|
|
10
|
-
export { CardTabProvider, useCardTab };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Check } from "lucide-react";
|
|
3
|
-
import { useId, useRef, useState } from "react";
|
|
4
|
-
import { useForm } from "../../hooks/useForm";
|
|
5
|
-
import { FieldTemplate } from "../../services/fieldTemplate";
|
|
6
|
-
import "./styles.css";
|
|
7
|
-
/**
|
|
8
|
-
* Checkbox — interactive checkbox input with label, validation, and form integration.
|
|
9
|
-
*
|
|
10
|
-
* Stores value in a hidden `<input>` for native form submission.
|
|
11
|
-
* Integrates with `useForm` to display validation errors by field name.
|
|
12
|
-
*
|
|
13
|
-
* @param props.name - Field name for form submission. Required.
|
|
14
|
-
* @param props.label - Label text displayed beside the checkbox.
|
|
15
|
-
* @param props.size - Checkbox size (`sm` | `md` | `lg`). Default: "md"
|
|
16
|
-
* @param props.value - Value stored when checked. Default: "checked"
|
|
17
|
-
* @param props.checked - Controlled checked state.
|
|
18
|
-
* @param props.defaultChecked - Uncontrolled initial checked state. Default: false
|
|
19
|
-
* @param props.onCheck - Callback fired on toggle — receives value or `""` when unchecked.
|
|
20
|
-
* @param props.errorMessage - Validation error message.
|
|
21
|
-
* @param props.showAsterisk - Appends `*` to the label.
|
|
22
|
-
* @param props.orientation - Layout direction (`horizontal` | `vertical` | `horizontalReverse`). Default: "horizontalReverse"
|
|
23
|
-
* @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false
|
|
24
|
-
*
|
|
25
|
-
* **...Other valid HTML properties for `<button>` (except `type`, `name`, `defaultValue`, `value`, `onChange`, `onSelect`, `onClick`)**
|
|
26
|
-
*
|
|
27
|
-
* @returns Checkbox JSX element wrapped in `FieldTemplate`.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* // Basic
|
|
32
|
-
* <Checkbox name="terms" label="I agree to the terms and conditions" />
|
|
33
|
-
*
|
|
34
|
-
* // With custom value and error
|
|
35
|
-
* <Checkbox
|
|
36
|
-
* name="newsletter"
|
|
37
|
-
* label="Subscribe to newsletter"
|
|
38
|
-
* value="subscribed"
|
|
39
|
-
* errorMessage={errors.newsletter}
|
|
40
|
-
* />
|
|
41
|
-
*
|
|
42
|
-
* // Controlled
|
|
43
|
-
* <Checkbox
|
|
44
|
-
* name="premium"
|
|
45
|
-
* label="Enable premium features"
|
|
46
|
-
* size="lg"
|
|
47
|
-
* checked={isPremium}
|
|
48
|
-
* onCheck={(v) => setIsPremium(!!v)}
|
|
49
|
-
* />
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
function Checkbox(props) {
|
|
53
|
-
const { id, name, className: wrapperClassName = "", size = "md", errorMessage: baseErrorMessage, defaultChecked = false, label, checked: baseChecked = null, onCheck, orientation = "horizontalReverse", showAsterisk, unShowFieldTemplate, value, ...rest } = props;
|
|
54
|
-
const { fieldErrors } = useForm();
|
|
55
|
-
const checkboxRef = useRef(null);
|
|
56
|
-
const checkboxId = id || useId();
|
|
57
|
-
const errorMessage = baseErrorMessage || fieldErrors?.[name];
|
|
58
|
-
const isError = !!errorMessage;
|
|
59
|
-
const [isChecked, setIsChecked] = useState(defaultChecked || false);
|
|
60
|
-
const currentChecked = typeof baseChecked === "boolean" ? baseChecked : isChecked;
|
|
61
|
-
const errorClass = isError ? "errorTrue" : "errorFalse";
|
|
62
|
-
const currentCheckedClass = currentChecked ? "checkedTrue" : "checkedFalse";
|
|
63
|
-
const className = `arkynCheckbox ${size} ${errorClass} ${currentCheckedClass}`;
|
|
64
|
-
function handleCheck() {
|
|
65
|
-
const defaultChecked = isChecked;
|
|
66
|
-
setIsChecked(!defaultChecked);
|
|
67
|
-
onCheck && onCheck(!defaultChecked ? value || "checked" : "");
|
|
68
|
-
}
|
|
69
|
-
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs("button", { id: checkboxId, type: "button", className: className, onClick: handleCheck, ...rest, children: [_jsx("input", { type: "hidden", name: name, ref: checkboxRef, value: currentChecked ? value || "checked" : "" }), _jsx(Check, {})] }) }));
|
|
70
|
-
}
|
|
71
|
-
export { Checkbox };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useHydrated } from "../hooks/useHydrated";
|
|
3
|
-
/**
|
|
4
|
-
* ClientOnly — renders its children only after client-side hydration.
|
|
5
|
-
*
|
|
6
|
-
* Prevents React hydration mismatches for components that rely on browser-only APIs
|
|
7
|
-
* (e.g. `window`, `navigator`, `document`). Uses `useHydrated` internally.
|
|
8
|
-
*
|
|
9
|
-
* @param props.children - Render function executed after hydration. Required.
|
|
10
|
-
* @param props.fallback - Content shown during SSR / before hydration. Default: null
|
|
11
|
-
*
|
|
12
|
-
* @returns `children()` after hydration, otherwise `fallback`.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* // With a skeleton fallback
|
|
17
|
-
* <ClientOnly fallback={<Skeleton />}>
|
|
18
|
-
* {() => <InteractiveWidget />}
|
|
19
|
-
* </ClientOnly>
|
|
20
|
-
*
|
|
21
|
-
* // Using browser APIs safely
|
|
22
|
-
* <ClientOnly fallback={<p>Loading...</p>}>
|
|
23
|
-
* {() => <p>Current time: {new Date().toLocaleString()}</p>}
|
|
24
|
-
* </ClientOnly>
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
function ClientOnly(props) {
|
|
28
|
-
const { children, fallback = null } = props;
|
|
29
|
-
return useHydrated() ? _jsx(_Fragment, { children: children() }) : _jsx(_Fragment, { children: fallback });
|
|
30
|
-
}
|
|
31
|
-
export { ClientOnly };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Loader2 } from "lucide-react";
|
|
3
|
-
import { useEffect, useId, useRef, useState, } from "react";
|
|
4
|
-
import { useForm } from "../../hooks/useForm";
|
|
5
|
-
import { FieldTemplate } from "../../services/fieldTemplate";
|
|
6
|
-
import { IconRenderer } from "../../services/iconRenderer";
|
|
7
|
-
import { maskCurrencyValues, normalizeValue, } from "../../services/maskCurrencyValues";
|
|
8
|
-
import "./style.css";
|
|
9
|
-
/**
|
|
10
|
-
* CurrencyInput — numeric input that automatically formats the displayed value according to a currency locale.
|
|
11
|
-
*
|
|
12
|
-
* The raw numeric value is stored in a hidden `<input>` for form submission.
|
|
13
|
-
* Integrates with `useForm` to display validation errors by field name.
|
|
14
|
-
*
|
|
15
|
-
* @param props.name - Field name for form submission. Required.
|
|
16
|
-
* @param props.locale - Currency locale (e.g. `"USD"`, `"BRL"`, `"EUR"`). Required.
|
|
17
|
-
* @param props.label - Label text displayed above the input.
|
|
18
|
-
* @param props.errorMessage - Validation error message.
|
|
19
|
-
* @param props.isLoading - Shows a spinner and disables the input. Default: false
|
|
20
|
-
* @param props.size - Input size (`md` | `lg`). Default: "md"
|
|
21
|
-
* @param props.variant - Visual style variant. Default: "solid"
|
|
22
|
-
* @param props.max - Maximum numeric value allowed. Default: 1_000_000_000
|
|
23
|
-
* @param props.value - Controlled numeric value.
|
|
24
|
-
* @param props.defaultValue - Uncontrolled default numeric value.
|
|
25
|
-
* @param props.onChange - Callback fired on change — receives the event, the raw numeric string, and the formatted string.
|
|
26
|
-
* @param props.prefix - Text or icon at the far left.
|
|
27
|
-
* @param props.suffix - Text or icon at the far right.
|
|
28
|
-
* @param props.leftIcon - Lucide icon inside the input on the left.
|
|
29
|
-
* @param props.rightIcon - Lucide icon inside the input on the right.
|
|
30
|
-
* @param props.showAsterisk - Appends `*` to the label.
|
|
31
|
-
* @param props.orientation - Layout direction. Default: "horizontal"
|
|
32
|
-
* @param props.unShowFieldTemplate - Skips wrapper, label, and error rendering. Default: false
|
|
33
|
-
*
|
|
34
|
-
* **...Other valid HTML properties for `<input>` (except `type`, `max`, `value`, `defaultValue`, `onChange`, `placeholder`)**
|
|
35
|
-
*
|
|
36
|
-
* @returns CurrencyInput JSX element wrapped in `FieldTemplate`.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* // Basic
|
|
41
|
-
* <CurrencyInput name="price" locale="USD" />
|
|
42
|
-
*
|
|
43
|
-
* // With label and validation
|
|
44
|
-
* <CurrencyInput
|
|
45
|
-
* name="salary"
|
|
46
|
-
* locale="BRL"
|
|
47
|
-
* label="Monthly Salary"
|
|
48
|
-
* showAsterisk
|
|
49
|
-
* errorMessage="Please enter a valid amount"
|
|
50
|
-
* />
|
|
51
|
-
*
|
|
52
|
-
* // With max value and controlled state
|
|
53
|
-
* <CurrencyInput
|
|
54
|
-
* name="limit"
|
|
55
|
-
* locale="USD"
|
|
56
|
-
* label="Credit Limit"
|
|
57
|
-
* max={10000}
|
|
58
|
-
* value={creditLimit}
|
|
59
|
-
* onChange={(e, original) => setCreditLimit(Number(original))}
|
|
60
|
-
* />
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
function CurrencyInput(props) {
|
|
64
|
-
const { name, disabled, title, style, variant = "solid", label, className: wrapperClassName = "", value, defaultValue, max = 1000000000, locale, onChange, prefix, suffix, isLoading = false, leftIcon, readOnly, onFocus, onBlur, errorMessage: baseErrorMessage, unShowFieldTemplate, orientation, showAsterisk, rightIcon, size = "md", id, ...rest } = props;
|
|
65
|
-
const { fieldErrors } = useForm();
|
|
66
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
67
|
-
const [maskedValue, setMaskedValue] = useState("0");
|
|
68
|
-
const inputRef = useRef(null);
|
|
69
|
-
const inputId = id || useId();
|
|
70
|
-
const errorMessage = baseErrorMessage || fieldErrors?.[name];
|
|
71
|
-
const isError = !!errorMessage;
|
|
72
|
-
const isDisabled = disabled || isLoading;
|
|
73
|
-
const iconSizes = { md: 20, lg: 20 };
|
|
74
|
-
const iconSize = iconSizes[size];
|
|
75
|
-
const loadingPosition = rightIcon ? "right" : "left";
|
|
76
|
-
const showLeftSpinner = loadingPosition === "left" && isLoading;
|
|
77
|
-
const showRightSpinner = loadingPosition === "right" && isLoading;
|
|
78
|
-
function handleSectionClick() {
|
|
79
|
-
if (isDisabled || !inputRef?.current)
|
|
80
|
-
return;
|
|
81
|
-
setIsFocused(true);
|
|
82
|
-
inputRef.current.focus();
|
|
83
|
-
}
|
|
84
|
-
function handleFocus(e) {
|
|
85
|
-
setIsFocused(true);
|
|
86
|
-
if (onFocus)
|
|
87
|
-
onFocus(e);
|
|
88
|
-
}
|
|
89
|
-
function handleBlur(e) {
|
|
90
|
-
setIsFocused(false);
|
|
91
|
-
if (onBlur)
|
|
92
|
-
onBlur(e);
|
|
93
|
-
}
|
|
94
|
-
const updateValues = (originalValue) => {
|
|
95
|
-
const [calculatedValue, calculatedMaskedValue] = maskCurrencyValues(originalValue, locale);
|
|
96
|
-
if (!max || calculatedValue <= max) {
|
|
97
|
-
setMaskedValue(calculatedMaskedValue);
|
|
98
|
-
return [calculatedValue, calculatedMaskedValue];
|
|
99
|
-
}
|
|
100
|
-
return maskCurrencyValues(originalValue, locale);
|
|
101
|
-
};
|
|
102
|
-
const handleChange = (event) => {
|
|
103
|
-
event.preventDefault();
|
|
104
|
-
const [originalValue, maskedValue] = updateValues(event.target.value);
|
|
105
|
-
onChange && onChange(event, String(originalValue), String(maskedValue));
|
|
106
|
-
};
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
function currentValue() {
|
|
109
|
-
if (typeof value === "number")
|
|
110
|
-
return value;
|
|
111
|
-
if (typeof defaultValue === "number")
|
|
112
|
-
return defaultValue;
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
const [, maskedValue] = maskCurrencyValues(currentValue(), locale);
|
|
116
|
-
setMaskedValue(maskedValue);
|
|
117
|
-
}, [locale, defaultValue, value]);
|
|
118
|
-
const hasPrefix = !!prefix ? "hasPrefix" : "";
|
|
119
|
-
const hasSuffix = !!suffix ? "hasSuffix" : "";
|
|
120
|
-
const errored = isError ? "errored" : "";
|
|
121
|
-
const opacity = isDisabled || readOnly || isLoading ? "opacity" : "";
|
|
122
|
-
const focused = isFocused ? "focused" : "";
|
|
123
|
-
const className = `arkynCurrencyInput ${hasPrefix} ${hasSuffix} ${variant} ${size} ${opacity} ${errored} ${focused}`;
|
|
124
|
-
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs("section", { title: title, style: style, className: className, onClick: handleSectionClick, children: [_jsx(IconRenderer, { iconSize: iconSize, icon: prefix, className: "prefix" }), _jsx(IconRenderer, { show: showLeftSpinner, iconSize: iconSize, className: "spinner", icon: Loader2 }), _jsx(IconRenderer, { show: !isLoading, icon: leftIcon, iconSize: iconSize }), _jsx("input", { disabled: isDisabled, readOnly: readOnly, ref: inputRef, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, id: inputId, placeholder: isDisabled ? maskedValue : undefined, value: isDisabled ? undefined : maskedValue, ...rest }), _jsx("input", { type: "hidden", name: name, value: normalizeValue(maskedValue), readOnly: true }), _jsx(IconRenderer, { show: !isLoading, icon: rightIcon, iconSize: iconSize }), _jsx(IconRenderer, { show: showRightSpinner, iconSize: iconSize, className: "spinner", icon: Loader2 }), _jsx(IconRenderer, { iconSize: iconSize, icon: suffix, className: "suffix" })] }) }));
|
|
125
|
-
}
|
|
126
|
-
export { CurrencyInput };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import "./styles.css";
|
|
3
|
-
/**
|
|
4
|
-
* Divider — visually separates content sections.
|
|
5
|
-
*
|
|
6
|
-
* @param props.orientation - Line direction (`horizontal` | `vertical`). Default: "horizontal"
|
|
7
|
-
*
|
|
8
|
-
* **...Other valid HTML properties for `<div>`**
|
|
9
|
-
*
|
|
10
|
-
* @returns Divider JSX element.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* // Between sections
|
|
15
|
-
* <h2>Section 1</h2>
|
|
16
|
-
* <Divider />
|
|
17
|
-
* <h2>Section 2</h2>
|
|
18
|
-
*
|
|
19
|
-
* // Vertical (e.g. between sidebar and content)
|
|
20
|
-
* <Divider orientation="vertical" />
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
function Divider(props) {
|
|
24
|
-
const { className: baseClassName, orientation = "horizontal", ...rest } = props;
|
|
25
|
-
const className = `arkynDivider ${orientation} ${baseClassName}`;
|
|
26
|
-
return _jsx("div", { className: className.trim(), ...rest });
|
|
27
|
-
}
|
|
28
|
-
export { Divider };
|