react-restyle-components 0.4.46 → 0.4.47
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/lib/index.js +1 -3
- package/lib/src/core-components/index.js +1 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Accordion.js +1 -15
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionContext.js +1 -6
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionSection.js +1 -39
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Header.js +1 -39
- package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.js +57 -94
- package/lib/src/core-components/src/components/Accordion/AccordionSection/hooks/useCurrentAccordionIndex.js +1 -13
- package/lib/src/core-components/src/components/Accordion/AccordionSection/index.js +1 -3
- package/lib/src/core-components/src/components/Accordion/AccordionSection/types.js +1 -9
- package/lib/src/core-components/src/components/Accordion/Collapsible/Collapsible2.component.js +1 -249
- package/lib/src/core-components/src/components/Action/types.js +1 -8
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +1 -45
- package/lib/src/core-components/src/components/AlertBanner/elements.js +45 -120
- package/lib/src/core-components/src/components/AlertBanner/index.js +1 -2
- package/lib/src/core-components/src/components/AlertBanner/types.js +1 -10
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-group-by-multiple-select-multiple-fields-display/auto-complete-filter-group-by-multiple-select-multiple-fields-display.component.js +1 -451
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-multi-fields-display-drag-drop/auto-complete-filter-multi-select-multi-fields-display-drag-drop.component.js +1 -229
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-selected-top-display/auto-complete-filter-multi-select-selected-top-display.component.js +1 -174
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +2 -129
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select/auto-complete-filter-single-select.component.js +1 -55
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +2 -308
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-group-by/auto-complete-group-by.component.js +1 -115
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.js +2 -442
- package/lib/src/core-components/src/components/AutoComplete/index.js +1 -8
- package/lib/src/core-components/src/components/Avatar/Avatar.js +14 -148
- package/lib/src/core-components/src/components/Badge/Badge.js +2 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/Inline.js +1 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/InnerBadge.js +1 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/elements.js +32 -78
- package/lib/src/core-components/src/components/Badge/InnerBadge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/types.js +1 -5
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +1 -83
- package/lib/src/core-components/src/components/Breadcrumb/elements.js +94 -166
- package/lib/src/core-components/src/components/Breadcrumb/index.js +1 -3
- package/lib/src/core-components/src/components/Breadcrumb/types.js +1 -3
- package/lib/src/core-components/src/components/Button/button.component.js +1 -18
- package/lib/src/core-components/src/components/Button/buttonGroup/buttonGroup.component.js +1 -4
- package/lib/src/core-components/src/components/Button/index.js +1 -2
- package/lib/src/core-components/src/components/Button/types.js +1 -1
- package/lib/src/core-components/src/components/Chip/Chip.js +1 -64
- package/lib/src/core-components/src/components/Chip/elements.js +48 -148
- package/lib/src/core-components/src/components/Chip/index.js +1 -2
- package/lib/src/core-components/src/components/Chip/types.js +1 -4
- package/lib/src/core-components/src/components/Divider/Divider.js +1 -25
- package/lib/src/core-components/src/components/Divider/elements.js +31 -68
- package/lib/src/core-components/src/components/Divider/index.js +1 -2
- package/lib/src/core-components/src/components/Divider/types.js +1 -4
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +1 -147
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +17 -24
- package/lib/src/core-components/src/components/DynamicGrid/elements.js +100 -162
- package/lib/src/core-components/src/components/DynamicGrid/index.js +1 -3
- package/lib/src/core-components/src/components/DynamicGrid/types.js +1 -28
- package/lib/src/core-components/src/components/DynamicGrid/utils.js +1 -193
- package/lib/src/core-components/src/components/FormField/FormField.js +1 -103
- package/lib/src/core-components/src/components/FormField/components/CheckboxGroupInput.js +1 -37
- package/lib/src/core-components/src/components/FormField/components/CheckboxInput.js +1 -8
- package/lib/src/core-components/src/components/FormField/components/CssMultilineInput.js +1 -192
- package/lib/src/core-components/src/components/FormField/components/DatePickerInput.js +1 -99
- package/lib/src/core-components/src/components/FormField/components/DropdownInput.js +1 -70
- package/lib/src/core-components/src/components/FormField/components/OtpInput.js +1 -81
- package/lib/src/core-components/src/components/FormField/components/PasswordInput.js +1 -40
- package/lib/src/core-components/src/components/FormField/components/PinInput.js +1 -75
- package/lib/src/core-components/src/components/FormField/components/RadioInput.js +1 -54
- package/lib/src/core-components/src/components/FormField/components/TextDropdownInput.js +1 -94
- package/lib/src/core-components/src/components/FormField/components/ToggleInput.js +1 -36
- package/lib/src/core-components/src/components/FormField/components/index.js +1 -11
- package/lib/src/core-components/src/components/FormField/css-properties.js +1 -161
- package/lib/src/core-components/src/components/FormField/index.js +1 -2
- package/lib/src/core-components/src/components/Icon/Icon.js +1 -159
- package/lib/src/core-components/src/components/Icon/index.js +1 -2
- package/lib/src/core-components/src/components/Icon/types.js +1 -9
- package/lib/src/core-components/src/components/Loader/loader.component.js +2 -215
- package/lib/src/core-components/src/components/Masonry/Masonry.js +1 -73
- package/lib/src/core-components/src/components/Masonry/elements.js +29 -46
- package/lib/src/core-components/src/components/Masonry/hooks.js +1 -100
- package/lib/src/core-components/src/components/Masonry/index.js +1 -3
- package/lib/src/core-components/src/components/Masonry/types.js +1 -1
- package/lib/src/core-components/src/components/Modal/BasicModal/modal.component.js +1 -116
- package/lib/src/core-components/src/components/Modal/index.js +1 -2
- package/lib/src/core-components/src/components/Modal/modal-confirm/modal-confirm.component.js +1 -147
- package/lib/src/core-components/src/components/Picker/color-picker/color-picker.component.js +1 -12
- package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +1 -40
- package/lib/src/core-components/src/components/Picker/index.js +1 -2
- package/lib/src/core-components/src/components/Selection/index.js +1 -4
- package/lib/src/core-components/src/components/Selection/multi-select/multi-select.component.js +1 -49
- package/lib/src/core-components/src/components/Selection/multi-select-with-field/multi-select-with-field.component.js +1 -58
- package/lib/src/core-components/src/components/Selection/multi-selection-dropdown/multi-selection-dropdown.component.js +1 -43
- package/lib/src/core-components/src/components/Selection/single-select/single-select.component.js +1 -87
- package/lib/src/core-components/src/components/Skeleton/Skeleton.js +1 -51
- package/lib/src/core-components/src/components/Skeleton/elements.js +54 -143
- package/lib/src/core-components/src/components/Skeleton/index.js +1 -2
- package/lib/src/core-components/src/components/Skeleton/types.js +1 -4
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +1 -128
- package/lib/src/core-components/src/components/SpeedDial/elements.js +62 -132
- package/lib/src/core-components/src/components/SpeedDial/index.js +1 -2
- package/lib/src/core-components/src/components/SpeedDial/types.js +1 -3
- package/lib/src/core-components/src/components/Stepper2/stepper.component.js +1 -139
- package/lib/src/core-components/src/components/Switch/Switch.js +1 -26
- package/lib/src/core-components/src/components/Switch/elements.js +34 -103
- package/lib/src/core-components/src/components/Switch/index.js +1 -2
- package/lib/src/core-components/src/components/Switch/types.js +1 -3
- package/lib/src/core-components/src/components/Table/Table.js +1 -1489
- package/lib/src/core-components/src/components/Table/columnReorder.js +36 -332
- package/lib/src/core-components/src/components/Table/columnResize.js +21 -284
- package/lib/src/core-components/src/components/Table/elements.js +173 -277
- package/lib/src/core-components/src/components/Table/filters.js +30 -555
- package/lib/src/core-components/src/components/Table/hooks.js +2 -536
- package/lib/src/core-components/src/components/Table/index.js +1 -6
- package/lib/src/core-components/src/components/Table/types.js +1 -1
- package/lib/src/core-components/src/components/Tabs/tabs.component.js +1 -22
- package/lib/src/core-components/src/components/Tags1/Tags.component.js +1 -118
- package/lib/src/core-components/src/components/Tags1/types.js +1 -20
- package/lib/src/core-components/src/components/Timer1/timer.component.js +1 -76
- package/lib/src/core-components/src/components/Toast/Toast.js +1 -50
- package/lib/src/core-components/src/components/Toast/elements.js +41 -122
- package/lib/src/core-components/src/components/Toast/index.js +1 -2
- package/lib/src/core-components/src/components/Toast/types.js +1 -9
- package/lib/src/core-components/src/components/Tooltip/Tooltip.js +1 -200
- package/lib/src/core-components/src/components/Tooltip/elements.js +55 -117
- package/lib/src/core-components/src/components/Tooltip/index.js +1 -2
- package/lib/src/core-components/src/components/Tooltip/types.js +1 -17
- package/lib/src/core-components/src/components/Tooltip/utils.js +1 -140
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +1 -303
- package/lib/src/core-components/src/components/TreeSelect/elements.js +117 -216
- package/lib/src/core-components/src/components/TreeSelect/hooks.js +1 -252
- package/lib/src/core-components/src/components/TreeSelect/index.js +1 -3
- package/lib/src/core-components/src/components/TreeSelect/types.js +1 -1
- package/lib/src/core-components/src/components/ag-grid/AgGrid.js +1 -1057
- package/lib/src/core-components/src/components/ag-grid/elements.js +396 -790
- package/lib/src/core-components/src/components/ag-grid/hooks.js +4 -1220
- package/lib/src/core-components/src/components/ag-grid/index.js +1 -15
- package/lib/src/core-components/src/components/ag-grid/types.js +1 -6
- package/lib/src/core-components/src/components/index.js +1 -31
- package/lib/src/core-components/src/components/pdf/pdf-images.components.js +1 -7
- package/lib/src/core-components/src/components/pdf/pdf-table.components.js +5 -48
- package/lib/src/core-components/src/components/pdf/pdf-typography.components.js +1 -70
- package/lib/src/core-components/src/components/pdf/pdf-wrapped-view.components.js +1 -50
- package/lib/src/core-components/src/core-components/Avatar.js +4 -33
- package/lib/src/core-components/src/core-components/CoreButton/CoreButton.js +1 -10
- package/lib/src/core-components/src/core-components/CoreButton/elements.js +67 -176
- package/lib/src/core-components/src/core-components/CoreButton/index.js +1 -3
- package/lib/src/core-components/src/core-components/CoreButton/types.js +1 -6
- package/lib/src/core-components/src/core-components/CoreButton/utils.js +1 -12
- package/lib/src/core-components/src/core-components/Divider/Divider.js +4 -19
- package/lib/src/core-components/src/core-components/Divider/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/selectionCardStrip.js +10 -33
- package/lib/src/core-components/src/core-components/StateLayer.js +3 -5
- package/lib/src/core-components/src/core-components/ToggleCore/elements.js +25 -50
- package/lib/src/core-components/src/core-components/ToggleCore/index.js +1 -2
- package/lib/src/core-components/src/core-components/ToggleCore/toggleCore.js +1 -14
- package/lib/src/core-components/src/core-components/atoms/Input/Input.js +1 -22
- package/lib/src/core-components/src/core-components/atoms/Label/Label.js +1 -21
- package/lib/src/core-components/src/core-components/atoms/Textarea/Textarea.js +1 -19
- package/lib/src/core-components/src/core-components/index.js +1 -3
- package/lib/src/core-components/src/helpers/constants.js +1 -11
- package/lib/src/core-components/src/hooks/index.js +1 -1
- package/lib/src/core-components/src/hooks/outside.hook.js +1 -28
- package/lib/src/core-components/src/index.js +1 -12
- package/lib/src/core-components/src/tc.global.css +1 -0
- package/lib/src/core-components/src/utils/abstracts/breakpoints/index.js +1 -28
- package/lib/src/core-components/src/utils/abstracts/colors/index.js +1 -49
- package/lib/src/core-components/src/utils/abstracts/index.js +1 -5
- package/lib/src/core-components/src/utils/abstracts/space/index.js +1 -26
- package/lib/src/core-components/src/utils/abstracts/theme/ThemeBoundary.js +1 -8
- package/lib/src/core-components/src/utils/abstracts/theme/default-themes.js +1 -30
- package/lib/src/core-components/src/utils/abstracts/theme/index.js +1 -3
- package/lib/src/core-components/src/utils/abstracts/theme/theme.js +1 -30
- package/lib/src/core-components/src/utils/abstracts/theme/types.js +1 -1
- package/lib/src/core-components/src/utils/abstracts/theme/useTheme.js +1 -17
- package/lib/src/core-components/src/utils/abstracts/typography/index.js +1 -25
- package/lib/src/core-components/src/utils/context/DefaultsProvider.js +1 -8
- package/lib/src/core-components/src/utils/context/InternalProvider.js +1 -24
- package/lib/src/core-components/src/utils/context/index.js +1 -2
- package/lib/src/core-components/src/utils/designTokens.js +1 -128
- package/lib/src/core-components/src/utils/helpers/attachSubComponents.js +1 -23
- package/lib/src/core-components/src/utils/helpers/flattenChildren.js +1 -11
- package/lib/src/core-components/src/utils/helpers/getChildByType.js +1 -3
- package/lib/src/core-components/src/utils/helpers/index.js +1 -5
- package/lib/src/core-components/src/utils/helpers/isComponentType.js +1 -16
- package/lib/src/core-components/src/utils/helpers/separateChildrenByType.js +1 -12
- package/lib/src/core-components/src/utils/hooks/index.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useClickOutside.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useCombinedRefs.js +1 -17
- package/lib/src/core-components/src/utils/hooks/useDebouncedCallback.js +1 -12
- package/lib/src/core-components/src/utils/hooks/useDebouncedValue.js +1 -20
- package/lib/src/core-components/src/utils/hooks/useDeprecation.js +1 -40
- package/lib/src/core-components/src/utils/hooks/useDeviceDetect.js +1 -10
- package/lib/src/core-components/src/utils/hooks/useDeviceForm.js +1 -24
- package/lib/src/core-components/src/utils/hooks/useDisableBodyScroll.js +1 -16
- package/lib/src/core-components/src/utils/hooks/useHoverState.js +1 -36
- package/lib/src/core-components/src/utils/hooks/useId.js +1 -7
- package/lib/src/core-components/src/utils/hooks/useIsBrowser.js +1 -11
- package/lib/src/core-components/src/utils/hooks/useMediaQuery.js +1 -16
- package/lib/src/core-components/src/utils/hooks/useOverflow.js +1 -22
- package/lib/src/core-components/src/utils/hooks/useSafeLayoutEffect.js +1 -5
- package/lib/src/core-components/src/utils/hooks/useScrollingUp.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useTrapFocus.js +1 -30
- package/lib/src/core-components/src/utils/hooks/useWindowDimensions.js +1 -23
- package/lib/src/core-components/src/utils/index.js +1 -9
- package/lib/src/core-components/src/utils/stories/Wrappers.js +8 -23
- package/lib/src/core-components/src/utils/stories/cleanProps.js +1 -5
- package/lib/src/core-components/src/utils/stories/index.js +1 -4
- package/lib/src/core-components/src/utils/stories/sleep.js +1 -4
- package/lib/src/core-components/src/utils/stories/view-ports.js +1 -50
- package/lib/src/core-components/src/utils/styling/calcWidthOfColumns.js +1 -5
- package/lib/src/core-components/src/utils/styling/createGridContainer.js +6 -12
- package/lib/src/core-components/src/utils/styling/createTransition.js +2 -7
- package/lib/src/core-components/src/utils/styling/forwardProps.js +1 -10
- package/lib/src/core-components/src/utils/styling/index.js +1 -5
- package/lib/src/core-components/src/utils/styling/pxToRem.js +1 -6
- package/lib/src/core-components/src/utils/testing/getComputedStyle.js +1 -3
- package/lib/src/core-components/src/utils/testing/index.js +1 -1
- package/lib/src/core-components/src/utils/utility.util.js +1 -14
- package/lib/src/core-components/tailwind.config.js +1 -233
- package/lib/src/core-hooks/index.js +1 -3
- package/lib/src/core-hooks/src/useClickOutside/useClickOutside.hook.js +1 -46
- package/lib/src/core-hooks/src/useDebounce/useDebounce.hook.js +1 -30
- package/lib/src/core-hooks/src/usePreventEKey/usePreventEKey.hook.js +1 -8
- package/lib/src/core-utils/index.js +1 -7
- package/lib/src/core-utils/src/calculation/calculation.util.js +1 -89
- package/lib/src/core-utils/src/colors/color.util.js +1 -15
- package/lib/src/core-utils/src/convert/numberToWords/numToWords.util.js +1 -145
- package/lib/src/core-utils/src/convert/typography/camelCaseToTitleCase.util.js +1 -5
- package/lib/src/core-utils/src/form-helper/form-helper.util.js +1 -82
- package/lib/src/core-utils/src/index.js +1 -7
- package/lib/src/core-utils/src/utility/utility.util.js +1 -12
- package/lib/src/core-utils/src/uuid/uuid.util.js +1 -8
- package/package.json +1 -1
|
@@ -1,193 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { gapSizeValues, gapSizes, } from './types';
|
|
3
|
-
// Breakpoint values in pixels
|
|
4
|
-
const BREAKPOINTS = {
|
|
5
|
-
xs: 0,
|
|
6
|
-
sm: 375,
|
|
7
|
-
md: 768,
|
|
8
|
-
lg: 1024,
|
|
9
|
-
xl: 1280,
|
|
10
|
-
'2xl': 1440,
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Convert pixels to rem
|
|
14
|
-
*/
|
|
15
|
-
export const pxToRem = (px) => px / 16;
|
|
16
|
-
/**
|
|
17
|
-
* Convert rem to pixels
|
|
18
|
-
*/
|
|
19
|
-
export const remToPx = (rem) => rem * 16;
|
|
20
|
-
/**
|
|
21
|
-
* Get gap value from GapSize or LegacyGapSize
|
|
22
|
-
*/
|
|
23
|
-
export const getGapValue = (gap) => {
|
|
24
|
-
if (typeof gap === 'number') {
|
|
25
|
-
return gapSizes[gap] || gapSizes[1];
|
|
26
|
-
}
|
|
27
|
-
return gapSizeValues[gap] || gapSizeValues.md;
|
|
28
|
-
};
|
|
29
|
-
const moduloColumns = (columns, modulo) => Math.floor(columns / modulo) * modulo;
|
|
30
|
-
export const calcColumns = ({ minWidth, elementWidth, gap, modulo, maxColumns, scrollHint = 0, }) => {
|
|
31
|
-
if (elementWidth === 0)
|
|
32
|
-
return 1;
|
|
33
|
-
const gapSize = parseFloat(gap);
|
|
34
|
-
const elementWidthInRem = pxToRem(elementWidth);
|
|
35
|
-
const columns = Math.min(Math.floor((elementWidthInRem + gapSize - minWidth * scrollHint) /
|
|
36
|
-
(minWidth + gapSize)), maxColumns);
|
|
37
|
-
return Math.max(1, moduloColumns(columns, modulo));
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Get responsive columns based on window width
|
|
41
|
-
*/
|
|
42
|
-
export const getResponsiveColumns = (responsiveColumns, windowWidth) => {
|
|
43
|
-
let columns = 1;
|
|
44
|
-
if (responsiveColumns.xs !== undefined && windowWidth >= BREAKPOINTS.xs) {
|
|
45
|
-
columns = responsiveColumns.xs;
|
|
46
|
-
}
|
|
47
|
-
if (responsiveColumns.sm !== undefined && windowWidth >= BREAKPOINTS.sm) {
|
|
48
|
-
columns = responsiveColumns.sm;
|
|
49
|
-
}
|
|
50
|
-
if (responsiveColumns.md !== undefined && windowWidth >= BREAKPOINTS.md) {
|
|
51
|
-
columns = responsiveColumns.md;
|
|
52
|
-
}
|
|
53
|
-
if (responsiveColumns.lg !== undefined && windowWidth >= BREAKPOINTS.lg) {
|
|
54
|
-
columns = responsiveColumns.lg;
|
|
55
|
-
}
|
|
56
|
-
if (responsiveColumns.xl !== undefined && windowWidth >= BREAKPOINTS.xl) {
|
|
57
|
-
columns = responsiveColumns.xl;
|
|
58
|
-
}
|
|
59
|
-
if (responsiveColumns['2xl'] !== undefined && windowWidth >= BREAKPOINTS['2xl']) {
|
|
60
|
-
columns = responsiveColumns['2xl'];
|
|
61
|
-
}
|
|
62
|
-
return columns;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Hook to get current window width
|
|
66
|
-
*/
|
|
67
|
-
export const useWindowWidth = () => {
|
|
68
|
-
const [width, setWidth] = useState(typeof window !== 'undefined' ? window.innerWidth : 1024);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (typeof window === 'undefined')
|
|
71
|
-
return;
|
|
72
|
-
const handleResize = () => {
|
|
73
|
-
setWidth(window.innerWidth);
|
|
74
|
-
};
|
|
75
|
-
window.addEventListener('resize', handleResize);
|
|
76
|
-
return () => window.removeEventListener('resize', handleResize);
|
|
77
|
-
}, []);
|
|
78
|
-
return width;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Hook to observe element resize
|
|
82
|
-
*/
|
|
83
|
-
export const useElementResize = (ref, callback) => {
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
const element = ref.current;
|
|
86
|
-
if (!element)
|
|
87
|
-
return;
|
|
88
|
-
// Initial size
|
|
89
|
-
callback(element.clientWidth, element.clientHeight);
|
|
90
|
-
if (!window.ResizeObserver)
|
|
91
|
-
return;
|
|
92
|
-
const observer = new ResizeObserver((entries) => {
|
|
93
|
-
window.requestAnimationFrame(() => {
|
|
94
|
-
const entry = entries[0];
|
|
95
|
-
if (entry) {
|
|
96
|
-
callback(entry.contentRect.width, entry.contentRect.height);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
observer.observe(element);
|
|
101
|
-
return () => observer.disconnect();
|
|
102
|
-
}, [ref, callback]);
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Hook to handle keyboard focus scrolling in scroll mode
|
|
106
|
-
*/
|
|
107
|
-
export const useScrollToKeyboardFocus = (ref, scroll) => {
|
|
108
|
-
const scrollToFocused = useCallback((keyboardEvent) => {
|
|
109
|
-
const { target } = keyboardEvent;
|
|
110
|
-
if (target instanceof HTMLElement &&
|
|
111
|
-
scroll?.enabled &&
|
|
112
|
-
keyboardEvent.key === 'Tab') {
|
|
113
|
-
target.scrollIntoView({
|
|
114
|
-
inline: 'center',
|
|
115
|
-
block: 'nearest',
|
|
116
|
-
behavior: scroll.smoothScroll !== false ? 'smooth' : 'auto',
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}, [scroll]);
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
const element = ref.current;
|
|
122
|
-
if (!element)
|
|
123
|
-
return;
|
|
124
|
-
element.addEventListener('keyup', scrollToFocused);
|
|
125
|
-
return () => {
|
|
126
|
-
element.removeEventListener('keyup', scrollToFocused);
|
|
127
|
-
};
|
|
128
|
-
}, [scrollToFocused, ref]);
|
|
129
|
-
};
|
|
130
|
-
export const useScrollNavigation = (ref, itemCount, columns) => {
|
|
131
|
-
const [scrollState, setScrollState] = useState({
|
|
132
|
-
canScrollLeft: false,
|
|
133
|
-
canScrollRight: true,
|
|
134
|
-
currentPage: 0,
|
|
135
|
-
});
|
|
136
|
-
const totalPages = Math.ceil(itemCount / columns);
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
const element = ref.current;
|
|
139
|
-
if (!element)
|
|
140
|
-
return;
|
|
141
|
-
const handleScroll = () => {
|
|
142
|
-
const { scrollLeft, scrollWidth, clientWidth } = element;
|
|
143
|
-
const canScrollLeft = scrollLeft > 0;
|
|
144
|
-
const canScrollRight = scrollLeft + clientWidth < scrollWidth - 1;
|
|
145
|
-
const currentPage = Math.round(scrollLeft / clientWidth);
|
|
146
|
-
setScrollState({ canScrollLeft, canScrollRight, currentPage });
|
|
147
|
-
};
|
|
148
|
-
element.addEventListener('scroll', handleScroll);
|
|
149
|
-
handleScroll(); // Initial check
|
|
150
|
-
return () => element.removeEventListener('scroll', handleScroll);
|
|
151
|
-
}, [ref]);
|
|
152
|
-
const scrollTo = useCallback((index) => {
|
|
153
|
-
const element = ref.current;
|
|
154
|
-
if (!element)
|
|
155
|
-
return;
|
|
156
|
-
const { clientWidth } = element;
|
|
157
|
-
element.scrollTo({
|
|
158
|
-
left: index * clientWidth,
|
|
159
|
-
behavior: 'smooth',
|
|
160
|
-
});
|
|
161
|
-
}, [ref]);
|
|
162
|
-
const scrollLeft = useCallback(() => {
|
|
163
|
-
if (scrollState.currentPage > 0) {
|
|
164
|
-
scrollTo(scrollState.currentPage - 1);
|
|
165
|
-
}
|
|
166
|
-
}, [scrollState.currentPage, scrollTo]);
|
|
167
|
-
const scrollRight = useCallback(() => {
|
|
168
|
-
if (scrollState.currentPage < totalPages - 1) {
|
|
169
|
-
scrollTo(scrollState.currentPage + 1);
|
|
170
|
-
}
|
|
171
|
-
}, [scrollState.currentPage, totalPages, scrollTo]);
|
|
172
|
-
return {
|
|
173
|
-
...scrollState,
|
|
174
|
-
totalPages,
|
|
175
|
-
scrollTo,
|
|
176
|
-
scrollLeft,
|
|
177
|
-
scrollRight,
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Get item count from children
|
|
182
|
-
*/
|
|
183
|
-
export const getItemCount = (children) => {
|
|
184
|
-
if (!children)
|
|
185
|
-
return 0;
|
|
186
|
-
if (Array.isArray(children))
|
|
187
|
-
return children.filter(Boolean).length;
|
|
188
|
-
return 1;
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Generate unique ID for accessibility
|
|
192
|
-
*/
|
|
193
|
-
export const generateGridId = () => `grid-${Math.random().toString(36).substr(2, 9)}`;
|
|
1
|
+
"use strict";import{useCallback as d,useEffect as f,useState as h}from"react";import{gapSizeValues as S,gapSizes as R}from"./types";const a={xs:0,sm:375,md:768,lg:1024,xl:1280,"2xl":1440};export const pxToRem=e=>e/16,remToPx=e=>e*16,getGapValue=e=>typeof e=="number"?R[e]||R[1]:S[e]||S.md;const b=(e,t)=>Math.floor(e/t)*t;export const calcColumns=({minWidth:e,elementWidth:t,gap:n,modulo:r,maxColumns:c,scrollHint:o=0})=>{if(t===0)return 1;const s=parseFloat(n),g=pxToRem(t),m=Math.min(Math.floor((g+s-e*o)/(e+s)),c);return Math.max(1,b(m,r))},getResponsiveColumns=(e,t)=>{let n=1;return e.xs!==void 0&&t>=a.xs&&(n=e.xs),e.sm!==void 0&&t>=a.sm&&(n=e.sm),e.md!==void 0&&t>=a.md&&(n=e.md),e.lg!==void 0&&t>=a.lg&&(n=e.lg),e.xl!==void 0&&t>=a.xl&&(n=e.xl),e["2xl"]!==void 0&&t>=a["2xl"]&&(n=e["2xl"]),n},useWindowWidth=()=>{const[e,t]=h(typeof window<"u"?window.innerWidth:1024);return f(()=>{if(typeof window>"u")return;const n=()=>{t(window.innerWidth)};return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e},useElementResize=(e,t)=>{f(()=>{const n=e.current;if(!n||(t(n.clientWidth,n.clientHeight),!window.ResizeObserver))return;const r=new ResizeObserver(c=>{window.requestAnimationFrame(()=>{const o=c[0];o&&t(o.contentRect.width,o.contentRect.height)})});return r.observe(n),()=>r.disconnect()},[e,t])},useScrollToKeyboardFocus=(e,t)=>{const n=d(r=>{const{target:c}=r;c instanceof HTMLElement&&t?.enabled&&r.key==="Tab"&&c.scrollIntoView({inline:"center",block:"nearest",behavior:t.smoothScroll!==!1?"smooth":"auto"})},[t]);f(()=>{const r=e.current;if(r)return r.addEventListener("keyup",n),()=>{r.removeEventListener("keyup",n)}},[n,e])},useScrollNavigation=(e,t,n)=>{const[r,c]=h({canScrollLeft:!1,canScrollRight:!0,currentPage:0}),o=Math.ceil(t/n);f(()=>{const l=e.current;if(!l)return;const i=()=>{const{scrollLeft:u,scrollWidth:p,clientWidth:x}=l,w=u>0,L=u+x<p-1,P=Math.round(u/x);c({canScrollLeft:w,canScrollRight:L,currentPage:P})};return l.addEventListener("scroll",i),i(),()=>l.removeEventListener("scroll",i)},[e]);const s=d(l=>{const i=e.current;if(!i)return;const{clientWidth:u}=i;i.scrollTo({left:l*u,behavior:"smooth"})},[e]),g=d(()=>{r.currentPage>0&&s(r.currentPage-1)},[r.currentPage,s]),m=d(()=>{r.currentPage<o-1&&s(r.currentPage+1)},[r.currentPage,o,s]);return{...r,totalPages:o,scrollTo:s,scrollLeft:g,scrollRight:m}},getItemCount=e=>e?Array.isArray(e)?e.filter(Boolean).length:1:0,generateGridId=()=>`grid-${Math.random().toString(36).substr(2,9)}`;
|
|
@@ -1,103 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Input } from '../../core-components/atoms/Input/Input';
|
|
4
|
-
import { Textarea, } from '../../core-components/atoms/Textarea/Textarea';
|
|
5
|
-
import { PasswordInput, ToggleInput, RadioInput, CheckboxInput, CheckboxGroupInput, DatePickerInput, DropdownInput, TextDropdownInput, PinInput, OtpInput, CssMultilineInput, } from './components';
|
|
6
|
-
// Re-export all FormField components for direct use
|
|
7
|
-
export { PasswordInput, ToggleInput, RadioInput, CheckboxInput, CheckboxGroupInput, DatePickerInput, DropdownInput, TextDropdownInput, PinInput, OtpInput, CssMultilineInput, } from './components';
|
|
8
|
-
export const Label = (props) => (_jsx(_Fragment, { children: _jsx("label", { htmlFor: props.htmlFor, className: `${props.hasError ? 'text-red-400' : 'text-gray-700'} block text-3xs font-medium mb-1`, style: { ...props.style }, children: props.children }) }));
|
|
9
|
-
export const InputWrapper = (props) => (_jsxs("div", { className: props.className, ref: props.ref, children: [_jsx(Label, { htmlFor: props.id || '', hasError: props.hasError, style: { ...props.style }, children: _jsx("span", { className: "dark:text-white", children: props.label }) }), props.children] }));
|
|
10
|
-
export const FormField = React.forwardRef(({ label, error, hasError, id, labelProps, required, type = 'text', showPasswordToggle, radioOptions, checkboxLabel, checkboxOptions, isToggleLabel = true, dateFormat = 'yyyy-MM-dd', dropdownItems = [], allowCustomInput = true, pinLength = 12, otpLength = 6, pinValue = [], pinErrorMsg, pinDefaultMsg, cssProperties, onReset, onMoreInfo, value, onChange, onValueChange, onBlur, onValueBlur, disabled, children, ...props }, ref) => {
|
|
11
|
-
const fieldId = id || `field-${Math.random().toString(36).substr(2, 9)}`;
|
|
12
|
-
const isTextarea = type === 'textarea';
|
|
13
|
-
const isToggle = type === 'toggle';
|
|
14
|
-
const isRadio = type === 'radio';
|
|
15
|
-
const isCheckbox = type === 'checkbox';
|
|
16
|
-
const isCheckboxGroup = type === 'checkbox-group';
|
|
17
|
-
const isDatePicker = type === 'date-picker';
|
|
18
|
-
const isInputDropdown = type === 'input-dropdown';
|
|
19
|
-
const isTextInputDropdown = type === 'text-input-dropdown';
|
|
20
|
-
const isInputPin = type === 'input-pin';
|
|
21
|
-
const isInputOtp = type === 'input-otp';
|
|
22
|
-
const isCssMultiline = type === 'css-multiline';
|
|
23
|
-
const isPassword = type === 'password';
|
|
24
|
-
const isInputWrapper = type === 'input-wrapper';
|
|
25
|
-
// Calculate effective error: use error message if provided, otherwise use hasError for styling
|
|
26
|
-
const effectiveError = error || (hasError ? ' ' : undefined);
|
|
27
|
-
// Handle checkbox change
|
|
28
|
-
const handleCheckboxChange = (e) => {
|
|
29
|
-
if (onChange) {
|
|
30
|
-
onChange(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
// Render toggle switch
|
|
34
|
-
if (isToggle) {
|
|
35
|
-
return (_jsx(ToggleInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, disabled: disabled, isToggleLabel: isToggleLabel, labelProps: labelProps, className: props.className, ...props }));
|
|
36
|
-
}
|
|
37
|
-
// Render radio buttons
|
|
38
|
-
if (isRadio && radioOptions) {
|
|
39
|
-
return (_jsx(RadioInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, disabled: disabled, radioOptions: radioOptions, name: props.name, className: props.className, labelProps: labelProps, ...props }));
|
|
40
|
-
}
|
|
41
|
-
// Render checkbox
|
|
42
|
-
if (isCheckbox) {
|
|
43
|
-
return (_jsx(CheckboxInput, { ref: ref, id: fieldId, label: label, checkboxLabel: checkboxLabel, error: effectiveError, required: required, value: value, onChange: handleCheckboxChange, disabled: disabled, name: props.name, labelProps: labelProps, ...props }));
|
|
44
|
-
}
|
|
45
|
-
// Render checkbox group
|
|
46
|
-
if (isCheckboxGroup && checkboxOptions) {
|
|
47
|
-
return (_jsx(CheckboxGroupInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, disabled: disabled, checkboxOptions: checkboxOptions, className: props.className, labelProps: labelProps, ...props }));
|
|
48
|
-
}
|
|
49
|
-
// Render date picker
|
|
50
|
-
if (isDatePicker) {
|
|
51
|
-
return (_jsx(DatePickerInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, disabled: disabled, dateFormat: dateFormat, placeholder: props.placeholder, className: props.className, labelProps: labelProps, ...props }));
|
|
52
|
-
}
|
|
53
|
-
// Render input dropdown
|
|
54
|
-
if (isInputDropdown) {
|
|
55
|
-
return (_jsx(DropdownInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, disabled: disabled, dropdownItems: dropdownItems, placeholder: props.placeholder, name: props.name, className: props.className, labelProps: labelProps, ...props }));
|
|
56
|
-
}
|
|
57
|
-
// Render text input dropdown
|
|
58
|
-
if (isTextInputDropdown) {
|
|
59
|
-
return (_jsx(TextDropdownInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, onBlur: props.onBlur, disabled: disabled, dropdownItems: dropdownItems, allowCustomInput: allowCustomInput, placeholder: props.placeholder, name: props.name, className: props.className, labelProps: labelProps, ...props }));
|
|
60
|
-
}
|
|
61
|
-
// Render input PIN
|
|
62
|
-
if (isInputPin) {
|
|
63
|
-
return (_jsx(PinInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: pinValue, onChange: onChange, disabled: disabled, pinLength: pinLength, pinErrorMsg: pinErrorMsg, pinDefaultMsg: pinDefaultMsg, className: props.className, labelProps: labelProps, ...props }));
|
|
64
|
-
}
|
|
65
|
-
// Render input OTP
|
|
66
|
-
if (isInputOtp) {
|
|
67
|
-
return (_jsx(OtpInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: pinValue, onChange: onChange, disabled: disabled, otpLength: otpLength, pinErrorMsg: pinErrorMsg, pinDefaultMsg: pinDefaultMsg, className: props.className, labelProps: labelProps, ...props }));
|
|
68
|
-
}
|
|
69
|
-
// Render CSS Multiline
|
|
70
|
-
if (isCssMultiline) {
|
|
71
|
-
return (_jsx(CssMultilineInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, disabled: disabled, cssProperties: cssProperties, onReset: onReset, onMoreInfo: onMoreInfo, placeholder: props.placeholder, className: props.className, labelProps: labelProps, ...props }));
|
|
72
|
-
}
|
|
73
|
-
// Render InputWrapper
|
|
74
|
-
if (isInputWrapper) {
|
|
75
|
-
return (_jsxs(InputWrapper, { id: fieldId, label: label, className: props.className, hasError: !!error || !!hasError, style: props.style, ref: ref, children: [children || (_jsx("input", { id: fieldId, type: "text", value: value, onChange: onChange, onFocus: props.onFocus, onBlur: props.onBlur, disabled: disabled, placeholder: props.placeholder, name: props.name, autoComplete: props.autoComplete, autoFocus: props.autoFocus, readOnly: props.readOnly, maxLength: props.maxLength, minLength: props.minLength, tabIndex: props.tabIndex, "aria-label": props['aria-label'], "aria-describedby": props['aria-describedby'], "aria-invalid": props['aria-invalid'], "aria-required": props['aria-required'], style: {
|
|
76
|
-
width: '100%',
|
|
77
|
-
padding: '8px 12px',
|
|
78
|
-
border: error || hasError ? '1px solid #ef4444' : '1px solid #d1d5db',
|
|
79
|
-
borderRadius: '6px',
|
|
80
|
-
fontSize: '14px',
|
|
81
|
-
} })), error && (_jsx("div", { style: {
|
|
82
|
-
color: '#ef4444',
|
|
83
|
-
fontSize: '12px',
|
|
84
|
-
marginTop: '4px',
|
|
85
|
-
}, children: error }))] }));
|
|
86
|
-
}
|
|
87
|
-
// Render textarea - use Textarea atom component
|
|
88
|
-
if (isTextarea) {
|
|
89
|
-
return (_jsx(Textarea, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, onValueChange: onValueChange, onBlur: onBlur, onValueBlur: onValueBlur, ...labelProps, ...props }));
|
|
90
|
-
}
|
|
91
|
-
// Render standard input - use Input atom component
|
|
92
|
-
// For password without toggle, use Input atom
|
|
93
|
-
if (isPassword && !showPasswordToggle) {
|
|
94
|
-
return (_jsx(Input, { ref: ref, id: fieldId, type: type, label: label, error: effectiveError, required: required, value: value, onChange: onChange, onValueChange: onValueChange, onBlur: onBlur, onValueBlur: onValueBlur, ...labelProps, ...props }));
|
|
95
|
-
}
|
|
96
|
-
// For password with toggle, use PasswordInput component
|
|
97
|
-
if (isPassword && showPasswordToggle) {
|
|
98
|
-
return (_jsx(PasswordInput, { ref: ref, id: fieldId, label: label, error: effectiveError, required: required, value: value, onChange: onChange, onValueChange: onValueChange, onBlur: onBlur, onValueBlur: onValueBlur, disabled: disabled, labelProps: labelProps, ...props }));
|
|
99
|
-
}
|
|
100
|
-
// Render standard input - use Input atom component
|
|
101
|
-
return (_jsx(Input, { ref: ref, id: fieldId, type: type, label: label, error: effectiveError, required: required, value: value, onChange: onChange, onValueChange: onValueChange, onBlur: onBlur, onValueBlur: onValueBlur, ...labelProps, ...props }));
|
|
102
|
-
});
|
|
103
|
-
FormField.displayName = 'FormField';
|
|
1
|
+
"use strict";import{jsx as t,Fragment as Z,jsxs as L}from"react/jsx-runtime";import p from"react";import{Input as M}from"../../core-components/atoms/Input/Input";import{Textarea as ee}from"../../core-components/atoms/Textarea/Textarea";import{PasswordInput as ae,ToggleInput as te,RadioInput as ne,CheckboxInput as re,CheckboxGroupInput as ie,DatePickerInput as le,DropdownInput as de,TextDropdownInput as ce,PinInput as oe,OtpInput as ue,CssMultilineInput as se}from"./components";export{PasswordInput,ToggleInput,RadioInput,CheckboxInput,CheckboxGroupInput,DatePickerInput,DropdownInput,TextDropdownInput,PinInput,OtpInput,CssMultilineInput}from"./components";export const Label=a=>t(Z,{children:t("label",{htmlFor:a.htmlFor,className:`${a.hasError?"text-red-400":"text-gray-700"} block text-3xs font-medium mb-1`,style:{...a.style},children:a.children})}),InputWrapper=a=>L("div",{className:a.className,ref:a.ref,children:[t(Label,{htmlFor:a.id||"",hasError:a.hasError,style:{...a.style},children:t("span",{className:"dark:text-white",children:a.label})}),a.children]}),FormField=p.forwardRef(({label:a,error:m,hasError:I,id:T,labelProps:d,required:c,type:i="text",showPasswordToggle:b,radioOptions:g,checkboxLabel:v,checkboxOptions:N,isToggleLabel:y=!0,dateFormat:P="yyyy-MM-dd",dropdownItems:k=[],allowCustomInput:R=!0,pinLength:B=12,otpLength:O=6,pinValue:w=[],pinErrorMsg:C,pinDefaultMsg:F,cssProperties:j,onReset:E,onMoreInfo:q,value:u,onChange:n,onValueChange:h,onBlur:x,onValueBlur:f,disabled:s,children:G,...e},l)=>{const r=T||`field-${Math.random().toString(36).substr(2,9)}`,S=i==="textarea",_=i==="toggle",z=i==="radio",W=i==="checkbox",$=i==="checkbox-group",V=i==="date-picker",A=i==="input-dropdown",H=i==="text-input-dropdown",J=i==="input-pin",K=i==="input-otp",Q=i==="css-multiline",D=i==="password",U=i==="input-wrapper",o=m||(I?" ":void 0),X=Y=>{n&&n(Y)};return _?t(te,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,disabled:s,isToggleLabel:y,labelProps:d,className:e.className,...e}):z&&g?t(ne,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,disabled:s,radioOptions:g,name:e.name,className:e.className,labelProps:d,...e}):W?t(re,{ref:l,id:r,label:a,checkboxLabel:v,error:o,required:c,value:u,onChange:X,disabled:s,name:e.name,labelProps:d,...e}):$&&N?t(ie,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,disabled:s,checkboxOptions:N,className:e.className,labelProps:d,...e}):V?t(le,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,disabled:s,dateFormat:P,placeholder:e.placeholder,className:e.className,labelProps:d,...e}):A?t(de,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,disabled:s,dropdownItems:k,placeholder:e.placeholder,name:e.name,className:e.className,labelProps:d,...e}):H?t(ce,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,onBlur:e.onBlur,disabled:s,dropdownItems:k,allowCustomInput:R,placeholder:e.placeholder,name:e.name,className:e.className,labelProps:d,...e}):J?t(oe,{ref:l,id:r,label:a,error:o,required:c,value:w,onChange:n,disabled:s,pinLength:B,pinErrorMsg:C,pinDefaultMsg:F,className:e.className,labelProps:d,...e}):K?t(ue,{ref:l,id:r,label:a,error:o,required:c,value:w,onChange:n,disabled:s,otpLength:O,pinErrorMsg:C,pinDefaultMsg:F,className:e.className,labelProps:d,...e}):Q?t(se,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,disabled:s,cssProperties:j,onReset:E,onMoreInfo:q,placeholder:e.placeholder,className:e.className,labelProps:d,...e}):U?L(InputWrapper,{id:r,label:a,className:e.className,hasError:!!m||!!I,style:e.style,ref:l,children:[G||t("input",{id:r,type:"text",value:u,onChange:n,onFocus:e.onFocus,onBlur:e.onBlur,disabled:s,placeholder:e.placeholder,name:e.name,autoComplete:e.autoComplete,autoFocus:e.autoFocus,readOnly:e.readOnly,maxLength:e.maxLength,minLength:e.minLength,tabIndex:e.tabIndex,"aria-label":e["aria-label"],"aria-describedby":e["aria-describedby"],"aria-invalid":e["aria-invalid"],"aria-required":e["aria-required"],style:{width:"100%",padding:"8px 12px",border:m||I?"1px solid #ef4444":"1px solid #d1d5db",borderRadius:"6px",fontSize:"14px"}}),m&&t("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:m})]}):S?t(ee,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,onValueChange:h,onBlur:x,onValueBlur:f,...d,...e}):D&&!b?t(M,{ref:l,id:r,type:i,label:a,error:o,required:c,value:u,onChange:n,onValueChange:h,onBlur:x,onValueBlur:f,...d,...e}):D&&b?t(ae,{ref:l,id:r,label:a,error:o,required:c,value:u,onChange:n,onValueChange:h,onBlur:x,onValueBlur:f,disabled:s,labelProps:d,...e}):t(M,{ref:l,id:r,type:i,label:a,error:o,required:c,value:u,onChange:n,onValueChange:h,onBlur:x,onValueBlur:f,...d,...e})});FormField.displayName="FormField";
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import { Label } from '../../../core-components/atoms/Label/Label';
|
|
4
|
-
import { Icon } from '../../Icon/Icon';
|
|
5
|
-
import s from '../../../tc.module.css';
|
|
6
|
-
import { cn } from '../../../utils';
|
|
7
|
-
export const CheckboxGroupInput = React.forwardRef(({ id, label, error, required, value, onChange, disabled, checkboxOptions = [], className, labelProps, ...props }, ref) => {
|
|
8
|
-
const [checkboxList, setCheckboxList] = useState(checkboxOptions);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (checkboxOptions) {
|
|
11
|
-
setCheckboxList(checkboxOptions);
|
|
12
|
-
}
|
|
13
|
-
}, [checkboxOptions]);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (value) {
|
|
16
|
-
setCheckboxList(value);
|
|
17
|
-
}
|
|
18
|
-
}, [value]);
|
|
19
|
-
const handleCheckboxGroupChange = (index) => {
|
|
20
|
-
const result = checkboxList.map((e, i) => {
|
|
21
|
-
if (i === index)
|
|
22
|
-
return { ...e, checked: !e.checked };
|
|
23
|
-
else
|
|
24
|
-
return { ...e };
|
|
25
|
-
});
|
|
26
|
-
setCheckboxList(result);
|
|
27
|
-
if (onChange) {
|
|
28
|
-
onChange(result.filter((item) => item.checked));
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return (_jsxs("div", { className: cn(s['w-full'], className), children: [_jsx(Label, { label: label, required: required, ...labelProps, children: checkboxList?.map((item, index) => (_jsxs("div", { className: cn(s['flex'], s['flex-row'], s['items-center'], s['mb-2'], className), onClick: () => {
|
|
32
|
-
if (!disabled) {
|
|
33
|
-
handleCheckboxGroupChange(index);
|
|
34
|
-
}
|
|
35
|
-
}, children: [_jsx("div", { className: cn(s['flex'], s['gap-2']), children: item.checked ? (_jsx(Icon, { nameIcon: "ImCheckboxChecked" })) : (_jsx(Icon, { nameIcon: "ImCheckboxUnchecked" })) }), _jsx("span", { className: cn(s['text-sm'], s['font-medium'], s['ml-2'], disabled && s['cursor-not-allowed'], !disabled && s['cursor-pointer']), children: item?.title })] }, index))) }), error && (_jsx("p", { className: cn(s['mt-1'], s['text-sm'], s['text-red-600'], s['dark:text-red-400']), children: error }))] }));
|
|
36
|
-
});
|
|
37
|
-
CheckboxGroupInput.displayName = 'CheckboxGroupInput';
|
|
1
|
+
"use strict";import{jsx as r,jsxs as h}from"react/jsx-runtime";import j,{useState as w,useEffect as x}from"react";import{Label as G}from"../../../core-components/atoms/Label/Label";import{Icon as u}from"../../Icon/Icon";import e from"../../../tc.module.css";import{cn as o}from"../../../utils";export const CheckboxGroupInput=j.forwardRef(({id:L,label:k,error:a,required:C,value:i,onChange:f,disabled:l,checkboxOptions:s=[],className:d,labelProps:I,...R},_)=>{const[p,n]=w(s);x(()=>{s&&n(s)},[s]),x(()=>{i&&n(i)},[i]);const b=m=>{const c=p.map((t,N)=>N===m?{...t,checked:!t.checked}:{...t});n(c),f&&f(c.filter(t=>t.checked))};return h("div",{className:o(e["w-full"],d),children:[r(G,{label:k,required:C,...I,children:p?.map((m,c)=>h("div",{className:o(e.flex,e["flex-row"],e["items-center"],e["mb-2"],d),onClick:()=>{l||b(c)},children:[r("div",{className:o(e.flex,e["gap-2"]),children:m.checked?r(u,{nameIcon:"ImCheckboxChecked"}):r(u,{nameIcon:"ImCheckboxUnchecked"})}),r("span",{className:o(e["text-sm"],e["font-medium"],e["ml-2"],l&&e["cursor-not-allowed"],!l&&e["cursor-pointer"]),children:m?.title})]},c))}),a&&r("p",{className:o(e["mt-1"],e["text-sm"],e["text-red-600"],e["dark:text-red-400"]),children:a})]})});CheckboxGroupInput.displayName="CheckboxGroupInput";
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import s from '../../../tc.module.css';
|
|
4
|
-
import { cn } from '../../../utils';
|
|
5
|
-
export const CheckboxInput = React.forwardRef(({ id, label, checkboxLabel, error, required, value, onChange, disabled, name, className, labelProps, ...props }, ref) => {
|
|
6
|
-
return (_jsxs("div", { className: cn(s['w-full'], className), children: [_jsxs("div", { className: cn(s['flex'], s['items-center'], s['gap-2']), children: [_jsx("input", { ref: ref, type: "checkbox", id: id, name: name, checked: value, onChange: onChange, disabled: disabled, className: cn(s['w-4'], s['h-4'], s['text-blue-600'], s['bg-gray-100'], s['border-gray-300'], s['focus:ring-blue-500'], s['dark:focus:ring-blue-600'], s['dark:ring-offset-gray-800'], s['focus:ring-2'], s['dark:bg-gray-700'], s['dark:border-gray-600'], className), ...props }), (checkboxLabel || label) && (_jsx("label", { htmlFor: id, className: cn(s['cursor-pointer']), children: checkboxLabel || label }))] }), error && (_jsx("p", { className: cn(s['mt-1'], s['text-sm'], s['text-red-600'], s['dark:text-red-400']), children: error }))] }));
|
|
7
|
-
});
|
|
8
|
-
CheckboxInput.displayName = 'CheckboxInput';
|
|
1
|
+
"use strict";import{jsx as a,jsxs as i}from"react/jsx-runtime";import u from"react";import r from"../../../tc.module.css";import{cn as e}from"../../../utils";export const CheckboxInput=u.forwardRef(({id:s,label:t,checkboxLabel:o,error:d,required:x,value:n,onChange:l,disabled:m,name:f,className:c,labelProps:b,...p},g)=>i("div",{className:e(r["w-full"],c),children:[i("div",{className:e(r.flex,r["items-center"],r["gap-2"]),children:[a("input",{ref:g,type:"checkbox",id:s,name:f,checked:n,onChange:l,disabled:m,className:e(r["w-4"],r["h-4"],r["text-blue-600"],r["bg-gray-100"],r["border-gray-300"],r["focus:ring-blue-500"],r["dark:focus:ring-blue-600"],r["dark:ring-offset-gray-800"],r["focus:ring-2"],r["dark:bg-gray-700"],r["dark:border-gray-600"],c),...p}),(o||t)&&a("label",{htmlFor:s,className:e(r["cursor-pointer"]),children:o||t})]}),d&&a("p",{className:e(r["mt-1"],r["text-sm"],r["text-red-600"],r["dark:text-red-400"]),children:d})]}));CheckboxInput.displayName="CheckboxInput";
|
|
@@ -1,192 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
3
|
-
import { Textarea } from '../../../core-components/atoms/Textarea/Textarea';
|
|
4
|
-
import { Icon } from '../../Icon/Icon';
|
|
5
|
-
import s from '../../../tc.module.css';
|
|
6
|
-
import { cn } from '../../../utils';
|
|
7
|
-
import { properties as defaultCssProperties } from '../css-properties';
|
|
8
|
-
// Helper function to map CSS properties to array format
|
|
9
|
-
const mapToArray = (arr) => {
|
|
10
|
-
const res = [];
|
|
11
|
-
arr.forEach(function (obj, index) {
|
|
12
|
-
const key = Object.keys(obj)[0];
|
|
13
|
-
const value = key;
|
|
14
|
-
res.push([value, obj[key]]);
|
|
15
|
-
});
|
|
16
|
-
return res;
|
|
17
|
-
};
|
|
18
|
-
export const CssMultilineInput = React.forwardRef(({ id, label, error, required, value, onChange, onBlur, disabled, cssProperties, onReset, onMoreInfo, placeholder = "fontSize: 12,backgroundColor:'#000000'", className, labelProps, ...props }, ref) => {
|
|
19
|
-
const [isCssListOpen, setIsCssListOpen] = useState(false);
|
|
20
|
-
const [cssPropertiesList, setCssPropertiesList] = useState(cssProperties || mapToArray(defaultCssProperties));
|
|
21
|
-
const cssValueRef = useRef(value || '');
|
|
22
|
-
const cssWrapperRef = useRef(null);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (cssProperties) {
|
|
25
|
-
setCssPropertiesList(cssProperties);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
setCssPropertiesList(mapToArray(defaultCssProperties));
|
|
29
|
-
}
|
|
30
|
-
}, [cssProperties]);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (value !== undefined) {
|
|
33
|
-
cssValueRef.current = value;
|
|
34
|
-
}
|
|
35
|
-
}, [value]);
|
|
36
|
-
// Outside click handler
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
function handleClickOutside(event) {
|
|
39
|
-
if (cssWrapperRef.current &&
|
|
40
|
-
!cssWrapperRef.current.contains(event.target) &&
|
|
41
|
-
isCssListOpen) {
|
|
42
|
-
setIsCssListOpen(false);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
46
|
-
return () => {
|
|
47
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
48
|
-
};
|
|
49
|
-
}, [isCssListOpen]);
|
|
50
|
-
const handleCssFilter = (css) => {
|
|
51
|
-
const props = cssProperties || mapToArray(defaultCssProperties);
|
|
52
|
-
if (css.length === 0) {
|
|
53
|
-
setCssPropertiesList(props);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const matchString = css.split(/,\s*/);
|
|
57
|
-
const lastPart = matchString[matchString.length - 1];
|
|
58
|
-
const key = lastPart.split(':')[0]?.split("'")[0]?.trim();
|
|
59
|
-
const filtered = props.filter((item) => item[0]?.startsWith(key || ''));
|
|
60
|
-
setCssPropertiesList(filtered);
|
|
61
|
-
};
|
|
62
|
-
const handleCssChange = (css) => {
|
|
63
|
-
cssValueRef.current = css;
|
|
64
|
-
handleCssFilter(css);
|
|
65
|
-
};
|
|
66
|
-
// Handle onChange - support both event and value patterns
|
|
67
|
-
const handleChange = (e) => {
|
|
68
|
-
const css = e.target.value;
|
|
69
|
-
handleCssChange(css);
|
|
70
|
-
setIsCssListOpen(true);
|
|
71
|
-
if (onChange) {
|
|
72
|
-
// Support both patterns:
|
|
73
|
-
// 1. Standard React: onChange={(e) => { const val = e.target.value; ... }}
|
|
74
|
-
// 2. Custom: onChange={(value) => { ... value ... }}
|
|
75
|
-
// Check if onChange expects a string (custom pattern) by examining function signature
|
|
76
|
-
// If parameter name suggests it expects a value (not 'e' or 'event'), call with value
|
|
77
|
-
// Otherwise, call with event (standard React pattern)
|
|
78
|
-
try {
|
|
79
|
-
const funcStr = onChange.toString();
|
|
80
|
-
const paramMatch = funcStr.match(/\(([^)]+)\)/);
|
|
81
|
-
if (paramMatch) {
|
|
82
|
-
const param = paramMatch[1].trim();
|
|
83
|
-
// If parameter is not 'e', 'event', or starts with 'e:', it might expect value
|
|
84
|
-
if (param &&
|
|
85
|
-
param !== 'e' &&
|
|
86
|
-
param !== 'event' &&
|
|
87
|
-
!param.startsWith('e:')) {
|
|
88
|
-
// Custom pattern - call with value
|
|
89
|
-
onChange(css);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
// Standard React pattern - call with event
|
|
93
|
-
onChange(e);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
// Default to standard React pattern
|
|
98
|
-
onChange(e);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
// If calling with value fails, try with event
|
|
103
|
-
try {
|
|
104
|
-
onChange(e);
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
// If both fail, call with value as fallback
|
|
108
|
-
onChange(css);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
// Handle onBlur - support both event and value patterns
|
|
114
|
-
const handleBlur = (e) => {
|
|
115
|
-
if (onBlur) {
|
|
116
|
-
const css = e.target.value;
|
|
117
|
-
// Similar logic for onBlur
|
|
118
|
-
try {
|
|
119
|
-
const funcStr = onBlur.toString();
|
|
120
|
-
const paramMatch = funcStr.match(/\(([^)]+)\)/);
|
|
121
|
-
if (paramMatch) {
|
|
122
|
-
const param = paramMatch[1].trim();
|
|
123
|
-
if (param &&
|
|
124
|
-
param !== 'e' &&
|
|
125
|
-
param !== 'event' &&
|
|
126
|
-
!param.startsWith('e:')) {
|
|
127
|
-
onBlur(css);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
onBlur(e);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
onBlur(e);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
catch (error) {
|
|
138
|
-
// If calling with value fails, try with event
|
|
139
|
-
try {
|
|
140
|
-
onBlur(e);
|
|
141
|
-
}
|
|
142
|
-
catch {
|
|
143
|
-
// If both fail, call with value as fallback
|
|
144
|
-
onBlur(css);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
const handleReset = () => {
|
|
150
|
-
const styles = cssValueRef.current.split(',').filter(Boolean);
|
|
151
|
-
if (styles.length > 0) {
|
|
152
|
-
styles.pop();
|
|
153
|
-
cssValueRef.current = styles.join(',') + (styles.length ? ',' : '');
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
cssValueRef.current = '';
|
|
157
|
-
}
|
|
158
|
-
if (onReset) {
|
|
159
|
-
onReset(cssValueRef.current);
|
|
160
|
-
}
|
|
161
|
-
if (onChange) {
|
|
162
|
-
// When resetting, we call onChange with the value directly (custom pattern)
|
|
163
|
-
// since we don't have an event object
|
|
164
|
-
onChange(cssValueRef.current);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
return (_jsxs("div", { className: cn(s['flex'], s['flex-col'], s['w-full'], s['relative'], className), ref: cssWrapperRef, children: [_jsxs("div", { className: cn(s['flex'], s['absolute'], s['gap-2'], s['right-2'], s['z-10']), children: [onReset && (_jsx(Icon, { nameIcon: "MdLockReset", propsIcon: { color: '#000000', size: 24 }, onClick: handleReset })), onMoreInfo && (_jsx(Icon, { nameIcon: "MdInfoOutline", propsIcon: { color: '#000000', size: 24 }, onClick: onMoreInfo }))] }), _jsx(Textarea, { ref: ref, id: id, label: label, error: error, required: required, placeholder: placeholder, value: cssValueRef.current, onChange: handleChange, onBlur: handleBlur, onKeyUp: () => setIsCssListOpen(true), disabled: disabled, ...labelProps, ...props }), isCssListOpen && cssPropertiesList.length > 0 && (_jsx("div", { children: _jsx("ul", { className: cn(s['flex'], s['flex-col'], s['bg-black'], s['text-white'], s['overflow-y-scroll'], s['w-full']), style: { maxHeight: 'calc(100vh - 20vh)' }, children: cssPropertiesList?.map((item, index) => (_jsxs("li", { className: cn(s['flex'], s['gap-4'], s['p-2']), children: [_jsx("span", { className: cn(s['underline']), children: item[0] }), item[1]?.map((prop, propIndex) => (_jsxs("li", { className: cn(s['flex'], s['bg-slate-800'], s['rounded-md'], s['items-center'], s['cursor-pointer']), onClick: () => {
|
|
168
|
-
let existsString = cssValueRef.current?.split(',');
|
|
169
|
-
if (cssValueRef.current.includes(',')) {
|
|
170
|
-
existsString = existsString.map((item) => {
|
|
171
|
-
if (item?.includes(':'))
|
|
172
|
-
return item;
|
|
173
|
-
});
|
|
174
|
-
if (prop != 'number')
|
|
175
|
-
existsString.push(`${item[0]}:'${prop}',`);
|
|
176
|
-
else
|
|
177
|
-
existsString.push(`${item[0]}:1,`);
|
|
178
|
-
cssValueRef.current = existsString
|
|
179
|
-
.join(',')
|
|
180
|
-
.replaceAll(',,', ',');
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
if (prop != 'number')
|
|
184
|
-
cssValueRef.current = `${item[0]}:'${prop}',`;
|
|
185
|
-
else {
|
|
186
|
-
cssValueRef.current = `${item[0]}:1,`;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
handleCssFilter(existsString.join(''));
|
|
190
|
-
}, children: [' ', prop, ' '] }, propIndex)))] }, index))) }) })), error && (_jsx("p", { className: cn(s['mt-1'], s['text-sm'], s['text-red-600'], s['dark:text-red-400']), children: error }))] }));
|
|
191
|
-
});
|
|
192
|
-
CssMultilineInput.displayName = 'CssMultilineInput';
|
|
1
|
+
"use strict";import{jsx as f,jsxs as g}from"react/jsx-runtime";import U,{useState as M,useEffect as C,useRef as O}from"react";import{Textarea as V}from"../../../core-components/atoms/Textarea/Textarea";import{Icon as R}from"../../Icon/Icon";import t from"../../../tc.module.css";import{cn as u}from"../../../utils";import{properties as I}from"../css-properties";const N=v=>{const p=[];return v.forEach(function(d,j){const a=Object.keys(d)[0],l=a;p.push([l,d[a]])}),p};export const CssMultilineInput=U.forwardRef(({id:v,label:p,error:d,required:j,value:a,onChange:l,onBlur:o,disabled:z,cssProperties:m,onReset:y,onMoreInfo:w,placeholder:E="fontSize: 12,backgroundColor:'#000000'",className:W,labelProps:A,...T},_)=>{const[k,S]=M(!1),[L,h]=M(m||N(I)),r=O(a||""),b=O(null);C(()=>{h(m||N(I))},[m]),C(()=>{a!==void 0&&(r.current=a)},[a]),C(()=>{function e(n){b.current&&!b.current.contains(n.target)&&k&&S(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[k]);const $=e=>{const n=m||N(I);if(e.length===0){h(n);return}const c=e.split(/,\s*/),s=c[c.length-1].split(":")[0]?.split("'")[0]?.trim(),x=n.filter(P=>P[0]?.startsWith(s||""));h(x)},q=e=>{r.current=e,$(e)},F=e=>{const n=e.target.value;if(q(n),S(!0),l)try{const i=l.toString().match(/\(([^)]+)\)/);if(i){const s=i[1].trim();s&&s!=="e"&&s!=="event"&&!s.startsWith("e:")?l(n):l(e)}else l(e)}catch{try{l(e)}catch{l(n)}}},H=e=>{if(o){const n=e.target.value;try{const i=o.toString().match(/\(([^)]+)\)/);if(i){const s=i[1].trim();s&&s!=="e"&&s!=="event"&&!s.startsWith("e:")?o(n):o(e)}else o(e)}catch{try{o(e)}catch{o(n)}}}},K=()=>{const e=r.current.split(",").filter(Boolean);e.length>0?(e.pop(),r.current=e.join(",")+(e.length?",":"")):r.current="",y&&y(r.current),l&&l(r.current)};return g("div",{className:u(t.flex,t["flex-col"],t["w-full"],t.relative,W),ref:b,children:[g("div",{className:u(t.flex,t.absolute,t["gap-2"],t["right-2"],t["z-10"]),children:[y&&f(R,{nameIcon:"MdLockReset",propsIcon:{color:"#000000",size:24},onClick:K}),w&&f(R,{nameIcon:"MdInfoOutline",propsIcon:{color:"#000000",size:24},onClick:w})]}),f(V,{ref:_,id:v,label:p,error:d,required:j,placeholder:E,value:r.current,onChange:F,onBlur:H,onKeyUp:()=>S(!0),disabled:z,...A,...T}),k&&L.length>0&&f("div",{children:f("ul",{className:u(t.flex,t["flex-col"],t["bg-black"],t["text-white"],t["overflow-y-scroll"],t["w-full"]),style:{maxHeight:"calc(100vh - 20vh)"},children:L?.map((e,n)=>g("li",{className:u(t.flex,t["gap-4"],t["p-2"]),children:[f("span",{className:u(t.underline),children:e[0]}),e[1]?.map((c,i)=>g("li",{className:u(t.flex,t["bg-slate-800"],t["rounded-md"],t["items-center"],t["cursor-pointer"]),onClick:()=>{let s=r.current?.split(",");r.current.includes(",")?(s=s.map(x=>{if(x?.includes(":"))return x}),c!="number"?s.push(`${e[0]}:'${c}',`):s.push(`${e[0]}:1,`),r.current=s.join(",").replaceAll(",,",",")):c!="number"?r.current=`${e[0]}:'${c}',`:r.current=`${e[0]}:1,`,$(s.join(""))},children:[" ",c," "]},i))]},n))})}),d&&f("p",{className:u(t["mt-1"],t["text-sm"],t["text-red-600"],t["dark:text-red-400"]),children:d})]})});CssMultilineInput.displayName="CssMultilineInput";
|